akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
//#include<vector>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

void pakuripair_sort(int N, int A[], int B[]) {
	const int b = 8;
	int tmp[200001], tmp2[200001];
	rep(k, 4) {
		int kazu[1 << b] = {}, kazu2[1 << b] = {};
		rep(i, N) kazu[A[i] >> k * b & ((1 << b) - 1)]++;
		rep(i, (1 << b) - 1) kazu[i + 1] += kazu[i];
		for (int i = N - 1; i >= 0; i--) {
			tmp[--kazu[A[i] >> k * b & ((1 << b) - 1)]] = A[i];
			tmp2[kazu[A[i] >> k * b & ((1 << b) - 1)]] = B[i];
		}
		k++;
		rep(i, N) kazu2[tmp[i] >> k * b & ((1 << b) - 1)]++;
		rep(i, (1 << b) - 1) kazu2[i + 1] += kazu2[i];
		for (int i = N - 1; i >= 0; i--) {
			A[--kazu2[tmp[i] >> k * b & ((1 << b) - 1)]] = tmp[i];
			B[kazu2[tmp[i] >> k * b & ((1 << b) - 1)]] = tmp2[i];
		}
	}
}

int X[200001], Y[100001], K[200001];
int x[200001], y[200001];
int Find(int A) {
	if (Y[A] < 0) return A;
	return Y[A] = Find(Y[A]);
}

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


	int N = getint();
	rep(i, N) {
		X[i] = getint();
		Y[i] = getint();
		K[i] = i;
	}
	pakuripair_sort(N, X, K);
	rep(i, N - 1) {
		X[i] = X[i + 1] - X[i];
		x[i] = K[i];
		y[i] = K[i + 1];
		K[i] = i;
	}
	K[N - 1] = N - 1;
	pakuripair_sort(N, Y, K);
	for (int i = N - 1; i < N + N - 2; i++) {
		X[i] = Y[i - N + 2] - Y[i - N + 1];
		x[i] = K[i - N + 1];
		y[i] = K[i - N + 2];
	}
	rep(i, N + N - 2) K[i] = i;

	pakuripair_sort(N + N - 2, X, K);

	rep(i, N) Y[i] = -1;
	ll kotae = 0;
	rep(i, N + N - 2) {
		int a = Find(x[K[i]]);
		int b = Find(y[K[i]]);
		if (a != b) {
			if (Y[a] > Y[b]) swap(a, b);
			Y[a] += Y[b];
			Y[b] = a;
			kotae += X[i];
		}
	}

	printf("%lld", kotae);

	Would you please return 0;
}

Measured memory_bytes: 5376
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
#include <string>
#include <queue>
 
using namespace std;
 
int main()
{
	int n;
	cin>>n;
	for(int i=0;i<3;i++){
		if(n%10==7){
			cout<<"Yes"<<endl;
			return 0;
		}
		n=n/10;
	}
	cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 3636
h = Array.new(4) { Array.new(3) { Array.new(10,0) }}

n = gets.to_i
n.times {
    b,f,r,v = gets.split.map &:to_i
    h[b-1][f-1][r-1] += v
}

4.times {|i|
    3.times{|j|
        10.times{ |k|
            print " ",h[i][j][k]
        }
        puts
    }
    if i < 3
        puts "####################"
    end
}

Measured memory_bytes: 8688
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<algorithm>
#include<math.h>
#include<numeric>
#include<iomanip>
#include<deque>
#include<tuple>
#include<queue>
#include<map>
#include <cstdint>
#include <boost/multiprecision/cpp_int.hpp>


#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define vi vector<int>
#define all(x) (x).begin(),(x).end()
#define Endl endl
#define F first
#define S second

namespace mp = boost::multiprecision;

using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;


int main() {
	string s;
	cin >> s;
	ll count = 0;
	rep(i, pow(2, s.size() - 1)) {
		int tmp = 0;
		rep(j, s.size() - 1) {
			if (i&(1 << j)) {
				string t = s.substr(tmp, j - tmp + 1);
				ll a =stoll(t);
				count += a;
				tmp = j + 1;
			//	cout << count << endl;
			}
		}
		string t = s.substr(tmp, s.size()-1 - tmp + 1);
	//	cout << t << endl;
		ll a =stoll(t);
		count += a;
		//cout << count << endl;
	}
	cout << count << endl;
}


Measured memory_bytes: 256
n=int(input())
h=list(map(int,input().split()))
judge = True

for i in range(n-1):
    if h[i]>h[i+1]:
        judge=False
        break
    elif h[i]!=h[i+1]:
        h[i+1]=h[i+1]-1

if judge:
    print("Yes")
else:
    print("No")



Measured memory_bytes: 63984
fn main() {
    let a: i32 = read().trim().parse().unwrap();
    let b: i32 = read().trim().parse().unwrap();
    let c: i32 = read().trim().parse().unwrap();
    let x: i32 = read().trim().parse().unwrap();

    let mut patternNum = 0;
    'a: for aNum in 0..a+1 {
        if (aNum * 500) > x {
            continue 'a;
        }

        'b: for bNum in 0..b+1 {

            if (aNum * 500 + bNum * 100) > x {
                continue 'b;
            }
            
            for cNum in 0..c+1 {
                let sum = (aNum * 500 + bNum * 100 + cNum * 50);
                if sum == x {
                    patternNum = patternNum + 1;
                }
            }   
        }   
    }

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

fn read() -> String {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s);
    s.to_string()
}


Measured memory_bytes: 4352
#include <iostream>
#include <algorithm>
#include <string>
#include <utility>
#include <map>
#include <queue>
using namespace std;

typedef pair<int, int> P;
typedef tuple<int, int, int> T;

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

int main(){
    while(1){
        int w, h;
        cin >> w >> h;
        if(w == 0){
            return 0;
        }

        vector<string> c(h);
        vector<P> s;
        map<int, P> mp;
        int sy, sx;
        int cnt = 1;
        for (int i = 0; i < h; i++){
            cin >> c[i];
            for (int j = 0; j < w; j++){
                if(c[i][j] == 'o'){
                    sy = i;
                    sx = j;
                    c[i][j] = '.';
                }
                if(c[i][j] == '*'){
                    mp[cnt++] = P(i, j);
                    s.emplace_back(i, j);
                }
            }
        }

        int dist[20][30][30];
        for (int i = 0; i < 20; i++){
            for (int j = 0; j < 30; j++){
                for (int k = 0; k < 30; k++){
                    dist[i][j][k] = 1e9;
                }
            }
        }

        int n = s.size();
        for (int i = 0; i <= n; i++){
            queue<T> que;
            if(i == 0){
                que.emplace(0, sy, sx);
                dist[0][sy][sx] = 0;
            }
            else{
                que.emplace(0, s[i - 1].first, s[i - 1].second);
                dist[i][s[i - 1].first][s[i - 1].second] = 0;
            }

            while(que.size()){
                int cost, cy, cx;
                tie(cost, cy, cx) = que.front();
                que.pop();

                for (int j = 0; j < 4; j++){
                    int ny = cy + dy[j];
                    int nx = cx + dx[j];

                    if(0 <= ny && ny < h && 0 <= nx && nx < w){
                        if(c[ny][nx] == 'x'){
                            continue;
                        }

                        if(dist[i][cy][cx] + 1 < dist[i][ny][nx]){
                            dist[i][ny][nx] = dist[i][cy][cx] + 1;
                            que.emplace(dist[i][ny][nx], ny, nx);
                        }
                    }
                }
            }
        }

        vector<int> v;
        for (int i = 1; i <= n; i++){
            v.emplace_back(i);
        }

        int ans = 1e9;
        do{
            int sum = 0;
            P nv = mp[v[0]];

            if(dist[0][nv.first][nv.second] == 1e9){
                cout << -1 << endl;
                goto END;
            }

            sum += dist[0][nv.first][nv.second];

            for (int i = 1; i < n; i++){
                nv = mp[v[i]];

                if(dist[v[i-1]][nv.first][nv.second] == 1e9){
                    cout << -1 << endl;
                    goto END;
                }

                sum += dist[v[i - 1]][nv.first][nv.second];
            }

            ans = min(ans, sum);

        } while (next_permutation(v.begin(), v.end()));

        cout << ans << endl;

        END:;
    }
}


Measured memory_bytes: 3120
/*
  || Shree Ganeshay Namah ||

     || Jai Shree Ram ||
  || Nabh Sparsham Diptam ||
*/
#include<bits/stdc++.h>
using namespace std;
typedef  long long int ll;
#define mod 1000000000000000001
#define block 180
#define ff first.first
#define fs first.second
#define sf second.first
#define ss second.second
#define f1 first
#define s1 second
int jai_shree_ram()
{
    return 1;
}
int shree_ganeshay_namah()
{
    return 1;
}
ll power(ll x,ll y)
{
    ll r=1;
    while(y>0)
    {
        if(y%2!=0)
            r=r*x;
        x=x*x;
        y=y/2;
    }
    return r;
}
ll ncr(ll n,ll k)
{

    ll c[k+1];
    memset(c,0,sizeof(c));
    c[0]=1;
    for(ll i=1;i<=n;i++)
    {
        for(ll j=min(i,k);j>0;j--)
            c[j]=c[j]+c[j-1];
    }
    return c[k];
}

bool prime[500001];
void sieve()
{
    ll i,j;
    memset(prime,true,sizeof(prime));
    prime[0]=false;
    prime[1]=false;
    for(i=2;i<=sqrt(100001);i++)
    {
        if(prime[i])
        {
            for(j=i*i;j<=100001;j=j+i)
                prime[j]=false;
        }
    }
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    char c;
    cin>>c;
    if(c>='a' && c<='z')
        cout<<"a";
    else
        cout<<"A";
    return 0;

}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
#define fo(i,a,n) for(i=a;i<n;i++)
#define ll long long
#define deb(x) cout << #x << "=" << x << endl
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define sortrev(x) sort(all(x),greater<int>())
#define pi 3.1415926535897932384626

typedef pair<int,int> pii;
typedef pair<ll, ll> pl;
typedef vector<int>	vi;
typedef vector<bool> vb;
typedef vector<ll>	vl;
typedef vector<pii>	vpii;
typedef vector<pl>	vpl;
typedef vector<vi>	vvi;
typedef vector<vl>	vvl;
typedef vector<double> vd;


const int mod = 100000007;
const int inf = 1000000000;
const int N = 200007, M = N;
ll i,j,x,cnt,par,n;

void solve() {
 ll n;
 cin>>n;

 ll ans = n + (n*n) + (n*n*n);
 cout<<ans<<"\n";
}

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

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

    return 0;
}




Measured memory_bytes: 3640
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner tan = new Scanner(System.in);
        while (tan.hasNext()){
            int n,AC=0,WA=0,TLE=0,RE=0;
            n=tan.nextInt();
            for (int i = 0; i < n; i++) {
                String st = tan.next();
                if ("AC".equals(st))
                    AC++;
                else if ("WA".equals(st))
                    WA++;
                else if ("TLE".equals(st))
                    TLE++;
                else
                    RE++;
            }
            System.out.println("AC x "+AC);
            System.out.println("WA x "+WA);
            System.out.println("TLE x "+TLE);
            System.out.println("RE x "+RE);
        }
    }
}


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





int dp[100010];
vector<int> g[100010];
int dfs(int x){
    if( dp[x] != -1 ) return dp[x];

    int ans = 0;
    for(int i : g[x]){
        ans = max(ans, dfs(i) + 1);
    }
    return dp[x] = ans;
}

void solve(long long N, long long M, vector<long long> x, vector<long long> y){
    for(int i = 0 ; i < x.size() ; i++){
        g[x[i]-1].push_back(y[i]-1);
    }
    memset(dp, -1, sizeof(dp));
    int ans = 0;
    for(int i = 0 ; i < N ; i++)
        ans = max(ans, dfs(i));
    cout << ans << endl;

}

int main(){
    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    vector<long long> x(M);
    vector<long long> y(M);
    for(int i = 0 ; i < M ; i++){
        scanf("%lld",&x[i]);
        scanf("%lld",&y[i]);
    }
    solve(N, M, x, y);
    return 0;
}


Measured memory_bytes: 11264
n=int(input())
tab=[10**8 for i in range(n+1)]
tab[0]=0

for i in range(n):
    now=1
    while i+now<=n:
        tab[i+now]=min(tab[i+now],tab[i]+1)
        now*=6
    now=9
    while i+now<=n:
        tab[i+now]=min(tab[i+now],tab[i]+1)
        now*=9

print(tab[-1])

Measured memory_bytes: 9864
#include<iostream>
#include<string>

using namespace std;

int main(){
    string s;
    cin >> s;
    if (s == "SUN"){
        cout << 7 <<endl;
    }else if(s=="MON"){
        cout << 6 << endl;
    }else if(s == "TUE"){
        cout << 5 << endl;
    }else if(s == "WED"){
        cout << 4 << endl;
    }else if(s == "THU"){
        cout << 3 << endl;
    }else if(s == "FRI"){
        cout << 2 << endl;
    }else{
        cout << 1 << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define MAX 300003
#define MOD 1000000007
#define INF 1000000000000000

int main(){
  int A,B,C,D;
  cin>>A>>B>>C>>D;
  while(true){
    C-=B;
    if(C<=0){
      cout<<"Yes"<<endl;
      break;
    }
    A-=D;
    if(A<=0){
      cout<<"No"<<endl;
      break;
    }
  }
}


Measured memory_bytes: 3632
import java.io.File;
import java.io.IOException;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Deque;
import java.util.Scanner;

public class Main {
 
	public static void main(String[] args) throws IOException {
		//File file = new File("input.txt");
		//Scanner sc = new Scanner(file);
		
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		int[] a = new int[n];
		int sum = 0;
		for(int i = 0; i < n; i++) sum += sc.nextInt() - 1;//a[i] = sc.nextInt();
		
		System.out.println(sum);
	}
}

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

using namespace std;

int main() {
    long long n, m, k;
    cin >> n >> m >> k;
    long long a[n+1], b[m+1];
    a[0] = b[0] = 0;
    for(int i = 1; i <= n; i++) {
        cin >> a[i];
        a[i] += a[i-1];
    }
    for(int i = 1; i <= m; i++) {
        cin >> b[i];
        b[i] += b[i-1];
    }

    int result = 0;
    for(int i = 0; i <= n; i++) {
        long long remain = k - a[i];
        if(remain < 0) break;
        int index = upper_bound(b, b+m+1, remain)-b-1;
        result = max(result, i+index);
    }

    cout << result << endl;
}

Measured memory_bytes: 6804
#include <bits/stdc++.h>
    using namespace std;
    #define ll long long
   // #define ll unsigned long long
    #define pb push_back
    #define mp make_pair
    #define fi first
    #define se second
    #define be begin()
    #define en end()
    #define le length()
    #define all(x) (x).begin(), (x).end()
    #define rep(i, n) for (ll i = 0; i < n; i++)
    #define repo(i, n) for (ll i = 1; i <= n; i++)
    #define fastIO                        \
        ios_base::sync_with_stdio(false); \
        cin.tie(NULL);                    \
        cout.tie(NULL)
    #define eps 1e-6
    #define pi 3.141592653589793
    #define c(a) cout << a << "\n";
    #define ao(a)        \
        for (auto i : a) \
            cout << i << " ";
    #define endl '\n'        
    typedef vector<int> vii;
    typedef vector<ll> vll;
    typedef pair<int, int> pii;
    typedef pair<ll, ll> pll;
    const int MOD = 1e9 + 7;
    const int INF = 1e9;
    const int N = 1e6 + 6;
 
    ll powmod(ll a, ll b, ll mod)
    {
        ll res = 1;
        a %= mod;
        for (; b; b >>= 1)
        {
            if (b & 1)
                res = (res * a) % mod;
            a = (a * a) % mod;
        }
        return res;
    }
 
    ll gcd(ll a, ll b)
    {
        while (b > 0)
        {
            ll t = a % b;
            a = b, b = t;
        }
        return a;
    }
 
    ll lcm(ll a, ll b)
    {
        return (a / gcd(a, b)) * b;
    }
 
    ll is_prime(ll n)
    {
        if (n <= 1 || n > 3 && (n % 2 == 0 || n % 3 == 0))
            return 0;
        for (ll i = 5, t = 2; i * i <= n; i += t, t = 6 - t)
            if (n % i == 0)
                return 0;
        return 1;
    }
    // long long bit[1000005], a[1000005];
    // ll N1 = 200005;
 
    // void update(int x, int del)
    // {
    //     for (; x <= N1; x += x & -x)
    //     {
    //         bit[x] += del;
    //     }
    // }
 
    // int query(int x)
    // {
    //     int sum = 0;
    //     for (; x > 0; x -= x & -x)
    //     {
    //         sum += bit[x];
    //     }
    //     return sum;
    // }
    /*************************************************************************************************************/
    int main(){
     ll n;
     cin>>n;
     string s;
     cin>>s;
     ll ans=0;
     for(int i=0;i<=n-3;i++){
         if(s[i]=='A' && s[i+1]=='B' && s[i+2]=='C') {ans++;i+=2;}
     }
     c(ans)
    return 0;   
    }
        
 
 
 

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define F first
#define S second
using namespace std;
const int maxN =1e3 + 13;
int n, m, lvl[maxN][maxN], ans, mvx[4] = {0, 0, -1, 1}, mvy[4] = {1, -1, 0, 0};
queue<pair<int, int>> qu;
bool mark[maxN][maxN];
char t[maxN][maxN];
bool can (int x, int y) {
    if (x >= 0 && x < n && y >= 0 && y < m && t[x][y] == '.' && !mark[x][y])
	return 1;
    return 0;
}
int main () {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> n >> m;
    for (int i = 0; i < n; i++)
	for (int j = 0; j < m; j++) {
	    cin >> t[i][j];
	    if (t[i][j] == '#') 
		qu.push({i, j});
	    
	}

    while (qu.size()) {
	pair<int, int> u = qu.front();
	int x = u.F, y = u.S;
	ans = max(ans, lvl[x][y]);
	qu.pop();
	for (int i = 0; i < 4; i++) {
	    if (can(x + mvx[i], y + mvy[i])) {
		mark[x + mvx[i]][y + mvy[i]] = 1;
		lvl[x + mvx[i]][y + mvy[i]] = lvl[x][y] + 1;
		qu.push({x + mvx[i], y + mvy[i]});
	    }
	}
    }

    cout << ans << endl;
}
    


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

int main(void) {
	int n;
	scanf("%d",&n);
	char s[100];
	int c[4] = {0,0,0,0};
	for(int i=0;i<=n;i++){
		gets(s);
		if(strcmp(s,"AC")==0){
			c[0]++;
		}
		else if(strcmp(s,"WA")==0){
			c[1]++;
		}
		else if(strcmp(s,"TLE")==0){
			c[2]++;
		}
		else if(strcmp(s,"RE")==0){
			c[3]++;
		}
	}
	printf("AC x %d\n",c[0]);
	printf("WA x %d\n",c[1]);
	printf("TLE x %d\n",c[2]);
	printf("RE x %d\n",c[3]);
}


Measured memory_bytes: 1772
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#define _GLIBCXX_DEBUG
#define INF 100000010
using namespace std;
const int mod = 1000000007;


int main() {
 
  string N,M;
  cin>>N>>M;
  
  //vector<int64_t> A(N);
  for(int i=0; i<N.size(); i++){
    if(N[i]!=M[i]){cout<<"No"<<endl;return 0;}
    
  }
  //vector<vector<int>> A(N,vector<int>(M));
  //for(int i=0; i<N; i++){for(int j=0; j<M; j++){cin>>A[i][j];}}
  //sort(A.begin(),A.end());
  //for (int i = 0; i < N; i++) { maximum = max(maximum , A[i]);}
  //for (int i = 0; i < N; i++) { minimum = min(minimum , A[i]);}
  cout << "Yes" << endl;
}

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

#define MAX_N 100001
#define INF 100000000000001

long long par[MAX_N]; // 親
long long rankuf[MAX_N]; // 木の深さ
long long sizeuf[MAX_N]; // 木の深さ
long long diff_weight[MAX_N];
// n要素で初期化
void init(long long n) {
	for (long long i = 0; i < n; i++) {
		par[i] = i;
    rankuf[i] = 0;
		sizeuf[i] = 1;
		diff_weight[i] = 0;
	}
}
// 木の根を求める
long long find(long long x) {
	if (par[x] == x) {
		return x;
	} else {
		long long f = find(par[x]);
		diff_weight[x] += diff_weight[par[x]];
		return par[x] = f;
	}
}

long long weight(long long x) {
  find(x); // 経路圧縮
  return diff_weight[x];
}

long long diff(long long x, long long y) {
  return weight(y) - weight(x);
}

long long size(long long x) {
  return sizeuf[find(x)];
}

// xとyの属する集合を併合
void unite(long long x, long long y, long long d) {
	d += weight(x); d -= weight(y);
	x = find(x);
	y = find(y);
	if (x == y) return;
	if (rankuf[x] < rankuf[y]) {
		par[x] = y;
		diff_weight[x] = -d;
		sizeuf[y] += sizeuf[x];
	} else {
		par[y] = x;
		diff_weight[y] = d;
		sizeuf[x] += sizeuf[y];
		if (rankuf[x] == rankuf[y]) rankuf[x]++;
	}
}
// xとyが同じ集合に属するか否か
bool same(long long x, long long y) {
	return find(x) == find(y);
}


int main(){
	ll N, M;
	scanf("%lld", &N);
	scanf("%lld", &M);
	vector<ll> a(M),b(M);
	for (int i = 0; i < M; i++) {
		scanf("%lld", &a[i]);
		scanf("%lld", &b[i]);
	}
	vector<ll> ans(M);
	init(N+1);
	ans[M-1] = N*(N-1)/2;
	for (int i = M-2; i >= 0; i--) {
		if (same(a[i+1],b[i+1])) ans[i] = ans[i+1];
		else {
			ans[i] = ans[i+1]-size(a[i+1])*size(b[i+1]);
			unite(a[i+1],b[i+1],0);
		}
	}
	for (int i = 0; i < M; i++) {
		printf("%lld\n", ans[i]);
	}
}


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

typedef long long lint;
typedef long double louble;

template<typename T1,typename T2> inline T1 max(T1 a,T2 b){return a<b?b:a;}
template<typename T1,typename T2> inline T1 min(T1 a,T2 b){return a<b?a:b;}

namespace ae86
{
	const int bufl = 1<<15;
	
	char buf[bufl],*s=buf,*t=buf;
	
	inline int fetch()
	{
		if(s==t){t=(s=buf)+fread(buf,1,bufl,stdin);if(s==t)return EOF;}
		return *s++;
	}
	
	inline int ty()
	{
		int a=0,b=1,c=fetch();
		while(!isdigit(c))b^=c=='-',c=fetch();
		while(isdigit(c))a=a*10+c-48,c=fetch();
		return b?a:-a;
	}
	
	template<typename T> inline int ts(T *s)
	{
		int a=0,c=fetch();
		while(c<=32 && c!=EOF)c=fetch();
		while(c>32 && c!=EOF)s[a++]=c,c=fetch();
		s[a]=0;
		return a;
	}
}
using ae86::ty;
using ae86::ts;

const int _ = 2007 , __ = _<<1;
const lint linf = 0x3f3f3f3f3f3f3f3f;

int to[__],ne[__],he[_]={0},ecnt=1;
inline void adde(int a,int b){to[++ecnt]=b,ne[ecnt]=he[a],he[a]=ecnt;}
inline void addde(int a,int b){adde(a,b),adde(b,a);}

int n,val[_],sval[_],fa[_]={0},dep[_]={0};
lint sdep,mip[_],mxp[_];

inline void duang(int x,int b)
{
	if((mip[x]<=mip[b] && mip[b]<=mxp[x]) || (mip[b]<=mip[x] && mip[x]<=mxp[b]))mip[x]=(mip[x]+mip[b])&1;
	else mip[x]=max(mip[x]-mxp[b],mip[b]-mxp[x]);
	mxp[x]+=mxp[b];
}

void dfs(int x,int ff)
{
	fa[x]=ff,dep[x]=dep[ff]+1,sdep+=val[x]*dep[x],sval[x]=val[x];
	mip[x]=mxp[x]=0;
	for(int i=he[x];i;i=ne[i])
	{
		int b=to[i];
		if(b==ff)continue;
		dfs(b,x),sval[x]+=sval[b],mip[b]+=sval[b],mxp[b]+=sval[b],duang(x,b);
	}
}

int main()
{
	n=ty(),ts(val+1);
	for(int i=1,a,b;i<n;i++)a=ty(),b=ty(),addde(a,b);
	for(int i=1;i<=n;i++)val[i]-=48;

	lint ans=linf;
	for(int i=1;i<=n;i++)
	{
		sdep=0,dep[0]=-1,dfs(i,0);
		if(mip[i]<=0)ans=min(ans,sdep/2);
	}

	if(ans>=linf)ans=-1;
	printf("%lld\n",ans);

	return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }

int N;

void _main() {
  cin >> N;
  int t = sqrt(N);
  cout << (t * t) << "\n";
}

Measured memory_bytes: 256
#include<stdio.h>

int ans = 0;

void check(long int x){
    int count[3] = {0};//[0]:3の個数...
    int cur = 0;
    int i = 0;
    while(x > 0){
        cur = x%10;
        if(cur == 3){count[0]++;}
        else if(cur == 5){count[1]++;}
        else {count[2]++;}
        x /= 10;
    }
    //for(i = 0; i < 3; i++){printf("count[%d]:%d ", i, count[i]);}printf("\n");
    if(count[0] * count[1] * count[2] != 0){ans++; /*printf("ansが増えました\n");*/}
}
void emoemo(long int x, long int N){
    //printf("今のxは%d\n", x);
    if(x > N) return ;
    //printf("checkいきます\n");
    check(x);
    emoemo(10*x+3, N);
    emoemo(10*x+5, N);
    emoemo(10*x+7, N);
}
int main(void){
    long int N;
    scanf("%ld", &N);

    emoemo(0, N);
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 128
H,W = map(int,input().split())

# ひとつは何らかの辺を完全に含む

def F(H,W):
  # 2つの場合
  # max, minを返す
  if H%2 == 0 or W%2 == 0:
    return (H*W//2, H*W//2)
  if H > W:
    H,W = W,H
  return (H*(W-1)//2, H*(W+1)//2)

answer = H*W
for h in range(1,H):
  x = [W*h]
  x += list(F(H-h,W))
  answer = min(answer, max(x) - min(x))
  
for w in range(1,W):
  x = [H*w]
  x += list(F(W-w,H))
  answer = min(answer, max(x) - min(x))
  
print(answer)

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

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

    string s;
    cin >> s;

    bool all9 = true;
    rep1(i, s.size()){
        if(s[i] == '9') all9 = all9 && true;
        else all9 = false;
    }

    int res = s[0] - '0' - 1 + 9 * (s.size() - 1);
    
    if(all9) cout << res + 1 << endl;
    else cout << res << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define whlie while
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define rep(i,N) for(int i = 0; i < (N); i++)
#define repr(i,N) for(auto i = (N) - 1; i >= 0; i -= 1)
#define each(x,v) for(auto& x : v)
#define all(v) (v).begin(),(v).end()
#define sz(v) ((int)(v).size())
#define vrep(v,it) for(auto it = v.begin(); it != v.end(); it++)
#define vrepr(v,it) for(auto it = v.rbegin(); it != v.rend(); it++)
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) ll __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
#define rand mtrand
#ifdef NyaanDebug
  #include "NyaanDebug.h"
  #define trc(...) do { cout << #__VA_ARGS__ << " = "; dbg_out(__VA_ARGS__);} while(0)
  #define trca(v,...) do { cout << #v << " = "; array_out(v , ##__VA_ARGS__);cout << endl;} while(0)
#else
  #define trc(...)
  #define trca(...)
#endif
using namespace std;
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector< vector<int> >;
constexpr int inf = 1001001001;
constexpr ll infLL = 0x1FFFFFFFFFFFFFFFLL;
struct IoSetupNya {IoSetupNya() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); cerr << fixed << setprecision(15);} } iosetupnya;
template<typename T, typename U> inline bool amin(T &x, U y) { return (y < x) ? (x = y, true) : false; }
template<typename T, typename U> inline bool amax(T &x, U y) { return (x < y) ? (x = y, true) : false; }
template<typename T, typename U> ostream& operator <<(ostream& os, const pair<T, U> &p) { os << p.first << " " << p.second; return os; }
template<typename T, typename U> istream& operator >>(istream& is, pair<T, U> &p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator <<(ostream& os, const vector<T> &v) { int s = (int)v.size(); rep(i,s) os << (i ? " " : "") << v[i]; return os; }
template<typename T> istream& operator >>(istream& is, vector<T> &v) { for(auto &x : v) is >> x; return is; }
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
template<typename T>void die(T x){out(x); exit(0);}

using P = pair<int,int>;
random_device seed_gen; mt19937_64 mtrand(seed_gen());
constexpr int MOD = 1000000007;
//////////////////////////////////////////

int main(){
  ini(N); ins(S); ini(K); K--;
  rep(i,N){
    if(S[i] != S[K]) S[i] = '*';
  }
  out(S);
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
  long int k,a[50],i,j;
  scanf("%ld",&k);
  for(i=0;i<50;i++)a[i]=49L+k/50L;
  for(i=0;i<k%50L;i++)for(j=0;j<50;j++)a[j]+=i==j?50L:-1L;
  printf("50\n");
  for(i=0;i<50;i++)printf("%ld ",a[i]);
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main() {

  int N;
  cin >> N;

  vector<int> W(N);
  for(int i =0; i < N; i++) {
    cin >> W.at(i);
  }

  int mini = 100;

  for(int i = 0; i < N - 1; i++) {
    int before = 0,after = 0;
      for(int j = 0; j <= i; j++) {
        before += W.at(j);
      }
      for(int k = i + 1; k < N; k++) {
        after += W.at(k);
      }
      mini = min(abs(before - after),mini);
    }
  
  cout << mini << endl;
   }



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

int main() {
    int n, m, l[100100], r[100100];
    cin >> n >> m;
    for (int i = 0; i < m; i++) {
        cin >> l[i] >> r[i];
    }
    sort(l, l + m);
    sort(r, r + m);

    if (l[m - 1] <= r[0]) cout << r[0] - l[m - 1] + 1 << endl;
    else cout << 0 << endl;
    return 0;
}

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

int i,j,k;

int main(){
    int n,k,r,s,p;//n回じゃんけん　k回前と同じ手は不可
    cin>>n>>k>>r>>s>>p;
    string t;//t:相手の出す手
    cin>>t;

    vector<bool> can(n+k,true);//k回前と同じ手を出さないようにする
    int ans=0;

    for(i=0;i<n;i++){
        switch (t[i])
        {
            case 'r': if(can[i]){ans+=p;if(i+k<n && t[i+k]=='r'){can[i+k]=false;}}
                      break;//k回後に同じ手は不可
            case 's': if(can[i]){ans+=r;if(i+k<n && t[i+k]=='s'){can[i+k]=false;}}
                      break;
            case 'p': if(can[i]){ans+=s;if(i+k<n && t[i+k]=='p'){can[i+k]=false;}}
                      break;
        }
    }

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

Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
using namespace std;
int a[100005];
int main()
{
    int i,k,n,m;
    cin >> n >> m;
    for(i=0;i<n;i++){
       cin >> a[i];
    }
    if((n-m)%(m-1)==0){
        k=(n-m)/(m-1)+1;
    }else
       k=(n-m)/(m-1)+2;
    cout << k;
    return 0;
}


Measured memory_bytes: 640
import java.util.*;

public class Main {
    public static void main(String args[]) {

        //X[k] = k - A[k]
        //Y[k] = i + A[i]
        //k > i

//        Scanner sc = new Scanner(System.in);
//        int n = sc.nextInt();
//        int count = 0;
//        Map<Integer,Integer> x_map = new HashMap<>();
//        int[] x = new int[n];
//        int[] y = new int[n];

//        for (int k = 1; k <= n; k++) {//key:X[k],value:X[k]の個数、のMapを作る
//            int inputNum = sc.nextInt();
//            x[k-1] = k - inputNum;//X[k]の配列を作る（番号とindexのずれに注意）
//
//            if(x_map.containsKey(x[k-1])){
//                x_map.replace(x[k-1],x_map.get(x[k-1]) + 1);//x[k]に対する値が既に存在していれば1を足す
//            }else{
//                x_map.put(x[k-1],1);//存在していなければ新たにMapに入れる
//            }
//            y[k-1] = k + inputNum;//Y[i]の配列を作る（番号とindexのずれに注意）
//        }
//
//        for(int i = 1; i <= n; i++) {
//            x_map.replace(x[i-1], x_map.get(x[i-1]) - 1);//k > iを維持するためにx[i]がkeyのvalue（）をカウントしている1つ分は毎回取り除く
//
//            //これをやるとvalueが負になる場合があるか？ → ない
//
//            if(x_map.containsKey(y[i-1])){
//                count += x_map.get(y[i - 1]);//y[i]と同じ値をもつx[i]の個数（iに対してkが成立するペアの数）をcountに投げ込む
//            }
//        }

        //第二段 上から潰してみる → 1番目のやつがn番目になってまうからだめや
        Scanner sc = new Scanner(System.in);
        long n = sc.nextInt();
        long count = 0;
        Map<Long,Long> x_map = new HashMap<>();

        for(long i = n; 1 <= i; i--){
            long A_i = sc.nextInt();//読み込み
            long y_i = i + A_i;
            if(x_map.containsKey(y_i)){//y_iに対応するx_iが存在した時、その個数を足しあげ
                count += x_map.get(y_i);
            }

            long x_i = i - A_i;//足しあげ時点でmapにはiより大きいkでのX[k]しか存在しないようにするため、毎回この時点で値を追加
            if(x_map.containsKey(x_i)){
                x_map.replace(x_i,x_map.get(x_i) + 1);//x[k]に対する値が既に存在していれば1を足す
            }else{
                x_map.put(x_i,(long)1);//存在していなければ新たにMapに入れる
            }
        }
        System.out.println(count);
    }
}


Measured memory_bytes: 70352
n=int(input())
A = [list(map(str,input().split())) for i in range(n)]
A_s = sorted(A, key=lambda x: int(x[1]), reverse=True)
A_ss = sorted(A_s, key=lambda x: x[0], reverse=False)
for i in range(n):
    print(A.index( A_ss[i])+1)

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

int main() {
  int n;
  string s;
  cin >> n >> s;
  int a = 0, b = 0;
  rep(i,n) if (s[i]=='R') ++a;
  int ans = max(a,b);
  rep(i,n) {
    if (s[i] == 'R') --a;
    else ++b;
    int now = max(a,b);
    ans = min(ans, now);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3732
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
const int INF=1e9+7;

int main() {
	int N,w=0,b=0,r=INF;
	string S;
	cin >> N >> S;

	rep(i,N)
		w += S.at(i)=='.';

	rep(i,N) {
		r = min(r, b+w);
		b += S.at(i)=='#';
		w -= S.at(i)=='.';
	}

	cout << min(r, b+w) << endl;
}

Measured memory_bytes: 640
#define MAX 10000005
p[MAX],four[1000],j,f;
main(i)
{
  for(i=2;i<MAX;i++)
    if(!p[i])
      for(j=i*2;j<MAX;j+=i)
	p[j]=1;
  for(i=3;i<MAX-7;i+=2)
    if(!p[i]&&!p[i+2]&&!p[i+6]&&!p[i+8])
      four[f++]=i+8;
  for(four[f]=MAX;scanf("%d",&j),j;printf("%d\n",four[i-1]))
      for(i=0 ;four[i]<=j; i++);

	exit(0);  
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long T,i,j,n,x,t;
    cin>>n>>x>>t;
    if(n%x==0)
    {
        cout<<(n/x)*t<<endl;
    }
    else
    {
        cout<<((n/x)+1)*t<<endl;
    }
}


Measured memory_bytes: 3620
// 1230
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(false);cin.tie(NULL)
using namespace std;
#define int long long
#define MOD 1000000007
typedef vector<int> vi;
typedef pair<int,int> pi;
#define inf 1e18
#define For(i,a,b) for (int i = a; i < b; i++)
#define Rep(i,a,b) for (int i = a; i <= b; i++)
#define ps(x,y) fixed << setprecision(y) << x 
#define pb push_back 
#define mp make_pair 

int a[27];
 
int32_t main()
{
    fast;
    string w; cin >> w;
    int flag = 0;
    if(w.size() % 2 == 1) cout << "No";
    else {
        For(i, 0, w.size()) {
            a[w[i] - 'a']++;
        }
        For(i, 0, 27) {
            if(a[i] % 2 == 0) flag = 1;
            else {
                flag = 0;
                break;
            }
        }
        cout << (flag ? "Yes" : "No");

    }
    
    
    
    return 0;
}

Measured memory_bytes: 3608
# 貪欲的だが「6^i円で払う分」と「9^i円で払う分」にNを分割してN+1通り全探索．


def how_many_times_withdraw(withdraw, base, limit):
    result = 0
    while withdraw >= base:
        result += withdraw // (base ** limit)
        withdraw = withdraw % (base ** limit)
        limit -= 1
    return result + withdraw


def main():
    N = int(input())
    limit = []
    answer = float("inf")
    for yen in [6, 9]:
        i = 1
        while yen ** i <= N:
            i += 1
        limit.append(i - 1)
    for i in range(N + 1):
        answer = min(answer, how_many_times_withdraw(i, 6, limit[0]) + how_many_times_withdraw(N - i, 9, limit[1]))
    print(answer)


if __name__ == '__main__':
    main()

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

int main(void) {
  int a, b, k; cin >> a >> b >> k;
  vector<int> divs;
  
  for (int i=1; i<=min(a,b); i++) {
    if (a % i == 0 && b % i == 0) {
      divs.push_back(i);
    }
  }
  cout << divs[divs.size()-k] << endl;
  return 0;
}

Measured memory_bytes: 3616
#include <stdio.h>
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>

using ll = long long int;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

int ch[1001001][26],p[1001001],t[1001001],e[225816],m=1,calc[1001001][26],cnt[1001001];
bool ise[1001001];
std::string s[225816];

int make(int v, int c){
	if(ch[v][c]){
		return ch[v][c];
	}
	ch[v][c] = m;
	p[m] = v;
	t[m] = c;
	++m;
	return ch[v][c];
}

void dfs(int v){
	int i,j;
	for(i=0; i<26; ++i){
		if(!ch[v][i]){
			continue;
		}
		dfs(ch[v][i]);
		for(j=0; j<26; ++j){
			if(i==j){
				calc[v][j] += cnt[ch[v][i]];
			}else{
				calc[v][j] += calc[ch[v][i]][j];
			}
		}
		cnt[v] += cnt[ch[v][i]];
	}
	if(ise[v]){
		++cnt[v];
	}
}

int main(void){
	int n,i,j,v;
	ll ans = 0ll;
	std::cin >> n;
	for(i=0; i<n; ++i){
		v = 0;
		std::cin >> s[i];
		std::reverse(s[i].begin(),s[i].end());
		for(j=0; j<s[i].l_ength(); ++j){
			v = make(v,s[i][j]-'a');
		}
		e[i] = v; ise[v] = true;
	}
	dfs(0);
	for(i=0; i<n; ++i){
		ans -= 1ll-calc[p[e[i]]][t[e[i]]];
	}
	std::cout << ans << std::endl;
	return 0;
}


Measured memory_bytes: 284180
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
using namespace std;
using ll = long long;
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; }
const ll INF = 1e9;
const ll MOD = 1e9 + 7;


int main(){
    int a, b, c, d;
    cin >> a >> b >> c >> d;

    rep(i, 1000){
        if(i%2 == 0) c -= b;
        else a -= d;
        if(c <= 0) cout << "Yes" << endl;
        if(a <= 0) cout << "No" << endl;
        if(a <= 0 || c <= 0) return 0;
    }
}

Measured memory_bytes: 3652
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>

using namespace std;

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

// container util
#define all(x) (x).begin(), (x).end()

// debug
#define dump(x) cerr << #x << " = " << (x) << endl;
#define debug(x)                                         \
  cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
       << " " << __FILE__ << endl;

// typedef
typedef long long lint;
typedef unsigned long long ull;
typedef complex<long double> Complex;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

// constant
const int MOD = (int)1e9 + 7;
const int INF = (int)1e18;
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

// conversion
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

//
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() {
  ios::sync_with_stdio(false);
  cin.tie(0);

  int N;
  cin >> N;

  for (int i = 1; i < 10; i++) {
    for (int j = 1; j < 10; j++) {
      if (i * j == N) {
        cout << "Yes\n";
        return 0;
      }
    }
  }
  cout << "No\n";

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>  // ver2.1.7
#define int long long
#define endl "\n"
#define ALL(v) (v).begin(),(v).end()
#define Vi vector<int>
#define Pii pair<int,int>
#define Tiii tuple<int,int,int>
#define PQi priority_queue<int>
#define PQir priority_queue<int, vector<int>, greater<int>>
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define sortr(v) sort(v,greater<>())
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repeq(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=a;i>b;i--)
#define repreq(i,a,b) for(int i=a;i>=b;i--)
#define leng(n) (int)(log10(n)+1)
#define dem(a,b) ((a+b-1)/(b))
#define Vout(a) rep(Z,0,a.size()-1)cout<<a[Z]<<' ';cout<<a.back()<<endl
#define VVout(a) rep(lW,0,a.size()){Vout(a[lW]);}
#define INF 9000000000000000000  //  9.0 * 10^18
#define MOD 1000000007  //  10^9 + 7
using namespace std;
 
int gcd(int a,int b){return b?gcd(b,a%b):a;}  //  最大公約数gcd
int lcm(int a,int b){return a/gcd(a,b)*b;}  //  最小公倍数lcm
 
int mypow(int x, int n, int m){  //  累乗x^n(mod m)  O(log(n))
if(n==0)return 1;if(n%2==0)return mypow(x*x%m,n/2,m);else return x*mypow(x,n-1,m)%m;}

vector<pair<int,int>> fac(int n) {  //  素因数分解
vector<Pii>r;for(int i=2;i*i<=n;++i){if(n%i)continue;r.emplace_back(i,0);while(n%i==0){
n/=i;r.back().second++;}}if(n!=1)r.emplace_back(n,1);return r;}

signed main() {
  cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(12);
  int n,m;
  cin >> n >> m;
  Vi a(0);
  int made = sqrt(m);
  
  repeq(i,1,made){
    if(m%i==0) {
      a.pb(i);
      a.pb(m/i);
    }
  }
  sortr(ALL(a));
  rep(i,0,a.size()){
    if(n*a[i] <= m) {cout<<a[i]<<endl;return 0;}
  }
  return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

s  = input()

a = 0
max = 0
for i in range(len(s)):
    if s[i] == 'A' or s[i] == 'T' or s[i] == 'C' or s[i] == 'G':
        a = a+1
    else:
        a = 0

    if max < a:
        max = a

print(max)



Measured memory_bytes: 2940
#include <iostream>
#include <vector>
#include <algorithm>
#include<stdio.h>
#include<functional>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;i++)
typedef long long ll;
// int N, D, X[10][10];
int main() {
    int r;
    // int N;
    // int D;
    // int ;
    cin >> r;
    int ans;
    // rep(i, 0, N) rep(d, 0, D) cin >> X[i][d];
    // int all;
    ans=3*r*r;
    cout << ans << endl;
    return 0;

}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
int main(){
       int a,b,c,d,st,end;
       scanf("%d%d%d%d",&a,&b,&c,&d);
       st = a > c ? a : c;
       end =b < d ? b : d ;
       if(end-st>=0) printf("%d",end-st);
       else printf("0");
       return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define REP(i, x, n) for(int i = x; i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
typedef long long ll;

int main() {
    ll N,M,c;
    cin >> N >> M;
    vector<pair<ll, ll> > data(N);

rep(i,N)
    cin >> data.at(i).first >> data.at(i).second;

sort(data.begin(), data.end()); //配列変数vecをソートする
c = 0;
ll A = 0;
rep(i,N)
{
    rep(j,data.at(i).second)
    {
        A += data.at(i).first;
        c += 1;
        if(c>=M)
        break;
    }
    if(c>=M)
    break;
}
    



cout << A << endl;

}






Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
typedef pair<int, int> P;
const int mx = 100005;
int n, ans[mx];
bool used[mx];
vector<P> p[mx];
stack<P> st;
int main(){
    scanf("%d", &n);
    for(int i = 0; i < n-1; i++){
        int u, v, w;
        scanf("%d%d%d", &u, &v, &w);
        u--; v--; w &= 1;
        p[u].push_back((P){v, w});
        p[v].push_back((P){u, w});
    }
    st.push((P){0,1});
    ans[0] = 1;
    used[0] = true;
    while(!st.empty()){
        P tmp = st.top(); st.pop();
        for(P i : p[tmp.first]){
            if(used[i.first]) continue;
            int ev = (tmp.second + i.second) & 1;
            if(ev) ans[i.first] = 1;
            st.push((P){i.first, ev});
            used[i.first] = true;
        }
    }
    for(int i = 0; i < n; i++) puts(ans[i] ? "0" : "1");
}

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

int main() {
    ll n, m;
    cin >> n >> m;

    vector<ll> h(n);
    for (int i=0; i<n; i++) {
        cin >> h.at(i);
    }

    vector<vector<ll>> br(n, vector<ll>());
    for (int i=0; i<m; i++) {
        ll a, b;
        cin >> a >> b;
        br.at(a-1).push_back(b-1);
        br.at(b-1).push_back(a-1);
    }

    ll ans = 0;
    vector<bool> visited(n, false);
    for (int i=0; i<n; i++) {
        if (!visited.at(i)) {
            visited.at(i) = true;
            ll highest = i;
            for (int j=0; j<br.at(i).size(); j++) {
                if (h.at(br.at(i).at(j)) >= h.at(highest)) highest = br.at(i).at(j);
            }
            if (highest == i) {
                for (int j=0; j<br.at(i).size(); j++) {
                    visited.at(br.at(i).at(j)) = true;
                }
                ans++;
            }
        }
    }

    cout << ans << endl;


}

Measured memory_bytes: 9808
#include<bits/stdc++.h>
#define mod pow(10,9)+7
#define pb push_back
#define ff first
#define ss second
#define ii pair<int,int>
#define vi vector<int>

#define mii map<int,int>
#define int long long
#define inf 2000000000000000000
#define re(i,x,n) for(i=x;i<=n;i++)

using namespace std;
#define int long long
void c_p_c()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
#ifndef  ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}
// struct edge
// {
// 	int a;
// 	int b;
// 	int w;
// };
// edge ar[100000];
// int par[10001];
// bool comp(edge a, edge b)
// {
// 	if (a.w < b.w)
// 		return true;
// 	else
// 		return false;
// }
// int find(int a)
// {
// 	if (par[a] == -1)
// 		return a;
// 	else
// 		return par[a] = find(par[a]);
// }
// void merge(int a, int b)
// {
// 	par[a] = b;
// }
//
int maxProductSubarrayOfSizeK(int A[], int n, int k)
{
	// sorting given input array
	sort(A, A + n);

	// variable to store final product of all element
	// of sub-sequence of size k
	int product = 1;

	// CASE I
	// If max element is 0 and
	// k is odd then max product will be 0
	if (A[n - 1] == 0 && (k & 1))
		return 0;

	// CASE II
	// If all elements are negative and
	// k is odd then max product will be
	// product of rightmost-subarray of size k
	if (A[n - 1] <= 0 && (k & 1)) {
		for (int i = n - 1; i >= n - k; i--)
			product *= A[i];
		return product;
	}

	// else
	// i is current left pointer index
	int i = 0;

	// j is current right pointer index
	int j = n - 1;

	// CASE III
	// if k is odd and rightmost element in
	// sorted array is positive then it
	// must come in subsequence
	// Multiplying A[j] with product and
	// correspondingly changing j
	if (k & 1) {
		product *= A[j];
		j--;
		k--;
	}

	// CASE IV
	// Now k is even
	// Now we deal with pairs
	// Each time a pair is multiplied to product
	// ie.. two elements are added to subsequence each time
	// Effectively k becomes half
	// Hence, k >>= 1 means k /= 2
	k >>= 1;

	// Now finding k corresponding pairs
	// to get maximum possible value of product
	for (int itr = 0; itr < k; itr++) {

		// product from left pointers
		int left_product = A[i] * A[i + 1];

		// product from right pointers
		int right_product = A[j] * A[j - 1];

		// Taking the max product from two choices
		// Correspondingly changing the pointer's position
		if (left_product > right_product) {
			product *= left_product;
			i += 2;
		}
		else {
			product *= right_product;
			j -= 2;
		}
	}

	// Finally return product
	return product;
}
int32_t main()
{

	

	int n;
	cin >> n;
	double a[n];
	int i;
	for (i = 0; i < n; i++)
		cin >> a[i];
	sort(a, a + n);

	double sum = 0;
	int temp = n - 1;
	i = 0;
	double maxi = INT_MIN;
	while (temp--)
	{
		sum = (a[i] + a[i + 1]) / 2;
		a[i + 1] = sum;
		maxi = max(maxi, sum);
		i++;
	}
	cout << maxi;

}


Measured memory_bytes: 3716