akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include<algorithm>
#include<math.h>
#include<set>
#include<vector>
#include<string>
#include<iostream>
using namespace std;
int main() {
  string S;
  cin>>S;
int x=0;
int y=0;
  for(int i=0;i<S.size();i++){
    if(S[i]=='A'){
      x=i;
      break;
    }
  }
  for(int i=0;i<S.size();i++)
    if(S[S.size()-i]=='Z')
    {
      y=S.size()-i;
      break;
    }
  cout<<y-x+1<<endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
const int inf = 2e9;

int main() {
    srand(time(0));
    
    ios_base :: sync_with_stdio(false);
    int n, m; cin >> n >> m;
    
    vector<int> a(m, 0), b(m, 0), c(m, 0);
    vector<int> v(n, inf);
    vector<pair<int, int>> edges;

    for(int i = 0; i < m; ++i) {
        cin >> a[i] >> b[i] >> c[i];
        v[a[i]] = min(v[a[i]], c[i] + 1);
        v[b[i]] = min(v[b[i]], c[i] + 2);
    }
    
    int best = inf;

    for(int i = 0; i < 3 * n; ++i) {
        best = min(best + 2, v[i % n]);
        v[i % n] = min(best, v[i % n]);
    }

    for(int i = 0; i < n; ++i) {
        a.push_back(i);
        b.push_back((i + 1) % n);
        c.push_back(v[i]);
    }

    for(int i = 0; i < n + m; ++i) {
        edges.push_back({c[i], i});
    }

    sort(edges.begin(), edges.end());
    long long ans = 0;

    vector<int> dad(n, 0);
    for(int i = 0; i < n; ++i)
        dad[i] = i;

    auto f = [&] (int x) {
        int root = x;
        while(root != dad[root])
            root = dad[root];
        while(x != root) {
            int temp = dad[x];
            dad[x] = root;
            x = temp;
        }
        return root;
    };

    auto unite = [&] (int a, int b) {
        if(rand() & 1)
            dad[a] = b;
        else
            dad[b] = a;
    };

    for(auto edge : edges) {
        int x = a[edge.second];
        int y = b[edge.second];
        if(f(x) != f(y)) {
            unite(f(x), f(y));
            ans += edge.first;
        }
    }

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

Measured memory_bytes: 11900
#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define reps(i,a,b) for(int i=a;i<b;++i)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template<typename T> inline bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T> inline bool chmin(T &a,T b){if(b<a){a=b;return 1;}return 0;}
template<typename T> vector<T> make_vec(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_vec(size_t a,Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a,make_vec<T>(ts...));}
template<typename T,typename U,typename... V>
typename enable_if<is_same<T,U>::value>::type fill_v(U &u,const V... v){u=U(v...);}
template<typename T,typename U,typename... V>
typename enable_if<!is_same<T,U>::value>::type fill_v(U &u,const V... v){for(auto &e:u)fill_v<T>(e,v...);}

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

    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    int sum = 0;
    rep(i, n) sum ^= a[i];
    rep(i, n) cout << (sum^a[i]) << endl;
}


Measured memory_bytes: 3920
#include"bits/stdc++.h"
//#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define print(x) cout<<x<<endl;
typedef long long ll;

int main() {
	ll mod = 1000000007;
	ll sum = 1;
	int n;
	cin >> n;
	rep(i, 1, n) {
		//print(i);
		sum = (sum * i) % mod;
		//print(sum);
	}
	print(sum);
}

Measured memory_bytes: 256
#! usr/bin/env python
# -*- coding: utf-8 -*-


def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)


a, b, c, d = map(int, input().split())
l = c // gcd(c, d) * d


def func(x):
    return x - x // c - x // d + x // l


def main():
    print(func(b)-func(a-1))


if __name__ == '__main__':
    main()


Measured memory_bytes: 38256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();

		int total = 0;
		for ( int i = 1; i < n; i++) {
			for ( int j = 1; j < n; j++) {
				if ( i * j < n) {
					total++;
				} else {
					break;
				}
			}
		}
		System.out.println(total);

	}

}


Measured memory_bytes: 36296
#include "bits/stdc++.h"
#pragma GCC optimize("Ofast")

// Begin {{{
using namespace std;

#ifndef DEBUG
#define dump(...)
#endif

template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

template <class T>
inline vector<T> make_v(const T &initvalue, size_t sz) {
    return vector<T>(sz, initvalue);
}

template <class T, class... Args>
inline auto make_v(const T &initvalue, size_t sz, Args... args) {
    return vector<decltype(make_v<T>(initvalue, args...))>(sz, make_v<T>(initvalue, args...));
}

constexpr int INF = 0x3f3f3f3f;
constexpr int64_t LINF = 0x3f3f3f3f3f3f3f3fLL;
// }}} End

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

    size_t H, W; cin >> H >> W;

    vector<string> mat(H);
    for (auto &s: mat) cin >> s;

    constexpr int MOD = int(1e9) + 7;
    auto dp = make_v(0LL, H + 1, W + 1);
    dp[1][1] = 1;
    for (size_t i = 0; i < H; ++i) {
        for (size_t j = 0; j < W; ++j) {
            if (mat[i][j] != '#') {
                dp[i + 1][j + 1] += dp[i + 1][j] + dp[i][j + 1];
                dp[i + 1][j + 1] %= MOD;
            }
        }
    }

    cout << dp[H][W] << "\n";

    return 0;
}


Measured memory_bytes: 9216
#include <iostream>
#include <algorithm>
#include <vector>
#include <list>
#include <string>
#include <cstdlib>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstring>
#include <climits>

using namespace std;

typedef long long ll;
typedef vector<int> ivec;
typedef pair<int, int> ipair;

char s[100], t[100];

int strncmp1(char *str1, char *str2, int n) {
    for (int i = 0; i < n; i++) {
        if (str1[i] == str2[i] || str1[i] == '?') {
            continue;
        } else {
            return 1;
        }
    }
    return 0;
}

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

    int n = strlen(s);
    int m = strlen(t);

    for (int i = n-m; i >= 0; i--) {
        if (strncmp1(s + i, t, m) == 0) {
            for (int j = 0; j < n; j++) {
                if (s[j] == '?') s[j] = 'a';
            }
            memcpy(s + i, t, m);
            cout << s << endl;
            return 0;
        }
    }

    cout << "UNRESTORABLE" << endl;

    return 0;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"sort"
	"strconv"
)

func main() {
	fmt.Println(abc178b(os.Stdin))
}

func nextInt(sc *bufio.Scanner) int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}

func nextLine(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}

func abc178b(r io.Reader) int {
	sc := bufio.NewScanner(r)
	sc.Split(bufio.ScanWords)

	a, b, c, d := nextInt(sc), nextInt(sc), nextInt(sc), nextInt(sc)

	//最大値、最小値スライス作成
	s := []int{a * c, a * d, b * c, b * d}
	sort.Sort(sort.Reverse(sort.IntSlice(s)))

	return s[0]
}


Measured memory_bytes: 1776
#include <stdio.h>

int main(void)
{
    int n, ans = 0;
    scanf("%d", &n);
    while (n--) {
        int l, r;
        scanf("%d%d", &l, &r);
        ans += r - l + 1;
    }
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 128
#include "bits/stdc++.h"

using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
	REP(i, v.size()) { if (i)os << ""; os << v[i]; }return os;
}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
	REP(i, v.size()) { if (i)os << endl; os << v[i]; }return os;
}

const ll INF = LLONG_MAX;
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

#define int long long

inline void my_io() {

	std::ios::sync_with_stdio(false);

	std::cin.tie(0);

	cout << fixed << setprecision(16);

	//cout << setprecision(10) << scientific << ans << endl;
}

signed main() {
	string s;

	cin >> s;

	ll ans = 0;

	REP(i, (1 << s.size() - 1)) {
		ll prev = 0;
		ll cnt = 0;
		REP(j, s.size() - 1) {
			cnt++;
			if (i & (1 << j)) {
				ans += stoll(s.substr(prev, cnt));
				prev += cnt;
				cnt = 0;
			}
		}
		ans += stoll(s.substr(prev));
	}

	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
  int N,H[20];
  int max_h = -1,ans=0;
  cin >> N;
  for(int i = 0; i < N; i++){
    cin >> H[i];
    max_h = max(max_h,H[i]);
    if(H[i] >= max_h)
      ans++;
  }
  cout << ans;
  return 0;
}


Measured memory_bytes: 384
/*
 *
 *   Author     : Amit Kumar
 *   Date    	: June 15 2019 
 * 
 */

#include <bits/stdc++.h>

#define FAST_INPUT_OUTPUT
//#define MORE_THAN_ONE_TESTCASE // COMMENT IT

#define vi vector<int>
#define vl vector<long long>
#define mii map<int , int>
#define mll map<long long , long long>
#define msi map<string , i>
#define msl map<string , long long>
#define umii unordered_map<int,int>
#define umll unordered_map<long long ,long long>
#define umsi unordered_map<string , int>
#define umsl map<string , long long> 
#define si set<int>
#define sl set<long long>
#define pii pair<int , int >
#define psi pair<string,int>
#define psl pair<string , long > 
#define pll pair<long long , long long>
#define vpii vector<pii>
#define vpll vector<pll>
#define vpsi vector<psi>
#define vpsl vector<psl>
#define pqi priority_queue<int>
#define pql priority_queue<long long>
#define ub upper_bound
#define lb lower_bound
#define bint long long int
#define ff first
#define ss second
#define all(x) x.begin(),x.end()
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define iv(v) for(auto &i:v){cin>>i;}
#define ov(v) for(auto i:v){cout<<i<<" ";}cout<<endl;
#define ovn(v) for(auto i:v){cout<<i<<endl;}
#define euv(v) for(auto i:v){cerr<<i<<" ";}cerr<<endl;
#define eovn(v) for(auto i:v){cerr<<i<<endl;}
#define os(s) for(auto itr:s){cout<<itr<<" ";}cout<<endl;
#define osn(s) for(auto itr:s){cout<<itr<<endl;}
#define eos(s) for(auto itr:s){cerr<<itr<<" ";}cerr<<endl;
#define eosn(s) for(auto itr:s){cerr<<itr<<endl;}
#define rep(x) for(auto i=0 ; i<(x); ++i)
#define _rep(a,b) for(auto i=(a); i<(b); ++i)
#define ef else if
#define wh while
#define el else
#define ivv(x) int x; cin>>x
#define lv(x) bint x; cin>>x
#define sv(x) string x; cin>>x
#define cv(x) char x; cin>>x
#define fv(x) float x; cin>>x
#define dv(x) double x; cin>>x
#define endl '\n'
using namespace std;

auto SOLUTION_FUNCTION( void ) ->void {

    // your solution goes here 
    bitset<10000>v;
    v.reset();
    ivv(s);
    int counter = 1; 
    int mx = INT_MIN;
    v.set(s , 1);
    while(true){
        s = (s&1)?(3*s+1):(s/2);
        counter++;
        if(v[s]){
            cout<<counter<<endl;
            return;
        }else{
            v.set(s , 1);
        }
    } 
//    cout<<counter+3<<endl;
    return ;
}




int main(void){
#ifdef FAST_INPUT_OUTPUT
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cout<<setprecision(10);
    cout<<fixed;
    cout<<boolalpha;
#endif
#ifdef MY_LOCAL_PROJECT
    freopen("input","r",stdin);
    freopen("output","w",stdout);
#endif
    int testcase = 1;


#ifdef MORE_THAN_ONE_TESTCASE
    cin>>testcase;
#endif
    
    while(testcase--){
        SOLUTION_FUNCTION();
    }

#ifdef MY_LOCAL_PROJECT
    cout<<"Time : "<<1.0*(double)clock()/CLOCKS_PER_SEC<<endl;
#endif
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
   string str;cin>>str;
   bool c1=true,c2=true;
   for(int i=0;i<str.size();i++)
   {
       if(i%2==0)//ODD
       {
            if(str[i]!='R'&& str[i]!='U'&& str[i]!='D')
            {
                c1=false;
                break;
            }
       }
       else if(i%2==1)
       {
            if(str[i]!='L'&& str[i]!='U'&&str[i]!='D')
            {
                c1=false;
                break;
            }
       }
   }
   if(c1==true && c2==true)
   {
       cout<<"Yes\n";
   }
   else cout<<"No\n";
   
   return 0;
}

Measured memory_bytes: 3628
import java.util.*;

	public class Main{
			
			public static void main(String args[]){
			
				Scanner sc = new Scanner(System.in);
				int n = sc.nextInt();
				
				int heights[] = new int[n];
				
				for(int i = 0; i < n; i++){
					
					heights[i] = sc.nextInt();
					
				}
				
				int flag = 1;
				
				for(int i = n-1; i > 0 ; i--) {
						
					if(heights[i] < heights[i-1]){

						heights[i-1]-=1;
						
						if(heights[i] < heights[i-1]){
	
							flag = 0;
							break;
						
						} else {
							
							continue;		
						
						}
						
					} else {

							continue;
				
					}						
				
				}
					
					if(flag == 1){
						
						System.out.println("Yes");
						
					} else {
						
						System.out.println("No");
						
					}
				
			
			}
	}

Measured memory_bytes: 50624
n = int(input())

lst = []
for i in range(n):
    xi, li = map(int, input().split())
    lst.append([xi, li])

lst_2 = []
for i in range(n):
    xi, li = lst[i][0], lst[i][1]
    lst_2.append([xi-li, xi+li])

lst_2.sort(key=lambda x: x[1])

cnt = 1
right = lst_2[0][1]
for i in range(1, n):
    if lst_2[i][0] >= right:
        right = lst_2[i][1]
        cnt += 1

print(cnt)

Measured memory_bytes: 37868
N = int(input())
board = [input(), input()]

if N == 1:
    print(3)
    quit()


if board[0][0] == board[0][1]:
    cnt, prev = 6, 0
else:
    cnt, prev = 3, 1
mod = 10 ** 9 + 7

for i in range(1, N):
    if board[0][i] == board[0][i - 1]:
        continue
    elif i < N - 1 and board[0][i] == board[0][i + 1] and prev == 0:
        cnt *= 3
        cnt %= mod
    elif i < N - 1 and board[0][i] == board[0][i + 1] and prev == 1:
        cnt *= 2
        cnt %= mod
        prev = 0
    elif board[0][i] == board[1][i] and prev == 0:
        prev = 1
    else:
        cnt *= 2
        cnt %= mod
print(cnt)


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

int main(){
  vector<int> x(3,0);
  REP(i,3) cin>>x.at(i);
  sort(x.begin(),x.end());
  cout<<x.at(2)*10+x.at(1)+x.at(0);
}

Measured memory_bytes: 256
use std::io;
use std::io::Write;

fn main() {
    let mut first_line  = String::new();
    let mut second_line = String::new();

    io::stdin().read_line(&mut first_line)
        .expect("Failed to read first line");

    io::stdin().read_line(&mut second_line)
        .expect("Failed to read second line");

    let first_line: Vec<u32> = first_line
        .split_whitespace()
        .map(|s| s.parse().unwrap())
        .collect();

    let second_line: Vec<u32> = second_line
        .split_whitespace()
        .map(|s| s.parse().unwrap())
        .collect();

    let minimum_height: u32 = first_line[1];
    let mut friends_allowed: u32 = 0;

    for index in 0..second_line.len() {
        if second_line[index] >= minimum_height {
            friends_allowed = friends_allowed + 1;
        }
    }

    print!("{}", friends_allowed);
    io::stdout().flush().unwrap();
}


Measured memory_bytes: 4352
#!/usr/bin/env python3
import sys
INF = float("inf")


def solve(S: str):
    print(700+100*S.count("o"))
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    solve(S)


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Math;

class Program
{
    static void Main()
    {
        var mb = new ModBinom(2000);
        var NK = ReadLine().Split(' ');
        var N = int.Parse(NK[0]);
        var K = int.Parse(NK[1]);
        SetOut(new System.IO.StreamWriter(OpenStandardOutput()) { AutoFlush = false });
        for (int i = 1; i <= K; i++)
        {
            WriteLine((mb.Binom(K - 1, i - 1) * mb.Binom(N - K + 1, i) % ((long)1e9 + 7)).ToString());
        }
        Out.Flush();
    }
}

class ModBinom
{
    long[] fac;
    long[] finv;
    int mod;

    public ModBinom(int N, int p = (int)1e9 + 7)//N < p  O(N)
    {
        N++;

        fac = new long[N];
        long[] inv = new long[N];
        finv = new long[N];

        fac[0] = fac[1] = 1;
        inv[1] = 1;
        finv[0] = finv[1] = 1;

        for (int i = 2; i < fac.Length; i++)
        {
            fac[i] = fac[i - 1] * i % p;
            inv[i] = p - inv[p % i] * (p / i) % p;
            finv[i] = finv[i - 1] * inv[i] % p;
        }

        mod = p;
    }

    [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
    public long Binom(int n, int k)// O(1)
    {
        if (n < k) return 0;
        if (n < 0 || k < 0) return 0;
        return fac[n] * finv[k] % mod * finv[n - k] % mod;
    }
}


Measured memory_bytes: 13212
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <queue>
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
ll n, a, sma;
vector<ll> vec, G;

ll pow(ll x, ll y)
{
	if (y == 0) return 1;
	if (y % 2)
	{
		return pow(x, y - 1) * x % mod;
	}
	else
	{
		ll yyy = pow(x, y / 2);
		return yyy * yyy % mod;
	}
}

ll div(ll x)
{
	return pow(x, mod - 2);
}

int main(void)
{
	cin >> n;
	sma = 100000000000000000;
	for (int i = 0; i < 5; i++)
	{
		cin >> a;
		sma = min(sma, a);
	}
	cout << 4 + (n - 1) / sma + 1 << endl;
	int www;
	cin >> www;
}


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


#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int MD = (int)1e9 + 7; typedef vector<ll> VL;
void dbg(){ cerr << "\n"; }  template <class T, class ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }
template <class T, class T2> void amin(T& a,T2 b){ if(a > b) a = b;}

int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	int h, w;
	cin >>h >>w;
	if(h%3==0 || w%3==0){puts("0"); return 0;}
	
	auto cker=[](ll hh, ll ww) ->ll{
		

		ll ans = hh%3? ww : 0;
		
		rep2(i, 1, hh){
			ll a = i *ww;
			
			ll wb = ww /2;
			ll b = (hh-i)*wb;
			ll c = (hh-i)*(ww-wb);
			if(a<=0 || b<=0 || c<=0) continue;
			ll cnd = max({a,b,c}) - min({a,b,c});
			ans = min(ans, cnd);
		}
		return ans;
	};
	
	cout << min(cker(h,w),  cker(w,h)) <<"\n";
	return 0;
}


Measured memory_bytes: 256
a, b, c = gets.chomp.split(" ").map(&:to_i)
k = gets.chomp.to_i
counter = 0
while a >= b do
    b *= 2
    counter += 1
end
while b >= c do
    c *= 2
    counter += 1
end

puts counter <= k ? "Yes" : "No"

Measured memory_bytes: 14308
# ITP1_4_D: Min, Max and Sum

MIN = -10 ** 6
MAX =  10 ** 6

n_nums = gets.to_i
nums   = gets.split.map &:to_i

min = MAX
max = MIN
sum = 0
nums.each do |n|
  min = n if n < min
  max = n if max < n
  sum += n
end

puts [min, max, sum].join(' ')

Measured memory_bytes: 9088
#include<iostream>
using namespace std;
int dfs(int y,int x);
int h,w;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
char flu;
char ma[111][111];
int main(){
  while(1){
    int cou=0;
    cin>>h>>w;
    if(h==0 && w==0) break;
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
	cin>>ma[i][j];
      }
    }
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
	if(ma[i][j]=='#' || ma[i][j]=='*' || ma[i][j]=='@'){
	  flu=ma[i][j];
	  dfs(i,j);
	  cou++;
	}
      }
    }
    cout<<cou<<endl;
  }
}
int dfs(int y,int x){
  ma[y][x]='.';
  for(int i=0;i<4;i++){
    int ny=y+dy[i];
    int nx=x+dx[i];
    if(0<=nx && nx<w && 0<=ny && ny<h && ma[ny][nx]==flu){
      dfs(ny,nx);
    }
  }
}

Measured memory_bytes: 1480
#include<iostream>//ITP1 7C:Spreadsheeet
using namespace std;
int main(void)
{
	int t[101][101],r,c;
	cin>>r>>c;
	for(int i=0;i<=r;i++) for(int j=0;j<c;j++) cin>>t[i][j];
	for(int i=0;i<=r;i++) t[i][c]=0;
	for(int j=0;j<=c;j++) t[r][j]=0;
	for(int i=0;i<r;i++){
		for(int j=0;j<c;j++){
			t[i][c]+=t[i][j];
			t[r][j]+=t[i][j];
			t[r][c]+=t[i][j];
		}
	}
	for(int i=0;i<=r;i++){
		for(int j=0;j<=c;j++){
			if(j)cout<< " ";
			cout<<t[i][j];
		}
		cout<<endl;
	}
	return 0;
}


Measured memory_bytes: 3120
N = int(input())
M1 = 0
M2 = 0
n = 0

for i in range(N):
  A = int(input())
  if M1 < A:
    M1 = A
    n = i
  elif M2 < A:
    M2 = A
  else:
    continue

for i in range(N):
  if n == i and M1 > M2:
    print(M2)
  else:
    print(M1)

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

typedef long long int ll;
ll MOD = 1000000007;
ll INFL = 1ll << 60;
ll INF = 1 << 28;

// ====================================================================

int main() {
  string s;
  cin >> s;
  if (s[0] == s[1] || s[1] == s[2] || s[2] == s[3])
    cout << "Bad" << endl;
  else
    cout << "Good" << endl;
}


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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int H,W;
int A[1010],B[1010];
int As[1010*1010];
int Bs[1010*1010];

int C[1010][1010];

ll mo=1000000007;

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	MINUS(As);
	MINUS(Bs);
	cin>>H>>W;
	FOR(i,H) {
		cin>>A[i];
		if(As[A[i]]>=0) return _P("0\n");
		As[A[i]]=i;
	}
	FOR(i,W) {
		cin>>B[i];
		if(Bs[B[i]]>=0) return _P("0\n");
		Bs[B[i]]=i;
	}
	
	ll ret=1;
	int cand=0;
	for(i=H*W;i>=1;i--) {
		if(As[i]>=0 && Bs[i]>=0) {
			FOR(x,W) {
				if(C[As[i]][x]==1) cand++;
				C[As[i]][x]++;
			}
			FOR(y,H) {
				if(C[y][Bs[i]]==1) cand++;
				C[y][Bs[i]]++;
			}
			
		}
		else if(As[i]>=0) {
			int pat=0;
			FOR(x,W) {
				if(C[As[i]][x]==1) cand++;
				C[As[i]][x]++;
				if(C[As[i]][x]==2) pat++;
			}
			ret=ret*pat%mo;
		}
		else if(Bs[i]>=0) {
			int pat=0;
			FOR(y,H) {
				if(C[y][Bs[i]]==1) cand++;
				C[y][Bs[i]]++;
				if(C[y][Bs[i]]==2) pat++;
			}
			ret=ret*pat%mo;
		}
		else {
			ret=ret*cand%mo;
		}
		cand--;
		
	}
	
	cout<<ret<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


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

int main() {
  int H;
  int W;

  cin >> H >> W;

  vector<string> vec(H);

  for (int i = 0; i < H; i++){
    cin >> vec.at(i);
  }
  for(int i = 0; i < W + 1; i++){
    cout << "#";
  }
    cout << "#" << endl;
  for(int i = 0; i < H; i++){
      cout << "#" + vec.at(i) + "#" << endl;
  }
  for(int i = 0; i < W + 1; i++){
    cout << "#";
  }
  cout << "#" << endl;
}


Measured memory_bytes: 3612
//Utkarsh.25dec
#include <bits/stdc++.h>
#include <chrono>
#include <random>
#define ll long long int
#define ull unsigned long long int
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define rep(i,n) for(ll i=0;i<n;i++)
#define loop(i,a,b) for(ll i=a;i<=b;i++)
#define vi vector <int>
#define vs vector <string>
#define vc vector <char>
#define vl vector <ll>
#define all(c) (c).begin(),(c).end()
#define max3(a,b,c) max(max(a,b),c)
#define min3(a,b,c) min(min(a,b),c)
#define deb(x) cerr<<#x<<' '<<'='<<' '<<x<<'\n'
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>
// ordered_set s ; s.order_of_key(val)  no. of elements strictly less than val
// s.find_by_order(i)  itertor to ith element (0 indexed)
typedef vector<vector<ll>> matrix;
ll power(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll modInverse(ll a){return power(a,mod-2);}
const int N=500023;
bool vis[N];
vector <int> adj[N];
void solve()
{
    ll n;
    cin>>n;
    ll odd=0;
    rep(i,n)
    {
        ll c;
        cin>>c;
        if(c%2==1)
            odd++;
    }
    if(odd%2==0)
        cout<<"YES\n";
    else
        cout<<"NO\n";
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int T=1;
    //cin>>T;
    int t=0;
    while(t++<T)
    {
        //cout<<"Case #"<<t<<":"<<' ';
        solve();
        //cout<<'\n';
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}

Measured memory_bytes: 15468
#![allow(non_snake_case, unused)]
use std::cmp::*;
use std::collections::*;
use std::f64::consts::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        x: usize,
        y: usize,
    }
    let mut ans = vec![];
    let mut acc = x;
    loop {
        ans.push(acc);
        if acc * 2 <= y {
            acc *= 2;
        } else {
            break;
        }
    }
    println!("{}", ans.len());
}


Measured memory_bytes: 4352
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		int[,]A = new int[3,3];
		for(var i=0;i<3;i++){
			string[] str = Console.ReadLine().Split();
			for(var j=0;j<3;j++){
				A[i,j] = int.Parse(str[j]);
			}
		}
		int[,]B = new int[3,3];
		int N = int.Parse(Console.ReadLine());
		for(var h=0;h<N;h++){
			int a1 = int.Parse(Console.ReadLine());
			for(var i=0;i<3;i++){
				for(var j=0;j<3;j++){
					if(A[i,j]==a1){
						B[i,j]=1;
					}
				}
			}
		}
		string ans = "No";
		for(var i=0;i<3;i++){
			bool flag = true;
			for(var j=0;j<3;j++){
				if(B[i,j]==0){
					flag = false;
				}
			}
			if(flag){
				ans = "Yes";
			}
		}
		for(var j=0;j<3;j++){
			bool flag = true;
			for(var i=0;i<3;i++){
				if(B[i,j]==0){
					flag = false;
				}
			}
			if(flag){
				ans = "Yes";
			}
		}
		bool flag2 = true;
		for(var i=0;i<3;i++){
			if(B[i,i]==0){
				flag2 = false;
			}
		}
		if(flag2){
			ans = "Yes";
		}
		flag2 = true;
		for(var i=0;i<3;i++){
			if(B[i,2-i]==0){
				flag2 = false;
			}
		}
		if(flag2){
			ans = "Yes";
		}
		for(var i=0;i<3;i++){
         	for(var j=0;j<3;j++){
              Console.Error.Write(B[i,j]+" ");
            }
          Console.Error.WriteLine();
        }
		Console.WriteLine(ans);
	}
}

Measured memory_bytes: 13140
//#include <bits/stdc++.h>
#include<iostream>
#include<cmath>
#include<string>
#include<queue>
#include<vector>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)//初期値a,i<bの範囲でループ
#define REP(i,n) FOR(i,0,n)//初期値0,i<nの範囲でループ
using namespace std;
typedef long long ll;//int64
typedef unsigned long long ull;

string s,t;

int flag=0;
int main(){

    cin>>s>>t;
    int i;
    
    if(s.size()<t.size()){
        cout<<"UNRESTORABLE"<<endl;
        return 0;
    }

    for(i=0;i<=s.size()-t.size();i++){
        string sb;
        //したからけんさく
        sb=s.substr(s.size()-i-t.size(),t.size());
        flag=0;
        for(int j=0;j<sb.size();j++){
            if(sb[j]=='?')continue;
            else if(sb[j]==t[j])continue;
            else flag=1;
        }
        if(!flag)break;
    }
    if(flag){
        cout<<"UNRESTORABLE"<<endl;
        return 0;
    }

    s.replace(s.size()-i-t.size(),t.size(),t);
    REP(k,s.size())if(s[k]=='?')s[k]='a';

    cout<<s<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){
  long long int N,M;
  scanf("%lld",&N);
  scanf("%lld",&M);
  if(N==1){
    if(M==1){
      printf("1");
    }
    else{
      printf("%lld",M-2);
    }
  }
  else if(M==1){
    printf("%lld",N-2);
  }
  else{
    printf("%lld",(M-2)*(N-2));
  }
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <cstdlib>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <string>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
using vi = vector<int>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける
using vl = vector<ll>;  // long longの1次元の型に vl という別名をつける
using vvl = vector<vl>; // long longの2次元の型に vvl という別名をつける
int MOD = 1000000007; //10^9 + 7

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

// 無限大の値
const ll  lINF = 1LL << 60;
const int iINF = 1 << 29;

int main(void){
  int n;
  cin >> n;

  cout << n/3 << endl;
  return 0;
} 

Measured memory_bytes: 3560
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n-1);i>=0;i--)
#define FOR(i,n,m) for(int i=n;i<=(int)(m);i++)
#define RFOR(i,n,m) for(int i=(int)(n);i>=m;i--)
#define all(x) (x).begin(),(x).end()
#define sz(x) int(x.size())
#define get_unique(x) x.erase(std::unique(all(x)), x.end());
typedef long long ll;
const int INF = 1e9;
const ll MOD = 1e9+7;
const ll LINF = 1e18;
const double PI=acos(-1);
using namespace std;
vector<int> dx={1,0,-1,0};
vector<int> dy={0,1,0,-1};
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; }
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

int main() {
    string s,t;
    cin>>s>>t;
    int n=sz(s),m=sz(t);
    auto dp=make_vec<int>(3010,3010);
    dp[0][0]=0;
    rep(i,sz(s)+1) {
        rep(j,sz(t)+1) {
            chmax(dp[i+1][j],dp[i][j]);
            chmax(dp[i][j+1],dp[i][j]);
            if(s[i]==t[j]) chmax(dp[i+1][j+1],dp[i][j]+1);
        }
    }
    
    string ans="";
    int x=n,y=m;
    while(x>0 && y>0) {
        if(dp[x][y]==dp[x-1][y]) x--;
        else if(dp[x][y]==dp[x][y-1]) y--;
        else {
            x--;
            y--;
            ans=s[x]+ans;
        }
    }
    
    cout<<ans<<endl;
     
}


Measured memory_bytes: 35712
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define max0(a,b,c) max(max(a,b),c)
#define min0(a,b,c) min(min(a,b),c)
#define ft first
#define sc second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define all(v) (v).begin(),(v).end()
#define mod 1000000007
using namespace std;
using Graph = vector<vector<int>>;
typedef long long lint;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ldouble;
typedef vector<int> vec;
typedef vector<ll> lvec;
typedef vector<ull> ulvec;
typedef vector<pair<int,int>> pvec;
typedef vector<pair<ll,ll>> plvec;
typedef vector<tuple<ll,ll,ll>> tvec;
typedef vector<string> svec;

set<ll> st;
ll m=1;

void solve(ll s){
    if(!st.count(s)){
        st.insert(s);
        m++;
        if(s%2==0) solve(s/2);
        else solve(3*s+1);
    }else cout<<m;
}

int main(){
    ll s;
    cin>>s;
    solve(s);
}

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

using namespace std;
//typedef long long ll;
typedef unsigned long long ll;

//#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) ll(x.size())
typedef pair<int, int> P;
//typedef pair<ll, ll> P;
//const double INF = 1e10;
//const ll INF = LONG_LONG_MAX;
const ll INF = 1e15;
const ll MINF = LONG_LONG_MIN;
//const int INF = INT_MAX / 10;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }


//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);

typedef priority_queue<ll, vector<ll>, greater<ll>> PQ_ASK;
const int mod = 1000000007;


// https://qiita.com/okaryo/items/8e6cd73f8a676b7a5d75
void warshall_floyd(int n, vector<vector<int>> &d) {
    for (int k = 0; k < n; k++) {       // 経由する頂点
        for (int i = 0; i < n; i++) {    // 始点
            for (int j = 0; j < n; j++) {  // 終点
                d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
            }
        }
    }
}

int main() {
    int h, w;
    cin >> h >> w;

    vector<vector<char>> maze(h, vector<char>(w));

    rep(y, h) rep(x, w) {
            char c;
            cin >> c;
            maze[y][x] = c;
        }

    vector<vector<int>> distances(h * w, vector<int>(h * w, 1000));

    auto toID = [&](int y, int x) {
        return y * w + x;
    };

    vector<P> move = {
            {0,  1},
            {1,  0},
            {0,  -1},
            {-1, 0},
    };


    rep(y, h) rep(x, w) {
            if (maze[y][x] == '#') continue;
            distances[toID(y, x)][toID(y, x)] = 0;

            for (P p : move) {
                int cy = p.first;
                int cx = p.second;

                int ny = y + cy;
                int nx = x + cx;

                if (ny == -1) continue;
                if (nx == -1) continue;
                if (ny == h) continue;
                if (nx == w) continue;

                if (maze[y][x] == '.' && maze[ny][nx] == '.') {
                    distances[toID(y, x)][toID(ny, nx)] = 1;
                    distances[toID(ny, nx)][toID(y, x)] = 1;
                }
            }
        }


    warshall_floyd(w * h, distances);

    int ans = 0;
    rep(i, h * w) rep(j, h * w) {
            int d = distances[i][j];
            if (d >= 1000) {
                continue;
            }
            cmax(ans, d);
        }
    cout << ans << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define per(i,a,n) for(int i=a;i<=n;i++)
using namespace std;
typedef long long ll;
typedef vector<ll>vec;
typedef vector<vector<ll>> mat;
set<int>s;
int a[5];
//vector<int>a[5];
int main()
{
  int n,m;
  cin>>n>>m;
  int flag=0;
  for(int i=1;i<=2000;i++)
  {
      int ans1=i*0.08,ans2=i*0.1;
      if(ans1==n&&ans2==m) {cout<<i<<endl;flag=1;break;}
  }
  if(!flag) cout<<-1<<endl;
  return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<vector>
#include<cmath>
#include<string>
#include<cstring>
#include<algorithm>
#include<queue>
#include<map>
#include<set>
#define  endl '\n'
#define all(s) s.begin(),s.end()
#define lowbit(x) (x&-x)
#define rep(i,a,n) for (int i=a;i<=n;i++)
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define mem(a,b) memset(a,b,sizeof(a))
#define fi first
#define se second
#define pb push_back
#define PI acos(-1.0)
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int mod=1e9+7;
const double eps=1e-8;
const int inf=0x3f3f3f3f;
const int N=2e5+10;
int n,m,q,a[N];
ll k;
int main()
{
	cin>>n>>k;
	for(int i=1;i<=n;i++) cin>>a[i];
	vector<int>pos;
	pos.pb(1);
	set<int>s;
	s.insert(1);
	int to=a[1];
	while(!s.count(to)){
		s.insert(to);
		pos.pb(to);
		to=a[to];
	}
//	cout<<to<<endl;
	int ans=0;
	for(int i=0;i<pos.size();i++){
		if(pos[i]==to){
			ans=i+1;
			break;
		}
	} 
	int tot=pos.size()-ans+1;
//	for(auto x:pos) cout<<x<<' ';
//	cout<<endl;
	k++;
	if(k<=pos.size()) cout<<pos[k-1];
	else{
		k-=ans-1;
		ll last=k%tot;
	//	cout<<tot<<" "<<last<<endl;
		if(last==0) cout<<pos[pos.size()-1];
		else cout<<pos[ans+last-2];		
	}

}


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

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

    vector<int> a(n+1);
    for(int i=1; i<=n; i++){
        cin >> a[i];
    }

    int k = 1;
    int count = 1;
    while(1){
        if(a[k] == 2) break;
        if(count > n){
            count = -1;
            break;
        }
        count += 1;
        k = a[k];
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0;i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<vector<int>> Graph;


int main() {
    int n;
    string s;
    cin >> n;
    cin >> s;
    int r=0,w=0,relse=0,welse=0;
    rep(i,n){
        if(s[i]=='R') r++;
        else w++;
    }
    rep(i,r){
        if(s[i]=='W') welse++;
    }
    relse = welse;
    if(r==n||w==n){
        cout << 0 << endl;
        return 0;
    }
    cout << max(relse,welse) << endl;
}

Measured memory_bytes: 3712
#include"bits/stdc++.h"
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define mkp(a,b) make_pair(a,b)
const long long mod = 1000000007;
const long long inf = 1ll<<61;
typedef pair<int, int> P;
typedef pair<int ,P> PP;
struct edge { int to; int to2; int cost; };

signed main() {
	int p, q, r; cin >> p >> q >> r;
	cout << p + q + r - max(p, max(q, r)) << endl;
}

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

int main(){
  ll n,k; cin>>n>>k;
  ll ans = min(n%k, abs((n%k)-k));
  cout << ans << endl;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define ALL(v) (v).begin(), (v).end()
using ll = long long;
using P = pair<int, int>;
constexpr int INF = 1e9;
constexpr long long LINF = 1e18;
constexpr long long MOD = 998244353;

template <int MOD = 1000000007>
struct Mint {
    int x;

    Mint() : x(0) {}
    Mint(long long t) {
        x = t % MOD;
        if (x < 0) x += MOD;
    }

    Mint pow(int n) {
        Mint res(1), t(x);
        while (n > 0) {
            if (n & 1) res *= t;
            t *= t;
            n >>= 1;
        }
        return res;
    }

    Mint inv() const {
        int a = x, b = MOD, u = 1, v = 0, t;
        while (b > 0) {
            t = a / b;
            a -= t * b;
            swap(a, b);
            u -= t * v;
            swap(u, v);
        }
        return Mint(u);
    }

    Mint &operator+=(Mint a) {
        x += a.x;
        if (x >= MOD) x -= MOD;
        return *this;
    }

    Mint &operator-=(Mint a) {
        x += MOD - a.x;
        if (x >= MOD) x -= MOD;
        return *this;
    }

    Mint &operator*=(Mint a) {
        x = int(1LL * x * a.x % MOD);
        return *this;
    }

    Mint &operator/=(Mint a) {
        return (*this) *= a.inv();
    }

    Mint operator+(Mint a) const {
        return Mint(x) += a;
    }
    Mint operator-(Mint a) const {
        return Mint(x) -= a;
    }
    Mint operator*(Mint a) const {
        return Mint(x) *= a;
    }
    Mint operator/(Mint a) const {
        return Mint(x) /= a;
    }

    Mint operator-() const {
        return Mint(-x);
    }

    bool operator==(const Mint a) {
        return x == a.x;
    }
    bool operator!=(const Mint a) {
        return x != a.x;
    }
    bool operator<(const Mint a) {
        return x < a.x;
    }

    friend ostream &operator<<(ostream &os, const Mint &a) {
        return os << a.x;
    }

    friend istream &operator>>(istream &is, Mint &a) {
        int t;
        is >> t;
        a = Mint<MOD>(t);
        return (is);
    }
};

signed main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    Mint<MOD> dp[c + 1][d + 1];
    dp[a][b] = 1;
    for (int i = a; i <= c; i++) {
        for (int j = b; j <= d; j++) {
            if(i > a) dp[i][j] += dp[i - 1][j] * j;
            if(j > b) dp[i][j] += dp[i][j - 1] * i;
            if(i > a && j > b){
                dp[i][j] -= dp[i - 1][j - 1] * (i - 1) * (j - 1);
            }
        }
    }
    cout << dp[c][d] << endl;
    return 0;
}

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

#define SZ(x) (int)((x).size())
#define xx first
#define yy second
#define pii pair<int, int>



void solve() {
    int x;
    cin >> x;
    cout << (x >= 30 ? "Yes" : "No") << '\n';
}
int main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    // int _; cin >> _; while (_--)
    solve();
    return 0;
}


Measured memory_bytes: 3648
import java.util.Scanner;

public class Main {
	public static void main(String[]args){
		//????????£?????????????????????
		Scanner sc = new Scanner(System.in);

		//???????????????a?????????
		int a = sc.nextInt();
		//?¨??????????b?????????
		int b = sc.nextInt();

		//??¢???
		int area = a*b;
		//??¨????????? (???+?¨?)*2
		int zhou = (a + b) * 2 ;

		//??¨??? ??¢??? ?¨?
		System.out.println(area + " " + zhou);
	}
}

Measured memory_bytes: 26216
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn min (a: &i64, b: &i64)-> i64{
    if *a <= 0i64 {*b}
    else if *b <= 0i64  {*a}
    else if *a < *b {*a}
    else {*b}
}

fn abs (a: &i64, b: &i64) -> i64{
    if *a - *b <= 0 {*b - *a} else {*a - *b}
}

fn main(){
    input!{
        n: usize,
        a: [i64; n],
    }
    let mut sum = vec![0i64; n+1];
    sum[0] = abs(&0i64, &a[0]);
    for i in 0..a.len()-1{
        sum[i+1] = abs(&a[i], &a[i+1]);
    }
    sum[a.len()] = abs(&a[a.len()-1], &0i64);
    let all = sum.iter().fold(0, |s, ad| s + ad);
    for i in 0..a.len(){
        let result = sum[i] + sum[i+1] - (if i == 0usize {abs(&0i64, &a[i+1])}
        else if i >= a.len() -1 {abs(&a[i-1], &0i64)}
        else {abs(&a[i-1], &a[i+1])});
        println!("{}", all-result);
    }
}


Measured memory_bytes: 7292
#include "bits/stdc++.h"
#define rep(i,n) for(int i=0;i<n;i++)
#define ALL(v) (v).begin(),(v).end()
typedef long long LL;
const LL INF = (1LL << 31) - 1;
const LL MOD = 1000000007LL;
using namespace std;
int len[200001];
vector<int> pos[26];
int main() {
	string A;
	cin >> A;
	rep(i, A.size()) pos[A[i] - 'a'].push_back(i);
	bool ch[26] = { 0 };
	int cnt = 0;
	int k = 0;
	len[A.size()] = 0;
	for (int i = A.size() - 1; i >= 0; i--) {
		if (!ch[A[i] - 'a']) {
			ch[A[i] - 'a'] = 1;
			cnt++;
		}
		if (cnt == 26) {
			rep(j, 26) ch[j] = 0;
			cnt = 0;
			k++;
		}
		len[i] = k + 1;
	}
	int now = 0;
	string ans = "";
	rep(i, len[0]) {
		rep(j, 26) {
			int ptr = lower_bound(pos[j].begin(), pos[j].end(), now) - pos[j].begin();
			if (ptr == pos[j].size() || len[pos[j][ptr] + 1] == len[now] - 1) {
				ans += string(1, 'a' + j);
				if (ptr < pos[j].size()) now = pos[j][ptr] + 1;
				break;
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 2180
#include<iostream>
using namespace std;
int p[10001];
int main()
{
    int a,b,k,cnt=0;
    cin>>a>>b>>k;
    for(int i=1;i<=max(a,b);i++)
    {
        if(!(a%i)&&!(b%i))p[++cnt]=i;
    }
    cout<<p[cnt-k+1];
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <fstream>
#include <iostream>
#include <list>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <valarray>
#include <vector>

#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#define repeat(i,n)     for(int i=0; i<(n); ++i)
#define repeat1(i,n)    for(int i=1; i<=(n); ++i)
#define range(i,l,r)    for(int i=(l); i<(r); ++i)

using namespace std;
typedef long long llint;

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

    int cnt = 0;
    for(auto it=pos.begin()+1; it!=pos.end(); ++it) {
        if(*it != *(it-1))    ++cnt;
    }

    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 512
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <climits>
#include <cmath>
#include <complex>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <iomanip>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <cstdint>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
#define MP make_pair
#define PB push_back
#define inf 1000000007
#define rep(i,n) for(int i = 0; i < (int)(n); ++i)
#define all(x) (x).begin(),(x).end()

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}
 
template<class T> inline bool chmax(T &a, T b){
    if(a<b){
        a = b;
        return true;
    }
    return false;
}

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

int main(){
    int k;
    cin >> k;
    rep(i,k){
        cout << "ACL";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 3588