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


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

//using namespace __gnu_pbds;

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

//#define REP(i,m) for(int i=0;i<(m);++i)
//struct dsu{
	//static const int MAXN=105;
	//int par[MAXN];
	//int size[MAXN];
	//void init(){
		//memset(par,-1,sizeof(par));
		//REP(i,MAXN) size[i]=1;
	//}
	//int root(int a){
		//if(par[a]==-1) return a;
		//return par[a]=root(par[a]);
	//}
	//void unite(int a,int b){
		//a=root(a);b=root(b);
		//if(a==b) return;
		//if(size[a]<size[b]) swap(a,b);
 
		//par[b]=a;
		//size[a]+=size[b];
	//}
	//bool same(int a,int b){
		//return root(a)==root(b);
	//}
//};	

#define ll long long 

int main(){
	ios::sync_with_stdio(false);cin.tie(0);
	ll h,w,k;cin>>h>>w>>k;
	char mat[h][w];
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			char temp;cin>>temp;
			mat[i][j]=temp;
		}
	}
	ll ans=0;
	for(ll mask=0;mask<(1<<(h+w));mask++){
		ll cnt=0;
		for(int i=0;i<h;i++){
			for(int j=0;j<w;j++){
				if(mat[i][j]=='.') continue;
				if((mask & ( (1<<i) | (1<<(h+j)) ))!=0 )continue;
				cnt++; 
			}
		}
		if(cnt==k)ans++;
	}
	cout<<ans<<endl;
	return 0;
	
}


Measured memory_bytes: 3588
S=list(input())
count=0
ans=0
for i in range(len(S)):
  if S[i]== "A" or S[i]== "T" or S[i]== "G" or S[i]== "C":
    count+=1
  else:
    if count>ans:
      ans=count
    count=0
if count>ans:
  ans=count
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define ll long long int
#define v vector<ll>
#define vv vector<v>
#define p pair<ll,ll>
using namespace std;
vv adj(51,v(51,0));
ll n;
ll MOD=1e9+7;
vector<vector<unordered_map<ll,ll> > > dp (51,vector<unordered_map<ll,ll> >(51));
ll solve(ll a,ll b, ll d)
{
    if (dp[a][b].find(d)!=dp[a][b].end())
        return dp[a][b][d];
    ll ans=0;
    if (d==1)
        return adj[a][b];
    for (int i=1; i<=n; i++)
        ans=(ans+(solve(a,i,d/2)*solve(i,b,d-d/2))%MOD)%MOD;
    dp[a][b][d]=ans;
    return ans;
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll k;
    cin>>n>>k;
    for (int i=1; i<=n; i++)
        for (int j=1; j<=n; j++)
            cin>>adj[i][j];
    ll ans=0;
    for (int i=1; i<=n; i++)
        for (int j=1; j<=n; j++)
            ans=(ans+solve(i,j,k))%MOD;
    cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 13568
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define FOR(i) for(cin>>i;i>0;i--)
#define elif else if
#define pb push_back
#define ll long long
#define mp make_pair
#define all(x) x.begin(),x.end()
#define re(x) {cout<<x<<endl;return 0;}
//#define x first
//#define y second

using namespace std;
int n,a[2005],ans=0;
int main()
{
	cin>>n;
	rep(i,n) cin>>a[i];
	sort(a,a+n);
	rep(i,n)
	rep2(j,i+1,n)
	rep2(l,j+1,n)
	{
		if(a[i]+a[j]<=a[l])
		{
			ans+=l-j-1;
			break;
		}
		if(l==n-1) ans+=l-j;
	}
	re(ans)
	return 0;}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] d = new int[n + 1];
        long[] cnt = new long[n + 1];
        for (int i = 1; i <= n; i++) {
            d[i] = sc.nextInt();
            cnt[d[i]]++;
        }

        if (d[1] != 0 || cnt[0] != 1) {
            System.out.println(0);
            return;
        }
        long MOD = 998244353;
        long ans = 1;
        for (int i = 2; i <= n; i++) {
            long j = 0;
            while (j < cnt[i]) {
                ans *= cnt[i - 1];
                ans %= MOD;
                j++;
            }
        }
        System.out.println(ans);
    }

}


Measured memory_bytes: 60172
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication32
{
    class Program
    {
        static void Main(string[] args)
        {
            
                for (int c = 1; c <10; c++)
                {
                    for (int d = 1; d <10; d++)
                    {
                        Console.WriteLine("{0}x{1}={2}", c, d, c * d);
                    }
                    
                }
         
            }
        
        }

    }

Measured memory_bytes: 9104
#include<cstdio>
#include<iostream>
#include<string>
using namespace std;

int main(){
    string S;
    string T;
    cin>>S;
    cin>>T;
    int len = S.size();
    int ans = 0;
    for(int i=0;i<len;i++){
        if(S[i] != T[i]) ans++;
    }
    printf("%d", ans);
    return 0;
}

Measured memory_bytes: 3828
#include <iostream>

using namespace std;

int getWeight(int a, int b, int c) {
  return a*200 + b*300 + c*500;
}

int getMoney(int a, int b, int c) {
  int res = 0;
  
  int a_ori = a%5;
  int a_dis = a/5*5;
  res += a_dis*380*0.80 + a_ori*380;
  
  int b_ori = b%4;
  int b_dis = b/4*4;
  res += b_dis*550*0.85 + b_ori*550;
  
  int c_ori = c%3;
  int c_dis = c/3*3;
  res += c_dis*850*0.88 + c_ori*850;
  
  return res;
}

int main() {
  int N;
  while(cin >> N && N) {
    int ans = (int)1e9;
    for(int i=0; i<30; i++)
      for(int j=0; j<30; j++)
	for(int k=0; k<30; k++)
	  if(getWeight(i, j, k) == N) {
	    ans = min(ans, getMoney(i, j, k));
	  }
    
    cout << ans << endl;
  }
  
  return 0;
}

Measured memory_bytes: 1156
// P=0だと奇数は偶数個選ぶ nCrを持ってくる
package main

import "fmt"

func main() {
	var N, P int
	fmt.Scan(&N, &P)
	evens, odds := 0, 0
	for i := 0; i < N; i++ {
		var V int
		fmt.Scan(&V)
		if V%2 == 0 {
			evens++
		} else {
			odds++
		}
	}
	ea := 0
	oa := 0
	if P == 0 {
		// 偶数をいくつでも、奇数は偶数個、0を含む
		for i := 0; i <= evens; i++ {
			ea += ncr(evens, i)
		}
		for i := 0; i <= odds; i += 2 {
			oa += ncr(odds, i)
		}
	} else {
		// 偶数をいくつでも、奇数は奇数個
		for i := 0; i <= evens; i++ {
			ea += ncr(evens, i)
		}
		for i := 1; i < odds; i += 2 {
			oa += ncr(odds, i)
		}
	}
	fmt.Println(ea * oa)
}

func ncr(n, r int) int {
	res := 1
	for i := 1; i <= r; i++ {
		res = res * (n - i + 1) / i
	}
	return res
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define fr(i,a,b) for(int i=a;i <= b;i++)
#define pb push_back
#define rep(i,n) for(int i=0;i < n;i++)
#define sz(x) x.size()
#define N 100005
#define pii pair<int,int>
#define mp make_pair
#define fir first
#define sec second

int k,ans = -1;
vector<pii> edg[N];
int dis[N];
bool vis[N];

void dij(int i) {
	dis[i] = 0;
	vis[i] = true;
	set<pii> temp;
	fr(i,0,k-1) temp.insert(mp(dis[i],i));
	while(sz(temp) != 0) {
		pii top = *(temp.begin()); temp.erase(temp.begin());
		assert(top.fir != INT_MAX);
		int ver = top.sec;
		vis[ver] = true;
		rep(j,sz(edg[ver])) {
			if(!vis[edg[ver][j].fir]) {
				if(dis[ver] + edg[ver][j].sec < dis[edg[ver][j].fir]) {
					temp.erase(mp(dis[edg[ver][j].fir],edg[ver][j].fir));
					dis[edg[ver][j].fir] = dis[ver] + edg[ver][j].sec;
					temp.insert(mp(dis[edg[ver][j].fir],edg[ver][j].fir));
				}
			}
		}
	}
}

int main() {
	cin >> k;
	fr(i,0,k-1) {
		int p = (i+1)%k,q = (10*i)%k;
		edg[i].pb(mp(p,1)); edg[i].pb(mp(q,0));
	}
	fr(i,0,N-1) dis[i] = INT_MAX;
	dij(1);
	fr(i,0,k-1) assert(dis[i] != INT_MAX);
	cout << dis[0]+1 << "\n";
}

Measured memory_bytes: 10880
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<functional>
#include<math.h>
using namespace std;
#define N (1000000000+7)
#define M (998244353)
#define INF 1e16
typedef long long ll;
typedef pair<ll,ll > P;
typedef pair<P,ll>Q;

int main(void){
    int a,b,c;
    cin>>a>>b>>c;
    cout<<min(b/a,c)<<endl;
    return 0;
}

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

int main(){
   int a, b, c;
   cin >> a >> b >> c;
   int k = b-a;
   int l = c-b;
   if (k==l){
     cout << "YES" << endl;
   }
   else {
      cout << "NO" << endl;
   }
}

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

#define all(x) begin(x), end(x)

using i64 = int_fast64_t;
using f64 = double;
using p64 = pair<i64, i64>;

constexpr i64 INF = INT_FAST64_MAX / 2;
constexpr f64 EPS = DBL_EPSILON;

void solve() {
    i64 a, b;
    cin >> a >> b;
    if (a > 0 && b > 0) {
        cout << "Positive" << endl;
    } else if (a * b <= 0) {
        cout << "Zero" << endl;
    } else if ((b - a + 1) % 2) {
        cout << "Negative" << endl;
    } else {
        cout << "Positive" << endl;
    }
}

int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#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(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

using Weight = int;
using Flow = int;
struct Edge {
	int s, d; Weight w; Flow c;
	Edge() {};
	Edge(int s, int d, Weight w = 1) : s(s), d(d), w(w), c(w) {};
	bool operator<(const Edge &e)const { return w < e.w; }
};
using Edges = vector<Edge>;
using Graph = vector<Edges>;
using Array = vector<Weight>;
using Matrix = vector<Array>;

inline ostream &operator<<(ostream &os, const Edge &e) { return (os << '(' << e.s << ", " << e.d << ", " << e.w << ')'); }

void add_edge(Graph &g, int a, int b, Weight w = 1) {
	g[a].emplace_back(a, b, w);
	g[b].emplace_back(b, a, w);
}
void add_arc(Graph &g, int s, int d, Weight w = 1) { g[s].emplace_back(s, d, w); }


//???????§????????????????(???????????????)
//Dijkstra O((E+V)logV)
//dist: ?§????????????????????????§??????????????¢
//?????????: ??????????????¨????????????(??????-1)
vector<int> dijkstra(const Graph &g, int s, Array &dist) {
	int n = g.size();
	assert(s < n);
	enum { WHITE, GRAY, BLACK };
	vector<int> color(n, WHITE); color[s] = GRAY;
	vector<int> prev(n, -1);
	dist.assign(n, INF); dist[s] = 0;
	using State = tuple<Weight, int, int>; //?§????????????????????????¢ ??? ???
	priority_queue<State, vector<State>, greater<State>> pq; pq.emplace(0, s, -1);
	while (pq.size()) {
		Weight d; int v, u; tie(d, v, u) = pq.top(); pq.pop();
		if (dist[v] < d)continue;
		color[v] = BLACK; prev[v] = u;
		for (auto &e : g[v]) {
			if (color[e.d] == BLACK)continue;
			if (dist[e.d] > dist[v] + e.w) {
				dist[e.d] = dist[v] + e.w;
				pq.emplace(dist[e.d], e.d, v);
				color[e.d] = GRAY;
			}
		}
	}
	return prev;
}


signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N, M, R, Q; cin >> N >> M >> R >> Q;
	Graph g(N + R);
	rep(i, 0, N) {
		add_arc(g, N + i%R, i, 0);
	}
	rep(i, 0, M) {
		int a, b, c; cin >> a >> b >> c;
		a--, b--;
		add_arc(g, b, a, c);
	}
	Matrix d(R, Array(N));
	rep(i, 0, R) {
		dijkstra(g, N + i, d[i]);
	}
	Weight ans = 0;
	rep(i, 0, Q) {
		int x, y, z; cin >> x >> y >> z;
		x--, y--;
		Weight c = 0;
		rep(j, 0, R) {
			chmax(c, z - (d[j][x] + d[j][y]));
		}
		ans += c;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 23792
// {{{
#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
// }}}

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;

static constexpr int mod = (int)1e9 + 7;
static constexpr int inf = 100100100;
static constexpr ll linf = 1e18;
static constexpr double eps = 1e-9;
static constexpr double pi = 3.14159265359;

#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rrep(i, n) for (ll i = n; i >= 0; --i)
#define all(c) begin(c), end(c)
#define rall(c) rbegin(c), rend(c)
#define pb push_back
#define ist insert
#define fst first
#define snd second


int main() {
    // cin.tie(0);
    // ios_base::sync_with_stdio(false);
    ll n;
    cin >> n;
    vector<ll> a;
    rep (i, n) {
        ll tmp;
        cin >> tmp;
        a.pb(tmp);
    }
    list<ll> b;
    rep (i, n) {
        if (i % 2 == 0) {
            b.pb(a[i]);
        } else {
            b.push_front(a[i]);
        }
    }
    if (n % 2 != 0) {
        ll i = 0;
        for (auto it = b.rbegin(); it != b.rend(); ++it) {
            cout << *it << " \n"[++i == n];
        }
    } else {
        ll i = 0;
        for (auto it = b.begin(); it != b.end(); ++it) {
            cout << *it << " \n"[++i == n];
        }
    }
}


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

using namespace std;

#define ll long long




void solve() {

	
	int a, b;
	cin >> a >> b;
	int ans = a + b;
	if(ans & 1) {
		cout << "IMPOSSIBLE";
	}
	else {
		cout << ans / 2;
	}
	




	
}

int main() {

	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	solve();

	return 0;
}

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

const int vmax=10010;
const int inf=1<<29;
struct edge{int to,cap,rev,id;};
vector<edge> graph[vmax];
int level[vmax],iter[vmax];

void add_edge(int from,int to,int cap,int id){
	graph[from].push_back({to,cap,int(graph[to].size()),id});
	graph[to].push_back({from,0,int(graph[from].size())-1,-id});
}

int dfs(int v,int t,int f){
	if(v==t) return f;
	for(int &i=iter[v];i<graph[v].size();i++){
		edge &e=graph[v][i];
		if(e.cap>0 && level[v]<level[e.to]){
			int d=dfs(e.to,t,min(f,e.cap));
			if(d==0) continue;
			e.cap-=d;graph[e.to][e.rev].cap+=d;
			return d;
		}
	}
	return 0;
}

int bfs(int s,int t){
	rep(i,vmax) level[i]=-1;
	queue<int> q;
	level[s]=0,q.push(s);
	while(!q.empty()){
		int v=q.front();q.pop();
		for(auto &e:graph[v]){
			if(e.cap>0 && level[e.to]<0){
				level[e.to]=level[v]+1;
				q.push(e.to);
			}
		}
	}
	return level[t]>=0;
}


int max_flow(int s,int t){
	int flow=0;
	while(bfs(s,t)){
		rep(i,vmax) iter[i]=0;
		while(1){
			int f=dfs(s,t,inf);
			if(f==0) break;
			flow+=f;
		}
	}
	return flow;
}

int a[1010],b[1010];
vector<int> ans;

int main(void){
	int n,m;
	cin >> n >> m;
	rep(i,m){
		cin >> a[i] >> b[i];
		a[i]--,b[i]--;
		add_edge(a[i],b[i],1,i+1);
		add_edge(b[i],a[i],1,i+1+m);
	}
	int s,t;
	cin >> s >> t;
	cout << max_flow(s-1,t-1) << endl;
	
	rep(i,n)for(auto &e:graph[i]){
		if(e.id<=m) continue;
		if(e.cap==0) ans.push_back(e.id-m);
	}
	cout << ans.size() << endl;
	sort(begin(ans),end(ans));
	for(auto &it:ans) cout << it << endl;
	return 0;
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr long long INFL = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



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

    long long K,A,B;
    cin >> K >> A >> B;
    long long cou=1;
    long long y=0;
    rep(i,K){
        if(y==1){
            cou+=B;
            y--;
        }
        else if(cou<A){
            cou++;
        }else{
            cou-=A;
            y++;
        }
    }
    if(y==1){
        cou+=A+1;
    }
    long long ans=max(1+K,cou);
    cout << ans << endl;




}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define inf 1000000000 //1E+9
using namespace std;
string ExtractString(string s, int begin, int end){
	string t;
	for(int i=begin; i<end; i++) t+=s[i];
	return t; }// [beg, end)を抽出
int main(){
	string s,t,u;cin>>s;
	
	t=ExtractString(s,6,13);
	u=ExtractString(s,14,19);
	s=ExtractString(s,0,5);
	cout<<s<<' '<<t<<' '<<u<<' '<<endl;
	return 0;
}



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

int main() {
	string s;
	cin >> s;
	while (!s.empty()) {
		s.pop_back();
		if (s.size() % 2 == 0) {
			string a, b;
			a = s.substr(0, s.size() / 2);
			b = s.substr(s.size() / 2);
			if (a == b) {
				cout << s.size() << endl;
				return 0;
			}
		}
	}
}


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

public class Main {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        String[] strings = scan.nextLine().split("");
        LinkedList<String> list = new LinkedList<>();
        for (int i = 0; i < strings.length; i++) {
            if (strings[i].equals("B")) {
                try {
                    list.removeLast();

                } catch (Exception e) {
                }
            } else {
                list.add(strings[i]);
            }
        }
        for (String string : list) {
            System.out.print(string);
        }
        System.out.println("");
    }
}


Measured memory_bytes: 9684
#include <bits/stdc++.h>
#define pb push_back
#define forn(i, n) for (int i = 0; i < n; i++)
#define fornd(i, n) for (int i = n - 1; i >= 0; i--)
#define for1(i, n) for (int i = 1; i <= n; i++)
#define for1d(i, n) for (int i = n; i >= 1; i--)
#define fi first
#define se second
#define all(x) x.begin(), x.end()

using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef tuple<int, int, int> iii;

const int maxn = 10;

int main() {
	int a, b;
	cin >> a >> b;
	if (b % a) cout << b - a;
	else cout << a + b;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
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();
    if(a<b){
      if(b<c){
        System.out.printf("%d %d %d\n",a,b,c);
      }
      else if(a<c){
        System.out.printf("%d %d %d\n",a,c,b);
      }
      else{
        System.out.printf("%d %d %d\n",c,a,b);
      }
    }
    else{
      if(a<c){
        System.out.printf("%d %d %d\n",b,a,c);
      }
      else if(b<c){
        System.out.printf("%d %d %d\n",b,c,a);
      }
      else{
        System.out.printf("%d %d %d\n",c,b,a);
      }
    }
  }
}


Measured memory_bytes: 26388
#include <bits/stdc++.h>
#define FASTIO
#define endl "\n" // Since endl forces a buffer flush which slows down large I/O operations.
#define ff first
#define ss second
#define pb push_back
#define input(c, n)             \
	for (int i = 0; i < (n); i++) \
		cin >> (c)[i];
#define exit_message(s) return 0 * printf(s)
#define show(c)           \
	for (auto i : (c))      \
		cout << i << " "; \
	cout << "\n";
#define display(c, n)           \
	for (int i = 0; i < (n); i++) \
		cout << (c)[i] << " ";    \
	cout << "\n";
#define forl(i, a, n) for (int (i) = (a); (i) < (n); (i)++)
#define dugbe(k) cout << "-\t> " << #k << " = " << k << "\n";

/* TIPS FOR DEBUGGING
 * Check if values are not overflowing (use long long where required)
 * Check if ranges are inclusive or not.
 * Check properly if greedy will work or not before using it.
 * Check EDGE CASES!! Seriously, even in 2B, saving 8 points by being
 * 2 minutes faster will bite you in the ass if you don't make sure
 * it works on edge cases.
 * Keep adding to this list.
*/

using namespace std;
typedef long long ll;
typedef pair<int, int> pr;
typedef pair<ll, ll> prll;
typedef vector<int> vi;
typedef vector<ll> vill;
typedef vector<pr> vpr;
ifstream in("input.txt");
const ll mod = 1e9 + 7;

ll mod_pow(ll a, ll b)
{
	if (b == 0)
		return 1LL;

	ll res = mod_pow(a, b >> 1);
	res = (res * res) % mod;
	if (b & 1LL)
		res = (res * a) % mod;

	return res;
}

const int N = 400 + 5;
const int SZ = 1e5 + 5;

int n;
int a[N];
ll b[N];
ll dp[N][N];

ll solve(int l, int r)
{
	if (l == r)
		return 0LL;

	ll &memo = dp[l][r];
	if (memo != -1)
		return memo;

	ll mn = 1e18;
	// cerr << "l : " << l << " r : " << r << "\n";
	for (int p = l; p < r; p++)
	{
		mn = min(mn, solve(l, p) + solve(p + 1, r));
	}
	// cerr << "l : " << l << " r : " << r << " mn : " << mn << "\n";
	mn += b[r] - b[l - 1];
	memo = mn;
	return mn;
}

int32_t main()
{
#ifdef FASTIO
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
#endif
	// freopen("in.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);

	memset(dp, -1, sizeof dp);

	cin >> n;
	forl(i, 1, n + 1)
	{
		cin >> a[i];
		b[i] = b[i - 1] + a[i];
	}

	ll ans = solve(1, n);
	cout << ans << "\n";

	return 0;
}

Measured memory_bytes: 1536
package main

import "fmt"

func main() {
	var a, b, c, x, y int
	fmt.Scan(&a, &b, &c, &x, &y)
	ans := a*x + b*y
	for i := 2; i <= 2*x || i <= 2*y; i += 2 {
		ab := x - i/2
		bb := y - i/2
		if ab < 0 {
			ab = 0
		}
		if bb < 0 {
			bb = 0
		}
		v := a*ab + b*bb + c*i
		if v < ans {
			ans = v
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll ans;
int n,m;
char s[1000];

int main(){
	scanf("%s%d",&s,&m); n=strlen(s);
	if(s[0]!=s[n-1]){
		for(int i=0,j=0;i<=n;i++) if(s[i]!=s[j])
			ans+=(i-j)/2,j=i;	
		printf("%lld\n",ans*m);
	}else{
		int k=0,l=0;
		for(k=0;k<n;k++) if(s[k]!=s[0]) break;
		for(l=n;l--;) if(s[l]!=s[0]) break;
		if(k==n) printf("%lld\n",1ll*n*m>>1);
		else{
			for(int i=k,j=k;i<=l+1;i++) if(s[i]!=s[j])
				ans+=(i-j)/2,j=i;
			l=n-l-1;
			ans=ans*m+(k+l)/2ll*(m-1)+k/2+l/2;
			printf("%lld\n",ans);
		}
	}
} 

Measured memory_bytes: 256
N, K, S = map(int, input().split())

mylist = []

if S != 10**9:
    for k in range(K):
        mylist += [S]
    for l in range(N-K):
        mylist += [S+1]
else:
    for k in range(K):
        mylist += [S]
    for l in range(N-K):
        mylist += [1]
        
print(" ".join(map(str, mylist)))

Measured memory_bytes: 15000
sou = lambda n: 2 ** (n + 2) - 3
ptn = lambda n: 2 ** (n + 1) - 1


def pate(lv, x):
    if x == 0:
        return 0
    if x < 0:
        return -1
    else:
        for i in range(lv + 1):
            if x < lv - i + sou(i):
                i -= 1
                return ptn(i) + 1 + pate(i, x - (lv - i + sou(i) + 1))
        else:
            return ptn(lv)


lv, x = map(int, input().split())
print(pate(lv, x))


Measured memory_bytes: 3060
# -*- coding: utf-8 -*-
 
import math
import itertools
import sys
import copy
 
# 入力
#N, W = map(int, input().split())
S = str(input())
T = str(input())

cnt = 0
for i in range(3) :
  if S[i] == T[i] :
    cnt += 1
print (cnt)


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

int main() {
  int n;
  cin >> n;
  vector<string> words(n);
  for (auto&& w : words) cin >> w;
  int numa = 0, numb = 0, numab = 0, cnt0 = 0, cnt1 = 0;
  for (auto&& w : words) {
    for (int j = 0; j < w.size() - 1; j++) {
      if (w[j] == 'A' && w[j + 1] == 'B') cnt0++;
    }
    if (w[0] == 'B' && w[w.size() - 1] == 'A')
      numab++;
    else if (w[0] == 'B')
      numb++;
    else if (w[w.size() - 1] == 'A')
      numa++;
  }
  cnt1 = max(numab - 1, 0);
  if (numab > 0) {
    if (numa > 0) {
      cnt1++;
      numa--;
    }
    if (numb > 0) {
      cnt1++;
      numb--;
    }
  }
  cnt1 += min(numa, numb);
  cout << cnt0 + cnt1 << endl;

  //   cout << numab << " " << numa << " " << numb << endl;
  //   cout << cnt0 << " " << cnt1 << endl;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
#define bit(n) (1LL << (n))
#define len(x) ((ll)(x).size())
#define debug(var) cout << "[" << #var << "]\n" << var << endl
#define int long long
typedef long long ll;
const int INF = 1001001001001001001ll;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;
const double EPS = 1e-9;

template <typename T>
ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  for (int i = 0; i < len; ++i) {
    s << v[i];
    if (i < len - 1)
      s << ' ';
  }
  return s;
}

template <typename T>
ostream& operator<<(ostream& s, const vector<vector<T>>& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) {
    s << vv[i];
    if (i != len - 1)
      s << '\n';
  }
  return s;
}

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

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

__attribute__((constructor)) void initial() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}

signed main() {
  vector<int> N(4);
  rep(i, 4) {
    cin >> N[i];
  }
  sort(all(N));

  vector<int> NN = {1, 9, 7, 4};
  sort(all(NN));

  bool ok = true;
  rep(i, 4) {
    if (N[i] != NN[i])
      ok = false;
  }
  if (ok)
    cout << "YES\n";
  else
    cout << "NO\n";
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <map>
typedef long long LL;

int int_vector_find(std::vector<int> vec, int num) {
	auto itr = std::find(vec.begin(), vec.end(), num);
	int index = std::distance(vec.begin(), itr);

	if (index != vec.size()) {
		return 1;
	}
	else {
		return 0;
	}
}

int main() {
	int n;
	LL ans = 0;
	int num;
	std::cin >> n;

	std::vector<int> vec;
	for (int i = 0; i < n; ++i) {
		int a;
		std::cin >> a;
		vec.push_back(a - (i + 1));
	}

	std::sort(vec.begin(), vec.end());

	num = vec[(n / 2)];

	for (int i = 0; i < n; ++i) {
		ans += std::abs(vec[i] - num);
	}

	std::cout << ans << std::endl;

}

Measured memory_bytes: 1400
module Main where

import Control.Applicative
import Numeric

main :: IO()
main = loop

loop :: IO ()
loop = do
  {[m, f, r] <- getInts
  ; if m == -1 && f == -1 && r == -1 then done
    else printGrade m f r
  
  
  -- ; if m == -1 && f == -1 && r == -1 then return ()
  --   else if m == -1 || f == -1 then putStrLn "F" >> loop
  --   else if m + f >= 80 then putStrLn "A" >> loop
  --   else if m + f >= 65 then putStrLn "B" >> loop
  --   else if m + f >= 50 then putStrLn "C" >> loop
  --   else if m + f >= 30 then putStrLn (if r >= 50 then "C" else "D") >> loop
  --   else putStrLn "F" >> loop
  }

done :: IO ()
done = return ()

printGrade :: Int -> Int -> Int -> IO ()
printGrade m f r  = putStrLn (grade m f r ) >> loop

grade :: Int -> Int -> Int ->String
grade m f r = if m == -1 || f == -1 then "F"
            else if mpf >= 80 then "A"
            else if mpf >= 65 then "B"
            else if mpf >= 50 then "C"
            else if mpf >= 30 then (if r >= 50 then "C" else "D")
            else "F"

  where
    mpf = m + f
                            
  
--

getInts :: IO [Int]
getInts = map read . words <$> getLine

putInts :: [Int] -> IO()
putInts = putStrLn . unwords . map show

getDoubles :: IO [Double]
getDoubles = map read . words  <$> getLine

putDoubles :: [Double] -> IO()
putDoubles = putStrLn . unwords . map showDouble

showDouble :: Double -> String
showDouble d = showFFloat Nothing d ""



Measured memory_bytes: 4216
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using System.Runtime.CompilerServices;
using static MyUtil;

class MyUtil
{
    public static int[] ReadIntArray()
    {
	return ReadLine().Split().Select(x => int.Parse(x)).ToArray();
    }
}

class Program
{
    public static void Main()
    {
	var tmp = ReadIntArray();
	int n = tmp[0], w = tmp[1];
	int[] weight = new int[n];
	int[] value = new int[n];

	for (int i = 0; i < n; i++)
	{
	    tmp = ReadIntArray();
	    weight[i] = tmp[0]; value[i] = tmp[1];
	}

	int vmax = value.Sum();
	long[][] dp = new long[n+1][];

	for (int i = 0; i <= n; i++)
	{
	    dp[i] = new long[vmax+1];
	    for (int j = 0; j <= vmax; j++)
		dp[i][j] = 10000000000;
	}
	dp[0][0] = 0;

	for (int i = 0; i < n; i++)
	{
	    for (int v = 0; v <= vmax; v++)
	    {
		if (v >= value[i])
		    dp[i+1][v] =
			Math.Min(dp[i+1][v],
				 dp[i][v - value[i]] + weight[i]);

		dp[i+1][v] =
		    Math.Min(dp[i+1][v], dp[i][v]);
	    }
	}

	for (int v = vmax;  v >= 0; --v)
	{
	    if (dp[n][v] <= w){
		WriteLine(v);
		return;
	    }
	}

    }
}


Measured memory_bytes: 92352
import java.util.Scanner;

public class Main
{
    public static void main(String[] args)
    {
    	Scanner scan = new Scanner( System.in );
    	
    	int x = scan.nextInt();
    	x = (int)Math.pow( x, 3 );
    	
    	System.out.println( x );
    }
}

Measured memory_bytes: 26072
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define endl "\n"
#define se second
#define ls( s) (s&(-s))
#define ll long long
#define inf 0x3f3f3f3f
#define fast    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int N = 2e5;
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
const ll mod =    1e9+7;

int main()
{  fast
int n;
cin>>n;
set<string> s;
while(n--)
{
	string ss;
	cin>>ss;
	s.insert(ss);
}
cout<<s.size();
}


Measured memory_bytes: 19216
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int y = sc.nextInt();
		sc.close();
		System.out.println(ans(x, y));
	}

	public static long ans(int x, int y) {
		if ((y * 2 - x) % 3 != 0 || (x * 2 - y) % 3 != 0) {
			return 0;
		} else {
			int s = (x * 2 - y) / 3;
			int t = (y * 2 - x) / 3;
			Combination cmb = new Combination(s + t + 1);
			return cmb.getComb(s + t, s);
		}
	}

	public static int[] arrayInt(Scanner sc, int n) {
		int[] array = new int[n];
		for (int i = 0; i < n; i++) {
			array[i] = sc.nextInt();
		}
		return array;
	}

	public static long[] arrayLong(Scanner sc, int n) {
		long[] array = new long[n];
		for (int i = 0; i < n; i++) {
			array[i] = sc.nextLong();
		}
		return array;
	}

	public static double[] arrayDouble(Scanner sc, int n) {
		double[] array = new double[n];
		for (int i = 0; i < n; i++) {
			array[i] = sc.nextDouble();
		}
		return array;
	}
}

class Combination {
	static final int MOD = 1000000007;
	long[] fac;
	long[] finv;
	long[] inv;

	public Combination(int size) {
		fac = new long[size];
		finv = new long[size];
		inv = new long[size];
		fac[0] = 1;
		fac[1] = 1;
		finv[0] = 1;
		finv[1] = 1;
		inv[1] = 1;
		for (int i = 2; i < size; i++) {
			fac[i] = fac[i - 1] * i % MOD;
			inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
			finv[i] = finv[i - 1] * inv[i] % MOD;
		}
	}

	public long getComb(int n, int k) {
		if (n < k || n < 0 || k < 0) {
			return 0;
		}
		return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
	}

}


Measured memory_bytes: 46804
"""解説を見てから解いたコード"""
N, M, P = map(int, input().split())
edges = []
for _ in range(M):
    a, b, c = map(int, input().split())
    edges.append((a, b, c-P))

INF = float('inf')

coin_map = [-INF] * (N+1)
coin_map[1] = 0

for i in range(2*N):
    for a, b, c in edges:
        if coin_map[b] < coin_map[a] + c:
            coin_map[b] = coin_map[a] + c
            if i >= N:
                coin_map[b] = INF

    if i == N - 1:
        ans = coin_map[N]

if ans != coin_map[N]:
    print(-1)
else:
    print(max(0, coin_map[N]))




Measured memory_bytes: 50412
#include <bits/stdc++.h>
#define maxn 100001
#define maxa 2000005
#define MOD  998244353 //1000000007
#define INF 1000000000000000000

using namespace std;

#define ll long long
#define pii pair<ll, ll>
#define piii pair<pii, ll>
#define ft first
#define sd second
#define pb push_back
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repr(i, n) for(ll i = n-1; i >= 0; i--)
#define mem(a, b) memset(a, b, sizeof(a))
#define sort(v) sort(v.begin(), v.end())
#define edge(v, x, y) v[x].pb(y); v[y].pb(x);
#define popcount __builtin_popcount

void fast(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout << setprecision(10) << fixed;
}
ll ceil(ll a, ll b){ return (a+ b-1)/b; }
void flaged(bool flag){
    if(flag) cout << "Yes\n";
    else cout << "No\n";
}
// power and modulo inverse
ll power(ll a, ll b = MOD-2){
    if(b == 0) return 1;
    ll r = power(a, b/2);
    r = (r*r)%MOD;
    if(b%2 == 1) r = (r*a)%MOD;
    return r;
}
// factorial
ll fact[maxa], finv[maxa];
void calf(){
    fact[0] = finv[0] = 1;
    for(ll i = 1; i < maxa; i++){fact[i] = (fact[i-1]*i) %MOD;finv[i] = (finv[i-1]*power(i))%MOD;}
}
// nCr
ll ncr(ll N, ll R){ if(R > N) return 0; return (fact[N]*((finv[R]*finv[N-R])%MOD))%MOD;}

void solve(){
    string a, b;
    cin >> a >> b;
    cout << b<< a;
}

int main()
{
    fast();
    ll t = 1;//cin >> t;
    while(t--){
        solve();
    }
}


Measured memory_bytes: 256
n = gets.to_i
words = Array.new(n){ gets.chomp.bytes.sort }

h = Hash.new
ans = 0
words.each do |s|
  
  if h.has_key?(s)
    h[s] += 1
    ans += h[s]
    p 
  else
    h[s] = 0
  end
end

puts ans

Measured memory_bytes: 34556
# -*- coding:utf8 -*-
import fractions

a,b,c,d = map(int, input().split())
t = b - a + 1
dc = (b // c) - (a // c) if a % c != 0 else (b // c) - (a // c) + 1
dd = (b // d) - (a // d) if a % d != 0 else (b // d) - (a // d) + 1
lc = c * d // fractions.gcd(c, d)
dlc = (b // lc) - (a // lc) if a % lc != 0 else (b // lc) - (a // lc) + 1
ans = t - dc - dd + dlc
print(ans)

Measured memory_bytes: 5432
//                               //
    // author : samars_diary //
    // 21-09-2020 │ 11:42:49 //
//                               //

#include <iostream>
using namespace std;

void solve(){
    long long int a, b, c, k, sum(0); 
    cin>> a >> b >> c >> k;
    while (k>0){
        if (k-a<=0 && a>0){
            sum=k ; break ;
        }else if (k-a>0 && a>0){
            sum += a ; k-=a ; a=-1 ;
        }else if (k-b<=0 && b>0){
            b=-1 ; break ;
        }else if (k-b>0 && b>0){
            k-=b ; b=-1 ;
        }else if (k-c<=0 && c>0){
            sum -= k ; break ;
        }else if (k-c>=0 && c>0){
            sum -= c ; break ;
        }else{
            break;
        }
    }
    cout<< sum <<'\n';
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);

    //#ifndef ONLINE_JUDGE
        //freopen("input.txt", "r", stdin);
        // freopen("output.txt", "w", stdout);
    //#endif

    int t = 1;
    while(t--){
        solve();
    }

    return 0;
}

Measured memory_bytes: 3584
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE LambdaCase #-}
module Main where

import           Data.List
import           Control.Monad
import           Debug.Trace
import qualified Data.ByteString.Char8         as BC
import           Data.Maybe                     ( fromJust )
import qualified Data.Set                      as S
import qualified Data.IntMap.Strict            as IM
import qualified Data.IntMap.Lazy            as IML
import qualified Data.Map.Strict               as M
import           Data.Char
import qualified Data.Array.IArray as A
import qualified Data.Array.Unboxed as UA
import Data.Bits
import Control.Monad.State.Strict
import qualified Data.Array.ST as STA
import qualified Data.Array.MArray as MA
import Control.Monad.ST



readTuple2 :: IO (Int, Int)
readTuple2 = do
    [a, b] <- map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine
    return (a, b)

readTuple3 :: IO (Int, Int, Int)
readTuple3 = do
    [a, b, c] <- map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine
    return (a, b, c)

readInt :: IO Int
readInt = fst . fromJust . BC.readInt <$> BC.getLine

readInts :: IO [Int]
readInts = map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine

split :: (a -> Bool) -> [a] -> [[a]]
split f [] = []
split f as =
    let (fo, la) = span f as
        las      = case la of
            [] -> []
            xs -> split f $ tail xs
    in  case fo of
            [] -> las
            xs -> xs : las

modN = 2019

pow :: Num a => a -> Int -> a
pow base 1 = base
pow base time
    | odd time = let 
        a = pow base (div time 2)
        in
        a * a * base
    | otherwise = let
        a = pow base (div time 2)
        in
        a * a

inv :: ModNum -> ModNum
inv a = pow a $ modN - 2

newtype ModNum = ModNum {getInt :: Int} deriving (Show, Eq, Ord)
instance Num ModNum where
    (+) (ModNum a) (ModNum b) = ModNum $ mod (a + b) modN
    (-) (ModNum a) (ModNum b)
            | a < b = (ModNum $ a + modN) - ModNum b
            | otherwise = ModNum $ mod (a - b) modN
    (*) (ModNum a) (ModNum b) = ModNum $ mod (a * b) modN
    abs (ModNum a)
        | a < 0 = abs . ModNum $ a + modN
        | otherwise = ModNum a
    signum (ModNum a) = ModNum $ signum a
    fromInteger i = abs . ModNum . fromIntegral $ mod i (fromIntegral modN)

mDiv :: ModNum -> ModNum -> ModNum
mDiv a b = a * inv b

comb :: Int -> [a] ->[[a]]
comb 0 xs = [[]]
comb _ [] = []
comb n (x:xs) = [x:y | y <- comb (n-1) xs] ++ comb n xs

main :: IO ()
main = do
    (l, r) <- readTuple2
    if r - l > 2019 then print 0 else print $ getInt $ minimum $ do
        [a, b] <- comb 2 $ fromIntegral <$> [l..r]
        pure $ a * b





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

using namespace std;

int main()
{
        int64_t  n, k, total = 0;
        cin >> n >> k;
        auto aa = vector<int64_t>(n + 1, 0);
        auto bb = vector<int64_t>();
        
        for (int64_t i = 1; i <= n; i++)
        {
                cin >> aa[i];
        }

        for (int64_t i = 1; i < k; i++)
        {
                total += aa[i];
        }

        for (int64_t i = k; i <= n; i++)
        {
                total = total + aa[i] - aa[i - k];
                bb.push_back(total);
        }

        for (int64_t i = 1; i < bb.size(); i++)
        {
                if (bb[i] > bb[i - 1])
                {
                        puts("Yes");
                }
                else
                {
                        puts("No");
                }
        }

        return 0;
}

Measured memory_bytes: 6924
//
//  main.c
//  ITP1_5_A
//
//  Created by ??±??°?????? on 2015/10/10.
//  Copyright ?? 2015??´ HamadaShogo. All rights reserved.
//

#include <stdio.h>

void printSquare(unsigned int High, unsigned int Wide);

int main(int argc, const char * argv[]) {
    unsigned int h = 1, w = 1;
    
    while (!(h == 0 && w == 0)) {
        scanf("%d %d", &h, &w);
        if(!(h == 0 && w == 0)){
            printSquare(h, w);
        }
    }

    return 0;
}

void printSquare(unsigned int High, unsigned int Wide){
    int i, j;
    
    for (i=0; i<High; i++) {
        for (j=0; j<Wide; j++) {
            printf("#");
        }
        puts("");
    }
    puts("");
}

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

using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n; i>-1; --i)
#define ALL(a) (a).begin(),(a).end()
#define FILL(a,n,x); REP(i,(n)){ (a)[i]=(x); }
#define CINA(a,n); REP(i,(n)){ cin >> (a)[i]; }
#define FILL2(a,n,m,x); REP(i,(n)){ REP(j,(m)){(a)[i][j]=(x);} }
#define CINA2(a,n,m); REP(i,(n)){ REP(j,(m)){cin >> (a)[i][j];} }
#define Liny "Yes\n"
#define Linn "No\n"
#define LINY "YES\n"
#define LINN "NO\n"

//cout << setfill('0') << right << setw`(4) << 12; // "0012"
int keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}
int keta_wa(ll x){ if(x<10){return x;} else{return keta_wa(x/10) + x%10;} }
int ctoi(char c){ return ( (c>='0' && c<='9')? c - '0': 0 );}
int __stoi(string s){ return atoi(s.c_str()); }
ll sum(ll a[],ll N){ return accumulate(a,a+N,0LL);}
ll gcd(ll a,ll b){if(a<b)swap(a,b); return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){if(a<b){swap(a,b);} return a/gcd(a,b)*b;}
template<class T> void chmax(T& a, T b){ if(a<b){a=b;} }
template<class T> void chmin(T& a, T b){ if(a>b){a=b;} }
template<class T> bool isIn(T a,vector<T> v){ for(T x:v){ if(a==x){return true;}} return false;}
string strReplace(string s,string target, string replacement){
    if (!target.empty()) {
      std::string::size_type pos = 0;
      while ((pos = s.find(target, pos)) != std::string::npos) {
        s.replace(pos, target.length(), replacement);
        pos += replacement.length();
      }
    }
    return s;
}
const ll MOD = 1e9+7;
#define pii pair<int,int>
#define pll pair<ll,ll>
#define MP make_pair

bool DEBUG = 0;
template<class T> void dprint(T s){
  if(DEBUG){ cout << s << "\n"; }
}
const ll MAX = MOD;

void solve(){
  int N; cin>>N;
  map<pii,ll> mp;
  REP(i,N){
    ld a; cin>>a;
    ll x = round(a*pow(10,9));
    dprint(x);
    int n=0,m=0;
    while(x%2==0){
      x /= 2;
      ++n;
    }
    while(x%5==0){
      x /= 5;
      ++m;
    }
    chmin(n,18);
    chmin(m,18);
    ++mp[MP(n,m)];
  }
  ll ans = 0LL;
  REP(i,19){
    REP(j,19){
      REP(k,19){
        REP(l,19){
          if(i+k<18 || j+l<18) continue;
          if(i==k && j==l){
            ans += max(mp[MP(i,j)] * (mp[MP(k,l)]-1),0LL);
          }else{
            ans += max(mp[MP(i,j)] * mp[MP(k,l)],0LL);
          }
        }
      }
    }
  }
  ans /= 2;
  cout << ans << "\n";
}

int main(int argc, char *argv[]){
  if(argc>1 && argv[1][0]=='D'){ DEBUG = 1;}
  solve();
  return 0;
}

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

#define each(i, c) for (auto& i : c)
#define mkp(a, b) make_pair(a, b)

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> Pll;
const ll MOD = 1e9+7;

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


template<typename T> inline T popcount(T);
template<> inline ll popcount(ll i) { return __builtin_popcountll(i); }

int main() {
  ll h, w, k;
  cin >> h >> w >> k;

  vector<vector<char>> c(h, vector<char>(w));
  for (ll i = 0; i < h; ++i) {
    string s;
    cin >> s;
    for (ll j = 0; j < s.size(); ++j) {
      c[i][j] = s[j];
    }
  }

  ll ans = 0;
  for (ll bh = 0; bh < (1<<h); ++bh) {
    for (ll bw = 0; bw < (1<<w); ++bw) {
      
      auto v = c;
      for (ll i = 0; i < h; ++i) {
        if (bh & (1<<i)) {
          for (ll j = 0; j < w; ++j) {
            v[i][j] = 'x';
          }
        }
      }

      for (ll i = 0; i < w; ++i) {
        if (bw & (1<<i)) {
          for (ll j = 0; j < h; ++j) {
            v[j][i] = 'x';
          }
        }
      }

      ll cnt = 0;
      for (ll i = 0; i < h; ++i) {
        for (ll j = 0; j < w; ++j) {
          if (v[i][j] == '#') ++cnt;
        }
      }
      if (k == cnt) ++ans;
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3624
// </> : towhid1zaman

#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair< int, int > pii;
typedef pair< pii, int > ppi;
#define fill(a,b) memset(a,b,sizeof(a))
#define all(v) (v).begin(),(v).end()
#define sp(k) cout<<setprecision(k)<<fixed;
#define rep(i,a) for(int i=0;i<a;i++)
#define rep1(i,a,b) for(int i=(a);i<=(b);++i)
#define irep(i,b,a) for(int i=(b);i>=(a);--i)
#define minv(v) *min_element(all(v))
#define maxv(v) *max_element(all(v))
#define unq(v) sort(all(v)),(v).erase(unique(all(v)),(v).end())
#define _ ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl "\n"
#define sqr(a) ((a)*(a))
#define sz(a) int(a.size())
#define ff first
#define ss second
#define pb push_back

const double pi = acos(-1.0);
const int mod = 1000000007; // (int)1e9+7
const int inf = 0x3f3f3f3f;// (int)3e18;
const int maxn = 2000100;



int main(){
        _
        int n; cin >> n;
        vi v(n);
        for(int i = 0; i<n; i++)cin >> v[i];
        int ans = 0;
        while(true){
            bool f = false;
            for(int i = 0; i<n; i++){
                if(v[i]%2==1)f = true;
                else{
                    v[i]/=2;
                }
            }
            if(f)break;
            ans++;
        }
        cout<<ans<<endl;

return 0;
}




Measured memory_bytes: 256
#include<bits/stdc++.h> 
using namespace std;
typedef long long ll;
template<typename T1,typename T2> bool chmin(T1 &a,T2 b){if(a<=b)return 0; a=b; return 1;}
template<typename T1,typename T2> bool chmax(T1 &a,T2 b){if(a>=b)return 0; a=b; return 1;}


signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);

    
    int n;
    cin>>n;
    set<char> st;
    for(int i=0;i<n;i++){
        char s;
        cin>>s;
        st.insert(s);
    }
    if(st.size() == 4){
        cout << "Four" << endl;
    }
    else cout << "Three" << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

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

    int N = sc.nextInt();
    int order[];
    order = new int[N];

    for(int i = 0; i < N; i++) {
      order[sc.nextInt() - 1] = i + 1;
    }
    for(int n = 0; n < N; n++) {
      System.out.println(order[n]);
    }
  }
}


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

using namespace std;

#define mod 1000000007
#define sz(c)  (int) c.size()
#define all(c) c.begin(), c.end()
#define tr(container,it) for(__typeof(container.begin()) it = container.begin();it != container.end(); it++)
#define present(s,x) s.find(x) != s.end()
#define cpresent(c,x) find(all(c),x) != c.end()
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,a,b) for(int i=a; i<b;i++)
#define ini(n) scanf("%d",&n)
#define opn printf("\n")

 
#define TRACE
 
#ifdef TRACE
#define trace1(x)                cerr << #x << ": " << x << endl;
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
#define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
#define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;
 
#else
 
#define trace1(x)
#define trace2(x, y)
#define trace3(x, y, z)
#define trace4(a, b, c, d)    
#define trace5(a, b, c, d, e)
#define trace6(a, b, c, d, e, f)

#endif 

typedef pair<int,int> pi;
typedef vector<pi> vp;
typedef vector<vp> vvp;
typedef vector<int> vi;
typedef unsigned long long int ull;
typedef long long int ll;
typedef vector<ll> vl;
typedef vector< vi > vvi;
typedef priority_queue<int> pq;
typedef priority_queue<int, vi , greater<int> >minpq;
typedef priority_queue<pi,vp,greater<pi> > mpq;


int main(){
	//ios_base::sync_with_stdio(false);cin.tie(NULL);
	ll a,b;
	cin>>a>>b;
	ll c=a*b;
	if(c&1)
		cout<<"Odd";
	else
		cout<<"Even";
	opn;
		
	
}

	

	



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    vector<int>a(100000);
    for(int i=0; i<n; i++){
        cin>>a.at(i);
    }
    bool check=false;
    int count = 0;
    int tmp = a.at(0);
    for(int i=0; i<n; i++){
        count++;
        if(tmp==2){
            check = true;
            break;
        }
        tmp=a.at(tmp-1);
    }
    if(check)cout<<count<<endl;
    else cout<<"-1"<<endl;
}

Measured memory_bytes: 640
#include<stdio.h>
#include<float.h>

int main(){
   
  double a,b,c;
  scanf("%lf",&a);
  b=3.141592653589*a*a;
  c=3.141592653589*2*a;
  printf("%lf %lf\n",b,c);
  return 0;
}
  

Measured memory_bytes: 648