akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef pair<int, int> pi;
typedef pair<long long, long long> pl;
 
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
#define speedhack() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define form(i, n) for (size_t i = 0; i < size_t(n); ++i)
#define forn(i, n) for (size_t i = 1; i <= size_t(n); ++i)
template<class T> using ordered_set=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
ll mod(ll a, ll b) { return (a%b+b)%b; }
ll gcd(ll x, ll y) { return __gcd(x, y); }
ll lcm(ll x, ll y) { return x * 1ll * y / gcd(x, y); }
 
 
const ll MAXN = 1e9 + 9;
const ll SIZE = 1e5 + 5;
const ll MOD  = 1e9 + 7;

ll N, K, p[SIZE];

int main() { speedhack()

	cin >> N >> K;

	forn (i, N)
		cin >> p[i];
	
	sort (p + 1, p + 1 + N);

	for (int i = 1; i <= K; i++)
		p[i] = p[i - 1] + p[i];
	
	cout << p[K] << endl;
	
	return 0;
}

Measured memory_bytes: 3560
import java.util.Scanner

import scala.collection.Searching._
import scala.annotation.tailrec
import scala.collection.immutable.Queue

class IUnionFind(val size: Int) {

  private case class Node(var parent: Option[Int], var treeSize: Int)

  private val nodes = Array.fill[Node](size)(new Node(None, 1))

  def union(t1: Int, t2: Int): IUnionFind = {
    if (t1 == t2) return this

    val root1 = root(t1)
    val root2 = root(t2)
    if (root1 == root2) return this

    val node1 = nodes(root1)
    val node2 = nodes(root2)

    if (node1.treeSize < node2.treeSize) {
      node1.parent = Some(t2)
      node2.treeSize += node1.treeSize
    } else {
      node2.parent = Some(t1)
      node1.treeSize += node2.treeSize
    }
    this
  }

  def connected(t1: Int, t2: Int): Boolean = t1 == t2 || root(t1) == root(t2)

  @tailrec
  private def root(t: Int): Int = nodes(t).parent match {
    case None => t
    case Some(p) => root(p)
  }
}


object Main {
  def solve(sc: => Scanner): Unit = {
    val N, Q = sc.nextInt
    for (_ <- 0 until Q) {
      var V, W = sc.nextInt
      if (N == 1) (println(math.min(V, W))) else {
        while (V != W) {
          if (V < W) {
            W = (W + N - 2) / N: Int
          } else {
            V = (V + N - 2) / N: Int
          }
        }
        println(V)
      }
    }
  }

  def main(args: Array[String]): Unit = {
    val sc: Scanner = new Scanner(System.in)
    solve(sc)
  }
}

Measured memory_bytes: 68484
n,m = gets.chomp.split().map(&:to_i)
submit = []
ac_list = Array.new(n,false)
ac_count = 0
wa_count = 0
wa_list = Array.new(n,0)

while(true)
    if submit.size == m
        break
    end
    a = gets.chomp.split()
    submit.push([a[0].to_i,a[1]])

end
i = 0
while true
    if i == m
        break
    end
    if submit[i][1] == 'AC'
        if !ac_list[(submit[i][0]-1)]
            ac_count += 1
            wa_count += wa_list[(submit[i][0]-1)]
            ac_list[(submit[i][0]-1)] = true
        end
    else
        wa_list[(submit[i][0]-1)] += 1
    end
    i += 1
end

print ac_count
print ' '
print wa_count

Measured memory_bytes: 29528
#include <bits/stdc++.h>
using namespace std;
#define MD 1000000007
typedef long long int ll;
typedef pair<ll, ll> P;
template <typename T>
std::string tostr(const T &t){std::ostringstream os;os << t;return os.str();}
int dx[4]={1, 0, -1, 0}, dy[4]={0, 1, 0, -1};

int main(){
    int a,p;
    cin>>a>>p;
    cout<<(a*3+p)/2<<endl;
    return 0;
}

Measured memory_bytes: 256
// Why am I so dumb? :c
#include <bits/stdc++.h>

#define pb push_back
#define mp make_pair

#define all(x) (x).begin(), (x).end()

#define fi first
#define se second

using namespace std;

typedef long long ll;

ll a, b, c, d;

ll roundUp(ll a, ll b) {
	ll ret = 0;

	if (a < 0) {
		ll x = (-a + b - 1) / b;
		a += b * x;
		ret = -x;
	}	

	ret += (a + b - 1) / b;
	return ret;
}

void solve() {                   
	scanf("%lld %lld %lld %lld", &a, &b, &c, &d);

	if (d < b) {
		printf("No\n");
		return;
	}

	if (a < b) {
		printf("No\n");
		return;
	}

	ll g = __gcd(b, d);
	a %= g;
    
    ll x = g * roundUp(c - b + 1 - a, g);
	printf(x < 0 ? "No\n" : "Yes\n");                 
}

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

    while (tt--) {
        solve();
    }

    return 0;
}

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

int main(){
  int N, T;
  cin >> N >> T;
  vector<P> ct(N);
  for(int i = 0; i < N; i++){
    cin >> ct.at(i).first >> ct.at(i).second;
  }
  sort(ALL(ct));
  int result = -1;
  for(int i = 0; i < N; i++){
    if(ct.at(i).second <= T){
      result = ct.at(i).first;
      break;
    }
  }
  if(result != -1) cout << result << endl;
  else cout << "TLE" << endl;
}

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

int main()
{
    int h1, m1, s1;
    int h2, m2, s2;
    for(int i = 0; i < 3; i++) {
        cin >> h1 >> m1 >> s1 >> h2 >> m2 >> s2;
        int sum = 0;
        sum = (h2 - h1) * 3600 + (m2 - m1) * 60 + s2 - s1;
        for(int j = 0; j < 3; j++) {
            int time = (sum / (int)(pow(60.0, (2 - j))));
            sum %= (int)pow(60.0, (2 - j));
            cout << time;
            if(j == 2)
                cout << endl;
            else 
                cout << " ";
        }
    }
}

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

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

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

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



int main(){
    int r;cin>>r;
    if(r<1200)cout<<"ABC";
    else if(r<2800)cout<<"ARC";
    else cout<<"AGC";
}



Measured memory_bytes: 256
tmp = list(map(int, input().split()))
n, x, y = tmp
cnt = [0 for k in range(n-1)]

for i in range(n-1):
    for j in range(i+1, n):
        a = j-i
        b = abs(x-i-1) + 1 + abs(j+1-y)
        cnt[min(a,b)-1] += 1

for c in cnt:
    print(c)

Measured memory_bytes: 3444
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 1000000007
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
typedef pair<ll,int> LL_IP;


#define ARRAY_MAX 101





typedef struct edge{
    int from;
    int to;
    int cost;
}EDGE;


/*頂点sから各頂点への最短距離を求めること、頂点sから到達できる負閉路があれば真が返る、目的地が決まっているバージョン*/
/*V-1回の更新で各ノードへの最短距離は求められる*/
/*V回目から2V回目までに最短距離が更新される場合は目的地を含む負閉路が存在する*/
bool shortest_path(int v,int e,int s,int t,vector<EDGE>& arr,vector<int>& d){
    /*頂点の個数、辺の個数、始点となる頂点、目的地の頂点、辺の情報、最短距離*/
    for(int i = 0;i < d.size();i++){
        d[i] = INF;
    }
    d[s]=0;
    
    for(int i = 0;i < 2*v;i++){
        for(int j = 0;j < e;j++){
            EDGE tmp = arr[j];
            if(d[tmp.from] != INF && d[tmp.to] > d[tmp.from] + tmp.cost){
                d[tmp.to] = d[tmp.from] + tmp.cost;
                if(i >= v-1 && tmp.to == t){
                    return true;
                }

            }
        }
    }
    return false;
}





int main(){


    int n,m,a,b,c,d;
    int s,g,v,p;
    char t;
    cin >> n >> m;
   
    vector<EDGE> G;/*n個の各頂点からそれ以外の頂点へのコスト*/
    vector<int> d1(n,INF);/*出発地点から柱までの最短経路*/
    vector<int> d2(n,INF);/*柱から出発地点までの最短経路*/

    
    REP(i,m){
        cin >> a >> t >> b >> t >> c >> t >> d;

        a--;
        b--;/*配列の添え字へ合わせる*/
        EDGE e1 = {a,b,c};
        EDGE e2 = {b,a,d};
        G.push_back(e1);
        G.push_back(e2);
    }
    /*グラフの作成が終了*/

    cin >> s >> t >> g >> t >> v >> t >> p;
    s--;
    g--;/*配列の添え字に合わせる*/

   
    bool ans1 = shortest_path(n,m*2,s,g,G,d1);
    bool ans2 = shortest_path(n,m*2,g,s,G,d2);

    /*REP(i,n){
        cout << d1[i] << " ";
    }
    cout << endl;

    REP(i,n){
        cout << d2[i] << " ";
    }
    cout << endl;
    cout << g << s << endl;
    cout << d1[g] << " " << d2[s] << endl;
    */
     
    ll ans = v - p - d1[g] - d2[s];
    cout << ans << endl;

    return 0;
}


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

vector<int> to[100007];
vector<int> color(100007);
vector<int> prenum(100007);
vector<int> parent(100007);
vector<int> lowest(100007);
int now = 0;

void dfs(int u, int b=-1){
    prenum[u] = now;
    now++;
    color[u] = 1;
    parent[u] = b;
    lowest[u] = prenum[u];
    if(to[u].size() != 0){
        rep(i, to[u].size()){
            int v = to[u][i];
            if(color[v] == 0){
                dfs(v, u);
                lowest[u] = min(lowest[u], lowest[v]);
            } else if(v != b){
                lowest[u] = min(lowest[u], prenum[v]);
            }
        }
    }
    return;
}

int main() {
    int V, E; cin >> V >> E;
    rep(i, E){
        int s, t; cin >> s >> t;
        to[s].push_back(t);
        to[t].push_back(s);
    }
    dfs(0);

    set<int> ans;
    int rc = 0;
    for (int i = 1; i < V; i++){
        int p = parent[i];
        if(p == 0){
            rc++;
        } else if(prenum[p] <= lowest[i]) {
            ans.insert(p);
        }
    }
    if(rc > 1){
        ans.insert(0);
    }
    if(!ans.empty()){
        for(auto x : ans){
            cout << x << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 8020
import java.io.*;

class Main{
    public static void main(String[] args) throws NumberFormatException,IOException{
        BufferedReader re =
         new BufferedReader(new InputStreamReader(System.in), 1);
          
        String line = re.readLine();    
        String[] w = line.split(" ",0);
        
        int W = Integer.parseInt(w[0]);
        int H = Integer.parseInt(w[1]);
        int x = Integer.parseInt(w[2]);
        int y = Integer.parseInt(w[3]);
        int r = Integer.parseInt(w[4]);
        
        String ret = "No";
        if (W>= (x+r) &&H>=(y+r)&& (x-r) >= 0 && (y-r) >= 0) ret = "Yes";   
        
        System.out.println(ret);
        re.close();
    }
}

Measured memory_bytes: 24280
N, K = map(int, input().split())
V = [0]*N
*V, = map(int, input().split())

ans = []
for i in range(N+1):
    for j in range(N+1):
        if i+j > min(N, K): continue
        out = V[:i] + V[N-j:]
        out.sort()
        r = 0
        while i+j+r < K and r < len(out):
            if out[r] < 0: r += 1
            else: break
        ans.append(sum(out[r:]))

print(max(ans))

Measured memory_bytes: 71272
#include<bits/stdc++.h>
#include<vector>
#include<deque>
#include<list>
#define rep(i,n) for(ll i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<P1,ll> P2;
const ll INF=1000000000000000001;
struct edge{int to,cost;};
struct pos{
	int x,y,cost;
};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};


int main() {

	string s;
	cin>>s;
	if(s=="ABC")cout<<"ARC"<<endl;
	else cout<<"ABC"<<endl;


	return 0;
}


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

int dp[1001][1001];

#define k 1000000007

int a[10001][10001];

int find(int n,int m)
{
	
	 dp[0][0]=1;
	 for(int i=1;i<n;i++)
	 {
	 	if(a[i][0]!=0)
	 		dp[i][0]=dp[i-1][0];
	 }

	 for(int i=1;i<m;i++)
	 {
	 	if(a[0][i]!=0)
	 		dp[0][i]=dp[0][i-1];
	 }

	 for(int i=1;i<n;i++)
	 {
	 	for(int j=1;j<m;j++)
	 	{
	 		if(a[i][j]!=0)
	 		{
	 			dp[i][j]=(dp[i-1][j]%k+dp[i][j-1]%k)%k;
	 		}
	 	}
	 }




	return dp[n-1][m-1];
}


int main()
{
	int n,m;
	cin>>n>>m;
	char sh[n][m];
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<m;j++)
		{
			cin>>sh[i][j];
			if(sh[i][j]=='.')
				{a[i][j]=-1;}
		}
	}

	int ans=find(n,m);
	
	cout<<ans;
	return 0;
}



Measured memory_bytes: 46080
#include<bits/stdc++.h>
#define int long long
using namespace std;
main()
{
    int n, k, x, ans;
    cin >> n >> k;
    int ara[10] = {0};
    for(int i = 0; i < k; i++)
    {
        cin >> x;
        ara[x]++;
    }
    int ok = 0;
    for(int i = n; !ok ; i++)
    {
        int x = i;
        ans = i;
        while(x)
        {
            if(ara[x % 10])
                break;
            x /= 10;
        }
        if(!x)
            ok = 1;
    }
    cout << ans << endl;
}



Measured memory_bytes: 256
import sys
input = sys.stdin.readline
def print_ans(N, P):
    """Test Case
    >>> print_ans(5, [4, 2, 5, 1, 3])
    3
    >>> print_ans(4, [4, 3, 2, 1])
    4
    >>> print_ans(6, [1, 2, 3, 4, 5, 6])
    1
    >>> print_ans(8, [5, 7, 4, 2, 6, 8, 1, 3])
    4
    >>> print_ans(1, [1])
    1
    """
    min_num = P[0]
    counter = 1
    for i in range(1, N):
        if min_num >= P[i]:
            counter += 1
        min_num = min(min_num, P[i])
    print(counter)



if __name__ == '__main__':
    N = int(input().rstrip())
    P = list(map(int, input().rstrip().split()))
    print_ans(N, P)

Measured memory_bytes: 24744
#include <bits/stdc++.h>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD ((ll)(1e9+7))
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
template<class T> void pr_vec(vector<T> &v, char ep=' '){int n=v.size();REP(ni,n){cout<<v[ni];if(ni!=n-1)cout<<ep;}cout<<endl;};
template<class T> inline bool chmin(T& a, T b){return a>b ? a=b, true : false;}
template<class T> inline bool chmax(T& a, T b){return a<b ? a=b, true : false;}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

int main(void)
{
    ll N,M,K;
    cin >> N >> M >> K;
    vector<ll> A(N), B(M);
    REP(i,N) cin >> A[i];
    REP(i,M) cin >> B[i];
    A.insert(A.begin(), 0);
    B.insert(B.begin(), 0);
    Rep(i,1,N+1) A[i] += A[i-1];
    Rep(i,1,M+1) B[i] += B[i-1];

    ll ans = 0;
    int b = M;
    REP(i, N+1){
        while(b >= 0 && A[i]+B[b] > K) b--;
        if(A[i]+B[b] <= K) chmax(ans, (ll)i+b);
    }
    pr(ans);
}

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

char str[110000];
std::regex pattern ("(erase|eraser|dream|dreamer)*");

int main () {
	fgets (str, 110000, stdin);
	str[strlen (str) - 1] = 0;
	if (std::regex_match (str, pattern))
		puts ("YES");
	else
		puts ("NO");
}


Measured memory_bytes: 39680
#include<bits/stdc++.h>
#define MAX 105
using namespace std;
 
int main(){
  int n;
  string s[MAX];
  bool t = true;
  scanf("%d", &n);
  for(int i = 0; i < n; i++){
    cin >> s[i];
    if(i && s[i-1][s[i-1].length()-1] != s[i][0]) t = false;
    for(int j = 0; j < i; j++){
      if(s[j] == s[i]) t = false;
    }
  }
  cout << (t ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
#pragma region Macros

#include <bits/stdc++.h>
using namespace std;

using ll = long long;
#define int ll
using vi = vector<int>;
using vvi = vector<vi>;

#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))

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>
ostream &operator<<(ostream &out, vector<T> const &v) {
    for (auto &&a : v) out << a << " ";
    out << endl;
    return out;
}

// debug methods
// usage: debug(x,y);
#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0, a1, a2, a3, a4, x, ...) x
#define debug_1(x1) cout << #x1 << ": " << x1 << endl
#define debug_2(x1, x2) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << endl
#define debug_3(x1, x2, x3) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << endl
#define debug_4(x1, x2, x3, x4) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << ", " #x4 << ": " << x4 << endl
#define debug_5(x1, x2, x3, x4, x5) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << ", " #x4 << ": " << x4 << ", " #x5 << ": " << x5 << endl
#ifdef _DEBUG
#define debug(...)                                                        \
    CHOOSE((__VA_ARGS__, debug_5, debug_4, debug_3, debug_2, debug_1, ~)) \
    (__VA_ARGS__)
#else
#define debug(...)
#endif

#pragma endregion

void Main() {
    int D;
    cin >> D;

    vi c(26);
    REP(i, 26) {
        cin >> c[i];
    }
    vector<vector<pair<int, int>>> s(D, vector<pair<int, int>>());
    int buff;
    REP(i, D) {
        REP(j, 26) {
            cin >> buff;
            s[i].push_back({buff, j + 1});
        }
    }

    int count = 0;
    REP(i, D) {
        set<int> set26;
        REP(j, 26) {
            set26.insert(j + 1);
        }
        while (!set26.empty()) {
            vector<pair<int, int>> sss = s[count];
            sort(ALL(sss), greater<pair<int, int>>());
            int a = 1;
            REP(k, 26) {
                if (set26.count(sss[k].second)) {
                    a = sss[k].second;
                    debug(sss[k].second);
                    break;
                }
            }

            cout << a << "\n";
            set26.erase(a);
            debug(a);
            count++;
            if (count >= D) {
                return;
            }
        }
    }
}

#pragma region main
signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    Main();
    cout << flush;
}
#pragma endregion


Measured memory_bytes: 3864
#include<iostream>
#include<algorithm>
#include<map>
#include<cmath>
using namespace std;
using ll = long long;

map< ll, int > prime_factor(ll n) {
  map< ll, int > ret;
  for(ll i = 2; i * i <= n; i++) {
    while(n % i == 0) {ret[i]++;n/=i;}
  }
  if(n != 1) ret[n] = 1;
  return ret;
}

int main() {
    ll n,p,g=1;
    cin >> n >> p;
    map<ll,int> a = prime_factor(p);
    for (auto aa:a) g *= pow(aa.first,(aa.second/n));
    cout << g << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cstring>
#include<algorithm>
#include<math.h>
#include<queue>
#include<deque>
#include<map>
#include<bitset>

#define rep(i, n) for(int i = 0;i < (n);i++)
#define rrep(i, n) for(int i = (n);i >= 0;i--)
#define FOR(i, m, n) for(int i = (m);i < (n);i++)

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;}

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


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



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

    vector<ll> p(60), a(60);
    p[0] = 1;
    a[0] = 1;
    for (int i = 0; i < 50; i++)
    {
        p[i+1] = p[i]*2 + 1;
        a[i+1] = a[i]*2 + 3;
    }

    auto func = [&](auto &&func, int level, ll x) -> ll {
        // cout << level << ' ' << x << endl;
        if (level == 0) return 1;
        if (x == 1) return 0;
        if (x <= 1+a[level-1])      return func(func, level-1, x-1);
        if (x == 2+a[level-1])      return p[level-1] + 1;
        if (x <= 2+2*a[level-1])    return p[level-1] + 1 + func(func, level-1, x-2-a[level-1]);
        if (x == 3+2*a[level-1])    return 2*p[level-1] + 1;
    };
    ll ans = func(func, n, x);
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


# aとbの最大公約数
def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)


# aとbの最小公倍数
def lcm(a, b):
    g = gcd(a, b)
    return a / g * b


def main():
    S = input()
    T = input()

    st = dict()
    ts = dict()
    for s, t in zip(S, T):
        if s in st and st[s] != t:
            print(No)
            return
        st[s] = t
        if t in ts and ts[t] != s:
            print(No)
            return
        ts[t] = s

    print(Yes)


if __name__ == '__main__':
    main()


Measured memory_bytes: 4648
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;
int main( void )
{
  ios::sync_with_stdio(false);
  ll N, K;
  cin >> N >> K;
  ll ret = 1;
  for( int i=0; i<N; i++ ){
    ret = min( ret*2, ret+K );
  }
  cout << ret << endl;
}

Measured memory_bytes: 256
from collections import deque
import sys
sys.setrecursionlimit(10 ** 9)
# import numpy as np
# 答えの提出の時にi+1とj+1は忘れないように
h, w = map(int, input().split())
maze = [[-1 for i in range(w)] for j in range(h)]
ch, cw = map(int, input().split())
ch, cw = ch-1, cw-1
dh, dw = map(int, input().split())
dh, dw = dh-1, dw-1


ans = 0
for i in range(h):
    maze[i] = input()

INF = h*w
distance = [[INF for i in range(w)] for j in range(h)]

queue0 = deque()
queue0.append((ch,cw))
distance[ch][cw] = 0

queue1 = deque()

while queue0 or queue1:

    if queue0:
        y, x = queue0.popleft()
    elif queue1:
        y, x = queue1.popleft()

    for dy in range(-2, 3):
        for dx in range(-2, 3):
            ny, nx = y+dy, x+dx
            if dy == dx == 0: continue
            elif abs(dy) + abs(dx) == 1:
                if 0 <= nx < w and 0 <= ny < h:
                    if maze[ny][nx] != '#' and distance[ny][nx] > distance[y][x]:
                            queue0.append((ny, nx))
                            distance[ny][nx] = distance[y][x]
            else:
                if 0 <= nx < w and 0 <= ny < h:
                    if maze[ny][nx] != '#' and distance[ny][nx] > distance[y][x]+1:
                            queue1.append((ny, nx))
                            distance[ny][nx] = distance[y][x]+1


ans = distance[dh][dw]
if ans == INF:
    print(-1)
else:
    print(ans)




Measured memory_bytes: 99776
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int mod=1e9+7;
ll m,n,l,yy[305][305],ans[305][305]; 
 
int main()
{
    std::ios::sync_with_stdio(0); std::cin.tie(0);
    cin>>m>>n>>l;
    ll a,b,c;
    for(int i=1;i<=m;++i)
     for(int j=1;j<=m;++j)
     yy[i][j]=1e15,ans[i][j]=1e15;
    for(int i=0;i<n;++i)
    {
    	cin>>a>>b>>c;
    	if(c>l) c=1e15;
    	yy[a][b]=yy[b][a]=c;
	}
	for(int i=1;i<=m;++i)
	 for(int j=1;j<=m;++j)
	  for(int k=1;k<=m;++k)
	  yy[j][k]=min(yy[j][k],yy[j][i]+yy[i][k]);
	  for(int i=1;i<=m;++i)
	 for(int j=1;j<=m;++j)
	  if(yy[i][j]<=l) ans[i][j]=1;
	  for(int i=1;i<=m;++i)
	 for(int j=1;j<=m;++j)
	  for(int k=1;k<=m;++k)
	  ans[j][k]=min(ans[j][k],ans[j][i]+ans[i][k]);
	ll q;
	cin>>q;
	while(q--)
	{
		cin>>a>>b;
		if(ans[a][b]<1e15) cout<<ans[a][b]-1<<'\n';
		else cout<<-1<<'\n';
	}
	return 0;
}

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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
#define int long long

signed main(){
    int n, d, a;
    cin >> n >> d >> a;
    vector<pll> x(n);
    for (int i = 0; i < n; ++i) {
        cin >> x[i].first >> x[i].second;
        x[i].second = (x[i].second + a - 1) / a;
    }
    vector<int> v(n+1, 0);
    sort(x.begin(), x.end());
    int res = 0;
    int num = 0;
    int left = 0;
    int right = 0;
    for (; left < n; ++left){
        num += v[left];
        if(num >= x[left].second) continue;
        while(x[left].first + 2LL * d >= x[right].first && right < n){
            right++;
        }
        res += x[left].second - num;
        v[right] -= x[left].second - num;
        num = x[left].second;
    }
    cout << res << endl;
}

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

using namespace std;

int main(void){
    int n;
    cin >> n;
    string s;
    map<string, long long> memo;
    long long sum = 0;
    for(int i = 0; i < n; i++){
        cin >> s;
        sort(s.begin(), s.end());
        if(memo.count(s) == 0){
            memo.insert(make_pair(s,1));
        }else{
            int temp = memo.at(s)++;
            sum += temp;
        }
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 11136
K = int(input())
runrun = [[] for _ in range(11)]
runrun[1] = [i for i in range(1, 10)]
for i in range(1, 10):
    run = runrun[i]
    for r in run:
        t = r%10
        if t != 0:
            runrun[i+1].append(r*10+t-1)
        runrun[i+1].append(r*10+t)
        if t != 9:
            runrun[i+1].append(r*10+t+1)
for i in range(11):
    if len(runrun[i]) <= K:
        K -= len(runrun[i])
        continue
    print(runrun[i][K-1])
    break

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

const int maxN = 100000;
const int64_t inf = (1LL << 50);

int h[maxN];
int64_t dp[maxN];

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

  for (int i = 0; i < n; i++) {
    cin >> h[i];
  }

  fill(dp, dp + n, inf);
  dp[0] = 0;

  for (int i = 1; i < n; i++) {
    for (int j = i - k; j < i; j++) {
      if (j >= 0) dp[i] = min(dp[i], dp[j] + abs(h[i] - h[j]));
    }
  }
  cout << dp[n - 1] << endl;

  return 0;
}

Measured memory_bytes: 1408
#include<stdio.h>

int main(void){
    int a,b,c,d,j[2];

    scanf("%d%d%d%d",&a,&b,&c,&d);

    if(a>c){j[0]=a;}
    else j[0]=c;

    if(b>d){j[1]=d;}
    else j[1]=b;

    if(j[1]<j[0])
        j[1]=j[0];

    printf("%d",(j[1]-j[0]));

    return 0;
}


Measured memory_bytes: 1732
import collections
n = int(input())
a = list(map(int, input().split()))
cnt = collections.Counter(a)
s = sum(a)
q = int(input())
for i in range(q):
    b, c = map(int, input().split())
    s += cnt[b]*(c-b)
    print(s)
    cnt[c] += cnt[b]
    cnt[b] = 0

Measured memory_bytes: 24336
#include <bits/stdc++.h>
#define mod 1000000007
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
typedef long long LL;
 
using namespace std;
 
int main() {
    fastio
    int n; cin >> n;
    string s;
    cin>>s;
    int q;
    cin>>q;
    vector<set<int>> rec(26);
    for(int i = 0; i<s.length();i++){
        rec[s[i]-'a'].insert(i);
    }
    while(q--){
    	int a;
    	cin>>a;
    	if(a == 1){
    		int b;
    		char c;
    		cin>>b;
    		cin>>c;
    		b--;
    		rec[s[b]-'a'].erase(b);
    		s[b] = c;
    		rec[s[b]-'a'].insert(b);
    	}
    	else{
    		int l, r;
    		cin>>l>>r;
    		l--;r--;
    		int res = 0;
    		for(int i = 0; i<26;i++){
    		    auto it = rec[i].lower_bound(l);
    		    if(it != rec[i].end() && *it<=r)
    		        res++;
    		}
    		cout<<res<<endl;
    	}
    }
    return 0;
}
   

Measured memory_bytes: 24220
#include <iostream>
#include <cstdio>
#include <fstream>
#include <algorithm>
#include <cmath>
#include <deque>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <map>
#include <stack>
#include <set>
#include <numeric>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){
    if(b==0)
        return a;
    return gcd(b,a%b);  //递归求最大公约数
}
ll lcm(ll a,ll b){
    return a/gcd(a,b)*b;    //递归求最小公倍数
}
int main()
{
    ll a,b;
    while(cin >> a >> b)
    {
        cout << gcd(a,b)<< " "<<lcm(a,b)<<endl;
    }
    return 0;
}


Measured memory_bytes: 3088
#include<iostream>
#include<string>
using namespace std;
int check(string n) 
{ 
    // Compute sum of digits 
    int l = n.length(); 
    int digitSum = 0; 
    for (int i=0; i<l; i++) 
        digitSum += (n[i]-'0'); 
  
    // Check if sum of digits is divisible by 9. 
    return (digitSum % 9 == 0); 
} 
int main() {
	string n;
	cin >> n;
	check(n)?  cout << "Yes" : cout << "No"; 
	return 0;
}

Measured memory_bytes: 3820
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
int main(){ 
    int n,k,x,y;
    int a=0;
    cin>>n>>k>>x>>y;
    REP(i,n){
        if(i+1<=k){
            a+=x;
        }else{
            a+=y;
        }
    }
    cout<<a;
    return 0;
}


Measured memory_bytes: 256
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
#include <random>
#include <cassert>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define MEM(a,b) memset((a),(b),sizeof(a))
const LL INF = 1e9 + 7;
const int N = 1e5 + 10;
int cnt[N];
LL dp1[2][N];
LL dp2[2][N];
LL sum1[N];
LL sum2[N];
int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int n, k;
	cin >> n >> k;
	int rt = 1;
	while (rt * rt <= n) rt++;
	rt--;
	for (int i = 1; i <= n; i++)
	{
		int l = i;
		int r = n / (n / l);
		if (n / l <= rt && r > rt)
		{
			cnt[n / l] = r - max(l, rt + 1) + 1;
		}
		i = r;
	}
	int o = 0;
	dp1[o][1] = 1;
	for (int i = 1; i <= k; i++)
	{
		memcpy(sum1, dp1[o], sizeof(sum1));
		memcpy(sum2, dp2[o], sizeof(sum2));
		for (int j = 1; j <= rt; j++) sum1[j] = (sum1[j] + sum1[j - 1]) % INF;
		for (int j = rt; j >= 0; j--) sum2[j] = (sum2[j] + sum2[j + 1]) % INF;
		o ^= 1;
		MEM(dp1[o], 0);
		MEM(dp2[o], 0);
		for (int j = 1; j <= rt; j++)
		{
			dp1[o][j] += sum1[rt] + sum2[j];
			dp1[o][j] %= INF;
		}
		for (int j = 1; j <= rt; j++)
		{
			dp2[o][j] += sum1[j] * cnt[j];
			dp2[o][j] %= INF;
		}
	}
	LL ans = 0;
	for (int i = 1; i <= rt; i++) ans += dp1[o][i] + dp2[o][i];
	ans %= INF;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 5120
package main

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

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

func ceil(a, b int) int {
	if a%b == 0 {
		return a / b
	} else {
		return a/b + 1
	}
}

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

func lcm(a, b int) int {
	return a / gcd(a, b) * b
}

// Sort
type RuneSlice []rune

func (a RuneSlice) Len() int           { return len(a) }
func (a RuneSlice) Less(i, j int) bool { return a[i] < a[j] }
func (a RuneSlice) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

// Main
const MOD = int(1e+9) + 7
const INF = 1 << 60

func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	defer wtr.Flush()
	N, K := sc.nextInt(), sc.nextInt()
	V := sc.nextIntSlice(N)
	ans := 0
	for a := 0; a <= min(K, N); a++ {
		for b := 0; b <= min(K-a, N); b++ {
			total := 0
			sum := []int{}
			l, r := 0, N-1
			for l < a {
				total += V[l]
				sum = append(sum, V[l])
				l++
			}
			for r >= N-b && l <= r {
				total += V[r]
				sum = append(sum, V[r])
				r--
			}
			sort.Ints(sum)
			rest := K - (a + b)
			for k := 0; k < len(sum) && k < rest; k++ {
				if sum[k] < 0 {
					total -= sum[k]
				} else {
					break
				}
			}
			//fmt.Fprintln(wtr, a, b, sum, l, r)
			ans = max(ans, total)
		}
	}

	fmt.Fprintln(wtr, ans)
}


Measured memory_bytes: 3072
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<cctype>
#include<ctime>
#include<iostream>
#include<string>
#include<map>
#include<queue>
#include<stack>
#include<set>
#include<vector>
#include<iomanip>
#include<list>
#include<bitset>
#include<sstream>
#include<fstream>
#include<complex>
#include<algorithm>
#if __cplusplus >= 201103L
#include <unordered_map>
#include <unordered_set>
#endif
#define ll long long
using namespace std;
const int INF = 0x3f3f3f3f;
int v[1010],w[1010],dp[20010];
int main(){
	ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	int h,n;
	cin>>h>>n;
	for(int i=1;i<=n;i++){
		cin>>v[i]>>w[i];
	}
	memset(dp,INF,sizeof dp);
	dp[0]=0;
	for(int i=1;i<=n;i++){
		for(int j=v[i];j<=20000;j++){
			 dp[j]=min(dp[j],dp[j-v[i]]+w[i]);
		}
	}
	int mmin=INF;
	for(int i=h;i<=20000;i++){
		mmin=min(mmin,dp[i]);
	}
	cout<<mmin<<endl;
    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using Map = map<ll,ll>;
using T = tuple<ll,ll,ll>;
using vvl = vector<vector<ll>>;
#define all(v) v.begin(), v.end()
#define print(v) cout<<v<<endl;
#define fi(v) get<0>(v)
#define se(v) get<1>(v)
#define th(v) get<2>(v)
template <typename T> bool chmax(T &a, const T &b){if (a<b){a=b;return 1;}return 0;}
template <typename T> bool chmin(T &a, const T &b){if (a>b){a=b;return 1;}return 0;}
const ll INF=1LL<<60;
const ll MOD=1000000007;


int main(){
    ll N, M, Q;
    cin>>N>>M>>Q;
    vector<ll> L(M,0);
    vector<ll> R(M,0);
    for(ll i=0;i<M;i++)cin>>L[i]>>R[i];
    vector<ll> p(Q,0);
    vector<ll> q(Q,0);
    for(ll i=0;i<Q;i++)cin>>p[i]>>q[i];
    //vec[i]には、i以降からはじまる電車の区間の右端を格納
    vector<vector<ll>> vec(N+1, vector<ll>(0));
    for(ll i=0;i<M;i++)
        for(ll j=1;j<=L[i];j++)vec[j].emplace_back(R[i]);
    
    for(ll i=1;i<=N;i++)sort(vec[i].begin(), vec[i].end());
    for(ll i=0;i<Q;i++){
        print(upper_bound(vec[p[i]].begin(), vec[p[i]].end(), q[i])-vec[p[i]].begin())
    }

    return 0;
}

Measured memory_bytes: 291876
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
#define drep(i,cc,n) for(int i=cc;i>=n;--i)
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 long long INF = 1LL <<60;
typedef long long ll;
using namespace std;
 
ll gcd(ll a, ll b) {
    if (b==0) return a;
    else return gcd(b, a%b);
}
 
ll lcm(ll a, ll b) {
    return a * b / gcd(a, b);
}
 
ll choose2(ll n){
    return n*(n-1)/2;
}
 
int main(){
    int d,n,result;
    cin>>d>>n;
    if(n == 100) result = pow(100,d) * n + pow(100,d);
    else result = pow(100,d) * n;
    cout<<result<<endl;
    return 0;
}

Measured memory_bytes: 256
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees#, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7
#from decimal import *
		
#階乗#
lim = 10**5+1  #必要そうな階乗の限界を入力
fact = [1] * (lim+1)
for n in range(1, lim+1):
	fact[n] = n * fact[n-1] % mod

N, M = MAP()

if 1 < abs(N-M):
	print(0)
	exit()

ans = (fact[N]*fact[M])%mod

if N == M:
	ans = 2*ans%mod

print(ans)

Measured memory_bytes: 9060
// N <= 10^5 なのに再帰DFSで通る理由
// https://twitter.com/maspy_stars/status/1256955111273717760
// けんしんさんのツイート参考https://twitter.com/knshnb/status/1256952059061927936?s=20
#include <bits/stdc++.h>

int main() {
    long long N, A, B, C;
    std::cin >> N >> A >> B >> C;
    std::vector<std::string> s(N);
    for(int i = 0; i < N; ++i) {
        std::cin >> s[i];
    }
    std::vector<char> ans;
    std::vector<long long> rem = {A, B, C};
    auto dfs = [&](auto f, long long idx) -> void {
        if(idx == N) {
            std::cout << "Yes" << std::endl;
            for(char c : ans) std::cout << c << "\n";
            exit(0);
        }
        long long x = s[idx][0] - 'A', y = s[idx][1] - 'A';
        for(int _ = 0; _ < 2; ++_) {
            if(rem[x] > 0) {
                ans.push_back('A' + y);
                rem[x]--, rem[y]++;
                f(f, idx + 1);
                rem[x]++, rem[y]--;
                ans.pop_back();
            }
            std::swap(x, y);
        }
    };
    dfs(dfs, 0);
    std::cout << "No" << std::endl;
    return 0;
}

Measured memory_bytes: 19488
sx,sy,tx,ty = list(map(lambda x: int(x), input().split(" ")))
route = ""

route += "U" * (ty-sy)
route += "R" * (tx-sx)
route += "D" * (ty-sy)
route += "L" * (tx-sx)
route += "L"
route += "U" * (ty-sy+1)
route += "R" * (tx-sx+1)
route += "D"
route += "R"
route += "D" * (ty-sy+1)
route += "L" * (tx-sx+1)
route += "U"

print(route)

Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
typedef long long ll;

ll n, k, ans, sa, a[505], b[505];

bool f(ll p) {
	ll i, sb=0, sc=0;
	for(i=0; i<n; i++) b[i] = a[i]%p, sb += b[i];
	sort(b, b+n);
	for(i=0; i<n-sb/p; i++) sc += b[i];
	return sc<=k;
}

int main() {
	ll i;
	cin >> n >> k;
	for(i=0; i<n; i++) cin >> a[i], sa += a[i];
	for(i=1; i*i<=sa; i++) if(sa%i==0) {
		if(f(i)) ans = max(ans, i);
		if(f(sa/i)) ans = max(ans, sa/i);
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mset(a, b) memset(a, b, sizeof(a))
using namespace std;
typedef long long LL;
const int MAXN = 200005;
const LL MOD = 1e9 + 7;

template <typename T> inline void read(T &AKNOI) {
	T x = 0, flag = 1;
	char ch = getchar();
	while (!isdigit(ch)) {
		if (ch == '-') flag = -1;
		ch = getchar();
	}
	while (isdigit(ch)) {
		x = x * 10 + ch - '0';
		ch = getchar();
	}
	AKNOI = flag * x;
}

int n, m, a, b;
LL fac[MAXN], inv[MAXN], finv[MAXN];

inline LL C(int x, int y) {
	return fac[x] * finv[y] % MOD * finv[x-y] % MOD;
}

inline LL Calc(int x, int y) {
	return C(x+y-2, x-1);
}

void init() {
	read(n); read(m); read(a); read(b);
	fac[0] = fac[1] = inv[0] = inv[1] = finv[0] = finv[1] = 1;
	for (int i=2;i<=n+m;++i) {
		fac[i] = fac[i-1] * i % MOD;
		inv[i] = (MOD-MOD/i) * inv[MOD%i] % MOD;
		finv[i] = finv[i-1] * inv[i] % MOD;
	}
}

void solve() {
	LL ans = Calc(n, m);
	for (int i=1;i<=b;++i) {
		ans = (ans - Calc(n-a, i) * Calc(a, m-i+1) % MOD + MOD) % MOD;
	}
	printf("%lld\n", ans);
}

int main() {
	init();
	solve();
	return 0;
}


Measured memory_bytes: 4992
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <limits>
#include <fstream>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define MOD1 1000000007

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  rep(i, N) cin >> A.at(i);
  int up = 1, down = -1;
  int state = 0;
  int ans = 1;
  rep(i, N - 1) {
    if (A.at(i) < A.at(i + 1)) {
      if (state == down) {
        state = 0;
        ans++;
      }
      else {
        state = up;
      }
    }
    if (A.at(i) > A.at(i + 1)) {
      if (state == up) {
        state = 0;
        ans++;
      }
      else {
        state = down;
      }
    }
  }

  cout << ans << endl;


}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#include <ext/pb_ds/detail/standard_policies.hpp>
#define INF 2000'000'000

using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef unsigned long long ull;
typedef tree<int, null_type,less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;


int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL), cout.tie(NULL);
	//freopen("in", "r", stdin);
	ll n, d, x, y, ans = 0;
	cin >> n >> d;
	d*= d;
	for(int i = 0; i < n && cin >> x >> y; i++){
		ans += d >= (x*x + y*y);
	}
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 3652
import java.util.*;
public class Main {
	public static void main(String[] args){
    //データ取り込み
		Scanner sc = new Scanner(System.in);
		//String S = sc.next();
    //int B = sc.nextInt();
    //System.out.println();
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		int D = sc.nextInt();
		if(A+B>C+D){
			System.out.println("Left");
		}else if(A+B<C+D){
			System.out.println("Right");
		}else{
			System.out.println("Balanced");
		}
	}
}


Measured memory_bytes: 21972
#include <bits/stdc++.h>
using namespace std;
#define rep(i, c) for (int i = 0; i < (int)c; i++)
int main()
{
    int n;
    scanf("%d", &n);
    vector<int> d(n);
    rep(i, n) scanf("%d", &d[i]);
    sort(d.begin(), d.end());
    int count = 1;
    rep(i, n - 1)
    {
        if (d[i] != d[i + 1])
            count++;
    }
    printf("%d\n", count);
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
string s;
char bloc1,bloc2,dir;
int num_f,num_s,rnum,lnum,lcount,i,count,len;
cin >> s;
len = (int)(s.length());
if(len == 2)cout << 1 << " " << 1;
  else{
bloc1 = s[0];
bloc2 = s[1];
  
num_f = 0;
num_s = 0;
rnum = 0;
lnum = 0;
lcount = 0;
dir = 'f';
for(count=0;count<(len-1);count++){
  if(bloc1 == 'R' && bloc2 == 'L'){
    if(dir = 's'){
      rnum = num_s+1;
      lnum = num_f+1;
    }else{
      rnum = num_f+1;
      lnum = num_s+1;
    }
    dir = 'f';
    num_f = 0;
    num_s = 0;
  }
  if(bloc1 == 'L' && bloc2 == 'L'){
    if(dir == 'f'){
      rnum++;
      dir = 's';
    }else{
      lnum++;
      dir = 'f';
    }
    lcount++;
  }
  if(bloc1 == 'L' && bloc2 == 'R'){
    cout << rnum << " " << lnum << " ";
    if(lcount > 0){
      for(i=0;i<lcount;i++)cout << 0 << " ";
    }
    lcount = 0;
    dir = 'f';
  }
    if(bloc1 == 'R' && bloc2 == 'R'){
      if(dir == 'f'){
        num_f++;
        dir = 's';
      }else{
        num_s++;
        dir = 'f';
      }
      cout << 0 << " ";
    }
  bloc1 = bloc2;
  bloc2 = s[(count+2)];
}
    cout << rnum << " " << lnum << " ";
    if(lcount > 0){
      for(i=0;i<(lcount-1);i++)cout << 0 << " ";
        cout << 0;
    }

      
  }
return 0;
}

Measured memory_bytes: 764
#include <stdio.h>
#include <string.h>

int main(){
    char s[50];
    scanf("%s", s);

    if (!strcmp(s, "Sunny")){
        printf("Cloudy\n");
    }else if (!strcmp(s, "Cloudy")){
        printf("Rainy\n");
    }else if (!strcmp(s,"Rainy")){
        printf("Sunny\n");
    }
}

Measured memory_bytes: 128
a = []
max, index, ans = 0, 0, 0
for i in range(5):
    tmp = int(input())
    a.append(tmp)
    if 10 - tmp % 10 > max and tmp % 10 != 0:
        max, index = 10 - tmp % 10, i
for i in range(5):
    if i == index or a[i] % 10 == 0:
        ans += a[i]
    else:
        ans += a[i] + 10 - a[i] % 10
print(ans)

Measured memory_bytes: 3060
#include <float.h>
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

// 内部定数
#define D_VAL_MAX		99										// 最大値
#define D_SUM_MAX		10000									// 最大合計値

// 内部変数
static FILE *szpFpI;											// 入力
static int si1PCnt[D_SUM_MAX + 5];								// パターン数

// 内部変数 - テスト用
#ifdef D_TEST
	static int siRes;
	static FILE *szpFpA;
	static int siTNo;
#endif

// １行出力
int
fOutLine(
	char *pcpLine				// <I> １行
)
{
	char lc1Buf[1024];

#ifdef D_TEST
	lc1Buf[0] = '\0';
	fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
	if (strcmp(lc1Buf, pcpLine)) {
		siRes = -1;
	}
#else
	printf("%s", pcpLine);
#endif

	return 0;
}

// 実行メイン
int
fMain(
)
{
	int i, j, k;
	char lc1Buf[1024];

	// データ - 初期化
	memset(si1PCnt, 0, sizeof(si1PCnt));

	// パターン数 - セット
	for (i = 1; i <= D_VAL_MAX; i++) {
		for (j = 1; j <= D_VAL_MAX; j++) {
			for (k = 1; k <= D_VAL_MAX; k++) {
				int liSum = i * i + j * j + k * k + i * j + j * k + k * i;
				if (liSum <= D_SUM_MAX) {
					si1PCnt[liSum]++;
				}
			}
		}
	}

	// N - 取得
	int liN;
	fgets(lc1Buf, sizeof(lc1Buf), szpFpI);
	sscanf(lc1Buf, "%d", &liN);

	// 出力
	for (i = 1; i <= liN; i++) {
		sprintf(lc1Buf, "%d\n", si1PCnt[i]);
		fOutLine(lc1Buf);
	}

	return 0;
}

// １回実行
int
fOne(
)
{
	int liRet;
	char lc1Buf[1024];

	// 入力 - セット
#ifdef D_TEST
	sprintf(lc1Buf, ".\\Test\\T%d.txt", siTNo);
	szpFpI = fopen(lc1Buf, "r");
	sprintf(lc1Buf, ".\\Test\\A%d.txt", siTNo);
	szpFpA = fopen(lc1Buf, "r");
	siRes = 0;
#else
	szpFpI = stdin;
#endif

	// 実行メイン
	liRet = fMain();

	// 残データ有無
#ifdef D_TEST
	lc1Buf[0] = '\0';
	fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
	if (strcmp(lc1Buf, "")) {
		siRes = -1;
	}
#endif

	// テストファイルクローズ
#ifdef D_TEST
	fclose(szpFpI);
	fclose(szpFpA);
#endif

	// テスト結果
#ifdef D_TEST
	if (siRes == 0) {
		printf("OK %d\n", siTNo);
	}
	else {
		printf("NG %d\n", siTNo);
	}
#endif

	return 0;
}

// プログラム開始
int
main()
{

#ifdef D_TEST
	int i;
	for (i = D_TEST_SNO; i <= D_TEST_ENO; i++) {
		siTNo = i;
		fOne();
	}
#else
	fOne();
#endif

	return 0;
}



Measured memory_bytes: 1712