akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <bitset>
#include <complex>
#include <unistd.h>
#include <cassert>
#include <cctype>
#include <random>
#include <time.h>
#define _USE_MATH_DEFINES
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<double, double, double> tddd;
typedef complex<double> xy_t;
typedef vector<ll> vll;
typedef vector< vector<ll> > matrix;
#define REP(i, x, y) for(ll i = (ll)x; i < (ll)y; i++)
#define DREP(i, x, y, d) for(ll i = (ll)x; i < (ll)y; i += (ll)d)
#define PER(i, x, y) for(ll i = (ll)x; i > (ll)y; i--)
#define DPER(i, x, y, d) for(ll i = (ll)x; i > (ll)y; i -= (ll)d)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
double pi = 3.141592653589793;
ll mod = 1000000007;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;
int iinf = intmax / 8;
ll inf = llmax / 8;
double eps = 1e-12;

ll bo[310][310];
ll cost[310][310][310];
ll dp[310][310][310];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll H, W;
    cin >> H >> W;
    REP(i, 0, H) {
        string s;
        cin >> s;
        REP(j, 0, W) {
            bo[i][j] = s[j] - 'a';
        }
    }
    REP(i, 0, W - 1) {
        REP(j, 0, H + 1) {
            cost[i][H][H - j] = 0;
            REP(k, 1, H - j + 1) {
                cost[i][H - k][H - j - k] = cost[i][H - k + 1][H - j - k + 1];
                if (bo[k - 1][i] == bo[j + k - 1][i + 1]) {
                    cost[i][H - k][H - j - k]++;
                }
            }
        }
        REP(j, 1, H + 1) {
            cost[i][H - j][H] = 0;
            REP(k, 1, H - j + 1) {
                cost[i][H - j - k][H - k] = cost[i][H - j - k + 1][H - k + 1];
                if (bo[j + k - 1][i] == bo[k - 1][i + 1]) {
                    cost[i][H - j - k][H - k]++;
                }
            }
        }
        dp[i][0][0] = 0;
        REP(j, 1, H + 1) {
            dp[i][j][0] = dp[i][j - 1][0] + cost[i][j - 1][0];
            dp[i][0][j] = dp[i][0][j - 1] + cost[i][0][j - 1];
        }
        REP(j, 1, H + 1) {
            REP(k, 1, H + 1) {
                dp[i][j][k] = min(dp[i][j - 1][k] + cost[i][j - 1][k], dp[i][j][k - 1] + cost[i][j][k - 1]);
            }
        }
    }
    // REP(i, 0, W - 1) {
    //     cout << i << endl;
    //     REP(j, 0, H + 1) {
    //         REP(k, 0, H + 1) {
    //             cout << cost[i][j][k] << " ";
    //         }
    //         cout << endl;
    //     }
    //     REP(j, 0, H + 1) {
    //         REP(k, 0, H + 1) {
    //             cout << dp[i][j][k] << " ";
    //         }
    //         cout << endl;
    //     }
    // }
    ll ans = 0;
    REP(i, 0, W - 1) {
        ans += dp[i][H][H];
    }
    cout << ans << endl;
}


Measured memory_bytes: 453504
#include <bits/stdc++.h>
 
using namespace std;
 
#define lli long long int
#define REP(i,s,l) for(lli i=s;i<l;i++)
#define DEBUG 0
#define INF (1LL<<50)

bool isBitOn(lli num,lli bit){
	lli rtn = (1LL<<bit);
	return (num&rtn);
}

signed main(){

	lli n,k;
	cin>>n>>k;
	vector<lli> a(n);
	REP(i,0,n)cin>>a[i];
	vector<lli> bitD(60,0);

	lli maxOn=0,minOn=0;

	for(lli i=0;i<n;i++){
		for(lli bit=0;bit<60;bit++){
			if(isBitOn(a[i],bit)){
				bitD[bit]++;
				if(DEBUG)cout<<"a[i]="<<a[i]<<" bit="<<bit<<endl;
			}
		}
	}

	/*maxOn, kとほぼ同等になるようにONする*/
	/*minOn, k以下の数字で最大になる値を撮り続ける*/

	lli flag=0;
	for(lli bit=59;bit>=0;bit--){
		lli onBit = bitD[bit];
		lli num = (1LL<<bit);
		if(DEBUG)cout<<"bit="<<bit<<endl;

		if(num > k){
			maxOn += num*onBit;
			continue;
		}

		if(onBit>=n/2){//nothing
			if(flag==0)minOn = max(maxOn,minOn);
			flag=1;
		}

		/*maxのON,OFFについて*/
		if(isBitOn(k,bit)){
			maxOn += num*(n-onBit);
		}
		else{
			maxOn += num*onBit;
		}
		if(flag){
			minOn += max(onBit,n-onBit)*num;
			if(maxOn==minOn)flag=0;
		}
	}

	cout<<max(maxOn,minOn)<<endl;

	return 0;
}

Measured memory_bytes: 1024
a = int(input())
x = 0
y = 0
time = 0
for i in range(a):
    aa,b,c = map(int,input().split())
    if (abs(b-x) + abs(c-y)) %2 == (aa - time)%2 and abs(b-x) + abs(c-y) <= aa - time:
        x = b
        y = c
        time = aa
    else:
        print("No")
        break
    if i == a-1:
        print("Yes")

Measured memory_bytes: 3060
//2*10^9
//9*10^18
// __int128_t 
#include<bits/stdc++.h>
using namespace std;

#define ull unsigned long long int
#define ll long long int

const ll M=1e9+7;

//to handle when remainder is -neg we add + M
//but when rem is +pos that time also we add so use %M
//so it will work for both
ll mod(ll n){
    return (n%M + M)%M; 
}
ll modAdd(ll a, ll b){
    return mod(mod(a)+mod(b));
}
ll modMul(ll a, ll b){
    return mod(mod(a)*mod(b));
}
ll modMinus(ll a, ll b){
    return mod(mod(a)-mod(b));
}
ll modpow(ll x, ll n) 
{ 
    if (n == 0) 
        return 1%M;
    if (n == 1)
        return x%M; 
    ll u = modpow(x,n/2); 
    u = modMul(u,u); 
    if (n%2) 
        u = modMul(u,x); 
    return u; 
}
ll gcd(ll a,ll b){
    if(b==0)
        return a;
    return gcd(b,a%b);
}
bool isPrime(ll n){
    int end = sqrt(n);
    for(int i=2;i<=end;i++)
        if(n%i==0)
            return false;
    return true;
}

int factors(int n){
    int count=0;
    int end=sqrt(n)-1;

    for(int i=1;i<=end;i++){
        if(n%i==0)
           count+=2;
    }
    if(n%(end+1)==0){
        if(n/(end+1)!=(end+1))
            count+=1;
        count+=1;
    }

    return count;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    
    int t=1;
    //cin>>t;

    while(t--){
        int n;
        cin>>n;

        ll ans=0;
        for(int i=1;i<n;i++)
            ans+=factors(n-i);
        cout<<ans<<endl;
    }
    return 0;
}

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

struct Node
{
    int key;
    Node *p, *l, *r;
};

Node *root, *NIL;

void insert(int k) {
    Node *tmp_p = NIL;
    Node *tmp = root;
    Node *z = new Node;

    // z = (Node *)malloc(sizeof(Node));
    z = new Node;
    z->key = k;
    z->l = NIL;
    z->r = NIL;

    while (tmp != NIL) {
        tmp_p = tmp;
        if (z->key < tmp->key) {
            tmp = tmp->l;
        }
        else {
            tmp = tmp->r;
        }
    }

    z->p = tmp_p;
    if (tmp_p == NIL) {
        root = z;
    }
    else {
        if (z->key < tmp_p->key) {
            tmp_p->l = z;
        }
        else {
            tmp_p->r = z;
        }
    }
}

Node * find(int k, Node *u) {
    while (u != NIL && k != u->key)
    {
        if (k < u->key)
        {
            u = u->l;
        }
        else
        {
            u = u->r;
        }
    }
    return u;
}

void inorder(Node *u) {
    if (u == NIL) {
        return;
    }

    inorder(u->l);
    cout << " " << u->key;
    inorder(u->r);
}

void preorder(Node *u) {
    if (u == NIL) {
        return;
    }

    cout << " " << u->key;
    preorder(u->l);
    preorder(u->r);
}

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

    string command;
    int node_i;

    for (int i = 0; i < N; i++)
    {
        cin >> command;
        if (command == "insert") {
            cin >> node_i;
            insert(node_i);
        }
        else if (command == "find") {
            cin >> node_i;
            Node *tmp = find(node_i, root);
            if (tmp != NIL)
                cout << "yes" << endl;
            else
                cout << "no" << endl;
        }
        else if (command == "print")
        {
            inorder(root);
            cout << endl;
            preorder(root);
            cout << endl;
        }
    }
}


Measured memory_bytes: 40668
from itertools import combinations_with_replacement as cwr
H,W,K=map(int,input().split())
C=[]
for _ in range(H):
    c = list(map(str, input()))
    C.append(c)
ans=0
lh = [0 for _ in range(H)]
while True:    
    lw = [0 for _ in range(W)]
    while True:
        num =0
        for i in range(H):
            for j in range(W):
                if lh[i]==1 or lw[j]==1 or C[i][j]==".":
                    continue
                else:
                    num+=1
        if num==K:
            ans +=1
        if sum(lw)==W:
            break
        for k in range(W):
            if lw[k]==0:
                lw[k]=1
                break
            if lw[k]==1:
                lw[k]=0
    if sum(lh)==H:
        break
    for k in range(H):
        if lh[k]==0:
            lh[k]=1
            break
        elif lh[k]==1:
            lh[k]=0

print(ans)

Measured memory_bytes: 9264
import java.util.*;

public class Main {

    static final int MOD = 1000000007;

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int ans = 0;
        int d[] = new int[n];
        for(int i=0;i<n;i++)d[i]=sc.nextInt();

        for(int i=0;i<n-1;i++)for(int j=i+1;j<n;j++)ans += d[i]*d[j];
        System.out.println(ans);

    }

}


Measured memory_bytes: 21588
n=int(input())

def out(x):
	print(x,flush=True)
	nxt=input()
	if nxt=="Vacant":
		exit()
	return nxt=="Male"

Lgen=out(0)
Rgen=out(n-1)

l,r=0,n-1
while True:
	m=(l+r)//2
	gen=out(m)
	if (m-l)%2==int(gen==Lgen):
		r=m
		Rgen=gen
	else:
		l=m
		Lgen=gen

Measured memory_bytes: 3660
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(long long)(n);i++)
#define all(a) a.begin(), a.end()
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
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 MOD=1e9+7;
const ll INF=1e18;
const int MAX=510000;
const double pi=acos(-1);
int dx[8] = {1,0,-1,0,1,1,-1,-1};
int dy[8] = {0,1,0,-1,-1,1,1,-1};
// int d[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false); 
  
  map<int,int>mp;
  rep(i,3){
    int x;
    cin >> x;
    mp[x]++;
  }
  cout << mp.size() << endl;

  return 0;
}


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

int main() {
    int A, B;
    cin >> A >> B;
    int i=0;
    while(1){
        if (int(i*0.08)==A && int(i*0.1)==B){
            cout << i << endl;
            return 0;
        }
        if (int(i*0.08)>A || int(i*0.1)>B) break;
        i++;
    }
    cout << -1 << endl;
}
 

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define ALL(v) (v).begin(),(v).end()
using ll = long long;
using P = pair<int, int>;
const int INF = 1e9;
const long long LINF = 1e18;
const long long MOD = 1e9 + 7;

bool rec(ll X, ll Y, bool now){
    if(X <= 1 && Y <= 1) return !now;
    if(now){
        bool res = false;
        for(int i = 1; i <= X / 2; i++){
            res |= rec(X - 2 * i, Y + i, !now);
        }
        for(int i = 1; i <= Y / 2; i++){
            res |= rec(X + i, Y - 2 * i, !now);
        }
        return res;
    }else{
        bool res = true;
        for(int i = 1; i <= X / 2; i++){
            res &= rec(X - 2 * i, Y + i, !now);
        }
        for(int i = 1; i <= Y / 2; i++){
            res &= rec(X + i, Y - 2 * i, !now);
        }
        return res;
    }
}

signed main(){
    ll x,y;
    cin >> x >> y;
    if(max(x, y) - min(x, y) <= 1){
        cout << "Brown" << endl;
    }else{
        cout << "Alice" << endl;
    }
    /*
    for(int i = 0; i <= 10; i++){
        for(int j = 0; j <= 10; j++){
            cout << i << " " << j << " : ";
            if(rec(i,j,true)){
                cout << "Alice" << endl;
            }else{
                cout << "Brown" << endl;
            }
        }
    }
    */
    return 0;
}

Measured memory_bytes: 256
n = gets.chomp.to_i
p = gets.chomp.split(" ").join()
q = gets.chomp.split(" ").join()

items =[]
n.times do |i|
  items << (i+1).to_s
end

count = 0
pc = -1
qc = -1
items.permutation(n) do |a|
  str = a.join()
  pc = count if str == p
  qc = count if str == q
  break if pc >= 0 && qc >= 0
  count +=1
end

puts (qc-pc).abs

Measured memory_bytes: 2428
#include<iostream>
using namespace std;
int main(){
	long double da,db;
	long double s=0;
	int n;
	int i,j,k;
	char ca[5];
	cin>>n;
	for(i=0;i<n;i++){
		cin>>da>>ca;
		if(ca[0]=='B')da*=380000.0;
		s+=da;
	}
	cout<<s<<endl;
	return 0;
}
		


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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;

const ll LongINF=1e13+7;
const int INF=1e9+7;
const int dx[]={0,1,0,-1};
const int dy[]={1,0,-1,0};

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;}
template <class T, class Y>T GCD(T a, Y b){if(a<b){int c=a;a=b;b=c;}if (a % b == 0){return b;}return GCD(b, a % b);}
template<class T,class Y>T LCM(T a,Y b){return (a*b)/GCD(a,b);}
void clear(queue<pair<int, int>> &q){queue<pair<int, int>> empty;swap(q, empty);} //queueの中身の型は適時変更を忘れない

using vi=vector<int>;
using vii=vector<vi>;

#define REP(i,a,b) for(ll i=(a);i<(b);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define rv reverse
#define ALL(a) (a).begin(),(a).end()
#define decimal(x) fixed<<setprecision(x)

int main(){
    string s;
    cin>>s;
    ll l=s.length(),cnt=0,ans=0;
    rep(i,l){
        if(s[i]=='B')cnt++;
        else if(s[i]=='W'){
            ans+=cnt;
        }
    }
    cout<<ans<<endl;
    return 0;
}

//a=97,z=122

Measured memory_bytes: 3740
#include <iostream>  
using namespace std;  
 
  
const int MAX_NUM = 100;  
const int MAX_WEIGHT = 10000;  

  
int weight[MAX_NUM];  
int value[MAX_NUM];  
 
int dp[MAX_WEIGHT];  
  

void Solve( int n, int w )  
{     
    for( int i=1; i<=n; i++ )  
    {  
        for( int j=w; j>=weight[i]; j-- )  
        {             
            if( dp[j-weight[i]] + value[i] > dp[j] )  
                dp[j] = dp[j-weight[i]] + value[i];           
        }  
    }  
    cout << dp[w] << endl;  
}  

int main()  
{    
    int n, w;  
    cin >> n >> w;        
    for( int i=1; i<=n; i++ )  
    {  
        cin >> value[i] >> weight[i];  
    }  
    Solve( n, w );  
 
    return 0;  
}  

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

// ループによる最大公約数
long gcd(long x, long y){
  long r;
  if(x < y) swap(x, y);
  
  while(y > 0){
    r = x % y;
    x = y;
    y = r;
  }
  return x;
}

int main() {
  long n, x;
  cin >> n >> x;
  
  cout << (n - gcd(n, x)) * 3 << endl;
}

Measured memory_bytes: 256
#include <stdio.h> 
 #include <ctype.h> 
 #include <string.h> 
 
 
 int main(){ 
     char search[21], word[21]; 
     int count=0; 
     int i; 
      
     scanf("%s", search); 
     while(1){ 
         scanf(" %s", word); 
         if(strcmp(word, "END_OF_TEXT")==0)break; 
         for(i=0;word[i]!='\0';i++){ 
             word[i]=tolower(word[i]); 
         } 
         if(strcmp(word, search)==0){ 
             count++; 
         } 
     } 
     printf("%d\n", count); 
 
 
     return 0; 
 } 



Measured memory_bytes: 2056
#include<bits/stdc++.h>
    #define ll long long
    #define pb push_back
    #define Fast ios_base::sync_with_stdio(false); cin.tie(0);
    using namespace std;

    int main() {
        int a,b;
        cin>>a>>b;
       if(b%2 || b < a*2 || a*4<b)cout<<"No"<<endl;
        else cout<<"Yes"<<endl;
        return 0;
    }


Measured memory_bytes: 3632
num = gets.to_i
max_day, left=gets.split.map(&:to_i)
array = []

num.times do
  x = gets.to_i
  (0..max_day).each_with_index do |a,idx|
    if idx * x + 1 > max_day
      break
    end
    array << idx * x + 1
  end
end
p array.size + left

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << endl;
#define CFYN(n) cout << ( (n) ? "YES":"NO") << endl;
#define OUT(n) cout << (n) << endl;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;

int main(void)
{
    IOS
    while(true) {
        int n; cin >> n;
        if (n == 0) break;
        vector<int> v(n);
        REP(i,n) cin >> v[i];
        sort(ALL(v));
        int ans = accumulate(ALL(v),0) - v.front() - v.back();
        ans /= v.size() -2;
        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 3128
x = input().split(" ")
n = int(x[0])
k = int(x[1])
h = list(map(int,input().split(" ")))

h.sort(reverse=True)

ans = 0
if k >= n:
    print(0)
else:
    for i in range(k,n):
        ans += h[i]
    print(ans)

Measured memory_bytes: 26764
#include <iostream>
#include <cmath>
using namespace std;
using ll=long long;

int main() {
  std::ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0);
  int Q;
  cin>>Q;
  while (Q--) {
    ll A,B;
    cin>>A>>B;
    if (A>B) {
      swap(A,B);
    }
    if (A==B||A+1==B) {
      cout<<2*A-2<<endl;
    } else {
      ll C=sqrt(A*B);
      if (A*B==C*C) {
        C--;
      }
      if (C*(C+1)<A*B) {
        cout<<2*C-1<<endl;
      } else {
        cout<<2*C-2<<endl;
      }
    }
  }
  return 0;
}



Measured memory_bytes: 256
import java.util.*;
import java.math.*;
     
class Main{
    public static void main(String[] args) {
        
        try(Scanner sc = new Scanner(System.in)){
 
            long n = Long.parseLong(sc.next());
            long a = Long.parseLong(sc.next());
            long b = Long.parseLong(sc.next());

            long mod = n % (a + b);

            long ans = 0;
            if(mod <= a){
                ans = ((n - mod)/(a + b))*a + mod;
            }else{
                ans = ((n - mod)/(a + b))*a + a;
            }

            System.out.println(ans);

        }catch(Exception e){
            e.printStackTrace();
        }        
    }
}

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

#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pll;
typedef long double ld;

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

int main() {
	int n; scanf("%d", &n);
	int dam[n];
	int total = 0;
	forn(i, n) {
		scanf("%d", &dam[i]);
		total += dam[i];
	}
	int ans[n];
	for(int i = 1; i < n; i+=2) {
		total -= dam[i] * 2;
	}
	ans[0] = total;
	for1(i, n) {
		ans[i] = dam[i - 1] * 2 - ans[i - 1];
	}
	for(auto a : ans)
		printf("%d ", a);






	return 0;
}

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

using namespace std;
using ll = long long;
constexpr ll INF = 1000000000000000000;

map<pair<int, int>, ll> optTake;

vector<ll> arr;

ll solve(int n, int k) {
	if (n == 0) {
		if (k == 0) return 0;
		else return -INF;
	}
	if (n == 1) {
		if (k == 0) return 0;
		else if (k == 1) return arr[0];
		else return -INF;
	}
	if ((n / 2 + n % 2) < k) return -INF;
	if (optTake.count(make_pair(n, k)) > 0) {
		return optTake[make_pair(n, k)];
	}
	// either we take this element or we don't
	ll ans = solve(n - 1, k);
	if (n >= 2) ans = max(ans, solve(n - 2, k - 1) + arr[n - 1]);
//	printf("solve(%d, %d) = %lld\n", n, k, ans);
	return optTake[make_pair(n, k)] = ans;
}

int main() {
	int n; scanf("%d", &n);
	arr = vector<ll>(n);
	for (int i = 0; i < n; ++i) scanf("%lld", &arr[i]);
	printf("%lld\n", solve(n, n/2));
	return 0;
}


Measured memory_bytes: 29844
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>

#define CH(N,A,B) (A<=N&&N<B)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define RREP(i,a,b) for(int i=(b-1);a<=i;i--)

using namespace std;

int N, M, a, b, ans = 0;
bool graph[9][9], visit[9];

void dfs(int node){
  int cnt = 0;
  REP(i,1,N+1) if(visit[i]) cnt++;
  if(cnt == N-1){
    ans++;
    return;
  }
  if(visit[node]) return;
  visit[node] = true;
  REP(i,1,N+1){
    if(graph[node][i] && !visit[i]) dfs(i);
  }
  visit[node] = false;
  return;
}

int main() {

  REP(i,0,N+1)REP(j,0,N+1) graph[i][j] = false;
  REP(i,0,N+1) visit[i] = false;

  cin>>N>>M;
  REP(i,0,M){
    cin>>a>>b;
    graph[a][b] = true;
    graph[b][a] = true;
  }

  dfs(1);
  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 256
#include <set>
#include <map>
#include <queue>
#include <ctime>
#include <cmath>
#include <cstdio>
#include <bitset>
#include <vector>
#include <cstring>
#include <cassert>
#include <iostream>
#include <algorithm>
using namespace std;
typedef double db;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pa;
typedef unsigned int uint;
typedef unsigned long long ull;
#define w1 first
#define ls (x<<1)
#define w2 second
#define ins insert
#define rs (x<<1|1) 
#define mp make_pair
#define pb push_back
#define mid ((l+r)>>1)
#define sqr(x) ((x)*(x))
#define cle(x) ((x).clear())
#define lowbit(x) ((x)&(-x))
#define SZ(x) (int((x).size()))
#define ms(x,y) memset(x,y,sizeof (x))
#define rep(i,a,b) for(int (i)=(a);(i)<=(b);(i)++)
#define rep2(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define per(i,a,b) for(int (i)=(a);(i)>=(b);(i)--)
#define Rep(p,x) for(int (p)=head[(x)];(p);(p)=nxt[(p)]) 
#define Rep2(p,x) for(int (p)=cur[(x)];(p);(p)=nxt[(p)])
#define debegin printf("debug\nbegin\n")
#define deend printf("debug\nend\n")
#define isfind printf("find\n")
template<class T>inline void rread(T&num){
	num=0;T f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9')num=num*10+ch-'0',ch=getchar();
	num*=f;
}
inline int getgcd(int x,int y){if(!x)return y;return getgcd(y%x,x);}
inline int power(int x,int k,int p){int res=1;for(;k;k>>=1,x=(ll)x*x%p)if(k&1)res=(ll)res*x%p;return res;}
const double pi=acos(-1);
inline void judge(){
	freopen("input.txt","r",stdin);
} 
//********************************head*************************************
ll A,B;
inline ll calc(ll A,ll B,int w){
	if(w<0)return 1;
	if((A>>w&1)==(B>>w&1)){
		if(A>>w&1)A^=(1ll<<w),B^=(1ll<<w);
		return calc(A,B,w-1);
	}
	int maxw=-1;
	per(i,w-1,0)if(B>>i&1){
		maxw=i;
		break;
	}
	maxw++;
	ll l1=A,r1=(1ll<<w)-1;
	ll l2=0,r2=(B|((1ll<<maxw)-1))-(1ll<<w);
	ll tmp=0;
	if(r2>=l1)tmp=r1-l2+1;
	else tmp=r1-l1+1+r2-l2+1;
	return (1ll<<w)-A+tmp;
}
int main(){
	rread(A);rread(B);
	printf("%lld\n",calc(A,B,59));
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int x = sc.nextInt();
        if (x < a) {
            System.out.println("NO");
        } else if (a + b < x) {
            System.out.println("NO");
        } else {
            System.out.println("YES");
        }
    }
}


Measured memory_bytes: 21716
#include <cstdio>

int main(){
  int n, k, sum=0;
  int x[100];
  scanf("%d",&n);
  scanf("%d",&k);
  for(int i =0; i < n;i++){
    scanf("%d", &x[i]);
  }
  for(int i=0; i < n;i++){
  if(x[i] > k - x[i]){
    sum += (2 * (k-x[i]));
  }else{
    sum += 2*x[i];
  }

  }

  printf("%d", sum);


  return 0;


}

Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>

using namespace std;

int main(){
    string s;
    int k;
    cin >> s >> k;
    vector<string> a(k, "zzzzz");
    for(int i = 0; i < s.size(); i++){
        for(int j = 1; i + j - 1 < s.size() && j <= k; j++){
            string tmp = s.substr(i, j);
            if(tmp < a[k - 1]){
                bool f = true;
                for(int z = 0; z < k - 1; z++){
                    if(tmp == a[z]){
                        f = false;
                        break;
                    }
                }
                if(f){
                        a[k - 1] = tmp;
                        sort(a.begin(), a.end());
                }
            }
        }
    }
    cout << a[k - 1] << endl;
    return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include  <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
#include<math.h>
#include<iomanip>
#include<stdio.h>
#include <stdlib.h>
#include<stdio.h>
#include <queue>
#include<map>
#include <sstream>
#include<set>
#include<stack>
#include<time.h>
typedef long long int ll;
//#include<bits/stdc++.h>


using namespace std;



int main()
{

    int n;
    cin >> n;

    int a = n / 2;
    if (n % 2)a++;
    cout << a << endl;


    return 0;

}

Measured memory_bytes: 3628
#include <iostream>
#include <string>
#include <set>
#include <algorithm>
using namespace std;
set<pair<string,int> >RB;set<pair<string,int> >::iterator it,ot;string T;int N;
int main() {
    while (cin>>T>>N) {RB.insert(make_pair(T,N));} it=ot=RB.begin();cout<<(it->first)<<endl<<(it->second);it++;
    while (it!=RB.end()) {if ((ot->first)==(it->first)) cout<<" "<<(it->second); else cout<<endl<<(it->first)<<endl<<(it->second);it++,ot++;}
    cout<<endl;return 0;}

Measured memory_bytes: 1228
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define rep(i,n) for(int i=0;i<n;i++)
#define mod 1000000007 // 10^9+7
#define INF 99999999999 //10^12-1
#define dev 998244353 //tenka1
#define P pair<int,int>
#define F first
#define S second

signed main(){
    int s;
    cin>>s;
    cout<<"0 0 1000000000 1 ";
    int x=(s+999999999)/1000000000,y=1000000000-(s%1000000000);
    if(y==1000000000)y=0;
    cout<<y<<" "<<x<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define all(x) (x).begin(), (x).end()
using ll = long long;
using namespace std;
template <typename T> using vec = std::vector<T>;

int main() {
    ll H, W, M;
    cin >> H >> W >> M;

    ll maxh = 0;
    ll maxw = 0;
    set<pair<int, int>> st;

    vec<ll> h(M), w(M), hb(H), wb(W);
    rep(i, M) {
        cin >> h[i] >> w[i];
        --h[i], --w[i];
        ++hb[h[i]], ++wb[w[i]];
        maxh = max(maxh, hb[h[i]]);
        maxw = max(maxw, wb[w[i]]);
        st.insert({h[i], w[i]});
    }
    vec<ll> maxhs, maxws;
    rep(i, H) if (hb[i] == maxh) maxhs.push_back(i);
    rep(i, W) if (wb[i] == maxw) maxws.push_back(i);
    for (auto e : maxhs) {
        for (auto j : maxws) {
            if (st.count({e, j}) == 0) {
                cout << maxh + maxw << endl;
                return 0;
            }
        }
    }
    cout << maxh + maxw - 1 << endl;
}


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

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  if(A+B > C+D){
    cout << "Left" << endl;
  }
  else if(A+B < C+D){
    cout << "Right" << endl;
  }
  else if(A+B == C+D){
    cout << "Balanced" << endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<vector>
#include<algorithm>
#include<string.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
long long int mod=1e9+7;
bool debug=false;
typedef long long int lint;
int main(){
  int n;
  cin>>n;
  vector<string> s(n);
  rep(i,n)cin>>s[i];
  sort(s.begin(),s.end());
  //rep(i,n)cout<<s[i]<<endl;
  vector<int>a(n);
  string now ="";
  int cnt = 1;
  int max = 1;
  rep(i,n){
    if(now==s[i]){
      cnt++;
      a[i]=cnt;
      if (max<cnt)max=cnt;
    }else{
      now=s[i];
      cnt=1;
      a[i]=cnt;
    }
  }
  rep(i,n){
    if(max==a[i]){
      cout<<s[i]<<endl;
    }
  }
  return 0;
}


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

//?????????
#pragma region MACRO 
#define putans(x)  std::cerr << "[ answer ]: " ; cout << (x) << endl
#define dputans(x) std::cerr << "[ answer ]: "; cout << setprecision(27) << (double)(x) << endl
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define RREP(i,a,n) for(int i=(int)(n-1); i>= a; i--)
#define rep(i,n) REP(i,0,n)
#define rrep(i,n) RREP(i,0,n)
#define all(a) begin((a)),end((a))
#define mp make_pair
#define exist(container, n) ((container).find((n)) != (container).end())
#define equals(a,b) (fabs((a)-(b)) < EPS)
#ifdef _DEBUG //???????????????????????????????????????????????????
std::ifstream ifs("data.txt");
#define put ifs >>
#else //?????£????????????????????§?????????????????????
#define put cin >>
#endif
#pragma endregion
//???????????°??????????????´
#pragma region CODING_SUPPORT
#ifdef _DEBUG
#define dbg(var0) { std::cerr << ( #var0 ) << "=" << ( var0 ) << endl; }
#define dbg2(var0, var1) { std::cerr << ( #var0 ) << "=" << ( var0 ) << ", "; dbg(var1); }
#define dbg3(var0, var1, var2) { std::cerr << ( #var0 ) << "=" << ( var0 ) << ", "; dbg2(var1, var2); }
#define dbgArray(a,n) {std::cerr << (#a) << "=";  rep(i,n){std::cerr <<(a[i])<<",";} cerr<<endl;} 
#else
#define dbg(var0) {}
#define dbg2(var0, var1) {}
#define dbg3(var0, var1, var2) {}
#define dbgArray(a,n) {}
#endif 
#pragma endregion 
//typedef????????????????????????????¶????????????§?????????
#pragma region TYPE_DEF
typedef long long ll;
typedef pair<int, int> pii; typedef pair<string, string> pss; typedef pair<int, string>pis;
typedef vector<string> vs; typedef vector<int> vi;
#pragma endregion
//??????????????°(???????????????????????§??????)
#pragma region CONST_VAL
#define PI (2*acos(0.0))
#define EPS (1e-10)
#define MOD (ll)(1e9 + 7)
#define INF (ll)(2*1e9)
#pragma endregion

int main() {
	int N; put N;
	int W; put W;
	int dp[101][10001];
	vi v; v.resize(N);
	vi w; w.resize(N);
	rep(i, N) {
		put v[i]; put w[i];
	}
	fill(*dp, *dp + 101 * 10001, -INF);
	dp[0][0] = 0;
	REP(i,0, N) {
		REP(j,0,w[i]) {
			dp[i+1][j] = dp[i][j];
		}
		REP(j,w[i], W+1) {
			dp[i+1][j] = max(dp[i][j], dp[i+1][j-w[i]] + v[i]);
		}
	}
	int ans = 0;
	rep(i, W+1) {
		ans = max(ans,dp[N][i]);
	}
	cout << ans << endl;
END:
	return 0;
}

Measured memory_bytes: 7040
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author toshibablack
 */

#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstring>
#include <fstream>
#include <functional>
#include <iostream>
#include <iomanip>
#include <iterator>
#include <memory>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

#define ll long long int
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define REP(i, n) for(int i=0;i<n;++i)
#define FOREACH(x, a) for(auto& (x) : (a))
#define ALL(a) (a).begin(),(a).end()
#define COUT(x) out << (x) << endl;
#define M0(x) memset(x,0,sizeof(x))
#define MINF(x) memset(x,0x3f,sizeof(x))
#define MMINUS(a) memset(a,0xff,sizeof(a))

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

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

int gcd(int a,int b){return b?gcd(b,a%b):a;}

using namespace std;

class CDivideTheProblems {
public:
    ll N;
    ll d[200000]{0};

    void solve(std::istream& in, std::ostream& out) {
        in >> N;
        REP(i, N) in >> d[i];
        sort(d, d+N);
        COUT(d[N/2] - d[N/2-1]);
    }
};


int main() {
    CDivideTheProblems solver;
    std::istream& in(std::cin);
    std::ostream& out(std::cout);
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 1792
//Author - Rahil Malhotra
#include <bits/stdc++.h>
using namespace std;
 
template <typename T> void print(T t) { cout<<t<<endl; }
template<typename T, typename... Args> void print(T t, Args... args) { cout<<t<<" "; print(args...); }
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl '\n'
#define int long long
#define double long double

int sieve[55556];
vector<int>v;
int32_t main() {
    IOS;
    int n;
    cin>>n;
    for(int i=2;i<=55555;i++)
    {
        if(!sieve[i])
            for(int j=1;i*j<=55555;j++)
                sieve[i*j]=i;
    }
    for(int i=2;i<=55555;i++)
        if(sieve[i]==i)
            v.push_back(i);
    vector<int>ans;
    for(int i=0;;i++)
    {
        if(ans.size()==n)
            break;
        if(v[i]%5 == 1)
            ans.push_back(v[i]);
    }
    for(int i:ans)
        cout<<i<<" "; 
}   



Measured memory_bytes: 4188
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
using namespace std;

int a, b, c;
int main()
{
	while(scanf("%d %d %d", &a, &b, &c) != EOF)
	{
		int x = a * 100 + b * 10 + c;
		if(x % 4 == 0) printf("YES\n");
		else printf("NO\n");
	}
	return 0;
}

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

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

	int x = 0;
	int max = 0;
	for(int i=0; i<s.length(); i++){
		if(s.at(i) == 'I') x++;
		else x--;
		if(x>max) max = x;
	}

	cout << max << endl;

	return 0;
}

Measured memory_bytes: 256
s = list(input())
t = list(input())

def eq(s, t):
    for i in range(len(s)):
        if s[i] != t[i] and s[i] != '?':
            return False
    return True

for i in reversed(range(len(s) - len(t)+1)):
    if eq(s[i:i+len(t)], t[:]):
        s[i:i + len(t)] = t[:]
        ans = ''.join(s)
        print(ans.replace('?', 'a'))
        quit()
print('UNRESTORABLE')

Measured memory_bytes: 3064
N,M = [int(x) for x in input().split()]
li = [0]*N
for _ in range(M):
    a,b = [int(x)-1 for x in input().split()]
    li[a]+=1
    li[b]+=1
for l in li[1:]:
    if(l%2!=0):
        print('NO')
        break
else:
    print('YES')
    


Measured memory_bytes: 46680
N,A,B,C=map(int,input().split())
l=[int(input()) for _ in range(N)]
INF=10**9

def dfs(cur,a,b,c):
  if cur==N:
    if min(a,b,c)>0:
      return abs(a-A)+abs(b-B)+abs(c-C)-30
    else:
      return INF
  ret0=dfs(cur+1,a+l[cur],b,c)+10
  ret1=dfs(cur+1,a,b+l[cur],c)+10
  ret2=dfs(cur+1,a,b,c+l[cur])+10
  ret3=dfs(cur+1,a,b,c)
  return min(ret0,ret1,ret2,ret3)

print(dfs(0,0,0,0))

Measured memory_bytes: 3064
use strict;
use warnings;

sub main {
    my ($sx, $sy, $tx, $ty) = split(/ /,<STDIN>);
    print solve($sx, $sy, $tx, $ty);
}

main() unless caller;

sub solve {
    my ($sx, $sy, $tx, $ty) = @_;
    my $dx = $tx-$sx;
    my $dy = $ty-$sy;
    my $ans = 'U' x $dy;
    $ans .= 'R' x $dx;
    $ans .= 'D' x $dy;
    $ans .= 'L' x $dx;
    $ans .= 'L';
    $ans .= 'U' x ($dy+1);
    $ans .= 'R' x ($dx+1);
    $ans .= 'D' . 'R';
    $ans .= 'D' x ($dy+1);
    $ans .= 'L' x ($dx+1);
    $ans .= 'U';
    return $ans;
}

Measured memory_bytes: 768
#include<bits/stdc++.h>
#define llenar(a,val)   memset(a,val,sizeof(a))
#define pb          push_back 
#define endl        "\n"
#define mostrar(x,y) cout<<x<<" "<<y<<endl;
#define f           first
#define s           second
#define mod         1000000007
#define EPS         1e-9
using namespace std;
typedef pair<int,int> ii;
typedef pair<pair<int,int>,int> iii;
typedef vector<int> vi;
typedef vector<pair<int,int>> vii;
typedef long long ll;
typedef vector< pair<pair<int,int>,int> > viii;

char a[1000][1000];

int main(){
    ofstream out("output.txt");
    

    int n,k,q;
    cin>>n>>k>>q;
    int a[n];
    for(int i =0;i<n;i++)a[i]=k;

    int x;
    for(int i=0;i<q;i++){
        cin>>x;
        a[x-1]++;
    }
    for(int i =0;i<n;i++){
        if(a[i]>q) cout<<"Yes\n";
        else       cout<<"No\n";
    }
    
    return 0;
}

 
 







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

using namespace std;
typedef long long int lld;
typedef pair<int,int> pii;

int main(){
  int h,w;
  cin>>h>>w;
  char grid[h][w];
  queue<pii> q;
  int dist[h][w];
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      cin>>grid[i][j];
      dist[i][j]=-1;
      if(grid[i][j]=='#'){
	dist[i][j]=0;
	q.push(pii(i,j));
      }
    }
  }
  int ans=0;
  while(!q.empty()){
    
    pii p=q.front();q.pop();
    //cout<<p.first<<" "<<p.second<<" "<<dist[p.first][p.second]<<endl;
    ans=dist[p.first][p.second];
    if(p.first>0 && dist[p.first-1][p.second]==-1){
      dist[p.first-1][p.second]=dist[p.first][p.second]+1;
      q.push(pii(p.first-1,p.second));
    }
    if(p.first<h-1 && dist[p.first+1][p.second]==-1){
      dist[p.first+1][p.second]=dist[p.first][p.second]+1;
      q.push(pii(p.first+1,p.second));
    }
    if(p.second>0 && dist[p.first][p.second-1]==-1){
      dist[p.first][p.second-1]=dist[p.first][p.second]+1;
      q.push(pii(p.first,p.second-1));
    }
    if(p.second<w-1 && dist[p.first][p.second+1]==-1){
      dist[p.first][p.second+1]=dist[p.first][p.second]+1;
      q.push(pii(p.first,p.second+1));
    }
  }cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 13328
import java.util.*;

class Main
{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = Integer.parseInt(sc.next());
		String s = sc.next();
		
		int sum = 0;
		
		Integer[] ary = new Integer[n];
		
		for(int i = 0; i < n; ++i) {
		    if(s.charAt(i) == 'I') {
		        int tmp = 1;
                sum += tmp;
		        ary[i] = sum;
		    }
		    else {
		        int tmp = -1;
                sum += tmp;
		        ary[i] = sum;
		    }
		}
		
		Arrays.sort(ary);
        //System.out.println(Arrays.toString(ary));
        
        if(ary[n-1] <= 0) System.out.println("0");
		else System.out.println(ary[n-1]);
		
	}
}

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

int main() {

  int W,H,x,y,r;

  cin >> W >> H >> x >> y >> r;

  bool isOverLineW = false;
  bool isOverLineH = false;
  if(x+r > W || x < 0)
    isOverLineW = true;
  if(y+r > H || y < 0)
    isOverLineH = true;

  if(isOverLineW || isOverLineH){
    cout << "No" << endl;
  } else {
    cout << "Yes" << endl;
  }
}

Measured memory_bytes: 1160
#include<stdio.h>
int main(){
  int a,b,c;
  scanf("%d%d",&a,&b);
  if(a>b){c=a,a=b,b=c;}
  while(b>0){
    c=a%b;
    a=b;
    b=c;
  }
  printf("%d\n",a);
  return 0;
}



Measured memory_bytes: 2108
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

bool comp(int a, int b){
    return(a < b);
}

int main(int argc, char const *argv[])
{
    int N, K;
    cin >> N >> K;
    vector<int> h;
    int tmp;
    for (int i = 0; i < N; i++)
    {
        cin >> tmp;
        h.emplace_back(tmp);
    }
    
    sort(h.begin(), h.end(), comp);
    int min = 1000000000;
    int d;
    for (int i = 0; i <= N - K; i++)
    {
        d = h[i + K - 1] - h[i];
        if (d < min)
        {
            min = d;
        }
        
    }
    
    cout << min << endl;

    return 0;
}

Measured memory_bytes: 892
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define pb push_back
#define f(i,x,n) for(int i=x;i<n;i++)
#define all(c) c.begin(),c.end()
#define int ll
using ll = long long;
using pii = pair<int,int>;
const int MOD = 1e9+7, N = 1e5 + 10; 

int32_t main(){
   ios::sync_with_stdio(false);
   cin.tie(NULL);
   int a,b,c;
   cin >> a >> b >> c;

   if(4*a*b < (c-a-b)*(c-a-b) and a<c and b<c){
      cout << "Yes\n";
   }else{
      cout << "No\n";
   }
   return 0;
} 

Measured memory_bytes: 256
#include <algorithm>
// #include <cstdlib>
#include <cstring>
#include <cstdio>
#include <string>
#include <queue>
#include <cmath>
#include <set>
#include <map>
#include <bitset>
using namespace std;
typedef long long LL;
typedef double db;
const int oo=2139063143;
const int N=1010000;
const int P=1000000007;
const db eps=1e-7;
#define pritnf printf
//char buf[1<<22],*p1=buf,*p2=buf,obuf[1<<22],*O=obuf;
//#define getchar() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++)
template <typename T>
inline void sc (T &x)
{
    x=0; static int p; p=1; static char c; c=getchar();
    while (!isdigit(c)) { if (c=='-') p=-1; c=getchar(); }
    while ( isdigit(c)) { x=(x<<1)+(x<<3)+(c-48); c=getchar(); }
    x*=p;
}
template <typename T>
inline void print (T x)
{
    if (x< 0) putchar('-'),x=-x;
    if (x>=10) print(x/10);
    putchar(x%10+'0');
}
template <typename T>
inline void pr (T x) { print(x),putchar('\n'); }
template <typename T1,typename T2>
void chkmax (T1 &A,T2 B) { A=A>=B?A:B; }
template <typename T1,typename T2>
void chkmin (T1 &A,T2 B) { A=A<=B?A:B; }
int n,s,w[N]; LL a[N];
LL solve (int l,int r,int t)
{
	if (w[l]> s||w[r]< s) return max (abs (s-w[l]),abs (s-w[r]));
	if (a[l]>=a[r]) return a[l]+=a[r],a[r]=0,solve (l,r-1,l)+(t==r?w[r]-w[l]:0);
	return a[r]+=a[l],a[l]=0,solve (l+1,r,r)+(t==l?w[r]-w[l]:0);
}

int main ()
{
    // freopen (".in","r",stdin);
    // freopen (".out","w",stdout);
	sc(n),sc(s);
	for (int i=1; i<=n; i++)
		sc(w[i]),sc(a[i]);
	pr(solve (1,n,a[1]>=a[n]?n:1));

    return 0;
}


Measured memory_bytes: 8960
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()
using ll = long long;
const ll mod = 1000000007;
const ll INF = 100000000000000000LL;
signed main(){
    string s;
    cin>>s;
    rep(i,s.length()){
        if(i%2==0)cout<<s[i];
    }
    cout<<endl;
}

Measured memory_bytes: 512
using System;
class p
{
  static void Main()
  {
    string s = Console.ReadLine();
    string result = string.Empty;
    for (int i = 0; i < s.Length; i++) {
      if (s[i] == '0') {
        result += '0';
      } else if (s[i] == '1') {
        result += '1';
      } else {
        if (0 < result.Length) {
          result = result.Remove(result.Length - 1, 1);
        }
      }
    }
    Console.WriteLine(result);
  }
}

Measured memory_bytes: 11092
//fifer a tak luboin
#include <bits/stdc++.h>

#define ll long long
#define mp make_pair
#define pb push_back
#define s second
#define f first

using namespace std;

const int inf = (int)1e9;
const int mod = (int)1e9 + 7;
const int N = (int)100100;
const double eps = 1e-10;
const double pi = acos(-1.0);

ll a[N];
int main(){
		ll n, x;
		cin >> n >>  x;
		for(int i = 1; i <= n; i++){
			cin >> a[i];
		}
		sort(a, a + n + 1);
		ll ans = 0;		
		for(int i = 1; i <= n - 1; i++){
			if(a[i] <= x){
				x -= a[i];
				ans++;	
			}
		}
		if(a[n] == x) ans++;
		cout << ans;

return 0;}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b;
	cin>>a>>b;
	int x,y,z;
	x=a+b;
	y=a-b;
	z=a*b;
	int _max;
	_max=max(x,max(y,z));
	cout<<_max<<endl;
	return 0;
} 

Measured memory_bytes: 256
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        n: i32,
        a: [i64; n],
    }

    const MOD: i64 = 1000000007;
    let mut ans: i64 = 0;
    let mut sum: i64 = a[0];
    for i in 1..n {
        ans += a[i as usize] * sum;
        ans %= MOD;
        sum += a[i as usize];
        sum %= MOD;
    }
    println!("{}", ans);
}


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

int main(){
    int n,l;
    cin >> n>>l;
    vector<string> s(n);
    for(int i=0;i<n;i++){
        cin >> s[i];
    }
    sort(s.begin(),s.end());
    for(int i=0;i<n;i++){
        cout << s[i];
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
//#include <cstdio>
//#include <iomanip>//"cout<<fixed<<setprecision(n)<<sth<<endl;"
//#include <string>//"reverse(s's it,s's it)"
//#include <functional>//"greater<T>" "sort(a,a+n,greater<int>());""
//#include <cmath>//"abs" "sqrt"
//#include <numeric>//"accumulate(inputit,inputit,init,(optional) object)"
//#include <algorithm>//"lower_bound(it,it,v)" "next_permutation(a,a+n)"
//"reverse(v's it,v's it)"(v: vector)
using namespace std;
#define pb push_back//also for STRING
#define fi first
#define sc second
#define mp make_pair
#define is insert
#define ps push//TMP//stack,(priority) queue,
#define fr front//TMP//queue//for priority, use top().
typedef long long ll;//not necessarily
typedef pair<int,int> pii;
//Add other types in the same way.
const ll M=1000000007;//can be changed
int mod(int a){	return (a+M)%M;	}//M can be a variable
void plmod(ll &a,ll b){	a=(a+b+M)%M;	return;	}
void mnmod(ll &a,ll b){	a=(a-b+M)%M;	return;	}
void mlmod(ll &a,ll b){	a=(a*b)%M;  	return;	}
//Caution! you may need sth larger than "+M"!
void chmax(int &a,int b){	a=max(a,b);	return;	}
void chmin(int &a,int b){	a=min(a,b);	return;	}
//These 2 could be better in long long

int main(){
	int n,m,k;
	set<int> s;
	cin>>n>>m>>k;
	for(int x=0;x<=n;++x) for(int y=0;y<=m;++y){
		s.is(x*m+y*n-2*x*y);
	}
	if(s.find(k)!=s.end()) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}

Measured memory_bytes: 13056
#include <iostream>
#include <regex>

using namespace std;

typedef long long ll;

int main() {
    string S;
    cin >> S;
    auto N = (int)(long)S.size();

    regex re("BC");
    S = regex_replace(S, re, "D");

    ll cnt = 0;
    ll a_cnt = 0;
    for(int i = 0; i < N; i++) {
        if(S[i] == 'A') {
            a_cnt++;
        } else if(S[i] == 'D') {
            cnt += a_cnt;
        } else {
            a_cnt = 0;
        }
    }

    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 776
#include<algorithm>
#include<iostream>
#include<vector>
#include<string>
#include<cstring>
#include<utility>
#include<queue>
#include<map>
#include<cmath>
using namespace std;
#define REP(i, a,b) for(i=a;i<b;i++) 
#define REP1(i,b,a) for(i=b-1;i>=a;i--)
#define output(x) cout<<x<<endl;
#define pb(x) push_back(x);
typedef long long int ll;
typedef pair<int, int> P;
const int INF = 1000000000;
const int MOD = 1000000007;
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };



int main()
{

	ll i,j,k,l,m,flag,cc,sum,N,M,A,B;
	flag = 0;
	sum = 0;
	cin >> N >> A >> B;
	cout <<fmin(A, B) << " " << fmax(A+B-N,0)<< endl;



	return 0;
}





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

int func(int);

int main(){
  int i,cnt = 0,n;
  int *in;
  scanf("%d",&n);
  if(n < 1 || n > 10000){
    exit(4);
  }
  in = (int *)malloc(sizeof(int)*n);
  for(i=0;i<n;i++){
      scanf("%d",&in[i]);
      if(in[i] < 2 || in[i] > 100000000) exit(3);
  }
  for(i=0;i<n;i++){
      if(func(in[i]) == 0) cnt++;
  }
  printf("%d\n",cnt);
  return 0;
}

int func(int n){
  int i;
  for(i=2; i*i<=n; i++) {
    if(n%i == 0 && n != i) {
      return 1;
    }
  }
  return 0;
}



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

using namespace std;
typedef long long ll;




int main(void)
{
    int n;
    cin>>n;
    int arr[n];
    for(int i=0;i<n;i++)
    {
        cin>>arr[i];
    }
    int low=arr[0];

    int ans=1;
    for(int i=1;i<n;i++)
    {
        if(arr[i]<low)
        {
            ans++;
            low=arr[i];
        }
        if(arr[i]<low)
        {
            low=arr[i];
        }
    }
    cout<<ans<<endl;




}




Measured memory_bytes: 4400