akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
using namespace std;

int main()
{
  int m,n;
  cin >> n >> m;
  int l, r;
  int ans;
  int max=n;
  int min=1;
  
  for(int j=0;j<m;j++){
    cin >> l >> r;
    if(min < l)
      min = l;
    if(max > r)
      max = r;
  }
  
  ans = max - min +1;
  if(ans<0)
    ans=0;
  
  cout << ans <<"\n";
  
  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define MAX_INF 0x3f
#define MAX_INF_VAL 0x3f3f3f3f
#define MAX_INF_VAL_LL 0x3f3f3f3f3f3f3f3f
#define pi 3.141592653589
#define eps 1e-6
//#define p 2173412051LL
//#define sz 2

using namespace std;

bool vis[ 4 ];

int main() {
	int a, b;
	scanf( "%d%d", &a, &b );
	vis[ a ] = vis[ b ] = true;
	for( int i = 1; i <= 3; ++i )
		if( !vis[ i ] ) {
			printf( "%d", i );
			return 0;
		}
	return 0;
}

Measured memory_bytes: 3756
#include <cstdio>
#include <iostream>
#include <cstring>
#include <string>
#include <cmath>
#include <algorithm>
#include <cstdlib>
#include <utility>
#include <map>
#include <stack>
#include <set>
#include <vector>
#include <queue>
#include <deque>
#define x first
#define y second
#define mp make_pair
#define pb push_back
#define LL long long
#define Pair pair<int,int>
#define LOWBIT(x) x & (-x)
using namespace std;

const int MOD=1e9+7;
const int INF=0x7ffffff;
const int magic=348;

int n,m;
int a[200048];
LL s1[200048],s2[200048];

int main ()
{
	int i;
	scanf("%d%d",&n,&m);
	for (i=1;i<=n;i++) scanf("%d",&a[i]);
	int from,to;
	for (i=1;i<=n-1;i++)
	{
		from=a[i];to=a[i+1];
		if (from>to) to+=m;
		s1[from+1]+=from+1;s1[to+1]-=(from+1);
		s2[from+1]++;s2[to+1]--;
	}
	//for (i=1;i<=m*2;i++) cout<<s1[i]<<' ';
	//cout<<endl;
	//for (i=1;i<=m*2;i++) cout<<s2[i]<<' ';
	//cout<<endl;
	for (i=2;i<=m*2;i++)
	{
		s1[i]+=s1[i-1];
		s2[i]+=s2[i-1];
	}
	//for (i=1;i<=m*2;i++) cout<<s1[i]<<' ';
	//cout<<endl;
	//for (i=1;i<=m*2;i++) cout<<s2[i]<<' ';
	//cout<<endl;
	LL ans=0,res,fans=1e16;
	for (i=1;i<=n-1;i++) if (a[i]<a[i+1]) ans+=a[i+1]-a[i]; else ans+=m-(a[i]-a[i+1]);
	//cout<<ans<<endl;
	for (i=1;i<=m;i++)
	{
		res=s2[i]*i+s2[i+m]*(i+m)-s1[i]-s1[i+m];
		if (ans-res<fans) fans=ans-res;
	}
	cout<<fans<<endl;
	return 0;
}

Measured memory_bytes: 3712
// 提出時に消す


import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

// 提出時にMainに変更する
public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        List<String> s = new ArrayList<String>();

        for (int i = 0; i < n; i++) {
            s.add(sc.next());
        }

        System.out.println("AC x " + s.stream().filter(e -> e.equals("AC")).count());
        System.out.println("WA x " + s.stream().filter(e -> e.equals("WA")).count());
        System.out.println("TLE x " + s.stream().filter(e -> e.equals("TLE")).count());
        System.out.println("RE x " + s.stream().filter(e -> e.equals("RE")).count());

        sc.close();
    }
}

Measured memory_bytes: 65732
#include<iostream>
#include<cstring>
#include<cstdio>
#include<vector>
#define MN 500
#define ll long long
using namespace std;
inline int read()
{
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar();
    return x*f;
}
char st[MN+5][MN+5];
int n,m;
bool Check(int x)
{
    if(n&1) return x&1;
    else return ((x<=n-2&&(x&1))||x==n);
}
int main()
{
    n=read();m=read();
    for(int i=1;i<=n;++i) scanf("%s",st[i]+1);
    for(int i=1;i<=n;++i)
    {
        for(int j=1;j<=m;++j)
            if((Check(i)&&j<m)||j==1||st[i][j]=='#') putchar('#');
            else putchar('.');
        puts("");
    }
    puts("");
    for(int i=1;i<=n;++i)
    {
        for(int j=1;j<=m;++j)
            if((!Check(i)&&j>1)||j==m||st[i][j]=='#') putchar('#');
            else putchar('.');
        puts("");
    }
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
using namespace std;
int main() {
  int n,a[100001],A;
  cin >> n;
  for(int i=1;i<=n;i++){
    cin >> A;
    a[A] = i;
  }
  for(int i=1;i<=n;i++){
    cout << a[i] << " ";
  }
  return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
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;
}
typedef long long int ll;

#define EPS (1e-7)
#define INF (1 << 30)
#define LLINF (1LL << 60)
#define PI (acos(-1))
#define MOD (1000000007)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------
const ll M = 100005;
vector<vector<ll>> imos(30, vector<ll>(M, 0));

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N, C;
    cin >> N >> C;
    ll mx = 0;
    for(ll i=0;i<N;i++){
        ll s,t,c;
        cin>>s>>t>>c;
        c--;
        imos[c][s-1]++;
        imos[c][t]--;
        chmax(mx,t);
    }
    for(ll i=0;i<C;i++){
        for(ll j=1;j<M;j++){
            imos[i][j]+=imos[i][j-1];
        }
    }
    //dbg
    for(ll i=0;i<C;i++){
        for(ll j=0;j<=mx;j++){
            if(imos[i][j]>=1){
                imos[i][j]=1;
            }
        }
    }
    ll ans = 0;
    for(ll i=0;i<M;i++){
        ll cnt = 0;
        for(ll j=0;j<C;j++){
            cnt+=imos[j][i];
        }
        chmax(ans,cnt);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 24576
#include<iostream>
using namespace std;
long long x, a, b, c, d, e, f, g;
int main() {
	cin >> x >> a >> b >> c >> d;
	g = (long long)(100.0*c / a + 0.99999);
	f = (long long)(100.0*d / b + 0.99999);
	e = x - g - f;
	if (e < 0) { e = -1; }
	cout << e << endl;
	return 0;
}

Measured memory_bytes: 1160
import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        int k = sc.nextInt();
        String ans = "";
        while(n!=0)
        {
            long digit = n%k;
            ans += String.valueOf(digit);
            n/=k;
        }
        System.out.println(ans.length());
    }
}


Measured memory_bytes: 23764
#include<stdio.h>
int main()
{
  int n, i, ac = 0, wa = 0, tle = 0, re = 0;
  scanf("%d", &n);
  char res[n][4];

  for (i = 0; i < n; i++) {
    scanf("%s", res[i]);
    if (res[i][0] == 'A')
      ac++;
    else if (res[i][0] == 'W')
      wa++;
    else if (res[i][0] == 'T')
      tle++;
    else if (res[i][0] == 'R')
      re++;
  }
  
  printf("AC x %d\n", ac);
  printf("WA x %d\n", wa);
  printf("TLE x %d\n", tle);
  printf("RE x %d\n", re);
  return(0);
}

Measured memory_bytes: 2096
#include <iostream>
#include <cstdio>
#include <vector>
#include <list>
#include <algorithm>
#include <cmath>
#include <stack>
#include <map>
#include <numeric>
#include <sstream>
#include <queue>
using namespace std;

#define REP(i,n) for(int (i)=0; (i)<(n); (i)++)
#define FOR(i,a,b) for(int (i)=(a); (i)<(b); (i)++)
#define PUSH(n,v) for(int i=0; i<(n); i++) {int j; cin >> j; v.push_back(j);}
#define ALL(v) v.begin(), v.end()
#define print(s) cout << (s) << endl

typedef pair<int,int> P;
const P NOT_FOUND = make_pair(-1,-1);

P placeOfLand(int bd[12][12]) {
    REP(i,12) {
        REP(j,12) {
            if (bd[i][j]) return make_pair(i, j);
        }
    }
    return NOT_FOUND;
}

bool island(int x, int y, int bd[12][12]) {
    return 0<=x && x<12 && 0<=y && y<12 && bd[x][y];
}

void solve68(string s) {
    int bd[12][12];
    REP(i,12) bd[0][i] = s[i]-'0';
    REP(j,11) {
        REP(i,12) {
            char k;
            cin >> k;
            bd[j+1][i] = k-'0';
        }
    }
    int cnt = 0;
    while (placeOfLand(bd) != NOT_FOUND) {
        cnt++;
        queue<P> que;
        que.push(placeOfLand(bd));
        while (que.size()) {
            P land = que.front();
            que.pop();
            int x = land.first, y = land.second;
            bd[x][y] = 0;
            if (island(x,y-1,bd)) {
                que.push(make_pair(x, y-1));
            }
            if (island(x,y+1,bd)) {
                que.push(make_pair(x, y+1));
            }
            if (island(x-1,y,bd)) {
                que.push(make_pair(x-1, y));
            }
            if (island(x+1,y,bd)) {
                que.push(make_pair(x+1, y));
            }
        }
    }
    cout << cnt << endl;
}

int main() {
    string s;
    while(cin >> s) {
        solve68(s);
    }
    return 0;
}

Measured memory_bytes: 7076
#include<bits/stdc++.h>
using namespace std;
int gcd(int a,int b){
    return (b==0?a:gcd(b,a%b));
}
int main(){
    int n,k;
    cin>>n>>k;
    vector<int> vec;
    for(int i=0;i<n;i++){
        int t;
        cin>>t;
        vec.push_back(t);
    }
    sort(vec.begin(),vec.end());
    vec.erase(unique(vec.begin(),vec.end()),vec.end());
    if(vec.size()==1){
        if(vec[0]==k){
            cout<<"POSSIBLE"<<endl;
        }
        else{
            cout<<"IMPOSSIBLE"<<endl;
        }
        return 0;
    }
    if(k>vec[vec.size()-1]){
        cout<<"IMPOSSIBLE"<<endl;
        return 0;
    }
    int md=vec[1]-vec[0];
    for(int i=2;i<vec.size();i++){
        md=gcd(md,vec[i]-vec[i-1]);
    }
    if(md==1){
        cout<<"POSSIBLE"<<endl;
        return 0;
    }
    bool f=true;
    for(int i=1;i<vec.size();i++){
        if((vec[i]-vec[i-1])%md||vec[i]%md){
            f=false;
        }
    }
    if(f){
        if(k%md){
            cout<<"IMPOSSIBLE"<<endl;
        }
        else{
            cout<<"POSSIBLE"<<endl;
        }
    }
    else{
        cout<<"POSSIBLE"<<endl;
    }
    return 0;
}

Measured memory_bytes: 892
#include <bits/stdc++.h>
using namespace std;
#define rep(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
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; }
using ll = long long;
const ll MOD = 1e9+7; ll LLINF = 1LL << 60; int INF = INT_MAX;

//

int main(){
    int a,b,c; cin>>a>>b>>c;
    if(a+b>=c) cout<<"Yes"<<endl;
    else  cout<<"No"<<endl;
}

Measured memory_bytes: 256
package main

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

var rdr = bufio.NewReaderSize(os.Stdin, 1000000)

func readLine() string {
	buf := make([]byte, 0, 1000000)
	for {
		l, p, e := rdr.ReadLine()
		if e != nil {
			panic(e)
		}
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}

func main() {
	var n int
	fmt.Scan(&n)

	str := readLine()

	strSlice := strings.Split(str, " ")

	var intSlice []int

	for _, sv := range strSlice {
		iv, _ := strconv.Atoi(string(sv))
		intSlice = append(intSlice, iv)
	}

	count, prevValue := 0, 0

	for i := 0; i < len(intSlice); i++ {
		iv := intSlice[i]

		if prevValue > iv {
			count += prevValue - iv
		}

		if prevValue-iv <= 0 {
			prevValue = iv
			continue
		}

		prevValue = iv + (prevValue - iv)
	}

	fmt.Println(count)
}


Measured memory_bytes: 18424
#include <iostream>
#include <iomanip> //! for setprecision(10)
#include <math.h>
#include <algorithm>
#include <functional> 
#include <string>
#include <vector>

#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <utility>

using namespace std;

typedef long long LL;

#define dump(c) { for (auto it = c.begin(); it != c.end(); ++it) if (it == c.begin()) cout << *it; else cout << ' ' << *it; cout << endl; } 
#define rep(i,n) for (int i = 0; i < (n); ++i)

const int MOD = 1000000007;

const LL INF = 1e18;

const int MAX = 2005;
LL dp[MAX][MAX]; //! [# of kids moved (from biggest C)][# of kids moved to left]


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

    int N;
    cin >> N;
    vector<pair<int, int>> Apos;
    rep(i, N) {
        int A;
        cin >> A;
        Apos.push_back({A, i});
    }
    sort(Apos.rbegin(), Apos.rend());

    rep(i, N+1) rep(j, N+1) dp[i][j] = -INF;
    dp[0][0] = 0;

    rep(i, N) { //! moving Apos[i]
        LL c = Apos[i].first;
        int p = Apos[i].second;
        rep(j, i+2) { //! destination j is in range [0..i+1]
          int il = j-1; //! destination index when move to left
          int ir = N-i+j-1; //! destination index when move to right
          if (j == 0) {
              dp[i+1][0] = dp[i][0] + c * (ir-p); //! move to right
          } else {
              dp[i+1][j] = max(dp[i][j] + c * (ir-p), dp[i][j-1] + c * (p-il));
          }
        }
    }

    LL ans = dp[N][0];
    rep(i, N) {
        ans = max(ans, dp[N][i]);
    }

    cout << ans << endl;

    return 0;
}


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

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);i--)
#define rrep(i,n) RFOR(i,n,0)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

// v is sorted
bool isUnique(vector<ll> v){
	rep(i, v.size()-1){
		if(v[i] == v[i+1]) return false;
	}

	return true;
}

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

	int N, M;
	cin >> N >> M;

	vector<ll> A(N);
	rep(i, N) cin >> A[i];
	sort(A.begin(), A.end());
	if(!isUnique(A)){
		cout << 0 << endl;
		return 0;
	}

	vector<ll> B(M);
	rep(i, M) cin >> B[i];
	sort(B.begin(), B.end());
	if(!isUnique(A)){
		cout << 0 << endl;
		return 0;
	}

	ll MOD = 1e9 + 7;
	ll ans = 1;

	for(ll x = N * M; x >= 1; x--){
		int ia = lower_bound(A.begin(), A.end(), x) - A.begin();
		int ib = lower_bound(B.begin(), B.end(), x) - B.begin();
		if(ia >= N || ib >= M){
			cout << 0 << endl;
			return 0;
		}

		if(A[ia] == x && B[ib] == x) continue;

		if(A[ia] == x){
			ans *= M - ib;
			ans %= MOD;
			continue;
		}

		if(B[ib] == x){
			ans *= N - ia;
			ans %= MOD;
			continue;
		}

		ans *= max((N - ia) * (M - ib) - (N * M - x), 0LL);
		ans %= MOD;
	}

	cout << ans << endl;
}


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

int main(){
    int n;
    bool can = false;
    cin >> n;
    if(n <= 81){
        for(int i = 9; i >= 1; i--){
            if(n % i == 0 && n / i <= 9){
                can = true;
            }
        }
    }
    cout << (can ? "Yes" : "No") << endl;
    return 0;
}

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

using namespace std;
#define MAX 123
int a[MAX];
int mark[MAX];
int main(void)
{
    int num;
    scanf("%d",&num);
    int sum=0;
    for(int i=0;i<num;i++){
        scanf("%d",&a[i]);
        mark[i+1]=a[i];
        sum+=a[i];
    }
    int T;
    scanf("%d",&T);
    for(int i=0;i<T;i++){
        int x,y;
        scanf("%d%d",&x,&y);
        sum-=mark[x];
        sum+=y;
        printf("%d\n",sum);
        sum-=y;
        sum+=mark[x];
    }

    return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#pragma warning(disable:4996)
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <functional>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <list>
#include <set>
#include <ctime>
using namespace std;
typedef long long ll;

const int INF = 100000000;
const int MAX_N = 100000;


int main(int argc, char *args[]) {
	int A, B;
	cin >> A >> B;
	int i;
	for (i = 0;; i++) {
		if (B <= (A - 1) * i + 1) {
			break;
		}
	}
	cout << i << endl;
}

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

const int MAXN = 50;
const int MAXM = 40;

class UnionFind {
private:
  int n;
  int *par, *rank;
public:
  UnionFind(int _n) {
    n = _n;
    par = new int[n];
    rank = new int[n];
    for(int i = 0; i < n; ++i) {
      par[i] = i;
      rank[i] = 0;
    }
  }

  ~UnionFind() {
    delete [] par;
    delete [] rank;
  }

  int find(int x) {
    if(par[x] == x) return x;
    return par[x] = find(par[x]);
  }

  bool same(int x, int y) {
    return find(x) == find(y);
  }

  void unite(int x, int y) {
    x = find(x);
    y = find(y);
    if(x == y) return;
    if(rank[x] < rank[y]) {
      par[x] = y;
    } else {
      par[y] = x;
      if(rank[x] == rank[y]) {
        ++rank[x];
      }
    }
  }
};

struct Edge {
  int a, b;
};

int N, M;
map<string, int> L;
vector<string> rL;
vector<int> S;
vector<int> V[6];
vector<Edge> E[MAXN];

void rec(int k, int i, int bit) {
  V[k].push_back(bit);
  if(k == 5) return;
  for(; i < N; ++i) {
    if(bit & (1<<i)) continue;
    rec(k+1, i+1, bit|(1<<i));
  }
}

bool test(int bit) {
  UnionFind uf(M);
  int cnt = 0;
  for(int i = 0; i < N; ++i) {
    if(bit & (1<<i)) {
      for(int j = 0; j < E[i].size(); ++j) {
        const Edge &e = E[i][j];
        if(!uf.same(e.a, e.b)) {
          uf.unite(e.a, e.b);
          ++cnt;
        }
      }
    }
  }
  return cnt == M-1;
}

int main() {
  bool first = true;
  while(cin >> N >> M && (N|M)) {
    L.clear();
    rL.clear();
    for(int i = 0; i < N; ++i) {
      string s;
      cin >> s;
      L[s] = L.size()-1;
      rL.push_back(s);
    }
    S = vector<int>(M, 0);
    for(int j = 0; j < M; ++j) {
      int k;
      cin >> k;
      while(k--) {
        string s;
        cin >> s;
        S[j] |= (1<<L[s]);
      }
    }
    for(int i = 0; i < 6; ++i) V[i].clear();
    rec(0,0,0);

    for(int i = 0; i < MAXN; ++i) E[i].clear();
    for(int a = 0; a < M; ++a) {
      for(int b = a+1; b < M; ++b) {
        int bit = (S[a] & S[b]);
        for(int k = 0; k < N; ++k) {
          if(bit & (1<<k)) {
            E[k].push_back((Edge){a,b});
          }
        }
      }
    }

    int ans = 0;
    try {
      for(int i = 1; i <= 5; ++i) {
        for(int j = 0; j < V[i].size(); ++j) {
          if(test(V[i][j])) {
            ans = V[i][j];
            throw 0;
          }
        }
      }
    } catch(...) {}

    if(first) first = false;
    else cout << endl;
    if(ans) {
      vector<string> v;
      for(int i = 0; i < N; ++i) {
        if(ans & (1<<i)) v.push_back(rL[i]);
      }
      cout << v.size() << endl;
      for(int i = 0; i < v.size(); ++i) {
        cout << v[i] << endl;
      }
    } else {
      cout << "Impossible" << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 2468
/*      ###########################
        #  Author : Pranay Garg   #
        #  College : SGSITS       #
        ###########################
*/      
#include<bits/stdc++.h>
#define ll long long int
#define ironman ios_base::sync_with_stdio(false);cin.tie(NULL);
#define MOD 1000000007
#define endl '\n'
using namespace std;
void fastio()
{
    ironman
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
        freopen("error.txt","w",stderr);
    #endif
}
ll parent[100005];
ll find(ll a)
{
    std::vector<ll> v;
    while(parent[a]>0)
    {
        v.push_back(a);
        a = parent[a];
    }
    for(ll i=0;i<v.size();i++)
        parent[v[i]] = a;
    return a;
}
bool prime[100005];
void SieveOfEratosthenes(int n) 
{  
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        if (prime[p] == true) 
        { 
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
}  
void union1(ll a, ll b)
{
    a = find(a);
    b = find(b);
    if(a!=b)
    {
        parent[a] = min(parent[a],parent[b]);
        parent[b] = a;
    }
}  
// ll n,w;
// std::vector<ll> weight(100005),value(100005);
// ll dp[100005];
// ll solve(ll i,ll w)
// {
//     if(i<0||w<0)
//         return 0;
//     if(dp[i][w]!=-1)
//         return dp[i][w];
//     ll a = 0;
//     if(weight[i]<=w)
//         a = value[i]+solve(i-1,w-weight[i]);
//     ll b = solve(i-1,w);
//     return dp[i][w] = max(a,b);
// }
int main()
{
    //fastio();
    ll n,w,weight,value;
    cin >> n >> w;
    ll dp[w+2];
    memset(dp,0,sizeof(dp));
    for(ll i=0;i<n;i++)
    {
        cin >> weight >> value;
        for(ll j=w-weight;j>=0;j--)
        {
            dp[weight+j] = max(dp[weight+j],dp[j]+value);
        }
    //     for(ll i=0;i<=w;i++)
    //     cout << dp[i] << " " ;
    // cout << endl;
    }
    cout << dp[w] << endl;
    //cout << solve(n-1,w) << endl;
    // for(ll i=0;i<n;i++)
    // {
    //     for(ll j=0;j<=w;j++)
    //         cout << i << " " << j << " " << dp[i][j] << "...";
    //     cout << endl;
    // }
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;

// #define int ll
#define REP(i,n) for (int i = 0; i < (n); ++i)
#define FORE(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define debug(x) cerr << #x << ": " << x << '\n'

const int MOD = (int)1e9 + 7;

int main() {
    ll S;

    cin >> S;

    if (S == (ll)1e18) {
        cout << "0 0 0 1000000000 1000000000 0" << endl;
        return 0;
    }

    ll a = (ll)1e9;
    ll b = 1;

    ll c = (ll)1e9 - (S % a);
    ll d = (S / a) + 1;

    debug(S);
    ll s = abs(a * d - b * c);
    debug(s);

    cout << "0 0 " << a << " " << b << " " << c << " " << d << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
int func()
{
	char i1[81]="",i2[81]="",res[81]="";
	bool cflag=false;
	std::string tmp;
	std::cin >> tmp;
	if(tmp.size()>80){
		std::cin >> tmp;
		return -1;
	}
	strcpy(i1,tmp.c_str());
	std::cin >> tmp;
	if(tmp.size()>80)
		return -1;
	strcpy(i2,tmp.c_str());
	for(int j=0;j<80;j++){
		char c='0';
		if(cflag)
			c+=1;
		cflag=false;
		if(strlen(i1)>j){
			c+=i1[strlen(i1)-j-1]-'0';
		}
		if(strlen(i2)>j){
			c+=i2[strlen(i2)-j-1]-'0';
		}
		if(c > '9'){
			cflag=true;
			c-=10;
		}
		res[79-j]=c;
	}

	if(cflag)
		return -1;
	char *p = res;
	while(*p++ == '0' && (p-res)<80);
	std::cout << (p-1) << std::endl;

	return 0;
}
int main(void){
	int n;
	std::cin >> n;
	for(int i=0; i<n; i++)
		if(func()==-1)
			std::cout << "overflow" << std::endl;

}

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

signed main(){
    int H,W;
    cin >> H >> W;
    vector<vector<char>> a(H,vector<char>(W));
    for(int i=0;i<H;i++){
        for(int k=0;k<W;k++){
            cin >> a[i][k];
        }
    }
    
    map<int,int> yoko;
    map<int,int> tate;
    for(int i=0;i<H;i++){
        for(int k=0;k<W;k++){
            if(a[i][k]=='.'){
                yoko[i]++;
                tate[k]++;
            }
        }
    }
    
    int cnt = 0;
    for(int i=0;i<H;i++){
        for(int k=0;k<W;k++){
            if(yoko[i]==W) continue;
            if(tate[k]==H) continue;
            cout << a[i][k];
            cnt++;
        }
        if(cnt>0) cout << endl;
        cnt = 0;
    }
    
    return 0;
}


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

#define rep(i, a, b) for (ll i = (a); i < (b); i++)
typedef uint64_t ull;
typedef int64_t ll;
typedef std::pair<ll, ll> PLL;

class UnionFind {
 public:
     int n;
     std::vector<int> par;
     std::vector<int> num;

     explicit UnionFind(int n) {  // [0 n)のunion find
         this->n = n;
         this->par.resize(n);
         this->num.resize(n, 1);
         for (int i = 0; i < n; i++) {
             this->par[i] = i;
         }
     }

     int root(int i) {
         if (par[i] == i)
             return i;
         else
             return par[i] = root(par[i]);
     }

     bool same(int i, int j) {
         return root(i) == root(j);
     }

     void unite(int i, int j) {
         int t = root(i);
         int k = root(j);

         if (t == k) return;

         par[t] = k;
         num[k] += num[t];
     }

     int size(int i) {
         return num[root(i)];
     }
};

signed main() {
    ll N, M;
    cin>>N>>M;
    vector<PLL> v(M);
    auto uf = UnionFind(N);
    rep(i,0,M){
        cin>>v[i].first>>v[i].second;
        v[i].first--;
        v[i].second--;
        uf.unite(v[i].first, v[i].second);
    }

    ll t = 0; // 便利さ： 互いに行き来できるペアの組み合わせ数
    //vector<ll> a(N, 0);
    //rep(i,0,N) if (uf.size(i) > 1) a[uf.root(i)] = uf.size(i);
    //rep(i,0,N) if (a[i]>1) t+=a[i]*a[i-1]/2;
    // cout<<"t="<<t<<endl;

    // 不便さ
    uf = UnionFind(N);
    vector<ll> ans(M);
    ans[M-1] = N*(N-1)/2 - t;
    // cout<<"ans[M-1]="<<ans[M-1]<<endl;
    for (ll i=M-2; i>=0; i--){
        // i+1の橋を増やす
        auto x = v[i+1].first, y = v[i+1].second;
        if (uf.root(x) != uf.root(y)) {
            t += uf.size(x) * uf.size(y);
            uf.unite(x, y);
        }
        ans[i] = N*(N-1)/2 -t;
    }
    rep(i,0,M){
        cout<<ans[i]<<endl;
    }
    return 0;
}


Measured memory_bytes: 4464
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstring>
#include <climits>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

constexpr ll INF = 1e18;
constexpr ll MOD = 1e9 + 7;
constexpr double PI = 3.14159265358979323846;
constexpr int di[] = {0, 0, 1, -1};
constexpr int dj[] = {1, -1, 0, 0};

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

    ll h, w;
    cin >> h >> w;

    if (h == 1 || w == 1)
    {
        cout << 1 << endl;
        return 0;
    }

    cout << (h * w + 1) / 2 << endl;

    return 0;
}


Measured memory_bytes: 256
def main():
    import sys
    from math import ceil
    input = sys.stdin.readline

    N, H = map(int, input().split())
    A = []
    B = []
    for i in range(N):
        a, b = map(int, input().split())
        A.append(a)
        B.append(b)
    a_max = max(A)
    B.sort(reverse=True)
    ans = 0
    for i in range(N):
        if a_max >= B[i]:
            break
        elif H > 0:
            ans += 1
            H -= B[i]
            continue
    if H > 0:
        ans += ceil(H / a_max)
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 51164
#include <iostream>
#include <utility>
#include <functional>
#include <math.h>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <tuple>
#include <stdlib.h>
#include <stdio.h>
#include <sstream>
using namespace std;
#define rep(i,n,x) for(int i=n;i<x;i++)
#define rem(i,n,x) for(int i=n;i>x;i--)
#define SORT(x) sort(x.begin(),x.end())
#define REV(x) reverse(x.begin(),x.end())
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp make_pair
#define fir first
#define sec second
#define setp(x) setprecision(x)
using LL = long long;
using ULL = unsigned long long;

int main() {
	char s;
	cin >> s;

	if (s == 'A') cout << 'T' << endl;
	else if (s == 'T') cout << 'A' << endl;
	else if (s == 'C') cout << 'G' << endl;
	else cout << 'C' << endl;

	return 0;
}

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

int main()
{
    short N,K;
    cin >> N >> K;

    string S;
    cin >> S;

    // if(1 < N < 50)
    //     return 0;

    // if(1 < K < N)
    //     return 0;

    // if(S.length() != N)
    //     return 0;

    transform(S.begin()+K-1, S.begin()+K, S.begin()+K-1, ::tolower);
    cout << S << endl;    
    return 0;    
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"strconv"
)

func main() {
	var (
		n      int
		y      int
		result string = "-1 -1 -1"
	)

	fmt.Scan(&n, &y)

	for i := 0; i < n+1; i++ {
		for j := 0; j < n+1-i; j++ {
			for k := 0; k < n+1-i-j; k++ {
				if n != i+j+k {
					continue
				}

				if y == 10000*i+5000*j+1000*k {
					result = strconv.Itoa(i) + " " + strconv.Itoa(j) + " " + strconv.Itoa(k)
				}
			}
		}
	}

	fmt.Println(result)
}


Measured memory_bytes: 512
import sys
sys.stdin

N, K = [int(x) for x in input().split()]
arr = [0] * (10**5+1)
for _ in range(N):
    a, b = [int(x) for x in input().split()]
    arr[a] += b

remain = K
for i in range(1, 10**5+1):
    if arr[i] != 0:
        remain -= arr[i]
    if remain <= 0:
        print(i)
        exit()

Measured memory_bytes: 5848
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;

#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, n) for(ll i = 1; i < n + 1; i++)
#define PI 3.14159265359
#define EPS 0.0000000001
#define MOD 1000000007
//cout << std::fixed << std::setprecision(15) << y << endl;


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

    ll a, b;
    a = 1;
    while(a * a <= N){
        a++;
    }
    a--;
    while(N % a != 0){
        a--;
    }
    b = N / a;

    cout << (a - 1) + (b - 1) << endl;

    return 0;
}

Measured memory_bytes: 3604
using System;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] str = Console.ReadLine().Split(' ');
            int A = int.Parse(str[0]);
            int B = int.Parse(str[1]);
            int C = int.Parse(str[2]);
            if (C >= A && C <= B)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
            Console.ReadKey();
        }
    }
}


Measured memory_bytes: 11092
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>

#define rep(i, n) for(int i=0;i<n;i++)

typedef int long long ll;
using namespace std;
typedef pair<int, int> P;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const ll MOD = 1e9 + 7;
static const int MAX = 100;
static const int INF = (1 << 23);

uint64_t dp[100005][13];
int main() {
    string s;
    cin>>s;
    ll n = s.size();


    dp[0][0] = 1;
    for(int i=0;i<n;i++){
        int c;
        if(s[i]=='?'){
            c=-1;
        }else{
            c=s[i]-'0';
        }
        //cout<<c<<endl;
            for(int j=0;j<10;j++){
                if(c!=-1&&c!=j)continue;
                for(int l=0;l<13;l++) {
                    dp[i + 1][(l*10+j)%13] += dp[i][l];
                }
            }
            for(int j=0;j<13;j++){
                dp[i+1][j]%=MOD;

            }


    }
//    rep(i,n+1){
//        rep(j,13){
//            cout<<dp[i][j]<<" ";
//        }
//        cout<<endl;
//    }

    cout<<dp[n][5]<<endl;
    return 0;
}


Measured memory_bytes: 10624
#include<stdio.h>
int main()
{
    int i,j,n,a[105],min,t,num=0;
    scanf("%d",&n);
    for(i=0;i<n;i++)
        scanf("%d",&a[i]);
    for(i=0;i<n;i++)
    {
        min=i;
        for(j=i;j<n;j++)
        {
            if(a[j]<a[min])
                min=j;
        }
        if(a[min]!=a[i])
        {
            t=a[i];
            a[i]=a[min];
            a[min]=t;
            num++;
        }
    }
    for(i=0;i<n-1;i++)
        printf("%d ",a[i]);
    printf("%d\n",a[i]);
    printf("%d\n",num);
    return 0;
}


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

int main() {
	long long N, K, SQ;
	static long long DP[110][80000] = {}, X[80000], MOD = 1000000007;
	DP[0][0] = 1;
	cin >> N >> K;
	SQ = sqrt(N);
	for (int i = 0; i < SQ; i++) {
		X[i] = 1;
	}
	for (int i = 0; i < SQ; i++) {
		int P = SQ - i;
		X[i + SQ] = N / P - N / (P + 1);
	}
	if (SQ * (SQ + 1) > N) X[SQ]--;
	SQ *= 2;
	for (int i = 0; i < K; i++) {
		long long Cur[80000] = {};
		Cur[0] = DP[i][0];
		for (int j = 1; j < SQ; j++) {
			Cur[j] = Cur[j - 1] + DP[i][j];
			Cur[j] = Cur[j] % MOD;
		}
		reverse(Cur, Cur + SQ);
		for (int j = 0; j < SQ; j++) {
			DP[i + 1][j] = (Cur[j] * X[j]) % MOD;
		}
	}
	long long ANS = 0;
	for (int i = 0; i < SQ; i++) {
		ANS = (ANS + DP[K][i]) % MOD;
	}
	cout << ANS << endl;
}

Measured memory_bytes: 65536
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <bitset>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <utility>
#include <set>
#include <map>
#include <tuple> 
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <list>
using namespace  std;
using ll = long long;
using P = pair<ll, ll>;
#define REP(i, n) for(long long (i)=0, i_bound = (long long)(n); (i)<i_bound; ++i)
#define FOR(i, a, b) for(long long (i)=(a); (i)<(b); ++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
const long long MOD = static_cast<long long>(1e9) + 7LL;
const long long INF = 1234567891234567890LL;
int main(){
    cin.tie(0);
    cout.sync_with_stdio(false);
    int N; 
    cin >> N;
    vector<ll> A(N);
    REP(i, N) cin >> A[i];
    vector<ll> C(N+1);
    vector<ll> D(N+1);
    REP(i, N) {
        C[i+1] = A[i] + C[i];
        D[i+1] = A[N-1-i] + D[i];
    }
    ll res = INF;
    //cout << C << endl;
    //cout << D << endl;
    FOR(i, 1, N){
        res = min(res, abs(C[i] - D[N-i]));
    }
    cout << res << endl;
    return 0;
}

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

#define rep(i,n) for(int i = 0; i < n; i++)
#define REP(i,n) for(int i = 1; i < n; i++)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl '\n'
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
using vs = vector<string>;
using vb = vector<bool>;
using vc = vector<char>;
using vcc = vector<vc>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll &a, const ll &b){return ((a)+(b)-1)/b;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }



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

  string a;
  rep(i,4) cin >> a[i];
  for(int i = 0; i < (1<<3); i++) {
    int res = a[0]-'0';
    bitset<3> b(i);
    rep(j,3) {
      if(b[j]) res += (a[j+1]-'0');
      else res -= (a[j+1]-'0');
    }
    if(res == 7) {
      cout << a[0];
      rep(j,3) cout << (b[j]?'+':'-') << a[j+1];
      cout << "=7" << endl;
      return 0;
    }
  }
}

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

int main() {

	int N;
	cin >> N;
	long long int sum = 0;

	for (int i = 1; i <= N; i++) {
		if (i% 3 != 0 && i%5!=0) {
			sum += i;
		}
	}
	cout << sum << endl;

}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
#define ll long long
#define deb(x) cout << #x << " " << x << "\n";
using namespace std;

void dfs(ll ver,unordered_map<int,vector<int>>&g,vector<int>&visited){
	visited[ver] = 1;
	for(auto x:g[ver]){
		if(visited[x] == -1){
				dfs(x,g,visited);
		}
	}
}

void solve(){
	ll n,m,temp1,temp2;
	unordered_map<int,vector<int>>g;
	cin >> n >> m;
	for(ll i = 0 ; i < m ;i++){
		cin >> temp1 >> temp2;
		g[temp1].push_back(temp2);
		g[temp2].push_back(temp1);
	}
	vector<int>visited(n+1,-1);
	temp2 = 0;
	for(ll i = 1; i <= n;i++){
		if(visited[i] == -1){
			dfs(i,g,visited);
			temp2++;
		}
	}
	temp2--;
	cout << temp2;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	solve();
}


Measured memory_bytes: 13708
#include<bits/stdc++.h>
using namespace std;
 
#define fi(a,b) for(int i=a;i<b;i++)
#define fj(a,b) for(int j=a;j<b;j++)
#define ff first
#define ss second
#define ll long long
#define ld long double
#define ull unsigned long long
#define bp(x) __builtin_popcount(x)
#define pr(x) for(auto it: x) cout<<it<<" "; cout<<endl;
#define endl "\n"
typedef vector<int> vi;
typedef vector< pair<int,int> > vii;
typedef vector<long long> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector< pair<ll,ll> > vll;

void nikal_pehli_fursat_mai(){
  int n,m,w;
  cin>>n>>m>>w;
  vi x(n,0),y(m,0);
  map<pii,int>arr;
  int mx=0,my=0;
  vi v1,v2;
  fi(0,w){
    int u,v;
    cin>>u>>v;
    u--;v--;
    arr[{u,v}]++;
    x[u]++;
    y[v]++;
    mx=max(mx,x[u]);
    my=max(my,y[v]);
  }
  fi(0,n){
    if(mx==x[i]) v1.push_back(i);
  }
  fi(0,m){
    if(my==y[i]) v2.push_back(i);
  }
  int ans=0;
  fi(0,v1.size()){
    fj(0,v2.size()){
      if(arr[{v1[i],v2[j]}]){
        ans=mx+my-1;
      }
      else{
        ans=mx+my;
        cout<<ans<<endl;
        return;
      }
    }
  }
  cout<<ans<<endl;
}

int main(){
  #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
  #endif
  ios::sync_with_stdio(0);
  cin.tie(0);
  int tc=1; 
  //cin>>tc;
  while(tc--){
    nikal_pehli_fursat_mai();
  }
}


Measured memory_bytes: 28428
#include <bits/stdc++.h>
using namespace std;
 
int main(){
 int N, K;
   cin >> N >> K;
	
  vector<int> P(N);
  for(int i = 0; i < N; i++){
  	cin >> P[i];
  }
  sort(P.begin(), P.end());
  
  int ans = 0;
  
  for(int i = 0 ; i<K; i++){
  	ans += P[i];
  }
  cout << ans << endl;
}

Measured memory_bytes: 3596
#include  <iostream>
#include  <stdio.h>
#include <algorithm>
#include <map>
#include <math.h>

using namespace std;
#include <vector>
#define rep(i,n) for (ll i = 0; i < (n) ; i++)
#define INF 1e9
#define llINF 1e18
#define base10_4 10000      //1e4
#define base10_5 100000     //1e5
#define base10_6 1000000    //1e6
#define base10_7 10000000   //1e7
#define base10_8 100000000  //1e8
#define base10_9 1000000000 //1e9

#define MOD 1000000007
#define pb push_back
#define ll long long
#define ull unsigned long long
#define vint vector<int>
#define vll vector<ll>

//#include <stack>
//#include <queue>

string ans_Yes = "Yes"; 
string ans_No = "No"; 
string ans_yes = "yes"; 
string ans_no = "no"; 

ll A;
ll B;
ll C;
ll N;
ll M;
ll K;

ll ltmp;
string stmp;
double dtmp;

int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    string S;
    cin >> S;
    ll leftend = S.size()/2;

    ll cnt=0;
    rep(li,leftend){
        string stmp1=S.substr(li,1);
        ll ri = (S.size()-1)-li;
        string stmp2=S.substr(ri,1);
        if(stmp1!=stmp2) cnt++;

    }
    cout << cnt << endl;
    

}

Measured memory_bytes: 3652
#include <iostream>
#include <vector>
#include <algorithm>
const int inf=0x3f3f3f3f;
using namespace std;

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

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

    vector <int> dp(n + 1,inf);
    dp[1]=0;
    dp[2]=abs(arr[2]-arr[1]);
    for(int i = 3; i <= n; i++)
    {
        for(int k=i-1;k>=max(1,i-temp);k--)
        {
        dp[i] = min(dp[k] + abs(arr[i] - arr[k]),dp[i]);
        }
    }
    cout << dp[n];
    return 0;
}


Measured memory_bytes: 1152
// 

#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <ios>
#include <iomanip>
#include <string>
#include <numeric>
#include <map>

using namespace std;
int N;

string arr2str(int A[26]) {
    string res = "";
    for (int i = 0; i < 26; i++) {
        res += to_string(A[i]);
    }
    return res;
}

int main() {
    long long count = 0;

    cin >> N;
    string strs[N];
    for (int i = 0; i < N; i++) {
        cin >> strs[i];
    }

    int memo[N][26];
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < 26; j++) {
            memo[i][j] = 0;
        }
    }

    
    for (int i = 0; i < N; i++) {
        string str = strs[i];
        for (int j = 0; j < 10; j++) {
            memo[i][str[j] - 'a']++;
        }
    }

    // for (int i = 0; i < N; i++) {
    //     for (int j = 0; j < 26; j++) {
    //         cout << memo[i][j] << " ";
    //     }
    //     cout << endl;
    // }


    map<string, long long> m;
    for (int i = 0; i < N; i++) {
        string s = arr2str(memo[i]);
        m[s]++;
    }

    for (auto i = m.begin(); i != m.end() ; ++i ) {
        long long n = i -> second;
        if (n > 1) {
            count += (n * (n - 1) / 2);
        }
    }

    cout << count << endl;

    return 0;
}


Measured memory_bytes: 31488
#include <bits/stdc++.h>
#define INF 1e9
using namespace std;

#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(a)  (a).begin(),(a).end()
#define endl "\n"

template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}
typedef long long ll;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}

void solve() {
    int v[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int K;
    cin >> K;
    cout << v[K-1] << endl;
}

int main() {
    solve();
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int a[5];
int main(){
	int n,m,i,s,c;
	scanf("%d%d",&n,&m);
	for(i=1;i<=n;i++)a[i]=-1;
	for(i=1;i<=m;i++){
		scanf("%d%d",&s,&c);
		if(a[s]!=-1&&a[s]!=c){
			printf("-1\n");
			return 0;
		}else{
			a[s]=c;
		}
	}
	if(n>1&&a[1]==0)printf("-1\n");
	else if(n==1){
		if(a[1]==-1)printf("0\n");
		else printf("%d\n",a[1]); 
	}
	else{
		for(i=1;i<=n;i++)
			if(i==1&&a[i]==-1)printf("1");
			else if(a[i]==-1)printf("0");
			else printf("%d",a[i]);
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 128
def f(x):
    if x%4 == 0:
        return x
    elif x%4 == 1:
        return 1
    elif x%4 == 2:
        return x^1
    elif x%4 == 3:
        return 0

a,b = map(int,input().split())
print(f(b)^f(a-1))

Measured memory_bytes: 2940
from itertools import permutations


d = dict()
p_s = None
n = 0

def main():
    global p_s, n
    n = int(input())
    p_s = [list(map(int, input().split(' '))) for i in range(n)]
    
    perms = list(permutations([i for i in range(n)]))
    l = len(perms)
    ans = sum(map(p2d, perms)) / l
    print(ans)


def p2d(lst):
    ans = 0
    for i in range(n-1):
        ans += fd(lst[i], lst[i+1])
    return ans


def fd(i, j):
    if (i, j) in d:
        return d[(i, j)]
    else:
        _d = ((p_s[i][0] - p_s[j][0])**2 + (p_s[i][1] - p_s[j][1])**2)**0.5
        d[(i, j)] = _d
        return _d


if __name__ == '__main__':
    main()

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

using namespace std;

typedef long long ll;

int main(){
	ll n; cin >> n;
	ll s=0, e=100000, m;
	while(m = (s+e)/2, e-s>1){
		if(m*(m+1)/2 >= n) e = m;
		else s = m;
	}
	cout << e;
}


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

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int x = sc.nextInt();
		int n = sc.nextInt();
		int p = 0;
		HashMap<Integer, Integer> map = new HashMap<Integer, Integer>();

		for (int i = 0; i < n; i++) {
			p = Integer.parseInt(sc.next());
			map.put(p, p);
		}

		int ans = 0;
		for (int i = 0; i <= 50; i++) {
			if (!map.containsKey(x - i)) {
				ans = x - i;
				break;
			}
			if (!map.containsKey(x + i)) {
				ans = x + i;
				break;
			}
		}

		System.out.println(ans);
	}

}


Measured memory_bytes: 35800
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Numerics;
using System.Runtime.InteropServices;
using System.Runtime.InteropServices.ComTypes;
using System.Text;
using System.Text.RegularExpressions;

namespace AtCoder.ABC
{
    class QuestionA
    {
        public static void Main(string[] args)
        {
            long n = int.Parse(Console.ReadLine());

            var hash = new HashSet<int>();

            for(int i = 0; i < n; i++) {
                hash.Add(int.Parse(Console.ReadLine()));
			}

            Console.WriteLine(hash.Count);
        }
    }
}



Measured memory_bytes: 27844
#include <iostream>
using namespace std;
void ABC80(void);
void ABC81(void);
void ABC83(void);
void ABC85(void);
void ABC86(void);
void ABC87(void);
void ABC88(void);
void ABC89(void);

int main(void){
    ABC83();
}

void ABC83(void){
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    if((a+b)>(c+d))cout<<"Left"<<endl;
    else if(a+b==c+d)cout<<"Balanced"<<endl;
    else cout<<"Right"<<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        String s = sc.next();

        int min = 0;
        int max = 0;

        for (int i = 0; i < s.length(); i++) {
            if (min == 0 && s.charAt(i) == 'A')
                min = i+1;
            if (min > 0 && s.charAt(i) == 'Z')
                max = i+1;
        }

        int ans = max - min;
        System.out.println(ans+1);
    }
}

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

int absolute(int x){
    return (x>0) ? x : x*(-1);
}

int mini(int a, int b){
    return (a>b) ? b : a;
}


int main(){

    int n, k;
    cin >> n >> k;

    int dp[n];
    dp[0] = 0;
    int h[n];

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

    for(int i = 1; i < mini(n,k); i++){
        dp[i] = absolute(h[i]-h[0]);
        for(int j = 1; j < i; j++){
            dp[i] = mini(dp[i],dp[j]+absolute(h[i]-h[j]));
        }
    }

    for(int i = k; i < n; i++){
        dp[i] = dp[i-k] + absolute(h[i]-h[i-k]);
        for(int j = i-k; j < i; j++){
            dp[i] = mini(dp[i],dp[j]+absolute(h[i]-h[j]));
        }
    }

    cout << dp[n-1];

    return 0;
}


Measured memory_bytes: 1024
#include<stdio.h>
int main(void)
{
  char en[1];
  
  scanf("%s",&en);
  
  if(en[0]=='A')
    printf("T\n");
  else if(en[0]=='T')
    printf("A\n");
  else if(en[0]=='C')
    printf("G\n");
  else if(en[0]=='G')
    printf("C\n");
  
  return 0;
  
}

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

#3<=N<=100

#i文字目がdの件数
#ACGT
mod=10**9+7
#NG
#AGC
#ACG
#GAC
#AGGC
#AGAC

index=[]
for s1 in "AGCT":
    for s2 in "AGCT":
        for s3 in "AGCT":
            for s4 in "AGCT":
                index.append(s1+s2+s3+s4)

#dp[i][bk]

dp=[[0]*256 for _ in range(n)]

if n==3:
    print(61)
    exit()
elif n==4:
    print(230)
    exit()

cnt=0
for i,item in enumerate(index):
    flag=0
    for ng in ["AGC","ACG","GAC","AGGC","ACGC","AGAC","ATGC","AGTC"]:
        if item==ng or item[1:]==ng or item[:-1]==ng:
            flag=1
    if flag==0:
        dp[3][index.index(item)]=1

for i in range(4,n):
    for j,item in enumerate(index):
        for s in "AGCT":
            ss=item[1:]+s
            flag=0
            for ng in ["AGC","ACG","GAC","AGGC","ACGC","AGAC","ATGC","AGTC"]:
                if ss==ng or ss[1:]==ng or ss[:-1]==ng:
                    flag=1
            if flag==0:
                dp[i][index.index(ss)]+=dp[i-1][j]%mod

print(sum(dp[-1])%mod)


Measured memory_bytes: 43500
#include <stdio.h>
#define SWAP(type,a,b) { type tmp = a; a = b; b = tmp; }

int main(void) {
    int arr[3];
    scanf("%d %d %d", &arr[0], &arr[1], &arr[2]);
    for (int i = 0; i < 2; i++) {
        for (int j = 0; j < 2; j++) {
            if (arr[j] > arr[j+1]) {
                SWAP(int, arr[j], arr[j+1]);
            }
        }
    }
    
    for (int i = 0; i < 3; i++) {
        printf("%d", arr[i]);

        if (i < 2) {
            printf(" ");
        } else {
            printf("\n");
        }
    }
    
    return 0;
}


Measured memory_bytes: 2148