akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>
#include <numeric>


#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

typedef long long int ll;


ll gcd(ll x, ll y)
{
    if (y == 0) {
        return x;
    } else {
        return gcd(y, x % y);
    }
}

int main(){


    ll n,X;
    cin >> n >> X;
    vector<ll> x(n);
    REP(i,n){
        cin >> x[i];
        x[i] = abs(x[i]-X);
        //cout << x[i] << endl;
    }

    ll maxi = x[0];


    REP(i,n){

        maxi = gcd(maxi,x[i]);
        
    }
    cout << maxi << endl;






    return 0;
}

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

const int MAXN = 100005;

int n, a[MAXN];

int main()
{
	ios::sync_with_stdio(false);
	cin >> n;
	for (int i = 1; i <= n; i++) cin >> a[i];
	auto solve = [](int tot) {
		int cnt = 0;
		for (int i = 1; i <= n; i++) {
			if (a[i] != tot && a[i] != tot-1) return false;
			if (a[i] == tot-1) cnt++;
		}
		if (tot < cnt) return false;
		int col = tot-cnt, cat = n-cnt;
		if (cat && col == 0) return false;
		return cat >= 2*col;
	};
	if (solve(a[1]) || solve(a[1]+1)) puts("Yes");
	else puts("No");
	return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int n;
int main()
{

	//string s;
	cin>>n;
	//cin>>s;
	//vector <string> v;
	map<string ,int> m;
		for (int i = 0; i < n; ++i)
		{
			string x;
			cin>>x;
			m[x]++;
		}
		string s="AC";
		cout<<"AC x "<<m[s]<<endl;
		s="WA";
		cout<<"WA x "<<m[s]<<endl;
		s="TLE";
		cout<<"TLE x "<<m[s]<<endl;
		s="RE";
		cout<<"RE x "<<m[s]<<endl;



	return 0;
}

Measured memory_bytes: 3576
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<set>
#include<map>
#include<string>
#include<functional>
#include<queue>
#include<stack>
#include<math.h>
#define INF ((1<<30)-1+(1<<30))
#define EPS 1.0e-6

using namespace std;

typedef long long ll;

ll a,b;

int main()
{
	int ans;
	cin >> a >> b;
	if (a <= 0 && b >= 0)ans = 0;
	if (a > 0)ans = 1;
	if (b < 0) {
		if ((b - a + 1) % 2 == 0)ans = 1;
		else ans = -1;
	}

	if (ans == 0)cout << "Zero" << endl;
	if (ans == 1)cout << "Positive" << endl;
	if (ans == -1)cout << "Negative" << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include "atcoder/all"
typedef long long int ll;
using namespace std;
// using namespace atcoder;
#define mod 1000000007
ll pow(ll a, ll n) {
    if (n == 0) {
        return 1;
    }
    else if (n % 2) return a * pow(a, n - 1) % mod;
    else {
        ll x = pow(a, n / 2);
        return x * x % mod;
    }
}
int main() {
    ll n;
    cin >> n;
    ll ret = (pow((ll)10, n) + pow((ll)8, n) - (ll)2 * pow((ll)9, n)) % mod;
    while(ret < 0) {
        ret += mod;
    }
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 3632
#include <stdio.h>
#include <math.h>
int main()
{
  int N,T;
  int c[100],t[100];
  int minCost = 1001;
  int i;

  scanf("%d %d",&N,&T);
  for(i=0;i<N;i++){
    scanf("%d %d",&c[i],&t[i]);
    if(t[i]<=T){
      if(minCost>c[i]){
        minCost = c[i];
      }
    }
  }
  if(minCost==1001){
    printf("TLE");
  }else{
    printf("%d",minCost);
  }
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
#include <iomanip>
#include <cassert>
using namespace std;
long long MOD = 1e9 + 7;

vector<vector<int>> black,white;
int N, K;

int ret(vector<vector<int>>& vec,int rx, int ry, int lx, int ly) {
	if (rx == -1 || ry == -1)return 0;
	int temp = vec[rx][ry];
	if (ly >= 1)temp -= vec[rx][ly-1];
	if (lx >= 1)temp -= vec[lx - 1][ry];
	if (lx >= 1 && ly >= 1)temp += vec[lx - 1][ly - 1];
	return temp;
}

int main() {
	cin >> N >> K;
	black.resize(2 * K, vector<int>(2 * K, 0));
	white.resize(2 * K, vector<int>(2 * K, 0));
	for (int n = 0; n < N; n++) {
		int x, y;
		string c;
		cin >> x >> y >> c;
		if (c == string("B")) black[(x % (2 * K) + 2 * K) % (2 * K)][(y % (2 * K) + 2 * K) % (2 * K)]++;
		else white[(x % (2 * K) + 2 * K) % (2 * K)][(y % (2 * K) + 2 * K) % (2 * K)]++;
	}
	for (int x = 0; x < 2 * K; x++) {
		for (int y = 0; y < 2 * K; y++) {
			if (x - 1 >= 0 && y - 1 >= 0) {
				black[x][y] -= black[x - 1][y - 1];
				white[x][y] -= white[x - 1][y - 1];
			}
			if (x - 1 >= 0) {
				black[x][y] += black[x - 1][y];
				white[x][y] += white[x - 1][y];
			}
			if (y - 1 >= 0) {
				black[x][y] += black[x][y - 1];
				white[x][y] += white[x][y - 1];
			}
		}
	}
	int ans = 0;
	for (int lx = 0; lx < K; lx++) {
		for (int ly = 0; ly < K; ly++) {
			//[lx,rx)*[ly,ry)が黒のパターン
			int rx = lx + K-1;
			int ry = ly + K-1;
			int bl = ret(black, rx, ry, lx, ly)
				+ ret(black, lx - 1, ly - 1, 0, 0)
				+ ret(black, lx - 1, 2 * K - 1, 0, ry + 1)
				+ ret(black, 2 * K - 1, 2 * K - 1, rx + 1, ry + 1)
				+ ret(black, 2 * K - 1, ly - 1, rx + 1, 0);
			int wh =
				ret(white, rx,ly-1,lx,0)
				+ ret(white, 2*K-1,ry,rx+1,ly)
				+ ret(white, rx,2*K-1,lx,ry+1)
				+ ret(white, lx-1,ry,0,ly);
			ans = max(ans, bl + wh);
		}
	}
	for (int lx = 0; lx < K; lx++) {
		for (int ly = 0; ly < K; ly++) {
			//[lx,rx)*[ly,ry)が白のパターン
			int rx = lx + K-1;
			int ry = ly + K-1;
			int bl = ret(white, rx, ry, lx, ly)
				+ ret(white, lx - 1, ly - 1, 0, 0)
				+ ret(white, lx - 1, 2 * K - 1, 0, ry + 1)
				+ ret(white, 2 * K - 1, 2 * K - 1, rx + 1, ry + 1)
				+ ret(white, 2 * K - 1, ly - 1, rx + 1, 0);
			int wh =
				ret(black, rx, ly - 1, lx, 0)
				+ ret(black, 2 * K - 1, ry, rx + 1, ly)
				+ ret(black, rx, 2 * K - 1, lx, ry + 1)
				+ ret(black, lx - 1, ry, 0, ly);
			ans = max(ans, bl + wh);
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 31616
#include<bits/stdc++.h>
#define mp make_pair
#define pb push_back
using namespace std;
typedef long long LL;


int main() {
	int n;
	cin >> n;
	int ans = 0;
	for(int i = 1 ; i <= n ; i += 2) {
		int ile = 0;
		for(int j = 1 ; j <= i ; ++j) {
			if(i % j == 0)
				ile++;
		}
		if(ile == 8)
			ans++;
	}
	cout << ans << "\n";
}

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

#define REP(i, n) for(int64_t i = 0; i < n; i++)
#define REPR(i, n) for(int64_t i = n; i >= 0; i--)
#define FOR(i, m, n) for(int64_t i = m; i < n; i++)
#define FORR(i, m, n) for(int64_t i = m; i >= n; i--)
#define ALL(v) v.begin(), v.end()
typedef long long ll;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    fill( (T*)array, (T*)(array+N), val );
}
template<class T>
inline bool chmax(T &a, T b) {if(a < b) {a = b;return true;}return false;}
template<class T>
inline bool chmin(T &a, T b) {if(a > b) {a = b;return true;}return false;}
const ll INF= 1ll << 60;
const ll MOD = 1000000007;
double EPS = 1e-10;
//----------------------------------------------------------


long n, m;
long a[1005];
long sum[1005];//累積和
long psum[2000000];//部分和
long bitflag = 1;


int main(){
	scanf("%ld%ld", &n, &m);
	for(int i = 1; i <= n; i++){
		scanf("%ld", &a[i]);
		sum[i] = sum[i-1] + a[i];
	}
	long pcnt = 0;
	for(int i = 0; i <= n; i++){
		for(int j = i+1; j <= n; j++){
			psum[pcnt] = sum[j] - sum[i];
			pcnt++;
		}
	}
	long upmost = 0;
	for(long bitflag = 1; bitflag < 35184372088832; (bitflag <<= 1)){
		int cnt = 0;
		for(int i = 0; i < pcnt; i++){
			if(bitflag & psum[i]){
				cnt++;
			}
		}
		if(cnt >= m){
			upmost = bitflag;
		}
	}
	if(upmost == 0){
		printf("0\n");
		return 0;
	}
	std::set<int> st;
	for(int i = 0; i < pcnt; i++){
		st.insert(i);
	}
	while(upmost > 0){
		int cnt = 0;
		for(auto i = st.begin(); i != st.end(); i++){
			if(psum[*i] & upmost){
				cnt++;
			}
		}
		std::set<int> st2;
		if(cnt >= m){
			for(auto i = st.begin(); i != st.end(); i++){
				if(psum[*i] & upmost){
					st2.insert(*i);
				}
			}
			st = st2;
			st2.clear();
		}
		upmost >>= 1;
	}
	long ans = psum[*st.begin()];
	for(auto i = st.begin(); i != st.end(); i++){
		ans = (ans & psum[*i]);
	}
	printf("%ld\n", ans);
}

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

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            var S = cin.Read;
			WriteLine("2018"+S.Substring(4));
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); }}
        public int ReadInt { get { return int.Parse(Read); }}
        public long ReadLong { get { return long.Parse(Read); }}
        public double ReadDouble { get { return double.Parse(Read); }}
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret;}
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret;}
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret;}
    }
}

Measured memory_bytes: 11220
#include <bits/stdc++.h>
using namespace std;
#define int long long int
int dist(int x,int y){
    return x*x+y*y;
}
signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t,ans=0,d;cin>>t>>d;
    while(t--){
        int x,y;cin>>x>>y;
        if(dist(x,y)<=d*d)ans++;
    }
    cout<<ans;
	return 0;
}

Measured memory_bytes: 3636
/*input
4 2 9
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef tree<long long, null_type, less<long long>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
#pragma GCC optimize("unroll-loops,no-stack-protector")
//order_of_key #of elements less than x
// find_by_order kth element
typedef long long int ll;
#define ld long double
#define pii pair<int,int>
#define f first
#define s second
#define pb emplace_back
#define REP(i,n) for(ll i=0;i<n;i++)
#define sz(_a) (ll)(_a.size())
#define FILL(n) memset(n,0,sizeof(n))
#define ALL(_a) _a.begin(),_a.end()
const ll maxn=100005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const ld PI=acos(-1);
const ld eps=1e-9;
ll mypow(ll a,ll b){
    ll res=1LL;
    while(b){
        if(b&1) res=res*a%MOD;
        a=a*a%MOD;
        b>>=1;
    }
    return res;
}
int arr[maxn];
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n,a,b;
    cin>>n>>a>>b;
    cout<<min(n*a,b);
}

Measured memory_bytes: 892
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long int N;
  cin >> N;
  long long int p = sqrt(N);
  for (long long int i = 0; i < p; i++) {
    long long int q = p - i;
    long long int r = N / q;
    if (N == r * q) {
      printf("%lld\n", r + q - 2);
      break;
    }
  }
}


Measured memory_bytes: 256
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>
#include <iomanip>

using namespace std;

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

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

template<class T>
void print_container(T &container, string delim=" ") {
    bool first = true;
    for(auto &t: container){
        if(!first){
            cout << delim;
        }
        first = false;
        cout << t;
    }
    cout << endl;
}

int main() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    vector<int> ss(n);
    map<char, int> conv = {
        {'R', 0},
        {'G', 1},
        {'B', 2}
    };
    REP(i, n)
        ss[i] = conv[s[i]];

    vector<vector<int>> accum(3, vector<int>(n+1, 0));

    FOR(i, 1, n+1){
        REP(j, 3){
            accum[j][i] = accum[j][i-1] + (ss[i-1]==j?1:0);
        }
    }   
    ll ans = 0;
    REP(i, n){
        FOR(j, i+1, n-1){
            if(ss[i] == ss[j]) continue;
            int target = 3 - ss[i] - ss[j];
            int ng = 2*j-i;

            int lb = j + 1;
            int ub = n;
            int cnt = accum[target][ub] - accum[target][lb];
            if(ng<n&&ss[ng]==target) cnt--;

            
            ans += cnt;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3216
#include<cstdio>
int main()
{
	  int a,b,t;
	  scanf("%d",&a);
	  scanf("%d",&b);
	  if(a>b)
	  {
	  	t=a;
	  	a=b;
	  	b=t;
	  }
	  if(a==1&&b==2)
	  printf("3\n");
	  if(a==2&&b==3)
	  printf("1\n");
	  if(a==1&&b==3)
	  printf("2\n");
	  
}

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

int course[15][15];
int pattern[16][16];

int main() {

  int X,Y,t,in;
  while(cin>>X>>Y, X|Y) {
    memset(course, 0, sizeof(course));
    memset(pattern, 0, sizeof(pattern));
    for(int i=0; i<Y; ++i) {
      for(int j=0; j<X; ++j) {
	cin>>in;
	course[i][j] = in;
      }
    }

    for(int i=Y-1; i>=0; --i) {
      for(int j=X-1; j>=0; --j) {
	if(i==Y-1) {
	  if(course[i][j] == 0 || course[i][j] == 2)
	    pattern[i][j] = 1;
	} else if(i == Y-2 && course[i][j] == 2){
	  pattern[i][j] = 1;
	} else {
	  if(course[i][j] == 0) {
	    pattern[i][j] = pattern[i+1][j];
	    if(j > 0 && course[i+1][j-1] == 0)
	      pattern[i][j] += pattern[i+1][j-1];
	    if(j < X-1 && course[i+1][j+1] == 0)
	      pattern[i][j] += pattern[i+1][j+1];
	  }
	  if(course[i][j] == 2 && course[i+2][j] != 1) {
	    pattern[i][j] = pattern[i+2][j];
	  }
	}
      }
    }

    /*
    cout<<endl;
    for(int i=0; i<Y; ++i) {
      for(int j=0; j<X; ++j) {
	cout<<pattern[i][j]<<" ";
      }
      cout<<endl;
    }
    cout<<endl;
    */
    int sum = 0;
    for(int i=0; i<X; ++i) {
      //cout<<pattern[0][i]<<" ";
      sum += pattern[0][i];
    }
    //cout<<endl;
    cout<<sum<<endl;
  }
}

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

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

        if(b.equals("A")){
            System.out.println("T");
        }
        else if(b.equals("C")){
            System.out.println("G");
        }
        else if (b.equals("G")) {
            System.out.println("C");
        }
        else if (b.equals("T")) {
            System.out.println("A");
        }
    }
}

Measured memory_bytes: 21716
n, k = map(int, input().split())
r, s, p = map(int, input().split())
t = input()
dp = [3] * k
point = 0
choice = (r, s, p)
t = t.replace('r', '2').replace('s', '0').replace('p', '1')
for j, i in enumerate(t):
    if dp[j % k] != int(i):
        point += choice[int(i)]
        dp[j % k] = int(i)
    else:
        dp[j % k] = 3
print(point)

Measured memory_bytes: 3956
#include <stdio.h>

void plural(void) {
  char str[1001];
  scanf("%s", str);
  int i = 0;
  for (; i < 1001; i++) {
    if (str[i] == '\0') {
      break;
    }
  }
  if (str[i-1] == 's') {
    str[i] = 'e';
    str[i+1] = 's';
    str[i+2] = '\0';
  } else {
    str[i] = 's';
    str[i+1] = '\0';
  }
  printf("%s\n", str);
}

int main(void) {
  plural();
  return 0;
}


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

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define INF  numeric_limits<int>::max()
#define NINF numeric_limits<int>::min()

using namespace std;
using ll = long long;

using coordinate = struct {
    int x;
    int y;
};

int H, W;
char world_map[50][50];
int  cost_map[50][50];

bool update_map(const coordinate& target, const int& cost) {
    if(0 <= target.x && target.x < W &&
       0 <= target.y && target.y < H ) {
        if(world_map[target.y][target.x] != '#' && cost_map[target.y][target.x] == -1) {
            cost_map[target.y][target.x] = cost;
            return true;
        }
    }
    return false;
}

int get_shortest_path_length(const coordinate& s, const coordinate& g) {
    REP(hi, H) {
        REP(wi, W) {
            cost_map[hi][wi] = -1;
        }
    }

    std::queue<coordinate> queue;
    queue.push(s);
    cost_map[s.y][s.x] = 0;

    while(true) {
        coordinate dst;
        coordinate src = queue.front();
        queue.pop();

        int cost = cost_map[src.y][src.x] + 1;

        dst = coordinate{src.x + 1, src.y};
        if(update_map(dst, cost)) {
            queue.push(dst);
        }

        dst = coordinate{src.x - 1, src.y};
        if(update_map(dst, cost)) {
            queue.push(dst);
        }

        dst = coordinate{src.x, src.y + 1};
        if(update_map(dst, cost)) {
            queue.push(dst);
        }

        dst = coordinate{src.x, src.y - 1};
        if(update_map(dst, cost)) {
            queue.push(dst);
        }

        if(cost_map[g.y][g.x] != -1 || queue.size() == 0) {
            break;
        }
    }

    return cost_map[g.y][g.x];
}

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

    std::cin >> H >> W;

    int num_white = 0;
    REP(hi, H) {
        REP(wi, W) {
            std::cin >> world_map[hi][wi];
            if(world_map[hi][wi] == '.') {
                num_white++;
            }
        }
    }

    int cost = get_shortest_path_length(coordinate{0, 0}, coordinate{W - 1, H - 1});
    if(cost == -1) {
        std::cout << -1 << std::endl;
    }
    else {
        std::cout << num_white - cost - 1 << std::endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  long long int n,i,sum=0;
  cin>>n;
  for(i=1;i<=n;i++)
  {
  	if(i%3 ==0 || i%5==0)
    {
        sum+=0;
    }
    else{
        sum+=i;
    }
  }

  cout<<sum;
}


Measured memory_bytes: 3636
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <cassert>
#include <memory>
#include <stack>
#include <set>
#include <map>
#include <cctype>
#include <climits>
#include <list>
#include <queue>

#define INF 1000000000
#define MOD 1000000007
typedef long long ll;
typedef unsigned long long ull;
using namespace std;

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

  int a,b; cin>>a>>b;
  string ans;
  if(a >= 9 || b >= 9) {
    ans = ":(";
  } else {
    ans = "Yay!";
  }
  cout << ans << endl;
}


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

int main(){

int64_t n;
cin>>n;
if(n==1){cout<<0;return 0;}

int ans =0;
for(int i=2;i<=1000000;i++)
{int num=0;
    if(n==1){cout<<ans;return 0;}

    else{
            while(n % i == 0)
            {
                n = n/i;
                num++;
            }

            for(int j=1;j<12;j++)
            {
                if(num < (j*(j+1))/2)
                {
                    ans += j-1;
                    break;
                }
            }
    }
}

cout<<ans+1 ;return 0;



}






Measured memory_bytes: 3524
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;

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

    vector<int> t(n), a(n);
    rep(i, n) {
        cin >> t[i];
    }
    rep(i, n) {
        cin >> a[i];
    }

    vector<int> v(n);
    int now = 0;  // 現時点での最大値
    rep(i, n) {
        if(now < t[i]) {  // 最大値が変化したとき v[i] = t[i] が確定
            v[i] = t[i];
            now = t[i];
        }
    }

    now = 0;
    for(int i = n-1; i >= 0; i--) {
        if(v[i] == 0) {  // v[i]が未確定のときはt(n)と同様
            if(now < a[i]) {
                v[i] = a[i];
                now = a[i];
            }
        }
        else {  // v[i]が確定しているとき
            if(now < a[i] && v[i] != a[i]) {  // 最大値が変化するとv[i] = a[i]が確定するがa[i] != v[i]だと矛盾
                cout << 0 << endl;
                return 0;
            }
            else if(a[i] < v[i]) {  // 最大値はv[i]以上なのでa[i] < v[i]は矛盾
                cout << 0 << endl;
                return 0;
            }
            else if(now < v[i]) {
                now = v[i];
            }
        }
    }

    vector<ll> x(n);
    now = v[0];
    rep(i, n) {
        if(now < v[i]) {
            now = v[i];
        }
        if(v[i] == 0) {
            x[i] = (ll)now;
        }
    }

    now = v[n-1];
    for(int i = n-1; i >= 0; i--) {
        if(now < v[i]) {
            now = v[i];
        }
        if(v[i] == 0) {
            x[i] = min(x[i], (ll)now);
        }
    }

    ll ans = 1LL;
    rep(i, n) {
        if(x[i] > 0) {
            ans *= x[i];
            ans %= mod;
        }
    }

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

Measured memory_bytes: 2176
#include<iostream>

using namespace std;

int p[25]={2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97};

int main(void)
{
	int n;
	cin >> n;
	int ind[105]={};

	for(int i=1;i<=n;i++)
	{
		int now=i;
		for(int j=1;j<=25;j++)
		{
			if(now%p[j-1]==0)
			{
				now/=p[j-1];
				ind[j-1]+=1;
//cout<<i<<":"<<p[j-1]<<endl;
				j--;
			}
			if(now==1)
				break;
		}
	}
//for(int i=1;i<=25;i++)
//	cout<<"num:"<<p[i-1]<<":"<<ind[i-1]<<endl;

	int ans=0;
	int ab74=0;
	int ab24=0;
	int ab14=0;
	int ab4=0;
	int ab2=0;

	for(int i=1;i<=n;i++)
	{
		if(ind[i-1]>=74)
		{
			ab74++;
			ab24++;
			ab14++;
			ab4++;
			ab2++;
		}
		else if(ind[i-1]>=24)
		{
			ab24++;
			ab14++;
			ab4++;
			ab2++;
		}
		else if(ind[i-1]>=14)
		{
			ab14++;
			ab4++;
			ab2++;
		}
		else if(ind[i-1]>=4)
		{
			ab4++;
			ab2++;
		}
		else if(ind[i-1]>=2)
		{
			ab2++;
		}
	}

	ans+=ab74;
	ans+=(ab24*(ab2-1));
	ans+=(ab14*(ab4-1));
	ans+=(ab4*(ab4-1)/2*(ab2-2));

	cout << ans << endl;
}

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

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

    int N,tmp,i,ans=0; 
    vector<int> a;

    cin >> N;
    for(i=0;i<N;i++){
        cin >> tmp;
        a.push_back(tmp);
    }

    sort(a.begin(),a.end(),greater<int>());

    for(int j=0;j<i;j++){
        if(j%2 == 0) ans += a[j];
        else        ans -= a[j];
    }

    cout << ans << '\n';

    return 0;
}

Measured memory_bytes: 256
import java.math.BigInteger;
import java.util.Scanner;

public class Main {

	static Scanner sc = new Scanner(System.in);

	static long solve() {
		char[] s = sc.next().toCharArray();
		int[] count = new int[26];
		for (int i = 0; i < s.length; ++i) {
			++count[s[i] - 'a'];
		}
		int odd = 0;
		for (int i = 0; i < count.length; ++i) {
			if (count[i] % 2 != 0) ++odd;
		}
		if (s.length % 2 == 0) {
			if (odd != 0) return 0;

		} else {
			if (odd != 1) return 0;
		}
		for (int i = 0; i < count.length; ++i) {
			count[i] /= 2;
		}
		BigInteger[] fact = new BigInteger[s.length / 2 + 1];
		fact[0] = BigInteger.ONE;
		for (int i = 1; i < fact.length; ++i) {
			fact[i] = fact[i - 1].multiply(BigInteger.valueOf(i));
		}
		BigInteger ans = fact[s.length / 2];
		for (int i = 0; i < count.length; ++i) {
			ans = ans.divide(fact[count[i]]);
		}
		return ans.longValue();
	}

	public static void main(String[] args) {
		System.out.println(solve());
	}
}

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

bool check(ll x)
{
    char ans;
    cout << "? " << x << endl;
    cout.flush();
    cin >> ans;
    return (ans == 'Y');
}

int main()
{
    ll n = 1;
    while(1)
    {
        if (!check(n)) break;
        n *= 10;
        if(n > (ll)1e10)
        {
            ll z = 1;
            while(n)
            {
                if(!check(n+1))
                {
                    z = n*10;
                    break;
                }
                else n/= 10;
            }
            cout << "! " << z << "\n";
            return 0;
        }
    }
    ll r = n*10 - 1, l = n-1;
    while(l < r)
    {
        ll mid = (l+r) >> 1;
        if(check(mid))
        {
            n = mid;
            r = mid - 1;
        }
        else l = mid + 1;
    }
    cout << "! " << n/10 << "\n";
    cout.flush();
    return 0;
}


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

//region Template
#include "ext/pb_ds/assoc_container.hpp"

using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef long double ld;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

const int MOD = 1000000007;
using namespace std;
#define finish(x) cout << x; exit(0);
#define fastIO cin.tie(0); cin.sync_with_stdio(false);
#define endl '\n'
void setIn(string s) { freopen(s.c_str(), "r", stdin); }
void setOut(string s) { freopen(s.c_str(),"w",stdout); }

//const string USCAO_TAG = "mountains";
void usaco(const string& USACO_TAG) { setIn(USACO_TAG + ".in"); setOut(USACO_TAG + ".out"); }
void print() {}
template<typename T, typename... Args>
void print(T firstArg, Args... args) {
	#ifdef LOCAL
	cout << firstArg << " ";
	print(args...);
	#endif
}

//endregion

/* Notes:
 * Farah </3
 */

const int MAXN = 6003;
const int INF = 2e9;

int dp[MAXN][MAXN];
pair<int, int> a[MAXN], b[MAXN];

int main() {
	//usaco("milkvisits");

#ifdef LOCAL
	setIn("in.txt");
	setOut("out.txt");
#endif

	int n, t;
	cin >> n >> t;

	for(int i = 1; i <= n; i++){
		cin >> a[i].first >> a[i].second;
	}

	sort(a + 1, a + n + 1, [&](auto p1, auto p2){
		return p2.first > p1.first;
	});

	for(int i = 1; i <= n; i++){
		for(int j = 0; j <= 6001; j++){
			if(j - a[i].first < t && j - a[i].first >= 0){
				dp[j][i] = max(dp[j][i - 1], dp[j - a[i].first][i - 1] + a[i].second);
			}
			else {
				dp[j][i] = dp[j][i - 1];
			}

			//print(j, i, dp[j][i], endl);
		}
	}
	int ans = 0;
	for(int i = 0; i <= n; i++) {
		for (int j = 0; j <= 6001; j++) {
			ans = max(ans, dp[j][i]);
		}
	}
	cout << ans;
}


Measured memory_bytes: 139904
// abc of ABC
#include <iostream>
#include <algorithm>
#include <string>

using namespace std;

int main(){
	string S;
	cin >> S;

	sort(S.begin(), S.end());
	if (S == "abc")
		cout << "Yes" << endl;
	else
		cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 256
EPS = 0.0000000001

class Point:
    
    global EPS
    
    def __init__(self, x = 0, y = 0):
        self.x = x
        self.y = y
        
        
    def __add__(a, b):
        s = a.x + b.x
        t = a.y + b.y
        return Point(s, t)
        
    def __sub__(a, b):
        s = a.x - b.x
        t = a.y - b.y
        return Point(s, t)
            
    def __mul__(self, a):
        s = a * self.x
        t = a * self.y
        return Point(s, t)
        
    def __truediv__(self, a):
        s = self.x / a
        t = self.y / a
        return Point(s, t)
            
            
            
            
    def norm(self):
        return self.x * self.x + self.y * self.y
        
    def abs(self):
        return self.norm() ** 0.5
            
    
            
            
    def __eq__(self, other):
        return abs(self.x - other.y) < self.EPS and abs(self.y - other.y) < self.EPS
            
            
            
    def dot(self, b):
        return self.x * b.x + self.y * b.y
        
    def cross(self, b):
        return self.x * b.y - self.y * b.x
    
    
class Segment:
    def __init__(self, p1, p2):
        self.p1 = p1
        self.p2 = p2

def project(s, p):
    base = s.p2 - s.p1
    hypo = p - s.p1
    r = hypo.dot(base) / base.norm()
    return s.p1 + base * r



nums=list(map(int,input().split()))
s = Segment(Point(nums[0], nums[1]), Point(nums[2], nums[3]))

n = int(input())
for i in range(n):
    nums=list(map(int,input().split()))
    p = Point(nums[0], nums[1])
    x = project(s, p)
    print(x.x, x.y)









Measured memory_bytes: 5648
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <cmath>
#include <cstdio>

using namespace std;

typedef long long ll;

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

int main(int argc, char **argv)
{
    int N, A, B;
    cin >> N >> A >> B;
    cout << min(N * A, B) << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#define BIG 2000000000
#define MAX 500000

int c = 0;

void merge(int a[], int left, int mid, int right) {
	int i, k, j;
	int n1 = mid - left, n2 = right - mid;
	int L[MAX/2 + 2], R[MAX/2 + 2];

	for (i = 0; i < n1; ++i) {
		L[i] = a[left + i];
	}

	for (i = 0; i < n2; ++i) {
		R[i] = a[mid + i];
	}

	L[n1] = BIG;
	R[n2] = BIG;
	i = 0;
	j = 0;

	for (k = left; k < right; ++k) {
		c = c + 1;
		if (L[i] <= R[j]) {
			a[k] = L[i];
			i = i + 1;
		}
		else {
			a[k] = R[j];
			j = j + 1;
		}
	}
}

void mergeSort(int a[], int left, int right) {

	int mid;

	if (left + 1 < right) {
		mid = (left + right)/2;
		mergeSort(a, left, mid);
		mergeSort(a, mid, right);
		merge(a, left, mid, right);
	}

}

int main() {
	int n, a[MAX], i;

	scanf("%d", &n);

	for (i = 0; i < n; ++i) {
		scanf("%d", &a[i]);
	}

	mergeSort(a, 0, n);

	for (i = 0; i < n; ++i) {
		printf("%d", a[i]);
		if (i == n - 1) {
			printf("\n");
		}
		else {
			printf(" ");
		}
	}

	printf("%d\n", c);
	return 0;
}

Measured memory_bytes: 5584
#include <cstdio>
#include <iostream>
#include <array>
#include <vector>
#include <deque>
#include <string>
#include <algorithm>
#include <functional>
#include <tuple>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <queue>
#include <stack>
#include <utility>
#include <memory>
#include <valarray>
#include <climits>

using namespace std;

using ll = long long int;

#define loop(i, N) for (int i = 0; i < N; ++i)
#define scanInt(x) int x; scanf("%d", &x); getchar();
#define scanLLInt(x) ll x; scanf("%lld", &x); getchar();
#define scanVecInt(A, N) vector<int> A(N); loop(i, N){scanf("%d", &(A[i])); getchar();}
#define scanVecLLInt(A, N) vector<ll> A(N); loop(i, N){scanf("%lld", &(A[i])); getchar();}

int main()
{
    scanInt(X);
    scanInt(K);
    scanVecInt(R, K);
    vector<tuple<int, int, int>> V; // 各R時点での斜め部分の増減、左端、右端
    V.emplace_back(0, 0, X);
    map<int, int, greater<int>> rev; // 時間からRの番号+1を引く
    rev.emplace(0, 0); // lower_boundでkey以下の要素を探せる
    bool up = false;
    loop(k, K){
        int d;
        if (k == 0){
            d = R[k];
        }else{
            d = R[k] - R[k - 1];
        }
        auto& offset = get<0>(V.back());
        auto& left = get<1>(V.back());
        auto& right = get<2>(V.back());
        if (up){
            if (left + offset < X - d){
                if (right + offset < X - d){ // 形変わらず上下だけ移動
                    V.emplace_back(offset + d, left, right);
                }else{ // 右端変化
                    V.emplace_back(offset + d, left, X - (offset + d));
                }
            }else{ // 全て平坦
                V.emplace_back(X, 0, 0);
            }
        }else{ // down
            if (d < right + offset){
                if (d < left + offset){ // 形変わらず上下だけ移動
                    V.emplace_back(offset - d, left, right);
                }else{ // 左端変化
                    V.emplace_back(offset - d, d - offset, right);
                }
            }else{ // 全て平坦
                V.emplace_back(0, 0, 0);
            }
        }
        rev.emplace(R[k], k + 1);
        up = !up;
    }
    for (auto& v : V){
        auto& a1 = get<0>(v);
        auto& a2 = get<1>(v);
        auto& a3 = get<2>(v);
        // printf("%d %d %d\n", a1, a2, a3);
    }
    scanInt(Q);
    loop(i, Q){
        scanInt(T);
        scanInt(A);
        auto it = rev.lower_bound(T);
        auto& R = it->first;
        auto& k = it->second;
        auto& offset = get<0>(V[k]);
        auto& left = get<1>(V[k]);
        auto& right = get<2>(V[k]);
        int rest;
        if (A <= left){
            rest = left + offset;
        }else if (right <= A){
            rest = right + offset;
        }else{
            rest = A + offset;
        }
        if (k % 2 == 1){ // up
            rest += (T - R);
            rest = min(X, rest);
        }else{ // down
            rest -= (T - R);
            rest = max(0, rest);
        }
        // printf("%d ", k);
        printf("%d\n", rest);
    }
}


Measured memory_bytes: 7476
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll f[10000002];


int main()
{
	for(int i=1; i<=10000001; i++)
	{
		f[i]++;
		for(int j=i+i; j<10000001; j+=i)
		{
			f[j]++;
		}
	}
	ll n;
	cin>>n;
	ll ans=0;
	for(int i=1; i<=n; i++)
	{
		ans+=(i*f[i]);
	}
	cout<<ans<<endl;

}

Measured memory_bytes: 81756
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e16;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

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 ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}
ll factorial(ll n) {
  if (n == 1) {
    return 1;
  }
  ll ans = factorial(n-1);
  return ans*n;
}
ll gcd(ll a, ll b) {
  if (b == 0) return a;
  return gcd(b, a%b);
}
ll lcm(ll a, ll b) {
  return (a/gcd(a, b))*b;
}
bool is_prime(ll n) {
  for (ll i = 2; i*i <= n; i++) {
    if (n%i == 0) return false;
  }
  return n != 1;
}
ll mod_pow(ll x, ll n, ll mod) {
  if (n == 0) return 1;
  ll res = mod_pow(x*x%mod, n/2, mod);
  if (n & 1) res = res * x % mod;
  return res;
}

int main() {
  string s;
  cin >> s;
  s.at(3) = '8';
  cout << s << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
  int N, M;
  scanf("%d %d\n", &N, &M);

  int maxL = 1;
  int minR = N;

  for (int i = 1; i <= M; i++)
  {
    int L, R;
    scanf("%d %d\n", &L, &R);

    if (L > maxL)
    {
      maxL = L;
    }

    if (R < minR)
    {
      minR = R;
    }
  }

  int answer = minR - maxL + 1;
  if (answer < 0)
  {
    answer = 0;
  }

  printf("%d\n", answer);

  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
  public static void main(String [] args) {
    Scanner sc = new Scanner(System.in);
    int h = sc.nextInt();
    int w = sc.nextInt();
    String s;
    while (h --> 0) {
      s = sc.next();
      System.out.println(s + "\n" + s);
    }
  }
}


Measured memory_bytes: 40012
#include<stdio.h>
int main(void)
{
	int i,n,a[1000],w,k;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	w=0; k=0;
	for(i=0;i<n;i++){
		if(a[i]%2==0){
			k++;
		}
		if((a[i]%2==0&&a[i]%3==0)||(a[i]%2==0&&a[i]%5==0)){
			w++;
		}
	}
	if(k==w){
		printf("APPROVED\n");
	}
	else{
		printf("DENIED\n");
	}
	return 0;
}

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

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

  vector<int> a(n);
  map<int, int> m;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    if (m.find(a[i]) == m.end())
      m.emplace(a[i], 0);
    m[a[i]]++;
  }

  ll ans = 0;
  for (auto p : m) {
    ll n = p.second;
    ans += n * (n - 1) / 2;
  }

  for (int i = 0; i < n; ++i) {
    ll x = m[a[i]];
    ll y = x * (x - 1) / 2;
    ll z = (x - 1) * (x - 2) / 2;
    cout << ans - y + z << endl;
  }
}

Measured memory_bytes: 8320
#include <iostream>
using namespace std;
 
int main() {
    int a, b, c, d;
  	int ans = 0;
  	cin >> a >> b >> c >> d;
  	for(int i = 0; i <= a; ++i){
    	for(int j = 0; j <= b; ++j){
         	for(int k = 0; k <= c; ++k){
             	if(500 * i + 100 * j + 50 * k == d) ans++;
            }
        }
  	}
 	  	
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define dunk(a) cout << (a) << endl
#define rall(a) (a).rbegin(),(a).rend()
const int INF = 2e9;
using namespace std;
using Graph = vector<vector<int>>;
typedef pair<int,int> P;
typedef long long ll;

int main(){
  int N,A,B;
  cin >> N;
  if(N==1) printf("%s","Hello World");
  else {cin >> A >> B;
              printf("%d",A+B);
             }
}
  


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define pb push_back
#define ff first
#define ss second
#define rep(i,a,n) for(int i=a;i<n;i++)
#define M 1000000007
ll power(ll x, ll y, ll p)
{
    int res = 1;
    x = x % p;
    while (y > 0)
    {   if (y & 1)
        res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}
int main()
{
	IOS;
	int n;
	cin>>n;
	int a[n],b[n],c[n-1];
	rep(i,0,n)cin>>a[i];
	rep(i,0,n)cin>>b[i];
	rep(i,0,n-1)cin>>c[i];
	ll ans=0;
	int p=-1;
	for(int i=0;i<n;i++)
	{
		if(p+1==a[i])
		{
			ans+=c[p-1];
		}
		p=a[i];
		ans+=b[a[i]-1];
	}
	cout<<ans;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int mod  = 1e9+7;
const int n_max = 21;
const ll INF = 1e18;
ll d[n_max+1][n_max+1];
ll dp[(1<<n_max)+1];

int main() {
    int N;
    cin >> N;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            cin >> d[i][j];
        }
    }

    dp[0] = 1;
    for (int S = 1; S < (1<<N); S++) {
        int i = __builtin_popcount(S); //bitが何本立っているか
        for (int j = 0; j < N; j++) {
            if (S & 1<<j && d[i-1][j] == 1) {
                dp[S] += dp[S^(1<<j)];
                dp[S] %= mod;
            }
        }
    }

    cout << dp[(1<<N)-1] << endl;
    
    return 0;
}

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

typedef long long ll;

const int MOD = 998244353;
const int N = 3e5 + 10;

int fact[N], ifact[N], inv[N];

ll comb(int m, int n) { return (ll) fact[m] * ifact[n] % MOD * ifact[m-n] % MOD; }


int main() {
    inv[1] = 1;
    for (int n = 2; n < N; n++) inv[n] = ll(MOD - MOD/n) * inv[MOD%n] % MOD;
    fact[0] = ifact[0] = 1;
    for (int n = 1; n < N; n++) {
        fact[n] = ll(n) * fact[n-1] % MOD;
        ifact[n] = ll(inv[n]) * ifact[n-1] % MOD;
    }

    ll n,A,B,k,ans = 0;
    cin >> n >> A >> B >> k;
    for (int a = 0; a <= n; a++) {
        auto rest = k - A*a;
        if (rest >= 0 && rest%B == 0) {
            auto b = rest/B;
            if (b <= n) ans += (ll) comb(n,a) * comb(n,b) % MOD;
        }
    }
    cout << ans%MOD << endl;
    return 0;
}




Measured memory_bytes: 3712
N = int(input())
tasks = []
for i in range(N):
    D = list(map(int,input().split()))
    tasks.append(D)
tasks.sort(key=lambda x:x[1])
time = 0
total = 0
for i in range(N):
    total += tasks[i][0]
    if total>tasks[i][1]:
        print('No')
        break
else:
    print('Yes')


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

int main() {
  int N,X;
  cin >> N>>X;
  vector<int> m(N);
  for(int i=0;i<N;i++){
    cin >> m[i];
  }
  sort(m.begin(), m.end());
  int c=0;
  int i=0;
  while(i<N){
    X -= m[i];
    if (X<0) break;
    c++;
    i++;
  }
  c += X/m[0];
  cout << c << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()		//sort(all(vi S)) sort(all(string S))
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }

using P = pair<int, int>;		//P.first, P.second
typedef long long ll;
typedef vector<int> vi;
typedef set<int> seti;
typedef vector<string> vs;

const int MOD = 1e9+7;
const int INF = 1e9;

int main() {
	int N;
	cin>>N;
	vector<ll> A(N);
	rep(i,N)cin>>A[i];
	int ans = 1;
	int now = 0;
	rep(i,N-1){
		if(now==0){
			if(A[i]<A[i+1])now = 1;
			else if(A[i]>A[i+1])now = 2;
		}
		else if(now == 1 && A[i]>A[i+1]){
			now = 0;
			ans++;
		}
		else if(now == 2 && A[i]<A[i+1]){
			now = 0;
			ans++;
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 1152
import java.util.Scanner;
class Main{
	public static void main(String[]args){
		Scanner sc;
		int n,m,ans=0;
		String s=new String();
		String tmpl=new String("I");
		sc=new Scanner(System.in);
		while(true){
			n=sc.nextInt();
			if(n==0){break;}
			m=sc.nextInt();
			s=sc.next();
			for(int i=0;i<n;i++){
				tmpl+="OI";
			}
			for(;;){
				int j=s.indexOf(tmpl);
				if(j>=0){
					ans++;
					s=s.substring(j+1,s.length());
				}else{break;}
			}
			System.out.println(ans);
			ans=0;tmpl="I";
		}
	}
}

Measured memory_bytes: 59680
#include <stdio.h>

int main(void){
	int r[101][101]={0};
	int n,m;
	int i,j;

	scanf(" %d %d",&n,&m);
	for(i = 0;i < n;i++){
		for(j = 0;j < m;j++){
			scanf("%d",&r[i][j]);
			r[i][m] += r[i][j];
		}
	}
	for(i = 0;i < m+1;i++){
		for(j = 0;j < n;j++){
			r[n][i] += r[j][i];
		}
	}

	for(i = 0;i < n+1;i++){
		for(j = 0;j < m+1;j++){
			printf("%ld",r[i][j]);
			if(j != m) printf(" ");
			else printf("\n");
		}
	}
	
	return 0;
}

Measured memory_bytes: 652
import math

N, K = list(map(int, input().split(' ')))

sum = 0.0
for x in range(1, N+1):
    if x < K:
        m = math.ceil(math.log2(float(K) / float(x)))
    else:
        m = 0.0
    sum += (1.0 / float(N)) * ((0.5) ** m)

print(sum)

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

bool iscollect(string str){
	string::iterator fwd,last;
	stack<bool> list;
	bool ret=true;
	fwd=str.begin();
	last=str.end();
	while(fwd!=last){
		if(*fwd=='('){
			list.push(true);
		}else if(*fwd=='['){
			list.push(false);
		}else if(*fwd==')'){
			if(list.empty()||list.top()==false){
				ret=false;
				break;
			}
			list.pop();
		}else if(*fwd==']'){
			if(list.empty()||list.top()==true){
				ret=false;
				break;
			}
			list.pop();
		}
		++fwd;
	}
	if(!list.empty())ret=false;
	return ret;
}

int main(){
	string in;
	while(true){
		getline(cin, in);
		if(in==".")break;
		if(iscollect(in)){
			cout<<"yes"<<endl;
		}else{
			cout<<"no"<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1184
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<queue>
#include<cmath>
#include <numeric>
#include<iomanip>
#include <cstdint>

using namespace std;


int main() {
	string s;
	cin >> s;
	int n = s.size();
	int ans = 0;
	for (int i = 0; i < n / 2; i++) {
		if (s[i] != s[n - 1 - i]) {
			ans++;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
let dfs vs n =
  let d = Array.make n 0 in
  let f = Array.make n 0 in
  let rec search i time =
    d.(i) <- time;
    let time =
      List.fold_left
        (fun time v ->
          if d.(v-1) = 0 then search (v-1) time
          else time)
        (time + 1) vs.(i) in
    f.(i) <- time;
    time + 1 in
  Array.fold_left (fun (i, time) e ->
    (i + 1, if e = 0 then search i time else time))
    (0, 1) d |> ignore;
  (d, f)

let split_on_char sep s =
  let open String in
  let r = ref [] in
  let j = ref (length s) in
  for i = length s - 1 downto 0 do
    if get s i = sep then begin
      r := sub s (i + 1) (!j - i - 1) :: !r;
      j := i
    end
  done;
  sub s 0 !j :: !r

let () =
  let n = read_int () in
  let vs = Array.make n [] in
  for _ = 0 to n - 1 do
    match read_line () |> split_on_char ' ' |> List.map int_of_string with
    | u :: _ :: l -> vs.(u-1) <- l
    | _ -> assert false
  done;
  let (d, f) = dfs vs n in
  for i = 0 to n - 1 do
    Printf.printf "%d %d %d\n" (i + 1) d.(i) f.(i)
  done

Measured memory_bytes: 2328
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>
#include<iomanip>

using namespace std;

typedef long long ll;

typedef std::pair<int, int> ipair;
bool lessPair(const ipair& l, const ipair& r){return l.second < r.second;}
bool morePair(const ipair& l, const ipair& r){return l.second > r.second;}

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

const ll MOD = 1e9 + 7;
// const long long INF = 1LL<<60;
void add(long long &a, long long b) { a += b; if (a >= MOD) a -= MOD; }
void sub(long long &a, long long b) { a -= b; if (a < 0) a += MOD; }
void mul(long long &a, long long b) { a *= b; a %= MOD; }
ll llmin(ll a, ll b) { if (a < b) return a; else return b; }
ll llmax(ll a, ll b) { if (a < b) return b; else return a; }
ll llabs(ll a) { if (a >= 0) return a; else return - a; }
ll llmodpow(ll a, ll n) {
   if (n == 0) return 1;
   ll tmp = llmodpow(a, n / 2);
   mul(tmp, tmp);
   if (n & 1) mul(tmp, a);
   return tmp;
}


const ll MAX = 2010;
long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


int main() {
   int N, K;
   cin >> N >> K;
   COMinit();
   for (int i = 1; i <= K; i++) {
      ll ans = COM(K - 1, K - i);
      ans %= MOD;
      ans *= COM(N - K + 1, i);
      ans %= MOD;
      cout << ans << endl;
   }
   return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	long long N,D,X,A[105],ans;
	cin>>N>>D>>X;
	for(int i=1;i<=N;i++){
		cin>>A[i];
	}
	ans=X;
	for(int i=1;i<=N;i++){
		ans=ans+1+(D-1)/A[i];
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
from fractions import gcd


def count(X, C, D, l):
    c = X // C
    d = X // D
    cd = X // l
    return c + d - cd


def main():
    A, B, C, D = map(int, input().split(" "))
    lcm = C * D // gcd(C, D)
    BorC = B - A + 1 - count(B, C, D, lcm) + count(A - 1, C, D, lcm)
    print(BorC)


if __name__ == '__main__':
    main()

Measured memory_bytes: 5464
#include <iostream>
#include <map>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;

int main() {
  map<string, vector<int> > index;
  string str;
  int page;
  while(cin >> str >> page) index[str].push_back(page);

  for (auto i : index) {
    cout << i.first << endl;
    sort(i.second.begin(), i.second.end());
    for (auto j = i.second.begin(); j != i.second.end() -1; j++)
      cout << *j << " ";
    cout << *(i.second.end() -1) << endl;
  }
}


Measured memory_bytes: 3248