akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  int n;
    cin >> n;
    map<ll,ll>mp;
    mp[0]++;
    ll sum=0;
    ll ret=0;
    for(int i=1;i<=n;i++)
    {
        int x;
        cin>>x;
        sum+=x;
        ret+=mp[sum];
        mp[sum]++;
    }
    printf("%lld\n",ret);
}

Measured memory_bytes: 12800
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author anand.oza
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ARightTriangle solver = new ARightTriangle();
        solver.solve(1, in, out);
        out.close();
    }

    static class ARightTriangle {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int[] x = new int[3];
            for (int i = 0; i < 3; i++) {
                x[i] = in.nextInt();
            }
            Arrays.sort(x);
            out.println(x[0] * x[1] / 2);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 22484
# 0:17-
h, w = gets.to_s.split.map{|t| t.to_i }

# p ".#".bytes #=> [46, 35]
blacks = []
a = Array.new(h) do |i| 
  s = gets.to_s.chomp.bytes
  s.each_with_index do |c, j|
    blacks << [i, j] if c == 35
  end
  s
end

dxy = [[1, 0], [0, 1], [-1, 0], [0, -1]]

ans = -1
while blacks.any?
  
  ns = []
  ans += 1
  
  blacks.each do |x, y|
    nx = x - 1
    if 0 <= nx && a[nx][y] == 46
      a[nx][y] = 35
      ns << [nx, y]
    end
    nx = x + 1
    if nx < h && a[nx][y] == 46
      a[nx][y] = 35
      ns << [nx, y]
    end
    ny = y - 1
    if 0 <= ny && a[x][ny] == 46
      a[x][ny] = 35
      ns << [x, ny]
    end
    ny = y + 1
    if ny <= w && a[x][ny] == 46
      a[x][ny] = 35
      ns << [x, ny]
    end
  end
  blacks = ns.dup
end

puts ans

Measured memory_bytes: 62588
use std::io;
use std::cmp;


fn main() {
    let n = read_one::<usize>();
    let mut vec = Vec::new();
    for _ in 0..n {
        let i = read::<isize>();
        vec.push((i[0], i[1], i[2]));
    }

    vec.sort_by_key(|x| x.2);
    vec.reverse();

    let mut ans_x = 0;
    let mut ans_y = 0;
    let mut ans_h = 0;
    for x in 0..101 { for y in 0..101 {
        let mut flg = true;
        let h = vec[0].2 + (x - vec[0].0).abs() + (y - vec[0].1).abs();
        for v in vec.iter() {
            if v.2 != cmp::max(h - (x - v.0).abs() - (y - v.1).abs(), 0) { flg = false; continue; }
        }

        if flg {
            ans_x = x;
            ans_y = y;
            ans_h = h;
        }
    }}

    println!("{} {} {}", ans_x, ans_y, ans_h);
}


#[allow(dead_code)]
fn read<T>() -> Vec<T>
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.split_whitespace()
        .map(|s| s.trim().parse().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_one<T>() -> T
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().unwrap()
}

Measured memory_bytes: 4352
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <set>
#include <queue>
#include <map>
#include <numeric>
#include <functional>
#include <math.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

#define INF ((int)1e9)
#define INFLL ((ll)1e18)
#define MOD (1000000007LL)


int main(int argc, const char * argv[]) {
    ios_base::sync_with_stdio(false);
    int R, G, B, N;
    cin >> R >> G >> B >> N;
    
    ll lRes = 0;
    for (int r = 0; r <= N/R; ++r) {
        for (int g = 0; g <= (N-r*R)/G; ++g) {
            if ((N-r*R-g*G)%B == 0) ++lRes;
        }
    }
    cout << lRes << endl;

    return 0;
}


Measured memory_bytes: 256
mod=998244353

n,s=map(int,input().split())
A=list(map(int,input().split()))
div2=pow(2,mod-2,mod)
dp=[0]*(s+1)
dp[0]=pow(2,n,mod)

for a in A:
    newdp=[0]*(s+1)
    for i in range(s,a-1,-1):
        before=i-a
        newdp[i]+=dp[before]*div2%mod
        newdp[i]%=mod
    for i in range(s+1):
        newdp[i]+=dp[i]
        newdp[i]%=mod
    dp=newdp
print(dp[-1])

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

using namespace std;

int main() {
  int A, B;
  cin >> A >> B;
  if (A == B) cout << "Draw" << endl;
  else {
    if (A == 1) cout << "Alice" << endl;
    else if (B == 1) cout << "Bob" << endl;
    else {
      if (A < B) cout << "Bob" << endl;
      else cout << "Alice" << endl;
    }
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <utility>
#include <functional>
#include <deque>
#include <cctype>
#include <stack>
#include <bitset>

using ll = long long;
typedef unsigned long long ull;
typedef std::pair<ll, ll>P;

ll min(ll a, ll b) {
	if (a >= b)return b;
	else return a;
}
ll max(ll a, ll b) {
	if (a >= b)return a;
	else return b;
}
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a%b);
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}

const ll Z = 1000000007;
const ll INF = 1 << 30;
const ll INF2 = 9000000000000000000LL;
bool flag = true;
bool fl = true;
bool f = true;
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
std::string abc = "abcdefghijklmnopqrstuvwxyz";
struct edge { ll to, cost; };
std::vector<edge>V[100010], W[100010];
typedef std::vector<std::vector<int>>ma;

int main() {
	ll n, m, d[210][210], R, r[10];
	std::cin >> n >> m >> R;
	for (int i = 0;i < R;i++)std::cin >> r[i];
	for (int i = 1;i <= n;i++) for (int j = 1;j <= n;j++)d[i][j] = INF;
	for (int i = 0;i < m;i++) {
		int a, b, c;
		std::cin >> a >> b >> c;
		d[a][b] = c;
		d[b][a] = c;
	}
	for (int i = 1;i <= n;i++)d[i][i] = 0;
	for (int k = 1;k <= n;k++) {
		for (int i = 1;i <= n;i++) {
			for (int j = 1;j <= n;j++) {
				d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
			}
		}
	}
	ll ans = INF2;
	std::vector<int>V(R);
	for (int i = 0;i < R;i++)V.push_back(r[i]);
	std::sort(V.begin(), V.end());
	int I = 1;
	for (int i = R;i >= 1;i--)I *= i;
	for (int i = 0;i < I;i++) {
		ll M = 0;
		for (int j = 0;j < V.size()-1;j++) {
				M += d[V[j]][V[j+1]];
		}
		ans = min(M, ans);
		std::next_permutation(V.begin(), V.end());
	}
	std::cout << ans << std::endl;
}

Measured memory_bytes: 5248
n = int(input())
a = list(map(int, input().split()))
b = []

a.sort(reverse=False)

for i in range(n-1):

    if a[i] < 0:

        if a[i+1] >= 0:

            if -a[i] > a[i+1]:
                a[i] = -a[i]
                a[i+1] = -a[i+1]
                b.append(a[i])

                for j in range(i+1,n-1):
                    b.append(a[j])
                break

            else:
                b.append(a[i])

                for j in range(i+1,n-1):
                    b.append(a[j])
                break

        a[i] = -a[i]
        a[i+1] = -a[i+1]
        b.append(a[i])

    else:
        b.append(a[i])

ans = sum(b) + a[n-1]

print(ans)

Measured memory_bytes: 14496
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <map>
#define ll long long
const int MOD = 1e9+7;
using namespace std;

int main(){
	string s;
	cin >> s;
	map<string, string> mp;
	mp.insert(make_pair("Sunny", "Cloudy"));
	mp.insert(make_pair("Cloudy", "Rainy"));
	mp.insert(make_pair("Rainy", "Sunny"));
	cout << mp.at(s) << endl;
	return 0;
}

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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}

using ll=long long;
using R=long double;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};

// Problem Specific Parameter:

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

	int ans = 1010;

	rep(ai,101)rep(bi,101)rep(ci,101){
		int na = a + bi + ci;
		int nb = ai + b + ci;
		int nc = ai + bi + c;

		int cur = ai + bi + ci;

		bool ok = true;
		const int cmax = max({na,nb,nc});

		for(auto &elem:{na,nb,nc}){
			if((cmax - elem) % 2 == 0){
				cur += (cmax - elem) /2;
			}else{
				ok = false;
			}
		}

		if(ok) chmin(ans,cur);
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
N,A,B = map(int,input().split())

ans = 0

for i in range(1,N+1):
  
  x = str(i)
  n = len(x)
  sum = 0
  
  for j in range(0,n):
    sum = sum + int(x[j])
  
  if sum >= A and sum <= B:
    ans += i
    
print(ans)

Measured memory_bytes: 9136
#include <iostream>
#include <vector>

#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=a,i##_len=(b);i<i##_len;++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()

using namespace std;
using ll = long long;
typedef long long ll;

int gcd(int a,int b){return b?gcd(b,a%b):a;}

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

    cout << (n * (n - 1) / 2) + (m * (m - 1) / 2) << '\n';

    return 0;
}


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

using ll = long long;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define SIZE(a) ((int)(a).size())

const int N = 100005;
const int mod = 1000*1000*1000 + 7;
const ll linf = 2e18;

int n, m, s, t;
vector<pair<int,int>> g[N];
ll dist[2][N];
int cnt[2][N];

void goDist(int v, int id) {
	set<pair<ll,int>> s;
	REP(i, n) dist[id][i] = linf, cnt[id][i] = 0;
	dist[id][v] = 0;
	cnt[id][v] = 1;
	s.insert({0, v});
	while (!s.empty()) {
		v = s.begin()->second;
		s.erase(s.begin());
		for (auto& item : g[v]) {
			int to = item.first;
			int c = item.second;
			if (dist[id][to] > dist[id][v] + c) {
				s.erase({dist[id][to], to});
				dist[id][to] = dist[id][v] + c;
				cnt[id][to] = 0;
				s.insert({dist[id][to], to});
			}
			if (dist[id][to] == dist[id][v] + c) {
				cnt[id][to] = (cnt[id][to] + cnt[id][v]) % mod;
			}
		}
	}
}

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

	cin >> n >> m;
	cin >> s >> t;
	--s; --t;
	vector<tuple<int,int,int>> edges;
	REP(i, m) {
		int x, y, c;
		cin >> x >> y >> c;
		--x; --y;
		g[x].emplace_back(y, c);
		g[y].emplace_back(x, c);
		edges.emplace_back(x, y, c);
	}
	goDist(s, 0);
	goDist(t, 1);
	int result = (1LL*cnt[0][t]*cnt[1][s]) % mod;
	ll d = dist[0][t];
	REP(i, n) if (dist[0][i] + dist[1][i] == d && i != s && i != t) {
		if (dist[0][i] == dist[1][i]) {
			int now = (1LL*cnt[0][i]*cnt[1][i]) % mod;
			now = (1LL*now*now) % mod;
			result = (result + mod - now) % mod;
		}
	}
	for (auto& edge : edges) {
		int x, y, c;
		tie(x, y, c) = edge;
		if (dist[0][x] + dist[1][y] + c != d) swap(x, y);
		if (dist[0][x] + dist[1][y] + c == d) {
			if (d <= 2*dist[0][x] || d <= 2*dist[1][y]) continue;
			int now = (1LL*cnt[0][x]*cnt[1][y]) % mod;
			now = (1LL*now*now) % mod;
			result = (result + mod - now) % mod;
		}
	}

	cout << result << '\n';
	return 0;
}

Measured memory_bytes: 19244
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n); i >= 0; i--)
#define REP(i, m, n) for (int i = (int)(m); i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
typedef long long ll;

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

const long long INF = 1LL << 60;

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

  int ab, bc, ca;
  ab = abs(a-b);
  bc = abs(b-c);
  ca = abs(c-a);

  cout << ((ab <= d && bc <= d) || (ca <= d) ? "Yes" : "No") << endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
using namespace std;
int main(){
  double r,x,y;
  cin>> r;
  x=r*r*3.141592653589;
  y=2*r*3.141592653589; 
  printf("%.6lf %.6lf\n", x,y);
    
  return 0;
}

Measured memory_bytes: 3196
#include<iostream>
#include<iomanip>
#include<math.h>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<string>
#include<bitset>
#include<random>
#define INF 1000000000ll
#define MOD 1000000007ll
#define EPS 1e-10
#define REP(i,m) for(long long i=0; i<m; i++)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define DUMP(a) for(long long dump=0; dump<(ll)a.size(); dump++) { cout<<a[dump]; if(dump!=(ll)a.size()-1) cout<<" "; else cout<<endl; }
#define ALL(v) v.begin(),v.end()
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef long double ld;

ll N = 202020;
ll bit[202020];
void add(ll a, ll w) {
	a++;
	for (ll x = a; x <= N; x += x & -x) bit[x] += w;
}
ll sum(ll a) {
	a++;
	ll ret = 0;
	for (ll x = a; x > 0; x -= x & -x) ret += bit[x];
 return ret;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	REP(i,N) bit[i]=0;
	ll n,m;
	cin>>n>>m;
	vector<P> gd(n);
	REP(i,n) cin>>gd[i].first>>gd[i].second;
	vector<pair<ll,P>> data(n);
	REP(i,n) {
		data[i].first=gd[i].second-gd[i].first+1;
		data[i].second=gd[i];
	}
	sort(ALL(data));
	vector<ll> ans(m,0);
	ll cur=0;
	FOR(i,1,m+1) {
		while(cur!=n&&data[cur].first<i) {
			add(data[cur].second.first,1);
			add(data[cur].second.second+1,-1);
			cur++;
		}
		ans[i-1]+=n-cur;
		ll pos=0;
		while(pos<=m) {
			ans[i-1]+=sum(pos);
			pos+=i;
		}
	}
	REP(i,m) cout<<ans[i]<<endl;
}


Measured memory_bytes: 14976
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define ll long long
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<long long>;
using vvll = vector<vll>;

//snippets:tmp,cl,cvl,cs,co,coy,con,cov

ll findm(vll &c){
    ll min=1000000;
    ll key=0;
    rep(i,c.size()){
        if(min>c[i]){
            min=c[i];
            key=i;
        }
    }
    return key;
}


int main(){
    ll n;
    cin >> n;
    vvll d(n);
    vll co(n,0);
    rep(i,n-1){
        ll a;
        cin >> a;
        ll b;
        cin >> b;
        d[a-1].push_back(b-1);
        d[b-1].push_back(a-1);
        co[a-1]++;
        co[b-1]++;
    }
    vll c(n);
    rep(i, n) cin >> c[i];
    sort(all(c));
    vll a(n);
    ll ans=0;
    rep(i,n){
        ll k=findm(co);
        a[k]=c[i];
        rep(j,d[k].size()){
            if(co[d[k][j]]==100000) ans+=a[d[k][j]];
            else co[d[k][j]]--;
        }
        co[k]=100000;
    }
    cout << ans << endl;
    rep(i,n-1) cout<<a[i]<<" ";
    cout<<a[n-1]<<endl;
}

Measured memory_bytes: 1152
(N,M) = (int(i) for i in input().split(" "))

K = N*(N-1)/2
K += M*N
K = int(K)
if M <=0 and N+M-1>=0:
	print(K)
elif M > 0:
	print(K-M)
else:
	print(K-N-M+1)


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

s = []
for i in range(n):
    tmp = []
    tmp = list(input())
    tmp.sort()
    s.append("".join(tmp))

s.sort()

cnt = 0
t_cnt = 0
for i in range(n-1):
    if s[i] == s[i+1]:
        t_cnt += 1
    elif s[i] != s[i+1]:
        if t_cnt > 1:
            t_cnt += 1

            t = 0
            for j in range(t_cnt):
                t += j

            cnt += t
            t_cnt = 0
        else:
            cnt += t_cnt
            t_cnt = 0

    if i == n-2:

        if t_cnt > 1:
            t_cnt += 1

            t = 0
            for j in range(t_cnt):
                t += j

            cnt += t
            t_cnt = 0
        else:
            cnt += t_cnt
            t_cnt = 0

print(cnt)


Measured memory_bytes: 10668
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;
long long gcd(long long x,long long y)
{
	if(y==0)
		return x;
	return gcd(y,x%y);
}
int main()
{
	int T;
	long long a,b,c,d;
	scanf("%d",&T);
	while(T--)
	{
		scanf("%lld%lld%lld%lld",&a,&b,&c,&d);
		if(a<b||d<b)
		{
			printf("No\n");
			continue;
		}
		a%=b;
		d=gcd(d,b);
		if(d!=b)
		{
			a%=d;
			a=a+b-d;
		}
		if(a>c)
			printf("No\n");
		else
			printf("Yes\n");
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <numeric>      

using namespace std;

int main(){
    int N, K;
    cin >> N >> K;
    vector<int> price;
    int p;
    int maxSum=0;
    for(int i = 0; i< N; i++){
        cin >> p;
        maxSum+=p;
        price.push_back(p);
    }
    sort(price.begin(), price.end());


    int res = 0;
    if(K>N){
        res = maxSum + (K-N)*price[0];
        cout << res << endl;
    }
    else{
        for(int i = 0; i< K; i++){
            res+=price[i];
            price.push_back(p);
        }
        cout << res << endl;
    }

}


Measured memory_bytes: 3212
# coding: utf-8

N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
#s = [str(input()) for i in range(N)]
#print(A)

cnt=0
for i in range(0,N):
  if A[i]>B[i]:
    cnt+=B[i]
    A[i]=A[i]-B[i]
  else:
    cnt+=A[i]
    B[i]=B[i]-A[i]
    A[i]=0
    if B[i]>A[i+1]:
      cnt+=A[i+1]
      A[i+1]=0
      B[i]=B[i]-A[i]
    else:
      cnt+=B[i]
      A[i+1]=A[i+1]-B[i]
      B[i]=0
    
print(cnt)

Measured memory_bytes: 82148
#include<iostream>
using namespace std;
long gcd(long a,long b){
  if(b == 0){
    return a;
  }else{
    return gcd(b, a%b);
  }
}

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

  long ans = A[0];
  for(i=1;i<n;i++){
    ans = gcd(ans, A[i]);
  }
  cout << ans;
}

Measured memory_bytes: 1024
object Main extends App {
  val scanner = new java.util.Scanner(System.in)

  val n = scanner.nextInt()
  val cards = (1 to n).map { _ =>
    (scanner.next(), scanner.next())
  }

  val outputs = cards.foldLeft((0, 0)) { (point, card) =>
    val (taroP, hanakoP) = point
    val (taro, hanako) = card

    if(taro == hanako) {
      (taroP + 1, hanakoP + 1)
    } else if(taro > hanako) {
      (taroP + 3, hanakoP)
    } else {
      (taroP, hanakoP + 3)
    }
  }

  println(s"${outputs._1} ${outputs._2}")
}

Measured memory_bytes: 50388
#include<stdio.h>
void DFS();
void search(int);
int n,data[100][100],flag[100],k,x[100],y[100];
int main(){
    int k,v,i,j,u;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        for(j=0;j<n;j++){
            data[i][j]=0;
        }
    }
    for(i=0;i<n;i++){
        scanf("%d %d",&u,&k);
        u=u-1;
        for(j=0;j<k;j++){
            scanf("%d",&v);
            v=v-1;
            data[u][v]=1;
        }
    }
    DFS();
}
void DFS(){
    int i;
    k=0;
    for(i=0;i<n;i++){
        flag[i]=0;
    }
    for(i=0;i<n;i++){
        if(flag[i]==0)search(i);
    }
    for(i=0;i<n;i++){
        printf("%d %d %d\n",i+1,x[i],y[i]);
    }
}
void search(int i){
    int j;
    flag[i]=1;
    x[i]=++k;
    for(j=0;j<n;j++){
        if(data[i][j]==0)continue;
        if(flag[j]==0)search(j);
    }
    flag[i]=2;
    y[i]=++k;
}


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

using namespace std;

#define ll long long 
#define Coming ios_base :: sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"

int main()
{
	ll r, d, x2;
	
	cin >> r >> d >> x2;
	
	for(int i = 1; i <= 10; i++)
	{
		int ans = (r*x2) - d;
		cout << ans << endl;
		x2 = ans;
	}
	
	
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
using namespace std;
int main()
{
	int n,i,j,c,max_c;
	while(scanf("%d",&n),n)
	{
		const int OFFSET = 256,MAX_I=OFFSET,MAX_J=OFFSET*3;
		char a[MAX_I][MAX_J] = {0};
		for(i=0;i<n;++i)
			scanf("%s",&a[i][OFFSET]);
		max_c = c =0;
		for(j=OFFSET;j<MAX_J;++j)
			for(c=0,i=0;i<MAX_I;++i)
				(a[i][j]=='1') ? max_c=max(++c,max_c): c=0;
		for(i=0;i<MAX_I;++i)
			for(c=0,j=OFFSET;j<MAX_J;++j)
				(a[i][j]=='1') ? max_c=max(++c,max_c): c=0;
		for(j=0; j<MAX_J ; ++j)
			for(c=0,i=0; i<MAX_I; ++i)
				if(i+j<=MAX_J)
					(a[i][i+j]=='1') ? max_c=max(++c,max_c): c=0;
		for(j=0; j<MAX_J; ++j)
			for(c=0,i=0;i<MAX_I; ++i)
				if( j-i>=0)
					(a[i][j-i]=='1') ? max_c=max(++c,max_c): c=0;
		printf("%d\n",max_c);
	}
	return 0;
}

Measured memory_bytes: 964
n = int(input())
A = list(map(int, input().split()))

plus_ans = 0
minus_ans = 0
sum = 0

for i in range(len(A)):
    sum += A[i]
    if i % 2 == 0:
        if sum <= 0:
            plus_ans += abs(sum) + 1
            sum = 1
    else:
        if sum >= 0:
            plus_ans += abs(sum) + 1
            sum = -1

sum = 0
for i in range(len(A)):
    sum += A[i]
    if i % 2 == 0:
        if sum >= 0:
            minus_ans += abs(sum) + 1
            sum = -1
    else:
        if sum <= 0:
            minus_ans += abs(sum) + 1
            sum = 1

print(min(plus_ans, minus_ans))


Measured memory_bytes: 85552
#include<iostream>
#include<algorithm>
#include<vector>
#include<stdio.h>
#include<cstring>
#include<math.h>
#include<map>
#include<bitset>
#include<iomanip>
#include<queue>
using namespace std;

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

int H, A;

int main() {
  cin >> H >> A;
  int ans;
  ans = (H - 1) / A + 1;
  cout << ans << endl;
  return 0;
}

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

int main() {
  int k,n;
  cin >> k >> n;
  
  //入力値を配列に格納
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  
  //円の始点を跨ぐ地点を追加して１直線上で考える
  a.push_back(a[0]+k);

  //lに最も長い辺を代入する。
  int l = 0;
  rep(i,n) {
    l = max(l, a[i+1]-a[i]);
  }
  int ans = k - l;//外周から最も長い辺の値を引いた値が答えになる。
  cout << ans << endl;
}

Measured memory_bytes: 1792
#include<iostream>
#include <algorithm>
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long int llint;
using namespace std;


int main() {
	string n;
	cin >> n;
	if(n=="ABC"){
    	cout << "ARC";
    }else{
      cout << "ABC";   
    }
    return 0;
}

Measured memory_bytes: 3604
/*..........AAKASH GOYAL............*/
/*............DAIICT................*/
 
#pragma GCC optimize("O3", "unroll-loops")
#pragma GCC target("avx2")
#include <bits/stdc++.h>
using namespace std;
 

#define    int                   long long int 
#define    f(i,j,n)                 for(int i = j; i <= n; i++)
#define    r(i,n,j)                 for(int i = n; i >= j; i--)
#define    mod                      1110111110111
#define    speed                    ios_base::sync_with_stdio(false);
#define    upp                      cin.tie(NULL);
#define    pb                       push_back
#define    mp                       make_pair
#define    T                        int tt; cin >> tt; while(tt--)
#define    ff                       first
#define    ss                       second
#define    all(container)           container.begin() , container.end()
#define    sz(container)            (int)container.size()
#define    pii                      pair <int , int>
#define    pll                      pair <long long int , long long int>
#define    ppl                      pair <long long int , pll>              //pair of ll and pair ll 
#define    sp(x)                    setprecision(x)
 

int32_t main()
{
    speed upp
    int n,k;
    cin>>n;
    int a[n+1][3],dp[n+1][3];
    f(i,1,n)
        f(j,0,2)
            cin>>a[i][j];
    dp[0][0]=dp[0][1]=dp[0][2]=0;
    f(i,1,n)
    {
        f(j,0,2)
        {
            dp[i][j]=-999999999999;
            f(k,0,2)
            {
                if(j!=k)
                    dp[i][j]=max(dp[i][j],dp[i-1][k]+a[i][j]);
            }
            
        }
    }
    
    cout<<max({dp[n][0],dp[n][1],dp[n][2]});
}

Measured memory_bytes: 4992
#include <stdio.h>
int parent(int);
int left(int);
int right(int);
 
int main(){
  int i,a,A[251];
  scanf("%d",&a);
  for(i=1; i<=a; i++){
    scanf("%d",&A[i]);
}
  for(i=1; i<=a; i++){
    printf("node %d: key = %d, ",i,A[i]);
    if(parent(i) >= 1){printf("parent key = %d, ",A[parent(i)]);}
    if(left(i) <= a){printf("left key = %d, ",A[left(i)]);}
    if(right(i) <= a){printf("right key = %d, ",A[right(i)]);}
    printf("\n");
  }
   return 0;
}
int parent(int p){
  return p/2;
}
int left(int l){
  return l*2;
}
int right(int r){
  return (r*2)+1;
}

Measured memory_bytes: 600
/* 
chirag11032000
Chirag Thakur
*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

using ll = long long;
using db = double;
using pii = pair < int, int >;
using pll = pair < ll, ll >;

template < typename T > using OrderedSet = tree < T, null_type, less < T >, rb_tree_tag, tree_order_statistics_node_update >;
template < typename T > using MinPriorityQueue = priority_queue < T, vector < T >, greater < T > >;

#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template < typename Arg1 >
void __f(const char* name, Arg1&& arg1) {
	cerr << name << " : " << arg1 << std :: endl;
}
template < typename Arg1, typename... Args >
void __f(const char* names, Arg1&& arg1, Args&&... args) {
	const char* comma = strchr(names + 1, ',');
	cerr.write(names, comma - names) << " : " << arg1 << " | ";
	__f(comma + 1, args...);
}
#else
#define trace(...)
#endif

#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

const db PI = acos(-1);
const ll LINF = LLONG_MAX;
const int INF = INT_MAX, MOD = 1e9 + 7, N = 1e5 + 10;

void testCase();

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	testCase();
	cerr << "Time taken: " << int((clock() * 1000.) / CLOCKS_PER_SEC) << "ms\n";
	return 0;
}

void testCase() {
	int n;
	cin >> n;
	set < pii > edges;
	int en = n - (n & 1);
	for (int i = 1; i < n / 2; ++i) {
		vector < int > a = {i, en - i + 1};
		vector < int > b = {i + 1, en - (i + 1) + 1};
		for (auto &u: a) {
			for (auto &v: b) {
				edges.insert({u, v});
			}
		}
	}
	if (en == n - 1) {
		int mid = n / 2;
		vector < int > a = {mid, mid + 1};
		vector < int > b = {n};
		for (auto &u: a) {
			for (auto &v: b) {
				edges.insert({u, v});
			}
		}
		a = {1, en};
		b = {n};
		for (auto &u: a) {
			for (auto &v: b) {
				edges.insert({u, v});
			}
		}
	} else {
		vector < int > a = {1, en};
		vector < int > b = {n / 2, en - (n / 2) + 1};
		for (auto &u: a) {
			for (auto &v: b) {
				edges.insert({u, v});
			}
		}
	}
	cout << edges.size() << "\n";
	for (auto &el: edges) {
		cout << el.first << " " << el.second << "\n";
	}
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <ctype.h>
#include <limits.h>
#define EPS 1e-10
#define sq(n) ((n)*(n))
#define rep(i,n) for(i=0;i<n;i++)
#define rev(i,n) for(i=n-1;i>=0;i--)
#define sort(a,n) qsort(a,n,sizeof(TYPE),cmp)
#define sort_r(a,n) qsort(a,n,sizeof(TYPE),cmp_r);
#define chsort(s,n) qsort(s,n,sizeof(char),cmp)
#define chsort_r(s,n) qsort(s,n,sizeof(char),char_cmp_r);
#define TYPE int
#define MEMSET(a) memset(a,0,sizeof(a))
long long mod=(long long)1e09+7;
int inf=1<<29;
long long llinf=1ll<<60;

int in(void){
    int i;scanf("%d",&i);
    return i;
}
long long llin(void){
    long long i;scanf("%lld",&i);
    return i;
}
double din(void){
    double i;scanf("%lf",&i);
    return i;
}
void chin(char s[]){
    scanf("%s",s);
}
void print(int a){
    printf("%d\n",a);
}
void llprint(long long a){
    printf("%lld\n",a);
}
void dprint(double a){
    printf("%.10f\n",a);
}
void print2(int a,int b){
    printf("%d %d\n",a,b);
}
long long max(long long a,long long b){
    return a>b?a:b;
}
long long min(long long a,long long b){
    return a<b?a:b;
}
int cmp(const void *a,const void *b){
    return *(TYPE *)a-*(TYPE *)b;
}
int cmp_r(const void *a,const void *b){
    return *(TYPE *)b-*(TYPE *)a;
}
int char_cmp(const void *a,const void *b){
    return strcmp((char *)a,(char *)b);
}
int char_cmp_r(const void *a,const void *b){
    return strcmp((char *)b,(char *)a);
}
void swap(int *a,int *b){
    int t=*a;
    *a=*b;
    *b=t;
}
long long gcd(long long x,long long y){
    return x%y?gcd(y,x%y):y;
}
long long lcm(long long x,long long y){
    return x/gcd(x,y)*y;
}

// write codes below this
// when you use 'sort',
// make sure TYPE macro is correct

int main(void){
    int n,t[16][17],i,j,k,c,dp[1<<16];
    while(1){
        n=in();
        if(!n)break;
        rep(i,n){
            rep(j,n+1){
                t[i][j]=in();
            }
        }
        rep(i,1<<n)dp[i]=inf;
        dp[0]=0;
        rep(k,1<<n){
            rep(i,n){
                c=t[i][0];
                rep(j,n){
                    if(k&1<<j)c=min(c,t[i][j+1]);
                }
                dp[k|1<<i]=min(dp[k|1<<i],dp[k]+c);
            }
        }
        print(dp[(1<<n)-1]);
    }
    return 0;
}


Measured memory_bytes: 2084
H, W = gets.split.map(&:to_i)
result = Array.new(H){Array.new(W,0)}
H.times do |h|
  s = gets
  s.each_char.with_index do |c, w|
    if c == "#"
      if h != 0
        result[h-1][w-1] += 1 if w != 0
        result[h-1][w] += 1
        result[h-1][w+1] += 1 if w != W-1
      end
      result[h][w-1] += 1 if w != 0
      result[h][w] = -10
      result[h][w+1] += 1 if w != W-1
      if h != H-1
        result[h+1][w-1] += 1 if w != 0
        result[h+1][w] += 1
        result[h+1][w+1] += 1 if w != W-1
      end
    end
  end
end
result.each do |row|
  row.each do |cell|
    print(cell < 0 ? "#" : cell)
  end
  print("\n")
end


Measured memory_bytes: 1788
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

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

		int n = Integer.parseInt(br.readLine());

		adjmatrix = new int[n+1][n+1];
//		issearched = new boolean[n+1];
		d = new int[n+1];
		f = new int[n+1];

		for (int i=0; i < n; i++) {
			String[] list = br.readLine().split(" ");
			int u = Integer.parseInt(list[0]);
			int k = Integer.parseInt(list[1]);
			adjmatrix[u][0] = u;
			for (int j=0; j < k; j++) {
				int vi = Integer.parseInt(list[j+2]);
				adjmatrix[u][vi] = 1;
			}
		}
//		search(adjmatrix[1]);
//		System.out.println(Arrays.toString(adjmatrix[2]));
		for (int i=1; i < n; i++) {
			search(adjmatrix[i]);
		}
		for (int i=1; i <= n; i++) {
			System.out.println(i + " " + d[i] + " " + f[i]);
		}
	}

	static int time = 0;

	static int[] d;

	static int[] f;

	static int[][] adjmatrix;

//	static boolean[] issearched;

	public static void search(int[] adjlist) {
		int u = adjlist[0];
//		issearched[u] = true;
		if (d[u] != 0) return;

		time++;
		d[u] = time;

		int n = adjlist.length - 1;
		for (int i=1; i <= n; i++) {
			if (adjlist[i] == 1) {
				search(adjmatrix[i]);
			}
		}

		time++;
		f[u] = time;
	}
}

Measured memory_bytes: 24564
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;

int n;

// arr[y][x]
int arr[260][260];

/*
0: ツ湘」
1: ツ債カ
2: ツ債カツ湘」
3: ツ右ツ湘」
*/
int dp[4][260][260];


int main() {
	for(;;) {
		scanf(" %d", &n);
		if(!n) break;
		for(int y = 0; y < n; y++) {
			char line[260];
			scanf(" %s", line);
			for(int x = 0; x < n; x++) {
				arr[y][x] = line[x] - '0';
			}
		}
		memset(dp, 0, sizeof dp);
		for(int y = 0; y < n; y++) {
			for(int x = 0; x < n; x++) {
				if(arr[y][x] == 1) {
					for(int i = 0; i < 4; i++) {
						dp[i][y][x] = 1;
					}
					if(y >= 1) {
						dp[0][y][x] += dp[0][y - 1][x];
					}
					if(x >= 1) {
						dp[1][y][x] += dp[1][y][x - 1];
					}
					if(x >= 1 && y >= 1) {
						dp[2][y][x] += dp[2][y - 1][x - 1];
					}
					if(y >= 1 && x < n - 1) {
						dp[3][y][x] += dp[3][y - 1][x + 1];
					}
				}
			}
		}
		int maxv = 0;
		for(int y = 0; y < n; y++) {
			for(int x = 0; x < n; x++) {
				for(int k = 0; k < 4; k++) {
					maxv = max(maxv, dp[k][y][x]);
				}
			}
		}
		printf("%d\n", maxv);
	}
	return 0;
}

Measured memory_bytes: 0
N = int(input())
A = list(map(int,input().split()))

s = ans1 = 0
for i,a in enumerate(A):
    s += a
    if i%2:
        if s <= 1:
            ans1 += 1-s
            s = 1
    else:
        if s >= -1:
            ans1 += s+1
            s = -1

s = ans2 = 0
for i,a in enumerate(A):
    s += a
    if i%2==0:
        if s <= 1:
            ans2 += 1-s
            s = 1
    else:
        if s >= -1:
            ans2 += s+1
            s = -1

print(min(ans1,ans2))

Measured memory_bytes: 14468
#include "bits/stdc++.h"
#define DEBUG(x) cout<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cout<<#v<<":";for(int i=0;i<v.size();i++) cout<<" "<<v[i]; cout<<endl
#define vi vector<int>
#define vl vector<ll>
#define vvi vector<vector<int>>
#define vvl vector<vector<ll>>
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define MOD 1000000007
#define mod 1000000009
#define pi 3.14159265358979323846
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
typedef long long ll;
typedef unsigned long long ull;
const ull INF = 1e18;
using namespace std;

int main(){
    ull num;
    cin>>num;
    string s="";
    do{
        num--;
        s+=(char)('a'+(num%26));
        num/=26;
    }while(num>0);
    reverse(s.begin(), s.end());
    cout<<s<<endl;
    return 0;
}


Measured memory_bytes: 3628
/*Whose woods these are I think I know.
His house is in the village though;
He will not see me stopping here
To watch his woods fill up with snow.

My little horse must think it queer
To stop without a farmhouse near
Between the woods and frozen lake
The darkest evening of the year.

He gives his harness bells a shake
To ask if there is some mistake.
The only other sound’s the sweep
Of easy wind and downy flake.

The woods are lovely, dark and deep,
But I have promises to keep,
And miles to go before I sleep,
And miles to go before I sleep.*/

#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define pb push_back
#define fi first
#define se second
#define MOD 1000000007
const int maxn= 100010;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n=0;string x;
    cin>>n;
    set<string> s;
    for(int i=0;i<n;++i)
    {
        cin>>x;
        s.insert(x);
    }
    cout<<s.size()<<endl;
}

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

#define ll long long
#define all(v) v.begin(), v.end()

int main() {
	
	int n;
	cin >> n;
	string s;
	cin >> s;
	if(n % 2 == 1) {
		cout << "No\n";
		return 0;
	}
	
	int j = n/2;
	for(int i=0; i<n/2; i++) {
		if(s[i]!=s[j+i]) {
			cout << "No\n";
			return 0;
		}
	}
	cout << "Yes\n";
	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 d = sc.nextInt();
		int t = sc.nextInt();
		int s = sc.nextInt();
		System.out.println(t*s >= d ? "Yes":"No");
		sc.close();
	}
}

Measured memory_bytes: 35780
using System.Collections.Generic;
using System.Linq;
using System;

public class Hello
{
    public static void Main()
    {
        var hs = new HashSet<string>();
        var n = int.Parse(Console.ReadLine().Trim());
        for (int i = 0; i < n; i++)
        {
            var s = Console.ReadLine().Trim();
            hs.Add(s);
        }
        Console.WriteLine(hs.Count());
    }
}


Measured memory_bytes: 43260
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>

using namespace std;
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(),(x).end()
// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return;std::cout << e << std::endl;}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class X> void DEBUG(X d, T e){if(DEBUG_OUT == false)return;std::cout <<d<<" ";DEBUG(e);};
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

  // vector<vector<vector<int> > > DP =  vector<vector<vector<int> > >(100001,vector<vector<int> >(2,vector<int>(2,0)));
void solve(void)
{
   int N;
   cin>>N;
   vector<int> vec(N);
   map<int,int> mp;
   for (int i = 0; i < N; i++)
   {
     int A;
     cin>>A;
     vec[i] = A;
     mp[A]++;
    //  auto itr = mp.find(A);
    //  if(itr == mp.end())
    //  {
    //    mp[A] = 1;
    //  }
    //  else
    //  {
    //    itr->second++;
    //  }
   }
   auto itr = mp.begin();
   int SUM = 0;
   for (int i = 0; i < mp.size(); i++)
   {
     int X = itr->second;
     SUM += (X)*(X-1)/2;
     itr++;
   }
  //  DEBUG(SUM);
   
   
   for (int i = 0; i < N; i++)
   {
     int X = vec[i];
     int K = mp[X];
     K--;
     cout<<SUM + (K)*(K-1)/2 - (K+1)*K/2<<endl;
   }
   
   
  return;
}

int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();

  return 0;
}


Measured memory_bytes: 11136
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
using namespace std;
typedef long long ll;
const int INF = 1<<30;
const int MOD = 1e9 + 7;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    cout << n * 32 << endl;
    return 0;
}




Measured memory_bytes: 3140
#pragma target("avx")
#include<bits/stdc++.h>
using ll = int_fast64_t;
using P = std::pair<ll,ll>;
using V = std::vector<ll>;
template<typename T> using pq = std::priority_queue<T>;
template<typename T> using rpq = std::priority_queue<T, std::vector<T>, std::greater<T>>;

#define rep(i,b,e) for(ll i=b; i<e; i++)
#define be(vec) vec.begin(),vec.end()
#define print(vec) printf("[ ");for(auto &i:vec)printf("%ld ",i);puts("]");
#define scan(vec) for(auto &i:vec)scanf("%ld",&i)
#define fi first
#define se second

const int MOD = 1e9+7;
const ll INF = 1e18;
int dx[] = {0, 1, 0, -1, 1, 1, -1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

ll digisum(ll x){
	ll ret = 0;
	while(x){
		ret += x%10;
		x /= 10;
	}
	return ret;
}

int main(){
	ll n;
	scanf("%ld", &n);
	ll ans = 1e18;
	rep(i, 1, n){
		ans = std::min(ans, digisum(i) + digisum(n-i));
	}
	printf("%ld\n", ans);
	return 0;
}


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

int main()
{
    string field;
    map<string, int> mp;
    string frequently_word;
    string max_num_word;
    int freq_count = 0;
    int max_letter_num = 0;

    while (cin >> field)
    {
        /* store the word which has the maximum number */
        if(field.size() > max_letter_num)
        {
            max_letter_num = field.size();
            max_num_word = field;
        }
        /* search the word from map */
        if(mp.count(field)) 
        {
            mp[field]++; 
        }
        else
        {
            mp[field] = 1;
        }
 
    }
    /* get the most frequently word */
    for(auto itr = mp.begin(); itr != mp.end(); ++itr)
    {
        if(itr->second > freq_count)
        {
            freq_count = itr->second;
            frequently_word = itr->first;
        }
    }
    cout << frequently_word << " " << max_num_word << endl;

    return 0;
}

Measured memory_bytes: 3140
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const ll maxn = 1e6 + 10;
const double pi = acos(-1.0);
 
int main(void)
{
	ll n,sum=0;
	scanf("%lld",&n);
	n++;
	for(ll i=1;i<n;i++)
	{
		if(i%3==0||i%5==0)continue;
		else sum+=i;
	}
	printf("%lld",sum);
	return 0;
} 

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

using namespace std;

#define int long long
#define endl '\n'
#define maxn 100010
const int MOD = 1000000007;

void solve() {
    int n;
    cin >> n;

    vector<pair<int, int>> v(n);
    for (int i = 0; i < n; i++) {
        cin >> v[i].first >> v[i].second;
    }
    int del = 0, ans = 0;
    for (int i = n - 1; i >= 0; i--) {
        v[i].first += del;
        int need = v[i].second - v[i].first % v[i].second;
        need %= v[i].second;
        ans += need;
        del += need;
    }
    cout << ans << endl;
}

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

    int t = 1;
//    cin >> t;

    while (t--)
        solve();
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <utility>
#include <algorithm>
#include <cmath>
#include <climits>

using namespace std;

typedef long long ll;

int main() {
    map<ll,ll> m;
    int n; cin >> n;
    ll *a = new ll[n];
    ll *cnt = new ll[n+1];
    for (int i = 0; i <= n; i++)
        cnt[i] = 0;

    ll ans = 0;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        cnt[a[i]]++;
    }


    for (ll k = 1; k <= n; k++) {
        ll x = cnt[k];
        if (x > 0) {
            ans += x*(x-1)/2;
        }
    }

    for (ll k = 0; k < n; k++) {
        ll x = cnt[a[k]];
        cout << ans - x*(x-1)/2 + (x-1)*(x-2)/2 << endl;
    }

    return 0;
}

Measured memory_bytes: 5760
#include <iostream>
#include <cstdio>
#include <cstring>
#include <queue>
#include <map>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;

int n, k, ans = 1;
int main() {
	cin >> n >> k;
	for (int i = 1; i <= n; i++) {
		ans += min(ans, k);
	}
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
class Solve{
    string s;
    public Solve(){}
    public static int Main(){
        new Solve().Calc();
        return 0;
    }
    void Calc(){
        getinput();
        int state;
        int count = 0;
        if(s[0] == 'B'){
            state = 1;
        }
        else{
            state = 0;
        }
        for(int i=1;i<s.Length;i++){
            if((state == 0 && s[i] == 'B') || (state == 1 && s[i] != 'B')){
                count++;
            }
            if(s[i] == 'B'){
                state = 1;
            }
            else{
                state = 0;
            }
        }
        Console.WriteLine(count);
    }
    void getinput(){
        s = Console.ReadLine();
    }    
}

Measured memory_bytes: 3032
#include <iostream>
using namespace std;
string str[7];

void distribution(double h) {
  if(h < 165.0) {
    str[1] += "*";
    return;
  }
  if(h < 170.0) {
    str[2] += "*";
    return;
  }
  if(h < 175.0) {
    str[3] += "*";
    return;
  }
  if(h < 180.0) {
    str[4] += "*";
    return;
  }
  if(h < 185.0) {
    str[5] += "*";
    return;
  }
  else {
    str[6] += "*";
    return;
  }
}

int main() {
  int n;
  double h;
  cin >> n;
  for(int i=0;i<n;i++) {
    cin >> h;
    distribution(h);
  }
  for(int i=1;i<7;i++) {
    cout << i << ":" << str[i] << endl;
  }
}

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

#define int long long int
#define ff first
#define ss second
#define pb push_back


int bexp(int a, int b)
{
	int res = 1;

	while (b)
	{
		if (b & 1) res = (res * a);

		a = (a * a); 
		b >>= 1;
	}
	return res;
}

int gcd(int a, int b)
{
	if (b == 0)
		return a;
	return gcd(b, a % b);
}

#define N 500010
#define MOD 1000000007

int32_t main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.precision(10);

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

	for (int i = 1; i < 10010; ++i)
	{
		if (floor(i * 0.08) == a && floor(i * 0.1) == b)
		{
			cout << i << endl;
			return 0;
		}
	}

	cout << -1;
	return 0;
}

Measured memory_bytes: 256
import sys


def inp(t): return t(sys.stdin.readline().strip())


def inpm(t): return map(t, sys.stdin.readline().split())


def inpl(t): return list(map(t, sys.stdin.readline().split()))


n = inp(int)
a = [inp(str), inp(str)]
dp = [0] * n

if a[0][0] == a[1][0]:
    dp[0] = 3
    i = 1
else:
    dp[1] = 6
    i = 2

while i < n:
    if a[0][i - 1] == a[1][i - 1]:
        if a[0][i] == a[1][i]:
            dp[i] = dp[i - 1] * 2
            i += 1
        else:
            dp[i + 1] = dp[i - 1] * 2
            i += 2
    else:
        if a[0][i] == a[1][i]:
            dp[i] = dp[i - 1]
            i += 1
        else:
            dp[i + 1] = dp[i - 1] * 3
            i += 2

print(dp[n - 1] % 1000000007)


Measured memory_bytes: 3064
#import math
#import itertools
#import numpy as np
#from collections import deque
# sys.setrecursionlimit(10 ** 6)
#MOD = 10 ** 9 + 7
#INF = 10 ** 9
#PI = 3.14159265358979323846

INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))

def do():
    temp=0
    maxz=1
    n=INT()
    for i in range(n):
        a,b=INTM()
        if a==b:
            temp+=1
            maxz=max(maxz,temp)
        else:
            temp=0

    if maxz>=3:
        print('Yes')
    else:
        print('No')
if __name__=='__main__':
    do()

Measured memory_bytes: 9228