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

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define NUM 2520
#define INF (1LL<<62)
#define DEBUG 1
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)
#define TO_STRING(VariableName) # VariableName
#define LOG(x) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<endl;
#define LOG2(x,y) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<endl;
#define LOG3(x,y,z) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;
#define LOG4(w,x,y,z) if(DEBUG)cout<<TO_STRING(w)<<"="<<w<<" "<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;

template<class T>bool chmax(T & a, const T & b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }

void func(long long N, long long K, std::vector<long long> x, std::vector<long long> y){

    vector<lli> xb(N),yb(N);
    REP(i,0,N){
        xb[i]=x[i];
        yb[i]=y[i];
    }

    SORT(xb);
    SORT(yb);

    lli ans =INF;

    REP(i,0,N)REP(j,i+1,N){
        lli x1 = xb[i];
        lli x2 = xb[j];
        REP(k,0,N)REP(l,k+1,N){
            lli y1 = yb[k];
            lli y2 = yb[l];

            lli cnt = 0;
            REP(m,0,N){
                if(x1<=x[m] && x[m]<=x2 && y1<=y[m] && y[m] <= y2)cnt++;
            }
            if(cnt>=K)chmin(ans,(x2-x1)*(y2-y1));
        }
    }

    cout<<ans<<endl;

}

int main(){
    // cout << fixed << setprecision(5);

    long long N;
    scanf("%lld",&N);
    long long K;
    scanf("%lld",&K);
    std::vector<long long> x(N);
    std::vector<long long> y(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&x[i]);
        scanf("%lld",&y[i]);
    }
    func(N, K, std::move(x), std::move(y));
    return 0;
}


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

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

    if (s[k-1] == 'A') s[k-1] = 'a';
    if (s[k-1] == 'B') s[k-1] = 'b';
    if (s[k-1] == 'C') s[k-1] = 'c';

    cout << s << endl;

    return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <limits.h>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string>
#include <vector>
#include <cstdio>
#include <iomanip>
#define ll long long
#define rep2(i,a,b) for(int i=a;i<=b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define rep3(i,a,b) for(int i=a;i>=b;i--)
#define REP(e,v) for(auto e:v)
#define queint queue<int>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>()>
#define pb push_back
#define vec vector<int>
#define vecvec vector<vector<int>>
#define vecll vector<ll>
#define vecvecll vector<vector<ll>>
#define bs binary_search
#define All(c) (c).begin(),(c).end()
#define mp make_pair
using namespace std;
int in(){int x;scanf("%d",&x);return x;}
string stin(){string s;cin>>s;return s;}
ll lin(){ll x;scanf("%lld",&x);return x;}
int main(){
    int n=in(),m=in();
    vec a(n-1);
    rep(i,n-1)a[i]=i+1;
    vector<vector<bool>> bl(n,vector<bool>(n));
    rep(i,m){
        int x=in()-1,y=in()-1;
        bl[y][x]=bl[x][y]=true;
    }
    int ans=0;
    do{
        bool flag=true;
        if(!bl[0][a[0]])flag=false;
        rep(i,n-2)if(!bl[a[i]][a[i+1]])flag=false;
        if(flag)ans++;
    }while(next_permutation(All(a)));
    cout<<ans<<endl;
}


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

int main(void){
	int a,b,c,d;
	
	scanf("%d %d %d %d",&a,&b,&c,&d);
	
	while(1){
		c-=b;
		if(c<=0){
			printf("Yes\n"); break;
		}
		a-=d;
		if(a<=0){
			printf("No\n"); break;
		}
	}
	return 0;
}

Measured memory_bytes: 1664
import java.util.Scanner;

public class Main {
	public static void main(String[] a){
		
		Scanner sc = new Scanner(System.in);
		int mx1 = 0, mx2 = 0, mx3 = 0;
		
		for(int i = 0; i < 10; i ++){
			int mtHeight = sc.nextInt();
			if(mx1 < mtHeight){
				mx3 = mx2;
				mx2 = mx1;
				mx1 = mtHeight;
			}else if(mx2 < mtHeight){
				mx3 = mx2;
				mx2 = mtHeight;
			}else if(mx3 < mtHeight){
				mx3 = mtHeight;
			}
			
			}
		System.out.printf("%d\n%d\n%d\n", mx1, mx2, mx3);
	}
}
	

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

int main(){
  int h,w;
  cin >> h >> w;
  
  string s;
  for (int i; i<w+2; i++){
    s+="#";
  }
  cout << s << endl;
  
  string t;
  for (int i; i<h; i++){
    cin >> t;
    cout << "#" << t << "#" << endl;
  }
  
  cout << s << endl;
}

Measured memory_bytes: 256
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n 
end
def array(size1,init=nil,size2=1) #size2に二次元配列時の最初の要素数、size1に次の配列の大きさ、initに初期値を投げることでその配列を返す
  if size2==1
    return Array.new(size1){init}
  else
    return Array.new(size2){Array.new(size1){init}}
  end
end

N=gets.to_i
D=get_i

ans=0
(N-1).times do|i|
  (i+1).upto(N-1) do|j|
      ans+=(D[i]*D[j])
  end
end
puts ans

Measured memory_bytes: 1788
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
const long long LINF = 1000000000000000018ll;
const int INF = 1000000009;
const int mod = 1000000007;

vector<long long> h;
// x 回の爆発で魔物を殲滅できるか?
bool is_ok(long long x, long long a, long long b, int n) {
  long long need = 0;
  for (int i = 0; i < n; i++) {
    long long remain = h[i] - b*x;
    if (remain > 0) {
      need += (remain + (a-b) - 1) / (a-b);
    }
  }
  return need <= x;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(20) << fixed;
  long long n, a, b; cin >> n >> a >> b;
  h.assign(n, 0);

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

  long long ng = -1, ok = 1e9+9;
  while (abs(ok-ng) > 1) {
    long long mid = (ok + ng) / 2;
    if ( is_ok(mid, a, b, n) ) {
      ok = mid;
    } else {
      ng = mid;
    }
  }
  cout << ok << endl;
  return 0;
}

Measured memory_bytes: 1024
import java.util.*;
public class Main{
    public static void main(String[] args){
	new Main().run();
    }
    Scanner kbd = new Scanner(System.in);

    void run(){
	int sum = 0;
	int x = 0;
	int y = 0;

	while(kbd.hasNext()){
	    sum += kbd.nextInt();
	}

	while(sum>=60){
	    x++;
	    sum -= 60;
	}
	y = sum;

	System.out.println(x+"\n"+y);
    }
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

#define ld long double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

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

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin>>n;
    double t,a; cin>>t>>a;
    double diff = 1e9;
    int ans;
    rep(i,n){
        double h; cin>>h;
        if (abs(a-(t-h*0.006)) < diff){
            ans = i+1;
            diff = abs(a-(t-h*0.006));
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int a = scan.nextInt();
		int work = n % 500;
		if(a >= work) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}


Measured memory_bytes: 21588
#include<stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
 /*
int Sumed(int Num , int min, int max){
  int i;
  for(i=min;i < max;i++){
    
}
*/
 
int main()
{
    long long X, Y;
    int len = 0;
    int i = 1;

  // 整数の入力
    scanf("%lld %lld", &X, &Y);
 // printf("%d\n",N);
  
  while(1){
    long long Xi;
    if(i == 1){
      Xi =X;
    } else {
    Xi = Xi * 2;
    }
//    printf("i:%d X:%lld\n", i, Xi);
    if(Xi > Y){
      break;
    } else {
        len = i;
    }
    i++;
  }
printf("%d\n", len);

/*  
    if((a + b) > (c + d))
    printf("Left\n");
    else if((a + b) == (c + d))
    printf("Balanced\n");
    else
    printf("Right\n");
    return 0;
*/
}


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

int main()
{
    int n;
    cin >> n;
    vector<int> a(n+1);
    for(int i = 0; i < n+1; ++i)
    {
        cin >> a[i];
    }

    int stock = 0;
    long long int ans = 0;
    for(int i = 0; i < n; ++i)
    {
        int t;
        cin >> t;
        if(t+stock >= a[i])
        {
            ans += a[i];
            stock = t - max(0, a[i] - stock);
        }
        else
        {
            ans += t+stock;
            stock = 0;
        }
    }
    ans += min(stock, a[n]);
    cout << ans << endl;
}

Measured memory_bytes: 640
#include<cstdio>
using namespace std;

int main(){
	int n;
	scanf("%d",&n);
	int t=10;
	for(int i=1;i<=5;i++){
		if(n==t){
			printf("10\n");
			return 0;
		}
		t*=10;
	}
	int ans=0;
	while(n){
		ans+=n%10;
		n/=10;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int N =scan.nextInt();
        int[][] mat = new int[N][N];
        for(int i=0;i<N;++i){
            String s = scan.next();
            for(int j=0;j<N;++j)mat[i][j]=s.charAt(j)-'a';
        }
        int ans = 0;
        for(int b=0;b<N;++b){
            boolean ok = true;
            for(int i=0;i<N;++i){
                for(int j=i+1;j<N;++j){
                    if(mat[i][(j-b+N)%N] != mat[j][(i-b+N)%N]){
                        ok=false;
                        break;
                    }
                }
                if(!ok)break;
            }
            if(ok)ans+=N;
        }
        System.out.println(ans);
        
    }
}

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

using namespace std;

int main(void)
{
    int N;
    cin >> N;
    vector<int> vx(N);
    vector<int> x(N);
    for (int i = 0; i < N; i++){
        cin >> vx[i];
        x[i] = vx[i];
    }
    sort(vx.begin(), vx.end());
    int medL = vx[(N-1)/2];
    int medH = vx[N/2];
    double medM = (medL + medH) / 2.0;
    //cout << medL << " " << medH << " " << medM << endl;
    for(int i = 0; i < N; i++){
        if(x[i] < medM){
            cout << medH << endl;
        }else{
            cout << medL << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3712
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define ll long long
using namespace std;
//typedef vector<unsigned int>vec;
//typedef vector<ll>vec;
//typedef vector<vec> mat;

const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int INF = 1000000000;
const ll LINF = 1000000000000000000;//1e18
const ll  MOD = 1000000007;
const double PI = acos(-1.0);
const double EPS = 1e-10;

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; }
//template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};



int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int c[3][3];
    REP(i,3) REP(j,3) cin >> c[i][j];

    REP(a0,101) REP(a1,101) REP(a2,101){
        int b0 = c[0][0] - a0;
        int b1 = c[1][1] - a1;
        int b2 = c[2][2] - a2;
        if(c[0][1] == a0 + b1 && c[0][2] == a0 + b2
             && c[1][0] == a1 + b0 && c[1][2] == a1 + b2
             && c[2][0] == a2 + b0 && c[2][1] == a2 + b1){
                 cout << "Yes" << endl;
                 return 0;
             }
    }
    cout << "No" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>

using namespace std;
int main()
{
    int n;
    cin >> n;
    
    vector<int> numbers;
    int sum = 0;
    for (int i = 0; i < n; i++) {
      int a;
      cin >> a; 
      numbers.push_back(a);
      sum += abs(a);
    }
  
    int S1 = 0;
    int min_index = 0;
    for (int i = 0; i < n; i++) {
      S1 += numbers[i]; 
      if (S1 > (sum / 2)) {
        min_index = i;
        break;
      }
    }
  
    if (abs(S1 - (sum / 2)) > abs(S1 - numbers[min_index] - (sum / 2))) {
       S1 = S1 - numbers[min_index];
    }
    int S2 = 0;
    S2 = sum - S1;

    cout << abs(S1 - S2) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdlib.h>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;
int main(int argc,char** argv){
  int a,b,c,ret;
  cin >> a >> b >> c;
  ret = (b/a > c) ? c : b/a;
  cout << ret << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n, k, s = 0;
    cin >> n >> k;
    int a[n], r = n;
    for (int i = 0; i < n; i++) cin >> a[i];
    sort(a, a + n);
    for (int i = n - 1; i >= 0; i--)
    {
        if (s + a[i] < k) s += a[i];
        else r = i;
    }
    cout << r;
}

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

int main(){
  string s,t;
  cin >>s>>t;
  int s_size, t_size;
  s_size = s.size();
  t_size = t.size();
  if(s_size + 1 == t_size && s==t.substr(0,s_size)){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
}

Measured memory_bytes: 3544
#include<iostream>
#include<string>
#include<vector>
#include<numeric>
#include<algorithm>
#include<cmath>
#include<map>

using namespace std;

int main(){

    int N;
    cin >> N;

    vector<int> d(N);
    int i;
    for(i=0; i<N; i++) cin >> d.at(i);

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

    int half = (N+1) / 2;

    int ans;
    if(d.at(half-1) == d.at(half)) {
        cout << 0 << endl;
        return 0;
    }
    else{
        ans = d.at(half) - d.at(half-1);
    }

    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<cmath>
using namespace std;
void addnumber(string, string);
int counter = 0;
long N;
int main(){
    cin >> N;
    addnumber("", "7");
    addnumber("", "5");
    addnumber("", "3");
    cout << counter << endl;
    return 0;
}

void addnumber(string currentNumber, string nextNumber){
    currentNumber = currentNumber + nextNumber;

    long currentIntNumber = stol(currentNumber);
    if (currentIntNumber > N){
        return;
    }

    bool count753[3];
    for(int i = 0; i < 3; i++){
        count753[i] = false;
    }
    for(int i = 0; i < currentNumber.length(); i++){
        if(currentNumber[i] == '7'){
            count753[0] = true;
        }
        else if(currentNumber[i] == '5'){
            count753[1] = true;
        }
        else if(currentNumber[i] == '3'){
            count753[2] = true;
        }
    }
    bool flag = true;
    for(int i = 0 ; i < 3; i++){
        if(count753[i] == false){
            flag = false;
        }
    } 

    if(flag == true){
        counter++;
    }
    //七五三数ならcount++
    addnumber(currentNumber, "3");
    addnumber(currentNumber, "5");
    addnumber(currentNumber, "7");
    
}

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

#define ll              long long
#define mod             1000000007
#define inf             1e18

int32_t main(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int n, k;
    cin>>n>>k;

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

    int dp[n];
    for(int i=1; i<n; i++)      dp[i] = mod;

    dp[0] = 0;
    int j;

    for(int i=0; i<n; i++){
        for(j=i+1; j<=i+k; j++){
            if(j < n)       dp[j] = min( dp[j], dp[i] + abs(a[i] - a[j]) );
        }
        
    }
    cout<<dp[n-1]<<endl;
    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
typedef long long ll;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#define ios ios_base::sync_with_stdio(0) ; cin.tie(0) ; cout.tie(0)
#define so sizeof
#define pb push_back
#define cl clear() ;
#define vl vector<ll>
#define sz size()
#define len length()
#define emp empty()
#define el endl;cout.flush()
#define be begin()
#define fi first
#define se second
#define br break
#define en end()
#define ro return 0
#define br break
#define eb emplace_back
#define con continue
#define ms(x) memset(x , 0, so x)
#define all(x) (x).be , (x).en
#define acc(x) accumulate((x).be , (x).en , 0ll)
#define forn(i,a,b) for(ll i=a;i<=b;++i)
#define rng_58 mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define vll vector<pair<ll,ll> >
#define pll pair<ll,ll>
#define plll pair<ll,pair<ll,ll>>
#define plvl pair<pair<ll,ll> ,ll>
#define mp make_pair
#define trace3(a,b,c) cerr <<"a is " << a << " b is " << b << " c is " << c << el;
#define trace4(a,b,c,d) cerr <<"a is " << a << " b is " << b << " c is " << c <<" d is " << d << el ;
#define trace5(a,b,c,d,e) cerr <<"a is " << a << " b is " << b << " c is " << c <<" d is " << d << " e is " << e << el;
#define trace6(a,b,c,d,e,f) cerr <<"a is " << a << " b is " << b << " c is " << c <<" d is " << d << " e is " << e << " f is " << f << el ;
vl v[100005];
ll visited[100005];
ll dp[100005];
ll dfs(ll curr , ll par)
{
    visited[curr] = 1 ;
    for(auto &x : v[curr]){
        if(x == par) con ;
        if(visited[x] == 0){
            dfs(x , curr) ;
        }
    }
    ll maxx = 0 ;
    for(auto &x : v[curr]){
        if(x == par) con ;
        else {
            dp[curr] = max(dp[curr] , 1 + dp[x]) ;
        }
    }

}
int main()
{
    ios;
    ll n , m;
    cin >> n >>  m ;
    forn(i , 1 , m ) {
      ll from , to ;
      cin >> from >> to  ;
      v[from].pb(to) ;
    }
    ms(visited);
    ms(dp) ;
    forn(i , 1 , n ){
       if(visited[i] == 0 ){
        dfs(i , -1);
       }
    }
    ll ans = 0 ;
    forn(i , 1 , n ) ans = max(ans , dp[i]);
    cout << ans << el ;
    ro;
}


Measured memory_bytes: 9984
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <sstream>
#include <queue> 
#include <list>
#include <stack>
#include <unordered_map>
#include <algorithm> 
#include <numeric>  
#include <functional>
#include <cassert>
#include <bitset>
#include <cctype>  
#include <iomanip> 
#include <limits>  
#include <regex>
// std::numeric_limits<int>::max(), min()
// std::setprecision(X)
// std::islower(), std::isupper(), std::tolower, std::toupper
// std::accumulate(m.begin(), m.end(), 0LL);
// std::sort(begin(),end()) // 0, 1, 2, 3 ,4 (default, less);
// std::priority_queue<int, vector<int>, less<int>> que; // 4, 3, 2, 1 (defualt, less) : 
// if ( std::regex_match(S, std::regex("(dream|dreamer|erase|eraser)*")) ) std::cout << "YES" << std::endl;

#define rep(i,n)  for(int i = 0; i < (int)(n);    i++)
#define sz(x)     ((int)(x).size())
#define all(x)    (x).begin(),(x).end()

using ll = long long;

ll gcd ( ll a, ll b ) { if ( b == 0 ) return a; else return gcd ( b, a%b ); }
ll lcm ( ll a, ll b ) { return a * b / gcd(a, b); }

int main (void) {
  std::cin.tie(0);  std::ios::sync_with_stdio(false);
  std::string S; std::cin >> S;
  if ( S == "ABC" ) std::cout << "ARC" << std::endl;
  else std::cout << "ABC" << std::endl;
  return 0;
}



Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
ios_base::sync_with_stdio(false);
  cin.tie(NULL);
#ifndef ONLINE_JUDGE
  //freopen("input.txt","r",stdin);
#endif

  int a;
  cin>>a;
  cout<<a+a*a+a*a*a<<endl;
  return 0;
}

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

ll gcd(ll a, ll b) {
	if(!b)	return a;
	return gcd(b, a % b);
}

int main(void) {
	ll a, b;	cin >> a >> b;
	ll g = gcd(a, b);
	int cnt = 1;
	for(ll i = 2; i * i <= g; ++i) if(g % i == 0) {
		while(g % i == 0)	g /= i;
		++cnt;
	}
	if(g != 1)	++cnt;
	cout << cnt;
	return 0;
}

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

int N, K, A[500005], Q, ans[500005], val[500005];
long long maxw[500005];

int main() {
	scanf("%d%d", &N, &K);
	for (int i = 0; i < N; i++) scanf("%d", &A[i]);
	maxw[N] = 0;
	for (int i = N - 1; i >= 0; i--) {
		if ((maxw[i + 1] + 1) * 2 >= A[i] + 1) maxw[i] = A[i] + maxw[i + 1];
		else maxw[i] = maxw[i + 1];
		//printf("%d: %lld\n", i, maxw[i]);
	}
	val[0] = K;
	for (int i = 1; i <= N; i++) {
		K = min(K, abs(K - A[i - 1]));
		val[i] = K;
		//printf("%d: %d\n", i, K);
	}
	scanf("%d", &Q);
	for (int i = 0; i < Q; i++) {
		int x;
		scanf("%d", &x);
		if (maxw[x] >= val[x - 1]) printf("NO\n");
		else printf("YES\n");
	}
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1

ll sq(ll num) { return num*num; }
ll mod_pow(ll x, ll n) {
	if (n == 0)return 1;
	if (n == 1)return x%MOD;
	ll res = sq(mod_pow(x, n / 2));
	res %= MOD;
	if (n % 2 == 1) {
		res *= x;
		res %= MOD;
	}
	return res;
}

ll n;

int main(){
	cin >> n;
	ll a = 0;
	ll b = 0;
	vector<ll> v(n);
	rep(i,n)cin >> v[i];
	sort(ALL(v));
	reverse(ALL(v));
	rep(i,n){
		if(i%2 == 0)a += v[i];
		else b += v[i];
	}
	cout << a - b << endl;
}

Measured memory_bytes: 256
N, K = map(int, input().split())
mod = 10**9+7
n = int(N**0.5)
dp1 = [[0]*(n+1) for _ in range(K)]
dp2 = [[0]*(n+1) for _ in range(K)]
for i in range(1, n+1):
    dp1[0][i] = 1
dp2[0][n] = N//n-n
for i in range(1, n):
    dp2[0][i] = (N//i-N//(i+1))%mod
for i in range(1, K):
    cum = 0
    for j in range(1, n+1):
        dp2[i][j] = ((dp1[i-1][j]+cum)%mod*dp2[0][j])%mod
        cum+=dp1[i-1][j]
        cum%=mod
    for j in range(1, n+1)[::-1]:
        dp1[i][j] = (cum+dp2[i-1][j])%mod
        cum+=dp2[i-1][j]
        cum%=mod
print((sum(dp1[-1])%mod+sum(dp2[-1])%mod)%mod)

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

using namespace std;

int main() {
    int x, y;
    cin >> x >> y;
    cout << "a";
    if(x > y)cout << " > ";
    else if(x == y) cout << " == ";
    else cout<< " < ";
    cout << "b" << endl;
}


Measured memory_bytes: 3108
import operator
import sys
f = sys.stdin

while True:
    n, m, a = map(int, f.readline().split())
    if n == 0:
        break 
    amida = [i for i in range(n + 1)]
    lines = [list(map(int, f.readline().split())) for _ in range(m)]
    lines.sort(key=operator.itemgetter(0))
    for _, p, q in lines:
        amida[p], amida[q] = amida[q], amida[p]
    
    print(amida[a])

Measured memory_bytes: 7040
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define MOD 1000000007

string solve(string s){
  for(int i=0;i<s.length();i++){
    if(s[i]=='?') s[i]='a';
  }
  return s;
}

int main(){
  string s,t,ans;
  cin>>s>>t;
  int S=s.length(), T=t.length();
  bool flag;
  for(int i=S-T;i>=0;i--){
    flag=true;
    for(int j=i;j<i+t.length();j++){
      if(s[j]!=t[j-i] && s[j]!='?'){
        flag=false;
        break;
      }
    }
    if(flag){
      s.replace(i,t.size(),t);
      ans=solve(s);
      break;
    }
  }
  if(flag) cout<<ans<<endl;
  else cout<<"UNRESTORABLE"<<endl;
  return 0;
}


Measured memory_bytes: 256
L, R = map(int, input().split())
a = L % 2019
b = R % 2019
if R - L >= 2019 or a > b:
    print(0)
else:
    s = 2019
    for i in range(a, b+1):
        for j in range(a, b+1):
            if i == j:
                continue
            s = min(s, (i * j)%2019)
    print(s)
    


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const ll MOD=1000000007;

int main() {
  long long N;
  cin>>N;
  vector<ll> a(N-1);
  for(int i=0;i<N-1;i++){
    cin>>a.at(i);
  }
  //sort(a.begin(),a.end());
  vector<ll> ans(N,0);
  for(int i=0;i<N-1;i++){
    ans.at(a.at(i)-1)++;
  }
  for(int i=0;i<N;i++){
    cout<<ans[i]<<endl;
  }
  
}

Measured memory_bytes: 6428
#include <bits/stdc++.h>
using namespace std;
#define db(x) cerr << #x << "=" << x << endl
#define db2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define db3(x, y, z) cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << endl
#define dbv(v) cerr << #v << "="; for (auto x : v) cerr << x << ", "; cerr << endl
#define dba(a, n) cerr << #a << "="; for (int i = 0; i < (n); ++i) cerr << a[i] << ", "; cerr << endl
typedef long long ll;
typedef long double ld;
int main() {
	int n;
	scanf("%d", &n);
	vector<int> L(n), R(n), lefts(n), rights(n);
	for (int i = 0; i < n; ++i) {
		scanf("%d%d", &L[i], &R[i]);
		lefts[i] = rights[i] = i;
	}
	sort(lefts.begin(), lefts.end(), [&](int a, int b) {
		return R[a] < R[b];
	});
	sort(rights.begin(), rights.end(), [&](int a, int b) {
		return L[a] > L[b];
	});
	auto f = [&](bool goingleft) {
		vector<bool> used(n);
		int x = 0, l = 0, r = 0;
		ll ans = 0;
		for (int i = 0; i < n; ++i) {
			if (goingleft) {
				while (used[lefts[l]]) ++l;
				int move = max(0, x - R[lefts[l]]);
				x -= move;
				ans += move;
				used[lefts[l]] = true;
			} else {
				while (used[rights[r]]) ++r;
				int move = max(0, L[rights[r]] - x);
				x += move;
				ans += move;
				used[rights[r]] = true;
			}
			goingleft = !goingleft;
		}
		ans += abs(x);
		return ans;
	};
	ll ans = max(f(true), f(false));
	printf("%lld\n", ans);
}


Measured memory_bytes: 1792
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Abhijeetkns
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        AChangingACharacter solver = new AChangingACharacter();
        solver.solve(1, in, out);
        out.close();
    }

    static class AChangingACharacter {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            int k = in.nextInt();
            String s = in.next();
            s = s.substring(0, k - 1) + s.substring(k - 1, k).toLowerCase() + s.substring(k, s.length());
            out.println(s);
        }

    }
}



Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define R cin>>
#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 INF 1e9
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main(){
    int a[5];
    rep(i, 5) R a[i];
    int k; R k;
    int max = a[0];
    int min = a[0];
    FOR(i, 1, 5) {
        if (max < a[i]){
            max = a[i];
        }
        if (min > a[i]){
            min = a[i];
        }
    }
    int div = max - min;
    if (div <= k) {
        cout << "Yay!" << '\n';
    } else {
        cout << ":(" << '\n';
    }
}


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

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

    int64_t W, H, x, y;
    std::cin >> W >> H >> x >> y;
    long double ans = W * H / 2.0l;
    bool exist = W == x * 2 && H == y * 2;
    std::cout << std::fixed << std::setprecision(10) << ans << " " << exist << std::endl;

}

Measured memory_bytes: 256
n, a, b = gets.chomp.split.map(&:to_i)
arr = []
for i in 1..n
    sum = i.to_s.split("").map(&:to_i).inject(:+)
    arr[sum] = [] if arr[sum].nil?
    arr[sum] << i
end

sum = 0
for i in a..b
    sum += arr[i].inject(:+) if arr[i]
end
puts sum

Measured memory_bytes: 2044
#include<iostream>
#include<stdio.h>
#include<vector>
using namespace std;
int main(){
    int n,x,count=0,ans=0,a,b,c,k,y;
    string s,aa;
    vector<int> v;
        cin>>s;
        char ch[10];
        for(int i=0;i<s.size();i++)ch[i]=s[i];
        for(int i=0;i<s.size();i++){
        if(ch[i]=='0')aa.push_back('0');
        if(ch[i]=='1')aa.push_back('1');
        if(ch[i]=='B'&&aa.size()>0)aa.pop_back();
        }
        cout<<aa<<endl;
}

Measured memory_bytes: 256
N = int(input())
p = tuple(map(float, input().split()))

DP = [[0.0] * (N+1) for i in range(N+1)]

DP[0][0] = 1.0 - p[0]
DP[0][1] = p[0]

for i in range(N - 1):
    for j in range(N + 1):
        if j > i+1:
            break
        else:
            DP[i+1][j] += DP[i][j] * (1 - p[i+1])
            DP[i+1][j + 1] += DP[i][j] * (p[i+1])

Sum = 0.0
for i in range((N+1)//2,N+1):
    Sum += DP[N-1][i]

print(Sum)

Measured memory_bytes: 111708
#include<cstdio>
#include<algorithm>
#include<iostream>
using namespace std;

struct P{
    P(double a, double b){
	x = a;y = b;
    }
    double x, y;
    double det(P a){
	return x * a.y - y * a.x;
    }
    P operator-(P a){
	return P(x - a.x, y - a.y);
    }
};

int main(){
    double xa, ya ,xb, yb, xc, yc, xd, yd;
    while(~scanf("%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf", &xa, &ya, &xb, &yb, &xc, &yc, &xd, &yd)){
	P a = P(xa, ya);
	P b = P(xb, yb);
	P c = P(xc, yc);
	P d = P(xd, yd);
	P ab = b - a;
	P bc = c - b;
	P cd = d - c;
	P da = a - d;
	if((ab.det(bc) <= 0) == (bc.det(cd) <= 0) && (bc.det(cd) <= 0) == (cd.det(da) <= 0) && (cd.det(da) <= 0) == (da.det(ab) <= 0)){
	    cout << "YES" << endl;
	}
	else{
	    cout << "NO" << endl;
	}
    }
}

Measured memory_bytes: 1224
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
#define rep(i, a, n) for (ll i = (a); i < (n); i++)
#define debug(x) cerr << #x << ": " << x << endl;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

int main() {
    ll n;
    cin >> n;
    ll ans;
    cin >> ans;
    rep(i, 1, n) {
        ll t;
        cin >> t;
        ans = (ans/__gcd(ans, t)) * t;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
using namespace std;
using ll = long long;

int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    int n;
    cin >> n;
    vector<double> a(n);
    for(auto & x : a) {
        cin >> x;
    }
    sort(a.begin(), a.end());
    for(int i = 1; i < n; ++i) {
        a[i] = (a[i] + a[i - 1]) / 2;
    }
    cout << setprecision(12) << fixed << a.back() << '\n';
}


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

namespace B_ABC154
{
    class MainClass
    {



        public static void Main(string[] args)
        {
            string s = ReadLine();
            int l = s.Length;
            for(int i = 0;i<l;i++){
                Write("x");
            }
            WriteLine();
        }
    }
}


Measured memory_bytes: 13140
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define rep2(i,s,n) for (int i = s; i < n; ++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define tmax(a,b,c) max(a,max(b,c))
#define tmin(a,b,c) min(a,min(b,c))
#define pb push_back
#define eb emplace_back
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vs vector<string>
#define vc vector<char>
#define vb vector<bool>
#define vp vector<P>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using LP = pair<ll,ll>;
template<class T> istream& operator>>(istream& is,vector<T>& v) { for(T& t:v){is>>t;} return is; }
template<class T> ostream& operator<<(ostream& os,const vector<T>& v) { for(T t:v){os<<t<<" ";} os<<"\n"; return os; }
void Yes(bool b) { cout << (b ? "Yes" : "No") << endl; }
void YES(bool b) { cout << (b ? "YES" : "NO") << endl; }
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 int inf = 1001001001;
const ll linf = 1001001001001001001;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);
    ll a,b,n;
    cin >> a >> b >> n;
    ll l = 0,r = n;
    auto f = [&](ll x) {
        return a*x/b-a*(x/b);
    };
    while(r-l > 2) {
        ll d1 = (l*2+r)/3;
        ll d2 = (l+r*2)/3;
        if(f(d1) <= f(d2)) {
            l = d1;
        } else {
            r = d2;
        }
    }
    ll ans = 0;
    for(ll i = l; i <= r; i++) chmax(ans,f(i));
    cout << ans << endl;
}

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

using namespace std;
typedef long long ll;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n;
  cin >> n;
  ll v[n];
  ll cost[n];
  for(int i=0;i<n;i++)
    cin >> v[i];
  for(int j=0;j<n;j++)
    cin >> cost[j];
  ll ms=0;
  for(int i=0;i<n;i++)
  {
    if(v[i]-cost[i]>=0)
      ms+=v[i]-cost[i];
  }
  cout<<ms<<"\n";
  return 0;
}


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

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);

  int n, a;
  double resultado;
  cin >> n;
  while (cin >> a) resultado += 1/(a+0.0);
  cout << fixed << 1/resultado << '\n';
  return 0;
}


Measured memory_bytes: 256
#pragma region template 2.4
#include <bits/stdc++.h>
using namespace std;
template <typename T>
using pq_asc = priority_queue<T, vector<T>, greater<T>>;
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> ii;
typedef vector<ii> vii;
typedef vector<string> vs;
#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REP1(i, n) for (ll i = 1; i <= (n); ++i)
#define FOR(i, a) for (auto &i : a)
#define CH(f, x, y) x = f(x, y)
#define IN(T, x) \
    T x;         \
    cin >> x;
#define AIN(T, a, n) \
    vector<T> a(n);  \
    FOR(i, a)        \
    cin >> i;
#define A2IN(T1, a, T2, b, n) \
    vector<T1> a(n);          \
    vector<T2> b(n);          \
    REP(i, n)                 \
    cin >> a[i] >> b[i];
#define OUT(x) cout << (x) << endl;
#define FOUT(x) cout << fixed << setprecision(15) << (x) << endl;
#define ALL(a) (a).begin(), (a).end()
#define SORT(a) sort(ALL(a))
#define RSORT(a) \
    SORT(a);     \
    reverse(ALL(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define DUMPA(a)          \
    cout << #a << " = {"; \
    JOUT(ALL(a), ", ", cout) << "}" << endl;

template <typename T>
ostream &JOUT(T s, T e, string sep = " ", ostream &os = cout)
{
    if (s != e)
    {
        os << *s;
        ++s;
    }
    while (s != e)
    {
        os << sep << *s;
        ++s;
    }
    return os;
}

ostream &YES(bool cond, string yes = "Yes", string no = "No", ostream &os = cout)
{
    if (cond)
    {
        os << yes << endl;
    }
    else
    {
        os << no << endl;
    }
    return os;
}

template <typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p)
{
    os << '(' << p.first << ", " << p.second << ')';
    return os;
}

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v)
{
    os << '[';
    JOUT(ALL(v), ", ", os) << ']';
    return os;
}

const ll INF = 1e18;
const ll MOD = 1e9 + 7;
#pragma endregion template

int main()
{
    IN(ll, N);
    IN(ll, K);
    AIN(ll, A, N);
    REP(k, K)
    {
        vi B(N + 1);
        REP(i, N)
        {
            ++B[max(0LL, i - A[i])];
            --B[min(N, i + A[i] + 1)];
        }
        ll acc = 0;
        bool ok = true;
        REP(i, N)
        {
            acc += B[i];
            A[i] = acc;
            ok &= acc == N;
        }
        if (ok)
        {
            break;
        }
    }
    JOUT(ALL(A)) << endl;
}

Measured memory_bytes: 6372
#include<stdio.h>
#include<map>
#include<algorithm>
#include<string.h>
#include<vector>
#include<math.h>
#include<stdlib.h>
#include<set>
#include<ctype.h>
using namespace std;

typedef long long ll;

const int MM = 1000000007;
const int MX = 1005;

ll pw(ll a, ll b){
	ll r = 1;
	while(b){
		if( b&1 ) r = r*a % MM;
		b /= 2; a = a*a % MM;
	}
	return r;
}

struct mat{
	int t[2][2];
	mat operator*(const mat &l){
		mat res;
		for(int i = 0; i < 2; i++){
			for(int j = 0; j < 2; j++){
				res.t[i][j] = 0;
				for(int k = 0; k < 2; k++){
					res.t[i][j] = (res.t[i][j] + (ll)t[i][k] * l.t[k][j]) % MM;
				}
			}
		}
		return res;
	}
};

char D[MX][MX];

ll solve(int H, int W, ll K)
{
	int a = 0, b = 0, c = 0;
	for(int i = 0; i < H; i++) a += D[i][0] == '#' && D[i][W-1] == '#';
	for(int i = 0; i < H; i++){
		for(int j = 0; j+1 < W; j++) b += D[i][j] == '#' && D[i][j+1] == '#';
	}
	for(int i = 0; i < H; i++){
		for(int j = 0; j < W; j++) c += D[i][j] == '#';
	}

	mat A = {{a, b, 0, c}}, R = {{1, 0, 0, 1}};
	ll v = K-1;
	while(v){
		if( v&1 ) R = R*A;
		A = A*A; v /= 2;
	}
	return (pw(c, K-1) - R.t[0][1] + MM) % MM;
}

int main()
{
	int H, W;
	ll K;
	scanf("%d%d%lld", &H, &W, &K);
	for(int i = 0; i < H; i++) scanf("%s", D[i]);
	int ch = 0, a3 = 0;
	for(int i = 0; i < H; i++){
		for(int j = 0; j < W; j++){
			if( D[i][j] == '#' ) a3++;
		}
	}
	for(int i = 0; i < H; i++){
		if( D[i][0] == '#' && D[i][W-1] == '#' ) ch |= 1;
	}
	for(int i = 0; i < W; i++){
		if( D[0][i] == '#' && D[H-1][i] == '#' ) ch |= 2;
	}

	if( ch == 0 ) printf("%lld\n", pw(a3, K-1));
	else if( ch == 3 ) printf("1\n");
	else{
		if( ch == 2 ){
			for(int i = 0; i < max(H, W); i++){
				for(int j = i+1; j < max(H, W); j++) swap(D[i][j], D[j][i]);
			}
			swap(H, W);
		}
		printf("%lld\n", solve(H, W, K));
	}
}


Measured memory_bytes: 1152
#include <iostream>
#include <map>
#include <string>
#include <algorithm>
#include <vector>

#define ll long long

ll Sum(ll x) {
    return x * (x-1) / 2;
}

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

    std::vector<ll> A(N);
    std::map<ll, ll> mp;
    for(ll i=0; i < N; i++) {
        ll x;
        std::cin >> x;
        A[i] = x;
        mp[x]++;
    }

    std::map<ll, ll> result;
    
    ll sum = 0;
    for(auto p : mp) {
        ll num = p.second;
        sum += Sum(num);
    }

    for(auto p : mp) {
        ll a1 = p.first;
        ll a2 = p.second;

        result[a1] = sum + Sum(a2-1) - Sum(a2);
    }

    for(ll i=0; i < N; i++) {
        std::cout << result[A[i]] << std::endl;
    }
}

Measured memory_bytes: 20564
#include<bits/stdc++.h>
#define endl "\n"
#define pb push_back
#define ll long long
#define d1(x)  cerr << #x << "--> " << x << endl
#define d2(x, y)  cerr << #x << "--> " << x << " | " << #y << "--> " << y <<endl
#define d3(x, y,z)  cerr << #x << "--> " << x << " | " << #y << "--> " << y <<" | " << #z << "--> "<< z<< endl
#define vpll vector<pair<ll,ll>>
#define F first
#define S second
#define T ll tt; cin>>tt; while(tt--)
using namespace std;
ll mode=pow(10,9)+7;
bool cmp(pair<long double ,int > x, pair<long double , int> y){ return x.F<y.F && x.S<y.S; }
const ll maxn=1e4+10;
ll __lcm(ll a, ll b){ return (a*b)/__gcd(a,b); }
ll solve(ll n){
	if (n==1) return 1;
	else return 1+2*solve(n/2);
}
int main(){ 
    
//    #ifndef ONLINE_JUDGE
//  		freopen("input.txt", "r", stdin);
//    #endif
    
    ios::sync_with_stdio(0);
    cin.tie(0);
    
	ll h,n;
	cin>>h>>n;
	ll a[n], b[n];
	for (int i=0;i<n;i++){
		cin>>a[i]>>b[i];
	}
	vector<ll> v(h+1);
	v[0]=0;
	v[1]=LLONG_MAX;
	for (int i=0;i<n;i++){
		v[1] = min(v[1], b[i]);
	}
	for (int i=2;i<=h;i++){
		v[i]=v[1]+v[i-1];
		for (int j=0;j<n;j++){
			if (a[j]>=i) v[i]=min(v[i], b[j]);
		}
		for (int j=0;j<n;j++){
			if (i-a[j]>=0) v[i]=min(v[i], v[i-a[j]]+b[j]);
		}
	}
	
	cout<<v[h]<<endl;
    
	return 0;
}

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

int main()
{
    int n, x;

    while(true){
        cin >> n >> x;
        if( n==0 and x==0){
            break;
        }

        int num = 0;
        for(int i=1; i<=n; ++i){
            for(int j=i+1; j<=n; ++j){
                for(int k=j+1; k<=n; ++k){
                    if( (i!=j and j!=k and i!=k ) and (i+j+k==x) ){
                        ++num;
                    }
                }
            }
        }
        cout << num << endl;

    }

    return 0;
}



Measured memory_bytes: 3116
N = int(input())
a = list(map(int, input().split()))
dic = {}

for i in range(N):
    if a[i] not in dic:
        dic[a[i]] = 1
    else:
        dic[a[i]] += 1

values = list(dic.values())
keys = list(dic.keys())

if len(dic.keys()) == 3 and values[0] == values[1] == values[2] and keys[0] ^ keys[1] ^ keys[2] == 0:
    print('Yes')
elif len(dic.keys()) == 2 and 0 in dic and dic[0] * 3 == N:
    print('Yes')
elif len(dic.keys()) == 1 and 0 in dic:
    print('Yes')
else:
    print('No')


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

if B-A<=2:
  print(K+1)
else:
  need_init=A-1
  if need_init>=K:
    print(K+1)
  else:
    K-=need_init
    answer=A
    
    answer+=(B-A)*(K//2)
    if K%2==0:
      print(answer)
    else:
      print(answer+1)

Measured memory_bytes: 9212
#include<bits/stdc++.h>
using namespace std;
const int N=2e5+5;
vector<int>g[N<<1];
int n,m,vis[N<<1];
char s[N];
void dfs(int x)
{
    vis[x]=1;
    for(int i=0;i<g[x].size();i++)
	{
		int v=g[x][i];
        if(vis[v]==0)dfs(v);
        if(vis[v]==1){puts("Yes");exit(0);}
    }
    vis[x]=-1;
}
int main()
{
	scanf("%d%d%s",&n,&m,s+1);
	for(int i=0;i<m;i++)
	{
		int u,v;scanf("%d%d",&u,&v);
		if(s[u]==s[v])g[u].push_back(n+v),g[v].push_back(n+u);
		else g[u+n].push_back(v),g[v+n].push_back(u);
	}
	for(int i=1;i<=n;i++)if(!vis[i])dfs(i);
	puts("No");
	return 0; 
}

Measured memory_bytes: 26624
import numpy as np

H, W, K = map(int,input().split())

board = np.zeros((H, W), dtype=np.uint8)

for h in range(H):
    S = input()
    for w in range(W):
        if S[w] == '#':
            board[h][w] = 1

hlist = board.sum(axis=1)
wlist = board.sum(axis=0)

hbitlist = np.asarray( [ (2**h)*(2**W) for h in range(H) ] )
wbitlist = np.asarray( [  2**w  for w in range(W) ] )

ret = 0
i = 0
loopnum = (2**H)*(2**W)
while True:
    htarget = i & hbitlist
    wtarget = i & wbitlist
    sumnum = 0
    for h in range(H):
            for w in range(W):
                if (htarget[h]==0) and (wtarget[w]==0):
                    sumnum += board[h][w]
    if sumnum == K:
        ret += 1
    i+=1
    if i>=loopnum:
        break

print(ret)

Measured memory_bytes: 27128
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;   
#define ll long long
#define ull unsigned long long
#define ordered_set tree<pair<ll, ll>, null_type, less<pair<ll, ll>>, rb_tree_tag, tree_order_statistics_node_update> 
ll mod=1e9+7;
#define PI 3.1415926535897932385
#define inf 9e18
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
string char_to_str(char c){string tem(1,c);return tem;}
typedef pair<long long, long long> ii;
#define S second
#define F first
ll max(ll a,ll b){if(a>b){return a;}return b;}
ll min(ll a,ll b){if(a<b){return a;}return b;}
#define MAXN 200005
// string to integer stoi() Remember: it takes string not character
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();
 
// To compile--> g++ -std=c++0x -o output one.cpp
// To run--> ./output

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

    ll n,k;
    cin>>n>>k;
    ll a[n+1];
    ll dp[n+1];
    for (int i = 1; i<=n; ++i)
    {
        cin>>a[i];
        dp[i]=INT_MAX;
    }
    dp[0]=0;
    dp[1]=0;
    for (int i=2; i<=n; ++i)
    {
        for (int j = i-1; j>=max(1, i-k); j--)
        {
            dp[i] = min(dp[i], dp[j]+abs(a[i]-a[j]));
        }
    }
    cout<<dp[n];

    return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<stdio.h>
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int main()
{
    int m,f,r;
    

    while(1){

        cin >> m >> f >> r;
        
        if(m == -1 && f == -1 && r == -1){
            break;
        }else if(m == -1 || f == -1){
            cout << "F" << endl;
        }else if(m+f >= 80){
            cout << "A" << endl;
        }else if(m+f >= 65){
            cout << "B" << endl;
        }else if(m+f >= 50){
            cout << "C" << endl;
        }else if(m+f>=30 && r >= 50){
            cout << "C" << endl;
        }else if(m+f>=30){
            cout << "D" << endl;
        }else{
            cout <<"F" << endl;
        }
    }

    


    return 0;

}


Measured memory_bytes: 3092
while 1:
	n, m = map(int,raw_input().split())
	if (n,m) == (0,0):
		break
	num = [0 for i in range(11)]
	for i in range(n):
		d, p = map(int,raw_input().split())
		num[p] += d
	expectation = 0
	for i in range(10):
		if m >= num[10-i]:
			m -= num[10-i]
		else :
			expectation += (num[10-i]-m)*(10-i)
			m = 0
	print expectation 

Measured memory_bytes: 4600
from heapq import heappop, heappush, heapify
import sys
input = lambda: sys.stdin.readline().rstrip()
inpl = lambda: list(map(int,input().split()))

N, M = inpl()
LRC = sorted([inpl() for _ in range(M)])
points = sorted(list({lrc[i] for i in range(2) for lrc in LRC} | {1,N}))
m = 0
dq = [(0,1)]
for i in points:
    while dq and dq[0][1] < i:
        heappop(dq)
    if not dq:
        print(-1)
        break
    d = dq[0][0]
    while m < M and LRC[m][0] == i:
        heappush(dq, (d+LRC[m][2], LRC[m][1]))
        m += 1
else:
    print(d)


Measured memory_bytes: 78680
#include<bits/stdc++.h>
#define int long long 
#define rep(i,x,n) for(int i=x;i<n;i++)
#define reprev(i,n,x) for(int i=n;i>=x;i--)
#define mp(a,b) make_pair(a,b)
#define mod 998244353
#define pb push_back
#define vi vector<int>
#define pi pair<int,int>
#pragma GCC target ("sse4.2")
using namespace std; 
void grayserge()
{
  int n;
  cin>>n;
  int a[n+1],b[n+1],c[n+1];
  for(int i=1;i<=n;i++){
    cin>>a[i]>>b[i]>>c[i];
  }
  int dp[n+1][3];
  for(int i=0;i<3;i++){
    dp[0][i]=0;
  }
  for(int i=1;i<=n;i++){
    dp[i][0]=max(dp[i-1][1],dp[i-1][2])+a[i];
    dp[i][1]=max(dp[i-1][2],dp[i-1][0])+b[i];
    dp[i][2]=max(dp[i-1][0],dp[i-1][1])+c[i];
  }
  cout<<max(max(dp[n][0],dp[n][1]),dp[n][2]);
}
signed main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    int t=1;
    // cin>>t;
    while(t--){
      grayserge();
    }
    cerr<<"time taken: "<<(float)clock()/CLOCKS_PER_SEC<<endl;
  return 0;
}

Measured memory_bytes: 4992
import java.util.Scanner;
 
public class Main {
  public static void main(String[] args){
  Scanner scan = new Scanner(System.in);
   
  int x = scan.nextInt();
  int a = scan.nextInt();
  int b = scan.nextInt();
  scan.close();

  	if(b - a <= 0){
  	System.out.println("delicious");
  	
  	}else if(b - a <= x){
  	System.out.println("safe");
  	
  	}else{
    System.out.println("dangerous");
  	}
  }
}

Measured memory_bytes: 21716