akhauriyash/Code-Regression huggingface dataset:
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <string>

using namespace std;

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

  string ab;
  for (int i = 0; i < b; i++) {
    ab += to_string(a);
  }

  string ba;
  for (int i = 0; i < a; i++) {
    ba += to_string(b);
  }


  cout << ((ab <= ba) ? ab : ba) << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <tuple>
#include <utility>
#include <vector>
#define ll long long
#define itn int
#define endl '\n'
#define co(ans) cout<<ans<<endl
#define COYE cout<<"YES"<<endl
#define COYe cout<<"Yes"<<endl
#define COye cout<<"yes"<<endl
#define CONO cout<<"NO"<<endl
#define CONo cout<<"No"<<endl
#define COno cout<<"no"<<endl
#define FORE(i,a) for(auto &i:a)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define PB push_back
#define MP make_pair
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define EACH(V,i) for(typeof((V).begin()) i=(V).begin();i!=(V).end();++i)
#define equals(a,b) (fabs((a)-(b))<EPS)
#define INF ((1LL<<62)-(1LL<<31))
#define EPS 1e-10
#define PI 3.141592653589793238
#define MOD 1000000007
#define MAX 5100000
using namespace std;
using Edge=pair<int,int>;
using Graph=vector<vector<int>>;
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>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;}
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

////////// 二項係数(N<=10^7) //////////

ll fac[MAX],finv[MAX],inv[MAX];
// fac[i] i!
// finv[i] i!の逆元
// inv[i] iの逆元

// テーブルを作る前処理
void COMinit(){
  fac[0]=fac[1]=1;
  finv[0]=finv[1]=1;
  inv[1]=1;
  for(ll i=2; i<MAX; ++i){
    fac[i]=fac[i-1]*i%MOD;
    inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
    finv[i]=finv[i-1]*inv[i]%MOD;
  }
}

// 二項係数計算
ll COM(ll n,ll k){
  if(n<k) return 0;
  if(n<0 || k<0) return 0;
  return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}

//////////////////////////////////////////////////

////////// 繰り返し二乗法 //////////

ll power(ll a,ll b){
  ll res=1;
  while(b>0){
    if(b&1) res=res*a%MOD;
    a=a*a%MOD;
    b>>=1;
  }
  return res;
}

//////////////////////////////////////////////////

int main(){
  COMinit();
  ll K,ans=0LL;
  string S;
  cin>>K>>S;
  ll P[2000010],Q[2000010];
  P[0]=1;
  Q[0]=1;
  RREP(i,S.size()+K){
    P[i]=P[i-1]*25%MOD;
    Q[i]=Q[i-1]*26%MOD;
  }
  
  
  REP(i,S.size()){
    ans+=COM(S.size()+K,i)*P[S.size()+K-i];
    ans%=MOD;
  }
  ans=Q[S.size()+K]-ans;
  ans%=MOD;
  if(ans<0) ans+=MOD;
  co(ans);
  return 0;
}

Measured memory_bytes: 155188
/**
 * Title: D - Disjoint Set of Common Divisors
 * Url: https://atcoder.jp/contests/abc142/tasks/abc142_d
 */
#include<bits/stdc++.h>

using namespace std;

#define ll long long

/**
 * 素因数分解
 * 計算量 O(log(n))
 **/
template<typename T>
map<T, int> get_prime_factors(T n) {
    map<T, int> prime_factors;
    T num = n;
    if(num<=1) return prime_factors;
    for(T i=2; i*i<=n; i++) {
        while(num%i==0) {
            prime_factors[i]++;
            num /= i;
        }
    } 
    if(num!=1) prime_factors[num]++;
    return prime_factors;
}


// 最大公約数
ll gcd(ll a, ll b) {
    if(a==b) return a;
    if(a<b) {
        ll tmp = a;
        a = b;
        b = tmp;
    }
    ll r = a%b;
    while(r!=0) {
        ll tmp_r = r;
        r = b % r;
        b = tmp_r;
    }
    return b;
}

int main() {
    ll a, b; cin >> a >> b;
    ll gcdn = gcd(a, b);
    auto primeFactors = get_prime_factors(gcdn);
    ll ans = primeFactors.size();
    cout << ans+1 << endl;
    return 0;
}

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

using namespace std;

int main()
{
	int n;
	cin >> n;
	map<int, int> cnt;
	vector<int> vec;
	for (int i = 0; i < n; i++)
	{
		int a;
		cin >> a;
		cnt[a]++;
		if (cnt[a] % 2 == 0)
			vec.push_back(a);
	}
	sort(vec.begin(), vec.end(), greater<int>());
	cout << (vec.size() < 2 ? 0 : (long long)vec[0] * vec[1]) << endl;

	return 0;
}

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

#define INFTY (1 << 30);
typedef long long ll;

int main(void) {

  int N, K;
  cin >> N >> K;
  

  string str;
  cin >> str;


  str[K-1] = (str[K-1] - 'A') + 'a';

  cout << str << endl;
  
  return 0;
}


Measured memory_bytes: 256
n = int(input())
x = list(map(int,input().split()))
f = [x[0]]
for i in range(n-1):
    f.append(abs(x[i+1]-x[i]))
c = [0]
for i in range(n):
    c.append(abs(f[i]+c[i]))
c.append(abs(x[-1])+c[-1])
d = c[-1]
x.insert(0,0)
x.append(0)
for i in range(n):
    if x[i] < x[i+1] and x[i+2] < x[i+1]:
        print(d-2*abs(x[i+1] - max(x[i],x[i+2])))
    elif x[i+1] < x[i] and x[i+1] < x[i+2]:
        print(d-2*abs(x[i+1] - min(x[i],x[i+2])))
    else:
        print(d)

Measured memory_bytes: 16296
n = int(input())
a = []
b = []
for i in range(n):
    a_, b_ = map(int, input().split())
    a.append(a_)
    b.append(b_)
a.sort()
b.sort()
if n%2 == 0:
    print(b[n//2] + b[n//2-1] - a[n//2] - a[n//2-1] + 1)
else:
    print(b[n//2] - a[n//2] + 1)

Measured memory_bytes: 25416
package main

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

func main() {
	n := getInt()
	as := getIntSlice(n)

	fmt.Println(max(as...) - min(as...))
}

func max(ns ...int) int {
	max := ns[0]
	for i := 1; i < len(ns); i++ {
		if max < ns[i] {
			max = ns[i]
		}
	}
	return max
}

func min(ns ...int) int {
	min := ns[0]
	for i := 1; i < len(ns); i++ {
		if min > ns[i] {
			min = ns[i]
		}
	}
	return min
}

// -----------------------------------------

var scanner = wordScanner()

func wordScanner() *bufio.Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	return sc
}

func getInt() int {
	scanner.Scan()
	i, err := strconv.Atoi(scanner.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func getIntSlice(n int) []int {
	is := make([]int, n)
	for i := range is {
		is[i] = getInt()
	}
	return is
}

func getString() string {
	scanner.Scan()
	s := scanner.Text()
	return s
}


Measured memory_bytes: 640
N=int(input())
P=["*"]+list(map(int,input().split()))

X=0
S=0
for i in range(1,N+1):
    if P[i]==i:
        S+=1
    else:
        X+=(S+1)//2
        S=0
X+=(S+1)//2
print(X)


Measured memory_bytes: 85680
import sys
input = lambda: sys.stdin.readline().rstrip()

def main():
    s = input()
    while True:
        if len(s) >= 5:
            if s[-5:] == 'dream' or s[-5:] == 'erase':
                s = s[:-5]
            elif s[-6:] == 'eraser':
                s = s[:-6]
            elif s[-7:] == 'dreamer':
                s = s[:-7]
            else:
                print('NO')
                return
            if s == '':
                print('YES')
                return
        else:
            print('NO')
            return

if __name__ == '__main__':
    main()

Measured memory_bytes: 3244
#include<iostream>
using namespace std;
int a[1007],c[1007];
long long b[1007];
long long aaa=(long long)1000000000000001;
int h=0;
int main()
{
	long long n;
	scanf("%lld",&n);
	b[1]=26;
	int h=0;
	for(int i=1;;++i)
	{
		b[i]=(b[i-1]+1)*26;
		if(b[i]>aaa||b[i]<=0)
		{
			h=i;break;
		}
	}
	b[h+1]=0x3f3f3f3f3f3f3f3f;
	for(int i=1;i<=h;++i)
	{
		c[i]=n%26;
		n=(n-1)/26;
		if(n==0)
		{
			for(int j=i;j>=1;--j)
			{
				if(c[j]==0)cout<<"z";
				else
				cout<<(char)(c[j]+'a'-1);
			}
			break;
		}
	}
return 0;
}

Measured memory_bytes: 3152
def red_or_blue(N, s):
  s_1 = [x for x in s]
  l_r = s_1.count('R')
  l_b = s_1.count('B')
  if l_r > l_b:
    return 'Yes'
  else:
    return 'No'

i = [input() for i in range(2)]
N = i[0]
s = i[1]
print(red_or_blue(N, s))

Measured memory_bytes: 3060
#include<iostream>

using namespace std;

int A,B,C,D;
int main(){
	cin >>A>>B>>C>>D;

	if(B<C||D<A){
		cout <<0;
	}else{

	if(A>C){
		if(B>D){
			cout <<D-A;
		}else{
			cout <<B-A;
		}

	}else{
		if(B>D){
			cout <<D-C;
		}else{
			cout <<B-C;
		}
	}
	}
		return 0;
}

Measured memory_bytes: 256
let () =
    let answer = Scanf.scanf "%d %d" (fun n m ->
        match n, m with
        | 1, 1 -> 1
        | 1, _ -> m - 2
        | _, 1 -> n - 2
        | _, _ -> (n - 2) * (m - 2)
    )
    in Printf.printf "%d\n" answer


Measured memory_bytes: 2432
N = int(input())

ans = 0

t = [[0]*9 for i in range(9)]

for i in range(1,N+1):
    if i%10==0:
        continue
    x = str(i)
    t[int(x[0])-1][int(x[-1])-1] += 1

for i in range(9):
    for j in range(9):
        if i==j:
            continue
        ans += t[i][j]*t[j][i]

for i in range(9):
    ans += t[i][i]*t[i][i]

print(ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define REP(i,s,e) for(int i=(s); i<(e);i++)
#define rep(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n)
#define repe(i,n) for(auto &&i:n)
#define all(v) (v).begin(),(v).end()
#define decimal fixed<<setprecision(20)
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)
using namespace std;
using LL = long long;
using Graph = vector<vector<int>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = 1e9;
const LL LLINF = 1e16;

double dp[110][110][2];

int main(){
    fastcin();

    int n, t, l, b;
    cin >> n >> t >> l >> b;
    cout << decimal;
    while(n > 0){
        vector<int> trap(n+1, 0);
        rep(i, l){
            int x;
            cin >> x;
            trap[x] = 1;
        }
        rep(i, b){
            int x;
            cin >> x;
            trap[x] = 2;
        }

        memset(dp, 0, sizeof(dp));
        dp[0][0][0] = 1;
        rep(i, t)rep(j, n+1)rep(skip, 2){
            if(j == n){
                dp[i+1][j][0] += dp[i][j][skip];
                continue;
            }
            if(skip == 1){
                dp[i+1][j][0] += dp[i][j][1];
                continue;
            }
            rep1(k, 7){
                int nxt = j+k, lose = 0;
                if(nxt > n) nxt = 2*n-(j+k);
                if(trap[nxt] == 1) lose = 1;
                if(trap[nxt] == 2) nxt = 0;
                dp[i+1][nxt][lose] += dp[i][j][0]/6.;
            }
        }

        cout << dp[t][n][0] << endl;

        cin >> n >> t >> l >> b;
    }
}


Measured memory_bytes: 3448
import java.util.*;

public class Main{
  
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    
    String b = sc.next();
    
    switch(b){
      case "A":
        System.out.println("T");
        break;
      case "C":
        System.out.println("G");
        break;
      case "G":
        System.out.println("C");
        break;
      case "T":
        System.out.println("A");
    }
  }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define mod 1000000007
#define inf 1e18
#define inp(arr,n) for(int i=0;i<n;i++) cin>>arr[i]
#define fr(i,a,b) for(int i=a;i<=b;i++)
using namespace std;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    ll n;
    cin>>n;
    if(n==1){
        cout<<0<<endl;
        return 0;
    }
    vector<ll> p;
    vector<ll> f;
    if(n%2==0){
        ll count=0;
        while(n%2==0){
            count++;
            n/=2;
        }
        p.push_back(2);
        f.push_back(count);
    }
    for(ll i=3;i<=(ll)sqrt(n);i+=2){
        if(n%i==0){
            ll count=0;
            while(n%i==0){
                count++;
                n/=i;
            }
            p.push_back(i);
            f.push_back(count);
        }
    }
    if(n>2){
        p.push_back(n);
        f.push_back(1);
    }
    ll c=0;
    fr(i,0,f.size()-1){
        ll a=f[i];
        ll b=(ll)((-1+sqrt(1+8*a))/2);
        c+=b;
    }
    cout<<c<<endl;
    return 0;
}


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

#ifdef LOCAL
#include "debug.h"
#else
#define DEBUG(...)
#endif

struct undoable_dsu {
  struct dat {
    int p, sz;
  };
  int cc;
  vector<dat> t;
  vector<pair<int, dat>> hist;
  undoable_dsu(int n = 0) : cc(n), t(n, {-1, 1}) {}
  int root(int v) const {
    while (t[v].p != -1) v = t[v].p;
    return v;
  }
  void unite(int u, int v) {
    u = root(u), v = root(v);
    assert(u != v);
    --cc;
    if (t[u].sz < t[v].sz) swap(u, v);
    hist.emplace_back(u, t[u]);
    hist.emplace_back(v, t[v]);
    t[v].p = u;
    t[u].sz += t[v].sz;
  }
  void undo() {
    ++cc;
    for (int _ = 2; _--; ) {
      t[hist.back().first] = hist.back().second;
      hist.pop_back();
    }
  }
  bool same(int u, int v) const { return root(u) == root(v); }
  int size(int v) const { return t[root(v)].sz; }
};

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<int> c(n);
  for (auto&& e : c) {
    cin >> e;
    --e;
  }
  vector<pair<int, int>> edges(n - 1);
  vector<vector<int>> g(n);
  for (auto&& [u, v] : edges) {
    cin >> u >> v;
    --u, --v;
    g[u].push_back(v);
    g[v].push_back(u);
  }
  vector<vector<int>> seg(2 * n);
  auto add = [&](int l, int r, int i) {
    for (l += n, r += n; l < r; l >>= 1, r >>= 1) {
      if (l & 1) {
        seg[l++].push_back(i);
      }
      if (r & 1) {
        seg[--r].push_back(i);
      }
    }
  };
  for (int i = 0; i < n - 1; ++i) {
    auto [u, v] = edges[i];
    if (c[u] > c[v]) {
      swap(u, v);
    }
    if (c[u] == c[v]) {
      add(0, c[u], i);
      add(c[u] + 1, n, i);
    } else {
      add(0, c[u], i);
      add(c[u] + 1, c[v], i);
      add(c[v] + 1, n, i);
    }
  }
  vector<vector<int>> vs(n);
  for (int v = 0; v < n; ++v) {
    vs[c[v]].push_back(v);
  }
  undoable_dsu ud(n);
  vector res(n, (long long)n * (n + 1) / 2);
  for (int k = 0; k < n; ++k) {
    if (empty(vs[k])) {
      res[k] = 0;
    }
  }
  auto dfs = [&](auto&& self, int k) -> void {
    for (int i : seg[k]) {
      ud.unite(edges[i].first, edges[i].second);
    }
    if (k < n) {
      self(self, 2 * k);
      self(self, 2 * k + 1);
    } else {
      set<int> se;
      for (int v : vs[k - n]) {
        for (int u : g[v]) {
          if (c[u] != k - n) {
            se.insert(ud.root(u));
          }
        }
      }
      long long cur = 0;
      for (int v : se) {
        long long sz = ud.size(v);
        cur += sz * (sz + 1) / 2;
      }
      res[k - n] -= cur;
    }
    for (int i : seg[k]) {
      ud.undo();
    }
  };
  dfs(dfs, 1);
  for (auto e : res) {
    cout << e << '\n';
  }
}


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

int main() {
    int n;
    string s;
    cin >> n >> s;
    int max1 = 0;
    for(int i=1;i<n;i++){
        int count = 0;
        string x1 = s.substr(0,i);
        string y1 = s.substr(i,n-i);
        int x[26]={};
        int y[26]={};
        for(int j=0;j<i;j++){
            x[x1[j]-'a']++;
        }
        for(int j=0;j<n-i;j++){
            y[y1[j]-'a']++;
        }
        for(int i=0;i<26;i++){
            if(x[i]>0&&y[i]>0) count++;
        }
        max1 = max(max1,count);
    }
    cout << max1 << endl;
}





Measured memory_bytes: 256
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();

int main() {
    int n;
    cin >> n;
    vector<int> arr(n, 0);
    for(auto& val: arr)
        cin >> val;
    int ans = 0;
    int level = 0;
    for(auto& val : arr) {
        if (val >= level) {
            ans += 1;
            level = val;
        }
    }
    cout << ans << endl;
    return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define lli long long int
#define REP(i,s,l) for(lli i=s;i<l;i++)
#define DEBUG 0
#define INF (1LL<<50)

lli needActNumToA(char c){
	return 'z'-c+1;
}

signed main(){

	string s;
	lli k;
	cin>>s>>k;
	lli size=s.size();

	REP(i,0,size){
		lli needNum = needActNumToA(s.at(i));
		if(s[i]=='a')continue;
		if(needNum <= k){
			s[i]='a';
			k-=needNum;
		}
	}
	if(k){
		k%=26;
		s[size-1]+=k;
	}
	cout<<s<<endl;

	return 0;
}

Measured memory_bytes: 512
# include <cstdio>
# include <algorithm>
# include <cstring>
# include <cmath>
# include <climits>
# include <iostream>
# include <string>
# include <queue>
# include <vector>
# include <set>
# include <map>
# include <cstdlib>
# include <stack>
# include <ctime>
using namespace std;

# define Rep(i,a,b) for(int i=a;i<=b;i++)
# define _Rep(i,a,b) for(int i=a;i>=b;i--)
# define mct(a,b) memset(a,b,sizeof(a))
# define gc getchar()
typedef long long ll;
const int N=2e5+5;
const int inf=0x7fffffff;
const double eps=1e-7;
template <typename T> void read(T &x){
	x=0;int f=1;
	char c=getchar();
	for(;!isdigit(c);c=getchar())if(c=='-')f=-1;
	for(;isdigit(c);c=getchar())x=(x<<1)+(x<<3)+c-'0';
	x*=f;
}
int n,k,ans;
int a[N];

int main()
{
	read(n),read(k);
	Rep(i,1,n)read(a[i]);
	Rep(i,1,n)if(a[i]>=k)ans++;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
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; }
const ll INF = 1e15;
const ll MOD = 1000000007;
typedef pair<ll,ll> P;
class Prim{
    public:
    struct Node{
        vector<P> edges; // cost node
        bool done;
        ll cost;
    };
    ll V;
    vector<Node> nodes;
    Prim(ll v){
        V = v;
        nodes.resize(v);
    }
    void add_edge(ll v,ll node,ll cost){
        nodes[v].edges.push_back(P(cost,node));
    }
    ll prim(){
        priority_queue<P,vector<P>,greater<P>> mincost;
        rep(i,V){
            nodes[i].cost = INF;
            nodes[i].done = false;
        }
        ll res = 0;
        mincost.push(P(0,0));
        while(!mincost.empty()){
            P p = mincost.top();mincost.pop();
            ll v = p.second;
            if (nodes[v].done) continue;
            nodes[v].done = true;
            res += p.first;
            for(P u:nodes[v].edges){
                if (!nodes[u.second].done) mincost.push(P(u.first,u.second));
            }
        }
        return res;
    }
};
int main(){
    ll v,e;
    cin >> v >> e;
    Prim g(v);
    ll s,t,w;
    rep(i,e){
        cin >> s >> t >> w;
        g.add_edge(s,t,w);
        g.add_edge(t,s,w);
    }
    PRINT(g.prim());
}



Measured memory_bytes: 10472
import sys
sys.setrecursionlimit(10**7)
def MI(): return map(int,sys.stdin.readline().rstrip().split())


class SCC:
    def __init__(self,N):
        self.N = N
        self.graph = [[] for _ in range(N)]
        self.graph_rev = [[] for _ in range(N)]
        self.flag = [False]*N

    def add_edge(self,start,end):
        if start == end:
            return
        self.graph[start].append(end)
        self.graph_rev[end].append(start)

    def dfs(self,node,graph):
        self.flag[node] = True
        for n in graph[node]:
            if self.flag[n]:
                continue
            self.dfs(n,graph)
        self.order.append(node)

    def first_dfs(self):
        self.flag = [False]*self.N
        self.order = []
        for i in range(self.N):
            if self.flag[i] == False:
                self.dfs(i,self.graph)

    def second_dfs(self):
        self.flag = [False]*self.N
        self.ans = []
        for n in reversed(self.order):
            if self.flag[n]:
                continue
            self.flag[n] = True
            self.order = []
            self.dfs(n,self.graph_rev)
            self.order.reverse()
            self.ans.append(self.order)

    def scc(self):
        self.first_dfs()
        self.second_dfs()
        return self.ans


N,M = MI()
SCC = SCC(N)

for _ in range(M):
    a,b = MI()
    SCC.add_edge(a,b)

ANS = SCC.scc()

print(len(ANS))
for s in ANS:
    print(*([len(s)]+s))



Measured memory_bytes: 267160
import math
a, b, x = map(int, input().split())

if x == a * a * b:
    print(0)
    exit()

x = x / a
res = 0
if x >= a*b/2:
    mins = 0
    maxs = math.degrees(math.atan2(b, a))
    mid = (mins + maxs) / 2
    pre = mins
    while abs(mid - pre) > 10 ** -10:
        if a * b - a * a * math.tan(math.radians(mid)) / 2 > x:
            mins = mid
        else:
            maxs = mid
        pre = mid
        mid = (maxs + mins) / 2
    res = mid
else:
    mins = math.degrees(math.atan2(b, a))
    maxs = 90
    mid = (mins + maxs) / 2
    pre = mins
    while abs(mid - pre) > 10 ** -10:
        if b * b / math.tan(math.radians(mid)) / 2 > x:
            mins = mid
        else:
            maxs = mid
        pre = mid
        mid = (maxs + mins) / 2
    res = mid

print(res)



Measured memory_bytes: 38256
#!/usr/bin/env python3

#!/usr/bin/env python3

N = int(input().split()[0])

if N % 2 == 0:
    n = (N // 2) // 5
    total_n = n
    count = 2
    while n >= 5:
        p = (N // 2) // (5 ** count)
        total_n += p
        count += 1
        if p <= 0:
            break
        # n_w = n // 5
        # # n_amari = n_w % 5 if n_w % 5 != 0 else 4
        # n_amari = n_w % 5
        # n_f = (n_w - 1) * 5 + (n_amari + 1)
        # # total_n += count * (n_amari + 1)
        # # total_n += (n_amari + 1) + (n_w - 1) * 5
        # n = n // 5
        # count += 1
        # total_n += 1
    ans = total_n
else:
    ans = 0

print(ans)


Measured memory_bytes: 2940
#include<iostream>
#include<vector>
#include<cstdlib>
using namespace std;

int main() {
	int N, a, b, c, px=0, py=0, gap, now=0;
	cin >> N;
	vector<int> t(N), x(N), y(N);
	for (int i = 0; i < N; i++) {
		cin >> a >> b >> c;
		t[i] = a;
		x[i] = b;
		y[i] = c;
	}
	int time;
	for (int i = 0; i < N; i++) {
		gap = abs(x[i] - px) + abs(y[i] - py);
		time = t[i] - now;
		if (gap > time || (time - gap) % 2 == 1) {
			cout << "No" << endl;
			return 0;
		}
		px = x[i];
		py = y[i];
		now = t[i];
	}
	cout << "Yes" << endl;

	return 0;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
#define debug(x) cerr << #x << ':' << x << endl
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define ALL(c) (c).begin(), (c).end()
using namespace std;
typedef long long ll;

int main(){
    int n;
    // cout << stoi("01") << endl;
    while(1){
        cin >> n;
        if(n==0) break;
        vector<int> T(60*60*60+1,0);
        for(int i=0; i<n; i++){
            string s1, s2;
            cin >> s1 >> s2;
            int from = stoi(s1.substr(0,2))*60*60 + stoi(s1.substr(3,2))*60 + stoi(s1.substr(6,2));
            int to = stoi(s2.substr(0,2))*60*60 + stoi(s2.substr(3,2))*60 + stoi(s2.substr(6,2));
            // cout << "from " << from << " to " <<to << endl;
            T[from] +=1;
            T[to] -= 1;
        }

        rep(i,60*60*60+1){
            T[i+1] += T[i];
            // cout << T[i] << " ";
            // if(i%40==0) cout << endl;
        }
        // cout << endl;
        int ma = -1;
        rep(i,60*60*60+1){
            if(ma < T[i]) ma = T[i];
        }
        cout << ma << endl;
    }
    return 0;
}


Measured memory_bytes: 3988
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <chrono>
#include <random>
#include <functional>

using namespace std;

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

	int a;
	cin >> a;
	cout << a + a * a + a * a * a << '\n';
}


Measured memory_bytes: 3164
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cassert>
#include <tuple>

using namespace std;

using ll = long long;

int main() {
    int a, b;
    cin >> a >> b;
    
    int ans = 0;
    
    if (a < b) {
        ans += b;   
        b--;
    } else {
        ans += a;
        a--;
    }
    
    ans += max(a, b);
    
    cout << ans << endl;
}

Measured memory_bytes: 888
#include<iostream>
#include<vector>
#include<sstream>
#include<string>
#include<numeric>
#include <algorithm>
using namespace std;
int input(){
  int x;
  cin>>x;
  return x;
}
int abs(int x){
  if(x>=0){
    return x;
  }else{
    return -x;
  }
}
int gcd(int x, int y){
	if(x<y){
    return gcd(y,x);
  }
  if(y==0){
    return x;
  }
  return gcd(y,x%y);
}
int moji(char i){
  if(i=='a'){
    return 1;
  }
  if(i=='b'){
    return 2;
  }
  if(i=='c'){
    return 3;
  }
  if(i=='d'){
    return 4;
  }
  if(i=='e'){
    return 5;
  }
  if(i=='f'){
    return 6;
  }
  if(i=='g'){
    return 7;
  }
  if(i=='h'){
    return 8;
  }
  if(i=='i'){
    return 9;
  }
  if(i=='j'){
    return 10;
  }
  if(i=='k'){
    return 11;
  }
  if(i=='l'){
    return 12;
  }
  if(i=='m'){
    return 13;
  }
  if(i=='n'){
    return 14;
  }
  if(i=='o'){
    return 15;
  }
  if(i=='p'){
    return 16;
  }
  if(i=='q'){
    return 17;
  }
  if(i=='r'){
    return 18;
  }
  if(i=='s'){
    return 19;
  }
  if(i=='t'){
    return 20;
  }
  if(i=='u'){
    return 21;
  }
  if(i=='v'){
    return 22;
  }
  if(i=='w'){
    return 23;
  }
  if(i=='x'){
    return 24;
  }
  if(i=='y'){
    return 25;
  }
  if(i=='z'){
    return 26;
  }
  return 100;
  
}




int main() {
  int X=input();
  int Y=input();
  int Z=input();
  X-=Y+Z+Z;
  int sum=1;
  while(X>=Y+Z){
    X-=Y+Z;
    sum++;

  }
  cout<<sum<<endl;
  
  


  


  

  




  
  
}


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

using namespace std;

#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define eb emplece_back
#define mp make_pair
#define i_i pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< i_i >
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; scanf("%lld", &x);
#define int2(x, y) int x, y; scanf("%lld %lld", &x, &y);
#define fir first
#define sec second
#define ffir first.first
#define fsec first.second
#define sfir second.first
#define ssec second.second

//int dxy[5] = {0, 1, 0, -1, 0};
// assign avl ncm dij geo2 kruskal graph uf lca BIT

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

    if (s[0] == s[s.size()-1]) {
        if ((s.size()-3) % 2) {
            std::cout << "First" << std::endl;
        } else {
            std::cout << "Second" << std::endl;
        }
    } else {
        if ((s.size()-2) % 2) {
            std::cout << "First" << std::endl;
        } else {
            std::cout << "Second" << std::endl;
        }
    }

    return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
#define int long long
#define double long double
#define pb push_back
#define ff first
#define ss second
#define PI acos(-1)
#define bp __builtin_popcountll
#define all(x) x.begin(),x.end()
#define sp fixed<<setprecision
#define pii pair<long long,long long>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;

int MOD = (1e9)+7;
const int N = 2005;

pii a[N];
int dp[N][N],n;

int rec(int l,int r)
{
    if(l>r)return 0;
    if(dp[l][r]!=-1)return dp[l][r];
    int id = n-r+l;
    dp[l][r] = max(rec(l+1,r)+(a[id].ff*abs(a[id].ss-l)),rec(l,r-1)+(a[id].ff*abs(a[id].ss-r)));
    return dp[l][r];
}

signed main()
{
    FAST
    int tc=1;
    //cin>>tc;
    for(int ti=1;ti<=tc;ti++)
    {
        memset(dp,-1,sizeof(dp));
        cin>>n;
        for(int i=1;i<=n;i++)cin>>a[i].ff,a[i].ss=i;
        sort(a+1,a+n+1);
        for(int i=1,j=n;i<j;i++,j--)swap(a[i],a[j]);
        cout<<rec(1,n)<<endl;
    }
    return 0;
}
/*
Test Case
*/


Measured memory_bytes: 35172
//	-*- mode: C++ -*-
//	Structured Programming
//		In programming languages like C/C++, a goto statement provides an unconditional jump from the "goto" to a labeled statement. For example, a statement "goto CHECK_NUM;" is executed, control of the program jumps to CHECK_NUM. Using these constructs, you can implement, for example, loops.
//
//		Note that use of goto statement is highly discouraged, because it is difficult to trace the control flow of a program which includes goto.
//
//		Write a program which does precisely the same thing as the following program (this example is wrtten in C++). Let's try to write the program without goto statements.
//
//		void call(int n){
//			int i = 1;
//		CHECK_NUM:
//			int x = i;
//			if ( x % 3 == 0 ){
//				cout << " " << i;
//				goto END_CHECK_NUM;
//			}
//		INCLUDE3:
//			if ( x % 10 == 3 ){
//				cout << " " << i;
//				goto END_CHECK_NUM;
//			}
//			x /= 10;
//			if ( x ) goto INCLUDE3;
//		END_CHECK_NUM:
//			if ( ++i <= n ) goto CHECK_NUM;
//
//			cout << endl;
//		}
//	Input
//		An integer n is given in a line.

//	Output
//		Print the output result of the above program for given integer n.

//	Constraints
//		3 ≤ n ≤ 10000
//	Sample Input
//		30
//	Sample Output
//		 3 6 9 12 13 15 18 21 23 24 27 30
//		Put a single space character before each element.


#include <iostream>
#include <vector>

void	call(int	n)
{
	for(int i = 1; i <= n;){
		int	x	= i;
		if((x % 3) == 0){
			std::cout << ' ' << i;
		}
		else{
			do{
				if((x % 10) == 3){
					std::cout << ' ' << i;
					break;
				}
			}
			while(x /= 10);
		}
		++i;
	}

	std::cout << '\n';
}

int	main(int	argc,
		 char*	argv[])
{
	unsigned int	n	{0};

	std::cin >> n;

	call(n);
}



Measured memory_bytes: 3092
N, X = map(int, input().split())
A = list(map(int, input().split()))
diff = [abs(a - X) for a in A]

# 最大公約数
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a


while len(diff) > 1:
    a, b = diff.pop(), diff.pop()
    diff.append(gcd(a, b))

print(diff[0])


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

using namespace std;

#define fcout(d) cout << fixed << setprecision(d)
#define rep(i,n) for(int (i) = 0; (i) < (n); ++(i))
#define rep1(i,n) for(int (i) = 1; (i) <= (n); ++(i))
#define repU(i,bottom,ceiling) for(auto (i) = (bottom); (i) <= (ceiling); ++(i))
#define repD(i,ceiling,bottom) for(auto (i) = (ceiling); (i) >= (bottom); --(i))
#define repV(i,v) for(auto (i) = begin(v); (i) < end(v); ++(i))
#define all(v)  begin(v),end(v)
#define clr(v) fill(all(v),0)
#define l_bnd lower_bound
#define u_bnd upper_bound
#define puf push_front
#define pub push_back
#define pof pop_front
#define pob pop_back
#define mkp make_pair
#define mkt make_tuple
#define fir first
#define sec second
#define q_ceil(n,d) ((n - 1)/(d) + 1)
#define parity(a,b) ((a)^(b) & 1LL ^ 1LL)

typedef long long ll;
typedef unsigned long long ull;
typedef double db;

const pair<int,int> DIR[] = { {1,0},{0,1},{-1,0},{0,-1},{1,1},{-1,1},{-1,-1},{1,-1} };
const int INF_32 = -1 + (1 << 30);
const ll INF_64 = -1 + (1LL << 62);
const int MOD = (int)1e9 + 7;

ull next_subset(ull subset){
	ull tem = subset + (subset & -subset);
	ull btm = (~tem & subset) / (subset & -subset) >> 1;
	return btm | tem;
}

int N,T,ans = 0;

void solve(){
	
	return;
}

void input(){
	
	cin>>N>>T;
	int t; 
	cin>>t;
	int last = 0;
	int cur = T;
	rep(i,N - 1){
		cin>>t;
		if(cur >= t){
			cur = t + T;
		}
		else{
			ans += cur - last;
			last = t;
			cur = t + T;
		}
	}
	ans += cur - last;
	cout<<ans<<endl;
	
	return;
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	input();
	solve();
	
	return 0;
}





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

int main() {
	int a, b, d, r;
	double f;

	cin >> a >> b;
	d = a / b;
	r = a % b;
	f = (double)a/b;
	printf("%d %d %f \n",d,r,f);
	return 0;
}

Measured memory_bytes: 3224
#include<bits/stdc++.h>
using namespace std;
int a[510][510];
int n,m;
int ans;
struct data{
	int i,j;
	int x,y;
}tot[1000010];
int main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)
	  for(int j=1;j<=m;j++)
	    scanf("%d",&a[i][j]);
	for(int i=1;i<n;i++)
	  for(int j=1;j<=m;j++)
	  	if(a[i][j]&1) 
			a[i+1][j]++,tot[++ans].i=i,tot[ans].j=j,tot[ans].x=i+1,tot[ans].y=j;
	for(int j=1;j<m;j++) if(a[n][j]&1) a[n][j+1]++,tot[++ans].i=n,tot[ans].j=j,tot[ans].x=n,tot[ans].y=j+1;
	printf("%d\n",ans);
	for(int i=1;i<=ans;i++) printf("%d %d %d %d\n",tot[i].i,tot[i].j,tot[i].x,tot[i].y); 	
	return 0;
}

Measured memory_bytes: 6400
#include<algorithm>
#include<bitset>
#include<iostream>
#include<iomanip>
#include<set>
#include<string>
#include<math.h>
#include<string>
#include<queue>
#include<vector>
using namespace std;
typedef long long int ll;
typedef pair<int, ll> P;

//--------------
//#define DEBUG
//--------------

#ifdef DEBUG
	#define debugprint(x) cout<<x<<" "
	#define debugendl cout<<endl
	#define debug(x) x
#else
	#define debugprint(x)
	#define debugendl
	#define debug(x)
#endif

class zahyo{
	public:
	int x;
	int y;
	zahyo(){
		x=0;
		y=0;
	}
	zahyo(int x_,int y_){
		x=x_;
		y=y_;
	}
	void print(){
		cout<<x<<" "<<y;
	}
	zahyo operator+(zahyo add){
		add.x=this->x+add.x;
		add.y=this->y+add.y;
		return add;
	}
	zahyo operator-(zahyo add){
		add.x=this->x-add.x;
		add.y=this->y-add.y;
		return add;
	}
	zahyo operator*(int t){
		zahyo temp;
		temp.x=this->x*t;
		temp.y=this->y*t;
		return temp;
	}
	zahyo operator%(int t){
		zahyo temp(this->x%t,this->y%t);
		return temp;
	}
	zahyo operator/(int t){
		zahyo temp(this->x/t,this->y/t);
		return temp;
	}
	bool operator==(const zahyo add) const{
		if(add.x==this->x and add.y==this->y){return true;}
		else{return false;}
	}
	bool operator!=(const zahyo add) const{
		if(add.x==this->x or add.y==this->y){return false;}
		else{return true;}
	}
	bool operator<(const zahyo add) const{
		if(this->x<add.x){return true;}
		else if(this->x==add.x and this->y<add.y){return true;}
		else{return false;}
	}
	bool operator>(const zahyo add) const{
		if(this->x>add.x){return true;}
		else if(this->x==add.x and this->y>add.y){return true;}
		else{return false;}
	}
	void input(){
		cin>>x>>y;
	}
};

zahyo ways[4];

bool IsInBoard(int x,int maxx, int y,int maxy){
	if(x>=0 and x<maxx and y>=0 and y<maxy){
		return true;
	}
	else{
		return false;
	}
}

int main(){
	int n,w;
	int shina[100][2];
	int dp[10001]={};
	cin>>n>>w;
	for(int i=0;i<n;i++){
		cin>>shina[i][0]>>shina[i][1];
	}
	for(int i=0;i<n;i++){
		for(int j=w;j>=0;j--){
			if(j>=shina[i][1]){
				dp[j]=max(dp[j],dp[j-shina[i][1]]+shina[i][0]);
			}
		}
	}
	int ans=0;
	for(int i=0;i<w+1;i++){
		ans=max(ans,dp[i]);
	}
	cout<<ans<<endl;
	return 0;
}



Measured memory_bytes: 3148
#include<iostream>
#include<bits/stdc++.h>
#define pq priority_queue
#define Pi acos(-1.0)
using namespace std;
#define INFF 10000000007
#define MOD 1000000007
int main()
{
    int x;
    cin>>x;
    cout<<x*800-(x/15)*200<<endl;
    return 0;
}


Measured memory_bytes: 256
r,g,b = list(map(int,input().split()))
k = int(input())
for i in range(k): 
  if b==0 or g==0: 
    break  
  elif b<=g: 
    b = b*2
  elif g<=r: 
    g = g*2   
if g>r and b>g:
  print("Yes")
else:
  print("No")  

Measured memory_bytes: 9128
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007

int main(){
    int n,m,a,b;
    bool ok = true;
    cin >> n >> m;
    vector<vector<int>> g(n);

    for(int i = 0;i < m;i++){
        cin >> a >> b;
        g[a - 1].push_back(b - 1);
        g[b - 1].push_back(a - 1);
    }

    vector<int> dist(n, -1);
    vector<int> prev(n, -1);
    queue<int> que;

    dist[0] = 0;
    que.push(0);

    while (!que.empty()) {
        int v = que.front();
        que.pop();

        for (int nv : g[v]) {
            if (dist[nv] != -1) continue;

            dist[nv] = dist[v] + 1;
            prev[nv] = v;
            que.push(nv);
        }
    }
    for (int v = 0; v < n; ++v){
        if(dist[v] == -1)ok = !ok;
    }
    cout << (ok ? "Yes" : "No") << endl;
    if(ok){
        for (int v = 1; v < n; ++v) cout << prev[v] + 1 << endl;
    }
}

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

#define _GLIBCXX_DEBUG
#define all(v) (v).begin(),(v).end()

using ll=long long;
using pii=pair<int, int>;
using vi=vector<int>;
using vii=vector<vector<int>>;

const ll LINF=1LL<<60;
const int INF=1<<29;
const int MOD=1e9+7;

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

template<typename T>
T chmax(T &a, T b){
    if(a < b){ a=b; return true;}
    return false;
}

int main(){
    int q; cin >> q;
    while(q--){
        string X, Y;
        cin >> X >> Y;

        vii dp(X.size()+1, vi(Y.size()+1, 0));
        for(int i=0; i<X.size(); i++){
            for(int j=0; j<Y.size(); j++){
                if(X[i] == Y[j]) chmax(dp[i+1][j+1], dp[i][j]+1);
                chmax(dp[i+1][j+1], max(dp[i+1][j], dp[i][j+1]));
            }
        }

        cout << dp[X.size()][Y.size()] << endl;
    }
    return 0;
}


Measured memory_bytes: 6852
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;
const int maxn=1e5+20;

struct Edge
{
    int u,v,len;
    Edge(int u=0,int v=0,int len=0):u(u),v(v),len(len){}
};

vector <Edge> g[maxn];
long long pre[maxn];

void dfs(int cur,int father)
{
    for(int i=0;i<g[cur].size();i++)
    {
        int v=g[cur][i].v;
        if(v==father)   continue;
        pre[v]=pre[cur]+g[cur][i].len;
        dfs(v,cur);
    }
    return ;
}
int main()
{
    int n;
    while(scanf("%d",&n)!=EOF)
    {
        for(int i=0;i<maxn;i++) g[i].clear();
        for(int i=1;i<n;i++)
        {
            int u,v,len;
            scanf("%d %d %d",&u,&v,&len);
            g[u].push_back(Edge(u,v,len));
            g[v].push_back(Edge(v,u,len));
        }
        int q,k;
        scanf("%d %d",&q,&k);
        memset(pre,0,sizeof(pre));
        dfs(k,-1);
        while(q--)
        {
            int x,y;
            scanf("%d %d",&x,&y);
            printf("%lld\n",pre[x]+pre[y]);
        }
    }
    return 0;
}


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

int main() {
  int A,B,C,X;
  cin >> A >> B >> C >> X;
  int res;
  for (int a = 0; a <= A; ++a)
  {
    for(int b = 0; b <= B; ++b)
    {
      for(int c = 0; c <= C; ++c)
      {
        int total = 500*a + 100*b + 50*c;
        if (total == X) ++res;
      }
    }
  }
  
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 256
from collections import Counter

S = input()
T = input()

st = {}
ts = {}

for s, t in zip(S, T):
  if s not in st:
    st[s] = t
  else:
    if st[s] != t:
      print('No')
      break
  if t not in ts:
    ts[t] = s
  else:
    if ts[t] != s:
      print('No')
      break
else:
  print('Yes')

Measured memory_bytes: 9724
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <math.h>
#include <complex>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <functional>
#include <assert.h>
#define int long
#define ll long long
#define rep(i, n) for(int i = 0; i < n; i++)
const int INF = 1e9;
using namespace std;

signed main() {
    int N; cin >> N;
    bool can = false;
    for(int i=1;i<=9;i++){
        for(int j=1;j<=9;j++){
            if(i*j==N) {can = true; break;}
        }
        if(can) break;
    }
    if(can) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
	int i,j;
	int N,minj,tmp,count=0;
	int A[100];

	//input
	scanf("%d",&N);
	for(i=0;i<N;i++){
		scanf("%d",&A[i]);
	}

	//selection sort
	for(i=0;i<N;i++){
		minj = i;
		for(j=i;j<N;j++){
			if(A[j] < A[minj]){
				minj = j;
			}
		}
		if(minj!=i){
			tmp = A[i];
			A[i] = A[minj];
			A[minj] = tmp;
			count++;;
		}
	}

	//output
	for(i=0;i<N;i++){
	printf("%d",A[i]);
	if(i<N-1) printf(" ");
	}
	printf("\n%d\n",count);
	return 0;
}

Measured memory_bytes: 604
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MM = 1000000000;
const int MOD = MM + 7;
const int MAX = 510000;
#define rep(i, n) for(ll i=0; i<n; i++)
#define Rep(i, j, n) for(ll i=j; i<n; i++)
#define all(vec) vec.begin(), vec.end()
template<class T> inline bool chmin(T& a, T b) {if(a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if(a < b) {a = b; return true;} return false;}
const ll INF = 1LL << 60;
const double pi = acos(-1.0);

int par[110000];
int r[110000];

void init(int n) {
    rep(i, n) {
        par[i] = i;
        r[i] = 0;
    }
}

int find(int x) {
    if(par[x] == x) return x;
    return par[x] = find(par[x]);
}

void unite(int x, int y) {
    x = find(x);
    y = find(y);
    if(x == y) return;
    if(r[x] < r[y]) par[x] = y;
    else {
        par[y] = x;
        if(r[x] == r[y]) r[x]++;
    }
}

bool same(int x, int y) {
    return find(x) == find(y);
}

int main() {
    ll n, m; cin >> n >> m;
    vector<ll> p(n); rep(i, n) cin >> p[i];
    init(110000);
    rep(i, m) {
        ll x, y; cin >> x >> y; x--; y--;
        unite(p[x], p[y]);
    }
    ll ans = 0;
    rep(i, n) if(same(p[i], p[p[i]-1])) ans++;
    cout << ans << endl;
}


Measured memory_bytes: 4756
#include<stdio.h>
int main(void)
{
	int i,N,p[100]={},count=0;
	scanf("%d",&N);
	for(i=1;i<=N;i++){
		scanf("%d",&p[i]);
		if(p[i]!=i){
			count++;
		}
	}
	if(count<=2){
		printf("YES\n");
	}else{
		printf("NO\n");
	}	
	return 0;
}

//  2 6 3 9 4  ,  4 6 2 5 8 ,3 14 2


Measured memory_bytes: 128
s = input()
k = int(input())

n = len(s)
s2 = s + s

renzoku = False
taisho = 0
aida = False
for i in range(2*n-1):
    if s2[i] == s2[i+1]:
        if not renzoku:
            renzoku = True
            start_i = i
            count = 0
        count += 1

    elif renzoku:
        renzoku = False
        end_i = i
        count += 1
        #print(start_i, end_i)
        if count % 2 == 1:
            indexs = list(range(start_i+1, end_i, 2))
            taisho += len(indexs)
            #print(indexs)
            if (n-1 in indexs) or (n in indexs):
                aida = True
        elif count % 2 == 0:
            indexs1 = list(range(start_i, end_i, 2))
            indexs2 = list(range(start_i+1, end_i, 2))
            taisho += len(indexs1)
            #print(indexs1)
            all_indexs = indexs1 + indexs2
            if (n-1 in all_indexs) or (n in all_indexs):
                aida = True

last_renzoku = False
if renzoku:
    last_renzoku = True
    renzoku = False
    end_i = 2*n - 1
    count += 1
    if count % 2 == 1:
        indexs = list(range(start_i+1, end_i, 2))
        taisho += len(indexs)
        #print(indexs)
        if (n-1 in indexs) or (n in indexs):
            aida = True
        last_odd = True
    elif count % 2 == 0:
        indexs1 = list(range(start_i, end_i, 2))
        indexs2 = list(range(start_i+1, end_i, 2))
        taisho += len(indexs1)
        #print(indexs1)
        all_indexs = indexs1 + indexs2
        if (n-1 in all_indexs) or (n in all_indexs):
            aida = True
        last_odd = False


#if True:
if not aida:
    assert taisho % 2 == 0
    hitotsu = taisho // 2
    out = hitotsu * k
else:
    if taisho % 2 == 0: 
        hitotsu = taisho // 2
        out = hitotsu * k
    else:
        if not last_renzoku:
            hitotsu = (taisho+1) // 2
            out = hitotsu * k - 1
        else:
            x = (taisho - 1) // 2
            #print("last_odd", last_odd)
            if last_odd:
                out = x + (x+1) * (k-1)
            else:
                if k % 2 == 0:
                    out = taisho * (k // 2)
                else:
                    out = taisho * ((k-1) // 2) + x


print(out)

Measured memory_bytes: 3192
use std::io::prelude::*;

fn input<T: std::str::FromStr>() -> T {
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

fn main() {
    let mut s: Vec<char> = input::<String>().chars().collect();
    s.sort();
    println!(
        "{}",
        if s[0] == s[1] && s[1] != s[2] && s[2] == s[3] {
            "Yes"
        } else {
            "No"
        }
    );
}


Measured memory_bytes: 4352
#include <assert.h>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <vector>
using namespace std;
#define debug printf("%s %d\n", __FUNCTION__, __LINE__)
const int inf = 2147483647;
const int maxn = 1e5 + 10;

int n;
int color[maxn];
int dep[maxn];
vector<int> e[maxn];
bool dfs(int u, int pre) {
    if (u == n) {
        color[u] = 1;
        return true;
    }
    bool flag = false;
    for (int i = 0; i < e[u].size(); i++) {
        int v = e[u][i];
        if (v == pre) continue;
        dep[v] = dep[u] + 1;
        if (dfs(v, u)) flag = true;
    }
    if (flag) {
        //cout << u << ' ' << dep[u] << endl;
        if (dep[u] - dep[1] <= dep[n] - dep[u]) color[u] = -1;
        else color[u] = 1;
    }
    return flag;
}
void colorize(int u, int pre) {
    for (int i = 0; i < e[u].size(); i++) {
        int v = e[u][i];
        if (color[v] != 0 || pre == v) continue;
        color[v] = color[u];
        colorize(v, u);
    }
}
int main(int argc, char **argv) {
    scanf("%d", &n);
    for (int i = 1, u, v; i < n; i++) {
        scanf("%d%d", &u, &v); 
        e[u].push_back(v);
        e[v].push_back(u);
    }
    dfs(1, 0);
    for (int i = 1; i <= n; i++) 
        if (color[i] != 0) colorize(i, -1);
    int cnt = 0;
    for (int i = 1; i <= n; i++) 
        if (color[i] == -1) cnt++;
    if (cnt > n - cnt) printf("Fennec\n");
    else printf("Snuke\n");
    return 0;
}

Measured memory_bytes: 14336