akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstring>
#include <cassert>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cmath>
#include <ctime>
#include <climits>
#include <cassert>
#include <ctime>
#include <bitset>
#include <complex>
using namespace std;

string s[3];

int main() {
  cin >> s[0];
  cin >> s[1];
  cin >> s[2];
  cout << s[0][0] << s[1][1] << s[2][2];

  return 0;
}


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

using namespace std;
#define int long long int
const int INF = 1001001001001001LL;
const int MOD = 1000000007;

signed main(){
    
    int h, w; cin >> h >> w;
    for(int i = 0; i < h; i++){
        string s; cin >> s;
        cout << s << endl << s << endl;
    }

    return 0;
}



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

using namespace std;

int k, n = 4;
int ta;

int main() {
	scanf("%d", &k);
	if (k < 4) {
		printf("%d\n", k);
		for (int i = 0; i < k; i++)
			for (int j = 0; j < k; j++)
				printf("%d%c", j + 1, j == k - 1 ? '\n' : ' ');
		return 0;
	}
	while (n * 2 < k)
		n += 2;
	printf("%d\n", n);
	for (int i = 0; i < n; i++)
		for (int j = 0; j < n; j++) {
			ta = (i + j) % n;
			if (i % 2 == 1 && ta + n < k)
				ta += n;
			printf("%d%c", ta + 1, j == n - 1 ? '\n' : ' ');
		}
	return 0;
}


Measured memory_bytes: 1152
#include<cstdio>
#include<iostream>
using namespace std;
int main(){
  int n,a[101]={},b=0,max=0;
  cin>>n;
  for(int i=1;i<=n;i++){
    cin>>a[i];
    b+=a[i];
  }
  for(int i=1;i<=n;i++){
    for(int j=1;j<=n-1;j++){
      if(a[j]>a[j+1]){
        int tmp;
        tmp=a[j];
        a[j]=a[j+1];
        a[j+1]=tmp;
      }
    }
  }
  int c=0,d=0,e=0;
  for(int i=0;i<=n;i++){
    c+=a[i];
    if((b-c)%10!=0){
      d++;
      break;
    }
    if(a[i]%10==0)e+=a[i];
  }
  if(d==0)printf("%d",b-c);
  else printf("%d",b-c+e);
  return 0;
}


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

signed main() {
	int N, D;
	cin >> N >> D;
	vector<vector<int>> points(N, vector<int>(D));
	for (int n = 0; n < N; ++n) {
		for (int d = 0; d < D; ++d) {
			cin >> points[n][d];
		}
	}
	int ans = 0;
	for (int u = 0; u < N; ++u) {
		for (int v = u+1; v < N; ++v) {
			int sum = 0;
			for (int d = 0; d < D; ++d)
				sum += (points[u][d]-points[v][d])*(points[u][d]-points[v][d]);
			if ((int)round(sqrt(sum))*(int)round(sqrt(sum)) == sum)
				++ans;
		}
	}
	cout << ans << endl;
}

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

using namespace std;

int main()
{
  double n, m, sum = 0;

  scanf("%lf %lf", &n, &m);

  vector<double> a(n);

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

  bool can = true;

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

  if (a[n - m] < sum / (4 * m))
  {
    can = false;
  }

  printf(can ? "Yes" : "No");
}

Measured memory_bytes: 256
#include <stdio.h>
 
using namespace std;
 
int main(){
    int a,b;
    double a_d,b_d;
    scanf("%d %d",&a,&b);
    a_d = static_cast<double>(a);
    b_d = static_cast<double>(b);
    printf("%d %d %.5f\n",a/b,a%b,a_d/b_d);
}


Measured memory_bytes: 2736
#include <iostream>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <algorithm>
using namespace std;
int main(){
    int a, b, c;
    cin >> a >> b >> c;
    if (a >= b && a >= c){
        cout << a*10+b+c << endl;
    } else if (b >= c && b >= a){
            cout << b*10+a+c << endl;
    } else {
        cout << c*10+b+a << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#pragma target("avx")
#pragma optimize("O3")
#include<bits/stdc++.h>
using ll = int_fast64_t;
using P = std::pair<ll,ll>;
using PP = std::pair<ll,P>;
using V = std::vector<ll>;
template<typename T> using pq = std::priority_queue<T>;
template<typename T> using rpq = std::priority_queue<T, std::vector<T>, std::greater<T>>;

#define REP(i,b,e) for(ll i=b; i<e; i++)
#define ALL(vec) vec.begin(),vec.end()
#define PRINT(vec) printf("[ ");for(auto &i:vec)printf("%ld ",i);puts("]");
#define SCAN(vec) for(auto &i:vec)scanf("%ld",&i)
#define fi first
#define se second

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

int main(){
	int a, b, c, d, e, f;
	scanf("%d %d %d %d %d %d", &a, &b, &c, &d, &e, &f);

	bool sugar[3001]={}, water[3001]={};
	sugar[0] = water[0] = true;
	REP(i, 0, 3001){
		if(sugar[i]){
			if(i+c<3001) sugar[i+c] = true;
			if(i+d<3001) sugar[i+d] = true;
		}
		if(water[i]){
			if(i+100*a<3001) water[i+100*a] = true;
			if(i+100*b<3001) water[i+100*b] = true;
		}
	}

	double max = -1;
	P ans;
	REP(i, 0, 3001) REP(j, 0, 3001){
		if(i+j>f) break;
		if(!sugar[i] or !water[j] or j/100*e<i) continue;
		double tmp = 100 * i / (double)(i+j);
		if(tmp>max){
			max = tmp;
			ans = P(i+j, i);
		}
	}
	printf("%ld %ld\n", ans.fi, ans.se);
	return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#define rep(i,n) for(int i=0;i<(n);i++)
typedef long long ll;

using namespace std;
int main() {
	string s;
	cin >> s;
	bool ans = true;
	rep(i, 3) {
		if (s.at(i) == s.at(i + 1)) ans = false;
	}
	if (ans) cout << "Good" << endl;
	else cout << "Bad" << endl;
	return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.StringTokenizer;

public class Main {

    public static void main(String[] args) throws IOException {
        init();
        int n = nextInt();
        boolean approved = true;
        for (int i = 0; i < n; i++) {
            int a = nextInt();
            if (a % 2 == 0 && !(a % 3 == 0 || a % 5 == 0)) {
                approved = false;
                break;
            }
        }

        System.out.println(approved ? "APPROVED" : "DENIED");
    }

    //Input Reader
    private static BufferedReader reader;
    private static StringTokenizer tokenizer;

    private static void init() {
        reader = new BufferedReader(new InputStreamReader(System.in));
        tokenizer = new StringTokenizer("");
    }

    private static String next() throws IOException {
        String read;
        while (!tokenizer.hasMoreTokens()) {
            read = reader.readLine();
            if (read == null || read.equals(""))
                return "-1";
            tokenizer = new StringTokenizer(read);
        }

        return tokenizer.nextToken();
    }

    private static int nextInt() throws IOException {
        return Integer.parseInt(next());
    }

    private static long nextLong() throws IOException {
        return Long.parseLong(next());
    }
}

Measured memory_bytes: 22996
#include <bits/stdc++.h>
//---------------------------
using namespace std;
//---------------------------
#define REP(i,n) for(int i = 0; i < (n); i++)
#define P(x) cout << (x) << "\n"

#define MOD 1e9+7
#define PI acos(-1.0)
//---------------------------

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

  int a,b,c;cin>>a>>b>>c;
  if(a + b>=c){
    P("Yes");
  }else{
    P("No");
  }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define pb push_back
#define all(v) v.begin(),v.end()
#define sort_1(v) sort(v.begin(),v.end())
#define sort_2(v) sort(v.begin(),v.end(),greater<ll>())
#define reverse(v) reverse(v.begin(),v.end())
typedef long long ll;
typedef long double la;
using namespace std;

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

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

int main(){
    int N, A, B;
    cin >> N >> A >> B;
    int price;
    int ans = A * N;

    for(int i=0; i<=N; i++){
        price = i * A + B;
        if(price < ans){
            ans = price;
        }
    }

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

Measured memory_bytes: 256
def expected(num)
    (num + 1).to_f / 2.0
end

n, k = gets.split.map(&:to_i)
dice = gets.split.map(&:to_i)
sums = [0]

dice.each{|d|
    sums.push(expected(d) + sums.last)
}
sums = sums[1..-1]

ans = sums.drop(k).zip(sums).map{|r, l|
    r - l
}.max

if ans == nil
    puts sums.last
else
    puts ans
end

Measured memory_bytes: 28164
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    ll t;
    //cin>>t;
    //while(t--)
    {
      ll i,j,k,l,m,n,a,b,c,cnt=0;
cin>>n>>m;
if(m>=n)
    cout<<"unsafe"<<endl;
else
    cout<<"safe"<<endl;




    }


}


Measured memory_bytes: 3636
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <utility>
using namespace std;
using ll = long long;
 
int main() {
	string s,t,u;
	ll a,b;
	cin >> s >> t;
	cin >> a >> b;
	cin >> u;
	if (u == s) {
		a--;
	} else {
		b--;
	}
	cout << a << " "<< b << endl;
	return 0;
}


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

using namespace std;

using ll = long long;
using db = double;
using vi = vector<int>;
int d[30]; 
ll f[30][2][2];

int main() {
	int D; 
	cin>>D; 
	memset(d, 0, sizeof(d)); 
	int i = 0; 
	while (D>0) {
		d[i] = D % 10; 
		D /= 10; 
		i++; 
	}
	ll ans = 0; 
	for (int len = i-1; len <= 20; ++len) {
		memset(f,0,sizeof(f)); 
		f[0][0][0] = 1; 
		for (int i = 0; i<=len/2; i++) {
			for (int l0 = 0; l0 <= 1; ++l0) 
			for (int r0 = 0; r0 <= 1; ++r0) 
			for (int l1 = 0; l1 <= 1; ++l1) 
			for (int r1 = 0; r1 <= 1; ++r1) 
				for (int x = 0+(i==0); x <= 9; ++x) 
					for (int y = 0; y <= 9; ++y) 
						if (x+d[len-i]+l1==l0*10+y && y+d[i]+r0==r1*10+x) {
							f[i+1][l1][r1] += f[i][l0][r0]; 
							if (i==len/2) {
								if (len % 2 == 0) {
									if (l1==r0 && l0==r1 && x==y) ans += f[i][l0][r0]; 
								}
								else {
									if (l1 == r1) ans += f[i][l0][r0]; 
								}
							}
						}
		}
	}
	cout<<ans<<endl; 
}


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

#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define dump(x)  cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl

using namespace std;

typedef long long LL;

template<typename T>
ostream& operator << (ostream& os, const vector<T>& vec) {
    os << "[";
    REP(i, vec.size()) {
        if (i > 0) cout << ", ";
        os << vec[i];
    }
    os << "]";

    return os;
}

struct Node {
    Node() : id_(-1), parent_(nullptr), left_(nullptr), right_(nullptr){};
    ~Node(){};

    int get_parent() {
        if (!parent_) return -1;

        return parent_->id_;
    }

    int get_left_id() {
        if (!left_) return -1;

        return left_->id_;
    }

    int get_right_id() {
        if (!right_) return -1;

        return right_->id_;
    }

    int get_sibling() {
        if(!parent_) return -1;

        int left = parent_->get_left_id();
        int right = parent_->get_right_id();

        return left == id_ ? right : left;
    }

    int get_degree() {
        int ret = 0;

        if (left_) ++ret;

        if (right_) ++ret;

        return ret;
    }

    int get_depth() {
        if (!parent_) return 0;

        return parent_->get_depth() + 1;
    }

    int get_height() {
        int left_h = -1, right_h = -1;
        if (left_) left_h = left_->get_height();
        if (right_) right_h = right_->get_height();

        return max(left_h, right_h) + 1;
    }

    void show() {
        cout << "node " << id_ << ": ";
        cout << "parent = " << get_parent() << ", ";
        cout << "sibling = " << get_sibling() << ", ";
        cout << "degree = " << get_degree() << ", ";
        cout << "depth = " << get_depth() << ", ";
        cout << "height = " << get_height() << ", ";
        cout << type() << endl;
    }

    string type() {
        if(!parent_) return "root";

        if(!left_ && !right_) return "leaf";

        return "internal node";
    }

    int id_;
    Node *parent_;
    Node *left_;
    Node *right_;
};

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

    int n;
    cin >> n;

    Node T[n];


    REP(i, n) {
        int id, left, right;
        cin >> id >> left >> right;
        T[id].id_ = id;

        if (left > -1) {
            T[left].parent_ = T + id;
            T[id].left_ = T + left;
        }

        if (right > -1) {
            T[right].parent_ = T + id;
            T[id].right_ = T + right;
        }

    }

    REP(i, n) {
        T[i].show();
    }

}


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

using namespace std;

bool solve(int *data)
{
  int i, j, k;
  int stack1[11] = {0};
  int stack2[11] = {0};

  for (i = j = k = 0; i < 10; i++) {
    if (stack1[j] < data[i]) {
      j += 1;
      stack1[j] = data[i];
    }
    else if (stack2[k] < data[i]) {
      k += 1;
      stack2[k] = data[i];
    }
    else {
      return false;
    }
  }
  return true;
}

int main()
{
  int i, j, n;

  cin >> n;

  for (j = 0; j < n; j++) {
    int *data = new int[10];
    for (i = 0; i < 10; i++)
      cin >> data[i];
    if (solve(data))
      cout << "YES" << endl;
    else
      cout << "NO" << endl;
  }

  return 0;
}

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

int main() {
	// your code goes here
	int x;
	cin>>x;
	int arr[3][x];
	for(int i=0;i<x;i++)
	{
		for(int j=0;j<3;j++)
		cin>>arr[j][i];
	}
	int dp[x][3];
	memset(dp,-1,sizeof(dp));
	dp[0][0]=arr[0][0];
	dp[0][1]=arr[1][0];
dp[0][2]=arr[2][0];

	
	for(int i=1;i<x;i++)
	{
		dp[i][0]=arr[0][i]+max(dp[i-1][1],dp[i-1][2]);
		dp[i][1]=arr[1][i]+max(dp[i-1][0],dp[i-1][2]);
		dp[i][2]=arr[2][i]+max(dp[i-1][1],dp[i-1][0]);
		
	}
	cout<<max(dp[x-1][1],max(dp[x-1][0],dp[x-1][2]));
}

Measured memory_bytes: 5936
#include <bits/stdc++.h>
using namespace std;
const int MAXn = 1e5 + 10;

int deg[MAXn], n, m;
int main() {
	cin >> n >> m;
	for (int i = 0; i < m; i++) {
		int u, v;
		cin >> u >> v;
		deg[u]++;
		deg[v]++;
	}
	for (int i = 1; i <= n; i++)
		if (deg[i] % 2) {
			cout << "NO";
			return 0;
		}
	cout << "YES";
	
}

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

int main() {
  int N;
  cin >> N;
  vector A(N, 0), B(N, 0);
  for (auto &a : A) cin >> a;
  for (auto &a : B) cin >> a;

  auto f = [&]() {
    for (int i = N - 1; i >= 0; i--) {
      if (A.at(i) == B.at(i)) return false;
    }
    cout << "Yes" << "\n";
    for (auto ans : B) cout << ans << "\n";
    return true;
  };

  reverse(B.begin(), B.end());
  if (f()) return 0;
  reverse(B.begin(), B.end());

  rotate(B.begin(), B.begin() + (N / 2), B.end());
  if (f()) return 0; 
  cout << "No" << "\n";
}

Measured memory_bytes: 4824
n = int(input())
s = [input() for _ in range(n)]

from collections import Counter
tot = Counter(s[0])
for i in range(1, n):
    c = Counter(s[i])

    for k in tot.keys():
        tot[k] = min(tot[k], c[k])

ans = ''
for k in tot.keys():
    ans += k * tot[k]
print(''.join(sorted(ans)))


Measured memory_bytes: 39280
import java.util.Scanner;

public class Main {

    private Scanner in = new Scanner(System.in);

    void solve() {
        int a = in.nextInt(), b = in.nextInt();
        int ans = 0;
        for(int i = a; i <=b; i++) {
            String s = String.valueOf(i);
            String t = new StringBuilder(s).reverse().toString();
            if(t.equals(s)) {
                ans ++;
            }
        }
        System.out.println(ans);
    }
    public static void main(String[] args) {
        new Main().solve();
    }
}


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

using namespace std;


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

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

    for (int i = n - 1; i >= 0; --i)
    {
        cout << v[i] << (i != 0 ? " " : "");
    }
    
    cout << endl;

    return 0;
} 

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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#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 eb emplace_back

using ll = long long;
using vll = vector<ll>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using P = pair<int, int>;

void Main(){
    int n; cin >> n;
    vi a(3*n);
    priority_queue<int, vector<int>, greater<int>> ql;
    priority_queue<int> qr;
    vll L(n+1, 0), R(n+1, 0);
    
    rep(i, 3*n) {
        cin >> a[i];
        if(i < n) {
            ql.push(a[i]);
            L[0] += a[i];
        }
        else if(i >= 2*n) {
            qr.push(a[i]);
            R[0] += a[i];
        }
    }
    
    rep(i, n){
        L[i+1] = L[i] + a[n+i];
        ql.push(a[n+i]);
        L[i+1] -= ql.top(); 
        ql.pop();
    }
    
    rep(i, n){
        R[i+1] = R[i] + a[2*n-1-i];
        qr.push(a[2*n-1-i]);
        R[i+1] -= qr.top(); 
        qr.pop();
    }
    
    ll ans = -1e18;
    rep(i, n+1){
        ans = max(ans, L[i] - R[n-i]);        
    }

    cout << ans << endl;
    return;
}

int main(){
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}

Measured memory_bytes: 7020
#include <bits/stdc++.h>
using namespace std;
bool prime[1000000];
void SieveOfEratosthenes(int n)
{
    memset(prime, true, sizeof(prime));
    for (int p=2; p*p<=n; p++)
    {
        // If prime[p] is not changed, then it is a prime
        if (prime[p] == true)
        {
            // Update all multiples of p greater than or
            // equal to the square of it
            // numbers which are multiple of p and are
            // less than p^2 are already been marked.
            for (int i=p*p; i<=n; i += p)
                prime[i] = false;
        }
    }

    // Print all prime numbers
    for (int p=2; p<=n; p++){
       if (prime[p]){
          //cout << p << " ";
       }
    }


}

// Driver Program to test above function
int main()
{
    int n = 1000000;
    SieveOfEratosthenes(n);
    int x;
    cin>>x;
    if(prime[x])
    {
        cout<<x<<endl;
    }
    else
    {
        for (int p=x; p<=n; p++){
        if (prime[p]){
          cout << p << " ";
          break;
        }
    }
    }
    return 0;
}


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

int main() {
  int N;
  string s;
  cin >> N >> s;
  int cE = 0;
  for (int i = 0; i < N; i++) {
    if(s[i] == 'E') cE += 1;
  }
  
  int cost = cE;
  int m = cost;
  for (int i = 0; i < N; i++) {
    if (s[i] == 'E') cost -= 1;
    else cost += 1;
    m = min(m,cost);
  }
  cout << m << endl;
}

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

long long cnt;
int A[1000000];
int n;
vector<int> G;

void insertionSort(int A[],int n,int g){
	for(int i=g;i<n;i++){
		int v=A[i];
		int j=i-g;
		while(j>=0 && A[j]>v){
			A[j+g]=A[j];
			j-=g;
			cnt++;
		}
		A[j+g]=v;
	}
}
void shell(int A[],int n){
	for(int i=1;i<=n;i=3*i+1){
		G.push_back(i);
	}
	for(int i=G.size()-1;i>=0;i--){
		insertionSort(A,n,G[i]);
	}
}



int main(){
	int n;
	cin>>n;
	for(int i=0;i<n;i++)
		cin>>A[i];
	cnt=0;
	shell(A,n);
	cout<<G.size()<<endl;
	for(int i=G.size()-1;i>=0;i--){
		cout<<G[i];
		if(i)cout<<" ";
	}
	cout<<endl;
	cout<<cnt<<endl;
	for(int i=0;i<n;i++){
		cout<<A[i]<<endl;
	}
	return 0;
}


Measured memory_bytes: 7032
#include<bits/stdc++.h>
using namespace std;
#define int            int64_t
#define double         long double
#define nitro          ios_base::sync_with_stdio(false);cin.tie(0);
#define vi             vector<int64_t>
#define pub            push_back
#define puf            push_front
#define pob            pop_back
#define pof            pop_front
#define PI             3.1415926535897932384626433832795
#define read(a)        for(auto& x : a) cin>> x
#define endl           '\n'
#define gap            ' '
#define min3(a,b,c)    min(a, min(b, c))
#define max3(a,b,c)    max(a, max(b, c))
#define MOD            1000000007
//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);
int sum(int n)
{
	if(n==0) return 0;
	else return n%10+sum(n/10);
}
int32_t main()
{
    nitro
    int n,a,c=0,b;cin>>n>>a>>b;
    for(int i=1;i<=n;++i)
    if(sum(i)>=a and sum(i)<=b) c+=i;
    cout<<c;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <map>
#include <cstdio>
#include <math.h>
#include <utility>
#include <list>
#include <functional>
using namespace std;

#define ll long long
#define vecint vector<int>
#define Pii pair<int, int>

#define REP(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define print(a) cout << a << endl

#define MOD 1000000007
#define NIL -1

int main(){
  int a,b,c;
  cin>>a>>b>>c;
  if(b-a==c-b){
    print("YES");
  }else{
    print("NO");
  }
  return 0;
}


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

int main() {
    ll a, b;
    cin >> a >> b;
    ll gcd = __gcd(a, b);
    cout << a * b / gcd << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define repone(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define Rep(j,n) for(int j=0;j<(int)(n);++j)
#define Repo(j,o,n) for(int j=o;j<(int)(n);++j)
#define Repone(j,n) for(int j=1;j<(int)(n);++j)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define int long long
#define pb(a) push_back(a)
#define eraser(v,i) (v).erase(v.begin()+(i))
#define pbpair(a,b) push_back(make_pair(a,b))
#define Little 1
const long long INF = 1LL<<60;
#define pairint pair<int,int>
signed main(){
  int x=0,y=0,z=0,w=0,n=0,m=0,o=0;
  char s;
  std::cin >> s;
  if((int)s<'a'){
    std::cout << "A" << '\n';
  }else{
    std::cout << "a" << '\n';
  }

}


Measured memory_bytes: 3592
import java.io.*
import java.util.*

// ans = [p_i][1-p_j]
fun solve(N: Int, p: DoubleArray) {
    // dp[i][j] iまで使って, j枚表になる確率
    // dp[i][j] = dp[i-1][j] * (1-p[i]) + dp[i-1][j-1] * p[i]
    val dp = Array(N){ DoubleArray(N+1) }
    dp[0][0] = 1- p[0]
    dp[0][1] =  p[0]
    for (i in 1 until N){
        for (j in 0..i+1){
            dp[i][j] = dp[i-1][j] * (1-p[i]) + dp[i-1].getOrElse(j-1){ 0.toDouble() } * p[i]
        }
    }
    val ans = dp[N-1].filterIndexed{ index, value -> index > N/2 }.sum()
    println(ans)
    return
}

fun main(args: Array<String>) {
    fun StringArray(size: Int, init: (Int) -> String = { "\u0000" }): Array<String> {
        return Array<String>(size, init)
    }
    class Scanner(stream: InputStream) {
        private val reader = BufferedInputStream(stream).bufferedReader()
        private var st: StringTokenizer? = null
        fun next(): String {
            while (!(st?.hasMoreTokens() ?: false)) st = StringTokenizer(reader.readLine())
            return st!!.nextToken()
        }
    }
    val sc = Scanner(System.`in`)
    val N = sc.next().toInt()
    val p = DoubleArray(N)
    for (i in 0 until N.toInt()) {
        p[i] = sc.next().toDouble()
    }
    solve(N, p)
}


Measured memory_bytes: 114712
#include <iostream>
#include <string>
#include <sstream>
#include <utility>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <cmath>
#include <functional>
#include <chrono>
#include <cstring>
#include <bits/stdc++.h>


using namespace std;
typedef long long lint;
typedef vector<int> vi;
typedef pair<int,int> pii;

typedef vector<lint> vl;
typedef pair<lint,lint> pll;

#define mpr make_pair


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

    int n; cin>>n;

    lint cnt = 0;
    for (int i=0; i<n-1; ++i){
        lint u, v;
        cin>>u>>v;
        if (u > v) swap(u, v);
        cnt += u * (n+1-v);
    }

    lint res = 0;
    for (lint i=1; i<=n; ++i){
        res += i * (n+1-i);
    }
    cout<<res - cnt;

}


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

int main(void)
{
  char a;
  cin>>a;
  switch(a){
    case 'A':cout<<'T'<<endl; break;
    case 'C':cout<<'G'<<endl; break;
    case 'T':cout<<'A'<<endl; break;
    case 'G':cout<<'C'<<endl; break;
  }
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) 
	{
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		String s = sc.next();
//		int n = s.length();
		

		
		long[] mat = new long[n];
		long score = 0;
		
//		System.out.println(Arrays.toString(kmp));
		for(int s1 = 1; s1 < n; s1++)
		{
			//get longest match in substring 0...s1-1
			
			//prepare kmp
			int[] kmp = new int[s.length()-s1];
			{ //for each index of s i, find its longest proper prefix that's also its suffix.
				//"proper" prefix meaning it can't be the whole string s[0...i],
				//which is why for i=0, the length is 0.
				int i = 1, j = 0;
				while(i < s.length()-s1)
				{
//					System.out.println("i = " + i + ", j = " + j);
					if(s.charAt(i+s1) == s.charAt(j+s1))
					{
						kmp[i] = j+1; //i is the length of prefix that's also current suffix
						j++;
						i++;
					}
					else if(j == 0)
					{ //mismatch
						kmp[i] = 0;
						i++;
					}
					else
					{  //mismatch: try again with j rolled back
						//kmp[i] = j+1;
						j = kmp[j-1];
					}
				}
			}					
			
			//begin search
			int j = 0;
			int i = 0;
			int c = 0;
//			System.out.println("START");
			
//			System.out.println("s1 " + s1 + ": " + s.substring(s1));
			while(i < s1)
			{
//				System.out.println(i + " " + j);
				if(s.charAt(i) == s.charAt(j+s1))
				{
					int otherstart = i-j;
					mat[s1] = Math.max(mat[s1], j+1);
//					System.out.println(i + " " + j + " " + s1);
//					System.out.println("match at " + i + " " + (j) + ", otherstart " + otherstart+ ", the match is " + s.substring(otherstart,otherstart+j+1));
					if(j+1>score)
					{
//						System.out.println("match at " + i + " " + (j) + ", otherstart " + otherstart+ ", the match is " + s.substring(otherstart,otherstart+j+1));
					}
					score = Math.max(score, (j+1));
					mat[otherstart] = Math.max(mat[otherstart], j+1);
					if(j+s1 == s.length()-1)
					{ //whole pattern matched
						break;
					}
					else
					{ //letter matched: go to next letter
						i++;
						j++;
					}
				}
				else
				{ //mismatch
					if(j > 0)
					{
						j = kmp[j-1]; 
					}
					//skip some of already-matched letters, rather than restarting with j=0
					else
					{
						j = 0;
						i++;
					}
				}
				
			}			
			
		}
		System.out.println(score);
		

	}

}


Measured memory_bytes: 45916
/* template.cpp {{{ */
#include <bits/stdc++.h>
using namespace std;
#define get_macro(a, b, c, d, name, ...) name
#define rep(...) get_macro(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__)
#define rrep(...) get_macro(__VA_ARGS__, rrep4, rrep3, rrep2, rrep1)(__VA_ARGS__)
#define rep1(n) rep2(i_, n)
#define rep2(i, n) rep3(i, 0, n)
#define rep3(i, a, b) rep4(i, a, b, 1)
#define rep4(i, a, b, s) for (ll i = (a); i < (ll)(b); i += (ll)(s))
#define rrep1(n) rrep2(i_, n)
#define rrep2(i, n) rrep3(i, 0, n)
#define rrep3(i, a, b) rrep4(i, a, b, 1)
#define rrep4(i, a, b, s) for (ll i = (ll)(b) - 1; i >= (ll)(a); i -= (ll)(s))
#define each(x, c) for (auto &&x : c)
#define fs first
#define sc second
#define all(c) begin(c), end(c)
using ui = unsigned;
using ll = long long;
using ul = unsigned long long;
using ld = long double;
const int inf = 1e9 + 10;
const ll inf_ll = 1e18 + 10;
const ll mod = 1e9 + 7;
const ll mod9 = 1e9 + 9;
const int dx[]{-1, 0, 1, 0, -1, 1, 1, -1};
const int dy[]{0, -1, 0, 1, -1, -1, 1, 1};
template<class T, class U> void chmin(T &x, const U &y){ x = min<T>(x, y); }
template<class T, class U> void chmax(T &x, const U &y){ x = max<T>(x, y); }
struct prepare_ { prepare_(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(12); } } prepare__;
/* }}} */

int main(){
  string s, t = "0123456789";
  cin >> s;
  pair<ll, string> res;
  ll tn = 1;
  rep(s.size()) tn *= 10;
  do {
    ll a = stoll(s);
    ll b = stoll(t.substr(0, s.size()));
    //cout << t << endl;
    chmin(res, make_pair(-min(abs(a - b), tn - abs(a - b)), t.substr(0, s.size())));
  } while (next_permutation(all(t)));
  cout << res.second << endl;
}

Measured memory_bytes: 3204
s = input()
if len(s) == 1:
  print(0)
  exit()
l = 0
r = len(s) - 1
cnt = 0
while l < r:
  if s[l] == s[r]:
    l += 1
    r -= 1
  else:
    if s[l] == "x":
      l += 1
      cnt += 1
    elif s[r] == "x":
      r -= 1
      cnt += 1
    else:
      print(-1)
      exit()
print(cnt)

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

int main(){
  int H,N;
  cin>>H>>N;
  vector<int>A(N);
  for(int i=0;i<N;i++){
    cin>>A[i];
  }
  for(int i=0;i<N;i++){
    H-=A[i];
  }
  if(H<=0){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
}

Measured memory_bytes: 640
#include<cstdio>
#include<math.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<set>
#include<cstring>
 
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1001001001
#define LLINF 1001001001001001001
#define mp make_pair
#define LLIandI pair<long long int , int>
#define ll long long



int main(){
    int N,K;
    scanf("%d %d",&N,&K);
    if(N+1<K*2){
        printf("NO\n");
    }else{
        printf("YES\n");
    }
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using pii = pair<int, int>;
const int N = 2e5 + 100;
int n, opt[4];
pii corn[4];

int dist(pii a, pii b) {
	int dx = abs(a.first - b.first);
	int dy = abs(a.second - b.second);
	return dx + dy;
}

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

	cin >> n;

	for (int i = 0;  i < 4; i++) {
		opt[i] = INT_MIN;
	}

	int x, y;
	for (int i = 0; i < n; i++) {
		cin >> x >> y;

		if (x + y > opt[0]) {
			opt[0] = x + y;
			corn[0] = {x, y};
		}
		if (x - y > opt[1]) {
			opt[1] = x - y;
			corn[1] = {x, y};
		}
		if (-x + y > opt[2]) {
			opt[2] = -x + y;
			corn[2] = {x, y};
		}
		if (-x - y > opt[3]) {
			opt[3] = -x - y;
			corn[3] = {x, y};
		}
	}

	int ans = 0;
	for (int i = 0; i < 4; i++) {
		for (int j = 0; j < 4; j++) {
			ans = max(ans, dist(corn[i], corn[j]));
		}
	}

	cout << ans << '\n';

	return 0;
}


Measured memory_bytes: 3644
// D - Dice in Line
#include <bits/stdc++.h>
using namespace std;
#define rp(i,s,e) for(int i=(s);i<(e);++i)
int in(){int x;scanf("%d",&x);return x;}

int main(){
	int N=in(), K=in();
	int ans, sum, p;
	queue<int> q;
	sum = 0;
	rp(i,0,K){
		p = in();
		sum += p;
		q.push(p);
	}
	ans = sum;
	rp(i,K,N){
		p = in();
		sum += p - q.front(); q.pop();
		q.push(p);
		ans = max(ans, sum);
	}
	printf("%.12f\n",(ans+K)/2.0);
}

Measured memory_bytes: 1024
import java.io.*;
import java.util.Scanner;

public class Main {
	public static void main(String args[]) throws IOException {
		//BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		Scanner scan = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();


		
		int i,s;
		i = 0;

		while(true){
			i++;
			s = scan.nextInt();
			//s = Integer.parseInt(br.readLine());
			if(s == 0){break;}
			
			//str = str+ "Case " + Integer.toString(i) + ": " + str + "\n";
			
			sb.append("Case ");
			sb.append(Integer.toString(i));
			sb.append(": ");
			sb.append(Integer.toString(s));
			sb.append("\n");
			
			
			
		}

		System.out.print(new String(sb));

	}
}

Measured memory_bytes: 42920
import itertools
from sys import stdin
input = stdin.readline

N = int(input())
A = [int(input()) for _ in range(N)]

max_value, max_cnt, sub_max = -1, 0, -1
for v in A:
	if v > max_value:
		sub_max = max_value
		max_value = v
		max_cnt = 1
	elif v == max_value:
		max_cnt += 1
	elif v > sub_max:
		sub_max = v

if max_cnt >= 2:
	print('\n'.join([str(max_value)] * N))
else:
	for v in A:
		print('%d' % (max_value if v != max_value else sub_max))


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

typedef long long ll;
const double EPS = 1e-9;
typedef vector<ll> vecl;
typedef pair<ll, ll> pairl;
#define ALL(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i, n) REP(i, 0, n)
template<class T, class C> void chmax(T& a, C b){ a>b?:a=b; }
template<class T, class C> void chmin(T& a, C b){ a<b?:a=b; }

#define MOD097 1000000007

///// For Debug

#define repi(itr, ds) for (auto itr = ds.begin(); itr != ds.end(); itr++)
// vector
template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
    for (T &x : vec) is >> x;
    return is;
}
// pair
template <typename T, typename U>
ostream &operator<<(ostream &os, pair<T, U> &pair_var) {
    os << "(" << pair_var.first << ", " << pair_var.second << ")";
    return os;
}
// vector
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
    os << "{";
    for (int i = 0; i < vec.size(); i++) {
        os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
    }
    os << "}";
    return os;
}
// map
template <typename T, typename U>
ostream &operator<<(ostream &os, map<T, U> &map_var) {
    os << "{";
    repi(itr, map_var) {
        os << *itr;
        itr++;
        if (itr != map_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
// set
template <typename T>
ostream &operator<<(ostream &os, set<T> &set_var) {
    os << "{";
    repi(itr, set_var) {
        os << *itr;
        itr++;
        if (itr != set_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
 
#define DUMPOUT cerr
 
void dump_func() {
    DUMPOUT << endl;
}
template <class Head, class... Tail>
void dump_func(Head &&head, Tail &&... tail) {
    DUMPOUT << head;
    if (sizeof...(Tail) > 0) {
        DUMPOUT << ", ";
    }
    dump_func(std::move(tail)...);
}

// 提出時はコメントアウト
// #define LOCAL
#define DEBUG_

#ifndef LOCAL
#undef DEBUG_
#endif

#ifdef DEBUG_

#define DEB
#define dump(...)                                                              \
    DUMPOUT << "  " << string(#__VA_ARGS__) << ": "                            \
            << "[" << to_string(__LINE__) << ":" << __FUNCTION__ << "]"        \
            << endl                                                            \
            << "    ",                                                         \
        dump_func(__VA_ARGS__)
#else
#define DEB if (false)
#define dump(...)

#endif

//////////

int main() {
    #ifdef LOCAL
    ifstream in("../../Atcoder/input.txt");
    cin.rdbuf(in.rdbuf());
    #endif

    ll N,M;
    cin >> N >> M;

    map<ll,vector<ll>> X;
    rep(i,N) {
        ll a,b;
        cin>>a>>b;

        X[a].push_back(b);
    }

    priority_queue<ll> que;

    ll ans = 0;
    for (ll i=M-1;i >= 0; i--) {
        ll ok = M - i;
        for (auto &x : X[ok]) {
            que.push(x);
            // cout << x << endl;
        }
        if (que.empty()) continue;

        ll b = que.top(); que.pop();
        ans += b;
    }

    cout << ans << endl;


    return 0;
}


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

using namespace std;

#define sz(x) (int) x.size()
#define all(a) a.begin(), a.end()

int main() {

    int a, b, c, k;

    cin >> a >> b >> c >> k;

    int ans = 0;
    
    ans += min(a, k);
    k -= min(a, k);
    
    k -= min(b, k);

    ans -= min(c, k);
    k -= min(c, k);

    cout << ans << endl;

    return 0;
}


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

int main(){
    ll n,k,ans=0;
    cin >> n >> k;
    vector<pair<ll,ll>> x(n);
    vector<bool> b(n,false);
    for(int i = 0;i < n;i ++){
        ll t,d;
        cin >> t >> d;
        x[i].first = d;
        x[i].second = t;
    }
    sort(x.begin(),x.end());
    reverse(x.begin(),x.end());
    map<ll,ll> mp;
    for(int i = 0;i < k;i ++){
        ans += x[i].first;
        b[i] = true;
        mp[x[i].second] ++;
    }
    ans += mp.size()*mp.size();
    int j = k;
    ll sub = 0,cnt = mp.size(),sans=ans;
    for(int i = k-1;i*(n-1-i) >= 0 && j < n && i>=0;){
        while(i>=0 && (!b[i] || mp[x[i].second]<=1)){
            i --;
        }
        while(j<n && (b[j] || mp[x[j].second]>=1)){
            j ++;
        }
        if(i*(n-1-i)>=0 && j<n)sub = x[j].first - x[i].first + 2*cnt+1;
        else break;
        sans += sub;
        if(sans>ans) ans=sans;
        cnt ++;
        mp[x[i].second] --;b[i] = false;
        mp[x[j].second] ++;b[j] = true;
        j ++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 5760
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n,x;
    scanf("%d",&n);
    x=n%10;
    if(x==2 || x==4 || x==5 || x==7 || x==9) printf("hon");
    else if(x==0 || x==1 || x==6 || x==8) printf("pon");
    else if(x==3) printf("bon");
    return 0;
}


Measured memory_bytes: 3732
import numpy as np


def main() -> None:
    n, m, x = map(int, input().split())
    books = [tuple(map(int, input().split())) for _ in range(n)]

    is_able = False
    answer = float('inf')
    for i in range(2**n):
        money = 0
        skills = np.zeros(m)
        for j in range(n):
            if ((i >> j) & 1):
                money += books[j][0]
                skills += books[j][1:]
        if x <= skills.min():
            is_able = True
            answer = min(answer, money)

    print(answer if is_able else -1)
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 27120
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <queue>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using namespace std;

template<class T>
constexpr T INF = ::numeric_limits<T>::max() / 32 * 15 + 208;

int main() {
    ll n;
    cin >> n;
    vector<ll> v(n);
    ll sum = 0;
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
        sum += v[i];
    }
    if(n == 1){
        cout << "YES\n";
        return 0;
    }else if(sum % (n*(n+1)/2)){
        cout << "NO\n";
        return 0;
    }
    ll nn = n*1000000000;
    ll x = (v[1]-v[0]+nn)%n, k = sum / (n*(n+1)/2);
    for (int i = 0; i < n; ++i) {
        ll y = v[i] - v[(i+1)%n] + k;
        if(y < 0 || y % n != 0) {
            cout << "NO\n";
            return 0;
        }
    }
    cout << "YES\n";
    return 0;
}



Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const int N = 100000;

namespace Modop {
    ll modAdd(ll a, ll b) {
        return (a + b) % MOD;
    }
    
    ll modSub(ll a, ll b) {
        return (((a - b) % MOD) + MOD) % MOD;
    }
    
    ll modMul(ll a, ll b) {
        return ((a % MOD) * (b % MOD)) % MOD;
    }

    ll modExp(ll base, ll power) {
        if (power == 0) {
            return 1;
        } else {
            ll cur = modExp(base, power / 2); cur = cur * cur; cur = cur % MOD;
            if (power % 2 == 1) cur = cur * base;
            cur = cur % MOD;
            return cur;
        }
    }
    
    ll modInv(ll a) {
        return modExp(a, MOD - 2);
    }
    
    ll modDiv(ll a, ll b) {
        return modMul(a, modInv(b));
    }
}

using namespace Modop;

ll n;
int seen[N];

int main() {
	cin.sync_with_stdio(0); cin.tie(0);
	cin >> n;
	vector<ll> a(n);
	
	for (auto& i : a) {
		cin >> i;
		seen[i]++;
	}
	
	bool pos = true;
	if (n % 2) {
		if (seen[0] != 1) pos = false;
		for (int i = 2; i < n; i += 2) {
			if (seen[i] != 2) pos = false;
		}
	} else {
		for (int i = 1; i < n; i += 2) {
			if (seen[i] != 2) pos = false;
		}
	}
	
	if (!pos) cout << 0;
	else cout << modExp(2, n / 2);
    return 0;
}


Measured memory_bytes: 1408
#!/usr/bin/perl

my ($N,$X) = map {$_ - 0} split(/\s+/o,<STDIN>);
my @x = map { abs(($_ - 0) - $X) } split(/\s+/o,<STDIN>);
my $D = 10 ** 10;
for(my $i=0;$i<$N;$i++){
  $D = $x[$i] if $x[$i] != 0 and $x[$i] < $D;
}
foreach my $x (@x){
  next if $x == 0;
  my $nD = &gcd($x,$D);
  $D = $nD;
}
print "$D\n";
exit(0);

sub gcd {
  my $mm = shift;
  my $nn = shift;
  while($nn != 0){
    my $rr = $mm % $nn;
    $mm = $nn;
    $nn = $rr;
  }
  return $mm;
}



Measured memory_bytes: 18764
#include<stdio.h>

int main()
{
    int n,x,count=0;
    while(1){
    scanf("%d %d",&n,&x);
        if(n+x==0)
            break;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            for(int k=1;k<=n;k++){
                    if(i==j||j==k||k==i){
                    }else{
                        if(i+j+k==x)
                            count+=1;
                    }
            }
        }
    }
    printf("%d\n",count/6);
        count=0;
    }
    return 0;
}


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

int main(void) {
    int a, b;
    cin >> a >> b;
    int m = min(a, b);
    int n = max(a, b);
    for (int i = 0; i < n; ++i) {
        printf("%d", m);
    }
    printf("\n");

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b)  for(int (i)=(a);(i)<(b);(i)++)
#define REP(i,n)    FOR(i,0,n)
#define RER(i,n)    FOR(i,0,(n+1))
#define pb          push_back
#define mp(a,b)     make_pair((a),(b))
#define mset(m,v)   memset(m,v,sizeof(m))
using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pair<int, int> > vpii;
typedef long long ll;
typedef vector<ll> vl;
typedef pair<ll,ll> pll;
typedef vector<pair<ll, ll> > vpll;
typedef vector<string> vs;
typedef long double ld;
const double EPS    = 1e-10;
const int INF       = 1e+9;
const double PI     = acos(-1);


auto main() -> int
{
    int a, b, c, d;
    cin >> a >> b >> c >> d;

    cout << max(a*b, c*d) << endl;

    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
//#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int main(){
	while(1){
		string ans = "impossible"; int a[6];
		cin >> a[0] >> a[1] >> a[2] >> a[3] >> a[4] >> a[5];
		if(a[0]+a[1]+a[2]+a[3]+a[4]+a[5] == 0) return 0;
		do{
			int b[6]; rep(i,6) b[i] = a[i];
			string s = "";
			while(b[0]+b[1]+b[2]+b[3]+b[4]+b[5] > 0){
				if(b[2] && b[2]+b[4]-1 <= b[0]+b[1]+b[3]+b[5] && b[1]+b[3] <= b[0]+b[2]+b[4]+b[5] && b[0]+b[5] <= b[1]+b[2]+b[3]+b[4]){
					s.pb('E');
					int f = b[5]; b[5] = b[2]-1; b[2] = b[0]; b[0] = b[4]; b[4] = f;
				}
				else if(b[3] && b[3]+b[1]-1 <= b[0]+b[2]+b[4]+b[5] && b[2]+b[4] <= b[0]+b[1]+b[3]+b[5] && b[0]+b[5] <= b[1]+b[2]+b[3]+b[4]){
					s.pb('N');
					int f = b[5]; b[5] = b[3]-1; b[3] = b[0]; b[0] = b[1]; b[1] = f;
				}
				else if(b[1] && b[3]+b[1]-1 <= b[0]+b[2]+b[4]+b[5] && b[2]+b[4] <= b[0]+b[1]+b[3]+b[5] && b[0]+b[5] <= b[1]+b[2]+b[3]+b[4]){
					s.pb('S');
					int f = b[5]; b[5] = b[1]-1; b[1] = b[0]; b[0] = b[3]; b[3] = f;
				}
				else if(b[4] && b[2]+b[4]-1 <= b[0]+b[1]+b[3]+b[5] && b[1]+b[3] <= b[0]+b[2]+b[4]+b[5] && b[0]+b[5] <= b[1]+b[2]+b[3]+b[4]){
					s.pb('W');
					int f = b[5]; b[5] = b[4]-1; b[4] = b[0]; b[0] = b[2]; b[2] = f;
				}
				else{
					goto bad;
				}
				//cout << b[0] << " " << b[1] << " " << b[2] << " " << b[3] << " " << b[4] << " " << b[5] << endl;
			}
			if(ans == "impossible") ans = s;
			else ans = min(ans,s); bad:;
		}while(next_permutation(a,a+6));
		int p,q; cin >> p >> q;
		if(ans != "impossible"){
		        for(int i=p-1;i<q;i++) printf("%c",ans[i]); puts("");
		}
		else{
			cout << ans << endl;
		}
	}
}

Measured memory_bytes: 3252
#include <iostream>
#define INF 10000000000000100
using namespace std;

int main(void){
  long long X,K,D;
  cin>>X>>K>>D;

  long long a = K/2 - (X/D)/2;

  long long retval=INF;
  for(long long i=-10;i<10;i++){
    long long _a = a+i;
    long long _b=K-_a;
    if(_a>=0 and _b>=0){
      retval=min(abs(X+_a*D-_b*D), retval);
    }
  }
  if(retval==INF){
    retval=min(abs(X+K*D),abs(X-K*D));
  }
  cout<<retval<<endl;


  return 0;
}


Measured memory_bytes: 3636
#include <cstdio>
using namespace std;
#define rep1(i,n) for(int i=1;i<=n;i++)
int main(){
	while(true){
		int n,cnt=0;
		scanf("%d",&n);
		if(n==0) break;
		rep1(a,1000){
			rep1(m,1000){
				if(m==1) continue;
				if((2*a+m-1)*m/2==n) cnt++;
				if((2*a+m-1)*m/2>n) break;
			}
		}
		printf("%d\n",cnt);
	}
	return 0;
}

Measured memory_bytes: 1012
#include "bits/stdc++.h"
#include "ext/pb_ds/assoc_container.hpp"
#include "ext/pb_ds/tree_policy.hpp"

using namespace std;
using namespace __gnu_pbds;


#define ll long long int
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(a) a.begin(),a.end()

typedef tree <ll, null_type, less <ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
// order_of_key(val): returns the number of values less than val
// find_by_order(k): returns an iterator to the kth largest element (0-based)

int main(void)
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll a, b, i;
    cin>>a>>b;
    for(i = 0; i <= 100000; i++) {
    	ll t1 = (i * 8) / 100;
    	ll t2 = (i * 10) / 100;
    	if(t1 == a && t2 == b) {
    		cout<<i<<"\n";
    		return 0;
    	}
    }
    cout<<"-1\n";
    return 0;
}

Measured memory_bytes: 256
import java.util.*;


public class Main {
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int d = sc.nextInt();
        
        System.out.println((a-c) * (b-d));
    }
}

Measured memory_bytes: 23764
mNum = map(int, input().split())
lNum = list(mNum)

weight = [1, 0, -1]

sumAns = 0

for i in range(3):
    sumAns += lNum[i] * weight[i] if lNum[i] <= lNum[3] else lNum[3] * weight[i]
    lNum[3] -= lNum[i]
    if(lNum[3] <= 0):
        break
    
print(sumAns)

Measured memory_bytes: 9192
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int codeNum = sc.nextInt();
		int featNum = sc.nextInt();
		int c = sc.nextInt();
        int[] b = new int[featNum];
        int num = 0;
        int num2 = 0;
        int sum = 0;
        int count = 0;
		for(int i=0; i<featNum; i++){
         	 b[i] = sc.nextInt();
        }
      	for(int i=0; i<codeNum; i++){
          for(int j=0; j<featNum; j++){
         	 num = sc.nextInt();
             num2 = b[j] * num;
             sum += num2;
          }
          if(sum + c > 0) count++;
          sum = 0;
        }
		System.out.println(count);
	}
}

Measured memory_bytes: 22612
n = int(input())
count = 0
l = [input() for i in range(n)]
a = 0
b = 0
ab = 0
for i in range(n):
    if "AB" in l[i]:
        count += l[i].count("AB")
    if l[i][0] == "B" and l[i][-1] == "A":
        ab += 1
    elif l[i][0] == "B":
        b += 1
    elif l[i][-1] == "A":
        a += 1
if ab >= 2:
    count += ab-1
    ab = 1
x= min(ab,b)
count += x
b -= x
x= min(ab,a)
count += x
a -= x
if a and b:
    count += min(a,b)
print(count)



Measured memory_bytes: 9580
#include<stdio.h>
int fibonacci(int);

int dp[45];

int main(){
  int n,i;
  for(i=0;i<45;i++){
    dp[i]=-1;
  }
  scanf("%d",&n);
  printf("%d\n",fibonacci(n));

  return 0;
}

int fibonacci(int n){
  if(n==0||n==1){
    return dp[n]=1;
  }
  else if(dp[n]!=-1){
    return dp[n];
  }
  return dp[n]=fibonacci(n-1)+fibonacci(n-2);
}




Measured memory_bytes: 2112