akhauriyash/Code-Regression huggingface dataset:
using AtCoderBeginnerContest156.Questions;
using AtCoderBeginnerContest156.Extensions;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;

namespace AtCoderBeginnerContest156.Questions
{
    public class QuestionC : AtCoderQuestionBase
    {
        int[] x = null;
        public override IEnumerable<object> Solve(TextReader inputStream)
        {
            var n = inputStream.ReadInt();
            x = inputStream.ReadIntArray();

            yield return Enumerable.Range(1, 100).Min(c => CalculateHP(c));
        }

        private int CalculateHP(int coodinate)
        {
            var hp = 0;
            for (int i = 0; i < x.Length; i++)
            {
                hp += (x[i] - coodinate) * (x[i] - coodinate);
            }
            return hp;
        }
    }
}


namespace AtCoderBeginnerContest156
{
    class Program
    {
        static void Main(string[] args)
        {
            IAtCoderQuestion question = new QuestionC();    // 問題に合わせて書き換え
            var answers = question.Solve(Console.In);
            foreach (var answer in answers)
            {
                Console.WriteLine(answer);
            }
        }
    }
}

#region Base Classes

namespace AtCoderBeginnerContest156.Questions
{

    public interface IAtCoderQuestion
    {
        IEnumerable<object> Solve(string input);
        IEnumerable<object> Solve(TextReader inputStream);
    }

    public abstract class AtCoderQuestionBase : IAtCoderQuestion
    {
        public IEnumerable<object> Solve(string input)
        {
            var stream = new MemoryStream(Encoding.Unicode.GetBytes(input));
            var reader = new StreamReader(stream, Encoding.Unicode);

            return Solve(reader);
        }

        public abstract IEnumerable<object> Solve(TextReader inputStream);
    }

}

#endregion

#region Extensions

namespace AtCoderBeginnerContest156.Extensions
{
    internal static class TextReaderExtensions
    {
        internal static int ReadInt(this TextReader reader) => int.Parse(ReadString(reader));
        internal static long ReadLong(this TextReader reader) => long.Parse(ReadString(reader));
        internal static double ReadDouble(this TextReader reader) => double.Parse(ReadString(reader));
        internal static string ReadString(this TextReader reader) => reader.ReadLine();

        internal static int[] ReadIntArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(int.Parse).ToArray();
        internal static long[] ReadLongArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(long.Parse).ToArray();
        internal static double[] ReadDoubleArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(double.Parse).ToArray();
        internal static string[] ReadStringArray(this TextReader reader, char separator = ' ') => reader.ReadLine().Split(separator);
    }
}

#endregion

Measured memory_bytes: 13396
def sentou(N: int, T: int, times: list) -> int:
    start_time, limit_time = 0, 0
    total_time = 0
    for t in times:
        if t >= limit_time:
            total_time += (limit_time - start_time)
            start_time = t
        limit_time = t + T
    return total_time + (limit_time - start_time)


if __name__ == "__main__":
    N, T = map(int, input().split())
    times = [int(s) for s in input().split()]
    ans = sentou(N, T, times)
    print(ans)


Measured memory_bytes: 25200
#include<bits/stdc++.h>
 
using namespace std;
 
#define all(a) a.begin(),a.end()
#define F first
#define S second
#define pb push_back
#define ll long long
#define vi vector<int>
#define pi pair<int,int>
#define mp make_pair
 
#ifdef LOCAL
#include "debug.h"
#else
#define debug(...) 42
#endif
 
const int mod=1e9+7;
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int mul(int a,int b)
{
	return ((a)*1ll*(b))%mod;
}
 
void add(int &a,int b)
{
	a+=b;
	if(a>=mod)a-=mod;
}
 
int sub(int a,int b){
	a-=b;
	if(a<0){
		a+=mod;
	}
	return a;
}
 
int powz(int a,int b)
{
	int res=1;
	while(b)
	{
		if(b&1)res=mul(res,a);
		b/=2;
		a=mul(a,a);
	}
	return res;
}
 
template <typename A, typename B>
istream& operator>>(istream& input,pair<A,B>& x) {
	input>>x.F>>x.S;
	return input;
}
 
template <typename A>
istream& operator>>(istream& input,vector<A>& x) {
	for(auto& i:x)
		input>>i;
	return input;
}
 
template<typename A>
ostream& operator<<(ostream& output,vector<A>& x) {
	for(auto& i:x)
		output<<i<<' ';
	return output;
}
 
const int N=200002;

void solve(){
	int n;
	cin>>n;
	vi b(n-1);
	cin>>b;
	ll ans=0;
	for(int i=0;i<n-1;i++){
		if(i==0){
			ans+=b[i];
		}
		else{
			ans+=min(b[i],b[i-1]);
		}
	}
	cout<<ans+b.back();
}
 
signed main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int tc=1;
	//~ cin>>tc;
	for(int _=0;_<tc;_++){
		//~ cout<<"Case #"<<_+1<<": ";
		solve();
		if(_!=tc-1)
		cout<<"\n";
	}
}
 



Measured memory_bytes: 256
import java.util.*;

public class Main{

    public static int gcd(int a, int b){
        if (a==0) return b;
        else if (b==0) return gcd(b, a);
        else if (a%b==0) return b;
        else{
            return gcd(b, a%b);
        }
    }

    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();

//        List<Integer> a = new ArrayList<>();
//        for (int i=0; i<n; i++) a.add(sc.nextInt());

//        for (int i=0 ;i<n; i++){
//            if (a.remove(a.get(i)))
//        }

        int ans = 0;
        int a[] = new int[n];
        for (int i=0; i<n; i++) a[i] = sc.nextInt();
//        int ans_list[] = new int[n];
//        List<Integer> ans_list = new ArrayList<>();

        int answer = 0;

        int l[] = new int[n];
        int r[] = new int[n];

        l[0] = 0;
        for (int i=1; i<n; i++){
            l[i] = gcd(l[i-1], a[i-1]);
        }
        r[n-1] = 0;
        for (int i=n-2; i>=0; i--){
            r[i] = gcd(r[i+1], a[i+1]);
        }

        for (int i=0; i<n; i++){
            ans = Math.max(ans, gcd(l[i], r[i]));
        }

        System.out.println(ans);
//        for (int i=0; i<n; i++){
//            ans = 0;
//            int tmp = a.get(i);
//            a.remove(a.get(i));
//            for (int j= 0; j<n-1; j++){
//                ans = gcd(ans, a.get(j));
//            }
//            a.add(i, tmp);
//            if (answer<ans) answer=ans;
////            ans_list.add(ans);
//        }

//        System.out.println(ans_list);
//        System.out.println(a);
//        System.out.println(answer);

    }

}


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

using namespace std;

typedef long long LL;

const int NMAX = 2e5;
const int VMAX = 1e6;

int N;
LL C;
LL dp[NMAX + 5];

class LiChao
{
public:
    struct Line
    {
        LL a = 0, b = 0;
        Line() { ; }
        Line(LL _a, LL _b) { a = _a, b = _b; }
        LL operator()(LL x) { return a * x + b; }
    };

    Line aint[4 * VMAX];

    void build(int nod, int st, int dr)
    {
        aint[nod] = Line((1LL << 30), (1LL << 60));
        if(st == dr)    return;
        int mij = st + (dr - st) / 2;
        build(nod * 2, st, mij);
        build(nod * 2 + 1, mij + 1, dr);
    }

    void update(int nod, int st, int dr, Line l)
    {
        int mij = st + (dr - st) / 2;

        if(l(mij)< aint[nod](mij)) swap(aint[nod], l);

        if(st == dr)    return;

        if(l(st) < aint[nod](st))   update(nod * 2, st, mij, l);
        if(l(dr) < aint[nod](dr))   update(nod * 2 + 1, mij + 1, dr, l);
    }

    LL query(int nod, int st, int dr, int pos)
    {
        if(st == dr)    return aint[nod](pos);

        LL val = aint[nod](pos);
        int mij = st + (dr - st) / 2;
        if(pos <= mij)  val = min(val, query(nod * 2, st, mij, pos));
        else    val = min(val, query(nod * 2 + 1, mij + 1, dr, pos));
        return val;
    }

    void update(LL x, LL y)
    {
        update(1, 1, VMAX, Line(x, y));
    }

    LL query(LL x)
    {
        return query(1, 1, VMAX, x);
    }

    void build()
    {
        build(1, 1, VMAX);
    }

}lichao;

int main()
{
    //freopen("1.in", "r", stdin);

    cin >> N >> C;
    LL h;
    cin >> h;
    lichao.build();
    lichao.update(-2LL * h, h * h);
    for(int i = 2; i <= N; i++)
    {
        cin >> h;
        LL val = lichao.query(h);
        dp[i] = val + h * h + C;
        lichao.update(-2LL * h, h * h + dp[i]);
    }

    cout << dp[N];

    exit(0);
}


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


typedef long long ll;
typedef vector<long long> vll;
typedef vector<pair<int,int>> vp;
typedef pair<int,int> pii;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,n) for(int i=1;i<=(int)(n);i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define ALL(a)  a.begin(),a.end()
#define RALL(a) a.begin(),a.end(),greater<int>()
#define ROT(a) a.begin(),a.begin()+1,a.end()
#define RROT(a) a.begin(),a.end()-1,a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
#define sz(a) a.size()
const ll MOD = 1e9+7;
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
//cout << 'H' << endl;
/*--------------------------------------------*/
vector< int64_t > divisor(int64_t n) {
  vector< int64_t > ret;
  for(int64_t i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}

int main(){
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll N;
    cin >> N;

    int ans = 100000;

    auto vec = divisor(N);

    for(auto i:vec)
    {
        chmin(ans,max(sz(to_string(i)),sz(to_string(N/i))));
    }

    cout << ans << endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout<<(ans)<<endl
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int
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;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);};};
const int MOD = 1000000007;
const int INF = INT_MAX;
const ll LLINF = 1LL<<62;


pair<ll,ll> insec(pair<ll,ll> a, pair<ll,ll> b) {
	if(a.first>a.second||b.first>b.second){
		return mp(-1,-2);
	}
	if(a.first>b.first){
		swap(a,b);
	}
	if(a.second<b.first){
		return mp(-1,-2);
	}
	if(a.second>=b.second){
		return b;
	} else{
		return mp(b.first,a.second);
	}
}
ll calc(pair<ll,ll> a, pair<ll,ll> b){
	ll suma=max(a.second-a.first+1,(ll)0);
	ll sumb=max(b.second-b.first+1,(ll)0);
	return suma+sumb;
}


int main(void) {

	int n;
	cin>>n;
	vector<pair<ll,ll> > v(n);
	rep(i,n){
		ll l,r;
		cin>>l>>r;
		v[i]=mp(l,r);
	}
	Sort(v);
	ll ans=0;
	vector<pair<ll,ll> > up(n),down(n);
	{
		up[0]=v[0];
		for(int i=1;i<n;i++){
			pair<ll,ll> tmp;
			tmp=insec(v[i],up[i-1]);
			up[i]=tmp;
		}
		down[n-1]=v[n-1];
		for(int i=n-2;i>=0;i--){
			pair<ll,ll> tmp;
			tmp=insec(v[i],down[i+1]);
			down[i]=tmp;
			
		}
		for(int i=0;i<n-1;i++){
			ans=max(ans,calc(up[i],down[i+1]));
		}
		// for(int i=0;i<n;i++){
		// 	cout<<up[i].first<<":"<<up[i].second<<" "<<down[i].first<<":"<<down[i].second<<endl;
		// }
	}
	for(int i=1;i<n-1;i++){
		ll a=v[i].second-v[i].first+1;
		pair<ll,ll> tmp=insec(up[i-1],down[i+1]);
		ans=max(ans,a+max(tmp.second-tmp.first+1,(ll)0));
	}
	
	
	fin(ans);


}



Measured memory_bytes: 5504
#include<bits/stdc++.h>
using namespace std;
#define MAX 3100
int dp[MAX][MAX];


int main(){
	for(int i=0;i<MAX;i++){
		for(int j=0;j<MAX;j++){
			dp[i][j]=0;
		}
	}

	string s,t;		cin>>s>>t;


	for(int i=0;i<s.length();i++){
		for(int j=0;j<t.length();j++){
			if(s[i]==t[j]){
				dp[i+1][j+1]=max(dp[i+1][j+1], dp[i][j]+1);
			}
			dp[i+1][j+1]=max(dp[i+1][j+1],dp[i+1][j]);
			dp[i+1][j+1]=max(dp[i+1][j+1],dp[i][j+1]);
		}
	}


	string ans="";
	int i=s.length(),	j=t.length();
	while(i>0 && j>0){
		

		// 1. (i-1, j) -> (i, j) と更新されていた場合
		if(dp[i][j]==dp[i-1][j]){
			--i;
		}

		// 2. (i, j-1) -> (i, j) と更新されていた場合
		else if(dp[i][j]==dp[i][j-1]){
			--j;
		}

		// 3.
		else{
			// この時、s[i-1] == t[j-1]
			ans = s[i-1] + ans;

			--i;
			--j;
		}
	}

	cout<<ans<<endl;


	return 0;
}


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

#define MOD 1000000007
#define f first
#define s second
#define es " "
#define pb push_back
#define endl "\n"
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define ll long long int
#define fastio ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)

vector<int> viz[100005];

int dp[100005];

int solve(int obj){
    if(dp[obj]!=-1){
        return dp[obj];
    }
    if(viz[obj].size()==0){
        return dp[obj]=0;
    }
    int ans=0;
    for(int i=0; i<viz[obj].size(); i++){
        ans=max(ans, 1+solve(viz[obj][i]));
    }
    return dp[obj]=ans;
}

int main(){
    fastio;
    int n, m;
    memset(dp, -1, sizeof(dp));
    cin >> n >> m;
    for(int i=0, a, b; i<m; i++){
        cin >> a >> b;
        viz[a].pb(b);
    }
    int resp=0;
    for(int i=1; i<=n; i++){
        if(dp[i]==-1){
            resp=max(resp, solve(i));
        }
    }
    cout << resp << endl;
    return 0;
}

Measured memory_bytes: 11516
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdint.h> // int64_t

#define max(a,b) ((a) > (b) ? (a) : (b))
#define min(a,b) ((a) > (b) ? (b) : (a))

int get_int2(int *a1, int *a2) {
  scanf("%d %d", a1, a2);
  return 0;
}

struct pair {
    int v1;
    int v2;
};

#define EDGE_MAX 10000

int main(void) {
    int num, k;
    get_int2(&num, &k);

    struct pair ps[EDGE_MAX];
    int pidx = 0;
    int mmax = (num-1)*(num-2)/2;
    if(k > mmax) {
        printf("-1\n");
        goto finish;
    }

    int i, j;
    int cnt = mmax;
    for(i = 1; i <= num-1; i++) {
        ps[pidx++] = (struct pair){i, num};
    }
    for(i = 1; i <= num-1; i++) {
        for(j = i+1; j <= num-1; j++) {
            if(cnt == k) goto exist;
            ps[pidx++] = (struct pair){i, j};
            cnt--;
        }
    }
exist:
    printf("%d\n", pidx);
    for(i = 0; i < pidx; i++) {
        printf("%d %d\n", ps[i].v1, ps[i].v2);
    }
finish:
    return 0;
}

Measured memory_bytes: 256
MOD = 1000000007
from collections import defaultdict as dd,Counter,deque

def si(): return input()
def ii(): return int(input())
def li(): return list(map(int,input().split()))
def mi(): return map(int,input().split())
def out(v): print(v)
def spout(): print(v,end=" ")
def d2b(n): return bin(n).replace("0b","")
def twod(n,m,num):return [[num for x in range(m)] for y in range(n)]
def vow(): return ['a','e','i','o','u']
def let(): return [chr(i) for i in range(97,123)]
def gcd(x, y):
    while y:
        x, y = y, x % y
    return x
def ispow2(x):
    return (x and (not(x & (x - 1))))
def prime_factors(n):
    i = 2
    factors = []
    while i * i <= n:
        if n % i: i+=1
        else:
            n //= i
            factors.append(i)
    if n > 1: factors.append(n)
    return (list(factors))
    
    
n,k,t=mi()
print(t*(n//k if n%k==0 else n//k+1))

Measured memory_bytes: 9412
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>

using namespace std;
using lli = long long int;
// #define DEBUG
#ifdef DEBUG
#define debug(var) cout << (#var) << ": " << (var) << endl;
template<class T> void dump_array_impl(const T& a) {
  bool first = true;
  for (auto&& x : a) {
    if (!first) cout << ", "; else first = false; cout << x;
  }
}
#define debug_array(a) cout<<(#a)<<": ";dump_array_impl(a);cout<<endl
#else
#define debug(var) {}
#define debug_array(a) {}
#endif
template<class T> void read_n(vector<T>& v, size_t n) {
  v = vector<T>(n); for (lli i=0; i<n; ++i) cin >> v[i];
}
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

int main() {
  lli n;
  cin >> n;
  const char* ans = "No";
  for (int i=0; i<=n; i+=4) {
    if ((n-i)%7==0) { ans = "Yes"; break; }
  }
  cout << ans << endl;
  return 0;
}


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

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

#define CHMIN(a, b) (a) = min((a), (b))
#define CHMAX(a, b) (a) = max((a), (b))

#define DEBUG(x) cout << #x << ": " << (x) << endl
#define PRINT(x) cout << x << endl
int main() {
  int N, T;
  cin >> N >> T;
  vector<pii> V(N);

  FOR(i, 0, N) {
    int a, b;
    cin >> a >> b;
    V[i] = pii(a, b);
  }

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

  FOR(i, 0, N) {
    int c = V[i].first;
    int t = V[i].second;

    if (t <= T) {
      PRINT(c);
      return 0;
    }
  }

  PRINT("TLE");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF (1<<30)
#define MOD 1000000007
#define l_ength size
using ll = long long;
using namespace std;

int main(){
	int n; cin >> n;
	vector<ll> a(n);
	for( auto &k : a ) cin >> k;
	sort( a.begin(), a.end(), greater<ll>() );
	vector<ll> candy;
	int cnt = 0;
	for( int i = 1; i < n; ++i ){
		if( cnt == 2 ) break;
		if( a[i-1] == a[i] ){
			candy.push_back(a[i]);
			++cnt;
			++i;
		}
	}
	if( cnt == 2 ){
		cout << candy[0]*candy[1] << endl;
		return 0;
	} else {
		cout << 0 << endl;
		return 0;
	}		
	return 0;
} 

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

#define endl '\n'
#define PB push_back
#define PF push_front
#define MP make_pair
#define fi first
#define se second
#define all(v) v.begin(),v.end()

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;

const int INF = 1e9 + 7;
const ll LINF = 1e18 + 14;

const ll mod = 998244353;

int main(){
    ios_base::sync_with_stdio(false); //cin.tie(nullptr); cout.tie(nullptr);
    int n;
    cin >> n;
    int k;
    cin >> k;
    vector<int> l(k), r(k);
    for (int i = 0; i < k; i++) {
        cin >> l[i] >> r[i];
    }

    vector<ll> dp(n * 2);
    vector<ll> sums(n * 2);
    dp[n] = 1;
    sums[n] = 1;
    for (int i = n + 1; i < n * 2; i++) {
        for (int j = 0; j < k; j++) {
            dp[i] = (mod + dp[i] + sums[i - l[j]] - sums[i - r[j] - 1]) % mod;
        }
        sums[i] = (mod + sums[i-1] + dp[i]) % mod;
    }    
    
    cout << dp.back() % mod;
    return 0;
} 



Measured memory_bytes: 9544
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string a,b;
    getline(cin,a);
    getline(cin,b);
    sort(a.begin(),a.end());
    sort(b.begin(),b.end(),greater<char>());
    if(a<b)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define lld long long int
#define vec vector<lld>
#define pll pair<lld,lld>
#define pb push_back
#define ss second
#define ff first
#define mp make_pair
#define mod 1000000007
#define answer(x) cout<<endl<<"answer : "<<x<<endl<<endl;
#define op(x) cout<<x<<endl;
#define maxn 500005
#define messi ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
int main() {messi lld t=1;//cin>>t;
    while(t--)
    {
        lld n=0,m=0,k=0,i=0,j=0,p=0,q=0,x=0,y=0,z=0,ans=0,cnt=0,l=0,r=0,mid=0,lo=0,hi=0;string s;bool flag=false;
        cin>>s;n=s.length();
        for(i=0;i<n;i++)
            cnt+=(int)(s[i]-'0');
        if(cnt%9==0)
            cout<<"Yes"<<endl;
        else
            cout<<"No"<<endl;
    }
	return 0;
}
/*  CODED BY:-
 ________________________________________
|            __        __                |
|  /\   /\  |__)  /\  |  \ |__| \ /  /\  |
| /~~\ /~~\ |  \ /~~\ |__/ |  |  |  /~~\ |
|________________________________________|

*/


Measured memory_bytes: 3764
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main()
{
    int a, p;
    cin >> a >> p;
    int ans = (a*3 + p) / 2;
    cout << ans << endl;
    return 0;
}

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

long long n, a, num, ans, i;

int main () {
	ios_base::sync_with_stdio(0); cin.tie(NULL);

	cin >> n;
	for (i=1; i<=n; i++) {
		cin >> a;
		num+=a;
		if (a==0 or i==n) {
			ans+=num/2;
			num=0;
		}
	}
	cout << ans;

}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include <cassert>
#include <cmath>
#include<cstdint>

#define INF 1e9
#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()

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

vector<int>bitSearch(int bit,int n){
    vector<int>S;
    rep(i,n)if(bit&(1<<i))S.push_back(i);
    return S;
}


int d[3] = {-1,0,1};
int main(){
    int a,b;char c;cin>>a>>c>>b;
    if(c=='+')cout<<a+b;
    else cout<<a-b;
}



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

int sx, sy, tx, ty;

int main() {
    while( scanf( "%d%d%d%d", &sx, &sy, &tx, &ty ) != EOF ) {
        
        for( int i = 0; i < ty-sy; ++i ) {
//            ans += 'U';
            putchar( 'U' );
        }
        for( int i = 0; i < tx-sx; ++i ) {
//            ans += 'R';
            putchar( 'R' );
        }
        for( int i = 0; i < ty-sy; ++i ) {
//            ans += 'D';
            putchar( 'D' );
        }
        
        for( int i = 0; i < tx-sx; ++i ) {
//            ans += 'L';
            putchar( 'L' );
        }
//        ans += 'L';
        putchar( 'L' );
        for( int i = 0; i < ty-sy+1; ++i ) {
//            ans += 'U';
            putchar( 'U' );
        }
        for( int i = 0; i < tx-sx+1; ++i ) {
//            ans += 'R';
            putchar( 'R' );
        }
//        ans += 'D';
//        ans += 'R';
        putchar( 'D' );
        putchar( 'R' );
        for( int i = 0; i < ty-sy+1; ++i ) {
//            ans += 'D';
            putchar( 'D' );
        }
        for( int i = 0; i < tx-sx+1; ++i ) {
//            ans += 'L';
            putchar( 'L' );
        }
//        ans += 'U';
        putchar( 'U' );
        puts( "" );
//        cout<<ans<<endl;C
    }

    
    
}






Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int H, W, K;
vector<string> fi;

int solve() {
    int res = 1<<29;
    for (int bit = 0; bit < (1<<(H-1)); ++bit) {
        bool gok = true; // そもそも不可能な場合もあるので判定
        int N = 0;
        vector<int> ord(H, 0);
        for (int i = 0; i < H-1; ++i) {
            if (!(bit & (1<<i))) ord[i+1] = ord[i];
            else ord[i+1] = ord[i]+1, ++N;
        }
        int add = 0;
        vector<int> nums(N+1, 0);
        for (int w = 0; w < W; ++w) {
            vector<int> one(N+1, 0);
            bool ok = true;
            for (int h = 0; h < H; ++h) {
                one[ord[h]] += fi[h][w] - '0';
                nums[ord[h]] += fi[h][w] - '0';
                if (one[ord[h]] > K) gok = false;
                if (nums[ord[h]] > K) ok = false;
            }
            if (!ok) ++add, nums = one;
        }
        if (gok) chmin(res, N + add);
    }
    return res;
}

int main() {
    cin >> H >> W >> K;
    fi.resize(H);
    for (int i = 0; i < H; ++i) cin >> fi[i];
    cout << solve() << endl;
}

Measured memory_bytes: 256
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let s = read::<String>().chars().collect::<Vec<_>>();
    let t = read::<String>().chars().collect::<Vec<_>>();

    if (0..s.len()).all(|x| s[x] == t[x]) {
        println!("Yes");
    } else {
        println!("No");
    }
}

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()
}


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

#define ll long long
#define inf 0x3f3f3f3f
const int maxn=2e5+5;
#define mod 1000000007
int a[maxn];
int f[maxn];
int main()
{
    int n;
    bool flag=0;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
        if(a[i]==1) flag=1;
    }
    int cnt=1;
    for(int i=1;i<=n;i++)
    {
        if(a[i]==cnt) cnt++;

    }
    if(flag) cout<<n-cnt+1<<endl;
    else cout<<"-1"<<endl;
    return 0;
}

Measured memory_bytes: 1024
{-# LANGUAGE BangPatterns #-}

module Main where

import Data.Char
import Data.List
import Control.Monad
import Control.Applicative
import Text.Printf


readInt :: IO Int
readInt = read <$> (input `seq` input)
    where input = do
            !c <- getChar
            if isDigit c || c == '-'
                then (c :) <$> input
                else return []

prints :: Show a => [a] -> IO ()
prints as = putStrLn $ concat $ intersperse " " $ map show as

main = do
    n <- readInt
    as <- replicateM n readInt
    putStrLn $ printf "%d %d %d" (minimum as) (maximum as) (sum as)


Measured memory_bytes: 13420
import sys
input = sys.stdin.readline


def main():
    a, b, c = map(int, input().split())
    k = int(input())
    while b <= a:
        b *= 2
        k -= 1

    while c <= b:
        c *= 2
        k -= 1

    if k >= 0:
        print("Yes")
    else:
        print("No")


if __name__ == "__main__":
    main()


Measured memory_bytes: 9104
// lcmとか__builtin_popcountとかはg++ -std=c++17 default.cppみたいなかんじで

#include <bits/stdc++.h>
#define mod 1000000007
#define INF LLONG_MAX
#define ll long long
#define ln cout<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define YES cout<<"YES"<<endl
#define No cout<<"No"<<endl
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
using namespace std;
ll dx[4]={1,0,-1,0};
ll dy[4]={0,1,0,-1};

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

    ll  a,b,c,d,e,n,k,maxi=0,f=0,mini=INF,sum=0,q;
	string str,stra,straa;
    ll x,y,z;
    char ca,cb,cc;
    cin>>n>>a>>b;
    cout<<min(n*a,b);
    return 0;
}


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

#define W 8
#define H 8

int main()
{
	int map[W][H] = {0};
	char a;
	int i, j;
	int flag;
	char form;

	while (1) {
		for (i = 0; i < W; i++)
			for (j = 0; j < H; j++)
				map[i][j] = 0;
		i = 0;
		j = 0;

		flag = 0;
		while (j<H) {
			if (scanf("%1c", &a) == EOF) {
				flag = 1;
				break;
			}
			if (a!='0' && a!='1') continue;
			map[i++][j] = a-'0';
			if (i == W) {
				i = 0;
				j++;
			}
		}
		if (flag) break;

		flag = 0;
		for (i = 0; i < W; i++) {
			for (j = 0; j < H; j++) {
				if (map[i][j]==1) {
					if (j+2<H && map[i][j+2]==1) {
						form = 'B';
					} else if (i+2<W && map[i+2][j]==1) {
						form = 'C';
					} else if (i+2<W && j-1>=0 && map[i+2][j-1]==1) {
						form = 'G';
					} else if (i+1<W && j-1>=0 && map[i+1][j-1]==1) {
						form = 'D';
					} else if (i+1<W && j+2<H && map[i+1][j+2]==1) {
						form = 'F';
					} else if (j+1<H && map[i][j+1]==1) {
						form = 'A';
					} else {
						form = 'E';
					}
					flag = 1;
					break;
				}
			}
			if (flag) break;
		}
		cout<<form<<endl;
	}

	return 0;
}

Measured memory_bytes: 0
#include<stdio.h>

int main(void)
{
	int N;
	long long power = 1;
	int i;
	scanf("%d",&N);

	for (i = 1; i <= N; i++) {
		power = (power * i) % 1000000007;
	}
	printf("%lld\n",power);
	return 0;
}


Measured memory_bytes: 128
#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 ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define ll long long
#define si(n) scanf("%d",&n);
#define PI acos(-1.0)
#define sl(n) scanf("%lld",&n);
#define sf(n) scanf("%lf",&n);
#define ss(n) scanf("%s",n);
#define for0(i,n) for(ll i=0;i<n;i++)
#define for1(i,n) for(ll i=1;i<=n;i++)
#define forc(i,j,n) for(ll i=j;i<n;i++)
#define pb push_back
#define sor(n) sort(n.begin(),n.end())
#define sorcmp(n) sort(n.begin(),n.end(),cmp)
#define rev(n) reverse(n.begin(),n.end())
#define pi(x)  printf("%d",x);
#define pl(x)  printf("%lld",x);
#define pf(x)  printf("%.10lf",x);
#define ps(x)  printf("%s",x);
#define en() printf("\n");
#define random_shuffle(r...)random_shuffle(r,[](int _){return rand()%_;})
#define SQR(a) (a)*(a)
#define sp(x) fixed<<setprecision(x)
#define mod 1000000007
#define endl '\n'
#define pii pair<int,int>
#define pll pair<ll,ll>
#define bug cout<<"Here"<<endl
void fastio(){ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);}
template <typename T> T POW(T B,T P){ if(P==0) return 1; if(P&1) return B*POW(B,P-1);  else return SQR(POW(B,P/2));}
ll powmod(ll a, ll b){ll ans = 1;while(b){if(b&1) ans = ans*a%mod;a = a*a%mod;b >>= 1;}return ans;}

int main(){
fastio();



            int x,y;
            cin>>x>>y;

            if(y%2)
            {
                cout<<"No"<<endl;
                return 0;
            }

            int b=y/2-x;
            int a=x-b;
            if(b>=0 && a>=0)
            {
                if(b*4+a*2==y) cout<<"Yes"<<endl;
                else cout<<"No"<<endl;
            }
            else cout<<"No"<<endl;





return 0;
}




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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    
    string S; cin >> S;
    ll N=S.size();
    ll P=2019;
    ll ans = 0;

    // Pが10と互いに素かどうかで場合分け
    if (P == 2 || P == 5){ // 最下桁がPで割り切れればok
        rep(i, N){
            if ((S[i] - '0') % P == 0){
                ans += (i + 1);
            }
        }
    } else {
        // 10^{n} (modP)を事前に計算
        vector<ll> modp_table(N);
        modp_table.at(0) = 1;
        rep(i, N-1){
            modp_table.at(i + 1) = 10 * modp_table.at(i) % P;
        }

        // 右からn文字使った数のmodPの値で分類，modP = a が2つ以上あればその間を使って一つ作れる
        map<ll, ll> modp_cnt;
        rep(i, P){modp_cnt[i] = 0;}
        modp_cnt[0] = 1; // 累積和と同様，0文字使った時を初期化
        ll tmp = 0;
        rep(i, N){
            tmp += (S[N - 1 - i] - '0') * modp_table.at(i) % P;
            modp_cnt[tmp % P] += 1;
        }
        rep(i, P){
            ll n = modp_cnt[i];
            if (n >= 2){ans += n * (n - 1) / 2;}
        }
    }
    cout << ans << endl;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


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

int main(){
	string s;
	cin >> s;
	string ans = "";
	ans+=s[0];
	for(int i=1;i<s.size();i++){
		if(s[i]!=s[i-1])
			ans+=s[i];
	}
	cout << ans.size()-1 << endl;
	return 0;
}


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

long long A[100005];

int K;

bool doesItWork(long long num){
    long long temp = num;
    for(int i = 0; i < K; i ++){
        temp = temp/A[i]*A[i];
    }
    return temp == 2;
}

int main(){
    scanf("%d", &K);

    for(int i = 0; i < K; i ++){
        scanf("%lld", &A[i]);
    }

    long long num = 2;
    for(int i = K-1; i >= 0; i --){
        long long temp = 1+(num-1)/A[i];
        num = temp*A[i];
    }

    long long num2 = 2;
    for(int i = K-1; i >= 0; i --){
        long long temp = 1+(num2-1)/A[i];
        num2 = (temp+1)*A[i]-1;
    }

    if(doesItWork(num)){
        printf("%lld ", num);

        long long lo = num;
        long long hi = 1LL << 61;
        while(lo < hi){
            long long mid = (lo+hi+1)/2;
            if(doesItWork(mid)){
                lo = mid;
            }else{
                hi = mid-1;
            }
        }
        printf("%lld", lo);
    }else{
        printf("-1");
    }
    return 0;
}


Measured memory_bytes: 1024
#include<stdio.h>
int main()
{
int n,i,j,k,ans,max;
  ans=0;
  scanf("%d",&n);
  long long int l[n];
  
  for(i=0;i<n;++i)
  {
  scanf("%lld",&l[i]);
  }
  
  for(i=2;i<n;i++)
  {
   for(j=1;j<i;j++)
   {
     if(l[j]!=l[i])
     {
     for(k=0;k<j;k++)
      {
       if(l[k]!=l[i] && l[k]!=l[j])
       {
       max=l[k];
         if(l[i]>max) max=l[i];
         if(l[j]>max) max=l[j];
         if(max < l[j]+l[i]+l[k]-max) ans++;
       }
      }
     }
   }
  }
printf("%d",ans);
return 0;
}

Measured memory_bytes: 1736
#include<stdio.h>
int main(void){
int a,b,c,d,i;
scanf("%d%d%d%d",&a,&b,&c,&d);
for(i=2;i<104;i++){
c-=b;
if(c<=0){ puts("Yes");break;}
a-=d;
if(a<=0){ puts("No");break;}
}
return 0;
}

Measured memory_bytes: 1660
#include <stdio.h> 
	

int main(void) {
	int N, M, count, flag, i;
	while( scanf("%d%d",&M,&N), M+N) {
		int member[1000] = {0};
		flag = 0;
		count = 0;
		while(flag != M) {
			for(i = 0; i < M; i++ ) {
				//printf("%d",member[i]);
				if(member[i] == 0 ) {
					count++;
					if(count == N ) {
						count = 0;
						member[i]++;
						//printf("%d\n",i+1);
						flag++;
						if(flag == M) {
							printf("%d\n",i+1);
						}
					}
				}
			}
		}
	}
	return 0;
}

Measured memory_bytes: 604
from sys import stdin
n,k = map(int,input().split())
l = [int(stdin.readline()) for _ in [0]*n]
l.sort()
difl = [0]*(n-k+1)
for i in range(n-k+1):
  difl[i] = l[i+k-1]-l[i]
print(min(difl))

Measured memory_bytes: 10844
{
  const main = (input: string) => {
    const r = reader(input)
    const N = r.n()
    const { pairs } = _divisor(N)

    let res = Infinity

    pairs.forEach(([a, b]) => {
      const k = a + b - 2

      res = Math.min(res, k)
    })
    console.log(res)
  }

  const reader = (str: string) => {
    const lines = str.trim().split('\n')
    const s = () => lines.shift() || ''
    const n = () => Number(s())

    const ss = () => s().split(' ')
    const ns = () => ss().map(Number)
    const nls = () => lines.map(Number)

    return { lines, s, n, ss, ns, nls }
  }
  const _divisor = (n: number) => {
    const sq = Math.floor(Math.sqrt(n))
    const list: number[] = []
    const pairs: [number, number][] = []

    for (let i = sq; i > 0; i--) {
      if (n % i !== 0) {
        continue
      }
      list.unshift(i)
      if (sq * sq !== n) {
        list.push(n / i)
      }
      pairs.unshift([i, n / i])
    }
    return { list, pairs }
  }

  const getInput = () => require('fs').readFileSync('/dev/stdin', 'utf8')

  main(getInput())
}


Measured memory_bytes: 9420
ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))

n = ii()
a = li()

sumnode = 0
sumleaf = sum(a)

nn = 1
sumnode = 1
if n == 0:
    if a[0] != 1:
        print(-1)
    else:
        print(1)
elif a[0] == 1:
    print(-1)
else:
    for i in range(1,n+1):
        if n == 0:
            print(-1)
            break

        if sumleaf > nn:
            nn = min(nn*2, sumleaf)
        
        sumnode += nn

        nn -= a[i]
        if nn < 0:
            print(-1)
            break
        sumleaf -= a[i]

        # print(i,nn,sumnode,sumleaf)
    else:
        print(sumnode)

Measured memory_bytes: 20172
#include<iostream>
#include<vector>
#include<stack>
using namespace std;
#define NIL -1
int n,m;
int color[1000100];
vector<int>G[100100];

void dfs(int r, int c){
  stack<int> S;
  S.push(r);
  color[r]=c;
  while(!S.empty()){
    int u=S.top();S.pop();
    for(int i=0;i<G[u].size();i++){
      int v=G[u][i];
      if(color[v]==NIL){
        color[v]=c;
        S.push(v);
      }
    }
  }
}

void assignColor(){
  int id=1;
  for(int i=0;i<n;i++)color[i]=NIL;
  for(int u=0;u<n;u++){
    if(color[u]==NIL)dfs(u,id++);
  }
}

int main(){
  int t,s,p,q,k,l;
  cin>>n>>m;
  for(int i=0;i<m;i++){
    cin>>t>>s;
    G[s].push_back(t);
    G[t].push_back(s);
  }

  assignColor();

  cin>>p;
  for(int i=0;i<p;i++){
    cin>>k>>l;
    if(color[k]==color[l]){
      cout<<"yes"<<endl;
    }else{
      cout<<"no"<<endl;
    }
  }
}



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

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
#ifdef _DEBUG_
#define dump(val) cerr << __LINE__ << ":\t" << #val << " = " << (val) << endl
#else
#define dump(val)
#endif

using namespace std;

typedef long long int ll;

template<typename T>
vector<T> make_v(size_t a, T b) {
    return vector<T>(a, b);
}

template<typename... Ts>
auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v(ts...))>(a, make_v(ts...));
}

class UnionFind {
public:
    vector<int> par, cnt;
    UnionFind(int n) {
        par.resize(n);
        cnt.resize(n, 1);
        REP(i, 0, n) {
            par[i] = i;
        }
    }
    int Find(int n) {
        return (n == par[n] ? n : par[n] = Find(par[n]));
    }
    ll Union(int a, int b) {
        a = Find(a);
        b = Find(b);
        if (a == b) return -1;
        par[a] = b;
        ll res = (ll)cnt[a] * cnt[b];
        cnt[a] += cnt[b];
        cnt[b] = cnt[a];
        return res;
    }
};

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    vector<int> A(m), B(m);
    REP(i, 0, m) {
        cin >> A[i] >> B[i];
        A[i]--;
        B[i]--;
    }
    UnionFind uf(n);
    ll ans = (ll)n * (n - 1) / 2;
    vector<ll> Ans(m);
    for (int i = m - 1; i >= 0; i--) {
        Ans[i] = ans;
        ll res = uf.Union(A[i], B[i]);
        if (res != -1) {
            ans -= res;
        }
    }
    REP(i, 0, m) {
        cout << Ans[i] << endl;
    }

    return 0;
}


Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
 
template <typename T> void print(T t) { cout<<t<<endl; }
template<typename T, typename... Args> void print(T t, Args... args) { cout<<t<<" "; print(args...); }

typedef complex<double> base;

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl '\n'
#define int long long
#define double long double

int32_t main() 
{
    IOS
    int k;
    cin>>k;
    int st=7;
    int ans=0;
    while(ans<=2e7)
    {
        st%=k;
        ans++;
        if(st==0)
            break;
        st=st*10+7;
    }
    if(ans>=1e7)
        print(-1);
    else
        print(ans);
}   


Measured memory_bytes: 3636
fn get_line() -> String {
    let mut line = String::new();
    std::io::stdin().read_line(&mut line).unwrap();
    line
}

fn evaluate(m: &i8, f: &i8, r: &i8) {
    let sum = m + f;
    match sum {
        80 ... 100 => println!("A"),
        65 ... 79 => println!("B"),
        50 ... 64 => println!("C"),
        30 ... 49 => if r >= &50 {
            println!("C");
        } else {
            println!("D");
        },
        _ => println!("F"),
    }
}

fn main() {
    loop {
        let nums: Vec<i8> = get_line().trim()
            .split_whitespace()
            .map(|n| n.parse().unwrap())
            .collect();
        let (m, f, r) = (nums[0], nums[1], nums[2]);
        if m == -1 && f == -1 && r == -1 {
            break
        }
        if m == -1 || f == -1 {
            println!("F");
        } else {
            evaluate(&m, &f, &r);
        }
    }
}



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

class Main{
    public static void main(String args[])throws IOException{
        try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))){
            String str = br.readLine();

            boolean one = false, two = false, three = false;

            one = ischeck(str);
            two = ischeck(str.substring(0, (str.length()-1)/2));
            three = ischeck(str.substring((str.length()+3)/2-1, str.length()));

            if(one && two && three){
                System.out.println("Yes");
            }else{
                System.out.println("No");
            }

        }
   
    }

    public static boolean ischeck(String s){
        int n = s.length();
        
        for(int i = 0; i < n/2; i++){
            if(s.charAt(i) != s.charAt(n-i-1)){
              return false;
            } 
        }
        
        return true;
    }
}

Measured memory_bytes: 22484
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int maxn =1e4+5;
const int mod=10000019;
const int inf=0x3f3f3f;
int main()
{
    int n;
    scanf("%d",&n);
    if(n>=30)printf("Yes\n");
    else printf("No\n");
    return 0;
}


Measured memory_bytes: 3764
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
	int r;cin>>r;
	cout << 3 * r * r << endl;
	return 0;
}

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

#define rep(i,x,y) for(int i=(x);i<(y);++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif

const int inf=1e9;
const int64_t inf64=1e18;
const double eps=1e-9;

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
    	os << v << ",";
    }
    os << "]";
    return os;
}

using i64=int64_t;

void solve(){
    i64 Q,H,S,D,N;
    cin >> Q >> H >> S >> D >> N;

    i64 x=min({Q*4,H*2,S}),y=min({Q*8,H*4,S*2,D}),ans=0;
    if(x*2>y){
        i64 ans=N/2*y;
        N%=2;
        ans+=N*x;
        cout << ans << endl;
    }else cout << x*N << endl;
}

int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main()
{
	int i, N, count = 0;
	char S[100001], tmp;
	scanf("%d", &N);
	scanf("%s", S);
	for (i = 0, tmp = 0; i < N; i++) {
		if (S[i] != tmp) {
			tmp = S[i];
			count++;
		}
	}
	printf("%d\n", count);
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 1828
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
//using namespace boost::multiprecision;
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> P;
#define PI 3.141592653589793
#define MOD 1000000007
//#define MOD 998244353
#define ALL(obj) (obj).begin(),(obj).end()
const ll INF = 1LL << 60;
//四方向への移動ベクトル
const int dx[4] = {1, 0, -1, 0};

struct edge{//グラフに使うヤツ
    ll from,to,cost;
};

typedef vector<vector<edge> > G;

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

int main(){
    ll zc=0;
    ll n;
    bool f=false;
    cin >> n;
    for (ll i=0;i<n;i++){
        ll a,b;
        cin >> a >> b;
        if (a==b)zc++;
        else zc=0;

        if (zc==3)f=true;

    }
    if (f)cout << "Yes";
    else cout << "No";
    cout << endl;
    return 0;
}


Measured memory_bytes: 3628
#include <iostream>
#include <vector>

using namespace std;

bool judge(int X, int Y,int h, int CX, int CY, int H){
    int height = max( H - abs(X - CX) - abs(Y - CY), 0);
//    cout << " hieght = " << height << endl;
    return height == h;
}


int main() {
    int N;
    cin >> N;
    
    int x[N], y[N], h[N];
    
    for(int i = 0; i < N; ++i){
        cin >> x[i] >> y[i] >> h[i];
    }
    
    vector<int> cand;
    vector<int> erase_list;
    for(int CX = 0; CX <= 100; ++CX){
        for(int CY = 0; CY <= 100; ++CY){
            for(int k = 0; k < N; ++k){
                if(h[k] == 0){
                    continue;
                } else {
                    cand = {h[k] + x[k] - CX + y[k] - CY,
                        h[k] + x[k] - CX - y[k] + CY,
                        h[k] - x[k] + CX + y[k] - CY,
                        h[k] - x[k] + CX - y[k] + CY};
                    break;
                }
            }
            
            
//            cout << "CX = "<< CX << " CY = " << CY << ", " << cand[0] << " " << cand[1] << " " << cand[2] << " " << cand [3]<< endl;
            
            for(int i = 0; i < 4; ++i){
                int flag = 0;
                
                for(int j = 0; j < N; ++j){
                    if(!judge(x[j], y[j], h[j], CX, CY, cand[i])){
                        flag = 1;
                        break;
                    }
                }
                
                if(flag == 0 && cand[i] >= 1){
                    cout << CX << " " << CY << " " << cand[i] << endl;
                    return 0;
                }
                
            }
        }
    }
    
    return 0;
}

Measured memory_bytes: 256
nl = lambda: list(map(int, input().split()))
sl = lambda: input().split()
n = lambda: int(input())
s = lambda: input()

N, K = nl()
S = s()

nums = [0]

num = 1
prev = S[0]
first_zero = prev == '0'
for i in range(1, N):
    if prev != S[i]:
        nums.append(num)
        num = 1
        prev = S[i]
    else:
        num += 1
nums.append(num)

total = 0
for i in range(len(nums)):
    total += nums[i]
    nums[i] = total

first = 0
if first_zero:
   first = -1

res = 0
for i in range(first, len(nums), 2):
    total = nums[min(i+2*K+1, len(nums)-1)] - nums[max(i, 0)]
    if total > res:
        res = total

print(res)





Measured memory_bytes: 7160