akhauriyash/Code-Regression huggingface dataset:
s = int(input())

a = [0]*(10**6+1)
c = [0]*(10**6+1)
a[1] = s
c[s] = 1
for i in range(2, 10**6+1):
    v = a[i-1]//2 if a[i-1] % 2 == 0 else 3*a[i-1]+1
    a[i] = v
    if c[v] == 1:
        print(i)
        exit()
    c[v] = 1

Measured memory_bytes: 24520
from collections import defaultdict
class UnionFind:
    def __init__(self, num):
        self.table = [-1 for _ in range(num)]
        self.sz = defaultdict(lambda:1)

    def find(self, x):
        if self.table[x] < 0:
            return x
        else:
            self.table[x] = self.find(self.table[x])
            return self.table[x]

    def union(self, x, y):
        s1 = self.find(x)
        s2 = self.find(y)

        if s1 != s2:
            size = self.sz[s1]+self.sz[s2]
            if self.table[s1] <= self.table[s2]:
                self.table[s1] += self.table[s2]
                self.table[s2] = s1
            else:
                self.table[s2] += self.table[s1]
                self.table[s1] = s2
            s = self.find(x)
            self.sz[s] = size
            return True
        return False

    def size(self, x):
        s = self.find(x)
        return self.sz[s]
N,M = map(int,input().split())
AB = [tuple(map(lambda x:int(x)-1,input().split())) for i in range(M)]
ans = N*(N-1)//2
l = []
u = UnionFind(N)
for i in range(M-1,-1,-1):
    l.append(ans)
    a,b = AB[i]
    if u.find(a)!=u.find(b):
        ans -= u.size(a)*u.size(b)
        u.union(a,b)
for i in range(M-1,-1,-1):
    print(l[i])


Measured memory_bytes: 30516
// #include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <tuple>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repd(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
#define repdm(i, a, b) for (ll i = (ll)(a); i > (ll)(b); i--)
const ll INF = 1LL << 60;

int gcd(int x, int y)
{
  if (y == 0)
    return x;
  return gcd(y, x % y);
}

int main()
{
  int N;
  cin >> N;
  int A[N];
  rep(i, N) cin >> A[i];
  int lgcd[N];
  int rgcd[N];
  rep(i, N)
  {
    if (i == 0)
    {
      lgcd[i] = A[i];
      rgcd[N - 1 - i] = A[N - 1 - i];
      continue;
    }
    lgcd[i] = gcd(A[i], lgcd[i - 1]);
    rgcd[N - 1 - i] = gcd(A[N - 1 - i], rgcd[N - 1 - i + 1]);
  }

  int ans = 0;
  rep(i, N)
  {
    if (i == 0)
    {
      ans = max(ans, rgcd[i + 1]);
      continue;
    }
    if (i == N - 1)
    {
      ans = max(ans, lgcd[i - 1]);
      continue;
    }
    ans = max(gcd(lgcd[i - 1], rgcd[i + 1]), ans);
  }
  cout << ans << endl;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
int main(){
    int N,K;
    cin >> N >> K;
   int ans = 1;
   for(int i = 0;i < N;i++){
       ans = min(2*ans,ans + K);
   }
   cout << ans << endl;
}

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

using namespace std;

long long power(int x, int y){
  long long n = 1;
  for(int i = 0; i < y; i++)
    n *= x;
  return n;
}

int log(int x, int y){
  int cnt = 0;
  while(y > 1){
    y /= x;
    cnt++;
  }
  return cnt;
}

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  vector<int> b(n);
  vector<int> c(n-1);
  for(int i = 0; i < n; i++)
    cin >> a.at(i);
  for(int i = 0; i < n; i++)
    cin >> b.at(i);
  for(int i = 0; i < n-1; i++)
    cin >> c.at(i);
  int ans = b.at(a.at(0)-1);
  for(int i = 1; i < n; i++){
    ans += b.at(a.at(i)-1);
    if(a.at(i)-a.at(i-1) == 1)
      ans += c.at(a.at(i-1)-1);
  }
  cout << ans << endl;
}


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

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pii;

#define abs(a) ((a) < (0)? -(a):(a))
#define rep(i, n) REP(i, 0, (n))
#define REP(i, a, n) for(int i=(a); i<(n); i++)
#define pb push_back

int main() {
	int n;
	cin >> n;
	vector<pair<pair<string, int>, int>> spi;
	rep(i, n) {
	    string s;
	    int p;
	    cin >> s >> p;
	    spi.pb({{s, -p}, i});
	}
	sort(spi.begin(), spi.end());
	for(auto e : spi) {
	    cout << e.second+1 << endl;
	}
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <cmath>
#include <algorithm>
#include <iterator>
#define r(i,n) for(int i=0;i<n;i++)
#define R(i,c,n) for(int i=c;i<n;i++)
#define DEBUG(x) cerr << #x << ": " << x << endl;
#define DUMP(a) REP(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}
#define ALL(v) v.begin(),v.end()
#define UNIQUE(v)  sort(ALL(v));v.erase(unique(ALL(v)),v.end());
#define pb push_back
using namespace std;
const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const double PI = 3.14159265358979323846;

int main(){
  ios::sync_with_stdio(false);
	cin.tie(0);
  int n;
  cin >> n;
  cout << "Christmas";
  r(i,25-n){
    cout << " Eve";
  }
  cout << endl;
  return 0;
}

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

using namespace std;
#define int long long
int MOD = 1000000007;

bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;
    
    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return false;
        }
    }
    
    return true;
}
signed main(){
    int X;
    cin >> X;
    
    for(int i=X;i<100000000;i++){
        if(IsPrime(i)==true){
            cout << i << endl;
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.*;
public class Main {
	int M,min,max;
	int[] P;
    public void solve() {
		P = new int[200 + 1];
		while(true){
			M = nextInt();
			min = nextInt();
			max = nextInt();
			
			if(M + min + max == 0)break;
			for(int i = 0;i < M;i++){
				P[i] = nextInt();
			}
			int maxGap = 0;
			int ans = 0;
			for(int i = min;i <= max;i++){
				int gap = P[(i - 1)] - P[Math.min(i,M - 1)];
				if(maxGap <= gap){
					ans = i;
					maxGap = gap;
				}
			}
			
			out.println(ans);
		}
    }
 
	public static void main(String[] args) {
		out.flush();
		new Main().solve();
		out.close();
	}
		/* Input */
	private static final InputStream in = System.in;
	private static final PrintWriter out = new PrintWriter(System.out);
	private final byte[] buffer = new byte[2048];
	private int p = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (p < buflen)
			return true;
		p = 0;
		try {
			buflen = in.read(buffer);
		} catch (IOException e) {
			e.printStackTrace();
		}
		if (buflen <= 0)
			return false;
		return true;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrint(buffer[p])) {
			p++;
		}
		return hasNextByte();
	}

	private boolean isPrint(int ch) {
		if (ch >= '!' && ch <= '~')
			return true;
		return false;
	}

	private int nextByte() {
		if (!hasNextByte())
			return -1;
		return buffer[p++];
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = -1;
		while (isPrint((b = nextByte()))) {
			sb.appendCodePoint(b);
		}
		return sb.toString();
	}

	public int nextInt() {
		return Integer.parseInt(next());
	}

	public long nextLong() {
		return Long.parseLong(next());
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}
}

Measured memory_bytes: 31924
import java.util.LinkedList;
import java.util.Scanner;

//Emacs-like Editor
public class Main{

	void run(){
		Scanner sc = new Scanner(System.in);
		LinkedList<String> l = new LinkedList<String>();
		while(true){
			String s = sc.nextLine();
			if(s.equals("END_OF_TEXT"))break;
			l.add(s+"$");
		}
		int i = 0;
		int j = 0;
		String buf = "";
		while(true){
			char ch = sc.next().charAt(0);
			
			if(ch=='-')break;
			if(ch=='a')j=0;
			else if(ch=='e')j=l.get(i).length()-1;
			else if(ch=='p'){
				if(i>0)i--;
				j=0;
			}
			else if(ch=='n'){
				if(i<l.size()-1)i++;
				j=0;
			}
			else if(ch=='f'){
				if(j!=l.get(i).length()-1)j++;
				else if(j==l.get(i).length()-1&&i<l.size()-1){
					i++;j=0;
				}
			}
			else if(ch=='b'){
				if(j>0)j--;
				else if(j==0&&i>0){
					i--;j=l.get(i).length()-1;
				}
			}
			else if(ch=='d'){
				if(l.get(i).charAt(j)!='$'){
					StringBuilder sb = new StringBuilder(l.remove(i));
					l.add(i, sb.substring(0, j)+sb.substring(j+1,sb.length()));
				}
				else if(i<l.size()-1){
					String t = l.remove(i);
					StringBuilder sb = new StringBuilder(t.substring(0, t.length()-1));
					sb.append(l.remove(i));
					l.add(i, sb.toString());
				}
			}
			else if(ch=='k'){
				if(j==l.get(i).length()-1&&i<l.size()-1){
					String t = l.remove(i);
					StringBuilder sb = new StringBuilder(t.substring(0, t.length()-1));
					sb.append(l.remove(i));
					l.add(i, sb.toString());
					buf = "$";
				}
				else if(j<l.get(i).length()-1){
					StringBuilder sb = new StringBuilder(l.remove(i));
					l.add(i, sb.substring(0,j)+"$");
					buf = sb.substring(j,sb.length()-1);
					j = l.get(i).length()-1;
				}
			}
			else if(ch=='y'){
				if(buf.equals(""))continue;
				if(buf.equals("$")){
					StringBuilder sb = new StringBuilder(l.remove(i));
					l.add(i, sb.substring(0,j)+"$");
					l.add(i+1,sb.substring(j,sb.length()));
					i++;j=0;
				}
				else {
					StringBuilder sb = new StringBuilder(l.remove(i));
					char r = sb.charAt(j);
					l.add(i, sb.substring(0, j)+buf+sb.substring(r=='$'?j+1:j,sb.length())+(r=='$'?"$":""));
					j += buf.length();
				}
			}
//			System.out.println("DUMP Line:" + i + " Column:" +j + " CHAR:" + l.get(i).charAt(j) + " BUF:" + buf + " IM:" + ch);
//			for(String s:l)System.out.println(s);
		}
		for(String s:l)System.out.println(s.substring(0,s.length()-1));
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"

using namespace std;
using ll = long long;

const ll MOD = 1000000007LL; // = 10^9 + 7
const double PI = 3.14159265358979;

void solve()
{
  int n;
  string s;
  cin >> n >> s;
  vector<int> W(n, 0), E(n, 0);
  int ans = n;
  for(int i = 0; i < n - 1; ++i)
  {
    W[i + 1] = W[i] + (s[i] == 'W');
  }
  for(int i = n - 1; i >= 1; --i)
  {
    E[i - 1] = E[i] + (s[i] == 'E');
    ans = min(ans, W[i - 1] + E[i - 1]);
  }

  cout << min(ans, W[n - 1] + E[n - 1]);
}

int main()
{
  fastio;
  solve();

  return 0;
}

Measured memory_bytes: 6100
#include <bits/stdc++.h>
using namespace std;
double dp[3000][3000];
vector<double> p;

int main() {
    int n;
    cin >> n;
    p.resize(n+1);
    for (int i = 1; i <= n; i++) cin >> p[i];
    dp[0][0] = 1;
    for (int i = 1; i <= n; i++) {
        for (int j = 0; j <= n; j++) {  //// i枚目まで考えたときにj枚が表である確率
            if (j > 0) dp[i][j] = dp[i-1][j-1] * p[i] + dp[i-1][j] * (1 - p[i]);
            else dp[i][j] = dp[i-1][j] * (1 - p[i]);
        }
    }
    double ans = 0;
    for (int i = (n+1) / 2; i <= n; i++) {
        ans += dp[n][i];
    }
    // for (int i = 0; i <= n; i++) {
    //     for (int j = 0; j <= n; j++) {
    //         cout << dp[i][j] << " ";
    //     }
    //     cout << endl;
    // }
    cout << setprecision(10) << ans << endl;
    return 0;
}

Measured memory_bytes: 74052
#include <bits/stdc++.h>
#define rep(i,n) for(long long int i = 0; i < n; i++)
#define _rep(i,m,n) for(long long int i = m; i < n; i++)
#define print(n) std::cout << n << std::endl
#define _print(n) std::cout << n
using namespace std;
typedef long long ll;
const int N = 1000000;
const ll mod = 1000000007;


int main() {
  int n; cin >> n;
  vector<int> t(n);
  vector<int> x(n);
  vector<int> y(n);
  rep(i,n){
      cin >> t[i] >> x[i] >> y[i];
  }
  bool flag = true;
  rep(i,n) {
      if (i == 0) {
          if (t[0] != abs(x[0]) + abs(y[0])) {
              flag = false;
              break;
          }
      }else{
          int dr = abs(x[i] - x[i - 1]) + abs(y[i] - y[i - 1]);
          int dt = t[i] - t[i - 1];
          if (dt >= dr && dt % 2 == dr % 2)continue;
          else flag = false;
          break;
      }
  }
  if(flag)print("Yes");
  else print("No");
}


Measured memory_bytes: 1408
#include <iostream>

int main()
{
	int n; std::cin >> n;
	
	int ans = 0;
	ans += n/25; n %= 25;
	ans += n/10; n %= 10;
	ans += n/5;  n %= 5;
	ans += n;
	std::cout << ans << std::endl;
	
	return 0;
}



Measured memory_bytes: 3104
#include<bits/stdc++.h>
#define ll long long int
#define MEM(a, b) memset(a, (b), sizeof(a))
using namespace std;
ll dp[3001][3001];
ll arr[3001]={};
// ll dfs(int i,int j,int temp)
// {
//   // if(dp[i][j]!=-1) return dp[i][j];
//   // if(temp==0)
//   // {
//   //   if(i==j) return dp[i][j]=arr[i];
//   //   return dp[i][j]=max(arr[i]+dfs(i+1,j,1-temp),arr[j]+dfs(i,j-1,1-temp));
//   // }
//   // if(temp==1)
//   // {
//   //   if(i==j) return dp[i][j]=0;
//   //   return dp[i][j]=min(dfs(i+1,j,1-temp),dfs(i,j-1,1-temp));
//   // }
// 	// // temp=0 means take max //temp=1 means take min
//   // return 0;
//   temp=1;
//   for(int i=n;i>=0;i--)
//   {
//     for(int j=i;j<=n;j++)
//     {
//       if(temp==1) { temp=0; if(i==j) { dp[i][j]=arr[i];} else { dp[i][j]=max(dp[i+1][j],dp[i][j-1]); } }
//  else if(temp==0) { temp=1; if(i==j) { dp[i][j]=0;     } else { dp[i][j]=min(dp[i+1][j],dp[i][j-1]); } }
//     }
//   }
// }
int main()
{  	ios_base::sync_with_stdio(false); cin.tie(0);
    int n,a,temp;cin>>n;
    MEM(dp ,0);
    ll sum=0;
    for(int i=1;i<=n;i++)
		{
			cin>>arr[i];
      sum+=arr[i];
		}
    a=(1+n)%2;
    for(int i=n;i>=0;i--)
    {
      for(int j=i;j<=n;j++)
      { if((i+j)%2==a) { temp=1; }else { temp=0; }
        if(temp==1) {  if(i==j) { dp[i][j]=arr[i];} else { dp[i][j]=max(arr[i]+dp[i+1][j],arr[j]+dp[i][j-1]); } }
   else if(temp==0) {  if(i==j) { dp[i][j]=0;     } else { dp[i][j]=min(dp[i+1][j],dp[i][j-1]); } }
      }
    }
    cout<<2*dp[1][n]-sum<<"\n";
    // for(int i=0;i<=4;i++)
    // {
    //   for(int j=0;j<=4;j++)
    //   cout<<dp[i][j]<<"  ";
    //   cout<<"\n";
    // }
return 0;
}


Measured memory_bytes: 70784
//============================================================================
// Name        : hoba.cpp :)
// Author      : (O_O Diab) (Why_not) (el 3AQ)
// Version     :
// Copyright   : please, Don't touch me :(
// Description : problem in C++
// MAIN IDEA   :
//============================================================================
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll unsigned long long int
#define ld long double
#define rw freopen("input.txt","r",stdin),freopen("output.txt","w",stdout);
#define pb push_back
#define F first
#define S second
#define pf push_front
#define lp(i,a,b) for (int i=a;i<=(int)b;++i)
#define lp2(i,a,b) for (int i=a;i>=b;--i)
#define f(x) return cout<<x<<"\n",0
#define pii pair<int,int>
#define pll pair<ll,ll>
#define all(c) c.begin(),c.end()
#define allr(c) c.rbegin(),c.rend()
#define p(x) cerr<<#x<<" = { "<<x<<" } \n"
#define vi vector<int>
#define vl vector<ll>
#define vii vector<pii>
#define vll vector<pll>
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define EPS 1e-6
// to convert string to number use int a = stoi(string);
// to convert number to string use string s = to_string(int);
#define FAST ios::sync_with_stdio(0),ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define clr(c,x) memset(c,x,sizeof(c));
using namespace __gnu_pbds;
using namespace std;
const ll INFL = 0x3f3f3f3f3f3f3f3fLL;
const int dx[] = { 0, 1, 0, -1, 1, -1, 1, -1 };
const int dy[] = { 1, 0, -1, 0, 1, -1, -1, 1 };
const int N = 50 + 5, mod = (int) 1e9 + 7, INF = 0x3f3f3f3f;
int n, A, B;
ll dp[N][N] = { }, x;
vl v;
bool vis1[N][N] = { }, vis2[N][N] = { };
vector<pair<ld, int>> vv;
ll solve(int idx, int len) {
	if (!len || (idx >= (int) v.size()))
		return 0;
	ll &ret = dp[idx][len];
	if (vis1[idx][len])
		return ret;
	vis1[idx][len] = 1;
	ret = 0;
	ret = max(ret, solve(idx + 1, len));
	ret = max(ret, solve(idx + 1, len - 1) + v[idx]);
	return ret;
}
ll dp2[N][N] = { };
ll out(int idx, int len) {
	if (!len || idx >= n)
		return 1;
	ll &rf = dp2[idx][len];
	if (vis2[idx][len])
		return rf;
	vis2[idx][len] = 1;
	rf = 0;
	ll &ret = dp[idx][len];
	if (ret == solve(idx + 1, len))
		rf += out(idx + 1, len);
	if (ret == (solve(idx + 1, len - 1) + v[idx]))
		rf += out(idx + 1, len - 1);
	return rf;
}
int main() {
#ifdef ONLINE_JUDGE
	   FAST;
#endif
	cin >> n >> A >> B;
	lp(i,1,n)
	{
		cin >> x;
		v.pb(x);
	}
	sort(allr(v));
	lp(i,A,B)
	{
		ll ans = solve(0, i);
		ld d = (ld) ans / (ld) i;
		vv.pb( { d, i });
	}
	sort(all(vv));
	cout << fixed << setprecision(6) << vv.back().F << "\n";
	ll ans = 0;
	for (auto u : vv)
		if (vv.back().F == u.F)
			ans += out(0, u.S);
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>	
#include <cmath>
#include <string>
#include<math.h>
#include<sstream>//���炵���̂Œ���
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define Cout(s) cout<<s<<endl
using namespace std;
typedef long long ll;
string Yes(bool b) { if (b) { return "Yes"; } else { return "No"; } }
string YES(bool b) { if (b) { return "YES"; } else { return "NO"; } }
//================================================

int a = 1, b = 0, c, d, n, k = 0, ans = 0;
string s, t;
int mod = 1000000007;

int main()
{
	ll x; cin >> x;
	ll ans = 100, flag=0;
	while (ans < x) {
		ans = ans * 1.01;
		flag++;
	}
	cout << flag << endl;

	return 0;
}


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

int main(){
    ll n;
    cin>>n;
    vector<ll> p(n);
    rep(i,n)cin>>p[i];
    ll cnt=0;
    for(ll i=1;i<n-1;i++){
        if(max(p[i-1],max(p[i],p[i+1]))!=p[i] && min(p[i-1],min(p[i],p[i+1]))!=p[i])cnt++;
    }
    cout<<cnt<<endl;
}


Measured memory_bytes: 256
N,M = map(int,input().split())
abc = []
for _ in range(M):
    abc.append(list(map(int,input().split())))

cost = [-float('inf')]*N
cost[0] = 0

for i in range(2):
    for a,b,c in abc:
        a,b = a-1,b-1
        cost[b] = max(cost[b], cost[a] + c)

    if i == 0:
        ans = cost[N-1]
    else:
        Max = cost[N-1]


if ans != Max:
    print('inf')
else:
    print(ans)


Measured memory_bytes: 3444
def d_equals(N, M, P, S):
    class UnionFind(object):
        def __init__(self, N):
            self.p = list(range(N))  # 初期状態ではi番の頂点の親(parent)はi番
            self.rank = [0] * N  # 初期状態では全頂点がランク0(何もつながってない)
            self.size = [1] * N  # 初期状態ではどの頂点も連結成分の大きさは1

        def find(self, x):  # 頂点xが属する連結成分の代表(根の番号)を求める
            if self.p[x] != x:  # 頂点xの代表は他の頂点だった
                self.p[x] = self.find(self.p[x])  # 経路圧縮(xを代表につなぐ)
            return self.p[x]

        def is_same(self, x, y):  # 頂点x,yは同じ連結成分に属するか？
            return self.find(x) == self.find(y)

        def union(self, x, y):  # x,yを同じ連結成分に属させる
            u = self.find(x)
            v = self.find(y)
            if u == v:  # x,yは既に同じ連結成分に属していた
                return
            if self.rank[u] < self.rank[v]:
                self.p[u] = v  # ランクの大きな方につなげる
                self.size[v] += self.size[u]  # つながっている要素数だけ足す
                self.size[u] = 0  # ランクが小さかった連結成分は「解散」
            else:
                # 上と同様にやる
                self.p[v] = u
                self.size[u] += self.size[v]
                self.size[v] = 0
                if self.rank[u] == self.rank[v]:
                    # 根の分だけ1個「ずれる」
                    self.rank[u] += 1

        def get_size(self, x):  # 頂点xが属する連結成分の大きさ
            return self.size[self.find(x)]

        def show(self):
            return self.p

    ans = 0
    uf = UnionFind(N)
    for a, b in S:
        uf.union(a - 1, b - 1)  # Pのa番とb番は繋がっている(0-indexed)
    for i in range(N):
        if uf.is_same(P[i] - 1, i):
            # 2つが同じ連結成分にあるなら、何回かswapしてp_i=iにできる
            ans += 1
        elif P[i] - 1 == i:
            # 同じ連結成分には属していないが、最初からp_i=iだった
            ans += 1
    return ans

N,M = [int(i) for i in input().split()]
P = [int(i) for i in input().split()]
S = [[int(i) for i in input().split()] for j in range(M)]
print(d_equals(N, M, P, S))

Measured memory_bytes: 30980
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;

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

typedef long long ll;

int main(void) {

	ll r, g, b;
	cin >> r >> g >> b;

	ll sum = r * 100 + g * 10 + b;

	if (sum % 4 == 0) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}

	return 0;
}

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

int main()
{

  ios::sync_with_stdio(0);
  cin.tie(0);
  ll n,d,x,y,ans=0;
  cin>>n>>d;
  while(n--){
   cin>>x>>y;
    if(x*x+y*y<=d*d){ans++;}
  }
  cout<<ans;
  

    return 0;
}

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

int main(){
  ll N, M, i, h, a, b, count = 0;
  vector<ll> H;
  cin >> N >> M;
  vector<ll> check(N, 1);
  rep(i, N){
    cin >> h;
    H.push_back(h);
  }
  rep(i, M){
    cin >> a >> b;
    if(H[a - 1] > H[b - 1]){
      check[b - 1] = 0;
    } else if(H[a - 1] < H[b - 1]){
      check[a - 1] = 0;
    } else {
      check[a - 1] = check[b - 1] = 0;
    }
  }

  rep(i, N){
    if(check[i] == 1){
      count++;
    }
  }
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 5092
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main(){
    int n;
    cin>>n;
    long long x=0,y=0;
    long long a[100005];
    for(int i=0;i<n;i++){
        scanf("%lld",&a[i]);
        }
    sort(a, a+n);
    for(int i=n-1;i>=0;i--){
        if(a[i]==a[i+1]){
            if(x!=0){
                y=a[i];
                break;
            }else{
                x=a[i];
                i--;
            }
        }
    }
    cout<<x*y<<endl;
    }

Measured memory_bytes: 1024
import java.util.*;

public class Main {
    private static final Scanner scn = new Scanner(System.in);
    
    public static void main(String[] args) {
        for(int n; (n = scn.nextInt()) > 0;) {
            printTable(createTable(n));
        }
    }
    
    private static int[][] createTable(int n) {
        int[][] tbl = new int[n + 1][n + 1];
        for(int i = 0; i < n; i++) {
            for(int j = 0; j < n; j++) {
                int v = scn.nextInt();
                tbl[i][j] = v;
                tbl[i][n] += v;
                tbl[n][j] += v;
                tbl[n][n] += v;
            }
        }
        return tbl;
    }
    
    private static void printTable(int[][] tbl) {
        for(int[] ary : tbl) {
            for(int elm : ary) {
                System.out.format("%5d", elm);
            }
            System.out.println();
        }
    }
}

Measured memory_bytes: 32356
use proconio::*;
use proconio::marker::Usize1;

fn main() {
    input!{
        n: usize,
        m: usize,
        ab: [(Usize1, Usize1); m],
    }

    let mut uf = UnionFind::new(n);

    for (a, b) in ab {
        uf.unite(a, b);
    }

    let mut ans = 0;
    for i in 0..n {
        ans = ans.max(uf.size(i));
    }

    println!("{}", ans);
}

struct UnionFind {
    pub data: Vec<i32>,
}

impl UnionFind {
    pub fn new(n: usize) -> UnionFind {
        UnionFind {
            data: vec![-1; n],
        }
    }

    pub fn unite(&mut self, x: usize, y: usize) -> bool {
        let mut x = self.find(x) as usize;
        let mut y = self.find(y) as usize;
        if x == y {
            return false;
        }
        if self.data[x] > self.data[y] {
            std::mem::swap(&mut x, &mut y);
        }

        self.data[x] += self.data[y];
        self.data[y] = x as i32;
        true
    }

    pub fn find(&mut self, x: usize) -> i32 {
        if self.data[x] < 0 {
            return x as i32;
        }

        let t = self.find(self.data[x] as usize);
        self.data[x] = t;
        t
    }

    pub fn size(&mut self, x: usize) -> usize {
        let t = self.find(x) as usize;
        -self.data[t] as usize
    }
}

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

using namespace std;
using ll = long long;
typedef pair<int, int> ii;
typedef vector<ii> vii; 
typedef vector<int> vi;

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0), cout.tie(0);
	
	ll x, a, b;
	cin >> x >> a >> b;
	
	int c = b - a;
	if(c <= 0) cout << "delicious" << endl;
	else if(c <= x) cout << "safe" << endl;
	else cout << "dangerous" << endl; 
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using datas=pair<ll,ll>;
using ddatas=pair<double,double>;
using tdata=pair<ll,datas>;
using vec=vector<ll>;
using mat=vector<vec>;
using pvec=vector<datas>;
using pmat=vector<pvec>;
#define For(i,a,b) for(i=a;i<(ll)b;i++)
#define bFor(i,a,b) for(i=a;i>=(ll)b;i--)
#define rep(i,N) For(i,0,N)
#define rep1(i,N) For(i,1,N)
#define brep(i,N) bFor(i,N-1,0)
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define vsort(v) sort(all(v))
#define vrsort(v) sort(allr(v))
#define endl "\n"
#define pb push_back
#define output(v) do{bool f=0;for(auto outi:v){cout<<(f?" ":"")<<outi;f=1;}cout<<endl;}while(0)
const ll mod=1000000007;
const ll inf=1LL<<60;
const double PI = acos(-1);
const double eps = 1e-9;
template<class T> inline bool chmax(T& a,T b){bool x=a<b;if(x)a=b;return x;} 
template<class T> inline bool chmin(T& a,T b){bool x=a>b;if(x)a=b;return x;} 
 
void startupcpp(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(15);
}
 
double distance(ddatas& x,ddatas& y){
  double a=x.first-y.first,b=x.second-y.second;
  return sqrt(a*a+b*b);
}
 
ll modinv(ll a) {
  ll b=mod,u=1,v=0,t;
  while(b){
    t=a/b;
    a-=t*b; swap(a,b);
    u-=t*v; swap(u,v);
  }
  return (u+mod)%mod;
}
 
ll moddevide(ll a,ll b){return (a*modinv(b))%mod;}
 
vec modncrlistp,modncrlistm;
 
ll modncr(ll n,ll r){
  ll i,size=modncrlistp.size();
  if(size<=n){
    modncrlistp.resize(n+1);
    modncrlistm.resize(n+1);
    if(!size){
      modncrlistp[0]=modncrlistm[0]=1;
      size++;
    }
    For(i,size,n+1){
      modncrlistp[i]=modncrlistp[i-1]*i%mod;
      modncrlistm[i]=modinv(modncrlistp[i]);
    }
  }
  return modncrlistp[n]*modncrlistm[r]%mod*modncrlistm[n-r]%mod;
}
 
ll modpow(ll a,ll n){
  ll res=1;
  while(n){
    if(n&1)res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}
 
ll gcd(ll a,ll b){if(!b)return a;return (a%b==0)?b:gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
 
ll countdigits(ll n){
  ll ans=0;
  while(n){n/=10;ans++;}
  return ans;
}
 
ll sumdigits(ll n){
  ll ans=0;
  while(n){ans+=n%10;n/=10;}
  return ans;
}
void judgement(int a){
  if(a){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
  if(a){
    cout<<"YES"<<endl;
  }else{
    cout<<"NO"<<endl;
  }
}
int main(){
  startupcpp();
  ll i,j,N,M,a,b;
  cin>>N>>M;
  vec v(N,0),s(N,0);
  rep(i,M){
    cin>>a>>b;
    a--;b--;
    if(!a)v[b]++;
    if(b==N-1)s[a]++;
  }
  rep(i,N)if(s[i]&&v[i]){
    cout<<"POSSIBLE"<<endl;
    return 0;
  }
  cout<<"IMPOSSIBLE"<<endl;
  return 0;
}

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

int main() {
    long long l,r;
    int c = 2019;
    cin >> l >> r;
    if(l / c != r / c){
        cout << 0 << endl;
        return 0;
    }
    long long ans = c;
    for(long long i = l; i <= r; i++){
        for(long long j = i+1; j <= r; j++){
            ans = min(ans, i*j%c);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.math.BigInteger;
import java.util.HashSet;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        BigInteger a = BigInteger.ZERO;
        for (int i = 0; i < n+1; i++) {
            if (i % 3 != 0 && i % 5 != 0) {
                a = a.add(new BigInteger(""+i));
            }
        }
        System.out.println(a.toString());

    }
}


Measured memory_bytes: 57152
#include<bits/stdc++.h>
using namespace std;
using ll = int64_t;
using P = pair<ll, ll>;
const ll INF = 5e15;
int main(){
    ll N;
    cin >> N;
    vector<ll> V(N);
    for(ll &a : V) cin >> a;
    for(ll i = 0; i < N; i++){
        if(V[i] & 1){
            cout << "first" << endl;
            return 0;
        }
    }
    cout << "second" << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <climits>
#include <math.h>
#define rep(i,n) for (int i=0; i<n; i++)

using namespace std;
using ll = long long;
using P = pair <int, int>;


int main(){
  int N;
  double D;
  cin >> N >> D;
  vector<double> X(N);
  vector<double> Y(N);
  double wa;
  int cnt=0;
  rep(i,N){
    cin >> X.at(i) >> Y.at(i);
    wa = X.at(i)*X.at(i)+Y.at(i)*Y.at(i);
    if( sqrt(wa) <=D){
      cnt++;
    };
  }
  cout<< cnt << endl;
  return 0;
}

Measured memory_bytes: 6496
use std::collections::HashSet;
use std::cmp::max;
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()
}

fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
fn main(){
    let n = read::<usize>();
    let an = read_vec2::<i64>(n as u32);
    let (xt,yt,ht) = {
            let sub = an.iter().filter(|x| x[2] >= 1).nth(0).unwrap();
            (sub[0],sub[1],sub[2])
        };
    let mut set = HashSet::new();
    for cx in 0..101{
        for cy in 0..101{
            let h = ht + (cx-xt).abs() + (cy-yt).abs();
            set.insert((cx,cy,h));
        }
    }
    let ans = set.into_iter().collect::<Vec<(_,_,_)>>()
        .into_iter().filter(|a| an.iter().all(|b| {
            let (xb,yb,hb) =(b[0],b[1],b[2]);
            hb == max(a.2-(a.0-xb).abs()-(a.1-yb).abs(),0)
        })).nth(0).unwrap();
    println!("{} {} {}",ans.0,ans.1,ans.2);

}


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

#define int				long long
#define FOR( i, m, n )  for( int (i) = (m); (i) < (n); (i)++ )
#define REP( i, n )     FOR( i, 0, n )
#define REPR( i, m )	for( int (i) = (m); (i) >= 0; (i)-- )
#define REPONE( i, n )	FOR( i, 1, n + 1 )
#define ALL( a )        (a).begin(), (a).end()
#define MP				make_pair
#define X				first.first
#define Y				first.second

typedef pair<int, int> P;

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( a > b ) { a = b; return 1; } return 0; }

const int INF = 1e9;
const int MOD = 1e9 + 7;

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

int field[12][12];

void dfs( int x, int y ) {
	REP( i, 4 ) {
		int nx = x + dx[i];
		int ny = y + dy[i];

		if( nx >= 0 && nx < 12 && ny >= 0 && ny < 12 && field[nx][ny] == 1 ) {
			field[nx][ny] = 0;
			dfs( nx, ny );
		}
	}
}

signed main() {
	while( 1 ) {
		REP( i, 12 ) {
			REP( j, 12 ) {
				char c; if( !( cin >> c ) ) return 0;
				field[j][i] = c - '0';
			}
		}

		int ans = 0;
		REP( i, 12 ) {
			REP( j, 12 ) {
				if( field[j][i] == 1 ) {
					field[j][i] = 0;
					dfs( j, i );
					ans++;
				}
			}
		}

		cout << ans << endl;

	}
	
}


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

  vector<char> c(1, 'a');

void dog(ll n) {
  char x;
  if(n/26 == 0 || n == 26){
    x = 'a' + (n - 1);
    c.push_back(x);
    reverse(c.begin(), c.end());
    c.pop_back();
    for(int i = 0; i < (int)c.size(); ++i) cout << c[i];
  }

  else{
    if(n%26 == 0){
      x = 'z';
      c.push_back(x);
      dog(n/26 - 1);
    }
    else{
      x = 'a' + (n%26 - 1);
      c.push_back(x);
      dog(n/26);
    }
  }


}

int main() {
  ll n;
  cin >> n;
  dog(n);

  cout << endl;
}


Measured memory_bytes: 3640
N, W = map(int, input().split())
items = [tuple(map(int, input().split())) for i in range(N)]

dp = [[10**15 for sum_v in range(10**5+100)] for i in range(N+100)]

for i in range(N):
    for sum_v in range(10**5+50):

        dp[0][0] = 0

        # i-1番目の品物を選ぶ場合
        if sum_v-items[i][1] >= 0:
            dp[i+1][sum_v] = min(dp[i+1][sum_v],
                                 dp[i][sum_v-items[i][1]]+items[i][0])

        # i-1番目の品物を選ばない場合
        dp[i+1][sum_v] = min(dp[i+1][sum_v], dp[i][sum_v])

ans = 0
for i in range(10**5+50):
    if dp[N][i] <= W:
        ans = i
print(ans)


Measured memory_bytes: 258440
#include<iostream>
#include<vector>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;

int main(){
	int a,b,c,x;
	cin>>a>>b>>c>>x;
	int sum = 0;
	rep(i,a+1){
		rep(j,b+1){
			rep(k,c+1){
				if(x==i*500+j*100+k*50)sum++;
			}
		}
	}
	cout<<sum<<endl;
	return 0;
}

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

int getPos(int i, int j){
  return i * 3 + j;
}


char running(const string& s){
  for(int q = 0; q < 2; q++){

    char c = "ox"[q];
    bool judge;

    for(int i = 0; i < 3; i++){
      judge = true;
      for(int j = 0; j < 3; j++){ //よこ
        judge &= s[getPos(i,j)] == c;
      }
      if(judge) return c;
    }
    
    for(int i = 0; i < 3; i++){
      judge = true;
      for(int j = 0; j < 3; j++){
        judge &= s[getPos(j,i)] == c;
      }
      if(judge) return c;
    }

    judge = true;
    for(int j = 0; j < 3; j++){
      judge &= s[getPos(j,j)] == c;
    }
    if(judge) return c;

    judge = true;
    for(int j = 0; j < 3; j++){
      judge &= s[getPos(2-j,j)] == c;
    }
    if(judge) return c;

  }
  return 'd';
}

int main(){
  string s;
  while(cin >> s){
    printf("%c\n", running(s));
  }
  return 0;
}

Measured memory_bytes: 1176
n = int(input())
mt = 10 ** 9
for i in range(1, n):
    t = 0
    for j in range(len(str(i))):
        t += int(str(i)[j])
    for j in range(len(str(n - i))):
        t += int(str(n - i)[j])
    mt = min(mt, t)
print(mt)


Measured memory_bytes: 3060
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <complex>
using namespace std;
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define mp make_pair
#define ERASE(v,i) (v).erase(remove(all(v),i),(v).end())
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define each(it,c) for(typeof((c).begin()) it=(c).begin();it!=(c).end();++it)
#define debug(x) cerr<<#x<<" = "<<(x)<<endl;
#define LINE cerr<<"LINE: "<<__LINE__<<endl;
inline int toInt(string s){int v;istringstream i(s);i>>v;return v;}
template<class T> inline string toString(T x){ostringstream o;o<<x;return o.str();}
template<class T> void pv(T a,T b){for(T it=a;it!=b;++it)cerr<<*it<<" ";cerr<<endl;}
const int INF = 1000000000;
const double PI = acos(-1.0), EPS = 1e-10;

inline double SQR(double x) {
	return x * x;
}

inline double dist(double ax, double ay, double bx, double by) {
	return sqrt(SQR(ax - bx) + SQR(ay - by));
}

int main() {
	vector<double> X;
	vector<double> Y;

	for(string line; getline(cin, line);) {
		rep(i,line.length()) if(line[i] == ',') line[i] = ' ';
		istringstream is(line);
		double dx, dy;
		is >> dx >> dy;

		X.push_back(dx);
		Y.push_back(dy);
	}

	const int N = X.size();

	for(int i = 1; i < N; i++) {
		X[i] -= X[0];
		Y[i] -= Y[0];
	}

	X[0] = 0;
	Y[0] = 0;

	double S = 0;

	for(int i = 1; i < N - 1; i++) {
		double a = dist(X[0], Y[0], X[i], Y[i]);
		double b = dist(X[i], Y[i], X[i + 1], Y[i + 1]);
		double c = dist(X[i + 1], Y[i + 1], X[0], Y[0]);

		double z = (a + b + c) / 2;
		S += sqrt(z * (z - a) * (z - b) * (z - c));
	}

	cout << S << endl;
	return 0;
}

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

fn main() {
    let mut s = read1::<String>().chars().collect::<Vec<char>>();
    s.insert(4, ' ');
    println!("{}", s.iter().map(|&c| c).collect::<String>());
}

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

# define C continue;
# define R return

# define D double
# define I insert
# define ll long long
# define ld long double

# define ull unsigned long long
# define ui unsigned int

# define pb push_back
# define pf push_front

# define vi vector < int >
# define vc vector < char >
# define vs vector < string >
# define vb vector < bool >
# define vd vector < D >
# define vll vector < ll >
# define vull vector < ull >
# define vld vector < ld >
# define PQ priority_queue

# define vvi vector < vector < int > >
# define vvb vector < vector < bool > >
# define vvc vector < vector < char > >
# define vvs vector < vs >
# define vvll vector < vector < ll > >
# define vvd vector < vector < D > >
# define vvld vector < vector < ld > >

# define all(v) (v).begin() , (v).end()
# define allrev(v) (v).rbegin() , (v).rend()
# define allcomp(v) v.begin() , v.end() , comp
# define allrevcomp(v) v.rbegin() , v.rend() , comp

# define pii pair < int , int >
# define pll pair < ll , ll >
# define pld pair < ld , ld >
# define pDD pair < D , D >

# define vpld vector < pld >
# define vpii vector < pii >
# define vpll vector < pll >
# define vpDD vector < pDD >

# define vvpii vector < vector < pii > >
# define F first
# define S second
# define mp make_pair

# define dist(a,b,p,q) sqrt((p-a)*(p-a) + (q-b)*(q-b))

# define pp(n) printf("%.10Lf",n);
# define line cout<<"\n";
# define fast ios_base::sync_with_stdio(false) ; cin.tie(0) ; cout.tie(0);

string vow = "aeiou";
int month[] = {-1, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

const int dxhorse[] = {-2, -2, -1, -1, 1, 1, 2, 2};
const int dyhorse[] = {1, -1, 2, -2, 2, -2, 1, -1};

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

const ld pie = 3.1415926535897932384626 ;
const ll mod = 1e9 + 7 ;

/// Tip : If a and b are positive integers ; we may say - ceil (a/b) = 1 + floor ( (a-1)/b ) .

void solve ( int test_case )
{
    ll a , b , c , k ;
    cin >> a >> b >> c >> k ;

    ll t = min ( a , k ) ;

    k -= t ;
    ll ans = t ;

    t = min ( k , b ) ;

    k -= t ;

    t = min ( k , c ) ;
    k -= t ;
    ans -= t ;

    cout << ans << "\n" ;
}

int main()
{
    int t = 1;
    // cin >> t;

    for ( int i = 1 ; i <= t ; i ++ )
    {
        solve ( i ) ;
    }

    return 0;
}


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

int main(){
  int n,m,H,K,x[101],y[101],h[101];
  cin >> n;
  r(i,n){
    cin >> x[i]>> y[i] >> h[i];
    if(h[i])m=i;
  }
  r(i,101){
    r(j,101){
      H=abs(x[m]-i)+abs(y[m]-j)+h[m];
      r(k,n){
        if(h[k]!=max(0,H-abs(x[k]-i)-abs(y[k]-j)))break;
        K=k;
      }
      if(K==n-1){
        cout << i << " " << j << " "<< H <<endl;
        return 0;
      }
    }
  }
}

Measured memory_bytes: 256
S=input()
S_len = len(S)
S_num = [0]*(S_len-2)
for i in range(S_len - 2):
    S_num[i] = int(S[i]+S[i+1]+S[i+2])
    S_num[i] = abs(753-S_num[i])
print(min(S_num))

Measured memory_bytes: 3060
#include <iostream>
#include <math.h>
#include <stdlib.h>
using namespace std;

int main(){
  int x;
  int y;
  cin >> x >> y;
  int count;
// caseA
  if((y-x)>0){
// A1
    if((y>0)&&(x>=0)){
     count=y-x;
    }
    //A2
    else if((y>0)&&(x<0)){
      if(abs(x)<abs(y)){
	count=1+y+x;
      }
      else if(abs(x)==abs(y)){
	count=1;
      }
      else{
	count=1-y-x;
      }
    }
    //A4
    else if((y==0)&&(x<0)){
      count=-x;
    }
    else{
      count=y-x;
    }
  }
// case B
  else{
    if((x>0)&&(y>0)){
      count=2-y+x;
    }
    else if((x>0)&&(y==0)){
      count=1+abs(x);
    }
    else if((x>0)&&(y<0)){
       if(abs(x)<abs(y)){
	count=-y-x+1;
      }
      else if(abs(x)==abs(y)){
	count=1;
      }
      else{
	count=1+y+x;
      }
    }
    else if((x==0)&&(y<0)){
      count=-y+1;
    }
    else{
      count=2-y+x;
    } 
  }
 
  cout << count << endl;

  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
using namespace std;
const long long NR=210000;
long long n,k,ans,a[NR];
int main()
{
	scanf("%lld%lld",&n,&k);
	for(long long i=1;i<=n;i++)
	{
		scanf("%lld",&a[i]);
	}
	sort(a+1,a+n+1);
	for(long long i=1;i<=(n-k);i++)
	{
		ans+=a[i];
	}
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mod = 998244353;

int main(){
  ll n,d,a,sum = 0;
  cin >> n >> d >> a;
  vector<pair<ll,ll>>x(n);
  vector<ll>pm(n+1),ac(n),it(n+1);
  for(int i =0; i<n; i++){
    cin >> x[i].first >> x[i].second;
    it[i] = x[i].first;
  }
  it[n] = 10000000000;
  sort(x.begin(),x.end());
  sort(it.begin(),it.end());
  
  for(ll i=0; i<n; i++){
    if(i>0) ac[i] = ac[i-1] - pm[i];
    x[i].second -= ac[i]*a;
    if(x[i].second <= 0)continue;
    ll count = x[i].second/a;
    if(x[i].second%a != 0)count++;
    ll fin = it[i]+d*2;
    ll Itre = upper_bound(it.begin(),it.end(),fin)-it.begin();
    pm[Itre]+=count;
    ac[i] += count;
    x[i].second -= count*a;
    sum += count;
  }
  
  
  cout << sum << endl;
  
  
}


Measured memory_bytes: 10920
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
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; }

bool buy[100110];

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int x;
	cin >> x;
	buy[0] = true;
	rep(i,x){
		rep(j,6){
			buy[i+100+j] |= buy[i];
		}
	}
	cout << (buy[x] ? '1' : '0') << endl;
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define printVec(v) printf("{"); for (const auto& i : v) { std::cout << i << ", "; } printf("}\n");
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; }
using namespace std;
using P = pair<int,int>;
using ll = long long;
const ll INF = 1LL<<60;
const double PI = 3.1415926535897932;
const int MOD = 1e9 + 7;

//cin.tie(0);ios::sync_with_stdio(false);
int main() {
  ll a, b, n;
  cin >> a >> b >> n;

  ll r;
  if (n < b) {
    r = n;
  } else {
    r = b - 1;
  }

  cout << a * r / b << endl;
  return 0;
}


Measured memory_bytes: 3584
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,a[100005],i,t=1,ans=0;
	cin>>n;
	for(i=1;i<=n;i++)
		cin>>a[i];
	sort(a+1,a+1+n);
	for(i=1;i<=n;i++)
	{
		if(a[i]==a[i+1])
			t++;
		if(a[i]!=a[i+1]||i==n-1)
		{
			if(a[i]<t) 
				ans+=t-a[i];//?
			if(a[i]>t) 
				ans+=t;//??
			if(a[i]!=a[i+1]&&i==n-1) 
				ans++;//???
			if(i<n-1) 
				t=1;
			else break;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <map>

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;

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

using namespace std;

const ll BIG = 1000000007LL;

int inputValue(){
    int a;
    cin >> a;
    return a;
};

template<typename T>
void inputArray(T* p, int a){
    rep(i, a){
        cin >> p[i];
    }
};

template<typename T>
void inputVector(vector<T> * p, int a){
    rep(i, a){
        T input;
        cin >> input;
        p -> push_back(input);
    }
}

template <typename T>
void output(T a, int precision = 0) {
    if(precision > 0){
        cout << setprecision(precision)  << a << "\n";
    }
    else{
        cout << a << "\n";
    }
}

const int Max = 30;
int n, p[Max];

int main(int argc, const char * argv[]) {
    cin >> n;
    inputArray(p, n);
    int count = 0;
    repd(i, 1, n-1) {
        if ((p[i] > p[i-1] && p[i] < p[i+1]) || (p[i] < p[i-1] && p[i] > p[i+1])) {
            count++;
        }
    }

    output(count);


    return 0;
}

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

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;

const int N = 200010;
const double eps = 1e-6;

int n, m;
int sum[N];
char str[N];

int main()
{
    scanf("%d%d%s", &n, &m, str + 1);

    for(int i = 1; i <= n; i++)
        sum[i] += sum[i - 1] + (str[i - 1] == 'A' && str[i] == 'C');

    while(m--)
    {
        int l, r;
        scanf("%d%d", &l, &r);
        printf("%d\n", sum[r] - sum[l]);
    }
    return 0;
}


Measured memory_bytes: 1280
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
#define FOR(i,a,b) for (size_t i = a; i < b; i++)
#define REP(i,b) FOR(i,0,b)
#define RFOR(i,a,b) for (size_t i = a-1; i >= b; i--)
#define RREP(i,a) RFOR(i,a,0)
#define INF 1e7

vector<string> v;

int main()
{
  int N, L;
  string ans = "";
  cin>>N>>L;

  REP(i,N) {
    string S;
    cin>>S;
    v.push_back(S);
  }

  sort(v.begin(), v.end());

  for (vector<string>::iterator itr = v.begin(); itr != v.end(); ++itr) {
    ans += *itr;
  }

  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <cstring>
#include <utility>
#include <vector>
#include <complex>
#include <valarray>
#include <fstream>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <numeric>

#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = Y-1;(X) >= 0;--(X))
#define repa(X,A,Y) for (int (X) = A;(X) <= (Y);++(X))
#define all(X) (X).begin(),(X).end()
#define mod(n, m) (((n)%(m)+(m))%m)
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
const int INFINT = 1 << 30;                          // 1.07x10^ 9
const ll INFLL = 1LL << 60;                          // 1.15x10^18
const double EPS = 1e-10;
const int MOD = 1000000007;

const int MAX_N = 100000;
int N, K, C;
int T[MAX_N];

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

  cin >> N >> C >> K;
  rep(i, N) cin >> T[i];
  sort(T, T+N);

  int ans = 0, t = T[0], c = 0;
  for (int i = 0; i < N-1; ++i) {
    ++c;
    if (T[i+1] > t+K || c == C) {
      ++ans; c = 0; t = T[i+1];
    }
  }
  ++ans;

  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define endl "\n"
#define se second
#define ll long long
#define inf 0x3f3f3f3f
#define fast    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int N = 3e5+10;
const ll mod =   1e9+7;

int main()
{  fast
//ll a,b,cx;
long double a,b;
cin>>a>>b;a*=b;
ll x=a;
cout<<x;

}

Measured memory_bytes: 3748
#include<cstdio>
#include<iostream>
#include<cstring>
using namespace std;
int main(void)
{
	int n,a,b,c,i;
	cin>>n;
	b=0;
	c=0;
	for(i=0;i<n;i++){
		cin>>a;
		if(a>b) b=a;
		c=c+a;
	}
	c=c-b;
//	cout<<b<<endl;
//	cout<<c<<endl;
	if(b<c){
		cout<<"Yes"<<endl;
	}
	else{
		cout<<"No"<<endl;
	}
}


Measured memory_bytes: 256