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

#define int long long

vector<int> v;

signed main() {

    int sum = 0;
    int n, l;
    cin >> n >> l;

    for ( int i = 0; i < n; i++ ) {
        sum += i + l;
        v.push_back(i+l);
    }

    sort(v.begin(), v.end());

    int ans = 0;
    int diff = INT_MAX;

    for ( int i = 0; i < n; i++ ) {
        if ( abs(sum-(sum-v[i])) < diff ) {
            diff = abs(sum-(sum-v[i]));
            ans = sum-v[i];
        }
    }

    cout << ans << endl;

    return 0;
}


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

int main() {
  int N, a;
  cin >> N;
  
  int b = N;

  for (int i = 9; i > 0; i--) {
	int digit = 1;
    
    for (int j = 0; j < (i - 1); j++) {
      digit *= 10;
    }
    
    if (b >= digit) {
      a += (b - b % digit) / digit;
      b = b % digit;
    }
  }
  
  if (N % a == 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  
  return 0;
}

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

inline void swap(int a[], int i, int j){
	int t = a[i]; a[i] = a[j]; a[j] = t;
}

void selection(int a[], int N)
{
	int i, j, min;
	for(i = 1; i < N; i++){
		min = i;
		for(j = i + 1; j <= N;j++)
			if(a[min] > a[j]) min = j;
		swap(a, min, i);
	}
}

int main(){
	int a[6];
	for(int i = 1; i <= 5; i++){
		int n;
		cin >> n;
		a[i] = n;
	}
	selection(a, 5);
	for(int i = 5; i > 1; i--)
		cout << a[i] << " ";
	cout << a[1] << endl;
}

Measured memory_bytes: 0
#include <algorithm>
#include <cmath>
#include <complex>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>
#include <functional>
#include <cstring>
#include <regex>
#include <random>
#include <cassert>
#include <stack>
#include <climits>
using namespace std;

#pragma region

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, s, n) for (int i = (s); i < (int)(n); i++)
#define revrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define revrepr(i, s, n) for (int i = (n) - 1; i >= s; i--)
#define debug(x) cerr << #x << ": " << x << "\n"
#define popcnt(x) __builtin_popcount(x)

const double PI = acos(-1.0);

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

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; }

template<class T>
istream& operator >>(istream &is, vector<T> &v) {
    for (int i = 0; i < (int)v.size(); i++) cin >> v.at(i);
    return is;
}

template<class T, class U>
ostream& operator <<(ostream &os, pair<T, U> p) {
    cout << '(' << p.first << ", " << p.second << ')';
    return os;
}

template<class T>
void print(const vector<T> &v, const string &delimiter = " ") { rep(i, v.size()) cout << (0 < i ? delimiter : "") << v.at(i); cout << endl; }

template<class T>
void print(const vector<vector<T>> &vv, const string &delimiter) { for (const auto &v: vv) print(v, delimiter); }

#pragma endregion


int main() {
    string res[4] = { "AC", "WA", "TLE", "RE" };
    int n;
    cin >> n;
    vector<int> cnt(4);
    rep(_, n) {
        string s;
        cin >> s;
        rep(i, 4) if (res[i] == s) cnt[i]++;
    }

    rep(i, 4) {
        printf("%s x %d\n", res[i].c_str(), cnt[i]);
    }
}

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

int main() {
	int l; cin >> l;
	int sum = 0, n;
	vector<tuple<int, int, int>> ans;
	for(int i = 0; sum + (1 << i) < l; ++i) {
		ans.emplace_back(i + 1, i + 2, 0);
		ans.emplace_back(i + 1, i + 2, (1 << i));
		n = i + 2;
		sum += (1 << i);
	}
	for(int i = n - 2; i >= 0; --i) {
		if(sum + (1 << i) < l) {
			ans.emplace_back(i + 1, n, sum + 1);
			sum += (1 << i);
		}
	}
	cout << n << " " << ans.size() << '\n';
	for(auto e : ans) {
		int a, b, c;
		tie(a, b, c) = e;
		printf("%d %d %d\n", a, b, c);
	}
	return 0;
}

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

int main(){
	int n,cnt=0,tmp=0;
	cin>>n;
	for(int i=1;i<=n;++i){
		if(i%2==0)	continue;
		tmp=0;
		for(int j=1;j<=i;++j)
			if(i%j==0)	tmp++;
		if(tmp==8)	cnt++;
	}
	cout<<cnt;
}

Measured memory_bytes: 256
#include<cmath>
#include<math.h>
#include<ctype.h>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<cwchar>
#include<cwctype>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<iterator>
#include<limits>
#include<list>
#include<locale>
#include<map>
#include<memory>
#include<new>
#include<numeric>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<typeinfo>
#include<utility>
#include<valarray>
#include<vector>
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
using namespace std;
int n,a[200010],b[200010],c[200010],d[200010];
long long ans;
int work(int x,int y)
{
	x--;
	int l,r,mid,s,f;
	bool flag;
	l=0;
	r=n-1;
	flag=false;
	while (l<=r)
	{
		mid=(l+r)>>1;
		/*
		if (c[mid]==x)
		{
			s=mid;
			flag=true;
			break;
		}
		*/
		if (c[mid]<=x)
		{
			l=mid+1;
		}
		else
		{
			r=mid-1;
		}
	}
	if (!flag)
	{
		s=l;
	}
	l=0;
	r=n-1;
	flag=false;
	while (l<=r)
	{
		mid=(l+r)>>1;
		/*
		if (c[mid]==y)
		{
			f=mid+1;
			flag=true;
			break;
		}
		*/
		if (c[mid]<=y)
		{
			l=mid+1;
		}
		else
		{
			r=mid-1;
		}
	}
	if (!flag)
	{
		f=l;
	}
	//cout<<x<<" "<<y<<" "<<s<<" "<<f<<endl;
	return f-s;
}
int main()
{
	scanf("%d",&n);
	for (int i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
	}
	for (int i=0;i<n;i++)
	{
		scanf("%d",&b[i]);
	}
	for (int k=1;k<30;k++)
	{
		for (int i=0;i<n;i++)
		{
			c[i]=a[i]%(1<<k);
			d[i]=b[i]%(1<<k);
		}
		sort(c,c+n);
		int res=0;
		for (int i=0;i<n;i++)
		{
			int l,r;
			l=((1<<(k-1))-d[i]+(1<<k))%(1<<k);
			r=((1<<k)-1-d[i]+(1<<k))%(1<<k);
			//cout<<d[i]<<endl;
			//cout<<l<<" "<<r<<endl;
			if (l<=r)
			{
				res+=work(l,r);
				//cout<<res<<endl;
			}
			else
			{
				res+=work(0,r)+work(l,(1<<k)-1);
			}
			//system("pause");
		}
		if (res&1)
		{
			//printf("%d\n",k);
			ans+=(1<<(k-1));
		}
	}
	printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 3328
use proconio::{input, fastout};
use std::collections::{HashSet, HashMap};

#[fastout]
fn main() {
    input! {
        n: i32,
        m: i32,
        r: [(i32, i32); m],
    }
    let mut done: HashMap<i32, i32> = HashMap::new();

    let mut rooms: HashMap<i32, HashSet<i32>> = HashMap::new();
    for i in 1..(n + 1) {
        rooms.insert(i, HashSet::new());
    }
    for e in r {
        rooms.get_mut(&e.0).unwrap().insert(e.1);
        rooms.get_mut(&e.1).unwrap().insert(e.0);
    }

    let mut next: HashSet<i32> = HashSet::new();
    next.insert(1);

    while next.len() > 0 {
        let now = next;
        next = HashSet::new();
        for n in now {
            for e in rooms.get(&n).unwrap() {
                if *e != 1 && !done.contains_key(e) {
                    next.insert(*e);
                    done.insert(*e, n);
                }
            }
        }
    }
    let mut v: Vec<(i32, i32)> = Vec::new();
    for e in done {
        v.push(e);
    }
    v.sort_by(|(k1, _v1), (k2, _v2)| k1.cmp(k2));
    println!("Yes");
    for (_k, v) in v {
        println!("{}", v);
    }
}


Measured memory_bytes: 21404
#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <tuple>
#include <functional>
#include <cmath>
#include <complex>

using namespace std;
#define PI       3.14159265358979323846
#define MOD 1000000007

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef complex<double> P;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

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


using namespace std;

int a[105];

int main() {
	int n;
	scanf("%d", &n);
	REP(i, n) scanf("%d", a + i);
	sort(a, a + n, greater<int>());
	int ret = 0;
	int mul = 1;
	REP(i, n) {
		ret += mul*a[i];
		mul = -mul;
	}
	cout << ret << endl;
	return 0;
}

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

typedef long long int ll;
typedef long double ld;

//****************************************************                
#define lp(var,start,end) for (ll var = start; var <end ; ++var)
#define rlp(var,start,end) for(ll var = start; var>=end ; var--)
#define pb push_back
#define mp make_pair
#define pf push_front
#define ff first
#define ss second
#define vll vector<ll>
#define pll pair<ll,ll> 
#define vpll vector<pll>
#define all(X) X.begin(),X.end()
#define endl "\n" //comment it for interactive questions
#define trace1(a) cerr << #a << ": " << a << endl;
#define trace2(a,b) cerr << #a << ": " << a << " " << #b << ": " << b << endl;
#define trace3(a,b,c) cerr << #a << ": " << a << " " << #b << ": " << b << " " << #c << ": " << c << endl;
#define trace4(a,b,c,d) cerr << #a << ": " << a << " " << #b << ": " << b << " " << #c << ": " << c << #d << ": " << d << endl;
#define OC   
#define FAST_IO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
        //*******************************************************
//Some Functions

const ll MOD = (ll)1e9+7; //change it for other mods

ll powmod(ll a,ll b)
{
   ll res = 1;
   while(b > 0) {
      if(b & 1) res = (res * a) % MOD;
      a = (a*a)%MOD;
      b = b >> 1; 
  }
  return res % MOD;
}

ll fact[600000], der[600000];

ll ncr(ll n, ll r) {
	if(n < r) {
		return 0;
	}
	if(r == 0) {
		return 1;
	}
	ll res = fact[n];
	res = (res * powmod(fact[n-r], MOD -2))%MOD;
	res = (res * powmod(fact[r], MOD -2))%MOD;
	return res;
}
void solve(ll testnum)
{
    ll n,m;
    cin >> n >> m;
    fact[0] = 1;
    fact[1] = 1;
    for(ll i=2;i<=m;i++) {
    	fact[i] = (i*fact[i-1])%MOD;
    }
    der[1] = 0;
    der[2] = 1;
    for(ll i=3;i<=m;i++) {
    	der[i] = (i-1)*((der[i-1] + der[i-2])%MOD);
    	der[i]%=MOD;
    }
    ll ans = 0;
    for(ll i=0;i<=n;i++) {
    	ll res = (ncr(m-i, n-i)*fact[n-i])%MOD;
    	res = (res * res)%MOD;
    	res = (res * ncr(n, i))%MOD;
    	res = (res * ncr(m, i))%MOD;
    	res = (res * fact[i])%MOD;
    	// cout << i << " " << ans << " " << res << "\n";
    	if(i%2 == 0) {
    		ans = (ans + res) % MOD;
    	} else {
    		ans = (MOD + ans - res)%MOD;
    	} 
    }
    cout << ans << "\n";
}

int main()
{
    FAST_IO;
    #ifdef STIO 
      freopen("input.txt" , "r", stdin);
      freopen("output.txt" , "w", stdout);
    #endif
    ll t = 1;
    // cin >> t;
    for (ll i = 1; i <= t; i++) {
        solve(i);
    }
}

Measured memory_bytes: 11456
#include <bits/stdc++.h>
#define N 100010
using namespace std;

double mem[N][50];
bool used[N][50];
double dfs(int day,int cnt,double p){
  if(day == 0) return 0;
  if(cnt >= 50) return 0;
  if(used[day][cnt])return mem[day][cnt];
  used[day][cnt] = 1;
  double res = 0;
  res+=p*(1+dfs(day-1,cnt+1,p/2));
  if(cnt)res+=(1-p)*dfs(day-1,0,1);
  return mem[day][cnt] = res;
}

int main(){
  int n;
  while(cin>>n,n)printf("%f\n",dfs(n,0,1));
  return 0;
}

Measured memory_bytes: 54072
const Main = input => {
    const inp = input.split("\n");
    const s = inp[0];
    const t = inp[1];

    if(t.indexOf(s) === 0 && s.length + 1 === t.length) {
        console.log("Yes");
    } else {
        console.log("No");
    }
}
 
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 29624
import array
import sys
input = sys.stdin.readline

class UnionFind():
    def __init__(self,n):
        self.parent = [-1 for _ in range(n)]

    def size(self,x):
        return -self.parent[self.find(x)]

    def find(self,x):
        if(self.parent[x]<0):
            return x
        else:
            self.parent[x]=self.find(self.parent[x])
            return self.parent[x]

    def unite(self,x,y):
        x = self.find(x)
        y = self.find(y)
        if(x == y):
            return False
        if(self.size(x)<self.size(y)):
            self.parent[y]+=self.parent[x]
            self.parent[x]=y
        else:
            self.parent[x]+=self.parent[y]
            self.parent[y]=x
        return True

    def same(self,x,y):
        return self.find(x)==self.find(y)

def main():
    N = int(input())
    xli = []
    yli = []
    x_app = xli.append
    y_app = yli.append


    for i in range(N):
        x,y = (int(x) for x in input().split())
        x_app([x-1,i])
        y_app([y-1,i])
    xli.sort()
    yli.sort()

    edges = []
    edges_app = edges.append
    for i in range(N-1):
        edges_app((xli[i][1],xli[i+1][1],xli[i+1][0]-xli[i][0]))
        edges_app((yli[i][1],yli[i+1][1],yli[i+1][0]-yli[i][0]))


    edges.sort(key=lambda edge: edge[2])
    uf = UnionFind(N)
    weight = 0

    for edge in edges:
        if not uf.same(edge[0], edge[1]):
            uf.unite(edge[0], edge[1])
            weight+=edge[2]
    print(weight)

if __name__ == '__main__':
    main()


Measured memory_bytes: 134108
#include <iostream>
#include <vector>
#include <map> 
#include <algorithm>
#include <cstring>

#define ll long long
using namespace std; 
long a[3001];

void solve(){
  int n; 
  cin >> n; 
  // vector<int> a(n); 
  for(int i=0; i<n; i++){
    cin >> a[i]; 
  }
  long dp[n][n]; 
  for(int l=1; l<=n; l++){
    for(int i=0; i<=n-l; i++){
      if(l==1){
        dp[i][i] = a[i];  
      }else{
        dp[i][i+l-1] = max(a[i]- dp[i+1][i+l-1], a[i+l-1] - dp[i][i+l-2]); 
      }
    }
  }
  cout << dp[0][n-1] << "\n"; 
}

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

Measured memory_bytes: 49744
<?php
fscanf(STDIN, "%d", $n);
$a = explode(' ', trim(fgets(STDIN)));

$max = max($a);
$f = array_fill(1, $max, 0);

foreach ($a as $v) {
  $k = 1;
  while ($v*$k <= $max) {
    if ($k == 1 && $f[$v*$k] == 1) {
      $f[$v*$k]++;
      break;
    }

    $f[$v*$k]++;
    $k++;
  }
}

$ans = 0;
foreach ($a as $v) {
  if ($f[$v] == 1) {
    ++$ans;
  }
}

echo $ans;


Measured memory_bytes: 60972
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
using P = pair<ll, ll>;

vector<P> v;
ll ans = 0;
vector<ll> prime;
ll N, M;

void dfs(ll idx, ll now){
    if(idx == v.size()){
        if(M / now >= N) ans = max(ans, now);
        return;
    }
    ll mul = 1;
    for(ll i = 0; i <= v[idx].second; i++){
        dfs(idx + 1, now * mul);
        mul *= v[idx].first;
    }
}

void init(){
    bool po[(ll)1e5 + 1] = {};
    for(ll i = 2; i <= 1e5; i++){
        if(po[i]) continue;
        prime.push_back(i);
        for(ll j = 1; i * j <= 1e5; j++) po[i * j] = 1;
    }
}


int main(){
    init();
    cin >> N >> M;
    ll cpy = M;
    for(auto p : prime){
        ll cnt = 0;
        while(cpy % p == 0){
            cpy /= p;
            cnt++;
        }
        if(cnt) v.push_back(P(p, cnt));
    }
    dfs(0, 1);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 512
import java.io.BufferedReader
import java.io.InputStream
import java.io.InputStreamReader
import java.io.PrintWriter
import java.lang.StringBuilder
import java.util.*

fun PrintWriter.solve(sc: FastScanner) {
    val a = sc.nextInt()
    val b = sc.nextInt()
    val c = sc.nextInt()
    val max = arrayOf(a,b,c).max()!!
    var i = max
    while (true) {
        val n = 3 * i - (a + b + c)
        if (n % 2 == 0) {
            println(n / 2)
            return
        }
        i++
    }
}

fun main(args: Array<String>) {
    val writer = PrintWriter(System.out, false)
    writer.solve(FastScanner(System.`in`))
    writer.flush()
}

class FastScanner(s: InputStream) {
    private var st = StringTokenizer("")
    private val br = BufferedReader(InputStreamReader(s))

    fun next(): String {
        while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())

        return st.nextToken()
    }

    fun nextInt() = next().toInt()
    fun nextLong() = next().toLong()
    fun nextLine() = br.readLine()
    fun nextDouble() = next().toDouble()
    fun ready() = br.ready()
}

Measured memory_bytes: 31932
import java.util.*;
import java.util.Map.Entry;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		Map<Long, Long> map = new TreeMap<Long, Long>();
		for (int i = 0; i < N; i++) {
			long a = sc.nextLong();
			long b = sc.nextLong();
			if (map.containsKey(b)) {
				long val = map.get(b);
				map.put(b, val + a);
			} else {
				map.put(b, a);
			}
		}
		sc.close();

		long time = 0;
		for (Entry<Long, Long> entry : map.entrySet()) {
			time += entry.getValue();
			if (time > entry.getKey()) {
				System.out.println("No");
				return;
			}
		}
		System.out.println("Yes");
	}
}


Measured memory_bytes: 75720
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define sz(v) (int)(v).size()
#define pb push_back
#define sc second
#define fr first
#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())
using namespace std;
typedef long long int ll;
typedef pair <int, int> P;
double dp[3000][30000];
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N;
    cin>>N;
    double p[N];
    rep(i,0,N) cin>>p[i];
    rep(i,0,N){
        rep(j,0,i+2){
            if(i==0){
                if(j==0) dp[i][j]=1-p[i];
                else dp[i][j]=p[i];
            }
            else{
                if(j==0) dp[i][j]=dp[i-1][j]*(1-p[i]);
                else dp[i][j]=dp[i-1][j]*(1-p[i])+dp[i-1][j-1]*p[i];
            }
        }
    }
    double ans=0;
    rep(i,N/2+1,N+1){
        ans+=dp[N-1][i];
    }
    cout <<setprecision(15)<<ans<<"\n";
}

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

using namespace std;

#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
#define Eunique(v) v.erace(unique(all(v)),v.end())
#define pvec(v)　rep(i,v.size()){cout << v[i] << " ";}
#define INF 0x3f3f3f3f
#define mset(m,v) memset(m,v,sezeof(m))
#define mod (ll)(1e9 +7);

const double pi = acos(-1.0);

typedef vector<int> vi;
typedef string ss;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef deque<ll> dll;
typedef pair<ll,ll> P;
ll dx[4] = {1,0,-1,0},dy[4] = {0,1,0,-1};

ll gcd(ll x,ll y)
{
    ll r;
    while((r = x % y) != 0)
    {
        x = y;
        y = r;
    }
    return y;
}

ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b; // Be careful not to overflow
}

ll digsum(ll n){
    ll sum = 0;
    while(n > 0){
        sum += n % 10;
        n /= 10;
    }

    return sum;
}

string to_binString(int val)
{
    if( !val )
        return std::string("0");
    string str;
    while( val != 0 ) {
        if( (val & 1) == 0 )  // val は偶数か？
            str.insert(str.begin(), '0');  //  偶数の場合
        else
            str.insert(str.begin(), '1');  //  奇数の場合
        val >>= 1;
    }
    return str;
}

int main()
{
    string s,ans;
    cin >> s;

    if(s == "Sunny")ans = "Cloudy";
    else if(s == "Cloudy")ans = "Rainy";
    else ans = "Sunny";
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
S =input()

input_line = int(input())

flag0 = ""
flag1 = ""
flag = 0


for i in range(input_line):
    action = list(input())
    # print(flag0,flag1)
    # print(action)
    if action[0]=="1":
        if flag == 0:
            flag = 1
        else:
            flag = 0
    else:
        # print("check")
        if action[2] == "2":
            
            if flag == 0:
                flag1 = flag1 + action[4]
            elif flag ==1:
                flag0 = action[4] + flag0
        else:
            if flag == 0:
                flag0 = action[4] + flag0
            
            elif flag == 1:
                flag1 += action[4]
                
S = flag0 + S + flag1
if flag == 1:
    S = S[::-1]
print(S)

Measured memory_bytes: 4380
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define ls (o<<1)
#define rs (o<<1|1)
#define pb push_back
const double PI= acos(-1.0);
const int M = 1e5+7;
/*
int head[M],cnt;
void init(){cnt=0,memset(head,0,sizeof(head));}
struct EDGE{int to,nxt,val;}ee[M*2];
void add(int x,int y){ee[++cnt].nxt=head[x],ee[cnt].to=y,head[x]=cnt;}
*/
 
char s[M];
struct na{
	int x,y;
	bool operator <(const na &r)const
	{
		return y<r.y;
	}
};
struct nb{
	int x,y;
	bool operator <(const nb &r)const
	{
		return x>r.x;
	}
};
vector<na>va;
vector<nb>vb;
int main()
{
	ios::sync_with_stdio(false);
  	cin.tie(0);
  	int n;
  	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>s;
		int l=strlen(s);
		int a=0,b=0;
		for(int j=0;j<l;j++)
		{
			if(s[j]=='(')a++;
			else
			{
				if(a)a--;
				else b++;
			}
		}
		//这里a的意思是需要在这个字符串后面补多少右括号，b是需要在其前面补多少左括号 
	 	//当a>b时，说明做左括号比右括号多，肯定优先放前面。显然，此时b越小在前面越优，因为需要在前面补左括号的个数就少了 
		//a<b时同理
	//	cout<<a<<" "<<b<<endl;
		if(a>=b)va.pb(na{a,b});
		else vb.pb(nb{a,b});
	} 
	sort(va.begin(),va.end());
	sort(vb.begin(),vb.end());
	bool f=true;
	int sm=0;
	for(int i=0;i<va.size();i++)
	{
		sm-=va[i].y;
		if(sm<0)f=false;//前面的左括号能否满足当前字符串的需要
		sm+=va[i].x;//当前字符串所能提供的左括号
		//肯定是左括号需求量少的在前面 
	}
	for(int i=0;i<vb.size();i++)
	{
		sm-=vb[i].y;
		if(sm<0)f=false;
		sm+=vb[i].x;
		//右边肯定是对称的来考虑，即需求后面右括号少的放在最右边 
	}
	if(sm!=0)f=false;
	if(f)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 11216
import std.stdio, std.conv, std.string, std.array, std.range, std.algorithm, std.container;
import std.math, std.random, std.bigint, std.datetime, std.format;
void main(string[] args){ if(args.length > 1) if(args[1] == "-debug") DEBUG = 1; solve(); }
void log()(){ writeln(""); } void log(T, A ...)(T t, lazy A a){ if(DEBUG) write(t, " "), log(a); } bool DEBUG = 0; 
string rstring(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }
T rtype(T)(){ return rstring.to!T; } alias rint = rtype!int, rlong = rtype!long, rreal = rtype!real;
T[] rtypes(T)(int n){ return n.iota.map!(i => rtype!T()).array; } alias rint = rtypes!int, rlong = rtypes!long, rreal = rtypes!real;
T[][] rtypess(T)(int n, int m){ return n.iota.map!(i => rtypes!T(m)).array; } alias rint = rtypess!int, rlong = rtypess!long, rreal = rtypess!real;
T chmin(T)(ref T x, T y){ if(x > y) x = y; return x; } T chmax(T)(ref T x, T y){ if(x < y) x = y; return x; }

// ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- //

void solve(){
	long a = rlong, b = rlong;
	if(a == 1 || b == 1) "1".writeln;
	else if(a * b % 2 == 0) (a * b / 2).writeln;
	else (a * b / 2 + 1).writeln;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
using ll = long long;
int main() {
    ll n,m;
    cin >> n >> m;
    ll ans = 1;
    ll mod=1000000007;
    for (int i = 0; i < n; i++) {
        ans *= (m - i);
        ans %= mod;
    }
    ll p = 1;
    ll q = 0;
    for (int i = 0; i < n; i++) {
        int qq = q;
        q = (qq+p) * (n - i - 1);
        p *= (m - n);
        p += qq * (m - n + 1);
        p %= mod;
        q %= mod;
    }
    cout << ans*p%mod<< endl;
}

Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
#define ll long long
map<int,ll>mp;
main()
{
	int n;
	cin>>n;
	ll ans=0;
	for(int i=1,x;i<=n;i++)
	{
		cin>>x;
		ans=ans+mp[i-x];
		mp[i+x]++;
	}
	cout<<ans<<"\n";
}



Measured memory_bytes: 26272
from collections import Counter
n = int(input())
arr = list(map(int, input().split()))

odd_list =[]
num_list =[]

for i in range(n):
    if i%2 == 0:
        odd_list.append(arr[i])
    if i%2 != 0:
        num_list.append(arr[i])

odd_count = Counter(odd_list)
num_count = Counter(num_list)
odd1 = odd_count[odd_count.most_common()[0][0]]
num1 = num_count[num_count.most_common()[0][0]]

if odd1 != num1:
    print(n-odd_count.most_common()[0][1]-num_count.most_common()[0][1])
    exit()

if len(set(arr)) == 1:
    print(int(n/2))
    exit()

if len(set(num_list))==1 and len(set(odd_list))==1:
    print(0)
    exit()

if len(set(odd_count)) == 1 and len(set(num_count)) != 1:
    num2 = num_count[num_count.most_common()[1][0]]
    if odd_list[0] == num_count.most_common()[0][0]:
        print(int(n/2)-num2)
        exit()
    if odd_list[0] != num_count.most_common()[0][0]:
        print(int(n/2)-num1)
        exit()

if len(set(odd_count)) != 1 and len(set(num_count)) == 1:
    odd2 = odd_list[odd_count.most_common()[1][0]]
    if num_list[0] == odd_count.most_common()[0][0]:
        print(int(n/2)-odd2)
        exit()
    if num_list[0] != odd_count.most_common()[0][0]:
        print(int(n/2)-odd1)
        exit()

odd2 = odd_count[odd_count.most_common()[1][0]]
num2 = num_count[num_count.most_common()[1][0]]

if odd_count.most_common()[0][0] != num_count.most_common()[0][0]:
    print(n-odd1-num1)

if odd_count.most_common()[0][0] == num_count.most_common()[0][0]:
    print(min(n-odd1-num2, n-odd2-num1))

Measured memory_bytes: 110192
import sys
sys.setrecursionlimit(1000000)
input = sys.stdin.readline
# from bisect import *
from collections import *
# from heapq import *
# INF = 500000
mod = 10**9+7

class UnionFind:

    def __init__(self, n):
        self.n = n
        self.par = [i for i in range(n)]
        self.height = [0] * n
        self.size = [1] * n

    def find(self, x):
        if self.par[x] == x:
            return x
        self.par[x] = self.find(self.par[x])
        return self.par[x]

    def getsize(self, x):
        return self.size[self.find(x)]

    def unite(self, x, y):
        x, y = self.find(x), self.find(y)
        if x == y:
            return
        if self.height[x] < self.height[y]:
            self.par[x] = y
            self.size[y] += self.size[x]
        else:
            self.par[y] = self.par[x]
            self.size[x] += self.size[y]
            if self.height[x] == self.height[x]:
                self.height[x] += 1

    def same(self, x, y):
        return self.find(x) == self.find(y)

N, M, K = map(int, input().split())
es = [[] for i in range(N)]
for i in range(M):
    u, v = map(int, input().split())
    u -= 1
    v -= 1
    es[u].append(v)
    es[v].append(u)
uf = UnionFind(N)
g = [-1]*N
def dfs(v, num):
    g[v] = num
    for u in es[v]:
        if g[u] == -1:
            uf.unite(v, u)
            dfs(u, num)
num = 0
for v in range(N):
    if g[v] == -1:
        dfs(v, num)
        num += 1
ans = [uf.getsize(v)-len(es[v])-1 for v in range(N)]
for i in range(K):
    u, v = map(int, input().split())
    u -= 1
    v -= 1
    if uf.same(u, v):
        ans[u] -= 1
        ans[v] -= 1
print(*ans)


Measured memory_bytes: 50880
M = int(raw_input())

t0,x0,y0=0,0,0
OK=1

for i in range(M):
    t,x,y = map(int, raw_input().split())
    dl=abs(x-x0)+abs(y-y0)
    dt=t-t0
    if(dl>dt):
        OK=0
        break
    elif ((dt-dl)%2==1):
        OK=0
        break
    else:
        t0,x0,y0=t,x,y

if OK==1 :
    print "Yes"
else:
    print "No"
 

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

using namespace std;


int main()
{
int N,K;
cin>>N;
cin>>K;

double max=0;
max=((N+1)/2)+0.5;


if(K<max)cout<<"YES"<<endl;
if(K>max)cout<<"NO"<<endl;
return 0;
}


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

using namespace std;

int main() {
    string s;
    cin >> s;
    if(s == "SUN"){
        cout << 7;
    }else if(s == "MON"){
        cout << 6;
    }else if(s == "TUE"){
        cout << 5;
    }else if(s == "WED"){
        cout << 4;
    }else if(s == "THU"){
        cout << 3;
    }else if(s == "FRI"){
        cout << 2;
    }else if(s == "SAT"){
        cout << 1;
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.ArrayDeque;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();
		int[][] map = new int[4][4];
		int a, b;
		for (int i = 0; i < 3; i++) {
			a = sc.nextInt() - 1;
			b = sc.nextInt() - 1;
			map[a][b]++;
			map[b][a]++;
		}
		boolean memo[];
		int tmp;
		boolean t;
		ArrayDeque<Integer> deque = new ArrayDeque<>();
		for (int i = 0; i < 4; i++) {
			deque.add(i);
			memo = new boolean[4];
			memo[i] = true;
			t = true;
			while (!deque.isEmpty()) {
				tmp = deque.poll();
				for (int j = 0; j < 4; j++) {
					if (map[tmp][j] == 1 && !memo[j]) {
						memo[j] = true;
						deque.add(j);
						break;
					}
				}
			}
			for (int j = 0; j < 4; j++) {
				if (!memo[j]) {
					t = false;
					break;
				}
			}
			if (t) {
				System.out.println("YES");
				return;
			}
		}
		System.out.println("NO");
	}
}


Measured memory_bytes: 23252
#include<stdio.h>
#include<string.h>
int main()
{
    long long int i,r,a,b;
    scanf("%lld %lld %lld",&r,&a,&b);
    long long int sum=b;
    for(i=1;i<=10;i++){
        sum=sum*r-a;
        printf("%lld\n",sum);
    }
}


Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <bitset>
#include <cmath>
#include <string>
#define FI first
#define SE second
#define VE vector<int>
#define PB push_back
#define MA make_pair
#define LL long long
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
using namespace std;
//
const int INF=1e9+7;
//
int main(){
  int N,Q;
  set<int> S;
  cin>>N;
  FOR(i,0,N){
    int A;
    cin>>A;
    S.insert(A);
  }
  int ans=0;
  cin>>Q;
  FOR(i,0,Q){
    int A;
    cin>>A;
    if(S.find(A)!=S.end()){
      ans++;
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 3116
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashSet;
import java.util.StringTokenizer;
public class Main {

	public static void main(String[] args) {

				FastScanner sc = new FastScanner();

				int Kuji = sc.nextInt();
				//リスト定義
				//List<String> gift = new ArrayList<String>();
				HashSet<String> hs = new HashSet<String>();

				//kujiの個数回繰り返す。
			for(int i = 1; i <= Kuji; i++) {
				String syohin = sc.next();
				//リストの中にデータがなければ追加する
					hs.add(syohin);
			}
				//リストの数を出力する。
		System.out.println(hs.size());
			}
		}


class FastScanner {

	BufferedReader br;

	StringTokenizer st;



	public FastScanner() {

		br = new BufferedReader(new InputStreamReader(System.in));

	}



	String next() {

		while (st == null || !st.hasMoreElements()) {

			try {

				st = new StringTokenizer(br.readLine());

			} catch (IOException e) {

				e.printStackTrace();

			}

		}

		return st.nextToken();

	}



	int nextInt() {

		return Integer.parseInt(next());

	}



	long nextLong() {

		return Long.parseLong(next());

	}

}

Measured memory_bytes: 72016
function main(input) {
    var arr = input.replace(/\r?\n/g, "").split(" ");
    const A = arr[0], B = arr[1], C = arr[2];
    var flg = false;
    if (A == B && B != C) flg = true;
    if (B == C && C != A) flg = true;
    if (C == A && A != B) flg = true;
    if (flg) console.log("Yes");
    else console.log("No");
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

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

int main() {
  int n;
  cin >> n;
  vector<vector<int>> p(n, vector<int>(3));
  rep(i,n) rep(j,3) cin >> p[i][j];
  vector<vector<int>> dp(n+1, vector<int>(3));
  for(int i = 1; i <= n; i++) {
    for(int j = 0; j < 3; j++) {
      for(int k = 0; k < 3; k++) {
        if(j == k) continue;
        dp[i][k] =  max(dp[i][k], dp[i-1][j] + p[i-1][k]);
      }
    }
  }
  int ans = 0;
  rep(i,3) ans = max(ans, dp[n][i]);
  cout << ans << endl;
  return 0;
}

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

void solve(int x,int y,int MAP[20][20],int s,int n);

int main()
{
    int x,y,num,size;
    char c;
    int MAP[20][20];

    while(cin >> size >> num , size && num)
    {
        int cnt = 0;

        for(int i=0; i<num; i++){
            for(int j=0; j<size; j++){
                cin >> c;
                if(c == '.'){
                    MAP[i][j] = 0;
                }
                if(c == '#'){
                    MAP[i][j] = 1;
                }
                if(c == '@'){
                    x = j;
                    y = i;
                    MAP[i][j] = 0;
                }
            }
        }

        solve(x,y,MAP,size,num);
        for(int i=0; i<num; i++){
            for(int j=0; j<size; j++){
                if(MAP[i][j] == 2)cnt++;
            }
        }

        cout << cnt << endl;
    }

    return 0;
}

void solve(int x,int y,int MAP[20][20],int s,int n)
{
    MAP[y][x] = 2;

    if(x-1 >= 0){
        if(MAP[y][x-1] == 0){
            solve(x-1,y,MAP,s,n);
        }
    }
    if(x+1 < s){
        if(MAP[y][x+1] == 0){
            solve(x+1,y,MAP,s,n);
        }
    }
    if(y-1 >= 0){
        if(MAP[y-1][x] == 0){
            solve(x,y-1,MAP,s,n);
        }
    }
    if(y+1 < n){
        if(MAP[y+1][x] == 0){
            solve(x,y+1,MAP,s,n);
        }
    }

    return;
}

Measured memory_bytes: 1180
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;
const ll Mod = 998244353;
const int MAX = 510000;
const double PI = 3.14159265358979323846;

int main() {
  int A, B;
  cin >> A >> B;
  cout << A*B << endl;
}

Measured memory_bytes: 3636
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<int, int> P;
typedef pair<int, P> E;
#define MOD (1000000007ll)
#define l_ength size

int n,a,b,c,l[10],ans=INF;

void dfs(int d, int x, int y, int z, int p, int q, int r){
	if(d<n){
		dfs(d+1,x,y,z,p,q,r);
		dfs(d+1,x+l[d],y,z,p+1,q,r);
		dfs(d+1,x,y+l[d],z,p,q+1,r);
		dfs(d+1,x,y,z+l[d],p,q,r+1);
	}else if(p&&q&&r){
		ans = min(ans,abs(x-a)+abs(y-b)+abs(z-c)+10*(p+q+r-3));
	}
}

int main(void){
	int i;
	cin >> n;
	cin >> a >> b >> c;
	for(i=0; i<n; ++i){
		cin >> l[i];
	}
	dfs(0,0,0,0,0,0,0);
	cout << ans << endl;
	return 0;
}


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

int main() {
  int x, y;
  cin >> x >> y;
  if (x == 2 || y == 2) cout << "No" << endl;
    
  else if ((x-1)%7%2==(y-1)%7%2) cout << "Yes" << endl;
  
  else cout << "No" << endl;
}


Measured memory_bytes: 256
// dile a la jardinera que traigo flores

#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define sz(x) int(x.size())
#define all(v) (v).begin(),(v).end()
#define trace(x) cout << #x << " = " << x << endl
#define fastio ios_base::sync_with_stdio(0);cin.tie(0)
#define FER(i,a,b) for(int i = int(a); i < int(b); ++i)
#define IFR(i,a,b) for(int i = int(a); i >= int(b); i--)
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;

int est[10],mm[10];
const int inf=1e9;



int main(){	
	fastio;
	int n;cin>>n;
	int A,B,C;cin>>A>>B>>C;
	FER(i,0,n)cin>>mm[i];
	int lim=(1<<(2*n));
	int ans=inf;
	FER(i,0,lim){
		int here=i;
		FER(j,0,n){
			est[j]=here%4;
			here/=4;
		}
		int val=inf;
		bool hay1=false,hay2=false,hay3=false;
		FER(j,0,n)if(est[j]==1)hay1=true;
		FER(j,0,n)if(est[j]==2)hay2=true;
		FER(j,0,n)if(est[j]==3)hay3=true;
		if(hay1&&hay2&&hay3){
			int val1=0,val2=0,val3=0;
			int mp=-30;
			FER(j,0,n)if(est[j]==1)val1+=mm[j],mp+=10;
			FER(j,0,n)if(est[j]==2)val2+=mm[j],mp+=10;
			FER(j,0,n)if(est[j]==3)val3+=mm[j],mp+=10;
			mp+=abs(A-val1);
			mp+=abs(B-val2);
			mp+=abs(C-val3);
			if(mp<ans){
				ans=mp;
				//FER(j,0,n)cout<<est[j];
				//cout<<endl;
				//trace(mp);
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int N = in.nextInt();
        int  min = Integer.MAX_VALUE;
        int max = Integer.MIN_VALUE;

        for (int i = 0; i < N; ++i) {
            int x = in.nextInt();
            min = Math.min(min, x);
            max = Math.max(max, x);
        }

        System.out.println(Math.abs(max - min));
    }
}

Measured memory_bytes: 23636
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; ++i)
#define ALL(v) v.begin(), v.end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1000000007;

struct job
{
	int a,b;
};

bool cmp(job a,job b)
{
	return a.b < b.b;
}

int main()
{
	int n;
	cin >> n;
	vector<job> ab(n);
	rep(i,n)
	{
		cin >> ab[i].a >> ab[i].b ;
	}
	sort(ALL(ab),cmp);
	ll now=0;
	rep(i,n)
	{
		now += ab[i].a;
		if(now>ab[i].b)
		{
			cout<<"No"<<endl;
			return 0;
		}
	}
	cout<<"Yes"<<endl;
	return 0;
}

Measured memory_bytes: 1792
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, i321) => {
        read_value!($next, i32) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

//
// # Examples
//
// # integers
// input! { n: i32, m: i32, ... }
//
// # array
// input! { n: i32, v: [i32; n], }
//
// # matrix
// input! { n: i32, m: i32, mat: [[]] }
//
// # string
// input! { s: chars }
//
// 3 4
// ####
// #..#
// .#.#
//
// input!{
//     h: i32,
//     w: i32,
//     board: [chars; h],
// }

// https://practice.contest.atcoder.jp/tasks/practice_1
//fn main() {
//    input!{
//        a: i32, b: i32, c: i32,
//        foo: chars,
//    }
//    let s: String = foo.into_iter().collect();
//    println!("{} {}", a+b+c, s);
//}
fn main() {
    input! { a: i32, b: i32, c: i32 }
    if a == b && a != c {
        println!("{}",c);
    } else if a != b && a == c {
        println!("{}",b);
    } else {
        println!("{}",a);
    }
}

Measured memory_bytes: 4352
#include <iostream>
#include <string>
#include <vector>
#include <string.h>

using namespace std;

int main() {
  int n, m;
  int cost[10] = { 0, 2, 5, 5, 4, 5, 6, 3, 7, 6 };
  cin >> n >> m;
  string dp[n + 1];
  vector<int> a;

  for (int i = 0; i < m; i++) {
    int num;
    cin >> num;
    a.push_back(num);
  }
  for (int i = 0; i <= n; i++) {
    dp[i] = "";
  }
  bool checked[n + 1];
  memset(checked, false, sizeof(checked));
  checked[0] = true;
  string ans = "";

  for (int i = 0; i < n; i++) {
    if (!checked[i]) continue;

    for (int j = 0; j < m; j++) {
      int v = a[j];
      int total = i + cost[v];
      if (total > n) continue;

      string org = dp[total];
      string str = dp[i] + to_string(v);

      if (org.size() == str.size()) {
        if (org < str) {
          dp[total] = str;
          checked[total] = true;

          if (total == n) ans = str;
        }
      } else if (org.size() < str.size()) {
          dp[total] = str;
          checked[total] = true;

          if (total == n) ans = str;
      }
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 33024
import sys
from itertools import accumulate

input = sys.stdin.readline


class SegmentTree:
    """Segment Tree class.

    Args:
        N (int): Number of elements
        X (list[int]): List for initialization
        func (callable): Function for interval.
        init_v (int): Initial value that does not affect `func`.
            For example, specify INF when `func = min`.

    References:
        <https://en.wikipedia.org/wiki/Segment_tree>
    """
    def __init__(self, N, X, func, init_v):
        N_ = 1
        while N_ < N: N_ *= 2
        self.N = N_
        self.func = func
        self.init_v = init_v
        self.__build(X)

    def __build(self, X):
        # Initialize all nodes
        self.node = [[self.init_v, -1] for _ in range(2 * self.N)]  # 1-based index

        # Elementary intervals are stored
        for i, x in enumerate(X, self.N):
            self.node[i] = [x, i - self.N + 1]

        # The internal nodes correspond to intervals that are the union of elementary intervals
        for i in range(self.N - 1, 0, -1):
            self.node[i] = self.func(self.node[i << 1], self.node[i << 1 | 1])

    def update(self, i, x):
        """Update the i-th node value to x.

        Args:
            i (int): index (1-based index)
            x (int): udpate value
        """
        i += self.N - 1
        self.node[i][0] = x
        while i > 1:
            i >>= 1
            self.node[i] = self.func(self.node[i << 1], self.node[i << 1 | 1])

    def query(self, l, r):
        """Query for right half-open interval [l, r).

        Args:
            l (int): index (1-based index)
            r (int): index (1-based index)
        """
        dst_l = [self.init_v, -1]
        dst_r = [self.init_v, -1]
        l += self.N - 1
        r += self.N - 1
        while l < r:
            if l & 1:
                dst_l = self.func(dst_l, self.node[l])
                l += 1
            if r & 1:
                r -= 1
                dst_r = self.func(self.node[r], dst_r)
            l >>= 1
            r >>= 1
        return self.func(dst_l, dst_r)


def func(a, b):
    return a if a[0] > b[0] else b


def main():
    N, M = map(int, input().split())
    AB = [None] * N
    for i in range(N):
        AB[i] = tuple(map(int, input().split()))

    AB.sort(key=lambda x: x[0])
    B = [0] * N
    C = [0] * (1 + 10 ** 5)
    for i, (a, b) in enumerate(AB):
        B[i] = b
        C[a] += 1
    C = list(accumulate(C))

    st = SegmentTree(N, B, func, -1)
    ans = 0
    l = 1
    for r in C[1:M + 1]:
        if r == 0:
            continue
        x, i = st.query(l, r + 1)
        if x == -1:
            continue
        ans += x
        st.update(i, -1)

    print(ans)


if __name__ == "__main__":
    main()


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

int main(){
    int N, M;
    std::cin >> N >> M;
    std::vector< std::pair< int, int > > AB(N+1);
    for(int i=0; i<N; i++){
        std::cin >> AB[i].first >> AB[i].second;
    }
    AB[N].first = 1e9;
    AB[N].second = 0;
    std::sort(AB.begin(), AB.end());
    
    std::priority_queue<int> que;
    
    int index = 0;
    int ans = 0;
    for(int i=1; i<=M; i++){
        while(AB[index].first == i){
            que.push(AB[index].second);
            index++;
        }
        if(!que.empty()){
            ans += que.top();
            que.pop();
        }
    }
    
    std::cout << ans << std::endl;
    
    return 0;
}



Measured memory_bytes: 1660
#include <iostream>

using namespace std;
int t, n;
int d[10001];

int main()
{
   cin >> n;
   for (int x = 1; x*x <= n; x++)
   for (int y = 1; y*y <= n; y++)
   for (int z = 1; z*z <= n; z++)
    {
        t = x*x+y*y+z*z+x*y+y*z+z*x;
        if (t > n) break;
        d[t]++;
    }
   for (int i = 1 ; i <= n; i++)
    cout << d[i] << endl;
   
   return 0;
}

Measured memory_bytes: 3552
#A
n, a, b = list(map(int,input().split()))
s = abs(a-b)

def chk(c,d):
    return abs(c-d)//2

if s % 2 == 0:
    print(s//2)
else:
    #p = max(a-1,b-1)
    #q = max(n-a,n-b)
    r = min(a-1,n-b) 
    u = r + 1 + min(chk(1,b-r-1),chk(a+r+1,n))
    print(u)

Measured memory_bytes: 3060
import sys

def make_divisors(n):
    D=[]
    for i in range(1, int(n**0.5)+1):
        if n%i==0:
            D.append(i)
            if i!=n//i:
                D.append(n//i)
    return list(sorted(D))

x=int(input())
D=make_divisors(x)
for d in D:
    #print(d)
    now=-(d//2)
    cnt=0
    while cnt<=10**9:
        #print(now+d,now,cnt)
        cnt=(now+d)**5-now**5
        if cnt==x:
            print(now+d,now)
            sys.exit()
        now+=1

Measured memory_bytes: 9404
N,K=map(int,input().split())
P=list(map(lambda x:int(x)-1,input().split()))
C=list(map(int,input().split()))

ans=-10**18

for i in range(N):
    cnt=K
    pos=i
    tmp=[0]
    base=C[pos]
    while cnt and P[pos]!=i:
        pos=P[pos]
        tmp.append(tmp[-1]+C[pos])
        base+=C[pos]
        cnt-=1
    if P[pos]==i:
        if base>0:
            test=base*(K//len(tmp))
            cnt=K%len(tmp)
            if cnt:
                ttt=max(tmp[j] for j in range(1,cnt+1))
                if test:
                    ttt=max(ttt,0)
                test+=ttt
            ans=max(ans,test)
            if K>=len(tmp):
                test=base*(K//len(tmp)-1)
                cnt=len(tmp)-1
                ttt=max(tmp[j] for j in range(1,cnt+1))
                if test:
                    ttt=max(ttt,0)
                test+=ttt
                ans=max(ans,test)
        else:
            tmp.append(tmp[-1]+C[i])
            cnt=min(K,len(tmp)-1)
            if cnt:
                test=max(tmp[j] for j in range(1,cnt+1))
                ans=max(ans,test)
    else:
        test=max(tmp[j] for j in range(1,len(tmp)))
        ans=max(ans,test)


print(ans)


Measured memory_bytes: 83968
#include <stdio.h>
#include <cctype>
#include <limits.h>
#include <math.h>
#include <complex>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cstring>
#include <string>
#include <sstream>
#include <algorithm>
#include <iomanip>
#include <iostream>

#define VARIABLE(x) cerr << #x << "=" << x << endl
#define BINARY(x) static_cast<bitset<16> >(x);
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for (int i=m;i<(int)(n);i++)
#define if_range(x, y, w, h) if (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))

const int INF = 1000000000;
const double EPS = 1e-8;
const double PI = 3.14159;
int dx[4]={-1, 0, 1, 0}, dy[4]={0, -1, 0, 1};
using namespace std;
typedef pair<int, int> P;

/** Problem0511 : Who Are The Student Yet To Submit **/
int main()
{
	bool a[30] = {0};
	rep(i, 28) {
		int b; cin>>b;
		a[b-1] = true;
	}
	rep(i, 30) {
		if (!a[i])
			cout << i+1 << endl;
	}
}

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

int main() {
  double w,h,x,y;
  cin>>w>>h>>x>>y;
  
  double ans = w * h / 2.0;
  // ans = max(ans, min(w-x,x) * h);
  // ans = max(ans, min(h-y,y) * w);
  cout << fixed << setprecision(10) << ans << " ";
  cout << (w/2.0==x&&h/2.0==y?1:0) << endl;
  return 0;
}


Measured memory_bytes: 256