akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
// #define cerr if(false)cerr
#define watch(x) cerr << "\n" << (#x) << " is " << (x) << endl;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<ll, ll> ii;
typedef vector<vector<ll>> vvll;
typedef vector<pair<ll, ll>> vii;
typedef long double ld;
typedef vector<ld> vld;
typedef vector<vector<ld>> vvld;
typedef vector<bool> vbl;
typedef vector<vbl> mbl;
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define all(s) (s).begin(), (s).end()
const ll MOD = 1e9 + 7;

inline void solve()
{
    int n;
    cin >> n;
    vll arr(n);
    for (int i = 0; i < n; i++)
    {
        cin >> arr[i];
    }
    sort(all(arr));
    ll ans = 0;
    for (int i = 1; i <= n - 1; i++)
    {
        ans += arr[n - 1 - i/2];
    }
    cout << ans << endl;
}

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

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

Measured memory_bytes: 4768
#include <iostream>
#include <map>
#include <set>
#include <utility>
#include <numeric> 
#include <bits/stdc++.h>
typedef long long ll;
typedef std::pair<std::pair<int,int>,int>pi;
using namespace std;

int main() {
    int n; cin >> n;
    string s = to_string(n);
    string ans = "No";
    for(auto x : s){
        if(x == '7'){
            ans = "Yes";
            break;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3696
#include <bits/stdc++.h>
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
Apparently, the tree supports the same operations as the set 
(at least I haven't any problems with them before), but also there are two new features — 
find_by_order() — The first returns an iterator to the k-th largest element (counting from zero)
order_of_key() — the number of items in a set that are strictly smaller than our item. 
https://codeforces.com/blog/entry/11080
using namespace __gnu_pbds; */
using namespace std;
#define test() int t;cin>>t;for(int test=1;test<=t;test++)
#define int long long
#define MOD 1000000007
#define pb push_back 
#define ins insert
#define fast(); ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ld long double
#define endl '\n'
int m(int a) {
    return ((a%MOD)+MOD)%MOD;
}
int p(int a, int b) {
    int res = 1;
    while(b > 0){
        if(b&1) res = m(m(res)*m(a));
        a = m(m(a)*m(a));
        b >>= 1;
    }
    return res;
}
signed main(){
    fast();
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i=0; i<n; i++)  cin >> a[i];
    sort(a.begin(), a.end(), greater<int>());
    int ans = 0;
    int p1 = 1, p2 = 1, curr = 0;
    while(p1 < n){
        if(p1 == 1) ans += a[0];
        else{
            ans += a[p2];
            curr++;
            if(curr == 2){
                p2++;
                curr = 0;
            }
        }
        p1++;
    }
    cout << ans << endl;
    cerr << "\nTime elapsed : " << 1000 * clock() / CLOCKS_PER_SEC << " ms\n";
}

Measured memory_bytes: 4768
import java.util.Scanner;
class Main{
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);int N=sc.nextInt();long C=sc.nextLong();
		long[][] sushi=new long[N][2];long[][] migi=new long[N][2];long[][] hidari=new long[N][2];long max_cal=0;
		for(int i=0; i<N; i++) {
			sushi[i][0]=sc.nextLong();sushi[i][1]=sc.nextLong();
		}
		migi[0][0]=sushi[0][0];migi[0][1]=sushi[0][1];
		for(int i=1; i<N; i++) {
			migi[i][0]=sushi[i][0];migi[i][1]=migi[i-1][1]+sushi[i][1];
		}
		for(int i=0; i<N; i++) {
			migi[i][1]-=migi[i][0];
			if(migi[i][1]>=0) {
				max_cal=Math.max(max_cal, migi[i][1]);
			}
		}
		hidari[0][0]=C-sushi[N-1][0];hidari[0][1]=sushi[N-1][1];
		for(int i=1; i<N; i++) {
			hidari[i][0]=C-sushi[N-1-i][0];hidari[i][1]=hidari[i-1][1]+sushi[N-1-i][1];
		}
		long[][] gyaku=new long[N][2];
		if(hidari[0][1]-hidari[0][0]>0) {
			gyaku[0][0]=hidari[0][1]-hidari[0][0];gyaku[0][1]=0;
		}
		else {
			gyaku[0][0]=0;gyaku[0][1]=-1;
		}
		for(int i=1; i<N; i++) {
			if(hidari[i][1]-hidari[i][0]>gyaku[i-1][0]) {
				gyaku[i][0]=hidari[i][1]-hidari[i][0];gyaku[i][1]=i;
			}
			else {
				gyaku[i][0]=gyaku[i-1][0];gyaku[i][1]=gyaku[i-1][1];
			}
		}
		for(int i=0; i<N-1; i++) {
			migi[i][1]-=migi[i][0];long tmp=migi[i][1]+gyaku[N-2-i][0];max_cal=Math.max(tmp,max_cal);
		}
		hidari[0][0]=C-sushi[N-1][0];hidari[0][1]=sushi[N-1][1];
		for(int i=1; i<N; i++) {
			hidari[i][0]=C-sushi[N-1-i][0];hidari[i][1]=hidari[i-1][1]+sushi[N-1-i][1];
		}
		for(int i=0; i<N; i++) {
			hidari[i][1]-=hidari[i][0];
			if(hidari[i][1]>=0) {
				max_cal=Math.max(max_cal, hidari[i][1]);
			}
		}
		migi[0][0]=sushi[0][0];migi[0][1]=sushi[0][1];
		for(int i=1; i<N; i++) {
			migi[i][0]=sushi[i][0];migi[i][1]=migi[i-1][1]+sushi[i][1];
		}
		if(migi[0][1]-migi[0][0]>0) {
			gyaku[0][0]=migi[0][1]-migi[0][0];gyaku[0][1]=0;
		}
		else {
			gyaku[0][0]=0;gyaku[0][1]=-1;
		}
		for(int i=1; i<N; i++) {
			if(migi[i][1]-migi[i][0]>gyaku[i-1][0]) {
				gyaku[i][0]=migi[i][1]-migi[i][0];gyaku[i][1]=i;
			}
			else {
				gyaku[i][0]=gyaku[i-1][0];gyaku[i][1]=gyaku[i-1][1];
			}
		}
		for(int i=0; i<N-1; i++) {
			hidari[i][1]-=hidari[i][0];long tmp=hidari[i][1]+gyaku[N-2-i][0];max_cal=Math.max(tmp,max_cal);
		}
		System.out.println(max_cal);
		sc.close();
	}
}

Measured memory_bytes: 106256
#include<iostream>
#include<vector>
#include<queue>
#include<cassert>
using namespace std;

#define REP(i,a,b) for(i=a; i<b; ++i)
#define rep(i,n) REP(i,0,n)

struct Edge{
  int s,t,c;
  Edge(int s,int t,int c) : s(s), t(t), c(c) {;}
};

struct UnionFind {
  vector<int> data;
  UnionFind(int size) : data(size, -1) { }
  bool unionSet(int x,int y) {
    x = root(x);
    y = root(y);
    if(x != y) {
      if(data[y] < data[x]) swap(x, y);
      data[x] += data[y];
      data[y] = x;
    }
      return x != y;
  }
  bool findSet(int x,int y) {
    return root(x) == root(y);
  }
  int root(int x) {
    return data[x] < 0 ? x : data[x] = root(data[x]);
  }
  int size(int x) {
    return -data[root(x)];
  }
};

bool operator<(const Edge &e,const Edge &f) {
  return (e.c != f.c) ? e.c > f.c : (e.s != f.s) ? e.s > f.c : e.t > f.t;
}

int solve(vector<vector<Edge> > &g,int hots) {
  const int n = g.size();
  int i,j;
  vector<int> atr(n,0);
  rep(i,hots) atr[i] = 1;
  UnionFind uf(n);

  priority_queue<Edge> Q;
  rep(i,hots) rep(j,g[i].size()) Q.push(g[i][j]);

  int ans = 0;
  while(!Q.empty()) {
    Edge e = Q.top(); Q.pop();
    if(uf.findSet(e.s,e.t)) continue;
    if(atr[e.s] != 0 && atr[e.t] != 0) continue;
    ans += e.c;
    //cout<<"add "<<e.s<<" "<<e.t<<endl;
    uf.unionSet(e.s,e.t);
    if(atr[e.s] == 0 && atr[e.t] == 0) assert(false);
    if(atr[e.s] == 0) {
      atr[e.s] = 1;
      rep(i,g[e.s].size()) Q.push(g[e.s][i]);
    }else if(atr[e.t] == 0) {
      atr[e.t] = 1;
      rep(i,g[e.t].size()) Q.push(g[e.t][i]);
    }
  }
  return ans;
}

int main() {
  int s,d,i,j,k;
  while(cin>>s>>d, s|d) {
    vector<vector<Edge> > g(s+d);
    rep(i,s) {
      rep(j,d) {
	cin>>k;
	if(!k) continue;
	g[i].push_back(Edge(i,j+s,k));
      }
    }

    rep(i,d) {
      REP(j,i+1,d) {
	cin>>k;
	if(!k) continue;
	g[i+s].push_back(Edge(i+s,j+s,k));
	g[j+s].push_back(Edge(j+s,i+s,k));
      }
    }

    cout<<solve(g,s)<<endl;
  }
}

Measured memory_bytes: 0
N, M = map(int, input().split())
ABs = [tuple(map(int, input().split())) for _ in range(M)]

par = [i for i in range(N)]

def find(x):
    if par[x] == x:
        return x
    else:
        par[x] = find(par[x])
        return par[x]

def unite(x, y):
    x = find(x)
    y = find(y)
    if x != y:
        par[x] = y

for a, b in ABs:
    unite(a-1, b-1)

for x in range(N):
    find(x)

print(len(set(par))-1)


Measured memory_bytes: 94056
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <string>
#include <map>
#include <numeric>
#include <utility>
#include <set>
#include <unordered_map>

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define IPSILON 1e-9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;


int main(){
  int M, D;
  cin >> M >> D;
  if(D<22){
    cout << 0 << endl;
    return 0;
  }
  int result = 0;
  int d1, d10, m;
  for(int i=22; i <=D; i++){
    d1 = i % 10;
    d10 = i / 10;
    m = d1 * d10;
    if(m <= M && 1 <= m && 2 <= d1){
      // cout << "d10 " << d10 << endl;
      // cout << "d1 " << d1 << endl;
      // cout << "m " << m << endl;
      result++;
    }
  }
  cout << result << endl;
  return 0;
}


Measured memory_bytes: 256
//
// Created by sark2 on 22-10-2019.
//

#include "bits/stdc++.h"

using namespace std;
#define PB push_back
#define IOS cin.sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define CASES int t;cin>>t;while(t--)
#define MP make_pair

using ll = long long;
using ld = long double;

ll mod = 1e9 + 7;

int main() {
    IOS

    int n; cin>>n;

    if(n%2 == 0){
        cout<<(double )(n)/(2*n);
    } else
        cout<<(double )(n+1)/(2*n);



}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <complex>
#include <cstdio>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

int n,m;

int main(){
	while(cin>>n){
		if(!n)return 0;
		int ans=0;
		for(int i=0;i<n/4;i++){
			cin>>m;
			ans+=m;
		}
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 0
// 2020-08-29 21:15:18
// clang-format off
#include<bits/stdc++.h>
#ifdef LOCAL
#include "lib/debug.hpp"
#else
#define debug(...) 1
#endif
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) REP(i, 0, (n))
#define repc(i, n) REPC(i, 0, (n))
#define REP(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define REPC(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define REPCM(i, n, m) for (int i = (int)(n); i >= (int)(m); i--)
using namespace std;
using ll = long long;
using ld = long double;
using pr = pair<ll, ll>;
using vll = vector<ll>;
using vpr = vector<pr>;
using P = pair<int, int>;
template<class T> inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } else return false; }
template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; }
namespace prime {
  bool is_prime(ll n) {
    if(n < 2) return false;
    for(ll i = 2; i * i <= n; i++) {
      if(n % i == 0) return false;
    }
    return true;
  }
  vector<ll> divisors(ll n) {
    vector<ll> res;
    for(ll i = 1; i * i <= n; i++) {
      if(n % i == 0) {
        res.push_back(i);
        if(i != n / i) res.push_back(n / i);
      }
    }
    return res;
  }
  map<ll, int> prime_factors(ll n) {
    map<ll, int> res;
    if(n < 2) return res;
    for(ll i = 2; i * i <= n; i++) {
      while(n % i == 0) {
        res[i]++;
        n /= i;
      }
    }
    if(n > 1) res[n] = 1;
    return res;
  }
};

// clang-format on
const int MX = 1e6;
bool b[MX + 10];
void answer() {
  int n;
  cin >> n;
  memset(b, true, sizeof b);
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  sort(ALL(a));
  bool pc = true;
  rep(i, n) if (pc) {
    if (a[i] == 1) continue;
    if (!b[a[i]]) {
      pc = false;
      break;
    }
    auto ds = prime::divisors(a[i]);
    sort(ALL(ds));
    for (auto d_ : ds) {
      if (d_ > 1) {
        int d = d_;
        for (int e = d; e <= MX; e += d) {
          b[e] = false;
        }
      }
    }
  }
  bool sc = true;
  {
    int now = a[0];
    REP(i, 1, n) now = __gcd(now, a[i]);
    sc = (now == 1);
  }
  if (pc) {
    cout << "pairwise coprime" << '\n';
  } else if (sc) {
    cout << "setwise coprime" << '\n';
  } else {
    cout << "not coprime" << '\n';
  }
}
int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  answer();
  return 0;
}

Measured memory_bytes: 8200
// ConsoleApplication56.cpp : 此文件包含 "main" 函数。程序执行将在此处开始并结束。
//

#include <iostream>
using namespace std;
int main()
{
    int a=0, n;
    cin >> n;
    char* p;
    p = new char[n];
    cin >> p;
    for (int i = 0; i < n - 2; i++)
    {
        if (p[i] == 'A' && p[i + 1] == 'B' && p[i + 2] == 'C')
        {
            a++;
        }
    }
    cout << a << "\n";
}



Measured memory_bytes: 256
#define LOCAL
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rrep(i, n) for(int i=(n-1); i>=0; --i)
#define rep2(i, s, n) for(int i=s; i<(n); ++i)
#define ALL(v) (v).begin(), (v).end()
#define memr(dp, val) memset(dp, val, sizeof(dp))
using namespace std;
typedef long long ll;
static const int INTINF = (INT_MAX >> 1); // 10^9 + 10^7
static const ll LLINF = (LLONG_MAX >> 1);
static const int MAX = 1e5+1;
static const ll MOD = 1e9+7;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
string to_string(string s) { return '"' + s + '"'; }
string to_string(bool b) { return b ? "true" : "false"; }
template <size_t N> string to_string(bitset<N> bs) {
  string res;
  for (size_t i = 0; i < N; ++i) res += '0' + bs[i];
  return res;
}
string to_string(vector<bool> v) {
  string res = "{";
  for (bool e : v) res += to_string(e) + ", ";
  return res += "}";
}
template <class T, class U> string to_string(pair<T, U> p);
template <class C> string to_string(C c) {
  string res = "{";
  for (auto e : c) res += to_string(e) + ", ";
  return res += "}";
}
template <class T, class U> string to_string(pair<T, U> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
void debug() { cerr << '\n'; }
template <class Head, class... Tail> void debug(Head head, Tail... tail) {
  cerr << '\t' << to_string(head), debug(tail...);
}
#ifdef LOCAL
#define DEBUG(...) cerr << "[" << #__VA_ARGS__ << "]:", debug(__VA_ARGS__)
#else
#define DEBUG(...)
#endif

int main(int argc, const char * argv[]) {
  std::cout << std::fixed << std::setprecision(15);

  string str; cin >> str;
  int ans = 0;
  rep(i, str.size()){
    int cnt = 0;
    rep2(j, i, str.size()){
      if(str[j] == 'A' || str[j] == 'C' || str[j] == 'G' || str[j] == 'T'){
        cnt++;
      }
      else{
        break;
      }
    }
    ans = max(ans, cnt);
  }

  cout << ans << endl;
}  


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

int main()
{
  int64_t A,B ;
  cin>>A>>B ;
  
  for(int a=1;a<=A;a++){
    if((a*B)%A==0){
      cout<<a*B<<endl ;
      return 0 ;
    }
  }
  return 0 ;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))

int main(){
	ll a,b;
	scanf("%lld%lld",&a,&b);
	puts(a%3==0||b%3==0||(a+b)%3==0?"Possible":"Impossible");
}

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

int main(){
  char b;
  cin>>b;
  
  if(b=='A'){
    cout<<'T'<<endl;
  }else if(b=='G'){
    cout<<'C'<<endl;
  }else if(b=='C'){
    cout<<'G'<<endl;
  }else if(b=='T'){
    cout<<'A'<<endl;
  }else{
    cout<<"error"<<endl;
  }
  return 0;
}

Measured memory_bytes: 256
import sys
import numpy as np
input = sys.stdin.readline

N, T = map(int, input().split())

c = [0] * N
t = [0] * N

for i in range(N):
    c[i], t[i] = map(int, input().split())

C = []
for j in range(N):
    if t[j] <= T:
        C.append(c[j])

if len(C) == 0:
    print('TLE')
else:
    print(min(C))


Measured memory_bytes: 12396
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        long[] ary = new long[n];
        long[] l = new long[n];
        long[] r = new long[n];
        for (int i = 0; i < n; i++) {
            long a = Long.parseLong(sc.next());
            ary[i] = a;
        }
        long temp = ary[0];
        l[0] = ary[0];
        for (int i = 0; i < n - 1; i++) {
            temp = getGcd(temp, ary[i + 1]);
            l[i + 1] = temp;
        }
        temp = ary[n - 1];
        r[n - 1] = ary[n - 1];
        for (int i = n - 1; i > 0; i--) {
            temp = getGcd(temp, ary[i - 1]);
            r[i - 1] = temp;
        }
        long ans = 0;
        for (int i = 0; i < n; i++) {
            if (i == 0) {
                ans = Math.max(ans, r[1]);
            } else if (i == n - 1) {
                ans = Math.max(ans, l[n - 2]);
            } else {
                ans = Math.max(ans, getGcd(l[i - 1], r[i + 1]));
            }
        }
        System.out.println(ans);
    }

    private static long getGcd(long x, long y) {
        return y == 0 ? x : getGcd(y, x % y);
    }
}

Measured memory_bytes: 49640
#include <cstring>
#include <map>
#include <deque>
#include <queue>
#include <stack>
#include <sstream>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <fstream>
#include <string>
#include <cstdlib>
#include <ctime>
#include <functional>
#include <algorithm>
#include <vector>
#include <set>
#include <complex>
#include <list>
#include <climits>
#include <cctype>
#include <bitset>
using namespace std;

#define PI 3.14159265359
#define all(v) v.begin(),v.end()
#define sortva(v) sort(all(v))
#define sortvd(v) sort(v.rbegin(),v.rend())
#define sortaa(a,n) sort(a,a+n)
#define sortad(a,n) sort(a,a+n),reverse(a,a+n)
#define sfi1(v) scanf("%d",&v)
#define sfi2(v1,v2) scanf("%d %d",&v1,&v2)
#define sfi3(v1,v2,v3) scanf("%d %d %d",&v1,&v2,&v3)
#define sfll1(v) scanf("%I64d",&v);
#define sfll2(v1,v2) scanf("%I64d %I64d",&v1,&v2)
#define sfll3(v1,v2,v3) scanf("%I64d %I64d %I64d",&v1,&v2,&v3)
#define sfstr(v) scanf("%s", v);
#define sz(v) (int)v.size()
#define ndl puts("")
#define SS stringstream
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

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

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

void PLAY() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	cout << fixed << setprecision(10);
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
}


int main() {
	//PLAY();
	
	int n;

	cin >> n;

	vector<int> v(n);
	for (int i = 0; i < n; i++)
		cin >> v[i];
	sortvd(v);
	int res = 1;
	int prev = v[0];
	for (int i = 1; i < n; i++)
		if (v[i] < prev) {
			prev = v[i];
			res++;
		}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define lli long long
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(),i.rend()
#define rep0(i,j) for(int i=0;i<j;i++)
#define rep1(i,j) for(int i=1;i<=j;i++)
#define rep0d(i,j) for(int i=j-1;i>=0;i--)
#define MOD 1000000007
 
using namespace std;
int pm[4][2] = {{0, -1}, {-1, 0}, {0, 1}, {1, 0}};

int main(){
    int h,w;
    cin >> h >> w;
    vector<string> vec(h);
    rep0(i,h)cin >> vec[i];

    lli ans = 0;
    rep0(i,h) rep0(j,w){
        if(vec[i][j] == '#')continue;
        rep0(k,h)rep0(l,w){
                if(vec[k][l] == '#')continue;
                vector<int> dist(h*w, -1);
                queue<int> que;
                dist[i*w+j] = 0;
                que.push(i*w+j);

                while(!que.empty()){
                    int v =que.front()/w, u = que.front()%w;
                    que.pop();
                
                    for(auto e: pm){
                        if(dist[(e[0]+v)*w + e[1] + u] != -1)continue;
                        if(e[0]+v < 0 || e[1] +u <0 || e[0]+v >= h || e[1] + u >= w ||  vec[e[0]+v][e[1]+u] == '#' )continue;
                        dist[(e[0]+v)*w + e[1] + u] = dist[v*w+u] + 1;
                        que.push((e[0]+v)*w + e[1] + u);
                    }
                }
                //cout << i << ' ' << j << ' ' << k << ' ' << l << ' ' <<  dist[k*w+l] << endl;
                if(ans < dist[k*w + l])ans= dist[k*w+l];
        }
        //cout << ans << endl;
    }
    cout <<ans;
}

Measured memory_bytes: 256
N,M=map(int,input().split())
XY=[list(map(int,input().split())) for i in range(M)]
def tsort(N,E):
    c=[[] for i in range(N)]
    t=[0]*N
    for i,j in E:
        c[i].append(j)
        t[j]+=1
    A,B=zip(*E)
    s=set(range(N))-set(B)
    l=[]
    while s:
        n=s.pop()
        l.append(n)
        for i in c[n]:
            t[i]-=1
            if t[i]==0:
                s.add(i)
    return c,l
c,l=tsort(N,[(x-1,y-1) for x,y in XY])
d=[0]*N
for i in l:
    for n in c[i]:
        d[n]=max(d[n],d[i]+1)
print(max(d))

Measured memory_bytes: 64560
/* Simplicity and Goodness */
 
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>

// using namespace __gnu_pbds;
using namespace std;
// typedef tree<int, null_type, less<int>, rb_tree_tag,
//             tree_order_statistics_node_update> indexed_set;

void my_dbg() { cout << endl; }
template<typename Arg, typename... Args> void my_dbg(Arg A, Args... B) 
{ cout << ' ' << A; my_dbg(B...); }
#define dbg(...)  cout << "(" << #__VA_ARGS__ << "):", my_dbg(__VA_ARGS__)

#define scn(n) scanf("%d", &n)
#define lscn(n) scanf("%lld", &n)
#define pri(n) printf("%d ", (int)(n))
#define prin(n) printf("%d\n", (int)(n))
#define lpri(n) printf("%lld ", n)
#define lprin(n) printf("%lld\n", n)
#define rep(i,a,b) for(int i=(int)(a); i<(int)(b); i++)
#define pb push_back
#define mp make_pair
#define F first
#define S second

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;

const int inf = INT_MAX;
const int ninf = INT_MIN;
const int mod = 1e9+7;
const int N = 2e6+2;

int fac[N], inv[N];

int mi(int x, int n) 
{
   int res = 1;
   while(n) {
      if(n & 1) 
         res = (1LL * res * x) % mod;
      x = (1LL * x * x) % mod;
      n >>= 1;
   }
   return res;
}

void fact() 
{
   fac[0] = 1;
   rep(i, 1, N) {
      fac[i] = (1LL * fac[i-1] * i) % mod;
   }

   inv[N-1] = mi(fac[N-1], mod-2);
   for(int i=N-1; i>0; i--) {
      inv[i-1] = (1LL * inv[i] * i) % mod;
   }
}

int nCr(int n, int k) 
{
   if(k > n)
      return 0;

   int ans = (1LL * fac[n] * inv[k]) % mod;
   ans = (1LL * ans * inv[n-k]) % mod;
   return ans;
}


void solve()
{   
    fact();

    int k;
    string s;

    cin >> k >> s;

    int m = (int)s.size();

    int ans = 0;

    for(int x=0; x<=k; x ++) {
        // 26^x * (k-x+m-1)Cm-1 * 25^(k-x)

        int here = mi(26, x);
        here = (1LL * here * nCr(k-x+m-1, m-1)) % mod;
        here = (1LL * here * mi(25, k-x)) % mod;
        ans = (1LL * ans + here) % mod;
    }

    prin(ans);
}

int main()
{
    int t = 1;
    // scn(t);

    while(t --) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 20896
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

class Main {
	private class Node {
		int id, parent=-1, left=-1, right=-1, sibling=-1, depth, height=-1;
		public Node(int id) {
			this.id = id;
		}
	    @Override
	    public String toString() {
		StringBuilder sb = new StringBuilder();
		sb.append("node " + id + ": ");
		sb.append("parent = " + parent + ", ");
		sb.append("sibling = " + sibling + ", ");
		sb.append("degree = " + getDegree() + ", ");
		sb.append("depth = " + depth + ", ");
		sb.append("height = " + height + ", ");
		if (parent == -1) {
		    sb.append("root");
		} else if (getDegree() == 0) {
		    sb.append("leaf");
		} else {
		    sb.append("internal node");
		}
		return sb.toString();
	    }
	    private int getDegree() {
		int degree = 0;
		if (left != -1) degree++;
		if (right != -1) degree++;
		return degree;
	    }
	}
    public static void main(String[] args) throws IOException {
	new Main().run();
    }
	private void run() throws IOException {
	    BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
	    int n = Integer.parseInt(reader.readLine());
	    Node[] nodes = new Node[n];
	    for (int i = 0; i < n; i++) {
		StringTokenizer st = new StringTokenizer(reader.readLine());
		int id = Integer.parseInt(st.nextToken());
		int left = Integer.parseInt(st.nextToken());
		int right = Integer.parseInt(st.nextToken());
		if (nodes[id] == null) {
				nodes[id] = new Node(id);
		}
		nodes[id].left = left;
		nodes[id].right = right;
		if (left != -1 && nodes[left] == null) {
		    nodes[left] = new Node(left);
		}
		if (right != -1 && nodes[right] == null) {
		    nodes[right] = new Node(right);
			}
		if (left != -1) {
		    nodes[left].sibling = right;
		    nodes[left].parent = id;
		}
		if (right != -1) {
		    nodes[right].sibling = left;
		    nodes[right].parent = id;
		}
	    }
	    reader.close();
		
	    int rootId = -1;
	    for (int i = 0; i < n; i++) {
		if (nodes[i].parent == -1) {
		    rootId = nodes[i].id;
		    break;
		}
	    }
	    
	    setDepth(nodes, rootId);
	    setHeight(nodes, rootId);
	    
	    for (int i = 0; i < n; i++) {
		System.out.println(nodes[i]);
		}
	}
    
    private void setDepth(Node[] nodes, int id) {
	if (nodes[id].left != -1) {
	    nodes[nodes[id].left].depth = nodes[id].depth + 1;
	    setDepth(nodes, nodes[id].left);
	}
	if (nodes[id].right != -1) {
	    nodes[nodes[id].right].depth = nodes[id].depth + 1;
	    setDepth(nodes, nodes[id].right);
	}
    }
    
    private void setHeight(Node[] nodes, int id) {
	if (nodes[id].right != -1) {
	    setHeight(nodes, nodes[id].right);
	}		
	if (nodes[id].left != -1) {
	    setHeight(nodes, nodes[id].left);
	}
	if (nodes[id].getDegree() == 0) {
	    nodes[id].height = 0;
	}
	if (nodes[id].left != -1) {
	    nodes[id].height = Math.max(nodes[id].height, nodes[nodes[id].left].height + 1);
	}
	if (nodes[id].right != -1) {
	    nodes[id].height = Math.max(nodes[id].height, nodes[nodes[id].right].height + 1);
	}
    }
}



Measured memory_bytes: 24388
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<cstdio>
#include<queue>
#include<deque>
#include<map>
#include<stack>
#include<set>
#include<utility>
using namespace std;
typedef pair<int,int> pii;
typedef pair<int,pii> pipii;
typedef long long ll;
typedef pair<ll,ll> pll;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
const int MAXN=100000;
const int MAXE=100000;
const int MAXV=10000;
const ll INF=2e18;
const ll MOD=1e9+7;
struct edge{
    int to;
    int cost;
};
int main(){
    int N;cin>>N;
    map<string,int> mp;
    for(int i=0;i<N;++i){
        string s;cin>>s;
        mp[s]++;
    }
    int mx=0;
    for(auto it:mp){
        if(it.second>mx) mx=it.second;
    }
    vector<string> ans;
    for(auto it:mp){
        if(it.second==mx) ans.push_back(it.first);
    }
    sort(ans.begin(),ans.end());
    for(auto it:ans){
        cout<<it<<endl;
    }
    return 0;
}

Measured memory_bytes: 27188
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
 
#define repp(I, A, B) for(int I = A; I <= B; I++)
#define rep(I, A, B) for(int I = A; I < B; I++)
#define rrep(I, B, A) for(int I = B; I >= A; I--)
#define pb emplace_back
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define LB lower_bound
#define UB upper_bound
#define MP make_pair
#define quickio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define bitcount(n) __builtin_popcountll(n)
#define in_edges(M) repp(I, 1, M){int A, B; cin >> A >> B; v[A].pb(B), v[B].pb(A);}
#define endl "\n"

const ll MOD = 1e9 + 7;
const ll INF = 1e18 + 18;
const int inf = 2e9;

const int N = 2e5 + 6;
vector<int> v[N];
bool vis[N];

void dfs(int s){
    vis[s] = 1;
    for(auto i : v[s]) if(!vis[i]) dfs(i);
}
int main() //PointBlank's code ¯\_(ツ)_/¯
{
    quickio
    int n, m;
    cin >> n >> m;
    in_edges(m);

    int res = 0;
    repp(i, 1, n){
        if(!vis[i]){
            dfs(i);
            res++;
        }
    }
    cout << res - 1;
}

Measured memory_bytes: 12068
n = int(input())
ab = [0] * n
for i in range(n):
    ab[i] = list(map(int, input().split()))

ab = sorted(ab, key=lambda x: x[1])


time = 0
for i in ab:
    time += i[0]
    if time > i[1]:
        print("No")
        exit()

print("Yes")

Measured memory_bytes: 55256
#include<bits/stdc++.h>
using namespace std;
#define inf INT_MAX
#define INF LLONG_MAX
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
#define vi vector<int>
#define IP pair<int,P>
#define PI pair<P,int>
#define PP pair<P,P>
#define Yes(f){cout<<(f?"Yes":"No")<<endl;}
#define YES(f){cout<<(f?"YES":"NO")<<endl;}
int Madd(int x,int y) {return (x+y)%M;}
int Msub(int x,int y) {return (x-y+M)%M;}
int Mmul(int x,int y) {return (x*y)%M;}


signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(20);

  int n;
  cin>>n;
  string s1,s2;
  char c1[4]={'.','.','#','#'};
  char c2[4]={'.','#','.','#'};
  bool b=true;
  while(s1.size()<n){
    bool flag=false;
    if(b){
      rep(i,4){
        cout<<s1<<c1[i]<<endl;
        cout<<s2<<c2[i]<<endl;
        string q;
        cin>>q;
        if(q[0]=='e') return 0;
        if(q[0]=='T'){
          s1+=c1[i];
          s2+=c2[i];
          flag=true;
          break;
        }
      }
      if(!flag) b=false;
    }else{
      rep(i,4){
        cout<<c1[i]<<s1<<endl;
        cout<<c2[i]<<s2<<endl;
        string q;
        cin>>q;
        if(q[0]=='e') return 0;
        if(q[0]=='T'){
          s1=c1[i]+s1;
          s2=c2[i]+s2;
          break;
        }
      }
    }
  }



}

Measured memory_bytes: 724
#pragma GCC optimize("O2")
#include <bits/stdc++.h>
using namespace std;
#define FASTIO ios_base::sync_with_stdio(false), cin.tie(0)
//#define MULTI_TEST
//#define GOOGLE
#ifdef LOCAL
#include "debugger.h"
#else
#define db(...)
#endif
#define ll long long
#define v32 vector<int>
#define v64 vector<ll>
#define s32 set<int>
#define s64 set<ll>
#define p32 pair<int, int>
#define p64 pair<ll, ll>
#define sz(v) (ll)(v).size()
#define fi first
#define se second
#define ln '\n'
const ll MOD = 1e9 + 7;
inline ll add(ll a, ll b, ll m) { return (((a % m + b % m) % m + m) % m); }
inline ll mul(ll a, ll b, ll m) { return (((a % m * b % m) % m + m) % m); }
ll getDistOpp(ll x, ll y, ll z)
{
	return min(abs(y - x), abs(z - x)) + abs(y - z);
}
ll getDistRight(ll x, ll y, ll z)
{
	return abs(x - max(y, z));
}
ll getDistLeft(ll x, ll y, ll z)
{
	return abs(x - min(y, z));
}
void solve(int tc)
{
	int a, b, q;
	cin >> a >> b >> q;
	v64 shrine(a, 0), temple(b, 0);
	for (int i = 0; i < a; i++)
		cin >> shrine[i];
	for (int i = 0; i < b; i++)
		cin >> temple[i];
	while (q--)
	{
		ll x;
		cin >> x;
		ll ans = 1e18;
		int s_l = -1, s_r = -1, t_l = -1, t_r = -1;
		//get closest shrine on left
		int idx = upper_bound(shrine.begin(), shrine.end(), x) - shrine.begin();
		idx--;
		if (idx >= 0)
			s_l = idx;
		//get closest shrine on right
		idx = lower_bound(shrine.begin(), shrine.end(), x) - shrine.begin();
		if (idx != sz(shrine))
			s_r = idx;
		//get closest temple on left
		idx = upper_bound(temple.begin(), temple.end(), x) - temple.begin();
		idx--;
		if (idx >= 0)
			t_l = idx;
		//get closest temple on right
		idx = lower_bound(temple.begin(), temple.end(), x) - temple.begin();
		if (idx != sz(temple))
			t_r = idx;
		db(x, s_l, s_r, t_r, t_l);
		if (s_l != -1 && t_r != -1)
			ans = min(ans, getDistOpp(x, shrine[s_l], temple[t_r]));
		if (s_r != -1 && t_l != -1)
			ans = min(ans, getDistOpp(x, shrine[s_r], temple[t_l]));
		if (s_r != -1 && t_r != -1)
			ans = min(ans, getDistRight(x, shrine[s_r], temple[t_r]));
		if (s_l != -1 && t_l != -1)
			ans = min(ans, getDistLeft(x, shrine[s_l], temple[t_l]));
		cout << ans << ln;
	}
	return;
}
int main()
{
#ifndef LOCAL
	FASTIO;
#endif
	int t = 1;
#ifdef LOCAL
	clock_t start, stop;
	start = clock();
#endif
#ifdef MULTI_TEST
	cin >> t;
#endif
	for (int tc = 1; tc < t + 1; tc++)
	{
#ifdef GOOGLE
		cout << "Case #" << tc << ": ";
#endif
		solve(tc);
	}
#ifdef LOCAL
	stop = clock();
	cerr << "Time :" << fixed << setprecision(5) << double(stop - start) / double(CLOCKS_PER_SEC) << "s" << ln;
#endif
	return 0;
}


Measured memory_bytes: 4776
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>
// *テンプレート*
#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define P pair<int, int>
// aよりbの方が小さかったら、aの値をbの値に置き換える。(swapではない！)
template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
// aよりbの方が大きかったら、aの値をbの値に置き換える。
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}

using namespace std;
typedef long long ll;
map<int, int> mp;
using Graph = vector<vector<int>>; 
//最大公約数
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
//最小公倍数
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}

const long long MOD = 1000000007;
const long long INF = 1LL << 60;
// *テンプレートここまで*

// pair -> vector<pair<int,int>> 
//		   AandB.push_back(make_pair(a[i],b[i]))

// ^= -> ビットごとの排他的論理和を計算する

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int a; string s; cin >> a>>s;
	if (a >= 3200)cout << s << endl;
	else cout << "red" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define FOR(i,a,b) for(int i=(a); i<=(b); i++) 
#define rep(i,n); for(int i = 0; i < (n); i++)
#define chmin(a,b) if((a)>(b)) (a)=(b); 
#define chmax(a,b) if((a)<(b)) (a)=(b);
#define vi vector<int>
int gcd(int a,int b){/*a>=0,b>=0,￢(a=b=0)*/
  while(min(a,b)>0){if(a<b)swap(a,b);a%=b;}return max(a,b);
}
int dx[]={0,1,0,-1,1,-1,-1,1};
int dy[]={1,0,-1,0,1,1,-1,-1};
const int MOD = 1e9+7;
const int INF = 1e18+10;

/*----------------------------------------------*/
signed main(){
  int a,b;
  cin>>a>>b;
  FOR(i,1,1000){
    int ca=i*0.08;
    int cb=i*0.1;
    if(ca==a&&cb==b){
      cout<<i<<endl;
      return 0;
    }
  }
  cout<<-1<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
using namespace std;

int main()
{
	string str;

	string allow;

	string replacechar;

	int S, E;

	string a;

	int q;

	cin >> str;

	cin >> q;

	for (int i = 0; i < q; i++)
	{
		cin >> allow >> S >> E;

		if (allow=="replace")
		{

			cin >> replacechar;

			str.replace(S, E-S+1, replacechar);
		}
		if (allow=="reverse")
		{

			string B = str.substr(S, E - S + 1);

			reverse(B.begin(),B.end());

			str.replace(S, E - S + 1, B);

		}
		if (allow=="print")
		{

			cout << str.substr(S,E-S+1);

			cout << endl;
		}
	}
	
	return 0;
}

Measured memory_bytes: 3180
import java.util.Scanner;

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

			int N = scan.nextInt();

			int oturi= 0;


			if(N%1000!=0) {
				System.out.println(1000-N%1000);
			}else {
				System.out.println(0);
			}
			

			

		}

	}

}

Measured memory_bytes: 35888
class Main {
    /**
     * main
     */
    public static main(input: string): void {
        const pair:Map<String,String> = new Map<String,String>();
        pair.set('A','T');
        pair.set('T','A');
        pair.set('C','G');
        pair.set('G','C');
        console.log(pair.get(input.trim()));    
    
    }
  }
  
  Main.main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7372
#from collections import Counter
word = list(input())
word.sort()
#print(set(word))
#print(word)
ans = []
for i in [chr(i) for i in range(97, 97+26)]:
  n = word.count(i)
  if n == 0:
    ans.append(i)
    break
else:
    ans.append('None')
    
    
print(ans[0])    

Measured memory_bytes: 4324
#include <vector>
#include <math.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <iomanip>
#include <deque>
#include <map>

typedef long long ll;
#define rep(i, a, n) for(int i = a; i<n; i++)
#define ALL(a) begin(a), end(a)
#define mii map<int, int>
#define msi map<string, int>
#define vi vector<int>
#define vl vector<ll>
#define MOD 1000000007
#define INF 1e9
#define showVector(v) rep(i,0,v.size()){p(v[i]);p(" ")} pl("")
#define p(s) std::cout << s ;
#define pl(s)  std::cout << s << endl;
using namespace std;

// 素数判定 O(√n)
bool is_prime(int n){
    for(int i = 2; i * i <= n; i++){
        if(n % i == 0) return false;
    }
    return true;
}

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 main() {
    ll N, K;
    cin >> N >> K;

    vl a(N);
    rep(i, 0, N) {
        cin >> a[i];
    }
    sort(a.begin(), a.end());

while(K > 0) {
    a.pop_back();
    --K;
    if (a.empty()) break;
}
ll res = 0;
rep(i, 0, a.size()) {
    res += a[i];
}
    cout << res << endl;
    return 0;
}

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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using ll = long long;
int mod = 1000000000+7;

int main(){

    string s,t;
    cin>>s>>t;
    rep(i,s.size()){
        if(s[i]!=t[i]){
            cout<<"No"<<endl;
            return 0;
        }
    }
    
    cout<<"Yes"<<endl;

    return 0;
}


Measured memory_bytes: 3596
#include <iostream>
#include <map>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <sstream>
#include <cmath>
#include <math.h>
#include <string>
using namespace std;
          
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a , b;
    cin >> a >> b;
    if ( a == 1 ) a = 14;
    if ( b == 1 ) b = 14;
    if ( a > b ) cout << "Alice";
    else if ( a == b ) cout << "Draw";
    else cout << "Bob";
}

Measured memory_bytes: 256
// #pragma GCC target("avx2")
#pragma GCC optimize("O3", "unroll-loops")

// #include <bits/extc++.h>
// using namespace __gnu_pbds;

#include <bits/stdc++.h>
using namespace std;

#define int long long
#define double long double
// template <typename T>
// using pbds_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
using pii = pair<int, int>;
template<typename T>
using prior = priority_queue<T, vector<T>, greater<T>>;
template<typename T>
using Prior = priority_queue<T>;

#define X first
#define Y second
#define ALL(x) (x).begin(), (x).end()
#define eb emplace_back
#define pb push_back

#define fastIO() ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define RANDOM() random_device __rd; \
                 mt19937 __gen = mt19937(__rd()); \
                 uniform_int_distribution<int> __dis(0, 1); \
                 auto rnd = bind(__dis, __gen);

const int INF = 1E18;
const int mod = 1E9 + 7;

int32_t main() {
    fastIO();
    
    int tmp;
    set<int> st;
    for (int i = 0; i < 3; ++i) cin >> tmp, st.insert(tmp);
    
    cout << st.size() << "\n";
    
    return 0;
}

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

using ll = long long;
using ld = long double;
using vi = vector<int>;
using vll = vector<ll>;
using P = pair<int, int>;

const int INF = 1e9;
const ll INFLL = 1e18;
const int MOD = 1e9 + 7;
const int NIL = -1;
const ld PI = acosl(-1);

#define rep(i,n) for(int i=0; i<(n); ++i)
#define all(n) n.begin(),n.end()

int main() {
	ios::sync_with_stdio(false); cin.tie(nullptr);
	//cout << fixed << setprecision(6);
	ll d, n;
	cin >> d >> n;

	int s = 1;
	rep(i, d) s *= 100;
	if(n <= 99)
		cout << n * s << endl;
	else
		cout << 101 * s << endl;
	return 0;
}

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

int main() {

int a,b,c,d;
  cin>>a>>b>>c>>d;
  cout<<c-d+b<<" "<<d+c-a<<" "<<a+b-d<<" "<<b+c-a<<endl;
}


Measured memory_bytes: 256
fn main() {
    let n: u32 = {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        s.trim_right().parse().unwrap()
    };
    let a:u32 = {
        let mut t = String::new();
        std::io::stdin().read_line(&mut t).unwrap();
        t.trim_right().parse().unwrap()
    };
    print!("{}\n", n * n - a);
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define _GLIBCXX_DEBUG
#define rep(i, a, b) for(int i = a; i < b; i++)
#define ALL(v) v.begin(), v.end()

int main(){
    int a,b,c; cin >> a >> b >> c;
    if(a+b+c >= 22) cout << "bust" << endl;
    else cout << "win" << endl;
}

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

typedef long long lli;

int main()
{
    string s;
    cin>>s;

    bool ok = false;
    if( s[2] == s[3] && s[4] == s[5])ok = true;

    if( ok )cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


Measured memory_bytes: 256
K, S = map(int, input().split())
ans = 0
for x in range(0, K+1):
    for y in range(0, K+1):
        z = S - (x + y)
        # print('x: {} | y: {} | z: {}'.format(x,y,z))
        if(z<0 or z>K):
            continue
        ans += 1
print(ans)

Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
int main() {
  int N, A, B, Entry = 0, Brank = 0;
  bool IsPassed;
  string S;
  cin >> N >> A >> B >> S;
  for(int i = 0; i < N; i++) {
    if(S[i] == 'a') {
      if(Entry < A + B) {
        cout << "Yes" << endl;
        Entry++;
      }
      else {
        cout << "No" << endl;
      }
    }
    else if(S[i] == 'b') {
      if(Entry < A + B && Brank < B) {
        cout << "Yes" << endl;
        Entry++;
        Brank++;
      }
      else {
        cout << "No" << endl;
      }
    }
    else if(S[i] == 'c') {
      cout << "No" << endl;
    }
  }
}
  
  

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

typedef pair<int, int> ii;
const int N = 4005;

int h, w, n, m;
short l[N][N], r[N][N];
short d[N][N], u[N][N];
int bit[N];
bool a[N][N];
long long res;
vector<ii> v;

void upd(int x) {
    for (int i = x; i < N; i += i & -i) bit[i]++;
}

long long get(int x) {
    long long ans = 0;
    for (int i = x; i > 0; i -= i & -i) ans += bit[i];
    return ans;
}

long long get(int l, int r) {
    if (l > r) return 0;
    return get(r) - get(l - 1);
}

void solve() {
    vector<ii> go[2];
    int sz = v.size();
    // check
    /*
    cout << "Check\n";
    for (int i = 0; i < sz; ++i) {
        cout << v[i].first << ' ' << v[i].second << '\n';
    }
    */
    // prepare
    for (int i = 0; i < sz; ++i) {
        go[0].push_back(ii(l[v[i].first][v[i].second], v[i].first));
        go[1].push_back(ii(r[v[i].first][v[i].second], v[i].first));
    }
    for (int i = 0; i < 2; ++i) {
        sort(go[i].begin(), go[i].end(), greater<ii>());
    }
    // min in 0
    int cur = 0;
    memset(bit, 0, sizeof bit);
    for (int i = 0; i < sz; ++i) {
        while (cur < sz && go[1][cur].first >= go[0][i].first) upd(go[1][cur++].second);
        res += get(go[0][i].second - go[0][i].first + 1, go[0][i].second - n + 1);
    }
    // min in 1
    cur = 0;
    memset(bit, 0, sizeof bit);
    for (int i = 0; i < sz; ++i) {
        while (cur < sz && go[0][cur].first > go[1][i].first) upd(go[0][cur++].second);
        res += get(go[1][i].second + n - 1, go[1][i].first + go[1][i].second - 1);
    }
}

void init(int x, int y) {
    v.clear();
    for (int i = 0; ; ++i) {
        if (x + i > h || y + i > w) return;
        v.push_back(ii(x + i, y + i));
    }
}

int main() {
    ios::sync_with_stdio(false);
    // in
    cin >> h >> w >> n >> m;
    for (int i = 0; i < m; ++i) {
        int x, y; cin >> x >> y; a[x][y] = 1;
    }
    // prepare
    for (int i = 1; i <= h; ++i) {
        for (int j = 1; j <= w; ++j) {
            if (a[i][j]) l[i][j] = u[i][j] = 0;
            else l[i][j] = l[i][j - 1] + 1, u[i][j] = u[i - 1][j] + 1;
        }
    }
    for (int i = h; i >= 1; --i) {
        for (int j = w; j >= 1; --j) {
            if (a[i][j]) r[i][j] = u[i][j] = 0;
            else r[i][j] = r[i][j + 1] + 1, d[i][j] = d[i + 1][j] + 1;
        }
    }
    for (int i = 1; i <= h; ++i) {
        for (int j = 1; j <= w; ++j) {
            l[i][j] = min(l[i][j], u[i][j]);
            r[i][j] = min(r[i][j], d[i][j]);
        }
    }
    // solve
    for (int i = 1; i <= w; ++i) {
        init(1, i), solve();
    }
    for (int i = 2; i <= h; ++i) {
        init(i, 1), solve();
    }
    // out
    cout << res << '\n';
}

Measured memory_bytes: 142876
import bisect
N = int(input())
a = sorted(list(map(int,input().split())))
b = sorted(list(map(int,input().split())))
c = sorted(list(map(int,input().split())))
ans = 0
for i in b:
	a2 = bisect.bisect_left(a,i)
	c2 = len(c) - bisect.bisect_right(c,i)
	ans += a2 * c2
print(ans)


Measured memory_bytes: 23092
#include <bits/stdc++.h>
#define mk make_pair
#define fs first
#define sc second
using namespace std;
typedef long long ll;
typedef long double ld;
int main(){
    int n, k, s;
    while(cin>>n>>k>>s){
        ll ans=0;
        for(int i=0; i<k; ++i){
            cout<<s<<" ";
        }
        for(int i=k; i<n; ++i){
            if(s==1)
                cout<<s+1<<" ";
            else
                cout<<s-1<<" ";
        }
        cout<<endl;
    }
  return 0;
}




Measured memory_bytes: 1280
/*
  NAME : RISHABH SINGH
  INSTITUTION : DELHI TECHNOLOGICAL UNIVERSITY
*/
#include "bits/stdc++.h"
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define int long long
#define pii pair<int, int>
#define bi __builtin_inf()
#define ll long long
#define mp make_pair
#define ss second
#define pb push_back
#define ff first
#define speed_cubing ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define um unordered_map
#define us unordered_set
#define bp __builtin_popcount
#define ld long double
#define rep(n) for (int i = 0; i < n; i++)
#define pll pair<ll, ll>
#define mx = 1e18;
#define lb(v, val) (lower_bound(v.begin(), v.end(), val) - v.begin())
#define ub(v, val) (upper_bound(v.begin(), v.end(), val) - v.begin())
#define PI 3.1415926535
typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> pbds;
ll powmod(ll base,ll exp,ll MOD){ll res=1;while(exp>0){if(exp%2==1) res=(res*base)%MOD;base=(base*base)%MOD;exp/=2;}return (res%MOD);}
#define sz(v) (int)v.size()
#define endl '\n'
const int mod = 1e9+7;
ll mul_inv(ll a,ll b = mod) {ll t1=a,t2=b,t3,v1=1,v2=0,v3;while(t2!=1){ll x=t1/t2;t3=t1-x*t2;v3=v1-x*v2;t1=t2,t2=t3;v1=v2,v2=v3;}return(v2+b)%b;}
const int N = 5e5+5;

int32_t main(){
   
   speed_cubing
   
   string x;
   int n;

   cin>>n>>x;

   int cnt = 0;

   for(int i=0;i<x.size();i++)
      if(x[i]=='1')
        cnt++;

   int temp = 1;

   int mod1 = 0,mod2 = 0;

   if(cnt-1 > 0){
    
    for(int i=0;i<x.size();i++){
    
      mod1 = (mod1*2)%(cnt-1);
    
      if(x[i]=='1')
        mod1++;

      mod1%=(cnt-1);   
   
    }

   }

   for(int i=0;i<x.size();i++){
      
      mod2 = (mod2*2)%(cnt+1);
    
      if(x[i]=='1')
        mod2++;
    
      mod2%=(cnt+1);   

   }

   reverse(x.begin(),x.end());

   for(int i=n-1;i>=0;i--){
      
      int temp = 0,count = 1;

      if(x[i]=='1'){
        if(cnt-1>0){
          temp = mod1 - powmod(2,i,cnt-1);
          temp%=cnt-1;
          if(temp<0)
            temp+=cnt-1;
        }
        else{
         count = 0; 
        }    
      }
      else{ 
        temp = mod2 + powmod(2,i,cnt+1);
        temp%=(cnt+1);
        if(temp<0)
          temp+=cnt+1; 
      }

      while(temp){
           int y = bp(temp);
           temp%=y;
           count++;
      }

      cout<<count<<endl;

   }
    
   return 0;
}

Measured memory_bytes: 3780