akhauriyash/Code-Regression huggingface dataset:
#include <iostream>

typedef long long ll;

#define FOR(i,a,b) for(ll i = (a);i < (b);++i)
#define REP(i,n) FOR(i,0,n)

#define debug(x) cout << #x << "=" << x << endl;

using namespace std;

char a[52][52];

int main(void){

  int H,W;
  cin >> H >> W;

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

  fill(a[0],a[52],'.');

  FOR(i,1,H+1) FOR(j,1,W+1) cin >> a[i][j];

  FOR(i,1,H) {
    FOR(j,1,W) {
      if(a[i][j] == '.') continue;
      bool flag = false;
      REP(ind,4) {
        if(a[i][j] == '#' and a[i+dx[ind]][j+dy[ind]] == '#') flag = true;
      }
      if(!flag){ cout << "No" << endl; return 0;}
    }
  }

  cout << "Yes" << endl;

  return 0;
}

Measured memory_bytes: 256
while true
	h, w = gets.split( " " ).map { | val | val.to_i }
	break if 0 == h && 0 == w

	for i in ( 0 ... h ) 
		for j in ( 0 ... w )
			if 0 == (i+j)%2
				print( "#" )
			else
				print( "." )
			end
		end
		print( "\n" )
	end
	print( "\n" )
end

Measured memory_bytes: 6108
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>

#define For(i, j, k) for(int i = j; i <= k; i++)

const int N = 100010;

double A[N];
int n, m, pos[N], op[N], C[N], P[N], tmp[N];
long long k;

void mul(int *u, int *v){
	For(i, 1, n - 1) tmp[i] = v[u[i]];
	For(i, 1, n - 1) u[i] = tmp[i];
}

int main(){
	scanf("%d", &n);
	For(i, 1, n) scanf("%lf", &A[i]), pos[i] = C[i] = i;
	scanf("%d%lld", &m, &k);
	For(i, 1, m) scanf("%d", &op[i]), std::swap(pos[op[i]], pos[op[i] - 1]);
	For(i, 1, n - 1) P[pos[i]] = i;

	while(k){
		if(k & 1) mul(C, P);
		mul(P, P);
		k >>= 1;
	}

	For(i, 1, n - 1) pos[C[i]] = i;

	double now = A[1];
	printf("%.10lf\n", now);
	For(i, 1, n - 1) printf("%.10lf\n", now += A[pos[i] + 1] - A[pos[i]]);

	return 0;
}

Measured memory_bytes: 5120
#include<bits/stdc++.h>
using namespace std;
const long long INF = 123456789;
const long long MOD = 1000000007;
const long double PI = 3.1415926;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
typedef long long int ll;
typedef vector<ll> vi;
typedef vector < pair<ll, ll > > vp;
typedef vector <string> vs;
typedef vector <char> vc;
typedef list <ll> lst;

ll n, m, k, ans = 0, sum = 0, cnt = 0;
string s;
char c;

#define Endl endl

/*--------------------template--------------------*/

int main() {
    cin >> n;
    m = n;
    while(1){
        if(n==0){
            break;
        }
        sum += n % 10;
        n /= 10;
    }
    cout << ((m % sum == 0) ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <algorithm>
#include <climits>
#include <vector>
#include <string>
#include <set>
#include <iomanip>
#include <map>
#include <stdio.h>
#include <queue>
#include <unordered_set>
#define rep(i,n) for (int i=0;i<(n);++i)
#define REP(i,n) for (int i=0;i<=(n);++i)
#define all(x) (x).begin(), (x).end()

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

using namespace std;
typedef long long ll;
const int INF = 10000000;

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

    unordered_set<int> p;
    rep(i, n){
        int a;
        cin >> a;
        p.insert(a);
    }

    for(int i = 0; i <= 200; ++i) {
        if(p.find(x-i) == p.end()) {
            cout << x - i << endl;
            return 0;
        }
        if(p.find(x+i) == p.end()) {
            cout << x + i << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 3588
#include<bits/stdc++.h>
using namespace std;
#define ll long long int



int main()
{
    //freopen("in.txt","r",stdin);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,m,k;
    cin>>n>>m>>k;
    if((n==5&&m==5&&k==7)||(n==5&&m==7&&k==5)||(n==7&&m==5&&k==5))
    	cout<<"YES"<<endl;
    else
    	cout<<"NO"<<endl;
   
    return 0;
}

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

import math
import bisect

N,M = map(int,input().split())
S = input()

if "1"*M in S:
  print(-1)
  exit()  

S = [int(S[i]) for i in range(N+1)]

L = [(1<<i) -1 for i in range(1,M+1)]

max_n = [0]
mask = (1<<M) -1
b = 0
for i in range(N):
  b = ((b<<1) + (1- S[i])) & mask
  max_n.append(bisect.bisect_left(L,b)+1)

now = N
deme = []
while now != 0:
  x = max_n[now]
  now -= x
  deme.append(x)
print(*deme[::-1])

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

#define MOD 1000000007LL

int main(void)
{
  int n;
  cin >> n;
  
  long long power = 1;
  for (int i = 1; i <= n; i++)
  {
  	power = power * i % MOD;
  }
  
  cout << power << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    int a, b, c;
    cin >> a >> b;
    if (b == 1) {
        cout << 0;
        return 0;
    }
    b -= a;
    c = 1;
    while (b > 0) b -= a - 1, c++;
    cout << c;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
#define Priq priority_queue<int,vi,greater<int>>
#define pb push_back
#define mp make_pair
signed main(){
  int N; cin>>N;
  vi A(2*N);
  rep(i,0,2*N) cin>>A[i];
  sort(ALL(A));
  int ans=0;
  rep(i,0,N) ans+=A[i*2];
  cout<<ans<<endl;
  }


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//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; }

const int MAX = 10555;
const string INF = "-";
string dp[MAX];

void chmax(string &a, string b){
    if(b.size() > a.size()) a = b;
    else if(b.size() < a.size()) a = a;
    else{
        if(b > a) a = b;
    }
}

int main(){
    int N, M; cin >> N >> M;
    int match[9] = {2,5,5,4,5,6,3,7,6};
    vector<int> A(M);
    for(int i=0; i<M; i++) cin >> A[i];

    for(int i=0; i<MAX; i++) dp[i] = INF;
    dp[0] = "";
    //配るdpをする。0から、ちょうどi個で作れる部分だけ遷移していくイメージ
    for(int i=0; i<N; i++){
        if(dp[i] == INF) continue;
        for(int j=0; j<A.size(); j++){
            chmax(dp[i+match[A[j]-1]], dp[i]+(char)('0'+A[j]));
        }
    }

    cout << dp[N] << endl;
}

Measured memory_bytes: 43776
package main

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

func main() {
	var n int
	fmt.Scan(&n)

	sc := bufio.NewScanner(os.Stdin)
	a := make([]int, n)
	max1, max2 := 0, 0
	for i := 0; i < n; i++ {
		sc.Scan()
		a[i], _ = strconv.Atoi(sc.Text())
		if a[i] > max1 {
			max1, max2 = a[i], max1
			continue
		}
		if a[i] > max2 {
			max2 = a[i]
		}
	}

	for _, v := range a {
		if v == max1 {
			fmt.Println(max2)
			continue
		}
		fmt.Println(max1)
	}
}


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

int main() {
    
    int N , K , Q;
    cin >> N >> K >> Q;
    int A[Q];

    for(int i = 0; i < Q; i++){
        cin >> A[i];
    }
    vector<int> score(N, K - Q);

    for(int i = 0; i < Q; i++){
        score[A[i] - 1]++;
    }

    for(auto v:score){
        if(v <= 0)
            cout << "No" << endl;
        else 
            cout << "Yes" << endl;
    }
 
    // for(int i = 0; i < Q; i++){
    //     cin >> A[i];
    // }
    // vector<int> score(N, K);

    // for(int i = 0; i < Q; i++){
    //     int a = A[i];
    //     for(int j = 0; j < N; j++){
    //         if(j != A[i] - 1){
    //             score[j]--;
    //         }
    //     }
    // }

    // for(auto v:score){
    //     if(v <= 0)
    //         cout << "No" << endl;
    //     else 
    //         cout << "Yes" << endl;
    // }
    

    return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define INF 1e9
#define endl '\n'
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); --i)
#define FORE(i, a, b) for (int i = (a), e = (b); i < e; ++i)
#define RFORE(i, a, b) for (int i = (b)-1, e = (a); i >= e; --i)
#define ALL(x) (x).begin(), (x).end()
#define SORT(c) sort((c).begin(), (c).end())
#define SORTR(c) sort((c).begin(), (c).end(), greater<int>())
using namespace std;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int N;
    cin >> N;
    vector<int> a(3 * N);
    for (int i = 0; i < 3 * N; i++) {
        cin >> a.at(i);
    }
    SORTR(a);
    long long ans = 0;
    FOR(i, 0, N) {
        ans += a.at(i * 2 + 1);
    }
    cout << ans << endl;
}


Measured memory_bytes: 4488
// clang-format off
#include <bits/stdc++.h>

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (int i = 0; i < int(n); i++)
#define forn1(i,n) for (int i = 1; i <= int(n); i++)
#define popcnt __builtin_popcount
#define ffs __builtin_ffs
#define ctz __builtin_ctz
#define clz __builtin_clz
#define all(a) (a).begin(), (a).end()
 
using namespace std;

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
using pil = pair<int,ll>;
using pll = pair<ll,ll>;
template <typename T> using vec = vector<T>;
using vi = vec<int>;
using vl = vec<ll>;
template <typename T> using que = queue<T>;
template <typename T> using deq = deque<T>;

template <typename T> T id(T b) {return b;};
template <typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template <typename T> void chmin(T &x, T y) {if (x > y) x = y;}
template<typename S, typename K> bool contains(S &s, K k) { return s.find(k) != s.end(); }
void fastio() { ios_base::sync_with_stdio(false); cin.tie(nullptr); }
constexpr ll TEN(int n) { if (n == 0) return 1LL; else return 10LL*TEN(n-1); }
// clang-format on

const ll MOD = TEN(9) + 7;
template <long long mod>
long long mod_pow(long long a, long long b) {
    if (b == 0) return 1;
    long long ret = mod_pow<mod>(a, b / 2);
    ret = ret * ret % mod;
    if (b % 2 == 1) ret = a * ret % mod;
    return ret;
}

int main() {
    fastio();

    map<pll, ll> cnt1, cnt2;
    ll z = 0, z1 = 0, z2 = 0;

    int n;
    cin >> n;
    forn(i, n) {
        ll a, b;
        cin >> a >> b;

        if (a == 0 && b == 0) {
            z++;
            continue;
        }

        if (a == 0) {
            z1++;
            continue;
        }

        if (b == 0) {
            z2++;
            continue;
        }

        ll g = gcd(a, b);
        a /= g, b /= g;

        if ((a >= 0 && b >= 0) || (a < 0 && b < 0)) {
            cnt1[mp(abs(a), abs(b))]++;
        } else {
            cnt2[mp(abs(a), abs(b))]++;
        }
    }

    ll ans = (mod_pow<MOD>(2, z1) + mod_pow<MOD>(2, z2) - 1 + MOD) % MOD;

    for (auto [p, c1] : cnt1) {
        auto [a, b] = p;

        ll c2 = cnt2[mp(b, a)];
        ll temp = (mod_pow<MOD>(2, c1) + mod_pow<MOD>(2, c2) - 1 + MOD) % MOD;
        cnt2.erase(mp(b, a));
        ans = ans * temp % MOD;
    }

    for (auto [p, c2] : cnt2) {
        ll temp = mod_pow<MOD>(2, c2);
        ans = ans * temp % MOD;
    }

    ans = (ans + z) % MOD;

    cout << (ans - 1 + MOD) % MOD << endl;

    return 0;
}

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

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

#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define test() int t;cin>>t;for(int test=1;test<=t;test++)
#define pb push_back
#define nl cout<<"\n"
#define F first
#define S second
#define all(x) x.begin(),x.end()

template<class C> void min_self( C &a, C b ){ a = min(a,b); }
template<class C> void max_self( C &a, C b ){ a = max(a,b); }

const ll MOD = 1000000007;
ll mod( ll n, ll m=MOD ){ n%=m,n+=m,n%=m;return n; }

const int MAXN = 1e5+5;
const int LOGN = 21;
const ll INF = 1e14;
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};

template<class T1, class T2> void add( T1 &x, T2 y, ll m = MOD )
{
    x += y;
    if( x >= m )
        x -= m;
}

template<class T1, class T2> void sub( T1 &x, T2 y, ll m = MOD )
{
    x -= y;
    if( x < 0 )
        x += m;
}

int cnt[4005][4];

int main() 
{
    fastio();

    int n;
    string s;
    cin>>n>>s;

    for(int i=0;i<n;i++)
    {
        for(int j=0;j<3;j++)
            cnt[i+1][j] = cnt[i][j];

        if( s[i] == 'R' )
            s[i] = 'A';
        else if( s[i] == 'G' )
            s[i] = 'C';

        cnt[i+1][s[i]-'A']++;
    }

    ll ans = 0;
    for(int i=0;i<n;i++)
    {
        for(int k=i+1;k<n;k++)
        {
            if( s[i] == s[k] )
                continue;

            int other = 3 - ( s[i] - 'A' ) - ( s[k] - 'A' );

            ans += cnt[k][other] - cnt[i+1][other];

            int j = (i+k)/2;
            if( 2*j == i+k && s[j] - 'A' == other )
                ans--;
        }
    }
    cout<<ans,nl;
    cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
    return 0;
}


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

typedef long long ll;
typedef vector<ll> v1;
typedef vector<v1> v2;

typedef vector<vector<ll>> graph;

const ll INF = 1ll << 50;
const ll mod = 1000000007;

ll n;
ll a[100000];
ll b[100000];

int main(){
    cin >> n;
    for(ll i = 0;i < n;i++) cin >> a[i] >> b[i];
    cout << a[min_element(b,b+n)-b]+(*min_element(b,b+n)) << endl;
}


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

using ll = long long;

ll gcd(ll a, ll b) {
	return b == 0 ? a : gcd(b, a % b);
}

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

	ll n, x;
	cin >> n >> x;
	vector<ll> a(n);
	set<ll> s;
	for (auto& e : a) {
		cin >> e;
	}
	a.push_back(x);
	sort(a.begin(), a.end());
	ll ans = 0;//abs(a[0] - a[1]);
	for (int i = 1; i < a.size(); i++) {
		// ans = min(ans, abs(a[i - 1] - a[i]));
		ans = gcd(ans, a[i] - a[i - 1]);
	}

	cout << ans << "\n";

}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define co cout
#define ci cin
#define sf1(n) scanf("%lld",&n);
#define sf2(n,m) scanf("%lld %lld",&n,&m);
#define sf3(n,m,p) scanf("%lld %lld %lld",&n,&m,&p);
#define en cout<<endl;
#define pb push_back
#define coy cout<< "YES"<<endl;
#define con cout<< "NO"<<endl;
#define For(a,b) for(ll a=0;a<b;a++)
#define br break;
#define i64 long long
i64 M=10000000;
//ll b[805],ans[805];
map< ll,pair<ll,ll> >mp;

int main()
{
    ll t,n,g,k,m,mx=0,mn=1e9,res,c1,x,y,c2;
    ci>>n>>m;
    ll a[n];
    for(ll i=0;i<n;i++)
    {
        ci>>a[i];
        if(a[i]>=m) mx++;
    }
    co<<mx;
}



Measured memory_bytes: 1024
def solve():
    N = int(input())
    S = input()

    if N % 2 != 0:
        print('No')
        exit()
    s_1 = S[:len(S)//2]
    s_2 = S[len(S)//2:]
    if s_1 == s_2:
        print('Yes')
    else:
        print('No')


if __name__ == '__main__':
    solve()

Measured memory_bytes: 3060
import java.util.*;

public class Main{
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		ArrayList<Integer> R = new ArrayList<Integer>();
		int n, max = -1000000000, minR;
		
		n = sc.nextInt();
		for(int i = 0; i < n; i++){
			R.add(sc.nextInt());
		}
		
		minR = R.get(0);
		for(int i = 1; i < n; i++){
			max = Math.max(max, R.get(i)-minR);
			minR = Math.min(minR, R.get(i));
		}
		
		System.out.println(max);
	}
}

Measured memory_bytes: 106088
#include <bits/stdc++.h>
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;

#define REP(i, n) for (int i = 0; i < (n); i++)
#define int long long
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define all(x) x.begin(), x.end()
using pii = pair<int, int>;
using ll = long long;
const int INF = 1e9;

struct Data {
    int rem, t, c;
    bool operator<(const Data &a) const { return rem < a.rem; }
};
bool solve() {
    int N;
    cin >> N;
    if (N == 0) return false;
    vector<int> C(N), T(N);
    vector<pii> v(N);
    REP(i, N) {
        cin >> T[i] >> C[i];
        C[i]--;
        v[i] = {T[i], C[i]};
    }
    vector<deque<Data>> deq(2);
    sort(all(v));
    int sum = 0;
    REP(i, N) { deq[0].push_back({v[i].first, v[i].first, v[i].second}); }
    while (true) {
        if (deq[0].empty() && deq[1].empty()) break;
        bool go = true;
        int mn = 1e9;
        if (!deq[0].empty()) {
            mn = min(mn, deq[0].front().rem);
                }
        if (!deq[1].empty()) mn = min(mn, deq[1].front().rem);
        if (deq[0].empty()) go = false;
        if (!deq[1].empty() && deq[1].front().rem < deq[0].front().rem) go = false;
        vector<Data> nxtret, nxtgo;
        if (true) {
            while (!deq[0].empty()) {
                Data d = deq[0].front();
                if (d.rem > mn) break;
                deq[0].pop_front();
                nxtret.push_back({d.t, d.t, d.c});
            }
            REP(i, deq[0].size()) { deq[0][i].rem -= mn; }
            while (!deq[1].empty()) {
                Data d = deq[1].front();
                if (d.rem > mn) break;
                deq[1].pop_front();
                if (d.c) nxtgo.push_back({d.t, d.t, d.c - 1});
            }
            REP(i, deq[1].size()) { deq[1][i].rem -= mn; }
            sort(all(nxtgo));
            sort(all(nxtret));
            for (auto d : nxtgo) {
                deq[0].push_back(d);
            };
            for (auto d : nxtret) {
                deq[1].push_back(d);
            }
            sum += mn;
        }
    }
    cout << sum << endl;
    return true;
}

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



Measured memory_bytes: 3140
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,n) for(int i=0;i<(n);i++)
#define MOD 1000000007
#define all(n) (n).begin(),(n).end()
typedef long long ll;
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}else{return 0;}}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}else{return 0;}}
template <class T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template <class T> inline T LCM(T a,T b){return a*b/GCD(a,b);}

int main(){
	
	int n,m;
	cin >> n >> m;
	ll p[100010],y[100010];
	vector<ll> v[100010];
	FOR(i,m){
		cin >> p[i] >> y[i];
		v[p[i]].push_back(y[i]);
	}
	FOR(i,n){
		sort(all(v[i+1]));
	}

	FOR(i,m){
		printf("%012lld\n",p[i]*1000000+(lower_bound(all(v[p[i]]),y[i])-v[p[i]].begin())+1);
	}





}

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

int main(){
	string t[12];

	while (cin >> t[0]){
		for (int i = 1; i < 12; i++){
			cin >> t[i];
		}

		stack <int> s1, s2;
		int island = 0;

		for (int x = 0; x < 12; x++){
			for (int y = 0; y < 12; y++){
				if (t[x][y] == '1'){
					island++;
					s1.push(x);
					s2.push(y);
					while (!s1.empty()){
						int X = s1.top();
						int Y = s2.top();
						s1.pop();
						s2.pop();
						if (X != 11 && t[X + 1][Y] == '1'){
							s1.push(X + 1);
							s2.push(Y);
						}
						if (Y != 11 && t[X][Y + 1] == '1'){
							s1.push(X);
							s2.push(Y + 1);
						}
						if (X != 0 && t[X - 1][Y] == '1'){
							s1.push(X - 1);
							s2.push(Y);
						}
						if (Y != 0 && t[X][Y - 1] == '1'){
							s1.push(X);
							s2.push(Y - 1);
						}
						t[X][Y] = '0';
					}
				}
			}
		}

		cout << island << endl;
	}

	return 0;
}


Measured memory_bytes: 3120
def main():
    n, m = map(int, input().split())
    array = [[] for _ in range(n+1)]
    temp = []
    for _ in range(m):
        a, b = map(int, input().split())
        array[a].append(b)
        array[b].append(a)
        temp.append([a, b])
    result = 0
    from collections import deque
    while len(temp) > 0:
        a, b = temp.pop()
        array[a].remove(b)
        array[b].remove(a)
        d = deque([1])
        pop = d.pop
        append = d.append
        flag = [True] * (n + 1)
        while len(d) > 0:
            now = pop()
            for to in array[now]:
                if flag[to]:
                    append(to)
                    flag[to] = False
        for f in flag[1:]:
            if f:
                result += 1
                break
        array[a].append(b)
        array[b].append(a)
    print(result)
main()

Measured memory_bytes: 3444
import java.io.BufferedReader;
import java.io.InputStreamReader;
public class Main {

	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str = br.readLine();
		String[] num = str.split(" ", 0);
		int a = Integer.parseInt(num[0]);
		int b = Integer.parseInt(num[1]);
		int c = Integer.parseInt(num[2]);

		if(a < b && b < c){
		 System.out.println("Yes");

		}else{
		 System.out.println("No");
		}
	}
}

Measured memory_bytes: 24472
var obj = init();
Main();
function nextInt(){return myconv(next(),1);}
function nextStrArray(){return myconv(next(),2);}//半角スペース分割
function nextIntArray(){return myconv(next(),4);}//半角スペース + 数値化
function nextCharArray(){return myconv(next(),6);}//1文字分割
function next(){return obj.next();}
function hasNext(){return obj.hasNext();}
function myin(){return require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");}
function init(){
  var inputFile = myin();
  var returnObj = {
    "list" : inputFile, "index" : 0, "max" : inputFile.length,
    "hasNext" : function(){return (this.index < this.max);},
    "next" : function(){if(!this.hasNext()){return "";}else{var returnInput = this.list[this.index];this.index++;return returnInput;}}
  };
  return returnObj;
}
function myout(t){console.log(t);}//標準出力
function myerr(t){console.error(t);}//標準エラー出力
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す　1:数値へ変換
//2:半角SPで分割 4:半角SPで分割し、数値配列へ
//6:1文字で分割  7:1文字で分割し、数値配列へ
//8:半角SPで結合 9:改行で結合 0:文字なしで結合
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map((a)=>Number(a));case 6:return i.split("");case 7:return i.split("").map((a)=>Number(a));case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}
function Main(){
  var N = nextInt();
  var list = nextIntArray();
  var map = {};
  for(var i = 0; i < N; i++){
    if(map[list[i]] == null){
      map[list[i]] = 1;
    }else{
      map[list[i]]++;
    }
  }
  var sum = 0;
  var keys = Object.keys(map);
  for(var i = 0; i < keys.length; i++){
    var tmp = map[keys[i]];
    sum += (tmp * (tmp - 1)) / 2;
  }
  var output = new Array(N);
  for(var i = 0; i < N; i++){
    var rem = list[i];
    var tmp = map[rem];
    output[i] = (sum - (tmp * (tmp - 1) / 2) + ((tmp - 1) * (tmp - 2) / 2));
  }
  myout(myconv(output,9));
}

Measured memory_bytes: 59856
#include <bits/stdc++.h>
using namespace std;
#define finish(x) return cout << x << endl, 0;
#define ll long long

int a, b;

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
    cin >> a >> a >> b;
    if((max(a, b)-min(a, b))%2) cout << "Borys" << endl;
    else cout << "Alice" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;
long long a[100000][3],f[100000][3],n;
int main()
{
    cin>>n;
    for (long i=1;i<=n;i++)
    for (long j=1;j<=3;j++) cin>>a[i][j];
    for (long i=1;i<=n;i++)
    {
        for (long j=1;j<=3;j++)
        {
                if (j==1) f[i][j]=max(f[i-1][2]+a[i][j],f[i-1][3]+a[i][j]);
                if (j==2) f[i][j]=max(f[i-1][1]+a[i][j],f[i-1][3]+a[i][j]);
                if (j==3) f[i][j]=max(f[i-1][1]+a[i][j],f[i-1][2]+a[i][j]);
        }
    }
    long long kq=max(f[n][1],max(f[n][2],f[n][3]));
    cout<<kq;
    return 0;
}


Measured memory_bytes: 4992
S=input()
K=int(input())
import copy
num=1
liS=[]

for i in range(len(S)-1):
    if S[i]==S[i+1]:
        num+=1
    else:
        liS.append(num)
        num=1
liS.append(num)



liSR=copy.copy(liS)
liSR[0]+=liSR[-1]
del liSR[-1]



if liSR!=[] and S[0]==S[-1]:
    for j in range(len(liS)):
        liS[j]=liS[j]//2
    for k in range(len(liSR)):
        liSR[k]=liSR[k]//2

    print(sum(liSR)*(K-1)+sum(liS))

elif liSR!=[] and S[0]!=S[-1]:
    for j in range(len(liS)):
        liS[j]=liS[j]//2
    print(sum(liS)*K)

else:
    print((sum(liS)*K)//2)



Measured memory_bytes: 9352
#include <stdio.h>
typedef long long ll;
using namespace std;

int main(void) {
  ll i = 1, j, k, n;
  scanf("%lld", &n);
  ll dp[n + 1];
  for(i = 0; i <= n; ++i) dp[i] = i;
  for(i = 6; i <= n; i *= 6) {
    for(j = 0; j <= n - i; ++j) if(dp[j + i] > dp[j] + 1) dp[j + i] = dp[j] + 1;
  }
  for(i = 9; i <= n; i *= 9) {
    for(j = 0; j <= n - i; ++j) if(dp[j + i] > dp[j] + 1) dp[j + i] = dp[j] + 1;
  }
  printf("%lld", dp[n]);
  return 0;
}

Measured memory_bytes: 896
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define pb push_back
#define F first
#define S second
//cout<<fixed<<setprecision(11);
const string nl="\n";
const ll MOD=1000000007;
const ll ARR_MAX = 1e5+1;

vector<int> graph[ARR_MAX];
int dp[ARR_MAX]; //dp[i]=number of nodes on the longest directed path starting from i.
bool vis[ARR_MAX];

void dfs(int x){
	int mx=0;
	for(int i=0;i<graph[x].size();i++){
		int nxt=graph[x][i];
		if(!vis[nxt]){
			vis[nxt]=1;
			dfs(nxt);
		}
		mx=max(mx,dp[nxt]);
	}
	dp[x]=mx+1;
}

void solve(){
    int n,m;cin>>n>>m;
    int x,y;
    for(int i=0;i<m;i++){
    	int x,y;cin>>x>>y;
    	x--;y--;
    	graph[x].pb(y);
    }
    memset(dp,-1,sizeof(dp));
    memset(vis,0,sizeof(vis));
    for(int i=0;i<n;i++){
    	if(!vis[i]){
    		vis[i]=1;
    		dfs(i);
    	}
    }
    int mx=0;
    for(int i=0;i<n;i++){
    	mx=max(mx,dp[i]);
    	// cout<<i+1<<" "<<dp[i]<<nl;
    }
    cout<<mx-1<<nl;
}

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

Measured memory_bytes: 8960
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //ai>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //ai>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define REV(x) (reverse(x.begin(),x.end())) //reverse
#define TO(x,t,f) ((x)?(t):(f))
#define CLR(mat) memset(mat, 0, sizeof(mat))
#define FILV(x,a) fill(x.begin(),x.end(),a)
#define FILA(ar,N,a) fill(ar,ar+N,a)
#define NEXTP(x) next_permutation(x.begin(),x.end())
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;else return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define pb push_back
#define pri(aa) cout<<(aa)<<endl
const ll INF=1e9+7;
const ll N = 104;
ll a,c,b;


int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>a>>b>>c;
	if(a+b>=c)pri("Yes");
	else pri("No");
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
 
const int N=1e4;
int n,m,ans;
vector <pair <int, pair <int, int> > > g;
vector <pair <int, int> > MST;
int parent [N];
 
int root (int a){
    if(parent[a] ==a)
        return a;
    parent[a]=root(parent[a]);
    return root(parent[a]);
}
 
void Union (int a,int b){
    parent[root(a)]=root(b);
}
 
void find_mst(){
	sort (g.begin (), g.end ());
	MST.clear();
	for(int i=0; i<n; i++)
	    parent[i]=i;
	for(int i=0; i<m; i++){
		int f=g[i].second.first;
		int t=g[i].second.second;
		if(root(f)!=root(t)){
		    MST.push_back(g[i].second);
		    ans+=g[i].first;
			Union(f,t);
		}
	}
}
 
int main() {
	cin >> n>>m;
	g.clear();
	for(int i=0; i<m; i++){
		int f,t,w;
		cin >>f>>t>>w;
		g.push_back(make_pair (w, make_pair (f,t)));
	}
    find_mst();	
    cout << ans << endl;
}

Measured memory_bytes: 4444
n = int(input())
t = [0] * 100
for i in range(11, 100):
  msb = i // 10
  lsb = i % 10
  if lsb == 0:
    continue
  for j in range(1, n+1):
    if j % 10 == lsb and int(str(j)[0]) == msb:
      t[i] += 1

ans = 0
for i in range(11, 100):
  msb = i // 10
  lsb = i % 10
  if lsb == 0:
    continue
  if msb == lsb:
    ans += t[i] ** 2
  else:
    ans += t[i] * t[lsb * 10 + msb]
print(ans)


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

int main() {
    string n;
    cin >> n;
    int sum = 0;
    for (int i = 0; i < n.size(); i++)
        sum += n[i] - '0';
    if ( stoi(n) % sum == 0 )
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

Measured memory_bytes: 256
/*
    Author: Nguyen Tan Bao
    Status:
    Idea:
*/

#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x

using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<II, int> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;

const ll MODBASE = 1000000007LL;
const int MAXN = 1000010;
const int MAXM = 1000;
const int MAXK = 16;
const int MAXQ = 200010;

int n, nt[MAXN];

void sieveBase(int n) {
    FOR(i,2,n) {
        if (nt[i] == 0) {
            nt[i] = i;
            for (ll j = (ll) i * i; j <= n; j += i) nt[j] = i;
        }
    }
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    cin >> n;
    ll res = 0;
    sieveBase(1000000);
    FOR(C,1,n-1) {
        int k = n - C;
        ll sum = 1;
        while (k > 1) {
            int x = nt[k], cnt = 0;
            while (k % x == 0) {
                k /= x;
                cnt++;
            }
            sum *= cnt+1;
        }
        res += sum;
    }
    cout << res;
    return 0;
}


Measured memory_bytes: 7552
#include <bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long int
#define pb push_back
#define fi first
#define se second
#define ld long double
#define vi vector<vector<ll> >
using namespace std;
const int MOD=1000000007;
const int MOD2=998244353;
const ll MAX=9187201950435737471;
const int N=100005;
const int INF=1e9+7;
const long double PI=acos(-1);
int a[8];

void solve(int T){
    for(int i=0;i<3;i++){
        int x;
        cin>>x;
        if(x<8)a[x]++;
    }
    if(a[5]==2 && a[7]==1)cout<<"YES\n";
    else cout<<"NO\n";
}
int main() {
    fastio

    int T=1;
    //cin>>T;
    for(int i=1;i<=T;i++){
        solve(i);
    }
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,m,n) for(int i=m;i<n;i++)
ll mod=1e9+7;

int main(){
  int n,m;
  cin>>n>>m;
  int a[n];
  rep(i,0,n) cin>>a[i];
  int sum[n+1];
  sum[0]=0;
  rep(i,0,n) sum[i+1]=(sum[i]+a[i])%m;
  map<int,ll> mp;
  rep(i,0,n+1) mp[sum[i]]++;
  ll ans=0;
  for(auto p:mp){
    ans+=p.second*(p.second-1)/2;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
#define FOR(I,A,B) for(int I=int(A);I<int(B);++I)

int INF = 2147483647;
struct RUQ{//平方分割 0-index
	int n,rn,bn,Q=0;
	vector<P> a,b;
	RUQ(int n_){
		n = n_; rn = sqrt(n); bn = ceil((double)n/rn);
		a.resize(n,{2147483647,0});
		b.resize(bn,{2147483647,0});
	}
	int value(int s){
		if(a[s].second < b[s/rn].second){
			a[s] = b[s/rn];
		}
		return a[s].first;
	}
	void updete(int s,int t,int x){
		Q++;
		FOR(i,s,t+1){
			if(i%rn==0 && (i+rn-1)<=t){
				b[i/rn] = {x,Q};
				i += rn-1;
			}else{
				a[i] = {x,Q};
			}
		}
	}
};

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int N,Q;
	cin >> N >> Q;
	priority_queue<pair<int,P>> pq;
	vector<int> D(Q+1,INF);
	FOR(i,0,N){
		int s,t,x;
		cin >> s >> t >> x;
		pq.push({x,{s-x,t-x}});
	}
	FOR(i,0,Q){
		cin >> D[i];
	}
	RUQ ruq(Q+1);
	FOR(i,0,N){
		int s = pq.top().second.first;
		int t = pq.top().second.second;
		int x = pq.top().first;
		pq.pop();
		s = (lower_bound(D.begin(),D.end(),s)-D.begin());
		t = (lower_bound(D.begin(),D.end(),t)-D.begin());
		ruq.updete(s,t-1,x);
	}
	FOR(i,0,Q){
		int ans = ruq.value(i);
		if(ans==INF) ans = -1;
		cout << ans << '\n';
	}
}


Measured memory_bytes: 7024
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i = n;i >= 0;--i)
#define FOR(i,m,n) for(int i = m, i##_len=(n);i <i##_len; ++i)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
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; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}
const int INF = 1e9;
const ll LLINF = 1e16;

int main(void)
{
    ll mod = 1e9 + 7;
    int n;
    cin >> n;
    vector<ll> a(n);
    REP(i,n){
        cin >> a[i];
    }

    ll sum = 0;
    ll a_max = *max_element(all(a));
    int digit_max = log2(a_max);
    unsigned long long pow2 = 1;
    REP(i, digit_max + 1)
    {
        int one_cnt = 0;
        int zero_cnt = 0;
        REP(j, n)
        {
            if(pow2 & a[j]){
                one_cnt++;
            }
            else{
                zero_cnt++;
            }
        }
        sum += (pow2 % mod * one_cnt % mod * zero_cnt % mod) % mod;
        pow2<<= 1;
    }

    cout << sum % mod << endl;

    return 0;
}

Measured memory_bytes: 2560
import java.util.Scanner;
public class Main{
 public static void main(String[] args) {
   Scanner kbd =new Scanner(System.in);
   String s=kbd.next();
   int cou=0;
   if(s.contains("RRR")){
    System.out.println(3);
 }else if(s.contains("RR")){
   System.out.println(2);
 }else if(s.contains("R")){
   System.out.println(1);
}else{
  System.out.println(0);
}
}}


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

int main() {
  int N, S1 = 0, S2 = 0;
  cin >> N;
  vector<int> W(N);
  for(int i = 0; i < N; i++) {
    cin >> W.at(i);
    S2 += W.at(i);
  }
  
  vector<int> ans(N);
  
  for(int i = 0; i < N; i++) {
    S1 += W.at(i);
    S2 -= W.at(i);
    ans.at(i) = abs(S1 - S2);
  }
  
  int min = 1000;
  for(int i = 0; i < N; i++) {
    if(min >= ans.at(i)) {
      min = ans.at(i);
    }
  }
  cout << min << endl;
}

Measured memory_bytes: 256
n = gets.to_i
a = gets.chomp.split(" ").map(&:to_i)

ans = []
(1..n).each do |i|
  if i % 2 == 0
    ans.unshift(a[i-1])
  else
    ans.push(a[i-1])
  end
end
ans.reverse! if n % 2 != 0
puts ans.join(" ")


Measured memory_bytes: 27360
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <functional>
#include "math.h"
#include <set>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define VI vector<int>
#define debug(x) cout<<#x<<": "<<x<<endl
#define DEBUG(x) cout<<#x<<": "<<x<<endl
int N,K;






int main()
{

	cin >> N >> K;

	if(N%K==0){
		cout << -1;
	} else {
		cout << N;
	}





}



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

int main()
{
  int m;
  cin >> m;
  for(int i = 0; i < m; i++){
    string s, x, y, rx, ry;
    set <string> t;
    cin >> s;
    for(int j = 1; j < s.size(); j++){
      x = rx = s.substr(0, j);
      y = ry = s.substr(j);
      reverse(rx.begin(), rx.end());
      reverse(ry.begin(), ry.end());
      t.insert(x + y);
      t.insert(rx + y);
      t.insert(x + ry);
      t.insert(rx + ry);
      t.insert(y + x);
      t.insert(ry + x);
      t.insert(y + rx);
      t.insert(ry + rx);
    }
    cout << t.size() << endl;
  }
}

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

int main() {
  string s;
  cin >> s;
  vector<string> t(4);
  t = {"dream", "dreamer", "erase", "eraser"};
  reverse(s.begin(), s.end());
  for (int i = 0; i < 4; i++) {
    reverse(t.at(i).begin(), t.at(i).end());
  }
  bool b = false;
  bool c = true;
  int a;
  for (int k = 0; k < s.size();) {
    b = false;
    for (int i = 0; i < 4; i++) {
      for (int j = 5; j <= 7; j++) {
        if (s.substr(k, j) == t.at(i)) {
          b = true;
          a = t.at(i).size();
        }
      }
    }
    if (b) k += a;
    if (!b) {
      c = false;
      break;
    }
  }
  if (c) cout << "YES" << endl;
  else cout << "NO" << endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>

using namespace std;

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define BW(a,x,b) ((a)<=(x)&&(x)<=(b))
#define ALL(v) (v).begin(), (v).end()
#define LENGTHOF(x) (sizeof(x) / sizeof(*(x)))
#define AFILL(a, b) fill((int*)a, (int*)(a + LENGTHOF(a)), b)
#define MP make_pair
#define PB push_back
#define F first
#define S second
#define INF 1 << 30
#define EPS 1e-10
#define MAX_N 100

typedef pair<int, int> P;
typedef vector<int> vi;
typedef queue<int> qi;
typedef long long ll;

struct edge{ int to, cost; };

vector<vector<edge> >G(MAX_N);
int n;
int d[MAX_N];

void dijkstra(int s){
  priority_queue<P, vector<P>, greater<P> >q;
  fill(d, d + n, INF);
  d[s] = 0;
  q.push(P(0, s));

  while(!q.empty()){
    P p = q.top(); q.pop();
    int v = p.S;
    if(d[v] < p.F) continue;
    rep(i, G[v].size()){
      edge e = G[v][i];
      if(d[e.to] > d[v] + e.cost){
	d[e.to] = d[v] + e.cost;
	q.push(P(d[e.to], e.to));
      }
    }
  }
}

int main(){
  int k;
  while(scanf("%d%d", &n, &k) && n+k){
    rep(i, MAX_N) G[i].clear();
    int a, b, c;
    rep(i, k){
      scanf("%d", &a);
      if(a){
	scanf("%d%d%d", &a, &b, &c); b--; a--;
	edge e;
	e.to = b; e.cost = c;
	G[a].PB(e);
	e.to = a;
	G[b].PB(e);
      }else{
	scanf("%d%d", &a, &b); a--; b--;
	dijkstra(a);
	printf("%d\n", d[b]==INF?-1:d[b]);
      }
    }
  }
  return 0;
}

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

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
                     
#define int             long long
#define ld              long double
#define mp              make_pair
#define ff              first
#define ss              second
#define pb              push_back
#define fo(i,n)         for(i=0;i<n;i++)
#define fo1(i,n)        for(i=1;i<=n;i++)
#define FO(i,k,n)       for(i=k;k<=n?i<=n:i>=n;k<=n?i++:i--)
#define all(c)          c.begin(),c.end()
#define rall(c)         c.rbegin(),c.rend()
#define si              set<int>
#define vi              vector<int>
#define mii             map<int,int>
#define pii             pair<int,int>
#define vpii            vector<pii>
#define vvi             vector<vi>
#define usi             unordered_set<int>
#define umii            unordered_map<int,int>
#define pqmx            priority_queue<int>
#define pqmn            priority_queue<int,vi,greater<int> >
#define sp(x)           cout<<setprecision(x)<<fixed;
#define setbits(x)      __builtin_popcountll(x)
#define zerobits(x)     __builtin_ctzll(x)
#define in(a,n)         vi a(n);fo(i,n)cin>>a[i];
#define in1(a,n)        vi a(n+1);fo1(i,n)cin>>a[i];
#define w(t)            int t;cin>>t;while(t--)
#define sz(v)           (int)v.size()
#define gcd             __gcd
#define lcm(x,y)        x*(y/gcd(x,y))
#define endl            '\n'
#define PI              3.14159265358979323846
const int inf =         1e18;
const int mod =         1e9+7;
void __p(int x) {cout<<x;}
void __p(int32_t x){cout<<x;}
void __p(float x){cout<<x;}
void __p(double x){cout<<x;}
void __p(ld x) {cout<<x;}
void __p(char x){cout <<'\''<<x<<'\'';}
void __p(const char *x){cout <<'\"' <<x<<'\"';}
void __p(const string &x) {cout<<'\"'<<x<<'\"';}
void __p(bool x) {cout<<(x?"true":"false");}
void _p() {cout << "]\n";}
template<typename T,typename V>     void __p(const pair<T,V> &x) {cout<<'{';__p(x.first);cout<<',';__p(x.second);cout<<'}';}
template<typename T>                void __p(const T &x) {int f = 0; cout << '{'; for (auto &i: x) cout << (f++ ? "," : ""), __p(i); cout << "}";}
template <typename T,typename... V> void _p(T t, V... v) {__p(t);if(sizeof...(v))cout<<", ";_p(v...);}
int po(int x,int p,int m = inf) {int ans=1;x%=m;while(p>0){if(p&1)ans=(ans*x)%m;p=p>>1;x=(x*x)%m;}return ans;}
int inv(int x,int m=mod){return po(x,m-2,m)%m;}
#ifndef ONLINE_JUDGE
#define dbg(x...) cout<<"["<<#x<<"]=[";_p(x)
#else 
#define dbg(x...)
#endif
//=================================================================================




const int N=1e6+6;
int n,m,k,x,y,z,a,b,c,d,i,j,l,r,f;








void sol()
{   
    cin>>n>>m;
    
    
    
    
    cout<< ((n==m)?"Yes":"No") <<endl;
}





int32_t main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    //sp(10);
    // w(t)
    sol();
    return 0;
}

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

class Program {
    static string ReadLine() { return Console.ReadLine(); }
    static int ReadInt() { return int.Parse(ReadLine()); }
    static int[] ReadInts() { return ReadLine().Split().Select(int.Parse).ToArray(); }
    static string[] ReadStrings() { return ReadLine().Split(); }

    static void Main() {
        string s;
        while ((s = ReadLine()) != null) {
            int n = s.Split().Select(int.Parse).ToArray().Sum();
            // Console.WriteLine(n.ToString().Length);

            int ans = (int)Math.Log10(n) + 1;
            Console.WriteLine(ans);
        }
    }
}

Measured memory_bytes: 10024
import sys

input = sys.stdin.readline

X, Y, Z, K = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
AB = []
ABC = []

for a in A:
    for b in B:
        AB.append(a+b)

AB.sort(reverse=True)
for i in range(min(len(AB), 3000)):
    for c in C:
        ABC.append(AB[i]+c)
        
ABC.sort(reverse=True)

for i in range(K):
    print(ABC[i])


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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}

typedef long long ll;
typedef long double R;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

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

// Problem Specific Parameter:

int main() {
  double N, K; cin >> N >> K;
  int cnt;
  double p;
  for(int i = 1; i <= N; ++i) {
    double tmp=0;
    double k = K;
    while(k > i) {
      tmp++;
      k/=2;
    }
    p += 1.0/N * pow(0.5, tmp);
  }
  printf("%.12lf\n" , p);

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;

int main()
{
	int n;
	cin >> n;
	int a[n];
	REP(i, n) cin >> a[i];

	bool flag = true;

	int count = 0;
	
	while(1){
		REP(i, n){
			if (a[i] % 2 == 1) flag = false;
			a[i] /= 2;
		}
		if (flag) count++;
		else break;

	}

	cout << count << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = int(a); i < int(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
const long long INFLL = 1LL << 60;
const int INFINT = 1 << 30;
const long long MOD = 1e9 + 7;

template <class T> void vecout(T V) {
    auto t = V.begin();
    while(t != V.end()) {
        cout << *t++;
        if(t != V.end()) cout << " ";
    }
    cout << endl;
};

int main() {
    int N, A, B, C, D;
    cin >> N >> A >> B >> C >> D;
    cout << min(B * ceil(N * 1.0 / A), D * ceil(N * 1.0 / C)) << endl;
}



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

struct x {
  string s;
  int p;
  int i;
};
  
int main()
{
  int n;
  cin >> n;
  vector<x> g(n);

  for (int i = 0; i < n; i++) {
    cin >> g[i].s >> g[i].p;
    g[i].i = i + 1;
  }

  sort(begin(g), end(g), [](auto a, auto b){return a.p > b.p;});
  stable_sort(begin(g), end(g), [](auto a, auto b){return a.s < b.s;});

  for (auto&& e : g) {
    cout << e.i << endl;
  }
}


Measured memory_bytes: 256
//abc162_c.cpp
//Sun Apr 12 20:57:54 2020

#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
#define MOD 1000000007

using namespace std;
using ll=long long;
typedef pair<int,int> P;

//最大公倍数、最大公約数（ユークリッド互除法）
ll gcd (ll a, ll b){ //最大公約数
	if (b == 0){
		return a;
	}
	return gcd(b, a%b);
}

int main(){
	ll k;
	cin >> k;

	ll matrix[k+2][k+2];

	for (ll i=1;i<=k;i++){
		for (ll j=1;j<=k;j++){
			matrix[i][j] = gcd(i,j);
		}
	}

	ll ans = 0;
	for (ll i=1;i<=k;i++){
		for (ll j=1;j<=k;j++){
			ll tmp = matrix[i][j];
			for (ll c=1;c<=k;c++){
				ans += matrix[tmp][c];
			}
		}
	}

	cout << ans << endl;

}

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

using namespace std;

const int MAXN = 100;
bool adj[MAXN + 1][MAXN + 1];

int main()
{
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++)
    {
        for (int j = i + 1; j <= n; j++)
        {
            adj[i][j] = adj[j][i] = true;
        }
    }
    int first, second;
    first = 1;
    if (n % 2 == 0)
        second = n;
    else
        second = n - 1;
    int m = n * (n - 1) / 2;
    while (first < second)
    {
        adj[first][second] = adj[second][first] = false;
        m--;
        first++;
        second--;
    }
    cout << m << endl;
    for (int i = 1; i <= n; i++)
    {
        for (int j = i + 1; j <= n; j++)
        {
            if (adj[i][j])
                cout << i << " " << j << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 256