akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
const ll INF = 1LL<<60;
const ll MOD = 1e9+7;
const ld pi = 3.14159265358979323846264;


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ld a,b,h,m;cin>>a>>b>>h>>m;
    ld ha = (h+m/60)/12*2*pi;
    ld hm = m/60*2*pi;
    cout<<setprecision(12)<<sqrt(a*a+b*b-2*a*b*cos(ha-hm));
    return 0;
}

Measured memory_bytes: 4172
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
#include<math.h>
#include<bitset>
#include<queue>
#include<set>
// #include<bits/stdc++.h>
using namespace std;
#define ll long long

int main(){
  int r;
  cin >> r;
  cout << r*r << endl;


  return 0;
}


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

using namespace std;

const long long INF = 1e9;

long long N, A, B, C;
long long l[8];

long long dfs(long long cur, long long a, long long b, long long c){
	if (cur == N){
		return (min({a,b,c}) > 0)? abs(a - A) + abs(b - B) + abs(c - C) - 30 : INF;
	}

	long long ret0 = dfs(cur + 1, a, b, c);
	long long ret1 = dfs(cur + 1, a + l[cur], b, c) + 10;
	long long ret2 = dfs(cur + 1, a, b + l[cur], c) + 10;
	long long ret3 = dfs(cur + 1, a, b, c + l[cur]) + 10;

	return min({ret0, ret1, ret2 , ret3});
}

int main(){
	cin >> N >> A >> B >> C;
	for (long long i = 0; i < N; i++){
		cin >> l[i];
	}

	cout << dfs(0, 0, 0, 0) << endl;
	return 0;
}


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

using namespace std;

const int N = 1024;

char s[N];

int main() {
  int k;
  scanf("%s %d", s, &k);
  int n = strlen(s);
  vector<pair<int, char>> groups;
  char last = s[0];
  int cnt = 0;
  for (int i = 0; i < n; ++i) {
    if (last != s[i]) {
      groups.emplace_back(cnt, last);
      cnt = 0;
      last = s[i];
    }
    ++cnt;
  }
  groups.emplace_back(cnt, last);
  if (groups.size() == 1) {
    long long tot = 1LL * n * k;
    printf("%lld\n", tot / 2);
    return 0;
  }
  long long ans = 0;
  if (groups[0].second == groups.back().second) {
    for (int i = 1; i + 1 < (int)groups.size(); ++i) {
      ans += groups[i].first / 2;
    }
    ans *= k;
    ans += groups[0].first / 2 + groups.back().first / 2;
    ans += 1LL * (k-1) * ((groups[0].first + groups.back().first) / 2);
  }
  else {
    for (auto it : groups) {
      ans += it.first / 2;
    }
    ans *= k;
  }
  printf("%lld\n", ans);
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int md = 1e9 + 7;
inline void add(int &a, int b) {
  a += b;
  if (a >= md) a -= md;
}
inline void sub(int &a, int b) {
  a -= b;
  if (a < 0) a += md;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, k;
  cin >> n >> k;
  vector<int> a(n + 1);
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  vector<vector<int>> dp(n + 1, vector<int>(k + 1, 0));
  for (int j = 0; j <= k; j++) {
    dp[0][j] = 1;
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j <= k; j++) {
      if (j) {
        dp[i][j] = dp[i][j - 1];
      }
      add(dp[i][j], dp[i - 1][j]);
      if (j - a[i] - 1 >= 0) {
        sub(dp[i][j], dp[i - 1][j - a[i] - 1]);
      }
    }
  }
  int ret = dp[n][k];
  if (k) {
    sub(ret, dp[n][k - 1]);
  }
  cout << ret << '\n';
  return 0;
}

Measured memory_bytes: 40192
n, y = map(int, input().split())
# 連立方程式で解く
y //= 1000
tmp = 10 * n - y
y_max = tmp // 5
z_max = tmp // 9

for cnt_y in range(n + 1):
    for cnt_z in range(n + 1):
        if cnt_y + cnt_z <= n:
            cnt_x = n - (cnt_y + cnt_z)
            if cnt_x + cnt_y * 5 + cnt_z * 10 == y:
                print(cnt_z, cnt_y, cnt_x)
                exit()
else:
    print(-1, -1, -1)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define ll long long
#define int long long int
#define MOD 1000000007
#define mkp make_pair
#define maxn 100005
#define pb push_back
#define ff first
#define ss second
#define all(x) x.begin(),x.end()
#define debug1(a) cout<<a<<endl;
#define debug2(a,b) cout<<a<<' '<<b<<endl;
#define debug3(a,b,c) cout<<a<<' '<<b<<' '<<c<<endl;
#define rep(i,n) for(int i=0;i<n;i++)
#define repl(i,a,b) for(int i=a;i<b;i++)
#define pi pair<int,int>
#define pii pair<int,pi>
#define mp map<int,int>
#define ump unordered_map<int,int>
#define  vi vector<int>
#define st set<int>
#define mst multiset<int>
#define pq priority_queue
#define mpq priority_queue<int,vector<int>,greater<int> >
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define in cin>>
#define out cout<<
using namespace std;
const int infi=1e15+7;
void printVector(vector<int> v){
    for(int i=0;i<(int)v.size();i++)
        cout<<v[i]<<" ";
    out endl;
}

void printArray(int arr[],int n)
{
   for(int i=0;i<n;i++)cout<<arr[i]<<' ';
cout<<endl;
}
 set<pair<int,int>> primeset;
 vi prime_number;
void SieveOfEratosthenes(int n)
{
    bool prime[n+1];
    memset(prime, true, sizeof(prime));

    for (int p=2; p*p<=n; p++)
    {
        if (prime[p] == true)
        {
        for (int i=p*p; i<=n; i += p)
                prime[i] = false;
        }
    }
    for (int p=2; p<=n; p++)
       if (prime[p])
           primeset.insert(mkp(p,1));
}
ll modExp(ll base, ll power) {
    if (power == 0) {
        return 1;
    } else {
        ll cur = modExp(base, power / 2); cur = cur * cur; cur = cur % MOD;
        if (power % 2 == 1) cur = cur * base;
        cur = cur % MOD;
        return cur;
    }
}
//for making unordered_map with pair
struct hash_pair {
    template <class T1, class T2>
    size_t operator()(const pair<T1, T2>& p) const
    {
        auto hash1 = hash<T1>{}(p.first);
        auto hash2 = hash<T2>{}(p.second);
        return hash1 ^ hash2;
    }
};
int32_t main()
{
fastio;
int n;in n;
vector<int> arr(n+1);
rep(i,n-1){
    int a;in a;
    arr[a]++;
}
for(int i=1;i<=n;i++) cout<<arr[i]<<"\n";
    return 0;
}

/*
google kick start
  cout << "Case #" << tt << ": "<<ans<<endl;
*/


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

int main(){
  long N,X;
  cin>>N>>X;
  long ans=0,a,b;
  a=N-X;
  b=X;
  ans+=N;
  while(true){
    if(a%b==0){
      ans+=b*((a/b)*2-1);
      break;
    }else if(b%a==0){
      ans+=a*((b/a)*2-1);
      break;
    }else if(a>b){
      long k=a/b;
      ans+=b*2*k;
      a=a%b;
    }else{
      long l=b/a;
      ans+=a*2*l;
      b=b%a;
    }
  }
  cout<<ans<<endl;
  return 0;
}


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

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

    int H = scanner.nextInt();
    int W = scanner.nextInt();
    int K = scanner.nextInt();
    char[][] map = new char[H][W];
    int[][] res = new int[H][W];
    for (int i = 0; i < H; i++) map[i] = scanner.next().toCharArray();
    List<Integer>[] places = new List[W];
    for (int i = 0; i < W; i++) places[i] = new ArrayList<>();
    for (int i = 0; i < H; i++) for (int j = 0; j < W; j++) if (map[i][j] == '#') places[j].add(i);
    for (int i = 0; i < W; i++) if (!places[i].isEmpty()) places[i].set(places[i].size() - 1, H - 1);
    int l = 0;
    for (int i = 0; i < W; i++) if (!places[i].isEmpty()) l = i;
    List<Integer> temp = places[l];
    places[l] = places[W - 1];
    places[W - 1] = temp;

    int px = -1;
    int id = 1;
    for (int i = 0; i < W; i++) {
      if (!places[i].isEmpty()) {
        int py = -1;
        for (int j : places[i]) {
          for (int y = py + 1; y <= j; y++) {
            for (int x = px + 1; x <= i; x++) {
              res[y][x] = id;
            }
          }
          py = j;
          id++;
        }
        px = i;
      }
    }
    StringBuilder sb = new StringBuilder();
    for (int i = 0; i < H; i++) {
      for (int j = 0; j < W; j++) {
        sb.append(res[i][j]).append(' ');
      }
      sb.setLength(sb.length() - 1);
      sb.append('\n');
    }
    System.out.print(sb.toString());
  }
}


Measured memory_bytes: 34448
# coding: utf-8
N = int(input())
T, A = map(int, input().split())
li_H = list(map(int, input().split()))

tmp = 10000
cnt = 0
for i, h in enumerate(li_H):
    t = T - h * 0.006
    diff_ave = abs(t-A)
    if diff_ave < tmp:
        tmp = diff_ave
        cnt = i+1
print(cnt)


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

#define rep(i,n) for(int i = 0; i < n; i++)
#define REP(i,n) for(int i = 1; i < n; i++)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl '\n'
#define fi first
#define se second
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
using vs = vector<string>;
using vb = vector<bool>;
using vc = vector<char>;
using vcc = vector<vc>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll &a, const ll &b){return ((a)+(b)-1)/b;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

int n, m, q;
int a[55], b[55], c[55], d[55];

int dfs(vi &v) {
  if(sz(v) == n) {
    int res = 0;
    rep(i,q) {
      if(v[b[i]-1] - v[a[i]-1] == c[i]) res += d[i];
    }
    return res;
  }
  int tmp = 0;
  for(int i = v.back(); i <= m; i++) {
    v.push_back(i);
    tmp = max(tmp, dfs(v));
    v.pop_back();
  }
  return tmp;
}

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

  cin >> n >> m >> q;
  rep(i,q) cin >> a[i] >> b[i] >> c[i] >> d[i];
  vi v;
  int ans = 0;
  rep(i,m) {
    v.push_back(i+1);
    ans = max(ans, dfs(v));
    v.pop_back();
  }
  cout << ans << endl;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b;
    cin>>a>>b;
    string s;
    cin>>s;
    string ans="Yes";
    if(s[a]!='-')
    {
        ans="No";
    }
   for(int i=0;i<a;i++)
   {
       if(!isdigit(s[i]))
       {
           ans="No";
       }
   }
    for(int i=a+1;i<(a+b+1);i++)
   {
       if(!isdigit(s[i]))
       {
           ans="No";
       }
      
   }
 cout<<ans<<"\n";
return 0;
}

Measured memory_bytes: 3604
s = input()
x, y = map(int, input().split())
hL = len(s)
L = 2 * hL

dp = [[False] * (L + 1) for i in range(2)]
ndp = [False] * (L + 1)

def next(i):
    global s
    while i < hL and s[i] != 'T':
        i += 1
    i += 1
    return i

def c(x):
    global hL
    return x + hL

index = 0
t = 0
js = [1]
dp[0][c(0)] = True
dp[1][c(0)] = True
mini, maxi = 0, 1
while index < hL:
    ni = next(index)
    dx, index = ni - index - 1, ni
    for i in range(mini, maxi):
        for j in js:
            if -hL <= i + j * dx <= hL:
                nx = c(i + j * dx)
                ndp[nx] = ndp[nx] or dp[t][c(i)]
    for i in range(mini, maxi):
        dp[t][c(i)] = False
    dp[t], ndp = ndp, dp[t]
    mini, maxi = mini - dx, maxi + dx
    js = [-1, 1]
    t = (t + 1) % 2
print('Yes' if dp[0][c(x)] and dp[1][c(y)] else 'No')


Measured memory_bytes: 45276
#include "bits/stdc++.h"

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

template <class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template <class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int h, m, d;
	char c;
	cin >> h >> c >> m >> c >> d;
	if (m <= 4) {
		cout << "Heisei" << endl;
	}
	else {
		cout << "TBD" << endl;
	}
}

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

#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define deb(x)	cout << #x << " " << x << endl;

typedef long long int ll;
#define MOD 1000000007

int power(ll b, int e) {
	ll res = 1;
	while (e) {
		if (e&1)
			res =(res * b) % MOD;
		e >>= 1;
		b = (b*b) % MOD;
	}

	return res;
}

int main() {

	IOS

	int n;
	cin >> n;

	if (n == 1)
		cout << 0;

	// else if (n == 2)
	// 	cout << 1;

	else {
		ll res = (2 * (ll)power(9, n)) % MOD;
		res = (res - (ll)power(8, n)+ MOD) % MOD;
		res = ((ll)power(10, n) - res + MOD) % MOD;

		cout << res;
	}

	return 0;
}

Measured memory_bytes: 3652
/*                         _
                        _ooOoo_
                       o8888888o
                       88" . "88
                       (| -_- |)
                       O\  =  /O
                    ____/`---'\____
                  .'  \\|     |//  `.
                 /  \\|||  :  |||//  \
                /  _||||| -:- |||||_  \
                |   | \\\  -  /'| |   |
                | \_|  `\`---'//  |_/ |
                \  .-\__ `-. -'__/-.  /
              ___`. .'  /--.--\  `. .'___
           ."" '<  `.___\_<|>_/___.' _> \"".
          | | :  `- \`. ;`. _/; .'/ /  .' ; |
          \  \ `-.   \_\_`. _.'_/_/  -' _.' /
===========`-.`___`-.__\ \___  /__.-'_.'_.-'================

                  Please give me AC.
*/

#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <string>
#include <sstream>
#include <complex>
#include <bitset>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <chrono>
#include <random>

using namespace std;

using int64 = long long;
using uint64 = unsigned long long;
using vi = vector<int>;
using vl = vector<int64>;
using pii = pair<int, int>;
using pll = pair<int64, int64>;

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(v) (v).begin(), (v).end()
#define print(x) cout << (x) << '\n'
#define print2(x, y) cout << (x) << ' ' << (y) << '\n'
#define print3(x, y, z) cout << (x) << ' ' << (y) << ' ' << (z) << '\n'
#define printn(v) rep(i, (v).size() - 1) cout << (v)[i] << ' '; cout << (v)[n - 1] << '\n';
#define debug(x) cerr << #x << ": " << (x) << '\n'
#define debug2(x, y) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v) for (size_t _ = 0; _ < v.size(); ++_){cerr << #v << "[" << _ << "] : " << v[_] << '\n';}
// constant
const int INF = (1<<30) - 1;
const int64 INF64 = (1LL<<62) - 1;

template<typename T> T gcd(T a, T b) {
    if (a < b) return gcd(b, a);
    T r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

template<typename T> T lcm(const T a, const T b) {
    return a / gcd(a, b) * b;
}

template<typename T> bool chmin(T& a, const T& b) {
    if (a > b) return a = b, true; else return false;
}

template<typename T> bool chmax(T& a, const T& b) {
    if (a < b) return a = b, true; else return false;
}

// End of template.

int main() {
    cout << fixed << setprecision(15);
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    // cin.read(buf, sizeof buf); // 注意: ./a.out < in か pbp | ./a.out で入力すること

    double a, b, h, m;
    cin >> a >> b >> h >> m;
    double atheta, btheta;
    atheta = (h + m / 60.0) / 12.0 * 2 * M_PI;
    btheta = m / 60.0 * 2 * M_PI;
    double theta = btheta - atheta;

    debug(theta);
    double x = sqrt(a * a + b * b - 2 * a * b * cos(theta));
    print(x);

    return 0;
}



Measured memory_bytes: 4308
N = int(input())
li = list(map(int, input().split()))
count = 0
flag = False

while True:
  for i in range(N):
    if(li[i]%2!=0):
      flag = True
    li[i] /= 2
  
  if(flag):
    break
    
  count+=1

print(count)

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

using namespace std;

int main()
{
	int a, b, c;
	cin >> a >> b >> c;
	if ((a == 7 && b == 5 && c == 5) || (a == 5 && b == 7 && c == 5) || (a == 5 && b == 5 && c == 7))
		cout << "YES" << endl;
	else
		cout << "NO" << endl;

	return 0;
}


Measured memory_bytes: 256
input = require('fs').readFileSync('/dev/stdin', 'utf8')
lines = input.split('\n')
N = lines.shift() * 1

_dividers = function(n) {
  var arr = []
  for (var i = 1; i*i <= n; i++) {
     if (n % i === 0) {
       arr.push(i)
       if ( i != n / i) {
         arr.push(n / i)
       }
     }
  }
  return arr.sort((a, b) => a - b)
}

ds = _dividers(N)

min = N
for (i=0; i <ds.length-i; i++) {
    for (j=i; j <ds.length; j++) {
        if (N == ds[i] * ds[j]) {
            if (min > ds[i] - 1 + ds[j] - 1) {
                min = ds[i] - 1 + ds[j] - 1
            }         
        }
    }
}
console.log(min)


Measured memory_bytes: 9532
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define vll vector<ll>
#define mll map<ll,ll>
#define pb push_back
#define mp make_pair
#define endl "\n"
#define MAX 1e18
#define F first
#define S second
#define all(s) s.begin(),s.end()
#define mod 998244353
ll lcm(ll a,ll b){return (a*b)/(__gcd(a,b));}
ll cel(ll n,ll d){return (n+d-1)/d;}

void hertz()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    #ifndef ONLINE_JUDGE
      freopen("input.txt", "r", stdin);
      freopen("output.txt", "w", stdout);
    #endif
}

int main()
{
    //hertz();
    ll n;
    cin>>n;
    ll arr[n];
    unordered_map<ll,ll> m1;
    for (int i = 0; i < n; ++i)
    {
    	cin>>arr[i];
    	m1[arr[i]]++;
    }
    
    sort(arr,arr+n);
    unordered_map<ll,ll> m;
	ll ans=0;
    for (int i = 0; i < n; ++i)
    {
    	int ok=1;
    	if(m1[arr[i]]==1)
    	{
	    	for (int j = 1; j*j <= arr[i]; ++j)
	    	{
	    		if(arr[i]%j==0)
	    		{
	    			if((m.count(arr[i]/j) || m.count(j))){
	    				ok=0;break;
	    			}
	    		}
	    	}
	    	if(ok){
	    		//cout<<arr[i]<<endl;
	    		ans++;
	    	}
    	}
	    	m[arr[i]]=1;
    }
    cout<<ans<<endl;
    
}

Measured memory_bytes: 21340
#![allow(non_snake_case)]
use std::io::*;
use std::str::FromStr;
use std::cmp::*;

#[allow(dead_code)]
fn read<T : FromStr>() -> T {
  let token: String = stdin().lock()
    .bytes()
    .map(|c| c.expect("failed reading char") as char)
    .skip_while(|c| c.is_whitespace())
    .take_while(|c| !c.is_whitespace())
    .collect();
  token.parse().ok().expect("failed parse")
}

#[allow(dead_code)]
fn read2<T : std::str::FromStr>() -> (T, T) {
  (read::<T>(), read::<T>())
}

#[allow(dead_code)]
fn read3<T : std::str::FromStr>() -> (T, T, T) {
  (read::<T>(), read::<T>(), read::<T>())
}

#[allow(dead_code)]
fn reads<T : std::str::FromStr>() -> Vec<T> {
  let mut line = String::new();
  stdin().read_line(&mut line).ok();
  line.trim().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}

struct MaxSegTree {
  n: usize,
  data: Vec<i64>,
}

impl MaxSegTree {
  fn new(data_: &[i64]) -> Self {
    let m = data_.len();
    let mut n = 1;
    while n < m { n *= 2; }

    let mut data = vec![std::i64::MIN; 2*n];

    for i in 0..m {
      data[i + n - 1] = data_[i];
    }

    for ri in 0..n-2 {
      let i = n - 2 - ri; // [n-2 .. 0]
      data[i] = max(data[i*2+1], data[i*2+2]);
    }

    Self {
      n,
      data,
    }
  }

  fn update(&mut self, i: usize, val: i64) {
    let mut i = self.n - 1 + i;
    self.data[i] = val;
    while i > 0 {
      i = (i - 1) / 2;
      self.data[i] = max(self.data[i*2+1], self.data[i*2+2]);
    }
  }

  fn query(&self, l: usize, r: usize) -> i64 {
    let mut l = l + self.n - 1;
    let mut r = r + self.n - 1;

    let mut res = std::i64::MIN;
    while l < r {
      if (l & 1) == 0 {
        res = max(res, self.data[l]);
      }
      if (r & 1) == 0 {
        res = max(res, self.data[r - 1]);
      }
      l = l / 2;
      r = (r - 1) / 2;
    }

    res
  }
}

fn main() {
  let n: usize = read();
  let k: usize = read();
  let mut xs: Vec<usize> = Vec::with_capacity(n);
  for _ in 0..n {
    let x = read();
    xs.push(x);
  }

  const LIMIT: usize = 300000 + 10;
  let mut seg = MaxSegTree::new(&vec![0; LIMIT]);
  let mut res = 1;
  for x in xs {
    let l = if x >= k { x - k } else { 0 };
    let r = if x + k + 1 <= LIMIT { x + k + 1 } else { LIMIT };
    let head = seg.query(l, r);

    seg.update(x, head + 1);
    res = max(res, head + 1);
  }

  // let res = seg.query(0, LIMIT);
  println!("{}", res);
}

Measured memory_bytes: 12656
#include <iostream>
#include <cmath>

using namespace std;

int main(){

    string S,T;

    cin >> S>>T;

    for(int i=0;i<S.length();++i){
        if(S[i] != T[i]){
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
    return 0;

}



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

using namespace std;

#define inputInt(a) scanf("%d", &a)
#define inputStr(a) getline(cin, a)
#define inputLong(a) scanf("%lld", &a)
#define clr(a) memset(a, 0, sizeof(a))
#define printn(a) cout<<a<<"\n"
#define print(a) cout<<a

int main()
{
    char row1[3];
    char row2[3];

    scanf("%s",row1);
    scanf("%s",row2);

    if(row1[0] == row2[2] and row1[1] == row2[1] and row1[2] == row2[0])
        printn("YES");
    else
        printn("NO");


return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader
import java.io.InputStreamReader
import java.io.PrintWriter

val br = BufferedReader(InputStreamReader(System.`in`))
val out = PrintWriter(System.out)

fun main() {
    br.use { out.use {
        solve()
        out.flush()
    } }
}

fun solve() {
    val n = readInteger()
    val ans = readLongList()
        .sorted()
        .drop(n)
        .filterIndexed { i, v -> i % 2 == 0}
        .sum()
    out.println(ans)
}

fun readInteger() = Integer.parseInt(br.readLine())
fun readLong() = java.lang.Long.parseLong(br.readLine())
fun readStringList() = br.readLine()!!.split(' ')
fun readIntegerList() = readStringList().map(Integer::parseInt)
fun readLongList() = readStringList().map(java.lang.Long::parseLong)
fun readDoubleList() = readStringList().map(java.lang.Double::parseDouble)


Measured memory_bytes: 81156
p=pow(10,9)+7
def ncr(n, r, p): 
    # initialize numerator 
    # and denominator 
    num = den = 1 
    for i in range(r): 
        num = (num * (n - i)) % p 
        den = (den * (i + 1)) % p 
    return (num * pow(den,  
            p - 2, p)) % p
n,a,b=list(map(int, input().split()))
x=(pow(2,n,p)-1-ncr(n,a,p)-ncr(n,b,p))
print(x%p)

Measured memory_bytes: 3064
#include <stdio.h>

int main(void)
{
	
	int a,b;
	char op;
	scanf("%d %c %d",&a,&op,&b);
	(((0<a)&&(a<=20000))&&((0<=b)&&(b<=20000)));
	while(!(op=='?'))
	{
		if(op=='+')
		{
			printf("%d\n",a+b);
		}
		else
		{
			if(op=='-')
			{
				printf("%d\n",a-b);
			}
			else
			{
				if(op=='*')
				{
					printf("%d\n",a*b);
				}
				else{
					if((op=='/')&&(!(b==0)))
					{
						printf("%d\n",a/b);
					}
				}
			}
		}
		scanf("%d %c %d",&a,&op,&b);
	}
	return 0;
}

Measured memory_bytes: 600
import java.util.*;
 
public class Main {
	public static void main(String args[]){
		Scanner stdIn = new Scanner(System.in);
		int n = stdIn.nextInt();
		int a[] = new int[n + 1];
		int b[] = new int[n + 1];
		int c[] = new int[n];
		int sum = 0;
		
		for(int i = 1; i <= n; i++){
		    a[i] = stdIn.nextInt();
		}
		
		for(int i = 1; i <= n; i++){
		    b[i] = stdIn.nextInt();
		}
		
		for(int i = 1; i <= n - 1; i++){
		    c[i] = stdIn.nextInt();
		}
		
		int index = -100;
		for(int i = 1; i <= n; i++){
		    sum += b[a[i]];
		    if(index + 1 == a[i]){
		        sum += c[a[i] - 1];
		    }
		    index = a[i];
		}
		
		System.out.println(sum);
		
	}
}

Measured memory_bytes: 21716
import sys


class Loop(Exception):
    pass


class Walker:
    def __init__(self, room, start):
        self.room = room
        self.position = start

    def walk(self):
        try:
            while True:
                x, y = self.position
                tile = self.room[y][x]
                if tile == '.':
                    break
                elif tile == '>':
                    new_position = (x + 1, y)
                elif tile == '<':
                    new_position = (x - 1, y)
                elif tile == '^':
                    new_position = (x, y - 1)
                elif tile == 'v':
                    new_position = (x, y + 1)
                elif tile == 'x':
                    raise Loop
                room[y][x] = 'x'
                self.position = new_position
            return self.position
        except Loop:
            return 'LOOP'


while True:
    h, w = tuple(map(int, sys.stdin.readline().split(' ')))
    if (h, w) == (0, 0):
        exit()
    room = []
    for i in range(h):
        line = sys.stdin.readline().rstrip('\n')
        room.append(list(line))
    walker = Walker(room, (0, 0))
    pos = walker.walk()
    if pos == 'LOOP':
        print 'LOOP'
    else:
        print pos[0], pos[1]

Measured memory_bytes: 4408
n=int(input())
prime=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47]
elecnt=[0]*len(prime)
for i in range(len(prime)):
  c=1
  while n>prime[i]**c:
    elecnt[i]+=n//(prime[i]**c)
    c+=1
above74=sum(1 for i in elecnt if i>=74)
above24=sum(1 for i in elecnt if i>=24)
above14=sum(1 for i in elecnt if i>=14)
above4=sum(1 for i in elecnt if i>=4)
above2=sum(1 for i in elecnt if i>=2)
print(above74+above24*(above2-1)+above14*(above4-1)+above4*(above4-1)*(above2-2)//2)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef pair<int64_t ,int64_t> P;

int main(){
    string s;
    int k;
    cin >> s >> k;
    set<string> se;
    for(int i=1;i<=k;i++){
        for(int j=0;j<(s.size()-i+1);j++){
            se.insert(s.substr(j ,i));
        }
    }

    set<string> ::iterator ite;;
    ite = se.begin();
    for(int i=0;i<(k-1);i++) ite++;
    cout << *ite << endl;

}

Measured memory_bytes: 1664
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  for(int i=0; i<n; i++){
    cin >> a[i];	
  }
  sort(a.begin(), a.end());
  int ans=0;
  for(int i=0; i<n; i++){
    for(int j=i+1; j<n; j++){
      for(int k=j+1; k<n; k++){
        if(a[i]<a[j]+a[k] && a[j]<a[k]+a[i] && a[k]<a[i]+a[j]){
          ans++;
        }else{
          break;
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
 }


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

#define LL long long

#define FOR(INDEX, START, END) for (LL INDEX = (START); INDEX < (END); ++INDEX)
#define REP(INDEX, COUNT) for (LL INDEX = 0; INDEX < (COUNT); ++INDEX)

int main()
{
	bool over = false;
	LL N;
	cin >> N;
	LL a = 1;
	REP(i, N) {
		LL b;
		cin >> b;

		if (b == 0) {
			a = 0;
			over = false;
		}
		else {

			if (a < INT64_MAX / b) {
				a *= b;

				if (a > 1000000000000000000) {
					over = true;
				}
			}
			else {
				over = true;
			}
		}
	}

	if (a == 0) {
		cout << 0 << endl;
	}
	else if (over) {
		cout << -1 << endl;
	}
	else {
		cout << a << endl;
	}

	return 0;
}


Measured memory_bytes: 3636
#![allow(unused_imports)]
#![allow(unused_macros)]
use std::cmp::{ min, max };

macro_rules! ewriteln {
    ($($args:expr),*) => { let _ = writeln!(&mut std::io::stderr(), $($args),*); };
}
macro_rules! trace {
    ($x:expr) => { ewriteln!(">>> {} = {:?}", stringify!($x), $x) };
    ($($xs:expr),*) => { trace!(($($xs),*)) }
}
macro_rules! put {
    ($x:expr) => { println!("{}", $x) };
    ($x:expr, $($xs:expr),*) => { print!("{} ", $x); put!($($xs),*) }
}

fn ok(r: u64, n: u64) -> Option<u64> {
    let m = n / r - 1;
    if m > r {
        Some(m)
    } else {
        None
    }
}

fn main() {
    let mut sc = Scanner::new();
    let n: u64 = sc.cin();
    let mut ans = 0;
    for i in 1..n {
        if i * i > n { break; }
        if n % i != 0 { continue; }
        ans += ok(i, n).unwrap_or(0);
        if i * i != n {
            ans += ok(n/i, n).unwrap_or(0);
        }
    }
    put!(ans);
}

use std::io::{self, Write};
use std::str::FromStr;
use std::collections::VecDeque;

struct Scanner { stdin: io::Stdin, buffer: VecDeque<String>, }
impl Scanner {
    fn new() -> Scanner { Scanner { stdin: io::stdin(), buffer: VecDeque::new() } }
    fn cin<T: FromStr>(&mut self) -> T {
        while self.buffer.len() == 0 {
            let mut line = String::new();
            let _ = self.stdin.read_line(&mut line);
            for w in line.split_whitespace() {
                self.buffer.push_back(String::from(w));
            }
        }
        self.buffer.pop_front().unwrap().parse::<T>().ok().unwrap()
    }
}


Measured memory_bytes: 4352
#include "bits/stdc++.h"
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
#include <tuple>
using namespace std;

#define FOR(i,init,a) for(int i=init; i<a; i++)
#define rep(i,a) FOR(i,0,a)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define rep1(i,a) for(int i=1; i<=a; i++)
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define mem(a,n) memset( a, n, sizeof(a))
#define all(a) a.begin(),a.end()
#define chmin(a,b) a=min(a,b);
#define chmax(a,b) a=max(a,b);

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;
static const double pi = 3.141592653589793;

int H,W;
string s[51];
int dh[] = { -1, -1, 0, 1, 1, 1, 0, -1};
int dw[] = { 0, 1, 1, 1, 0, -1, -1, -1};

int calc(int h,int w){
    int res=0;
    rep(i,8){
        int hh=h+dh[i];
        int ww=w+dw[i];
        res+=(hh>=0&&hh<H&&ww>=0&&ww<W&&s[hh][ww]=='#');
    }
    return res;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    cin>>H>>W;
    rep(i,H) cin>>s[i];
    
    rep(i,H)rep(j,W){
        if(s[i][j]=='.'){
            int n=calc(i,j);
            s[i][j]='0'+n;
        }
    }
    rep(i,H){
        rep(j,W) cout<<s[i][j];
        cout<<endl;
    }
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

#define ld long double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

//-------------------------------------------------

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    using P = pair<double,double>;
    auto dist = [](P p1,P p2){
        double dx = (p1.fi-p2.fi);
        double dy = (p1.se-p2.se);
        return sqrt(dx*dx+dy*dy);
    };
    int n; cin>>n;
    vector<P> ps(n);
    rep(i,n){
        cin>>ps[i].fi>>ps[i].se;
    }
    auto f = [&](double x){
        double l=-1001, r=1001;
        rep(i,100){
            double c1=(l*2+r)/3;
            double c2=(l+r*2)/3;
            P p1(x,c1), p2(x,c2);
            double m1=0,m2=0;
            rep(i,n){
                m1=max(m1,dist(p1,ps[i]));
                m2=max(m2,dist(p2,ps[i]));
            }
            if (m1>m2) l=c1;
            else r=c2;
        }
        double ret=0;
        P cp(x,(l+r)/2);
        rep(i,n){
            ret=max(ret,dist(cp,ps[i]));
        }
        return ret;
    };
    double l=-1001, r=1001;
    rep(i,100){
        double c1=(l*2+r)/3;
        double c2=(l+r*2)/3;
        if (f(c1)>f(c2)) l = c1;
        else r = c2;
    }
    double ans=f((l+r)/2);
    cout<<setp(15)<<ans<<endl;
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <tuple>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <numeric>
#include <string.h>
#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define repn(i, x) for (int i = 1; i <= (int)(x); i++)
#define repr(i, x) for (int i = ((int)(x) - 1); i >= 0; i--)
#define reprn(i, x) for (int i = ((int)(x)); i > 0; i--)
#define all(x) (x).begin(),(x).end()
typedef long long int64;
using namespace std;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const long long INFL = 1e18;
const int MOD = 1000000007;
const int MAX = 210000;

int gcd(int a, int b) {
    return b != 0 ? gcd(b, a % b) : a;
}

//逆元を求める関数
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++) {
      fac[i] = fac[i-1] * i % MOD;
      inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
      finv[i] = finv[i-1] * inv[i] % MOD;
    }
}
//組み合わせ
long long COM (int n, int k) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD;
}

void solve() {
		int n, k, q; cin >> n >> k >> q;
		vector<int> a(q), ans(n), cnt(n);
		rep (i, q) cin >> a[i];
		rep (i, n) ans[i] = k;
		for (int i = 0; i < q; ++i) {
			int tmp; tmp = a[i] - 1;
			cnt[tmp]++;
		}
		rep (i, n) ans[i] = k + (-q + cnt[i]);
		auto f = [&](int num) {
			return num > 0 ? "Yes" : "No";
		};
		rep (i, n) cout << f(ans[i]) << endl;
    return;
}

int main() {
    solve();
    return 0;
}



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

const int N = 550000;

char a[N], b[N];

int f[N], g[N];

void KMP(char *P, int n) {
	f[1] = 0;
	for (int i = 1, j = 0; i < n; i++) {
		while (j && P[i] != P[j]) j = f[j];
		if (P[i] == P[j]) j++;
		f[i+1] = j;
	}
}

void kmp(char *P, int n) {
	g[1] = 0;
	for (int i = 1, j = 0; i < n; i++) {
		while (j && P[i] != P[j]) j = g[j];
		if (P[i] == P[j]) j++;
		g[i+1] = j;
	}
}

bool ok(int st, int en) {
	int len = en - st + 1;
	if (st == 0) {
		if (f[en + 1] == 0) return 1;
		if (len % (len - f[en + 1]) == 0) return 0;
		return 1;
	} else {
		if (g[en - st + 1] == 0) return 1;
		if (len % (len - g[en - st + 1]) == 0) return 0;
		return 1;
	}
	return 1;
}

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	cin >> a;
	int len = strlen(a);
	for (int i = 0; i < len; i++) b[i] = a[i];
	reverse(b, b + len);
	KMP(a, len); kmp(b, len);
	if (ok(0, len - 1)) {
		cout << "1\n1\n";
		return 0;
	}
	bool flg = 1;
	for (int i = 1; i < len; i++) if (a[i] != a[0]) flg = 0;
	if (flg) {
		cout << len << "\n1\n";
		return 0;
	}
	int ans = 0;
//	cerr << ok(0, 0) << endl; //" " << ok(1, 3) << endl;
	for (int i = 0; i < len - 1; i++) if (ok(0, i) && ok(i + 1, len - 1)) {
		ans++;
	}
	cout << 2 << endl << ans << endl;
	return 0;
}



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

using ll = long long;
using pp = pair<ll,ll>;
const ll amari = 1e9+7;
const char BC = 'A' - 'a';
#define ben(a) a.begin(),a.end()
#define pb(a,b) a.push_back(b)
//fixed << setprecision(20)

int main(){
	int a,b,c,d,e;
	string f,g,h,j,k;
	cin >> a;
	cout << a * a * a << endl;
	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
int n;
int a[100005];
long long ans;
int main() {
	scanf("%d", &n);
	int i;
	for (i = 1; i <= n; i++) scanf("%d", &a[i]);
	for (i = 1; i <= n; i++) {
		if (a[i] == 0) continue;
		a[i] += a[i - 1];
		ans+=a[i] / 2;
		a[i] %= 2;
	}
	printf("%lld", ans);
	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <cstdio>
#include <algorithm>
#include <cassert>
#include <utility>
#include <string>
#include <cmath>
#include <set>
#include <map>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; ++i)
typedef long long ll;
typedef pair<int,int> pii;
int main(){
    string S;
    string A="CODEFESTIVAL2016";
    cin >> S;
    int ans=0;
    rep(i,S.length()){
        if(S[i]!=A[i])ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
// by adiforluls
#pragma GCC optimize ("-O2")
#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;
#define FAST            ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define ll              long long
#define ld              long double
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define all(a)          (a).begin(),(a).end()
#define clz(a)          __builtin_clz(a) // count leading zeroes
#define ctz(a)          __builtin_ctz(a) // count trailing zeroes
#define popc(a)         __builtin_popcount(a) // count set bits (for ints only diff for ll)
#define rep(i,a,b)      for(ll i=a;i<b;i++)
#define rfor(i,a,b)     for(ll i=a; i>=b; i--)
#define debug(x)        cerr << #x << " = " << x << endl;
#define F               first
#define S               second
#define endl            '\n'
#define SIZE            1000005
#define deci(n)         cout<<fixed<<setprecision(n)
#define ordered_set     tree<pll, null_type,less<pll>, rb_tree_tag,tree_order_statistics_node_update>
// order_of_key(k)
// find_by_order(k)
const ld PI = acos(-1.0);
const int INF = 0x3f3f3f3f;
const ll lul2 = 998244353;
const ll lul = 1000000007;

void mod(ll &x)
{
    if(x>=lul) x-=lul;
    if(x<0) x+=lul;
}

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

ll expo(ll n, ll p)
{
    if(p == 0) return 1;
    ll x = expo((n*n)%lul, p/2)%lul;
    if(p&1) return (x*n)%lul;
    return x;
}
//---------------------------------------------------------------------

unordered_map<int,int> ma;
int MOD = 2019;
void solve()
{
    string s; cin>>s;
    reverse(all(s));
    int n = s.size(), ten = 1, sum = 0,ans = 0;
    ma[0] = 1;
    rep(i,0,n)
    {
        int dig = s[i] - '0';
        sum = (sum+dig*ten)%MOD;
        ans+=ma[sum];
        ma[sum]++;
        ten = (ten*10) % MOD;
    }
    cout<<ans;
}
int main()
{   
    FAST;
   //  #ifndef ONLINE_JUDGE
     // freopen("input.txt", "r", stdin);
     // freopen("output.txt", "w", stdout);
   //  #endif
    int t; t=1;
    rep(i,1,t+1){
        solve();
    }
    return 0;
}

Measured memory_bytes: 3792
#define _GLIBCXX_DEBUG
#include<algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<iostream>
#include<vector>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<string>
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define rep2(i,s,n) for(int i=s;i< (int)n; i++)
#define ll long long 
#define all(v) v.begin(),v.end()
using namespace std;
int main(){
  int n,k;
  cin >>n>>k;
  vector<vector<int>> vec(k);
  set<int> S;
  rep(i,k){
    int d;
    cin >>d;
    rep(j,d) {
      int a;
      cin >>a;
      S.insert(a);
    }
  }
  cout <<n-S.size()<<endl;
}

Measured memory_bytes: 3640
using System;
using System.Linq;

class Prog{
  static void Main(){
    string s = Console.ReadLine();
    int n = 1000;
    for(int i= 0;i<s.Length-2;i++){
      string k = s.Substring(i,3);
      int p = int.Parse(k);
      if(System.Math.Abs(p-753) < n){
        n = System.Math.Abs(p-753);
      }
    }
    Console.WriteLine(n);
  }
}

Measured memory_bytes: 11092
#include <iostream>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;

int main()
{
    string s;
    int len, l, r;
    cin >> s;
    len = s.length();
    l = -1;
    r = -1;
    if(len == 2){
        if(s[0] == s[1]){
            l = 1;
            r = 2;
        }
    }
    else {
        for(int i=0; i<len-2; ++i){
            if(s[i] == s[i+1] || s[i] == s[i+2] || s[i+1] == s[i+2]){
                l = i+1;
                r = i+3;
                break;
            }
        }
    }
    cout << l << " " << r << endl;
}


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

int main(){
    int n;
    cin >> n;
    vector<int> d(n);
    for (int i=0; i<n; i++){
        cin >> d.at(i);
    }
    int k=0;
    vector<int> t(n+1,0);
    t.at(0)=d.at(0);
    for (int j=0; j<n; j++){
            if (t.at(0) < d.at(j)){
                t.at(0)=d.at(j);
            }
    }
    for (;;){
        k++;
        for (int j=0; j<n; j++){
            if (t.at(k) < d.at(j) && d.at(j) < t.at(k-1)){
                t.at(k)=d.at(j);
            }
        }
        if (t.at(k)==0){
            break;
        }
    }
    cout << k<< endl;

}

Measured memory_bytes: 256
from collections import deque

INF = 1e9

def BFS(n, adj):
    d = [INF] * N
    d[0] = 0
    next_v = deque([0]) # ?¬??????????????????????
    
    while next_v:
        u = next_v.popleft()
        
        for v in adj[u]:
            if d[v] == INF:
                d[v] = d[u] + 1
                next_v.append(v)
    
    return d

N = int(input())
Adj = [None] * N

for i in range(N):
    u, k, *vertex = [int(i)-1 for i in input().split()]
    Adj[u] = vertex

distance = BFS(N, Adj)

for i, di in enumerate(distance, start = 1):
    if di == INF:
        print(i, -1)
    else:
        print(i, di)

Measured memory_bytes: 8048
def maximum_profit(n):
    maxv = min(n) - max(n)
    minv = n[0]
    for i in range(1, len(n)):
        maxv = n[i] - minv if maxv < n[i] - minv else maxv
        minv = n[i]        if minv > n[i]        else minv
    return maxv
if __name__ == '__main__':
    n = int(input())
    numbers = [int(input()) for i in range(0, n)]
    print(maximum_profit(numbers))



Measured memory_bytes: 13592
import std.stdio, std.string, std.algorithm, std.array, std.range, std.conv,
    std.typecons, std.math, std.container, std.format, std.traits;

/** Computes the value of a positive integer `x`, raised to the power `n`, modulo `m`.
 *
 *  Params:
 *      x = base
 *      n = exponent
 *      m = modulus
 *
 *  Returns:
 *      `x` to the power `n`, modulo `m`.
 *      The return type is the largest of `x`'s and `m`'s type.
 *
 * The function requires that all values have unsigned types.
 */
Unqual!(Largest!(F, H)) powmod(F, G, H)(F x, G n, H m)
        if (isUnsigned!F && isUnsigned!G && isUnsigned!H)
{
    import std.meta : AliasSeq;

    alias T = Unqual!(Largest!(F, H));
    static if (T.sizeof <= 4)
    {
        alias DoubleT = AliasSeq!(void, ushort, uint, void, ulong)[T.sizeof];
    }

    static T mulmod(T a, T b, T c)
    {
        static if (T.sizeof == 8)
        {
            static T addmod(T a, T b, T c)
            {
                b = c - b;
                if (a >= b)
                    return a - b;
                else
                    return c - b + a;
            }

            T result = 0, tmp;

            b %= c;
            while (a > 0)
            {
                if (a & 1)
                    result = addmod(result, b, c);

                a >>= 1;
                b = addmod(b, b, c);
            }

            return result;
        }
        else
        {
            DoubleT result = cast(DoubleT)(cast(DoubleT) a * cast(DoubleT) b);
            return result % c;
        }
    }

    T base = x, result = 1, modulus = m;
    Unqual!G exponent = n;

    while (exponent > 0)
    {
        if (exponent & 1)
            result = mulmod(result, base, modulus);

        base = mulmod(base, base, modulus);
        exponent >>= 1;
    }

    return result;
}

void main(string[] args)
{
    const MOD = cast(ulong)(1e9 + 7);
    long n = readln.strip.to!long;
    auto as = readln.split.to!(long[]);

    long ans = 0;
    foreach (i; 0 .. 60)
    {
        ulong[] cnt = [0, 0];
        foreach (j; 0 .. n)
        {
            cnt[(as[j] >> i) & 1]++;
        }

        ans = (ans + (cnt[0] * ((cnt[1] * powmod(2uL, cast(ulong) i, MOD)) % MOD)) % MOD) % MOD;
    }
    writeln(ans);
}


Measured memory_bytes: 18996
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define all(x) (x).begin (),(x).end()
#define pb push_back
#define mp make_pair
#define vi vector<ll>
#define pii pair<ll,ll>
#define vii vector<pii>
#define mi map<ll,ll>
#define endl "\n"
#define si set<ll>
#define rep(i,a,b) for(unsigned ll i=a;i<b;i++)
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define M 1000000007LL
vi r,g,b;
void solve()
{
    ll n,r=0,g=0,b=0; cin>>n;
    string s; cin>>s;
    rep(i,0,n)
    {
        if(s[i]=='R') r++;
        else if(s[i]=='G') g++;
        else b++;
    }
    ll ans = r*g*b;

    rep(i,0,n-2)
    {
        rep(j,i+1,n-1)
        {
            if(s[i]==s[j]) continue;

            ll k = 2*j-i;
            if(k>=n) continue;

            if(s[j]==s[k] || s[k]==s[i]) continue;

            ans--;
        }
    }
    cout<<ans;
}

int main()
{
    SPEED;
    ll t = 1;

   //cin>>t;

    while(t--) solve();

   return 0;
}


Measured memory_bytes: 3660
n = int(input())
w = list(map(int, input().split()))

count = 0
flg = True
for i in range(len(w)):
    weight = abs(sum(w[:i+1]) - sum(w[i+1:]))
    if flg:
        count = weight
        flg = False
        continue
    if weight < count:
        count = weight
        
print(count)

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

int main()
{
    int n;
    cin >> n;
    int ans = 0;
    int comb = -1;
    int preb = 0;
    for(int i = 0; i < n; ++i)
    {
        int t;
        cin >> t;
        if(preb < t)
        {
            comb = 0;
        }
        else
        {
            comb += 1;
            ans = max(ans, comb);
        }
        preb = t;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {
    public static void main(String args[]){
        Scanner scanner = new Scanner(System.in);
        
        while(true){
            int h = scanner.nextInt();
            int w = scanner.nextInt();
            
            if(h==0 && w ==0) break;
            
            for (int i=1;i<=h;i++) {
                for (int j=1;j<=w;j++) {
                    if(i%2 != 0 && j%2!=0) { 
                        System.out.print("#");
                    } else if(i%2 == 0 && j%2==0) { 
                        System.out.print("#");
                    } else {
                        System.out.print(".");
                    }
                }
                System.out.println("");
            }
            System.out.println("");
        }
    }
}


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

int main() {
    string s, t;
    cin >> s >> t;
    int n = s.size(), m = t.size();
    string ans = "";
    for (int i = n - m; i >= 0; i--) {
        bool flag = true;
        for (int j = 0; j < m; j++) {
            if (s[i + j] == t[j] || s[i + j] == '?') continue;
            flag = false;
        }
        if (flag) {
            for (int j = 0; j < m; j++) {
                s[i + j] = t[j];
            }
            ans = s;
            break;
        }
    }
    if (ans == "")
        cout << "UNRESTORABLE\n";
    else {
        for (char c : ans) {
            cout << (c == '?' ? 'a' : c);
        }
        cout << endl;
    }
}

Measured memory_bytes: 256
A, B, M = map(int, input().split())
*a, = map(int, input().split())
*b, = map(int, input().split())
a_s = sorted(a)
b_s = sorted(b)
min_v = a_s[0] + b_s[0]
for _ in range(M):
    x, y, c = map(int, input().split())
    min_v = min(min_v, a[x-1] + b[y-1] - c, )
print(min_v)

Measured memory_bytes: 18736