akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define sf scanf
#define pf printf
#define pb push_back
#define mp make_pair
#define PI ( acos(-1.0) )
#define mod 998244353LL
#define IN freopen("C.in","r",stdin)
#define OUT freopen("output.txt","w",stdout)
#define FOR(i,a,b) for(i=a ; i<=b ; i++)
#define DBG pf("Hi\n")
#define INF 1000000000
#define i64 long long int
#define eps (1e-8)
#define xx first
#define yy second
#define ln 17
#define off 2

using namespace __gnu_pbds;
using namespace std ;

typedef pair<int, int> pi ;
typedef tree< pi, null_type, less<pi>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

#define maxn 300005

/*
     *os.find_by_order(k) -> returns the k'th smallest element (indexing starts from 0)
      os.order_of_key(v)  -> returns how many elements are strictly smaller than v
*/

pair<int,int> p[maxn] ;
pair<int,int> q[maxn] ;

int dp[maxn] ;
int pos[maxn] ;

int main()
{
    int n ;
    scanf("%d",&n) ;
    for(int i=1 ; i<=n ; i++) scanf("%d",&p[i].yy) ;
    for(int i=1 ; i<=n ; i++) scanf("%d",&p[i].xx) ;

    sort( p+1 , p+n+1 ) ;

    for(int i=1 ; i<=n ; i++) q[i] = mp( p[i].yy , i ) ;

    sort( q+1 , q+n+1 ) ;

    for(int i=1 ; i<=n ; i++)
    {
        if( p[i].xx < q[i].xx )
        {
            printf("No\n") ;
            return 0 ;
        }
    }

    for(int i=1 ; i<=n ; i++) pos[ q[i].yy ] = i ;

    for(int i=2 ; i<=n ; i++)
    {
        if( q[i].xx==q[i-1].xx )
        {
            printf("Yes\n") ;
            return 0 ;
        }
    }

    int cur = 1 , len = 0 ;

    while( 1 )
    {
   //     printf("---%d\n",cur) ;
        len++ ;
        cur = pos[cur] ;
        if(cur==1) break ;
    }

  //  printf("-----%d\n",len) ;

    if(len!=n)
    {
        printf("Yes\n") ;
        return 0 ;
    }

    for(int i=2 ; i<=n ; i++)
    {
        if( q[i].xx <= p[i-1].xx ) dp[i] = 1 + dp[i-1] ;
   //     printf("%d---%d\n",i,dp[i]) ;
    }

//    for(int i=1 ; i<=n ; i++) printf("%d\n",pos[i]) ;

    for(int i=1 ; i<=n ; i++)
    {
  //      printf("----------%d\n",pos[i]) ;
        if( pos[ i ] >= i && p[i].yy <= p[i].xx )
        {
            printf("Yes\n") ;
            return 0 ;
        }
        else if( dp[i] >= i-pos[i] && pos[i] < i )
        {
            printf("Yes\n") ;
            return 0 ;
        }
    }

    printf("No\n") ;

    return 0 ;
}


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

using namespace std;

typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define debug(a) cout << #a << ": " << a << endl;

int main() {
  int A, B, C;
  cin >> A >> B >> C;
  cout << max((C - A + B), 0) << endl;
}


Measured memory_bytes: 256
/*   _ _ _                     
    | | | | ___  ___           
    | | | || . ||  _|          
    |_____||_  ||_|  _____     
             |_|    |_____|  */
// Time : 19/10/16
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define inf 0x3f3f3f3f
using pii = pair<int, int>;
int main(){
#ifdef Wqr_
    freopen("in.txt","r",stdin);
#endif
    std::ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
    vector<pii> v;
    int n;
    cin >> n;
    int tmp;
    for(int i = 1; i <= n; i++){
        cin >> tmp;
        v.push_back(make_pair(i, tmp));
    }
    sort(v.begin(), v.end(), [](pii a, pii b){return a.second < b.second;});
    for(auto i : v){
        cout << i.first << " ";
    }
    return 0;
}

Measured memory_bytes: 1780
#include <string>
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
using ll = long long int;
const int MOD = 1e9+7;

int main(){
    string k;
    ll d; 
    cin >> k >> d;
    int w = (int)k.length();
    vector<int> keta;
    for(int i=0; i<w; i++){
        keta.push_back((int)k[i] - 48);
    }
    vector<vector<vector<ll>>> dp(d, vector<vector<ll>>(w, vector<ll>(2, 0)));
    for(int i=0; i<w; i++){
        if(i==0){
            for(int j=0; j<keta[0]; j++){
                dp[j % d][0][1] += 1;
            }
            dp[keta[0] % d][0][0] += 1;
            continue;
        }
        for(int j=0; j<d; j++){
            for(int k=0; k<10; k++){
                dp[(j+k)%d][i][1] += dp[j][i-1][1];
                if(k < keta[i]){
                    dp[(j+k)%d][i][1] += dp[j][i-1][0];
                }
            }
            dp[(j + keta[i]) % d][i][0] += dp[j][i-1][0];
            dp[j][i][1] %= MOD;
        }
    }
    // for(int i=0; i<2; i++){
    //     for(int j=0; j<w; j++){
    //         for(int k=0; k<d; k++){
    //             cout << dp[k][j][i] << " ";
    //         }
    //         cout <<"\n";
    //     }
    //     cout << "\n";
    // }
    cout << (dp[0][w-1][0] + dp[0][w-1][1] - 1) % MOD << "\n";
    return 0;
}

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

// 全体の最初・最後のstringで例外アリ
int main(){
	int N, cnt, bstart, aend, btoa, cnt_sub;
	cin >> N;
	cnt = 0;
	bstart = 0;
	aend = 0;
	btoa = 0;
	vector<string> s(N);
	for(int i=0; i<N; i++){
		cin >> s[i];
	}
	for(int i=0; i<N; i++){
		for(int ci=0; ci<s[i].length()-1; ci++){
			if(s[i][ci] == 'A' && s[i][ci+1] == 'B'){
				cnt++;
			}
		}
	}
	//cout << cnt << endl;
	for(int i=0; i<N; i++){
		if(s[i][0]=='B' && s[i][s[i].length()-1]=='A'){
			btoa++;
		}else{
			if(s[i][0]=='B'){
				bstart++;
			}else if(s[i][s[i].length()-1]=='A'){
				aend++;
			}
		}
	}
	cnt_sub = 0;
	if(btoa >= 2){
		cnt_sub += btoa - 1;
		btoa = 1;
	}
	if(btoa==1 && bstart >= 1){
		bstart--;
		cnt_sub++;
	}
	if(btoa==1 && aend >= 1){
		aend--;
		cnt_sub++;
	}
	cnt_sub += min(bstart, aend);

	//cout << cnt_sub << endl;
	//cnt += min(cnt_sub, N-1);
	cnt += cnt_sub;
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 768
def grouping(a, b)
  group_a = [1, 3, 5, 7, 8, 10, 12]
  group_b = [4, 6, 9, 11]
  if (group_a.include?(a) && group_a.include?(b)) || (group_b.include?(a) && group_b.include?(b)) || (a == b)
    puts "Yes"
  else
    puts "No"
  end
end

a, b= gets.chomp.split(" ").map(&:to_i)
grouping(a, b)

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

int main()
{
  std::string input;
  std::cin >> input;
  
  if (input[0] == input[1])
  {
    if (input[0] != input[2] && input[2] == input[3])
    {
      std::cout << "Yes\n";
    }
    else
    {
      std::cout << "No\n";
    }
  }
  else if (input[0] == input[2])
  {
    if (input[0] != input[1] && input[1] == input[3])
    {
      std::cout << "Yes\n";
    }
    else
    {
      std::cout << "No\n";
    }
  }
  else if (input[0] != input[1] && input[0] == input[3])
  {
    if (input[1] == input[2])
    {
      std::cout << "Yes\n";
    }
    else
    {
      std::cout << "No\n";
    }
  }
  else
  {
      std::cout << "No\n";
  }
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template <typename A, typename B>
string to_string(pair<A, B> p);

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);

string to_string(const string& s) {
    return '"' + s + '"';
}

string to_string(const char* s) {
    return to_string((string) s);
}

string to_string(bool b) {
    return (b ? "true" : "false");
}

string to_string(vector<bool> v) {
    bool first = true;
    string res = "{";
    for (int i = 0; i < static_cast<int>(v.size()); i++) {
        if (!first) {
            res += ", ";
        }
        first = false;
        res += to_string(v[i]);
    }
    res += "}";
    return res;
}

template <size_t N>
string to_string(bitset<N> v) {
    string res = "";
    for (size_t i = 0; i < N; i++) {
        res += static_cast<char>('0' + v[i]);
    }
    return res;
}

template <typename A>
string to_string(A v) {
    bool first = true;
    string res = "{";
    for (const auto &x : v) {
        if (!first) {
            res += ", ";
        }
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
    return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
    return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
    return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}

void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H);
    debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

int main() {
    int n, m; cin >> n >> m;
    if(abs(n - m) > 1) {
        cout << 0;
        return 0;
    }
    long long ans = 1;
    long long md = 1e9 + 7;
    for (int i = 2; i <= min(n, m); i++) {
        ans = (ans * i) % md;
    }
    ans = (ans * ans) % md;
    if (n != m) {
        ans = (ans * max(n, m)) % md;
    } else {
        ans = (ans * 2) % md;
    }
    cout << ans;
}


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

char s[100001];

int main(){
	scanf("%s", s);
	int n = strlen(s), p = 0, r = 0, an = 0;
	f(i, 0, n)if (s[i] == 'g'){
		if (r > p)++an, ++p;
		else ++r;
	}
	else if (r > p)++p;
	else ++r, --an;
	printf("%d\n", an);
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string J;
  int i;
  char c;
  bool f = true;
  cin >> J;
  
  
  for(i = 0;i < J.length();i++){
    if(i == 0){
      c = J.at(i);
      continue;
    }
    if(c == J.at(i)){
      cout << "Bad" << endl;
      f = false;
      break;
    }
    else{
      c = J.at(i);
    }
  }
  if(f){
    cout << "Good" << endl;
  }
}

Measured memory_bytes: 256
n, a, b = map(int, input().split())

if a == 0 or b == 0:
    print(n if b == 0 else 0)
else:
    num_of_sets, rem = divmod(n, a + b)
    a_num = num_of_sets * a
    b_num = num_of_sets * b
    a_add = min(rem, a)
    rem -= a_add
    a_num += a_add
    print(a_num)






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


#define li			long long int
#define rep(i,to)	for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)	for(li i=(li)(start);i<((li)(to));i++)
#define pb			push_back
#define sz(v)		((li)(v).size())
#define bgn(v)		((v).begin())
#define eend(v)		((v).end())
#define allof(v)	(v).begin(), (v).end()
#define dodp(v,n)		memset(v,(li)n,sizeof(v))
#define bit(n)		(1ll<<(li)(n))
#define mp(a,b)		make_pair(a,b)
#define rin	rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)		idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)		idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)		idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)		idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)		idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)		idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)		idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)		idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)		idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)	for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)		idp p2((x).F, (x).S)
#define dump(x,n)	idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)	idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)	idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)	idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)	rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)	rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;

li a[1010];

int main(){
	li n,m;
	cin>>n>>m;
	rep(i,m){cin>>a[i];}

	if(m==1){
		if(a[0]==1){
			cout<<a[0]<<endl;
			cout<<1<<endl;
			cout<<a[0]<<endl;
			return 0;
		}
		cout<<a[0]<<endl;
		cout<<2<<endl;
		cout<<1<<" "<<a[0]-1<<endl;
		return 0;
	}
	if(m==2){
		cout<<a[0]<<" "<<a[1]<<endl;

		if(a[0]==1){
			puts("1");
			cout<<n<<endl;	
			return 0;
		}
		cout<<2<<endl;
		cout<<a[0]-1<<" "<<a[1]+1<<endl;
		return 0;
	}
	vector<li> odd,even;
	rep(i,m){
		if(a[i]%2>0)odd.pb(a[i]);
		else even.pb(a[i]);
	}
	if(sz(odd)>2){
		puts("Impossible");
		return 0;
	}

	vector<li> res;
	if(sz(odd)>0)res.pb(odd[0]);
	res.insert(res.end(), allof(even));
	if(sz(odd)>1)res.pb(odd[1]);

	foreach(it,res){cout<<*it<<" ";}
	if(res[0]>1){
		cout<<sz(res)<<endl;
		cout<<res[0]-1<<" ";
	}else{
		cout<<sz(res)-1<<endl;
	}
	repp(i,1,sz(res)-1){
		cout<<res[i]<<" ";
	}
	cout<<res[sz(res)-1]+1<<endl;

	return 0;
}


Measured memory_bytes: 256
n=int(input())
d={}
a=[]
for i in range(n):
  s=input()
  if s not in d:
    d[s]=1
  else:
    d[s]+=1
    
m=max(d.values())

for keys in d.keys():
  if d[keys]==m:
    a.append(keys)
a=sorted(a)

for word in a:
  print(word)

Measured memory_bytes: 32988
#include <iostream>
#include <algorithm>
#include <cstring>
#include <memory.h>
#include <math.h>
#include <vector>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <stdio.h>
#include <queue>
#include <stack>
#include <cstdio>
#include <bitset>

using namespace std;

#define nfs ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define f first
#define s second
#define m_p make_pair
#define pb push_back
#define ii pair<int,int>
#define iii pair<int,pair<int,int> >
#define ll long long
#define ull unsigned long long
#define ld long double
#define ef else if
#define loc(x) (x).begin(),(x).end() 
#define locR(x) (x).rbegin(),(x).rend()
#define no puts("NO")
#define yes puts("YES")
#define ex puts("-1")
#define en puts("")
#define _ cout  
#define __ <<
#define outV(v) for(int i = 0 ; i < v.size() ; i++)cout << v[i] << ' ';
#define outA(x,l,r) for(int i = l ; i < r ; i++)cout << x[i] << ' ';

const ld EPS = 1e-18;
const double DEPS = 1e-9;
const ld PI = 3.141592653589793238;
const ll MOD = 998244353;
const int N = (int)(3e5) + 1;


ll gcd(ll fx, ll fy)
{
	if (!fy) return fx;
	return gcd(fy, fx % fy);
}

inline void fill(int* ar, int sz, int val)
{
	for (int i = 0; i < sz; i++)
	{
		ar[i] = val;
	}
}

int n, a[3030];
ll dp[3001][3001];
bool mark[3001][3001];

ll dfs(int l, int r)
{
	if (l > r || r < l)return 0;
	bool t = (r - l) % 2 == n % 2;
	ll& dp = ::dp[l][r];
	if (mark[l][r])return dp;
	mark[l][r] = 1;
	ll x = (t ? -1 : 1) * a[l] + dfs(l + 1, r);
	ll y = (t ? -1 : 1) * a[r] + dfs(l, r - 1);

	return dp = (!t ? max(x, y) : min(x, y));
}

int main()
{
	cin >> n;

	for (int i = 0; i < n; i++)
	{
		scanf("%d", a + i);
	}

	printf("%lld", dfs(0, n - 1));
}

Measured memory_bytes: 78464
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		int SUM = 1;
		if(A == B && A == C) {
		}else if(A != B && A != C && B != C) {
			SUM = 3;
		}else{
			SUM = 2;
		}
		System.out.print(SUM);
	}
}

Measured memory_bytes: 21716
// C++ Implementation of the above approach
#include<bits/stdc++.h>
using namespace std;

// Function to find the minimum number
// character change required

void change(string s)
{

	// Finding the length of the string
	int n = s.length();

	// To store the number of replacement operations
	int cc = 0;

	for(int i=0;i<n/2;i++)
	{

		// If the characters at location
		// i and n-i-1 are same then
		// no change is required
		if(s[i]== s[n-i-1])
			continue;

		// Counting one change operation
		cc+= 1;

		// Changing the character with higher
		// ascii value with lower ascii value
		if(s[i]<s[n-i-1])
			s[n-i-1]= s[i] ;
		else
			s[i]= s[n-i-1] ;
	}
	//printf("Minimum characters to be replaced = %d\n", (cc)) ;
	//cout<<s<<endl;

	cout << cc << endl;
}
// Driver code
int main()
{
string s;

cin >> s;
change((s));
return 0;
}
//contributed by Arnab Kundu


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <ios> 
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>
#include <map>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)

using namespace std;
typedef long long int lli;
typedef vector<int> vi;
//const int MAX=;

int w[2001][2001][2];

int main(){
	int N,K;
	cin>>N>>K;
	rep(i,N){
		int x,y,d;
		char c;
		cin>>x>>y>>c;
		x=x%(2*K);y=y%(2*K);
		if(c=='W')d=0;
		else d=1;
		w[x][y][d]++;
	}
	rep(i,2*K)rep(j,2*K){
		if(K<=i&&K<=j){
			w[i-K][j-K][0]+=w[i][j][0];
			w[i-K][j-K][1]+=w[i][j][1];
		}
		else if(K<=i){
			w[i-K][j][0]+=w[i][j][1];
			w[i-K][j][1]+=w[i][j][0];
		}
		else if(K<=j){
			w[i][j-K][0]+=w[i][j][1];
			w[i][j-K][1]+=w[i][j][0];
		}
	}  
	//[0,i)*[0,j)での白希望の個数
	int wh[1002][1002];
	rep(i,K+1)wh[0][i]=wh[i][0]=0;
	rep1(i,K)rep1(j,K){
		wh[i][j]=w[i-1][j-1][0]+wh[i][j-1]+wh[i-1][j]-wh[i-1][j-1];
	}
	//[0,i)*[0,j)での黒希望の個数
	int bl[1002][1002];
	rep(i,K+1)bl[0][i]=bl[i][0]=0;
	rep1(i,K)rep1(j,K){
		bl[i][j]=w[i-1][j-1][1]+bl[i][j-1]+bl[i-1][j]-bl[i-1][j-1];
	}	
	int ans=0;
	
	//[0,i)*[0,j)までを白とした
	rep(i,K+1)rep(j,K+1){
		int ct;
		ct=2*wh[i][j]+bl[i][K]+bl[K][j]-2*bl[i][j]+wh[K][K]-wh[i][K]-wh[K][j];
		ans=max(ans,ct);
	}
		//[0,i)*[0,j)までを黒とした
	rep(i,K+1)rep(j,K+1){
		int ct;
		ct=2*bl[i][j]+wh[i][K]+wh[K][j]-2*wh[i][j]+bl[K][K]-bl[i][K]-bl[K][j];
		ans=max(ans,ct);
	}
	cout<<ans;
	
}

Measured memory_bytes: 39296
n,m=map(int,input().split())
ab=[list(map(int,input().split())) for _ in range(n)]
ab.sort()
x = 0
c = 0
for a,b in ab:
    if x+b <= m:
        x += b
        c += a*b
    else:
        c += a*(m-x)
        break
print(c)
    

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

long long INF = 1e18;

int main(){
    int n;
    cin>>n;
    char s[n+100];
    for(int i=0; i<n; i++){
        cin>>s[i];
    }
    int cnt = 0;
    for(int i = 0; i<n-2; i++){
        if(s[i] == 'A' && s[i+1] == 'B' && s[i+2] == 'C'){
            cnt++;
        }
    }
    cout<<cnt<<endl;
    return 0;
}

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

typedef long long ll;

template<class T> inline bool chmax(T& a, T b){
  if (a < b) { a = b; return true; } return false;
}

int
main(void)
{
  int n; cin >> n;
  ll happy_arr[100010][3];
  ll dp_arr[100010][3];
  for(int i = 0; i < n; ++i){
    for(int j = 0; j < 3; ++j){
      cin >> happy_arr[i][j];
    }
  } 
  for(int i = 0; i < 3; ++i){
    dp_arr[0][i] = 0;
  }
  
  for(int i = 1; i <= n; ++i){
    dp_arr[i][0] = happy_arr[i-1][0] + max(dp_arr[i - 1][1], dp_arr[i - 1][2]);
    dp_arr[i][1] = happy_arr[i-1][1] + max(dp_arr[i - 1][0], dp_arr[i - 1][2]);
    dp_arr[i][2] = happy_arr[i-1][2] + max(dp_arr[i - 1][0], dp_arr[i - 1][1]);
  }

  ll max = 0;
  for (int i = 0; i < 3; ++i){
    chmax(max,dp_arr[n][i]);
  }

  cout << max << endl;
  
  return 0;
}

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

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める

int main(){
    string s,t;
    cin >> s >> t;
    int ans=0;
    for(int i=0;i<s.length();i++){
        if(s[i]!=t[i]) ans++;
    }
    cout << ans << endl;
    return 0;
}

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

const double PI = acos(-1);
const int INF = 1001001001;

int main()
{

    int n,m,x; cin >> n >> m >> x;
    vector<int> c(n);
    vector<vector<int>> a(n,vector<int>(m));
    rep(i,n) {
        cin >> c.at(i);
        rep(j,m) cin >> a.at(i).at(j);
    }

    int ans = INF;
    rep(s, 1<<n) {
        int cost = 0;
        vector<int> d(m);
        rep(i, n) {
            if(s>>i&1) {
                cost += c.at(i);
                rep(j,m) d.at(j) += a.at(i).at(j);
            }
        }
        bool ok = true;
        rep(j,m) if(d.at(j) < x) ok = false;
        if(ok) ans = min(ans, cost);
    }

    if (ans == INF) cout << -1 << endl;
    else cout << ans << endl;

}


Measured memory_bytes: 3628
s = input()
 
if s[1] == 'S':
  if 'R' in s:
    print(1)
  else:
    print(0)
else:
  if s[0] == 'R' or s[2] == 'R':
    if 'S' in s:
      print(2)
    else:
      print(3)
  else:
    print(1)

Measured memory_bytes: 9044
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
 
using namespace std;
 
#define rep(i,n) for(int i=0; i<(n); i++)
#define repc(i,s,e) for(int i=(s); i<(e); i++)
#define pb(n) push_back((n))
#define mp(n,m) make_pair((n),(m))
#define all(r) r.begin(),r.end()
#define fi first
#define se second
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
 
 
 
const int INF = 1000000;
 


const int MAX_PRIME = 1000000;

vector<int> is_prime(MAX_PRIME,1);

void calcPrime(){
	is_prime[0]=is_prime[1]=0;
	for(int i=2; i<MAX_PRIME; i++){
		if(is_prime[i]==1){
			for(int j=i*2; j<MAX_PRIME; j+=i){
				is_prime[j]=0;
			}
		}
	}
}


int main(){
	calcPrime();
	int n;
	while(cin>>n && n > 0){
		int ans = 0;
		for(int i = 2; i <= n / 2 ; i++){
			if(is_prime[i] && is_prime[n - i]) ans++;
		}
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 4900
from sys import stdin

n, k = (int(v) for v in stdin.readline().split())
monsters = [int(v) for v in stdin.readline().split()]


if len(monsters) <= k:
    print("0")
else:
    monsters = sorted(monsters)
    monsters = monsters[:-k] if k > 0 else monsters
    print(sum(monsters))


Measured memory_bytes: 80340
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<stack>
#include<queue>
#include<vector>
#include<set>
#include<map>
#include<string>
#define ls k<<1,l,mid
#define rs k<<1|1,mid+1,r
#define mp(x,y) make_pair(x,y)
#define r(x) read(x)
#define rr(x,y) read(x);read(y)
#define rrr(x,y,z) read(x);read(y);read(z)
#define FOR(i,l,r) for(int i=l;i<=r;i++)
#define pb(x) push_back(x)
#define sss(str) scanf("%s",str+1)
#define ssf(x) scanf("%lf",&x)
#define all(x) x.begin(),x.end()
using namespace std;
typedef long long LL;
typedef double dd;
typedef pair<int,int> pt;
const int N=1e5+5;
const int M=2e3+5;
const int INF=0x7fffffff;
const int mod=1e9+7;
const int sz=18;
const double eps=1e-10;
const double pi=acos(-1);
//***********************
int f[N];
//***********************
template<class T>
inline void read(T &x)
{
    char c; x=1;
    while((c=getchar())<'0'||c>'9') if(c=='-') x=-1;
    T res=c-'0';
    while((c=getchar())>='0'&&c<='9') res=res*10+c-'0';
    x*=res;
}
int main()
{
    int n,m;
    r(n);
    FOR(i,1,n) r(f[i]);
    sort(f+1,f+n+1);
    int ans=INF;
    FOR(i,f[1],f[n]){
        int p=i;
        int res=0;
        FOR(j,1,n) res+=(p-f[j])*(p-f[j]);
        ans=min(ans,res);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
const int N = 71;
using namespace std;
string judge(string,string);
int main(){
  int w,h,i,j,lenmax,flag;
  string str[N],dp[N][N],which,out;
  while(1){
    cin >> w >> h;
    if(w==0&&h==0) break;
    for(i=0;i<=h;i++){
      for(j=0;j<=w;j++){
	dp[i][j]="0";
      }
    }
    for(i=0;i<=w;i++) str[0]+='X';
    for(i=1;i<=h;i++){
      cin >> str[i];
      str[i]='X'+str[i];
    }
    for(i=1;i<=h;i++){
      for(j=1;j<=w;j++){
	if('0'<=str[i][j]&&str[i][j]<='9'){
	  if(dp[i-1][j]=="0"&&dp[i][j-1]=="0"){
	    dp[i][j]=str[i][j];
	  }
	  else if(dp[i-1][j]=="0") dp[i][j]=dp[i][j-1]+str[i][j];
	  else if(dp[i][j-1]=="0") dp[i][j]=dp[i-1][j]+str[i][j];
	  else{
	    if(dp[i-1][j].size()==dp[i][j-1].size()){
	      which=judge(dp[i-1][j],dp[i][j-1]);
	      dp[i][j]=which+str[i][j];
	    }
	    else if(dp[i-1][j].size()>dp[i][j-1].size()) dp[i][j]=dp[i-1][j]+str[i][j];
	    else dp[i][j]=dp[i][j-1]+str[i][j];
	  }
	}
      }
    }
    int len;
    lenmax=0;
    for(i=1;i<=h;i++){
      for(j=1;j<=w;j++){
	len=dp[i][j].size();
	lenmax=max(lenmax,len);
      }
    }
    flag=0;
    for(i=1;i<=h;i++){
      for(j=1;j<=w;j++){
	if(flag==0&&dp[i][j].size()==lenmax){
	  flag=1;
	  out=dp[i][j];
	}
	else if(flag==1&&dp[i][j].size()==lenmax){
	  which=judge(out,dp[i][j]);
	  out=which;
	}
      }
    }
    cout << out << endl;
  }
  return 0;
}
string judge(string a,string b){
  int flag=0,len=a.size(),i;
  for(i=0;i<len;i++){
    if(a[i]>b[i]){
      flag=1;
      break;
    }
    else if(a[i]<b[i]){
      flag=2;
      break;
    }
  }
  if(flag==0||flag==1) return a;
  else return b;
}

Measured memory_bytes: 1380
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Stack;

public class Main {

	public static void main(String[] args) throws IOException {
		// TODO ?????????????????????????????????????????????
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String inputStr = br.readLine();

		Stack<Character> stack = new Stack<Character>();
		ArrayList<Integer> lakes = new ArrayList<Integer>();
		int sumOfLakes = 0;

		for(int i = 0; i < inputStr.length() ; i++){
			//System.out.println(i);

			double areaOfLake = 0;
			if(inputStr.charAt(i) == '\\'){
				int currentDepth = 0;
				//max??¨???????????????????????¬?????????depth????§???±?????????
				int maxheight = Integer.MAX_VALUE;
				//int maxposition = i;
				
				int up = 0;
				
				for(int j = i; j < inputStr.length() ; j++){
					

					//System.out.println("j = " + j + "depth "+ currentDepth);
					if(inputStr.charAt(j) == '\\'){
						stack.push('\\');
						areaOfLake += currentDepth + 0.5;
						currentDepth++;
					}
					else if(inputStr.charAt(j) == '/'){
						stack.pop();
						currentDepth--;
						//if(currentDepth > maxheight){
						//	maxposition = j;
						//}
						up++;
						areaOfLake += currentDepth + 0.5;
					}
					else if(inputStr.charAt(j) == '_'){
						areaOfLake += currentDepth;
					}
					

					if(stack.isEmpty()){
						lakes.add((int)areaOfLake);
						//System.out.println("i = " + i + " j = "+j);
						sumOfLakes += (int)areaOfLake;
						i = j;
						break;
					}
				}
				
				int remainStack = 0;
				/*
				if(stack.isEmpty() == false){
					remainStack = stack.size();
					i += remainStack - 1;
				}*/
				if(stack.isEmpty() == false && up == 0){
					break;
				}

				stack.clear();
			}
		}

		System.out.println(sumOfLakes);

		if(lakes.size() != 0){
			System.out.print(lakes.size() + " ");
		}
		else{
			System.out.println(0);
		}
		for(int i = 0; i < lakes.size(); i++){
			System.out.print(lakes.get(i));
			if(i != lakes.size() - 1){
				System.out.print(" ");
			}
		}
		if(lakes.size() != 0){
			System.out.println();
		}

	}

}

Measured memory_bytes: 27540
#include<bits/stdc++.h>
#define endl '\n'
using namespace std;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int ans = 1;
  int n, h[25];
  int judge;
  
  cin >> n;

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

  for(int i = 1;i < n;i++){
    for(judge = i - 1;judge >= 0 && h[i] >= h[judge];judge--);
    if(judge < 0){
      ans ++;
    }
  }

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



Measured memory_bytes: 256
H,W,A,B=$<.read.split.map(&:to_i)
# H,W,A,B=[7,4,2,3]

arr = Array.new(H) { Array.new(W,0) }

s = [0] * A + [1] * (W-A)
t = [1] * A + [0] * (W-A)

arr = [s] * B + [t] * (H-B)


puts arr.map {|l| l.join}

Measured memory_bytes: 27352
N,M = map(int,input().split())

from math import gcd

if N % 2 == 1:
    for i in range(M):
        print("{} {}".format(i+1,N-i-1))
else:
    if N % 4 == 2:
        for i in range(M//2):
            print("{} {}".format(i+1,N-i))
        for i in range(M//2,M):
            print("{} {}".format(i+1,N-i-1))
    else:
        for i in range((M+1)//2):
            print("{} {}".format(i+1,N-i))
        for i in range((M+1)//2,M):
            print("{} {}".format(i+1,N-i-1))

Measured memory_bytes: 9172
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    int n = scan.nextInt();
    long sum = 0;
    int k = scan.nextInt();

    if (n<=k){
      System.out.println(0);
      return;
    }

    int [] a = new int[n];
    for (int i=0;i<n;i++){
      a[i] = scan.nextInt();
    }

    Arrays.sort(a);
    int p = n-k;
    for (int t = 0; t<p;t++){
      sum += a[t];
    }
    System.out.println(sum);
  
  }
}


Measured memory_bytes: 61352
A = []
m = 0
ans = 0
for i in range(5):
  a = int(input())
  if a%10 != 0:
    if round(a+5, -1) - a > m:
      m = round(a+5, -1) - a
    ans += round(a+5,-1)
  else:
    ans += a
print(ans-m)

Measured memory_bytes: 9112
import java.io.*;
import java.util.*;

class Main {
  public static void main(String[] args) throws IOException{
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    String l = br.readLine();
		 StringTokenizer st = new StringTokenizer(l);
    int answer = (int)Math.floor(Integer.parseInt(st.nextToken())/3);
    System.out.println(answer);
    
  }
}

Measured memory_bytes: 23124
fun main(args: Array<String>) {
    val n = readInputLine().toInt()
    val k = readInputLine().toInt()
    
    val xs = readInputLine().split(" ").map { it.toInt() }
    
    var ans = 0
    
    for (i in 0 until n) {
        val x = xs[i]
        
        if (x + x < k) {
            ans += x + x
        } else {
            ans += k + k - x - x
        }
    }
    
    println(ans)
}
 
fun readInputLine(): String {
    return readLine()!!
}

Measured memory_bytes: 36016
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize ("Ofast")
//#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define d long double
#define pii pair<int,int>
#define pb push_back
#define pf push_front
#define cases int t;cin>>t;while(t--)
#define N 100003
#define M 103
#define inf LLONG_MAX
//int mod=1e9+7;
//int mod=998244353;

signed main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

    char c;
    cin>>c;
    if(c=='A')
        cout<<'T';
    else if(c=='T')
        cout<<'A';
    else if(c=='C')
        cout<<'G';
    else
        cout<<'C';


    return 0;
}


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

using namespace std;

void solve() {
  int H, W, K;
  cin >> H >> W >> K;

  vector<vector<int>> grid(H, vector<int>(W));
  int id = 0;
  for (int i = 0; i < H; ++i) {
    int prev = -1;
    for (int j = 0; j < W; ++j) {
      char s;
      cin >> s;
      if (s == '#') {
        ++id;
        fill(grid[i].begin() + prev + 1, grid[i].begin() + j + 1, id);
        prev = j;
      }
      if (prev != -1)
        fill(grid[i].begin() + prev + 1, grid[i].end(), id);
    }
  }

  for (size_t r = 0; r < H; ++r) {
    if (grid[r][0] == 0) {
      for (size_t r2 = r + 1; r2 < H; ++r2) {
        if (grid[r2][0]) {
          copy(grid[r2].begin(), grid[r2].end(), grid[r].begin());
          break;
        }
      }
      if (grid[r][0] == 0) {
        for (size_t r2 = r - 1; r2 != size_t(-1); --r2) {
          if (grid[r2][0]) {
            copy(grid[r2].begin(), grid[r2].end(), grid[r].begin());
            break;
          }
        }
      }
    }
  }

  for (auto& row : grid) {
    bool first = true;
    for (int id : row) {
      if (first)
        first = false;
      else
        cout << " ";
      cout << id;
    }
    cout << endl;
  }
}

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

  solve();
}


Measured memory_bytes: 1152
N = int(input())
s = input().split(" ")
A = list(map(int,s))
for i in range(N):
    if i == N-1:
        print(A[i])
    else:
        print(A[i],end=" ")
for i in range(1,N):
    v = A[i]
    j = i - 1
    while j >= 0 and A[j] > v:
        A[j + 1] = A[j]
        j -= 1
    A[j + 1] = v
    for i in range(N):
        if i == N-1:
            print(A[i])
        else:
            print(A[i],end=" ")

Measured memory_bytes: 7960
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>

using namespace std;

const int MAXM = 90;
const long long INF = 1ll << 60;
const int MOD = 1000000000 + 7;

typedef pair<long long, long long> pii;
long long fib[MAXM];
pii spe[MAXM][MAXM];

void init()
{
	fib[0] = fib[1] = 1;
	for(int i = 2; i < MAXM; i++)
		fib[i] = fib[i - 1] + fib[i - 2];
	// for(int i = 0; i < MAXM; i++)
	// 	cerr << fib[i] << endl;
	spe[1][0] = make_pair(1, 2), spe[1][1] = make_pair(1, 3);
	for(int i = 2; i + 2 < MAXM; i++)
	{
		for(int j = 0; j <= i - 1; j++)
			spe[i][j] = make_pair(spe[i - 1][j].second, spe[i - 1][j].first + spe[i - 1][j].second);
		spe[i][i] = make_pair(fib[i], fib[i + 2]);
	}
	// for(int i = 1; i < MAXM; i++)
	// 	cerr << spe[i][i].first << ' ' << spe[i][i].second << endl;
}

long long X, Y;

void work()
{
	cin >> X >> Y;
	if(X > Y) swap(X, Y);
	int k = 1;
	while(fib[k + 1] <= X && fib[k + 2] <= Y)
		k++;
	if(k == 1)
	{
		cout << k << ' ' << (X % MOD) * (Y % MOD) % MOD << endl;
		return ;
	}
	int ans = 0;
	for(int i = 0; i <= k - 1; i++)
	{
		if(X >= spe[k - 1][i].second) ans = (ans + (Y - spe[k - 1][i].first) / spe[k - 1][i].second) % MOD;
		if(Y >= spe[k - 1][i].second) ans = (ans + (X - spe[k - 1][i].first) / spe[k - 1][i].second) % MOD;
	}
	cout << k << ' ' << ans << endl;
}	

int main()
{
	ios::sync_with_stdio(false);
	// freopen("1.in", "r", stdin);
	// freopen("1.out", "w", stdout);

	init();
	int T;
	cin >> T;
	while(T--)
		work();


	return 0;
}


Measured memory_bytes: 4224
#include<stdio.h>
#include<stdlib.h>

int double_comp(const void* x,const void* y) {
	const double* a=(const double*)x;
	const double* b=(const double*)y;
	if(*a>*b)return 1;
	if(*a<*b)return -1;
	return 0;
}

int main(){
  int i,j,k,N;
  double ans=0.0;
  scanf("%d",&N);
  double A[N];
  for(i=0;i<N;i++)
    scanf("%lf",&A[i]);
  
  qsort(A,N,sizeof(double),double_comp);
  
  for(i=0;i<N-1;i++){
    A[i+1] = (A[i]+A[i+1])/2.0;
  }
  printf("%lf\n",A[N-1]);
  return 0;
}

Measured memory_bytes: 128
#/*
    AUTHOR:shivam51
    IIESTS
*/
  #include<bits/stdc++.h>
  using namespace std;
  //
  #define add accumulate
  #define ll long long int
  #define ff first
  #define ss second
  #define pb push_back
  #define mp make_pair
  #define vll vector<ll>
  #define lb lower_bound
  #define ub upper_bound
  #define pll pair<ll,ll>
  #define vpll vector<pll>
  #define all(v) v.begin(), v.end()
  #define rep(i,k,n) for(int i=k;i<n;i++)
  #define hs ios_base::sync_with_stdio(false);cin.tie(NULL);
  const ll mod=1e9+7;
  const ll MAX=1e6+1;
  //
  //	
  ll oper(ll a,ll b){
  	return abs(a)<abs(b);
  }
    	ll  solve(){
  		ll n,l;
  		cin>>n>>l;
  		int arr[n],mn=MAX,sm=0;
  		bool sign=false;
  		rep(i,0,n)
  			arr[i]=l+i;
  		sort(arr,arr+n,oper);
  		cout<<(add(arr+1,arr+n,0));
  	}
	int main(){ 
		hs;
		ll t;
		// cin>>t;
		t=1;
		while(t--)
			solve();
    return 0; 
} 

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

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

#define pb push_back
#define rep(i, a, n) for(int i = (a); i < (n); i++)
#define dep(i, n, a) for(int i = (a); i >= (n); i--)
#define mod 1e9+7
#define int ll

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

signed main() {
  int h, w;
  cin >> h >> w;
  int a[501][501];
  rep(i, 0, h) rep(j, 0, w) {
    cin >> a[i][j];
  }
  int am = 0;
  vector<pair<P, P> > ans;
  rep(i, 0, h) rep(jj, 0, w) {
    int j = jj;
    if(i % 2) j = w - j - 1;
    if(a[i][j] % 2) {
      if(am) am = 0;
      else am = 1;
    }
    if(am) {
      if(i % 2) {
        if(j >= 1) ans.pb({P(i + 1, j + 1), P(i + 1, j)});
        else if(i != h - 1) {
          ans.pb({P(i + 1, j + 1), P(i + 2, j + 1)});
        }
      }else {
        if(j < w - 1) ans.pb({P(i + 1, j + 1), P(i + 1, j + 2)});
        else if(i != h - 1) {
          ans.pb({P(i + 1, j + 1), P(i + 2, j + 1)});
        }
      }
    }
  }

  cout << ans.size() << endl;
  rep(i, 0, ans.size()) {
    cout << ans[i].first.first << " " << ans[i].first.second << " ";
    cout << ans[i].second.first << " " << ans[i].second.second;
    cout << endl;
  }
}


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

#define SIS std::ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define lowbit(x) (x & -x)
#define FOR(i,a,b)  for(int i=(a); i< (b); ++i)
#define RFOR(i,b,a) for(int i=(b);i>=(a);i--)
#define REP(i,a,b)  for(int i=(a); i<=(b); ++i)

#define PI 3.14159265358979323846264338327950L

using namespace std;
typedef long long ll;
template<typename T>
void PrArr(const T a[] , int len){
	for(int i = 0;i <= len; i++)cout << a[i] << " ";
	cout << endl;
}
template<typename T>
void PrVec(const vector<T> a){
	for(auto it : a)cout << it << " ";
	cout << endl;
}
const int MAX = 0x7ffffff;
const int MIN = 0xcf;
int test;
void slove()
{
	int n;
	cin >> n;
	map<pair<int,int> ,int> cnt;
	for(int rep = 0 ; rep < n ;rep ++)
	{
		double x;cin >> x;
		ll i = llround(x * 1e9);
		int two = 0 , five = 0;
		while(i % 2 == 0)
		{
			two++;
			i /= 2;
		}
		while(i % 5 == 0)
		{
			five++;
			i /= 5;
		}
		++ cnt[{two , five}];
	}

	ll ans = 0;

	for(auto p1 : cnt)
	{
		for(auto p2 : cnt)
		{
			if(p1.first.first + p2.first.first >= 18 && p1.first.second+p2.first.second >= 18)
			{
				if(p1 < p2){
					ans += (ll)p1.second * p2.second;
				}else if(p1 == p2){
					ans += (ll)p1.second * (p1.second - 1) / 2;
				}
			}
		}
	}
	cout << ans << endl;
}
int main()
{
#ifdef LOCAL
	auto start_time = clock();
	cerr << setprecision(3) << fixed; // 在iomanip中
#endif
	SIS;slove();
#ifdef LOCAL
	auto end_time = clock();
	cerr << "Execution time: " << (end_time - start_time) * (int)1e3 / CLOCKS_PER_SEC << " ms\n";
#endif
}

Measured memory_bytes: 3628
// clang-format off
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979;
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
bool odd(const int &n) { return n & 1; }
bool even(const int &n) { return ~n & 1; }
template<typename T> int len(const T &v) { return v.size(); }
template<typename T = int> T in() { T x; cin >> x; return x; }
template<typename T = int> T in(T &&x) { T z(forward<T>(x)); cin >> z; return z; }
template<typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &x : v) is >> x; return is; }
template<typename A, typename B> istream &operator>>(istream &is, pair<A, B> &p) { return is >> p.first >> p.second; }
template<typename T> ostream &operator<<(ostream &os, const vector<vector<T>> &v) { int n = v.size(); rep(i, n) os << v[i] << (i == n - 1 ? "" : "\n"); return os; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { int n = v.size(); rep(i, n) os << v[i] << (i == n - 1 ? "" : " "); return os; }
template<typename A, typename B> ostream &operator<<(ostream &os, const pair<A, B> &p) { return os << p.first << ' ' << p.second; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
// clang-format on

class Combination {
  int r;
  vector<int> data;

public:
  Combination(int n, int r) : r(r) {
    data.resize(n);
    fill(data.end() - (n - r), data.end(), 1);
  }

  bool next() { return next_permutation(data.begin(), data.end()); }

  vector<int> get() {
    vector<int> v;
    v.reserve(r);
    rep(i, data.size()) if ((*this)[i]) v.emplace_back(i);
    return v;
  }

  bool operator[](int i) { return !data[i]; }
};

main() {
  int n, k;
  while (cin >> n >> k, n) {
    vector<string> a(n);
    cin >> a;
    set<string> s;
    Combination c(n, k);
    sort(all(a));
    do {
      auto v = c.get();
      do {
        string t;
        rep(i, k) t += a[v[i]];
        s.emplace(t);
      } while (next_permutation(all(v)));
    } while (c.next());
    cout << s.size() << endl;
  }
}



Measured memory_bytes: 3344
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

typedef long long ll;
const ll INF = 1e5;


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

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

	int ans = 0;

	for (int i = 0; i < N; i++) {
		if (h[i] >= K) { ans++; }
	}

	cout << ans;

	system("PAUSE");
}


Measured memory_bytes: 888
s = input()
t = input()

m = 0
for i in range(0, len(s) - len(t) + 1):
    b = s[i : i + len(t)]
    cnt = 0
    for j, v in enumerate(b):
        if v == t[j]:
            cnt += 1
    m = max(m, cnt)
print(len(t) - m)


Measured memory_bytes: 73220
#include <bits/stdc++.h>
#define int long long
#define bp __builtin_popcountll
#define pb push_back
#define in(s) freopen(s, "r", stdin);
#define out(s) freopen(s, "w", stdout);
#define inout(s, end1, end2) freopen((string(s) + "." + end1).c_str(), "r", stdin),\
		freopen((string(s) + "." + end2).c_str(), "w", stdout);
#define fi first
#define se second
#define bw(i, r, l) for (int i = r - 1; i >= l; i--)
#define fw(i, l, r) for (int i = l; i < r; i++)
#define fa(i, x) for (auto i: x)
using namespace std;
const int mod = 1e9 + 7, inf = 1061109567;
const long long infll = 4557430888798830399;
const int N = 1e5 + 5;
int n, a[N], ans[N];
map<int, int> mnPile, cntPile;
signed main() {
	#ifdef BLU
	in("blu.inp");
	#endif
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> n;
	vector<int> v;
	fw (i, 0, n) {
		cin >> a[i];
		v.pb(a[i]);
		if (!mnPile.count(a[i])) mnPile[a[i]] = inf;
		mnPile[a[i]] = min(mnPile[a[i]], i);
		cntPile[a[i]]++;
	}
	sort(v.begin(), v.end());
	v.resize(unique(v.begin(), v.end()) - v.begin());
	reverse(v.begin(), v.end());
	int curMn = inf, curCnt = 0;
	fw (i, 0, v.size()) {
		curCnt += cntPile[v[i]];
		curMn = min(curMn, mnPile[v[i]]);
		
		int nxt = 0;
		if (i < v.size() - 1) nxt = v[i + 1];
		ans[curMn] += (v[i] - nxt) * curCnt;
	}
	fw (i, 0, n) cout << ans[i] << "\n";
	return 0;
}

Measured memory_bytes: 15860
/**
*    author:  souzai32
*    created: 14.08.2020 15:57:40
**/

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

int main() {

    int n;
    cin >> n;
    vector<long long> p(n+1);
    long long num;
    int a;

    for(int i=2; i<=n; i++){
        num=i;
        a=2;
        while(1){
            if(num%a==0){
                p.at(a)++;
                num/=a;
            }
            else a++;
            if(num<a*a){
                p.at(num)++;
                break;
            }
        }
    }

    long long ans=1;
    for(int i=2; i<=n; i++){
        ans*=p.at(i)+1;
        ans%=long(1e9+7);
        // cout << p.at(i) << ' ';
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3600
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <set>
#include <vector>
#include <utility>
#include <queue>
#include <cmath>

#define BEGIN(x) x.begin()
#define END(x) x.end()
#define ALL(x) BEGIN(x), END(x)
#define PAIR make_pair
#define VEC(type) vector<type >

using namespace std;

typedef long long lint;

void io_init()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
};

string S;
int dp[1 << 20][10];

int f(int i, int carry)
{
    if (i == -1)
        return carry;
    int& ans = dp[i][carry];
    if (ans >= 0)
        return ans;
    ans = 100 * 1000000;
    int digit = S[i] - '0';
    for (int d = 0;d < 10; d++)
        ans = min(ans, d + (digit + carry + d) % 10 + 
                    f(i - 1, (digit + carry + d) / 10));

    return ans;
};

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

    // Actual program code starts here.
    cin >> S;
    memset(dp, -1, sizeof dp);
    cout << f(S.size() - 1, 0) << endl;
    return 0;
};


Measured memory_bytes: 89244
#include<iostream>
using namespace std;
int main(){
	int a=1,b=1;
	while(!(a==0&&b==0)){
		cin >> a >> b;
		for (int i=1;i<=a;i++){
			for(int j=1;j<=b;j++)
				if (i==1||i==a||j==1||j==b)
					cout << '#';
				else
					cout << '.';
			cout << endl;
		}
		if(!(a==0&&b==0))
			cout << endl;
	}
    return 0;
}


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

#define rep(i, n) rep2(i, 0, n)
#define rep2(i, m, n) for (ll i = m; i < (n); i++)

using ll = long long;
using pii = pair<int, int>;
using Vi = vector<int>;


int main(){
  int N;
  cin >> N;
  if(N == 0){
  cout << 1 << endl;
  }
  else{
    cout << 0 << endl;
  }
}



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

#define ll long long

using namespace std;

int main(){
   int N; cin >> N;
   int nb[52][52];
   ll ans = 0;
   memset(nb, 0, sizeof nb);
   vector<pair<int,int>> v;
   for (int i = 0; i < N; i++) {
      double d; cin >> d;
      ll num = llround(d*1e9);
      int a, b; a = b = 0;
      while (num%2 == 0) {
         num/= 2;
         a++;
      }
      while (num%5 == 0) {
         num/= 5;
         b++;
      }
      v.push_back({a,b});
      for (int j = 0; j <= a; j++) {
         for (int k = 0; k <= b; k++) {
            nb[j][k]++;
         }
      }
   }
   for (int i = 0; i < N; i++) {
      int a = v[i].first, b = v[i].second;
      ans+= nb[max(18-a,0)][18-b];
      if (a > 8 && b > 8)
         ans--;
   }
   cout << ans/2;
}

Measured memory_bytes: 5464