akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<typename T> using gpp_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T, typename L> using gpp_map = tree<T, L, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T> using gpp_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;*/
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define bit_exist(x, n) ((x >> n) & 1)
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) { cout << #v << "=" << endl; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << endl; }
#define mdebug(m) { cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;} }
#define Return(ans) { cout << (ans) << endl; return 0; }
#define pb push_back
#define f first
#define s second
#define int long long
#define INF 1000000000000000000
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); i++) { cout << v[i]; if(i != v.size() - 1) cout << endl; }; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p){ cout << '(' << p.first << ',' << p.second << ')'; return os; }
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void Ans(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }
 
using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using bools = vector<bool>;
using pairs = vector<Pii>;
 
//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//char d[4] = {'D','R','U','L'};
 
const int mod = 1000000007;
//const int mod = 998244353;
//#define Add(x, y) x = (x + (y)) % mod
//#define Mult(x, y) x = (x * (y)) % mod


#include <bits/stdc++.h>
using namespace std;
signed main(){
    string w; cin>>w;
    vec A(26,0);
    REP(i,w.size()){
        A[w[i]-'a']++;
    }
    bool ans = true;
    REP(i,A.size()){
        if(A[i]%2!=0) ans = false;
    }
    if(ans) Out("Yes");
    else Out("No");
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int r,c,i,j,k,l,a,b;
    cin >> r >> c;
    long int vec[101][101]={{}};
    for(i=0;i<r;i++){
        for(j=0;j<c;j++){
            cin >> vec[i][j];
        }
    }
    for(k=0;k<r;k++){
        for(l=0;l<c;l++){
            vec[r][l]+=vec[k][l];
            vec[k][c]+=vec[k][l];
        }vec[r][c]+=vec[k][c];
    }
    for(a=0;a<=r;a++){
        for(b=0;b<=c;b++){
            cout << vec[a][b];
            if(b==c)continue;
            else cout << " ";
        }cout << endl;
    }
   
    return 0;
}


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

using namespace std;

#define sp << " " <<

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    string s,t;
    cin >> s >> t;
    int d=s.length(),p=t.length();
    int dp[d+1][p+1];
    for(int i=0;i<=d;i++)
    {
        for(int j=0;j<=p;j++)
        {
            if(i==0||j==0)
                dp[i][j]=0;
            else if(s[i-1]==t[j-1])
                dp[i][j]=dp[i-1][j-1]+1;
            else
                dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
        }
    }
    vector <char> h;
    while(d>0&&p>0)
    {
        if(dp[d][p]==dp[d-1][p])
            d--;
        else if(dp[d][p]==dp[d][p-1])
            p--;
        else if(dp[d][p]==dp[d-1][p-1]+1)
        {
            h.push_back(s[d-1]);
            d--,p--;
        }
    }
    for(int i=h.size();i>0;i--)
        cout << h[i-1];
    return 0;
}


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

#define ll long long
#define ull unsigned ll

#define vi vector <int>
#define ii pair <int, int>
#define vii vector <ii>
#define INFLL 9e18
#define INF 2e9
#define EPS 1e-9
#define pb push_back
#define emp emplace_back
#define PI acos(-1.0)
#define endl "\n"
#define mp make_pair
#define DEBUG 0


int main ()

{
    #define int ll
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //cout.tie(NULL);

    //freopen("input.txt", "r", stdin); 
    //freopen("output.txt", "w", stdout);
    
    int n;
    cin >> n;
    int activity[n][3];
    for (int i=0; i<n; i++){
        for (int j=0; j<3; j++){
            cin >> activity[i][j];
        }
    }

    for (int i=1; i<n; i++){
        activity[i][0] += max(activity[i-1][1], activity[i-1][2]);
        activity[i][1] += max(activity[i-1][0], activity[i-1][2]);
        activity[i][2] += max(activity[i-1][1], activity[i-1][0]);
    }

    int ans = 0;
    for (int i=0; i<3; i++){
        ans = max(ans, activity[n-1][i]);
    }

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

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

int main(){
    #ifdef LOCAL_DEFINE
        freopen("./a.in","r",stdin);
        freopen("./a.out", "w",stdout);
    #endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int m,d;
    int ans = 0;
    cin >> m >> d;
    for(int i=1;i<=m;i++){
        for(int j=1;j<=d;j++){
            int temp;
            int satu = j/10,dua=j%10;
            if(i == satu*dua && satu>=2 && dua>=2){
                ans++;
            }
        }
    }
    cout << ans << endl;

}


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

int main() {
  ll h,w;
  ll ans = 1e10+1;
  cin >> h >> w;
  rep(x,1,h){
    ll m,M;
    m = min(x*w,(h-x)*(w/2));
    M = max(x*w,(h-x)*((w+1)/2));
    ans = min(ans,M-m);
    m = min(x*w,((h-x)/2)*w);
    M = max(x*w,((h-x+1)/2)*w);
    ans = min(ans,M-m);
  }
  rep(y,1,w){
    ll m,M;
    m = min(y*h,(w-y)*(h/2));
    M = max(y*h,(w-y)*((h+1)/2));
    ans = min(ans,M-m);
    m = min(y*h,((w-y)/2)*h);
    M = max(y*h,((w-y+1)/2)*h);
    ans = min(ans,M-m);
  }
  cout << ans << endl;
}

Measured memory_bytes: 3636
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define repi(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define repdi(i,a,b) for(ll i=(a)-1;i>=(b);--i)
#define repd(i,a) repdi(i,a,0)
#define itr(it,a) for( auto it = (a).begin(); it != (a).end(); ++it )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

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

constexpr ll INF = 1ll<<60;

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 S, class T>
std::ostream& operator<< ( std::ostream& out, const std::pair<S,T>& a )
{ std::cout << '(' << a.first << ", " << a.second << ')'; return out; }

template<class T>
std::ostream &operator<< ( std::ostream& out, const std::vector<T>& a )
{ std::cout << '['; rep( i, a.size() ){ std::cout << a[i]; if( i != a.size()-1 ) std::cout << ", "; } std::cout << ']'; return out; }

struct UnionFind {
  std::vector<int> d;
  UnionFind(int n=0): d(n,-1) {}
  int find(int x) {
    if (d[x] < 0) return x;
    return d[x] = find(d[x]);
  }
  bool unite(int x, int y) {
    x = find(x); y = find(y);
    if (x == y) return false;
    if (d[x] > d[y]) std::swap(x,y);
    d[x] += d[y];
    d[y] = x;
    return true;
  }
  bool same(int x, int y) { return find(x) == find(y);}
  int size(int x) { return -d[find(x)];}
};

ll N, M;
std::map<ll, ll> mp;

int main()
{
  std::cin >> N >> M;

  UnionFind uf( N+10 );

  rep( i, M )
  {
    ll X, Y, Z;
    std::cin >> X >> Y >> Z;

    --X; --Y;

    uf.unite( X, Y );
  }

  rep( i, N ) 
    ++mp[uf.find(i)];

  std::cout << mp.size() << std::endl;

  return 0;
}

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

const int nm = 2e5, pm = 1e4;
int n, p, c[pm], ten[pm];
long long rv = 0;
string s;

int main() {
	cin >> n >> p >> s;
	if (10 % p) {

		ten[0] = 1;
		for (int i = 1; i < p - 1; i++) {
			ten[i] = ten[i - 1] * 10 % p;
		}

		c[0]++;
		for (int i = 0, v = 0; i < n; i++) {
			v = (v + (s[n - 1 - i] - '0') * ten[i % (p - 1)]) % p;
			c[v]++;
		}

		for (int i = 0; i < p; i++) {
			rv += (long long) c[i] * (c[i] - 1) / 2;
		}

	} else {
		for (int i = 0; i < n; i++) {
			if (!((s[i] - '0') % p)) {
				rv += i + 1;
			}
		}
	}
	cout << rv << endl;
}


Measured memory_bytes: 644
#include <stdio.h>

struct eye{
	int Left,Right;
};

int main(){
	eye A={0,0},B={0,0},C={0,0},D={0,0};
	/*A.Left=B.Left=C.Left=D.Left=0;
	A.Right=B.Right=C.Right=D.Right=0;*/
	float L,R;
	while(scanf("%f%f",&L,&R)!=EOF){
		if(L>=1.1) A.Left++;
		else if(L>=0.6) B.Left++;
		else if(L>=0.2) C.Left++;
		else D.Left++;
		if(R>=1.1) A.Right++;
		else if(R>=0.6) B.Right++;
		else if(R>=0.2) C.Right++;
		else D.Right++;
	}
	printf("%d %d\n",A.Left,A.Right);
	printf("%d %d\n",B.Left,B.Right);
	printf("%d %d\n",C.Left,C.Right);
	printf("%d %d\n",D.Left,D.Right);
	return 0;
}

Measured memory_bytes: 1052
import java.util.Scanner;
class Main{


	static char[][] map;

	static long[][] c;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);			//文字の入力
		int n = sc.nextInt();
		int[] a = new int[n];
		
		for(int i = 0;i < n;i++){
			a[i] = sc.nextInt();
 		}
		int[] sub = new int[n];
		int ans = 0;
		
		for(int i = n-1;i >= 0;i--){
			int sum = 0;
			for(int j = i;j < n;j+=i+1){
				sum += sub[j];
			}
			if(a[i] == 0){
				if(sum % 2 == 0){
					sub[i] = 0;
				}else{
					sub[i] = 1;
					ans++;
				}
			}else{
				if(sum % 2 == 0){
					sub[i] = 1;
					ans++;
				}else{
					sub[i] = 0;
				}
			}
			
		}
		
		System.out.println(ans);
		int count = 0;
		for(int i = 0;i < n;i++){
			if(sub[i] == 1){
				System.out.print(i+1 + " ");
			}
			
			
		}
		

		
		
	}
	


	static int gcd(int a,int b){				//最大公約数を返す
		if(b == 0){
			return a;
		}else{
			return gcd(b, a%b);
		}
	}
	static long gcd(long a,long b){
		if(b == 0){
			return a;
		}else{
			return gcd(b, a%b);
		}
	}



	static long lcm (long a, long b) {
		long g = gcd(a,b);
		return a/g*b;
	}




}



class Pair implements Comparable{
	int from;
	int end;
	@Override
	public int compareTo(Object other) {
		Pair otherpair = (Pair)other;

		return   end- otherpair.end;
	}








}






Measured memory_bytes: 83816
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
//#include <stdio.h>
//#include <stack>
//#include <queue>
//#include <cstdio>
#include <cmath>
#include <iterator>
#include <map>
#include <fstream>
//#include <list>
#include <iomanip>
//#include <stdlib.h>
//#include <cctype>

using namespace std;

const int MAX_N = 1000000;
#define IOS ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define prec std::cout << std::fixed << std::setprecision(15);
#define endl "\n"
#define MOD 1000000007
#define Int int64_t
#define PI 3.14159265358979
#define rep(i, n) for (int i = 0; i < int(n); i++)
#define ssort(z) sort(z.begin(), z.end())
#define rsort(z) sort(z.rbegin(), z.rend())
#define eerase(z) z.erase(unique(z.begin(), z.end()), z.end())
#define ccnt(z, w) count(z.begin(), z.end(), w)
template <typename T>
void printV(const std::vector<T>& v, const char * const separator = " ")
{
    if(!v.empty())
    {
        std::copy(v.begin(),
                  --v.end(),
                  std::ostream_iterator<T>(std::cout, separator));
        std::cout << v.back() << "\n";
    }
}


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

Int lcm(Int a, Int b) {
    return a / gcd(a, b) * b;
    //a*bは64bit integer overflow
}

int Max(int a, int b, int c) {
    int temp = max(a, b);
    return max(temp, c);
}

int Min(int a, int b, int c) {
    int temp = min(a, b);
    return min(temp, c);
}

bool integer(double num) {
    return floor(num) == num;
}

Int fact(int num) {
    if (num == 0)
        return 1;
    else
        return num * fact(num - 1);
}

void y() {
    cout << "Yes" << endl;
    exit(0);
}

void n() {
    cout << "No" << endl;
    exit(0);
}

void Y() {
    cout << "YES" << endl;
    exit(0);
}

void N() {
    cout << "NO" << endl;
    exit(0);
}

Int yakusu(int n) {
    int cnt = 0;
    for (int i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            cnt++;
            if (i * i != n) cnt++;
        }
    }
    return cnt;
}

/*   kokomade  */

int cnt = 0;
bool is_prime[ 50000 + 1 ];
vector<int> P;
void Eratosthenes( const int N )
{
    for( int i = 0; i <= N; i++ )
    {
        is_prime[ i ] = true;//初期化
    }
    for( int i = 2; i <= N; i++ )
    {
        if( is_prime[ i ] )
        {
            for( int j = 2 * i; j <= N; j += i )
            {
                is_prime[ j ] = false;
            }
            P.emplace_back( i );
        }
    }
}

int main() {
    IOS;
    //int n,x,t;cin>>n>>x>>t;
    int a,b,c;cin>>a>>b;
    // string str;cin>>str;
    //vector<int> l(n);
    // vector<string> s(n);
    int cnt;
    //if(b==1){
    //    cout<<0;
    //    return 0;
    //}

    for (int i = 0; i < 100; ++i) {
        cnt=i;
        //cout<<a*i-cnt+1<<endl;
        if(a*i-cnt+1>=b){
            cout<<cnt;
            break;
        }
    }


    cout<<endl;
    return 0;
}

/*
テレビも無ェ ラジオも無ェ
自動車もそれほど走って無ェ
ピアノも無ェ バーも無ェ
巡査 毎日ぐーるぐる
朝起ぎで 牛連れで
二時間ちょっとの散歩道
電話も無ェ 瓦斯も無ェ
バスは一日一度来る
俺らこんな村いやだ 俺らこんな村いやだ
東京へ出るだ 東京へ出だなら
銭コァ貯めで 東京でベコ(牛)飼うだ
*/


Measured memory_bytes: 256
n,m=map(int,input().split())
ab=[[int(x) for x in input().split()] for _ in range(n)]
cd=[[int(x) for x in input().split()] for _ in range(m)]

for a,b in ab:
  ans=list()
  for c,d in cd:
    ans.append(abs(a-c)+abs(b-d))
  print(ans.index(min(ans))+1)

Measured memory_bytes: 9180
/*input

*/
#include <bits/stdc++.h>
#define up(i,a,b) for(int (i) = (a);(i)<=(b);++(i))
#define down(i,b,a) for(int (i) = (b);i>=(a);--i)
#define debug(x) cerr << (x) << '\n';
#define bits(x,i) ((x >> i) & 1)
#define mid ((l+r)/2)
#define pr pair<int,int>
using namespace std;
const int N = 2000005;
int p[N];
int nxt[500005];
int ans[500005];
int ok[500005];
string s, t,tmp;
void KMP(){
	int n = tmp.size();
	int t_size = t.size();
	int len = max(tmp.size(), t.size()) * 2;
	while (s.size() < len) s += tmp;
	s = t + "#" + s;
	len = s.size();
	// cout << s << '\n';
	for(int i=1;i<len;++i){
		int j = p[i-1];
		while (j && s[i] != s[j]) j = p[j-1];
		if (s[i] == s[j]) j++;
		p[i] = j;
	}
	memset(nxt, -1, sizeof(nxt));
	for(int i= len - n;i<len;++i){
		if (p[i] == t_size) nxt[(i - t_size + 1) % n] = (i + 1) % n;	
	}
	// for(int i=0;i<n;++i) cout << nxt[i] << '\n';
	int res = 0, cnt = 0;
	bool cycle = 0;
	for(int i=0;i<n;++i){
		if (!ok[i] && nxt[i] != -1){
			int j = i;
			ok[j] = ++cnt;
			ans[cnt] = 0;
			while (nxt[j] != -1){
				j = nxt[j];
				ans[cnt]++;
				if (ok[j]) { 
					if (ok[j] == cnt || ans[ok[j]] == -1) {
						ans[cnt] = -1; 
						cycle = 1;
					}
					else ans[cnt] += ans[ok[j]];
					break; 
				}
				ok[j] = cnt;
			}
			res = max(res, ans[cnt]);
		}
	}
	// for(int i=0;i<n;++i) cout << ok[i] << ' ';
	cout << (!cycle ? res : -1);
}
int main(){
	ios_base::sync_with_stdio(0); cin.tie(0);
	cin >> tmp >> t;
	KMP();
}


Measured memory_bytes: 18916
A, B, K = map(int, input().split())

if A+K-1 >= B-K+1:
    for i in range(A, B+1):
        print(i)
else:
    for i in range(A, A+K):
        print(i)
    for i in range(B-K+1, B+1):
        print(i)

Measured memory_bytes: 3060
n,k=map(int,input().split())
x=[0]*n
for i in range(k):
    y=int(input())
    z=list(map(int,input().split()))
    for j in z:
        x[j-1] +=1
a=0
for b in x:
    if b==0:
        a+=1
print(a)

Measured memory_bytes: 9052
#include<stdio.h>

int main() {
  int n;
  scanf("%d", &n);
  
  switch(n % 10) {
    case 2:
    case 4:
    case 5:
    case 7:
    case 9:
      printf("hon\n");
      break;
    case 0:
    case 1:
    case 6:
    case 8:
      printf("pon\n");
      break;
    case 3:
      printf("bon\n");
      break;
    default:
      break;
  }
  
  return 0;
}

Measured memory_bytes: 1644
import java.util.*

fun main(args: Array<String>) {
    val N = readLine()!!.toInt()
    val A = readLine()!!.split(" ").map {it.toInt()}

    var l = 0
    var r = N

    while(r - l > 1) {
        val c = (l + r) / 2

        fun judge(c: Int): Boolean {
            val s = ArrayDeque<Triple<Int, Int, Int>>()
            s.addLast(Triple(0, A[0], 0))

            for (i in 1 until N) {
                val len = A[i]

                if (s.last.second < len) {
                    s.addLast(Triple(s.last.second, len, 0))
                } else {
                    while(s.isNotEmpty() && s.last.first >= len) {
                        s.pollLast()
                    }

                    while(s.isNotEmpty() && s.last.third >= c - 1) {
                        s.pollLast()
                    }

                    if (s.isEmpty()) {
                        return false
                    }

                    var t = s.removeLast()
                    if (t.second > len) {
                        t = Triple(t.first, len, t.third)
                    }
                    if (t.second - t.first > 1) {
                        s.addLast(Triple(t.first, t.second - 1, t.third))
                    }
                    s.addLast(Triple(t.second - 1, t.second, t.third + 1))

                    if (s.last.second < len) {
                        s.addLast(Triple(s.last.second, len, 0))
                    }
                }
            }

            return true
        }

        if (judge(c)) {
            r = c
        } else {
            l = c
        }
    }

    println(r)
}


Measured memory_bytes: 134356
import math

input = input().split()
a, b, x = int(input[0]), int(input[1]), int(input[2])

# ちょうど半分入っている時
if x == a*a*b/2:
    print(45.)

elif x == a*a*b:
    print(0.)
    
# 半分より多く入っている時 : theta<45
elif x > a*a*b/2:
    tan = 2*(a*b - x/a) / (a**2)
    print(math.degrees(math.atan(tan)))

# 半分より少なく入っている時 : theta>45
else:
    tan = a * b * b / (2*x)
    print(math.degrees(math.atan(tan)))

Measured memory_bytes: 38384
#include<iostream>
using namespace std;
int main(){
  int P, Q, R;
  cin >> P >> Q >> R;
  if(P>=Q && P>=R) cout << Q+R << endl;
  else if(Q>=P && Q>=R) cout << P+R << endl;
  else cout << P+Q << endl;
  return 0;
}

Measured memory_bytes: 888
#include <bits/stdc++.h>
#define rep(begin, end) for (i=begin;i<end;i++)
#define init(arr, val) for (i=0;i<end;i++) arr[i] = val;
#define printint(i0, i1) printf("%d %d\n", i0, i1)

using namespace std;
typedef long long int ll;
const int inf = pow(10,9);
const int nil = -1;
int i, n, m, k, ans;
int a[1000];

int main() {
    scanf(" %d %d", &n, &m);

    if (n <= m) printf("unsafe");
    else printf("safe");
}

Measured memory_bytes: 3828
#include <iostream>
using namespace std;
int main(void){
    int N,M,i,point = 0;
    double sum = 0;
    cin >> N >> M;
    int A[N];
    for(i=0;i<N;i++){
        cin >> A[i];
        sum = sum + A[i];
    }
    for(i = 0;i < N;i++){
        if(A[i] >= (sum/double((4*M)))){
            point += 1;
        }
    }
    if(point >= M){
        cout << "Yes";
    }
    else{
        cout << "No";
    }
    return 0;        
}


Measured memory_bytes: 256
import java.io.*;
import java.math.BigInteger;
import java.util.*;
import java.lang.*;
 
public class Main {
	
	public static void main(String[] args) throws InterruptedException {
		FastScanner fs=new FastScanner();
		String s=fs.next(), t=fs.next();
		int n=s.length(), m=t.length();
		
		int [][] dp = new int[n+1][m+1];
		for(int i=0 ; i<n+1 ; ++i) 
			for(int j=0 ; j<m+1 ; ++j)
				dp[i][j] = 0;
		
		for(int i=1 ; i<n+1 ; ++i) {
			for(int j=1 ; j<m+1 ; ++j) {
				dp[i][j] = Math.max(dp[i-1][j], dp[i][j-1]);
				if(s.charAt(i-1) == t.charAt(j-1)) {
					dp[i][j] = Math.max(dp[i][j], dp[i-1][j-1] + 1);
				}
			}
		}
		
		String ans="";
		int x=n, y=m;
		while(x > 0 && y > 0) {
			if(dp[x-1][y] == dp[x][y])--x;
			else if(dp[x][y-1] == dp[x][y])--y;
			else {
				ans += s.charAt(x-1);
				--x;--y;
			}
		}
		
		System.out.println(reverse(ans));
	}
	
	void sort(int[] a) {
		ArrayList<Integer> list=new ArrayList<>();
		for (int i:a) list.add(i);
		Collections.sort(list);
		for (int i=0; i<a.length; i++) a[i]=list.get(i);
	}
	
	public static String reverse(String str) {
	    StringBuilder sb=new StringBuilder(str);
	    sb.reverse();
	    return sb.toString();
	}
	
	
	static class FastScanner {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");
		
		public String next() {
			while (!st.hasMoreTokens())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
			
		}
		
		public int nextInt() {
			return Integer.parseInt(next());
		}
		
		public int[] readArray(int n) {
			int[] a=new int[n];
			for (int i=0; i<n; i++) a[i]=nextInt();
			return a;
		}
		
		public long nextLong() {
			return Long.parseLong(next());
		}
		
		public long[] readLongArray(int n) {
			long[] a=new long[n];
			for (int i=0; i<n; i++) a[i]=nextLong();
			return a;
		}
	}
 
}

Measured memory_bytes: 87484
import java.util.*;
import java.io.*;
import java.awt.geom.*;
import java.math.*;

public class Main implements Runnable {

	static final Scanner in = new Scanner(System.in);
	static final PrintWriter out = new PrintWriter(System.out,false);
	static boolean debug = false;

	static int[][][] undirectedGraph(int n, int[] v1, int[] v2, int[] cost) {
		int[] cnt = new int[n];
		for (int i : v1) cnt[i]++;
		for (int i : v2) cnt[i]++;

		int[][][] g = new int[n][][];
		for (int i=0; i<n; i++) g[i] = new int[cnt[i]][2];
		for (int i=0; i<v1.length; i++) {
			int s = v1[i];
			int t = v2[i];

			g[s][--cnt[s]][0] = t;
			g[s][cnt[s]][1] = cost[i];

			g[t][--cnt[t]][0] = s;
			g[t][cnt[t]][1] = cost[i];
		}

		return g;
	}

	static ArrayList<int[]> bridge(int[][][] g) {
		int n = g.length;
		int[] ord = new int[n];
		Arrays.fill(ord, -1);

		ArrayList<int[]> res = new ArrayList<>();

		for (int cur=0; cur<n; cur++) {
			if (ord[cur] == -1) {
				dfsBridge(g, cur, -1, 0, res, ord, new boolean[n], new ArrayDeque<Integer>(), new ArrayDeque<Integer>());
				res.remove(res.size()-1);
			}
		}

		return res;
	}

	static void dfsBridge(int[][][] g, int cur, int prev, int d, ArrayList<int[]> res, int[] ord, boolean[] visited, ArrayDeque<Integer> roots, ArrayDeque<Integer> stack) {
		ord[cur] = d++;
		visited[cur] = true;
		roots.addFirst(cur);
		stack.addFirst(cur);

		for (int[] to : g[cur]) {
			int next = to[0];
			if (next == prev) continue;
			if (ord[next] == -1) dfsBridge(g, next, cur, d+1, res, ord, visited, roots, stack);
			else if (visited[next]) while (ord[roots.peek()] > ord[next]) roots.pollFirst();
		}

		if (cur == roots.peek()) {
			res.add(new int[]{cur, prev});
			while (true) {
				int v = stack.pollFirst();
				visited[v] = false;
				if (cur == v) break;
			}
			roots.pollFirst();
		}
	}

	public void run() {
		int v = in.nextInt();
		int e = in.nextInt();
		int[] s = new int[e];
		int[] t = new int[e];
		int[] c = new int[e];
		for (int i=0; i<e; i++) {
			s[i] = in.nextInt();
			t[i] = in.nextInt();
			c[i] = 0;
		}
		int[][][] g = undirectedGraph(v, s, t, c);
		ArrayList<int[]> ans = bridge(g);

		for (int i=0; i<ans.size(); i++) {
			if (ans.get(i)[0] > ans.get(i)[1]) {
				int tmp = ans.get(i)[0];
				ans.get(i)[0] = ans.get(i)[1];
				ans.get(i)[1] = tmp;
			}
		}

		Collections.sort(ans, new Comparator<int[]>(){
			public int compare(int[] a, int[] b) {
				if (a[0] != b[0]) return a[0] - b[0];
				return a[1] - b[1];
			}
		});
		for (int i=0; i<ans.size(); i++) {
			out.println(ans.get(i)[0]+" "+ans.get(i)[1]);
		}

		out.flush();
		in.close();
		out.close();
	}

	public static void main(String[] args) {
		debug = args.length > 0;
		new Thread(null, new Main(), "", 16 * 1024 * 1024).start();
	}

	static void dump(Object... o) { if (debug) System.err.println(Arrays.deepToString(o)); }
}

Measured memory_bytes: 70372
#pragma region 
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<cstring>
#include<string>
typedef long long ll;
template <typename T>void read(T &x){x=0;char ch=getchar();ll f=1;while(!isdigit(ch)){if(ch=='-')f*=-1;ch=getchar();}while(isdigit(ch)){x=x*10+ch-48;ch=getchar();}x*=f;}
#define IO ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
using namespace std;
#pragma endregion
int main() {
    IO;
    int n, m;
    cin >> n >> m;
    if (n&1) {
        for (int i = 1; i <= m;++i)
            cout << i << " " << n - i << endl;
    }else {
        for (int i = 1; i <= m;++i) {
            if (i<=n/4)
                cout << i << " " << n - i + 1 << endl;
            else
                cout << i << " " << n - i << endl;
        }
    }
}

Measured memory_bytes: 3616
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(int argc, char* argv[]){
        char buf[64]={0};
        char* p=NULL;
        int odd_num = 0;
        int evn_num = 0;
        int ans1 = 0;
        int ans2 = 0;

        if(fgets(buf, sizeof(buf)-1, stdin)==NULL){
                return 1;
        }
        p = strtok(buf, " ");
        evn_num = atoi(p);
        if(evn_num<0 || evn_num>100){
                return 1;
        }
        p = strtok(NULL, " ");
        odd_num = atoi(p);
        if(odd_num<0 || odd_num>100){
                return 2;
        }
        ans1 = evn_num*(evn_num-1);
        ans1 = ans1/2;
        ans2 = odd_num*(odd_num-1);
        ans2 = ans2/2;
        printf("%d\n", ans1+ans2);
        return 0;
}

Measured memory_bytes: 128
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt, factorial
from collections import deque
from bisect import bisect, bisect_left, bisect_right
INF = 10 ** 10
MOD = 10 ** 9 + 7

def main():
    N, M = map(int, input().split())
    diff = abs(N - M)
    if diff > 1:
        print(0)
        return

    ans = 2 if diff == 0 else 1
    for i in range(1, N + 1):
        ans = (ans * i) % MOD
    for i in range(1, M + 1):
        ans = (ans * i) % MOD
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3316
//INCLUDE
//------------------------------------------
#include <bits/stdc++.h>
//DEFINE
//------------------------------------------
#define ll long long
#define ld long double
#define ALLv(a)  (a).begin(),(a).end()
#define ALL(a,n)  (a),(a)+n
#define vi vector<long long>
#define vd vector<long double>
#define vs vector<string>
//CONST
//------------------------------------------
#define INF 1010000000000000017LL
#define MOD 1000000007LL
#define EPS 1e-12
#define PI 3.14159265358979323846
//REPEAT
//------------------------------------------
#define   FOR(i,m,n) for(ll (i)=(m);   (i)<(n);  (i)++)
#define   REP(i,n)   for(ll (i)=0;     (i)<(n);  (i)++)
#define  REPS(i,x)   for(ll (i)=1;     (i)<=(x); (i)++)
#define  RREP(i,x)   for(ll (i)=(x)-1; (i)>=0;   (i)--)
#define RREPS(i,x)   for(ll (i)=(x);   (i)> 0;   (i)--)
#define  WREP(i,in,j,jn) REP(i,in)REP(j,jn)
//-----------------------------------------
#define dcml(n) fixed<<setprecision(n)
using namespace std;
int main(void){
    string S;cin>>S;
    ll N=S.size();
    vi a(N);
    REP(i,N){
        a[i]=(S[i]-'0');
    }
    ll ans=0;
    for(ll bit=0;bit<(1<<N);bit++){
        ll sm=0;ll n=0;
        REP(i,N){
            if(bit&(1<<i)){
                //cout<<"+";
                sm+=n;
                n=a[i];
            }
            else{
                n*=10;
                n+=a[i];
            }
            //cout<<a[i];
            if(i==N-1)sm+=n;
        }
        //cout<<"="<<sm<<"\n";
        ans+=sm;
    }
    cout<<ans/2<<"\n";
}


Measured memory_bytes: 256
n, T = gets.split.map(&:to_i)
s = gets
ans = 0

for i in 0..s.size()-1
  if "0" <= s[i] && s[i] <= "9"
    ans += n ** s[i].to_i;
  end
end
ans *= T
if 1e+9 < ans
  puts "TLE"
else
  puts ans
end

Measured memory_bytes: 6152
N, A, B = map(int, input().split())

t = float('inf')
if abs(A - B) % 2 == 0:
    t = min(abs(A - B) // 2, t)
    
t = min(B - 1, t)
t = min(N - A, t)
t = min((A - 1 + 1) + (B - A - 1) // 2, t)
t = min((N - B + 1) + (N - (A + (N - B + 1))) // 2, t)

print(t)

Measured memory_bytes: 3060
#import math
#=input()
#=int(input())
x,y=map(int,input().split())
#=list(map(int,input().split()))
#=[list(map(int,input().split())) for _ in range()]

if (2*x <= y <= 4*x) and (y % 2 == 0):
    print('Yes')
else:
    print('No')

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

using namespace std;

#define fi first
#define se second
#define pb push_back
#define sz(x) ((int) x.size())
#define all(x) (x).begin(), (x).end()
#define re return
#define mp make_pair
#define makeunique(x) sort(all(x)), x.resize(unique(all(x)) - x.begin())
#define endl '\n'

typedef pair<int, int> ii;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<ll> vll;
typedef vector<string> vs;

template <class T> T abs (T x) { re x > 0 ? x : -x; }
template <class T> T sqr (T x) { re x * x; }

const double pi = acos(-1.);
const ll inf = 1e18 + 7;
const int N = 3e5 + 17;

int n, m;
int a[N], x[N], y[N];
int t[2 * N];

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		a[i]--;
	}
	for (int i = 0; i < 2 * N; i++) t[i] = -1;
	for (int i = 0; i < n; i++) {
		int l = 0;
		int r = a[i];
		x[i] = -1;
		for (l += n, r += n; l <= r; l >>= 1, r >>= 1) {
			if (l & 1) x[i] = max(x[i], t[l++]);
			if (!(r & 1)) x[i] = max(x[i], t[r--]);
		}
		x[i]++;
		int pos = a[i] + n;
		t[pos] = i;
		while (pos > 1) {
			t[pos >> 1] = max(t[pos], t[pos ^ 1]);
			pos >>= 1;
		}
	}
	ll ans = 0;
	for (int i = 0; i < 2 * N; i++) t[i] = n;
	for (int i = n - 1; i >= 0; i--) {
		int l = 0;
		int r = a[i];
		y[i] = n;
		for (l += n, r += n; l <= r; l >>= 1, r >>= 1) {
			if (l & 1) y[i] = min(y[i], t[l++]);
			if (!(r & 1)) y[i] = min(y[i], t[r--]);
		}
		y[i]--;
		int pos = a[i] + n;
		t[pos] = i;
		while (pos > 1) {
			t[pos >> 1] = min(t[pos], t[pos ^ 1]);
			pos >>= 1;
		}
		ll cntl = i - x[i] + 1, cntr = y[i] - i + 1;
		ans += cntl * cntr * (a[i] + 1);
	}
	cout << ans;
}


Measured memory_bytes: 8328
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <iomanip>
#include <functional>
#include <cassert>
#include <bitset>

using namespace std;

typedef long long ll;

const int N = 1e5 + 7;
const int K = 11;
vector <int> g[N];
int mem[N][K];

void go(int u, int x, int c) {
  if (mem[u][x]) return;
  mem[u][x] = c;
  if (x > 0) {
    go(u, x - 1, c);
    for (auto v : g[u]) {
      go(v, x - 1, c);
    }
  }
}

int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);
#ifdef LOCAL
  freopen("input.txt", "r", stdin);
#endif
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < m; ++i) {
    int u, v;
    cin >> u >> v;
    --u, --v;
    g[u].push_back(v);
    g[v].push_back(u);
  }
  int q;
  cin >> q;
  vector <int> v(q), d(q), c(q);
  for (int i = 0; i < q; ++i) cin >> v[i] >> d[i] >> c[i];
  for (int i = q - 1; i >= 0; --i) {
    go(v[i] - 1, d[i], c[i]);
  }
  for (int i = 0; i < n; ++i) {
    cout << mem[i][0] << '\n';
  }
}


Measured memory_bytes: 12024
#include <bits/stdc++.h>
using namespace std;
#define N_PRIME 1000000007
#define ll int64_t


int main(void){
    int N;
    string s1,s2;
    cin >> N;
    cin >> s1;
    cin >> s2;
    
    int min_length = min(s1.size(),s2.size());
    int ret = s1.size()  + s2.size();
    
    for(int i = 1 ; i <= min_length ; i++ ){
        string last = s1.substr(s1.size()-i,i);
        string first = s2.substr(0,i);
        
        if( last == first ){
            ret = min(ret,(int)s1.size() + (int)s2.size() - i);
        }
    }
    
    cout << ret << endl;
    
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <stack>
#include <set>
#include <map>


using namespace std;

int main(int argc, const char * argv[]) {
    int a, b;
    cin >> a;
    cin >> b;
    if(a != 2 && b != 2) {
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }
}


Measured memory_bytes: 1016
#include <bits/stdc++.h>
using namespace std;
int main () {
    long long N, K;
    cin >> N >> K;
    long long ans = 0;
    long long mod = 1000000007;
    for (long long k = K; k <= N+1; k++) {
        long long a = (k-1)*k/2;
        long long b = (N+(N-k+1))*k/2;
        ans += (b-a+1);
        ans %= mod;
    }
    cout << ans << endl;
}

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

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

    x = s;
    reverse(x.begin(), x.end());

    if (!(x == s))
    {
        cout << "No" << endl;
        return 0;
    }

    string c1 = s.substr(0, (s.size() - 1) / 2);
    string cr = c1;
    reverse(c1.begin(), c1.end());

    if (!(c1 == cr))
    {
        cout << "No" << endl;
        return 0;
    }

    c1 = s.substr((s.size() + 3) / 2 - 1, s.size());
    cr = c1;
    reverse(c1.begin(), c1.end());

    if (!(c1 == cr))
    {
        cout << "No" << endl;
        return 0;
    }

    cout << "Yes" << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define all(a) a.begin(), a.end()
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,int> pli;
typedef pair<int,int> pii;
#define rep(i,a,b) for(ll i=a ; i<b ; i++)
#define qrep(que, ite) for(auto ite=begin(que) ; ite!=end(que) ; ite++)
const int max_n = 1e5;
const ll mod = 1e9+7;
const ll INF = 1LL<<60;
const int inf = 1e5;
//typedef long double ld;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
ll mo = 998244353;
struct UnionFind {
    vector<int> par;

    UnionFind(int n) : par(n, -1) { }
    void init(int n) { par.assign(n, -1); }

    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }

    bool issame(int x, int y) {
        return root(x) == root(y);
    }

    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }

    int size(int x) {
        return -par[root(x)];
    }
};
int d[10][10];
int n,k;
bool ok=true;
void dfs(int now, int m){
  if(now<n){
    rep(i,0,k){
        dfs(now+1, m^d[now][i]);
    }
  }else{
    if(m==0) ok=false;
  }
  return ;
}
int main(){
  ll n,m; cin>>n>>m;
  if(n==1 && m==1){
    cout << 1 << endl;
    return 0;
  }
  if(n>=2 && m>=2){
    cout << (n-2)*(m-2) << endl;
  }else{
    cout << max(0LL, (max(n,m)-2)) << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>

using namespace std;

vector<long> enumDiviser(long n) {
  vector<long> res(1,1);

  for (long i=2; i*i<=n; i++) {
    if (n%i==0) {
      res.push_back(i);
      if (i*i != n) res.push_back(n/i);
    }
  }

  res.push_back(n);
  return res;
}

int main() {
  long n,m;
  long ans = -1;
  cin >> n >> m;
  vector<long> divisers = enumDiviser(m);
  sort(divisers.rbegin(), divisers.rend());

  for (auto diviser : divisers) {
    if (n <= m/diviser) ans = diviser;
    if (ans > 0) break;
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
while True:
    s = input()
    if s == ".":
        break

    stack = list()
    judge = True

    for c in s:
        if c == '(' or c == '[':
            stack.append(c)

        if c == ')':
            if stack and stack[-1] == '(':
                stack.pop()
            else:
                judge = False
                break

        if c == ']':
            if stack and stack[-1] == '[':
                stack.pop()
            else:
                judge = False
                break

    if judge and not stack:
        print("yes")
    else:
        print("no")


Measured memory_bytes: 5576
import sys
import bisect
input = sys.stdin.readline
n = int(input())
a = sorted(list(set([int(x) for x in input().strip().split()])))

ai = max(a)
if ai % 2 == 0:
    mid = [ai // 2]
else:
    mid = [ai // 2, ai // 2 + 1]

mini = float('INF')
minia = 0
for aa in a:
    if aa <= mid[0]:
        t = mid[0]-aa
        minia = aa
    else:
        t = aa-mid[-1]
    if t < mini:
        mini = t
        minia = aa
print(ai, minia)

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

int main(){
    int n;cin>>n;
    vector<int> a(n+1);
    rep(i,n)cin>>a[i+1];
    int ans=0;
    vector<int> b(n+1,-1);
    for(int i=n;i>=1;i--){
        int x=(n/i)*i;
        int m=0;
        while(1){
            if(b[x]==-1){
                if(m%2!=a[x]){
                    b[x]=1;
                }
                else b[x]=0;
                break;
            }
            else if(b[x]==1){
                m++;
            }
            x-=i;
        }
        ans+=b[i];
        if((m+b[i])%2!=a[i]){
            cout<<"-1"<<endl;
            return 0;
        }
    }
    cout<<ans<<endl;
    rep(i,n){
        if(b[i+1]==1){
            cout<<i+1<<" ";
        }
    }
}

Measured memory_bytes: 4840
#include <bits/stdc++.h>
using namespace std;
#define pii pair<int,int>
#define pll pair<ll,ll>
#define plll pair<pll,ll>
#define ff first
#define ss second
#define sfi(a) scanf("%d",&a)
#define sfi2(a,b) scanf("%d %d",&a,&b)
#define sfi3(a,b,c) scanf("%d %d %d",&a,&b,&c)
#define sfll(a) scanf("%lld",&a)
#define all(a) a.begin(),a.end()
#define inf 1e7
#define m_p make_pair
#define min3(a,b,c) min(a,min(b,c))
#define pb push_back
#define mem(x,val) memset(x,val,sizeof(x))
#define read freopen("input.txt","r",stdin)
#define write freopen("output.txt","w",stdout)
#define FAST  ios_base::sync_with_stdio(0);cout.tie(0)
#define sqr(x) ((x)*(x))

using ll = long long int;
const ll sz = 2005;
const ll mod = 1000000007;

int main()
{
    //write;
    //read;
    int a,b,c,k;
    cin >> a >> b >> c >> k;

    if(k<=a) cout << min(k,a) << endl;
    else if(k<=(a+b)) cout << a << endl;
    else {
        if(k>(a+b)){
            int ans = a;
            k -= (a+b);
            ans -= k;
            cout << ans << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 3636
n, m = map(int, input().split())
a = [(int(i), 1) for i in input().split()]
for i in range(m):
    b, c = map(int, input().split())
    a += [(c, b)]

a.sort(reverse=True)

ans = 0
i = 0
j = 0
while True:
    ans += a[i][0] * min(a[i][1], n-j)
    j += a[i][1]
    i += 1
    if j >= n:
        print(ans)
        break


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

namespace ABC118A
{
    class Program
    {
        static void Main(string[] args)
        {
            int a, b;

            var word = Console.ReadLine().Split(' ');

            a = int.Parse(word[0]);
            b = int.Parse(word[1]);

            if (b % a == 0)
            {
                Console.WriteLine(a + b);
            }
            else
            {
                Console.WriteLine(b - a);
            }

            Console.ReadKey();
        }
    }
}

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

const int N = 1e6 + 5;

int main(){
    ios::sync_with_stdio(0) ; cin.tie(0) ; cout.tie(0);
    int n;
    cin >> n;
    double p[n] , dd[n + 1][n + 1];
    memset(dd , 0 , sizeof(dd));



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

    dd[1][0] = 1 - p[0];
    for(int i = 2; i <= n ; i ++) {
        dd[i][0] = dd[i-1][0] *(1 - p[i-1]);
    }

    dd[1][1] = p[0];

    for(int i = 2 ; i <= n ; i ++) {
        for(int j = 1; j <= n ; j ++) {
            dd[i][j] = dd[i-1][j]*(1 - p[i-1]) + (dd[i-1][j-1])*p[i-1];
        }
    }



    double ans = 0;
    int i = n / 2 + 1;
    for(i ; i <= n ; i ++)
        ans += dd[n][i];
    cout << fixed << setprecision(9) << ans;

}

Measured memory_bytes: 70656
N,H = map(int,input().split())
A = []
B = []
for _ in range(N):
    a,b = map(int,input().split())
    A.append(a)
    B.append(b)
A.sort()
B.sort()
from bisect import bisect_right
val = A[-1]
idx = bisect_right(B,val)
B= B[idx:]
cnt = 0
while B and H:
    H-=B.pop()
    cnt += 1
    if H<=0: print(cnt);exit()
cnt += H//val
cnt += 1 if H%val else 0
print(cnt)

Measured memory_bytes: 87976
import java.util.*;

public class Main {
	
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int l = sc.nextInt();
		String[] arr = new String[n];
		for (int i = 0; i < n; i++) {
			arr[i] = sc.next();
		}
		Arrays.sort(arr);
		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < n; i++) {
			sb.append(arr[i]);
		}
		System.out.println(sb);
	}
}


Measured memory_bytes: 23892
#include <stdio.h>
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long int lli;
#define urept(soeji, start, n) for (int soeji = start; soeji < n; soeji++)
#define drept(soeji, start, n) for (int soeji = start; soeji > n; soeji--)
int main(void)
{
    int A,P;
    cin >> A >> P;
    cout << (int)(A*3+P)/2 << endl;
    return 0;
}

Measured memory_bytes: 256
from itertools import combinations

def sqdist(X, Y):
    temp = 0
    for x, y in zip(X, Y):
        temp += (x - y)**2
    return temp

N, D = map(int, input().split())
points = [tuple(map(int, input().split())) for _ in range(N)]
ans = 0
for x, y in combinations(points, 2):
    d2 = sqdist(x, y)
    if d2 == int(d2**0.5)**2: ans += 1
print(ans)

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

using namespace std;

// Repetitions
#define FOR(i,a,n) for(ll i = ((ll) a); i < ((ll) n); ++i)
#define FORR(i, s, g) for(ll i = ((ll)s - 1); i >= ((ll) g); --i)
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) FORR(i, n, 0)

// Container Utils
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define SORTALL(v) sort(ALL(v))
#define SZ(a) int((a).size())
#define CLR(a) memset((a), 0 ,sizeof(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())

// For Debug
#define DMP(x)  cerr << #x << " = " << (x) << endl
#define DBG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl

// Aliases
#define PB push_back
#define MP make_pair
typedef long long ll;
typedef string str;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;

// I/O Asynchronizing
struct aaa{
    aaa(){
        cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);
    };
}aaaaaaa;

inline ll combi2(const ll n) {
    return n * (n - 1) / 2;
}



int main() {
    int n;
    cin >> n;
    vi b(n - 1);
    REP(i, n - 1) {
        cin >> b[i];
    }
    ll ans = b[n - 2];
    int lb = b[n - 2];
    REPR(i, n - 2) {
        if(lb < b[i]) {
            ans += lb;
        }
        else {
            ans += b[i];
        }
        lb = b[i];
    }
    ans += lb;

    cout << ans << "\n";

    return 0;
}


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

class MainClass
{
    static void Main()
    {
        int N = int.Parse(ReadLine());
        if (N <= 999)
        {
            WriteLine("ABC");
        }
        else
        {
            WriteLine("ABD");
        }
    }
}


Measured memory_bytes: 27324
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <cstring>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <string.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>

using namespace std;


#define ld long double
#define F first
#define S second
//
#define int long long
#define ll long long
#define db(x)                cerr<<#x<<": "<<x<<endl
#define db2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define db3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define db4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define db5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define db6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
//
#define mem(x,y) memset(x,y,sizeof(x))
#define bitcount    __builtin_popcount
//
#define pii pair<int, int>
#define all(v) v.begin(),v.end()
//
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL)
#define vi vector<int>
#define vvi vector< vector<int> >
#define si set<int>
#define pb push_back
#define lp(i,a,b) for(int i=a;i<b;i++)
#define rloop(i,a,b) for(int i=a;i>=b;i--)
#define mk make_pair
const int N=50;
const int mod=1e9+7;
const int mod1=998244353;
const int inf=1e16+7;
using namespace std;
int gcd(int a,int b){if(a==0) return b;else return gcd(b%a,a);}
void solve(){
    int gc[201][201];
    for(int i=1;i<=200;i++)
        for(int j=1;j<=200;j++)
            gc[i][j]=gcd(i,j);
    int n;
    cin>>n;
    int ans=0;
    lp(i,1,n+1) lp(j,1,n+1) lp(k,1,n+1){
        ans+=gc[gc[i][j]][k];
    }
    cout<<ans;
}


int32_t main() {
    IOS;
    int t;
//    cin>>t;
    t=1;
    for(int i=1;i<=t;i++){
        solve();
       // cout<<endl;
    }
   
}

















Measured memory_bytes: 3968
mod = 1000000007
from sys import setrecursionlimit

setrecursionlimit(100000)


def valid(i, j, n, m):
	if 0 <= i < n and 0 <= j < m and good[i][j]:
		return True
	return False


def solve(i, j):
	if dp[i][j] != -1:
		return dp[i][j]
	if i == n - 1 and j == m - 1:
		return 1
	sm = 0
	if valid(i + 1, j, n, m):
		sm += solve(i + 1, j)
	if valid(i, j + 1, n, m):
		sm += solve(i, j + 1)
	dp[i][j] = sm % mod
	return dp[i][j]


n, m = map(int, input().split())
good = [[] for i in range(n)]
for i in range(n):
	s = input()
	for j in range(m):
		if s[j] == '.':
			good[i].append(True)
		else:
			good[i].append(False)

dp = [[-1 for i in range(m)] for j in range(n)]
print(solve(0, 0))


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

int main(){
    int k,f=0;
    vector<int> a(5);
    cin>>a[0]>>a[1]>>a[2]>>a[3]>>a[4]>>k;
    for(int i=0;i<5;i++){
        for(int j=0;j<i;j++){
            if(a[i]-a[j]>k){
                f=1;
            }
        }
    }
    if(f==1){
        cout<<":("<<endl;    
        }
        else{
            cout<<"Yay!"<<endl;
        }
    return 0;
}

Measured memory_bytes: 256