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

using namespace std;

int main(void){

    int n, count = 0;
    vector<int> list, list2;

    cin >> n;

    for(int i = 0;i < n;i++){
        int x;
        cin >> x;
        list.push_back(x);
        list2.push_back(x);
    }

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

    for(int i = 0;i < n;i++){
        if(list[i] != list2[i]){
            count++;
        }
    }
    
    cout << (count <= 2 ? "YES" : "NO") << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main() {
	string str;
	cin >> str;
	sort(str.begin(), str.end());
	if (str[0] == str[1] && str[2] == str[3] && str[1] != str[2]) {
		cout << "Yes" << endl;
	}
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
#include <atcoder/all>
using namespace atcoder;
using namespace std;
using ll = long long int;
using int64 = long long int;
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const int INF = 1LL << 29;
const ll LONGINF = 1LL << 60;
const ll MOD = 1000000007LL;

using mint = modint998244353;

namespace seg_f {
    using S = pair<mint, int>; // value, len
    using F = int;
    mint inv9 = mint(9).inv();

    mint ONE(F len) {
        // 1111...1 を長さ len だけ
        // 1 + 10 + 100 + ... + 10^(len-1)
        // 初項 1, 公比 10, 項数 len
        // (1-10^len) / (1-10) --> (10^len-1)/9
        return (mint(10).pow(len) - mint(1)) * inv9;
    }
    
    S op(S a, S b) {
        mint av; int al; tie(av, al) = a;
        mint bv; int bl; tie(bv, bl) = b;
        mint rv = mint(10).pow(bl) * av + bv;
        int rl = al + bl;
        return make_pair(rv, rl);
    }
    
    S e() {
        return make_pair(mint(0), 0);
    }

    S mapping(F f, S x) {
        if(f < 0) return x;
        return make_pair(ONE(x.second) * mint(f), x.second);
    }

    F composition(F f, F g) {
        if(f > 0) return f;
        return g;
    }

    F id() {
        return -1;
    }

    using seg_t = lazy_segtree<S, op, e, F, mapping, composition, id>;
}

int main() {
    int N, Q; scanf("%d%d", &N, &Q);
    vector< pair<mint, int> > A(N);
    for(int i=0; i<N; i++) A[i] = make_pair(mint(1), 1);

    seg_f::seg_t seg(A);
    while(Q--) {
        int l, r, d; scanf("%d%d%d", &l, &r, &d);
        l--;
        seg.apply(l, r, d);
        printf("%u\n", seg.all_prod().first.val());
    }
    return 0;
}


Measured memory_bytes: 9892
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    string S;
    cin >> S;
    int n = count(S.begin(),S.end(),'1');
    if(n==0){
        for(int i=0;i<N;i++) cout << 1 << "\n";
        return 0;
    }
    vec<map<int,int>> mp(N+1);
    vec<map<int,int>> mod(N+1);
    for(int d=-1;d<=1;d++){
        int m = n+d;
        if(!m) continue;
        mp[N-1][m] = 1%m;
        mod[N][m] = 0;
        for(int i=N-1;i>=0;i--){
            if(i!=N-1) mp[i][m] = 2*mp[i+1][m]%m;
            if(S[i]=='1') mod[i][m] = (mp[i][m]+mod[i+1][m])%m;
            else mod[i][m] = mod[i+1][m];
        }
    }
    vec<int> ans(N);
    auto calc = [](int x){
        int res = 0;
        while(x){
            int n = __builtin_popcount(x);
            x %= n;
            res++;
        }
        return res;
    };

    for(int i=0;i<N;i++){
        int m = (S[i]=='0'? n+1:n-1);
        if(m==0){
            ans[i] = 0;
            continue;
        }
        if(m==1){
            ans[i] = 1;
            continue;
        }
        int now = mod[0][m];
        if(S[i]=='0') (now += mp[i][m])%=m;
        else (now += m-mp[i][m])%=m;
//        cerr << i << " " << now << " " << m << "\n";
        ans[i] = calc(now)+1;
    }
    for(int i=0;i<N;i++) cout << ans[i] << "\n";
}

Measured memory_bytes: 79108
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		sc.close();
		int min = Math.min(a + b, b + c);
		min = Math.min(min, a + c);
		System.out.println(min);
	}
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, begin, end) for (int i = begin; i < (int)(end); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1000000007;

int main()
{
    int N;
    cin >> N;
    vector<int> A(N);
    int count = 0;
    int min = 1000000000;
    ll sum = 0;
    rep(i, 0, N)
    {
        cin >> A.at(i);
        if (A.at(i) < 0)
        {
            count++;
            sum += -A.at(i);
            if (-A.at(i) < min)
            {
                min = -A.at(i);
            }
        }
        else
        {
            sum += A.at(i);
            if (A.at(i) < min)
            {
                min = A.at(i);
            }
        }
    }
    if (count % 2 == 0)
    {
        cout << sum << endl;
    }
    else
    {
        cout << sum - 2 * min << endl;
    }
}

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

const long long inf = (long long) 1e9 * 100 + 5;
const int maxn = 105, maxm = (int) 1e5 + 5;
long long dp[maxn][maxm] = {0};
bool vis[maxn][maxm];
int n, w;
int we[maxn];
long long v[maxn];

long long solve(int i, int weight) {
    if (i == n) return 0;
    if (vis[i][weight]) return dp[i][weight];
    long long ans = solve(i + 1, weight);
    if (weight + we[i] <= w) ans = max(ans, solve(i + 1, weight + we[i]) + v[i]);
    vis[i][weight] = true;
    return dp[i][weight] = ans;
}
int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    cin >> n >> w;
    for (int i = 0; i < n; ++i) cin >> we[i] >> v[i];
    memset(vis, false, sizeof(vis));
    cout << solve(0, 0) << '\n';
    return 0;
}



Measured memory_bytes: 90368
#include <cstdio>
#include<iostream>
#include<map>
#include<algorithm>
#include<vector>
#include <cmath>
#include <iomanip>
#include <regex>
#include <queue>
using namespace std;
using ll = long long;
using Lf = long double;
using plong = pair<ll,ll>;
const int mod = 1000000007;
 
 
bool cmp(ll a,ll b){
    return a>b;
}
int main(){
    ll N,A,B;
    cin>>N>>A>>B;
    vector<ll> v(N);
    for(ll i=0;i<N;i++){
        cin>>v[i];
    }
    sort(v.begin(),v.end(),cmp);
    ll sum=0;
    for(ll i=0;i<A;i++){
        sum+=v[i];
    }
    long double r = (double)sum/A;
    printf("%.10Lf\n",r);
    ll com[51][51]={0};
    com[0][0] = 1;
    for (int i = 1; i < 51; ++i) {
        for (int j = 0; j <= i; ++j) {
            com[i][j] += com[i-1][j];
            if (j > 0) com[i][j] += com[i-1][j-1];        
        }
    }
    if(v[0]==v[A-1]){
        ll num=0;
        for(ll i=0;i<N;i++){
            if(v[i]==v[0]){
                num++;
            }
        }
        ll res=0;
        for(ll j=A;j<=B;j++){
            res += com[num][j];
        }
        cout<<res<<endl;
        return 0;
    }else{
        double _min = v[A-1];
        ll num_toA=0;
        ll num=0;
        for(ll i=0;i<A;i++){
            if(_min == v[i])num_toA++;
        }
        for(ll i=0;i<N;i++){
            if(_min == v[i])num++;
        }
        cout<<com[num][num_toA]<<endl;
    }

}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int n=0,k=0;
  int num[1000] = {0};
  int sum=0;
  scanf("%d %d",&n,&k);
  for(int i=0;i<n;i++){
    int cost = 0;
    scanf("%d ",&cost);
    num[i] = cost;
  }
  
  for(int i=0;i<n;i++){
     for(int i=0;i<n-1;i++){
       if(num[i] > num[i+1]){
         int k =0;
         k = num[i];
         num[i] = num[i+1];
         num[i+1] =k;
      }
    }
  }
  
  for(int i=0;i<k;i++){
    sum += num[i];
  }
  
  printf("%d",sum);
}

Measured memory_bytes: 1692
/*   _/                _/                 _/_/_/   _/
  _/_/_/_/   _/_/   _/_/_/_/   _/_/    _/       _/_/
   _/     _/    _/   _/     _/    _/  _/_/_/     _/
  _/     _/    _/   _/     _/    _/  _/    _/   _/
   _/_/   _/_/       _/_/   _/_/      _/_/     _/ */
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;
using ll=long long;
const int MOD=1e9+7;
const double pi=3.14159265358979323846;
const int inf=1e9+5;
const ll INF=1e18;
using P=pair<int,int>;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
int main() {
  cin.tie(0),cout.tie(0);
  ios::sync_with_stdio(false);
  int a;
  cin >> a;
  cout << a+a*a+a*a*a << endl;
}

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

int main(){
	int e;
	while(1){
		cin >> e;
		if(e == 0) break;

		int min = e;
		for(int i = 0; i * i * i <= e; i++){
			for(int j = 0; j*j+i*i*i <= e; j++){
				if(min > i + j + e - i*i*i - j*j){
					min = i + j + e - i*i*i - j*j;
				}
			}
		}
		cout << min << endl;
	}
}

Measured memory_bytes: 1160
import numpy as np
N, M, Q = map(int, input().split())
LR = []
for i in range(M):
    l, r = map(int, input().split())
    LR.append([l, r])
PQ = []
for i in range(Q):
    p, q = map(int, input().split())
    PQ.append([p, q])
ar_sec = np.zeros([N, N])
for i in range(M):
    l, r = LR[i][0], LR[i][1]
    ar_sec[l-1][r-1] += 1


ar_sum = np.zeros([N+1, N+1])
for i in range(N):
    for j in range(N):
        ar_sum[i+1][j+1] = ar_sum[i][j+1]+ar_sum[i+1][j]-ar_sum[i][j]+ar_sec[i][j]

for i in range(Q):
    p, q = PQ[i][0], PQ[i][1]
    print(int(ar_sum[q][q]-ar_sum[p-1][q]))


Measured memory_bytes: 56964
#include <iostream>

using namespace std;

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))

int main()
{
    int A,B,C,D,P;
    cin >> A >> B >> C >> D >> P;
    int X;
    int Y;
    X=A*P;
    Y=B+MAX(0,(P-C)*D);
    cout << MIN(X,Y) << endl;
    return 0;
}

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

public class Main {
	private static void solve(){
		//Implement solution here.
		int h = ni();
		int w = ni();
		int n = ni();
		if(h > w) {
			System.out.println((int)Math.ceil((double)n/h));
		}else {
			System.out.println((int)Math.ceil((double)n/w));
		}
	}

	//Switch input source (stdin/file)
	private static BufferedReader br;
	public static void main(String[] args){
		br = new BufferedReader(new InputStreamReader(System.in));
		String debugDataPath = System.getenv("DD_PATH");        
		if(debugDataPath != null){
			try{
				br = new BufferedReader(new InputStreamReader(new FileInputStream(new File(debugDataPath))));
			}catch(Exception e){
				throw new RuntimeException(e);
			}
		}
		solve();
	}

	//Input read utility
	private static StringTokenizer tokenizer = null;
	public static String next() {
		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(br.readLine());
			} catch (Exception e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}
	//Get next single int
	private static int ni() {
		return Integer.parseInt(next());
	}
	//Get next single long
	private static long nl() {
		return Long.parseLong(next());
	}
	//Get next single double
	private static double nd() {
		return Double.parseDouble(next());
	}
	//Get next int array from one line
	private static int[] na(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = ni();
		return a;
	}
	//Get next char array from one line
	private static char[] ns() {
		return next().toCharArray();
	}
	//Get next long array from one line
	private static long[] nal(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nl();
		return a;
	}
}


Measured memory_bytes: 21076
#include <bits/stdc++.h>
#define dbgi(x) cout << #x << " = " << (x) << "\n";
#define dbgvi(x) cout << #x << " = "; for(int i = 0; i < (x.size()); ++i) cout << x[i] << " ";
#define mrk() cout << "HERE\n"
#define int long long
#define vi vector < int >
#define vs vector < string >
#define vii vector < vi >
#define viii vector < vii >
#define viiii vector < viii >
#define pii pair < int, int >
#define vpii vector < pii >
#define foru(i, a, b) for(int i = a; i < b; ++i)
#define ford(i, b, a) for(int i = b; i > a; --i)
#define fastio() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ld long double
using namespace std;

const int mod = (int)1e9 + 7;
const int mxfac = (int)1e6;
int fac[mxfac];


int pw(int a, int b){
    if(b == 0)return 1;
    int t = pw(a, b / 2);
    if(b % 2 == 0){
        return (t * t) % mod;
    } else {
        return (((t * t) % mod) * a) % mod;
    }
}

void preparefac(){
    fac[0] = 1;
    foru(i, 1, mxfac){
        fac[i] = (fac[i - 1] * i) % mod;
    }
}

int c(int n, int k){
    if(k < 0 || n < 0 || (n - k) < 0)return 0;
    return (fac[n] * pw((fac[n - k] * fac[k]) % mod, mod - 2)) % mod;
}

signed main(){
    preparefac();
    int n;
    cin >> n;
    vi cnt(n + 1, 0);
    vi a(n + 1);
    foru(i, 0, n + 1)cin >> a[i];
    foru(i, 0, n + 1)cnt[a[i]]++;
    int cn = -1;
    foru(i, 1, n + 1){
        if(cnt[i] == 2)cn = i;
    }
    int pos = -1;
    foru(i, 0, n + 1){
        if(a[i] == cn){
            if(pos == -1){
                pos = i;
            } else {
                pos = i - pos + 1;
            }
        }
    }
    foru(k, 1, n + 2){
        int ans = (c(n + 1, k) - c(n + 1 - pos, k - 1) + mod) % mod;
        cout << ans << "\n";
    }

}


Measured memory_bytes: 10624
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
#define drep(i,cc,n) for(int i=cc;i>=n;--i)
typedef long long ll;
using namespace std;
const ll INF = 100000000000000000;

int main(){
    int a,b;
    cin>>a>>b;
    cout<<6-a-b<<endl;
    return 0;
}

Measured memory_bytes: 256
/*
If you want to shine like a sun, first burn like a sun.
*/

#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// using namespace __gnu_pbds;
using namespace std;
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define ll long long int
#define ld long double
#define vi vector<int>
#define vl vector<ll>
#define v2i vector<vector<int>>
#define v2l vector<vector<ll>>
#define ppi pair<int,int>
#define ppl pair<ll,ll>
#define vpi vector<ppi>
#define vpl vector<ppl>
#define all(x) x.begin(),x.end()
#define ii int,int 
#define ff first    
#define ss second
#define forn(i,a,b) for(int i=a;i<b;i++)
#define forr(i,a,b) for(int i=a;i>=b;i--)
#define forv(i,m) for(auto i : m)
#define imx INT_MAX
#define imn INT_MIN
#define inf 9000000000000000000
#define minf -inf
#define endl "\n"
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define sze size()
#define rvs reverse 
#define itr iterator 
#define pre cout<<fixed<<setprecision(10);
#define umap unordered_map
#define uset unordered_set
#define pi 3.141592653589793
#define MAXN 1000005
#define test1(x) cout << #x " = " << x << endl;
#define test2(x,y) cout << #x " = " << x << " " << #y " = " << y << endl;
const ll infinity = 9e18;


#define oset tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define MODM(a,b,md) ((a%md)*(b%md))%md
#define MODA(a,b,md) ((a%md)+(b%md))%md
#define ull unsigned long long int



bool compare(int a,int b) {return a > b;}
bool compare1(ppi a,ppi b) {return a.ff > b.ff;}
bool compare2(ppi a,ppi b) {return a.ss < b.ss;}
ll Npower(ll a,ll b) {ll product = 1; while(b){if(b&1){product = product*a;}a = a*a;b = b>>1;} return product;}
ll power(ll a,ll b,ll md) {ll product = 1; while(b){if(b&1){product = MODM(product,a,md);}a = MODM(a,a,md);b = b>>1;} return product%md;}
bool isprime(ll n){if(n < 2) return 0; ll i = 2; while(i*i <= n){if(n%i == 0) return 0; i++;} return 1;}
ll GCD(ll a,ll b) {return b==0 ? a:GCD(b,a%b);}
ll LCM(ll a,ll b) {return (a/GCD(a,b))*b; }



ll fact[MAXN],inv[MAXN];

void factorial()
{
    fact[0] = inv[0] = 1;

    for(ll i = 1; i < MAXN; i++)
    {
        fact[i] = (i*(fact[i-1]))%mod;
    }

    for(ll i = 1; i < MAXN; i++)
    {
        inv[i] = power(fact[i],mod-2,mod);
    }
}

int main()
{
    fast

/*
    #ifndef ONLINE_JUDGE
        freopen("input.txt",  "r",  stdin);
        freopen("output.txt", "w", stdout);
    #endif
//*/
	factorial();

    ll x,y;
    cin>>x>>y;

    if((x+y)%3 != 0)
    {
    	cout<<0;
    }
    else
    {
		ll b = (2*y - x)/3;
		ll a = (2*x - y)/3;

		if(a >= 0 && b >= 0)
		{

			ll ab = fact[a+b];
			
			ll ans = (fact[a+b]*((inv[a]*inv[b])%mod))%mod;

			cout<<ans;
		}
		else
		{
			cout<<0;
		}

    }




    return 0;
}

Measured memory_bytes: 15872
#include <bits/stdc++.h>
using namespace std;
#ifdef __DEBUG__
    void debug_out() { cerr << endl; } 
    template <typename Head, typename... Tail>
    void debug_out(Head H, Tail... T) {cerr << " " << H; debug_out(T...);}
    #define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
    #define debug(...) 
#endif

using ll = long long int;

inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

#include <atcoder/modint>
#include <atcoder/convolution>
using modint = atcoder::modint998244353;

int N;
vector<int> H;
inline void input(){
    fast_io();
    cin >> N;
    H = fetch_vec<int>(2*N);
}

int solve(){
    vector<modint> fact(2*N+1), revfact(2*N+1), odd_fact(2*N+1);
    fact[0] = fact[1] = 1;
    for (int i = 0; i < 2*N; i++) fact[i+1] = fact[i]*(i+1);
    revfact[2*N] = fact[2*N].inv();
    for (int i = 2*N-1; i >= 0; i--) revfact[i] = revfact[i+1]*(i+1);
    // odd_fact[i] = (2*i-1)!!
    odd_fact[0] = 1;
    for (int i = 0; i < 2*N; i++) odd_fact[i+1] = odd_fact[i]*(2*i+1);
    auto combi = [&](int n, int k){ return fact[n]*revfact[n-k]*revfact[k];};
    // modint ans = fact[2*N]*revfact[N]*modint(2).pow(N).inv();
    map<int, int> cnt;
    for(auto h:H) cnt[h]++;
    vector<ll> nums;
    for(auto [h,c]:cnt) nums.emplace_back(c);
    int K = nums.size();
    sort(nums.begin(),nums.end());
    deque<vector<modint> > q;
    for (int k = 0; k < K; k++)
    {
        ll n = nums[k];
        vector<modint> tmp;
        for (int i = 0; 2*i <= n; i++)
        {
            // tmp.push_back(fact[n]*revfact[i]*revfact[n-2*i]*modint(2).pow(i).inv());
            tmp.push_back(combi(n,2*i)*odd_fact[i]);
        }
        q.push_back(tmp);
    }
    auto cmp = [](vector<modint> a, vector<modint> b){return a.size() < b.size();};
    sort(q.begin(), q.end(), cmp);

    while(q.size()>1){
        vector<modint> c = atcoder::convolution(q[0], q[1]);
        q.push_back(c);
        q.pop_front();
        q.pop_front();
    }
    
    vector<modint> pair_coff = q.front();
    modint ans = 0;
    // 同じグループ内のペアを少なくともk個つくる、でほう助原理をつかう。
    for (int k = 0; k < (int)pair_coff.size(); k++)
    {
        modint ans_k = pair_coff[k]*odd_fact[N-k];
        if(k%2) ans -= ans_k;
        else ans += ans_k;
    }
    cout << ans.val() << "\n";
    return 0;
}   

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


Measured memory_bytes: 15692
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPLL(i, n) for (ll i = 0; i < (ll)(n); i++)
using namespace std;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;}
typedef long long ll;

// ABC150D = Semi Common Multiple
// aiは必ず偶数のなので2で割れる
// 任意k（つまり正数列A全部）について、「akを2で割った数」の「奇数倍の数」を調べる
// 「最小半公倍数」が見つかれば、Mをそれをそれで割れば数を求められる
// 6 = 2*3, 10 = 2*5 →　2で割った数は3と5 → 15（最小半公倍数、5倍と3倍）
// 15の「奇数倍」が答え
// aiが2と6 → 1と3 → 最小半公倍数は3 →　1000000000/3 = 333333333
// 333333333 - (333333333/2) = 333333333 - 166666666 = 166666667
// 14, 22, 40 → 7, 11, 20;2^2*5 → 2の累乗があっても良いが全てのakで2の累乗の個数が同じ場合のときのみ
// ↑の判定式が必要

ll gcd(ll n, ll m){
  if(m == 0) return n;
  return gcd(m, n%m);
}

ll lcm(ll n, ll m){
  return n / gcd(n, m) * m;
}

int func(int n){
  int cnt = 0;
  while(n%2 == 0){
    n /= 2;
    cnt++;
  }
  return cnt;
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, M; cin >> N >> M;
  vector<int> A(N);
  REP(i, N){
    int a; cin >> a;
    if(a%2 == 1){
      cout << 0 << endl;
      return 0;
    }
    a /= 2;
    A[i] = a;
  }
  int cnt = func(A[0]);
  REPLL(i, N){
    if(cnt != func(A[i])){
      cout << 0 << endl;
      return 0;
    }
    // A[i] >>= cnt; // 2^cntは無駄なので消す
  }
  // M >>= cnt; // 2^cntは無駄なので消す
  ll g = 1;
  REP(i, N){
    g = lcm(g, A[i]);
    if(g > M){
      cout << 0 << endl;
      return 0;
    }
  }
  cout << M/g - (M/g)/2 << endl;
}

Measured memory_bytes: 768
import sys
S = input()
half_idx = (len(S)-1)//2
half = S[0:half_idx]
for i in range(half_idx-1):
    if half[i] != half[-1-i]:
        print("No")
        sys.exit()
    
for i in range((len(S)+1)-(len(S)+3)//2):
    if S[i] != S[-1-i]:
        print("No")
        sys.exit()
print('Yes')
        


Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        double N = Integer.parseInt(sc.next());
        int L = Integer.parseInt(sc.next());

        int temp = 10000;
        int temp2 = 10000;
        for (int i = 0; i < N; i++) {
            if (temp > Math.abs(L + i)) {
                temp = Math.abs(L + i);
                temp2 = (L + i);
            }
        }
        System.out.println((int)(L * N + (N / 2) * (N - 1)) - temp2);
        sc.close();
    }
}


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

using namespace std;

int main() {
	string a, b;
	cin >> a >> b;
	for (int i = 0; i < a.size(); i++) {
		cout << a[i];
		if (i < b.size()) {
			cout << b[i];
		}
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
fun main(args : Array<String>) {
    val (n, m) = readLine()!!.split(" ").map { it.toInt() }
    val ss = Array(m) { readLine()!!.split(" ").map { Math.pow(2.0, it.toDouble()-1.0).toInt() }.drop(1).sum() }
    val pp = readLine()!!.split(" ").map { it.toInt() }

    var cnt = 0L

    outer@for (i in 0 until Math.pow(2.0, n.toDouble()).toInt()) {
        for (j in ss.indices) {
            val bitCnt = Integer.bitCount(i and ss[j])
            if (bitCnt % 2 != pp[j]) continue@outer
        }
        cnt++
    }

    println(cnt)
}

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

using namespace std;

int main() {
  int n;
  cin >> n;
  int ma = -1;
  map<string, int> m;
  for (int i = 0; i < n; ++i) {
    string s;
    cin >> s;
    m[s]++;
    ma = max(ma, m[s]);
  }

  for (auto e: m) {
    if (e.second == ma) cout << e.first << endl;
  }
  return 0;
}



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

/*#pragma GCC optimize("Ofast")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,popcnt,abm,mmx,tune=native")   */


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

using namespace std;
//using namespace __gnu_pbds;

#define ss second
#define ff first
#define int long long
//#define double long double
#define pb push_back

const int N = 2e6 + 51, MOD = 1e9 + 7, mod = 998244353, INF = 2e18;

mt19937 Flash_new_51(51515);

using vi = vector <int>;
using vp = vector <pair <int, int>>;

int sum, color[N], used[N];
vi g[N], g1[N];

void dfs (int v, int cv) {
    used[v] = cv;
    sum++;
    for (auto to : g[v]) {
        if (!used[to]) dfs(to, cv);
    }
}

signed main() {
    #ifdef Flash
     freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n, k, m;
    cin >> n >> m >> k;
    for (int i = 0; i < m; i++) {
        int l, r;
        cin >> l >> r;
        g[l].pb(r);
        g[r].pb(l);
    }
    for (int i = 0; i < k; i++) {
        int l, r;
        cin >> l >> r;
        g1[l].pb(r);
        g1[r].pb(l);
    }
    int kol = 1;
    for (int i = 1; i <= n; i++) {
        if (!used[i]) {
            sum = 0;
            dfs(i, kol);
            color[kol] = sum;
            kol++;
        }
    }
    vector <bool> ok(n + 1, 0);
    for (int i = 1; i <= n; i++) {
        int minn = 0;
        for (auto to : g[i]) minn++, ok[to] = 1;
        for (auto to : g1[i]) {
            if (used[to] != used[i]) continue;
            if (!ok[to]) minn++;
        }
        for (auto to : g[i]) ok[to] = 0;
        cout << color[used[i]] - 1 - minn << ' ';
    }
}


Measured memory_bytes: 106752
n,q = map(int,raw_input().split())
task = []
lst = []
a = 0
for i in range(n):
    name,time = raw_input().split()
    task.append(int(time))
    lst.append(name)
while True:
	if task[0] > q:
		task[0] = task[0] - q
		task.append(task.pop(0))
		lst.append(lst.pop(0))
		a += q
	else:
		a += task[0]
		print lst[0],a
		task.pop(0)
		lst.pop(0)
		if len(lst) == 0:
			break

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

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

int main() {
  ll n, ans = 0;
  cin >> n;

  cout << (n >= 30 ? "Yes" : "No") << endl;
  return 0;
}


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

using namespace std;
inline void prep ()
{
  cin.tie (0);
  cin.sync_with_stdio (0);
};
const double pi = acos(-1.);
//printf("%.12lf\n",mid);
// __builtin_popcount(int) count 1's in binary
// get decimal pert of number
/*
double intpart;
double thiss = modf((double)(n*m)/(double)k, &intpart);
*/
// round = (int)(num+.5)
int mod = 998244353;

long long mymod(long long num){
  if (num< 0 && !(num%mod == 0)){
    if (mod == 1){
      return 0;
    }
    return mod-abs(num)%mod;
  }else{
    return num%mod;
  }
}

/*string sentence = "And I feel fine...";
    istringstream iss(sentence);
*/  

double eps = .000000001;

int main ()
{
  prep();
  int n;
  double res = 0;
  cin >> n;
  vector<double> sorted;
  for (int i=0; i<n; i++){
      double num;
      cin >> num;
      sorted.push_back(num);
  }
  sort(sorted.begin(), sorted.end());
  res = sorted[0];
  for (int i=1; i<n; i++){
      res += sorted[i];
      res /= 2;
  }
  cout << res;
  return 0; 
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <math.h>
using namespace std;
int main(void){
    int n,s[1000],i;
    double a,m;
    while(1){
        cin>>n;
        if(!n) 
           break;
        m=a=0;
        for(i=0;i<n;i++){
            cin>>s[i];
            m+=s[i];
        }
        m/=n;
        for(i=0;i<n;i++){
            a+=(s[i]-m)*(s[i]-m);
        }
        a=sqrt(a/n);
        cout<<fixed<<setprecision(6)<<a<<endl;
    }
}


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


int main() {
    int N;
    string S;
    cin >> N >> S;
    int A[N];
    int c=0 , m;
    for (int i=1;i<N;i++){
        if (S[i]=='E') c++;
    }
    A[0]=c;
    m=c;
    for (int i=0;i<N;i++){
        if (S[i]!=S[i+1]) A[i+1]=A[i];
        else if (S[i]=='E'&&S[i+1]=='E') A[i+1]=A[i]-1;
        else A[i+1]=A[i]+1;
        m=min(m,A[i+1]);
    }
    cout << m <<endl;
}


Measured memory_bytes: 1796
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
count = 0 
for i in range(n):
  count += min(a[i] + a[i + 1], b[i])
  if a[i] < b[i]:
    a[i + 1] = max(a[i + 1] - (b[i] - a[i]), 0)
print(count)

Measured memory_bytes: 18476
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a),i##formax=(b);i<i##formax;i++)
#define FORR(i,a,b) for(int i=(a),i##formax=(b);i>=i##formax;i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)
#define show(x) cout<<#x<<" = "<<x<<endl;
#define all(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))
#define bitComb(a,n,k) for(int a##x,a##y,a=(1<<k)-1;a<(1<<n);a##x=a&-a,a##y=a+a##x,a=(((a&~a##y)/a##x)>>1)|a##y)
#define uniq(v) sort(all(v));v.erase(unique(all(v)), v.end())
#define bit(n) (1LL<<(n))
#define randInt(l,r) (uniform_int_distribution<ll>(l,r)(rnd))
#define randDouble(l,r) (uniform_real_distribution<double>(l,r)(rnd))
#define dout(d) printf("%.12f\n",d)

typedef long long ll;
typedef __int128_t lll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<class T>using V=vector<T>;
template<class T>using VV=V<V<T>>;
template<class T,class Y>ostream& operator<<(ostream& o,const pair<T,Y>& p){return o<<"("<<p.fi<<", "<<p.se<<")";}
template<typename A,size_t N,typename T>void Fill(A (&array)[N],const T&v){fill((T*)array,(T*)(array+N),v);}
lll gcd(lll a,lll b,lll &x,lll &y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll gcd(ll a,ll b){lll x=0,y=0;return gcd(a,b,x,y);}
ll modInv(ll a,ll m){lll x,y;gcd(a,m,x,y);return (x%m+m)%m;}
ll modPow(lll a,lll n,ll m){if(!a)return a;lll p=1;for(;n>0;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return(ll)p;}
bool isPrime(ll n){if(n<2||n%2==0)return n==2;lll t=n-1,d=t/(t&-t);for(lll a:{2,325,9375,28178,450775,9780504,1795265022})if(a%n){for(t=d,a=modPow(a,t,n);t!=n-1&&a!=1&&a!=n-1;a=a*a%n,t=t*2%n);if(a!=n-1&&t%2==0)return 0;}return 1;}
const int IINF = 1e9+6;
const ll LINF = 1e18;
const int MOD = 1e9+7;
const double PI = acos(-1);
const double EPS = 1e-10;
static random_device rd;
static mt19937 rnd(rd());

const int N = 20;
int n;
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n;
  int ma = -IINF, ans=0;
  FOR(i, 0, n){
    int a;
    cin >> a;
    if(ma <= a) ans++;
    maxs(ma, a);
  }
  cout << ans << endl;
}

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

#include <assert.h>    // LON
#include <math.h>    // sqrt()


using namespace std;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) ll(x.size())
typedef long long ll;
//typedef pair<int, int> P;
typedef pair<ll, ll> P;
//const double INF = 1e10;
const ll INF = LONG_LONG_MAX;
const ll MINF = LONG_LONG_MIN;
//const int INF = INT_MAX;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }


//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);

typedef priority_queue<ll, vector<ll>, greater<ll>> PQ_ASK;
const int mod = 1000000007;

class Knapsack {
    vector<map<ll, ll>> knapsack;
    vector<ll> values;
    vector<ll> weights;
    set<ll> weight_candidates;
    ll n;
public:
    Knapsack(ll n, vector<ll> values, vector<ll> weights, set<ll> weight_candidates)
            : n(n), values(values), weights(weights), weight_candidates(weight_candidates) {
        knapsack.resize(n, map<ll, ll>());
    }

    ll get(ll i, ll j, ll def) {
        if (i == -1) return def;
        return knapsack[i][j];
    }

    ll getBefore(ll i, ll j) {
        return get(i - 1, j, 0);
    }

    ll getChange(ll i, ll j) {
        ll i_value = values[i];
        ll i_weight = weights[i];
        if (j < i_weight) return 0;
        return get(i - 1, j - i_weight, 0) + i_value;
    }

    ll calculate() {
        rep(i, n) for (ll j : weight_candidates) {
                ll before = getBefore(i, j);
                ll change = getChange(i, j);

                knapsack[i][j] = max(max(before, change), 0ll);
            }
        ll ans = 0;
        for (auto e : knapsack[n - 1]) {
            cmax(ans, e.second);
        }
        return ans;
    }

};

int main() {

    ll n, w;
    cin >> n >> w;

    vector<ll> weights(n);
    vector<ll> values(n);
    rep(i, n) {
        ll wi, vi;
        cin >> wi >> vi;
        weights[i] = wi;
        values[i] = vi;
    }

    set<ll> weight_candidates;
    for (ll s = weights[0], e = s + 3, i = 0; i <= 100; i++, s = s + weights.front(), e += weights.front() + 3) {
        for (ll k = s; k <= e; k++) {
            if (k > w) continue;
            weight_candidates.insert(k);
        }
    }


    Knapsack k(n, values, weights, weight_candidates);
    cout << k.calculate() << endl;


}



Measured memory_bytes: 94976
import java.util.*;

class Main{
    public static void main(String[] args){
	Scanner sc = new Scanner(System.in);

	int n = sc.nextInt();

	while(n!=0){

	    int[] num = new int[n];
	    for(int i=0; i<n; i++){
		num[i] = sc.nextInt();
	    }

	    int max = Integer.MIN_VALUE;
	    int min = 0;
	    int sum = 0;
	    int sum2 = 0;
	    for(int i=0; i<n; i++){
		sum += num[i];
		if(sum-min>max){max = sum-min;}
		if(sum<min){min = sum;}
	    }

	    System.out.println(max);

	    n = sc.nextInt();
	}
    }
}

Measured memory_bytes: 12000
N = int(input())

if N == 1 or N == 2 or N == 3 or N == 4 or N == 5 or N == 6 or N == 7 or N == 8 or N == 9 or N == 10 or N == 12 or N == 14 or N == 15 or N == 16 or N == 18 or N == 20 or N == 21 or N == 24 or N == 25 or N == 27 or N == 28 or N == 30 or N == 32 or N == 35 or N == 36 or N == 40 or N == 42 or N == 45 or N == 48 or N == 49 or N == 54 or N == 56 or N == 63 or N == 64 or N == 72 or N == 81:
  print("Yes")
else:
  print("No")


Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>

using namespace std;

int main(){
    string S;
    cin>>S;
    bool check=false;
    for(int i=0;i<S.length();i++){
        check=false;
        if(i%2==0){
            if(S[i]=='R'||S[i]=='U'||S[i]=='D'){
                check=true;
            }
        }else{
            if(S[i]=='L'||S[i]=='U'||S[i]=='D'){
                check=true;
            }
        }
        if(!check){
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes";
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int main(){
  int n,m,A[200001],B[200001],C[200001],count=0;
  long long ans=0;
  cin>>n>>m;
  priority_queue<int> Q;
  vector<pair<int,int>> D(m);
  rep(i,n) cin>>A[i],Q.push(A[i]);
  rep(i,m) cin>>B[i]>>C[i],D[i]=make_pair(C[i],B[i]);
  sort(D.begin(),D.end());
  reverse(D.begin(),D.end());
  rep(i,m){
    rep(j,D[i].second) Q.push(D[i].first),count++;
    if(count>100000) break;
  }
  rep(i,n) ans+=Q.top(),Q.pop();
  cout<<ans;
}

Measured memory_bytes: 4472
/*      Chill raho be kuch nhi rakha sadness me. 
               Author: Maskman_lucifer                   */
               
#include <bits/stdc++.h>   
#define IO ios_base::sync_with_stdio(false);cin.tie(NULL);
#define ll long long 
#define pll pair<ll,ll>
#define pb push_back
#define M 1000000007
#define lc '\n'
using namespace std;
ll dp[110][200005];;
ll weights[111+1];
ll values[111+1];
ll knapsack(ll index,ll size)
{
    ll take,dontTake;
    take = dontTake = 0;
    
    if (dp[index][size]!=-1)
    {
        return dp[index][size];
    }

    if(index==0)
    {
        if (weights[0]<=size)
        {
            dp[index][size] = values[0];
            return values[0];
        }
        else
        {
            dp[index][size] = 0;
            return 0;
        }
    }

    if (weights[index]<=size)
    {
        take = values[index] + knapsack(index-1, size-weights[index]);
    }
    dontTake = knapsack(index-1, size);
    
    dp[index][size] = max (take, dontTake);
    
    return dp[index][size];

}
int main()
{
    IO
    memset(dp,-1,sizeof(dp));
    ll n;
    cin>>n;
    ll knapsackSize;
    cin>>knapsackSize;
   
    for(ll i=0;i<n;i++)
    {
        cin>>weights[i]>>values[i];
    }
    cout<<knapsack(n-1,knapsackSize)<<lc;
    return 0;
}

Measured memory_bytes: 175536
import java.math.*

fun main(args: Array<String>) {
    val (N, D) = readLine()!!.split(" ").map(String::toInt)
    val list = (0 until N).map {
        readLine()!!.split(" ").map(String::toInt)
    }

    var count = 0

    for (i in 0 until N - 1) {
        for (j in i + 1 until N) {
            var sum = 0.0
            for (k in 0 until D) {
                sum += (list[i][k] - list[j][k]) * (list[i][k] - list[j][k])
            }
            val distance = Math.sqrt(sum)
            if(distance.isDecimal().not()) {
                count++
            }
        }
    }

    println(count)


}

fun Double.isDecimal(): Boolean = ((this - Math.floor(this)) != 0.0)


Measured memory_bytes: 37896
#include<iostream>
#include<string.h>
using namespace std;

int main(){
	char w[300], a[26]={ 0 };	
	cin>>w;
	int i, l, t;
	l=strlen(w);
	for(i=0;i<l;i++){
		t=w[i]-97;
		a[t]++;
	}
	
	for(i=0;i<26;i++){
		if(a[i]%2!=0){
			cout<<"No"<<endl;
			break;
		}
		else if(i==25) cout<<"Yes"<<endl;
	}
}



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

int main(){
    int A[100][100],B[100],c[100];
    
    int n,m;
    cin>>n>>m;
    for(int i=0; i<n; i++){
        for(int j=0; j<m; j++){
            cin>>A[i][j];
        }
    }
    for(int j=0; j<m; j++){
        cin>>B[j];
    }
    
    for(int i=0; i<n; i++){
        c[i]=0;
        for(int j=0; j<m; j++){
            c[i]+=A[i][j]*B[j];
        }
    }
    
    for(int i=0; i<n; i++){
        cout<<c[i]<<endl;
    }
    
    return 0;
    
}


Measured memory_bytes: 3148
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n,k;
    cin >> n >> k;
    int ans=1;
    for(int i=0;i<n;i++){
        if(ans*2<ans+k){
            ans=ans*2;
        }
        else {
            ans=ans+k;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxn=100100;
int Max(int x,int y){
	return x>y?x:y;
}
void chkmax(int &x,int y){
	x=x>y?x:y;
}
void chkmin(int &x,int y){
	x=x<y?x:y;
}
void chkmin(long long &x,long long y){
	x=x<y?x:y;
}
int n;
int beg[maxn],tto[maxn<<1],nex[maxn<<1],e;
void putin(int s,int t){
	tto[++e]=t;
	nex[e]=beg[s];
	beg[s]=e;
}
int len1[maxn],len2[maxn];
void updata(int u,int v){
	if(v>len1[u]){
		len2[u]=len1[u];
		len1[u]=v;
	}
	else if(v>len2[u])
		len2[u]=v;
}
void get_maxlen(int u,int fa){
	len1[u]=len2[u]=0;
	for(int i=beg[u];i;i=nex[i]){
		if(tto[i]==fa) continue;
		get_maxlen(tto[i],u);
		updata(u,len1[tto[i]]+1);
	}
}
void find_dis(int u,int fa,int l){
	updata(u,l);
	for(int i=beg[u];i;i=nex[i]){
		if(tto[i]==fa) continue;
		if(len1[tto[i]]+1==len1[u])
			find_dis(tto[i],u,len2[u]+1);
		else
			find_dis(tto[i],u,len1[u]+1);
	}
}
int dep[maxn];
void get_dep(int u){
	for(int i=beg[u];i;i=nex[i]){
		if(dep[tto[i]]) continue;
		dep[tto[i]]=dep[u]+1;
		get_dep(tto[i]);
	}
}
int mxd[maxn],d[maxn];
long long solve(int rt1,int rt2,int ans1){
	for(int i=1;i<=n;i++)
		dep[i]=0,mxd[i]=0;
	dep[rt1]=dep[rt2]=1;
	for(int i=1;i<=n;i++)
		if(dep[i]==1)
			get_dep(i);
	for(int i=1;i<=n;i++){
		if(dep[i]==1&&rt2==0)
			chkmax(mxd[dep[i]],d[i]);
		else
			chkmax(mxd[dep[i]],d[i]-1);
	}
	long long ans2=rt2==0?1:2;
	for(int i=1;i<=ans1/2;i++)
		ans2=ans2*mxd[i];
	return ans2;
}
int main(){
	int s,t;
	scanf("%d",&n);
	for(int i=1;i<n;i++){
		scanf("%d%d",&s,&t);
		d[s]++,d[t]++;
		putin(s,t);
		putin(t,s);
	}
	get_maxlen(1,-1);
	find_dis(1,-1,0);
	int ans1=0;
	for(int i=1;i<=n;i++)
		chkmax(ans1,len1[i]+len2[i]);
	long long ans2;
	if(ans1%2==1){
		int rt1=0,rt2=0;
		for(int i=1;i<=n;i++){
			if(len1[i]==(ans1+1)/2){
				if(!rt1) rt1=i;
				else rt2=i;
			}
		}
		ans2=solve(rt1,rt2,ans1);
	}
	else{
		int rt;
		for(int i=1;i<=n;i++)
			if(len1[i]==ans1/2)
				rt=i;
		ans2=solve(rt,0,ans1);
		for(int i=beg[rt];i;i=nex[i])
			chkmin(ans2,solve(rt,tto[i],ans1));
	}
	printf("%d %lld\n",ans1/2+1,ans2);
	return 0;
}


Measured memory_bytes: 384
//------------------------------>> tsukasa_diary's template <<------------------------------//
#include <bits/stdc++.h>
using namespace std;

#define for_(i,a,b) for(int i=(a);i<(b);++i)
#define allof(a) (a).begin(),(a).end()
using lint = long long;
template< typename T > using Vec = vector< T >;

template< typename T > bool inRange(T x, T lb, T ub) { return lb <= x && x < ub; }
template< typename T > bool inRange(T x, T y, T lb, T ub) { return in_range(x, lb, ub) && in_range(y, lb, ub); }
template< typename T > void modAdd(T& a, T b, T mod) { a = (a + b + mod) % mod; }
template< typename T > void modMul(T& a, T b, T mod) { a = (a * b) % mod; }
template< typename T > void minUpdate(T& a, T b) { a = min(a, b); }
template< typename T > void maxUpdate(T& a, T b) { a = max(a, b); }
inline int bitCount(int x) { return __builtin_popcount(x); }
inline int bitCount(lint x) { return __builtin_popcountll(x); }

const int dx[4] = {0,1,0,-1}, dy[4] = {-1,0,1,0};
const int Dx[8] = {0,1,1,1,0,-1,-1,-1}, Dy[8] = {-1,-1,0,1,1,1,0,-1};
const double PI = acos(-1);

//--------------8---------------->> coding space <<-----------------8-------------//



int main() {
	int P, Q, R;
	cin >> P >> Q >> R;
	cout << min(P + Q, min(Q + R, R + P)) << endl;
}
//--------------8---------------->> coding space <<-----------------8-------------//

Measured memory_bytes: 256
import java.util.*;

class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();

		while(true){
			final String[] data = sc.nextLine().split(" ");
			final int n = Integer.parseInt(data[0]);
			final int x = Integer.parseInt(data[1]);
			if(n == 0 && x == 0) break;
			int count = 0;
			for(int i = 1; i <= n - 2; i++){
				for(int j = i + 1; j <= n - 1; j++){
					for(int k = j + 1; k <= n; k++){
						if((i + j + k ) == x){
							count++;
						}
					}
				}
			}
			System.out.println(count);
		}
	}
}

Measured memory_bytes: 18980
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <string.h>
#include <string>
#include <vector>
#include <map>
#include <set>
using namespace std;
map<int,int> mp;
int a[51];
int main()
{
    int n,m;
    while(cin>>n>>m){
        for(int i=0;i<n;i++)
            cin>>a[i];
        sort(a,a+n);
        int s=0;
        for(int i=n-m;i<n;i++){
            s+=a[i];
        }
        cout<<s<<endl;
    }
    return 0;
}



Measured memory_bytes: 256
from sys import stdin
import sys
import math
from functools import reduce
import functools
import itertools
from collections import deque,Counter,defaultdict
from operator import mul
import copy
# ! /usr/bin/env python
# -*- coding: utf-8 -*-
import heapq
sys.setrecursionlimit(10**6)
# INF =  float("inf")
INF = 10**18
import bisect
import statistics
mod = 10**9+7
# mod = 998244353

H, W = list(map(int, input().split()))
S = []
for i in range(H):
    S.append(input())

def bfs(u):
    stack = deque([u])
    visited = set()
    seen = set()
    p = [[INF for j in range(W)] for i in range(H)]
    p[u[0]][u[1]] = 0
    for i in range(H):
        for j in range(W):
            if S[i][j] == "#":
                p[i][j] = -1

    while len(stack) > 0:
        v = stack.popleft()
        ###
        visited.add(v)
        ###

        a = (v[0] + 1, v[1])
        b = (v[0]    , v[1] + 1)
        c = (v[0] - 1, v[1])
        d = (v[0]    , v[1] - 1)

        e = [a, b, c, d]

        for ee in e:
            if ee[0] >= 0 and ee[0] <= H-1 and ee[1] >= 0 and ee[1] <= W-1:
                if S[ee[0]][ee[1]] == ".":
                    if ee not in visited:
                        p[ee[0]][ee[1]] = min(p[ee[0]][ee[1]], p[v[0]][v[1]] + 1)
                        if ee not in seen:
                            stack.append(ee)
                            seen.add(ee)

    ans = 0
    for i in range(H):
        ans = max(ans, max(p[i]))
    return ans

sol = 0
for i in range(H):
    for j in range(W):
        if S[i][j] == ".":
            sol = max(sol, bfs((i,j)))

print(sol)

Measured memory_bytes: 79772
from collections import deque
def bfs(s):
    color[s] = 'GRAY'
    d[s] = 0
    Q.append(0)
    while len(Q) != 0:
        u = Q.popleft()
        for v in range(n):
            if M[u][v] and color[v] == 'WHITE':
                color[v] = 'GRAY'
                d[v] = d[u] + 1
                Q.append(v)
        color[u] = 'BLACK'
        
n = int(input())
M = [[0] * n for _ in range(n)]
color = ['WHITE'] * n
d = [-1] * n
Q = deque()

for _ in range(n):
    a = list(map(int, input().split()))
    u = a[0]
    v = a[2:]
    for j in v:
        M[u - 1][j - 1] = 1
        
bfs(0)

for i in range(n):
    out = ''
    out += '{} {}'.format(i + 1, d[i])
    print(out)

Measured memory_bytes: 6084
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
ll mod=1e9+7;
#define PI 3.1415926535897932385
#define inf 100000000000000000ll
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
string char_to_str(char c){string tem(1,c);return tem;}
typedef pair<long long, long long> ii;
#define S second
#define F first
ll max(ll a,ll b){if(a>b){return a;}return b;}
ll min(ll a,ll b){if(a<b){return a;}return b;}
#define MAXN 200005
// string to integer stoi() Remember: it takes string not character
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();
 
// To compile--> g++ -std=c++0x -o output one.cpp
// To run--> ./output
double calcAngle(double long h, double long m)  
{  
  
    double long hour_angle = 0.5 * ((h * 60.0) + m);  
    double long minute_angle = (6.0) * m;  
    double long angle = abs(hour_angle - minute_angle);  
    angle = min(360.0 - angle, angle);
    return angle;  
}  

int main() {
    fastio;
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);

    double a,b,h,m;
    cin>>a>>b>>h>>m;

    double long diff = (calcAngle(h, m)*PI)/180.0;
    double long c1 = ((a*a)+(b*b))-(2*b*a*cos(diff));
    c1 = powl(c1, 0.5);

    cout<<setprecision(20)<<c1;

    return 0;
}


Measured memory_bytes: 4180
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <complex>
#include <algorithm>
#include <vector>
#include <string.h>
using namespace std;


int main()
{
    vector<int> num(100010,0);
    int n;
    cin >> n;
    for(int i=0;i<n;i++){
        int a;
        cin >> a;
        num[a]++;
    }
    int cnt=0;
    for(int i=1;i<100010;i++){
        if(num[i]>1)   cnt+=num[i]-1;
    }
    if(cnt%2==0)     cout << n-cnt << endl;
    else                cout << n-(cnt+1) << endl;
    return 0;
}


Measured memory_bytes: 640