akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
using namespace std;
double fie[55][55];
long long int fieN[55][55];
int main(){
    long long int N,A,B;
    cin>>N>>A>>B;
    long long int vv[100];
    for(int i=0;i<N;i++)cin>>vv[i];
    sort(vv,vv+N);
    for(int i=0;i<N/2;i++)swap(vv[i],vv[N-i-1]);
    fieN[0][0]=1;
    for(int i=0;i<N;i++){
        for(int j=0;j<=N;j++){
            if(fieN[i][j]==0)continue;
            if(fabs(fie[i][j]-fie[i+1][j])<0.01){
                fieN[i+1][j]+=fieN[i][j];
            }
            else if(fie[i][j]>fie[i+1][j]){
               fie[i+1][j]=fie[i][j];fieN[i+1][j]=fieN[i][j];
            }
            if(fabs((fie[i][j]*(long double)j+(long double)vv[i])/(long double)(j+1)-fie[i+1][j+1])<0.01){
                fieN[i+1][j+1]+=fieN[i][j];
            }
            else if((fie[i][j]*(long double)j+(long double)vv[i])/(long double)(j+1)>fie[i+1][j+1]){
                fie[i+1][j+1]=(fie[i][j]*(long double)j+(long double)vv[i])/(long double)(j+1);fieN[i+1][j+1]=fieN[i][j];
            }

        }
    }
/*
    for(int i=0;i<6;i++){
        for(int j=0;j<6;j++){
            printf("[%5f]",fie[i][j]);
        }
        puts("");
    }
    puts("=======\n");
    for(int i=0;i<6;i++){
        for(int j=0;j<6;j++){
            printf("[%5d]",fieN[i][j]);
        }
        puts("");
    }
*/
    double ans=-1;
    long long int ansN;
    for(int i=A;i<=B;i++){
        if(fieN[N][i]==0)continue;
        if(fabs(ans-fie[N][i])<0.01){
            ansN+=fieN[N][i];
        }
        else if(ans<fie[N][i]){
            ans=fie[N][i];
            ansN=fieN[N][i];
        }
    }
    printf("%.12lf\n%lld\n",ans,ansN);
    return 0;
}


Measured memory_bytes: 256
xs,ys,xg,yg = map(int, input().split())
n = int(input())
xyr=[list(map(int,input().split())) for i in range(n)]

import math
from collections import defaultdict
link = defaultdict(list)
dist = math.sqrt((xs-xg)**2 + (ys-yg)**2)
link[10000].append([20000,dist])

for i in range(n):
    x,y,r = xyr[i]

    dist = math.sqrt((x-xs)**2 + (y-ys)**2) - r
    dist = max(0,dist)
    link[10000].append([i,dist])

    dist = math.sqrt((x-xg)**2 + (y-yg)**2) - r
    dist = max(0,dist)
    link[i].append([20000,dist])

for i in range(n):
    for j in range(i+1,n):
        x1,y1,r1=xyr[i]
        x2,y2,r2=xyr[j]

        dist = math.sqrt((x1-x2)**2 + (y1-y2)**2) - r1 - r2
        dist = max(0,dist)
        link[i].append([j,dist])
        link[j].append([i,dist])

from heapq import heappush, heappop,heappushpop,heapify
from collections import defaultdict
def dks(g,start):
    visited = set()
    hq = []
    heappush(hq, (0,start))

    cost = defaultdict(lambda: float("inf"))
    while hq:
        shortest, i = heappop(hq)
        if i in visited:
            continue
        visited.add(i)
        cost[i] = shortest
        for j, t in g[i]:
            if j in visited:
                continue
            heappush(hq, (shortest + t, j))
    return cost

res = dks(link,10000)
print(res[20000])

Measured memory_bytes: 201480
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<queue>
#include<climits>
#include<set>
#include<map>
#define ll long long
using namespace std;

int main() {
	ll n;
	cin >> n;
	if (n >= 3) {
		cout << n / 3 << endl;
	}
	else {
		cout << "0" << endl;
	}
}

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

using namespace std;

int main(){
  int a, b;
  cin >> a >> b;
  string s;
  cin >> s;
  int f = 0;
  for(int i = 0; i < a; i++){
    if(s[i] - '0' < 0 || s[i] - '0' > 9){
      f = 1;
      break;
    }
  }
  if(s[a] != '-') f = 1;
  for(int i = a+1; i < a+b+1; i++){
    if(s[i] - '0' < 0 || s[i] - '0' > 9){
      f = 1;
      break;
    }
  }
  if(f) cout << "No";
  else cout << "Yes";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < n; ++i)
#define sz(x) int(x.size())
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())
#define FORV(i, v) for (auto i = v.begin(); i != v.end(); i++)
using namespace std;

using ll = int64_t;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const int INF = 1001001001;
const ll INFL = (1LL<<60);
const double eps = (1e-9);

using P = pair<int, int>;

struct Sieve {
  int n;
  vector<int> f, primes;
  // 1~n までの素数を求める
  Sieve(int n=1):n(n), f(n+1) {
    f[0] = f[1] = -1;
    for (ll i = 2; i <= n; ++i) {
      if (f[i]) continue;
      primes.push_back(i);
      f[i] = i;
      for (ll j = i*i; j <= n; j += i) {
        if (!f[j]) f[j] = i;
      }
    }
  }
  bool isPrime(int x) { return f[x] == x;}
  vector<int> factorList(int x) {
    vector<int> res;
    while (x != 1) {
      res.push_back(f[x]);
      x /= f[x];
    }
    return res;
  }
  // 素因数分解の結果を返す
  vector<P> factor(int x) {
    vector<int> fl = factorList(x);
    if (fl.size() == 0) return {};
    vector<P> res(1, P(fl[0], 0));
    for (int p : fl) {
      if (res.back().first == p) {
        res.back().second++;
      } else {
        res.emplace_back(p, 1);
      }
    }
    return res;
  }
};

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

  int q;
  cin >> q;

  Sieve sieve(1e5);

  vector<int> w(100001, 0);
  for (int i = 1; i < 100001; i++) {
    w[i] = w[i-1];
    if (i % 2 == 0) continue;

    if (sieve.isPrime(i) && sieve.isPrime((i+1) / 2)) {
      w[i] += 1;
    }
  }

  rep(i, q) {
    int l, r;
    cin >> l >> r;
    cout << w[r] - w[l-1] << endl;
  }

  return 0;
}


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

char c;
string ans = "consonant";

void f(char x) {
	if (c == x) {
		ans = "vowel";
	}
}

int main() {
	cin >> c;
	f('a');
	f('i');
	f('u');
	f('e');
	f('o');
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 384
main(){
  int a,b,i,gcd=1;        /* The gcd is the greatest common divisor. */

  scanf("%d%d",&a,&b);    /* Scaning two natural numbers a and b */
  
  if(a<1||a>10e9||b<1||b>10e9){
    return 0;
  }                       /* Constrants: 1<=a,b<=10e9 */

  for(i=2;a>=2||b>=2;i++){
    while(a%i==0||b%i==0){
      if(a%i==0&&b%i==0){
	gcd = gcd * i;   /* Multiply the common prime factor. */
	a = a/i;
	b = b/i;
      }
      else if(a%i==0)a = a/i;
      else b = b/i;
    }
  }

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

Measured memory_bytes: 0
#include<iostream>
#include<string>
#include<cstring>
#include<vector>
#include<set>
typedef long long ll;
using namespace std;
typedef vector<int> vi;
int n,m,a,b,c,t;
typedef pair<int,int> pii;
typedef vector<vector<int> > Matrix;

Matrix mul(const Matrix& A,const Matrix & B, const int mod)
{
  Matrix C(A.size(),vector<int>(B[0].size()));
  for(int i=0;i<A.size();i++)
    {
      for(int k=0;k<B.size();k++)
	{
	  for(int j=0;j<B[0].size();j++)
	    {
	      C[i][j]=(C[i][j]+A[i][k]*B[k][j])%mod;
	    }
	}
    }
  return C;
}

Matrix pow(Matrix A,int n,int mod)
{
  Matrix B(A.size(),vector<int>(A.size()));
  for(int i=0;i<A.size();i++)
    {
      B[i][i]=1;
    }
  while(n)
    {
      if(n&1) B=mul(B,A,mod);
      A=mul(A,A,mod);
      n>>=1;
    }
  return B;
}

int main()
{
  while(cin >> n >> m >> a >> b >> c >> t && n)
    {
      Matrix B(n,vector<int>(1));
      for(int i=0;i<n;i++)
	{
	  cin >> B[i][0];
	}
      Matrix A(n,vector<int>(n));
      for(int i=0;i<n;i++)
	{
	  if(i-1>=0) A[i][i-1]=a;
	  A[i][i]=b;
	  if(i+1<n) A[i][i+1]=c;
	}
      A=pow(A,t,m);
      A=mul(A,B,m);
      for(int i=0;i<n;i++)
	{
	  cout << A[i][0] << (i+1==n ? '\n':' ');
	}
    }
  return 0;
}



Measured memory_bytes: 3152
n = int(input())
a = [int(i) for i in input().split()]
approved = True

for i in range(n):
    if a[i] % 2 == 0:
        if a[i] % 3 == 0 or a[i] % 5 == 0:
            pass
        else:
            approved = False

if approved:
    print('APPROVED')
else:
    print('DENIED')

Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <string>
#include <bitset>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define fin(ans) cout<<(ans)<<endl
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p,q)
#define pb(n) push_back(n)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define Sort(a) sort(a.begin(),a.end())
#define Rort(a) sort(a.rbegin(),a.rend())
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
const int P = 1000000007;
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;




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

int n,l;
cin >> n >> l;
vi taste(n);
vi abstaste(n);
int target = 0;
rep(i,n){
    taste[i] = l+i;
    abstaste[i] = abs(taste[i]);
    target += taste[i];
}
Sort(abstaste);
rep(i,n){
    if(abs(taste[i]) == abstaste[0]){
        cout << target - taste[i] << endl;
        return 0;
    }
}

//////////////////////////////////////////////////////
return 0;}

Measured memory_bytes: 384
#include <cstdio>
#include <iostream>
#include <string>

using namespace std;

int J, Y;

void t(int j, int y, string str)
{
	if(j > J || y > Y) return;
	if(j == J && y == Y){
		cout << str << endl;
		return;
	}
	if(j == 5 && y == 5){
		return;
	}
	if((j <= 3 && y >= 5) || (j >= 5 && y <= 3)){
		return;
	}
	
	t(j + 1,y,str + "A");
	t(j,y + 1,str + "B");
}

int main()
{
	scanf("%d %d", &J, &Y);
	
	t(0, 0, "");
}

Measured memory_bytes: 1224
if __name__ == '__main__':
    N = int(input())
    a = list(map(int, input().split()))

    result_counter = [0 for i in range(100001)]
    for number in a:
        if number == 0:
            result_counter[0] += 1
            result_counter[1] += 1
        else:
            result_counter[number - 1] += 1
            result_counter[number] += 1
            result_counter[number + 1] += 1

    print(max(result_counter))


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

typedef long long ll;

int main(){
  ll l,r; cin >> l >> r;
  ll ans = 2019;
  if(((l-1)/2019+1)*2019<=r){
    ans = 0;
  }else{
    for(ll i=l;i<=r;i++)
      for(ll j=i+1;j<=r;j++)
        ans = min(ans,(i*j)%2019);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
from collections import Counter

C = [[0]*(61) for _ in range(61)]

for i in range(61):
    C[i][0] = 1
    
    for j in range(1, 61):
        C[i][j] = C[i-1][j-1]+C[i-1][j]

N, A, B = map(int, input().split())
v = list(map(int, input().split()))
v.sort(reverse=True)
cnt1 = Counter(v)
S = sum(v[:A])
print(S/A)

ans = 0

for i in range(A, B+1):
    s = sum(v[:i])
    
    if s*A!=S*i:
        break
    
    cnt2 = Counter(v[:i])
    mark = v[:i][-1]
    ans += C[cnt1[mark]][cnt2[mark]]

print(ans)

Measured memory_bytes: 39152
#include <bits/stdc++.h>
#include <vector>
#include <string>
#include <stdlib.h>
#include <algorithm>
#include <functional>
 
using namespace std;
 
int main(void) {
    unsigned long int N = 0, P[200001], count = 1, min = 0;
    cin >> N;
    for(int i = 0 ; i < N ; i++){
        cin >> P[i];
    }
    min = P[0];
    for(int i = 1 ; i < N ; i++){
        if(P[i] < min){
            min = P[i];
            count++;
        }
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 1792
# define _CRT_SECURE_NO_WARNINGS 1
# include <iostream>
# include <string>
# include <bitset>
# include <vector>
# include <algorithm>
# include <cstdlib>
# include <cstdio>
# include <cstring>
# include <cstdlib>
# include <iomanip>
# include <queue>
# include <sstream>
# include <climits>
# include <cmath>
# include <list>
# include <functional>
# include <string>
# include <set>
# include <map>
# include <stack>
using namespace std;
# define M_PI 3.141592
# define FOR(i,n) for(int i=0;i<(int)n;i++)
# define FORI(i,k,n) for(int i=k;i<(int)n;i++)
# define toRad 2.0*M_PI/360.0
# define inin(x) int x;cin>>x;
# define all(x) x.begin(),x.end()
# define debug(x) cout<<#x<<" :"<<x<<endl;
# define rep(i,n) for(int i=0;i<(int)n;i++)
# define EPS 1e-12
# define pri_max 60000
# define CHECK(i,a) FOR(i,a.size())cout<<#a<<"["<<i<<"] : "<<a[i]<<endl; 
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef vector<int> vi;
typedef vector<vi> vvi;


int main()
{
	int t;
	while (cin >> t&&t)
	{
		int n,S=0;
		cin >> n;
		for (int i = 0; i < n; i++)
		{
			int s, e;
			cin >> s >> e;
			S += e - s;
		}
		if (S >= t)cout << "OK" << endl;
		else cout << t - S << endl;
	}
}

Measured memory_bytes: 1160
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<iostream>
#include<string>
using namespace std;


int main() {

	int n;
	int a, b;
	int ascore = 0, bscore = 0;
	for (;;) {
		cin >> n;
		if (n == 0) break;

		for (int i = 0; i < n; i++) {
			cin >> a >> b;

			if (a > b) ascore += (a + b);
			else if (a < b)bscore += (a + b);
			else {
				ascore += a;
				bscore += b;
			}



		}

		printf("%d %d\n", ascore, bscore);
		ascore = 0;
		bscore = 0;
	}

	//system("pause");
	return 0;
}


Measured memory_bytes: 3160
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;

using System.Collections;

class Program
{
    static void Main()
    {
        int[] ab = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
        int A = ab[0];
        int B = ab[1];

        if (A >= 13)
        {
            Console.WriteLine(B);
        }
        else if (A >= 6)
        {
            Console.WriteLine(B / 2);
        }
        else
        {
            Console.WriteLine(0);
        }
    }    
}

Measured memory_bytes: 13268
#include<stdio.h>
#include<string.h>
int main()
{
     char n[3];
     scanf("%s",&n);
     for(int i=0;i<3;i++){
          if(n[i]=='7'){
               printf("Yes\n");
               return 0;
          }
     }
     printf("No\n");
}


Measured memory_bytes: 1592
/* ＵＴＦ－８ */
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <array>
#include <queue>
#include <stack>
#include <algorithm>
#include <tuple>
#include <numeric>
#include <type_traits>
#include <limits>

#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <string.h>

#define USE_COLORED 1

#ifdef USE_COLORED
static const char stdout_pre[]  = "\033[1m"; // bold black
static const char stderr_pre[]  = "\033[31;1m"; // bold red
static const char stdxxx_post[] = "\033[m";

// 当然ながら GCC(g++)/libstdc++ 依存
#include <ext/stdio_filebuf.h>
using stdio_filebuf = __gnu_cxx::stdio_filebuf<char>;
class colored_stdio_filebuf : public stdio_filebuf {
private:
	const char* const pre_;
	const char* const post_;

public:
	colored_stdio_filebuf(FILE* fp, const char* pre, const char* post) : stdio_filebuf(fp, std::ios_base::out), pre_(pre), post_(post)
	{
	}

protected:
	std::streamsize xsputn(const char* s, std::streamsize count) override
	{
		stdio_filebuf::xsputn(pre_, strlen(pre_));
		auto ret = stdio_filebuf::xsputn(s, count);
		stdio_filebuf::xsputn(post_, strlen(post_));
		return ret;
	}
};
#endif

int main()
{
#ifdef USE_COLORED
	if (getenv("DEBUG")) {
		std::cout.rdbuf(new colored_stdio_filebuf(stdout, stdout_pre, stdxxx_post));
		std::cerr.rdbuf(new colored_stdio_filebuf(stderr, stderr_pre, stdxxx_post));
	} else
#endif
	{
		int fd = open("/dev/null", O_WRONLY);
		dup2(fd, 2);
		close(fd);
	}
	
	int N;
	std::vector<std::string> S;
	std::cin >> N;
	S.resize(N);
	for (auto& s : S)
		std::cin >> s;

	int maxoccur = 0;
	std::map<std::string, int> occur;
	for (auto& s : S) {
		maxoccur = std::max(maxoccur, ++occur[s]);
	}

	for (auto& p : occur) {
		if (p.second == maxoccur)
			std::cout << p.first << "\n";
	}
}


Measured memory_bytes: 26752
#include <bits/stdc++.h>
using namespace std;
const long long mod = pow(10, 9) + 7;
const long long MOD = 998244353;
const long long INF = 1LL << 60;
const int inf = pow(10, 9) + 7;
template <class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template <class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
int divCeil(int a, int B) {return (a + (B - 1)) / B;}
long long divCeil(long long a, int B) {return (a + (B - 1)) / B;}
long long divCeil(int a, long long B) {return (a + (B - 1)) / B;}
long long divCeil(long long a, long long B) {return (a + (B - 1)) / B;}

int main()
{
  int N;
  cin >> N;
  vector<long long> a(N);
  for (int i = 0; i < N; i++)
  {
    cin >> a.at(i);
  }
  
  sort(a.begin(), a.end());
  a.push_back(inf);

  long long ans = 0;
  for (int i = 1, j = 1; i < N + 1; i++)
  {
    if (a.at(i) == a.at(i - 1)) j++;
    else
    {
      if (a.at(i - 1) <= j) ans += j - a.at(i - 1);
      else ans += j;
      j = 1;
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 1792
#include <stdio.h> 

#include <iostream>
using namespace std;

int main() {
    int num;
    int dig;
    int sum = 0;
    int tmp;
    cin >> num;
    tmp = num;
    while(num){ 
      dig = num % 10; 
      sum = sum + dig; 
      num = num / 10; 
    } 
    num = tmp;
    if(num % sum == 0){
      cout << "Yes" << endl;
    }else{
      cout << "No" << endl;
    }

}

  


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int[] p = new int[n];
        for (int i = 0 ; i < n ; i++) {
            p[i] = sc.nextInt() - 1;
        }
        int[] x = new int[m];
        int[] y = new int[m];
        for (int i = 0 ; i < m ; i++) {
            x[i] = sc.nextInt() - 1;
            y[i] = sc.nextInt() - 1;
        }

        UnionFindTree uf = new UnionFindTree(n);
        for (int i = 0 ; i < m ; i++) {
            uf.union(x[i], y[i]);
        }
        int count = 0;
        for (int i = 0 ; i < n ; i++) {
            if (uf.same(i, p[i])) count++;
        }
        System.out.println(count);

    }

}

class UnionFindTree {
    int[] parent;
    int[] rank;

    public UnionFindTree(int size) {
        this.parent = new int[size];
        this.rank = new int[size];

        for (int i = 0 ; i < size ; i++) {
            makeSet(i);
        }
    }
    /*
     * UnionFindを初期化
     * はじめはすべての頂点が根
     * はじめはすべての高さは1
     */
    public void makeSet(int i) {
        parent[i] = i;
        rank[i] = 0;
    }

    /*
     * 引数の属する木のルートのIDを返す
     */
    public int find(int i) {
        if (i != parent[i]) {
            parent[i] = find(parent[i]);
        }
        return parent[i];
    }

    /*
     * 引数を同じ集合に追加する。
     * その際に木構造もいい感じにいじくる。
     */
    public void union(int x, int y) {
        int xRoot = find(x);
        int yRoot = find(y);

        if (rank[xRoot] > rank[yRoot]) {
            parent[yRoot] = xRoot;
        } else if (rank[xRoot] < rank[yRoot]) {
            parent[xRoot] = yRoot;
        } else if (xRoot != yRoot) {
            parent[yRoot] = xRoot;
            rank[xRoot]++;
        }
    }

    /*
     * 同じ木に属しているか
     */
    public boolean same(int x, int y) {
        return find(x) == find(y);
    }
}

Measured memory_bytes: 92176
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<time.h>
#define rep(i,n)for(ll i=0;i<n;i++)
#define ll long long
#define double long double
#define pi 3.141592653589
using namespace std;
pair<ll, ll>a[114514];
signed main() {
	ll n, m, ans = 0, cnt;
	cin >> n >> m;
	rep(i, n)cin >> a[i].first >> a[i].second;
	if (n == 1)cout << max(a[0].first*a[0].second, a[0].first*m) << endl;
	else {
		sort(a, a + n);
		rep(i, n) {
			if (a[i].second <= m) {
				ans += a[i].first*a[i].second;
				m -= a[i].second;
			}
			else {
				cnt = a[i].first;
				break;
			}
		}
		cout << ans + cnt * m << endl;
	}
	getchar(); getchar(); return 0;
}

Measured memory_bytes: 1792
#include"bits/stdc++.h"
using namespace std;
using ll = int64_t;

ll N;
vector<ll> a;

int main() {
    cin >> N;
    a.resize(N);
    for (ll i = 0; i < N; i++) {
        cin >> a[i];
    }

    ll ans[] = { 0, 0 };
    for (ll i = 0; i < N; i++) {
        if (a[i] > 0) {
            ans[i % 2] += a[i];
        }
    }

    vector<bool> use(N, false);
    if (max(ans[0], ans[1]) == 0) {
        //a[i]の要素として0以下のものしかなかったということ
        //一番大きいものを一つ残すように取っていけばいい
        ll max_index = max_element(a.begin(), a.end()) - a.begin();
        cout << a[max_index] << endl;
        use[max_index] = true;
    } else if (ans[0] > ans[1]) {
        cout << ans[0] << endl;

        for (ll i = 0; i < N; i += 2) {
            if (a[i] > 0) {
                use[i] = true;
            }
        }
    } else {
        cout << ans[1] << endl;

        for (ll i = 1; i < N; i += 2) {
            if (a[i] > 0) {
                use[i] = true;
            }
        }
    }

    vector<ll> op;

    //端に使わないものがあったらそれを消す
    while (!use.front()) {
        op.push_back(1);
        use.erase(use.begin());
    }
    while (!use.back()) {
        op.push_back(use.size());
        use.erase(use.end() - 1);
    }

    //TFT ot FFFとなっている真ん中のFを消す
    while (use.size() > 1) {
        for (ll i = 1; i < (ll)use.size() - 1; i++) {
            if (use[i - 1] && !use[i] && use[i + 1]
                || !use[i - 1] && !use[i] && !use[i + 1]) {
                op.push_back(i + 1);
                use.erase(use.begin() + i);
                use.erase(use.begin() + i);
                break;
            }
        }
    }

    cout << op.size() << endl;
    for (auto i : op) {
        cout << i << endl;
    }
}

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

int H,W;
using namespace std;
int main (){
    cin >> H >> W;
    for(int i=0; i<=H+1;i++){
        for(int j=0; j<=W+1; j++){
            if(i == 0 || j == 0 || i == H+1 || j == W+1 ) cout << "#" ;
            else {
                char a;
                cin >> a;
                cout << a;
            }
        }
        cout << endl;
    }
    return 0;
}


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

// 総数を1000000007で割った余り
const long long mod = 1e9 + 7;

using ll  = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

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

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int func(long long a, long long b) {
    ios::sync_with_stdio(false);
    cin.tie(0);
    // cout << fixed << setprecision(5);

    if (b == 1) {
        cout << 0 << endl;
        return 0;
    }

    int cnt = a;
    int ans = 1;
    while (1) {
        if (cnt >= b) {
            break;
        }
        cnt += a - 1;
        ans++;
    }

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

int main() {
    long long A;
    scanf("%lld", &A);
    long long B;
    scanf("%lld", &B);

    func(A, B);

    return 0;
}


Measured memory_bytes: 256
A,B,C,K = map(float,input().split())
 
a = min(A, K)
if K-A>=0:
    b = min(abs(K-A), B)
else:
    b = 0
    c = 0

if K-A-B>=0:
    c = min(abs(K-A-B), C)
else:
    c = 0

ans = 1*a + 0*b - 1*c

print(int(ans))

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcountll

#define INF 1e16
#define mod 1000000007

string b[5] = {
R"(aa.
..b
..b)",
R"(aabc
ddbc
xwyy
xwzz)",
R"(iijjk
paa.k
p..bl
o..bl
onnmm)",
R"(aabc..
ddbc..
..aabc
..ddbc
bc..aa
bc..dd)",
R"(aa.aa.i
..b..bi
..b..bj
aa.aa.j
..b..bk
..b..bk
iijjkk.)",
};

char calc(ll k,ll i,ll j){
	return b[k][i*(k+4)+j];
}

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

  ll N;
  cin>>N;
  if(N==2){
  	cout<<-1<<endl;
  }else if(N==3){
  	cout<<b[0]<<endl;
  }else{
  	ll r=N%4;
  	ll len=r+4;
  	ll x=(N-len)/4;
  	vector<string> res(N);
  	rep(i,N)rep(j,N)res[i]+=".";
  	rep(s,x){
  		for(ll si=s*4;si<s*4+4;si++)for(ll sj=s*4;sj<s*4+4;sj++){
  			res[si][sj]=calc(1,si-s*4,sj-s*4);
  		}
  	}
  	{
  		for(ll si=N-len;si<N;si++)for(ll sj=N-len;sj<N;sj++){
  			res[si][sj]=calc(1+r,si-(N-len),sj-(N-len));
  		}
  	}
  	rep(i,N)cout<<res[i]<<"\n";
  }

  return 0;
}


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

using namespace std;

typedef long long ll;


int main (){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int N;
    cin >> N;
    unordered_set<string> v;
    for(int i = 0 ; i < N ; ++i){
        string s;
        cin >> s;
        v.insert(s);
    }
    cout << v.size() << endl;


    return 0;


}

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

int main()
{
    int n;
    scanf("%d", &n);
    int a[100000];
    for (int i = 0; i < n; i++)
    {
        scanf("%d", &a[i]);
    }
    sort(a, a + n);
    int ans = 0;
    int i = 0;
    while (i < n)
    {
        int v = a[i];
        int oc = 0;
        while (i < n && a[i] == v)
        {
            oc++;
            i++;
        }
        ans += oc % 2;
    }
    printf("%d\n", ans);
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,f1=0,f2=0,count=0;;
  cin>>n;
  int a[n];
  
  for(int i=1;i<=n;i++)
  {
   if(i%2==1) f1=1;
    cin>>a[i];
    if(a[i]%2==1) f2=1;
    if(f1==1 && f2==1) count++;
    f1=0;f2=0;
  }
  cout<<count<<endl;
  
  
 return 0; 
}

Measured memory_bytes: 3576
/*     !ya khoda!     */
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

#define ll long long
#define ld long double

#define pp push
#define po pop()
#define pb push_back
#define pf push_front
#define pob pop_back()
#define pof pop_front()
#define I insert
#define E erase

#define F first
#define S second

#define mkp make_pair
#define pll pair<ll,ll>
#define smax(a,b) a=max(a,b)
#define smin(a,b) a=min(a,b)
#define all(a) a.begin(),a.end()

#define coutghat(x)      cout<<tolower(x);
#define coutashar(x,d)   cout<<fixed<<setprecision(x)<<(ld)d
#define IOS ios_base::sync_with_stdio(false) , cin.tie(0) , cout.tie(0);

#define LB(x) ((x) & -(x))
#define BIT(a , b) (((a)>>(b)) & 1)
//#define poow(a,b,M)   b?(poow((a*a)%M,b/2)%M * (b&1?a))%M:1 ;
/*==========================================================================*/
using namespace std;
using namespace __gnu_pbds;
template <typename T> using ordered_set =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <typename T> using ordered_multiset =  tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;
ll poow(ll x,ll n,ll Mod=1e9+7) { return (n==0?1:poow(x*x%Mod,n/2)*(n&1?x:1)%Mod); }
//#pragma optimize O3
// 107,109, 211,223, 307, 401,409, 503,509, 601,607, 701,709, 809, 907, 1009
/*==========================================================================*/
const int N=1e3+100 , M=1e4+100 , SQ=sqrt(1e5) , LG=23 , base=2;
const int mod=1e9+7 , MOD=1e9+9;
const ll  INF=1e9   , inf=1e18 , super_inf=~0ull/4;
ll n,m,ed[N][N] , c[2],cc[N],dp[N] , ans;
bool vis[N];
/*==========================================================================*/
void dfs1(ll v,ll b)
{   ++c[b] , cc[v]=b , vis[v]=1;
	for(int i=0;i<n;++i)
    {
		if(i==v || ed[i][v])   continue;
		if(vis[i] && cc[i]==cc[v])
		{
			cout<<-1<<"\n";
			exit(0);
		}
		if(!vis[i])   dfs1(i,b^1);
	}
}


int main()
{
    IOS;
	cin>>n>>m;
	for(int i = 0; i < m; ++i)
    {   ll a,b;
		cin>>a>>b , a--,b--;
		ed[a][b]=ed[b][a]=1;
	}

	dp[0]=1;
	for(int i=0;i<n;++i)
    {
        if(!vis[i])
        {
			c[0]=c[1]=0;
			dfs1(i,0);
			for(int j=n;j>=0;--j)
            {   ll x=0;
				if(j>=c[0])   x|=dp[j-c[0]];
				if(j>=c[1])   x|=dp[j-c[1]];
				dp[j]=x;
			}
		}
    }

    ans=n*n;
	for(int i=0;i<=n;++i)
		if(dp[i])
			ans=min(ans , 1LL*i*(i-1)/2+(n-i)*(n-i-1)/2 );

	cout<<ans<<"\n";
	return 0;
}


Measured memory_bytes: 6400
#include <stdio.h>
#include <math.h>

void heapInsert(int);
//void heapIncreasekey(int, int);
void heapExtractMax();
void maxHeapify(int);

int parent(int i){ return i/2;}
int left(int i){ return i*2;}
int right(int i){ return i*2+1;}

int a[2000000];
int key;
int size =1;

int main(){

  char o[10];

  while(1){

    scanf("%s", o);

    if(o[0]=='e' && o[1]=='n') break;

    if(o[0]=='i'){
      scanf("%d", &key);
      heapInsert(key);     
    }
    if(o[0]=='e' && o[1]=='x'){
      heapExtractMax();
    }
  }
  return 0;
}
void heapInsert(int key){

  int i, temp;
  size++;
  
  a[size]=key;

  i=size;
  while(1<i && a[parent(i)]< a[i] ){
    temp=a[parent(i)];
    a[parent(i)]=a[i];
    a[i]=temp;
    i=parent(i);
  }
}
void heapExtractMax(){

  int max;
  
  if(size<1) printf("error\n");

  printf("%d\n", a[1]);
  max=a[1];
  a[1]=a[size];
  size--;
  maxHeapify(1);
}
void maxHeapify(int i){ //error

  int left =(i*2);
  int right=(i*2+1);
  int largest, temp;
  
  //左の子、自分、右の子でMAXを選ぶ

  if(left<=size && a[i]< a[left]){ //左の子存在、左の子より小さい
    largest=left; //あくまで節点の場所
  }else largest=i;

  if(right<=size && a[largest]<a[right]){

    largest=right;
  }

  if(largest != i){

    temp=a[largest];

    a[largest]=a[i];
    a[i]=temp;

    maxHeapify(largest);
  }
}



Measured memory_bytes: 5640
#include <iostream>
#include <set>
#include <string>
#include <algorithm>
using namespace std;

int main(){
  string S;
  char rS='a'-1;
  cin >> S;
  set<char> alp;
  set<char> word;
  set<char> res;
  string resS="";
  int flag=0;
  
  for(char s='a';s<='z';s++) alp.insert(s);
  while(flag==0){
    word.clear();
    res.clear();
    if (S.empty()) flag=1;
    for(auto itr=S.begin();itr!=S.end();itr++) word.insert(*itr);
    set_difference(alp.begin(),alp.end(),
                   word.begin(),word.end(),
                   inserter(res,res.end()));
    for(auto itr=res.begin();itr!=res.end();itr++){
      if(*itr>rS){
        resS=S;
        resS.push_back(*itr);
        flag=1;
        break;
      }
    }
    
    if(flag==1) break;
    rS = *(S.end()-1);
    S.pop_back();
  }
  if(resS.empty()){cout << -1 << endl;}
  else{ cout << resS << endl;}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << (x) << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}
using ll = long long;
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;
int solve(bool dif0,V<int> x,V<int> y){
	int N = x.size();
	if(N==0) return dif0?1:0;
	int x0 = 0;
	int y0 = 0;
	V<int> x0s,y0s;
	rep(i,N) if(x[i]==0) x0++,x0s.pb(i);
	rep(i,N) if(y[i]==0) y0++,y0s.pb(i);
	int ans = 1e9;
	for(int l = -x0-1; l<=y0+1; l++){
		int r = y0-x0-l;
		if( (l%2!=0) ^ dif0 ) continue;
		V<int> a,b;
		if(l>0){
			rep(i,l) a.pb(-1);
		}else{
			rep(i,-l) b.pb(-1);
		}
		for(int v:x0s) a.pb(v);
		for(int v:y0s) b.pb(v);
		if(r>0){
			rep(i,r) a.pb(N);
		}else{
			rep(i,-r) b.pb(N);
		}
		assert(a.size() == b.size());
		int cost = 0;
		int K = a.size();
		rep(i,K) cost += abs(a[i]-b[i]);
		chmin(ans,cost);
	}
	return ans;
}
int main(){
	int N;
	string s,t;
	cin>>N>>s>>t;
	bool dif0 = s[0]!=t[0];
	V<int> x(N-1),y(N-1);
	rep(i,N-1){
		x[i] = s[i]!=s[i+1];
		y[i] = t[i]!=t[i+1];
	}
	cout<<solve(dif0,x,y)<<endl;

}

Measured memory_bytes: 512
#include<stdio.h>

#define MAX_LENGTH (1200)

int main(void)
{
        char str[MAX_LENGTH];
        int i;

        scanf("%[^\r\n]", str);

        for(i=0; i < MAX_LENGTH; i++){
                if(str[i] == '\0') {
                        break;
                }

                if(0x5b > str[i] && str[i] > 0x40){
                        str[i] |= 0x20;
                }else if(0x7b > str[i] && str[i] > 0x60){
                        str[i] &= 0x5f;
                }else{
                        str[i];
                }
        }

                printf("%s\n", str);

        return 0;
}


Measured memory_bytes: 2052
#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
#include<string>
#include<map>
using namespace std;
int main(){
    char p[101];
    cin>>p;
    for(int i=0;i<p[i];i++){
        cout<<"x";
    }
    cout<<endl;
    return 0;
}

Measured memory_bytes: 256
X, N = map(int, input().split())
P = list(map(int, input().split()))

# 考えたポイント
# 答えはあることを理解する
# 絶対値のうち最小
# 0, 101の扱い
# countを使う
# Xも含む
for i in range(0,X+1):
    for s in [-1,1]:
        ans = X + (i * s)
        if P.count(ans) == 0:
            print(ans)
            exit(0)



Measured memory_bytes: 9176
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
typedef long long int ll;
int main(){
    ios_base::sync_with_stdio(false),cin.tie(NULL);
    ll n,k;
    cin>>n>>k;
    ll a[n],ans=0;
    for(ll i=0;i<n;i++)cin>>a[i];
    sort(a,a+n);
    for(ll i=0;i<k;i++)ans+=a[i];
    cout<<ans;

    return 0;
}



Measured memory_bytes: 3668
#include <bits/stdc++.h>
using namespace std;
#define MD 1000000007
typedef long long int ll;

int main(){
    int d;
    cin>>d;
    if(d==25){
        cout<<"Christmas"<<endl;
    }else if(d==24){
        cout<<"Christmas Eve"<<endl;
    }else if(d==23){
        cout<<"Christmas Eve Eve"<<endl;
    }else if(d==22){
        cout<<"Christmas Eve Eve Eve"<<endl;
    }
    return 0;
}
    

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, z, n) for(int i = z; i < n; i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
//const int INF = 1<<29;
//const int MODINF = 1000000007;
using namespace std;

int main(){
    char a, b;
    cin >> a >> b;
    if (b == 'H'){
        if (a == 'H') cout << "H" << endl;
        else cout << "D" << endl;
    }
    else{
        if (a == 'H') cout << "D" << endl;
        else cout << "H" << endl;
    }
}

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

using namespace std;

int main() {
    int N;
    string S;
    cin >> N >> S;
    bool A = false, B = false;
    int count = 0;
    for (int i = 0; i < N - 2; i++) {
        if (S[i] == 'A' && S[i + 1] == 'B' && S[i + 2] == 'C') {
            count++;
        }
    }

    cout << count << "\n";

    return 0;
}


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

int main() {
  char n[3];
  int x = 0;
  for(int i = 0; i < 3; i++) {
    cin >> n;
  }
  for(int i = 0; i < 3; i++) {
    if (n[i] == '7') {
      x = 1;
      break;
    }
  }
  if(x == 1) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3616
# Reference: https://tjkendev.github.io/procon-library/python/min_cost_flow/primal-dual.html
from heapq import heappush, heappop
class MinCostFlow:
    INF = 10**18

    def __init__(self, N):
        self.N = N
        self.G = [[] for i in range(N)]

    def add_edge(self, fr, to, cap, cost):
        forward = [to, cap, cost, None]
        backward = forward[3] = [fr, 0, -cost, forward]
        self.G[fr].append(forward)
        self.G[to].append(backward)

    def flow(self, s, t, f):
        N = self.N; G = self.G
        INF = MinCostFlow.INF

        res = 0
        H = [0]*N
        prv_v = [0]*N
        prv_e = [None]*N

        d0 = [INF]*N
        dist = [INF]*N

        while f:
            dist[:] = d0
            dist[s] = 0
            que = [(0, s)]

            while que:
                c, v = heappop(que)
                if dist[v] < c:
                    continue
                r0 = dist[v] + H[v]
                for e in G[v]:
                    w, cap, cost, _ = e
                    if cap > 0 and r0 + cost - H[w] < dist[w]:
                        dist[w] = r = r0 + cost - H[w]
                        prv_v[w] = v; prv_e[w] = e
                        heappush(que, (r, w))
            if dist[t] == INF:
                return None

            for i in range(N):
                H[i] += dist[i]

            d = f; v = t
            while v != s:
                d = min(d, prv_e[v][1])
                v = prv_v[v]
            f -= d
            res += d * H[t]
            v = t
            while v != s:
                e = prv_e[v]
                e[1] -= d
                e[3][1] += d
                v = prv_v[v]
        return res

###

from sys import stdin
def input():
    return stdin.readline().strip()

def main():
    n, m = map(int, input().split())
    s = [input() for _ in range(n)]

    mcf = MinCostFlow(n*m + 2)

    source = n * m
    sink = n * m + 1

    ans = 0
    cnt = 0
    for i in range(n):
        for j in range(m):
            if s[i][j] == '#':
                continue

            ind = m * i + j

            # source >>> 'o'
            if s[i][j] == 'o':
                ans -= i + j
                cnt += 1
                mcf.add_edge(source, ind, 1, 0)

            mcf.add_edge(ind, sink, 1, -i-j)

            if i < n - 1 and s[i+1][j] != '#':
                mcf.add_edge(ind, m*(i+1) + j, 100, 0)
            if j < m - 1 and s[i][j+1] != '#':
                mcf.add_edge(ind, m*i + j+1, 100, 0)

    print(ans - mcf.flow(source, sink, cnt))

main()

Measured memory_bytes: 76536
n=int(input())
s=input()
s=s.lower()


PLAIN = s

KEY = n

enc = ""

for char in list(PLAIN):
    ASCII = ord(char)
    num = ASCII - 97
    num = (num + KEY) % 26
    ASCII = num + 97
    enc += chr(ASCII)

print(enc.upper())

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(x) x.begin(), x.end()
#define mod 1000000007
typedef long long ll;

int main() {
    int a;
    cin >> a;
    cout << a + a*a + a*a*a << endl;
    return 0;
}

Measured memory_bytes: 3636
/**
 *    author:  otera    
**/
#include<iostream>
#include<string> 
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm> 
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

//#define int long long
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

void solve() {
	int n; cin >> n;
    unordered_map<string, int> mp;
    rep(i, n) {
        string s; cin >> s;
        mp[s] ++;
    }
    cout << "AC x " << mp["AC"] << endl;
    cout << "WA x " << mp["WA"] << endl;
    cout << "TLE x " << mp["TLE"] << endl;
    cout << "RE x " << mp["RE"] << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//int t; cin >> t; rep(i, t)solve();
	solve();
    return 0;
}

Measured memory_bytes: 3652
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main() {
	int N;
	cin >> N;

	int b[22];

	int v[22], c[22];

	int ans = 0;

	for (int i = 1; i <= N; i++) {
		cin >> v[i];
	}

	for (int i = 1; i <= N; i++) {
		cin >> c[i];
	}

	for (int i = 1; i <= N; i++) {
		b[i] = v[i] - c[i];
		if (b[i] < 0)b[i] = 0;

		ans += b[i];
	}

	cout << ans;
}

Measured memory_bytes: 256
def solve(i, m):

    if i >= n:
        combs.add(m)
        return

    solve(i+1, m)
    solve(i+1, m+A[i])


def main():
    global n
    global A
    global combs
    n = int(input())
    A = list(map(int, input().split()))
    _ = int(input())
    Q = list(map(int, input().split()))
    # 先に全部の組み合わせを計算しておくことで時間短縮
    combs = set()
    solve(0, 0)

    for q in Q:
        if q in combs:
            print("yes")
        else:
            print("no")


if __name__ == '__main__':
    main()


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

bool disallow[10];

bool ok(int a) {
	while (a) {
		if (disallow[a % 10]) return false;
		a /= 10;
	}
	return true;
}

int main() {
	int n, k, d;
    scanf("%d%d", &n, &k);
    for (int i = 1; i <= k; i++) {
		scanf("%d", &d);
		disallow[d] = true;	
    }
    for (int i = n; ; i++) 
		if (ok(i)) {
			printf("%d\n", i);
			return 0;
		}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cout << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cout<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 300010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = 1 << 30;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
///////////////////////////////////////////////////////////////////////////////////////////////////

int N;
ll A[16][16];
ll C[(1 << 16)];
ll dp[(1 << 16)];

void solve() {
	cin >> N;
	rep(i, 0, N) {
		rep(j, 0, N) {
			cin >> A[i][j];
		}
	}
	rep(bit, 0, (1 << N)) {
		dp[bit] = -linf;
		rep(i, 0, N) {
			if(!(bit & (1 << i))) continue;
			rep(j, 0, N) {
				if(!(bit & (1 << j))) continue;
				C[bit] += A[i][j];
			}
		}
	}
	// debug(vi(C, C + 8));
	dp[0] = 0;
	rep(bit, 0, (1 << N)) {
		for(int to = bit; to; to = (to - 1) & bit) {
			MAX(dp[bit], dp[bit ^ to] + C[to]);
		}
	}
	cout << dp[(1 << N) - 1] / 2 << "\n";
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
	srand((unsigned int)time(NULL));
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
    freopen("in.txt", "rt", stdin);
#endif	
	solve();
#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}



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


using namespace std;



int main(){
	
	int a,b,c ,ans;

	
	cin >> a >> b >> c; 
	
	
	ans = max(a*10 + b + c , max(b*10 + c + a , c*10 + b + a)); 
	
	cout << ans << endl;
	
	
    return 0;
}


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

int main() {
    int a, b;
    cin >> a >> b;

    switch(a * b) {
        case 2: 
            cout << 3 << endl;
            break;
        case 6:
            cout << 1 << endl;
            break;
        case 3:
            cout << 2 << endl;
    }

    return 0;
}

Measured memory_bytes: 256
fn gcd(x: u64, y: u64) -> u64 {
    let mut x = x;
    let mut y = y;
    while y != 0 {
        let t = y;
        y = x % y;
        x = t;
    }
    x
}

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).unwrap();
    let mut iter = buf.split_whitespace();
    let a: u64 = iter.next().unwrap().parse().unwrap();
    let b: u64 = iter.next().unwrap().parse().unwrap();
    let c: u64 = iter.next().unwrap().parse().unwrap();
    let d: u64 = iter.next().unwrap().parse().unwrap();

    let div_c = b/c - (a - 1)/c;
    let div_d = b/d - (a - 1)/d;
    let lcm_cd = c * d / gcd(c, d);
    let div_cd = b/(lcm_cd) - (a - 1)/(lcm_cd);

    let ans: u64 = (b - a + 1) - div_c - div_d + div_cd;

    println!("{}", ans);
}


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

class Main {

    static int square(int i){
	return i * i;
    }

    public static void main(String[] args){
	Scanner stdin = new Scanner(System.in);
	int limit = stdin.nextInt();
	int[] num = new int[3];
	for(int i = 0; i < limit; i++){
	    for(int j = 0; j < 3; j++){
		num[j] = stdin.nextInt();
	    }
	    Arrays.sort(num);
	    System.out.println(square(num[0]) + square(num[1]) == square(num[2]) ? "YES" : "NO");
	}
    }
}

Measured memory_bytes: 12000
#include<stdio.h>
#include<stdlib.h>
 
#define MAX 101
 
void DFS(int, int);
 
int Adj[MAX][MAX];
int D[MAX], F[MAX];
int C[MAX]={0};
int count = 1;
 
int main(void){
  //int Adj[MAX][MAX];
  int i, j, n, u, k, v;
 
  scanf("%d", &n);
  for(i=1; i<n+1; i++){
    for(j=1; j<n+1; j++){
      Adj[i][j] = 0;
    }
  }
 
  for(i=1; i<n+1; i++){
    scanf("%d%d", &u, &k);
    for(j=1; j<k+1; j++){
      scanf("%d", &v);
      Adj[i][v] = 1;
    }
  }
 
  /* A.c
  for(i=1; i<n+1; i++){
    for(j=1; j<n+1; j++){
      if(j == n) printf("%d\n", Adj[i][j]);
      else printf("%d ", Adj[i][j]);
    }
    }*/
 
  for(i=1; i<n+1; i++){
    if(C[i] == 0) DFS(i, n);
  }
 
  for(i=1; i<n+1; i++) printf("%d %d %d\n", i, D[i], F[i]);
 
  return 0;
}
 
void DFS(int i, int n){
  int j;
 
  D[i] = count++;
  C[i] = 1;
 
  for(j=1; j<n+1; j++){
    if(Adj[i][j] == 1 && C[j] == 0) DFS(j, n);
  }
 
  F[i] = count++;
 
  return;
}

Measured memory_bytes: 636