akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
using namespace std; 
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }
const int INF = 1e9 + 5;
typedef long long ll;
inline int two(int n) { return 1 << n; }
inline int test(int n, int b) { return (n>>b)&1; }
inline void set_bit(int & n, int b) { n |= two(b); }
inline void unset_bit(int & n, int b) { n &= ~two(b); }
inline int last_bit(int n) { return n & (-n); }
inline int ones(int n) { int res = 0; while(n && ++res) n-=n&(-n); return res; }
template<class T> void chmax(T & a, const T & b) { a = max(a, b); }
template<class T> void chmin(T & a, const T & b) { a = min(a, b); }
/////////////////////////////////////////////////////////////////////

int main() {
    int N, W;
    scanf("%d%d", &N, &W);
    vector<ll> dp(W + 1); // 0 ... W
    // dp[i] - the maximum total value with weight exactly i
    for (int i = 0; i < N; ++i) {
        int weight, value;
        scanf("%d%d", &weight, &value);
        for (int weight_already = W - weight; weight_already >= 0; --weight_already) {
            dp[weight_already + weight] = max(dp[weight_already + weight], dp[weight_already] + value);
        }
    }
    printf("%lld\n", *max_element(dp.begin(), dp.end()));

    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007, INF=(1LL<<60);
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

ll fac[2000007],finv[2000007],inv[2000007];
void cominit(){
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for(int i=2;i<2000007;i++){
        fac[i]=fac[i-1]*i%mod;
        inv[i]=mod-inv[mod%i]*(mod/i)%mod;
        finv[i]=finv[i-1]*inv[i]%mod;
    }
}
ll com(ll n,ll k){
    if(n<k)return 0;
    if(n<0 || k<0)return 0;
    return fac[n]*(finv[k]*finv[n-k]%mod)%mod;
}
vector<ll> p26(1000001, 1), p25(1000001,1);
int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    cominit();
    for(int i=1;i<=1000000;i++) p26[i] = p26[i-1] * 26 % mod;
    for(int i=1;i<=1000000;i++) p25[i] = p25[i-1] * 25 % mod;
    ll k;
    cin >> k;
    string s;
    cin >> s;
    ll n = s.length();
    ll ans = 0;
    k += n;
    for(ll i=n;i<=k;i++){
    	ll num = (p26[k-i] * p25[i-n]) % mod;
    	num *= com(i-1, n-1);
    	num %= mod;
    	ans += num;
    	ans %= mod;
    }
    cout << ans << endl;
    return 0;
}


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

ll isp(ll n) {
	ll res=1;
	for(ll i=2;i<=sqrt(n);i++) {
		if(n%i==0) return 0;
	}
	return res;
}

int main()
{
	ll a,b,n,i,c=0;
	cin>>a>>b;
	n=__gcd(a,b);
	for(i=1;i<=sqrt(n);i++) {
		if(n%i==0) {
			if(isp(i)) c++;
			if(n/i!=i) {
				if(isp(n/i)) c++;
			}
		}
	}
	cout<<c;
}

Measured memory_bytes: 256
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] a = new int[N+1];
        for(int i=1;i<=N;i++) a[i] = sc.nextInt();
        boolean[] vis = new boolean[N+1];
        int i=1;
        int cnt=0;
        while(!vis[i]){
            vis[i]=true;
            i=a[i];
            cnt++;
            if(i==2){
                System.out.println(cnt);
                System.exit(0);
            }
        }
        System.out.println(-1);
    }
}
 

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

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

	int a, b;
	cin >> a >> b;
	int height_a = 0;
	if (a < 9 && b < 9) {
		cout << "Yay!" << endl;
	}
	else {
		cout << ":(" << endl;
	}

	return 0;
}

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

int max(int a, int b){
	return a >= b ? a : b;
}

signed main(){
	int N, W, w, v, i, j;
	scanf("%lld%lld", &N, &W);
	int *dp = (int *)malloc(sizeof(int) * (W + 1));
	for(j = 0; j <= W; j++){
		dp[j] = 0;
	}
	for(i = 0; i < N; i++){
		scanf("%lld%lld", &w, &v);
		for(j = W; j >= w; j--){
			dp[j] = max(dp[j], dp[j - w] + v);
		}
	}
	printf("%lld\n", dp[W]);
	return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (int i = j; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
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; }
//name[i][j]-> vvl name(i,vl(j))
//map<int,int>mp
//余りを切り上げる =>  (a + b - 1) / b 

signed main(){
	int n; cin>>n;
	vi vec(n);
	int total=0;
	rep(i,0,n){
		int a; cin>>a;
		total+=a;
		vec[i]=a;
	}
	if(total%10!=0){
		cout<<total;
		return 0;
	}
	int ans=0;
	rep(i,0,n){
		int k=total-vec[i];
		if(k%10==0) k=0;
		ans=max(ans,k);
	}
	cout<<ans;
	
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<map>
#include<iostream>
#include<iomanip>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<vector>
#include<set>

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

using namespace std;

int main(){
	int n;cin>>n;
	if(n%10==9 || n>=90) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}


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

using namespace std;

//using Matrix = vector< vector<int> >;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9 + 10;
//const ll INF = 1e18 + 10LL;
int dx[5] = {0, 0, 1, -1, 0}, dy[5] = {1, -1, 0, 0, 0};
const double EPS = 1e-10;
bool cmp(P a, P b) { return a.second < b.second; } //End sort (Interval scheduling problem)

int n;
ll a[100010], b[100010];
ll cnt;

int main(void){
	cin>>n;
	for (int i = 0; i < n + 1; i++) cin>>a[i];
	for (int i = 0; i < n; i++) cin>>b[i];

	for (int i = 0; i < n; i++) {
		if (b[i] > a[i]) {
			cnt += a[i];
			b[i] -= a[i];
			if (b[i] > a[i + 1]) {
				cnt += a[i + 1];
				a[i + 1] = 0;
			}
			else {
				cnt += b[i];
				a[i + 1] -= b[i];
			}
		} else {
			cnt += b[i];
			b[i] = 0;
		}
	}

	printf("%lld\n", cnt);
	
	return 0;
}

Measured memory_bytes: 1792
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {          
            var number1 = Console.ReadLine();
            var str = Console.ReadLine();
            var arr = number1.Split(' ');
            var numberInt1 = int.Parse(arr[0]);
            var numberInt2 = int.Parse(arr[1]);

            var multiResult = numberInt1 * numberInt2;

            var divisionResult = multiResult % 2;
            if (divisionResult == 0) 
            {
                Console.WriteLine("Even");
            }
            else
            {
                Console.WriteLine("Odd");
            }          
        }
    }
}


Measured memory_bytes: 11092
#include<iostream>
using namespace std;
int n,m,k,sum_r=0,A[101][101]={},sum_l=0;

int main() {
	cin>>n>>m;	
  	for (int i=0;i<n;i++){
		for (int j=0;j<m;j++){ 
          	cin>>A[i][j];
          	A[i][m]+=A[i][j];
          	A[n][j]+=A[i][j];
          	A[n][m]+=A[i][j];
        }
    }
    
  	for (int i=0;i<n+1;i++){
        for (int j=0;j<m+1;j++){
        	if (j!=0) cout<<" ";
          cout<<A[i][j];
        }
      	cout<<endl;
    }
      
  return 0;
}


Measured memory_bytes: 3124
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
using ll = long long;
using u64 = uint_fast64_t;
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007;
//constexpr long long MOD = 998244353;
template<class T1, class T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return true;} return false; }
template<class T1, class T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return true;} return false; }
inline int popcount(int x) {return __builtin_popcount(x);}
inline int popcount(long long x) {return __builtin_popcountll(x);}
void print() { cout << "\n"; }
template<class T, class... Args>
void print(const T &x, const Args &... args) {
    cout << x << " ";
    print(args...);
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////

const int MAXL = 100000;
int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int N; cin >> N;
    vector<ll> V(N+1),W(N+1);
    rep(i,N) cin >> V[i+1] >> W[i+1];
    int Q; cin >> Q;
    vector<vector<pii>> L(N+1);
    rep(i,Q) {
        int v,l; cin >> v >> l;
        L[v].emplace_back(l,i);
    }
    
    vector<vector<ll>> dp(512, vector<ll>(MAXL+1));
    vector<ll> ans(Q);
    auto dfs=[&](auto&& self, int v, int a,const vector<pll> &arr)->void {
        if (v > N) return;
        int pv = v/2;
        if (v < 512) {
            rep(i,MAXL+1) {
                chmax(dp[v][i],dp[pv][i]);
                if (i+W[v]<=MAXL) chmax(dp[v][i+W[v]],dp[pv][i]+V[v]);
            }
            for (auto i : L[v]) {
                ans[i.second] = dp[v][i.first];
            }
            self(self,v*2,v,arr);
            self(self,v*2+1,v,arr);
        } else {
            auto B = arr;
            for (auto val : arr) {
                B.emplace_back(val.first+V[v],val.second+W[v]);
            }
            for (auto i : L[v]) {
                for (auto val : B) {
                    if (val.second > i.first) continue;
                    chmax(ans[i.second],dp[a][i.first-val.second]+val.first);
                }
            }
            self(self,v*2,a, B);
            self(self,v*2+1,a, B);
        }
    };
    vector<pll> arr;
    arr.emplace_back(0,0);
    dfs(dfs,1,0,arr);
    rep(i,Q) cout << ans[i] << ln;
}

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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define sf scanf
#define pf printf
#define pb push_back
#define mp make_pair
#define PI ( acos(-1.0) )
#define mod 998244353LL
#define IN freopen("C.in","r",stdin)
#define OUT freopen("output.txt","w",stdout)
#define FOR(i,a,b) for(i=a ; i<=b ; i++)
#define DBG pf("Hi\n")
#define INF 1000000000
#define i64 long long int
#define eps (1e-8)
#define xx first
#define yy second
#define ln 17
#define off 2

using namespace __gnu_pbds;
using namespace std ;

typedef tree< i64, null_type, less<i64>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef pair<i64, i64> pii;

#define maxn 1000005
const int N = 1000000 ;

bool prime[maxn] ;

int main()
{
    i64 n , p ;

    scanf("%lld %lld",&n,&p) ;

    i64 ans = 1LL ;

    for(i64 i=2 ; i*i<=p ; i++)
    {
        if( prime[i] == 0 )
        {
            for(i64 j=i+i ; j<=N ; j+=i) prime[j] = 1 ;
            i64 cnt = 0 ;
            while( p%i == 0 )
            {
                p /= i ;
                cnt++ ;
            }
            cnt /= n ;
            while( cnt !=0 )
            {
                ans *= i ;
                cnt-- ;
            }
        }
    }

    if( n==1 ) ans *= p ;

    printf("%lld\n",ans) ;

    return 0 ;
}


Measured memory_bytes: 1280
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.concurrent.TimeUnit;

/**
 *
 * @author yoshkur
 */
public class Main {

	public static void main(String[] args) {
		try {
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			InputData inputData = new InputData(br);

			System.out.println(inputData.getTime());

		} catch (IOException | NumberFormatException e) {
			System.err.println(e.getLocalizedMessage());
		}
	}
}

class InputData {

	private Long second;

	public InputData(BufferedReader br) throws IOException {
		String line = br.readLine().trim();
		this.second = Long.parseLong(line);
	}

	public Long getSecond() {
		return this.second % TimeUnit.MINUTES.toSeconds(1);
	}
	
	public Long getMinute() {
		Long temp = (this.second - this.getSecond()) % TimeUnit.HOURS.toSeconds(1);
		return TimeUnit.SECONDS.toMinutes(temp);
	}
	
	public Long getHour() {
		Long temp = (this.second - this.getSecond() - this.getMinute()) % TimeUnit.DAYS.toSeconds(1);
		return TimeUnit.SECONDS.toHours(temp);
	}
	
	public String getTime() {
		StringBuilder sb = new StringBuilder();
		sb.append(this.getHour().toString());
		sb.append(":");
		sb.append(this.getMinute());
		sb.append(":");
		sb.append(this.getSecond());
		return sb.toString();
	}
}

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

int main(){
	int pay,sum;
	int B[4],S[4];
	int m[4]={10,50,100,500};
	cin>>pay;
	while(pay){
		S[0]=S[1]=S[2]=S[3]=0;
		cin>>B[0]>>B[1]>>B[2]>>B[3];
		sum=0;
		for(int i=0;i<4;i++){
			sum+=m[i]*B[i];
		}
		sum-=pay;
		for(int i=0;i<4;i++){ 
			if(sum>=m[3-i]){
				S[3-i]=sum/m[3-i];
				sum%=m[3-i];
			}
		}
		for(int i=0;i<4;i++){
			if(B[i]-S[i]>0){
				cout<<m[i]<<" "<<B[i]-S[i]<<endl;
			}
		}
		cin>>pay;
		if(pay!=0){
			cout<<endl;
		}

	}
	return 0;
}

Measured memory_bytes: 3052
n, k = [int(x) for x in input().split()]

temp_list = [1] * (n + 1)
temp_list[0] = 0
for _ in range(k):
    d = int(input())
    a_list = [int(x) for x in input().split()]
    for a in a_list:
        temp_list[a] = 0
print(sum(temp_list))

Measured memory_bytes: 9188
#include <chrono>

#include <iostream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <time.h>
#include <random>
#include <string>
#include <cassert>
#include <vector>
#include <ostream>
#include <istream>
#include <stack>
#include <deque>
#include <queue>
#include <functional>

using namespace std;

#define int long long
#define pb push_back
#define all(a) (a).begin(), (a).end()
#define pii pair<int, int>
#define ld long double

ostream& operator << (ostream &a, const vector<int> &b) {
    for (auto k : b) cout << k << " ";
    return a;
}

#ifdef LOCAL
    #define dbg(x) cout << #x << " : " << (x) << "\n";
    const int INF = 1e18;
//    const int mod = 2600000069;
//    const int p = 10;
//    const ld PI = 3.1415926535;
#else
    #define dbg(x)
    const int INF = 1e18;
//    const int mod = 2600000069;
//    const int p = 179;
//    const ld PI = 3.1415926535;
#endif

//#pragma GCC optimize("Ofast,no-stack-protector")
//#pragma GCC target("sse,sse2,sse3,sse3,sse4")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC optimize("fast-math")
//#pragma GCC target("avx2")
//#pragma GCC optimize("section-anchors")
//#pragma GCC optimize("profile-values,profile-reorder-functions,tracer")
//#pragma GCC optimize("vpt")
//#pragma GCC optimize("rename-registers")
//#pragma GCC optimize("move-loop-invariants")
//#pragma GCC optimize("unswitch-loops")
//#pragma GCC optimize("function-sections")
//#pragma GCC optimize("data-sections")

int n, m, k;

vector<vector<int>> a;

int check(vector<int> c) {
    int cur = 0;
    vector<int> cnt(n, 0);
    for (int j = 0; j < m; j++) {
        bool add = 0;
        for (int i = 0; i < n; i++) {
            cnt[c[i]] += a[i][j];
            if (cnt[c[i]] > k) add = 1;
        }
        if (add) {
            cur++;
            for (int i = 0; i < n; i++) cnt[c[i]] = 0;
            for (int i = 0; i < n; i++) {
                cnt[c[i]] += a[i][j];
                if (cnt[c[i]] > k) {
                    return INF;
                }
            }
        }
    }
    return cur + c.back();
}

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    #ifdef LOCAL
    #else
//        freopen("capitals.in", "r", stdin);
//        freopen("capitals.out", "w", stdout);
    #endif
    cin >> n >> m >> k;
    a.resize(n, vector<int>(m, 0));
    char z;
    for (int i = 0 ;i < n; i++) {
        for (int j = 0 ; j < m; j++) {
            cin >> z;
            a[i][j] = z - '0';
        }
//        cout << a[i] << "\n";
    }
    int ans = INF;
    vector<int> cur(n, 0);
    for (int i = 0; i < (1 << (n - 1)); i++) {
        cur[0] = 0;
        for (int j = 0; j < n - 1; j++) {
            cur[j + 1] = cur[j];
            if ((i >> j) & 1) cur[j + 1]++;
//            cout << ((i >> j) & 1);
        }
//        cout << "\n";
        ans = min(ans, check(cur));
//        dbg(cur)
//        dbg(check(cur))
    }
    cout << ans;
}
/*

*/


Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<string>
#include<stack>
#include<cstdio>
#include<cmath>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<ll,P> P1;

#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define rep(i,x) for(int i=0;i<x;i++)
#define rep1(i,x) for(int i=1;i<=x;i++)
#define rrep(i,x) for(int i=x-1;i>=0;i--)
#define rrep1(i,x) for(int i=x;i>0;i--)
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
#define mp1(a,b,c) P1(a,P(b,c))

const ll INF=1000000000000000000;
const int dir_4[4][2]={{1,0},{0,1},{-1,0},{0,-1}};
const int dir_8[8][2]={{1,0},{1,1},{0,1},{-1,1},{-1,0},{-1,-1},{0,-1},{1,-1}};

int main(){
	int K = 42;
	int N = K*(K-1)+1;
	printf("%d %d\n",N,K);
	for(int i = 1 ; i <= K ; i ++){
		printf("1");
		rep(j,K-1){
			printf(" %d",(K-1)*(i-1)+2+j);
		}
		printf("\n");
	}
	for(int j = 2 ; j <= K ; j ++){
		rep(i,K-1){
			printf("%d",j);
			rep(k,K-1){
				int x = (K-1)*(k+1)+2+((i+(j-2)*k)%(K-1));
				printf(" %d",x);
			}
			printf("\n");
		}
	}
}
	



Measured memory_bytes: 512
#include <cstdio>
int main() {
	int n,debt=100000;
	scanf("%d",&n);
	for(int i=0;i<n;i++) {
		debt=debt*1.05;
		if(debt%1000>0) {
			debt-=debt%1000;
			debt+=1000;
		}
	}
	printf("%d\n",debt);
}

Measured memory_bytes: 1020
N = int(input())
c = input()
rlist = []
wlist = []
for i in range(N):
    if c[i] == 'R':
        rlist.append(i)
    else:
        wlist.append(i)

cnt = 0
if len(rlist) == 0:
    print(0)
    exit()
for i in range(len(wlist)):
    if wlist[i] < rlist[-cnt - 1]:
        cnt += 1
    else:
        break
print(cnt)

Measured memory_bytes: 17280
let () =
  Scanf.scanf "%d %d" @@ fun n k ->
  let h = Array.init n (fun _ -> Scanf.scanf " %d" ((+) 0)) in
  let dp = Array.make n max_int in
  dp.(0) <- 0;
  for i = 1 to n-1 do
    for j = 1 to min i k do
      dp.(i) <-
        min dp.(i) (dp.(i-j) + abs (h.(i-j) - h.(i)))
    done
  done;
  Printf.printf "%d\n" dp.(n-1)

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

int main() {
  char b;
  cin >> b;
  
  if(b=='A')
    cout << 'T' << endl;
  else if(b=='C')
    cout << 'G' << endl;
  else if(b=='G')
    cout << 'C' << endl;
  else if(b=='T')
    cout << 'A' << endl;
}

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

int solve(long long x){
    int rep = 0;
    while (x>0){
        rep += x%10;
        x /= 10;
    }
    return rep;
}

int main(){
    int k;
    cin >> k;
    long long n = 0;
    long long m;
    int x;
    long long y;
    for (int i = 0; i<k; i++){
        n++;
        m = n;
        for (int d = 0; d<15; d++){
            if (pow(10, d) > n) break;
            x = (long long)(n/pow(10, d)) % 10;
            y = (long long)(n/pow(10, d)) - x;
            for (int s = 1; s <= 10; s++){
                if (x >= s) continue;
                if (1.0f*((long long)((y+s)*pow(10, d)) - 1)/solve((long long)((y+s)*pow(10, d)) - 1) < 1.0f*m/solve(m)){
                    m = (long long)((y+s)*pow(10, d)) - 1;
                }
            }
        }
        n = m;
        cout << n << endl;
    }
}


Measured memory_bytes: 256
import java.io.IOException;

import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws IOException {
        try (
            BufferedReader reader = new BufferedReader(
                new InputStreamReader(System.in))) {
            final String s = reader.readLine();

            StringBuilder sb = new StringBuilder();
            for (int i = 0; i < s.length(); i += 2) sb.append(s.charAt(i));

            System.out.println(sb.toString());
        }
    }
}


Measured memory_bytes: 23892
lines=readlines(open("/dev/fd/0"))
input()=shift!(lines)
int(s::String)=parse(Int,s)
intSub(s::SubString{String})=parse(Int,s)
intLine(s::Array{SubString{String},1})=map(intSub,s)
function main()
    INF=2^60
    a,b,q=input()|>split|>intLine
    s=[-INF]
    append!(s,[int(input())for i in 1:a])
    push!(s,INF)
    t=[-INF]
    append!(t,[int(input())for i in 1:b])
    push!(t,INF)
    for x in[int(input())for i in 1:q]
        m=INF
        i=searchsortedlast(s,x)
        j=searchsortedlast(t,x)
        for v in view(s,i:i+1)
            for w in view(t,j:j+1)
                m=min(m,abs(x-v)+abs(v-w),abs(x-w)+abs(w-v))
            end
        end
        println(m)
    end
end
main()

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

const int Max = 100001;
int parent(int i)
{
    return i/2;
}
int left(int i)
{
    return i*2;
}
int right(int i)
{
    return i*2+1;
}
int H, i, A[Max];

int main()
{
    cin >> H;
    for(int i=1; i<=H; i++)
    {
        cin >> A[i];
    }
    for(int i=1; i<=H; i++)
    {
        cout << "node " << i << ": key = " << A[i] << ", ";
        if(parent(i)>=1)
            cout << "parent key = " << A[parent(i)] << ", ";
        if(left(i)<=H)
            cout << "left key = " << A[left(i)] << ", ";
        if(right(i)<=H)
            cout << "right key = " << A[right(i)] << ", ";
        cout << endl;
    }
    return 0;
}



Measured memory_bytes: 3092
K=int(input())
S=list(input())
if len(S)>K:
  answer=[]
  for i in range(K):
    answer.append(S[i])
  answer.append('...')
  s=''
  for i in range(len(answer)):
    s+=answer[i]
  print(s)
else:
  g=''
  for i in range(len(S)):
    g+=S[i]
  print(g)
      
  


Measured memory_bytes: 9192
#include <stdio.h>
#include <stdlib.h>
int compare_int(const void *a, const void *b)
{
    return *(int*)a - *(int*)b;
}

int main(){
	int n = 0;
	scanf("%d",&n);
    int k = 0;
    scanf("%d",&k);
    int tree[100004];
    for(int i = 0;i < n;i++){
    	scanf("%d",&tree[i]);
    }
    qsort(tree,n,sizeof(int),compare_int);
    int min = 1000000006;
    for (int i = 0; i < n - k + 1; i ++){
    	if(tree[i + k - 1] - tree[i] <= min){
        	min = tree[i + k - 1] - tree[i];
        }
    }
    printf("%d",min);
    return 0;
}


Measured memory_bytes: 892
#include<cstdio>
#include<functional>
#include<algorithm>
using namespace std;
int main(void)
{
	int n,i,j,x,a[1000],x1,y1;
	scanf("%d",&n);
	for(i=0;i<n;i++)	scanf("%d",&a[i]);
	for(i=0;i<n-1;i++)	{
		for(j=i+1;j<n;j++)	{
			x=a[i]-a[j];
			if(x<0)	x=-x;
			if(x%(n-1)==0)	{
				x1=a[i];	y1=a[j];
				j=n;	i=n-1;
			}
		}
	}
	printf("%d %d\n",x1,y1);
    return 0;
}


Measured memory_bytes: 2772
#include <bits/stdc++.h>
using namespace std;
 
bool isPalindrome (string a) {
  string b = "";
  for (int i = a.size()-1; i >= 0; i--) {
    b+= a[i]; }
  if(b==a){
    return true;}
  else {
    return false;} }
    
 
 
 
int main () {
  string x;
  cin >> x;
  string y = "";
  int n = x.size();
  for (int i = 0; i < (n-1)/ 2; i++) {
    y+= x[i]; }
  string z = "";
  for (int i = (n+1) /2; i < n; i++) {
    z+= x[i]; }
  if (isPalindrome(x) && isPalindrome(y) && isPalindrome(z)){
    cout <<"Yes"; }
      else {
        cout <<"No"; } }

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cassert>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
typedef long long ll;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000001
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
string s;
int main()
{
	cin >> s;
	int nx=0; string res = "";
	for(int i=0;i<s.size();i++)
	{
		if(nx%2 == 0 && s[i]=='A')
		{
			nx++; res.pb(s[i]);
		}
		else if(nx%2 == 1 && s[i]=='Z')
		{
			nx++; res.pb(s[i]);
		}
	}
	if(res.size()%2 == 1) res.resize(res.size()-1);
	if(res.empty()) res = "-1";
	cout << res << endl;
}

Measured memory_bytes: 1188
#[allow(unused_macros)]
macro_rules! scan {
    () => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().to_string()
        }
    };
    (;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().split_whitespace().map(|s| s.to_string()).collect::<Vec<String>>()
        }
    };
    (;;$n:expr) => {
        {
            (0..$n).map(|_| scan!()).collect::<Vec<_>>()
        }
    };
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty;;$n:expr) => {
        (0..$n).map(|_| scan!($t;;)).collect::<Vec<_>>()
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
                    scan!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
                    scan!($($t),*)
        ).collect::<Vec<_>>()
    };
}

fn main() {
    let mut vs = scan!(i64;;);
    vs.sort();
    if vs[0] == 5 && vs[1] == 5 && vs[2] == 7 {
        println!("YES");
    } else {
        println!("NO")
    }
}


Measured memory_bytes: 4352
#include <iostream>
#include <cstdio>
#include <cstring>
#include <map>

using namespace std;

typedef long long LL;

int n;

map<LL, int> hmp;

int main() {
    scanf("%d", &n);
    LL res = 0, sum = 0;
    ++hmp[0];
    for (int i = 1; i <= n; ++i) {
        int x;
        scanf("%d", &x);
        sum += x;
        res += hmp[sum];
        ++hmp[sum];
    }
    printf("%lld\n", res);
    return 0;
}

Measured memory_bytes: 12800
import numpy as np

n, m, c = map(int, input().split())
b = np.array(list(map(int, input().split())))
a = np.array([list(map(int, input().split())) for i in range(n)])
cnt = 0
sum = 0

for i in range(n):
  sum = np.sum(a[i] * b) + c
  if sum > 0:
    cnt += 1

    
print(cnt)

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

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy

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

	int N; cin >> N;

	ll data[N][2];
	F0R(i, N) {
		F0R(j, 2) cin >> data[i][j];
	}

	ll ans = 0;

	F0R(xP, 2) {
		F0R(yP, 2) {
			ll xC = xP; if (xC == 0) xC = -1;
			ll yC = yP; if (yP == 0) yC = -1;

			vpl oldPoints;
			oldPoints.pb({0, 0});

			F0R(i, N) {
				vpl newPoints;
				F0R(j, sz(oldPoints)) {
					newPoints.pb(oldPoints[j]);
					newPoints.pb(mp(oldPoints[j].f+data[i][0]*xC, oldPoints[j].s+data[i][1]*yC));
				}
				sort(all(newPoints));
				reverse(all(newPoints));
				oldPoints.clear();

				F0R(x, sz(newPoints)) {
					int k = sz(oldPoints)-1;
					if (sz(oldPoints) == 0 || oldPoints[k].f < newPoints[x].f || oldPoints[k].s < newPoints[x].s) {
						oldPoints.pb(newPoints[x]);
					}
				}
            }

			F0R(i, sz(oldPoints)) {
				//cout << oldPoints[i].f << " " << oldPoints[i].s << endl;
				ans = max(ans, oldPoints[i].f*oldPoints[i].f+oldPoints[i].s*oldPoints[i].s);
			}
		}
	}


	cout << setprecision(30) << sqrtl((ld) ans) << endl;

	return 0;
}


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

using ll = long long;
using ld = long double;
constexpr ll inf = static_cast<ll>(1e17);
constexpr int iinf = static_cast<int>(1e9);
constexpr ll mod = static_cast<ll>(1e9 + 7);
constexpr long long MOD(long long in) {
	return in % mod;
}

using P=std::pair<int, int>;

int n, m;
int s, t;
std::vector<int> g[100005];
int d[100005][3];
int main() {
	std::cin >> n >> m;

	for (int i = 0; i < m; ++i) {
		int u, v;

		std::cin >> u >> v;
		--u, --v;

		g[u].emplace_back(v);
	}

	std::cin >> s >> t;
	--s, --t;

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

	d[s][0] = 0;
	std::queue<std::pair<int, int>> que;
	que.emplace(s, 0);
	while (!que.empty()) {
		auto p = que.front();
		que.pop();

		for (int i = 0, end = g[p.first].size(); i < end; ++i) {
			auto v = g[p.first][i];
			auto next = (p.second + 1) % 3;

			if (d[v][next] == -1) {
				d[v][next] = d[p.first][p.second] + 1;
				que.emplace(v, next);
			}
		}
	}

	if (d[t][0] < 0)
		std::cout << -1 << std::endl;
	else
		std::cout << d[t][0] / 3 << std::endl;

	return 0;
}


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

const int MAXN=1e5+5;

int main()
{
	int a[MAXN];
	int b[110][110];
    int h,w;
    while(scanf("%d%d",&h,&w)!=EOF)
    {
        int n;cin>>n;
        for(int i=1;i<=n;++i)
          cin>>a[i];
        int k=1;
        for(int i=1;i<=h;++i)
        {
            if(i&1)
            {
                for(int j=1;j<=w;++j)
                {
                   if(a[k]>0) {b[i][j]=k;--a[k];}
                   else if(a[k]==0) {++k;b[i][j]=k;--a[k];}
                }
            }
			else
            {
                for(int j=w;j>=1;--j)
                {
                    if(a[k]>0) {b[i][j]=k;--a[k];}
                    else if(a[k]==0) {++k;b[i][j]=k;--a[k];}
                }
            }
        }
        for(int i=1;i<=h;++i)
        {
            for(int j=1;j<=w;++j)
            {
                if(j!=w) cout<<b[i][j]<<endl;
                else cout<<b[i][j]<<endl;
            }
        }
    }
}

Measured memory_bytes: 384
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>

#define all(x) x.begin(),x.end()
#define sz(s) (int) s.size()
#define pb push_back
#define rc(x) return cout<<x<<"\n",0

using namespace std;
    void solve()
    {
     string s, t;
     cin >> s;
     cin >> t;
     bool ok = false;
     for (int i = 0; i < sz(s) ; i++)
      if (s[i] != t[i])
          {
            cout << "No";
            ok = true;
            break;
          }
    if ( ok == false) cout << "Yes" ;
      
 }
               
    int main()
    {
        ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
        int t=1;
        //cin>>t;
        while(t--)
        {
            solve();
        }
    }

Measured memory_bytes: 3652
#include <cstdio>
#include <cstring>
static const int MAXN = 1e5 + 4;

char s[MAXN];

int main()
{
    scanf("%s", s);
    int len = strlen(s);
    puts((s[0] == s[len - 1]) ^ (len % 2 == 1) ? "First" : "Second");
    return 0;
}


Measured memory_bytes: 256
import static java.lang.Math.*;
import static java.util.Arrays.*;

import java.util.*;
import java.io.*;

public class Main {

	void run() {
		Scanner sc = new Scanner(System.in);
		for(;;) {
			int n = sc.nextInt();
			if( n == 0 ) break;
			Poly[] poly = new Poly[n+1];
			for(int i=0;i<=n;i++) {
				int m = sc.nextInt();
				poly[i] = new Poly();
				for(int j=0;j<m;j++) poly[i].add(new P(sc.nextInt(), sc.nextInt()));
			}
			for(int i=1;i<=n;i++) if(poly[0].equal(poly[i])) System.out.println(i);
			System.out.println("+++++");
		}
	}
	
	class Poly {
		int size;
		ArrayList<P> list;
		Poly() {
			list = new ArrayList<P>();
			size = 0;
		}
		
		void add(P p) {
			list.add(p);
			size++;
		}
		int[][][] tr = { {{1, 0}, {0, 1}}, {{0, 1}, {-1, 0}}, {{0, -1}, {1, 0}}, {{-1, 0}, {0, -1}} };
		boolean equal(Poly poly) {
			if(size != poly.size) return false;
			int sx = poly.list.get(0).x, sy = poly.list.get(0).y;
			int dx = list.get(0).x, dy = list.get(0).y;
			for(int i=0;i<4;i++) {
				boolean f = true;
				for(int j=0;j<size;j++) {
					int px = (poly.list.get(j).x - sx) * tr[i][0][0] + (poly.list.get(j).y - sy) * tr[i][0][1] + dx;
					int py = (poly.list.get(j).x - sx) * tr[i][1][0] + (poly.list.get(j).y - sy) * tr[i][1][1] + dy;
					debug(j, px, list.get(j).x, py, list.get(j).y);
					if(px != list.get(j).x || py != list.get(j).y) f = false;
				}
				if( f ) return true;
			}
			sx = poly.list.get(size-1).x; sy = poly.list.get(size-1).y;
			for(int i=0;i<4;i++) {
				boolean f = true;
				for(int j=0;j<size;j++) {
					int px = (poly.list.get(size-j-1).x - sx) * tr[i][0][0] + (poly.list.get(size-j-1).y - sy) * tr[i][0][1] + dx;
					int py = (poly.list.get(size-j-1).x - sx) * tr[i][1][0] + (poly.list.get(size-j-1).y - sy) * tr[i][1][1] + dy;
					debug(j, px, list.get(j).x, py, list.get(j).y);
					if(px != list.get(j).x || py != list.get(j).y) f = false;
				}
				if( f ) return true;
			}
			return false;
		}
	}
	
	class P {
		int x, y;
		P(int x, int y) {
			this.x = x;
			this.y = y;
		}
	}

	void debug(Object... os) {
//		System.err.println(Arrays.deepToString(os));
	}

	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 32940
#include <iostream>
#include <queue>
#include <algorithm>
#include <cstring>

using namespace std;

namespace {
    const int MAX_W = 50;
    const int MAX_H = 50;
    int W, H;
    int F[MAX_H][MAX_W];
    bool input() {
        cin >> W >> H;
        if (W == 0 && H == 0) return false;
        for (int i = 0; i < H; i++) {
            for (int j = 0; j < W; j++) {
                cin >> F[i][j];
            }
        }
        return true;
    }

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

    void solve() {
        bool used[H][W];
        memset(used, 0, sizeof(used));
        int ans = 0;
        for (int i = 0; i < H; i++) {
            for (int j = 0; j < W; j++) {
                if (F[i][j] == 0) continue;
                if (used[i][j]) continue;
                typedef pair<int, int> P;
                queue<P> Q;
                Q.push(P(i, j));
                ans++;
                used[i][j] = true;
                while (!Q.empty()) {
                    P c = Q.front(); Q.pop();
                    int y = c.first, x = c.second;
                    for (int k = 0; k < 8; k++) {
                        int ny = y + dy[k];
                        int nx = x + dx[k];
                        if (ny < 0 || ny >= H) continue;
                        if (nx < 0 || nx >= W) continue;
                        if (F[ny][nx] == 0) continue;
                        if (used[ny][nx]) continue;
                        used[ny][nx] = true;
                        Q.push(P(ny, nx));
                    }
                }
            }
        }
        cout << ans << endl;
    }
}

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

Measured memory_bytes: 1232
from sys import stdin, stdout
from collections import deque
from math import log10


l = int(stdin.readline())
n = 21
M = 0

vertices = [[] for i in range(n)]
cur = 2
f = 20
vl = 1
i = f - 1

while cur <= l:
    vertices[i].append((i + 1, 0))
    vertices[i].append((i + 1, vl))
    M += 2
    vl <<= 1
    cur <<= 1
    i -= 1

st = i + 1
cur >>= 1


while cur != l:
    lb, rb = st, f
    
    while rb - lb > 1:
        m = (lb + rb) >> 1
        
        if (1 << (f - m)) + cur <= l:
            rb = m
        else:
            lb = m
    
    vertices[st].append((rb, cur))
    cur = (1 << (f - rb)) + cur
    M += 1
    

stdout.write(str(f - st + 1) + ' ' + str(M) + '\n')
for i in range(st, f + 1):
    for v in vertices[i]:
        stdout.write(str(i - st + 1) + ' ' + str(v[0] - st + 1) + ' ' + str(v[1]) + '\n')


Measured memory_bytes: 3316
# -*- coding: utf-8 -*-

SA,SB,SC = [input().strip() for _ in range(3)]

S_dic={}
S_dic['a']=SA
S_dic['b']=SB
S_dic['c']=SC

turn="a"
while True:
    if S_dic[turn] == "":
      print(turn.upper())
      break
    
    next_turn = S_dic[turn][0]
    S_dic[turn] = S_dic[turn][1:]
    turn = next_turn


Measured memory_bytes: 3060
#include<bits/stdc++.h>
	using namespace std;
	typedef long long ll;
	typedef double d;
	#define for(i,a,b) for(int i=a;i<b;i++)
	#define f(i,a,b) for(int i=a;i<=b;i++)
    int main()
    {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    int k,c=0;
    long long n=0;
    cin>>k;
    if(k%2==0) return cout<<-1<<endl,0;
    while(c<=k)
    {
     n=n*10+7;
     c+=1;
     n=n%k;
     if(n==0) {return cout<<c<<endl,0;}
	}
    
cout<<-1<<endl;
}

Measured memory_bytes: 3632
from sys import stdin

M, D = [int(x) for x in stdin.readline().rstrip().split()]
ans = 0

for m in range(1, M + 1):
    for d in range(1, D + 1):
        if d >= 10:
            d1 = int(str(d)[1])
            d10 = int(str(d)[0])
            if m == d1 * d10 and d1 >= 2 and d10 >= 2:
                ans += 1

print(ans)


Measured memory_bytes: 38896
from heapq import heappush,heappop,heapify
from collections import deque,defaultdict,Counter
import itertools
from itertools import permutations,combinations
import sys
import bisect
import string
import math
import time
#import random
def I():
    return int(input())
def MI():
    return map(int,input().split())
def LI():
    return [int(i) for i in input().split()]
def LI_():
    return [int(i)-1 for i in input().split()]
def StoI():
    return [ord(i)-97 +10 for i in input()]
def ItoS(nn):
    return chr(nn+97)
def GI(V,E,Directed=False,index=0):
    org_inp=[]
    g=[[] for i in range(n)]
    for i in range(E):
        inp=LI()
        org_inp.append(inp)
        if index==0:
            inp[0]-=1
            inp[1]-=1
        if len(inp)==2:
            a,b=inp
            g[a].append(b)
            if not Directed:
                g[b].append(a)
        elif len(inp)==3:
            a,b,c=inp
            aa=(inp[0],inp[2])
            bb=(inp[1],inp[2])
            g[a].append(bb)
            if not Directed:
                g[b].append(aa)
    return g,org_inp
def show(*inp,end='\n'):
    if show_flg:
        print(*inp,end=end)
YN=['Yes','No']
mo=10**9+7
inf=float('inf')
l_alp=string.ascii_lowercase
u_alp=string.ascii_uppercase

#sys.setrecursionlimit(10**5)
input=lambda: sys.stdin.readline().rstrip()

show_flg=False
show_flg=True

ans='Possible'
n=I()
a=LI()
M=max(a)
m=min(a)
c=[0]*(M+1)
for i in range(n):
    c[a[i]]+=1
if sum([min(c[i],1) for i in range(m,M+1)])!=M-m+1:
    ans='Impossible'
if c[m]!=1+M%2:
    ans='Impossible'
    
print(ans)

Measured memory_bytes: 38640
import java.util.*;
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    
    String s = sc.next();
    
    String first = s.substring(0,1);
    String second = s.substring(1,2);
    String third = s.substring(2,3);
    String fourth = s.substring(3,4);
    
    if (first.equals(second)) {
      System.out.println("Bad");
    } else if (second.equals(third)) {
      System.out.println("Bad");
    } else if (third.equals(fourth)) {
      System.out.println("Bad");
    } else {
      System.out.println("Good");
    }
  }
}

Measured memory_bytes: 21204
#include <iostream>
#include <algorithm>

#define ll long long
using namespace std;

ll lcm(ll a, ll b) {
    return a / __gcd(a, b) * b;
}

int main() {
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    ll x = b / c +
           b / d -
           b / lcm(c, d);
    a--;
    ll y = a / c +
           a / d -
           a / lcm(c, d);

    cout << (b - a) - (x - y) << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int X = sc.nextInt();
		int N = sc.nextInt();
		int[] p = new int[N];
		for(int i=0; i<N; i++)
			p[i] = sc.nextInt();
		Arrays.sort(p);
		int ans = X;
		for(int i=0; i<100; i++) {
			int v = X-i;
			if(Arrays.binarySearch(p, v)<0) {
				ans = v;
				break;
			}
			v = X+i;
			if(Arrays.binarySearch(p, v)<0) {
				ans = v;
				break;
			}
		}

		System.out.println(ans);
		sc.close();
	}
}


Measured memory_bytes: 27176
/*
    A - ABC333
    https://atcoder.jp/contests/abc109/tasks/abc109_a
*/
#include <bits/stdc++.h>
using namespace std;

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

    int a, b;
    cin >> a >> b;

    if (a % 2 == 0 || b % 2 == 0) {
        cout << "No" << endl;
    } else if (a == 1 && b == 1 || a == 3 && b == 3) {
        cout << "Yes" << endl;
    } else if (a == 1 && b == 3 || a == 3 && b == 1) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
def main():
    n = int(input())
    # G = [[0] * (n-1) for i in range(2)]
    cnt = [0] * n
    G = [[] for i in range(n)]
    for i in range(n-1):
        a, b = map(int, input().split())
        G[a-1].append((b-1, i))
        cnt[a-1] += 1
        cnt[b-1] += 1


    # for i in range(n-1):
    #     a,b = map(int, input().split())
    #     G[0][i] = a-1
    #     G[1][i] = b-1
    #     cnt[a-1] += 1
    #     cnt[b-1] += 1
    num = 0
    # print(G)
    print(max(cnt))

    tmp_clr = [0] * (n-1)
    tmp_edge = [0] * n

    # print(G)
    for frm, child in enumerate(G):
        clr = 1
        for j, to  in enumerate(child):

            if tmp_edge[frm] == clr :
                clr += 1
            tmp_clr[to[1]] = clr
            # tmp_edge[frm] = clr
            tmp_edge[to[0]] = clr
            clr+=1
    # print(tmp_edge)
    # print(tmp_clr)
    print('\n'.join(map(str, tmp_clr)))

if __name__=='__main__':
    main()


Measured memory_bytes: 34204
#include<bits/stdc++.h>
using namespace std;
int main()
{
	 string s;
	 cin>>s;
	 for(int i=0;i<s.length();i++)
	 {
	 	 if(s[i]=='9')s[i]='1';
	 	 else if(s[i]=='1')s[i]='9';
	 }
	 cout<<s;
}

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

int main(){
	int n,a, max=0, second_max=0;
	vector<int> arr;
	cin >> n;
	for(int i=0; i<n; ++i){
		cin >> a;
		arr.push_back(a);
		if(a >= max){
			if(i == 0){
				max = a;
			}
			else{
				second_max = max;
				max = a;
			}
		}
		else{
			if(a > second_max){
				second_max = a;
			}
		}
	}
	// Print result
	//cout << "max: " << max << " second_max: " << second_max << '\n';
	for(int i=0; i<n; ++i){
		if(arr[i] == max){
			cout << second_max << '\n';
		}
		else{
			cout << max << '\n';
		}
	}
	return 0;
}

Measured memory_bytes: 2548
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AtCoder
{
    class Program
    {
        private const int MODULO = 1000000007;
        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }

        static long Solve(int N, int A, int B)
        {
            return Math.Max((Math.BigMul(B, N - 1) + A) - (Math.BigMul(A, N - 1) + B) + 1, 0);
        }
        static void Main(string[] args)
        {
            var V = ReadInts();
            Console.WriteLine(Solve(V[0], V[1], V[2]));
        }
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC target("sse4")

using namespace std;

#define FOR(a,b) for(int a=0;a<b;a++)
#define F0R(a,b,c) for(int a = b; a<=c; a++)
#define f first
#define s second
#define m0(x) memset(x,0,sizeof(x))

typedef pair<int,int> pi;
typedef long long ll;
typedef vector<int> vi;
typedef vector<pi> vpi;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    int a,b,c,d; cin >> a >> b >> c >> d;
    while(a > 0 && c > 0){
        c -= b;
        a -= d;
    }
    if(c <= 0) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3648
#include <algorithm>
#include <cstring>
#include <ctime>
#include <iostream>
#include <map>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <deque>
using namespace std;

#ifdef __APPLE__
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define eprintf(...)
#endif

const int N = (int)1e6 + 123;
const int MOD = (int)1e9 + 7;
const int inf = (int)5e8;
const long long infll = (long long)1e17;

int a[N];

void solve() {
    int n;
    scanf("%d", &n);
    for (int i = 0; i < n; ++i) {
        scanf("%d", &a[i]);
    }
    deque<int> b;
    for (int i = 0; i < n; ++i) {
        if (i % 2 == 0) {
            b.push_back(a[i]);
        } else {
            b.push_front(a[i]);
        }
    }
    vector<int> ans;
    for (auto i : b) {
        ans.push_back(i);
    }
    if (n % 2)  {
        reverse(ans.begin(), ans.end());
    }
    for (auto i : ans) {
        printf("%d ", i);
    }
}

int main() {
#ifdef __APPLE__
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    int t = 1;
    while (t--) {
        solve();
    }
}

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

int main() {
	
	int n;
	cin >> n;
	int need = 1;
	int del = 0;
	for (int i=0; i<n; i++) {
		int x;
		cin >> x;
		if (x == need) {
			need++;
		}
		else {
			del++;
		}
	}
	if (del == n) {
		cout << -1 << endl;
	}
	else {
		cout << del << endl;
	}
	
}


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

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();

            Console.WriteLine(Math.Min(input[0] * input[1], input[2]));


        }
    }
}

Measured memory_bytes: 13396