akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <climits>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <fstream>

using namespace std;
#define TOSTRING(x) #x
#define SZ(x) (int)(x).size()
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REPR(i,n) for(int i=(n)-1;i>=0;i--)
#define ALL(s) (s).begin(), (s).end()
#define so(V) sort(ALL(V))
#define rev(V) reverse(ALL(V))
#define uni(v) v.erase( unique(ALL(v)) , v.end());
#define PAU system("pause")

typedef long long unsigned int llu;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<vb> vvb;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;
const int INF = (1 << 28);
const double PI = acos(-1);

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N;
	cin >> N;
	int n = 3;
	int d = 3;
	bool ok = false;
	if (N == 1) {
		cout << "Yes" << endl;
		cout << 2 << endl;
		cout << "1 1" << endl;
		cout << "1 1" << endl;
		PAU;
		return 0;
	}
	while (n <= N) {
		if (n == N) {
			ok = true;
			break;
		}
		n += d;
		d++;
	}
	if (!ok) {
		cout << "No" << endl;
		PAU;
		return 0;
	}
	d--;//数列一つ一つの要素数。
	
	if (N == 3) {
		cout << "Yes" << endl;
		cout << 3 << endl;
		cout << "2 1 2" << endl;
		cout << "2 1 3" << endl;
		cout << "2 2 3" << endl;
		PAU;
		return 0;
	}
	int cnt = 1;
	vvi Ans;
	vi S;
	REP(i, d) {
		S.push_back(i + 1);
	}
	Ans.push_back(S);
	S = vi();
	FOR(i, d, 2 * d) {
		S.push_back(i);
	}
	int nxt = 2 * d;
	Ans.push_back(S);
	REP(i, N * 2 / d - 2) {
		S = vi();
		S.push_back(i + 1);
		FOR(j, 1, cnt + 1) {
			S.push_back(Ans[j][cnt]);
		}
		REP(i, d - cnt - 1) {
			S.push_back(nxt);
			nxt++;
		}
		Ans.push_back(S);
		cnt++;
	}
	cout << "Yes" << endl;
	cout << N * 2 / d << endl;
	REP(i, SZ(Ans)) {
		cout << d;
		for (int s : Ans[i]) {
			cout << " " << s;
		}
		cout << endl;
	}
	PAU;
	return 0;
}


Measured memory_bytes: 2424
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define all(v) v.begin(),v.end()
#define P pair<int,int>
#define len(s) (int)s.size()
 
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;
}
constexpr int mod = 1e9+7;
constexpr long long inf = 3e18;

struct BIT{
	int N;
	vector<int>bit;
	void add(int x,int y){
		while(x<=N){
			bit[x]+=y;x+=x&-x;
		}
	}
	int sum(int x){
		int res=0;
		while(x>0){
			res+=bit[x];x-=x&-x;
		}
		return res;
	}
	int lower_bound(int w){
		if(w<=0)return 0;
		int x=0;
		int k=1;while(k*2<=N)k*=2;
		for(;k>0;k/=2){
			if(x+k<=N&&bit[x+k]<w){
				w-=bit[x+k];
				x+=k;
			}
		}
		return x+1;
	}
	BIT(int x):N(x),bit(x+1){}
};
signed main(){
	cin.tie(0);ios::sync_with_stdio(false);
	int N,Q;cin>>N>>Q;
	BIT bit(N);
	rep(i,N){
		int a;cin>>a;
		bit.add(i+1,a);
	}
	while(Q--){
		int t,p,x;cin>>t>>p>>x;
		if(!t)bit.add(p+1,x);
		else cout<<bit.sum(x)-bit.sum(p)<<"\n";
	}
}

Measured memory_bytes: 8260
#include <iostream>

using namespace std;

int main()
{
    int x,y;
    cin>>x>>y;
    int a = 4*x-y;
    int b = y-2*x;
    if(a%2!=0 || b%2!=0 || a<0 || b<0){
        cout<<"No";
    }
    else{
    a/=2;
    b/=2;
    int result1 = 2*a + 4*b;
    int result2  = a+b;
    if(result1!=y || result2!=x){
        cout<<"No";
    }
    else{
    cout<<"Yes";
    }
    }
}


Measured memory_bytes: 3528
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define USE_LLONG_AS_INT
#ifdef USE_LLONG_AS_INT
#define int long long
#define inf (1ll<<60)
#else
#define inf (1<<30)
#endif
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())

using namespace std;

const int mod=1e9+7;
const string sp=" ";

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

void run(){
    int n;
    cin>>n;
    vi d(n+1);
    REP(i,1,n){
        int t=i;
        REP(j,2,i){
            while(t%j==0){
                d[j]++;
                t/=j;
            }
        }
    }
    int ans=1;
    for(int t:d)ans=ans*(t+1)%mod;
    cout<<ans<<endl;
}

Measured memory_bytes: 256
/*
  ∧,,∧
( 'ω' )つ ＜WA,またお前か！！　
（m9 ＼ 　　
　 ＼　 ＼
　 　 ) ) ＼
　 ／／ ＼ ＼
　 (＿） 　 (＿)
*/

#include <bits/stdc++.h>
using namespace std;

#define all(x) (x).begin(),(x).end()
#define rep(x, y) for (int x = 0; x < y; x++)
#define MOD 1000000007

typedef long long LL;
typedef long double LD;

bool compare_by_b(pair<int, int> a, pair<int, int> b)
{
    if (a.second != b.second) {
        return a.second < b.second;
    } else {
        return a.first < b.first;
    }
}

ostringstream oss_global;
string s_global = oss_global.str();

int main()
{
    int N, K, Q;
    cin >> N >> K >> Q;
    vector<int> A(Q, 0);
    for (int i = 0; i < Q; i++)
        cin >> A[i];

    vector<int> p(N, 0);
    for (int i = 0; i < Q; i++) {
        int par = A[i] - 1;
        p[par]++;
    }

    for (int par = 0; par < N; par++) {
        if (K - Q + p[par] > 0) cout << "Yes" << endl;
        else cout << "No" << endl;
    }

    return 0;
}


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

#define TRACE(x) x
#define WATCH(x) TRACE(cout << #x" = " << x << endl)
#define WATCHR(a, b) TRACE(for (auto it=a; it!=b;) cout << *(it++) << " "; cout << endl)
#define WATCHC(V) TRACE({cout << #V" = "; WATCHR(V.begin(), V.end());})

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

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

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

    int N;
    cin >> N;

    vi a(N), b(N);
    for (int i = 0; i < N; i++)
        cin >> a[i];
    for (int i = 0; i < N; i++)
        cin >> b[i];

    int res = 0;
    for (int bit = 0; bit < 29; bit++) {
        int M = 1 << (bit + 1);

        vi av;
        for (int v : a) {
            av.push_back(v & (M - 1));
        }
        sort(all(av));

        vi bv;
        for (int v : b) {
            bv.push_back(v & (M - 1));
        }
        sort(all(bv));

        // count a + b >= 2^b mod 2^(b+1)
        // b in [M/2 - a, M - a)
        ll app = 0;

        int i, l = N, r = N;
        for (i = 0; i < N && av[i] <= M/2; i++) {
            while (l > 0 && bv[l - 1] >= M/2 - av[i])
                l--;
            while (r > l && bv[r - 1] >= M - av[i])
                r--;
            app += r - l;
        }

        l = N, r = N;
        for (; i < N; i++) {
            while (l > 0 && bv[l - 1] >= M + M/2 - av[i])
                l--;
            app += N - l;

            while (r > 0 && bv[r - 1] >= M - av[i])
                r--;
            app += r;
        }

        if (app&1) res ^= 1 << bit;
    }

    cout << res << endl;
    return 0;
}



Measured memory_bytes: 4492
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<functional>
#include<map>
#define INF 999999999
typedef long long ll;

int main() {
	int r,g;
	std::cin >> r >> g;
	std::cout << g * 2 - r << std::endl;

}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getInts(N int) []int {
	ret := make([]int, N)
	for i := 0; i < N; i++ {
		ret[i] = getInt()
	}
	return ret
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func lowerBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] >= x
	})
	return idx
}

func upperBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] > x
	})
	return idx
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer([]byte{}, 1000000)
	S := getString()
	T := getString()
	ans := 100000
	for i := 0; i <= len(S)-len(T); i++ {
		cnt := 0
		// out("----")
		for j := 0; j < len(T); j++ {
			// out(string(S[i+j]), string(T[j]))
			if S[i+j] != T[j] {
				cnt++
			}
		}
		ans = min(ans, cnt)
	}
	out(ans)
}


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

public class Main {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = Integer.parseInt(scan.next());
        int k = Integer.parseInt(scan.next());
        int[] p = new int[n];
        for (int i = 0; i < n; i++) {
            p[i] = Integer.parseInt(scan.next());
        }
        scan.close();

        Arrays.sort(p);
        int ans = 0;
        for (int i = 0;i<k;i++) {
            ans += p[i];
        }

        System.out.println(ans);
    }

}


Measured memory_bytes: 38048
#include<stdio.h>
#include<math.h>
#include<iostream>
using namespace std;
int main(){
    double r,s,l,pi;
    pi = M_PI;
    cin >> r;
    s = r * r * pi;
    l = r * 2 * pi;
    printf("%.6f %.6f",s,l);
    return 0;
}


Measured memory_bytes: 3288
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner scan = new Scanner(System.in);
    String str_scan = scan.nextLine();
    // スペース区切りで分ける
    var str = str_scan.split(" ");
    // float型へ変換
    float D = Float.parseFloat(str[0]);
    float T = Float.parseFloat(str[1]);
    float S = Float.parseFloat(str[2]);
    var ans = "No";

    float min = D / S;

    if (min <= T){
      ans = "Yes";
    }

    System.out.println(ans);
    scan.close();
  }
}

Measured memory_bytes: 35808
#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>
#define chmin(a, b) ((a)=min((a), (b)))
#define chmax(a, b) ((a)=max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;

const ll MOD=1e9+7;
const ll INF=1e18;
const double pi=acos(-1);
const double eps=1e-10;

int dx[]={1, 0, -1, 0};
int dy[]={0, -1, 0, 1};

int main(){
    int n; cin>>n;
    vector<string> s(n);
    vector<int> cnt(3, 0);
    int ans=0;
    int sumcnt=0;
    vector<bool> validA(n, false), validB(n, false);
    for(int i=0; i<n; i++){
        cin>>s[i];
        for(int j=0; j<s[i].size()-1; j++){
            if(s[i][j] == 'A' && s[i][j+1] == 'B') ans++;
        }

        if(s[i][0] == 'B' && s[i][s[i].size()-1] == 'A'){
            cnt[2]++;
        }
        else if(s[i][0] == 'B'){
            cnt[1]++;
            validB[i] = true;
        }
        else if(s[i][s[i].size()-1] == 'A'){
            cnt[0]++;
            validA[i] = true;
        }
    }

    int sum=0;
    for(int i=0; i<n; i++){
        if(validA[i] || validB[i]){
            sum++;
        }
    }

    if(cnt[2] > 0){
        if(cnt[1] > 0 && cnt[0] > 0){
            ans += cnt[2] + 1;
            cnt[2] = 0;
            cnt[1]--;
            cnt[0]--;
        }
        else if(cnt[1] > 0){
            ans += cnt[2];
            cnt[2] = 0;
            cnt[1]--;
        }
        else if(cnt[0] > 0){
            ans += cnt[2];
            cnt[2] = 0;
            cnt[0]--;
        }
        else{
            ans += cnt[2] - 1;
            cnt[2] = 0;
        }
    }

    cout << ans + min(cnt[0], cnt[1]) << endl;
}


Measured memory_bytes: 768
/*氏名：保坂優介, 学籍番号：200441141
  概要：2点間び距離を求める*/

#include<stdio.h>
#include<math.h>

int main(void)
{
    double x1, y1, x2, y2, ans;

    scanf("%lf %lf %lf %lf", &x1, &y1, &x2, &y2);

    ans = sqrt(pow(x1 - x2, 2) + pow(y1 - y2, 2));

    printf("%lf\n", ans);

    return 0;
}


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

vector<pair<ll, ll>> prime_factorize(ll n) {
  vector<pair<ll, ll>> v;
  for (ll i = 2; i * i <= n; i++) {
    if (n % i != 0) continue;
    int num = 0;
    while (n % i == 0) {
      num++;
      n /= i;
    }
    v.push_back(make_pair(i, num));
  }
  if (n != 1) v.push_back(make_pair(n, 1));
  return v;
}

int main() {
  ll n, p;
  cin >> n >> p;
  auto f = prime_factorize(p);
  ll ans = 1;
  for (auto i : f) {
    for (int j = 0; j < i.second / n; j++) {
      ans *= i.first;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3568
#include <stdio.h>
#include <stdlib.h>
int main(){
  int i,j,v,N,*A,n;
  
  scanf("%d",&N);
  A=malloc(sizeof(int)*N);
  for(i=0;i<=N-1;i++){
    scanf("%d",&A[i]);
  }

  
  for(i=1;i<N;i++){
    //if(A[i]>A[i+1]){
    for(n=0;n<N-1;n++){
      printf("%d ",A[n]);
    }
    printf("%d\n",A[N-1]);
    
    v=A[i];
    j=i-1;
    while(j>=0 && A[j]>v){
      A[j+1]=A[j];
      j--;
    }
    A[j+1]=v;
      
  }
  for(n=0;n<N-1;n++){
    printf("%d ",A[n]);
  }
  printf("%d\n",A[N-1]);
  free(A);

  return 0;
}

Measured memory_bytes: 600
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;
const int maxn = 107;
typedef pair <int, int> pr;
map <int, int> mp;
set <int> sst;
vector <int> vect;
priority_queue <pr> qua;
int n;
int a[maxn];

int main() {
	cin >> n;
	for(int i = 1; i <= n; i++) cin >> a[i];
	sort(a + 1, a + n + 1);
	cout << a[n] - a[1] << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int 
int main()
{
    string s,t;
    cin >> s >>t;
    ll n=t.size();
    ll ans=INT_MAX;
    if(n==s.size())
    {
        ll cnt=0;
        for(ll i=0;i<n;i++)
        {
            if(t[i]!=s[i])
            {
                cnt++;
            }
        }
        cout << cnt;
        return 0;
    }
    for(ll i=0;i<s.size()-t.size();i++)
    {
        string now=s.substr(i,n);
        ll count=0;
        for(ll j=0;j<n;j++)
        {
            if(now[j]!=t[j])
            {
                count++;
            }
        }
        ans=min(ans,count);
    }
    cout << ans;
}


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

using namespace std;
#define int int64_t
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, n) for (int i = 1; i <= (n); i++)
#define all(x) (x).begin(), (x).end()
#define gsort(x) sort((x).begin(), (x).end(), greater<int>())
#define rv(s) reverse((s).begin(), (s).end())
#define pii pair<int, int>
#define re(s) reverse((s).begin(), (s).end())
#define setout(n, x) setw(n) << setfill(x)
#define Fixed fixed << setprecision(10);
const long long mod = 1e9 + 7;

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

   int n, cnt = 0, big;
   cin >> n;
   vector<int> x(n);

   rep(i, n)
   {
      cin >> x[i];
      if (i == 0)
         ++cnt, big = x[i];
      else if (x[i] >= big)
         ++cnt, big = x[i];
   }
   cout << cnt << '\n';
}

Measured memory_bytes: 892
#include<iostream>
#include<math.h>
using namespace std;
int main() {
	long long int n;
	cin >> n;
	if (n == 2) {
		cout << 1 << endl;
		return 0;
	}
	int counter = 0;
	long long int nn;
	long long int i;
	for (i = 2; i <= sqrt(n); i++) {
		//cout << sqrt(n);
		//cout << n - 1 <<':' << i << endl;
		if (((n - 1) % i) == 0) {
			counter = counter + 2;
			//cout << 'a' << i << endl;
			if (i * i == n - 1) {
				counter = counter - 1;
			}
		}
		if (n % i == 0) {
			nn = n;
			while (nn % i == 0) {
				nn = nn / i;
			}
			if (nn % i == 1) {
				//cout << 'i' << i << endl;
				counter++;
			}
		}
		//cout << "i:" << i << endl;
	}
	counter=counter+ 2;
	cout << counter << endl;
	return 0;
}

Measured memory_bytes: 3656
import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
      	int A1 = sc.nextInt();
      	int A2 = sc.nextInt();
        int A3 = sc.nextInt();
      
      	if(A1+A2+A3>=22) System.out.println("bust");
     	else System.out.println("win");
    }
}

Measured memory_bytes: 35780
#include<stdio.h>
int main(void)
{
    int h,w,i,y;
    while(1){
        scanf("%d %d",&h,&w);
        if(w+h==0) break;
        for(i=0;i<h;i++){
            for(y=0;y<w;y++){
                if(0<i&&i<h-1&&0<y&&y<w-1)
                    printf(".");
                else if(i==0||y==0||i==h-1||y==w-1)
                    printf("#");

            }
            printf("\n");
        }
        printf("\n");
    }
    return 0;
}



Measured memory_bytes: 2028
import java.util.Scanner;

public class Main {
	public static void main(String[]args) {
		try(Scanner scan = new Scanner(System.in)){
			
			int N = scan.nextInt();
			int[]H = new int[N];
			int[]count = new int[N];
			
			
			for(int i =0;i<N;i++) {
				H[i] = scan.nextInt();
			}
			
			int chakuti=0;
			int genzai =0;
			
			
			while(true) {
				if(genzai==N-1) {
					break;
				}
				
				if(H[genzai]>=H[genzai+1]) {//順に小さいところにはカウントする必要がない
					count[chakuti]+=1;
					genzai++;
				}else if(H[genzai]<H[genzai+1]) {
					chakuti=genzai+1;
					genzai++;
				}
				
				
				
				
				
				
				
			}
			
			
			int max = 0;
			for(int i = 0;i<N;i++) {
				if(max<count[i]) {
					max = count[i];
				}
			}
			
			
			System.out.println(max);
			
			
			
			
		}
		
		
	}
		

}


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

using namespace std;

long d[111][111111];
int main() {
	int n, w;
	cin >> n >> w;
	for (int i = 0; i < n; i++) {
		int u, v;
		cin >> u >> v;
		for (int j = 0; j <= w; j++)
			d[i + 1][j] = max(d[i][j], j < u ? 0 : d[i][j - u] + v);
	}
	cout << d[n][w] << endl;
	return 0;
}


Measured memory_bytes: 87296
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
#define MAXN 1000001
void solve(){
	string s1;
	cin>>s1;
	if(s1=="ABC")
	{
		cout<<"ARC"<<endl;
		return;
	}
	cout<<"ABC"<<endl;
}
int main(){
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    int t=1;
  //  cin>>t;
    while(t--){
        solve();
    }
} 


Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
const int N=2*10000+5;  //宏定义，偷懒
const int maxn=0x3f3f3f3f;  //继续偷懒
int dp[N];

int main(){
    int h,n,x,y,i,j;
    cin>>h>>n;
    memset(dp,maxn,sizeof(dp));
    //先将值调大，因为要用min函数 

    dp[0]=0;   //DP边界

    for(i=0;i<n;i++){
        cin>>x>>y;
        for(j=0;j+x<N;j++)  //状态转移方程
        dp[j+x]=min(dp[j+x],dp[j]+y);
    }
    sort(dp+h,dp+N-1);  //排序

    cout<<dp[h];  //打印
    return 0;
}

Measured memory_bytes: 384
-- modules to import --
import qualified Data.ByteString.Char8
import qualified Data.Maybe
import           Prelude

-- functions for this task --
read_Integer = Prelude.fst . Data.Maybe.fromJust . Data.ByteString.Char8.readInteger
get_Integer  = read_Integer <$> Data.ByteString.Char8.getLine

-- main process is below --

task_A :: Integer -> Integer -> Integer -> Integer
task_A val_budget val_cake val_doughnut = mod (val_budget - val_cake) val_doughnut

main :: IO ()
main = do

        -- STEP.01
        -- read out the given data
        val_budget   <- get_Integer
        val_cake     <- get_Integer
        val_doughnut <- get_Integer

        -- STEP.02
        -- output the answer of this task
        Prelude.print $ task_A val_budget val_cake val_doughnut

-- End of this source code --

Measured memory_bytes: 380
//////////////////////////
//////////////////////////
////Please give me AC!////
////Please give me AC!////
//////////////////////////
//////////////////////////
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
const int MOD=1e9+7;
const long double Pi=acos(-1);
using  P=pair<ll,ll>;
ll gcd(ll a,ll b){//aとbの最大公約数を返す
  if(a%b==0){return b;}
  else{return gcd(b,a%b);}
}
ll lcm(ll a,ll b){//aとbの最小公倍数を返す
  return a*b/gcd(a,b);
}
ll pow(ll x,ll y){//x^yを返す
  ll tmp=x,res=1;
  while(y){
    if(y%2){res=res*tmp%MOD;}
    y>>=1;
    tmp=tmp*tmp%MOD;
  }
  return res;
}
ll nature(ll a){//絶対値を返す
  if(a>=0){return(a);}
  else{return(-1*a);}
}
ll prime(ll a){//素数なら1を返す
  if(a==2){return 1;}
  else if(a%2==0 || a==1){return 0;}
  for(ll i=3;i*i<=a;i+=2){if(a%i==0){return 0;}}
  return 1;
}
int main(){
  ll N,M,X,Y,Z;
  string S,T;
  cin>>N>>M>>X>>Y>>Z;
  if(N==0){cout<<1<<endl;}
  if(M==0){cout<<2<<endl;}
  if(X==0){cout<<3<<endl;}
  if(Y==0){cout<<4<<endl;}
  if(Z==0){cout<<5<<endl;}
}

Measured memory_bytes: 3620
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstring>
#include <cstdio>
using namespace std;

#define rep(i,a) for(int i = 0 ; i < a ; i ++)
#define vi vector<int>

int main(void){
  string s;
  cin>>s;
  int c = 0;
  char cf[] = "CF\n";

  rep(i,s.size()){
    if(cf[c] == s[i])c++;
  }
  if(c>=2)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 256
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

a = int(input())

fact = factorization(a)

count = 0

for tup in fact:
    countTup = 0
    while True:
        countTup += 1
        if tup[1] < countTup:
            break
        tup[1] -= countTup
    count += countTup - 1

if a == 1:
    print(0)
else:
    print(count)


Measured memory_bytes: 63388
S = input()
ans = 0
N = len(S)
for i in range(2**(N-1)):
  b = bin(i)[2:]
  T = S
  while len(b)<N-1:
    b = '0'+b
  b = b[::-1]
  ind = [0]
  count= 1
  for j in range(N-1):
    if b[j]=='1':
      ind +=[count]
      count = 1
    else:
      count +=1
  ind = ind[1:]
  for h in ind:
    ans += int(T[:h])
    T = T[h:]
  ans += int(T)
  
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
 
#define int long long
#define REP(i, n) for ( int i = 0; i < (n); i++ )
 
signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);

  string s;
  cin >> s;

  vector<int> ans(s.size(), 0);  
  int lr = 0, rr = 0, ll = 0, rl = 0;
  int now = 0;  
  for ( int i = 1; i < (int)s.size(); i++ ) {
    // cout << now << " " << lr << " " << rr << " " << ll << " " << rl << endl;    
    if ( now == 0 ) {
      if ( s[i] == 'R' ) {
	rr = i;
      } else {
	now = 1;
	ll = rl = i;	
      }
    } else {
      if ( s[i] == 'R' ) {
	ans[rr] = (rr - lr)/2 + (rl - rr)/2 + 1;	
	ans[ll] = (ll - lr)/2 + (rl - ll)/2 + 1;	
	lr = rr = ll = rl = i;
	now = 0;
      } else {
	rl = i;	
      }
    }
    // cout << now << " " << lr << " " << rr << " " << ll << " " << rl << endl;    
  }

  ans[rr] = (rr - lr)/2 + (rl - rr)/2 + 1;	
  ans[ll] = (ll - lr)/2 + (rl - ll)/2 + 1;

  REP(i, (int)s.size()) {
    if ( i ) cout << " ";
    cout << ans[i];
  } cout << endl;

  return 0;
}


Measured memory_bytes: 4244
import sys
import math
from collections import deque
import heapq
import itertools
MAX_INT = int(10e10)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

def tami(x, cnt):
  if visited[x-1] != -1:
    return [x, visited[x-1], cnt-visited[x-1]]
  else:
    visited[x-1] = cnt
    return tami(a[x-1], cnt+1)

def nasu1(x, cnt):
  if cnt == K:
    return x
  else:
    return nasu1(a[x-1], cnt+1)

def nasu2(x, cnt):
  if cnt == num:
    return x
  else:
    return nasu2(a[x-1], cnt+1)

N,K = IL()
a = IL()

visited = [-1]*N
i, start, roop = tami(1, 0)
if K <= start:
  print(nasu1(1, 0))
else:
  #print(visited)
  num = (K-start)%roop
  #print(start,roop,num)

  print(nasu2(i, 0))

Measured memory_bytes: 267404
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <map>
#include <queue>
#include <set>
#define rep(i,n) for (ll i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
//#define repitr(itr, st) for(auto itr = st.begin(); itr != st.end(); ++itr)
#define P_B push_back
#define PO_B pop_back
#define E_B emplace_back
#define M_P make_pair
#define fi first
#define se second
#define debug(x) cout << #x << ": " << x << endl
//#define print(x) printf("%d\n", x)

using namespace std;
using ll = long long;
using Pii = pair<int,int>;
using Pll = pair<ll,ll>;
using VI = vector<int>;
using VL = vector<ll>;
using VVI = vector<vector<int> >;
using VVL = vector<vector<ll> >;
//int dx[4] = {1, 0, -1, 0};
//int dy[4] = {0, 1, 0, -1};
//const ll LINF = (ll)1e18 - 1;
//const int INF = 1e9 - 1;
//int:±2*10^9くらい　ll:±9*10^18くらい



void Main(){
	int N, M;
	cin >> N >> M;
	vector<Pll> p(N+M);

	rep(i, N){
		cin >> p[i].fi;
		p[i].se = 1;
	}
	rep(i, M){
		cin >> p[i+N].se >> p[i+N].fi;
	}
	sort(all(p));
	reverse(all(p));

	ll ans = 0;
	int rem = N;
	rep(i, N+M){
		if(rem > p[i].se){
			rem -= p[i].se;
			ans += p[i].se * p[i].fi;
		}else{
			ans += rem * p[i].fi;
			break;
		}
	}
	cout << ans << endl;

}

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

  return 0;
}


Measured memory_bytes: 6364
import java.io.*;
import java.util.*;
public class Main implements Runnable{
    
    private void solve()throws IOException{
        int n=nextInt();
        ArrayList<Pair> list=new ArrayList<>();
        int ans=0;
        for(int i=1;i<=n;i++){
            int x=nextInt();
            int l=nextInt();
            list.add(new Pair(x-l,x+l));
        }
        Collections.sort(list,new Comparator<Pair>(){
            public int compare(Pair a,Pair b){
                return a.second-b.second;
            }
        });
        int prev=-inf;
        for(Pair p:list){
            if(p.first<prev)
                continue;
            else{
                ans++;
                prev=p.second;
            }
        }
        out.println(ans);
    }
    class Pair{
        int first,second;
        Pair(int a,int b){
            first=a;
            second=b;
        }
    }

     
    ///////////////////////////////////////////////////////////

    final long mod=(long)(1e9+7);
    final int inf=(int)(2e9+1);
    final int maxn=(int)(1e6);
    final long lim=(long)(1e18);

    public void run(){
        try{
            br=new BufferedReader(new InputStreamReader(System.in));
            st=null;
            out=new PrintWriter(System.out);

            solve();

            // int t=nextInt();
            // for(int i=1;i<=t;i++){
            //     // out.print("Case #"+i+": ");
            //     solve();
            // }

            br.close();
            out.close();
        }catch(Exception e){
            e.printStackTrace();
            System.exit(1);
        }
    }
    public static void main(String args[])throws IOException{
        new Main().run();
    } 
    int max(int ... a){
        int ret=a[0];
        for(int i=1;i<a.length;i++)
        ret=Math.max(ret,a[i]);
        return ret;
    }
    int min(int ... a){
        int ret=a[0];
        for(int i=1;i<a.length;i++)
        ret=Math.min(ret,a[i]);
        return ret;
    }
    void debug(Object ... a){
        System.out.print("> ");
        for(int i=0;i<a.length;i++)
        System.out.print(a[i]+" ");
        System.out.println();
    }
    void debug(int a[]){debuga(Arrays.stream(a).boxed().toArray());}
    void debug(long a[]){debuga(Arrays.stream(a).boxed().toArray());}
    void debuga(Object a[]){
        System.out.print("> ");
        for(int i=0;i<a.length;i++)
        System.out.print(a[i]+" ");
        System.out.println();
    }
    BufferedReader br;
    StringTokenizer st;
    PrintWriter out;
    String nextToken()throws IOException{
        while(st==null || !st.hasMoreTokens())
        st=new StringTokenizer(br.readLine());
        return st.nextToken();
    }
    String nextLine()throws IOException{
        return br.readLine();
    }
    int nextInt()throws IOException{
        return Integer.parseInt(nextToken());
    }
    long nextLong()throws IOException{
        return Long.parseLong(nextToken());
    }
    double nextDouble()throws IOException{
        return Double.parseDouble(nextToken());
    }
}

Measured memory_bytes: 44780
#include <bits/stdc++.h>
#define loop(n, i) for(int i=0;i<n;i++)
#define loop1(n, i) for(int i=1;i<=n;i++)
#define rloop(n, i) for(int i=n;i;i++)
#define HERE cout << "HERE: " << __LINE__ << endl;
#define INSP(v) cout << v << " at " << __LINE__ << endl;
using namespace std;
using ll = long long;
template <class T>
using V = vector<T>;
using P = pair<int, int>;

int n, m;
V<P> G[100010];
int vis[100010] = {};
int evis[100010] = {};
V<P> A;

int dfs(int crr) {
    vis[crr] = 1;
    V<P> E;
    int children = 0;

    for (auto next : G[crr]) {
        if (vis[next.first]) {
            E.push_back(next);
            continue;
        }
        evis[next.second] = 1;
        if (dfs(next.first)) {
            children++;
            A.push_back({ crr, next.first });
        } else {
            A.push_back({ next.first, crr });
        }
    }

    for (auto e : E) {
        if (evis[e.second]) continue;
        evis[e.second] = 1;
        children++;
        A.push_back({ crr, e.first });
    }

    return (children % 2) == 0;
}

int main() {
    cin >> n >> m;
    loop (m, i) {
        int a, b; cin >> a >> b;
        G[a].push_back({ b, i });
        G[b].push_back({ a, i });
    }

    if (dfs(1)) {
        for (auto a : A) {
            cout << a.first << " " << a.second << endl;
        }
    } else {
        cout << -1 << endl;
    }
    return 0;
}



Measured memory_bytes: 19444
import java.util.*;
class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    String str = scan.nextLine();
    if(str.equals("Rainy")){
      System.out.println("Sunny");
    }else if(str.equals("Sunny")){
      System.out.println("Cloudy");
    }else{
      System.out.println("Rainy");
    }
  }
 }

Measured memory_bytes: 21716
#include<stdio.h>

#define INITIALIZE_INT 0//整数型の初期値
#define INPUT_END 0//入力の終了値
#define START_NUMBER 1//魔方陣に入る最初の数値
#define CALCULATION_HALF 2 //魔方陣のマスのセンター座標を求めるときに使う値
#define NO_CONTENTS 0//空のマスの値
enum
{
	OFF, //すべてのパネルが埋まっていない状態
	ON   //すべてのパネルが埋まっていない状態
};

void out_magic_square(short *x, short *y, unsigned short input_n);/*現在の座標が魔方陣の外に出た時、座標の修正を行う関数*/

int main(void)
{
	while(1)
	{
		short x = INITIALIZE_INT;//魔方陣のx座標
		short y = INITIALIZE_INT;//魔方陣のy座標
		
		unsigned short input_n = INITIALIZE_INT;//入力値n
		scanf("%hd", &input_n);
		
		/*入力の終了*/
		if(INPUT_END == input_n)
		{
			break;
		}
		
		short ix = INITIALIZE_INT;
		short iy = INITIALIZE_INT;
		
		unsigned short loop_flag = OFF;//すべてのマスが埋まっているかどうかのフラグ
		unsigned short center = INITIALIZE_INT;//センター座標を格納
		unsigned short number = START_NUMBER;//格納していく数字
		
		short magic_square[input_n][input_n];//魔方陣のマス
		
		/*魔方陣のマスの初期化*/
		for(iy = 0; iy < input_n; iy++)
		{
			for(ix = 0; ix < input_n; ix++)
			{
				magic_square[iy][ix] = NO_CONTENTS;
			}
		}
		
		/*最初の数字を入れるマスの座標を求める*/
		center = input_n / CALCULATION_HALF;
		x = center;
		y = center - 1;
		magic_square[y][x] = number;
		number++;
		
		while(1)
		{
			x++;
			y--;
			out_magic_square(&x, &y, input_n);
			
			/*中身のないマスに数字を入れる*/
			if(NO_CONTENTS == magic_square[y][x])
			{
				magic_square[y][x] = number;
				number++;
			}
			
			/*中身がある場合に行う*/
			else if(NO_CONTENTS != magic_square[y][x])
			{
				
				/*マスに数字が入るまで繰り返す*/
				while(1)
				{
					x--;
					y--;
					out_magic_square(&x, &y, input_n);
					if(NO_CONTENTS == magic_square[y][x])
					{
						magic_square[y][x] = number;
						number++;
						break;
					}
				}
			}
			
			/*魔方陣がすべての埋まっているか埋まっていないかの判定*/
			loop_flag = OFF;
			for(iy = 0; iy < input_n; iy++)
			{
				for(ix = 0; ix < input_n; ix++)
				{
					if(NO_CONTENTS == magic_square[iy][ix])
					{
						loop_flag = ON;
					}
				}
			}
			if(OFF == loop_flag )
			{
				break;
			}
		}
		
		/*結果の出力*/
		for(iy = input_n - 1; iy >= 0; iy--)
		{
			for(ix = 0; ix < input_n; ix++)
			{
				printf("%4d", magic_square[iy][ix]);
			}
			printf("\n");
		}
	}
	return 0;
}

/*自分がいる座標が魔方陣の外に出た時、座標の修正を行う関数*/
void out_magic_square(short *x, short *y, unsigned short input_n)
{
	if(*x >= input_n )
	{
		*x = 0;
	}
	if(*y < 0)
	{
		*y = input_n - 1;
	}
	if(*x < 0)
	{
		*x = input_n - 1;
	}
}

Measured memory_bytes: 616
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;

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

	int n, i, j, k, c;
	cin >> n;
	k = 1; 
	while (k * (k - 1) / 2 < n) k++;

	if (k * (k - 1) / 2 > n) cout << "No\n";
	else {
		cout << "Yes\n";
		cout << k << "\n";

		vector<vector<int>> ans;
		vector<int> ct(n, 0);
		vector<int> v;

		for (i = 0; i < k - 1; i++) {
			v.push_back(i);
			ct[i]++;
		}
		ans.push_back(v);
		c = k - 1;

		vector<int> p(k, 0);
		for (i = 1; i < k; i++) {
			v.clear();
			for (j = 0; j < i; j++) {
				while (ct[ans[j][p[j]]] == 2) p[j]++;
				v.push_back(ans[j][p[j]++]);
			}
			while (v.size() < k - 1) {
				v.push_back(c++);
			}
			ans.push_back(v);
			for (auto p : v) ct[p]++;
		}

		for (auto p : ans) {
			cout << p.size() << " ";
			for (auto pp : p) cout << pp + 1 << " ";
			cout << "\n";
		}
	}

	return 0;
}


Measured memory_bytes: 2560
import math
from functools import reduce

n = int(input())
ans = 0
for i in range(1, n + 1):
    for j in range(1, n + 1):
        t = math.gcd(i, j)
        for k in range(1, n + 1):
            ans += math.gcd(t, k)
print(ans)


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

using namespace std;

string s;

int main(){
	cin >> s;
	reverse(s.begin(), s.end());
	int pos = 0;
	while(pos < s.size()){
		if(s.substr(pos, 5) == "maerd") pos += 5;
		else if(s.substr(pos, 7) == "remaerd") pos += 7;
		else if(s.substr(pos, 5) == "esare") pos += 5;
		else if(s.substr(pos, 6) == "resare") pos += 6;
		else{
			cout << "NO" << endl;
			return 0;
		}
	}
	cout << "YES" << endl;
}

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

int main() {
  int n;
  string s;
  cin >> n >> s;
  
  for (int i = 0; i < s.size(); i++){
    s[i] = (s[i] - 'A' + n) % 26 + 'A';
  }
  cout << s << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <stack>
#include <iomanip>
#include <numeric>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <cassert>
#include <map>
#include <set>
#include <vector>
#include <utility>
#include <queue>
#include <cmath>

#define BEGIN(x) x.begin()
#define END(x) x.end()
#define ALL(x) BEGIN(x), END(x)
#define PAIR make_pair
#define VEC(type) vector<type >
#define endl '\n'
#define FIR first
#define SEC second
#define PB push_back
#define SZ(x) ((int)x.size())

#define FOR(i, A, B) for(auto i = (A);i != (B); i++)
#define FORD(i, A, B) for(auto i = (A);i != (B); i--)

#define READRANGE(begin, end) FOR(it, begin, end) cin >> *it
#define READVEC(V) READRANGE(BEGIN(V), END(V))

using namespace std;

typedef long long lint;
typedef pair<int, int> Pii;
typedef pair<int, lint> Pil;
typedef pair<lint, lint> Pll;
typedef pair<lint, int> Pli;

template<class U, class V>
istream& operator >>(istream& in, pair<U, V>& pr) {
    return in >> pr.first >> pr.second;
}

template<class U, class V>
ostream& operator <<(ostream& out, pair<U, V>& p) {
    return out << p.first << " " << p.second;
}

template<class T>
ostream& operator <<(ostream& out, vector<T> vec) {
    for (T& e : vec)
        out << e << " ";
    return out << endl;
}

// ---- BEGIN LIBRARY CODE ----
// ---- END LIBRARY CODE ----
void io_init()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
};

void solveSingleCase(int caseNo)
{
    string S;
    cin >> S;
    VEC(bool) present(26, false);
    for (char c : S)
        present[c - 'a'] = true;

    char ret = 'A';
    FOR(i, 0, 26)
        if (!present[i]) {
            ret = (char)('a' + i);
            break;
        }

    cout << (ret == 'A' ? "None" : string(1, ret)) << endl;
};

int main(int argc, char **argv)
{
    io_init();

    // Actual program code starts here.
    int T = 1;
    // cin >> T;
    FOR(tcase, 1, T + 1) {
        solveSingleCase(tcase);
    }
    return 0;
};


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

int main() {
	int N;
	string A, B, C;
	cin >> N >> A >> B >> C;
	int ans = 0;
	rep(i, N) {
		if (A.at(i) != B.at(i) && B.at(i) != C.at(i) && C.at(i) != A.at(i)) ans += 2;
		else if (A.at(i) == B.at(i) && B.at(i) == C.at(i));
		else ans++;
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;

int main() {
	int n, m;
	string a[50], b[50],ans="No";
	cin >> n >> m;
	for (int i = 0; i < n; i++) {
		string tmp;
		cin >> tmp;
		a[i] = tmp;
	}
	for (int i = 0; i < m; i++) {
		string tmp;
		cin >> tmp;
		b[i] = tmp;
	}
	for (int x = 0; x <= n - m; x++) {
		for (int y = 0; y <= n - m; y++) {
			for (int i = 0; i < m*m; i++) {
				if (a[y + i / m][x + i%m] != b[i / m][i%m]) {
					break;
				}
				if (i == m*m - 1)ans = "Yes";
			}
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
package main

import (
  "fmt"
)

func convert(s string) int {
  if s == "H" {return 1}
  return 0
}

func main() {
  var a, b string; fmt.Scan(&a, &b)
  ans := "H"; if convert(a) ^ convert(b) == 1 {ans = "D"}
  fmt.Println(ans)
}

Measured memory_bytes: 512
#include <stdio.h>

int a[100000];

int main(void)
{
	int n;
	int i, j, sum;
	
	for (i = 2; i <= 50000; i++)a[i] = 1;
	
	for (i = 2; i * i <= 50000; i++){
		if (a[i] == 1){
			for (j = i * i; j <= 50000; j += i)a[j] = 0;
		}
	}
	
//	for (i = 0; i <= 100; i++)printf("a[%d]=%d\n", i, a[i]);
	while (1){
		sum = 0;
		scanf("%d", &n);
		if (n == 0)return (0);
		
		for (i = 0; i <= 50000; i++){
			if (a[i] == 1 && n - i >= i && a[n - i] == 1){
				sum += 1;
//				printf("%d %d\n", i, n - i);
			}
		}
		printf("%d\n", sum);
	}
	
}

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

#define ull unsigned long long
#define ul unsigned long
#define ll long long
#define size_t long long
// std::sort(&a[0], &a[4], [](auto& x, auto& y){return x[0] < y[0];});
//accumulate(&arr2[n], &arr2[m-1], 0);
using namespace std;

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

  int N,A,B;
  std::cin >> N >> A >> B;

  std::cout << min(N*A,B) << '\n';

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int n;
    long long a[100];
    a[0]=2;
    a[1]=1;
    std::cin >> n;
    for (int i = 2; i <= n; i++) {
        a[i]=a[i-1]+a[i-2];
    }
    std::cout << a[n] << std::endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)n; ++i)
#define all(obj) (obj).begin(), (obj).end()
static const int dx[4] = { 0, 1, 0, -1 };
static const int dy[4] = { 1, 0, -1, 0 };
static const char dir[4] = { 'u', 'r', 'd', 'l' };
static const ll INF = 1 << 21;
static const ll MOD = 1e9 + 7;
string s;

signed main()
{
    cin >> s;
    int l = 0, r = s.size() - 1;
    int cnt = 0;
    while (l < r) {
        if (s[l] == s[r]) {
            ++l;
            --r;
        } else if (s[l] == 'x') {
            ++l;
            ++cnt;
        } else if (s[r] == 'x') {
            --r;
            ++cnt;
        } else {
            cout << -1 << endl;
            return 0;
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 512
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int isPrimeNum( int x )
{
    int i;

    for( i = 2; i <= sqrt((double)x); i++ )
        if( x % i == 0 ) return 0;
    return 1;
}

int main(){
  int num;
  int i,j;
  int *array;
  int count = 0;

  do{
  scanf("%d",&num);
  }while(num < 1 || num > 10000);

  array = (int *)malloc(sizeof(int)*num);

  for(i = 0;i < num;i++){
    do{
    scanf("%d",&array[i]);
    }while(array[i]<2 || array[i]>100000000);
  }

  for(i = 0;i < num;i++) {
        if( isPrimeNum( array[i] ) ) {
	  count++;
        }
    }

  printf("%d\n",count);
  
  free(array);
  
  return 0;
}


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

public class Main {

	public static void main(String[] args) {
		Scanner stdin = new Scanner(System.in);
		int k = 0, n = 0;
		boolean b = true;
		n = stdin.nextInt();
		int[] a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = stdin.nextInt();
			k = k + a[i];
			if (a[i] % 10 != 0) {
				b = false;
			}
		}
		Arrays.sort(a);
		if (b) {
			System.out.println(0);
		} else {
			if (k % 10 != 0) {
				System.out.println(k);
			} else {
				for (int j = 0; j < n; j++) {
					if (a[j] % 10 != 0) {
						k = k - a[j];
					}
					if (k % 10 != 0) {
						System.out.println(k);
						break;
					}
				}
			}
		}

	}
}


Measured memory_bytes: 21844
import sys
sys.setrecursionlimit(100000)
class UnionFind:
    def __init__(self, n):
        # 親要素のノード番号を格納
        # par[x]=xの時そのノードは根　
        self.par = [-1] * n
        # rank
        self.size = [1] * n

    def find(self, x):
        # 根の番号を返す(所属する集合を確認する)
        if self.par[x] < 0:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    def check(self, x, y):
        # x,yが同じ集合に属するかどうか調べる
        return self.find(x) == self.find(y)


    def union(self, x, y):
        # 根を探す
        x = self.find(x)
        y = self.find(y)
        if x == y:return
        self.par[y]=x
        self.size[x]+=self.size[y]

import sys
input=sys.stdin.readline
n,m,k=map(int,input().split())
uf=UnionFind(n)
out=[[] for i in range(n)]

for i in range(m):
    a,b=map(int,input().split())
    uf.union(a-1,b-1)
    out[a-1].append(b-1)
    out[b-1].append(a-1)

for i in range(k):
    c,d=map(int,input().split())
    if uf.check(c-1,d-1):
        out[c-1].append(d-1)
        out[d-1].append(c-1)

for i in range(n):
    ans=uf.size[uf.find(i)]-1-len(out[i])
    print(ans,end=' ')


Measured memory_bytes: 56984
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define ll long long
#define ld long double
#define all(a) a.begin(),a.end()
#define endl '\n'
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ull unsigned long long
#define int long long
#define iter vector<int>::iterator
using namespace std;
using namespace __gnu_pbds;

template<class T>
using ordered_set=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

template<class T>
using ordered_multiset=tree<T,null_type,less_equal<T>,rb_tree_tag,tree_order_statistics_node_update>;

mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
mt19937_64 rnd1(chrono::steady_clock::now().time_since_epoch().count());

//find_by_order
//order_of_key

const int N=2e5+7;
const int inf=1e18+5;
const int mod=1e9+7;

vector<int>pos[N];

main ()
{
    ios;
    string s,t;
    cin>>s>>t;
    int n=s.size();
    s="#"+s;
    int pos1=0;
    int ans=0;
    for (int i=1;i<s.size();++i){
        pos[s[i]-'a'].pb(i);
    }
    for (int i=0;i<t.size();++i){
        int ch=t[i]-'a';
        if (pos[ch].size()==0){
            cout<<-1<<endl;
            exit(0);
        }
        iter it=upper_bound(all(pos[ch]),pos1);
        if (it==pos[ch].end()){
            ans+=n-pos1;
            int pos2=pos[ch][0];
            ans+=pos2;
            pos1=pos2;
        }
        else {
            int pos2=*it;
            ans+=pos2-pos1;
            pos1=pos2;
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 6504
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::{Bytes, Chars};
#[allow(unused_imports)]
use std::cmp::{min, max};
use std::collections::VecDeque;

fn main() {
	input! {
		n: usize,
		m: usize,
		ab: [(usize, usize); m]
	}

	let inf: usize = 9999999999999;
	let mut ans = 0;

	for x in 0..m {
		// グラフを生成
		let mut v: Vec<Vec<usize>> = vec![vec![]; n];
		for i in 0..m {
			if i == x {
				continue;
			}
			v[ab[i].0-1].push(ab[i].1-1);
			v[ab[i].1-1].push(ab[i].0-1);
		}

		let mut d = vec![inf; n];
		let mut q = VecDeque::new();
		d[0] = 0;
		q.push_back((0usize, 0usize));	// スタートノード, 距離

		while q.len() > 0 {
			let tmp = q.pop_front().unwrap();
			for i in 0..v[tmp.0].len() {
				if d[v[tmp.0][i]] != inf {
					continue;
				}
				d[v[tmp.0][i]] = tmp.1 + 1;
				q.push_back((v[tmp.0][i], tmp.1 + 1));
			}
		}
		// 全ノードに到達したか確認
		for i in 0..n {
			if d[i] == inf {
				ans += 1;
				break;
			}
		}
	}
	println!("{}", ans);
}



Measured memory_bytes: 2188
#include<bits/stdc++.h>
using namespace std;
#define F(A) (A=='#')
const int N=2010;
int g[N][N];
char s[N][N];
int stk[N];
int ht[N][N];
void print(int a[][2010],int n,int m){
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++) printf("%d",a[i][j]);
		cout<<endl;
	}
	cout<<endl;
}
int main(){
//	freopen("in","r",stdin);
	//freopen("out","w",stdout);
	int n,m;
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++) scanf("%s",s[i]+1);
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			int sum=0;
			sum+=F(s[i][j])+F(s[i+1][j])+F(s[i][j+1])+F(s[i+1][j+1]);
			g[i][j]=sum&1^1;
		}
	}
	int ans=max(n,m);
	n--,m--;
	for(int i=n;i;i--){
		for(int j=1;j<=m;j++){
			if(g[i][j]) ht[i][j]=ht[i+1][j]+1;
		}
	}
	//print(g,n,m);
	//print(ht,n,m);
	for(int i=1;i<=n;i++){
		int top=0;
		for(int j=1;j<=m+1;j++){
			while(top&&ht[i][stk[top]]>=ht[i][j]){
				ans=max(ans,(j-stk[top-1])*(ht[i][stk[top]]+1));
				top--;
			}
			stk[++top]=j;
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 35712
#include<iostream>
#include<string>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<functional>
using namespace std;
int main(void) {
    
   int x,t;
   cin>>x>>t;

    if(x-t>0)   cout<<x-t<<endl;
    else cout<<0<<endl;

    return 0;
}

Measured memory_bytes: 256