akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

public class Main {
    static int modP = 1000000007;
    static long inf  = Long.MAX_VALUE;
    static int totalTime;

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int[] T = new int[n];
        int[] V = new int[n];
        for(int i = 0; i < n; i++) {
            T[i] = in.nextInt();
        }
        for(int i = 0; i < n; i++) {
            V[i] = in.nextInt();
        }

        Restriction[] R = new Restriction[n+2];
        int currentTime = 0;
        for(int i = 0; i < n; i++) {
            R[i] = new Restriction(currentTime, currentTime+T[i], V[i]);
            currentTime += T[i];
        }
        totalTime = Arrays.stream(T).sum();
        R[n]   = new Restriction(0, 0, 0);
        R[n+1] = new Restriction(totalTime, totalTime, 0);

        float totalTraveled = 0f;
        float currentSpeed = 0f;
        for(float a = 0f; a < totalTime; a += 0.5f) {
            float nextLim = Float.MAX_VALUE;
            for(int i = 0; i < n+2; i++) {
                nextLim = Math.min(R[i].getLimit(a+0.5f), nextLim);
            }

            if(nextLim == currentSpeed) {
                totalTraveled += currentSpeed;
            }else if(nextLim > currentSpeed) {
                totalTraveled += currentSpeed + 0.5f;
                currentSpeed += 0.5f;
            }else if(nextLim < currentSpeed) {
                totalTraveled += currentSpeed - 0.5f;
                currentSpeed -= 0.5f;
            }
        }

        print(totalTraveled * 0.5f);
    }

    static void print(String s) {
        System.out.println(s);
    }

    static void print(int i) {
        System.out.println(i);
    }

    static void print(long i) {
        System.out.println(i);
    }

    static void print(float i) {
        System.out.println(i);
    }
}

class Restriction {
    int l, r, v;
    Restriction(int l, int r, int v) {
        this.l = l;
        this.r = r;
        this.v = v;
    }

    public float getLimit(float x) {
        if(x < l) {
             return (v + l - x);
         }else if(x > r) {
             return (v + x - r);
         }else{
             return v;
         }
    }
}

Measured memory_bytes: 29268
#include<iostream>
#include<set>	
#include<string>

using namespace std;

int main() {

	set<string> s;

	int n = 0;

	cin >> n;

	string str;

	for (int i = 0; i < n; i++) {
		cin >> str;
		s.insert(str);
	}

	cout << s.size();

	//system("pause");
	return 0;
}

Measured memory_bytes: 19216
#include <iostream>
#include <algorithm>

int coins[100];
int ncoin;
int ans[100000+1];

void init() {
    coins[0] = 1;
    ncoin = 1;
    for (int cur = 6; cur <= 100000; cur *= 6)
        coins[ncoin++] = cur;
    for (int cur = 9; cur <= 100000; cur *= 9)
        coins[ncoin++] = cur;
    std::sort(coins, coins + ncoin);
}

void compute(int n) {
    ans[0] = 0;
    for (int p = 1; p <= n; p++) {
        ans[p] = p;
        for (int c = 0; c < ncoin && coins[c] <= p; c++)
            ans[p] = (ans[p] < ans[p - coins[c]])?ans[p]:(ans[p - coins[c]] + 1);
    }
    std::cout << ans[n];
}

int main() {
    init();
    int n;
    std::cin >> n;
    compute(n);
    return 0;
}


Measured memory_bytes: 640
N = int(input())
xy = [[int(i) for i in input().split()] for _ in range(N)]

a = 1
for i in range(1, N):
    a *= i
    
b = 1
for i in range(1, N+1):
    b *= i

s = 0
for i in range(N):
    for j in range(i):
        s += ((xy[i][0] - xy[j][0])**2 + (xy[i][1] - xy[j][1])**2) ** (1/2)
        
ans = s * a * 2 / b
print(ans)

Measured memory_bytes: 3188
#include <cstdlib>
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>

using namespace std;

int main(){
    
    int a,b;
    string s;
    cin >> a >> b >> s;
    bool hihn=false,suu=true;
    for(int i=0;i<a+b+1;++i){
        
        if(i==a){
            if(s[i]=='-')hihn=true;
        }
        
        else{
            if(!(s[i]>='0'&&s[i]<='9'))suu=false;
        }
        
    }
    
    if(hihn&&suu) cout<<"Yes";
    else cout << "No";
    
    
    
    return 0;
}

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

int main()
{
	priority_queue<int> q;
	int i,j,k,n,m;
	cin>>n>>m;
	for(i=0;i<n;i++)
    {
        int ai;cin>>ai;
        q.push(ai);
    }
    for(i=0;i<m;i++)
    {
    	k=q.top();
    	k/=2;
    	q.pop();
    	q.push(k);
	}
	long long res=0;
	for(i=0;i<n;i++)
	{
		res+=q.top();
		q.pop();
	}
	cout<<res<<endl;
	
	return 0;
}


Measured memory_bytes: 892
N = int(input())
d = [int(i) for i in input().split()]
d = sorted(d)
mid = N//2

left = d[mid-1]
right = d[mid]

ans = 0

l = 0
for i in d:
    if i >= right:
        l += 1

if l == mid:
    ans += 1

if right != left:
    ans += right - left - 1 

print(ans)


Measured memory_bytes: 14396
#include<stdio.h>
int main(){
  int K, S;
  int X, Y, Z;
  int cnt=0;
  scanf("%d %d", &K, &S);
  for(X=0; X<=K; X++){
     for(Y=0; Y<=S-X && Y<=K; Y++){
     	Z=S-X-Y;
        if(Z<=K)
          cnt++;
     }
  }
  printf("%d\n", cnt);
  return 0;
}


Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		int k = scanner.nextInt();
		int count = 0;
		for (int i = 0; i < n; i++) {
			if (scanner.nextInt() >= k)
				count++;
		}
		System.out.println(count);
	}

}


Measured memory_bytes: 48036
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
#include<map>
#include<queue>
#include<set>
#include<vector>
#include<cstdio>

using namespace std;

int find(int x, vector<int> &p) {
	if (p[x] == x)return x;
	return p[x] = find(p[x], p);
}

void uni(int x, int y, vector<int> &p) {
	x = find(x, p);
	y = find(y, p);
	p[x] = y;
}

int same(int x, int y, vector<int> p) {
	if (find(x, p) == find(y, p))return 1;
	return 0;
}

int main()
{
	int N, M, X, Y, P, ans = 0;
	vector<int>p, set;

	cin >> N >> M;

	for (int i = 0; i < N; i++) {
		cin >> P;
		p.push_back(P-1);
		set.push_back(i);
	}

	for (int i = 0; i < M; i++) {
		cin >> X >> Y;
		uni(X-1, Y-1, set);
	}

	for (int i = 0; i < N; i++) {
		if (find(p[i], set) == find(i, set)) {
			ans++;
		}
	}

	cout << ans;

	char qq;
	cin >> qq;
	return 0;
}

Measured memory_bytes: 1276
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
using namespace std;

#include <math.h>
#include <iomanip>
#include <vector>
#include <queue>
#include <climits>
using Graph = vector<vector<int>>;
const double PI = 3.14159265358979323846;



long long modpow(long long a, long long n, long long mod) {
	long long res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}


//約数をベクトル形式で返す
vector<int> vect_yakusuu(int n) {
	vector<int> ret;
	for (int i = 1; i*i <= n; i++) {
		if (n%i == 0) {
			ret.push_back(i);
			if (i*i != n) ret.push_back(n / i);
		}
	}
	sort(begin(ret), end(ret));
	return ret;
}

int popcount(int A) {
	int count = 0;
	while (1) {
		if (A == 0) {
			break;
		}
		if (A % 2 == 1) {
			count++;
		}
		A = A / 2;
	}
	return count;
}

int main() {


	long long K;
	long long tmp,sum;

	cin >> K;

	tmp = 7;
	sum = 0;
	int flg = 0;

	int i;

	for (i = 0; i < K; i++) {
		if (i != 0) {
			tmp = (tmp * 10) % K;
		}
		sum = (sum + tmp) % K;
		if (sum == 0) {
			flg = 1;
			break;
		}
	}

	int ans;

	ans = i + 1;

	if (flg == 0) {
		ans = -1;
	}

	cout <<ans <<endl;

	cin >> K;

	return 0;


}

Measured memory_bytes: 3624
#include <stdio.h>

int main(int argc,char* argv[]){
  
  int num;
  int first = 0;

  while(scanf("%d",&num) != EOF){
    int i,j;
    int digits[5] = 
      {
	(num / 10000) % 10,
	(num / 1000) % 10,
	(num / 100) % 10,
	(num / 10) % 10,
	num % 10
      };
    
    if(first != 0){
      printf("\n");
    }

    for(i = 0; i < 5; i++){
      if(digits[i] / 5 == 0){
	printf("%c",'*');
      }else{
	printf("%c",' ');
      }
    }
    printf("\n");

    for(i = 0; i < 5; i++){
      if(digits[i] / 5 == 1){
	printf("%c",'*');
	digits[i] -= 5;
      }else{
	printf("%c",' ');
      }
    }
    printf("\n");

    printf("=====\n");

    for(i = 0; i < 5; i++){
      for(j = 0; j < 5; j++){
	if(digits[j] == i){
	  printf("%c",' ');
	}else{
	  printf("%c",'*');
	}
      }
      printf("\n");
    }

    if(first == 0){
      first = 1;
    }
    
  }
  
  return 0;
  
}

Measured memory_bytes: 0
#include <algorithm>
#include <cmath>
#include <vector>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <ctype.h>
#include <climits>
#include <queue>
using namespace std;
typedef long long ll;
#define REP(i, n) for(ll i = 0; i < (ll)(n); ++i)
template<class T> inline bool chmax(T& a, T b) { if(a < b){ a=b; return 1; } return 0;}
template<class T> inline bool chmin(T& a, T b) { if(a > b){ a=b; return 1; } return 0;}

int main(){
	int n;
	cin >> n;
	vector<ll> a(n);
	REP(i,n) cin >> a[i];
	
	ll ans=0;
	const ll mod = 1000000007;
	ll two = 1;
	for(int digit=0; digit<=60; digit++){
		ll sum=0;
		REP(i,n){
			if(a[i] & (1LL<<digit)) sum++;
		}
		sum = sum*(n-sum)%mod;
		sum = (sum*two)%mod;
		ans = (ans+sum)%mod;
		two = (two*2)%mod;
		
	}
	

	ans %= mod;
	cout << ans << endl;
	
	
	return 0;
}

Measured memory_bytes: 5552
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, x, n) for (int i = x; i < (n); i++)
#define all(n) begin(n), end(n)
struct cww
{
    cww()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
} star;
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<char> vchar;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template <typename T, typename... Ts>
auto make_v(size_t a, Ts... ts)
{
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }

template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v)
{
    for (auto &e : t)
        fill_v(e, v);
}
int main()
{
    ll N;
    cin >> N;
    ll a, ans = 0;
    unordered_map<ll, ll> cnt;
    rep(i, N)
    {
        cin >> a;
        cnt[a]++;
    }
    for (auto i : cnt)
    {
        if (i.second % 2)
            ans++;
    }
    cout << ans;
    return 0;
}

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

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

    std::vector<int> d(n);
    for(int i = 0; i < n; i++){
        std::cin >> d.at(i);
    }

    long long ans = 0;

    for(int i = 0; i <= n-2; i++){
        for(int j = i+1; j <= n-1; j++){
            int product = d.at(i) * d.at(j);
            ans += (long long)product;
        }
    }
    std::cout << ans << std::endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
  
int main() {
  int N;
  cin >> N;
  int A,B;
  cin >> A >> B;
  vi nums(3,0);
  rep(i,N) {
    int n;
    cin >> n;
    if(n <= A) {
      nums[0]++;
    } else if(n <= B) {
      nums[1]++;
    } else {
      nums[2]++;
    }
  }
  cout << min(nums[0],min(nums[1],nums[2])) << endl;
  return 0;
}

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

struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;

/* cpp template {{{ */

/* short */
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define X real()
#define Y imag()

/* REPmacro */
#define REPS(i, a, n) for (ll i = (a); i < (ll)(n); ++i)
#define REP(i, n) REPS(i, 0, n)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (ll i = (a); i >= (ll)(n); --i)
#define DEP(i, n) DEPS(i, n, 0)
#define EACH(i, n) for (auto&& i : n)

/* debug */
#define debug(x) cerr << x << " " << "(L:" << __LINE__ << ")" << '\n';

/* alias */
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;
using D = double;
using P = complex<D>;
using vs = vector<string>;
template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

/* const */
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;
const D EPS = 1e-9;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

/* func */
inline bool inside(int y, int x, int H, int W) {return y >= 0 && x >= 0 && y < H && x < W;}
inline int in() {int x; cin >> x; return x;}
inline ll IN() {ll x; cin >> x; return x;}
inline vs split(const string& t, char c) {vs v; stringstream s(t); string b; while(getline(s, b, c)) v.eb(b); return v;}
template <typename T> inline bool chmin(T& a, const T& b) {if (a > b) a = b; return a > b;}
template <typename T> inline bool chmax(T& a, const T& b) {if (a < b) a = b; return a < b;}
template <typename T, typename S> inline void print(const pair<T, S>& p) {cout << p.first << " " << p.second << endl;}
template <typename T> inline void print(const T& x) {cout << x << '\n';}
template <typename T, typename S> inline void print(const vector<pair<T, S>>& v) {for (auto&& p : v) print(p);}
template <typename T> inline void print(const vector<T>& v, string s = " ") {REP(i, v.size()) cout << v[i] << (i != (ll)v.size() - 1 ? s : "\n");}
// clang-format on
/* }}} */


signed main() 
{
    int n;
    cin >> n;
    char c[n];
    bool judge=false;
    REP(i,n)
    {
        cin >> c[i];
        if(c[i]=='Y') judge=true;
    }
    if(judge) cout << "Four" << endl;
    else cout << "Three" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h> //Ithea Myse Valgulious
namespace chtholly{
typedef long long ll;
#define re0 register int
#define rec register char
#define rel register ll
#define gc getchar
#define pc putchar
#define p32 pc(' ')
#define pl puts("")
/*By Citrus*/
inline int read(){
  int x=0,f=1;char c=gc();
  for (;!isdigit(c);c=gc()) f^=c=='-';
  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');
  return f?x:-x;
  }
inline bool read(ll &x){
  x=0;int f=1;char c=gc();
  for (;!isdigit(c)&&~c;c=gc()) f^=c=='-';
  if (!~c) return 0;
  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');
  return x=f?x:-x,1;
  }
template <typename mitsuha>
inline int write(mitsuha x){
  if (!x) return pc(48);
  if (x<0) x=-x,pc('-');
  int bit[20],i,p=0;
  for (;x;x/=10) bit[++p]=x%10;
  for (i=p;i;--i) pc(bit[i]+48);
  }
inline char fuhao(){
  char c=gc();
  for (;isspace(c);c=gc());
  return c;
  }
}using namespace chtholly;
using namespace std;
int n,x[1010],a;
ll dp[99][99][2560];

ll dfs(int pos,int last,int sum,int cnt){
if (pos>n) return !last&&sum==cnt*a;
if (~dp[pos][last][sum]) return dp[pos][last][sum];
return dp[pos][last][sum]=dfs(pos+1,last-1,sum+x[pos],cnt)+
                          dfs(pos+1,last,sum,cnt);
}

int main(){
int i;
n=read(),a=read();
for (i=1;i<=n;++i) x[i]=read();
ll ans=0;
for (i=1;i<=n;++i){
  memset(dp,-1,sizeof dp);
  ans+=dfs(1,i,0,i);
  }
write(ans);
}

Measured memory_bytes: 196352
def main():
    num = int(input())
    lst = []
    for i in range(num):
        lst.append(list(map(int, input().split())))

    count = 0
    flg = False
    for j in lst:
        if j[0] == j[1]:
            count += 1
            if count == 3:
                flg = True
                break
        else:
            count = 0

    if flg:
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    main()

Measured memory_bytes: 9196
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
    int N,ans=0;
    int a,count=1;
    vector<int> list;
    cin >> N;
    for(int i=0;i<N;i++){
        cin >> a;
        list.push_back(a);
    }
    sort(list.begin(),list.end());
    for(int i=0;i<N;i++){
        if(i != N-1 && list[i] == list[i+1]) count++;
        else{
            ans += list[i] <= count? count-list[i] : count;
            count = 1;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 892
#include<stdio.h>
#include<math.h>

#define f(x) x*x

int main(void)
{
  int d,sum=0;
  double x;
  while(scanf("%d",&d)!=EOF){
    sum=0;
  for(x=0;x<600/d;x++){
    sum+=f(x*d)*d;
  }

  printf("%d\n",sum);
  }
  return 0;
}

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

namespace AtCoder.Abc
{
    //https://atcoder.jp/contests/abc141/tasks/abc141_a
    public class Question1
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            // 文字列の入力
            //string s = Console.ReadLine();

            // 整数の入力
            //int n = int.Parse(Console.ReadLine());

            // 文字列配列の入力
            //string[] inputStrArray = Console.ReadLine().Split(' ');

            // 整数配列の入力
            var inputintArray = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();

            int H = inputintArray[0];
            int W = inputintArray[1];
            var S = new char[H][];
            var SS = new char[H][];

            for (int i = 0; i < H; i++)
            {
                S[i] = Console.ReadLine().ToCharArray();
                SS[i] = S[i];
            }

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

            for(int i = 0; i < H; i++)
            {
                for (int j = 0; j < W; j++)
                {
                    if (S[i][j] == '.')
                    {
                        int sum = 0;
                        for (int k = 0; k < 8; k++)
                        {
                            int dj = j + dx[k];
                            int di = i + dy[k];

                            if ( 0<=dj && dj<W && 0<=di && di<H)
                            {
                                if (S[di][dj] == '#')
                                {
                                    sum++;
                                }
                            }
                        }

                        SS[i][j] = (char)('0'+sum);
                    }
                }
                Console.WriteLine(SS[i]);
            }
            

            Console.Out.Flush();
        }
    }
}


Measured memory_bytes: 13396
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string.h>
#include <vector>
#include <cmath>
#include <iostream>
#include <unordered_map>
#include <queue>
using namespace std;
typedef unsigned long long ui64;
typedef long long i64;
void Pair() {
	int K;
	cin >> K;
	cout << ((K / 2) * ((K / 2) + (K % 2 == 1))) << "\n";
}
int main() {
	Pair();

	return 0;
}

Measured memory_bytes: 256
//tt89 ;)
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL);
void testcase(int t) { cout<<"Case #"<<t<<": "; }
void online() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif //ONLINE_JUDGE
}
const int mod= 1e9+7;

int main() {
    fastIO;
    double x; cin>>x;
    if(x>=30) cout<<"Yes";
    else cout<<"No";
    return 0;
}

Measured memory_bytes: 3704
#include <bits/stdc++.h>
using namespace std;
int main()
{
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	string s,t;
	cin>>s>>t;
	int z=INT_MAX;
	int k;
	int si=s.size(),ti=t.size();
	for(int i=0;i<=si-ti;i++)
    {
        k=0;
        for(int j=0;j<ti;j++)
        {
            if(s[i+j]!=t[j])
            {
                k++;
            }
        }
        z=min(z,k);
    }
    cout<<z<<endl;
	return 0;
}


Measured memory_bytes: 3648
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        s: [chars; 3],
    }
    println!("{}", if s[0].last() == s[1].first() && s[1].last() == s[2].first() {"YES"} else {"NO"});
}


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


int main() {
  int X,Y,A,B,C;
  cin >> X >> Y >> A >> B >> C ;
  vector< int > p(A), q(B), r(C);
  REP(i,A) cin >> p[i];
  REP(i,B) cin >> q[i];
  REP(i,C) cin >> r[i];

  sort( p.begin(), p.end(), greater<int>() );
  sort( q.begin(), q.end(), greater<int>() );
  sort( r.begin(), r.end(), greater<int>() );

  vector<int> t;
  REP(i,X) t.emplace_back( p[i] );
  REP(i,Y) t.emplace_back( q[i] );
  REP(i,min(C,(X+Y))) t.emplace_back( r[i] );

  sort( t.begin(), t.end(), greater<int>() );
  ll ans = 0;
  REP(i,X+Y) ans += t[i];
  
  cout << ans << endl;
}


Measured memory_bytes: 3572
#include "bits/stdc++.h"
using namespace std;

int main( ) {
	cin.tie(0); ios::sync_with_stdio(false);
	string S; cin >> S;
	int Lbit = S.size()-1;
	S = string(10 - S.size( ), '0') + S;
	int64_t total = 0;
	for (int i = 0; i < (1 << Lbit); ++i) {
		bitset<9> b(i);
		int64_t sum = 0;
		int64_t pool = 0;
		for (int k = 0; k < 9; ++k) {
			int64_t self = int(S[k] - '0');
			if (b.test(8-k)) { // test ビットが1なら真
				//プールも自分もフラッシュ
				sum += (pool + self);
				pool = 0;
			} else {
				//自分をプールにいれて，１０倍する
				pool += self;
				pool *= 10;
			}
		}
		//最後の桁の処理 	//プールをフラッシュして，自分をsumに足す
		sum += (pool + int(S[9] - '0'));
		total += sum;
	}
	cout << total << endl;
}

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

int main(){
    int n;
    cin >> n;
    vector <long> a(n);
    rep(i,n) cin >> a[i];

    map <long, int> edge;
    for(long x:a){
        if(edge.count(x)){
            edge.at(x) ++;
        }
        else{
            edge[x] = 1;
        }
    }
    
    sort(all(a));
    a.erase( unique (  a.begin() , a.end() ) , a.end() ); 

    long ledge=0, sedge=0;
    for(int x:a){
        if(edge.at(x) >= 4){
            if(x > ledge){
                sedge=x;
                ledge=x;
            }
            else if(x > sedge){
                sedge = x;
            }
        }
        else if(edge.at(x) >= 2){
            if(x > ledge){
                sedge = ledge;
                ledge = x;
            }
            else if(x > sedge){
                sedge = x;
            }
        }
    }
    cout << ledge * sedge << endl;

}


Measured memory_bytes: 10216
#include<stdio.h>
#define MAX 100000
#define SENTINEL 2000000000

struct Card {
	char suit;
	int value;
};

struct Card L[MAX / 2 + 2], R[MAX / 2 + 2];

void merge(struct Card A[], int n, int left, int mid, int right) {
	int i, j, k;
	int n1 = mid - left;
	int n2 = right - mid;
	for ( i = 0; i < n1; i++ ) L[i] = A[left + i];
	for ( i = 0; i < n2; i++ ) R[i] = A[mid + i];
	L[n1].value = R[n2].value = SENTINEL;
	i = j = 0;
	for ( k = left; k < right; k++ ) {
		if ( L[i].value <= R[j].value ) {
			A[k] = L[i++];
		} else {
			A[k] = R[j++];
		}
	}
}

void mergeSort(struct Card A[], int n, int left, int right) {
	int mid;
	if ( left + 1 < right ) {
		mid = (left + right) / 2;
		mergeSort(A, n, left, mid);
		mergeSort(A, n, mid, right);
		merge(A, n, left, mid, right);
	}
}

int partition(struct Card A[], int n, int p, int r) {
	int i, j;
	struct Card t, x;
	x = A[r];
	i = p - 1;
	for ( j = p; j < r; j++ ) {
		if ( A[j].value <= x.value ) {
			i++;
			t = A[i]; A[i] = A[j]; A[j] = t;
		}
	}
	t = A[i + 1]; A[i + 1] = A[r]; A[r] = t;
	return i + 1;
}

void quickSort(struct Card A[], int n, int p, int r) {
	int q;
	if ( p < r ) {
		q = partition(A, n, p, r);
		quickSort(A, n, p, q - 1);
		quickSort(A, n, q + 1, r);
	}
}

int main() {
	int n, i, v;
	struct Card A[MAX], B[MAX];
	char S[10];
	int stable = 1;
	
	scanf("%d", &n);
	
	for ( i = 0; i < n; i++ ) {
		scanf("%s %d", S, &v);
		A[i].suit = B[i].suit = S[0];
		A[i].value = B[i].value = v;
	}
	
	mergeSort(A, n, 0, n);
	quickSort(B, n, 0, n-1);
	
	for ( i = 0; i < n; i++ ) {
		if ( A[i].suit != B[i].suit ) stable = 0;
	}
	
	if ( stable == 1 ) printf("Stable\n");
	else printf("Not stable\n");
	for ( i = 0; i < n; i++) {
		printf("%c %d\n", B[i].suit, B[i].value);
	}
	
	return 0;
}


Measured memory_bytes: 4996
#include<vector>
#include<iostream>
#include<string>
#include<algorithm>
#include<math.h>
#include<map>
#include<functional>
#include<queue>
#include<stack>
#include<string.h>
#include<list>
#include<limits>
#include<bitset>
#include<ctype.h>
#include<set>
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
const ll MOD=10000;
const ll INF=1000000000;
const int MAX=100001;
const double EPS=1e-10;
int main(){
    string s;
    int k;
    cin>>s;
    int sl=s.length();
    cin>>k;
    for(int i=0;i<sl;i++){
        int a=s[i]-'a';
        if(a!=0&&26-a<=k){
            k-=26-a;
            s[i]='a';
        }
    }
    k%=26;
    for(int i=0;i<k;i++){
        int a=s[sl-1]-'a';
        a++;
        s[sl-1]=a+'a';
    }
    cout<<s<<endl;
    return 0;
}

Measured memory_bytes: 512
c=[list(map(int,input().split())) for _ in range(3)]
if c[0][0]-c[1][0]==c[0][1]-c[1][1]==c[0][2]-c[1][2] and c[0][0]-c[2][0]==c[0][1]-c[2][1]==c[0][2]-c[2][2]:
  print("Yes")
else:
  print("No")


Measured memory_bytes: 9196
n, k = gets.chomp.split(' ').map(&:to_i)
data = []
min = 1000000000000
n.times do
  data << gets.chomp.to_i
end
data.sort!()
for i in 0..(n-k)
  _min = data[i]
  _max = data[i+k-1]
  min = _max - _min if (_max-_min) < min
end
puts min

Measured memory_bytes: 3704
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <sstream>
#include <cassert>
#include <list>
using namespace std;
static const double EPS = 1e-10;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> PI;
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define SZ(a) (int(a.size()))
#define F first
#define S second
const double pi=acos(-1);
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};



typedef struct _state{
  int from,vis;
  double cost;
  _state(double ic,int ifr,int iv):cost(ic),from(ifr),vis(iv){
  };
  bool operator<(const _state&r)const{
    return cost>r.cost;
  };
}state;

typedef struct _edge{
  int to,cost;
  _edge(int ito,int icost):to(ito),cost(icost){
  };
}edge;

int ret,c;
inline int num(){
  ret=0;
  while(!isdigit(c=getchar()));
  ret=c&15;
  while(isdigit(c=getchar()))ret=(ret<<3)+(ret<<1)+(c&15);
  return ret;
}

main(){
  int n,m,p,a,b;
  while(n=num(),m=num(),p=num(),a=num()-1,b=num()-1,n){
    int ti[n];
    vector<edge> V[m];
    rep(i,n)ti[i]=num();

    rep(i,p){
      int x=num()-1,y=num()-1,z=num();
      V[x].pb(edge(y,z));
      V[y].pb(edge(x,z));
    }

    priority_queue<state> Q;
    Q.push(state(0,a,0));

    bool cost[1<<n][m];
    memset(cost,0,sizeof(cost));
    double ans=-1;

    int from,cti;
    double ccost;
    while(!Q.empty()){
      from=Q.top().from,cti=Q.top().vis;
      ccost=Q.top().cost;
      Q.pop();
      if(cost[cti][from])continue;
      cost[cti][from]=true;
      if(from==b){
        ans=ccost;
        break;
      }

      int to,cc,sz;
      rep(i,n){
        if(cti>>i&1)continue;
        sz=SZ(V[from]);
        rep(j,sz){
          to=V[from][j].to;
          cc=V[from][j].cost;
          if(cost[cti|1<<i][to])continue;
          Q.push(state(ccost+1.0*cc/ti[i],to,cti|1<<i));
        }
      }
    }
    if(ans<0)puts("Impossible");
    else printf("%f\n",ans);
  }
}

Measured memory_bytes: 7732
#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstring>
#include <cstdio>
#include <cstdlib>
using namespace std;

signed main(){
    cin.tie(0); 
    ios::sync_with_stdio(false);
    int n;
    int d[100010];
    int ans;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>d[i];
    }
    sort(d,d+n);
    ans = d[n/2] - d[n/2-1];
    cout<<ans<<"\n";
    return 0;
}


Measured memory_bytes: 640
using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using E = System.Linq.Enumerable;
 
class Program
 {

      
        static void Main(string[] args)
        {
          //入力を受け取る
          var NK = Console.ReadLine().Split(' ').Select(x => double.Parse(x)).ToArray();
          var N = NK[0];
          var K = NK[1];
          var S = Console.ReadLine();
          
          var tyoku = new List<int>();
          var saka  = new List<int>();
          var all   = new List<int>();
          for(int i = 0 ; i < N ; i++){
            var sentou = S[i];
            var count = 1;
            i++;
            while(i < N && sentou == S[i]){
              i++;
              count++;
            }
            if(sentou == '1'){
              saka.Add(count);
              all.Add(count);
            }else{
              tyoku.Add(count);
              all.Add(count);
            }
            i--;
          }
          var tyo = tyoku.ToArray();
          var sa =  saka.ToArray();
          var AllA =  all.ToArray();
          
          var sum = new int[AllA.Length+1];
          sum[0] = 0;
          for(int i = 1 ; i < AllA.Length+1 ; i++){
            sum[i] = sum[i-1]+AllA[i-1];
          }
          
          var res = 0;
          if(S[0] == '1'){
            for(int i = 1;i < sum.Length;i += 2){
              var start = i;
              var end = (int) Math.Min(i+2*K,sum.Length-1);
              var cum = sum[end]-sum[start-1];
              if(res < cum){
                res = cum;
              }
            }
          }else{
             var start = 1;
             var end = (int) Math.Min(2*K,sum.Length-1);
             res = sum[end]-sum[start-1];
             for(int i = 2;i < sum.Length;i += 2){
               start = i;
               end = (int) Math.Min(i+2*K,sum.Length-1);
               var cum = sum[end]-sum[start-1];
               if(res < cum){
                 res = cum;
               }
             }
          }
          Console.WriteLine(res);
        }
}


Measured memory_bytes: 14688
import java.util.Scanner;

class Main {

	public static void main(String args[]) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int[] c = new int[n];
		int key;
		int cnt=0;
		for (int i = 0; i < n; i++) {
			c[i] = in.nextInt();
		}
		int q=in.nextInt();

		for (int i = 0; i < q; i++) {
			key = in.nextInt();
			for (int j = 0; j < n; j++) {
				if(key==c[j]) {
					cnt+=1;
					break;
				}
			}
		}
		System.out.println(cnt);
		in.close();
	}



}



Measured memory_bytes: 40380
// Problem : F - Removing Robots
// Contest : AtCoder - AtCoder Beginner Contest 158
// URL : https://atcoder.jp/contests/abc158/tasks/abc158_f
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

//Macros

#define ll long long
#define db long double
#define pb push_back
#define eb emplace_back
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define mi map<int,int>
#define mii map<pii,int>
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()
#define sz(x) (int)x.size()
#define mod 998244353
#define EPS 1e-9
#define io ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define inf 1e10
#define PI acos(-1.0)
#define int long long
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define N 200005

//Solution

void solve(){
    int n;
    cin>>n;
    vii a(n);
    for(int i=0;i<n;i++) cin>>a[i].fi>>a[i].se;
    sort(all(a));
    vi dp(n+1);
    dp[n] = 1;
    stack<pii> st;
    st.push({n,inf});
    for(int i=n-1;~i;i--){
        while(st.top().se < a[i].fi+a[i].se) st.pop();
        int p = st.top().fi;
        dp[i] = dp[p];
        dp[i] += dp[i+1];
        dp[i] %= mod;
        st.push({i,a[i].fi});
    }
    cout<<dp[0]<<endl;
}

signed main(){
    io;
    //freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
    int tests;
    //cin>>tests;
    tests = 1;
    while(tests--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 9452
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  string str;
  cin >> str;
  int cursor = 0;
  int counter = 0;
  while(cursor < N - 2){
    if(str.at(cursor) == 'A' && str.at(cursor + 1) == 'B' && str.at(cursor + 2) == 'C'){
      cursor += 3;
      counter++;
    }
    else cursor++;
  }
  cout << counter << endl;
}

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

a = []
for _ in range(M):
    a.append(int(input()))

val = [0,1]
for i in range(1, N + 1):
    ans = val[0] + val[1]
    val[0] = val[1]
    val[1] = ans
    if len(a) > 0:
        if i == a[0]:
            val[1] = 0
            a.pop(0)

print(ans % (10**9 +7))

Measured memory_bytes: 7208
#include<bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n ; i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define whole(f, x, ...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x) // decltypeで型取得、引数があればva_argsのところに入れる
using namespace std;
typedef long long ll; // long longをllでかけるようにした
const int INF = 1e9;

int main(void){
    string s; cin >> s;
    int n = s.size();
    int ans = 0, i = 0;
    while(i < n){
        int count = 0;
        while (s[i] == 'A' or s[i] == 'T' or s[i] == 'G' or s[i] == 'C'){
            count++;
            i++;
        }
        ans = max(ans, count);
        i++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
# include <iostream>
# include <algorithm>
#include <array>
# include <cassert>
#include <cctype>
#include <climits>
#include <numeric>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <tuple>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
# include <chrono>
# include <random>
# include <limits.h>
# include <unordered_map>
# include <unordered_set>
# include <deque>
# include <cstdio>
# include <cstring>
#include <stdio.h>
#include<time.h>
#include <stdlib.h>
#include <cstdint>
#include <cfenv>
#include<fstream>
//#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
long long MOD = 1000000000 + 7; //924844033 1000000000 + 9;
constexpr long long INF = numeric_limits<LL>::max();
const double PI = acos(-1);
#define fir first
#define sec second
#define thi third
#define debug(x) cerr<<#x<<": "<<x<<'\n'
typedef pair<LL, LL> Pll;
typedef pair<double, double> Dll;
typedef pair<LL, pair<LL, LL>> Ppll;
typedef pair<LL, pair<LL, bitset<100001>>> Pbll;
typedef pair<LL, pair<LL, vector<LL>>> Pvll;
typedef pair<LL, LL> Vec2;
struct Tll { LL first, second, third; };
struct Fll { LL first, second, third, fourth; };
typedef pair<LL, Tll> Ptll;
#define rep(i,rept) for(LL i=0;i<rept;i++)
#define Rrep(i,mf) for(LL i=mf-1;i>=0;i--)
LL h, w, n, m, k, t, s, p, q, last, first, cnt, sum[700000], ans, dp[700000];
Pll a[700000], b[700000];
string str, ss;
bool f[4000][4000];
char c[4000][4000];
int di[4][2] = { { 0,1 },{ 1,0 },{ 0,-1 },{ -1,0 } };
struct Edge { LL to, cost; };
struct edge { LL from, to, cost; };
vector<vector<Edge>>vec;
vector<edge>ed;
vector<LL>v;
map<string, LL>ma;
set<LL>st;

map<LL, LL>zip;
LL unzip[700000];
void compress(vector<LL>x) {
	LL now = -1;
	cnt = 0;
	sort(x.begin(), x.end());
	rep(i, x.size()) {
		if (now != x[i]) {
			zip[x[i]] = cnt;
			unzip[cnt] = x[i];
			now = x[i];
			cnt++;
		}
	}
	cnt = 0;
}
void YN(bool f) {
	if (f)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}
void yn(bool f) {
	if (f)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}

int main() {
	cin >> n;
	rep(i, n) {
		cin >> a[i].fir >> a[i].sec;
	}
	sort(a,a+n);
	h = -1; cnt = -1;
	rep(i, n) {
		if (h != a[i].fir) {
			cnt++;
			b[cnt].fir = a[i].fir;
			b[cnt].sec += a[i].sec;
			h = a[i].fir;
		}
		else {
			b[cnt].sec += a[i].sec;
		}
	}
	n = cnt + 1;
	rep(i, n)v.push_back(b[i].fir), a[i] = b[i];
	compress(v);
	rep(i, n) {
		a[i].fir = zip[a[i].fir];
		sum[i + 1] += a[i].sec;
	}
	rep(i, n) {
		sum[i + 1] += sum[i];
		dp[i] = sum[i+1] - a[i].sec - unzip[a[i].fir];
	}
	LL l = INF;
	ans = a[0].sec;
	for (int i = 0; i < n; i++) {
		l = min(l, dp[i]);
		ans = max(ans, sum[i + 1] - l - unzip[a[i].fir]);
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 65380
#include<iostream>
#include<cstdint>
#include<cstdlib>
template<typename T>
void fin(T const& t){ std::cout << t << std::endl; exit(0); }

int main() {
  std::cin.tie(0); std::ios::sync_with_stdio(false);
  int64_t A, V, B, W, T; std::cin >> A >> V >> B >> W >> T;
  if(V <= W) fin("NO");
  int64_t L = (V-W)*T;
  if(L >= std::abs(A-B)) fin("YES");
  fin("NO");
  return 0;
}


Measured memory_bytes: 3660
#[allow(unused_macros)]
macro_rules ! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( stdin . lock ( ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! input_inner { ( $ next : expr ) => { } ; ( $ next : expr , ) => { } ; ( $ next : expr , mut $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let mut $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! read_value { ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) } ; ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 } ; ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) } ; }

fn main() {
    input! {
        n: usize,
        t: [u64; n],
        m: usize,
        px: [(usize1, u64); m]
    }

    for i in 0..m {
        let mut t2 = t.to_vec();
        let (p, x) = px[i];
        t2[p] = x;
        println!("{}", t2 .iter().fold(0, |acc, &x| acc + x));
    }
}

Measured memory_bytes: 4352
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [i for i in range(n)]
        self.rank = [0 for _ in range(n)]
        self.size = [1 for _ in range(n)]

    def find(self, x):
        root = x
        while self.parents[root] != root:
            root = self.parents[root]
        while self.parents[x] != root:
            parent = self.parents[x]
            self.parents[x] = root
            x = parent
        return root

    def unite(self, x, y):
        xroot = self.find(x)
        yroot = self.find(y)
        if xroot == yroot:
            return
        xrank = self.rank[xroot]
        yrank = self.rank[yroot]
        if xrank < yrank:
            self.parents[xroot] = yroot
            self.size[yroot] += self.size[xroot]
        elif xrank == yrank:
            self.parents[yroot] = xroot
            self.rank[yroot] += 1
            self.size[xroot] += self.size[yroot]
        else:
            self.parents[yroot] = xroot
            self.size[xroot] += self.size[yroot]

    def len(self, x):
        return self.size[self.find(x)]

    def roots(self):
        return [i for i in range(N) if self.rank[i] == 0]

from collections import defaultdict

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

uf1 = UnionFind(N)
uf2 = UnionFind(N)

for _ in range(K):
    p, q = map(int, input().split())
    uf1.unite(p - 1, q - 1)

for _ in range(L):
    r, s = map(int, input().split())
    uf2.unite(r - 1, s - 1)

D = defaultdict(int)

for i in range(N):
    D[(uf1.find(i), uf2.find(i))] += 1

res = []

for i in range(N):
    res.append(D[(uf1.find(i), uf2.find(i))])

print(' '.join(map(str, res)))

Measured memory_bytes: 126432
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll inf = 1e18;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define per(i, a, b) for (int i = b - 1; i >= a; i--)
#define int ll
using pint = pair<int, int>;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

signed main() {
    int x[5];
    rep(i, 0, 5) cin >> x[i];
    rep(i, 0, 5) {
        if (x[i] == 0) {
            cout << i + 1 << "\n";
            return 0;
        }
    }
}

Measured memory_bytes: 3560
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
ll mod=1e9+7;
#define PI 3.1415926535897932385
#define INF 100000000000000000ll
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
string char_to_str(char c){string tem(1,c);return tem;}
 
typedef pair<long long, long long> ii;
#define S second
#define F first
ll max(ll a,ll b){if(a>b){return a;}return b;}
ll min(ll a,ll b){if(a<b){return a;}return b;}
#define MAXN 200005
// string to integer stoi() Remember: it takes string not character
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();
 
// To compile--> g++ -std=c++0x -o output one.cpp
// To run--> ./output

int main() {
    fastio;
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    ll n;
    cin>>n;
    ll a[n+1];
    for (int i = 1; i<=n; ++i)
    {
        cin>>a[i];
    }
    ll s[n+1];
    ll d[n+1];
    map<ll, ll> m1;
    for (int i = 1; i < n+1; ++i)
    {
        s[i]=i+a[i];
        d[i]=i-a[i];
        m1[d[i]]++;
    }

    ll ans=0;
    for (int i = 1; i<=n; ++i)
    {
        ans+=m1[s[i]];
    }
    cout<<ans;

    return 0;
}


Measured memory_bytes: 31004
import qualified Data.ByteString.Char8 as BS
import qualified Data.List as L
import qualified Data.Set as S
import qualified Control.Monad as M
import Data.Maybe (fromJust)

main = do
 [n,k] <- map read <$> words <$> getLine
 a <- S.size <$>S.unions<$> M.replicateM k gen
 print (n-a)

gen = do
 getLine
 S.fromList<$>BS.words<$>BS.getLine


Measured memory_bytes: 5120
n,k = gets.split.map(&:to_i)

mother = []
n.times do |i|
  i = i + 1
  sum = 1
  until i >= k
    i = i * 2
    sum *= 2
  end
  mother << sum * n
end

child = 1
mother.each do |a|
  next if a >= mother[0]
  b = a
  sum = 1
  until b == mother[0]
    b += a
    sum += 1
  end
  child += sum
end
puts child.fdiv(mother[0])

Measured memory_bytes: 2684
S = list(input())
char_cnt = dict()
cnt = 2
ans = 'Yes'

for s in S:
    if s in char_cnt:
        char_cnt[s] += 1
    else:
        char_cnt[s] = 1

for n in char_cnt.values():
    if n != cnt:
        ans = 'No'

print(ans)


Measured memory_bytes: 38384
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
using namespace std;

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


template <typename T=long long>
class BIT  
{
    private:
        int sz;  // 1, 2, ..., sz の index を管理
        vector<T> bit;  // BIT を保存する vector; 区間の右端で番号付け

    public:
        BIT(int N): sz(N), bit(N+1, 0) {};

        // v[idx] に w を足す
        void add(int idx, T w){
            // x&(-x) で x の最も下の立っているbitが取り出せる
            for(int x = idx; x <= sz; x += x&(-x)) bit[x] += w;  // 1-index
        }

        // v[1]+...+v[idx] を返す
        T sum(int idx){
            T ret = 0;
            for(int x = idx; x > 0; x -= x&(-x)) ret += bit[x];  // 1-index
            return ret;
        }
        
        // v[left+1]+...+v[right] を返す
        T sum(T left, T right){ return sum(right)-sum(left); }
};

// 座標圧縮 O(NlogN)
template <typename T>
vector<T> coordComp(vector<T>& a)
{
    int n = a.size();
    vector<T> ret(n), tmp(a);

    sort(tmp.begin(), tmp.end());  // sort
    tmp.erase(unique(tmp.begin(), tmp.end()), tmp.end());  // unique な値のみ残す

    for(int i = 0; i < n; ++i){
        ret[i] = lower_bound(tmp.begin(), tmp.end(), a[i]) - tmp.begin();
    }

    return ret;
}


int main()
{
    int N, K;
    cin >> N >> K;
    vector<long long> a(N+1);
    REP(i, N) cin >> a[i+1];

    REP(i, N){
        a[i+1] -= K;
        a[i+1] += a[i];
    }

    // 座標圧縮; a[0], [1], ... , a[N] -> [0, N] に圧縮
    auto comp_a = coordComp<long long>(a);

    BIT<> bit(N+1); // BIT で 0~N の出現回数を管理
    long long ans = 0;
    // r を探索
    REP(i, N+1){
        ans += bit.sum(comp_a[i]+1);
        bit.add(comp_a[i]+1, 1);
    }
    cout << ans << endl; 

    return 0;
}

Measured memory_bytes: 4992