akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int inf = (1 << 30) - 1;
const ll infll = (1LL << 61) - 1;
#define fast() ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define digit(N) cout << fixed << setprecision((N))
#pragma GCC target("avx2")
#pragma GCC optimization("O3")
#pragma GCC optimization("unroll-loops")

int main()
{
	long double a, b, c;
	cin >> a >> b >> c;
	if (a + b - c < -2 * (long double)sqrt(a * b))
	{
		cout << "Yes\n";
	}
	else
	{
		cout << "No\n";
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(n) begin(n), end(n)
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;
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 <typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template <typename T, typename... Ts>
auto make_v(size_t a, Ts... ts)
{
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }

template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v)
{
    for (auto &e : t)
        fill_v(e, v);
}
int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    cout<<min(c,b/a);
    return 0;
}

Measured memory_bytes: 3640
#include <stdio.h>
int main()
{
  int H,N,i,m;
  scanf("%d %d\n",&H,&N);
  int A[N];
  i,m = 0;
  while (i < N)
  {
    scanf("%d ",&A[i]);
    m += A[i];
    i++;
  }
  if (m >= H)
  {
    printf("Yes");
    return(0);
  }
  printf("No");
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define x first
#define y second
#define ndl '\n'
#define mp make_pair
#define pb push_back
#define up_b upper_bound
#define low_b lower_bound
#define sz(x) (int)x.size()
#define bit __builtin_popcount
#define all(x) x.begin(),x.end()

using namespace std;
using namespace __gnu_pbds;

template<typename T> using indexed_set=tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef pair<int,ll> pil;
typedef pair<ll,int> pli;
typedef pair<int,ull> piu;
typedef vector<vector<int>> matrix;

const ll INF=1e18+123;
const ld EPS=1e-9;
const int inf=1e9+123;
const int MOD=1e9+7;
const int N=2e5+123;
const int M=1e6+123;
const int dx[]={0,0,1,-1};
const int dy[]={1,-1,0,0};

vector<int>g[N];

int mx,dp[N];

//1-in

void dfs(int v,int p=-1){
    int mx1=0,mx2=0;
    for(int to : g[v]){
        if(to!=p){
            dfs(to,v);
            if(mx1<dp[to]){
                mx2=mx1;
                mx1=dp[to];
            }
            else if(mx2<dp[to]){
                mx2=dp[to];
            }
        }
    }
    mx=max(mx1+mx2+1,mx);
    dp[v]=mx1+1;
}

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin>>n;
    for(int i=1,u,v;i<n;i++){
        cin>>u>>v;
        g[u].pb(v);
        g[v].pb(u);
    }
    dfs(1);
    if(mx%3==2){
        cout<<"Second";
    }
    else{
        cout<<"First";
    }
    return 0;
}


Measured memory_bytes: 27008
#include <iostream>
#include <queue>
using namespace	std;
int main(){

  int n,g[100][100]={},tmp1,amo,tmp2;
  queue <int> q;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>tmp1>>amo;
    for(int j=0;j<amo;j++){
      cin>>tmp2;
      g[tmp1-1][tmp2-1]=1;
    }
  }
  int dis[100]={},flag[100]={1};
  for(int i=0;i<n;i++) if(i) dis[i]=-1;
  q.push(0);
  for(;!q.empty();){
    for(int i=0;i<n;i++) if(g[q.front()][i]&&flag[i]!=1){
        dis[i]=dis[q.front()]+1;
        flag[i]=1;
        q.push(i);
      }
    q.pop();
  }
  for(int i=0;i<n;i++) cout<<i+1<<" "<<dis[i]<<endl;
  return 0;

}

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

using namespace std;


long long f(long long b, long long n) {
    long long ret = 0;
    while (n) {
        ret += n % b;
        n /= b;
    }
    return ret;
}

void run_case() {
//    n / b + (n % b) = s
//    let x = floor(n / b)
//    x + n - x * b = s
//    x - x * b = s - n
//    x * b - x = n - s
//    x ( b- 1 ) = n - s
//    b = (n-s) / x + 1

    long long n, s;
    cin >> n >> s;
    const int N = 1e6;
    if (n == s) {
        cout << n + 1 << endl;
        return;
    }

    if (s > n) {
        cout << -1 << endl;
        return;
    }

    for (int i = 2; i <= N; i++) {
        if (f(i, n) == s) {
            cout << i << endl;
            return;
        }
    }

    for (int x = N; x >= 1; x--) {
        long long b = (n - s) / x + 1;
        if (b >= 2 && x == n / b && f(b, n) == s) {
            cout << b << endl;
            return;
        }
    }

    cout << -1 << endl;

}


int main() {


    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t = 1;
    //cin >> t;
    while (t--)run_case();


    return 0;
}
 
 
 
 
 
 
 
 


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

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int getRand(int l, int r)
{
    uniform_int_distribution<int> uid(l, r);
    return uid(rng);
}
  
#define int long long 
#define pb push_back
#define S second
#define F first
#define f(i,n) for(int i=0;i<n;i++)
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define vi vector<int>
#define pii pair<int,int>
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define precise(x) fixed << setprecision(x) 

const int MOD = 1e9+7;

int mod_pow(int a,int b,int M = MOD)
{
    int res = 1;
    
    while(b)
    {
        if(b&1) res=(res*a)%M;
        a=(a*a)%M;
        b>>=1;
    }
    
    return res;
}


void solve()
{
   int a,b,c,d;
    cin >> a >> b >> c >> d;
    
    int res = a*c;
    res = max(res,a*d);
    res = max(res,b*c);
    res = max(res,b*d);
    cout << res;
    
    
}

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

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

int main(){
	bool dt[51001];
	dt[0]=false;dt[1]=false;dt[2]=true;
	int count=0;
	for(int i=3;i<51001;i++){
		for(int j=2;j<i && j<5000;j++){
			if(dt[j]==true){if(i%j==0)count++;}
		}
		if(count==0){dt[i]=true;}else{dt[i]=false;}
		count=0;
	}
	int n=0;
	while(cin>>n){
		int i=0;
		int ansf=0,ansl=0;
		for(i=1;i<n;i++){
			if(dt[i]==true){ansf=i;}
		}
		i++;
		while(i>0){
			if(dt[i]==true){ansl=i;i=-10;}
			i++;
		}
		cout<<ansf<<" "<<ansl<<endl;
	}
	return 0;
}

Measured memory_bytes: 1208
#include <stdio.h>
int main(){
  int i, j, k=0, flag,n,A[100],t;
  scanf("%d", &n);
  for(i=0; i<n; i++){
    scanf("%d",&A[i]);
  }
  flag=1;
  while(flag){
    flag = 0;
    for(j=n-1; j>=1; j--){
      if(A[j]<A[j-1]){
        t = A[j-1];
        A[j-1] = A[j];
        A[j] = t;
        flag = 1;
        k++;
      }
    }
  }
    for(i=0; i<n-1; i++){
      printf("%d ", A[i]);
    }
    printf("%d\n", A[n-1]);
    printf("%d\n", k);
    return 0;

  }



Measured memory_bytes: 2084
N = int(input())
x = []
y = []
h = []

for i in range(N):
    xt, yt, ht = map(int, input().split())
    x.append(xt)
    y.append(yt)
    h.append(ht)
    if ht != 0:
        cx = xt
        cy = yt
        htt = ht

for j in range(101):
    for k in range(101):
        flg=True
        H = htt + abs(cx - j) + abs(cy - k)
        for i in range(N):
            if h[i] != max(H - abs(x[i] - j) - abs(y[i] - k), 0):
                flg = False
                break
        if flg==True:
            print(j, k, H)


Measured memory_bytes: 3064
_,*a=map(str.split,open(0))
U,R,D,L="URDL"
d={i:[]for i in"URDL"}
for *z,u in a:d[u]+=[*map(int,z)],
N=9e9
P,M="x+y,","x-y,"
for A,B,S in(U,D,"x,y,"),(R,L,"y,x,"),(R,U,P+M),(D,L,P+M),(U,L,M+P),(R,D,M+P):
 n=p=-9e9
 for x,y,r in sorted(eval(f"[({S}Q)for P,Q in[(A,1),(B,0)]for x,y in d[P]]")):
  if x-n:
   if r:n,p=x,y
  elif r:p=y
  else:N=min(N,y-p)
print(["SAFE",N*5][N<9e9])

Measured memory_bytes: 131388
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();
		int ans = 0;
		for(int i = 1 ; i <= n ; i++) {
			int temp = i; int sum = 0;
			for(int j = 0 ; j < 5 ; j++) {
				sum += temp % 10;
				temp /= 10;
				if(temp == 0) break;
			}
			if(a <= sum && sum <= b) ans += i;
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 21844
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(x),end(x)
#define show(obj) {for(auto x:obj)cout<<x<<' ';cout<<endl;}
#define line "----------"
typedef long long ll;
typedef pair<int,int> ip;
typedef pair<ll,ll> lp;
const int inf = 1001001000;
const ll INF = 1LL<<60;
const ll MOD = 1e9 + 7;

int main(){
	int N; cin>>N;
	string su, sb;
	cin>>su>>sb;
	ll ans;
	int i;
	if(su[0]!=sb[0]){
		i = 2;
		ans = 6;
	}else{
		i = 1;
		ans = 3;
	}
	while(i<N){
		if(su[i] != sb[i]){
			if(su[i-1]!=sb[i-1]){
				// cout<<"ff"<<endl;
				ans *= 3;
				ans%=MOD;
			}else{
				// cout<<"ft"<<endl;
				ans *= 2;
				ans%=MOD;
			}
			i+=2;
		}else{
			if(su[i-1] == sb[i-1]){
				ans *= 2;
				ans%=MOD;
				// cout<<"tt"<<endl;
			}else{
				// cout<<"tf"<<endl;
			}
			++i;
		}
	}
	if(ans<0)ans += MOD;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>

using namespace std;
using ll = long long;
constexpr int MOD = 1e9+7;

void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ cin >> head; _cin(forward<Tail>(tail)...); }
void _cout(){ cout << "\n"; } template <class Head, class... Tail> void _cout(Head&& head, Tail&&... tail){ cout << head; _cout(forward<Tail>(tail)...); }
int gcd(int a, int b){ return (b == 0) ? a : gcd(b, a % b); }

#define For(i, n) for(int i = 0; i < (n); i ++)
#define Rep(n) For(_, n)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) (find(Range(c), x) != c.end())
#define Search(rb, re, x) distance(rb, find(rb, re, x))
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Reverse(c) reverse(Range(c))
#define Vec2(T, n, m, xs) vector<vector<T>> xs(n, vector<T>(m))
#define Sum(a) accumulate(Range(a), 0)
#define Cusum(T, xs, sxs) vector<T> sxs(xs.size()+1); For(i, (int)xs.size()) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, ...) T __VA_ARGS__; _cin(__VA_ARGS__)
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinss(T, n, m, xs) Vec2(T, n, m, xs); For(i, n) For(j, m) cin >> xs[i][j]
#define Cinm(T, n, map) unordered_map<T, int> map; Rep(n){ Cin(T, x); map[x] ++; }
#define Cout(...) _cout(__VA_ARGS__)
#define Couts(xs) for(const auto &e : xs) cout << e << " "; cout << "\n"
#define Coutyn(cond) Cout((cond) ? "yes" : "no")
#define CoutYn(cond) Cout((cond) ? "Yes" : "No")
#define CoutYN(cond) Cout((cond) ? "YES" : "NO")

int main(void){
    Cin(int, a, b, c, d);
    CoutYn(a == b && b == c);
}

Measured memory_bytes: 256
//#include "debug.h"
#include <string.h>
#include <limits.h>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
using namespace std;

#define MAXN 100
int g[MAXN][MAXN];

int a, b;
int k = 50;

int input() {
	if (scanf("%d %d", &a, &b) < 0) return 0;
	return 1;
}

void init() {
}

long solve() {
	memset(g, 0, sizeof(g));
	for (int i=0; i<k; i++)
		for (int j=0; j<2*k; j++)
			g[i][j] = 1;

	for (int i=0; i<a-1; i++) {
		g[i/k*2][i%k*2] = 0;
	}

	for (int i=0; i<b-1; i++) {
		g[2*k-1-i/k*2][i%k*2] = 1;
	}
	return 1;
}

void output(long ans) {
	printf("%d %d\n", k*2, k*2);
	char t[3]=".#";
	for (int i=0; i<2*k; i++) {
		for (int j=0; j<2*k; j++)
			printf("%c", t[g[i][j]]);
		printf("\n");
	}
}

void cleanup() {
}

int main() {
	//int ca; scanf("%d", &ca);
	while (input()) {
		init();
		output(solve());
		cleanup();
		//break;
	}
}





Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<math.h>
#include<iomanip>
#include<stdio.h>
using namespace std;

int main(){

  int x, y, z, total, cnt=0;
  cin >> x >> y >> z;

  total=2*z;
  while(total<=x+1){
    total+=y;
     cnt++;
    if(total>x){
      cout << cnt-1 << endl;
      return 0;
    }
    total+=z;
    if(total>x){
      cout << cnt << endl;
      return 0;
    }
  }

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cassert>
#include <cstring>
#include <climits>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define mp make_pair
#define fi first
#define se second
#define pb push_back

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

constexpr ll INF = 1e18;
constexpr ll MOD = 1e9 + 7;
constexpr double PI = 3.14159265358979323846;
constexpr int di[] = {0, 0, 1, -1};
constexpr int dj[] = {1, -1, 0, 0};

string comp(string a, string b)
{
    if (a.size() != b.size())
    {
        if (a.size() > b.size())
            return a;
        else
            return b;
    }

    if (a == b)
        return a;

    string res = "";

    for (int i = 0; i < a.size(); i++)
    {
        if (a[i] != b[i])
        {
            if (a[i] - '0' > b[i] - '0')
                return a;
            else
                return b;
        }
    }

    return res;
}

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

    int n, m, a[10];
    int num[] = {0, 2,
                 5,
                 5,
                 4,
                 5,
                 6,
                 3,
                 7,
                 6};

    cin >> n >> m;
    REP(i, m)
    cin >> a[i];

    string res = "";

    string dp[11234];

    dp[0] = "";

    for (int i = 1; i <= n; i++)
    {
        dp[i] = "";
        REP(j, m)
        {
            if (num[a[j]] <= i && (num[a[j]] == i || dp[i - num[a[j]]] != ""))
                dp[i] = comp(dp[i], to_string(a[j]) + dp[i - num[a[j]]]);
        }

        //cout << dp[i] << endl;
    }

    cout << dp[n] << endl;

    return 0;
}

Measured memory_bytes: 32512
public class Main {
	public static void main(String[] args){
		java.util.Scanner scan = new java.util.Scanner(System.in);
		int n = scan.nextInt();
		int m = scan.nextInt();

		int[][] A = new int[n][m];
		int[] B = new int[m];
		int c;

		for(int i = 0;i<n;i++){
			for(int j = 0;j<m;j++){
				A[i][j] = scan.nextInt();
			}
		}
		for(int i = 0;i<m;i++){
			B[i] = scan.nextInt();
		}
		for(int i = 0;i<n;i++){
			c = 0;
			for(int j = 0;j<m;j++){
				c +=  A[i][j]*B[j];
			}
			System.out.println(c);
		}
	}
}

Measured memory_bytes: 40464
//75B
#include <bits/stdc++.h>
#define rep(i, n) for(int i=1; i<=n; i++)
using namespace std;
int main(void){
    int H, W;
    cin >> H >> W;
    string tmp;
    vector<vector<char>>field(H+2, vector<char>(W+2));
    vector<vector<int>>ans(H+2, vector<int>(W+2));
    //rep(i, H) rep(j, W) ans[i][j]=0; //初期化
    
    rep(i, H){
        cin >> tmp;
        rep(j, W) field[i][j] = tmp[j-1];
    }
    
    
    rep(i,H){
        rep(j,W){
            if(field[i][j]=='#'){
                ans[i-1][j-1] +=1;
                ans[i-1][j] +=1;
                ans[i-1][j+1]+=1;
                ans[i][j-1]+=1;
                ans[i][j+1]+=1;
                ans[i+1][j-1] +=1;
                ans[i+1][j] +=1;
                ans[i+1][j+1]+=1;
            }
        }
    }
    
    rep(i,H){
        rep(j,W){
            if (field[i][j]=='#'){
                cout << '#';
            }else{
                cout << ans[i][j];
            }
        }
        cout << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

typedef long long ll;

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

    ll a;
    int count = 0;
    for (int i = 0; i < N; i++) {
        cin >> a;
        while (!(a&1)) {
            count++;
            a /= 2;
        }
    }
    
    cout << count << endl;
}

Measured memory_bytes: 256
A, B, C, D = map(int, input().split())

def eg(a, b):
    amari = max(a,b)%min(a,b)
    if amari == 0:
        return min(a,b)
    return eg(min(a,b), amari)

g = eg(C, D)
l = C*D // g

countB = B - (B // C + B // D) + B // l
countA = (A-1) - ((A-1) // C + (A-1) // D) + (A-1) // l

print(countB - countA)

Measured memory_bytes: 3064
using System;

namespace B_005_56
{
    internal class Program
    {
        private static void Main(string[] args)
        {

            new Logic_B().Start();//OK

        }

        public class Logic_B
        {
            public void Start()
            {
                var str = Console.ReadLine().Split(' ');
                var W = Convert.ToInt32(str[0]);
                var a = Convert.ToInt32(str[1]);
                var b = Convert.ToInt32(str[2]);

                var d = 0;
                if ((a <= b && b <= a + W) && (a - W <= b && b <= a))
                {
                    d = 0;
                }
                else
                {
                    if (b >= a + W)
                    {
                        d = b - a - W;
                    }
                    else if (a >= b + W)
                    {
                        d = a - b - W;
                    }
                }

                Console.WriteLine(d);
            }
        }

      
    }
}

Measured memory_bytes: 11220
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <numeric>
#include <cstdint>
#include <iomanip>
#include <set>
#include <map>
#include <unordered_map>
#include <cassert>
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define fast_io(); std::ios_base::sync_with_stdio(0); std::cin.tie(0); std::cout.tie(0);

int main(){
    int n; std::cin >> n;
    std::vector<ll> l(n+1,0);
    l[0] = 2;
    l[1] = 1;
    for(int i=2; i<n+1; i++){
        l[i] = l[i-1] + l[i-2];
    }
    std::cout << l[n] << "\n";
    return 0;
}

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

import math
from decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_EVEN

n=int(input())
a=list(map(int, input().split()))

alice=0
bob=0

a.sort()

for i in range(n):
    if i%2==0:
        alice+=a.pop()
    else:
        bob+=a.pop()
print(alice-bob)


Measured memory_bytes: 5076
#include <bits/stdc++.h>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)

using namespace std;
class CompareFirst
{
public:
  bool operator()(pair<int,int> n1,pair<int,int> n2) {
    return n1.first>n2.first; //>:desc <:asc
  }
};


int main(){

  string s;
  int a,b,i,j,k,l,n,m;
  vector<string> vs;
  vector<int> vi;
  pair<int,int> pr;
  //unordered_map<string,int> mp;
  //priority_queue<int> pq; // default ‘å‚«‚¢‡
  //priority_queue<pair<int,int>,vector<pair<int,int>>,CompareFirst> pq;

  cin >> n;
  
  int p[n];
  
  rep(i,0,n-1)cin >> p[i]; 
  int flg = 0;
  rep(i,0,n-1){
    if(p[i]==i+1)continue;
    if(flg == 1){
      cout << "NO" <<endl;
      return 0;
    }
    swap(p[i],p[p[i]-1]);
    flg = 1;
  }
  
  cout << "YES" << endl;

  return 0;

}

Measured memory_bytes: 256
s = input().split()

n = int(s[0])
k = int(s[1])

a = input().split()

siyouzumi = {1}
y = [1]
t = 1

for i in range(1,k+1):

    t = int(a[t-1])
    if t in siyouzumi:
        haba = i - y.index(t)
        kaisu = int((k - i) / haba)

        l = k - (i + (haba * kaisu))

        for j in range(l):
            t = int(a[t-1])
        break

    siyouzumi.add(t)
    y.append(t)


print(t)

Measured memory_bytes: 41728
A, B, C = list(map(int, input().split()))
if A == B == C and A % 2 == 0 and B % 2 == 0 and C % 2 == 0:
    print(-1)
    exit()
ans = 0
while True:
    if A % 2 == 0 and B % 2 == 0 and C % 2 == 0:
        ans += 1
        A, B, C = (B + C) // 2, (A + C) // 2, (A + B) // 2
    else:
        break
print(ans)


Measured memory_bytes: 3060
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.regex.Pattern;

public class Main {
    public void solve(final BufferedReader stdin, final PrintWriter stdout) throws NumberFormatException, IOException {
        int k = Integer.parseInt(stdin.readLine());
        long[] a = Pattern.compile(" ").splitAsStream(stdin.readLine()).mapToLong(Long::parseLong).toArray();

        long min = 2;
        long max = 2;
        for (int i = k - 1; i >= 0; i--) {
            min = ceilDiv(min, a[i]) * a[i];
            max = max / a[i] * a[i] + a[i] - 1;
        }

        if (min <= max) {
            stdout.printf("%d %d%n", min, max);
        } else {
            stdout.println(-1);
        }

    }

    private long ceilDiv(long x, long y) {
        if (x % y == 0) {
            return x / y;
        } else {
            return x / y + 1;
        }
    }

    public static void main(String[] args) throws NumberFormatException, IOException {
        BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter stdout = new PrintWriter(System.out, false);
        new Main().solve(stdin, stdout);
        stdout.flush();
    }
}


Measured memory_bytes: 44772
#include "bits/stdc++.h"
#define MAXN 100009
#define INF 1000000007
#define mp(x,y) make_pair(x,y)
#define all(v) v.begin(),v.end()
#define pb(x) push_back(x)
#define wr cout<<"----------------"<<endl;
#define ppb() pop_back()
#define tr(ii,c) for(__typeof((c).begin()) ii=(c).begin();ii!=(c).end();ii++)
#define ff first
#define ss second
#define my_little_dodge 46
#define debug(x)  cerr<< #x <<" = "<< x<<endl;
using namespace std;

typedef long long ll;
typedef pair<int,int> PII;
template<class T>bool umin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T>bool umax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
int main(){
   // freopen("file.in", "r", stdin);
	int r,d;
	ll x;
	cin>>r>>d>>x;
	for(int i=1;i<=10;i++){
		x=r*x-d;
		cout<<x<<endl;	
	}
	return 0;
}


Measured memory_bytes: 256
sx, sy, tx, ty = map(int, input().split())
X = tx - sx
Y = ty - sy
S = ''
S += 'R' * X
S += 'U' * Y
S += 'L' * X
S += 'D' * (Y + 1)
S += 'R' * (X + 1)
S += 'U' * (Y + 1)
S += 'LU'
S += 'L' * (X + 1)
S += 'D' * (Y + 1)
S += 'R'
print(S)

Measured memory_bytes: 3060
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define F first
#define S second
//#define int long long
#define ll long long
//#define int  unsigned long long
#define pb push_back
#define double long double

using namespace std;
using namespace __gnu_pbds;
typedef  tree< int , null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
const int N = 900000;
const int K = 60;
const int mod = 1e9 + 7;
int a[N], used[N], cnt[N], s[N], n, m, b[N], ip = 1, qq[N], ans[N];
vector < int > q[N];
main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
  //  freopen("input.txt", "r", stdin);
    int n;
    cin >> n;
    srand(100);
    for (int i = 1; i <= n; i++){
        int x;
        cin >> x;
       // cout << x << endl;
        cnt[x]++;
    }
    sort(cnt + 1, cnt + 300000 + 1);
    reverse(cnt + 1, cnt + 300000 + 1);
    for (int i = 1; i <= n; i++) if (cnt[i] != 0) m = i;
    for (int i = 1; i <= m; i++) s[i] = s[i - 1] + cnt[i];
    for (int i = 1; i <= m; i++){
        b[i] = s[m] - s[i - 1];
        ans[i] = 1e9;
    }
    ans[0] = 1e9;
   // cout << b[1] << endl;
    for (int i = 1; i <= m; i++){
        int x = b[i];
        int k = 0;
     //   cout << x << " " << k << endl;
        while((k + 1) * (k + 1) <= b[i]){
            k++;
            ans[i + k - 1] = min(ans[i + k - 1], b[i] / k);
        }
        ans[i] = min({ans[i - 1], ans[i], b[i]});
        if (ans[i] == 1) break;
        while (b[i] / k != 1){
            x = b[i] / k;
            if (b[i] % x == 0) x = b[i] / x; else x = b[i] / x + 1;
            if (x == k) x = k + 1;
            if (x + i - 1 > m) break;
            ans[x + i - 1] = min(ans[x + i - 1], b[i] / x);
            k = x;
          //  cout << x << endl;
        }
    }
    ans[0] = 1e9;
    for (int i = 1; i <= m; i++){
        ans[i] = min(ans[i - 1], ans[i]);
        cout << ans[i] << " " << endl;
    }
    for (int i = m + 1; i <= n; i++) cout << 0 << " ";
   cout << endl;
}


Measured memory_bytes: 33920
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

typedef long long ll;
typedef pair<int,int> PP;

/*
    freopen("input","r",stdin);
    freopen("output","w",stdout);
*/

int N;
ll L[50];

bool check(ll n) {
	ll c = 0;
	for (int i = 0;i < N;i++) {
		c += (L[i] + n) / (N + 1);
	}
	return c <= n;
}

bool check2(ll n) {
	ll c = 0;
	for (int i = 0;i < N;i++) {
		c += (L[i] + n) / (N + 1);
		ll rem = (L[i] + n) % (N + 1);
		if (rem >= N) return 0;
	}
	return c == n;
}

int main() {
    ios::sync_with_stdio(false);
    cin >> N;
    for (int i = 0;i < N;i++) cin >> L[i];
    ll s = 0, l = 1E18;
    bool ok = 1;
    for (int i = 0;i < N;i++) {
    	if (L[i] >= N) ok = 0;
    }
    if (ok) {
    	cout << 0 << endl;
    	return 0;
    }
    while (s + 1 < l) {
    	ll m = s + (l - s) / 2;
    	if (check(m)) l = m;
    	else s = m;
    }
    for (ll x = max(0LL, l - 1000);x <= l + 1000;x++) {
    	if (check2(x)) {
    		cout << x << endl;
    		return 0;
    	}
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <stack>
#include <set>
#include <bitset>
#include <functional>
#include <cassert>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using mint = modint1000000007;
#define fast_io ios_base::sync_with_stdio (false) ; cin.tie(0) ; cout.tie(0) ;
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define MOD (long long int)(1e9+7)
#define INF (int)(1e9)
#define LINF (long long int)(1e18)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()
typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;

ll mpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = mpow(a,b/2); return memo*memo%MOD;}
  else return mpow(a,b-1) * a % MOD;
}
ll lpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = lpow(a,b/2); return memo*memo;}
  else return lpow(a,b-1) * a;
}
ll gcd(ll a, ll b){
  if(b==0) return a;
  else return gcd(b, a%b);
}
vector<ll> kaijo_memo;
ll kaijo(ll n){
  if(kaijo_memo.size() > n) return kaijo_memo[n];
  if(kaijo_memo.size() == 0) kaijo_memo.push_back(1);
  while(kaijo_memo.size() <= n) kaijo_memo.push_back(kaijo_memo[kaijo_memo.size()-1] * kaijo_memo.size() % MOD);
  return kaijo_memo[n];
}
vector<ll> gyaku_kaijo_memo;
ll gyaku_kaijo(ll n){
  if(gyaku_kaijo_memo.size() > n) return gyaku_kaijo_memo[n];
  if(gyaku_kaijo_memo.size() == 0) gyaku_kaijo_memo.push_back(1);
  while(gyaku_kaijo_memo.size() <= n) gyaku_kaijo_memo.push_back(gyaku_kaijo_memo[gyaku_kaijo_memo.size()-1] * mpow(gyaku_kaijo_memo.size(), MOD-2) % MOD);
  return gyaku_kaijo_memo[n];
}

ll nCr(ll n, ll r){
  if(n == r) return 1;//0個の丸と-1個の棒みたいな時に時に効く？不安.
  if(n < r || r < 0) return 0;
  ll ret = 1;
  if(n <= 1e7){
    ret *= kaijo(n); ret %= MOD;
    ret *= gyaku_kaijo(r); ret %= MOD;
    ret *= gyaku_kaijo(n-r); ret %= MOD;
  }else{
    rep(i,r){
      ret *= n-i; ret %= MOD;
      ret *= mpow(r-i, MOD-2); ret %= MOD;
    }
  }
  return ret;
}

vector<ll> yakusu(ll n){
  vector<ll> ret;
  for(ll p = 1; p*p <= n; p++){
    if(n%p == 0){
      ret.push_back(p);
      if(p*p != n){
        ret.push_back(n/p);
      }
    }
  }
  sort(all(ret));
  return ret;
}

map<ll,ll> soinsu(ll n){
  map<ll,ll> mp;
  for(ll p = 2; p*p <= n; p++){
    if(n%p == 0){
      mp[p]++;
      n /= p;
      p--;
    }
  }
  if(n > 1){
    mp[n]++;
  }
  return mp;
}

int main(void){
  fast_io
  cout<<fixed<<setprecision(15);

  int n,m;cin>>n>>m;
  dsu d(n);
  rep(i,m){
    int a,b;cin>>a>>b;a--;b--;
    d.merge(a,b);
  }

  cout << d.groups().size() - 1 << endl;
  return 0;
}

Measured memory_bytes: 9028
#include<iostream>
#include<vector>
#include<queue>
#include<cmath>
#include<algorithm>
#include<stack>
#include<map>
#include<set>
#define INF 2147483647
#define lli long long int

using namespace std;
typedef vector<int> vi;
typedef vector< vector<int> > vvi;

vector< vector<bool> > graph(8,vector<bool>(8,false));

int dfs(vector<bool> visited,int v){
	bool all_visited = true;
	for (int i = 0; i < visited.size(); i++){
		if (!visited[i]){
			all_visited = false;
		}
	}

	if (all_visited){
		return 1;
	}
	
	int res = 0;
	for (int i = 0; i < visited.size(); i++){
		if (graph[v][i] == false) continue;
		if (visited[i] == true) continue;
		visited[i] = true;
		res += dfs(visited,i);
		visited[i] = false;
	}
	
	return res;

}


int main() {

	int n,m; cin >> n >> m;

	for (int i = 0; i < m; i++){
		int a,b; cin >> a >> b;
		graph[a-1][b-1] = graph[b-1][a-1] = true;
	}
	vector<bool> visited(n,false);
	visited[0] = true;
	cout << dfs(visited,0) << endl;
	return 0;
}





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

int main() {
    ll n; cin >> n;
    cout << n*(n-1)/2 << endl;

    return 0;
}

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

using namespace std;

int main() {
  string s;
  cin >> s;
  char ans = 'a';
  for (char i = 'a'; i <= 'z'; i++) {
    if (s.find(i) == string::npos) {
      cout << i << '\n';
      return 0;
    }
  }
  cout << "None\n";
  return 0;
}

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

int main() {

	ll N;
	cin >> N;
	vector<pair<ll, ll>> d(N);
	REP(i, N) cin >> d[i].first >> d[i].second;

	ll A = 1, B = 1;
	for(auto e : d) {
		ll k = max((A+e.first-1)/e.first, (B+e.second-1)/e.second);
		A = k * e.first;
		B = k * e.second;
	}

	cout << A + B << endl;

}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
using namespace std;

class Stack
{
  private:
     int arr[102];
     int index;
  public:
    Stack()
   {
      index=0;
   }
   void push(int data)
   {
       arr[index]= data;
       index++;
   }
   int pop()
   {
       index--;
       return arr[index];
   }



};

main()
{
    int input;
    Stack s;
    while(scanf("%d",&input)!=EOF)
    {
        if(input==0)
        {
            printf("%d\n",s.pop());
        }
        else
            s.push(input);
    }
}



Measured memory_bytes: 3188
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int find(vector<int> &uf, int i) {
    int j = i;
    while (uf[j] >= 0) {
        j = uf[j];
    }

    while (uf[i] >= 0) {
        int temp = uf[i];
        uf[i] = j;
        i = temp;
    }

    return j;
}

void merge(vector<int> &uf, int i, int j) {
    i = find(uf, i);
    j = find(uf, j);

    if (i == j) return;

    int size = uf[i] + uf[j];
    if (abs(uf[i]) <= abs(uf[j])) {
        uf[i] = size;
        uf[j] = i;
    } else {
        uf[j] = size;
        uf[i] = j;
    }
}

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

    vector<int> uf(n, -1);

    for (int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        merge(uf, a - 1, b - 1);
    }

    cout << abs(*min_element(uf.begin(), uf.end())) << endl;

    return 0;
}


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

n = int(input())
ab = [list(map(int,input().split())) for _ in range(n)]
cd = [list(map(int,input().split())) for _ in range(n)]

ans = 0
used = [False]*n
ab.sort(key = lambda x: x[1])
ab.sort(key = lambda x: x[0])
cd.sort(key = lambda x: x[1])
cd.sort(key = lambda x: x[0])

for i in range(n):
    c,d = cd[i]
    li = []
    for j in range(n):
        if ab[j][0] < c and ab[j][1] < d and not used[j]:
            li.append((ab[j], j))
    max_idx = 0
    max_tmp = -1
    if li:
        for j in li:
            if max_tmp < j[0][1]:
                max_tmp = j[0][1]
                max_idx = j[1]
        ans += 1
        used[max_idx] = True

print(ans)


Measured memory_bytes: 39280
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

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

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned long long ULL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

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

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

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

int main() {
  int a, b;
  VI y;

  cin >> a >> b;
  while(1) {
    for(int i = a; i <= b; i++) {
      if(i % 400 == 0) y.PB(i);
      else if(i % 100 == 0) continue;
      else if(i % 4 == 0) y.PB(i);
    }

    if(y.empty()) cout << "NA" << endl;
    else {
      VI::iterator it = y.begin();
      while(it != y.end()) {
	cout << *it << endl;
	it++;
      }
    }
    y.clear();

    cin >> a >> b;
    if(a+b == 0)break;
    cout << '\n';
  }
}

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

#define int long long 
#define ld long double
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define dbg(x) cerr << #x << ": " << x << '\n'
#define fast_io() ios::sync_with_stdio(false); cin.tie(0);
#define fi first
#define se second

signed main() {
    fast_io();
    int n;
    cin >> n;
    vector<int> ind(n);
    for(int i = 0; i < n; i++){
        int p;
        cin >> p;
        p--;
        ind[p] = i;
    }
    int mx = 0, len = 0;
    for(int i = 0; i < n; i++){
        if(i == 0 || ind[i] > ind[i - 1]) len++; else len = 1;
        mx = max(mx, len);
    }
    cout << n - mx;
    return 0;
}


Measured memory_bytes: 4780
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
int acs(const void *a, const void *b) { 
  return *(int*)a - *(int*)b;
} /* 1,2,3,4.. */
int des(const void *a, const void *b) {
  return *(int*)b - *(int*)a;
} /* 8,7,6,5.. */
int cmp_char(const void *a, const void *b) { 
  return *(char*)a - *(char*)b;
} /* a,b,c,d.. */
int cmp_str(const void *a, const void *b) {
  return strcmp(*(const char **)a, *(const char **)b);
} /* aaa,aab.. */
#define min(a,b) (a < b ? a : b)
#define max(a,b) (a > b ? a : b)
#define rep(i, l, r) for (int i = l; i < r; i++)
#define MAX 100001
#define MOD 1000000007

typedef long long int lli;

int main(void) {
  int a, b, c;
  scanf("%d %d %d", &a, &b, &c);
  int sum = a + b + c;
  int max = max(a, max(b ,c));
  int ans;
  rep(i, max, 100) {
    if ( (i * 3 - sum) % 2 != 0 ) continue;
    ans = (i * 3 - sum) / 2;
    break;
  }
  printf("%d\n", ans);
  return 0;
}


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


// type definitions
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector< vi > vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
typedef complex<int> ci;
typedef complex<double> cd;
typedef complex<long double> cld;

// macros
#define rep(i, a, b) for(int i=a; i<b; i++)
#define TIME clock() * 1.0 / CLOCKS_PER_SEC
#define all(c) c.begin(), c.end()
#define tr(c, it) for(auto it=(c).begin(); it!=c.end(); it++)
#define pb push_back
#define mp make_pair
#define bitcount __builtin_popcount
#define ispresent(c, x) ((c).find(x) != (c).end())
#define watch(x) cout<< (#x) << " is " << (x) <<"\n";
#define sz(x) ((int)((x).size()))
#define UNIQUE(c) (c).resize(unique(all(c)) - (c).begin())
#define pii2ll(p) ((ll)(p).first<<32 | (p).second)

// template functions
template <typename T>
inline void printV(vector<T>& a) { rep(i, 0, sz(a)) { cout<<a[i]<<" "; } cout<<"\n"; }
template <typename T>
inline void printV(vector<T>& a, int n) { rep(i, 0, n) { cout<<a[i]<<" "; } cout<<"\n"; }
template <typename T>
inline void printVV(vector<vector<T>>& a)
{
	rep(i, 0, sz(a)) {
		printV(a[i]);
	}
	cout<<"\n";
}

template <typename T>
inline void clearVV(vector<vector<T>>& a)
{
	for(auto& x:a) {
		x.clear();
	}
	a.clear();
}
template <typename T>
inline void assignVV(vector<vector<T>> &a, T val)
{
	for(int i=0; i<sz(a); i++) {
		for(int j=0; j<sz(a[i]); j++) {
			a[i][j]=val;
		}
	}
}


// constants
const long double eps = 1e-9;
const int inf = 5e8;
const int modn = 1e9+7;
const int MAX = 1e5;

typedef long double ld;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    // Your code here
    cout<<fixed<<setprecision(10);
	int n;
	cin>>n;
	vector<ld> p(n);
	rep(i,0, n) cin>>p[i];
	vector<vector<ld>> dp(n, vector<ld>(n));
	assignVV(dp, (ld)-1);
	
	function<ld(int, int)> solve=[&](int i, int no)
	{
		
		if(i==n-1) {
			if(no<1) return (ld)1;
			else if(no==1) return p[i];
			else return (ld)0;
		}
		if(no <= 0) return (ld)1; 
		if(no > n-i+1) return (ld)0;
		
		if(fabs(dp[i][no]+1)>eps) return dp[i][no];
		ld &memo=dp[i][no];
		memo=p[i]*solve(i+1, no-1);
		memo+=(1-p[i])*solve(i+1, no);
		return memo;
	};
	cout<<solve(0, n/2+1)<<"\n";
	//~ printVV(dp);
    return 0;
}



Measured memory_bytes: 141312
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mod = 1e9+7;

#define rep(i, n) for(int i = 0; i < n; i++)

int main()
{
  // 0 0 1 2
  int sx, sy, tx, ty; cin >> sx >> sy >> tx >> ty;
  rep(i, ty-sy) cout << "U";
  rep(i, tx-sx) cout << "R";
  rep(i, ty-sy) cout << "D";
  rep(i, tx-sx) cout << "L";

  cout << "L";
  rep(i, ty-sy+1) cout << "U";
  rep(i, tx-sx+1) cout << "R";
  cout << "DR";
  rep(i, ty-sy+1) cout << "D";
  rep(i, tx-sx+1) cout << "L";
  cout << "U";
}

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

int main()
{
    int n, k;
    cin >> n >> k;
    int a[10] = {};
    while(k--){
        int t;
        cin >> t;
        a[t]++;
    }
    while(true){
        string s = to_string(n);
        bool next = false;
        for(auto c: s){
            for(int i=0; i<10; i++){
                if(a[i] != 0 && c-'0' == i) next = true;
            }
            if(next) break;
        }
        if(!next){
            cout << s << endl;
            return 0;
        }
        n++;
    }
    return 0;
}

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	n, _ := strconv.Atoi(sc.Text())
	return n
}

func main() {
	sc.Split(bufio.ScanWords)
	a, b, c := getInt(), getInt(), getInt()

	if b/a > c {
		fmt.Print(c)
	} else {
		fmt.Println(b / a)
	}

}


Measured memory_bytes: 640
import java.io.IOException;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		String str = sc.next();

		int result = 0;
		for(int i = 1; i < str.length() - 1; i++){
			String x = str.substring(0, i);
			String y = str.substring(i);

			int tmp = 0;
			for(char c = 'a'; c <= 'z'  ; c++){
				if(x.indexOf(c) >= 0 && y.indexOf(c) >= 0){
					tmp++;
				}
			}

			result = Math.max(result, tmp);
		}

		System.out.println(result);
	}
}


Measured memory_bytes: 23636
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n, T;
    cin >> n >> T;
    vector<int> t(n+1);
    for(int i = 0; i < n; i++)
        cin >> t[i];
    t[n] = INT_MAX;
    long ans = 0;
    for(int i = 0; i < n; i++)
        ans += min(T, t[i+1] - t[i]);
    cout << ans;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main(){
	string S;
	cin>>S;
	if(S[0]!=S[1]&&S[1]!=S[2]&&S[0]!=S[2]){
		cout<<"Yes"<<endl;
		}else{
			cout<<"No"<<endl;
}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
void factorize(long long n,vector<long long> &ans) 
{ 
    int count = 0; 
    while (!(n % 2)) { 
        n >>= 1;
        count++; 
    } 
    if (count) 
      ans.push_back(count); 
    for (long long i = 3; i <= sqrt(n); i += 2) { 
        count = 0; 
        while (n % i == 0) { 
            count++; 
            n = n / i; 
        } 
        if (count) 
            ans.push_back(count);
    } 
    if (n > 2) 
       ans.push_back(1);
} 
int main(){
 long long N;
 cin>>N;
 vector<long long >ans;
 factorize(N,ans);
 int res=0;
 if(N!=1){
 for(int i=0;i<ans.size();i++){
 	int count=1;
 	int j=1;
 	while(count<=ans[i]){
 			j++;
 		count=count+j;
 		res++;
	 }
 }}
 cout<<res<<"\n";
}

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

int dfs(vector<vector<int>> &adj,int cur,vector<int> &dp){
    if(adj[cur].size()==0)  dp[cur]=0;
    if(dp[cur]!=-1) return dp[cur];
    int ans=0;
    for(auto c:adj[cur]){
        ans = max(dfs(adj,c,dp),ans);
    }
    dp[cur]=ans+1;
    return dp[cur];
}
int main(){
    int n,m,x,y;
    cin>>n>>m;
    vector<vector<int>> adj(n+1);
    for(int i=0;i<m;i++){
        cin>>x>>y;
        adj[x].push_back(y);
    }
    vector<int> dp(n+1,-1);
    int ans=0;
    for(int i=1;i<=n;i++){
        ans = max(ans,dfs(adj,i,dp));
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 11872
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef pair<int, int> P;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define all(x) (x).begin(),(x).end()
vi dy = { 0,0,1,-1 };
vi dx = { 1,-1,0,0 };
constexpr auto INF = INT_MAX/2;
constexpr auto MOD = 1000000007;

int n,k;
vi h;
vi memo;

int dp(int x) {
	if (memo[x] < INF)return memo[x];
	if (x == 0)return 0;
	if (x == 1)return abs(h[1] - h[0]);

	int st,re=INF;
	if (x - k>= 0)st = x - k;
	else st = 0;

	for (;st < x;st++) re = min(re, dp(st) + abs(h[st] - h[x]));
	memo[x] = re;return re;
}


int main() {
	cin >> n >> k;
	h.resize(n);
	rep(i, n)cin >> h[i];
	memo.assign(n, INF);
	memo[0] = 0;
	memo[1] = abs(h[1] - h[0]);

	cout << dp(n-1) << endl;
}

Measured memory_bytes: 5760
#![allow(non_snake_case)]
#![allow(unused_imports)]
#![allow(dead_code)]

use proconio::{input, fastout};
use proconio::marker::*;
use whiteread::parse_line;
use std::collections::*;
use num::*;
use num_traits::*;
use superslice::*;
use std::ops::*;

use itertools::Itertools;
use itertools_num::ItertoolsNum;


#[fastout]
fn solve() {
    const MOD: usize = 1_000_000_007;
    const INF: usize = std::usize::MAX;
    
    input!{
        n: usize, x: usize, m: usize,
    }

    let mut vec = vec![x];
    let mut set: HashSet<usize> = HashSet::new();
    let mut idx = 0;
    for j in 0..n-1 {
        let t = (*vec.last().unwrap()).pow(2) % m;

        if !set.contains(&t) {
            set.insert(t);
            vec.push(t);
        } else {
            for (i, &v) in vec.iter().enumerate() {
                if v == t {
                    idx = i;
                    break;
                }
            }
            break
        }
    }

    
    let rep = vec[idx..].iter().map(|x| *x).collect::<Vec<usize>>();

    let rep_cnt = (n - idx) / rep.len();
    let rep_mod = (n - idx) % rep.len();

    let ans = vec[..idx].iter().sum::<usize>() + rep.iter().sum::<usize>() * rep_cnt + rep[..rep_mod].iter().sum::<usize>();    

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

fn main() {
    solve()
}

#[cfg(test)]
mod test {
    use super::solve;
}


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

int a[110];

int main(void){
	int n,m,t;
	cin >> n >> m >> t;
	rep(i,n) cin >> a[i];
	
	int ans=0;
	ans+=max(a[0]-m,0);
	rep(i,n-1) ans+=max(a[i+1]-a[i]-2*m,0);
	ans+=max(t-a[n-1]-m,0);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3100
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main() {
  ll n,m,a,b;
  cin >>n>>m;
  vector <pair<ll,ll>> v;
  for(ll i=0;i<n;i++) {
    cin >>a>>b;
    v.push_back(make_pair(a,b));
  }
  sort(v.begin(),v.end());
  ll sum=0,ans=0;
  for(ll i=0;i<n;i++){
    ll k=m-sum;
    if(k>=0){
       if(k>=v[i].second) {
         ans+=(v[i].second*v[i].first);
         sum+=v[i].second;
       }
       else{
         ans+=(k*v[i].first);
         sum+=k;
       }
    }
    else break;
  }
  cout <<ans<<endl;
}


Measured memory_bytes: 2420
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector<int> vec(0);
  int a;
  cin >> a;
  vec.push_back(a);
  for (int i = 0; i < N-1; i++) {
    int b;
    cin >> b;
    for (int j = 0; j < vec.size(); j++) {
      if (vec.at(j) == b) break;
      else if (j+1 == vec.size()) vec.push_back(b);
    }
  }
  cout << vec.size() << endl;
}

Measured memory_bytes: 256