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

using namespace std;

#define forn(i, n) for (ll i = 0; i < (ll) (n); ++i)
#define sz(a) static_cast<int>((a).size())
#define pb emplace_back
#define mp make_pair
#define endl '\n'
#define f first
#define s second

#ifdef SEREZHKA
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define dbg(...)
#endif

template<typename T>
void _dbg(const char* _s, T _h) { cerr << _s << " = " << _h << "\n"; }

template<typename T, typename... Ts>
void _dbg(const char*_s, T _h, Ts... _t) {
    int _b = 0;
    
    while (((_b += *_s == '(') -= *_s == ')') != 0 || *_s != ',')
        cerr << *_s++;
    
    cerr << " = " << _h << ",";
    _dbg(_s + 1, _t...);
}

using ll = long long;

const ll INF = static_cast<ll>(1e9) + 7ll;
const ll LINF = INF * INF;
const int MAXN = static_cast<int>(2e5) + 17;

int n, m, q;
vector<int> g[MAXN];
pair<int, int> P[MAXN][11];

bool read() {
    if (!(cin >> n >> m))
        return false;

    forn (i, m) {
        int u, v;
        cin >> u >> v;
        g[u - 1].pb(v - 1);
        g[v - 1].pb(u - 1);
    }

    cin >> q;

    return true;
}

void solve() {
    forn (i, q) {
        int v, d, c;
        cin >> v >> d >> c;
        P[v - 1][d] = mp(i, c);
    }

    for (int d = 10; d > 0; --d)
        forn (v, n) {
            for (auto to : g[v])
                P[to][d - 1] = max(P[to][d - 1], P[v][d]);

            P[v][d - 1] = max(P[v][d - 1], P[v][d]);
        }

    forn (i, n)
        cout << P[i][0].s << endl;
}

int main() {
    cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    
#ifdef SEREZHKA
    freopen("file.in", "r", stdin);
#endif
    
    while (read())
        solve();
    
    return 0;
}



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

void solve(){
	set < int > s;
	int n;
	cin >> n;
	for(int i = 0; i < n; i++){
		int p;
		cin >> p;
		s.insert(p);
	}
	if(s.size() == n){
		cout << "YES" << "\n";
	}
	else{
		cout << "NO" << "\n";
	}
	
}

int main(){
	
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	solve();

}

Measured memory_bytes: 13040
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;

public class Main {

	public static void main(String[] args) throws NumberFormatException, IOException {
		
		for(int i =  1; i <= 9; i++) for(int j =  1; j <= 9; j++) System.out.println(i + "x" + j + "=" + (i * j));
		
	}
}

Measured memory_bytes: 24176
#include<stdio.h>
int main(){
    int t;
    scanf("%d",&t);
    char ch[100];
    int t1=0,t2=0,t3=0,t4=0;
    while(t--){
        scanf("%s",ch);
        if(ch[0]=='A')
            t1=t1+1;
        else if(ch[0]=='W')
            t2=t2+1;
        else if(ch[0]=='T')
            t3=t3+1;
        else if(ch[0]=='R')
            t4=t4+1;
    }
    printf("AC x %d\n",t1);
    printf("WA x %d\n",t2);
    printf("TLE x %d\n",t3);
    printf("RE x %d\n",t4);
}

Measured memory_bytes: 1732
N = int(input())
A = [0]*N; B = [0]*N; C = [0]*N
for i in range(N):
    A[i], B[i], C[i] = map(int, input().split())

lisA = [0]*N; lisB = [0]*N; lisC = [0]*N
lisA[0] = A[0]; lisB[0] = B[0]; lisC[0] = C[0];
for i in range(1, N):
    lisA[i] = max(lisB[i-1], lisC[i-1]) + A[i]
    lisB[i] = max(lisA[i-1], lisC[i-1]) + B[i]
    lisC[i] = max(lisA[i-1], lisB[i-1]) + C[i]

print(max(lisA[N-1], lisB[N-1], lisC[N-1]))

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

int main () {
  int n, h, w;
  cin >> n >> h >> w;
  vector<int> a(n), b(n);
  for (int i = 0; i < n; i++) {
    cin >> a.at(i) >> b.at(i);
  }
  int count = 0;
  for (int i = 0; i < n; i++) {
    if (a.at(i) >= h && b.at(i) >= w) count++;
  }
  cout << count << endl;
}

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

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

void solve(){
    string s;
    cin>>s;
    ll cur = 0;
    rep(i,s.size()){
        cur*=16;
        if('0'<=s[i]&&s[i]<='9')cur+=s[i]-'0';
        else cur+=s[i]-'a'+10;
    }
    bool sgn = false;
    if(cur>=1ll<<31){
        cur-=1ll<<31;
        sgn = true;
    }
    rep(i,7)cur*=5;
    if(sgn)cout<<"-";
    cout<<cur/10000000;
    cout<<".";
    string ans = "";
    bool ok = false;
    rep(i,7){
        if(cur%10!=0||ok){
            ans = (char)(cur%10+'0')+ans;
            ok=true;
        }
        cur/=10;
    }
    if(ans=="")ans="0";
    cout<<ans<<endl;
}

int main(){
    int n;
    cin>>n;
    while(n--)solve();
}


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

int main() {
    ios::sync_with_stdio(false); cin.tie(0);
    int a[3],k;
    cin>>a[0]>>a[1]>>a[2];
    cin>>k;

    sort(a,a+3);

    REP(i,k){
        a[2] *= 2;
    }

    int ans = 0;
    REP(i,3) ans += a[i];

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

Measured memory_bytes: 256
n = gets.chomp.to_i

for i in (0...n)
  sdk = []

  c_hline = (0..8).map{[0] * 10}
  c_vline = (0..8).map{[0] * 10}
  c_smbox = (0..8).map{[0] * 10}

  for y in (0..8)
    hl = gets.chomp.split(" ").map{|s| s.to_i}
    sdk.push hl

    for x in (0..8)
      k = sdk[y][x]
      c_hline[y][k] += 1
      c_vline[x][k] += 1
      c_smbox[(y / 3) * 3 + (x / 3)][k] += 1
    end
  end

  puts if i > 0

  for y in (0..8)
    str = ''
    for x in (0..8)
      k = sdk[y][x]
      mark = " "
      if c_hline[y][k] > 1 || c_vline[x][k] > 1 ||
          c_smbox[(y / 3) * 3 + (x / 3)][k] > 1
        mark = "*"
      end

      str += mark + k.to_s
    end
    puts str
  end
end

Measured memory_bytes: 6120
/* {{{ */
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}
/* }}} */

fn main() {
    input! {
        s: chars,
        t: chars
    }
    if s.len() + 1 != t.len() {
        println!("No");
        return;
    }
    if s.iter().zip(t.iter()).all(|(l,r)| l == r) {
        println!("Yes");
    } else {
        println!("No");
    }
}
/* vim:set foldmethod=marker: */


Measured memory_bytes: 2108
import java.util.Scanner;

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


Measured memory_bytes: 26084
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include<time.h>
using namespace std;
typedef long long int llint;
typedef pair<int, int> pint;
typedef vector<bool> vbool;
typedef vector<int> vint;
typedef vector<vint> vvint;
typedef vector<llint> vllint;
typedef vector<vllint> vvllint;
typedef vector<pair<int, int>> vpint;
typedef vector<pair<llint, llint>> vpllint;
#define rep(i,n) for(int i=0;i<n;i++)
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define yes(ans) if(ans)cout<<"yes"<<endl;else cout<<"no"<<endl;
#define Yes(ans) if(ans)cout<<"Yes"<<endl;else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl;else cout<<"NO"<<endl;
#define POSSIBLE(ans) if(ans)cout<<"POSSIBLE"<<endl;else cout<<"IMPOSSIBLE"<<endl;
#define Pi 3.1415926535897932384626
#define coutans rep(i, ans.size())cout << ans[i] << endl;

class UnionFind {
public:
	//親の番号を格納する。親だった場合は-(その集合のサイズ)
	vector<int> Parent;

	//作るときはParentの値を全て-1にする
	//こうすると全てバラバラになる
	UnionFind(int N) {
		Parent = vector<int>(N, -1);
	}

	//Aがどのグループに属しているか調べる
	int root(int A) {
		if (Parent[A] < 0) return A;
		return Parent[A] = root(Parent[A]);
	}

	//自分のいるグループの頂点数を調べる
	int size(int A) {
		return -Parent[root(A)];//親をとってきたい
	}

	//AとBをくっ付ける
	bool connect(int A, int B) {
		//AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
		A = root(A);
		B = root(B);
		if (A == B) {
			//すでにくっついてるからくっ付けない
			return false;
		}

		//大きい方(A)に小さいほう(B)をくっ付けたい
		//大小が逆だったらひっくり返しちゃう。
		if (size(A) < size(B)) swap(A, B);

		//Aのサイズを更新する
		Parent[A] += Parent[B];
		//Bの親をAに変更する
		Parent[B] = A;

		return true;
	}
};

//aとbの最大公約数を求めるよ
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

// 返り値: a と b の最大公約数
// ax + by = gcd(a, b) を満たす (x, y) が格納される
long long extGCD(long long a, long long b, long long& x, long long& y) {
	if (b == 0) {
		x = 1;
		y = 0;
		return a;
	}
	long long d = extGCD(b, a % b, y, x);
	y -= a / b * x;
	return d;
}

bool check(int a, int b) {
	return a > b;
}

// mod. m での a の逆元 a^{-1} を計算する
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

//aCbを1000000007で割った余りを求める
llint convination(llint a, llint b) {
	llint ans = 1;
	for (llint i = 0; i < b; i++) {
		ans *= a - i;
		ans %= 1000000007;
	}
	for (llint i = 1; i <= b; i++) {
		ans *= modinv(i, 1000000007);
		ans %= 1000000007;
	}
	return ans;
}

int main() {
	string s;
	cin >> s;
	string table[3] = { "replace","reverse","print" };
	int n;
	cin >> n;
	vector<string>ans;
	rep(i, n) {
		string t;
		cin >> t;
		int x, y;
		cin >> x >> y;
		if (t == table[0]) {
			cin >> t;
			for (int i = x; i <= y; i++) {
				s[i] = t[i - x];
			}
		}
		else if (t == table[1]) {
			t = s.substr(x, y - x + 1);
			for (int i = x; i <= y; i++) {
				s[i] = t[y - i];
			}
		}
		else {
			ans.push_back(s.substr(x, y - x + 1));
		}
	}
	coutans;
	return 0;
}


Measured memory_bytes: 3208
#include <iostream>
#include <vector>
#include <algorithm>
#define REP(i ,n) for(int i=0 ;i < n; i++)
#define REPB(i ,n) for(int i=n; i >= 0; i--)
#define FOR(i ,m ,n) for(int i=m; i < n; i++)
#define FORB(i, m, n) for(int i=m; i>= m; i--)
#define ll long long
#define pb push_back
using namespace std;

int main(){
    vector<int> a;
    int t,ans;

    REP(i, 3){
        cin >> t;
        a.pb(t);
    } 
        
    
    sort(a.begin(), a.end());

    ans = (a[2] - a[1]) + (a[1] - a[0]);
    cout << ans << endl;
    return 0;
}

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

int main(){
	int n, a, MAX=-1000000, MIN=1000000;
	long int SUM=0;
	cin >>n;
	for(int i=0;i<n ; i++){
	
		cin>>a;
		MAX= max(MAX,a);
		MIN= min(MIN,a);
		SUM= SUM+a;
	}
	cout<< MIN << " " << MAX << " " << SUM << endl;
	return 0;
}

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

using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
typedef long long ll;
#define INF 1e9


 
int main(){
    string s; cin >> s;
    int n = s.size();
    char now = s[0];
    int cnt = 0;
    rep(i,n){
        if(now == s[i]){
            
        }else{
            now = s[i];
            cnt++;
        }
    }
        
    cout << cnt << endl;


}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const int MOD =1e9+7;
using ll=long long;

int c[3][3];
bool j = 1;
int main(){
  rep(i,3)rep(j,3) cin >> c[i][j];
  int sa1 = c[1][0] - c[0][0];
  int sa2 = c[2][0] - c[1][0];
  int sb1 = c[0][1] - c[0][0];
  int sb2 = c[0][2] - c[0][1];
  rep(i,3){
    if(sa1 != c[1][i] - c[0][i]) j = 0;
    if(sa2 != c[2][i] - c[1][i]) j = 0;
    if(sb1 != c[i][1] - c[i][0]) j = 0;
    if(sb2 != c[i][2] - c[i][1]) j = 0;
  }
  cout << ((j) ?"Yes" :"No") << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;
typedef long long ll;
using namespace std;
const ll mod=998244353;
template <class T>inline T lcm(T a,T b){return (a*b/__gcd(a,b));}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,k;
    cin>>n>>k;
    int a;
    int ans=0;
    for(int i=0;i<n;i++){
        cin>>a;
        if(a>=k){
            ans++;
        }
    }
    cout << ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define	 int long long
using namespace std;
const int N = (int)2e5  + 7;
int a[N] , h[N] , t[4 * N] , dp[N];

int get(int v , int tl , int tr , int l , int r)
{
	if(l > tr || tl > r)return 0;
	if(tl <= l && r <= tr)return t[v];
	
	int mid = l + r >> 1;
	
	return max( get(v + v , tl , tr , l , mid ) , get(v + v + 1 , tl , tr , mid+1 , r ) );
}

void upd(int v , int pos , int val , int l , int r)
{
	if(l == r){
		t[v] = val;
		return;
	}
	
	int mid = l + r >> 1;
	
	if(pos <= mid)
		upd(v + v , pos , val , l , mid);
	else
		upd(v + v + 1 , pos , val , mid+1 , r);
	t[v] = max(t[v + v] , t[v + v + 1]);
}


main()
{
	int n;
	cin >> n;
	
	for(int i = 1; i <= n; i++)
		scanf("%I64d" ,&h[i]);
		
	for(int i = 1; i <= n; i++)
		scanf("%I64d" ,&a[i]);
	
	int mx = 0;
	for(int i = 1; i <= n; i++)
	{
		dp[i] = get(1 , 1 , h[i] - 1 , 1 , N ) + a[i];
		upd(1 , h[i] , dp[i] , 1 , N);
		mx = max(mx , dp[i]);
	}
	
	cout << mx << endl;
}


Measured memory_bytes: 11136
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()

typedef long long lint;

using namespace std;

int main(){
  int N;
  cin>>N;
  int A=0;
  int B=0;
  int AB=0;
  int ans=0;
  REP(i,N){
    string S;
    cin>>S;
    REP(j,S.size()-1){
      if(S[j]=='A' and S[j+1]=='B')ans++;
    }
    if(S[0]=='B' and S[S.size()-1]=='A'){
      AB++;
      continue;
    }
    if(S[0]=='B')B++;
    if(S[S.size()-1]=='A')A++;
  }
  cerr<<A<<' '<<B<<' '<<AB<<endl;
  if(AB!=0){
    ans+=AB-1;
    if(A==0 and B==0){
      cout<<ans<<endl;
      return 0;
    }
    A++;
    B++;
  }
  ans+=min(A,B);
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 384
#include <cstdio>
#include <algorithm>

using namespace std;

int main()
{
	int n, m;
	int wf[128][128][2];
	
	while (scanf("%d %d", &n, &m) && n){
		for (int i = 0; i < 128; i++){
			for (int j = 0; j < 128; j++){
				wf[i][j][0] = 100000000 * (i != j);
				wf[i][j][1] = 100000000 * (i != j);
			}
		}
		
		for (int i = 0; i < n; i++){
			int a, b, cost, time;
			scanf("%d %d %d %d", &a, &b, &cost, &time);
			wf[a][b][0] = wf[b][a][0] = min(wf[a][b][0], cost);
			wf[a][b][1] = wf[b][a][1] = min(wf[a][b][1], time);
		}
		
		for (int k = 0; k < 128; k++){
			for (int i = 0; i < 128; i++){
				for (int j = 0; j < 128; j++){
					for (int l = 0; l < 2; l++){
						wf[i][j][l] = min(wf[i][j][l], wf[i][k][l] + wf[k][j][l]);
					}
				}
			}
		}
		
		int q;
		scanf("%d", &q);
		
		for (int i = 0; i < q; i++){
			int a, b, c;
			scanf("%d %d %d", &a, &b, &c);
			printf("%d\n", wf[a][b][c]);
		}
	}
	return (0);
}

Measured memory_bytes: 1156
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[]=new int[n];
		for(int i=1;i<=n;i++) {
			int j=sc.nextInt();
			a[j-1]=i;
		}
		for(int i=0;i<n;i++) {
			 if(i==n-1)
				System.out.println(a[i]);
			 else
				 System.out.print(a[i]+" ");
		}

	}

}


Measured memory_bytes: 61760
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<functional>
#include<string>

typedef long long int ll;

using namespace std;

int main(void){

    string str;
    int ans = 0;

    cin >> str;

    if(str == "SUN") ans = 7;
    else if(str == "MON") ans = 6;
    else if(str == "TUE") ans = 5;
    else if(str == "WED") ans = 4;
    else if(str == "THU") ans = 3;
    else if(str == "FRI") ans = 2;
    else if(str == "SAT") ans = 1;

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp> 
//using namespace boost::multiprecision; 
using namespace std;
#define ll long long int
#define ld long long double
#define vi vector<int>
#define vl vector<ll>
#define pi pair<int, int>
#define pl pair<ll, ll>
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define nl '\n'
#define mp make_pair
#define debug1(x) cout <<#x<<" "<<x<<'\n';
#define debug2(x,y) cout <<#x<<" "<<x <<" "<<#y<<" "<<y <<'\n';
#define debug3(x,y,z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<'\n';
#define fi first
#define se second
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define inf 1e18
const int mod = (int)1e9+7;
pair<ll,ll>s4[4]={{-1,0},{1,0},{0,-1},{0,1}};
pair<ll,ll>s8[8]={{-1,-1},{-1,0},{-1,1},{0,-1},{0,1},{1,1},{1,0},{1,-1}};

void solve() {
    string s,t;
    cin >> s >> t;
    if(s.length()+1 == t.length()) {
        bool flag=true;
        for(int i=0;i<s.length();i++) {
            if(s[i]!=t[i]){
                cout << "No\n";
                return;
            }
        }
        cout << "Yes\n";
    }
    else{
        cout << "No\n";
    }
}

signed main() {
    boost;
    solve();
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);i++)
#define erep(i,a,b) for(int i=a;i<=(int)(b);i++)
#define per(i,a,b) for(int i=(b)-1;i>(a);i--)
#define eper(i,a,b) for(int i=((int)(a));i>=b;i--)
#define pb push_back
#define mp make_pair
#define INF (1<<30)-1
#define MOD 1000000007
using namespace std;
typedef long long ll;
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int gcd(int a,int b){return b?gcd(b,a%b):a;}

string s, t;
char ns[1000], nt[1000];
int main() {
 ios::sync_with_stdio ( false );
 cin.tie ( 0 );
    cin >> s >> t;
    sort(s.begin(), s.end());
    sort(t.begin(), t.end(), greater<char>());
    if (s < t) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


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

int main() {
    int h, w;
    cin >> h >> w;
    vector<string> a(h);
    
    for (int i = 0; i < h; i++) {
        cin >> a[i];
    }
    vector<bool> row(h, false);
    vector<bool> column(w, false);
    
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            if (a[i][j] == '#') {
                row[i] = true;
                column[j] = true;
            }
        }
    }
    for (int i = 0; i < h; i++) {
        if (row[i]) {
            for (int j = 0; j < w; j++) {
                if (column[j]) {
                    cout << a[i][j];
                }
            }
            cout << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <cmath>

#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
const int inf = 1e9;
const ll linf = 1LL << 50;
int a[101], b[101];
ll c[101];

int main(int argc, char const* argv[])
{
  int n;
  cin >> n;
  for(int i = 0; i < n; i++){
    int x, y;
    cin >> x >> y;
    ll h;
    cin >> h;
    a[i] = x;
    b[i] = y;
    c[i] = h;
  }
  for(int i = 0; i < 101; i++){
    for(int j = 0; j < 101; j++){
      set<ll> hs;
      vector<int> vec;
      for(int k = 0; k < n; k++){
        if(c[k] != 0){
          hs.insert(c[k] + abs(i - a[k]) + abs(j - b[k]));
        }else{
          vec.pb(k);
        }
      }
      if(hs.size() == 1 && *(hs.begin()) > 0){
        bool flag = true;
        int H = *(hs.begin());
        for(int k: vec){
          if(H - abs(i - a[k]) - abs(j - b[k]) > 0)flag = false;
        }
        if(!flag)continue;
        cout << i << " " << j << " " << H << endl;
        return 0;
      }
    }
  }
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
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; }
const int INF=1001001001;
const int mod=1e9+7;

int main() {
  int N;
  cin>>N;
  vector<int64_t>dc(N+1);
  for(int i=1;i<=N;i++){
    for(int j=1;j<=N/i;j++){
       dc[i*j]++;
    }
  }
  int64_t sum=0;
  for(int64_t i=1;i<=N;i++){
    sum+=i*dc[i];
  }
  cout<<sum<<endl;
  return 0;
}


Measured memory_bytes: 81376
#include <stdio.h>
int main() {int a=0,b=0,c=0,d;for (int i=0;i<10;i++) {scanf("%d",&d);if (a<=d) c=b,b=a,a=d; else if (b<=d) c=b,b=d; else if (c<d) c=d;}printf("%d\n%d\n%d\n",a,b,c);return 0;}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

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

    vector<int> a(n+2);
    rep(i,n) cin >>a[i+1];
    n += 2;

    int f = 0;
    rep(i,n-1) f += abs(a[i]-a[i+1]);

    for(int i=1; i<=n-2; ++i){
        int ans = f;
        ans -= abs(a[i]-a[i-1]);
        ans -= abs(a[i]-a[i+1]);
        ans += abs(a[i-1]-a[i+1]);
        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 1664
def main():
    a = [1,3,5,7,8,10,12]
    b = [4,6,9,11]
    c = [2]

    x, y = map(int, input().split())

    if x in a and y in a:
        print('Yes')
    elif x in b and y in b:
        print('Yes')
    elif x in c and y in c:
        print('Yes')
    else:
        print('No')

if __name__ == '__main__':
    main()


Measured memory_bytes: 38256
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace ConsoleApp
{
    class Program
    {
        
        static void Main(string[] args)
        {
            var x = long.Parse(ReadLine());
            var prime = new List<long>();
            
            for (int i = 2; i < x;i++)
            {
                bool isPrime = true;
                foreach(var p in prime){
                    if (i % p == 0) { isPrime = false; break; }
                }
                if(isPrime)
                    prime.Add(i);
            }
            long j = x;
            while(true)
            {
                bool isPrime = true;
                foreach(var p in prime){
                    if (j % p == 0)
                    {
                        isPrime = false;
                        break;
                    }
                }
                if (isPrime)
                {
                    prime.Add(j);
                    break;
                }
                j++;
            }

            WriteLine(prime.Last());
        }

       

    }

}


Measured memory_bytes: 13252
//#pragma GCC optimize("O3")
//#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>

using namespace std;

int main()
{
    //freopen("in.txt", "r", stdin);
    // freopen("out.txt", "w", stdout);
    string s;
    cin >> s;
    if (s.back() == 's')
        s.push_back('e');
    s.push_back('s');
    cout << s;
}

Measured memory_bytes: 3636
/* ex6_2: i18n
    Jun_JPN */

#include <stdio.h>
#include <string.h>
#define SIZE 128

int main(void){

    char str[SIZE];
    int length;

    scanf("%s", str);

    length = strlen(str);   // 文字列strの長さを取得

    /* 文字列strの先頭と末尾の文字を配列から取り出し，
        それらの間に「(文字列strの長さ)-2」を挟めば良い */
    printf("%c%d%c\n", str[0], length-2, str[length-1]);

    return 0;
}

Measured memory_bytes: 128
import math
total_sum = 0
def calculate_sum(n,coords,appender):
	i=0
	dist = 0
	while i<n-1:
		first = appender[i]
		second = appender[i+1]
		dist += math.sqrt((coords[first][0]-coords[second][0])**2+(coords[first][1]-coords[second][1])**2)
		i+=1
	return dist


def factorial(n,coords,nos,appender,flag):
	if nos==n:
		global total_sum
		total_sum += calculate_sum(n,coords,appender)
		#print(total_sum)
		return
	else:
		for i in range(n):
			if i not in flag:
				flag.append(i)
				appender.append(i)
				factorial(n,coords,nos+1,appender,flag)
				flag.pop()
				appender.pop()
		return

n = int(input())
coords = [[0]*2 for i in range(n)]
for i in range(n):
	coords[i][0],coords[i][1] = map(int,input().split())
the_nos_fact = 1
for i in range(2,n+1):
	the_nos_fact*=i
factorial(n,coords,0,[],[-1])
print(total_sum/the_nos_fact)

Measured memory_bytes: 3188
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
using namespace std;

int main()
{
	int N;
	string S[2];
	cin >> N;
	cin >> S[0];
	cin >> S[1];

	auto isFirst = true;
	auto isPrevHorizontal = false;
	auto count = 1ull;
	auto mod = 1000000007;
	for (auto i = 0; i < N; ++i)
	{
		auto isNextHorizontal = S[0][i] != S[1][i];

		if (isFirst)
		{
			isFirst = false;
			if (isNextHorizontal)
			{
				count *= 6;
			}
			else
			{
				count *= 3;
			}
		}
		else if(isPrevHorizontal)
		{
			if (isNextHorizontal)
			{
				count *= 3;
			}
		}
		else
		{
			count *= 2;
		}

		if (isNextHorizontal)
		{
			++i;
		}
		isPrevHorizontal = isNextHorizontal;
		count = count % mod;
	}

	cout << count << endl;

	return 0;
}

Measured memory_bytes: 256
import copy

def partition(A, p, r):
    x = A[r][1]
    i = p-1
    for j in range(p, r):
        if A[j][1] <= x:
            i = i+1
            A[i], A[j] = A[j], A[i]

    A[i+1], A[r] = A[r], A[i+1]
    return i+1


def quicksort(A, p, r):
    if p < r:
        q = partition(A, p, r)
        quicksort(A, p, q-1)
        quicksort(A, q+1, r)
        

def merge(A, left, mid, right):
    L = A[left:mid] + [("J", 1000000000) ]
    R = A[mid:right] + [("J", 1000000000)]
    i, j = 0, 0
    for k in range(left, right):
        if L[i][1] <= R[j][1]:
            A[k] = L[i]
            i += 1
        else:
            A[k] = R[j]
            j += 1
            
def mergesort(A, left, right):
    if left + 1 < right:
        mid = (left + right) // 2
        mergesort(A, left, mid)
        mergesort(A, mid, right)
        merge(A, left, mid, right)
    
    
n = int(input())
A_Q = [input() for _ in range(n)]
A_Q = [(i.split()[0], int(i.split()[1])) for i in A_Q]
A_M = copy.deepcopy(A_Q)

quicksort(A_Q, 0, n-1)
mergesort(A_M, 0, n)

A_Q = [f"{str(i[0])} {str(i[1])}"for i in A_Q]
A_M = [f"{str(i[0])} {str(i[1])}"for i in A_M]
if A_Q == A_M:
    print("Stable")
else:
    print("Not stable")
print(*A_Q, sep="\n")



Measured memory_bytes: 29340
fun main(args: Array<String>) {
    val (n, m) = readLine()!!.split(' ').map { it.toInt() }
    val a = readLine()!!.split(' ').map { it.toInt() }.sorted()
    val dists = (0 until m - 1).map { a[it + 1] - a[it] }.sortedDescending()
    val all = a.max()!! - a.min()!!
    println(all - dists.take(n - 1).sum())
}

Measured memory_bytes: 53056
#include<bits/stdc++.h>
#include <algorithm>
#include <cctype>
#include <iostream>
#include <string>
using namespace std;

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

const ll MOD = 1e9+7;

// Combinationの使い方
// vector<vector<ll>> v(N+1, vector<ll>(N+1, 0));
// comb(v);
void comb(vector<vector<ll>> &v){
    for(int i = 0; i < v.size(); i++){
        v[i][0] = 1;
        v[i][i] = 1;
    }
    for(int k = 1; k < v.size(); k++){
        for(int j = 1; j < k; j++){
            v[k][j] = (v[k-1][j-1] + v[k-1][j]);
            //余りを求める問題は毎回計算ごとにやる
            // v[k][j] = (v[k-1][j-1] + v[k-1][j]) % MOD;
        }
    }
}

// Union Find
struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

// vector<tuple<long,long>> items; // (value, weight)
// auto item = items[i];
// long v = get<0>(item);
// long w = get<1>(item);
// long v, w;
//   for( int i = 0; i < N; i++ ){
//     cin >> v >> w;
//     items.push_back( make_tuple(v, w) ); // item : (value, weight)
//   }

// 1 << 3 : int "3" change to bit "100"
// rep(pattern, 1 << N) if (pattern & (1 << x)) cnt++

int main(){
    int N, A;
    cin >> N >> A;
    if(N % 500 <= A) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<deque>
#include<queue>
#include<stack>
using namespace std;
#define int long long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define dup(x,y) (((x)+(y)-1)/(y))
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef pair<int, int>P;
//const int MOD = 1e9 + 7;
//const int MOD = 998244353;
const int INF = 1e18;
const long double PI = (acos(-1));


signed main() {
	int N, X, M;
	cin >> N >> X >> M;
	vector<int>v;
	int x = X % M;
	int start;
	map<int, int> m;
	rep(i, N + 5) {
		v.push_back(x);
		m[x]++;
		x = (x * x) % M;
		if (m[x]) {
			for (int j = 0; j < 100005; j++) {
				if (v[j] == x) {
					start = j;
					break;
				}
			}
			break;
		}
	}
	int ans = 0;
	if (N <= start) {
		rep(i, N)ans += v[i];
		cout << ans;
		return 0;
	}
	rep(i, start)ans += v[i];
	N -= start;
	int cycle = v.size() - start;
	int sum = 0;
	rep(i, cycle)sum += v[start + i];
	int loop = N / cycle;
	ans += loop * sum;
	if (N % cycle) {
		rep(i, N% cycle)ans += v[start + i];
	}
	cout << ans;
}

Measured memory_bytes: 6772
#include <cassert>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <complex>
#include <chrono>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>
#include <random>
#include <memory>
#include <utility>
#include <limits>
#include "limits.h"
 
#define rep(i, a, b) for (long long (i) = (a); i < (b); i++)
#define all(i) i.begin(), i.end()
#define debug(...) std::cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

void debug_out(){std::cerr<<std::endl;}

template<typename Head,typename... Tail>
void debug_out(Head h,Tail... t){
  std::cerr<<" "<<h;
  debug_out(t...);
}
 
template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, std::pair<T1, T2> pa) {
  return os << pa.first << " " << pa.second;
}
 
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (int i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}
 
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);}
 
long long pow_mod(long long a, long long b, long long mod=-1) {
  if(b==0)return 1;
  if ((a == 0)||(mod!=-1&&(a+mod)%mod==0)) {
    return 0;
  }
  long long x = 1;
  while (b > 0) {
    if (b & 1) {
      x = (mod!=-1)?(x * a) % mod:x*a;
    }
    a = (mod!=-1)?(a * a) % mod:a*a;
    b >>= 1;
  }
  return x;
}

// const long long MOD = 998244353;
const long long MOD = 1e9 + 7;

using ll = long long;
using P=std::pair<long long,long long>;

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

  ll n;
  std::cin>>n;

  std::vector<ll> s(n);
  rep(i,0,n)std::cin>>s[i];

  ll ans=0;

  rep(c,1,n-1){
    ll val=0;
    for(ll k=1;k*c<n-1;k++){
      ll a=n-1-c*k;
      val+=s[c*k]+s[a];
      if(a<=c)continue;
      if(a%c==0&&a/c<=k)continue;
      chmax(ans,val);
    }
  }

  std::cout<<ans<<"\n";

  return 0;
}

Measured memory_bytes: 1024
# include<iostream>
# include<cmath>
# include<algorithm>

using namespace std;

int main(void){
  int n, l, min_=1000, sum=0;
  cin >> n >> l;
  for(int i=1; i<=n; i++){
    sum += l + i - 1;
    min_ = abs(min_) > abs(l + i - 1)? l + i - 1 : min_;
  }
  cout << sum - min_ << endl;
  return 0;
}

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

#define NREP() for(ll i = 0; i < n; i++)
#define MREP() for(ll j = 0; j < m; j++)
#define REP(i, n) for(ll i = 0; i < n; i++)
#define ALL(x) (x).begin(), (x).end()
#define MSG(x) cout << x << endl;
#define IPT(t, x) t ipt; cin >> ipt; x.push_back(ipt);
#define YN(x) x ? cout << "YES" << endl : cout << "NO" << endl;
#define Yn(x) x ? cout << "Yes" << endl : cout << "No" << endl;
#define yn(x) x ? cout << "yes" << endl : cout << "no" << endl;

using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;

const static ll MOD = 1e9 + 7;
ll n, cnt, ans, tmp, sum, minimum, maximum, a, b, c, d, k, m, h, w, q, x, y;
string s, t;

int main() {
    cin >> s >> t;

    REP(i, s.size()) {
        string tmp = s.substr(i, s.size()-i) + s.substr(0, i);
        if (tmp == t) {
            MSG("Yes")
            exit(0);
        }
    }
    MSG("No")
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
#define F first
#define S second
using ll = long long;
#define ull unsigned ll
#define endl "\n"
#define vi vector<int>
#define vl vector<ll>
#define all(v) (v).begin(),(v).end()
#define mst(a,b) memset(a,b,sizeof(a))
#define pii pair<int,int>
#define pll pair<ll,ll>
#define ppi pair<int, pii>
#define mt make_tuple
#define eb emplace_back
#define pcii pair<char, pair<int, int>>
using namespace std;

const ll N = 105, mod = 1e9 + 7;
const int inf = 1e9;

void solve(){
    int n;
    cin >> n;
    vi a(n), b(n), c(n);
    for(int i = 0; i < n; i++){
        cin >> a[i] >> b[i] >> c[i];
    }
    vector<vi> dp(n, vi(3, inf));
    dp[0][0] = a[0];
    dp[0][1] = b[0];
    dp[0][2] = c[0];
    for(int i = 1; i < n; i++){
        dp[i][0] = a[i] + max(dp[i - 1][1], dp[i - 1][2]);
        dp[i][1] = b[i] + max(dp[i - 1][0], dp[i - 1][2]);
        dp[i][2] = c[i] + max(dp[i - 1][0], dp[i - 1][1]);
    }
    cout << max(dp[n - 1][0], max(dp[n - 1][1], dp[n - 1][2])) << endl;
}

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    ll t,p;
    t=1;
    //cin>>t;
    for(p=1;p<=t;p++){
        solve();
    }
    return 0;
}


Measured memory_bytes: 9800
using System;
using System.Linq;

namespace AtCoder {
	class Program {
		public static void Main() {
			int[] input = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
			int x1 = input[0];
			int y1 = input[1];
			int x2 = input[2];
			int y2 = input[3];
			int x3 = x2 + (y1 - y2);
			int y3 = y2 + (x2 - x1);
			int x4 = x3 + (y2 - y3);
			int y4 = y3 + (x3 - x2);
			Console.WriteLine($"{x3} {y3} {x4} {y4}");
		}
	}
}


Measured memory_bytes: 13396
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using ll = long long;
using P = pair<int, int>;
ll GCD(ll a, ll b) { return b?GCD(b, a%b):a; }
ll LCM(ll a, ll b) { return a/GCD(a, b)*b; }

template <class T>
class SegTree {
    int n;
    vector<T> data;
    T def;
    function<T(T, T)> operation;
    function<T(T, T)> update;

    // 区間[a,b)の処理。ノードk=[l,r)に着目
    // 要素の取得は最上段から再帰していく
    // [a,b):クエリの要求範囲, [l,r):ノードの対象範囲, k:高さ
    T _query(int a, int b, int k, int l, int r) {
        if(r <= a || b <= l) return def;    // 要求区間外は単位元
        if(a <= l && r <= b) return data[k];    // 要求区間を完全に包含
        else {
            // 要求区間が対象区間を一部含むときは子を辿る
            T c1 = _query(a, b, 2*k+1, l, (l+r)/2);
            T c2 = _query(a, b, 2*k+2, (l+r)/2, r);
            return operation(c1, c2);
        }
    }

  public:
    // _n:必要サイズ, _def:初期値または単位元, _operation:クエリ関数
    // _update:更新関数
    SegTree(size_t _n, T _def, function<T(T, T)> _operation, function<T(T, T)> _update)
        : def(_def), operation(_operation), update(_update) {
        n = 1;
        while(n < _n) {
            n *= 2;
        }
        data = vector<T>(2*n-1, def);
    }

    // 場所i(0-indexed)の値をxで更新
    void change(int i, T x) {
        i += n-1;
        data[i] = update(data[i], x);
        while(i > 0) {
            i = (i-1) / 2;
            data[i] = operation(data[2*i+1], data[2*i+2]);
        }
    }

    // [a,b)の区間クエリを実行
    T query(int a, int b) {
        return _query(a, b, 0, 0, n);
    }

    // 添え字でアクセス
    T operator[](int i) {
        return data[i+n-1];
    }
};

int main() {
    int N, q; cin >> N >> q;
    SegTree<ll> seg(N, 0,
                        [](ll a, ll b){ return a+b; },
                        [](ll a, ll b){ return a+b; });
    for(int i = 0; i < q; ++i) {
        ll c, x, y; cin >> c >> x >> y;
        if(c == 0) seg.change(x-1, y);
        else cout << seg.query(x-1, y) << endl;
    }
}


Measured memory_bytes: 4952
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>

using namespace std;

#define PB push_back
#define MP make_pair

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vii;

const int MOD = 1e9+7;
const int INF = 1e9;

int main() {
  ll x, y, tmp;
  cin >> x >> y;
  if (x % y == 0) {
    cout << -1 << endl;
    return 0;
  }
  for (int i = 1;; i++) {
    tmp = x * i;
    if (tmp % y != 0) {
      cout << tmp << endl;
      break;
    }
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>

using namespace std;

int main(){

	string A, B;
	cin >> A >> B;

	int i;

	if(A.size() > B.size()){
		cout << "GREATER\n";
		return 0;
	}else if (A.size() < B.size()){
		cout << "LESS\n";
	}else {
		for(i = 0; i < A.size(); i++){
			
			if(A[i] > B[i]){
				cout << "GREATER\n";
				return 0;
			}else if(A[i] < B[i]){
				cout << "LESS\n";
				return 0;
			}

		}	
		cout << "EQUAL\n";
                return 0;

	}


}

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

map<int, int> m;
int main() {
  int x, n;
  cin >> x >> n;
  for (int i = 0; i < n; i++) {
   	int a; cin >> a;
   	m[a] = 1;
  }
  for (int i = 0;; i++) {
    if (!m[x - i]) {
      cout << x - i << endl;
      return 0;
    }
    if (!m[x + i]) {
      cout << x + i << endl;
      return 0;
    }
  }
}

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

using namespace std;

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

#define fi first
#define se second
#define mp make_pair
#define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

int main(){
  fastIO;
  int n;
  cin >> n;
  vector<pii> f;
  int a;
  for(int i = 1; i <= n; i ++ ){
    cin >> a;
    f.push_back(mp(a,i));
  }
  sort(f.begin(), f.end());
  for(int i = 0 ; i < n ;i ++ )
    cout << f[i].se << " ";
  return 0;
}

Measured memory_bytes: 1780
#include <iostream>
#include <sstream>
#include <math.h>
#include <algorithm>
using namespace std;
int main(){
    int a,b,c;
    cin >> a >> b >> c;
    if(a < b && b < c){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 3088
import sys
def input(): return sys.stdin.readline().rstrip()

def main():
    N = int(input())
    BTC_RATE = 380000
    ans = 0
    for _ in range(N):
        x, u = input().split()
        x = float(x)
        if u == 'BTC':
            x *= BTC_RATE
        ans += x
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<bool> vb;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define in insert
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int INF = 1e9 + 5;
const int  N = 2e5 + 314;
void foo(){
    int n, q, k;
    cin>>n>>q>>k;
    map<int, int>mp;
    for(int i = 0; i < k; i++){
        int x;
        cin>>x;
        mp[x]++;
    }
    for(int i = 1; i <= n; i++){
        if(q+mp[i]-k>0)cout<<"Yes"<<"\n";
        else cout<<"No"<<"\n";
    }
}
int main(){
    speed;
    int t=1;
    //cin>>t;
    while(t--)foo();
}

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

double dist[11][11];
string input;
int len, r;
vector<int> v;

void prepare() {
    int a, b, n = v.size();
    for (int i=0; i<n; ++i) {
        for (int j=0; j<n; ++j) {
            a = v[i];
            b = v[j];
            dist[a][b] = sqrt(pow(b + a, 2) - pow(b - a, 2));
            dist[b][a] = dist[a][b];
        }
    }
}

double getWidth(vector<int> &v1, vector<int> &v2) {
    int n = v1.size();
    int m = v2.size();
    double sum = v1[0] + (n == m ? v2[m-1] : v1[n-1]);
    for (int i=0; i<n; ++i) {
        if (i < n && i < m) sum += dist[v1[i]][v2[i]];
        if (i+1 < n && i < m) sum += dist[v2[i]][v1[i+1]];
    }
    return sum;
}

bool solve(vector<int> v1, vector<int> v2) {
    if (v1.size() < v2.size()) swap(v1, v2);
    do {
        sort(v2.begin(), v2.end());
        do {
            if (getWidth(v1, v2) < len + 1e-6) {
                return true;
            }
        } while (next_permutation(v2.begin(), v2.end()));
    } while (next_permutation(v1.begin(), v1.end()));
    return false;
}

int main() {
    while (getline(cin, input)) {
        stringstream ss(input);
        ss >> len;
        v.clear();
        while (ss >> r) {
            v.push_back(r);
        }
        sort(v.begin(), v.end());
        prepare();
        int siz = v.size();
        int n = siz / 2 + (siz % 2);
        int m = siz / 2;
        bool ok = solve(vector<int>(v.begin(), v.begin() + n),
                        vector<int>(v.end() - m, v.end()));
        if ( ! ok) {
            ok |= solve(vector<int>(v.end() - n, v.end()),
                        vector<int>(v.begin(), v.begin() + m));
        }
        cout << (ok ? "OK" : "NA") << endl;
    }
    return 0;
}

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

const int MX = 10010;
int N;
vector<int> A;
bool isprime[MX + 1];

vector<int> divisor(int M) {
    vector<int> prime;
    for (int i = 2; i * i <= M; ++i) {
        int cnt = 0;
        while (M % i == 0) {
            ++cnt;
            M /= i;
        }
        if (cnt) prime.emplace_back(i);
    }
    if (M != 1) prime.emplace_back(M);
    return prime;
}

signed main() {
    cin >> N;
    A.resize(N + 1);
    for (auto& e: A) cin >> e;
    reverse(A.begin(), A.end());

    auto valid = [&](int p) -> bool {
        auto B(A);
        for (auto& e: B) e = (e % p + p) % p;
        for (int i = N; i >= 0; --i) {
            if (B[i] == 0) continue;
            int j = i - (p - 1);
            if (j < 0) return false;
            B[j] += B[i];
            B[j] %= p;
            B[i] = 0;
        }
        return true;
    };

    set<int> prime;

    if (A[0] == 0) {
        // eratosthenes
        REP(i, MX + 1) isprime[i] = true;
        for (int i = 2; i * i <= MX; ++i) {
            if (not isprime[i]) continue;
            for (int j = 2 * i; j <= MX; j += i) {
                isprime[j] = false;
            }
        }
        REP(i, min(2, MX)) isprime[i] = false;
        REP(i, MX + 1) if (isprime[i]) prime.emplace(i);
        // prime divisor of gcd
        int g = 0;
        for (auto& e: A) g = gcd(g, e);
        for (auto& e: divisor(g)) prime.emplace(e);
    } else {
        // prime divisor
        for (auto& e: divisor(abs(A[0]))) prime.emplace(e);
    }

    // for (auto& e: prime) cerr << e << endl;

    for (auto& e: prime) {
        if (valid(e)) {
            cout << e << endl;
        }
    }
}


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

int main(){
    string s;
    cin >> s;
    int ans = 0;
    int t = 0;
    for(int i = 0; i < s.size();i++){
        if(s.at(i) == 'R')t++;
        else{
            ans = max(ans,t);
            t=0;
        }
    }
    ans = max(ans,t);
    cout << ans << endl;
    
}

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

int main() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  
  int n;
  cin >> n;
  int ans = 0;
  int MAX = -1;
  int MIN = 1e5;
  int mx = MAX;
  int mn = MIN;
  rep(i, n) {
    int a;
    cin >> a;
    mx = max(mx, a);
    mn = min(mn, a);
  }
  ans = mx - mn;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3608