akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
int main(void)
{
    int i;
    int kane;
    int maisuu;
    while(1){
        maisuu = 0;
        scanf("%d",&kane);
        if(kane == 0) break;
        kane = 1000 - kane;
        for(i = 0;; i++){
            if(kane - 500 >= 0){
                kane -= 500;
                maisuu++;
            }
            else if(kane - 100 >= 0){
                kane -= 100;
                maisuu++;
            }
            else if(kane - 50 >= 0){
                kane -= 50;
                maisuu++;
            }
            else if(kane - 10 >= 0){
                kane -= 10;
                maisuu++;
            }
            else if(kane - 5 >= 0){
                kane -= 5;
                maisuu++;
            }
            else if(kane - 1 >= 0){
                kane -= 1;
                maisuu++;
            }
            if(kane == 0) break;
        }
        printf("%d\n",maisuu);
    }
    return 0;
}

Measured memory_bytes: 596
using System;
using System.Linq;

namespace ConsoleApp
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var N = input[0];
            var A = input[1];
            var B = input[2];

            Console.WriteLine(Math.Min(A * N, B));
        }
    }
}

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

using namespace std;

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

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

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

    cout << v.back() - v.front() << endl;
}


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

using ll = long long;
#define REP(i,n) for(int i=0; i < (n); ++i)
#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)

#define INF 1e9
int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};

int main(){
  int H, W;
  cin >> H >> W;
  vector<string> s(H);
  REP(i, H){
    cin >> s[i];
  }
  int black = 0, white = 0;
  REP(i, H){
    REP(j, W){
      if(s[i][j] == '.'){
        white++;
      }
      else{
        black++;
      }
    }
  }
  vector<vector<int>> dist(H, vector<int>(W, -1));
  queue<pair<int, int>> que;
  que.push({0,0});
  dist[0][0] = 1;
  while(!que.empty()){
    int y, x;
    tie(y, x) = que.front(); que.pop();
    REP(i, 4){
      int ny = y + dy[i], nx = x + dx[i];
      if(ny < 0 || H <= ny || nx < 0 || W <= nx) continue;
      if(s[ny][nx] == '#' || dist[ny][nx] != -1) continue;
      dist[ny][nx] = dist[y][x]+1;
      que.push({ny, nx});
    }
  }
  if(dist[H-1][W-1] == -1){
    cout << -1 << endl;
  }
  else{
    cout << white - dist[H-1][W-1] << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a) for(int i=0; i<(a); i++)
typedef long long ll;
const string yes = "Yes";
const string no = "No";

int main()
{
  ll a; cin >> a;
  ll b; cin >> b;
  ll c; cin >> c;

  if (c-a-b>0 && 4*a*b < (c-a-b)*(c-a-b)) cout << yes << endl;
  else cout << no << endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main {

	public static void main(String[] args) {

		int n,m;

		Scanner stdIn = new Scanner(System.in);

		n = stdIn.nextInt();
		m = stdIn.nextInt();

		int[][] matrixA = new int[n][m];

		for(int i = 0; i < n; i++) {
			for(int j = 0; j < m; j++) {
				matrixA[i][j] = stdIn.nextInt();
			}
		}

		int[] vectorB = new int[m];

		for(int i = 0; i < m; i++) {
			vectorB[i] = stdIn.nextInt();
		}

		int[] vectorC = new int[n];

		for(int i = 0; i < n; i++) {
			for(int j = 0; j < m; j++) {
				vectorC[i] += (matrixA[i][j] * vectorB[j]);
			}
		}

		for(int i : vectorC) {
			System.out.println(i);
		}
	}

}

Measured memory_bytes: 40572
/* ＵＴＦ－８ */
#include <iostream>
#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);
	}

	std::unordered_map<char,char> m = {{'A', 'T'}, {'T', 'A'}, {'C', 'G'}, {'G', 'C'}};

	std::string b;
	std::cin >> b;
	for (auto ch : b) {
		std::cout << m[ch];
	}
	std::cout << "\n";
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
//INSERT ABOVE HERE
signed main(){
  int n;
  cin>>n;
  vector<int> a(n);
  for(int i=0;i<n;i++) cin>>a[i];
  int m;
  cin>>m;
  vector<int> b(m);
  for(int i=0;i<m;i++) cin>>b[i];

  vector<int> c;
  set_difference(a.begin(),a.end(),b.begin(),b.end(),back_inserter(c));
  for(int x:c) cout<<x<<endl;
  return 0;
}



Measured memory_bytes: 5448
import math
K,N = map(int,input().split())
a = list(map(int,input().split()))
a.sort()
for i in range(N):
    a.append(a[i] + K)
minimum = math.inf 
for i in range(N):
    minimum = min(minimum,a[i+N-1]-a[i])
print(minimum)



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

using namespace std;
#define rep(i,n) for (int i =0;i<(n);++i)
using ll = long long;
using P = pair<int, int>;

const int INF = 1001001001;
int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    rep(i, N) cin >> A[i];
    sort(A.begin(), A.end());
    int b = 0;
    rep(i, N-1) {
        if (A[i] == A[i + 1]) b++;
    }
    if (b == 0)cout << "YES";
    else cout << "NO";



   
  
}

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

//C++14 (GCC 5.4.1)
int main() {
    int R,G,B,N;
    cin >>R>>G>>B>>N;

    //-----------------------------------
    int Ans=0,N_r,N_rg,N_b;

    rep(r,N+1){
        N_r=R*r;
        if(N_r>N)break;
        rep(g,N+1){
            N_rg=N_r+G*g;
            if(N_rg>N)break;

            if((N-N_rg)%B==0){
                Ans++;
            }

        }
    }

    cout << Ans <<endl;
    return (0);
}

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

int main() {
  int a, b;
  cin >> a >> b;
  if (a / 2 == (a - 1) /2 && b / 2 == (b - 1) /2) {
    cout << "Odd" << endl;
  }
  else {
    cout << "Even" << endl;
  }
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
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 mod=1000000007;
const int INF=1001001001;

int main() {
  int N;
  cin>>N;
  vector<pair<int,int>>p(N);
  vector<int>num(N);
  for(int i=0;i<N;i++){
    int x,y;
    cin>>x>>y;
    p[i]=make_pair(y,x);
    num[i]=i;
  }
  sort(p.begin(),p.end());
  int cnt=0;
  double sum=0;
  do{
    for(int i=0;i<N;i++){
      if(i>0){
        double dx=(p[num[i]].second-p[num[i-1]].second);
        double dy=(p[num[i]].first-p[num[i-1]].first);
        sum+=sqrt(dx*dx+dy*dy);
      }
    }
    cnt++;
  }while(next_permutation(num.begin(),num.end()));
  cout<<fixed<<setprecision(10)<<sum/cnt<<endl;
  return 0;  
}

Measured memory_bytes: 3768
using System;
using System.Linq;
class Program{
    static void Main(){
       char[] s = Console.ReadLine().ToCharArray();
       bool f = true;
       int n = s.Count(p => p == 'N');
       int so = s.Count(p => p == 'S');
       int e = s.Count(p => p == 'E');
       int w = s.Count(p => p == 'W');
       f = f && ((n == 0 && so == 0) || (n != 0 && so != 0)) && ((e == 0 && w == 0) || (e != 0 && w != 0));
      string ans = f ? "Yes" : "No";
      Console.WriteLine(ans);
    }
}

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

using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define REP(i, l, n) for(int i=(l), i##_len=(n); i<i##_len; ++i)
#define ALL(x) (x).begin(),(x).end()
#define pb push_back

const int MAX = 51000; //テーブルの数
const int MOD = 1e9 + 7; //mod宣言

long long fac[MAX], finv[MAX], inv[MAX];
// finv ->階乗割り算
// fac ->階乗掛け算

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(){
    COMinit();
    ll n, k; cin >> n >> k;
    REP(i, 1, k+1){
        cout << (COM(n-k+1, i) * COM(k-1, i-1))%MOD << endl;
    }
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
int main(){
	int h,w;
  	cin>>h>>w;
  	for(int i=1;i<=h;i++){
    	for(int j=1;j<=w;j++){
        	string s;
          	cin>>s;
          	if(s=="snuke") cout<<(char)(j+'A'-1)<<i;
        }
    }
}

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

int main() {
  int a,v,b,w;
  cin>>a>>v>>b>>w;
  int t;
  cin>>t;
  if((long long)(v-w)*t>=abs(b-a))cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
}


Measured memory_bytes: 3612
import numpy as np

w,h,n = map(int,input().split())
b = np.zeros((h,w),dtype=np.int)

for i in range(n):
    x,y,a = map(int,input().split())
    if a == 1:
        b[:,:x] = 1
    elif a == 2:
        b[:,x:] = 1
    elif a == 3:
        b[:y,:] = 1
    else:
        b[y:,:] = 1
print(np.count_nonzero(b < 1))

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


const int n_max=100010;
ll dp[n_max][3];

int main() {
    int n;
    int a[n_max][3];

    cin>>n;
    rep(i,n) {
        for(int j=0;j<3;j++) {
            cin>>a[i][j];
        }
    }

    for(int i=0;i<n;i++) {
        for(int j=0;j<3;j++) {
            for(int k=0;k<3;k++) {
                if(j!=k) {
                    dp[i+1][k]=max(dp[i][j]+a[i][k],dp[i+1][k]);
                }       
            }
        }
    }
    ll ans=0;
    for(int i=0;i<3;i++) {
        ans=max(dp[n][i],ans);
    }
    cout<<ans<<endl;
  
 return 0;
}

Measured memory_bytes: 3712
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int main()
{
    ll n,ans=0,c=0,i;
    cin>>n;
    vector<ll>a(n);
    for(i=0;i<n;i++)
    {
        cin>>a[i];
        if(a[i]<0)
            c++;
    }
    for(i=0;i<n;i++)
    {
        a[i]=abs(a[i]);
    }
    sort(a.rbegin(),a.rend());
    for(i=0;i<n-1;i++)
        ans+=a[i];
        if(c%2==0)
            ans+=a[n-1];
        else
            ans-=a[n-1];
    cout<<ans;
}




Measured memory_bytes: 4048
// see https://gist.github.com/LumaKernel/ff55d49ee1af69b7388f15b707e75c15
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <complex>
#include <random>
#include <iomanip>
 
using namespace std;
 
typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> VI;
typedef vector<P> VP;
 
#define omajinai ios::sync_with_stdio(false);cin.tie(0)
 
#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=(b)-1;i>=(a);--i)
#define RREP(i,n) RFOR(i,0,n)
 
#define LFOR(i,a,b) for(ll i=(a);i<(b);++i)
#define RLFOR(i,b,a) for(ll i=(b)-1;i>=(a);--i)
 
#define ALL(a) (a).begin(),(a).end()
#define UNIQUE(a) (a).erase(unique((a).begin(),(a).end()),(a).end())
#define MP make_pair
#define PB push_back
#define EACH(i,c) REP(i,(int)(c).size())
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
 
#define dump(x) cerr << "[L " << __LINE__ << "] " << #x << " = " << (x) << "\n";
#define dump2(x,y) cerr << "[L " << __LINE__ << "] " << #x << " = " << (x)\
			<< " , " << #y << " = " << (y) << "\n";
 
const int INF = 1e9;
const double EPS = 1e-10;
const int MOD = 1e9 + 7;

int a,b;
unsigned short as[5000], bs[5000];

unsigned short dp[5000][5000];

void smax(unsigned short &a, unsigned short b) { 
  a = max(a, b);
}

int main(){
  omajinai;
  cin >> a >> b;
  REP(i, a) cin >> as[i];
  REP(i, b) cin >> bs[i];

  
  unsigned short ans = 0;
  REP(i, a) REP(j, b) {
    if(as[i] == bs[j]){
      smax(dp[i][j],
        ((i>0&&j>0) ? dp[i-1][j-1] : 0) + 1);
    }
    if(i>0)smax(dp[i][j], dp[i-1][j]);
    smax(ans, dp[i][j]);
  }
  
  cout << ans << endl;
}

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

int main(){
  // 入力
  string ABCD;
  cin >> ABCD;

  // A, B, C, Dを個別の変数に定義
  int A, B, C, D;
  A = ABCD[0] - '0';
  B = ABCD[1] - '0';
  C = ABCD[2] - '0';
  D = ABCD[3] - '0';

  // A, B, C, Dをまとめたベクターを宣言
  vector<int> num = {A, B, C, D};
  // 出力用に'+', '-'の文字を要素とするベクターを宣言
  vector<char> op = {'+', '-'};

  // ビット全探索　ビットパターン 2^3 = 8
  for (int i = 0; i < (1 << 3); i++) {
    int sum = A;
    // ビットパターンと'+', '-'を関連付け
    // "0":'+'
    // "1":'-'
    for (int j = 0; j < 3; j++) {
      if (i >> j & 1) sum -= num[j + 1];
      else            sum += num[j + 1];
    }
    // 出力
    if (sum == 7) {
      cout << A;
      for (int k = 0; k < 3; k++) {
        // ビットパターンiからベクターopの文字を選択
        cout << op[(i >> k) & 1] << num[k + 1];
        if (k == 2) {
          cout << "=7" << endl;
          return 0;
        }
      }
    }
  }
}

Measured memory_bytes: 256
room = []
for i in range(120):
    room.append(0)


n = int(input())
for i in range(n):
    dataset = input().split(" ")
    b = int(dataset[0])
    f = int(dataset[1])
    r = int(dataset[2])
    v = int(dataset[3])

    

    room[(b-1)*30 + (f-1)*10 + r-1] += v
    

for tou in range(4):
    for kai in range(3):
        for heya in range(10):
            print(" %d" % room[(tou)*30 + (kai)*10 + heya], end="")
        print()
    if tou < 3:
        print("####################")



Measured memory_bytes: 5620
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 12 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}
const int dm = 1 << 20;
char dn[dm], * di = dn;
inline void putint(int X) {
	if (X == 0) {
		*di++ = '0';
		*di++ = '\n';
		return;
	}
	int keta = 0;
	char C[10];
	while (X) {
		*(C + keta) = '0' + X % 10;
		X /= 10;
		keta++;
	}
	for (int i = keta - 1; i >= 0; i--)* di++ = (*(C + i));
	*di++ = '\n';
}

int to[200001], ne[200001], he[100001];
int kotae[100001];
char d[100001];
const int m = (1 << 20) - 1;
const int m2 = (1 << 30) - m - 1;
void sagasu(int P, int D, int C) {
	if (!kotae[P]) kotae[P] = C;
	if (d[P] < D) {
		d[P] = D;
		for (int p = he[P]; p; p = ne[p]) {
			sagasu(to[p], D - 1, C);
		}
	}
}

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


	int N, M, Q;
	N = getint();
	M = getint();
	int k = 1;
	rep(i, M) {
		int a = getint(), b = getint();
		to[k] = a;
		ne[k] = he[b];
		he[b] = k++;
		to[k] = b;
		ne[k] = he[a];
		he[a] = k++;
	}
	Q = getint();
	int v[100000], d[100000], c[100000];
	rep(i, Q) {
		v[i] = getint();
		d[i] = getint();
		c[i] = getint();
	}
	for (int i = Q - 1; i >= 0; i--) sagasu(v[i], d[i], c[i]);

	rep1(i, N) putint(kotae[i]);

	fwrite_unlocked(dn, di - dn, 1, stdout);

	Would you please return 0;
}

Measured memory_bytes: 4736
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int MAXN=2e5+7;
ll a[MAXN],b[MAXN],B[MAXN],A[MAXN];
int n;
inline ll find(ll k)
{
	int l=1,r=n+1;
	while(l<r){
		int mid=l+r>>1;
		if(B[mid]>=k) r=mid;
		else l=mid+1;
	}
	return l;
}
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++) cin>>a[i];
	for(int i=1;i<=n;i++) cin>>b[i];
	ll ans=0;
	for(int k=1;k<=29;k++){
		ll base=(1<<k)-1;
		for(int i=1;i<=n;i++) B[i]=b[i]&base;
		for(int i=1;i<=n;i++) A[i]=a[i]&base;
		sort(B+1,B+n+1);
		ll cnt=0;
		for(int i=1;i<=n;i++)
			cnt+=n-find((1<<(k-1))-A[i])+1;
		for(int i=1;i<=n;i++)
			cnt-=find((1<<k)+(1<<(k-1))-A[i])-find((1<<k)-A[i]);
		if(cnt&1) ans+=(1<<(k-1));
	}
	cout<<ans;
}

Measured memory_bytes: 6528
#include <stdio.h>

int
main(int argc, char *argv[])
{
  char s[20] = {}; int ans, k;
  scanf("%s", s);
  int i = 0, d = 0;
  while(s[i] == '9') i++;
  while(s[d] != 0) d++;
  if(d == 1) ans = s[0] - '0';
  else{
    if(i > 0){
      if(i == d) ans = 9 * d;
      else ans = 9 * d - 1;
    }
    else{
      k = 1;
      while(s[k] == '9') k++;
      if(k == d)ans = s[0] - '0' + 9 * (d - 1);
      else ans = s[0] - '0' - 1 + 9 * (d - 1);
    }
  }

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

  return 0;
}


Measured memory_bytes: 128
import itertools
import sys

input = sys.stdin.readline

ri = lambda: int(input())
rs = lambda: input().rstrip()
ril = lambda: list(map(int, input().split()))
rsl = lambda: input().rstrip().split()
ris = lambda n: [ri() for _ in range(n)]
rss = lambda n: [rs() for _ in range(n)]
rils = lambda n: [ril() for _ in range(n)]
rsls = lambda n: [rsl() for _ in range(n)]

n, m = ril()
ls = rils(n)

res = 0
for sx, sy, sz in itertools.product([-1, 1], repeat=3):
    values = []
    for x, y, z in ls:
        values.append(sx * x + sy * y + sz * z)
    values.sort(reverse=True)
    res = max(res, sum(values[:m]))
print(res)

Measured memory_bytes: 3408
let n, m = Scanf.sscanf (read_line ()) "%d %d" @@ fun a b -> a, b
let a_s = Array.init n @@ fun _ -> read_line ()
let bs = Array.init m @@ fun _ -> read_line ()
let _ = for i = 0 to n - m do for j = 0 to n - m do let b = ref true in
  for k = 0 to m - 1 do for l = 0 to m - 1 do if a_s.(i + k).[j + l] <> bs.(k).[l] then b := false done done; if !b then (print_endline "Yes"; exit 0) done done; print_endline "No"

Measured memory_bytes: 384
//
//  main.cpp
//

#include <algorithm>
#include <array>
#include <assert.h>
#include <complex>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <math.h>
#include <memory>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

using ll = int64_t;
using ull = uint64_t;
constexpr ll LL_MAX = numeric_limits<ll>::max();
constexpr ull ULL_MAX = numeric_limits<ull>::max();

template<typename T>
vector<T> make_vec_nd(T init, ll size) {
	return vector<T>(size, init);
}
template<typename T, typename... Args>
auto make_vec_nd(T init, ll size, Args... rest) {
	auto inner = make_vec_nd(init, rest...);
	return vector<decltype(inner)>(size, inner);
}

#define rep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrep(i, a, b) for (ll i = (a)-1; i >= (b); i--)

int main() {
    string s;
    cin >> s;
    unordered_map<int, ll> min_at_vec;
    auto get_min_at_vec = [&min_at_vec](int vec) -> ll {
        if (min_at_vec.find(vec) == min_at_vec.end()) {
            return numeric_limits<ll>::max();
        } else {
            return min_at_vec[vec];
        }
    };
    min_at_vec[0] = 0;
    int vec = 0;
    rep(i,0,s.size()) {
        ll ans_loc = numeric_limits<ll>::max();
        vec ^= (1 << (s[i] - 'a'));
        ans_loc = min(ans_loc, get_min_at_vec(vec));
        rep(ch,0,26) {
            int vec_loc = vec ^ (1 << ch);
            ans_loc = min(ans_loc, get_min_at_vec(vec_loc));
        }
        ans_loc++;
        min_at_vec[vec] = min(get_min_at_vec(vec), ans_loc);
        if (i == s.size() - 1) {
            cout << ans_loc << endl;
        }
    }
}


Measured memory_bytes: 11384
IDENTIFICATION DIVISION.
        PROGRAM-ID. AtCoder.
      
        ENVIRONMENT DIVISION.
      
        DATA DIVISION.
        WORKING-STORAGE SECTION.
        01 INP PIC X(100).
        01 A PIC S9(15).
        01 B PIC S9(15).
        01 C PIC S9(15).
      	01 D PIC S9(15).
      	01 E PIC S9(15).
      	01 F PIC -ZZZZZZZZZZZZ9.
	    01 temp1 PIC 9(15).
        01 temp2 PIC 9(15).
        01 N PIC 9(15).
      
        PROCEDURE DIVISION.
      	MAIN.
			ACCEPT INP.
        	PERFORM VARYING temp1 FROM 1 BY 1
            UNTIL INP(temp1:1) = SPACE
        	END-PERFORM.
        	SUBTRACT 1 FROM temp1.
        	MOVE INP(1:temp1) TO A.
        	ADD 2 TO temp1.
        	PERFORM VARYING temp2 FROM temp1 BY 1
            UNTIL INP(temp2:1) = SPACE
        	END-PERFORM.
        	COMPUTE N = temp2 - temp1.
        	MOVE INP(temp1:N) TO B.
      		COMPUTE C = A + B.
      		COMPUTE D = A - B.
      		COMPUTE E = A * B.
      		IF D < C THEN
      			MOVE C TO D
      		END-IF.
      		IF D > E THEN
      			MOVE D TO E
      		END-IF.
      		MOVE E TO F.
      		DISPLAY F.
		STOP RUN.

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

int main() {
  int N , a, b ,c;
  cin >> N;
  
  a = N /100;
  b = ( N - a*100) / 10;
  c = N % 10;
    
  if (a == 7 || b == 7 || c == 7 )
    cout << "Yes" << endl;
  else cout << "No"<<endl;
}

Measured memory_bytes: 3632
using System;
public class Program{
    public static void Main(){
        string[] input = Console.ReadLine().Split(' ');
        int kox = int.Parse(input[0]);
        int koy = int.Parse(input[1]);
        int zax = int.Parse(input[2]);
        int zay = int.Parse(input[3]);
        if(zax<zay){
            string[] zahyoux = Console.ReadLine().Split(' ');
            string[] zahyouy = Console.ReadLine().Split(' ');
//            Console.WriteLine(zahyoux.Length);
            int kazux = zahyoux.Length;
            int kazuy = zahyouy.Length;
            
            int xmax = -100;
            int ymin = 100;
            for(int i=0;i<kazux;i++){
                int temp = int.Parse(zahyoux[i]);
                if(temp>xmax){
                    xmax = temp;
                }
            }
            for(int i=0;i<kazuy;i++){
                int temp = int.Parse(zahyouy[i]);
                if(temp<ymin){
                    ymin = temp;
                }
            }
            
            if(xmax<ymin && xmax<zay && zax<ymin){
                Console.WriteLine("No War");
            }else{
                Console.WriteLine("War");
            }
            
        }else{
            Console.WriteLine("War");
        }
    }
}

Measured memory_bytes: 13140
def main():
    square_num = int(input()) + 2
    flag_list = list(map(int, input().split()))

    dice_num = 1

    # ゲームオーバーがなければ即終了
    if 1 not in flag_list:
        print(dice_num)
        return

    index = 0
    wk_index = 0
    gameover_count = 0
    answer = 0
    # ゲームオーバーが連続する最大数を求める
    while index < len(flag_list):
        if flag_list[index] == 1:
            gameover_count += 1

            wk_index = index
            while True:
                if (wk_index + 1 <= len(flag_list) - 1) and (flag_list[wk_index + 1] == 1):
                    wk_index += 1
                    gameover_count += 1
                else:
                    break

            answer = max(answer, gameover_count)
            gameover_count = 0

        index = max(index + 1, wk_index)

    # 最もゲームオーバーが連続する数 + 1を出力
    print(answer + 1)


main()


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

using namespace std;

int main() {
    int x, y;
    cin >> x >> y;
    int diff = y - x;
    int sum = 0;
    for (int i = 1; i < diff; i++) sum += i; 
    cout << sum - x << endl;

    return 0;
}



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



using ll = long long;
const int INF = 1e9+5;

int main(){
    int n,W;
    cin>>n>>W;
    
    vector<ll> dp(W+1,0);

    for(int i=0; i<n; ++i){
        int w,v;
        cin>>w>>v;
        for(int wa=W-w; wa>=0; --wa){
            dp[wa+w]=max(dp[wa+w],dp[wa]+v);
        }
    }

    cout<<dp[W];
    
}

Measured memory_bytes: 4004
import java.util.Scanner;
public class Main{
 public static void main(String args[]){
  boolean flag=false;
  Scanner scan=new Scanner(System.in);
  String s;

  s=scan.next();
  int n=Integer.parseInt(s);
  s=scan.next();
  int x=Integer.parseInt(s);
 
  int a[]=new int[n+10];
  int b=0;
  for(int i=0;i<n;i++){
   s=scan.next();
   a[i]=Integer.parseInt(s);
  }

  for(int i=0;i<n;i++){
   for(int j=i+1;j<n;j++){
    if(a[i]>a[j]){
     b=a[i];
     a[i]=a[j];
     a[j]=b;
    }
   }
  }
  int cnt=0,ans=0;
  while(cnt<x&&ans<n){
   cnt+=a[ans];
   ans++;
 // System.out.println(ans+" "+cnt);
  }
  if(cnt>x)ans--;
  if(cnt<x&&ans==n)ans--;
  System.out.println(ans);
 }
}


Measured memory_bytes: 35668
import math
k = int(input())

if k % 2 == 0:
    comb = pow((math.factorial(k//2))/(math.factorial(k//2-1)), 2)
    print(int(comb))
else:
    comb = (math.factorial(k//2))/(math.factorial(k//2-1)) * (math.factorial(k//2 + 1))/(math.factorial(k//2))
    print(int(comb))


Measured memory_bytes: 3064
class Segtree():  # Segtree

    ide_ele = 0  # 初期値(単位元)

    def segfunc(self, x, y):  # 区間にしたい操作
        return max(x, y)  # ex) max,min,gcd,lcm,sum,product

    def __init__(self, n):  # LIST: 配列の初期値
        self.num = 1 << (n - 1).bit_length()
        self.tree = [Segtree.ide_ele] * 2 * self.num
        for i in range(self.num - 1, 0, -1):  # 構築していく
            self.tree[i] = self.segfunc(self.tree[2 * i], self.tree[2 * i + 1])

    def update(self, k, x):  # k番目の値をxに更新
        k += self.num
        self.tree[k] = x
        while k > 1:
            self.tree[k >> 1] = self.segfunc(self.tree[k], self.tree[k ^ 1])
            k >>= 1

    def query(self, l, r):  # [l, r)のsegfuncしたものを得る
        res = self.ide_ele
        l += self.num
        r += self.num
        while l < r:
            if l & 1:
                res = self.segfunc(res, self.tree[l])
                l += 1
            if r & 1:
                res = self.segfunc(res, self.tree[r - 1])
            l >>= 1
            r >>= 1
        return res


n, k = map(int, input().split())
a = [int(input()) for _ in range(n)]

num = max(a) + k + 1
seg_dp = Segtree(num)
for ai in a:
    tmp = seg_dp.query(max(ai - k, 0), min(ai + k + 1, num))
    seg_dp.update(ai, tmp + 1)
print(max(seg_dp.tree))


Measured memory_bytes: 110220
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}


int main(){
  int n,m;
  cin >> n;
  map<string,int> plus;
  rep(i,n){
    string input;
    cin >> input;
    plus[input]++;
  }
  cin >> m;
  rep(i,m){
    string input;
    cin >> input;
    plus[input]--;
  }
  int ans = 0;
  for(auto itr : plus){
    ans = max(itr.second,ans);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <math.h> 
#include <string>
#include <iomanip>
#include <vector>
#include <chrono>
#include <cstdlib>
#include <bitset>
using namespace std;
int main(){
    int n;
    cin >> n;
    if(n%2 == 1) cout << n/2 + 1 << endl;
    else cout << n/2 << endl;    
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,i,p=0,k=0,s;
    cin>>n;
    for(i=1;i<=n;i++){
        if(i%2==0){
           p++;
        }
        if(i%2==1){
           k++;
        }
        s=p*k;
    }
    cout<<s<<endl;
    return 0;
}



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

using namespace std;

int main(){
    int n , q, l[100009], r[100009], sml[100009], smr[100009];
    memset(sml, 0, sizeof(sml));
    string s;
    cin >> n  >> q;
    cin >> s;
    for(int i=0;i<q;i++){
        cin >> l[i] >> r[i];
        l[i]--;r[i]--;
    }
    for(int i=1;i<n;i++){
        if(s[i-1]=='A' && s[i]=='C'){
            sml[i]++;
        }
        sml[i] += sml[i-1];
    }
    for(int i=0;i<q;i++){
        cout << sml[r[i]] - sml[l[i]] << endl;
    }
}

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

int main() {
  long double x, y;
  cin >> x >> y;
  cout << ceil(log2((y + 1) / x)) << endl;
}


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

#define FOR(i, n) for(int i = 0; i < (n); i++)
#define FORq(i, m, n) for(int i = (m); i < (n); i++)
#define FORr(i, n) for (int i = (n); i >= 0; i++)

int main() {
	int N, A, B;
	cin >> N >> A >> B;
	vector<int> P(N);
	bool Q1 = false;
	bool Q2 = false;
	bool Q3 = false;
	int count = 0;

	FOR(i, N) {
		cin >> P[i];
	}

	while (1) {
		FOR(i, N) {
			if (P[i] <= A && P[i] >= 1) {
				Q1 = true;
				P[i] = -1;
				goto Q1;
			}
		}
		Q1:
		if (!Q1) {
			cout << count << endl;
			
			return 0;
		}
		else {
			FOR(i, N) {
				if (P[i] > A && P[i] <= B) {
					Q2 = true;
					P[i] = -1;
					goto Q2;
				}
			}
			Q2:
			if (!Q2) {
				cout << count << endl;
				
				return 0;
			}
			else {
				FOR(i, N) {
					if (P[i] > B) {
						Q3 = true;
						P[i] = -1;
						goto Q3;
					}
				}
				Q3:
				if (!Q3) {
					cout << count << endl;
					
					return 0;
				}
				else {
					/*FOR(i, N) {
						if (P[i] == -1) {
							count++;
							P[i] = 101;
						}
					}*/
					count++;
					Q1 = Q2 = Q3 = false;
				}
			}
		}
	}
}

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



Measured memory_bytes: 256
import sys

read = sys.stdin.buffer.read
input = sys.stdin.buffer.readline
inputs = sys.stdin.buffer.readlines


#mod=10**9+7
# rstrip().decode('utf-8')
# map(int,input().split())
#import numpy as np

from scipy.optimize import fmin



def main():
	n = int(input())
	xy = [list(map(int, input().split())) for _ in [0] * n]
	def calc(k):
		i, j = k
		ans = 0
		for x, y in xy:
			ans = max(ans, (x - i) ** 2 + (y - j) ** 2)
		return ans

	x, y = fmin(calc, [500, 500], disp=0)
	print(calc((x, y)) ** 0.5)



if __name__ == "__main__":
	main()


Measured memory_bytes: 34792
s = input()
pat = [bin(i)[2:].zfill(len(s)-1) for i in range(2**(len(s)-1))]
ans = 0
if len(s) == 1:
    print(int(s))
    exit()
for cond in pat:
    cnt = 0
    now = int(s[0])
    for i in range(len(cond)):
        if cond[i] == "0":
            now *= 10
            now += int(s[i+1])
        else:
            cnt += now
            now = int(s[i+1])
    cnt += now
    ans += cnt
print(ans)




Measured memory_bytes: 39536
#include <iostream>
using namespace std;
int kakaku(int a,int b,int c,int d,int e,int f){
return a * 100 + b * 101 + c * 102 + d * 103 + e * 104 + f * 105;
}

int main(){

  int x;
  cin >> x;
  for(int i = 1; i < x; i++){
  if(i * 100 <= x && x <= i * 105){
   // cout << i << endl;
    for(int a = 0; a <= x; a++){
    for(int b = 0; a + b <= x; b++){
    for(int c = 0; a + b + c <= x; c++){
    for(int d = 0; a + b + c + d <= x; d++){
    for(int e = 0; a + b + c + d + e <= x; e++){
    int f = i - (a+b+c+d+e);
      if(kakaku(a,b,c,d,e,f) == x){
      cout << "1" << endl;
      return 0;  
      }
    }  
    }
    }
    } 
    }
  }
  }
  
  cout << 0 << endl;

  return 0;
}



Measured memory_bytes: 256
from math import factorial
N, M = map(int, input().split())

diff = abs(N-M)
div = 10**9 + 7

if diff > 1:
    print(0)
elif diff == 1:
    ans = factorial(N) % div * factorial(M) % div % div
    print(ans)
else:
    ans = (((factorial(N) % div) ** 2) % div * 2) % div
    print(ans)


Measured memory_bytes: 4096
//                                               KEEP GRINDING
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 

using namespace std;
using namespace __gnu_pbds; 

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>   new_data_set;

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); 

#define int long long
#define ld long double
#define MOD 1000000007
#define precise(i) fixed << setprecision(10) << i
#define f(i,a,b) for(int i=a;i<b;++i)

#define endl '\n'
#define debug cout<<"\n========================================\n";
#define err1(a) cout<<#a<<" "<<a<<endl;
#define err2(a,b) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<endl;
#define err3(a,b,c) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<endl;
#define err4(a,b,c,d) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<" "<<#d<<" "<<d<<endl;

#define all(a) a.begin(),a.end()
#define show(a) for(auto xyz:a)cout<<xyz<<" ";cout<<endl;
#define PQ priority_queue
#define LB lower_bound  
#define UB upper_bound   

#define fr first
#define sc second
#define sz(x) (int)(x).size()

#define MAXN 200010
#define INF 9223372036854775807

void solve(){
	int n,ans=0;
	cin>>n;
	vector<int> a(n);
	f(i,0,n)	cin>>a[i];
	sort(all(a));
	ans += a[n-1] ;
	int k=n-2,i=n-2;
	while(k>0){
		if(k>1)
		ans+=2*a[i],--i,k-=2;
		else
		ans+=a[i],--i,k-=1;
	}
	cout<<ans;	
}
signed main(){
    fastio
    int t=1;
    for(;t--;solve());
}


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

int main(){
  int n;
  cin >> n;
  int s=0;
  int x=n;
  while(x>0){
    int a=x%10;
    x=x/10;
    s+=a;
  }
  if(n%s==0){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

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

#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define eb emplace_back
#define rep(i, a, b) for (long i = (a); i <= (b); ++i)
#define per(i, a, b) for (long i = (a); i >= (b); --i)
#define mmst(v) memset(v, 0, sizeof(v))

template<typename T1,typename T2> inline void chmin(T1 & a, T2 b) { if (a > b) a = b; }
template<typename T1,typename T2> inline void chmax(T1 & a, T2 b) { if (a < b) a = b; }

const long kMax2 = 109;
const long kMax3 = 1009;
const long kMax4 = 10009;
const long kMax5 = 100009;
const long kMax6 = 1000009;
const long kInfI = 0x3F3F3F3F;
const float kInfF = 1e15;
const long long kMod = 1000000007;

const long kMAX = 1000000000;

using namespace std;
using ll = long long;

inline int readInt() {
  char c = getchar();
  while(!isdigit(c) && c != '-') c = getchar();
  int sigma = 1;
  if (c == '-') {
    sigma = -1;
    c = getchar();
  }
  int x = 0;
  while (isdigit(c)) {
    x = x * 10 + c - '0';
    c = getchar();
  }
  return x * sigma;
}

struct RMQ {
  long dat[kMax5][20];
  long dat2[kMax5][20];

  RMQ() {}
  void init(const vector<long> & a) {
    auto n = a.size();
    rep(i, 0, n - 2) {
      dat[i][1] = max(a[i], a[i + 1]);
      dat2[i][1] = min(a[i], a[i + 1]);
      // cout << i << " " << 1 << " " << dat[i][1] << " " << dat2[i][1] << endl;
    }
    for (auto j = 2; (1 << j) <= n; ++j) {
      for (auto i = 0; i + (1 << j) - 1 < n; ++i) {
        dat[i][j] = max(dat[i][j - 1], dat[i + (1 << (j - 1))][j - 1]);
        auto min_dat = min(dat[i][j - 1], dat[i + (1 << (j - 1))][j - 1]);
        auto max_dat2 = max(dat2[i][j - 1], dat2[i + (1 << (j - 1))][j - 1]);
        dat2[i][j] = max(min_dat, max_dat2);
        // cout << i << " " << j << " " << dat[i][j] << " " << dat2[i][j] << endl;
      }
    }
  }

  long query(ll l, ll r) {
    if (l > r) {
      return 0;
    }

    auto k = 0;
    while (l + (1 << (k + 1)) - 1 <= r) { ++k; }
    auto dat_l = dat[l][k];
    auto dat_r = dat[r - (1 << k) + 1][k];
    auto dat2_l = dat2[l][k];
    auto dat2_r = dat2[r - (1 << k) + 1][k];
    // auto min_dat = min(dat[l][k], dat[r - (1 << k) + 1][k]);
    // auto max_dat2 = max(dat2[l][k], dat2[r - (1 << k) + 1][k]);
    if (dat_l == dat_r && dat2_l == dat2_r) {
      return dat2_l;
    } else if (dat_l == dat_r) {
      return max(dat2_l, dat2_r);
    } else if (dat2_l == dat2_r){
      return min(dat_l, dat_r);
    } else if (dat_l == dat2_r){
      return dat_l;
    } else if (dat2_l == dat_r){
      return dat2_l;
    } else {
      return max(min(dat_l, dat_r), max(dat2_l, dat_r));
    }
  }
};

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

  ll ans = 0;
  string s;
  vector<long> a;
  int n;
  // cin >> n;
  cin >> s;
  rep(i, 0, s.size()) {
    if (i % 2 == 0 && s[i] == 'L') {
      cout << "No" << endl;
      return 0;
    } else if (i % 2 == 1 && s[i] == 'R') {
      cout << "No" << endl;
      return 0;
    }
  }

  cout << "Yes" << endl;

  return 0;
}


Measured memory_bytes: 256
def gcd(a,b):
    a,b = max(a,b),min(a,b)
    while a%b!=0:
        a,b = b,a%b
    return b

A,B = list(map(int,input().split()))

g = gcd(A,B)

def factorize(n):
    b,e = 2,0
    fct = []
    while b*b <= n:
        while n%b==0:
            n//=b
            e+=1
        if e>0:
            fct.append((b,e))
        b+=1
        e=0
    if n!=1:
        fct.append((n,1))
    return fct

fct = factorize(g)

print(len(fct)+1)

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

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

int di[] = {-1, 0, 1, 0, -1, 1, 1, -1};
int dj[] = {0, 1, 0, -1, 1, 1, -1, -1};

signed main(){
  
  int a, b; cin >> a >> b;
  cout << max(max(a + b, a - b), a * b) << endl;  
  return 0;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD (1000000007);

int main()
{
	ll n; cin>>n;
	unordered_map <string, ll> m;
	for (ll i=0; i<n; i++)
	{
		string s; cin>>s; sort(s.begin(),s.end());
		m[s]++;		
	}
	ll ans=0;
	for (auto x : m)
	{
		ll buf = (x.second*(x.second-1))/2;
		ans+=buf;
	}
	cout<<ans<<endl;
	return 0;
}


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

int main(){
int n,m;
cin>>n>>m;
 if (n==m)cout << "Yes" << endl;
 else cout << "No" << endl;
}

Measured memory_bytes: 256
s = gets.chomp.split("")
w = 0
ans = 0
for i in 0..s.length - 1
 if s[i] == "W"
   w += 1
 end
end 
bw = []
for i in 0..s.length - 1
 if s[i] == "B"
   bw.push(w)
 else
   w -= 1
 end
end
for i in 0..bw.length - 1
  ans += bw[i]
end

puts ans

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

int main(){
    bool prime[100001];
    int like[100001];
    prime[0]=prime[1]=false;
    for(int i=2;i<=100000;i++) prime[i]=true;
    for(int i=2;i<=sqrt(100000);i++){
        if(prime[i]){
            for(int j=2;j*i<=100000;j++) prime[i*j]=false;
        }
    }
    like[0]=like[1]=like[2]=0;
    for(int i=3;i<=100000;i+=2){
        like[i]=like[i-1];
        if(prime[i]&&prime[(i+1)/2]) like[i]=like[i-1]+1;
        like[i+1]=like[i];
    }

    int Q;
    cin >> Q;
    for(int i=0;i<Q;i++){
        int l,r;
        cin >> l >> r;

        cout << (like[r]-like[l-1]) << endl;
    }

    return 0;
}

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

using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=1;i<=n;i++)

int main(){
	int n;
	cin >> n;
	ll sum =0;
	rep(i,n){
		if(i %3 != 0 && i%5!= 0){
			sum += i;
		}
	}
	
	cout << sum << endl;

	return 0;
}

Measured memory_bytes: 3632
import java.io.PrintStream;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	static final PrintStream out = System.out;
	Scanner sc = new Scanner(System.in);
	static final long Mod = 1000_000_007L;
	public static void main(String[] args) {
		Main main = new Main();
		main.solve();
		System.exit(0);
	}

	void solve() {
		int n = nextInt();
		int[] A = new int[n+1];
		for(int i=0;i<n;i++)A[i] = nextInt();
		sc.close();
		int[] XorA = new int[n];
		XorA[0]=A[0];
		for(int i=0;i<n-1;i++)XorA[i+1] = XorA[i]^A[i+1];

		int INF = 20;
		long[] dp1 = new long[1<<INF];
		long[] dp0 = new long[1<<INF];
		long[] cnt = new long[1<<INF];
		Arrays.fill(dp0, 1);
		int zero=0;
		for (int i=0;i<n;i++) {
			if (XorA[i]==0) {
				zero++;
			} else {
				dp0[XorA[i]]+=dp1[XorA[i]]*(zero-cnt[XorA[i]]);
				dp1[XorA[i]]+=dp0[XorA[i]];
				dp0[XorA[i]]%=Mod;
				dp1[XorA[i]]%=Mod;

				cnt[XorA[i]]=zero;
			}
		}

		if (XorA[n-1]>0) {
			out.println(dp0[XorA[n-1]]);
		} else {
			long sum = 1;
			for (int i=0;i<zero-1;i++) {
				sum*=2;
				sum-=sum<Mod?0:Mod;
			}
			for (int i=0;i<(1<<INF);i++) {
				sum+=dp1[i];
				sum%=Mod;
			}
			System.out.println(sum);
		}
	}
	@SuppressWarnings("unused")
	private int min(int a, int b) {
		return Math.min(a, b);
	}
	@SuppressWarnings("unused")
	private int nextInt() {
		return Integer.parseInt(next());
	}
	@SuppressWarnings("unused")
	private long nextLong() {
		return Long.parseLong(next());
	}
	private String next() {
		return sc.next();
	}
}

Measured memory_bytes: 95000
#include <bits/stdc++.h>
#define ll long long

using namespace std;
#define MOD 1000000007
int main(){
  ll m, n;
  cin >> m >> n;
  ll ans = 1;
  ll i = m;
  while(n){
    if(n & 1 == 1){
      ans = ans * i % MOD;
    }
    i = i * i % MOD;
    n >>= 1;
  }
  cout << ans << endl;
  
}

Measured memory_bytes: 3072
#include <iostream>
#include <cmath>
#include <cctype>
#include<cstdio>
#include <string>
using namespace std;
int main(){
   
    string s1,s2;
    cin>>s1>>s2;
    s1=s1+s1;
    if(s1.find(s2)!=string::npos){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
    
    return 0;
}



Measured memory_bytes: 3240
# 2019/09/10
# かんにんぐ

n,k=map(int,input().split())
cnt=0
num=[0]*(k+1)
for i in range(1,n+1):
    num[i%k]+=1

for a in range(k):
    b=(k-a)%k
    c=(k-a)%k
    if (b+c)%k:continue
    cnt+=num[a]*num[b]*num[c]
    
print(cnt)


Measured memory_bytes: 4596
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.nextLine();
        char[] c = {'A','C','G','T'};
        int ans = 0;
        int temp = 0;
        boolean flag = false;
        for (int i = 0; i < s.length(); i++) {
            for (int j = 0; j < c.length; j++) {
                if (s.substring(i, i + 1).equals(String.valueOf(c[j]))) {
                    flag = true;
                    break;
                }
            }
            if (flag) {
                temp++;
                flag = false;
                ans = Math.max(ans, temp);
            } else {
                temp = 0;
            }

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

Measured memory_bytes: 23508
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int main() {
    string s;
    cin >> s;
    if(s.length() == 2) {
        cout << s << endl;
    }
    else {
        reverse(ALL(s));
        cout << s << endl;
    }
}

Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <cstring>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
#include <sstream>
#include <typeinfo>
#include <fstream>

using namespace std;

int main(){
    int X;
    int result;

    cin >> X;

    result=0;
    result += (X / 500) * 1000;
    result += ((X % 500) / 5) * 5;

    cout << result << endl;
    return 0;
}

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

int main() {
	string n;cin>>n;
	for(int i=0;i<3;++i){
		if(n[i]=='1')cout<<9;
		else if(n[i]=='9')cout<<1;
		else cout<<n[i];
	}
	return 0;
}

Measured memory_bytes: 256
using System;

namespace ITP1_10_A
{
	class Program
	{
		public class PointD
		{
			public double X { get; set; }
			public double Y { get; set; }

			public PointD(string x, string y)
			{
				this.X = double.Parse(x);
				this.Y = double.Parse(y);
			}
		}

		static void Main(string[] args)
		{
			string[] vs = Console.ReadLine().Split(' ');

			PointD p1 = new PointD(vs[0], vs[1]);
			PointD p2 = new PointD(vs[2], vs[3]);

			Console.WriteLine($"{Math.Sqrt(Math.Pow(p1.X - p2.X, 2) + Math.Pow(p1.Y - p2.Y, 2)):F8}");
		}
	}
}



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

#define loop(i,a,b) for(int i=(a); i<(int)(b); i++)
#define rep(i,b) loop(i,0,b)
#define all(c) (c).begin(), (c).end()
 
typedef vector<int> vi;
typedef vector<vi> vvi;

int main() {
  int m; cin >> m;
  while(m--) {
    int money, y, n; cin >> money >> y >> n;
    int ans = -1<<31;
    while(n--) {
      int type, fee;
      double interest;
      cin >> type >> interest >> fee;
      int sum = money, isum = 0;
      for(int i = 0; i < y; i++) {
        if(type == 0) {
          isum += sum * interest;
          sum -= fee;
        } else {
          sum += sum * interest - fee;
        }
      }
      sum += isum;
      ans = max(ans, sum);
    }
    cout << ans << endl;
  }
}

Measured memory_bytes: 1240
#include<stdio.h>

#define MAX 10000
#define NIL -1

struct Node{
  int p,l,r;
};
struct Node T[MAX];
int n;

void preParse(int);
void inParse(int);
void postParse(int);

int main(){
  int i,v,l,r,root;

  scanf("%d",&n);
  for(i=0;i<n;i++)
    T[i].p = NIL;

  for(i=0;i<n;i++){
    scanf("%d %d %d",&v,&l,&r);
    T[v].l = l;
    T[v].r = r;
    if(l != NIL)T[l].p = v;
    if(r != NIL)T[r].p = v;
  }

  for(i=0;i<n;i++)
    if(T[i].p == NIL)root = i;

  printf("Preorder\n");
  preParse(root);

  printf("\nInorder\n");
  inParse(root);

  printf("\nPostorder\n");
  postParse(root);
  printf("\n");

  return 0;
}

void preParse(int u){

  if(u == NIL)return;
  printf(" %d",u);
  preParse(T[u].l);
  preParse(T[u].r);
}

void inParse(int u){

  if(u  == NIL)return;
  inParse(T[u].l);
  printf(" %d",u);
  inParse(T[u].r);
}

void postParse(int u){

  if(u == NIL)return;
  postParse(T[u].l);
  postParse(T[u].r);
  printf(" %d",u);
}

Measured memory_bytes: 620
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define f(i,x,n) for (int i = x;i < n;++i)

int main() {
	int n;
	scanf("%d", &n);
	ll an = 0;
	bool p = false;
	f(i, 0, n) {
		int t;
		scanf("%d", &t);
		if (p && t > 0)--t, ++an;
		an += t / 2;
		p = t & 1;
	}
	printf("%lld", an);
}

Measured memory_bytes: 256
n = int(input())
list_w = [int(i) for i in input().split()]
tmp1 = 0
tmp2 = 0
ans = sum(list_w)
for i in range(0, len(list_w)):
    tmp1 = sum(list_w[:i + 1])
    tmp2 = sum(list_w[i + 1:])
    if ans > abs(tmp1 - tmp2):
        ans = abs(tmp1 - tmp2)
print(ans)

Measured memory_bytes: 9128