akhauriyash/Code-Regression huggingface dataset:
// atcoder/agc037/A/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; for (auto& i: v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { for (auto& i: v) is >> i; return is; }
template<typename T> ostream& operator << (ostream& os, set<T> s) { os << "#{"; for (auto& i: s) os << i << ","; os << "}"; return os; }
template<typename K, typename V> ostream& operator << (ostream& os, map<K, V> m) { os << "{"; for (auto& i: m) os << i << ","; os << "}"; return os; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

using lli = long long int;
using ull = unsigned long long;
using point = complex<double>;
using str = string;
template<typename T> using vec = vector<T>;

constexpr array<int, 8> di({0, 1, -1, 0, 1, -1, 1, -1});
constexpr array<int, 8> dj({1, 0, 0, -1, 1, -1, -1, 1});
constexpr lli mod = 1e9 + 7;

int main(int argc, char *argv[])
{
  std::ios_base::sync_with_stdio(0);
  std::cin.tie(0);
  std::cout.setf(std::ios_base::fixed);
  std::cout.precision(15);

  str s;
  while (cin >> s) {
    const int N = 2 * 1e5 + 5;
    static int dp[N][3];
    fill(&dp[0][0], &dp[N - 1][3 - 1] + 1, -(1 << 29));
    dp[0][0] = 0;
    for (int i = 0; i < s.size(); ++i) {
      for (int j = 0; j <= 2; ++j) {
        if (dp[i][j] < 0) continue;
        str prev;
        for (int k = 0; k < j; ++k) {
          if (0 <= i - k - 1) {
            prev += s[i - k - 1];
          } else {
            prev = "";
            break;
          }
        }
        reverse(prev.begin(), prev.end());
        str t;
        for (int k = 0; k < 2 && i + k < s.size(); ++k) {
          t += s[i + k];
          if (prev != t) {
            setmax(dp[i + k + 1][t.size()], dp[i][j] + 1);
          }
        }
      }
    }
    cout << max(dp[s.size()][1], dp[s.size()][2]) << endl;
  }

  return 0;
}


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


/*
    TopologicalSort
        Return "true" if the graph is DAG(Directed Acyclic Graph)
        sorted vertices is in "tpl"
    Time Complexity O(|V|+|E|)
*/


template<typename T>
pair<bool, vector<int>> TopologicalSort(const vector<vector<pair<int, T>>> &G) {
    int n = G.size();
    vector<int> tpl;
    vector<int> indeg (n, 0);
    vector<bool> seen (n,false);
    for (int i = 0; i < n; i++) {
        for (auto v : G[i]) indeg[v.first]++;
    }
    for (int s = 0; s < n; s++) {
        if (indeg[s] == 0 && !seen[s]) {
            queue<int> que; que.push(s); seen[s] = true;
            while (!que.empty()) {
                int u = que.front(); que.pop(); tpl.emplace_back(u);
                for (int i = 0; i < G[u].size(); i++) {
                    int v = G[u][i].first; indeg[v]--;
                    if (indeg[v] == 0 && !seen[v]) {
                        seen[v] = true; que.push(v);
                    }
                }
            }
        }
    }
    return make_pair(((int)tpl.size()==n), tpl);
}



int main() {
    int V, E;
    cin >> V >> E;
    vector<vector<pair<int, int>>> G(V);
    for (int i = 0; i < E; i++) {
        int s, t;
        cin >> s >> t;
        G[s].emplace_back(t, 1);
    }
    
    if (TopologicalSort(G).first) cout << 0 << endl;
    else cout << 1 << endl;
    return 0;
}
    


Measured memory_bytes: 3176
#include<bits/stdc++.h>
#define mp make_pair
#define pb push_back
using namespace std;
typedef long long LL;
typedef pair<int,int> PII;
inline LL read()
{
	LL 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<<1)+(x<<3)+(ch^48);ch=getchar();}
	return x*f;
}
const int N=708;
int n,m;
int x,y;
bool w[N][N];
int vis[N],t[3];
bool f[2][N];
//bitset<N> f;
inline bool dfs(int x)
{
	++t[vis[x]];
	for(int i=1;i<=n;++i){
		if(i!=x&&!w[x][i]){
			if(vis[i]==vis[x]){
				return 0;
			}
			if(!vis[i]){
				vis[i]=3-vis[x];
				if(!dfs(i))	return 0;
			}
		}
	}
	return 1;
}
int ans,pre,now;
int main()
{
	n=read();m=read();
	for(int i=1;i<=m;++i){
		x=read();y=read();
		w[x][y]=w[y][x]=1;
	}
	/*for(int i=1;i<=n;++i){
		for(int j=1;j<=n;++j){
			if(i!=j){
				w[i][j]^=1;
			}
		}
	}*/
	f[0][0]=1;
	//f[0]=1;
	now=1;
	for(int i=1;i<=n;++i){
		if(!vis[i]){
			t[1]=t[2]=0;
			vis[i]=1;
			if(!dfs(i)){
				puts("-1");
				return 0;
			}
			memset(f[now],0,sizeof(f[now])); 
			for(int j=n;j>=0;--j){
				if(j>=t[1]){
					f[now][j]|=f[pre][j-t[1]];
				}
				if(j>=t[2]){
					f[now][j]|=f[pre][j-t[2]];
				}
			}
			swap(now,pre);
			//f=(f<<t[1])|(f<<t[2]);
		}
	}
	ans=n;
	for(int i=1;i+i<=n;++i){
		if(f[pre][i]&&f[pre][n-i])	ans=min(ans,n-i-i);
	}
	
	x=(n+ans)>>1;
	y=(n-ans)>>1;
	printf("%d",(x*(x-1)+y*(y-1))/2); 
	return 0;
}

Measured memory_bytes: 768
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<array>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<functional>
#include<limits>
#include<list>
#include<map>
#include<numeric>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<unordered_map>
#include<queue>
#include<vector>
using namespace std;

using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define dump(o) {cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) {cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
const int MOD = 1e9 + 7;

signed main() {
	rep(i, 0, 1000) {
		string s; cin >> s;
		bool flag = true;
		rep(j, 1, s.size()) {
			if (!flag)break;
			if (s[j - 1] == s[j])flag = false;
			int a = abs(s[j] - s[j - 1]);
			if ( !(a == 3 || (a == 1 && ((s[j - 1] - 'A') / 3) == ((s[j] - 'A') / 3) )) )flag = false;
		}
		if (flag)cout << s << endl;
	}
	return 0;
}

Measured memory_bytes: 3236
/*
#pragma GCC optimize("Ofast",3,"inline")
#include<bits/stdc++.h>
using namespace std;
set<int>sett;
int n,k;
int a[200005];
int x[200005]; 
int ans;
bool flag;
int read(){
	char c=getchar();
	int sum=0;
	while(c>'9'||c<'0')c=getchar();
	while(c<='9'&&c>='0')sum=sum*10+c-'a',c=getchar();
	return sum;
}
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	cin>>n>>k;
	x[0]=1;
	for(int i=0;i<n;i++){
		cin>>a[i];
		if(i==0)continue;
		if(a[i]>a[i-1])x[i]=x[i-1]+1;
		else x[i]=1;
		if(x[i]>=k)flag=1;
	}
	for(int i=0;i<k;i++)sett.insert(a[i]);
	if(x[k-1]<k)ans++;
	for(int i=k;i<n;i++){
		sett.insert(a[i]);
		if((a[i]!=*sett.end()||a[i-k]!=*sett.begin())&&x[i]<k)ans++;
		sett.erase(a[i-k]); 
	}
	cout<<(ans+flag);
	return 0;
}
*/
//stevenjin
#include<bits/stdc++.h>
using namespace std;
int n,a[200005],cnt[200005],k,ans;
int main()
{
	scanf("%d%d",&n,&k);
	for(int i=0;i<n;i++)
		scanf("%d",&a[i]);
	for(int i=1;i<n;i++)
	{
		if(a[i]>a[i-1])cnt[i]=cnt[i-1]+1;
		else cnt[i]=0;
		if(cnt[i]>=k-1)ans=1;
	}
	set<int>se;
	for(int i=0;i<k;i++)
		se.insert(a[i]);
	if(cnt[k-1]!=k-1)ans++;
	for(int i=k;i<n;i++)
	{
		se.insert(a[i]);
		if(a[i-k]!=*se.begin()||a[i]!=*se.rbegin())
		{
			if(cnt[i]<k-1)ans++;
		}
		se.erase(a[i-k]);
	}
	printf("%d\n",ans);
	return 0;
}



Measured memory_bytes: 11136
n, m = [int(x) for x in input().split()]
locs = [int(x) for x in input().split()]
locs.sort()
 
difLocs = []
first = locs[0]
for bot,top in zip(locs, locs[1:]):
  if top == first:
    break
  difLocs.append(top-bot)
 
difLocs.sort()
if (m-n) < 0:
  print(0)
else:
  newLocs = difLocs[0:m-n]
  print(sum(newLocs))

Measured memory_bytes: 13832
import java.io.IOException;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {

		Scanner scan = new Scanner(System.in);

		long A = scan.nextLong();
		String op = scan.next();
		long B = scan.nextLong();

		if (op.equals("+")) {
			System.out.println(A + B);
		} else {
			System.out.println(A - B);
		}
	}

	//***********************以下共通関数************************************************
	/**
	 * 文字列を反転して返す
	 * @param pStr 文字列
	 * @return 反転した文字列
	 */
	public static String myReverse(String pStr) {
		if (pStr.length() < 1) {
			return "";
		}

		StringBuffer sb = new StringBuffer(pStr);
		return sb.reverse().toString();
	}

	/**
	 * 余りを求める。
	 * @param a
	 * @param b
	 * @return 余り。余りがマイナスの時はプラスで返す。
	 */
	public static long myMod(long a, long b) {
		long ret = 0;

		ret = a % b;

		if (ret < 0) {
			ret += b;
		}

		return ret;
	}

	/**
	 * 乗数を求める ※mod対応
	 * @param kisu 基数
	 * @param josu 乗数
	 * @param primeNumMod_0 法 mod値 使わない場合は「0」
	 * @return
	 */
	public static long myPowWithMod(long kisu, long josu, long primeNumMod_0) {

		long ans = 1;

		//乗数が0の場合→1
		if (josu == 0)
			return 1;

		if (primeNumMod_0 == 0) {
			//modを使わないとき

			while (josu > 0) {

				if (josu % 2 == 0) {
					//累乗が偶数の時

					kisu *= kisu;
					josu = josu / 2;
				} else {
					//累乗が奇数の時
					ans *= kisu;
					josu--;
				}
			}

			return ans;

		} else {
			//modを使うとき

			//初めに桁を落とす
			kisu = myMod(kisu, primeNumMod_0);

			while (josu > 0) {

				if (josu % 2 == 0) {
					//累乗が偶数の時

					kisu *= myMod(kisu, primeNumMod_0);
					josu = josu / 2;

				} else {
					//累乗が奇数の時
					ans *= myMod(kisu, primeNumMod_0);
					josu--;

				}
			}

			return myMod(ans, primeNumMod_0);

		}

	}

}


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

#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 ALL(v) v.begin(), v.end()

// 最大公約数を返す
int64_t gcd(int64_t a, int64_t b) {
 if (b == 0) {
   return a;
 }
 return gcd(b, a % b);
}

// 最小公倍数を返す
int64_t lcm(int64_t a, int64_t b) {
 return a / gcd(a, b) * b;
}

int t(int64_t a){
  int i = 0;
  if( a == 0) return i;
  if( a % 2 != 0) return i;
  a /= 2;
  i++;
  return i + t(a);
}

int main() {

  int64_t N, M;
  
  cin >> N >> M;

  vector<int64_t> a(N,0);

  REP(i,N) cin >> a[i];
  REP(i,N) a[i] /= 2;

  int num = 0;
  num = t(a[0]);
  FOR(i,1,N){
    if(num != t(a[i])){
      cout << 0 << endl;
      return 0;
    }
  }
  REP(i,N) a[i] >>= num;
  M >>= num;
  int64_t lcm_ = 1;
  REP(i, N){
    lcm_ = lcm(lcm_,a[i]);
    if(lcm_ > M){
      cout << 0 << endl;
      return 0;
    }
  }

  int answer = (M/lcm_ +1)/2;

  cout << answer << endl;

  return 0;




  



}

Measured memory_bytes: 1024
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

class Main{

	public static void main(String[] args) throws IOException{

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder sb = new StringBuilder();
		final int test_num = 3;
		int[] score = new int[test_num];

		while(true){

			String[] token = br.readLine().split(" ");

			for(int i = 0; i < test_num; i++){
				score[i] = Integer.parseInt(token[i]);
			}

			int total_score = score[0] + score[1];

			if(score[0] == -1 && score[1] == -1 && score[2] == -1){
				break;
			}

			if(score[0] == -1 || score[1] == -1 || total_score < 30){
				sb.append("F");
			}else if(total_score >= 30 && total_score < 50){

				if(score[2] < 50){
					sb.append("D");
				}else{
					sb.append("C");
				}

			}else if(total_score >= 50 && total_score < 65){
				sb.append("C");
			}else if(total_score >=65 && total_score < 80){
				sb.append("B");
			}else if(total_score >= 80){
				sb.append("A");
			}

			sb.append("\n");

		}

		System.out.print(sb);

	}
}

Measured memory_bytes: 24212
#include <stdio.h>
#include <string.h>

int main(){
	
	int Atk, Hth;
	scanf ("%d %d", &Atk, &Hth);
	
	int Tot = Atk/Hth;
	
	int Rst = Atk % Hth;
	
	Rst > 0 ? printf("%d", Tot+1) : printf("%d", Tot);
	
	return 0 ;
}

//  \N JANGAN LUPA!!!!!

Measured memory_bytes: 1696
// INCLUDES
#include <bits/stdc++.h>
#include<assert.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
//DEFINES
#define MAX 1000001
#define pii pair<int, int>
#define c1 __builtin_popcount
#define F first
#define S second
#define all(s) begin(s),end(s)
#define MIN3POS(a, b, c) (a) =< (b) ? ((a) =< (c) ? 1 : 3) : ((b) =< (c) ? 2 : 3)
#define MAX3POS(a,b,c) (a) >= (b) ? ((a) >= (c) ? 1 : 3) : ((b) >= (c) ? 2:3)
#define endl '\n'
#define int long long
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define FOR(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define IOS   ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args);}
//NAMESPACES
using namespace __gnu_pbds; 
using namespace std;
vector<string> vec_splitter(string s) {
    s += ',';
    vector<string> res;
    while(!s.empty()) {
        res.push_back(s.substr(0, s.find(',')));
        s = s.substr(s.find(',') + 1);
    }
    return res;
}
void debug_out(
vector<string> __attribute__ ((unused)) args,
__attribute__ ((unused)) int idx, 
__attribute__ ((unused)) int LINE_NUM) { cerr << endl; } 
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
    if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
    stringstream ss; ss << H;
    cerr << args[idx] << " = " << ss.str();
    debug_out(args, idx + 1, LINE_NUM, T...);
}
#ifdef XOX
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
#else
#define debug(...) 42
#endif
//HELPERS

vector<int> powers2(32,0);void initialize(){ for(int i=1;i<powers2.size();i++) powers2[i] = powers2[i-1]*2;}
int32_t main()
{
IOS
int n;
cin>>n;
set<string> s;
FOR(i,0,n) {
    string a;
    cin>>a;
    s.insert(a);
}
cout<<s.size();
return 0;
}
// Use emplace back in place of pushback
// Use tie function , for object destructuring

Measured memory_bytes: 19152
#include <iostream>
#include <iomanip>
#include <cmath>
#include <algorithm>
using namespace std;
int main()
{
    int n, t, a, h[100000];
    
    cin >> n >> t >> a;
    for (int i = 0; i < n; i++) cin >> h[i];
    
    double ans_d = abs(a - (t - h[0] * 0.006));
    int ans = 0;
    for (int i = 0; i < n; i++) {
       if (ans_d > abs(a - (t - h[i] * 0.006))) {
           ans = i;
           ans_d = abs(a - (t - h[i] * 0.006));
       }
    }
    
    cout << ans + 1 << endl;
    
    return 0;
}

Measured memory_bytes: 256
/* monkukui 競技プログラミング用のテンプレート  (ここから) */
#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 <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
#include <bitset>

using namespace std;
using lint = long long int;
using ll = long long int;
using lnt = long long int;
using graph = vector<vector<long long int>>;
using wgraph = vector<vector<pair<long long int, long long int>>>;
long long int INF = 1001001001001001LL;
long long int MOD = 1000000007LL;
double PI = 3.1415926535897932;
long long int di[] = {-1, 0, 1, 0, -1, 1, 1, -1};
long long int dj[] = {0, 1, 0, -1, 1, 1, -1, -1};

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;}
inline void yes(){ cout << "yes" << endl; }
inline void Yes(){ cout << "Yes" << endl; }
inline void YES(){ cout << "YES" << endl; }
inline void no(){ cout << "no" << endl; }
inline void No(){ cout << "No" << endl; }
inline void NO(){ cout << "NO" << endl; }
inline void possible(){ cout << "possible" << endl; }
inline void Possible(){ cout << "Possible" << endl; }
inline void POSSIBLE(){ cout << "POSSIBLE" << endl; }
inline void impossible(){ cout << "impossible" << endl; }
inline void Impossible(){ cout << "Impossible" << endl; }
inline void IMPOSSIBLE(){ cout << "IMPOSSIBLE" << endl; }

#define rep(i,n) for(long long int i = 0; i < (n); i++)
#define rrep(i,n) for(long long int i = 1; i <= (n); i++)
#define drep(i,n) for(long long int i = (n)-1; i >= 0; i--)
#define srep(i,s,t) for(long long int i = s; i < t; i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define pb push_back

/* monkukui 競技プログラミング用のテンプレート (ここまで)*/

int main(){
  
  int n; cin >> n;
  vector<int> a(n);
  vector<int> b(n);
  vector<int> c(n);

  rep(i, n) cin >> a[i];
  rep(i, n) cin >> b[i];
  rep(i, n - 1) cin >> c[i];

  int ans = 0;

  rep(i, n) {
    
    int idx = a[i] - 1;
    ans += b[idx];
    if(i == 0) continue;

    int pre = a[i - 1] - 1;
    if(pre + 1 == idx) {
      ans += c[pre];
    }
  }

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


Measured memory_bytes: 888
#include <bits/stdc++.h>
#define REP(i, m, n) for(int (i) = (m); (i) < (n); ++i)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
using namespace std;
using Graph = vector<vector<int>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
typedef long long ll;
typedef pair<ll, ll> P;
const int INF = 1e9+7;
const ll LINF = 1LL<<60;

const int MAXN = 100000;

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];

    multiset<int> s;

    rep(i, n) {
        int now = a[i];
        auto itr = s.lower_bound(now);
        if (itr != s.begin()) s.erase(--itr);
        s.insert(now);
    }

    cout << s.size() << endl;

    return 0;
}

Measured memory_bytes: 5376
#include <bits/stdc++.h>
using namespace std;
 
int main() {
string s;
  cin>>s;
  int n =s.length();
  bool ans=true;
for (int i = 0; i < n; i++) {
if(i%2==0&&s[i]=='L'){
  ans=false;
}
  if(i%2==1&&s[i]=='R'){
  ans=false;
}
}

  if(ans){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
  }

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

int main() {
  int N, L;
  string mini_words;
  cin >> N >> L;
  vector<string>S(N);
  for(int i = 0; i < N; i++){
    cin >> S[i];
  }
  sort(S.begin(), S.end());
  for(int j = 0; j < N; j++){
    mini_words += S[j];
  }
  cout << mini_words << endl;
}

Measured memory_bytes: 256
/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
          fozubaoyou    no BUGs alive
*/
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i = a; i < b; i++)
using namespace std;

int main(){
    int a, b, c; cin >> a >> b >> c;
    int n = 0;
    FOR(i, a, b+1) {
        if (c%i == 0) n++;
    }
    cout << n << endl;
}

Measured memory_bytes: 3100
'use strict'

function Main(input) {
  // 左から数えていって、花の本数をカウントしていく
  // もし、左隣りの本数より少ない場合はカウントしない
  const lines = input.split('\n')
  const N = parseInt(lines[0])
  const hs = lines[1].split(' ').map(Number)

  let pre = 0
  let count = 0
  // 左から数えていって、花の本数をカウントしていく
  hs.forEach(h => {
    if (h < pre) {
      // もし、左隣りの本数より少ない場合はカウントしない
      pre = h
      return
    }
    // 左隣りより本数が多い場合は、その分カウントする
    count += h - pre
    pre = h
  })
  console.log(count)
}
Main(require('fs').readFileSync('/dev/stdin', 'utf8'))

// Main(`6
// 3 1 2 3 1 3`)


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




    int main(){
        int n, x;
        std::cin >> n >> x;
        std::vector<int> d(n+1);
        d[0] = 0;
        rep(i, n){
            int x;
            std::cin >> x;
            d[i+1] = d[i] + x;
        }
        int ans = 0;
        for (int i = 0; i <= n; ++i)
        {
            if (d[i] <= x)
            {
                ans++;
            }
        }
        std::cout << ans << "\n";
    }


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

// template {{{  0 
// using {{{ 1
using ll = long long int;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vii = vector<pii>;
using vll = vector<pll>;
// }}} 1
// definition {{{ 1
// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)
#define Scll(x) scanf("%lld", &x)
#define Scll2(x,y) scanf("%lld%lld", &x, &y)
#define Scll3(x,y,z) scanf("%lld%lld%lld", &x, &y, &z)
#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2
// constants {{{ 2
#define EPS (1e-7)
#define INF (2e9)
#define PI (acos(-1))
// }}} 2
// systems {{{ 2
#define Repe(x,y,z) for(ll x = z; x < y; x++)
#define Rep(x,y) Repe(x,y,0)
#define RRepe(x,y,z) for(ll x = y-z-1; x >= 0; x--)
#define RRep(x,y) RRepe(x,y,0)
// }}} 2
// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n")
#define YESNO(a) (a)?printf("YES\n"):printf("NO\n")
// }}} 2
// }}} 1
// input {{{ 1
// }}} 1
// }}} 0

int main() {

    int N,M;
    Scd2(N,M);

    vi a(N);

    ll full = 0;
    ll ans = 1e17;

    vl c(M*2);
    vl d(M*2);
    vl s(M*2);
    Rep(i,N){
        Scd(a[i]);
        a[i]--;
    }

    Rep(i,N-1){
        if( a[i] < a[i+1] ){
            c[a[i]]++, c[a[i+1]]--;
            d[a[i+1]] += a[i+1] - a[i];
            full += a[i+1] - a[i];
        }else{
            c[a[i]]++, c[a[i+1]+M]--;
            d[a[i+1]+M] += a[i+1]+M - a[i];
            full += a[i+1]+M - a[i];
        }
    }

    ll cnt = 0;
    ll tmp = 0;
    Rep(i,M*2){
        tmp -= d[i];
        s[i] = tmp;
        cnt += c[i];
        tmp += cnt;
        // printf ("!%lld\n", s[i] );
    }

    Rep(i,M){
        ans = min( ans, full-s[i]-s[i+M] );
    }

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

    return 0;
}



Measured memory_bytes: 5376
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
using namespace std;
const ll MOD=pow(10,9)+7;
const ll INF=(1LL<<62);
const int dx[4]={0,1,0,-1};
const int dy[4]={1,0,-1,0};
const int ddx[8]={1,0,-1,-1,-1,0,1,1};
const int ddy[8]={1,1,1,0,-1,-1,-1,0};
void init(){
}

class UnionFind{
public:
  vector< int > data;
 
  UnionFind(int sz) {
    data.assign(sz, -1);
  }
 
  bool unite(int x, int y) {
    x = find(x), y = find(y);
    if(x == y) return (false);
    if(data[x] > data[y]) swap(x, y);
    data[x] += data[y];
    data[y] = x;
    return (true);
  }
 
  int find(int k) {
    if(data[k] < 0) return (k);
    return (data[k] = find(data[k]));
  }
 
  int size(int k) {
    return (-data[find(k)]);
  }
};

int main(){
    ll N,M;cin>>N>>M;
    UnionFind uf(N);
    for(int i=0;i<M;i++){
        ll x,y,z;
        cin>>x>>y>>z;
        x--;
        y--;
        uf.unite(x,y);
    }
    set<ll>pa;
    for(int i=0;i<N;i++){
        pa.insert(uf.find(i));
    }
    cout<<pa.size()<<endl;
}

Measured memory_bytes: 5376
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cmath>
#include <climits>
#include <cstring>
#include <string>
#include <map>
#include <set>
#include <vector>
#include <queue>


using namespace std;
#define INF 0x3f3f3f3f3f
#define ll long long
#define pr(x) (cerr << #x << ' ' << x << ' ')
#define prln(x) (cerr << #x << ' ' << x << endl)


int main()
{
	#ifdef LOCAL
		freopen("in.txt", "r", stdin);
	#endif // LOCAL
	int a, b;
	cin >> a >> b;
	for (int i = 1; i <= 3; ++i) {
		int t = i * a * b;
		if (t & 1) {
			cout << "Yes\n";
			return 0;
		}
	}
	cout << "No\n";
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
    int t,i,a[100],n=0;
    cin>>t;
    for(i=0;i<t;i++){
        cin>>a[i];}
         for(i=0;i<t;i++){
        if(a[i]%2==0 && a[i]%3!=0 && a[i]%5!=0){
        cout<<"DENIED"<<endl;
        return 0;}}
        cout<<"APPROVED"<<endl;
    return 0;
}




Measured memory_bytes: 256
N, M, K = map(int, input().split())
As = list(map(int,input().split()))
Bs = list(map(int,input().split()))
a, b = [0], [0]
for i in range(N):
  # a[i+1]: i番目のものまで読むのにかかる総時間
  a.append(a[i]+As[i]) # 累積和の考え方
for i in range(M):
  # aのBバージョン
  b.append(b[i] + Bs[i])

ans = 0
j = M # Bから読める冊数の最大値を入れておく
for i in range(N+1):
  if a[i] > K: # 読めない
    break
  while b[j] > K-a[i]: #すべてのiに対して、a[i]+b[j]<=K になるjを求めたい
    j -= 1
  ans = max(ans, i+j) # i+jが最大値を更新したら記録

print(ans)

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

int n, q, c, l, r;
char s[100010];
int k[100010];

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

	c = 0;
	k[0] = c;
	for (int i = 1; i < n; ++i){
		if (s[i-1] == 'A' && s[i] == 'C') c++;
		k[i] = c;
	}

	for (int i = 0; i < q; ++i){
		cin >> l >> r;
		cout << (k[r-1] - k[l-1]) << endl;
	}
}

Measured memory_bytes: 1280
pub fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

pub fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

pub fn read_vec2<T: std::str::FromStr>(n: usize) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

pub fn read_col<T: std::str::FromStr>(n: usize) -> Vec<T> {
    (0..n).map(|_| read()).collect()
}

fn f(t: u32, c: u32, s: u32, f: u32) -> u32 {
    let ans: u32;
    if t <= s {
        ans = s + c;
    } else {
        let k = (t - s + f - 1) / f;
        ans = s + c + f * k;
    }
    ans
}

fn main() {
    let n: usize = read();
    let csfvec: Vec<Vec<u32>> = read_vec2(n - 1);
    for j in 0..n {
        let mut ans: u32 = 0;
        for i in j..(n - 1) {
            ans = f(ans, csfvec[i][0], csfvec[i][1], csfvec[i][2]);
        }
        println!("{}", ans);
    }
}


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

#define N 3

int main() {
    
    int a[N];
    for(int i = 0; i < N; i++) cin>>a[i];
    
    for(int i = 0; i < N; i++) {
        for(int j = 0; j < N-i-1; j++) {
            if(a[j] > a[j+1]) {
                int tmp = a[j];
                a[j] = a[j+1];
                a[j+1] = tmp;
            }
        }
    }
    
    cout<<a[0];
    for(int i = 1; i < N; i++) {
        cout<<' '<<a[i];
    }
    cout<<endl;
    
    return 0;
}


Measured memory_bytes: 3100
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <vector>
#include <algorithm>
#include <functional>

using namespace std;

char S[100007];
long long int dp[100007][13];
long long int MOD=1e9+7;
int main()
{
    scanf("%s\n", S);

    dp[strlen(S)][0]=1;
    long long int r=1;
    for(int i=strlen(S)-1; i>=0; i--)
    {
        if(S[i]=='?')
        {
            for(int k=0; k<10; k++)
            {
                for(int m=0; m<13; m++)
                {
                    dp[i][(r*k%13+m)%13] += dp[i+1][m];
                    dp[i][(r*k%13+m)%13] %= MOD;
                }
            }

            r = (r*10)%13;
        }
        else
        {
            long long int d = S[i] - '0';

            for(int m=0; m<13; m++)
            {
                dp[i][(r*d%13+m)%13] += dp[i+1][m];
                dp[i][(r*d%13+m)%13] %= MOD;
            }

            r = (r*10)%13;

        }
        
    }
    
    printf("%lld\n",dp[0][5]);
    return 0;
}

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

int main(){
  	int N;
  	cin >> N;
  	int Mc = N/4+1;
  	int Md = N/7+1;
  	for(int i=0;i<Mc;i++){
      	for(int j=0;j<Md;j++){
          	if(i*4+j*7 == N){
              	cout << "Yes" << endl;
              	return 0;
            }
        }
    }
  	cout << "No" << endl;
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n,sum=0,b=0,min;
    cin>>n;
    vector<int> a(n);
    for(int i=0;i<n;i++){
        cin>>a.at(i);
        sum+=a.at(i);
    }
    min=sum;
    for(int i=0;i<n;i++){
        b+=a.at(i);
        sum-=a.at(i);
        if(min>abs(sum-b)) min=abs(sum-b);
    }
    cout<<min<<"\n";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define pi pair<int,int>
#define eps 0.000000001
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
#define sz(x) ((int)x.size())
#define ln(x) ((int)x.length())
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define endl '\n'
#define dbg(x) cout<<#x<<" "<<x<<endl
#define clr(x,v) memset(x, v, sizeof(x))
#define FASTIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
const int mod = 1e9 + 7;
const double PI = acos(-1.0);
const int MAXN = 1e6 + 5;

void cp()
{
    ll n, k;
    cin >> n >> k;
    int arr[n + 1];
    for(int i = 0; i < n; i++)
        cin >> arr[i + 1];
    bool vis[n + 1];
    clr(vis, false);
    ll cycle_len = 0;
    int town = 1;
    int cycle[n + 5];
    while(!vis[town])
    {
        cycle[cycle_len] = town;
        vis[town] = true;
        town = arr[town];
        cycle_len++;
    }
    int pos = 0;
    for(int i = 0; i < n + 5; i++)
    {
        if(cycle[i] == town)
        {
            pos = i;
            break;
        }
    }
    if(k > pos)
    {
        cout << cycle[pos + (k - pos) % (cycle_len - pos)];
    }
    else
        cout << cycle[k];
}

int main()
{
    FASTIO;
    int t;
    t = 1;
    // cin >> t;
    while(t--)
    {
        cp();
    }
    return 0;
}

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

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

    int K, T;
    cin >> K >> T;
    vector<int> v(T);
    rep(i, T) { cin >> v[i]; }

    rep(i, K) {
        sort(all(v), greater<int>());
        if (v[0] != 0 && v[1] != 0)
            v[0]--, v[1]--;
        else if (v[0] == 0) {
            cout << 0 << endl;
            return 0;
        } else {
            cout << v[0] - 1 << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 256
"use strict";
    
const main = arg => {
    arg = arg.trim().split("\n");
    let X = parseInt(arg[0].split(" ")[0]);
    const K = parseInt(arg[0].split(" ")[1]);
    const D = parseInt(arg[0].split(" ")[2]);
    
    let answer = 0;
    
    X = Math.abs(X);
    
    // if(X >= 0) {
        // 0までたどり着かない
        if(X - (K * D) > 0) {
            answer = X - (K * D);
            console.log(answer);
            return;
        // 0までたどり着く
        } else {
            let rest = K - Math.ceil(X / D);
            let now = X - (D * Math.ceil(X / D));
            // console.log(Math.ceil(X / D));
            // console.log(now);

            if(rest % 2 !== 0) {
                now += D; 
            }
            
            console.log(Math.abs(now));
        }
    // }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 29692
#include<stdio.h>

int main()
{
	int A,B,C,D;
	scanf("%d %d %d %d",&A,&B,&C,&D);
	if (A*B>C*D)
{ 
	printf("%d",A*B);
}
	else 
{
	printf("%d",C*D);
} 
    return 0; 
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define FO(x) {freopen(#x".in","r",stdin);freopen(#x".out","w",stdout);}
#define pa pair<int,int>
#define mod 200003
#define ll long long
#define mk make_pair
#define pb push_back
#define fi first
#define se second
#define cl(x) memset(x,0,sizeof x)
#ifdef Devil_Gary
#define bug(x) cout<<(#x)<<" "<<(x)<<endl
#define debug(...) fprintf(stderr, __VA_ARGS__)
#else
#define bug(x)
#define debug(...)
#endif

const double pi = acos(-1.0);
const int INF = 0x7fffffff;
const int N=6e5+5;
ll M,l,n,m,r[N];
ll k,b,ans,ans2;
ll a[N],v[N],g[N];
inline ll read(){
    ll x=0,rev=0,ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')rev=1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=(x<<1)+(x<<3)+ch-'0';ch=getchar();}
    return rev?-x:x;
}
struct Cp{
	double x,y;
	Cp(double _x=0,double _y=0) {x=_x,y=_y;}
	Cp operator + (const Cp& rhs) {return Cp(x+rhs.x,y+rhs.y);}
	Cp operator - (const Cp& rhs) {return Cp(x-rhs.x,y-rhs.y);}	
	Cp operator * (const Cp& rhs) {return Cp(x*rhs.x-y*rhs.y,x*rhs.y+y*rhs.x);}	
}A[N],B[N],x,w,w0;
inline void FFT(Cp *A,int f){
	int i,j,k;
	for(i=0;i<M;i++) if(i<r[i]) swap(A[i],A[r[i]]);
	for(i=1;i<M;i<<=1){
		w.x=cos(pi/i),w.y=sin(pi/i)*f;
		for(j=0;j<M;j+=i<<1){
			w0.x=1,w0.y=0;
			for(k=0;k<i;k++){
				x=A[j+k];
				A[j+k]=x+(w0*A[i+j+k]),A[i+j+k]=x-(w0*A[i+j+k]);
				w0=w0*w; 
			}
		}
	}
	if(f==-1) for(i=0;i<M;i++) A[i].x/=M;
}
int main(){
#ifdef Devil_Gary
	freopen("in.txt","r",stdin);
//	freopen("out.txt","w",stdout);
#endif
	cin>>n;
	for(ll i=0,tt=1;i<mod;i++) {
		g[i]=tt,v[tt]=i;
		(tt*=2)%=mod;
	}	
//	for(int i=1;i<mod;i++) if(!v[i]) cout<<i<<endl;
	for(M=1;M<=mod+mod;M<<=1,l++);
    for(ll i=0;i<N;i++) A[i].x=a[i],A[i].y=0; 
	for(ll i=1,tmp;i<=n;i++) {
		tmp=read();
		if(!tmp) continue;
		ans2+=tmp*tmp%mod;
		A[v[tmp]].x+=1; 
	}
	for(ll i=0;i<M;i++) r[i]=(r[i>>1]>>1)|((i&1)<<(l-1));
	FFT(A,1);
	for(ll i=0;i<M;i++) A[i]=A[i]*A[i];
	FFT(A,-1);
	for(ll i=0;i<mod+mod;i++){
//		if(A[i].x) bug(i),bug(A[i].x);
		ll t=(ll)(A[i].x+0.5);
//		if(t) cout<<i<<" "<<t<<endl;
		ans+=(g[i%(mod-1)]*t);
	}
	ans-=ans2,ans/=2;
//	cout<<g[235484%(mod-1)]<<" "<<g[198602%(mod-1)]<<" "<<g[236884%(mod-1)]<<endl; 
	printf("%lld\n",ans);
}

Measured memory_bytes: 30012
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,e) for(int i = a;i < e;++i)
using LL = long long;

int main() {

	int K, X;
	cin >> K >> X;
	FOR(i, -1000000, 1000000 + 1) {
		if (abs(i - X) < K) {
			cout << i << " ";
		}
	}
	cout << endl;
}




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

int main()
{
	int test = 0;
	int N;
	vector<int> a;
	int answer;
	cin >> N;

	answer = N;
	int temp;
	for (int i = 0; i < N; i++){
		cin >> temp;
		a.push_back(temp);
	}

	if (test){
		cout << endl;
		for (int i = 0; i < N; i++){
			cout << a[i] << " ";
		}
		cout << endl;
	}

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

	if (test){
		cout << endl;
		for (int i = 0; i < N; i++){
			cout << a[i] << " ";
		}
		cout << endl;
	}


	int num1, num2;
	int flug =1;
	int start = 0;
	while (flug){
		flug = 0;
		for (int i = start; i < N-1; i++){
			if(a[i]!=0 && a[i] == a[i + 1]){
				num1 = i;
				start = i;
				if (i == N - 2){
					num2 = i + 1;
				}
				else if (a[i+1] == a[i + 2]){
					num2 = i + 1;
				}
				else{
					num2 =i + 1;
					for (int j = i + 2; j < N-1; j++){
						if (a[j]!=0 && a[j] == a[j + 1]){
							num2 = j;
							break;
						}
					}

				}
				a[num1] = 0;
				a[num2] = 0;
				flug = 1;
				answer = answer - 2;
				break;
			}
		}
	}

	cout << answer;


	if (test){ 
		cout << endl;
		for (int i = 0; i < N; i++){
			cout << a[i] << " ";
		}
		cout << endl;
	}

	return 0;
}

Measured memory_bytes: 892
#include <iostream>
#include <stdio.h>
#include <vector>
#include <utility>
#include <algorithm>
#define llint long long
#define PI 3.141592653589793238
#define inf 1000000000

using namespace std;
typedef pair<llint, llint> P;

llint n;
llint sx, sy, tx, ty;
P p[200005];
llint dp[200005];
vector<llint> vec;

int main(void)
{
	cin >> sx >> sy >> tx >> ty;
	cin >> n;
	for(llint i = 1; i <= n; i++) cin >> p[i].first >> p[i].second;
	
	if(sy > ty) swap(sx, tx), swap(sy, ty);
	if(sx > tx){
		for(llint i = 1; i <= n; i++) p[i].first = 99999999 - p[i].first;
		sx = 99999999 - sx, tx = 99999999 - tx;
	}
	sort(p+1, p+n+1);
	
	for(llint i = 1; i <= n; i++){
		if(p[i].first >= sx && p[i].first <= tx && p[i].second >= sy && p[i].second <= ty) vec.push_back(p[i].second);
	}
	
	double ans;
	if(sx == tx || sy == ty){
		ans = (tx-sx) * 100 + (ty-sy) * 100;
		if(vec.size()) ans += PI*10 - 20;
		printf("%.15f\n", ans);
		return 0;
	}
	
	for(llint i = 0; i < 200005; i++) dp[i] = inf;
	dp[0] = -1;
	for(llint i = 0; i < vec.size(); i++) *lower_bound(dp, dp+200005, vec[i]) = vec[i];
	llint lis = lower_bound(dp, dp+200005, inf) - dp - 1;

	ans = (tx-sx + ty-sy) * 100.0;
	ans += lis * (PI*5 - 20);
	if(lis == min(tx-sx+1, ty-sy+1)){
		ans -= PI*5 - 20;
		ans += PI*10 - 20;
	}
	printf("%.15f\n", ans);
	
	return 0;
}

Measured memory_bytes: 7152
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(v) v.begin(),v.end()

int main() {
  ll x,k,d;
  cin >> x >> k >> d;
  if(x>=0){
  	ll a=x/d;
  	if(a>=k){
  	cout << x-k*d << endl;
  }else{
  	ll b=k-a;
    if(b%2==0){
    	cout << x-(a*d) << endl;
    }else{
    	cout << (x-(a*d)-d)*(-1) << endl;
    }
  }
  }else{
  	ll a=x/d;
  if(abs(a)>=k){
  	cout << abs(x+k*d) << endl;
  }else{
  	ll b=k-abs(a);
    if(b%2==0){
    	cout << abs(x-(a*d)) << endl;
    }else{
    	cout << abs(x-(a*d)+d) << endl;
    }
  }
  }
  
}



Measured memory_bytes: 3568
#include <bits/stdc++.h>
using namespace std;
#define Endl endl
typedef long long ll;
const int MAXN = (int)2e5 + 5;
ll n;
string s;
int main()
{
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	while (cin >> n)
	{
		map<string, ll> m;
		for (int i = 1; i <= n&&cin >> s; ++i)
			sort(s.begin(), s.end()), m[s]++;
		ll ans = 0;
		for (auto i : m)
			if (i.second > 1)
				ans += i.second*(i.second - 1LL) / 2LL;
		cout << ans << endl;
	}
}
/*
3
acornistnt
peanutbomb
constraint

2
oneplustwo
ninemodsix

5
abaaaaaaaa
oneplustwo
aaaaaaaaba
twoplusone
aaaabaaaaa
*/

Measured memory_bytes: 11264
#include <iostream>

int main()
{
	int a, b, c;
	std::cin >> a >> b >> c;

	if (a == b)
	{
		std::cout << c << std::endl;
	}
	else if(a == c)
	{
		std::cout << b << std::endl;
	}
	else
	{
		std::cout << a << std::endl;
	}

	return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;

int main(){
    int x;
    for(int i=1;;i++){
        cin >> x;
        if(x==0) break;
        cout << "Case " << i << ": " << x << endl;
    }
    
    return 0;
}


Measured memory_bytes: 2988
import sys
input = sys.stdin.readline
N, K = map(int, input().split())
p = list(map(int, input().split()))
c = list(map(int, input().split()))
res = [0] * N
for i in range(N):
  x = i
  score = -float("inf")
  loopscore = 0
  loop = 0
  while x != i or loop == 0:
    loop += 1
    x = p[x] - 1
    loopscore += c[x]
    if loop <= K: score = max(score, loopscore)
  #print(loopscore)
  if loopscore <= 0:
    res[i] = score
  else:
    res[i] = K // loop * loopscore
    #print(res, loop, loopscore)
    plus = 0
    plusmx = 0
    x = i
    t = 0
    while t < K % loop:
      t += 1
      x = p[x] - 1
      plus += c[x]
      plusmx = max(plusmx, plus)
    res[i] += plusmx
    if K >= loop: res[i] = max(res[i], (K // loop - 1) * loopscore + score)

print(max(res))

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

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

  int a, b;
  cin >> a >> b;

  if (b >= a) cout << a << '\n';
  else cout << a-1 << '\n';

  return (0);
}


Measured memory_bytes: 3580
n,m=map(int,input().split())
L=[0]*m
R=[0]*m
table=[0]*(n+3)
for i in range(m):
    L[i],R[i]=map(int,input().split())
    table[L[i]]+=1
    table[R[i]+1]-=1
s=[0]*(n+3)#累積和をするリスト
for i in range(1,n+3):
    s[i]=s[i-1]+table[i]
print(s.count(m))


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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------


int N;
int A[100];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N;
	FOR(i,N) cin>>A[i];
	
	ll cur=1000;
	FOR(i,N) {
		x=N,y=N;
		for(j=i+1;j<N;j++) {
			if(A[j]>A[i]) x=min(x,j);
			if(A[i]>A[j]) y=min(y,j);
		}
		if(x<y) {
			cur=cur%A[i]+cur/A[i]*A[x];
			i=x-1;
		}
	}
	cout<<cur<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
#define REPi(i, a, b) for(int i=int(a); i<int(b); i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll MOD = 1e9+7;

ll DP[100100][3];
ll ABC[100010][3];

int main(){
    int N;
    cin >> N;
    REP(i,N){
        REP(j,3)
            cin >> ABC[i][j];
    }

    REP(i,N){
        REP(k,3){
            if(i == 0) DP[i][k] = 0;
            else DP[i][k] = -1;
        }
    }

    REP(i,N){
        REP(j,3){
            REP(k,3){
                if(j == k) continue;
                chmax(DP[i+1][k], DP[i][j] + ABC[i][k]);
            }
        }
    }

    ll ans = 0;
    REP(k,3){
        chmax(ans, DP[N][k]);
    }

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


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

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

string S;
long long K;
vector<pair<int,int>> uv;

int main() {

	cin >> S >> K;
	
	string st = S+S+S;

	for (int i = 0; i < st.size(); i++)
	{
		if (st[i] == st[i + 1])st[i + 1] = 'B';
	}

	long long ans = 0;

	rep(i, S.size())
	{
		if (st[i] == 'B')ans++;
	}

	int c=0;
	rep(i, S.size())
	{
		if (st[i+S.size()] == 'B')c++;
	}
	ans += c * (K/2);

	c = 0;
	rep(i, S.size())
	{
		if (st[i + 2*S.size()] == 'B')c++;
	}
	ans += c * ((K - 1) / 2);


	if(S.size()==1)
	{
		ans = K / 2;
	}

	cout << ans << endl;
	
}

Measured memory_bytes: 256
//#include "pch.h" 
#include <iostream>
#include <string>
#include <string.h>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <stdio.h>
#include <vector>
#include <time.h>
#include <iomanip>
#include <thread>
#include <atomic>
#include <mutex>
#include <future>
#define double long double
#define int long long
#define low lower_bound
#define upp upper_bound
#define mod 1e9 + 7
#define inf 1e16
#define rep(i,n) for(int i=0;i<n;i++)
#define all(vec) vec.begin(),vec.end()
#define vsort(vec) sort(all(vec))
#define vrever(vec) reverse(all(vec));
#define vunsort(vec) vsort(vec); vrever(vec);
#define bisea binary_search
using namespace std;

signed main() {
	char a;
	cin >> a;
	if (a == 'A') cout << "T" << endl;
	else if (a == 'T') cout << "A" << endl;
	else if (a == 'G') cout << "C" << endl;
	else cout << "G" << endl;
}


Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#include <numeric>
#define IINF 1000000000
#define INF 3223372036854775807
#define MOD 1000000007
//#define mod 0
#define INT_MAX_ 2147483647
#define EPS (1e-10)
#define REP(i, a, n) fo-r (ll i = a; i < (ll)(n); i++)
#define REPE(i, a, n) for (ll i = a; i <= (ll)(n); i++)
//#define rep(i,n)for (ll i = 0; i < (ll)(n); i++)
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define Endl endl
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
#define me memset
#define bit(n,k) ((n>>k)&1)
//#define leng length()
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef pair<int,int>Pin;
typedef pair<ll,ll>Pll;
template<class T> using V=vector<T>;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T> >;
long long GCD(long long a, long long b) {return b?GCD(b,a%b):a;}
long long LCM(long long a, long long b) {return a/GCD(a,b)*b;}
ll pom(ll a,ll n,int m){ll x=1;for(a%=m;n;n/=2)n&1?x=x*a%m:0,a=a*a%m;return x;}
#define invp(a,p)pom(a,p-2,p)
int dx[4]={-1,0,1,0};
int dy[4]={0,-1,0,1};
int ddx[8]={-1,0,1,0,1,1,-1,-1};
int ddy[8]={0,-1,0,1,1,-1,1,-1};
ll cmp1(pair<Pll,ll> a,pair<Pll,ll> b){
        return a.fi.se>b.fi.se;
}
ll cmp2(pair<Pll,ll> a,pair<Pll,ll> b){
        return a.se<b.se;
}
//----------------------------------------------------------------------

//----------------------------------------------------------------------
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------  
    //ll begin_t=clock();
    //freopen("big.txt", "r", stdin);
    //freopen("out3.txt", "w", stdout);
    //-----------------------------
    ll k;cin>>k;
    ll mod=k;
    ll b = k%10;
    if(k%2==0||b==5){
        cout<<-1<<endl;
        return 0;
    }
    ll x = 7;
    x%=mod;
    ll cnt=1;
    while(1){
        if(x==0)break;
        x*=10;
        x%=mod;
        x+=7;
        x%=mod;
        cnt++;
    }
    cout<<cnt<<endl;
    //------------------------------
    //fclose(stdin);
    //fclose(stdout);
    //ll end_t=clock();cout<<"time="<<end_t-begin_t<<"ms"<<endl;
    //------------------------------- 
    return 0;
}
//----------------------------------------------------------------------














































Measured memory_bytes: 3604