akhauriyash/Code-Regression huggingface dataset:
p=1
x=0
while p==1:
        n=int(input())
        if n==0:
            break
        else:
            r=1000-n
            a=r//500
            r-=500*a
            b=r//100
            r-=100*b
            c=r//50
            r-=50*c
            d=r//10
            r-=10*d
            e=r//5
            r-=5*e
            x=a+b+c+d+e+r
            print(x) 


Measured memory_bytes: 5584
#include <bits/stdc++.h>
#define maxn 200005
#define MOD 998244353
#define INF 10000000000

using namespace std;

#define ll long long
#define pii pair<ll, ll>
#define piii pair<ll, pii>
#define ft first
#define sd second

void fast(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
}

void solve(){
    ll k, n;
    cin >> k >> n;
    ll a[n];
    for(ll i = 0; i < n; i++){
        cin >> a[i];
    }
    ll x = 0;
    for(ll i = 0; i < n-1; i++){
        x = max(x, a[i+1] - a[i]);
    }
    x = max(x, a[0] + k - a[n-1]);
    cout << k - x ;
}

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


Measured memory_bytes: 1792
#include <stdio.h>

int main(void)
{
	int l,m,n,K,S,num=0;
	scanf("%d%d",&K,&S);

	for(l=0;l<=K;l++)
		for(m=l;m<=K;m++)
			for(n=m;n<=K;n++){
				if(l+m+n==S){
					if(l==m&&m==n){
						num++;
					}else if(l!=m&&l!=n&&m!=n){
						num+=6;
					}else{
						num+=3;
					}
				}
			}
	
	printf("%d\n",num);
	return 0;
}

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

int main()
{
    int n;
    cin >> n;
    double x[n],y[n],sum[4]={0,0,0,0};
    for(int i=0;i<n;i++) cin >> x[i];
    for(int i=0;i<n;i++) cin >> y[i];
    for(int i=1;i<4;i++){
        for(int j=0;j<n;j++) sum[i-1]+=pow(abs(x[j]-y[j]),i);
    }
    for(int i=1;i<=3;i++)
        cout << fixed << setprecision(7) << pow(sum[i-1],1/(i*1.000000)) <<endl;
    double ma=0;
    for(int i=0;i<n;i++){
        if(ma<abs(x[i]-y[i])) ma=abs(x[i]-y[i]);
    }
    cout << fixed << setprecision(7) << ma << endl;
    return 0;
}



Measured memory_bytes: 3452
import java.util.*;

public class Main {
        public static void main(String[] 麺類総選挙){
            Scanner うどん = new Scanner(System.in);
            String そば = うどん.nextLine();
            int ラーメン = そば.length();
            String 山菜そば[] = そば.split("");
            String[] シチュー = new String[ラーメン];
            String[] 信州そば = new String[ラーメン];
            for(int 稲庭うどん=0;稲庭うどん<ラーメン;稲庭うどん++) {
                シチュー[稲庭うどん] = String.valueOf((稲庭うどん + 1)%2); //白スタート
                信州そば[稲庭うどん] = String.valueOf((稲庭うどん)%2);
            }
            //差分比較
            int 赤いきつね=0;
            int 緑のたぬき=0;
            for(int スパゲッティ=0;スパゲッティ<ラーメン;スパゲッティ++){
                if(!山菜そば[スパゲッティ].equals(シチュー[スパゲッティ])){
                    赤いきつね++;
                }else if(!山菜そば[スパゲッティ].equals(信州そば[スパゲッティ])){
                    緑のたぬき++;
                }
            }
            int 第三回人気投票;
            if (赤いきつね < 緑のたぬき) {
                第三回人気投票 = 赤いきつね;
            }else{
                第三回人気投票 = 緑のたぬき;
            }
            System.out.println(第三回人気投票);
        }

}


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

using namespace std;

/* g++ -g -fsanitize=address -lasan -std=c++11 -Dfoo_ */

/* freopen("input.txt", "rt", stdin); */
/* freopen("output.txt", "wt", stdout); */

#define ALL(c)          (c).begin(), (c).end()
#define ALLR(c)         (c).rbegin(), (c).rend()
#define FOR(i,a,b)      for (int i=(a); i < (b); ++i)
#define FORR(i,a,b)     for (int i=(a); i > (b); --i)
#define FOR_ALL(i,c)    for (__typeof((c).begin()) i=(c).begin();   \
                             i != (c).end(); ++i)
#define FOR_ALLR(i,c)   for (__typeof((c).rbegin()) i=(c).rbegin(); \
                             i != (c).rend(); ++i)
#define SZ(array)       (sizeof(array)/sizeof(array[0]))
#define lc(x)           (x<<1)     /* 2*x */
#define rc(x)           (x<<1 | 1) /* 2*x+1 */
#define lowbit(x)       (x & (-x)) /* 0b10100 -> 0b100 */

typedef long long       LL;
typedef map<int,int>    MII;
typedef pair<int,int>   PII;
typedef set<int>        SI;
typedef vector<bool>    VB;
typedef vector<double>  VD;
typedef vector<int>     VI;
typedef vector<string>  VS;

/* check if a key is in container C */
template <class C>
inline bool in_(const typename C::key_type& k, const C& A)
{ return A.find(k) != A.end(); }
inline bool in_(const string& s, const string& S)
{ return S.find(s) != string::npos; }

const int inf = 1e9;

int main()
{
/* #ifdef foo_ */
/*     freopen("foo", "rt", stdin); */
/* #endif */
/*     ios::sync_with_stdio(false); */
    int n;
    while (cin >> n) {
        VI A(n+1);
        FOR(i,1,n+1)
            cin >> A[i];
        int mx = inf; int i = 1; int ans = 0;
        FOR(i,1,n+1) {
            if (mx > A[i])
                ans++;
            mx = min(mx, A[i]);
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
using namespace std;
int main()
{
	int i;
	char s[10], r;
	bool f;
	while (cin >> s)
	{
		if (s[0] != 's' && s[0] == s[1] && s[1] == s[2])
			cout << s[0] << endl;
		else if (s[3] != 's' && s[3] == s[4] && s[4] == s[5])
			cout << s[3] << endl;
		else if (s[6] != 's' && s[6] == s[7] && s[7] == s[8])
			cout << s[6] << endl;
		else if (s[0] != 's' && s[0] == s[3] && s[3] == s[6])
			cout << s[0] << endl;
		else if (s[1] != 's' && s[1] == s[4] && s[4] == s[7])
			cout << s[1] << endl;
		else if (s[2] != 's' && s[2] == s[5] && s[5] == s[8])
			cout << s[2] << endl;
		else if (s[0] != 's' && s[0] == s[4] && s[4] == s[8])
			cout << s[0] << endl;
		else if (s[2] != 's' && s[2] == s[4] && s[4] == s[6])
			cout << s[2] << endl;
		else
			cout << "d" << endl;
	}
}

Measured memory_bytes: 0
/* Author : Aaryan Srivastava ^__^ */ 
#include <bits/stdc++.h>
#include <random>
#include <chrono>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#define pb push_back
#define mp make_pair
#define ff first
#define ss second   
#define rep(i,n) for(int (i) = 0 ; i < (n) ; i++)
#define repA(i,x,y) for(int i = (x) ; i <= (y) ; i++)
#define repD(i,x,y) for(int i = (x) ; i >= (y) ; i--)
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).end()
#define setval(a,val) memset(a,val,sizeof(a))
#define Randomize mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define trav(x , a) for(auto &x : a)
#define sz(a) ((int)a.size())
typedef long long ll ; 

#define int ll

using namespace std;

const int N = 3e5 +5 ;
const int mod = 1e9 + 7 ;
const ll inf = 1e18 ;
const int SZ = 101 ;
const double eps = 1e-9 ;
using namespace __gnu_pbds;
using ordered_set =  tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ;

typedef pair<int, int> pii; 
typedef pair<int , pii> ipii ;
typedef pair<pii , int> piii ; 
typedef unsigned long long ull ;
typedef long double ld;

ll po(ll x,ll y,ll p = mod) {ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}

void solve()
{
    int n , m;
    cin >> n >> m;
    int a[n] , cnt= 0, tot = 0;
    rep(i , n){
        cin >> a[i];
        tot += a[i];
    }
    rep(i , n){
        if(a[i] * 4 * m >= tot) cnt++;
    }
    cout << (cnt >= m ? "Yes" : "No");
}   

     
int32_t main(int32_t argc, char *argv[])
{
    ios::sync_with_stdio(0);    
    cin.tie(0); cout.tie(0);
    int TC = 1, t = 0;
    //cin >> TC ;
    while(t++ < TC)
    {
        //cout << "Case #" << t << ": " ;
        solve();
        cout << "\n" ;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <cmath> //sqrt pow
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // dequef
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower

#define rep(i,n) for(int i = 0; i < n; i++)
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define all(a) (a).begin(), (a).end()
#define mod 1000000007
using ll = long long;
using namespace std;
int main(){
  int n;
  cin >> n;
  vi dp(n + 1, n);
  dp[0] = 0;
  rep(i, n){
    dp[i + 1] = min(dp[i + 1], dp[i] + 1);
    int nine = 9, six = 6;
    while(n >= nine + i){
      dp[nine + i] = min(dp[nine + i], dp[i] + 1);
      nine *= 9;
    }
    while(n >= six + i){
      dp[six + i] = min(dp[six + i], dp[i] + 1);
      six *= 6;
    }
  }
  cout << dp[n] << endl;
}

Measured memory_bytes: 640
fun main(){
    val x = readLine()!!.split(" ").map { it.toInt() }[0]
    var a = 0
    var b = 0
    var kotaeA = 0
    var kotaeB = 0
    var xx = 0
    for (i in -120 until 120){
        a = i
        for (j in -120 until 120){
            b = j
            xx = (a * a * a * a * a) - (b * b * b * b * b)
            if (xx == x) {
                kotaeA = a
                kotaeB = b
                break
            }
        }
    }
    println("${kotaeA} ${kotaeB}")
}

Measured memory_bytes: 36232
N, M = map(int,input().split())
A = list(map(int,input().split()))
A.sort(reverse = True)
it = 0
for i in range(M):
    A[it]=A[it]//2
    if it<N-1:
        if A[it]<A[it+1] and A[0]<A[it+1]:
            it+=1
        else:
            A.sort(reverse = True)
            it = 0
    if it == N-1:
        A.sort(reverse = True)
        it = 0
print(sum(A))

Measured memory_bytes: 14224
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <set>

using namespace std;

const int INF = 1000000009;

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

  vector<set<int>> a(26, set<int>({INF})); // INF は番兵のようなもの
  for (int i = 0; i < n; i++) { a[s[i]-'a'].insert(i); }

  int q; cin >> q;
  while (q--) {
    int type; scanf("%d", &type);
    if (type == 1) {
      int idx; char c; scanf("%d %c", &idx, &c); idx--;
      a[s[idx]-'a'].erase(idx);
      a[c-'a'].insert(idx);
      s[idx] = c;
    }
    if (type == 2) {
      int l, r; scanf("%d %d", &l, &r); l--;
      int ret = 0;
      for (int i = 0; i < 26; i++) {
        int lid = *a[i].lower_bound(l);
        if (lid < r) ret++;
      }
      cout << ret << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 24196
#include <stdio.h>
#define N 110

int main ( void ) {
  int i, j;
  char ch[N];

  for ( ; scanf ( "%s", ch ) == 1; ) { 
    for ( i = 0; ch[ i ]; i++)
      if ( ch[ i ] == '@' ) {
        for ( j = 0; j < ( ch[ i+1 ] - '0' ); j++ )
          printf ( "%c", ch[ i+2 ] );

        i+=2;
      } else {
        printf ( "%c", ch[ i ] );
      }

    printf ( "\n" );
  }

  return ( 0 );
}

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

int gcd(int x,int y){
    if (x==0) return y;
    if (y==0) return x;
    int z = 1;
    while(z!=0){
        z = x%y;
        x = y;
        y = z;
    }
    return x;
}

struct SegTree{
    vector<int> data;
    int data_num;

    SegTree(): data(){

    } 
    void init(int n){
        data_num = 1;
        while(n!=0){
            n = n/2;
            data_num*=2;
        }
        data_num*=2;
        data_num--;
        rep(i,data_num) data.push_back(0);
    }

    void update(int i,int x){
        i = (data_num+1)/2 -1 + i;
        data[i] = x;
        while(i>0){
            i = (i-1)/2;
            data[i]=gcd(data[i*2+1],data[i*2+2]);
        }
    }

    int all_gcd(){
        return data[0];
    }

};

void debug(){
    cout << "debug>>" ;
    int dummy;
    cin >> dummy;
}

int main(){
    int n;
    cin >> n;
    SegTree sg;
    vector<int> a(n+1);
    sg.init(n+1);
    rep(i,n){
        cin >> a[i];
        sg.update(i,a[i]);
    }
    //debug();
    a[n]=a[n-1];

    //cout <<sg.all_gcd() << endl;
    int res = 0;
    rep(i,n){
        sg.update(i,0);
        res = max(res,sg.all_gcd());
        sg.update(i,a[i]);
    }
    cout << res << endl;
    
    



}

Measured memory_bytes: 1784
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define sqr(a) ((a) * (a))
#define io() ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define co() cout.precision(10);
#define F for(li i=0;i<n;i++)
#define fo(i,a,n) for(i=a;i<n;i++)
#define ne cout<<"\n";
#define nec cout<<'\n';continue;
#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
#define test int t;cin>>t;while(t--)
//#define oj #ifndef ONLINE_JUDGE freopen("input.txt","r",stdin); freopen("output.txt","w",stdout); #endif
//memset(arr, 0, sizeof arr);
typedef long long li;
typedef long double ld;

const li mod = 1000000007;

int main()
{
    io();
    li a,b,c,d;
    cin>>a>>b>>c>>d;
    li x=a*c;
    x=max(x,a*d);
    x=max(x,b*c);
    x=max(x,b*d);
    cout<<x;
}


Measured memory_bytes: 3648
#include<cstdio>
#include<vector>
#include<algorithm>
#include<utility>
#include<numeric>
#define _USE_MATH_DEFINES

#include<math.h>

#define min(a,b) (a)>(b)?(b):(a)
#define max(a,b) (a)>(b)?(a):(b)

using namespace std;

int main()
{
	int n;
	vector<long long int> a;
	scanf("%d", &n);
	for (int i = 0; i < n; i++)
	{
		long long int ta;
		scanf("%lld", &ta);
		a.push_back(ta);
	}
	sort(a.begin(), a.end());
	printf("%lld %lld %lld\n", a.front(), a.back(), accumulate(a.begin(), a.end(), (long long int)0));
	return 0;
}

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

int main() {
    int N, X, T;
    cin >> N >> X >> T;
    int times = N / X;
    int nokori = N % X;
    if (nokori != 0) {
        cout << (times + 1) * T << endl;
    }
    else {
        cout << times * T << endl;
    }
}

Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;
using ll = long long;
//西暦⇒時代の歴
ll a[100010];
int main()
{
    int N;
    cin >> N;
    for (int i = 0; i < N; ++i)
        cin >> a[i];
    sort(a, a + N);

    ll r1 = 0, r2 = 0;
    for (int i = N - 1; i >= 0; --i)
    {
        if (a[i - 1] == a[i])
        {
            if (r1 == 0)
            {
                r1 = a[i];
                i--;
            }
            else if (r1 != 0)
            {
                cout << r1 * a[i] << endl;
                return 0;
            }
        }
    }
    cout << 0 << endl;
    return 0;
}

Measured memory_bytes: 1024
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		char[] s = sc.next().toCharArray();
		int x = 0;
		int ret = s.length;
		for (int i = 0; i < s.length; i++) {
			if (s[i] == 'S') {
				x++;
			} else {
				if (x > 0) {
					x--;
					ret -= 2;
				}
			}
		}
		System.out.println(ret);
	}

}

class FastScanner {
	public static String debug = null;

	private final InputStream in = System.in;
	private int ptr = 0;
	private int buflen = 0;
	private byte[] buffer = new byte[1024];
	private boolean eos = false;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				if (debug != null) {
					buflen = debug.length();
					buffer = debug.getBytes();
					debug = "";
					eos = true;
				} else {
					buflen = in.read(buffer);
				}
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen < 0) {
				eos = true;
				return false;
			} else if (buflen == 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	private void skipUnprintable() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
	}

	public boolean isEOS() {
		return this.eos;
	}

	public boolean hasNext() {
		skipUnprintable();
		return hasNextByte();
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		return (int) nextLong();
	}

	public long[] nextLongList(int n) {
		return nextLongTable(1, n)[0];
	}

	public int[] nextIntList(int n) {
		return nextIntTable(1, n)[0];
	}

	public long[][] nextLongTable(int n, int m) {
		long[][] ret = new long[n][m];
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++) {
				ret[i][j] = nextLong();
			}
		}
		return ret;
	}

	public int[][] nextIntTable(int n, int m) {
		int[][] ret = new int[n][m];
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++) {
				ret[i][j] = nextInt();
			}
		}
		return ret;
	}
}

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

char a[110];
int main(){
    scanf("%s",a);
    int k,i,s,in=0;
    s=strlen(a);
    for(k=0;k<s;k++){
        if(a[k]=='C'){
            in++;
            break;
        }
    }
    for(;k<s;k++){
        if(a[k]=='F'){
            in++;
            break;
        }
    }
    if(in==2) puts("Yes");
    else puts("No");
}

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

using namespace __gnu_pbds;
using namespace std;

#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// order_of_key (val): returns the no. of values less than val
// find_by_order (k): returns the kth largest element.(0-based)

#define ll long long int
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define pi pair<ll,ll>
#define pii pair<ll,pi >
#define ppi pair<pi,ll>
#define ppp pair<pi,pi >
#define ex(str,a,b) str.substr((int)(a),min((int)str.size()-a,(int)(b-a+1))) 
#define all(X) X.begin(),X.end()
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

// for pair comparison function(ascending order) use return (i1.ff < i2.ff);

/* string operations :
   str.substr (x,y) : returns a substring str[x],str[x+1],...str[x+y-1]
   __builtin_popcount(n) : no. of set bits in n.
*/

const int M = (1<<20)+5;
const int md = 1e9+7;

priority_queue<ll,vector<ll >,greater<ll > > pq;

ll pwr(ll a,ll n,ll m)
{
	ll p=1;
	while(n>0)
	{
		if(n%2==1)
			p=(p*a)%m;
		a=(a*a)%m;
		n=n/2;
	}
	return p;
}

ll ar[M];

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

	ll i,n,ans = 0;

	cin >> n;
	for(i=1;i<=n;++i)
	{
		cin >> ar[i];
		if(ar[i]<ar[i-1])
		{
			ans += ar[i-1]-ar[i];
			ar[i] = ar[i-1];
		}
	}
	cout << ans << "\n";
}

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

int main() {
  int n; 
  cin >> n;
  int number = 1;
  int answer = 0;
  int count = 0;
  for(int i = 1; i <= n; i++){ 
    int x = i;
    while(x % 2 == 0){
      count++;
      x /= 2;
    }
    if(answer < max(count, answer)){
      number = i;
      answer = max(count, answer);
      count = 0;
    }
    else{
      count = 0;
    }
  }
  cout << number << endl;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
      	
		Scanner sc = new Scanner(System.in);
		int H = sc.nextInt();
		int A = sc.nextInt();
		if (H%A==0) {
			System.out.println(H/A);
		} else {
			System.out.println(H/A+1);
		}
		
      	sc.close();
    }
		
		
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define maxn 100
using namespace std;
int n,a[maxn],id[maxn];
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
        scanf("%d",&a[i]);
        id[a[i]]=i;
    }
    int cnt=0;
    for(int i=1;i<=n;i++){

        if(id[i]!=i&&id[id[i]]!=i){
            puts("NO");
            return 0;
        }
        if(id[i]!=i&&id[id[i]]==i){
            cnt++;
        }

    }
    if(cnt==2||cnt==0) puts("YES");
    else puts("NO");
    return 0;
}

Measured memory_bytes: 256
/*
*/

#pragma comment(linker, "/STACK:16777216")
#define _CRT_SECURE_NO_WARNINGS

#include <fstream>
#include <iostream>
#include <string>
#include <complex>
#include <math.h>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <stdio.h>
#include <stack>
#include <algorithm>
#include <list>
#include <ctime>
#include <memory.h>
#include <assert.h>

#define y0 sdkfaslhagaklsldk
#define y1 aasdfasdfasdf
#define yn askfhwqriuperikldjk
#define j1 assdgsdgasghsf
#define tm sdfjahlfasfh
#define lr asgasgash
#define norm asdfasdgasdgsd
#define have adsgagshdshfhds

#define eps 1e-6
#define M_PI 3.141592653589793
#define bs 1000000007
#define bsize 350

using namespace std;

const int INF = 1e9;
const int N = 3000;

int main(){
	//freopen("fabro.in","r",stdin);
	//freopen("fabro.out","w",stdout);
	//freopen("F:/in.txt", "r", stdin);
	//freopen("F:/output.txt", "w", stdout);
	ios_base::sync_with_stdio(0);
	//cin.tie(0);

	string st;

	cin >> st;
	for (int i = 0; i < st.size(); i++)
	{
		for (int j = i + 1; j < st.size(); j++)
		{
			if (st[i] == 'C'&&st[j] == 'F')
			{
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	cout << "No" << endl;

	cin.get(); cin.get();
	return 0;
}

Measured memory_bytes: 764
def resolve():
    a,b,k=map(int,input().split())
    while 1:
        if a%2==1:
            a-=1
        a//=2
        b+=a
        k-=1
        if k==0:
            break
        if b%2==1:
            b-=1
        b//=2
        a+=b
        k-=1
        if k==0:
            break
    print('{} {}'.format(a,b))
resolve()

Measured memory_bytes: 38256
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <vector>
#include <array>
#include <stack>
#include <list>
#include <queue>
#include <deque>
#include <climits>
#include <utility>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <complex>
#include <numeric>
#include <chrono>
#include <cmath>
#include <bitset>

using namespace std;

#define FOR(it, ar) for(auto &it: ar)
#define loop(i, start, end) for(auto i = (start); i <= (end); i++)
#define loopSkip(i, start, end, skip) for(auto i = (start); i <= (end); i += skip)
#define loopRev(i, start, end) for(int i = (start); i >= (end); i--)
#define FLASH ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define testCases(t) cin >> t; while(t--)
#define PN(n) cout << (n)
#define PN1(n) cout << (n) << " "
#define PN2(a, b) cout << (a) << " " << (b) << " "
#define PN3(a, b, c) cout << (a) << " " << (b) << " " << (c) << " "
#define PNN1(n) cout << (n) << "\n"
#define PNN2(a, b) cout << (a) << " " << (b) << "\n"
#define PNN3(a, b, c) cout << (a) << " " << (b) << " " << (c) << "\n"
#define PrintObject(ar) for(auto var: ar) cout << var << " "; cout << "\n"
#define PrintMap(map) for(auto var: map) PNN2(var.first, var.second)
#define PrintPair(pair) PNN2(pair.first, pair.second)
#define IN1(n) cin >> n
#define IN2(a, b) cin >> a >> b
#define IN3(a, b, c) cin >> a >> b >> c
#define ALL(s) s.begin(), s.end()
#define ENTER PNN1("")
#define llPair std::pair<lli, lli>
#define iiPair std::pair<int, int>

// Math macros
#define M_PI 3.14159265358979323846

typedef long long int lli;
typedef unsigned long long int ulli;
typedef long double ld;

template <typename T>
T ii() {
	T a;
	IN1(a);
	return a;
}

struct custom_hash {
  static uint64_t splitmix64(uint64_t x) {
      // http://xorshift.di.unimi.it/splitmix64.c
      x += 0x9e3779b97f4a7c15;
      x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
      x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
      return x ^ (x >> 31);
  }

  size_t operator()(uint64_t x) const {
      static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
      return splitmix64(x + FIXED_RANDOM);
  }
};

int main(void){
	FLASH
	#ifndef ONLINE_JUDGE
		freopen("input-stream.txt", "r", stdin);
		freopen("output-stream.txt", "w", stdout);
	#endif

	int d, t, s;
	IN3(d, t, s);

	PNN1(d <= t * s ? "Yes" : "No");

	return 0;
}


Measured memory_bytes: 3612
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <queue>
#include <cmath>
#include <map>
#include <set>
#include <deque>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int mod = 1e9+7;
typedef pair<int, int> P;

int main() {
  int n, k; cin >> n >> k;
  double res = 0;
  for(int i = 1; i <= n; i++) {
    double tmp = 1.0/n;
    int now = i;
    while(now < k) {
      now *= 2;
      tmp /= 2;
    }
    res += tmp;
  }
  printf("%.12lf\n", res);
  return 0;
}


Measured memory_bytes: 256
#import sys
#import numpy as np
import math
#from fractions import Fraction
import itertools
from collections import deque
from collections import Counter
import heapq
from fractions  import gcd
#input=sys.stdin.readline
#import bisect
n=int(input())
if n<1200:
    print("ABC")
elif n<2800:
    print("ARC")
else:
    print("AGC")

Measured memory_bytes: 77404
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a) for(int i = 0; i < (a); i++)
#define reps(i, a, b) for(int i = (a); i < (b); i++)
#define INF 1e9
typedef vector<int> vi;
typedef vector<vi> vii;
typedef pair<int, int> pii;
int main() {
	int n;
	vector<pii> v;
	cin >> n;
	rep(i, n) {
		int ind, a;
		cin >> ind >> a;
		v.push_back(make_pair(ind,a));
	}
	sort(v.begin(), v.end(), [](pii a,pii b) -> bool {
			if(a.second == b.second) return a.first < b.first;
			return a.second > b.second;
			});
	cout << v[0].first << " " << v[0].second << endl;
	return 0;
}

Measured memory_bytes: 1204
#include<bits/stdc++.h>
using namespace std;
#define inf 2500
#define Nmax 100

class node{
    public:
    int cost;
    int num;
    node(int cost,int num){
        this->cost=cost;
        this->num=num;
    };
};

bool operator< (const node &node1,const node &node2){
    return node1.cost < node2.cost;
};

bool operator> (const node &node1,const node &node2){
    return node1.cost > node2.cost;
};

void shortest(int **lines,int **dist,int N){
    priority_queue<node, vector<node>, greater<node> > q;
    for(int dep=1;dep<=N;dep++){    
        for(int i=1;i<=N;i++){
            if(lines[dep][i]!=0)
                q.push(node(lines[dep][i],i));
        }

        while(!q.empty()){
            const node& tmp=q.top();
            int num=tmp.num;
            int cost=tmp.cost;
            q.pop();
            for(int i=1;i<=N;i++){
                if(lines[num][i]!=0&&lines[num][i]!=inf){
                    int alt=cost+lines[num][i];
                    if(dist[dep][i]>alt){
                        dist[dep][i]=alt;
                        q.push(node(alt,i));
                    }
                }
            }
        }
    }
}

int main(){
    int N,M;
    cin>>N>>M;
    int a[M+1],b[M+1],c[M+1];
    for(int i=1;i<=M;i++){
        cin>>a[i]>>b[i]>>c[i];
    }
    int **lines,**dist;
    lines=new int*[N+1];
    dist=new int*[N+1];
    for(int i=1;i<=N;i++){
        lines[i]=new int[N+1];
        dist[i]=new int[N+1];
    }

    for(int i=1;i<=N;i++){
        for(int j=1;j<=N;j++){
            lines[i][j]=inf;
            dist[i][j]=inf;
            if(i==j){
                lines[i][j]=0;
                dist[i][j]=0;
            }
        }
    }    
    for(int i=1;i<=M;i++){
        lines[a[i]][b[i]]=c[i];
        lines[b[i]][a[i]]=c[i];
        dist[a[i]][b[i]]=c[i];
        dist[b[i]][a[i]]=c[i];
    }
    shortest(lines,dist,N);
    int count=M;
    for(int i=1;i<=M;i++){
        bool inc=false;
        for(int j=1;j<=N;j++){
            for(int k=1;k<=N;k++){
                if(dist[j][a[i]]+lines[a[i]][b[i]]+dist[b[i]][k]==dist[j][k])
                    inc=true;
            }
        }
        if(inc)count--;
    }
    cout<<count<<endl;
    return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
using namespace std;
typedef long long ll;
ll mod = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)
int main(){
    int a, b;
    cin >> a >> b;
    cout << max({a+b, a-b, a*b}) << endl;
    return 0;
}

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

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

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

ll dp[101010];

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

    ll N, K;
    cin >> N >> K;
    vector<ll> a(N);
    REP(i, N) cin >> a[i];

    REP(i, 101010) dp[i] = 0;
    REP(i, 101010){
    	if(!dp[i]){
    		REP(j, N){
    			if(i+a[j]<101010) dp[i+a[j]] = 1;
    		}
    	}
    }

    cout << (dp[K] ? "First" : "Second") << endl;
    return 0;
}

Measured memory_bytes: 1024
//
//  main.cpp
//  codeforces
//
//  Created by cfhaiteeh on 29/5/2018.
//  Copyright © 2018 cfhaiteeh. All rights reserved.
//

#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <vector>
#define  LL long long

using namespace  std;
int n,k;
int ai[56][56];
int bi[5];
void init(){
   
}


int ans;
void play(){
    memset(ai,0,sizeof(ai));
    int sum=bi[1]+bi[2]+bi[3]+bi[4];
    for(int i=1;i<=50;i++){
        for(int j=1;j<=50;j++){
            for(int k=1;k<=4;k++){
                if(bi[k]>0){
                    if(k!=ai[i][j-1]&&k!=ai[i-1][j]){
                        ai[i][j]=k;
                        sum--;
                        bi[k]--;
                        break;
                    }
                    else{
                        continue;
                    }
                }
                if(ai[i][j]>0)break;
               
            }
         
        }
    }
}
void pri(){
   
}
struct he1 {
    int x;
    int id;
}need[100];
int vvv[100];
bool cmp1(he1 a,he1 b){
    return a.x>b.x;
}
int main() {
    int a,b;
    while(scanf("%d%d",&a,&b)!=EOF){
        if(a<=8&&b<=8)printf("Yay!\n");
        else printf(":(\n");
    }

    
    return 0;
}


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

const int INF = 1<<29;
using Edge = P;
using Graph = vector<vector<Edge>>;

Graph G;
set<P> use;

vector<ll> Dijkstra(int s){
    vector<ll> dist((int)G.size(), INF);
    vector<vector<int>> prev((int)G.size());
    dist[s] = 0;
    priority_queue<P, vector<P>, greater<P>> que;
    que.push({0,s});
    while(!que.empty()){
        auto cur = que.top(); que.pop();
        int cur_dist = cur.first;
        int v = cur.second;
        if(cur_dist > dist[v]) continue;
        for(auto e : G[v]){
            if(dist[e.first] > dist[v] + e.second){
                dist[e.first] = dist[v] + e.second;
                que.push({dist[e.first], e.first});
                prev[e.first].clear();
                prev[e.first].push_back(v);
            }else if(dist[e.first] == dist[v] + e.second){
                prev[e.first].push_back(v);
            }
        }
    }
    for(int v = 0; v < (int)G.size(); ++v){
        for(auto u : prev[v]){
            use.insert(make_pair(min(u, v), max(u, v)));
        }
    }
    return dist;
}


int main(){
    int n, m; cin >> n >> m;
    G.resize(n);
    rep(i,m){
        int a, b, c; cin >> a >> b >> c;
        --a, --b;
        G[a].push_back(P(b,c));
        G[b].push_back(P(a,c));
    }
    for(int v = 0; v < n; v++) Dijkstra(v);
    cout << m - (int)use.size() << endl;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define mp make_pair
#define ff first
#define ss second
#define pb push_back
#define w(x) scanf("%d",&x);while(x--)
#define rep(i,a,b) for(i=a;i<=b;i++)
#define ios ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pi 2*acos(0.0)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
typedef vector<int> vi;

long long  mod=1e9+9,ans=0,n;
const int N=100000;
int t,i,j,cs=0,a,b;
string s;

int main()
{
    cin>>n;
    ans=1000*(n/500);
    n=n%500;
    ans+=5*(n/5);
    cout<<ans<<endl;

}




Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int MAX=605;
int n,fin;
char s1[MAX][MAX],s2[MAX][MAX];
int ifsym(){
    for(int i=0;i<n;i++) for(int j=0;j<n;j++) if(s2[i][j]!=s2[j][i]) return 0;
    return 1;
}
int main(){
    scanf("%d",&n);
    for(int i=0;i<n;i++) scanf("%s",s1[i]);
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++) for(int k=0;k<n;k++) s2[(j+i)%n][k]=s1[j][k];
        fin+=ifsym()*n;
    }
    printf("%d\n",fin);
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
string s;
int a[100005],Max;
int main(){
    cin >> s;
    for(int i=0;i<s.length();i++){
        if(s[i]==s[i+1]){
            cout << i+1 << " " << i+2;
            a[1]=1;
            break;
        }
        if(s[i]==s[i+2]){
            cout << i+1 << " " << i+3;
            a[1]=1;
            break;
        }
    }
    if(a[1]!=1) cout << -1 << " " << -1;
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <cstring>
#include <iomanip>
#include <utility>

#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n) for(int i=1;i<=(n);i++)
#define lol long long
#define mp make_pair
#define fi first
#define se second
#define pu push_back
#define SYOU(x) setprecision(x+1)
#define abs(x,y) (max(x,y)-min(x,y))

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;

using namespace std;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int a,b;
    cin>>a>>b;

    printf("%d %d %.8lf\n",a/b,a%b,(double)a/(double)b);
    return 0;
}



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

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

    string str;
    int r, p, s, i;
    cin >> r >> s >> p;
    cin >> str;

    vector <bool> visited(n, false);

    int ans = 0;
    string checker = "";
    for(i = 0; i < k; i++)
    {
    	if(str[i] == 'r')
    	{
    		ans = ans + p;
    		checker.push_back('p');
    	}
    	else if(str[i] == 'p') 
    	{
    		ans = ans + s;
    		checker.push_back('s');
    	}
    	else if(str[i] == 's') 
    	{
    		ans = ans + r;
    		checker.push_back('r');
    	}
    }

    for(i = k; i < n; i++)
    {
    	if(str[i] == 'r' && checker[i - k] != 'p')
    	{
    		ans = ans + p;
    		checker.push_back('p');
    	}
    	
    	else if(str[i] == 'p' && checker[i - k] != 's')
    	{
    		ans = ans + s;
    		checker.push_back('s');
    	}
    	
    	else if(str[i] == 's' && checker[i - k] != 'r')
    	{
    		ans = ans + r;
    		checker.push_back('r');
    	}
    	else
    		checker.push_back('.');
    }
    cout << ans << endl;
    // cout << checker << endl;
}

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

using namespace std;

#define LOG(...) fprintf(stderr, __VA_ARGS__)
//#define LOG(...)
#define FOR(i, a, b) for(int i=(int)(a); i<(int)(b); ++i)
#define REP(i, n) for(int i=0; i<(int)(n); ++i)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))
#define SQ(n) (n) * (n)

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

int main() {
  int n;
  while(cin >> n) {
    int cnt = 0;
    REP(a, 10) REP(b, 10) REP(c, 10) REP(d, 10){
      if(a + b + c + d == n) cnt++;
    }
    cout << cnt << endl;
  }
}

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

long long INF = 1LL << 60;
const int N_MAX = 1e5;
const int W_MAX = 1e5;
long long int dp[W_MAX+1];
vector<int> h(N_MAX, 0);

int main(){
  int N, W; cin >> N >> W;
  
  dp[0] = 0;
  for(int i = 0; i < N; i++){
    int w, v; cin >> w >> v;
    for(int j = W; j >= w; j--){
      dp[j] = max(dp[j], dp[j - w] + v);
    }
  }
  
  cout << dp[W] << endl;
}

Measured memory_bytes: 1408
#include <stdio.h>
#include <math.h>

int pow(int a,int b)
{
    for(int i=0;i<b;i++)
    {
        a*=10;
    }
    return a;
}

int main()
{
    int a,b;
    scanf("%d%d",&a,&b);
    int blength=log10(b)+1;
    a=pow(a,blength);
    int n=a+b;
    int x=sqrt(n);
    if(n==x*x) printf("Yes\n");
    else printf("No\n");
}

Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<math.h>
#include<queue>
#include<vector>
#include<climits>
#include<map>
#include<string>
#include<functional>
#include<iomanip>
#include<deque>
#include<random>
#include<set>
#include<bitset>

using namespace std;
typedef long long ll;
typedef double lldo;
#define mp make_pair
#define pub push_back
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
ll gcd(ll a, ll b) { if (a % b == 0) { return b; } else  return gcd(b, a % b); }
ll lcm(ll a, ll b) { if (a == 0) { return b; }return a / gcd(a, b) * b; }
template<class T>ll LBI(vector<T>& ar, T in) { return lower_bound(ar.begin(), ar.end(), in) - ar.begin(); }
template<class T>ll UBI(vector<T>& ar, T in) { return upper_bound(ar.begin(), ar.end(), in) - ar.begin(); }

ll n, a, b;

int main() {
	cin >> n >> a >> b;
	if (n % (a + b) <= a) {
		cout << (n / (a + b)) * a + n % (a + b) << endl;
	}
	else {
		cout << (n / (a + b) + 1) * a << endl;
	}
	return 0;
}

Measured memory_bytes: 256
input = raw_input

n, m = map(int, input().split(" "))
a_list = map(int, input().split(" "))

suma = sum(a_list)
th = float(suma) / (4*m)

count = 0
for a in a_list:
    if a * 4* m >= suma:
        count += 1
if count >= m:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 28012
import sys
input = sys.stdin.readline
N = int(input())
T, A = map(int, input().split())
array = list(map(int, input().split()))
ans = abs(A - (T - (array[0] * 0.006)))
ans_num = 1
for i in range(1,N):
    if abs(A - (T - (array[i] * 0.006))) <= ans:
        ans = abs(A - (T - (array[i] * 0.006)))
        ans_num = i + 1
print(ans_num)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#ifdef DEBUG
    #define debug(...) printf(__VA_ARGS__)
#else
    #define debug(...) (void)0
#endif
#define mp make_pair
#define pb push_back
#define LL long long
#define pii pair<int,int>
#define PII pair<long long, long long>
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
const int inf = 0x7fffffff; //beware overflow
const LL INF = 0x7fffffffffffffff; //beware overflow
#define mem(x, y) memset(x, (y), sizeof(x) );
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
template<typename A, typename B>
ostream& operator <<(ostream &s, const pair<A,B> &p) {
     return s<<"("<<p.first<<","<<p.second<<")";
}
template<typename T>
ostream& operator <<(ostream &s, const vector<T> &c) {
    s << "[ ";
    for (auto it : c) s << it << " ";
    s << "]";
    return s;
}
template<typename T>
ostream& operator << (ostream &o, const set<T> &st) {
    o << "{";
    for (auto it=st.begin(); it!=st.end(); it++) o << (it==st.begin() ? "" : ", ") << *it;
    return o << "}";
}
template<typename T1, typename T2>
ostream& operator << (ostream &o, const map<T1, T2> &mp) {
    o << "{";
    for (auto it=mp.begin(); it!=mp.end(); it++) {
        o << (it==mp.begin()?"":", ") << it->fi << ":" << it->se;
    }
    o << "}";
    return o;
}
inline LL getint(){
   LL _x=0,_tmp=1; char _tc=getchar();
   while( (_tc<'0'||_tc>'9')&&_tc!='-' ) _tc=getchar();
   if( _tc == '-' ) _tc=getchar() , _tmp = -1;
   while(_tc>='0'&&_tc<='9') _x*=10,_x+=(_tc-'0'),_tc=getchar();
   return _x*_tmp;
}
#define maxn 200005
int b[maxn],a[maxn];
int main() {
    int n = getint();
    int cur = 2+(n-1)*(n);
    for(int i=0;i<n;i++) {
        int x;scanf("%d", &x); x--;
        a[x] = 1+n*x; b[x] = cur-a[x];
        cur++;
    }
    for(int i=0;i<n;i++)printf("%d%c", a[i], i==n-1?'\n':' ');
    for(int i=0;i<n;i++) printf("%d%c", b[i], i==n-1?'\n':' ');
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
typedef long long ll;
const int N = 3e5 + 54;

using std::cin;
using std::cout;

inline void up(int &x, int y) { x < y ? x = y : 0; }
inline void down(int &x, int y) { x > y ? x = y : 0; }
inline int max(const int x, const int y) { return x > y ? x : y; }
inline int min(const int x, const int y) { return x < y ? x : y; }

int n, x;
struct seq {
	int s[N], tot, v[N];
	ll ans;
	seq() { tot = 0; memset(s, 0, sizeof s); }
	inline int lowbit(int x) { return x & -x; }
	inline void insert(int x) { for (; x <= n; x += lowbit(x)) ++s[x]; }
	inline int query(int x, int ret = 0) {for (; x; x -= lowbit(x)) ret += s[x]; return ret; }
	inline void add(int x) { v[++tot] = x; }
	inline void calc() { ans = 0; for (int i = 1; i <= tot; ++i) ans += i - 1 - query(v[i] - 1), insert(v[i]); }
} P, Q, R;

int main() {
    std::ios::sync_with_stdio(false), std::cin.tie(0);
    cin >> n;
    for (int i = 1; i <= n; ++i) {
    	cin >> x;
    	if (i & 1) {
    		if (x & 1) P.add(x);
    		else return cout << "No" << '\n', 0;
		} else {
			if (x & 1) return cout << "No" << '\n', 0;
			else Q.add(x);
		}
		R.add(x);
	}
    P.calc(), Q.calc(), R.calc();
    if (R.ans % 3 != 0) return cout << "No" << '\n', 0;
    if (R.ans != (P.ans + Q.ans) * 3) return cout << "No" << '\n', 0;
    cout << "Yes" << '\n';
	return 0;
}



Measured memory_bytes: 9520
using System;

class Program
{
    static void Main()
    {
        var K = int.Parse(Console.ReadLine());
        var q = 7 % K;
        var result = 1;

        while (true)
        {
            if (q == 0)
            {
                break;
            }
            if (K < result)
            {
                result = -1;
                break;
            }
            q = (10 * q + 7) % K;
            result++;
        }
        Console.WriteLine(result);
    }
}


Measured memory_bytes: 27168
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    n=int(input())
    for a in range(n//4+1,3501):
        for b in range(n*a//(4*a-n),3501):
            if 4*a*b-n*(a+b)>0 and n*a*b%(4*a*b-n*(a+b))==0:
                print(a,b,n*a*b//(4*a*b-n*(a+b)))
                sys.exit()

if __name__=='__main__':
    main()

Measured memory_bytes: 38896
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>

typedef long long ll;
using namespace std;

int main(){
    int N;
    ll D, A;
    cin >> N >> D >> A;
    vector<pair<ll, ll>> XHP(N);
    for (int i = 0; i < N;i++){
        cin >> XHP[i].first >> XHP[i].second;
        XHP[i].second = (XHP[i].second + A - 1) / A;
    }

    sort(XHP.begin(), XHP.end());

    ll num = 0, ans = 0;
    queue<pair<ll,ll>> que;
    for (int i = 0; i < N; i++)
    {
        while(!que.empty() && que.front().first < XHP[i].first){
            num -= que.front().second;
            que.pop();
        }

        XHP[i].second -= num;

        if(XHP[i].second <= 0)
            continue;

        ans += XHP[i].second;
        que.push(make_pair(XHP[i].first + 2*D, XHP[i].second));
        num += XHP[i].second;
    }
    cout << ans << endl;
}

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

using namespace std;

const int MAXN = 1005;

string s[MAXN];

int n, L;

int main()
{
	ios::sync_with_stdio(false);
	cin >> n >> L;
	for (int i = 1; i <= n; i++)
		cin >> s[i];
	sort(s + 1, s + n + 1);
	for (int i = 1; i <= n; i++)
		cout << s[i];
	cout << endl;
	return 0;	
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int SIZE = 200005;

int n, m;
int A[SIZE], B[SIZE], C[SIZE];
int main(){
	cin>>n>>m;
	for(int i = 0; i < m; i ++)
		cin>>A[i]>>B[i];

	for(int i = 0; i < m; i ++)
		if(A[i] == 1)C[B[i]] = 1;

	bool ans = false;
	for(int i = 0; i < m; i ++){
		if(B[i] == n&&C[A[i]] == 1)ans = true;
		if(ans)break;
	}

	if(!ans)cout<<"IM";
	cout<<"POSSIBLE"<<endl;
	return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll MOD = 1000000007;
const long long INF = 1LL << 60;

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

int main()
{
    int n; cin >> n;
    set<ll> s;
    for(int i=0;i<n;i++){
        int j;cin >> j;
        s.insert(j);
    }
    if(s.size() == n)cout << "YES" << endl;
    else cout << "NO" << endl;
}
    

Measured memory_bytes: 9600