akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Text;
using System.Linq;
using static System.Math;

class Program{
    static void Main(){
        int n = int.Parse(Console.ReadLine());
        long[] ans = {61,230,865,3247,12185,45719,171531,643550,2414454,9058467,33985227,127504505,478366600,794717734,733354121,261943303,776803305,580025381,51688048,44657419,737209731,604119499,159693437,858533109,639056669,549054109,996291083,531294469,23314687,783022045,855462856,649970414,68697295,409213624,604356692,88638656,978442997,534833116,763737161,785892908,123883652,639213333,181836645,998121103,124885216,501575626,39816123,113468411,799008836,775465589,256852905,664630886,971550783,751629411,51018086,702530485,725438992,696683714,792638194,221791721,149602322,414054379,986519078,981760191,305799096,515140586,406959393,975058685,245601370,324759692,673385295,191483611,570246669,427196161,781042769,569725155,842176273,25328739,847501730,206282374,353770801,323137024,371653459,940737264,123820509,915711339,847205021,252858375,718889563,866398347,738390145,133009077,333099663,170591295,329869205,616680192,597534442,388130742};
        Console.WriteLine(ans[n - 3]);
    }
}


Measured memory_bytes: 11092
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define mod (int)1000000007
#define pb push_back
#define endl "\n"
#define all(a) a.begin(),a.end()
#define mx(a) *max_element(all(a))
#define mn(a) *min_element(all(a))
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repe(i,a,b) for(int i=a;i<=b;i++)
#define repo(i,b) for(int i=(int)0;i<b;i++)
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)

signed solve(){
	int a;
	cin>>a;
	cout<<a+a*a+a*a*a<<endl;
	return 0;
}

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

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

int main() {
    int A,B,K;
    cin>>A>>B>>K;
    int c=1;
    for(int i=0;;i++){
        if(A%(A-i)==0&&B%(A-i)==0){
            if(c==K){
                cout<<A-i<<endl;
                return 0;
            }
            c++;
        }
    }
return 0;}
/*
g++ code.cpp
./a.out
*/

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
#include <vector>
using namespace std;
 
int main(){
    int N,K;
    cin>>N>>K;
    vector<int> a(N);
    for(int i=0;i<N;i++)cin>>a.at(i);

    sort(a.begin(),a.end());
    reverse(a.begin(),a.end());
    int L=0;
    for(int i=0;i<K;i++){
        L+=a.at(i);
    }
    cout<<L<<endl;
}

Measured memory_bytes: 256
// In the name of God

#include <iostream>
#include <algorithm>
#include <fstream>
#include <vector>
#include <deque>
#include <assert.h>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <stdio.h>
#include <string.h>
#include <utility>
#include <math.h>
#include <bitset>
#include <iomanip>

using namespace std;

const int N = (int) 505, mod = (int) 0;
string mat[N];
int mark[N];
int32_t main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int n;
    cin >> n;
    int flag = 1;
    for (int j = 0; j < n; ++j) {
        cin >> mat[j];
        for (int i = 0; i < n; ++i)
            if (mat[j][i] == '#') {
                flag = 0;
                mark[i] = 1;
            }
    }
    if (flag) {
        cout << -1 << endl;
        return 0;
    }
    int res = 1e9, z = n;
    for (int j = 0; j < n; ++j) {
        int cnt = 0;
        for (int i = 0; i < n; ++i)
            cnt += (mat[i][j] != '#');
        z -= (cnt == 0);
    }
    for (int j = 0; j < n; ++j) {
        int cnt = 0;
        for (int i = 0; i < n; ++i)
            cnt += (mat[j][i] != '#');
        res = min(res, cnt + (!mark[j]));
    }
    cout << res + z << '\n';
}



Measured memory_bytes: 512
#include<iostream>
#include<string>
using namespace std;
int main() {
	int a[11], b[11], kazu;
	string m;
	kazu = 0;
	while (cin >> m) {
		for (int i = 1; i <= 10; i++) {
			a[i] = (int)m[i - 1] - '0';
		}
		for (int z = 9; z >= 1; z--) {
			for (int i = 1; i <= z; i++) {
				b[i] = a[i + 1] + a[i];
				b[i] = b[i] % 10;
			}
			for (int i = 1; i <= z; i++) {
				a[i] = b[i];
			}
		}
		cout << a[1] << endl;
	}
}


Measured memory_bytes: 3204
#include <stdio.h> 

int main() {
  int x,i,n;

  scanf("%d",&n);
  
  for(i=1; i<=n; i++) {
    x = i;
    
    if(x %3 == 0) {
      printf(" %d",i);
    } else if(x % 10 == 3) {
      printf(" %d",i);
    } else { 
      while(x != 0) {
	x /=10;
	if(x % 10 == 3) {
	  printf(" %d",i);
	  break;
	}
      }
    }
    
  }
  printf("\n");
  return 0;
}



Measured memory_bytes: 2104
# define _CRT_SECURE_NO_WARNINGS 1
# define _USE_MATH_DEFINES
# include <iostream>
# include <numeric>
# include <string>
# include <bitset>
# include <vector>
# include <algorithm>
# include <cstdlib>
# include <cstdio>
# include <cstring>
# include <cstdlib>
# include <iomanip>
# include <queue>
# include <sstream>
# include <unordered_set>
# include <unordered_map>
# include <climits>
# include <complex>
# include <cmath>
# include <list>
# include <functional>
# include <string>
# include <ctime>
# include <set>
# include <forward_list>
# include <map>
# include <stack>
using namespace std;
# define INF ((int)(1<<25))
# define REP(i,n) for(int i=0;i<(int)n;i++)
# define FOR(i,n) REP(i,n)
# define FORI(i,k,n) for(int i=k;i<(int)n;i++)
# define TORAD 2.0*M_PI/360.0
# define INT(x) int x;cin>>x;
# define STR(x) string x;cin>>x;
# define ALL(x) begin(x),end(x)
# define RALL(x) (x).rbegin(),(x).rend()
# define DEBUG(x) cout<<#x<<":"<<x<<endl;
# define EPS 1e-12
#ifdef _MSC_VER
#include <intrin.h>
#define __builtin_popcount __popcnt
#endif
typedef long long lint;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<int> vi;
typedef vector<lint> vl;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
const int dx[4] = { 0,1,0,-1 }, dy[4] = { -1,0,1,0 };
template<class T> void debug(T a) { for (auto i : a)cout << i << endl; }

vector<vi> seg;
int n;
void init(int y, int x)
{
	n = 1;
	while (n < x)n *= 2;

	vi a(2*n-1, INT_MAX);
	FOR(i, y)seg.push_back(a);
}

void update(int y, int k, int a)
{
	k += n - 1;
	seg[y][k] = a;
	while (k > 0)
	{
		k = (k - 1) / 2;
		seg[y][k] = min(seg[y][k * 2 + 1], seg[y][k * 2 + 2]);
	}
}

int getMin(int y, int a, int b, int k, int l, int r)
{
	if (r <= a || b <= l)return INT_MAX;
	if (a <= l&&r <= b)return seg[y][k];
	return min(getMin(y, a, b, k * 2 + 1, l, (l + r) / 2), getMin(y, a, b, k * 2 + 2, (l + r) / 2, r));
}
int main()
{
	while (true)
	{
		seg.clear();
		int y, x, q;
		bool swp = false;
		cin >> y >> x >> q;
		if (!y)break;
		if (y > x)swp = true;

		if (swp)init(x, y);
		else init(y, x);
		FOR(i, y)
		{
			FOR(j, x)
			{
				INT(v);
				if (swp)update(j,i,v);
				else update(i, j, v);
			}
		}
		FOR(i, q)
		{
			int r1, r2, c1, c2;
			cin >> r1 >> c1 >> r2 >> c2;
			int ans = INT_MAX;
			if (swp)
			{
				for (int j = c1; j <= c2; j++)
				{
					ans = min(ans, getMin(j, r1, r2 + 1, 0, 0, n));
				}
			}
			else
			{
				for (int j = r1; j <= r2; j++)
				{
					ans = min(ans, getMin(j, c1, c2 + 1, 0, 0, n));
				}
			}
			cout << ans << endl;
		}
	}
}

Measured memory_bytes: 19248
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

#define FOR(i,k,n) for (int (i)=(k); (i)<(n); ++(i))
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fst first
#define snd second
#define all(v) begin(v), end(v)
#define debug(x) cerr<< #x <<": "<<x<<endl
#define debug2(x,y) cerr<< #x <<": "<< x <<", "<< #y <<": "<< y <<endl

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ll> vll;
typedef vector<vector<ll> > vvll;
typedef vector<char> vc;
typedef vector<vector<char> > vvc;
typedef vector<double> vd;
typedef vector<vector<double> > vvd;
template<class T> using vv=vector<vector< T > >;
typedef deque<int> di;
typedef deque<deque<int> > ddi;
typedef deque<bool> db;
typedef deque<deque<bool> > ddb;

// offset は新しく生成する部分を狙って加算する
vvi solve_body(int len, int offset) {
  vvi ret(len, vi(len-1));
  if (len == 4) {
    ret[0] = {2, 3, 4};
    ret[1] = {3, 1, 4};
    ret[2] = {4, 2, 1};
    ret[3] = {1, 2, 3};
    rep (i, len) {
      rep (j, len-1) {
        ret[i][j] += offset;
      }
    }
    return ret;
  }
  if (len % 2 == 1) {
    rep (i, len) {
      rep (j, len-1) {
        ret[i][j] = (i+j+1) % len + 1;
        ret[i][j] += offset;
      }
    }
    return ret;
  }
  int le = len / 2;
  vvi lu = solve_body(le, offset);
  vvi rb = solve_body(le, offset + le);
  rep (i, le) {
    rep (j, le-1) {
      ret[i][j] = lu[i][j];
      ret[i+le][j+le-1] = rb[i][j];
    }
  }
  rep (i, le) {
    rep (j, le-1) {
      ret[i][j+le-1] = le + (i + j + 1) % le + 1;
      ret[i+le][j] = (i + j + 2) % le + 1;
      ret[i][j+le-1] += offset;
      ret[i+le][j] += offset;
    }
  }
  rep (i, le) {
    ret[i][len-2] = le + i + 1;
    ret[i+le][len-2] = (i + 1) % le + 1;
    ret[i][len-2] += offset;
    ret[i+le][len-2] += offset;
  }
  return ret;
}

vvi solve(vi &part) {
  int len = part.size();
  int offset = part[0];
  vvi ret = solve_body(len, offset);
  return ret;
}

int main() {
  int n;
  cin >> n;
  if (n == 2) {
    printf("-1\n");
    return 0;
  }
  vi orig(n);
  rep (i, n) {
    orig[i] = i;
  }

  vvi ans = solve(orig);

  rep (i, n) {
    rep (j, n-2) {
      printf("%d ", ans[i][j]);
    }
    printf("%d\n", ans[i][n-2]);
  }

  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define dhoom ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);  
typedef long long ll;
typedef long double ld;
const ll inf = 1e18;
const int nax = 2e6 + 7;
const ll mod = 1e9 + 7;
//ll tree[4 * nax];
//9uS-22RSwk7gQqh
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);
	ll lc = (a/g) * b;
	return lc;
}
vector< ll > a;
vector< ll > st;
int main()
{
	int n;
	cin >> n;
	for(int i = 0 ; i < n ; i++){
		ll x;
		cin >> x;
		st.push_back(x);
	}
	sort(st.begin(),st.end());
	for(int i = 0 ; i < (int)st.size() ; i++){
		if(st[i] == st[i+1]){
			a.push_back(st[i]);
			i++;
		}
	}
	if(a.size() < 2)
	{
		cout << 0 << endl;
		return 0;
	}
	cout << a[a.size() - 1 ] * a[a.size() - 2] << endl;
	return 0;
} 




Measured memory_bytes: 1908
A,B=map(int,input().split())
if A>=B:
    a=A-1
    if a>=B:
        print(A+a)
    else :
        print(A+B)
elif B>A:
    b=B-1
    if b>=A:
        print(b+B)
    else :
        print(B+A)


Measured memory_bytes: 2940
#include "bits/stdc++.h"
using namespace std;
int main(void)
{
	int a, b;
	cin >> a >> b;
	if (a%2==1 && b%2==1)
	{
		cout << "Yes" << "\n";
	}
	else 
	{
		cout << "No" << "\n";
	}
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <string>
#define N 21
#define T 7
using namespace std;
void Change(int);
void Rot_Left();
int stoi();
string s[N],t[T];

int main(){
  int a[2][6],coma,comb,d[2][6][2]={
    {{0,7},{7,0},{7,7},{7,14},{7,21},{14,7}},
    {{0,36},{7,29},{7,36},{7,43},{7,50},{14,36}}
  };
  while(1){
    cin>>s[0];
    if(s[0]=="0") break;
    for(int i=1;i<N;i++) cin>>s[i];
    for(int i=0;i<2;i++){
      for(int j=0;j<6;j++){
	for(int k=0;k<T;k++) t[k]=s[k+d[i][j][0]].substr(d[i][j][1],7);
	Change(j);
	a[i][j]=stoi();
      }
    }
    coma=comb=0;
    for(int i=0;i<6;i++){
      for(int j=0;j<6;j++){
	if(a[0][i]>a[1][j]) coma++;
	else if(a[0][i]<a[1][j]) comb++;
      }
    }
    if(coma>=comb) cout<<"HIGH"<<endl;
    else cout<<"LOW"<<endl;
  }
  return 0;
}

void Change(int x){
  for(int i=0;i<T;i++) reverse(t[i].begin(),t[i].end());
  if(x==1) Rot_Left();
  if(x==3)
    for(int i=0;i<3;i++) Rot_Left();
  if(x==5) swap(t[1],t[5]),swap(t[2],t[4]);
}

void Rot_Left(){
  string temp[T];
  for(int i=0;i<T;i++) temp[i]=t[i];
  for(int i=0;i<T;i++)
    for(int j=0;j<T;j++){
      temp[i][j]=t[j][T-i-1];
      if(temp[i][j]=='-') temp[i][j]='|';
      else if(temp[i][j]=='|') temp[i][j]='-';
    }
  for(int i=0;i<T;i++) t[i]=temp[i];
}

int stoi(){
  string data[9][T]={
    {"#######","#.....#","#...|.#","#.....#","#...|.#","#..-..#","#######"},
    {"#######","#..-..#","#...|.#","#..-..#","#.|...#","#..-..#","#######"},
    {"#######","#..-..#","#...|.#","#..-..#","#...|.#","#..-..#","#######"},
    {"#######","#.....#","#.|.|.#","#..-..#","#...|.#","#.....#","#######"},
    {"#######","#..-..#","#.|...#","#..-..#","#...|.#","#..-..#","#######"},
    {"#######","#..-..#","#.|...#","#..-..#","#.|.|.#","#..-..#","#######"},
    {"#######","#..-..#","#...|.#","#.....#","#...|.#","#.....#","#######"},
    {"#######","#..-..#","#.|.|.#","#..-..#","#.|.|.#","#..-..#","#######"},
    {"#######","#..-..#","#.|.|.#","#..-..#","#...|.#","#..-..#","#######"},
  };
  for(int i=0;i<9;i++){
    int flag=0;
    for(int j=0;j<T;j++)
      if(t[j]!=data[i][j]) flag=1;
    if(!flag) return i+1;
  }
}

Measured memory_bytes: 1200
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define int long long
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>>;



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

    int N,K;
    cin>>N>>K;
    map<int,int> m;
    int cou=0;
    rep(i,N){
        int x,y;
        cin>>x>>y;
        m[x]+=y;
    }
    for(auto p:m){
        cou+=p.second;
        if(cou>=K) {
            cout << p.first << endl;
            break;
        }
    }




}


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

int main() {
    int64_t N;
    cin >> N;
    int64_t a, b, i = 1;
    while(i * i <= N) {
        if (N % i == 0) {
            a = i;
            b = N / i;
        }
        i++;
    }
    
    cout << a + b - 2 << endl;
    return 0;
}


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

string N;
ll dp[1010101][2];

int main() {
    cin >> N;
    reverse(N.begin(), N.end());

    int n = N.size();
    rep(i, n+1) rep(d, 2) dp[i][d] = 1e12;
    dp[0][0] = 0;
    rep(i, n) rep(d, 2) {
        if (dp[i][d] != 1e12) {
            int c = N[i] - '0' + d;
            dp[i+1][0] = min(dp[i+1][0], dp[i][d] + c);
            dp[i+1][1] = min(dp[i+1][1], dp[i][d] + 10 - c);
        }
    }

    ll ans = min(dp[n][0], dp[n][1] + 1);
    cout << ans << endl;
}


Measured memory_bytes: 17028
let main () =
        let m, k = Scanf.sscanf (read_line ()) "%d %d" (fun m k -> m, k) in
        if k >= 1 lsl m || m = 1 && k = 1 then print_endline "-1" else
        if k = 0 then (
            for i = 0 to (1 lsl m) - 1 do
                Printf.printf "%d %d " i i
            done;
            print_newline ()
        ) else (
            for i = 0 to (1 lsl m) - 1 do
                if i <> k then Printf.printf "%d " i
            done;
            Printf.printf "%d " k;
            for i = (1 lsl m) - 1 downto 0 do
                if i <> k then Printf.printf "%d " i
            done;
            Printf.printf "%d\n" k
        )
    in
    main ()

Measured memory_bytes: 4224
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <limits>
#include <fstream>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;
struct Dijkstra {
  typedef pair<int, int> P;
  struct edge {
    int to;
    int cost;
  };
  int V;
  vector<vector<edge> > G;
  vector<int> d;
  Dijkstra (int V):V(V) {
    G.resize(V+1);
    d.resize(V+1,1e9);
  }
  void calc(int s){
    priority_queue<P, vector<P>, greater<P> > que;
    d[s]=0;
    que.push(P(0, s));
    while(!que.empty()){
      P p=que.top();que.pop();
      if(d[p.second]<p.first)continue;
      for(auto v : G[p.second]){
        if(d[v.to]>d[p.second]+v.cost){
          d[v.to]=d[p.second]+v.cost;
          que.push(P(d[v.to],v.to));
        }
      }
    }
  }
};

int main(){
    int V,E,r;
    cin>>V>>E>>r;
    Dijkstra dij(V+1);
    FOR(i,0,E){
        int s,t,d;
        cin>>s>>t>>d;
        dij.G[s].push_back({t, d});
    }
    dij.calc(r);
    FOR(i,0,V){
        if(dij.d[i]==1e9)cout<<"INF"<<endl;
        else cout<<dij.d[i]<<endl;
    }
}




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

INFTY = 1000000001
cnt = [0]

def merge(left, mid, right):
    n1 = mid - left
    n2 = right - mid
    L = A[left:left+n1]
    R = A[mid:mid+n2]
    L.append(INFTY)
    R.append(INFTY)
    i = 0
    j = 0
    for k in range(left, right):
        cnt[0] += 1
        if L[i] <= R[j]:
            A[k] = L[i]
            i += 1
        else:
            A[k] = R[j]
            j += 1

def merge_sort(left, right):
    if left+1 < right:
        mid = int((left+right) / 2)
        merge_sort(left, mid)
        merge_sort(mid, right)
        merge(left, mid, right)

merge_sort(0, N)
print(" ".join(map(str, A)))
print(cnt[0])


Measured memory_bytes: 66724
import java.util.*;
import java.awt.*;
import static java.lang.System.*;
import static java.lang.Math.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(in);
        int n=sc.nextInt();
        int a=sc.nextInt();
        int b=sc.nextInt();
        int turn=0;
        int[] x=new int[3];
        if(n==2){
            out.println("Borys");
        }else{
            while(true){
                x[0]=a-1;
                x[1]=b-1-a;
                x[2]=n-b;
                if(turn%2==0){
                    if(x[0]==0&&x[1]==0){
                        out.println("Borys");
                        break;
                    }else if(x[1]==0){
                        a--;
                    }else{
                        a++;
                    }
                }else{
                    if(x[1]==0&&x[2]==0){
                        out.println("Alice");
                        break;
                    }else if(x[1]==0){
                        b++;
                    }else{
                        b--;
                    }
                }
                turn++;
            }
        }
    }
}

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

int main() {
  int x,a,b;
  cin >>x >>a >>b;
  if(a<b){
    if((b-a)>x){
      cout <<"dangerous" <<endl;
    }
    else{
      cout <<"safe" <<endl;
    }
  }
  else{
    cout <<"delicious" <<endl;
  }
  
  return 0;
}


Measured memory_bytes: 256
a,b,c=map(int,input().split())
migi=c-a-b
hidari=2*((a*b)**(1/2))
flag=0
if migi <=0:
    flag+=1
if migi**2 <= 4*a*b:
    flag+=1
if flag:
    print('No')
else:
    print('Yes')


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

int head, tail, total_time;

struct Process{
  char name[10];
  int time;
};

Process p[100000];

void enqueue(struct Process v){
  p[tail] = v;
  if ( tail+1 == 100000 ) tail = 0;
  else tail++;
}

Process dequeue(){
  Process x = p[head];
  if ( head+1 == 100000 ) head = 0;
  else head++;

  return x;
}

int main(){
  int n, q;
  Process v;
  head = tail = total_time = 0;

  cin >> n >> q;
  for ( int i = 0; i < n; i++ ) cin >> p[i].name >> p[i].time;
  tail = n;

  while ( head != tail ){
    v = dequeue();
    if ( v.time > q ){
      v.time -= q;
      total_time += q;
      enqueue(v);
    } else {
      total_time += v.time;
      cout << v.name << " " << total_time << endl;
    }
  }
  return 0;
}


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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
string char_to_string(char val) {
  return string(1, val);
}
int char_to_int(char val) {
  return val - '0';
}
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;
}
int vector_finder(std::vector<ll> vec, int number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}
struct edge {
  ll to, cost;
};

int main() {
  ll N; cin >> N;
  vector<ll> ans; int n = pow(10, 7);
  for(ll i = 1; i <= n; ++i) {
    if(i % 3 == 0 || i % 5 == 0) ans.push_back(0);
    else ans.push_back(i);
  }
  ll res = 0;
  REP(i, N) {
    res += ans[i];
  }
  cout << res << endl;
}

Measured memory_bytes: 134488
#include <stdio.h>
#define rep(i, n) for(int i = 0; i < n; ++i)
 
int main(void) {
  int n, m;
  scanf("%d%d", &n, &m);
  int uf[n];
  rep(i, n) uf[i] = i;
  rep(i, m) {
    int s, t, nows, nowt;
    scanf("%d%d", &s, &t);
    nows = s, nowt = t;
    while(uf[nows] != nows) {
      nows = uf[nows];
    }
    while(uf[nowt] != nowt) {
      nowt = uf[nowt];
    }
    uf[nowt] = nows;
  }
  rep(i, n) {
    int nows = i;
    while(uf[nows] != nows) {
      nows = uf[nows];
    }
    uf[i] = nows;
  }
  /*rep(i, n) printf("%d ", uf[i]);
  printf("\n");*/
  int q;
  scanf("%d", &q);
  rep(i, q) {
    int s, t;
    scanf("%d%d", &s, &t);
    if(uf[s] != uf[t]) printf("no\n");
    else printf("yes\n");
  }
  return 0;
}


Measured memory_bytes: 3016
#include<algorithm>
#include<iostream>
#include<vector>
#include<string>
#include<cstring>
#include<utility>
#include<queue>
using namespace std;
#define REP(i, a,b) for(i=a;i<b;i++) 
#define REP1(i,b,a) for(i=b-1;i>=a;i--)
#define output(x) cout<<x<<endl;
#define pb(x) push_back(x);
typedef long long int ll;
const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

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

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

long long ruijyo(ll n, ll k) {
	if (k == 0) {
		return 1;
	}
	ll sum = 1;
	ll i;
	REP(i, 0, k) {
		sum *= n;
		sum %= MOD;
	}
	return sum;
}

int main()
{
	ll  i, j, k, l, m,n, sum, flag, N,  M, K, H, W, B,C,D;
	sum = 0;
	flag = 0;
	cin >> N >> K;
	vector<ll>a(N);
	REP(i, 0, N) {
		cin >> a[i];
	}
	vector<ll>ans(N - K + 1);
	vector<ll>sum1(N + 1);
	vector<ll>sum2(N + 1);
	sum1[0] = sum2[0] = 0;
	REP(i, 0, N) {
		sum1[i + 1] = sum1[i] + a[i];
		if (a[i] > 0) {
			sum2[i + 1] = sum2[i] + a[i];
		}
		else {
			sum2[i + 1] = sum2[i];
		}
	}
	REP(i, 0, N - K + 1) {
		if (sum1[i + K] - sum1[i] > 0) {
			ans[i] += sum1[i + K] - sum1[i];
		}
		ans[i] += sum2[i] + sum2[N] - sum2[i + K];
	}
	sort(ans.begin(), ans.end());
	output(ans[N - K ]);
	return 0;
	

	
}













Measured memory_bytes: 3328
#include <stdio.h>
int main(void){
    int a;
    long b,n;
    scanf("%d %ld %ld",&a,&b,&n);
    if(a==1)
        printf("0");
    else if(n<b)
        printf("%ld",(a*n)/b-a*(n/b));
    else
        printf("%ld",(a*(b-1))/b-a*((b-1)/b));
}


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

int main() {
	ll N;
	cin >> N;
  map<string,int> mp;
  rep(i,N){
    string s;
    cin >> s;
    sort(all(s));
    mp[s]++;
  }

  ll ans = 0;
  for(auto e:mp){
    ll second = e.second;
    ans += second*(second-1)/2;
  }

  cout << ans << endl;
}

Measured memory_bytes: 11136
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        int n = 700;
        if (s.charAt(0) == 'o') n += 100;
        if (s.charAt(1) == 'o') n += 100;
        if (s.charAt(2) == 'o') n += 100;

        System.out.println(n);
    }
}

Measured memory_bytes: 21716
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i,n) for(ll i=0;i<n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define fi first
#define se second
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){int len=d.size();rep(i,len){s<<d[i];if(i<len-1) s<<" ";}return s;}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){int len=d.size();rep(i,len){s<<d[i]<<endl;}return s;}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){s<<"{"<<endl;for(auto itr=m.begin();itr!=m.end();++itr){s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;}s<<"}"<<endl;return s;}

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double PI=acos(-1);
const double EPS=1e-10;

int main(){
	cin.tie(0);ios::sync_with_stdio(false);
	string s;
	cin>>s;
	sort(begin(s),end(s));
	if(s=="abc") cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<bitset>
using  namespace std;
#define ll long long
#define pb push_back
#define sc second
#define fr first
#define mp make_pair
const int N = 3e5 + 10, Max = 2e5 + 10;
const ll  MOD = 1e9 + 7, OO = 1e9;
int a[N] , pos[N];
int main() {
	int n;
	cin >> n;
	for (int i = 1; i <= n; ++i) {
		cin >> a[i];
		pos[a[i]] = i;
	}
	int cnt = 0;
	for (int i = 1; i <= n; ++i) {
		if (pos[i] == i)
			continue;
		int x = a[i];
		swap(a[x], a[pos[i]]);
		swap(pos[i], pos[x]);
		++cnt;
	}
	if (cnt <= 1)return cout << "YES" << endl, 0;
	cout << "NO" << endl;
}


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

inline string toString(int a){
  stringstream ss;
  ss << a;
  return ss.str();
}

inline string trans(string s){
  string res;
  int id = 0, num = 1;
  for(int i=1;i<(int)s.size();i++){
    if(s[i] == s[id]){
      num++;
    }else{
      res += toString(num) + s[id];
      id = i; num = 1;
    }
  }
  res += toString(num) + s[id];
  return res;
}

int main(){
  int n;
  while(cin >> n, n){
    string s; cin >> s;
    for(int i=0;i<n;i++){
      s = trans(s);
    }
    cout << s << endl;
  }
}

Measured memory_bytes: 1360
from collections import deque, _heapq
N = int(input())

g = [{"num":0, "neighber":[]} for _ in range(N+1)]

for _ in range(N-1):
    x, y = map(int, input().split())
    g[x]["neighber"].append(y)
    g[y]["neighber"].append(x)

c = sorted(map(int, input().split()))
print(sum(c[:-1]))

i = 0
s = [(0, 1)]
while i < len(s):
    pre, cur = s[i]
    i+=1
    g[cur]["num"] = c.pop()

    for x in g[cur]["neighber"]:
        if x == pre:
            continue
        s.append((cur, x))

print(" ".join((str(g[i]["num"]) for i in range(1, N+1))))


Measured memory_bytes: 9848
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cmath>
#include <iostream>
#include <queue>
#include <list>
#include <stack>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;

class UnionFind{
  int n;
  vector<int> data;
public:
  UnionFind(int _n):n(_n),data(_n,-1){}
  bool link(int a, int b){ //if new link, then true.
    int ra=find_root(a);
    int rb=find_root(b);
    if(ra!=rb){
      if(data[rb]<data[ra]) swap(ra,rb);
      data[ra]+=data[rb];
      data[rb]=ra;
    }
    return (ra!=rb);
  }
  bool check(int a, int b){ //if same set, then true.
    return (find_root(a)==find_root(b));
  }
  int find_root(int a){
    return ((data[a]<0)?a:(data[a]=find_root(data[a])));
  }
};


int main(){
  ios::sync_with_stdio(false);
  int N, M;
  cin >> N >> M;

  map<int,map<int,int> > lang;

  rep(i,N){
    int K;
    cin >> K;
    rep(j,K){
      int L;
      cin >> L;
      lang[L][i] = 1;
    }
  }
  
  UnionFind uf(N);
  FOR(it1,lang){
    int fst = -1;
    FOR(it2,it1->second){
      if(fst<0){
        fst = it2->first;
      }else{
        uf.link(fst, it2->first);
      }
    }
  }

  bool flg = true;
  rep(i,N){
    if(uf.find_root(0) != uf.find_root(i)) flg = false;
  }
  
  if(flg){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }

  
  return 0;
}



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

typedef long long ll;
typedef pair<int, int> pi;
#define F first
#define S second
#define PB push_back

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

int main()
{
    int a, b;
    cin >> a >> b;
    int result = 0;
    int num = 1;
    while (num < b)
    {
        --num;
        num += a;
        ++result;
    }
    cout << result << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
const long long INF = LLONG_MAX / 2;
const long long MOD = 1000000007;
const long double PI = 3.1415926;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define REP(i,n) FOR(i,0,n)
#define ll long long int
#define ALL(x) x.begin(),x.end()
using namespace std;
ll ans = 0, sum = 0, n, k, counter = 0, w, h;
string s;
vector<ll> v;
vector < pair<ll, ll > > vp;
vector<vector<ll> > vv(50, vector<ll>(50, INF));
vector<string> vs;
vector<char> vc;
vector<ll> vi;
/*--------------------template--------------------*/

int main() {
	cin >> n >> h;
	REP(i, n) {
		string t;
		cin >> t;
		vs.push_back(t);
	}
	sort(ALL(vs));
	REP(i, n) {
		cout << vs[i];
	}
	cout << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
typedef long long ll;

ll a[1000][1000], d[1000][1000], n, s[1000][1000];
bool flg[1000][1000], flg2[1000][1000];

ll dfs(ll b, ll c) {
  if(flg2[b][c]) return -1;
  ll now = 0, t;
  flg2[b][c] = flg2[c][b] = true;
  if(s[b][c]) {
    t = 0;
    if(flg[b][a[b][s[b][c] - 1]]) {
      t = dfs(b, a[b][s[b][c] - 1]);
      if(t == -1) return -1;
    } else t = d[b][a[b][s[b][c] - 1]];
    if(now < t) now = t;
  }
  if(s[c][b]) {
    t = 0;
    if(flg[c][a[c][s[c][b] - 1]]) {
      t = dfs(c, a[c][s[c][b] - 1]);
      if(t == -1) return -1;
    } else t = d[c][a[c][s[c][b] - 1]];
    if(now < t) now = t;
  }
  flg[b][c] = flg[c][b] = false;
  d[b][c] = d[c][b] = now + 1;
  flg2[b][c] = flg2[c][b] = false;
  return now + 1;
}

int main(void) {
  ll i, j, k, ans = 0;
  scanf("%lld", &n);
  for(i = 0; i < n; ++i) for(j = 0; j < n - 1; ++j) scanf("%lld", &a[i][j]), s[i][--a[i][j]] = j;
  for(i = 0; i < n; ++i) for(j = 0; j < n; ++j) flg[i][j] = true, flg2[i][j] = false;
  for(i = 0; i < n; ++i) flg[i][i] = false;
  for(i = 0; i < n; ++i) for(j = 0; j < n; ++j) if(i != j) {
    if(flg[i][j]) {
      if(dfs(i, j) == -1) {
        printf("-1");
        return 0;
      }
    }
  }
  for(i = 0; i < n; ++i) for(j = 0; j < n; ++j) if(i != j && d[i][j] > ans) ans = d[i][j];
  printf("%lld", ans);
  return 0;
}

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

int memo[1001][1001];
string s,t;

int dfs(int i, int j)
{
    if(i == 0 || j == 0) return 0;
    
    if(memo[i][j] != -1)return memo[i][j];
    
    int res = 0;
    
    if(s[i-1] == t[j-1]) res = dfs(i-1, j-1) + 1;
    else {
        res = max(dfs(i - 1, j), dfs(i, j - 1));
    }
    return memo[i][j] = res;
}

int main()
{
    int n;
    cin >> n;
    for(int i = 0; i < n; ++i){
        cin >> s >> t;
        fill((int*)memo, (int*)(memo + (int)max(s.size(), t.size()) + 1), -1);
        cout << dfs(s.size(), t.size()) << endl;
    }
}

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

using namespace std;

#define foru(i, l, r) for(register int i = l; i <= r; i++)
#define ford(i, r, l) for(register int i = r; i >= l; i--)

typedef long long ll;
const int maxn = 2e5 + 5;

ll N, D, A, cha[maxn];
struct Hhw { ll x, h; } a[maxn];
bool cmp(Hhw x, Hhw y) { return x.x == y.x ? x.h < y.h : x.x < y.x; }

int main() {
  scanf("%lld%lld%lld", &N, &D, &A), D <<= 1;
  for(ll i = 1; i <= N; i++) scanf("%lld%lld", &a[i].x, &a[i].h);
  sort(a + 1, a + N + 1, cmp), a[N + 1].x = 0x3f3f3f3f3f3f3f3f;
  ll l = 0, r = 0, Ans = 0;
  for(l = 1; l <= N; l++) {
    cha[l] += cha[l - 1];
    a[l].h -= cha[l] * A;
    if(a[l].h <= 0) continue;
    while(a[r + 1].x - a[l].x <= D) r++;
    ll times = (a[l].h + A - 1) / A;
    cha[l] += times, cha[r + 1] -= times;
    Ans += times;
  }
  printf("%lld\n", Ans);
  return 0;
}


Measured memory_bytes: 4992
import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
import Data.List

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

main = do
    n <- getInt
    as <- getIntList
    putStrLn $ solve as n

solve as n | (== n) . length . group $ sort as = "YES"
           | otherwise = "NO"

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

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

    long long int r,tmp,x = a*b;

    if(a < b){
        tmp = a;
        a = b;
        b = tmp;
    }

    r = a%b;
    while (r != 0)
    {
        a = b;
        b = r;
        r = a%b;
    }

    cout << x/b << endl;
    
    return 0;
}

Measured memory_bytes: 256
void call(int n){
  int i, x, flag;
  for (i = 1; i <= n; i++) {
    x = i;
    flag = 0;
    if (x % 3 == 0) {
      printf(" %d", i);
    } else {
      do {
        if(x % 10 == 3) {
          printf(" %d", i);
          flag = 1;
        } else {
          x /= 10;
        }
      } while (x && flag == 0);
    }
  }
  printf("\n");
}


int main() {
  int n;
  scanf("%d", &n);
  call(n);
  return 0;
}

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

int A, B, C, D, E, F;

int main() {
    cin >> A >> B >> C >> D >> E >> F;

    int suger_water = 100*A;
    int suger = 0;
    double ratio = 0;
    for (int a = 0; 100*A*a <= F; a++) {
        for (int b = 0; 100*B*b <= F; b++) {
            for (int c = 0; C*c <= F; c++) {
                for (int d = 0; D*d <= F; d++) {
                    if (C*c + D*d <= (A*a +B*b)*E && 100*(A*a + B*b) + C*c + D*d <= F) {
                        double w = 100*(A*a + B*b);
                        double s = C*c + D*d;
                        if (ratio < s/(s+w)) {
                            suger_water = s+w;
                            suger = s;
                            ratio = s/(s+w);
                        }
                    }
                }
            }
        }
    }

    cout << suger_water << " " << suger << endl;
    
    
    return 0;
}


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

using namespace std;

int main(){

	int n;

	cin>> n;

	if(n<10){
		cout<< n << endl;
		return 0;
	}

	if(n<100){
		cout<< 9 << endl;
		return 0;
	}

	if(n<1000){
		cout<< 9+n-99 << endl;
		return 0;
	}

	if(n<10000){
		cout<< 909 << endl;
		return 0;
	}

	if(n<100000){
		cout<< 909+n-9999 << endl;
		return 0;
	}

	if(n==100000){
		cout<< 90909 << endl;
		return 0;
	}


}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ULL = unsigned long long;
const ULL MOD = 1000000007;
#define rep(i, ns, ne) for (ULL i = ns; i < ne; ++i)

/*
int main() {
        int N;
        cin >> N;
        vector<int> A(N);
        vector<long long> B(N + 1, 0); //累積和テーブル
        int mod = 1000000007;

        for (int i = 0; i < N; i++)
        {
                cin >> A[i];
                B[i + 1] = B[i] + A[i];
        }

        long ans = 0;

        //i について全探索する
        for (int i = 0; i < N; i++)
        {
                //累積和を使ってA[i+1] + ... + A[N] を求める
                long long sum = (B[N] - B[i + 1]) % mod;

                ans += A[i] * sum;
                ans %= mod;
        }

        cout << ans << endl;
}*/

int main() {
  ULL N;
  cin >> N;
  vector<ULL> a(N);
  vector<ULL> b(N + 1,0);
  rep(i, 0, N) {
    cin >> a[i];
    b[i + 1] = b[i] + a[i];
  }

  ULL sum, ans = 0;
  rep(i, 0, N) {
    sum = (b[N] - b[i + 1]) % MOD;
    ans = (ans + a[i] * sum) % MOD;
  }

  cout << ans << endl;
  getchar();
}

Measured memory_bytes: 6396
#include <stdio.h>
#include<stdlib.h>
int main() {
	
	int *arr = (int*)malloc(sizeof(int)*2*100001);
	int n,temp;
	
	
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		arr[i]=0;
	
	for(int i=2;i<=n;i++){
		scanf("%d",&temp);
		arr[temp]++;
	}
	
	for(int i=1;i<=n;i++){
		printf("%d ",arr[i]);
	}
	
    return 0;
}


Measured memory_bytes: 2468
a, b, c = map(int,input().split())

def gcd(x, y):
    while x != 0 and y != 0:
        x, y = max(x, y), min(x, y)
        x %= y
    return max(x, y)

print("YES" if c % gcd(a, b) == 0 else "NO")

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

main () {
  int n, m;
  scanf("%d %d", &n, &m);

  int min_ = 1;
  int max_ = n;
  rep(i,m) {
    int l, r;
    scanf("%d %d", &l, &r);
    if (min_ < l) min_ = l;
    if (max_ > r) max_ = r;
  }

  printf("%d\n", max(max_-min_+1, 0));

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,k,l;
int q,p,r,s;
int f1[1000001],f2[1000001];
map<pair<int,int>,int> m;
int find1(int x)
{
	if(x==f1[x]) return x;
	else return f1[x]=find1(f1[x]);
}
int find2(int x)
{
	if(x==f2[x]) return x;
	else return f2[x]=find2(f2[x]);
}
int merge1(int x,int y)
{
	int x1=find1(x),y1=find1(y);
	f1[y1]=x1;
}
int merge2(int x,int y)
{
	int x2=find2(x),y2=find2(y);
	f2[y2]=x2;
}
int main()
{
	cin>>n>>k>>l;
	for(int i=1;i<=n;i++)
	{
		f1[i]=f2[i]=i;
	}
	for(int i=1;i<=k;i++)
	{
		cin>>p>>q;
		merge1(p,q);
	}
	for(int i=1;i<=l;i++)
	{
		cin>>r>>s;
		merge2(r,s);
	}
	for(int i=1;i<=n;i++)
	{
		find1(i);
		find2(i);
	}
	for(int i=1;i<=n;i++)
	{
		m[{f1[i],f2[i]}]++; 
	}
	for(int i=1;i<=n;i++)
	{
		cout<<m[{f1[i],f2[i]}]<<" ";
	}
	return 0;
}

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

using namespace std;
using ll = long long;

int main() {
	int n;
	cin >> n;
	vector<ll> a(n);
	for (ll &i: a)
		cin >> i;
	ll ans = 0;
	for (int i = 0; i < n; i++) {
		for (int j = i + 1; j < n; j++) {
			for (int k = j + 1; k < n; k++) {
				vector<ll> x = {a[i], a[j], a[k]};
				sort(x.begin(), x.end());
				if (a[i] != a[j] && a[j] != a[k] && a[i] != a[k])
					if (x[0] + x[1] > x[2])
						ans++;
			}
		}
	}
	cout << ans << endl;
}

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

int main() {
  int A,B,M;
  cin >>A>>B>>M;
  vector<int>a(A);
  vector<int>b(B);
  vector<int>x(M);
  vector<int>y(M);
  vector<int>c(M);
  int ans=0;
  int ANS=0;
  for(int i=0;i<A;i++){
    cin>>a[i];
  }
  for(int i=0;i<B;i++){
    cin>>b[i];
  }
  for(int i=0;i<M;i++){
    cin>>x[i]>>y[i]>>c[i];
  }
  for(int i=0;i<M;i++){
    if(i==0){
      ans=+a[x[i]-1]+b[y[i]-1]-c[i];
    }
    else if(ans>=a[x[i]-1]+b[y[i]-1]-c[i]){
      ans*=0;
      ans+=a[x[i]-1]+b[y[i]-1]-c[i];
    }
  }
  sort(a.begin(), a.end());
  sort(b.begin(), b.end());
  ANS+=a[0]+b[0];
  if(ans<=ANS){
    cout<<ans<<endl;
  }
  else{
    cout<<ANS<<endl;
  }
}

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

int main()
{
  int n;
  cin >> n;
  vector<int> a(n);
  map<int, int> mp;

  for (auto&& e : a) {
    cin >> e;
    mp[e]++;
  }

  if (all_of(begin(a), end(a), [](auto a){return a == 0;})) {
    cout << "Yes" << endl;
    return 0;
  }

  if (mp.size() > 3 || n % 3 != 0) {
    cout << "No" << endl;
    return 0;
  }

  if (mp.size() == 2) {
    if (mp[0] == n / 3) {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
    return 0;
  }

  if (mp.size() == 3) {
    int x = 0;
    for (auto&& e : mp) {
      x ^= e.first;
    }
    if (x != 0) {
      cout << "No" << endl;
      return 0;
    } else {
      for (auto&& e : mp) {
        if (mp[e.first] != n / 3) {
          cout << "No" << endl;
          return 0;
        }
      }
      cout << "Yes" << endl;
      return 0;
    }
  }

  cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 4224
#include<string>
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<map>
#include<functional>
using namespace std;
typedef long long int llint;
typedef bool izryt;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
const int big=1e9;
template <class T,class U>void mineq(T& a,U b){if(a>b){a=b;}}
template <class T,class U>void maxeq(T& a,U b){if(a<b){a=b;}}
const int mod=1e9+7;
class SCC{
	/*
	?????????
	road????????????rroad????????????????????£????????§????????????
	???????????¢??°???do_scc??????????????????
	unite_scc??§?????¨???????????¨?????§?????????
	*/
public:
	vector<vector<int>>road;
	vector<vector<int>>rroad;
	vector<int>ban;//??°?????????????????´???
	vector<bool>sir;//????????????true
	vector<int>uni;//????????£?????????????????????
	int n,num;
	void dfs_scc(int town){
		if(sir[town]){return;}
		sir[town]=true;//cout<<"de "<<town<<endl;
		for(int i=0;i<road[town].size();i++){dfs_scc(road[town][i]);}
		ban.pub(town);
		return;
	}
	void rdfs_scc(int town){
		if(uni[town]!=0){return;}
		uni[town]=num;//cout<<"rde "<<town<<endl;
		for(int i=0;i<rroad[town].size();i++){rdfs_scc(rroad[town][i]);}
		return;
	}
	void do_scc(void){
		//????????£??????????????????????????????vector?????????
		//scc_chain???????????????????????¨??????????????¨??????DAG??????????????????
		n=road.size();
		num=1;
		sir.res(n);
		uni.res(n);
		int i,j;
		for(i=0;i<n;i++){dfs_scc(i);}
		num=1;
		for(i=0;i<n;i++){if(uni[ban[n-i-1]]==0){rdfs_scc(ban[n-i-1]);num++;}}
		return;
	}
};
int main(void){
	int n,m,i,q,w,u,v;cin>>n>>m;
	SCC gla;
	gla.road.res(n);
	gla.rroad.res(n);
	for(i=0;i<m;i++){
		cin>>q>>w;
		gla.road[q].pub(w);
		gla.rroad[w].pub(q);
	}
	gla.do_scc();
	cin>>q;
	for(i=0;i<q;i++){
		cin>>u>>v;
		if(gla.uni[u]==gla.uni[v]){cout<<1<<endl;}
		else{cout<<0<<endl;}
	}
	//for(i=0;i<n;i++){cout<<"de ban="<<gla.ban[i]<<endl;}
	//for(i=0;i<n;i++){cout<<"de uni="<<gla.uni[i]<<endl;}
	return 0;
}

Measured memory_bytes: 4404
#pragma region
#include <bits/stdc++.h>
using namespace std;
inline void ci(void){
  return;
}
template <typename First, typename... Rest>
void ci(First& first, Rest&... rest){
  cin >> first;
  ci(rest...);
  return;
}
inline void co(void){
  cout << endl;
  return;
}
template <typename First, typename... Rest>
void co(First first, Rest... rest){
  cout << first << "";
  co(rest...);
  return;
}
#define ll long long
#define ld long double
#define st string
#define wh while
#define ve vector
#define mp make_pair
#define tp tuple
#define mt make_tuple
#define pb push_back
#define pof pop_front
#define pob pop_back
#define pf push_front
#define fr front
#define ft first
#define sc second
#define tos to_string
#define len length
#define rt return
#define br break
#define con continue
#define lcm(n, m) (n * m / __gcd(n, m))
#define np next_permutation
#define repi(i, m, n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i, n) repi(i, 0, n)
#define revi(i, m, n) for(int i=(int)(m) - 1;i>=(int)(n);i--)
#define rev(i, m) revi(i, m, 0)
#define sz(v) ((int)(v).size()) 
#define each(i, n) for(auto&& i: n)
#define all(n) n.begin(), n.end()
#define allr(n) n.rbegin(), n.rend()
#define sp(n) cout << fixed << setprecision(n)
#define pi 3.14159265358979323846
#define inf 1000000007
#pragma endregion
// sqrt ルート, int 2*10^9, gcd　最大公約数
// __builtin_popcount bitの個数

ve<int> dx = {0, 0, 1, -1}, dy = {1, -1, 0, 0};

int main() {
  st a, b, c;
  ci(a, b, c);
  queue<char> A, B, C;
  rep(i, sz(a)){
    A.push(a.at(i));
  }
  rep(i, sz(b)){
    B.push(b.at(i));
  }
  rep(i, sz(c)){
    C.push(c.at(i));
  }
  char cnt = A.fr();
  A.pop();
  wh(true){
     if(cnt == 'a'){
       if(sz(A) == 0){
        co('A');
        rt 0;
       }
      cnt = A.fr();
      A.pop();
    }
    if(cnt == 'b'){
      if(sz(B) == 0){
        co('B');
        rt 0;
      }
      cnt = B.fr();
      B.pop();
    }
    if(cnt == 'c'){
      if(sz(C) == 0){
        co('C');
        rt 0;
      }
      cnt = C.fr();
      C.pop();
    }
  }
}


Measured memory_bytes: 256
// ===== 2018/06/02 20:44:53 =====

// ../../../lib/template/includes.hpp

#include <algorithm>
#include <array>
#include <cassert>
#include <climits>
#include <complex>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <string>
#include <tuple>
#include <vector>

// ../../../lib/template/const_value.hpp

template <typename T> constexpr T inf();
template <> constexpr int inf<int>() { return 1e9; }
template <> constexpr long long inf<long long>() { return 1e18; }
template <> constexpr long double inf<long double>() { return 1e30; }

template <typename T>
constexpr typename std::enable_if<std::is_arithmetic<T>::value, T>::type
zero() {
  return T(0);
}

const long double pi = acos(-1.0);

// ../../../lib/template/initialize.cpp

struct yes_no : std::numpunct<char> {
  string_type do_truename() const { return "Yes"; }
  string_type do_falsename() const { return "No"; }
};

struct Initialize {
  Initialize() {
    std::locale loc(std::locale(), new yes_no);
    std::cout << std::boolalpha << std::setprecision(11) << std::fixed;
    std::cout.imbue(loc);
  }
};

const Initialize init;

// ../../../lib/template/macros.hpp

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()

// ../../../lib/template/misc.hpp

template <typename T> T &chmin(T &a, const T &b) { return a = std::min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = std::max(a, b); }

// ../../../lib/template/range.hpp

class range {
  class index_type {
    int x;

  public:
    index_type(int x_) : x(x_) {}
    int operator*() const { return x; }
    bool operator!=(index_type &r) { return x < r.x; }
    void operator++() { ++x; }
  };
  index_type i, n;

public:
  range(int n_) : i(0), n(n_) {}
  range(int i_, int n_) : i(i_), n(n_) {}
  index_type &begin() { return i; }
  index_type &end() { return n; }
};

// ../../../lib/template/typedef.hpp

using ll = long long;
using ld = long double;
using Point = std::complex<ld>;

// ../../../lib/template/template.cpp

using namespace std;

// C.cpp

template<typename T>
vector<T> table(int n, T v) { return vector<T>(n, v); }

template <class... Args>
auto table(int n, Args... args) {
  auto val = table(args...);
  return vector<decltype(val)>(n, move(val));
}

void solve(ll N, string S) {
  vector<int> sum(N + 1);
  for (int i: range(N)) sum[i + 1] = sum[i] + (S[i] == 'W');
  int res = inf<int>();
  for (int i: range(N)) {
    int num = sum[i] + ((N - i - 1) - (sum[N] - sum[i + 1]));
    chmin(res, num);
  }
  cout << res << endl;
}

int main() {
	string S;
	ll N;
	scanf("%lld", &N);
	cin >> S;
	solve(N, S);
	return 0;
}
// ===== 2018/06/02 20:44:53 =====



Measured memory_bytes: 2176