akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i = 0; i < (n); i++)

int main(){
    int N;
    cin >> N;
    vector<int> A(N);
    bool ans = true;
    rep(i,N){
        cin >> A.at(i);
        if (A.at(i) % 2 == 0){
            if (!(A.at(i) % 3 == 0 || A.at(i) % 5 == 0)){
                ans = false;
            }
        }
    }
    cout << (ans ? "APPROVED" : "DENIED") << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
#include <math.h>
#include <string>
#include <sstream>
#include <stack>
#include <deque>
#define pb push_back
#define make make_pair
#define kaku(a) cout << a << endl
#define isort(a) sort(a.begin(),a.end())

using namespace std;

#define ll long long
#define rep(i,n) for(ll i=0;i<n;i++)
#define PI 3.14159265359
long long gcd(long long a,long long b){ return b==0?a:gcd(b,a%b);}
long long lcm(long long a,long long b){ return a/gcd(a,b)*b;}

typedef pair<ll,ll> Pair;
const ll inf =1000000007;

//繰り返し
ll RepeatSquaring(ll N, ll P, ll M){
    if(P==0) return 1;
    if(P%2==0){
        ll t = RepeatSquaring(N, P/2, M);
        return t*t % M;
    }
    return N * RepeatSquaring(N, P-1, M);
}

vector< ll > divisor(ll n) {
    vector<ll> ret;
    for (ll i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n) ret.push_back(n / i);
        }
    }
    sort(begin(ret), end(ret));
    return (ret);
}

ll n,k;

ll cal(ll x) {  // (K/x)^N
    int p = n;
    x = 1LL * k / x;
    x %= inf;
    ll res = 1;
    while (p > 0) {
        if (p & 1) res = (x * res) % inf;
        x = x * x % inf;
        p >>= 1;
    }
    return res;
}

void esolve(){
    cin >> n >> k;
    ll ans=0;
    ll d[k+1];
    rep(i,k+1) d[i]=0;
    for(ll i=k;i>=1;i--){
        vector<ll> motu=divisor(i);
        ll score=cal(i);
        score%=inf;
        ll extra=0;
        for(ll j=2*i;j<=k;j+=i){
            extra+=d[j];
            extra%=inf;
        }
        d[i]=(score-extra+inf)%inf;
    }
    for(ll i=1;i<=k;i++){
        ans+=i*d[i];
        ans%=inf;
    }
    kaku(ans);
}
int main(){
    esolve();
}

Measured memory_bytes: 4384
#include <stdio.h>
int main(void){
    int N, i, j, k, ans = 0;
    scanf("%d", &N);
    int d[N];
    for (i = 0; i < N; i++) {
        scanf("%d", &d[i]);
    }
    for (j = 0; j < N - 1; j++) {
        for (k = j + 1; k < N; k++) {
            ans += d[j] * d[k];
        }
    }
    printf("%d", ans);
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}void pr(){ln;}
template<class A,class...B>void pr(const A &a,const B&...b){cout<<a<<(sizeof...(b)?" ":"");pr(b...);}
template<class A>void PR(A a,ll n){rep(i,n)cout<<(i?" ":"")<<a[i];ln;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[8]={-1,0,1,0,-1,-1,1,1},dy[8]={0,1,0,-1,-1,1,1,-1};
typedef pair<ll,ll> P;

void Main() {
  ll x,y;
  cin >> x >> y;
  rep(i,111) {
    rep(j,111) {
      if(i+j==x&&i*2+j*4==y) {
        pr("Yes");
        return;
      }
    }
  }
  pr("No");
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


Measured memory_bytes: 3652
'use strict';
(function(input){
  input=input.trim().split(/\s+/).map(x=>x-0);
  const N=input.shift();
  
  function Node(id){
    var t=this;
    t.index=id;
    t.connected=[];
    t.depth='not yet scanned';
    t.depth2='not yet scanned';
  }
  
  const nodes=new Array(N+1).fill(0).map((x,i)=>new Node(i));
  nodes[0]='zero';
  
  for(let i=0;i<N-1;i++){
    let u=nodes[input[2*i]];
    let v=nodes[input[2*i+1]];
    u.connected.push(v);
    v.connected.push(u);
  }
  
  const stack=[1];
  var parentsDepth=-1;
  var deepest=nodes[1];
  
  while(stack.length>0){
    let i=stack[stack.length-1];
    //console.log(i);
    let n=nodes[i];
    if(n.depth==='not yet scanned')
      n.depth=parentsDepth+1;
    parentsDepth=n.depth;
    if(n.depth>deepest.depth)
      deepest=n;
    if(n.connected.length>0){
      let c=n.connected[n.connected.length-1];
      if(c.depth==='not yet scanned'){
        stack.push(c.index);
        n.connected.pop();
        continue;
      }else{
        n.connected.pop();
        continue;
      }
    }else stack.pop();
  }
  //console.log(deepest);
  
  for(let i=0;i<N-1;i++){
    let u=nodes[input[2*i]];
    let v=nodes[input[2*i+1]];
    u.connected.push(v);
    v.connected.push(u);
  }
  
  stack.push(deepest.index);
  
  parentsDepth=-1;
  
  while(stack.length>0){
    let i=stack[stack.length-1];
    let n=nodes[i];
    if(n.depth2==='not yet scanned')
      n.depth2=parentsDepth+1;
    parentsDepth=n.depth2;
    if(n.depth2>deepest.depth2)
      deepest=n;
    if(n.connected.length>0){
      let c=n.connected[n.connected.length-1];
      if(c.depth2!=='not yet scanned'){
        n.connected.pop();
        continue;
      }else{
        stack.push(c.index);
        continue;
      }
    }else stack.pop();
  }
  //console.log(deepest);
  
  if(deepest.depth2%3===1)
    console.log('Second');
  else console.log('First');
})(require('fs').readFileSync('/dev/stdin','utf8'));


Measured memory_bytes: 145832
import collections
import sys

def make_divisors(n):  # 任意の整数の約数をリストで返す関数
    divisors = []
    for i in range(1, int(n ** 0.5) + 1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n // i)

    divisors.sort()
    return divisors

#####

X = int(input())

if X == 0:
  print("0 0")
  sys.exit()

x = abs(X)
c = make_divisors(x)
c.append(1)
c = sorted(c)
#print(c)


for i in range(len(c)):
  B = (c[i] // 2) * -1
  A = B + c[i]
  while True:
    Z = A**5 - B**5
    #print(A,B,c[i],Z)
    if Z == x:
      if X < 0:
        print(B,A)
      else:
        print(A,B)
      sys.exit()

    if Z > x:
      break    
      
    A += 1
    B += 1



  

Measured memory_bytes: 84048
#pragma region
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <list>
#include <iomanip>
#include <cstdint>
#include <bitset>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define rrep(i, s) for (int(i) = (s) - 1; (i) >= 0; --(i))
#define all(x) x.begin(),x.end()

#pragma region UnionFind
struct UnionFind
{
	vector<int> par;

	UnionFind(int n) : par(n, -1) {}
	void init(int n) { par.assign(n, -1); }

	int root(int x)
	{
		if (par[x] < 0) return x;
		else return par[x] = root(par[x]);
	}

	bool issame(int x, int y)
	{
		return root(x) == root(y);
	}

	bool merge(int x, int y)
	{
		x = root(x); y = root(y);
		if (x == y) return false;
		if (par[x] > par[y]) swap(x, y);
		par[x] += par[y];
		par[y] = x;
		return true;
	}

	int size(int x)
	{
		return -par[root(x)];
	}
};
#pragma endregion
#pragma region GCD
ll gcd(ll a, ll b)
{
	if (b == 0)return a;
	return gcd(b, a%b);
}
#pragma endregion
#pragma region LCM
ll lcm(ll a, ll b)
{
	return a / gcd(a, b) * b;
}
#pragma endregion
#pragma region chmin
template<class T> inline bool chmin(T& a, T b)
{
	if (a > b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma region chmax
template<class T> inline bool chmax(T& a, T b)
{
	if (a < b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma endregion


int main()
{
	int n; cin >> n;
	vector<int> a(n + 2);
	rep(i, n)cin >> a[i + 1];
	int sum = 0;
	rep(i, n + 1)sum += abs(a[i + 1] - a[i]);
	for (int i = 1; i <= n; ++i)
	{
		int res = sum - abs(a[i] - a[i - 1]) - abs(a[i + 1] - a[i]) + abs(a[i + 1] - a[i - 1]);
		cout << res << endl;
	}
}

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

typedef long long ll;

template <class T>
void printArray(vector<T> arr) {
	for (T a: arr) cout << a << " ";
	cout << '\n';
}

void printVerdict(bool verdict) {
	cout << (verdict ? "YES": "NO") << '\n';
}

void printDecimal(double d) {printf("%.9f\n", d);}

int main() {
	std::ios_base::sync_with_stdio(false);
	cin.tie(0);
	int n; cin >> n; 
	int a[n];
	for (int i = 0; i<n; i++) cin >> a[i];
	int ret = 0;
	for (int i = 0; i<n-1; i++) {
		for (int j = i+1; j<n; j++) {
			ret += a[i] * a[j];
		}
	}
	cout << ret << '\n';
}



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

#define all(v) v.begin(), v.end()
#define V vector
#define P pair
typedef long long ll;

int main() {
    int n; cin >> n;
    V<ll> a(n + 2, 0);
    ll sum = 0;
    for(int i = 1; i <= n; i++){
        cin >> a[i];
        sum += abs(a[i] - a[i - 1]);
    }
    sum += abs(a[n]);

    for(int i = 1; i <= n; i++){
        cout << sum + abs(a[i - 1] - a[i + 1]) - (abs(a[i - 1] - a[i]) + abs(a[i] - a[i + 1])) << endl;

    }
}


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

#define Fast ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0)
#define FO freopen("in.txt", "r", stdin)
#define FC freopen("out.txt", "w", stdout)
#define aise cout<<"aise"<<endl
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define mp make_pair
#define ll long long
#define all(x) x.begin(), x.end()
#define mset(v, a) memset(v, a, sizeof(v))
#define pll pair< ll, ll >
#define pdd pair< double, double >
#define ff first
#define ss second
#define pi acos(-1.0)
#define mxN 2010
#define inf 1e14
#define MOD 1000000007

int main()
{

    string x,y;
    cin >> x >> y;
    sort(all(x));
    sort(all(y));
    reverse(all(y));
    if(x < y) cout << "Yes";
    else cout << "No";
}




Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>

typedef struct node{
    int x;
    int y;
    int value;
    struct node* next;
}node;

int main(){
    int h, w;
    scanf("%d%d", &h, &w);
    char map[h+2][w+2];
    for(int i=0; i<h+2; i++){
        for(int j=0; j<w+2; j++){
            map[i][j] = '#';
        }
    }
    node start;
    node * l = &start;
    for(int i=1; i<=h; i++){
        char str[w+1];
        scanf("%s", str);
        for(int j=1; j<=w; j++){
            map[i][j] = str[j-1];
            if(map[i][j] == '#'){
                l->next = (node*)malloc(sizeof(node));
                l = l->next;
                l->y = i;
                l->x = j;
                l->value = 0;
                l->next = NULL;
            }
        }
    }
    node * n = start.next;
    while(n != NULL){
        if(map[n->y-1][n->x] == '.'){
            map[n->y-1][n->x] = '#';
            l->next = (node*)malloc(sizeof(node));
            l = l->next;
            l->y = n->y-1;
            l->x = n->x;
            l->value = n->value + 1;
            l->next = NULL;
        }
        if(map[n->y][n->x+1] == '.'){
            map[n->y][n->x+1] = '#';
            l->next = (node*)malloc(sizeof(node));
            l = l->next;
            l->y = n->y;
            l->x = n->x+1;
            l->value = n->value + 1;
            l->next = NULL;
        }
        if(map[n->y+1][n->x] == '.'){
            map[n->y+1][n->x] = '#';
            l->next = (node*)malloc(sizeof(node));
            l = l->next;
            l->y = n->y+1;
            l->x = n->x;
            l->value = n->value + 1;
            l->next = NULL;
        }
        if(map[n->y][n->x-1] == '.'){
            map[n->y][n->x-1] = '#';
            l->next = (node*)malloc(sizeof(node));
            l = l->next;
            l->y = n->y;
            l->x = n->x-1;
            l->value = n->value + 1;
            l->next = NULL;
        }
        n = n->next;
    }
    printf("%d", l->value);

    return 0;
}

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

int main() {
  int N;
  cin >> N;
  for(int i = 0; i < N; i++){
    string color;
    cin >> color;
    if(color == "Y"){
      cout << "Four" << endl;
      break;
    }
    if(i == (N-1))cout << "Three" << endl;
  }
}


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

int N, cnt, R[1 << 20];
string S[1 << 20];

int main() {
	cin >> N;
	for (int i = 1; i <= N; i++) cin >> S[i];
	for (int i = 1; i <= N; i++) {
		int cnt2 = 0;
		for (int j = 0; j < S[i].size(); j++) {
			if (S[i][j] == '(') { cnt++; cnt2++; }
			else { cnt--; cnt2--; }
		}
		R[i] = cnt2;
	}
	if (cnt != 0) {
		cout << "No" << endl;
		return 0;
	}

	vector<pair<int, int>> V1, V2;
	for (int i = 1; i <= N; i++) {
		if (R[i] >= 0) {
			int dep = 0, depmin = 0;
			for (int j = 0; j < S[i].size(); j++) {
				if (S[i][j] == '(') dep++;
				else dep--;
				depmin = min(depmin, dep);
			}
			V1.push_back(make_pair(depmin, dep));
		}
		else {
			int dep = 0, depmin = 0;
			for (int j = S[i].size() - 1; j >= 0; j--) {
				if (S[i][j] == ')') dep++;
				else dep--;
				depmin = min(depmin, dep);
			}
			V2.push_back(make_pair(depmin, dep));
		}
	}
	sort(V1.begin(), V1.end()); reverse(V1.begin(), V1.end());
	sort(V2.begin(), V2.end()); reverse(V2.begin(), V2.end());

	bool flag = false; int height = 0;
	for (int i = 0; i < V1.size(); i++) {
		if (height + V1[i].first < 0) flag = true;
		height += V1[i].second;
	}

	height = 0;
	for (int i = 0; i < V2.size(); i++) {
		if (height + V2[i].first < 0) flag = true;
		height += V2[i].second;
	}

	if (flag == true) cout << "No" << endl;
	else cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 47872
#include<bits/stdc++.h>
using namespace std;
long long n,x,ans;
void dfs(long long a,long long b){
    if(a%b==0){
        ans+=a*2-b;//不可再拆
        return;
    }
    ans+=a/b*b*2;//拆成更小的
    dfs(b,a%b);//更小的
    return;
}
int main(){
    cin>>n>>x;
    if(x>=n-x)dfs(x,n-x);
    else dfs(n-x,x);
    cout<<ans+n<<endl;//最大的两条边
    return 0;
}


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

using namespace std;

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

const int N = (int)1e5 + 7;
const int inf = (int)1e9 + 7;

int n;
int a[N], b[N];
int cnt[4];

int main(){
  scanf("%d", &n);
  for(int i = 1; i <= n; ++i){
    scanf("%d", a + i);
    cnt[a[i] % 4]++;
  }
  for(int i = 2; i <= n; i += 2){
    if(cnt[0]){
      b[i] = 4;
      --cnt[0];
    }
  }
  for(int i = 1; i <= n; i++){
    if(b[i]){
      continue;
    }
    if(cnt[1]){
      b[i] = 1;
      --cnt[1];
    } else if(cnt[3]){
      b[i] = 3;
      --cnt[3];
    } else{
      b[i] = 2;
      --cnt[2];
    }
  }
  for(int i = 1; i < n; ++i){
    if((b[i] * b[i + 1]) % 4 != 0){
      cout << "No";
      return 0;
    }
  }
  cout << "Yes";
  return 0;
}


Measured memory_bytes: 1024
import bisect

N = int(input())
A = [-int(input()) for i in range(N)]
X = []
for i in range(N):
    a = A[i]
    idx = bisect.bisect(X, a)
    if idx == len(X):
        X.append(a)
    else:
        X[idx] = a
print(len(X))

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

using namespace std;

int main() {
    int H, W;

    while (cin >> H >> W) {
        if (H == 0 && W == 0) break;

        for (int h = 0; h < H; h++) {
            for (int w = 0; w < W; w++) {
                cout << '#';
            }
            cout << endl;
        }

        cout << endl;
    }

    return 0;
}


Measured memory_bytes: 3092
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<ctime>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<queue>
#include<cstring>
#include<map>
#include<vector>
#include<set>
#define rep(i,j,k) for(register int i = j; i <= k; i++) 
#define dow(i,j,k) for(register int i = j; i >= k; i--)
#define fi first
#define se second
//#define P pair<ull,ull>
//#define PP pair<int,pair<int,int> >
//#define mp(a,b) make_pair(a,b)
#define ll long long
#define ull unsigned long long
using namespace std;
 
inline int read() { 
	int s = 0, t = 1; char c = getchar();
	while( !isdigit(c) ) { if( c == '-' ) t = -1; c = getchar(); }
	while( isdigit(c) ) s = s * 10 + c - 48, c = getchar();
	return s * t;
}

const int N = 1e5+7, p = 1e9+7;
struct edge{ int to, v, nxt; } e[N<<1];
int head[N], cnt = 0;
inline void add(int v,int y,int x) { 
	e[++cnt].to = y, e[cnt].v = v, e[cnt].nxt = head[x], head[x] = cnt;
	e[++cnt].to = x, e[cnt].v = v, e[cnt].nxt = head[y], head[y] = cnt;
}
ll ans = 0;
int n, q[N], sz[N], g[N], f[N], l, minl = N;
#define ez(i,j) for(register int i = head[j]; i; i=e[i].nxt)
#define to e[i].to
inline void dfs(int x,int fa=0) {
	sz[x] = 1; 
	ez(i,x) if( to != fa ) dfs(to,x);
	ez(i,x) if( to != fa ) { 
		ans += 2ll * min(n-sz[to],sz[to]) * e[i].v;
		sz[x] += sz[to];
		g[x] = max(sz[to],g[x]);
	}
	g[x] = max(g[x],n-sz[x]);
	if( g[x] < minl ) minl = g[x], f[l=1] = x;
	else if( g[x] == minl ) f[++l] = x;
}

int main() {
	n = read();
	rep(i,1,n-1) add(read(),read(),read()); 
	dfs(1);
	if( l == 2 ) { 
		ez(i,f[1]) if( to == f[2] ) ans -= e[i].v;
	} 
	else { 
		int minl = 1e8;
		ez(i,f[1]) minl = min(minl,e[i].v);
		ans -= minl;
	} 
	cout<<ans<<endl;
	return 0; 
}

Measured memory_bytes: 5888
def bfs(limit)
  queue = [*1..9]
  count = 0

  until queue.empty?
    x = queue.shift
    count += 1

    return x if count == limit

    d = x % 10

    if d == 0
      queue << 10 * x
      queue << 10 * x + 1
    elsif d == 9
      queue << 10 * x + d - 1
      queue << 10 * x + d
    else
      queue << 10 * x + d - 1
      queue << 10 * x + d
      queue << 10 * x + d + 1
    end
  end
end

k = gets.to_i

puts bfs(k)


Measured memory_bytes: 3964
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define All(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;

int main(){
    int N;cin>>N;
    vector<int> a(N+1);
    REP(i, N) cin >> a[i+1];
    vector<int> b(N+1,0);
    int M=0;
    for(int i=N;i>=1;--i){
        int tmp=0;
        for(int j=2*i;j<=N;j+=i){
            tmp+=b[j];
        }
        tmp=(tmp+a[i])%2;
        b[i]=tmp;
        if(b[i]) M++;
    }
    cout<<M<<endl;
    REP(i,N+1) if(b[i]) cout<<i<<" ";
    cout<<endl;
}

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

int main() {
  int n;
  string s;
  cin >> n >> s;
  if (n == 1 || n % 2 == 1) {
    cout << "No" << endl;
    return 0;
  }

  REP(i, n / 2) {
    if (s[i] != s[i + n / 2]) {
    cout << "No" << endl;
    return 0;
    }
  }

  cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#define INF 1 << 30

int min(int a,int b){
  if(a < b){
    return a;
  }
  return b;
}

int main(void){
  int N,M;
  scanf("%d%d",&N,&M);

  int a[N],b[N];
  int c[M],d[M];
  for(int i = 0;i < N;i++) scanf("%d%d",&a[i],&b[i]);
  for(int i = 0;i < M;i++) scanf("%d%d",&c[i],&d[i]);

  for(int i = 0;i < N;i++){
    int dist = INF;
    int num = 1;
    for(int j = 0;j < M;j++){
      if(dist > abs(a[i]-c[j])+abs(b[i]-d[j])){
        dist = abs(a[i]-c[j])+abs(b[i]-d[j]);
        num = j+1;
      }
    }
    printf("%d\n",num);
  }

  return 0;
}

Measured memory_bytes: 128
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define INF 0x6fffffff
#define INFL 0x6fffffffffffffffLL

int main() {
	ll		a,b,c,i,j,k,n,m,x,y,l,r,ans = INF;
	string	s;
	cin >> l >> r;
	for(i=l;i<=min(r,l+2019);i++) {
		for(j=i+1;j<=min(r,i+1+2019);j++) {
			ans = min(ans , i*j%2019);
		}
	}
	//vector<ll>	aa(n);
	//for(i=0;i<n;i++) cin >> aa[i];
	//vector<ll>	dp(n+1,INFL);
	//vector<vector<ll>>	dp2(x , vector<ll>(y,INFL));

	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define rep2(i,n) for(int i=0;i<=n;i++)
#define repr(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define P pair<long long,long long>
#define double long double
#define INF 1e10
#define MOD 1e9+7
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using Graph = vector<vector<int>>;
int fg(int k){
    int sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}
signed main(){
  int N;
  cin>>N;
  int sum=0;
  rep(a,N){
    rep(b,N){
      rep(c,N){
       int x=__gcd(a+1,b+1);
       int y=__gcd(c+1,x);
       sum+=y;
      }
    }
  }
  cout<<sum;
}


Measured memory_bytes: 3632
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#define mod 1000000007 //1e9+7
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 201

const int MAX_P = 123456 * 2; //max
int prime[MAX_P+1];

void Eratosthenes(void){
  for(int i=2;i<=MAX_P;i++)
    prime[i]=true;
  
  for(int i=2;i*i<=MAX_P;i++)
    if(prime[i])  
      for(int j=i;i*j<=MAX_P;j++)
	prime[i*j]=false;
}

void calc(int n){
  int ans = prime[2*n] - prime[n];
  
  printf("%d\n",ans);
}

int main(){
  int n;
  
  Eratosthenes();

  for(int i=0;i<123456*2;i++) prime[i+1] += prime[i];
  
  while(1){
    scanf("%d",&n);
    if(n==0) break;
    calc(n);
  }
  
  return 0;
}

Measured memory_bytes: 4160
#include<iostream>
#include<string>
#include<string.h>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1000000000000 ;
const ll mod=1000003 ;

int main(){
  ll n,k;
  cin >> n >> k;
  pair<ll,ll> p[n];
  rep(i,n)cin >> p[i].first >> p[i].second;
  sort(p,p+n);
  ll sum[n]={};
  sum[0]=p[0].second;
  rep(i,n-1){
    sum[i+1]=sum[i]+p[i+1].second;
  }
  ll x=lower_bound(sum,sum+n,k)-sum;
  cout << p[x].first << endl;
return 0;}

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

vector<pair<ll, ll>> prime_factorize(ll N) {
  vector<pair<ll, ll>> res;
  for (ll a = 2; a*a <= N; a++) {
    if (N % a != 0) continue;
    ll ex = 0;
    while (N % a == 0) {
      ex++;
      N /= a;
    }
    res.push_back({a, ex});
  }
  if (N != 1) res.push_back({N, 1});
  return res;
}

int main() {
  ll N;
  cin >> N;
  const auto &res = prime_factorize(N);
  ll ans = 0;
  for (auto p : res) {
    int tmp = 1;
    int cnt = 0;
    while (cnt + tmp <= p.second) {
      cnt += tmp;
      tmp++;
      ans++;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3604
n=int(input())
count1=0
count2=0
count3=0
count4=0
 
for i in range(n):
  s=input()
  if(s=="AC"):
    count1+=1
  elif(s=="WA"):
    count2+=1
  elif(s=="TLE"):
    count3+=1
  elif(s=="RE"):
    count4+=1
print("AC x",count1)
print("WA x",count2)
print("TLE x",count3)
print("RE x",count4)

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

int main()
{
    int l, r, d, c = 0;
    cin >> l >> r >> d;
    for(int i = l; i <= r; i++){
        if(i % d == 0){
            c++;
        }
    }
    cout << c;

    return 0;
}


Measured memory_bytes: 3560
#include <stdio.h>

int main(void)
{
	int i,n;
	scanf("%d",&n);
	for(i=1;i<=n;i++){
		if(i%3==0||i%10==3)
		printf(" %d",i);
		else if(i/10%10==3)
			printf(" %d",i);
			else if(i/10/10%10==3)
			printf(" %d",i);
			else if(i/10/10/10%10==3)
			printf(" %d",i);
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
#define ll long long
#define x first
#define y second
using namespace std;
main (){
ll n;
cin>>n;
vector<ll>a;
vector<ll>d;
a.resize(n+1);
d.resize(n+1);
for (int i=1;i<=n;i++)
    cin>>a[i];
d[1]=0;
d[2]=abs(a[2]-a[1]);
for (int i=3;i<=n;i++)
    d[i]=min(abs(a[i]-a[i-1])+d[i-1],abs(a[i]-a[i-2])+d[i-2]);
    cout<<d[n];
return 0;}


Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>
#include <algorithm>
using namespace std;
int main() {
	string a, b;
	cin >> a >> b;
	
	if (a.size() > b.size()) {
        std::cout << "GREATER" << std::endl;
	    
	}else if(a.size() < b.size()) {
        std::cout << "LESS" << std::endl;
        
	}else if(a == b){
	    std::cout << "EQUAL" << std::endl;
	    
	}else{
        for (int i = 0; i < a.size(); i++) {
            if(a[i] > b[i]){
                 std::cout << "GREATER" << std::endl;
                 break;
                 
            }
            if(a[i] < b[i]) {
                std::cout << "LESS" << std::endl;
                break;
                
            }
        }
        
	}
	
	return 0;
}

Measured memory_bytes: 256
n=int(input())
s=input()
wc=[0]
ec=[0]
for i in range(n):
    if s[i]=="W":
        wc.append(wc[i]+1)
        ec.append(ec[i])
    else:
        wc.append(wc[i])
        ec.append(ec[i]+1)
ans=10**6
for i in range(1,n+1):
    tmp=0
    
    tmp+=wc[i-1]
    tmp+=ec[n]-ec[i]
    ans=min(tmp,ans)
print(ans)


Measured memory_bytes: 17644
#include<stdio.h>
#include<string.h>
char s[105];
int main()
{
	int i,len,j;
	scanf("%s",s);
	len=strlen(s);
	if(len==2)
	{
		if(s[0]=='C'&&s[1]=='F')
		  printf("Yes");
		else printf("No"); 
		return 0;
	} 
	for(i=0;i<len-1;i++)
	{
		if(s[i]=='C')
		{
			for(j=i+1;j<len;j++)
			{
				if(s[j]=='F')
				{
					printf("Yes");
					return 0;
				}
			}
		}
	}
	printf("No");
	return 0;
}

Measured memory_bytes: 128
n,m=map(int,input().split())
k=["+","-"]
d=[[]for i in range(8)]
for i in range(n):
    a,b,c=map(str,input().split())
    for j in range(2):
        for h in range(2):
            for p in range(2):
                s=4*j+2*h+p
                d[s].append(eval(k[j]+a+k[h]+b+k[p]+c))
h=0
for i in range(8):
    h=max(h,sum(sorted(d[i])[n-m:]))
print(h)

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

t, x, y = 0, 0, 0

for i in range(N):
    tn, xn, yn = map(int, input().split())
    l = abs(x-xn) + abs(y-yn)
    if l > tn - t or (l - (tn - t)) % 2 == 1:
        print('No')
        exit()
    t, x, y = tn, xn, yn
print('Yes')


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

int main()
{
    int n;
    cin >> n;
    int a[n];
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        a[i]--;
    }
    int l = a[0];
    int prev = 0;
    int c = 1;
    while(l != 1) {
        if (c > n) {
            cout << -1;
            return 0;
        }
        l = a[l];
        c++;
    }
    cout << c;
    return 0;
}


Measured memory_bytes: 640
import java.io.IOException;

public class Main {

	public static void main(String[] args) {
		while (true) {
			int n = nextInt();
			if (n == 0) {
				break;
			}

			int[][] cir = new int[n][4];
			int[] above = new int[n];// 上に重なってる円盤

			int[] bitDP = new int[1 << n];

			for (int i = 0; i < n; i++) {
				int x = nextInt();
				int y = nextInt();
				int r = nextInt();
				int c = nextInt();
				cir[i][0] = x;
				cir[i][1] = y;
				cir[i][2] = r;
				cir[i][3] = c;

				for (int j = 0; j < i; j++) {
					// 重なっている円盤があるかの判定
					int jx = cir[j][0] - x;
					int jy = cir[j][1] - y;
					int jr = cir[j][2];
					double dist = Math.sqrt(jx * jx + jy * jy);
					if (dist < r + jr) {
						above[i] += (1 << j);
					}
				}
			}

			int max = 0;
			for (int bit = 0; bit < bitDP.length; bit++) {
				// 到達しうる遷移か
				if (bit != 0 && bitDP[bit] == 0) {
					continue;
				}
				for (int i = 0; i < n; i++) {
					// 円iとjが取り除かれていないかチェック
					if ((bit & (1 << i)) != 0) {
						continue;
					}
					for (int j = i + 1; j < n; j++) {
						// 円iとjが取り除かれていないかチェック
						if ((bit & ((1 << i) + (1 << j))) != 0) {
							continue;
						}
						// iとjの上に載っている円が全部取り除かれている
						if ((above[i] & bit) != above[i] || (above[j] & bit) != above[j]) {
							continue;
						}
						// 色が一緒かどうか
						if (cir[i][3] == cir[j][3]) {
							int newbit = bit + (1 << i) + (1 << j);
							bitDP[newbit] = Math.max(bitDP[newbit], bitDP[bit] + 2);
							max = Math.max(max, bitDP[newbit]);
						}
					}
				}
			}

			System.out.println(max);
			System.gc();
		}
	}

	static int nextInt() {
		int c;
		try {
			c = System.in.read();
			while (c != '-' && (c < '0' || c > '9'))
				c = System.in.read();
			if (c == '-')
				return -nextInt();
			int res = 0;
			while (c >= '0' && c <= '9') {
				res = res * 10 + c - '0';
				c = System.in.read();
			}
			return res;
		} catch (IOException e) {
			e.printStackTrace();
		}
		return -1;
	}

}

Measured memory_bytes: 94668
n, k = list(map(int, input().split()))
mod = int(1e9 + 7)

a, b = 2000, 2000
dp = [[0 for i in range(b+1)] for j in range(a+1)]
for j in range(b+1):
    dp[0][j] = 0
for i in range(a + 1):
    dp[i][0] = 1

for i in range(1, a+1):
    for j in range(1, b+1):
        dp[i][j] = (dp[i-1][j-1] + dp[i-1][j]) % mod


for i in range(1, k+1):
    print(dp[n-k+1][i] * dp[k-1][i-1] % mod)


Measured memory_bytes: 76764
n=int(input())
a=list(map(int,input().split()))
sum=a[0]
if(sum==0):
  opp=1
  sum=1
  for i in a[1:]:
    if(sum*(sum+i)>=0):
      opp+=abs(sum+i)+1
      if(sum<0):sum=1
      else:sum=-1
    else:sum+=i
  opm=1
  sum=-1
  for i in a[1:]:
    if(sum*(sum+i)>=0):
      opm+=abs(sum+i)+1
      if(sum<0):sum=1
      else:sum=-1
    else:sum+=i
  op=min(opm,opp)
else:
  opp=0
  for i in a[1:]:
    if(sum*(sum+i)>=0):
      opp+=abs(sum+i)+1
      if(sum<0):sum=1
      else:sum=-1
    else:sum+=i
  sum=a[0]
  opm=abs(sum)+1
  if(sum>0):sum=-1
  else:sum=1
  for i in a[1:]:
    if(sum*(sum+i)>=0):
      opm+=abs(sum+i)+1
      if(sum<0):sum=1
      else:sum=-1
    else:sum+=i
  op=min(opp,opm)
    
print(op)

Measured memory_bytes: 14216
#include <bits/stdc++.h>
using namespace std;
#define _K ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ld long double
#define ll long long
#define ull unsigned ll
#define pb push_back
#define mod 1e9+7
#define eps 1e-7
#define pi acos(-1)
#define F first
#define S second
#define X real()
#define Y imag()
#define cross(a,b) (conj(a)*(b)).X
#define dot(a,b) (conj(a)*(b)).Y
typedef complex <ld> point ;
typedef vector <point> polygon ;
typedef tuple <int , int , int> line ;
//====================================
int main()
{
	_K
	ll n , x ;
	cin >> n >> x ;
	ll h[n] , ans[n] ;
	for (int i =0 ; i < n ;  cin >> h[i++]);
	ans[0] = 0 ;
	ans[1] = abs(h[1]-h[0]) ;
	for (int i = 2 ; i < n ; i++)
	{
		ans[i] = 1e10 ;
		for (int j = i-1 ; j >= max((ll)0 , i-x) ; j--)
			ans[i] = min(ans[j] + abs(h[i]-h[j]) , ans[i]) ;
	}
	cout << ans[n-1] ;
	return 0;
}

Measured memory_bytes: 1792
import std.stdio;
import std.string;
import std.algorithm;
import std.conv;

void main()
{
	auto N = readln.split[0].to!int;
	int[] yamafuda = readln.split.to!(int[]);
	writeln(yamafuda.to!(string[]).join(" "));
	foreach(i; 1..N)
	{
		auto tefuda = yamafuda[i];
		auto j = i - 1;
		while(j>=0 && yamafuda[j]>tefuda)
		{
			yamafuda[j+1] = yamafuda[j];
			j--;
			yamafuda[j+1] = tefuda;
		}
		writeln(yamafuda.to!(string[]).join(" "));
	}
	
}


Measured memory_bytes: 2572
n = int(input())
for i in range(1,n+1):
    if i % 3 == 0:
        print(" {0}".format(i), end="")
    else:
        x = i
        while x != 0:
            if x % 10 == 3:
                print(" {0}".format(i), end="")
                break;
            x //= 10;
print("")

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

typedef long long ll;

int N;
int A[20];
int x[20][20];
int y[20][20];

int counter(int x) {
    if (x == 0) return 0;
    return counter(x >> 1) + (x & 1);
}

void solve() {
    cin >> N;
    for (int i = 1; i <= N; i++) {
        cin >> A[i];
        for (int j = 1; j <= A[i]; j++) {
            cin >> x[i][j] >> y[i][j];
        }
    }
    int ans = 0;
    for (int bits = 1; bits < (1<<N); bits++) {
        bool ok = true;
        for (int i = 1; i <= N; i++) {
            if (!(bits & (1 << (i-1)))) continue;
            for (int j = 1; j <= A[i]; j++) {
                if (((bits >> (x[i][j]-1)) & 1) ^ y[i][j]) ok = false;
            }
        }
        if (ok) ans = max(ans, counter(bits));
    }
    cout << ans << endl;
}

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<algorithm>
using namespace std;


int main(){
    int n;
    list<int> lst;
    lst.push_back(555);
    while(scanf("%d",&n)!=EOF){
        if(n==0){
            auto itr=lst.begin();
            printf("%d\n",*itr);
            lst.pop_front();
        }else{
            lst.push_front(n);
        }
    }
    return 0;
}

Measured memory_bytes: 1172
#include <algorithm>
#include <array>
#include <bitset>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <queue>

using namespace std;

struct BoolName : numpunct<char> {
  string t, f;
  BoolName (string t = "Yes", string f = "No") : t(t), f(f) {}
  string do_truename() const {return t;}
  string do_falsename() const {return f;}
};

struct Initializer {
  Initializer() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(15) << boolalpha;
    cout.imbue(locale(cout.getloc(), new BoolName));
  }
} initializer;

template<typename T> istream& operator>>(istream &s, vector<T> &v) {
  for (T &t : v) s >> t;
  return s;
}

template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
  for (const T &t : v) s << t << endl;
  return s;
}

void set_bool_name(string t, string f) {
  cout.imbue(locale(cout.getloc(), new BoolName(t, f)));
}

int main() {
  int64_t n, p, res = 1;
  cin >> n >> p;
  if (n == 1) {
    cout << p << endl;
    return 0;
  }
  for (int64_t i = 2; pow(i, n) <= p; ++i) {
    auto q = p;
    for (int j = 0; j < n; ++j) {
      if (q % i) goto next;
      q /= i;
    }
    res = i;
  next:;
  }
  cout << res << endl;
}



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

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

bool isPalindrome(string a){
	// cout<<a<<endl;
	int n = a.size();
	for(int i = 0; i < n; i++){
		if(a[i] != a[n-1-i])return false;
	}
	return true;
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cout<<setprecision(32);

	string s;
	cin>>s;
	int n = s.size();
	if(!isPalindrome(s) || !isPalindrome(s.substr(0, (n - 1)/2)) || !isPalindrome(s.substr((n + 1)/2, (n - 1)/2))){
		cout<<"No"<<endl;
		exit(0);
	}
	cout<<"Yes"<<endl;

	return 0;
}

Measured memory_bytes: 256
k = gets.strip.to_i
a, b = gets.strip.split.map(&:to_i)

if a % k == 0 then
  puts 'OK'
  exit
end

if b % k == 0 then
  puts 'OK'
  exit
end

if b / k - a / k > 0 then
  puts 'OK'
  exit
end

puts 'NG'


Measured memory_bytes: 14284
def gcd(a, b):
    if a < b:
        a, b = b, a
    if b ==  0:
        return a
    r = a % b
    return gcd(b, r) 

def lcm(a, b):
    return a*b // gcd(a, b)

A, B, C, D = map(int, input().split())

l = lcm(C, D)

A = A-1
N_range = B - A
l_sum = (B//l) - (A//l)
c_sum = (B//C) - (A//C)
d_sum = (B//D) - (A//D)
print(N_range - c_sum - d_sum + l_sum)

Measured memory_bytes: 3064
#!venv/bin/python
 
import math
import numpy as np
import random
import copy
import statistics 
import bisect
import heapq
from collections import defaultdict 
import time
import sys
from pprint import pprint

N = int(input())
P = []
for _i in range(N):
    P.append([ int(x) for x in input().split() ])

diff = defaultdict(int)
for i in range(N):
    for j in range(N):
        if i == j:
            continue
        key = "{} - {}".format(P[i][0]-P[j][0], P[i][1]-P[j][1])
        diff[key] += 1

if N == 1:
    print(1)
else:
    key = max(diff.keys(), key=lambda x: diff[x])
    print(N-diff[key])


Measured memory_bytes: 24776
import sys
import itertools

def main():
  x, y, a, b, c = map(int, sys.stdin.buffer.readline().split())
  red = sorted(map(int, sys.stdin.buffer.readline().split()), reverse=True)
  green = sorted(map(int, sys.stdin.buffer.readline().split()), reverse=True)
  colorless = sorted(map(int, sys.stdin.buffer.readline().split()), reverse=True)
  
  apples = sorted(itertools.chain(red[:x], green[:y], colorless), reverse=True)
  print(sum(apples[:x + y]))

main()

Measured memory_bytes: 27500
#include "bits/stdc++.h"
using namespace std;

int main() {
	long long N, K, A, ans = 0;
	static long long SumA[100010] = {}, SumB[100010] = {};
	cin >> N >> K;
	for (int i = 0; i < N; i++) {
		cin >> A;
		SumA[i + 1] = max(SumA[i], SumA[i] + A);
		SumB[i + 1] = SumB[i] + A;
	}
	long long All = SumA[N];
	for (int i = 0; i <= N - K; i++) {
		ans = max(ans, All - (SumA[i + K] - SumA[i]) + max(SumB[i + K] - SumB[i], (long long)0));
	}
	cout << ans;
}

Measured memory_bytes: 1792
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <iostream>
#include<math.h>
using namespace std;

int main()
{
    int a;
    cin>>a;
    cout<<a+pow(a,2)+pow(a,3);

    return 0;
}


Measured memory_bytes: 4152
from sys import stdin
from collections import deque
from operator import itemgetter

N, M = [int(x) for x in stdin.readline().rstrip().split()]
A = [int(x) for x in stdin.readline().rstrip().split()]
A.sort()
A = deque(A)
X = [[int(x) for x in stdin.readline().rstrip().split()] for _ in range(M)]
X.sort(key=itemgetter(1), reverse=True)
D = []
for b, c in X:
    if len(D) < N:
        D.extend([c] * b)
    else:
        break
D = deque(D)

for i in range(len(D) if len(D) < len(A) else len(A)):
    a = A.popleft()
    c = D.popleft()
    if a < c:
        A.append(c)
    else:
        A.append(a)
        print(sum(A))
        quit()
print(sum(A))

Measured memory_bytes: 84904
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int y = sc.nextInt();
		if (x < y) {
			System.out.println("a < b");
		}else if(x > y){
			System.out.println("a > b");
		}else {
				System.out.println("a == b");
			}
		}
	}

Measured memory_bytes: 17172
#include <stdio.h>
int main(void){
  char C;
  if(scanf("%c",&C)<1) return 1;
  if(C=='A') printf("T\n");
  if(C=='T') printf("A\n");
  if(C=='C') printf("G\n");
  if(C=='G') printf("C\n");
  
  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll a[20005]={0},b[20005]={0};
int main(){
  ll n;
  cin>>n;
  for(ll i=1;i<=n;i++){
    a[i]=i*(n+1);
    b[i]=(n-i+1)*(n+1);
  }
  for(ll i=1;i<=n;i++){
    ll p;
    cin>>p;
    b[p]+=i;
  }
  for(int i=1;i<=n;i++) cout<<a[i]<<" ";
  cout<<endl;
  for(int i=1;i<=n;i++) cout<<b[i]<<" ";
  cout<<endl;
}


Measured memory_bytes: 896
#include<stdio.h>
main(){
	double x[100],y[100];
	double a,b,c,d;
	int n,j;
	scanf("%d",&n);
	for(j=0;j<n;j++){
		scanf("%lf%lf%lf%lf%lf%lf%lf%lf",&x[j],&y[j],&x[j+1],&y[j+1],&x[j+2],&y[j+2],&x[j+3],&y[j+3]);
		a=x[j]-x[j+1];
		b=y[j]-y[j+1];
		c=x[j+2]-x[j+3];
		d=y[j+2]-y[j+3];
		if((a*d-b*c)==0){
			printf("YES\n");
		}else{
			printf("NO\n");
		}
	}
	return 0;
}

Measured memory_bytes: 620
d, n = map(int, input().split())
if d == 0:
    if n == 100:
        print(101)
    else:
        print(n)
elif d == 1:
    if n == 100:
        print(10100)
    else:
        print(n * 100)
else:
    if n == 100:
        print(1010000)
    else:
        print(n * 10000)

Measured memory_bytes: 3060
using System;

class AtCoder
{
    static void Main()
    {       
        string[] s;       
        s = NextS();
        int n = int.Parse(s[0]);

        int[] a = new int[n];
        int[] b = new int[n];
        int[] d = new int[n];
        int[] e = new int[n];
        s = NextS();
        for (int i = 0; i < n; i++) a[i] = int.Parse(s[i]);
        s = NextS();
        for (int i = 0; i < n; i++) b[i] = int.Parse(s[i]);
        for (int i = 0; i < n; i++)
        {
            d[i] = a[i] - b[i];            
            e[i] = d[i];
        }
        Array.Sort(d, a); Array.Sort(e, b); e = null;
        int ans = 0; long sum = 0;
        for (int i = 0; i < n; i++) sum += d[i];
        if (sum < 0) Console.WriteLine(-1);
        else
        {
            int x = 0; int y = n - 1;
            sum = 0;
            while (d[x] < 0)
            {
                sum += d[x];
                x++;
                ans++;
                while (sum < 0)
                {
                    sum += d[y];
                    y--;
                    ans++;
                }
            }
            Console.WriteLine(ans);
        }
    }

    static void DebugWL(object x) { System.Diagnostics.Debug.WriteLine(x); }
    static string[] NextS() { return Console.ReadLine().Trim().Split(' '); }
}

Measured memory_bytes: 29536
#include <iostream>
#include <algorithm>
#include <string>
#include <deque>
using namespace std;

int main(void)
{
    string str;
    cin >> str;
    deque<char> d;
    for (size_t i = 0; i < str.size(); i++)
    {
        d.push_back(str.at(i));
    }
    int n;
    cin >> n;
    bool is_reverse = 1;
    for (int i = 0; i < n; i++)
    {
        int tmp;
        cin >> tmp;
        if (tmp == 1)
        {
            is_reverse ^= 1;
        }
        else
        {
            int tmp_2;
            char c;
            cin >> tmp_2 >> c;
            if (tmp_2 == 1)
            {
                if (is_reverse)
                    d.push_front(c);
                else
                    d.push_back(c);
            }
            else
            {
                if (is_reverse)
                    d.push_back(c);
                else
                    d.push_front(c);
            }
        }
    }
    if (is_reverse)
    {
        while (!d.empty())
        {
            cout << d.front();
            d.pop_front();
        }
        cout << endl;
    }
    else
    {
        while (!d.empty())
        {
            cout << d.back();
            d.pop_back();
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 1024
#include<stdio.h>

int main(void)
{
    int a, b, c, i, x, y;
    int j = 0;
	
    scanf("%d %d %d", &a, &b, &c);

    for(i = a; i <= b; i++)
    {
	y = c / i;
	x = c % i;

	if(x == 0)
	{
	    j++;
	}
    }
    printf("%d\n", j);

    return 0;
}

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

using namespace std;

#define dump(n) cout<<"# "<<#n<<'='<<(n)<<endl

typedef vector<int> vi;
const int INFTY=1<<29;

struct UnionFind{
	vi data;
	UnionFind(int size):data(size,-1){}
	int Find(int n){
		return data[n]<0?n:(data[n]=Find(data[n]));
	}
	void Unite(int a,int b){
		int ra=Find(a),rb=Find(b);
		if(ra!=rb){
			if(-data[ra]<-data[rb])
				swap(ra,rb);
			data[ra]+=data[rb];
			data[rb]=ra;
		}
	}
	int Size(int n){
		return -data[Find(n)];
	}
};

int calc(int n,vi& ss,vi& ds,vi& ws,int i0)
{
	UnionFind uf(n);
	for(int i=i0;i<ss.size();i++){
		uf.Unite(ss[i],ds[i]);
		if(uf.Size(0)==n)
			return ws[i]-ws[i0];
	}
	return INFTY;
}

int main()
{
	for(int n,m;cin>>n>>m,n|m;){
		vi ss(m),ds(m),ws(m);
		for(int i=0;i<m;i++){
			cin>>ss[i]>>ds[i]>>ws[i];
			ss[i]--,ds[i]--;
		}
		
		{
		vi is(m); iota(begin(is),end(is),0);
		sort(begin(is),end(is),[&](int a,int b){return ws[a]<ws[b];});
		vi t;      for(int i:is) t.push_back(ss[i]); ss=t;;
		t.clear(); for(int i:is) t.push_back(ds[i]); ds=t;;
		t.clear(); for(int i:is) t.push_back(ws[i]); ws=t;;
		}
		
		int res=INFTY;
		for(int i=0;i<m;i++)
			res=min(res,calc(n,ss,ds,ws,i));
		cout<<(res==INFTY?-1:res)<<endl;
	}
}

Measured memory_bytes: 1348
#include <iostream>
using namespace std;
int main(){
	int n,l;
	cin >> n >> l;

	int sum=0;
	int taste=l;
	for(int i=1;i<=n;i++){
		sum+=l+i-1;
		if(abs(taste)>abs(l+i-1)){
			taste=l+i-1;
		}
	}

	cout << sum-taste << endl;
	return 0;
}

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

using ll = long long;
using pii = pair<int, int>;

#define vt          vector
#define sz(x)       (int)(x).size()
#define all(x)      (x).begin(), (x).end()
#define rall(x)     (x).rbegin(), (x).rend()
#define fi          first
#define se          second

signed main() {
    ios::sync_with_stdio(0), cin.tie(0);

    int n, m;
    cin >> n >> m;
    vt<int> p(n);
    for (int &i : p) cin >> i, i--;
    vt<vt<int>> adj(n);
    while (m--) {
        int u, v;
        cin >> u >> v;
        u--, v--;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }

    int ans = 0;
    vt<bool> vis(n);
    set<int> connected;
    function<void(int)> dfs = [&](int x) {
        vis[x] = true;
        connected.insert(x);
        for (int i : adj[x]) {
            if (vis[i]) continue;
            dfs(i);
        }
    };
    for (int i = 0; i < n; i++) {
        if (vis[i]) continue;
        vis[i] = true;
        dfs(i);
        for (int j : connected) {
            if (connected.count(p[j])) ans++;
        }
        connected.clear();
    }

    cout << ans;
}


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

int main(void) {

	int op[3];
	string inp;
	int A, B, C, D;
	cin >> inp;
	A = (int)((unsigned char)(inp[0])-'0');
	B = (int)((unsigned char)(inp[1])-'0');
	C = (int)((unsigned char)(inp[2])-'0');
	D = (int)((unsigned char)(inp[3])-'0');
	for (int i = -1; i <= 1; i+=2) {
		for (int j = -1; j <= 1; j+=2) {
			for (int k = -1; k <= 1; k+=2) {
				op[0]=i;
				op[1]=j;
				op[2]=k;

				if ((A+op[0]*B+op[1]*C+op[2]*D)==7) {
					cout << A;
					if (op[0]==-1) cout << "-";
					else cout << "+";
					cout << B;
					if (op[1]==-1) cout << "-";
					else cout << "+";
					cout << C;
					if (op[2]==-1) cout << "-";
					else cout << "+";
					cout << D << "=7" << endl;

					return 0;
				}
			}
		}
	}
	return 0;
}


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

int main() {
	int n, x, l[101], now=0, ans=0, idx=0;
	
	cin>>n>>x; for(int i=0;i<n;i++) cin>>l[i];
	
	while(now<=x && idx<=n){
		now+=l[idx];
		idx++;
		ans++;
	}
	
	cout<<ans;
	
	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(v) v.begin(), v.end()
typedef long long ll;
const int MOD = 1e9+7,MAX = 1e5;

int main()
{
	int a,b;
	cin >> a >> b;
	if(a<b)
	{
		cout<<"a < b"<<endl;
	}
	else if(a>b)
	{
		cout<<"a > b"<<endl;
	}
	else
	{
		cout<<"a == b"<<endl;
	}

	
	return 0;
}


Measured memory_bytes: 3076
class InputLine
  def self.to_s
    gets.chomp
  end

  def self.to_i
    InputLine.to_s.to_i
  end
  
  def self.to_f
    InputLine.to_s.to_f
  end

  def self.to_sa
    InputLine.to_s.split(' ')
  end

  def self.to_ia
    InputLine.to_sa.map(&:to_i)
  end
  
  def self.to_fa
    InputLine.to_sa.map(&:to_f)
  end
end

def main(argv)
  (a, b, c) = InputLine.to_ia

  v = [a, b, c].sort
  if ((v[0] == v[1]) && (v[1] == v[2])) then
    puts 'No'
  elsif ((v[0] == v[1]) || (v[1] == v[2])) then
    puts 'Yes'
  else
    puts 'No'
  end
end

if self.to_s == 'main' then
  main(ARGV)
end

Measured memory_bytes: 1788