akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const int MOD = 998244353;
const int INF = 1000000000;
const ll LINF = 1ll<<50;
template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}
int main() {
  cin.tie(0);
  cout << fixed << setprecision(10);
  int n; cin >> n;
  string s; cin >> s;
  ll ans = 1;
  int r = 0, g = 0, b = 0;
  int mi = 0, mid = 0, ma = 0;
  for(int i=0;i<3*n;++i) {
    if(s[i] == 'R') {
      if(ma == r) {
      } else if(mid == r) {
        ans *= ma - mid;
        ans %= MOD;
      } else if(mi == r) {
        ans *= mid - mi;
        ans %= MOD;
      }
      r++;
    } else if(s[i] == 'G') {
      if(ma == g) {
      } else if(mid == g) {
        ans *= ma - mid;
        ans %= MOD;
      } else if(mi == g) {
        ans *= mid - mi;
        ans %= MOD;
      }
      g++;
    } else {
      if(ma == b) {
      } else if(mid == b) {
        ans *= ma - mid;
        ans %= MOD;
      } else if(mi == b) {
        ans *= mid - mi;
        ans %= MOD;
      }
      b++;
    }
    mi = min(r, min(g, b));
    ma = max(r, max(g, b));
    if(r != mi && r != ma) mid = r;
    else if(g != mi && g != ma) mid = g;
    else mid = b;
  }
  for(int i=1;i<=n;++i) {
    ans *= i;
    ans %= MOD;
  }
  cout << ans << endl;
}


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

using namespace std;

int main(){
  int N,K,i;
  cin >> N >> K;
  int p[N];
  for(i=0;i<N;i++){
    cin >> p[i];
  }
  
  sort(p,p+N);
  
  
  for(i=1;i<K;i++){
    p[0]=p[0]+p[i];
  }
  
  cout << p[0] << endl;
  return 0;
}

Measured memory_bytes: 3604
import java.util.Scanner;

public class Main {
	public static void main (String args[]) {
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		String stra = "";
		String strb = "";
		for(int i = 0; i < a; i++) {
			stra = stra + String.valueOf(b);
		}
		for(int i = 0; i < b; i++) {
			strb = strb + String.valueOf(a);
		}
		if(stra.compareTo(strb) <= 0) {
			System.out.println(stra);
		} else {
			System.out.println(strb);
		}
	}
}

Measured memory_bytes: 19668
n,w = map(int, input().split())
VW = [list(map(int, input().split())) for _ in range(n)]
DP = [[0]*(w+1) for _ in range(n+1)]

for n_i in range(1, n+1):
  for w_i in range(w+1):
    if w_i-VW[n_i-1][1]>=0:
      DP[n_i][w_i] = max(DP[n_i-1][w_i], DP[n_i-1][w_i-VW[n_i-1][1]]+VW[n_i-1][0])
    else:
      DP[n_i][w_i] = DP[n_i-1][w_i]
      
print(max(DP[-1]))


Measured memory_bytes: 25520
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <queue>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using namespace std;

template<class T>
constexpr T INF = ::numeric_limits<T>::max() / 32 * 15 + 208;

int main() {
    int n, x;
    cin >> n >> x;
    if(x == 1 || x == (2*n-1)) {
        cout << "No" << "\n";
        return 0;
    }
    cout << "Yes" << "\n";
    deque<int> Q;
    if(x == 2){
        Q.emplace_back(1);
        Q.emplace_back(2);
        Q.emplace_back(3);
        for (int i = 4; i <= 2*n-1; ++i) {
            if(i%2) Q.emplace_back(i);
            else Q.emplace_front(i);
        }
    }else if(x == 2*n-2){
        Q.emplace_back(2*n-1);
        Q.emplace_back(2*n-2);
        Q.emplace_back(2*n-3);
        for (int i = 2*n-4; i >= 1; --i) {
            if(i%2) Q.emplace_back(i);
            else Q.emplace_front(i);
        }
    }else {
        Q.emplace_back(x+2);
        Q.emplace_back(x-1);
        Q.emplace_back(x);
        Q.emplace_back(x+1);
        Q.emplace_back(x-2);
        int turn = 0;
        for (int i = 1; i < x-2; ++i) {
            if(turn%2) Q.emplace_back(i);
            else Q.emplace_front(i);
            turn++;
        }
        for (int i = x+3; i <= 2*n-1; ++i) {
            if(turn%2) Q.emplace_back(i);
            else Q.emplace_front(i);
            turn++;
        }
    }
    while(!Q.empty()){
        printf("%d\n", Q.front());
        Q.pop_front();
    }
    return 0;
}


Measured memory_bytes: 2304
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin>>s;
  int ans=s.size();
  for(int i=0;i<2;i++){
    int cnt =0;
    for(int j=0;j<s.size();j++){
      if(j%2==0&&s.at(j)!=(char)(i+'0'))cnt++;
      if(j%2==1&&s.at(j)==(char)(i+'0'))cnt++;
    }
    ans=min(ans,cnt);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3740
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static void Main()
    {
        Console.WriteLine(Solve());
        return;

    }

    public static string Solve()
    {
        int N = ReadInt();
        double sum = 0;
        for(int i=0;i<N;i++)
        {
            string[] input = Read().Split(' ');
            if(input[1] == "JPY")
            {
                sum += int.Parse(input[0]);
            }
            else
            {
                sum += double.Parse(input[0]) * 380000;
            }
        }
        return sum.ToString();
    }

    private static string Read() { return Console.ReadLine(); }
    private static int ReadInt() { return int.Parse(Read()); }
    private static long ReadLong() { return long.Parse(Read()); }
    private static double ReadDouble() { return double.Parse(Read()); }
    private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
    private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
    private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
}


Measured memory_bytes: 11092
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

int main()
{
    string s,t;
    cin >> s >> t;
    int a,b;
    cin >> a >> b;
    string u;
    cin >> u;
    if( u == s )
    {
        a = a - 1;
    }
    else{
        b = b - 1;
    }

    cout << a << " " << b << endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned ll
#define PI acos(-1)
#define vi vector<int>
#define pi pair<int, int>
#define pl pair<ll, ll>
template<typename T> using v2 = vector<vector<T>>;
template<typename T> using v3 = vector<vector<vector<T>>>;
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
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; }
const int MOD = 1e9 + 7;
const int INF = 1e9 + 200;
const ll INFLL = 2e18 + 200;

template<typename M>
class SegmentTree {
private:
    vector<M> data;
    const function<M(M, M)> merge;
    const M identity_element;
    size_t base_data_size;

    void data_size_calc_and_init(size_t N) {
        base_data_size = 1;
        while (base_data_size < N) base_data_size <<= 1;
        data = vector<M>(2 * base_data_size, identity_element);
    }

    void build() {
        for (size_t index = base_data_size - 1; index > 0; index--) {
            data[index] = merge(data[2 * index], data[2 * index + 1]);
        }
    }

public:
    explicit SegmentTree(size_t N, const function<M(M, M)> merge, const M identity_element) : merge(merge), identity_element(identity_element) {
        data_size_calc_and_init(N);
    }
    
    explicit SegmentTree(const vector<M> &init_data, const function<M(M, M)> merge, const M identity_element) : merge(merge), identity_element(identity_element) {
        data_size_calc_and_init(init_data.size());
        for (size_t index = 0; index < init_data.size(); index++) {
            data[base_data_size + index] = init_data[index];
        }
        build();
    }

    void update(size_t index, M value) {
        index += base_data_size;
        data[index] = value;
        while (index >>= 1) {
            data[index] = merge(data[2 * index], data[2 * index + 1]);
        }
    }

    // [left, right)
    M query(size_t left_index, size_t right_index) {
        M left = identity_element, right = identity_element;
        left_index += base_data_size;
        right_index += base_data_size;
        while (left_index < right_index) {
            if (left_index & 1) left = merge(left, data[left_index++]);
            if (right_index & 1) right = merge(data[--right_index], right);
            left_index >>= 1;
            right_index >>= 1;
        }
        return merge(left, right);
    }

    const M &operator[](const size_t index) {
        return data[index + base_data_size];
    }
};

int main() {
    const int MAX = 300050;
    int N, K;
    cin >> N >> K;
    auto merge = [](int a, int b) {
        return max(a, b);
    };
    SegmentTree<int> cnt(MAX, merge, 0);
    for (int i = 0; i < N; i++) {
        int A;
        cin >> A;
        int left = max(0, A - K);
        int right = min(MAX, A + K + 1);
        int tmp = cnt.query(left, right);
        cnt.update(A, tmp + 1);
    }
    cout << cnt.query(0, MAX) << endl;
}

Measured memory_bytes: 7488
#include <iostream>
using namespace std;
int w, h;
char cc,a[50][50];
bool flag[50][50];
int dd[5]={0,-1,0,1,0};
int dfs(int x,int y,char c){
	if (x<0||x>=w||y<0||y>= h||flag[x][y])return 0;
	if(a[x][y]==c)return (cc=c,0);
	if(a[x][y]!='.')return -1;
	flag[x][y]=1;
	int ret=1;
	for(int i=0;i<4;i++){
		int cs=dfs(x+dd[i],y+dd[i+1],c);
		if(cs==-1)ret=-1;
		if(ret>0)ret+=cs;
	}
	return ret;
}
int main(){
	while(cin>>w>>h,w){
		for(int i=0;i<h*w;i++){
			flag[i%w][i/w]=false;
			cin>>a[i%w][i/w];
		}
		char c[3]="BW";
		for(int k=0;k<2;k++){
			int r=0;
			for(int i=w*h;i--;)flag[i%w][i/w]=0;
			for(int i=0;i<w*h;i++){
				cc='N';
				int a=dfs(i%w,i/w,c[k]);
				r+=(a>0&&cc==c[k])?a:0;
			}
			cout<<r<<(k?"":" ");
		}
		cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 1276
#include <iostream>
#include <vector>
#include <algorithm>

struct TCard
{
    char Suit;
    int  Num;
    bool operator==(const TCard& C)const
    {
        return Suit == C.Suit && Num == C.Num;
    }
    bool operator <(const TCard& C)const
    {
      return Num < C.Num;
    }
    bool operator <=(const TCard& C)const
    {
        return Num <= C.Num;
    }
};
typedef std::vector<TCard> TList;

int partition(TList& A, int p, int r)
{
  int i = p - 1;
  for(int j = p; j < r; ++j){
    if(A[j] <= A[r]){
      i = i + 1;
      std::swap(A[i],A[j]);
    }
  }
  std::swap(A[i+1],A[r]);
  return i+1;
}

void quickSort(TList& A, int p, int r)
{
  if(p < r){
    int q = partition(A, p, r);
    quickSort(A, p, q-1);
    quickSort(A, q+1, r);
  }
}
TList Input()
{
    int Count;
    std::cin >> Count;
    TList List(Count);
    for(int i = 0; i < Count; ++i){
        std::cin >> List[i].Suit;
        std::cin >> List[i].Num;
    }
    return List;
}
void Output(const TList& List)
{
    TList::const_iterator It = List.begin();
    std::cout << It->Suit << " " << It->Num;
    for(++It; It != List.end(); ++It){
        std::cout << "\n" << It->Suit << " " << It->Num;
    }
    std::cout << std::endl;
}
void Check(const TList& List, const TList& Stable)
{
    if(std::equal(List.begin(), List.end(), Stable.begin())){
        std::cout << "Stable" << std::endl;
    }else{
        std::cout << "Not stable" << std::endl;
    }
}

int main()
{
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    const TList List = Input();
    TList StableList = List;
    std::stable_sort(StableList.begin(), StableList.end());

    TList QuickList = List;
    quickSort(QuickList, 0, QuickList.size() - 1);
    Check(QuickList, StableList);
    Output(QuickList);
    return 0;
}

Measured memory_bytes: 5260
#!/usr/bin/env python3
import numpy as np


N = int(input().strip())
x = [int(str) for str in input().strip().split()]

x = np.array(x)
odd = x[x % 2 == 0]

result = np.all((odd % 3 == 0) | (odd % 5 == 0))

print('APPROVED' if result else 'DENIED')


Measured memory_bytes: 12404
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
using namespace std;
const int MAXN = 1e6 + 5;
int a[MAXN],n;
long long ans;
int main() {
	scanf("%d",&n);
	for(int i = 1;i <= n;i ++) {
		scanf("%d",&a[i]);
		if(a[i] >= a[i - 1])
		continue;
		ans += a[i - 1] - a[i];
		a[i] = a[i - 1];
	}
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 2508
n = gets.to_i
a = gets.split(' ').map &:to_i
ar = a.map.with_index(1){|x,i| [i,x]}
ar.sort_by!{|k,v| v}
(0...n).each do |i|
  print "#{ar[i].first}"
  print ' ' if i != n-1
end

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

#define ln                '\n'
#define all(dat)           dat.begin(), dat.end()
#define loop(i, to)        for (int i = 0; i < to; ++i)
#define cont(i, to)        for (int i = 1; i <= to; ++i)
#define circ(i, fm, to)    for (int i = fm; i <= to; ++i)
#define foreach(i, dat)    for (__typeof(dat.begin()) i = dat.begin(); i != dat.end(); ++i)

typedef long long          num;

using namespace std;

const int nsz = 1e4, ksz = 1e2, mod = 1e9 + 7;
int n, k, dp[nsz + 5][ksz + 5][2];
string dat;

void inline upd(int &a, int b) {
    (a += b) && a >= mod && (a -= mod);
}

int inline modulo(int a) {
    return (a % mod + mod) % mod;
}

int main() {
    ios::sync_with_stdio(0);
    cin >> dat >> k;
    n = (int) dat.size();
    loop (d, dat[0] - 48) {
        upd(dp[1][d % k][0], 1);
    }
    dp[1][(dat[0] - 48) % k][1] = 1;
    circ (i, 1, n - 1) {
        loop (s, k) {
            loop (d, 10) {
                upd(dp[i + 1][(s + d) % k][0], dp[i][s][0]);
            }
            loop (d, dat[i] - 48) {
                upd(dp[i + 1][(s + d) % k][0], dp[i][s][1]);
            }
            upd(dp[i + 1][(s + dat[i] - 48) % k][1], dp[i][s][1]);
        }
    }
    cout << modulo(dp[n][0][0] + dp[n][0][1] - 1) << ln;
}

Measured memory_bytes: 8448
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		new Main().run();
	}

	void run() {
		Scanner sc = new Scanner(System.in);
		long[] L = new long[100];
		L[0] = 2;
		L[1] = 1;
		for (int i = 2; i < L.length; ++i) {
			L[i] = L[i - 1] + L[i - 2];
		}
		int N=sc.nextInt();
		System.out.println(L[N]);
	}

	void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}
}


Measured memory_bytes: 23508
import itertools
n = int(input())
point = []
a = [i for i in range(n)]
for i in range(n):
    x,y = map(int,input().split())
    point.append((x,y))
a = list(itertools.permutations(a,n))
length = 0
for i in range(len(a)):
    for j in range(n-1):
        cnt = (point[a[i][j]][0] - point[a[i][j+1]][0])**2\
        + (point[a[i][j]][1] - point[a[i][j+1]][1])**2
        cnt = cnt**0.5
        length += cnt
print(length / len(a))



Measured memory_bytes: 8180
using System;
using System.Linq;
using System.Collections.Generic;

namespace AtCoder.Beginner067
{
    public class ABC067A_SharingCookies
    {
        public static void Main(string[] args)
        {
            
            // 入力
            int[] nums = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();

            // 結果出力
            if( nums[0] % 3 == 0 || nums[1] % 3 == 0 || (nums[0] + nums[1]) % 3 == 0 )
            {
                Console.WriteLine("Possible");
            }
            else
            {
                Console.WriteLine("Impossible");
            }

        }
    }
}

Measured memory_bytes: 13396
#include <stdio.h>
int main(){
  double n,x,s;
  char u[4];
  for(scanf("%lf",&n);n;n--){
    scanf("%lf%s",&x,u);
    if(u[0]=='J')s+=x;
    else s+=380000*x;
  }
  printf("%f",s);
  return 0;
}

Measured memory_bytes: 128
void insertionSort(int A[], const int N)
{
    int i, j;

    for( i = 0; i < N; ++i ){
        int tmp = A[i];
        for( j = i-1; -1 < j && tmp < A[j]; --j ){
            A[j+1] = A[j];
        }
        A[j+1] = tmp;

        //出力
        for( j = 0; j < N; ++j ){
            printf("%d", A[j]);
            if( j != N-1 ) printf(" ");
        }
        printf("\n");
    }
}

int main()
{
    int i;

    //入力
    int N;
    scanf("%d", &N);
    int A[N];
    for( i = 0; i < N; ++i )
        scanf("%d", &A[i]);

    insertionSort(A, N);

    return 0;
}


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

/*
struct Edge
{
    int to;
    int weight;
    Edge(int t, int w) : to(t), weight(w) {}
};
using Graph = vector<vector<Edge>>;
*/

using Graph = vector<vector<int>>;

const long long INF = 1LL << 60;
const int INT_INF = 1000000000;

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

// 辺を表す構造体
struct edge
{
    int from, to;
    long long cost;
};

// v:=頂点数 es:=辺の集合 cost:=始点からの最短経路のコストを格納する配列
// s:=始点(指定しなければ頂点0) g:=終点(指定しなければ頂点v-1)
// 始点から到達可能で、かつ終点へ到達可能な負閉路が検出された場合falseを、それ以外の場合trueを返す
bool bellman_ford(int v, const vector<edge> &es, vector<ll> &dist, int s = 0, int g = -1)
{
    if (g == -1)
    {
        g = v - 1;
    }

    dist.assign(v, INF);
    dist[s] = 0;

    for (int i = 0; i < v * 2; ++i)
    {
        for (auto &e : es)
        {
            if (dist[e.from] < INF && dist[e.from] + e.cost < dist[e.to])
            {
                if (i >= v - 1 && e.to == g)
                {
                    return false;
                }
                else if (i >= v - 1)
                {
                    dist[e.to] = -INF;
                }
                else
                {
                    dist[e.to] = dist[e.from] + e.cost;
                }
            }
        }
    }

    return true;
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N, M;
    cin >> N >> M;
    vector<edge> es;
    for (int i = 0; i < M; i++)
    {
        int a, b, c;
        cin >> a >> b >> c;
        a--, b--;
        edge e = {a, b, -c};
        es.push_back(e);
    }

    vector<ll> dist(N);

    if (!bellman_ford(N, es, dist, 0, N - 1))
        cout << "inf" << endl;
    else
    {
        cout << -dist[N - 1] << endl;
    }
    return 0;
}

// 頂点1から到達できる負閉路であっても，その閉路から頂点Nへと至ることが出来ない:検出されるけど無視しなければならない．->通常のBellmanfordでは負閉路ありとして検出してしまう．
// N回目の更新で更新された箇所に-INFを入れておいて更に追加でN回伝播する．


Measured memory_bytes: 3708
#include<stdio.h>
#include<stdlib.h>
#include<string>
#include<iostream>

using namespace std;

struct Node {
  int key;
  Node *right, *left, *parent;
};

Node *root, *NIL;

Node *treeMinimum(Node *x) {
  while(x->left != NIL) x = x->left;
  return x;
}

Node *find(Node *u, int k) {
  while(u != NIL && k != u->key) {
    if(u->key > k) u = u->left;
    else u = u->right;
  }
  return u;
}

void treeDelete(Node *z) {
  Node *y;
  Node *x;

  if(z->left == NIL || z->right == NIL) y = z;
  else {
    y = treeMinimum(z->right);
  }

  if(y->left != NIL) {
    x = y->left;
  } else {
    x = y->right;
  }

  if(x != NIL) {
    x->parent = y->parent;
  }

  if(y->parent == NIL) {
    root = x;
  } else {
    if(y == y->parent->left) {
      y->parent->left = x;
    } else {
      y->parent->right = x;
    }
  }

  if(y != z) {
    z->key = y->key;
  }

  free(y);
}

void insert(int k) {
  Node *y = NIL;
  Node *x = root;
  Node *z;

  z = (Node *)malloc(sizeof(Node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x != NIL) {
    y = x;
    if(z->key < x->key) {
      x = x->left;
    } else {
      x = x->right;
    }
  }
  z->parent = y;

  if(y == NIL) {
    root = z;
  } else {
    if(z->key < y->key) {
      y->left = z;
    } else {
      y->right = z;
    }
  }
}

void inorder(Node *u) {
  if(u == NIL) return;
  inorder(u->left);
  printf(" %d", u->key);
  inorder(u->right);
}

void preorder(Node *u) {
  if(u == NIL) return;
  printf(" %d", u->key);
  preorder(u->left);
  preorder(u->right);
}

int main() {
  int n, i, x;
  string com;

  scanf("%d", &n);

  for(i = 0; i < n; i++) {
    cin >> com;
    if(com == "find") {
      scanf("%d", &x);
      Node *t = find(root, x);
      if(t != NIL) printf("yes\n");
      else printf("no\n");
    } else if(com == "insert") {
      scanf("%d", &x);
      insert(x);
    } else if(com == "print") {
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if(com == "delete") {
      scanf("%d", &x);
      treeDelete(find(root, x));
    }
  }

  return 0;
}



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


class Main {

    public static void main(String[] args) throws IOException {

        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));

        String s;
        s=reader.readLine();

        String[] inp = s.split(" ");

        int a,b,c;

        a=Integer.parseInt(inp[0]);
        b=Integer.parseInt(inp[1]);
        c=Integer.parseInt(inp[2]);

        if(a+b>=c)
            System.out.println("Yes");
        else
            System.out.println("No");

    }

}


Measured memory_bytes: 21204
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>

using namespace std;
#define int long long int
const int INF = 1001001001001001LL;
const int MOD = 1000000007;

int di[] = {-1, 0, 1, 0, -1, 1, 1, -1};
int dj[] = {0, 1, 0, -1, 1, 1, -1, -1};

signed main(){
    
    int n, l; cin >> n >> l;
    int ans = INF;
    vector<int> a(n);
    int sum = 0;
    for(int i = 1; i <= n; i++){
        a[i - 1] = i + l - 1;
        sum += a[i - 1];
    }
    int hoge;
    for(int i = 0; i < n; i++){
        if(ans > (int)abs(a[i])){
            ans = (int)abs(a[i]);
            hoge = i;
        };
    }
    cout << sum - a[hoge] << endl;
    return 0;
}


Measured memory_bytes: 256
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.math,
    std.functional, std.numeric, std.range, std.stdio, std.string, std.random,
    std.typecons, std.container, std.format;

// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] aryread(T = long)(){return readln.split.to!(T[])();}
void scan(TList...)(ref TList Args){auto line = readln.split();
foreach (i, T; TList){T val = line[i].to!(T);Args[i] = val;}}
alias sread = () => readln.chomp();enum MOD = 10 ^^ 9 + 7;
alias PQueue(T, alias less = "a<b") = BinaryHeap!(Array!T, less);
// dfmt on

void main()
{
    long N, K;
    scan(N, K);
    long v = min(K, N - 1);
    long ans;
    auto c = Combination_mod(10 ^^ 6);
    // n個の中から重複ありでk個選ぶ
    long h(long n, long k)
    {
        return c(n + k - 1, n - 1);
    }

    // xは0人の部屋の数
    foreach (x; 0 .. v + 1)
    {
        // c(N, x): 0人の部屋を選ぶ
        // h(N-x, x): 0人になった部屋から移動した人の移動先を選ぶ
        ans = (ans + (c(N, x) * h(N - x, x) % MOD)) % MOD;
    }
    writeln(ans);
}

/// Number of k-combinations % m (precalculated)
alias Combination_mod = Combination_modImpl!long;
struct Combination_modImpl(T)
{
    T _n, _m;
    T[] _fact, _factinv;
    this(T maxnum, T mod = 10 ^^ 9 + 7)
    {
        _n = maxnum, _m = mod, _fact = new T[](_n + 1), _factinv = new T[](_n + 1), _fact[0] = 1;
        foreach (i; 1 .. _n + 1)
            _fact[i] = _fact[i - 1] * i % _m;
        T powmod(T x, T n, T m)
        {
            if (n < 1)
                return 1;
            if (n & 1)
            {
                return x * powmod(x, n - 1, m) % m;
            }
            T tmp = powmod(x, n / 2, m);
            return tmp * tmp % m;
        }

        foreach (i; 0 .. _n + 1)
            _factinv[i] = powmod(_fact[i], _m - 2, _m);
    }

    T opCall(T n, T k, T dummy = 10 ^^ 9 + 7)
    {
        return n < k ? 0 : ((_fact[n] * _factinv[n - k] % _m) * _factinv[k] % _m);
    }
}


Measured memory_bytes: 19580
#include <bits/stdc++.h>
        using namespace std;
   #define int long long
const int MAX = 510000;
const int MOD = 1000000007;


     signed main(){
         cout << std::fixed << std::setprecision(15);
int n,k;
cin>>n>>k;
int a[n],mina=0;
for(int i=0;i<n;i++)cin>>a[i];
for(int i=0;i<n;i++)mina=min(mina,a[i]);
int b[n];
int t=0;
while(mina<n&&t<k){
     fill(b,b+n,0);
     for(int i=0;i<n;i++){
          b[max(0ll,i-a[i])]++;
          if(i+a[i]+1<n)b[i+a[i]+1]--;
     }
     mina=b[0];
     for(int i=1;i<n;i++){b[i]+=b[i-1];mina=min(mina,b[i]);}
 for(int i=0;i<n;i++)swap(a[i],b[i]);
     t++;

}
if(t<k){
     for(int i=0;i<n;i++)cout<<n<<' ';
     cout<<endl;
     
}else{
     for(int i=0;i<n;i++)cout<<a[i]<<' ';
     cout<<endl;
}
     }

 


 






    





      

        


Measured memory_bytes: 6752
#include<stdio.h>
int p_tax, a_tax, price, max, search_cnt;

int MAX(int a, int b)
{
    return (a > b) ? a : b;
}

int tax_calcurate(int tax, int left, int right)
{
    return left * (100 + tax) / 100 + right * (100 + tax) / 100;
}

void Max_Search(int left, int right)
{
    int tmp = 0, p_price;
    if( left <= right ){
        p_price = tax_calcurate(p_tax, left, right);
        if(  p_price == price ) tmp = tax_calcurate( a_tax, left, right );
        max = MAX( max, tmp);

        if(( p_price == price && search_cnt <= price / 2) ||( p_price < price && search_cnt <= price / 2)) Max_Search( search_cnt++, price );
        else Max_Search( left, right - 1);
    }
}

int main()
{
    while(1){
        scanf("%d %d %d", &p_tax, &a_tax, &price);
        max = search_cnt = 1;

        if( p_tax == 0 && a_tax == 0 && price == 0 ) break;
        Max_Search(search_cnt, price);
        printf("%d\n", max);

    }
    return 0;
}

Measured memory_bytes: 2572
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<cstdlib>
#include<tuple>
#include<iomanip>
#include<map>
#define int long long 
using namespace std;

signed main() {
	int a1,a2,a3,b1,b2,b3,c1,c2,c3;
	cin >> a1 >> a2 >> a3 >> b1 >> b2 >> b3 >> c1 >> c2 >> c3;
	if(a2 - a1 == b2 - b1 && b2 - b1 == c2 - c1 && a3 - a2 == b3 - b2 && b3 - b2 == a3 - a2 && b1 - a1 == b2 - a2 && b2 - a2 == b3 - a3 && c1 - b1 == c2 - b2 && c2 - b2 == c3 - b3) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<queue>
#include<vector>
using namespace std;
#define REP(i, b, e) for ( int i = b; i < (int)e; i++ )
#define rep(i, n) REP(i, 0, n)
static const int MAX = 10000;

pair<int, int> P[MAX];
vector<pair<int, double> > G[MAX];
int N, M;

double getDist(double x1, double y1, double x2, double y2){
  return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));
}

double prim(){
  double sum = 0.0;
  priority_queue<pair<double, int> > PQ;
  bool V[MAX];
  rep(i, N) V[i] = false;

  rep(s, N){
    if ( V[s] ) continue;
    PQ.push(make_pair(0, s));
    pair<double, int> u;
    while( !PQ.empty() ){
      u = PQ.top(); PQ.pop();
      if ( V[u.second] ) continue;
      V[u.second] = true;
      sum += u.first;
      rep(i, G[u.second].size()){
	int v = G[u.second][i].first;
	double c = G[u.second][i].second;
	if ( V[v] ) continue;
	PQ.push(make_pair(c, v));
      }
    }
  }
  return sum;
}

main(){
  int s, t;
  double sum = 0;
  cin >> N >> M;
  rep(i, N) cin >> P[i].first >> P[i].second;
  rep(i, N) G[i].clear();
  rep(i, M){
    cin >> s >> t;
    s--; t--;
    double d = getDist(P[s].first, P[s].second, P[t].first, P[t].second);
    sum += d;
    G[s].push_back(make_pair(t, d));
    G[t].push_back(make_pair(s, d));
  }
  printf("%.8lf\n", sum - prim());
}

Measured memory_bytes: 0
#include <iostream>
#include <map>

using namespace std;

int main()
{
    int n;
    cin >> n;
    std::map<int, int> a;
    for(int i=0; i<n; i++)
    {
        int tmp;
        cin >> tmp;
        a[tmp] = i+1;
    }
    
    std::map<int, int>::iterator itr = a.begin();
    while(itr != a.end())
    {
        cout << itr->second << " ";
        ++itr;
    }
    cout << endl; 
    
    return 0;
}

Measured memory_bytes: 5504
from collections import Counter
from itertools import accumulate


def counting_sort(A, k):
    counter = Counter(A)
    B = [0]*(len(A)+1)
    C = list(accumulate((counter[i] for i in range(k+1))))
    for n in A[::-1]:
        B[C[n]] = n
        C[n] -= 1

    return B[1:]


if __name__ == "__main__":
    input()
    a = list(map(int, input().split()))
    print(*counting_sort(a, 10000))


Measured memory_bytes: 231376
#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() {
		string s; cin >> s;
		int len = s.size();
		vector<int> ans(len);
		for (int i = 0; i < 2; ++i) {
			int cnt = 0;
			for (int j = 0; j < len; ++j) {
				//Lに到達するまでのRの数をカウントする
				if (s[j] == 'R') {
					cnt++;
				} else {
					//偶数番目のRはLに振り分けられる
					ans[j] += cnt / 2;
					//帰趨番目のRはRに振り分けられる
					ans[j - 1] += (cnt + 1) / 2;
					cnt = 0;
				}
			}
			//Rを末尾までカウントしてからリバース
			reverse(all(s));
			reverse(all(ans));
			//LをRへ変換して処理する
			rep (j, len) {
				if (s[j] == 'L') s[j] = 'R';
				else s[j] = 'L';
			}
		}
		rep (i, len) {
			cout << ans[i] << endl;
		}
    return;
}

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



Measured memory_bytes: 1024
import java.util.*;
import java.io.*;

public class Main {	

	private static void solve(){
		//Implement solution here.
		int[] x = na(5);
		for(int i = 0; i < 5; i++) {
			if(x[i] == 0) {
				System.out.println(i + 1);
				return;
			}
		}
	}

	//Switch input source (stdin/file)
	private static BufferedReader br;
	public static void main(String[] args){
		br = new BufferedReader(new InputStreamReader(System.in));
		String debugDataPath = System.getenv("DD_PATH");        
		if(debugDataPath != null){
			try{
				br = new BufferedReader(new InputStreamReader(new FileInputStream(new File(debugDataPath))));
			}catch(Exception e){
				throw new RuntimeException(e);
			}
		}
		boolean hasNext = true;
		while(hasNext){
			solve();	
			try{
				br.mark(1);
				if(br.read() > 0){
					br.reset();			
					System.out.println("---");
				} else {
					hasNext = false;
				}
			}catch(Exception e){
				throw new RuntimeException(e);
			} 
		}
	}

	//Input read utility
	private static StringTokenizer tokenizer = null;
	public static String next() {
		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(br.readLine());
			} catch (Exception e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}
	//Get next single int
	private static int ni() {
		return Integer.parseInt(next());
	}
	//Get next single long
	private static long nl() {
		return Long.parseLong(next());
	}
	//Get next single double
	private static double nd() {
		return Double.parseDouble(next());
	}
	//Get next int array from one line
	private static int[] na(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = ni();
		return a;
	}
	//Get next char array from one line
	private static char[] ns() {
		return next().toCharArray();
	}
	//Get next long array from one line
	private static long[] nal(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nl();
		return a;
	}
}


Measured memory_bytes: 25328
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
using namespace std;
typedef long long ll;
const int INF=1001001001;
int main(){
  int r;
  cin>>r;
  int ans=r*r;
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
h,w,n = map(int,input().split())
sr,sc = map(int,input().split())
sr -=1
sc -=1
s = input()
t = input()
p1,p2 = sr,sr
p3,p4 = sc,sc
for i in range(n):
    if s[i] == "U":
        p1 -=1
        if p1 < 0:
            print("NO")
            exit()
    if t[i] == "D" and p1 < h-1:
        p1 += 1
for i in range(n):
    if s[i] == "D":
        p2 +=1
        if p2 >= h:
            print("NO")
            exit()
    if t[i] == "U" and p2 >0:
        p2 -= 1
for i in range(n):
    if s[i] == "R":
        p3 +=1
        if p3 >= w:
            print("NO")
            exit()
    if t[i] == "L" and p3 >0:
        p3 -= 1
for i in range(n):
    if s[i] == "L":
        p4 -=1
        if p4 < 0:
            print("NO")
            exit()
    if t[i] == "R" and p4 < h-1:
        p4 += 1
print("YES")

Measured memory_bytes: 43700
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;
 
static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
static const ll INF = 1023456789;
 
#define REP(i,n)	for(int i=0;i<n;++i)
#define REPR(i,n)	for(int i=n-1;i>=0;--i)
#define FOR(i,s,n)	for(int i=s;i<n;++i)
#define FORR(i,s,n)	for(int i=n-1;i>=s;--i)
#define ALL(c)		(c).begin(),(c).end()
#define CLEAR(v)	memset(v,0,sizeof(v))
#define MP(a,b)		make_pair((a),(b))
#define ABS(a)		((a)>0?(a):-(a))
#define F			first
#define S			second

int h, w;
char s[52][52];
int ar8[9] = { 0, 1, -1, -1, 0, -1, 1, 1, 0 };
 
int main(int argc, char **argv) {
	cin >> h >> w;
	REP(y, h) REP(x, w) cin >> s[x + 1][y + 1];
	FOR(y, 1, h + 1) FOR(x, 1, w + 1) if (s[x][y] == '.') {
		s[x][y] = '0';
		REP(i, 8) if (s[x + ar8[i]][y + ar8[i + 1]] == '#') ++s[x][y];
	}
	REP(y, h) {
		REP(x, w) cout << s[x + 1][y + 1];
		cout << endl;
	}
	return 0;
}
 

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
Created on Thu Mar 12 01:53:56 2020

@author: Kanaru Sato
"""

s = input()
hag = 0

for i in range(len(s)//2):
    if s[i] != s[len(s)-i-1]:
        hag += 1


print(hag)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define prtd(var, i) cout << fixed << setprecision(i) << var << endl;
#define ll long long
using namespace std;

int main(){
    int l, r, d, cnt = 0;
    cin >> l >> r >> d;
    for(int i = l; i <= r; i++){
        if(i%d==0)cnt++;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define int long long
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)
#define INF LLONG_MAX/3
#define eps LDBL_EPSILON
#define moder 1000000007
#define pie 3.141592653589793238462643383279
#define P std::pair<int,int>
#define prique priority_queue
using namespace std;
int a,b,q,s[100010],t[100010],x;
signed main(){
	cin>>a>>b>>q;
	s[a]=-INF,s[a+1]=INF;
	t[b]=-INF,t[b+1]=INF;
	rep(i,a)cin>>s[i];
	rep(i,b)cin>>t[i];
	sort(s,s+a+2);
	sort(t,t+b+2);
	rep(i,q){
		cin>>x;
		int ans=INF;
		ans=min(ans,abs(x-*lower_bound(t+1,t+b+1,*lower_bound(s+1,s+a+1,x))));
		ans=min(ans,abs(x-*lower_bound(s+1,s+a+1,*lower_bound(t+1,t+b+1,x))));
		ans=min(ans,abs(x-*(lower_bound(t+1,t+b+1,*(lower_bound(s+1,s+a+1,x)-1))-1)));
		ans=min(ans,abs(x-*(lower_bound(s+1,s+a+1,*(lower_bound(t+1,t+b+1,x)-1))-1)));
		ans=min(ans,min(abs(x-*lower_bound(t+1,t+b+1,x)),abs(x-*(lower_bound(s+1,s+a+1,x)-1)))*2+max(abs(x-*lower_bound(t+1,t+b+1,x)),abs(x-*(lower_bound(s+1,s+a+1,x)-1))));
		ans=min(ans,min(abs(x-*lower_bound(s+1,s+a+1,x)),abs(x-*(lower_bound(t+1,t+b+1,x)-1)))*2+max(abs(x-*lower_bound(s+1,s+a+1,x)),abs(x-*(lower_bound(t+1,t+b+1,x)-1))));
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 2816
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int num = sc.nextInt();
		int a[][] = new int[2][3];
		for(int i = 0; i < 2; i ++) {
			for(int j = 0; j < 3; j ++) {
				a[i][j] = sc.nextInt();
			}
		}

		int dp[] = new int[num + 1];
		int weight[] = a[0];
		int value[] = a[1];
		dp[0] = 0;
		for(int i = 1; i <= num; i ++) {
			dp[i] = dp[i - 1] + 1;
			for(int j = 0; j < 3; j ++) {
				if(i >= weight[j]) {
					dp[i] = Math.max(dp[i], dp[i - weight[j]] + value[j]);
				}
			}
		}
		long dp2[] = new long[dp[num] + 1];
		weight = a[1];
		value = a[0];
		dp2[0] = 0;
		for(int i = 1; i <= dp[num]; i ++) {
			dp2[i] = dp2[i - 1] + 1;
			for(int j = 0; j < 3; j ++) {
				if(i >= weight[j]) {
					dp2[i] = Math.max(dp2[i], dp2[i - weight[j]] + value[j]);
				}
			}
		}

		System.out.println(dp2[dp[num]]);
	}
}

Measured memory_bytes: 217300
#include <stdio.h>

int main(void){

	int word[26];				/* ????????????26??§????????´??°?????????????????????????????¨?????? */
	char x;

	for(x=0; x<26; x++){
		word[x]=0;
	}

	while(!feof(stdin)){
		x = fgetc(stdin);
		if('a'<=x && x<='z'){	/* ????????§x?????¢???????????????????????????????????? */
			x-='a'-'A';			/* ??£?¶?????????¢?????????????????????????????????????????????????????§????????????'A'???????????????????????????????????? */
		}
		if('A'<=x && x<='Z'){
			word[x-'A']++;
		}
	}

	for(x=0; x<26; x++){
		printf("%c : %d\n", 'a'+x, word[x]);
	}							/* ?????¢??????????????????????????°?????¨??? */

	return 0;
}

Measured memory_bytes: 524
import java.util.HashMap;
import java.util.Scanner;

public class Main{ 
	public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)) {
			
			while(sc.hasNext()) {
				HashMap<String,Integer> hm = new HashMap<>();
				int n = sc.nextInt();
				for(int i=0;i<n;i++) {
					hm.put(sc.next(), 0);
				}
				int m= sc.nextInt();
				int open=0;
				for(int i=0;i<m;i++) {
					String str = sc.next();
					if(!hm.containsKey(str))
						System.out.println("Unknown "+str);
					else {
						if(open==0) {
							System.out.println("Opened by "+str);
							open=1;
						}
						else {
							System.out.println("Closed by "+str);
							open=0;
						}
					}
				}
				
			}
		}
	}
}



Measured memory_bytes: 28576
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define REVERSE(a) reverse(a.begin(), a.end())
#define int long long
#define INF 1000000000000000
using namespace std;

typedef vector<int> vec;
typedef vector<vec> mat;
typedef pair<int, int> Pii;

template<typename T>
void readvec(vector<T> &a);
void readindex(vector<int> &a);



signed main(){

    int N, P; cin >> N >> P;
    vec A(N); readvec(A);

    int ans[2] = {1, 0};
    REP(i, N){
        if(A[i] % 2 == 0){
            ans[0] *= 2;
            ans[1] *= 2;
        }else{
            int a = ans[0];
            ans[0] += ans[1];
            ans[1] += a;
        }
    }

    cout << ans[P];
    
    return 0;
}


template<typename T>
void readvec(vector<T> &a){
    REP(i, a.size()){
        cin >> a[i];
    }
}
void readindex(vector<int> &a){
    REP(i, a.size()){
        cin >> a[i];
        a[i]--;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define pi acos(-1)
#define MAXN 1000010
#define inf 0x3f3f3f3f
using namespace std;
typedef pair<int,int>P;
bool prime[MAXN];
int cnt[MAXN];
void init()
{
	memset(prime, true, sizeof(prime));
	prime[1] = false;
	for(int i = 2; i < MAXN; i++)
	{
		if(prime[i])
		for(int j = i * 2; j < MAXN; j += i)
		prime[j] = false;
	}
	for(int i = 1; i < MAXN; i++)
	if(prime[i])
	cnt[i] = cnt[i - 1] + 1;
	else
	cnt[i] = cnt[i - 1];
}
int main()
{
	int n;
	init(); 
	while( cin >> n)
	{
		cout << cnt[n] << endl;
	}
    return 0;
}

Measured memory_bytes: 7940
use std::collections::HashSet;

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}

#[allow(dead_code)]
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

fn main() {
    let n = read::<i32>();
    let mut v = Vec::new();
    for _ in 1..n+1 {
        let d = read::<i32>();
        v.push(d);
    }

    let hs = v.into_iter().map(|i| i).collect::<HashSet<i32>>();
    let count = hs.len();
    println!("{}", count);
}


Measured memory_bytes: 4352
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<queue>
typedef long long ll;
using namespace std;
const int N=1e5+5;
ll read(){
	ll x=0,w=1;
	char ch=0;
	while (ch<'0' || ch>'9'){
		  if (ch=='-') w=-1;
		  ch=getchar();
	}
	while (ch<='9' && ch>='0'){
		  x=(x<<1)+(x<<3)+ch-'0';
		  ch=getchar();
	}
	return x*w;
}
ll cnt[2],n,k;
ll ans=0;
int main(){
	n=read();k=read();
	cnt[0]=n/k;
	if (!(k&1)) cnt[1]=n/(k>>1)-cnt[0];
	ans=(cnt[0]*cnt[0]*cnt[0])+(cnt[1]*cnt[1]*cnt[1]);
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 128
import sys
import itertools
if sys.platform =='ios':
    sys.stdin=open('input_file.txt')
    
N=int(input())
A=list(map(int,input().split()))

l=[0]*(N+1)
cnt=0

for i in A:
		l[i]+=1
		
for j in l:
		cnt+=(j*(j-1))//2

for k in range(N):
	print(cnt-l[A[k]]+1)

Measured memory_bytes: 26140
#include<bits/stdc++.h>
#define pb push_back
#define all(x) (x).begin(),(x).end()
using namespace  std ;
typedef long l ;
typedef long long ll ;
typedef vector<int>vi ;
typedef vector<l>vl ;
typedef vector<ll>vll ;
typedef vector<vector<ll> >vvl ;
typedef pair<int,int> pii ;
typedef pair<ll,ll> pll ;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    std::cout.unsetf ( std::ios::floatfield );//this and next line for floating precision upto 6
    std::cout.precision(10);
    ll a,b,c,d,e,x,i,j,n,t,m,k,y;
    double p,q,r,w,u ;
    string str = "",str1 = "" ;
    ll a1,a2,b1,b2 ;
    cin>>n>>m>>c ;
    vll vb ;
    for(i=0 ; i<m ; i=i+1)
    {
        cin>>a ;
        vb.pb(a) ;
    }
    k = 0 ;
    for(i=0 ; i<n ; i=i+1)
    {
        d = c ;
        for(j=0 ; j<m ; j=j+1)
        {
            cin>>a ;
            d = d + vb[j]*a ;
        }
        if(d>0)
        {
            k++ ;
        }
    }
    cout<<k ;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(void)
{
    IOS
    int n, k;
    cin >> n >> k;
    int ans = n % k == 0 ? 0 : 1;
    cout << ans << '\n';


    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip> // << fixed << precision(10)
#include <vector>
#include <string>
#include <map>
#include <set>
#include <cmath>
#include <algorithm>
using namespace std;

#define FOR(i,s,t) for(int i=s;i<t;i++)
#define REP(i,n) FOR(i,0,n)
#define PRINT(s) cout << s << "\n"
#define SORT(A) sort(A.begin(), A.end())
#define EACHPRINT(A, T) for_each(begin(A), end(A), [&](T i){ cout << i << " "; });cout << "\n"
#define NEWMAT(N, M, ini) MAT(N, vector<lint>(M, ini))
#define MOD 1000000007

typedef long long lint;
typedef pair<lint, lint> P;
typedef vector<lint> V;
typedef vector<vector<lint>> MAT;
bool lessPair(const P& l, const P& r){return l.second < r.second;}

struct UnionFind {
  vector<lint> par;

  UnionFind(int N) : par(N) {
    for(int i = 0; i < N; i++) {
      par[i] = i;
    }
  }
  
  int root(lint x) {
    if (par[x] == x) return x;
    return par[x] = root(par[x]);
  }

  void unite(lint x, lint y) {
    lint rx = root(x);
    lint ry = root(y);
    if (rx == ry) return;
    par[rx] = ry;
  }

  bool same(lint x, lint y) {
    lint rx = root(x);
    lint ry = root(y);
    return rx == ry;
  }
};


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    lint N; cin >> N;
    lint M; cin >> M;

    UnionFind uni = UnionFind(N);

    V X(N);
    REP(i, M) {
      lint x; cin >> x;
      lint y; cin >> y;
      lint z; cin >> z;
      uni.unite(x-1, y-1);
    }

    set<lint> s;

    REP(i, N) {
      s.insert(uni.root(i));
    }    

    lint res = s.size();
    cout << res << "\n";

    return 0;
}


Measured memory_bytes: 6528
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<string>
#include<iostream>
#include<cctype>
#include<cstdio>
#include<vector>
#include<stack>
#include<queue>
#include <algorithm>
#include<math.h>
#include<set>
#include<map>
#include<iomanip>

//#include<bits/stdc++.h>

using namespace std;


int main() {

	
	string p;
	cin >> p;
	sort(p.begin(), p.end());
	char ans = 'a';
	for (int i = 0; i < p.size(); i++) {
		if (ans >= p[i])ans = p[i] + 1;
	}
	if (ans > 'z')cout << "None" << endl;
	else cout << ans << endl;
	return 0;
	
}


Measured memory_bytes: 512
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace D
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = RInt();

            Dictionary<int, List<int>> tree = new Dictionary<int, List<int>>();
            for (int i = 0; i < n; i++)
            {
                tree.Add(i, new List<int>());
            }
            for (int i = 0; i < n - 1; i++)
            {
                int[] vs = RArInt();
                tree[vs[0] - 1].Add(vs[1] - 1);
                tree[vs[1] - 1].Add(vs[0] - 1);
            }

            int[] score = RArInt();
            Array.Sort(score);
            Array.Reverse(score);

            int[] nodeScore = new int[n];

            int idx = 0;
            Queue<int> q = new Queue<int>();
            q.Enqueue(0);

            while (q.Count > 0)
            {
                int cur = q.Dequeue();
                if (nodeScore[cur] > 0) continue;

                nodeScore[cur] = score[idx];
                idx++;

                foreach (var child in tree[cur])
                {
                    if (nodeScore[child] > 0) continue;
                    q.Enqueue(child);
                }
            }

            Console.WriteLine(score.Sum() - score.First());
            Console.WriteLine(WAr(nodeScore));
        }
        static string RSt() { return Console.ReadLine(); }
        static int RInt() { return int.Parse(Console.ReadLine().Trim()); }
        static long RLong() { return long.Parse(Console.ReadLine().Trim()); }
        static double RDouble() { return double.Parse(Console.ReadLine()); }
        static string[] RArSt(char sep = ' ') { return Console.ReadLine().Trim().Split(sep); }
        static int[] RArInt(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => int.Parse(e)); }
        static long[] RArLong(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => long.Parse(e)); }
        static double[] RArDouble(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => double.Parse(e)); }
        static string WAr<T>(IEnumerable<T> array, string sep = " ") { return string.Join(sep, array.Select(x => x.ToString()).ToArray()); }
    }
}


Measured memory_bytes: 22972