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

int main(){
    int n,m,x;
    std::cin >> n >> m >> x;
    int c[n],a[n][m];

    //まずはc[N]配列とA[N][M]を用意する
    for (int i=0; i<n; i++){
        std::cin >> c[i];
        for (int j=0; j<m; j++){
            std::cin >> a[i][j];
        }
    }

    int ans = 1e9;

    //求めたいのは本のコストなのでc[i]の合計である．
    //iについての組合せ(=状態数)は 0000 0000 0000 →　1111 1111 1111 まである
    //例えば，本0と本2の2冊を買う場合は 0000 0000 0101 という状態になる
    
    //まず，本のIDであるiをNビット(Max=12ビット)拡張
    for (int i=0; i<(1<<n); i++){
        int sum=0;
        int rikai[m]={};
        for (int j=0; j<n; j++){
            if((i>>j) & 1){
                sum += c[j];
                for (int k=0; k<m; k++){
                    rikai[k] += a[j][k];
                }
            }
        }
        bool flag=true;
        for(int k=0; k<m; k++)
            if(rikai[k]<x) flag=false;
        if(flag && ans > sum) ans=sum;
    }   
    std::cout << (ans==1e9?-1:ans);
    return 0;
}

Measured memory_bytes: 3632
n = int(input())
xl = [list(map(int, input().split())) for _ in range(n)]
st_en = [[x-l, x+l] for x, l in xl]

st_en.sort(key=lambda x: x[1])

now = -10**9+10
ans=0
for st, en in st_en:
    if now <= st:
        now = en
        ans+=1
print(ans)

Measured memory_bytes: 43816
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr int Inf = 1000000010;
constexpr ll INF= 1000000000000000000;
constexpr ll MOD = 998244353;
const double PI = 3.1415926535897;
typedef pair<ll,ll> P;

template<typename T>
T Pow(T a,T b) {
    T ret = 1;
    for(int i = 0;i < b;i++) {
        ret *= a;
    }
    return ret;
}

ll mod(ll val) {
    ll res = val % MOD;
    if(res < 0) {
        res += MOD;
    }
    return res;
}

ll RS(ll N, ll P, ll M){
    if(P==0) return 1;
    if(P < 0) {
        return 0;
    }
    if(P%2==0){
        ll t = RS(N, P/2, M);
        return t*t % M;
    }
    return N * RS(N, P-1, M) % M;
}

int main() {
    ll N;
    cin >> N;
    N--;
    string ret = "";
    while(N >= 0) {
        ret += ('a' + N % 26);
        N -= N % 26;
        N /= 26;
        N--;
    }
    reverse(ret.begin(),ret.end());
    cout << ret << endl;
}

Measured memory_bytes: 3628
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <cmath>

using namespace std;
#define PI 3.1415926535897932384626433832795
#define MOD (1000000007)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
typedef long long ll;
typedef unsigned long long ull;

int main()
{
	string S, T;

	cin >> S >> T;

	cout << T << S << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#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 ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int main() {
    int n;
    cin >> n;
    VI a(n);
    REP(i,n) cin >> a[i];
    sort(ALL(a));
    reverse(ALL(a));

    int ans = 0;
    REP(i,n){
        if (i % 2 == 0) ans += a[i];
        else ans -= a[i];
    }
    cout << ans << endl;

    return 0;
}


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

bool isP(string s)
{
    auto t = string(s.rbegin(), s.rend());
    return t==s;
}

int main()
{
    cin.tie(0); ios::sync_with_stdio(false);
    //-----------------------------------------
    string S;
    cin >> S;

    int N=S.length();
    bool ans = true;
    if(!isP(S)) ans = false;
    if(!isP(S.substr(0, N/2))) ans = false;
    if(!isP(S.substr((N+1)/2))) ans = false;

    if(ans)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;   
    }
    return 0;
}


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

#define fs first
#define sc second
#define pb emplace_back
#define mp make_pair
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

const int32_t inf = 1001001001;
const int64_t infll = 1001001001001001001ll;
const int dx[] = {0, -1, 1, 0, -1, 1, -1, 1}, dy[] = {-1, 0, 0, 1, -1, -1, 1, 1};
const string YES = "YES", NO = "NO", Yes = "Yes", No = "No", yes = "yes", no = "no";

// clang-format off
// ostream &operator<<(ostream &os, __int128_t value) { if (ostream::sentry(os)) { __uint128_t tmp = value < 0 ? -value : value; char buffer[64]; char *d = end(buffer); do { --d; *d = "0123456789"[tmp % 10]; tmp /= 10; } while (tmp != 0); if (value < 0) { --d; *d = '-'; } int len = end(buffer) - d; if (os.rdbuf()->sputn(d, len) != len) { os.setstate(ios_base::badbit); }} return os; }
// istream &operator>>(istream &is, __int128_t &value) { string in; is >> in; value = 0; for (const char &c : in) { if ('0' <= c && c <= '9') value = 10 * value + (c - '0'); } if (in[0] == '-') value *= -1; return is; }
// ostream &operator<<(ostream &os, __uint128_t value) { if (ostream::sentry(os)) { char buffer[64]; char *d = end(buffer); do { --d; *d = "0123456789"[value % 10]; value /= 10; } while (value != 0); int len = end(buffer) - d; if (os.rdbuf()->sputn(d, len) != len) { os.setstate(ios_base::badbit); }} return os; }
// istream &operator>>(istream &is, __uint128_t &value) { string in; is >> in; value = 0; for (const char &c : in) { if ('0' <= c && c <= '9') value = 10 * value + (c - '0'); } return is; }
template <typename T> ostream &operator<<(ostream &os, vector<T> &v) { os << v[0]; for (int i = 1; i < v.size(); ++i) os << " " << v[i]; return os; }
template <typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &in : v) is >> in; return is; }
template <typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p) { os << p.fs << " " << p.sc; return os; }
template <typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.fs >> p.sc; return is; }

struct IoSetup { IoSetup(){ cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); cerr << fixed << setprecision(10); } } iosetup;

inline int64_t in() { int64_t x = 0; cin >> x; return x; }

template <typename T> void sort(vector<T> &v) { sort(all(v)); }
template <typename T> vector<T> make_v(size_t a, T b) { return vector<T>(a, b); }
template <typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v(ts...))>(a, make_v(ts...)); }
template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
// clang-format on

signed main(int argc, char *argv[]) {
  int64_t a = in(), b = in(), c = in();
  int64_t x = in(), y = in();

  int64_t ans = inf;
  for (int i = 0; i <= max(x, y); ++i) {
    int64_t sum = 2 * i * c + max((int64_t)0, x - i) * a + max((int64_t)0, y - i) * b;
    chmin(ans, sum);
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        int n = sc.nextInt();
        int a = sc.nextInt();
        int b = sc.nextInt();
        
        if(n*a < b){
            System.out.println(n*a);
        }else if(n*a > b){
            System.out.println(b);
        }else{
            System.out.println(b);
        }
    }
}

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

int main() {
  string s;
  bool flag = false;
  cin >> s;
  
  for(int i = 0; i < s.size(); i++){
    if(s.at(i) == '7')
      flag = true;
  }
  
  if(flag)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}


Measured memory_bytes: 3628
using System;
class Program
{
    static void Main(string[] args)
    {
        //文字列の入力
        string[] input = Console.ReadLine().Split(' ');
        int a = int.Parse(input[0]);
        int b = int.Parse(input[1]);

        if((a*b)%2 == 0)
        {
            Console.WriteLine("Even");
        }
        else
        {
            Console.WriteLine("Odd");
        }
    }
}

Measured memory_bytes: 11092
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <iomanip>
using namespace std;
#define pb push_back
#define pf push_fron
#define INF 1000000000
typedef long long ll;

struct Point {
	int x, y;
};
char mp[55][55];

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

int dist[55][55];


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

	int H, W, cnt = 0;
	cin >> H >> W;

	for (int i = 0; i < H; i++)for (int j = 0; j < W; j++) {
		dist[i][j] = -1;
	}
	

	for (int i = 0; i < H; i++)for (int j = 0; j < W; j++) {
		cin >> mp[i][j];
	}
	for (int i = 0; i < H; i++)for (int j = 0; j < W; j++) {
		if (mp[i][j] == '#')cnt++;
	}
	
	queue<Point> q;
	q.push({ 0,0 });
	dist[0][0] = 0;
	while (!q.empty()) {
		Point now = q.front();
		q.pop();
		for (int i = 0; i < 4; i++) {
			Point next = { now.x + dx[i],now.y + dy[i] };
			if (mp[next.y][next.x] == '#')continue;
			if (dist[next.y][next.x] != -1)continue;
			dist[next.y][next.x] = dist[now.y][now.x] + 1;
			q.push({ next.x,next.y });
		}
	}
	if (dist[H - 1][W - 1] == -1) { cout << -1 << endl; }
	else {
		cout << (H * W) - cnt - dist[H - 1][W - 1] - 1 << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
args = sys.argv
if len(args) == 2:
  from IPython import embed
  em = True
else:
  em = False
input = sys.stdin.readline
N = int(input())
if em: sys.stdin = open('/dev/tty')
for i in range(1,10):
  if N // i < 10 and N % i == 0:
    print("Yes")
    exit()
  else:
    continue
print("No")


Measured memory_bytes: 3068
#include<stdio.h>
#define NUM 100000

int A[NUM],n;

int partition(int p, int r){
  int x,i,j,key;

  x = A[r];
  i = p-1;

  for(j = p; j < r; j++){
    if(A[j] <= x){
      i += 1;
      key = A[i];
      A[i] = A[j];
      A[j] = key;
    }
  }

  key = A[i+1];
  A[i+1] = A[r];
  A[r] = key;

  return i+1;
}

int main(){
  int i,q;
  
  scanf("%d",&n);

  for(i = 0; i < n; i++)
    scanf("%d",&A[i]);

  q = partition(0, n-1);

  for(i = 0; i < q; i++)
    printf("%d ",A[i]);

  printf("[%d] ",A[q]);

  for(i = q+1; i < n-1; i++)
    printf("%d ",A[i]);

  printf("%d\n",A[n-1]);

  return 0;
}

Measured memory_bytes: 988
#include<stdio.h>

int main()
{
	int s;
	int i=1;

	scanf("%d",&s);
	// a_n=f(n)= ? n/2 : 3n+1
	while(1)
	{
		if(s==4||s==2||s==1) break;
		s=s%2==0?s/2:s*3+1;
		i++;
	}
	printf("%d\n",i+3);
	return 0;
}




Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <math.h>
 
using namespace std;
 
int main(){
    char t, w1, w2;
    for(int i = 0; i < 5; i++){
        cin >> t;
        cout << t;
    } 
    cout << " ";
    cin >> w1;
    for(int i = 0; i < 7; i++){
        cin >> t;
        cout << t;
    } 
    cout << " ";
    cin >> w1;
    for(int i = 0; i < 5; i++){
        cin >> t;
        cout << t;
    } 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
template <class T> using treap = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define int long long
#define REP(i, n) for (long long i = 0, max_i = (n); i < max_i; i++)
#define REPI(i, a, b) for (long long i = (a), max_i = (b); i < max_i; i++)
#define ALL(obj) begin(obj), end(obj)
#define RALL(obj) rbegin(obj), rend(obj)
#define fi first
#define se second
using ii = pair<int, int>;
vector<ii> dirs = {
    {1, 0}, {0, 1}, {-1, 0}, {0, -1},  // 4方向
    {1, 1}, {-1, 1}, {-1, -1}, {1, -1},  // 斜め
    {0, 0},  // 自身
};
template <class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } return false; }
template <class T> inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } return false; }
template <class T, class S> vector<T> make_vec(size_t n, S x) { return vector<T>(n, x); }
template <class T, class... Ts> auto make_vec(size_t n, Ts... ts) { return vector<decltype(make_vec<T>(ts...))>(n, make_vec<T>(ts...)); }

// debug
template <class T> ostream& operator<<(ostream& s, vector<T>& d) { REP (i, d.size()) s << d[i] << (i == d.size() - 1 ? "" : " "); return s; }
template <class T> ostream& operator<<(ostream& s, vector<vector<T>>& d) { REP (i, d.size()) s << d[i] << (i == d.size() - 1 ? "" : "\n"); return s; }
template <class T, class S> ostream& operator<<(ostream& s, pair<T, S>& p) { s << "{" << p.first << ", " << p.second << "}"; return s; }
template <class T, class S> ostream& operator<<(ostream& s, map<T, S> m) { for (auto it = m.begin(); it != m.end(); it++) { s << *it << (next(it) == m.end() ? "" : "\n"); } return s; }
template <class T, class S> ostream& operator<<(ostream& s, unordered_map<T, S> m) { for (auto it = m.begin(); it != m.end(); it++) { s << *it << (next(it) == m.end() ? "" : "\n"); } return s; }
#ifdef _MY_DEBUG
    #define dump(...) cerr << "/* " << #__VA_ARGS__ << " :[" << __LINE__ << ":" << __FUNCTION__ << "]" << endl, dump_func(__VA_ARGS__), cerr << "*/\n\n";
#else
    #define dump(...)
    #define endl "\n"
#endif
void dump_func() { cerr << endl; }
template <class Head, class... Tail> void dump_func(Head&& h, Tail&&... t) { cerr << h << (sizeof...(Tail) == 0 ? "" : ", "), dump_func(forward<Tail>(t)...); }

struct Fast { Fast() { cin.tie(nullptr); ios::sync_with_stdio(false); } } fast;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
constexpr int MOD = 1000000007;
// *************** TEMPLATE END *************** 

signed main() {
    int n; cin >> n;
    vector<int> b(n + 1, 1e18);
    REP (i, n - 1) cin >> b[i + 1];
    int ans = 0;
    REP (i, n) ans += min(b[i], b[i + 1]);
    cout << ans << endl;
}


Measured memory_bytes: 256
N = int(input())
P = list(map(int,input().split()))
Q = list(map(int,input().split()))
import math
def num(P):
    l = list(range(N+1))
    l.remove(0)
    p = 1
    for i in range(N):
        p += l.index(P[i]) * math.factorial(N-1-i)
        l.remove(P[i])
    return p
ans = num(P) - num(Q)
print(abs(ans))

Measured memory_bytes: 9180
#include<bits/stdc++.h>
#define L long int
#define LL long long int
#define Pi pair<int,int>
#define Pl pair<L,L>
#define vi vector<int>
#define Vi vector<vector<int>>
#define vl vector<long int>
#define Vl vector<vector<long int>>
#define vp vector<Pi>
#define mod 1000000007
using namespace std;
int main(){
	LL num;
	cin>>num;
	vi rem;
	while(num>0){
		rem.push_back(num%26);
		num/=26;
		if(!rem.empty()%26 && rem.back()==0){
			num--;
		}
	}
	reverse(rem.begin(),rem.end());
	for(int i:rem){
		if(i==0)
			cout<<"z";
		else
			cout<<(char)('a'+i-1);
	}
	cout<<endl;
	return 0;
}


Measured memory_bytes: 3576
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using System.Globalization;
using System.Diagnostics;



class Myon
{
    public Myon() { }
    public static int Main()
    {
        new Myon().calc();
        return 0;
    }


    Scanner cin;

    void calc()
    {
        cin = new Scanner();
        int N = cin.nextInt();
        int M = cin.nextInt();
        int[] A = new int[M];
        int[] B = new int[M];
        for (int i = 0; i < M; i++)
        {
            A[i] = cin.nextInt() - 1;
            B[i] = cin.nextInt() - 1;
        }

        int ans = 0;
        for (int i = 0; i < M; i++)
        {
            init(N);
            for (int j = 0; j < M; j++)
            {
                if (j == i) continue;
                connect(A[j], B[j]);
            }
            if (uni[root(0)] != -N) ans++;
        }
        Console.WriteLine(ans);
    }

    int[] uni;
    void init(int N)
    {
        uni = new int[N];
        for (int i = 0; i < N; i++)
        {
            uni[i] = -1;
        }
    }

    int root(int a)
    {
        if (uni[a] < 0) return a;
        else return uni[a] = root(uni[a]);
    }

    bool connect(int a, int b)
    {
        a = root(a);
        b = root(b);
        if (a == b) return false;
        if (uni[a] > uni[b]) swap(ref a, ref b);
        uni[a] += uni[b];
        uni[b] = a;
        return true;
    }

    void swap<T>(ref T a, ref T b)
    {
        T c = a;
        a = b;
        b = c;
    }  
}


class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}


Measured memory_bytes: 13140
import java.io.*;
import java.math.BigInteger;
import java.util.*;

public class Main {

    public static void main(String[] args) throws IOException {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        InputReader.OutputWriter out = new InputReader.OutputWriter(outputStream);

        int x = in.nextInt();
        long ans = 0;
        int hundred = x/500;
        x-=hundred*500;
        int five = x/5;
        out.println(hundred * 1000 + five * 5);

        out.flush();
    }
}

class Interval {
    int start;
    int end;

    public int getStart() {
        return start;
    }

    public int getEnd() {
        return end;
    }

    public Interval(int start, int end) {
        this.start = start;
        this.end = end;
    }

    @Override
    public String toString() {
        return
                "start=" + start +
                ", end=" + end +
                '}';
    }
}


class InputReader extends BufferedReader {
    StringTokenizer tokenizer;

    public InputReader(InputStream inputStream) {
        super(new InputStreamReader(inputStream), 32768);
    }

    public InputReader(String filename) {
        super(new InputStreamReader(Thread.currentThread().getContextClassLoader().getResourceAsStream(filename)));
    }

    public String next() {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(readLine());
            } catch (IOException e) {
                throw new RuntimeException();
            }
        }
        return tokenizer.nextToken();
    }

    public Integer nextInt(){
        return Integer.valueOf(next());
    }
    public Long nextLong() {
        return  Long.valueOf(next());
    }
    public Double nextDouble() {
        return Double.valueOf(next());
    }
    static class OutputWriter extends PrintWriter {
        public OutputWriter(OutputStream outputStream) {
            super(outputStream);
        }

        public OutputWriter(Writer writer) {
            super(writer);
        }

        public OutputWriter(String filename) throws FileNotFoundException {
            super(filename);
        }

        public void close() {
            super.close();
        }
    }
}


Measured memory_bytes: 21460
# import itertools
# import math
# import sys
# import numpy as np

# N = int(input())
# S = input()
# n, *a = map(int, open(0))
N, M = map(int, input().split())
# A = list(map(int, input().split()))
# Q = list(map(int, input().split()))
# S = input()

# d = sorted(d.items(), key=lambda x:x[0]) # keyでsort

conditions = []
for i in range(M):
    conditions.append(list(map(int, input().split())))

ans = -1

for i in range(1000):
    i_str = str(i)
    if len(i_str) == N:
        # print(i)
        for condition in conditions:
            # print(condition)
            if i_str[condition[0] - 1] != str(condition[1]):
                # print("a")
                break
        else:
            ans = i
            break
    # print(i)


print(ans)

Measured memory_bytes: 9176
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
#include <map>
#include <cmath>
#include <iostream>
#include <deque>
#include <math.h>
#include <cstdio>
#include <iomanip>
typedef  long long ll;
using namespace std;

int main(void) {
	ll n;
	cin >> n;
	vector<ll> p(n);
	for (ll i = 0; i < n; i++) cin >> p[i];
	vector<ll> a(n);
	ll min_num = 1000000;
	for (int i = 0; i < n; i++){
		min_num = min(min_num, p[i]);
		a[i] = min_num;
	}


	ll ans = 0;
	for (int i = 0; i < n ; i++)
	{
		if (p[i] <= a[i])
		{
			ans++;
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3328
A, B = map(int, input().split())

for i in range(50):
    if pow(2, i) >= max(A, B):
        maxk = i
        break
lisA = [-1] * (maxk + 1)
lisB = [-1]*(maxk+1)
# print(maxk)
for i in range(maxk+1):
    lisA[i] = A % pow(2, i+1)
    # if A % pow(2, i+1) == 0:
    #     lisA[i] = pow(2, i+1)
    lisB[i] = B % pow(2, i+1)
    # if B % pow(2, i+1) == 0:
    #     lisB[i] = pow(2, i+1)

# print(lisA)
# print(lisB)
ans = [-1] * (maxk + 1)

for i in range(1, maxk + 1):
    if lisA[i] >= pow(2, i) and lisB[i] >= pow(2, i):
        ans[i] = (abs(lisA[i] - lisB[i]) + 1) % 2
    elif lisA[i] >= pow(2, i) and lisB[i] < pow(2, i):
        ans[i] = (pow(2, i+1)-lisA[i]) % 2
    elif lisB[i] >= pow(2, i) and lisA[i] < pow(2, i):
        ans[i] = (lisB[i] - pow(2, i)+1) % 2
    else:
        ans[i] = 0
if A % 2 == 0:
    if (B - A) % 4 == 0 or (B - A) % 4 == 3:
        ans[0] = 0
    else:
        ans[0] = 1
else:
    if (B - A) % 4 == 1 or (B - A) % 4 == 0:
        ans[0] = 1
    else:
        ans[0] = 0


# print(ans)
ans2 = 0
for i in range(maxk+1):
    ans2 += pow(2, i)*ans[i]
print(ans2)

Measured memory_bytes: 3188
//   PIGMEISTER™   //

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

#define ll long long
#define ld long double
#define sidha(i,x,n) for(ll i=(ll)(x);i<(ll)(n);++i)
#define ulta(i,x,n) for(ll i=(ll)(x);i>=(ll)(n);--i)
#define sab(a) a.begin(),a.end()
#define bas(a) a.rbegin(),a.rend()
#define test ll _;cin>>_;while(_--)
#define jaldi ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define MOD (ll)1000000007
//#define MOD (ll)998244353
#define PI (ld)3.141592653589793238
#define MAX 100005

int main()
{
    jaldi;
    
    ll n;
    cin >> n;
    ll a[n];
    map<ll, ll> s;
    sidha (i, 0, n) cin >> a[i], s[a[i]]++;

    ll one = 0;
    sidha (i, 0, n) {
        if (a[i] == 1) 
            one++;
    }
    if (one == 1) {
        cout << 1;
        return 0;
    }
    else if (one > 1) {
        cout << 0;
        return 0;
    }

    ll ans = 0;
    sidha (i, 0, n) {
        bool flag = false;
        for (ll j = 2; j*j <= a[i]; j++) {
            if (a[i]%j) continue;
            if (s.find(j) != s.end() or s.find(a[i]/j) != s.end()) {
                flag = true;
                break;
            }
        }
        if (flag or s[a[i]] > 1) continue;
        ans++;
    }

    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 17720
n,m =map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(n)]
dxy = [list(map(int, input().split())) for _ in range(m)]

for i in range(n):
    dt = 10**9
    for j in range(m):
        dx = abs(ab[i][0]-dxy[j][0])
        dy = abs(ab[i][1]-dxy[j][1])
        if dt > dx+dy:
            ij = j
            dt = dx+dy
    print(ij+1)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
 
const int N = 2e5 + 10;
ll n;

bool check(ll n, ll div)
{
	while (n % div == 0) n /= div;
	if (n == 1) return 1;
	if ((n - 1) % div == 0) return 1;
	return 0;
}

map<ll, int>vis;

int main()
{
	cin >> n;
	
	ll ans = 0;
	for (ll i = 1; i <= sqrt(n - 1); i++)
	{
		if ((n - 1) % i) continue;
		ans++;
		if (i * i != n - 1) ans++;
	}
	ans--;
	
	for (ll i = 1; i <= sqrt(n); i++)
	{
		if (n % i) continue;
		if (i != 1) ans += check(n, i);
		if (i * i != n) ans += check(n, n / i);
	}
	
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<algorithm>
#include <iomanip> 
#include<vector>
#define fo(i,n) for(ll i=0;i<n;i++)
#define f(i,n) for(ll i=1;i<n;i++)
#define ff(i,k,n) for(ll i=k,i<n;i++)
#define ll long long
/*Elegizip, elegizip otken sol bir shaktar-ai
 Elendeter zamanymnyn otip bara zhatkanny-ai
Umytylmas-Umytylmas Kairan esil shaktar-ai
Zamanymnyn kolyn bulgap otip bara jatkany-ai
 kairan esil , kairan esil shaktar-ai
kolyn bulgap zamanymnyn otip bara jatkany-ai;*/
using namespace std;

int main()
{ios::sync_with_stdio(0);
ll n, r=0;
cin>>n;
ll m;
cin>>m;
ll l=0;
fo(i,m){

    ll c;
    cin>>c;
    l+=c;
}
if(l>n) cout<<-1;
else cout<<n-l;
}





Measured memory_bytes: 3640
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<string> vs;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define REPR(i,n) for(int i=n-1;i>=0;i--)
#define FORR(i,n,m) for(int i=n-1;i>=m;i--)
#define all(in) in.begin(),in.end()
#define ALL(in,K) in,in+K
#define INF 1e18
#define MOD 100000007
#define SIZE 10005
#define PI 	3.14159265358979323846

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,m,N,M;
    cin >> n >> m >> N >> M;
    cout << (n-N)*(m-M) << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(a) (a).begin(), (a).end()
#define forn(i,a,b) for (int i = a; i <= b; i++)
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define rc(s) return cout<<s,0
#define pi pair <int, int>
#define sz(x) (int)((x).size())
#define make_unique(v) v.erase(unique(all(v)),v.end())
#define int long long

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

const ll inf = 0x3f3f3f3f3f3f3f;
const ll mod = 1e9 + 7;
const int N = 2e5 + 11;

int n,a[N],h[N],t[4*N];

void build(int v,int l,int r){
    if(l==r){
        t[v] = a[l];
    }else{
        int mid = (l+r)/2;
        build(2*v,l,mid);
        build(2*v+1,mid+1,r);
        t[v] = max(t[2*v],t[2*v+1]);
    }
}

int get(int v,int tl,int tr,int l,int r){

    if(tl <= l && r <= tr)return t[v];
    int mid = (l+r)/2;
    return max(((tl <= mid) ? get(2*v,tl,tr,l,mid) : 0),((tr > mid) ? get(2*v+1,tl,tr,mid+1,r) : 0));
}

void update(int v,int l,int r,int pos, int val){

    if(l==r){
        t[v] = val;
        return;
    }
    int mid = (l+r)/2;
    if(mid >= pos)update(2*v,l,mid,pos,val);else
        update(2*v+1,mid+1,r,pos,val);
    t[v] = max(t[2*v],t[2*v+1]);
}


int32_t main(){
ios_base::sync_with_stdio(0); cin.tie(0); cerr.tie(0); cout.tie(0);

    cin >> n;

    for(int i  = 1; i <= n; i++) cin >> h[i];

    for(int i  = 1; i <= n; i++) cin >> a[i];

    for(int i = 1; i <= n; i++){

        int best = (h[i] == 1 ? 0 : get(1,1,h[i] - 1,1,n)) + a[i];
        update(1,1,n,h[i],best);

    }

    rc(t[1]);
return 0;
}

Measured memory_bytes: 9600
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <limits>
#include <sstream>
#include <fstream>
#include <climits>
#include <map>
#include <numeric>
#include <functional>
#include <utility>

using namespace std;

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

int main(void) {
  string s;
  cin >> s;
  if (s == "ABC") {
    cout << "ARC" << endl;
  }
  else if (s == "ARC") {
    cout << "ABC" << endl;
  }

  return 0;
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
string s,b;
int main()
{
	cin>>s;
	b=s;
	reverse(b.begin(),b.end());
	for(int i=0;i<b.length();i++)
		{
			if(b[i]=='b')
				b[i]='d';
			else
				if(b[i]=='d')
					b[i]='b';
			else
			    if(b[i]=='q')
					b[i]='p';
			else
				if(b[i]=='p')
					b[i]='q';
		}
	if(b==s)
		cout<<"Yes";
	else
		cout<<"No";
	return 0;
} 

Measured memory_bytes: 512
using System;
using System.Collections.Generic;
using System.Linq;

namespace CSharpSample01
{
    

    class Program
    {

        static List<int>[] portlist;


        static void Main(string[] args)
        {
            string[] str = Console.ReadLine().Split(' ');
            int N = int.Parse(str[0]);
            int M = int.Parse(str[1]);

            portlist = new List<int>[N];

            for(int i = 0; i < N; i++)
            {
                portlist[i] = new List<int>();
            }
            

            for(int i = 0; i < M; i++)
            {
                string[] input = Console.ReadLine().Split(' ');
                int a = int.Parse(input[0]) - 1;
                int b = int.Parse(input[1]) - 1;

                portlist[a].Add(b);
                portlist[b].Add(a);
            }
            
            for(int i = 1; i < N - 1; i++)
            {
                bool flag0 = false;
                bool flagN = false;

                for(int j = 0; j < portlist[i].Count; j++)
                {
                    if(portlist[i][j] == 0)
                    {
                        flag0 = true;
                    }
                    else if(portlist[i][j] == N - 1)
                    {
                        flagN = true;
                    }

                    if(flag0 && flagN)
                    {
                        Console.WriteLine("POSSIBLE");
                        return;
                    }

                }

            }

            Console.WriteLine("IMPOSSIBLE");

        }
    }
}


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

int main() {
  long long n, k, ans(0), mod(1e9+7);
  cin >> n >> k;
  for (long long i = k; i <= n + 1; ++i) {
    // first i
    // (0, 1, ..., k-1)
    long long s1 = (0 + i - 1) * i / 2;
    // last i
    // (n - k + 1) ... n - k + k
    long long s2 = (n - i + 1 + n) * i / 2;
    //cout << s2 << ' ' << s1 << endl;
    ans += (s2 - s1 + 1);
    ans %= mod;
  }
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 3624
n = int(input())
a = []
b = []
a_b = []
point_a = 0
point_b = 0
for i in range(n):
    tmp1 , tmp2 = map(int,input().split())
    a.append(tmp1)
    b.append(tmp2)
    a_b.append((tmp1+tmp2,i))
a_b.sort()
while a_b:
    point_a += a[a_b.pop(-1)[1]]
    if a_b:
        point_b += b[a_b.pop(-1)[1]]
    else:
        break
print(point_a - point_b)


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

using namespace std;

template <class T>inline T updmax(T& a, T b) {return a = max(a, b);}
template <class T>inline T updmin(T& a, T b) {return a = min(a, b);}

int f(string s){
	s += "_";
	int n = s.length();
	int x = 1;
	int ret = 0;
	for(int i=1; i < n; i++){
		if(s[i] == s[i-1]){
			x++;
		}
		else{
			ret += x/2;
			x = 1;
		}
	}
	return ret;
}

class Solution {
public:
	void solve() {
		string s;
		long long  k;
		cin >> s >> k;
		bool same = true;
		for(int i=0; i < s.length(); i++)if(s[0] != s[i])same =false;
		if(same){
			cout << (s.length() * k)/2 << "\n";
			return;
		}
		int n = s.length();
		int r1 = f(s);
		int r2 = f(s+s);
		cout << r1 + (k-1)*(r2-r1) << endl;
		return;
	};
};

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	Solution solution;
	solution.solve();
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cassert>
#include <functional>

using namespace std;

#define LOG(...) printf(__VA_ARGS__)
#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((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define CLR(a) memset((a), 0 ,sizeof(a))
#define WRAP(y,x,h,w) (0<=y && y<h && 0<=x && x<w)

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

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

int main() {
	int time;
	cin >> time;
	cout << 48 - time << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int n,arr[100],i,j,temp,min,count=0;
  
  scanf("%d",&n);
  
  for(i=0;i<n;i++){
    scanf("%d",&arr[i]);
  }
  for(i=0;i<n-1;i++){
    min=i+1;
    for(j=i+1;j<n;j++){
      if(arr[j]<arr[min]){
	min=j;
      }
    }
    if(arr[min]<arr[i]){
      temp=arr[i];
      arr[i]=arr[min];
      arr[min]=temp;
      count++;
    }
  }
  for(i=0;i<n;i++){    
    printf("%d",arr[i]);
    if(i<n-1){
      printf(" ");
    }
  }
  printf("\n");
  printf("%d\n",count);
  return 0;
}

Measured memory_bytes: 604
function main()
  
  (M, D) = map(x -> parse(Int, x), split(readline()))
  
  count = 0
  
  for i in 1:D
   
   d1 = i % 10
   d10 = div(i,10)
      
   if d1 * d10 <= M && d1 >= 2 && d10 >= 2
     count += 1
   end
    
  end
  
  println(count)
  
end

main()

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

int main() {
  int A, B;
  char op;
  cin >> A >> op >> B;
  
  if (op == '+') {
    cout << A + B << endl;
  }
  
  if (op == '-') {
    cout << A - B << endl;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 int arr[4];
int main()
{ int a,b,c;
cin>>a>>b>>c;
arr[0]=a+b,arr[1]=a+c,arr[2]=b+c;
sort(arr,arr+3);
cout<<arr[0]<<endl;
return 0;
}



Measured memory_bytes: 256
package main

import (
	"fmt"
	"strings"
)

func main() {
	var s string
	fmt.Scan(&s)

	ss := strings.Split(s, "")
	i := ""
	for _, n := range ss {
		if i == "" {
			i = n
			continue
		}

		if i == n {
			fmt.Print("Bad")
			return
		}

		i = n
	}
	fmt.Print("Good")
}


Measured memory_bytes: 640
#include<iostream>

int main() {
	int a, b,c;

	std::cin >> a >> b;

	if (a == 1) {
		a = 14;
	}
	if (b == 1) {
		b = 14;
	}

	c = a - b;
	if (c==0) {
		std::cout << "Draw" << std::endl;
	}
	else {
		if (c > 0) {
			std::cout << "Alice" << std::endl;
		}
		else {
			std::cout << "Bob" << std::endl;
		}
	
	}
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	static Scanner scan=new Scanner(System.in);
	static int gcd (int a, int b) {return b>0?gcd(b,a%b):a;}
	static long lcm (int a, int b) {return a*b/gcd(a,b);}
	static int max(int a,int b) {return a>b?a:b;}
	static int min(int a,int b) {return a<b?a:b;}
	static long factorial(int i) {return i==1?1:i*factorial(i-1);}
	static int lower_bound(int a[],int key) {
		int low=0,high=a.length;
		while(low<high) {
			int mid=((high-low)/2)+low;
			if(a[mid]<=key)low=mid+1;
			else high=mid;
		}
		return high;
		}
	static int upper_bound(int a[],int key) {
		int low=0,high=a.length;
		while(low<high) {
			int mid=((high-low)/2)+low;
			if(a[mid]<key)low=mid+1;
			else high=mid;
		}
		return high;
		}
	static boolean isPrime (int n) {
		if (n==2) return true;
		if (n<2 || n%2==0) return false;
		double d = Math.sqrt(n);
		for (int i=3; i<=d; i+=2)if(n%i==0){return false;}
		return true;
	}
	static int upper_division(int a,int b) {
		if(a%b==0) {
			return a/b;
		}
		else {
			return a/b+1;
		}
	}
	static long lupper_division(long a,long b) {
		if(a%b==0) {
			return a/b;
		}
		else {
			return a/b+1;
		}
	}
	static long lmax(long a,long b) {return Math.max(a, b);}
	static long lmin(long a,long b) {return Math.min(a, b);}
	static int[] setArray(int a) {
		int b[]=new int[a];
		for(int i=0;i<a;i++) {
			b[i]=scan.nextInt();
		}
		return b;
	}
	//Arrays.sort(array, (a, b) -> Integer.compare(a[0], b[0]));
	
	public static void main(String[] args) {
		long a=scan.nextInt();
		long ans=(1+a)*a/2-a;
		System.out.println(ans);
	}
}

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

int main()
{
    int n,i,a[205],s=0,flag=0;
    scanf("%d",&n);
    for(i=0;i<n;i++)
        scanf("%d",&a[i]);
    while(1)
    {
        for(i=0;i<n;i++)
        {
            if(a[i]%2==0)
                flag=0;
            else
            {flag=1;break;}
            a[i]=a[i]/2;
        }
        if(flag==0)
            s++;
        else
            break;
    }
    printf("%d",s);
    return 0;
}


Measured memory_bytes: 128
$a = {}
def all(n)
  return 1 if n == 0
  return $a[n] if $a[n]
  $a[n] = 3 + 2*all(n-1) 
end

$b = {}
def patall(n)
  return 1 if n == 0
  return $b[n] if $b[n]
  $b[n] = 1 + 2*patall(n-1)
end

def pat(n, x)
  return 0 if x <= 0
  return patall(n) if all(n) == x

  return pat(n-1,x-1) if 1+all(n-1) >= x

  r = 0
  r += patall(n-1)
  x -= 1+all(n-1)
  return r if x == 0
  r += 1
  x -= 1

  if all(n-1) <= x
    r += patall(n-1)
    return r
  else
    r += pat(n-1, x)
    return r
  end
end

n,x=gets.split.map(&:to_i)
puts pat(n,x)

Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define PI 3.1415926535
#define MOD 1000000007

int main(){
  
  ll A,B,C,D;
  cin >> A >> B >> C >> D;
  
  while(A > 0 && C > 0){
    C -= B;
    if(C <= 0){
      cout << "Yes" << endl;
      break;
    }
    A -= D;
    if(A <= 0){
      cout << "No" << endl;
      break;
    }
  }
  
  return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include<algorithm>
#include<vector>
#include<deque>
#include <numeric>
#include<cmath>
#include<string>
using namespace std;
#define ll long long


int main(void){
    int cnt=0;
    int  n,d;
    cin >> n>>d;
    int x[n][d];
    for(int i=0;i<n;i++){
        for(int j=0;j<d;j++){
            cin >> x[i][j];
        }
    }
    
    // for(int i=0;i<n;i++){
    //     for(int j=0;j<d;j++){
    //         cout << x[i][j]<<' ';
    //     }
    //     cout << endl;
    // }
 
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            double dis = 0; 
            if(i>=j){
                continue;
            }
            
            for(int k=0;k<d;k++){
                dis += pow(x[i][k]-x[j][k],2);
             
            }
            int k=0;
            while(pow(k,2)<=dis){
                // cout << pow(k,2)<<' '<<dis<<endl;
                if(pow(k,2)==dis){
                    cnt++;
                    break;
                }
                k++;
            }
        }
    }
    cout << cnt <<endl;
}

Measured memory_bytes: 256
//by yjz
#include<bits/stdc++.h>
using namespace std;
#define FF first
#define SS second
#define PB push_back
#define MP make_pair
#define bged(v) (v).begin(),(v).end()
#define foreach(it,s) for(__typeof((s).begin()) it=(s).begin();it!=(s).end();it++)
typedef long long ll;
const int Imx=2147483647;
const ll Lbig=2e18;
const int mod=1e9+7;
//My i/o stream
struct fastio
{
	char s[100000];
	int it,len;
	fastio(){it=len=0;}
	inline char get()
	{
		if(it<len)return s[it++];it=0;
		len=fread(s,1,100000,stdin);
		if(len==0)return EOF;else return s[it++];
	}
	bool notend()
	{
		char c=get();
		while(c==' '||c=='\n')c=get();
		if(it>0)it--;
		return c!=EOF;
	}
}_buff;
#define geti(x) x=getnum()
#define getii(x,y) geti(x),geti(y)
#define getiii(x,y,z) getii(x,y),geti(z)
#define puti(x) putnum(x),putchar(' ')
#define putii(x,y) puti(x),puti(y)
#define putiii(x,y,z) putii(x,y),puti(z)
#define putsi(x) putnum(x),putchar('\n')
#define putsii(x,y) puti(x),putsi(y)
#define putsiii(x,y,z) putii(x,y),putsi(z)
inline ll getnum()
{
	ll r=0;bool ng=0;char c;c=_buff.get();
	while(c!='-'&&(c<'0'||c>'9'))c=_buff.get();
	if(c=='-')ng=1,c=_buff.get();
	while(c>='0'&&c<='9')r=r*10+c-'0',c=_buff.get();
	return ng?-r:r;
}
template<class T> inline void putnum(T x)
{
	if(x<0)putchar('-'),x=-x;
	register short a[20]={},sz=0;
	while(x)a[sz++]=x%10,x/=10;
	if(sz==0)putchar('0');
	for(int i=sz-1;i>=0;i--)putchar('0'+a[i]);
}
inline char getreal(){char c=_buff.get();while(c==' '||c=='\n')c=_buff.get();return c;}
int n;
int f[100111];
int gf(int x){return f[x]==x?x:f[x]=gf(f[x]);}
set<int> s0[100111],s1[100111];
bool check(int x,int y)
{
	x=gf(x);y=gf(y);
	if(x==y)return false;
	return s0[x].find(y)!=s0[x].end()&&s1[x].find(y)!=s1[x].end();
}
bool fix[100111];
void un(int x,int y)
{
//	cerr<<"un:"<<x<<","<<y<<endl;
	x=gf(x);y=gf(y);
	if(x==y)return;
	assert(f[x]==x);
	assert(f[y]==y);
	assert(!fix[x]);
	assert(!fix[y]);
	if(s0[x].size()+s1[x].size()>s0[y].size()+s1[y].size())swap(x,y);
	//x to y
	f[x]=y;
	fix[x]=1;
	foreach(it,s0[x])
	{
		if(*it==x||*it==y)continue;
		assert(s0[*it].find(x)!=s0[*it].end());
		s0[*it].erase(x);
		s0[*it].insert(y);
		s0[y].insert(*it);
	}
	foreach(it,s1[x])
	{
		if(*it==x||*it==y)continue;
		assert(s1[*it].find(x)!=s1[*it].end());
		s1[*it].erase(x);
		s1[*it].insert(y);
		s1[y].insert(*it);
	}
	if(s0[y].find(x)!=s0[y].end())s0[y].erase(x);
	if(s1[y].find(x)!=s1[y].end())s1[y].erase(x);
	int tmp=s0[x].size();
	foreach(it,s0[x])
	{
		assert(s0[x].size()==tmp);
		if(check(*it,y))un(*it,y);
	}
	tmp=s1[x].size();
	foreach(it,s1[x])
	{
		assert(s1[x].size()==tmp);
		if(check(*it,y))un(*it,y);
	}
}
pair<int,int> q[100111];
int qn;
int main()
{
	geti(n);
	for(int i=1;i<=n;i++)f[i]=i;
	for(int i=1;i<n;i++)
	{
		int x,y;
		getii(x,y);
		s0[x].insert(y);
		s0[y].insert(x);
	}
	for(int i=1;i<n;i++)
	{
		int x,y;
		getii(x,y);
		s1[x].insert(y);
		s1[y].insert(x);
	}
	for(int i=1;i<=n;i++)
	{
		foreach(it,s0[i])if(check(i,*it))
		{
			q[qn++]=MP(i,*it);
		}
	}
	for(int i=0;i<qn;i++)
	{
		un(q[i].FF,q[i].SS);
	}
	for(int i=2;i<=n;i++)if(gf(i)!=gf(i-1))
	{
		puts("NO");
		return 0;
	}
	puts("YES");
	return 0;
}


Measured memory_bytes: 35200
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastScanner in = new FastScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, FastScanner in, PrintWriter out) {
            out.println((1000 - (in.nextInt() % 1000)) % 1000);
        }

    }

    static class FastScanner {
        private InputStream in;
        private byte[] buffer = new byte[1024];
        private int bufPointer;
        private int bufLength;

        public FastScanner(InputStream in) {
            this.in = in;
            this.bufPointer = 0;
            this.bufLength = 0;
        }

        private int readByte() {
            if (bufPointer >= bufLength) {
                if (bufLength == -1)
                    throw new InputMismatchException();

                bufPointer = 0;
                try {
                    bufLength = in.read(buffer);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }

                if (bufLength <= 0)
                    return -1;
            }
            return buffer[bufPointer++];
        }

        private static boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public int nextInt() {
            int n = 0;

            int b = readByte();
            while (isSpaceChar(b))
                b = readByte();

            boolean minus = (b == '-');
            if (minus)
                b = readByte();

            while (b >= '0' && b <= '9') {
                n *= 10;
                n += b - '0';
                b = readByte();
            }

            if (!isSpaceChar(b))
                throw new NumberFormatException();

            return minus ? -n : n;
        }

    }
}



Measured memory_bytes: 32556