akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,n) for (int64_t i=0; i<(n); ++i)
#define P pair<int,int>
using ll=int64_t;
using namespace std;
#define ketasuu(n) fixed<<setprecision(n)
#define btoe(p) p.begin(),p.end()
#define etob(p) p.rbegin(),p.rend()




int main(){
    int n; cin>>n;
    vector<int> p(n);
    rep(i,n) cin>>p[i];
    vector<ll> ps(n+1), px(n+1);
    ps[0]=p[0]; px[0]=p[0];
    rep(i,n-1){
        ps[i+1]=ps[i]+p[i+1];
        px[i+1]=px[i]^p[i+1];
    }
    ll ans=0;
    rep(i,n){
        if(i==0){
            int ll=0, rr=n,mm;
            while((rr-ll)>1){
                mm=(rr+ll)/2;
                if(ps[mm]!=px[mm]){
                    rr=mm;
                }
                else ll=mm;
            }
            ans+=(ll+1);
            continue;
        }
        int l=i, r=n, m=(l+r)/2;
        while((r-l)>1){
            m=(l+r)/2;
            if((ps[m]-ps[i-1])!=(px[m]^px[i-1])){
                r=m;
            }
            else l=m;
        }
        ll kari=l-i+1;
        //if(kari!=0) cout<<i<<" "<<kari<<endl;
        ans+=kari;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 7216
#include<iostream>
#include<iomanip>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<string>
#include<algorithm>
#include<functional>
#include<math.h>
#include<unordered_set>
using namespace std;

bool solve(int n) {
	for (int i = 1; i <= 1000; i++) {
		if (n % i != 0)continue;
		if (n / i == i)return true;
	}
	return false;
}

int main() {
	string a, b;
	int n;

	cin >> a >> b;

	n = atoi((a + b).c_str());

	if (solve(n))cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <functional>
#include <algorithm>
#include <vector>
#include <limits>
#include <numeric>
#include <type_traits>
#include <iostream>
#include <queue>
#include <bits/stdc++.h>

#define INF (1ll<<60)
#define MOD 1000000007
#define BOUND 27182818284

typedef long long ll;
typedef long long int lli;

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

template<class T>bool umax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool umin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

using namespace std;

// gcd
int gcd(int a, int b){
    if(a==0)
        return b;
    return gcd(b%a,a);
}
// gcd array
int findGCD(int arr[], int n){
    int result = arr[0];
    for (int i=1; i < n; i++)
        result = gcd(arr[i], result);

    return result;
}

// sort big to small
// sort(A,A+N, greater<int>());

// v.front() = -BOUND;
// v.back() = BOUND;

// Iterator
// v.begin
// v.end

int main() {
    long long X,Y,Z;
    cin >> X >> Y >> Z;

    cout << (X-Z)/(Y+Z) << endl;
    return 0;
}



Measured memory_bytes: 256
n = int(input())
l = []
for i in range(1,n+1):
    a, b = input().split()
    l += [[a,int(b),i]]
l = sorted(sorted(l, key=lambda x:x[1], reverse=True), key=lambda x:x[0])
for i in range(len(l)):
    print(l[i][2])

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

using namespace std;

#ifdef ACMTUYO
struct RTC{~RTC(){cerr << "Time: " << clock() * 1.0 / CLOCKS_PER_SEC <<" seconds\n";}} runtimecount;
#define DBG(X) cerr << #X << " = " << X << '\n';
#else
struct RTC{};
#define DBG(X)
#endif

#define fast_io() ios_base::sync_with_stdio(false)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define sz(x) ((int)(x).size())
#define all(c) (c).begin(),(c).end()
#define forn(i, n) for (int i = 0; i < (n); i++)
typedef long long int number;

int main() {
  fast_io();
  string s;
  cin >> s;
  int cnt = 0;
  int maxi = 0;
  forn (i, sz(s)) {
    if (s[i] == 'R') {
      cnt++;
    } else {
      cnt = 0;
    }
    maxi = max(maxi, cnt);
  }
  cout << maxi << '\n';
  return 0;
}


Measured memory_bytes: 3648
#include <stdio.h>

int main(){

while(1){

	int a,b,n,m;
	
	scanf("%d %d",&a,&b); //入力
	
	if(a==0&&b==0){ //両方0やったらbreak
		
		break;
	
	}
	
	for(m=1;m<=a;m++){ //行単位でのループ
		
		if(m-(m/2)*2!=0){ //奇数行目
		
			if(b-(b/2)*2==0){ //横が偶数のとき
	
				for(n=1;n<=(b/2);n++){ //同じ奴の偶数繰り返し
			
					printf("#.");
			
					}
					
				printf("\n"); //行変わる
		
			}else{ //横が奇数のとき
		
				for(n=1;n<=(b/2);n++){ //同じ奴の偶数までの繰り返し
			
					printf("#.");
			
					}
		
				printf("#\n"); //足りひん分の追加+行変える
		
			} //横のif節終了
		
		}else{ //偶数行目
		
			if(b-(b/2)*2==0){ //横が偶数のとき
	
				for(n=1;n<=(b/2);n++){ //同じ奴の偶数繰り返し
			
					printf(".#");
			
					}
				
				printf("\n"); //行変わる
				
			}else{ //横が奇数のとき
		
				for(n=1;n<=(b/2);n++){ //同じ奴の偶数までの繰り返し
			
					printf(".#");
			
					}
		
				printf(".\n"); //足りひん分の追加+行変える
		
			} //横のif節終了
		
		} //行数if節終了
	
	} //行数のループ終了

printf("\n"); //行下げ

} //無限ループ終了

return 0;

}

Measured memory_bytes: 600
import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Random;
import java.util.StringTokenizer;

public class Main {
	
	public static void main(String[] args) {
		FastReader scan = new FastReader();
		PrintWriter out = new PrintWriter(System.out);
		Task solver = new Task();
		solver.solve(1, scan, out);
		out.close();
	}
	
	static class Task {
		public void solve(int testNumber, FastReader scan, PrintWriter out) {
			int a = scan.nextInt();
			String s = scan.next();
			if(a < 3200) out.println("red");
			else out.println(s);
		}
	}
	
	static void shuffle(int[] a) {
		Random get = new Random();
		for(int i = 0; i < a.length; i++) {
			int r = get.nextInt(a.length);
			int temp = a[i];
			a[i] = a[r];
			a[r] = temp;
		}
	}
	
	static void shuffle(long[] a) {
		Random get = new Random();
		for(int i = 0; i < a.length; i++) {
			int r = get.nextInt(a.length);
			long temp = a[i];
			a[i] = a[r];
			a[r] = temp;
		}
	}
	

	static class FastReader {
		BufferedReader br;
		StringTokenizer st;

		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}
		public FastReader(String s) throws FileNotFoundException {
			br = new BufferedReader(new FileReader(new File(s)));
		}

		String next() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

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

		long nextLong() {
			return Long.parseLong(next());
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}
	}

}


Measured memory_bytes: 21588
import sys
inf = sys.maxsize

if __name__ == '__main__':
    h, w, k = map(int, sys.stdin.readline().strip().split())
    s = [[int(i) for i in sys.stdin.readline().strip()] for _ in range(h)]
    
    ans = inf
    for i in range(2 ** (h - 1)): #縦方向の割り方を全探索 O(512)
        hdiv = [1 if i & 2 ** j else 0 for j in range(h - 1)]
        hdiv.append(1)
        sh = sum(hdiv)
        tmpans = sh - 1
        partsum = [0 for _ in range(sh)]
        partsum_p = [0 for _ in range(sh)]
        j = 0
        for j in range(w): #O(10 ** 3)
            tmp = 0
            idx = 0
            flag = False
            for kk in range(h): #O(10)
                tmp += s[kk][j]
                if hdiv[kk]:
                    partsum_p[idx] = partsum[idx]
                    partsum[idx] += tmp
                    if partsum[idx] > k and not flag:
                        tmpans += 1
                        flag = True
                    tmp = 0
                    idx += 1
            if flag:
                partsum = [partsum[l] - partsum_p[l] for l in range(sh)]
                partsum_p = [0 for _ in range(sh)]
                for kk in range(sh):
                    if partsum[kk] > k:
                        tmpans = inf
                        break
        ans = min(ans, tmpans)
    print(ans)


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

using namespace std;
#define SZ(v) int((v).size())
#define ALL(vec) begin(vec), end(vec)
#define pb push_back
#define mk make_pair
typedef long long ll;


template<typename T> inline bool uax(T &x, T y) {return (y > x) ? x = y, true : false;}
template<typename T> inline bool uin(T &x, T y) {return (y < x) ? x = y, true : false;}
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); \
  stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
string to_string(char c) { return "'" + string(1, c) + "'";}
string to_string(string s) { return '"' + s + '"';}
string to_string(const char* s) { return to_string((string) s);}
template<typename A> string to_string(A);
template<typename A, typename B> string to_string(pair<A, B> p){
  return "(" + to_string(p.first) + ": " + to_string(p.second) + ")";}
template<typename A> string to_string(A v) {bool f = false; string r = "{"; 
  for (auto x: v) {if (f) r += ", "; r += to_string(x); f = true;} return r += "}";}
template<typename A> string to_string(vector<vector<A>> v) {string r; 
  for (auto x: v) r += "\n" + to_string(x); return r;}
int Nerr;
template<typename A> string to_string(A *p) {return to_string(vector<A>(p, p + Nerr));}
void err(istream_iterator<string>) { cerr << endl; }
template<typename T,typename... Args> void err(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << " =: " << to_string(a) << "; "; err(++it, args...); }
template<typename T> void kek(T ans) {cout << ans << endl; exit(0);}
int const MOD = 1e9 + 7;
long long const INF = 1e18 + 42;
int mod = 1e9 + 7;

int add(int a, int b){
	if(a + b >= mod)return a+ b - mod;
	return a + b;
}
int mul(int a, int b){
	return 1LL * a * b  % mod;
}
int power(int a, int b){
	if(b < 0)return 0;
	int re = 1;
	while(b){
		if(b&1){
			re = mul(re, a);
		}
		a = mul(a, a);
		b >>= 1;
	}
	return re;
}
// int const N = 100000 + 5;
// int fact[N], inverse[N];
// void FAC(){
//  	fact[0] = 1;
// 	for(int x = 1; x< N; x++){
// 		fact[x] = mul(fact[x-1], x);
// 	}
// 	inverse[N-1] = power(fact[N-1], mod -2);
// 	for(int x = N-2; x>= 0; x--){
// 		inverse[x] = mul(x + 1, inverse[x+1]);
// 	}

//  }

// int ncr(int a, int b){
// 	if(a < b)return 0;
// 	return mul(fact[a], mul(inverse[a-b], inverse[b]));
// }


/******************************************************/

void solve(){
	vector<int> v = {0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4};
	int k ; cin >> k;
	cout << v[k];
	
}


/******************************************************/
int main()
{
	ios_base::sync_with_stdio(false);cin.tie(nullptr);
	int t;
	t = 1;
	// cin >> t;
	while(t--){
		solve();
	}

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
#define int long long
int INF = 1e9+7;
signed main() {
    int N;
    cin >> N;
    if(N == 1) {
        cout << 1 << endl;
        return 0;
    }
    vector<int>A(N);
    vector<int> is_prime(1000005,1);
    for(int i = 0; i < N; i++) {
        cin >> A[i];
    }
    sort(A.begin(),A.end());
    int ans = 0;
    if(A[0] != A[1]) {
        ans++;
    }
    for (int j = A[0]; j < 1000005; j+=A[0]) {
        is_prime[j] = 0;
    }
    for (int i = 0; i < N; i++) {
        bool ok = true;
        if (!is_prime[A[i]]) {
            continue;
        }
        if(i+1 != N) {
            if(A[i] == A[i+1]) {
                for (int j = A[i]; j < 1000005; j+=A[i]) {
                    is_prime[j] = 0;
                }
                ok = false;
            }
        }
        if(ok == false) {
            continue;
        }
        ans++;
        for (int j = A[i]; j < 1000005; j+=A[i]) {
            is_prime[j] = 0;
        }
    }
    cout << ans << endl;
}


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

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define forn(i , n) for(int i=0;i<n;i++)


int main(){
    int n;
    int i = 1;
    
    while((cin >> n) && n!=0){
        cout << "Case " << i << ": " << n << endl;
        i++;
        
        
    }
    return 0;
}

Measured memory_bytes: 3044
import java.util.*;

public class Main {
    public static void main(String[] args) {
        //solve_147_C();
        solve_147_D();
        return;
    }

    private static void solve_147_D() {
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        long[] Ai = new long[N + 1];
        long sum = 0;

        for (int i = 0; i < N; i++) {
            Ai[i] = sc.nextLong();
        }
        sc.close();

        long surp = 0;
        int mod = (int)1e9+7;
        for( int i=0; i<61; i++ ) { //bitは60桁まで
            int cnt = 0;
            for( int j=0; j<N; j++ ) {
                if(((Ai[j]>>i) & 1) == 1) cnt++;
            }
            surp += (long)cnt * (((long)(N-cnt) * (((long)1<<i)%mod)%mod)%mod);
            surp %= mod;
        }

        System.out.println(surp);
        return;
    }

    private static void solve_147_C() {
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        int[] A = new int[20];
        int[][] x = new int[20][20];
        int[][] y = new int[20][20];

        for (int i = 1; i <= N; i++) {
            A[i] = sc.nextInt();
            for (int j = 1; j <= A[i]; j++) {
                x[i][j] = sc.nextInt();
                y[i][j] = sc.nextInt();
            }
        }
        int ans = 0;
        for (int bits = 1; bits < (1 << N); bits++) {
            boolean ok = true;
            for (int i = 1; i <= N; i++) {
                if ((bits & (1 << (i - 1))) == 0) continue;
                for (int j = 1; j <= A[i]; j++) {
                    if ((((bits >> (x[i][j] - 1)) & 1) ^ y[i][j]) == 1) ok = false;
                }
            }
            if (ok) ans = Math.max(ans, counter(bits));
        }
        System.out.println(ans);
        return;
    }

    private static int counter(int x) {
        if (x == 0) return 0;
        return counter(x >> 1) + (x & 1);
    }
}

Measured memory_bytes: 97768
import sys
S = int(input())
mod = 10**9 + 7
if S <= 2:
  print(0)
  sys.exit()
d = [[0 for i in range(S + 1)] for j in range(S + 1)]
d[3][1] = 1
for j in range(S - 3):
  for i in range(S):
    d[j+4][i+1] = (d[j+3][i+1] + d[j+1][i]) %mod
print(sum(d[S])%mod)

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

using namespace std;
typedef long long ll;
const ll mx = 10000007;
const ll mod = 1e9 + 7;
const double pi = acos(-1);
#define    ss   second
#define    ff   first
#define    pb   push_back
#define gcd(a, b) __gcd((a), (b))
#define lcm(a, b) ((a) / __gcd((a), (b)) * (b))
#define FIO ios_base::sync_with_stdio(false);  cin.tie(NULL);


int main() {
    FIO;
    ll n;
    cin >> n;
    vector<ll>a, b, c;
    for (ll i = 0; i < n; i++) {
        ll x;
        cin >> x;
        a.push_back(x);
    }

     for (ll i = 0; i < n; i++) {
        ll x;
        cin >> x;
        b.push_back(x);
    }

     for (ll i = 0; i < n; i++) {
        ll x;
        cin >> x;
        c.push_back(x);
    }
    ll ans = 0;
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    sort(c.begin(), c.end());

    for (ll i = 0; i < n; i++) {
        ll p = b[i];
        auto aa = upper_bound(a.begin(), a.end(), p - 1);
        auto cc = lower_bound(c.begin(), c.end(), p + 1);

        ll k = c.end() - cc;
        ll kk = aa - a.begin();
        ans += (k * kk);
    }

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


Measured memory_bytes: 6340
#include <bits/stdc++.h>
#define int long long
#define fi first
#define se second

using namespace std;

const int maxN = 1e5 + 10;
const int inf = 3e18 + 10;

typedef pair<int, int> ii;

int k;
int dist[maxN];
vector<ii> adj[maxN];

void dijkstra(int src){
    priority_queue<ii , vector<ii> , greater<ii> > pq ;

    for(int i = 0; i < maxN; ++i)
        dist[i] = inf;

    pq.push({0,src});
    dist[src] = 0 ;

    while(!pq.empty()){
        int u = pq.top().se;
        pq.pop();

        for(auto &t : adj[u]){
            int v = t.fi;
            int w = t.se;
            if(dist[v] > dist[u] + w){
                dist[v] = dist[u] + w ;
                pq.push({dist[v], v});
            }
        }
    }

    cout << dist[0] + 1 << endl;
}

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

    cin >> k;

    for(int i = 1; i <= k; ++i){
        int u = i % k;
        int v = (i + 1) % k;
        adj[u].push_back({v,1});
    }

    for(int i = 1; i <= k; ++i){
        int u = i % k;
        int v = (10 * i) % k;
        adj[u].push_back({v,0});
    }

    dijkstra(1);
}


Measured memory_bytes: 12060
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VRSORT(v) sort(v.begin(), v.end(),greater<int>());
#define INF 999999999
#define MOD 1000000007
#define M_PI 3.14159265358979323846
#define ALL(X) (X).begin(),(X).end()

#ifdef __LOCAL
    #define DBG(X) cout << #X << " = " << (X) << endl;
    #define SAY(X) cout << (X) << endl;
#else
    #define DBG(X)
    #define SAY(X)
#endif

#ifdef __LOCAL
    #include <filesystem>
    namespace fs = std::filesystem;
#endif

using namespace std;

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

int dx[]={1, 0, -1, 0, 0};
int dy[]={0, 1, 0, -1, 0};
const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);
const int NIL = -1;
static mt19937 _g(time(nullptr));
 
std::string pad(int num){ char buffer[4]; std::snprintf(buffer, sizeof(buffer), "%03d", num); return buffer;}
inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T> inline T sign(T x) { return T(x > 0) - T(x < 0); }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline T fetch() { T ret; cin >> ret; return ret; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }


int N;
vector<ll> A,B;
int countMinus=0;


void input(){
  fast_io();
  #ifdef __LOCAL
    fs::path p = __FILE__;
    fs::path input,output;
    input = output = p.parent_path();
    input += string("/input/") + string(p.stem()) + string(".txt");
    output += string("/output/") + string(p.stem()) + string(".txt");
    freopen(input.c_str(), "r", stdin);
    freopen(output.c_str(), "w", stdout);
  #endif
  cin >> N;

  for (int i = 0; i < N; i++)
  {
    ll a;
    cin >> a;
    A.push_back(a);
    B.push_back(abs(a));
    countMinus += (a<0);
  }
  
}


int solve(){
  ll ans=0;
  ans = (countMinus%2==0) ? accumulate(ALL(B),0LL):accumulate(ALL(B),0LL)-*min_element(ALL(B))*2;
  cout << ans << endl;
  return 0;
}

int main()
{
  input();
  solve();
  return 0;
}


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

bool isOK(int C, int M){
  if ( M < C ) M += 60;
  return (M - C) <= 8;
}

void print(string str, int r, int n){
  if ( n == 0 ){
    cout << str << " no guest" << endl;
  } else {
    cout << str << " " << 100*r/n << endl;
  }
}

main(){
  int n, hh, mm, C, T;
  char ch;

  while( cin >> n, n){
    int nL, nD, nM, L, D, M;
    nL = nD = nM = L = D = M = 0;
    for ( int i = 0; i < n; i++ ){
      cin >> hh >> ch >> mm >> T;
      if ( hh <= 2 ) hh += 24;
      C = 60*hh + mm;
      if ( 660 <= C && C < 900 ){
	if ( isOK(mm, T) ) L++;
	nL++;
      } else if ( 1080 <= C && C < 1260 ){
	if ( isOK(mm, T) ) D++;
	nD++;
      } else if ( 1260 <= C && C < 1560){
	if ( isOK(mm, T) ) M++;
	nM++;
      }
    }

    print("lunch", L, nL);
    print("dinner", D, nD);
    print("midnight", M, nM);
  }
}

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

int main() {
    ll n;
    cin >> n;
    map<ll, ll> mp;
    vector<ll> a(n);
    for (ll i = 0; i < n; ++i) {
        ll p;
        cin >> p;
        mp[p]++;
        a[i] = p;
    }
    ll sum = 0;
    for (pair<ll, ll> i : mp) if (i.second >= 2) sum += i.second * (i.second - 1) / 2;
    for (ll j = 0; j < n; ++j) {
        ll x = mp[a[j]];
        cout << sum - x * (x - 1) / 2 + (x - 1) * (x - 2) / 2 << "\n";
    }
}


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

using namespace std;

int honsu[10] = {6,2,5,5,4,5,6,3,7,6};
int usable[10] = {0};
string dp[100010];

int cmp(string s, string t){
  if (s.length()>t.length()) return +1;
  else if (s.length()<t.length()) return -1;
  for (int i=0; i<s.length(); i++){
    if (s[i]>t[i]) return +1;
    if (s[i]<t[i]) return -1;
  }
  return 0; // s==t
}



int main(void){
  int n,m;
  
  cin >> n >> m;
  for (int i=0; i<m; i++){
    int t;
    cin >> t;
    usable[t] = 1;
  }
  // DP init
  for (int i=1; i<=9; i++){
    if (usable[i]){
      dp[honsu[i]] = std::to_string(i);
    }
  }
  // DP
  for (int i=2; i<=n; i++){
    for (int j=1; j<=9; j++){
      if (!usable[j]) continue;
      if (honsu[j]<=i){
        if (dp[i-honsu[j]]=="") continue;
        if (cmp(dp[i], dp[i-honsu[j]]+(char)('0'+j))<0){
          dp[i] = dp[i-honsu[j]]+(char)('0'+j);
        }
      }
    }
//    cout << i << ":" << dp[i] << endl;
  }
  cout << dp[n] << endl;
  return 0;
}


Measured memory_bytes: 42496
#include<bits/stdc++.h>
using namespace std;
typedef long long int llint;
typedef long int lint;
typedef vector<char> vchar;
typedef vector<int> vint;
typedef vector<vector<int>> vvint;
typedef vector<vector<char>> vvchar;
#define vsort(v) sort((v).begin(), (v).end())
#define vreverse(v) reverse((v).begin(), (v).end())
#define pb(a) push_back(a)
#define INF 1000000007
#define MOD 1e9+7
int main(){
  lint n,m,i,j,b;cin>>n>>m;
  vint k(m),p(m);
  vvint s(m,vint(0));
  for(i=0;i<m;i++){
  cin>>k[i];
  for(j=0;j<k[i];j++){cin>>b;b--;s[i].pb(b);}
  }
  for(i=0;i<m;i++){cin>>p[i];}
  int ans=0;
  lint li=0;li |= (1<<n);
  for(lint bit=0;bit<li;bit++){
    bool d=true;
    for(j=0;j<m;j++){
      int g=0;
      for(int y=0;y<k[j];y++){
        if(bit&(1<<s[j][y])){g++;}
      }
      if((g%2)!=p[j]){d=false;}
    }
    if(d){ans++;}
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  string s1,s2,s3;
  cin >> s1 >> s2 >> s3;
  char S1,S2,S3;
  S1=s1.at(0);
  S2=s2.at(0);
  S3=s3.at(0);
  
  S1-='a'-'A';
  S2-='a'-'A';
  S3-='a'-'A';
  
  cout << S1 << S2 << S3 << endl;
}

Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn f(s: &[char]) -> bool {
    let m = s.len();
    for i in 0..m {
        if s[i] != s[m - 1 - i] {
            return false;
        }
    }
    true
}

use std::iter::Iterator;

fn main() {
    input! {
        n:usize,
    }

    let mut ans = false;

    for elem1 in 1..10 {
        for elem2 in 1..10 {
            if elem1 * elem2 == n {
                ans = true;

            }
        }
    }

    if ans {
        println!("Yes")
    }else{
        println!("No")
    }

}


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


int main()
{


     ios_base::sync_with_stdio(false);
     cin.tie(NULL);
   

 long long int first,second;
 cin>>first>>second;
 vector<long long int>nish(first+2,0);
 vector<long long int>nish2(first+2,0);
 for(int i=1;i<=first;i++)
 {
    long long int temp;
    cin>>temp;
    nish[i]=temp;
 }

 int count=1;
 int flag=0;
 int i=1;
 while(nish2[i]==0 && flag==0){
       nish2[i]=count;
       i=nish[i];
       count++;

       if(count==second+1)
       {
        flag=1;
        cout<<i<<endl;
         break;
       }

 }

 if(!flag)
 {
    int round=count-nish2[i];
    int roundto=(second-(count-1))%round;
    int totalcount=0;
    while(totalcount<roundto)
    {
       i=nish[i];
       totalcount++;
    }

    cout<<i<<endl;
 }


  return 0;

}

Measured memory_bytes: 6352
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <cstring>
#include <cstdio>
#include <cmath>
using namespace std;

int main() {

    int n, l;
    cin >> n >> l;

    vector<string> s(n);
    for (int i = 0; i < n; i++)
        cin >> s[i];
    
    sort(s.begin(), s.end());

    for (int i = 0; i < n; i++)
        cout << s[i];

    return 0; 

}


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

using namespace std;
#define TOSTRING(x) #x
#define SZ(x) (int)(x).size()
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(s) (s).begin(), (s).end()
#define dis distance
#define so(V) sort(ALL(V))
#define rev(V) reverse(ALL(V))
#define uni(v) v.erase( unique(ALL(v)) , v.end());

typedef long long unsigned int llu;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<vector <int> > vvi;
typedef vector<vb> vvb;
const double EPS = 1e-9;
const int MOD = 1e9+7;
const int INF = (1 << 29);
const ll LINF = 1e18;
const double PI = acos(-1);

struct Edge{
    int from,to;
    ll cost;
    Edge(int _from = -1, int _to = -1, ll _cost = -1):from(_from),to(_to),cost(_cost){}
};

typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

int V,E;
typedef pair<ll,int> P;

vll dijkstra(int s,Graph G){
    priority_queue<P, vector<P>, greater<P> > Q;
    vll ret(V,LINF);
    ret[s] = 0;
    Q.push(P(0,s));

    while(!Q.empty()){
        P p = Q.top();Q.pop();
        int v = p.second;
        for(Edge e: G[v]){
            if(ret[e.to] > p.first + e.cost){
                ret[e.to] = p.first + e.cost;
                Q.push(P(ret[e.to], e.to));
            }
        }
    }
    return ret;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> V >> E;
    int r;
    cin >> r;
    Graph G(V);
    REP(i,E){
        int s,t,d;
        cin >> s >> t >> d;
        G[s].push_back(Edge(s,t,d));
    }

    vll dist = dijkstra(r,G);
    REP(i,V){
        if(dist[i] == LINF){
            cout << "INF" << endl;
        }else{
            cout << dist[i] << endl;
        }
    }
    return 0;
}



Measured memory_bytes: 30704
#include<cmath>
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
stack<int> st;
queue<int> qu;
queue<pair<int,int> > qu2;
priority_queue<ll> pq;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define rep2(i,n) for(int i=1; i<=(int)(n); i++)
#define mins(x,y) x=min(x,y)
#define maxs(x,y) x=max(x,y)
typedef set<int> set_t;
typedef set<string> set_g;
typedef complex<double> xy_t;
static const int NIL = -1;
static const int INF = 1000000007;
#define mp make_pair
#define sz(x) int(x.sise())
#define mod 1000000007
#define reps(i,s,n) for(int i = s; i < n; i++)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
deque<int> deq;
#define fi first
#define se second
//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
typedef pair<int, int> P;
vector<ll> v;
int main(){
    int n;
    cin >> n;
    ll mn=INF;
    ll tol=0;
    rep(i,n){
        ll a;
        cin >> a;
        v.push_back(a);
    }
    ll ans=0;
    sort(v.begin(),v.end(),greater<ll>());
    rep(i,n){
        if(i==0){
            pq.push(v[0]);
        }else{
            int k=pq.top();
            ans+=k;
            pq.pop();
            pq.push(v[i]);
            pq.push(v[i]);
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 8000
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
using namespace std;
typedef long long int ll;

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	ll h,w,n; cin >> h >> w >> n;
	map<pair<ll,ll>,ll> mp;
	for(int i=0;i<n;i++){
		int a,b; cin >> a >> b;
		for(int j=-1;j<=1;j++){
			for(int k=-1;k<=1;k++){
				int nx=a+j,ny=b+k;
				if(1<=nx&&nx<=h&&1<=ny&&ny<=w){
					mp[make_pair(nx,ny)]++;
				}
			}
		}
	}
	vector<ll> ans(10,0);
	ans[0]=(h-2)*(w-2);
	for(auto p:mp){
		if(p.first.first==1||p.first.first==h)continue;
		if(p.first.second==1||p.first.second==w)continue;
		ans[p.second]++;
		ans[0]--;
	}
	for(int i=0;i<10;i++){
		printf("%lld\n",ans[i]);
	}
}

Measured memory_bytes: 58496
from sys import stdin
def main():
    #入力
    readline=stdin.readline
    mod=10**9+7
    N=int(readline())
    S1=readline().strip()
    S2=readline().strip()

    now=0
    before="Z"
    res=1
    while now<N:
        if S1[now]==S2[now]:
            if now==0:
                res*=3
            else:
                if before=="X":
                    res*=2
                else:
                    res*=1
            now+=1
            before="X"
        else:
            if now==0:
                res*=6
            else:
                if before=="X":
                    res*=2
                else:
                    res*=3
            now+=2
            before="Y"

    print(res%mod)
if __name__=="__main__":
    main()

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

int main(void){
  vector<int> a(5);
  int min = 10,sum = 0;
  for(int i = 0; i < 5; i++){
    cin >> a[i];
    sum += a[i];
    if(a[i] % 10 != 0){
      sum += (10 - a[i] % 10);
      if(a[i] % 10 < min)min = a[i] % 10;
    }
  }
  cout << sum - (10 - min) << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,s,e) for(int i=(s); i<(e);i++)
#define rep(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n)
#define repe(i,n) for(auto &&i:n)
#define all(v) (v).begin(),(v).end()
#define decimal fixed<<setprecision(20)
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)
using namespace std;
using LL = long long;
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 int INF = 1e9;
const LL LLINF = 1e16;


int main(){
    fastcin();

    int n;
    cin >> n;
    string s;
    cin >> s;

    vector<int> idx(10, -1);
    rep(i, n){
        if(idx[s[i]-'0'] == -1) idx[s[i]-'0'] = i;
    }
    int ans = 0;
    rep(i, 10){
        if(idx[i] == -1) continue;
        vector<int> idx2(10, -1);
        REP(j, idx[i]+1, n){
            if(idx2[s[j]-'0'] == -1) idx2[s[j]-'0'] = j;
        }

        rep(j, 10){
            if(idx2[j] == -1) continue;
            vector<int> idx3(10, -1);
            REP(k, idx2[j]+1, n){
                if(idx3[s[k]-'0'] == -1){
                    idx3[s[k]-'0'] = k;
                    ans++;
                }
            }
        }
    }
    cout << ans << endl;
}

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

typedef struct {
  int number;
  int kazu;
} set;

int cmp( const void *p, const void *q ) {
    return ((set*)p)->number - ((set*)q)->number;
}

int main(){
  int i,j,k,N;
  long K;
  
  scanf("%d %ld",&N,&K);
  set A[N];
  for(i=0;i<N;i++){
    scanf("%d %d",&A[i].number,&A[i].kazu);
  }
  qsort(A,sizeof(A) / sizeof(set),sizeof(set),cmp);
  i=0;
  while(K>0){
    K-=A[i].kazu;
    i++;
  }
  printf("%d\n",A[i-1].number);
  return 0;
}




Measured memory_bytes: 1788
var
	n,p,s:int64;
    f:array[0..1000010] of longint;
    i,j,t:longint;
begin
	read(n,p);
    if n=1 then
    begin
    	writeln(p);
        halt;
    end;
    if p=1 then 
    begin
    	writeln(1);
        halt;
    end;
    fillchar(f,sizeof(f),0);
    i:=1;
    t:=trunc(sqrt(p))+1;
    while (p<>1) and (i<=t) do
    begin
    	inc(i);
        while p mod i=0 do
        begin
        	p:=p div i;
            inc(f[i]);
        end;
    end;
    s:=1;
    for i:=2 to t do
    	if f[i]>=n then
        	for j:=1 to f[i] div n do s:=s*i;
    writeln(s);
end.


Measured memory_bytes: 3968
#include<bits/stdc++.h>
using namespace std;
char buf[1<<20],*fs,*ft;
inline char getc()
{
    return (fs==ft&&(ft=(fs=buf)+fread(buf,1,1<<15,stdin),fs==ft))? 0 : *fs++;
}
inline int read()
{
    int s=0,w=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){s=s*10+ch-'0';ch=getchar();}
    return s*w;
}
const double eps=1e-10;
struct poi
{
	double x,y;
};
poi p[505];
int n;
inline double dist(poi aa,poi bb)
{
	return sqrt((aa.x-bb.x)*(aa.x-bb.x)+(aa.y-bb.y)*(aa.y-bb.y));
}
inline poi cicenter(poi aa,poi bb,poi cc)
{
	poi ret;
	double a1=bb.x-aa.x,b1=bb.y-aa.y,c1=(a1*a1+b1*b1)/2;
	double a2=cc.x-aa.x,b2=cc.y-aa.y,c2=(a2*a2+b2*b2)/2;
	double d=a1*b2-a2*b1;
	ret.x=aa.x+(c1*b2-c2*b1)/d;
	ret.y=aa.y+(a1*c2-a2*c1)/d;
	return ret;
}
inline void micircle(poi *p,int n,poi &c,double &r)
{
	random_shuffle(p+1,p+n+1);
	c=p[1];
	r=0;
	int i=2,j=1,k=1;
	while(i<=n)
	{
		if(dist(p[i],c)>r+eps)
		{
			c=p[i];
			r=0;
			j=1;
			while(j<i)
			{
				if(dist(p[j],c)>r+eps)
				{
					c.x=(p[i].x+p[j].x)/2;
					c.y=(p[i].y+p[j].y)/2;
					r=dist(p[j],c);
					k=1;
					while(k<j)
					{
						if(dist(p[k],c)>r+eps)
						{
							c=cicenter(p[i],p[j],p[k]);
							r=dist(p[i],c);
						}
						++k;
					}
				}
				++j;
			}
		}
		++i;
	}
}
int main()
{
	srand(time(0));
	scanf("%d",&n);
	poi c;
	double r;
	int i=1;
	while(i<=n)
	{
		scanf("%lf%lf",&p[i].x,&p[i].y);	
		++i;
	}
	micircle(p,n,c,r);
	printf("%.17lf\n",r);
	return 0;
}
/*
1996Äê£º¶«·½ÁéÒì´«£¨TOH1£©
1997Äê£º¶«·½·âÄ§Â¼£¨TOH2£©
1997Äê£º¶«·½ÃÎÊ±¿Õ£¨TOH3£©
1998Äê£º¶«·½»ÃÏëÏç£¨TOH4£©
1998Äê£º¶«·½¹Öç²Ì¸£¨TOH5£©
2002Äê£º¶«·½ºìÄ§Ïç£¨TOH6£©
2003Äê£º¶«·½ÑýÑýÃÎ£¨TOH7£©
2004Äê£º¶«·½ÝÍÃÎÏë£¨TOH7.5£©
2004Äê£º¶«·½ÓÀÒ¹³­£¨TOH8£©
2005Äê£º¶«·½»¨Ó³Ú££¨TOH9£©
2005Äê£º¶«·½ÎÄ»¨Ìû£¨TOH9.5£©
2007Äê£º¶«·½·çÉñÂ¼£¨TOH10£©
2008Äê£º¶«·½ç³ÏëÌì£¨TOH10.5£©
2008Äê£º¶«·½µØÁéµî£¨TOH11£©
2009Äê£º¶«·½ÐÇÁ«´¬£¨TOH12£©
2009Äê£º¶«·½·ÇÏëÌìÔò£¨TOH12.3£©
2010Äê£º¶«·½ÎÄ»¨ÌûDS£¨TOH12.5£©
2010Äê£º¶«·½ÈýÔÂ¾«£¨TOH12.8£©
2011Äê£º¶«·½ÉñÁéÃí£¨TOH13£©
2013Äê£º¶«·½ÐÄç²Â¥£¨TOH13.5£©
2013Äê£º¶«·½»ÔÕë³Ç£¨TOH14£©
2014Äê£ºµ¯Ä»ÌìÐ°¹í£¨TOH14.3£©
2014Äê£º¶«·½ÉîÃØÂ¼£¨TOH14.5£©
2015Äê£º¶«·½ç¤Öé´«£¨TOH15£©
2017Äê£º¶«·½Æ¾ÒÀ»ª£¨TOH15.5£©
2017Äê£º¶«·½Ìì¿Õè°£¨TOH16£©
*/

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

using namespace std;
using ll = long long;
constexpr int mod = 1e9+7;
constexpr int md = mod;
int main(){
    int n,m;
    cin>>n>>m;
    vector<int> a(m+1);;
    
    for(int i=0;i<n;++i){
        int k; cin>>k;
        for(int j=0;j<k;++j){
            int ai; cin>>ai;
            a[ai]++;
        }
    }
    int num = 0;
    for(auto b : a){
        if(b >= n){
            num++;
        }
    }
    cout << num << endl;
    return 0;
}



Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>

int main()
{
    using namespace std;

    vector<vector<int>> grid;
    int stdin;
    bool TakahashiKunnNoUsoTsuki = false;
    vector<int> a(3), b(3);
    for(int i = 0; i < 3; i++)
    {
	std::vector<int> line;
	for(int j = 0; j < 3; j++)
	{
	    cin >> stdin;
	    line.push_back(stdin);
	}
	grid.push_back(line);
    }

    a[0] = 0;
    for(int j = 0; j < 3; ++j)
	b[j] = grid[0][j];
    for(int i = 1; i < 3; ++i)
	a[i] = grid[i][0] - b[0];
    

    for(int i = 0; (i < 3) and !TakahashiKunnNoUsoTsuki; ++i)
    {
	for(int j = 0; (j < 3) and !TakahashiKunnNoUsoTsuki; ++j)
	{
	    if(grid[i][j] != a[i] + b[j])
		TakahashiKunnNoUsoTsuki = true;
	}
    }

    

    if(TakahashiKunnNoUsoTsuki)
	cout << "No" << endl;
    else
	cout << "Yes" << endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define fill(a,val) memset(a, (val), sizeof a)
#define pb push_back
#define lli long long int
#define scantype int
#define endl "\n"
#define unique(x) x.erase(unique(x.begin(),x.end()), x.end())
 
lli MOD  = 1000000007;
lli inf = 1e15;
 
void scan(scantype &x);
lli powermod(lli _a,lli _b,lli _m){lli _r=1;while(_b){if(_b%2==1)_r=(_r*_a)%_m;_b/=2;_a=(_a*_a)%_m;}return _r;}
lli string_to_number(string s){lli x=0; stringstream convert(s); convert>>x; return x;}
lli add(lli a,lli b){lli x = (a+b)%MOD; return x; }
lli mul(lli a,lli b){lli x = (a*b)%MOD; return x; }
lli sub(lli a,lli b){lli x = (a-b+MOD)%MOD; return x; }
lli divi(lli a,lli b){lli x = a;lli y = powermod(b,MOD-2,MOD);lli res = (x*y)%MOD;return res;}
 
#define N 100003
 
int main(void)
{
  int n;
  cin>>n;

  int arr[n+1];
  for(int i=1;i<=n;i++){
  	scan(arr[i]);
  }

  int res = 0;
  for(int i=1;i<=n;i++){
  	if(arr[i] == i){
  		res++;
  		if(i+1<=n && arr[i+1]==i+1) i = i + 1;
  	} 
  }
  cout<<res;
  return 0;
}
 
 
void scan(scantype &x)
{
    register int c = getchar(); //for negative/positive
    x = 0;
    int neg = 0;
    for(;((c<48 || c>57) && c != '-');c = getchar());
    if(c=='-') {neg=1;c=getchar();}
    for(;c>47 && c<58;c = getchar()) {x = (x<<1) + (x<<3) + c - 48;}
    if(neg) x=-x;
}

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


int main() 
{
    long N,D;
    cin>>N>>D;

    vector<pair<long,long>>P(N);
    for (int i = 0; i < N; i++)
    {
        cin>>P[i].first>>P[i].second;
    }

    long ans=0;
    for (long i = 0; i < N; i++)
    {
        ulong x2=P[i].first*P[i].first;
        ulong y2=P[i].second*P[i].second;
        ulong D2=D*D;

        if(x2+y2<=D2)
        {
            ans++;
        }
    }
    
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 6376
while True:
    n = int(raw_input())
    if n == 0: break
    ans = [0 for i in range(7)]
    for i in xrange(n):
        age = int(raw_input())
        if age <= 9:
            ans[0] += 1
        elif age <= 19:
            ans[1] += 1
        elif age <= 29:
            ans[2] += 1
        elif age <= 39:
            ans[3] += 1
        elif age <= 49:
            ans[4] += 1
        elif age <= 59:
            ans[5] += 1
        else:
            ans[6] += 1
    for c in ans:
        print c

Measured memory_bytes: 4236
#include<bits/stdc++.h>
using ll = long long;
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define ALL(x) x.begin(),x.end()

#define INF (ll)1e9 //10^9:∞
#define LLINF (ll)1e12
#define MOD (ll)(1e9+7) //10^9+7:合同式の法
#define PI 3.141592653589
#define PB push_back
#define F first
#define S second
#define __MAGIC__ ios::sync_with_stdio(false);cin.tie(nullptr);

#define YESNO(T) if(T){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define yesno(T) if(T){cout<<"yes"<<endl;}else{cout<<"no"<<endl;}
#define YesNo(T) if(T){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}

#define Graph vector<vector<int>>
#define PII pair<int,int>
#define VI vector<int>
#define VVI vector<vector<int>>
#define VPII vector<pair<int,int>>

#define DDD fixed<<setprecision(10)
#define endl "\n"

using namespace std;
/*..................DEFINE GLOBAL VARIABLES...................*/


/*.....................DEFINE FUNCTIONS ......................*/



/*.........................kemkemG0...........................*/
signed main() {
	__MAGIC__


	int N, M;
	cin >> N >> M;
	VI P(M), Y(M);
	
	REP(i, M) {cin >> P[i] >> Y[i]; P[i]--; Y[i]--;}

	vector<vector<int>> vals(N);

	REP(i, M) { vals.at(P[i]).emplace_back(Y[i]); }

	REP(i, N) {
		sort(ALL(vals[i]));
		vals[i].erase(unique(ALL(vals[i])), vals[i].end());
	}

	REP(i, M) {
		cout << setfill('0') << right << setw(6) << P[i] + 1;
		int id = lower_bound(ALL(vals[P[i]]), Y[i]) - vals[P[i]].begin();
		cout << setfill('0') << right << setw(6) << id + 1;
		cout << endl;
	}

	return 0;
}


Measured memory_bytes: 9392
/*
ID: espr1t
TASK: 
KEYWORDS: 
*/

#include <iostream>

using namespace std;

int ans;
int limit;

void recurse(long long num, int mask) {
    if (num > limit)
        return;
    if ((mask & 7) == 7)
        ans++;
    recurse(num * 10 + 3, mask | 1);
    recurse(num * 10 + 5, mask | 2);
    recurse(num * 10 + 7, mask | 4);
}

int main(void) {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	cin >> limit;
	
	recurse(0, 0);
	cout << ans << "\n";
	
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<vector>
#include<cmath>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb(in,tmp) in.push_back(tmp)
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
using namespace std;
int main(){
  int n,m;
  while(cin>>n>>m,n||m){
    vector<int>in(n);
    rep(i,n)cin>>in[i];
    sort(all(in),greater<int>());
    int sum=0;
    rep(i,n){
      if(!((i+1)%m))continue;
      sum+=in[i];
    }
    cout<<sum<<endl;
  }
}

Measured memory_bytes: 1216
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repn(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define EQ(a,b) (abs((a)-(b))<eps)
template<class T> void chmin(T& a,const T& b){if(a>b)a=b;}
template<class T> void chmax(T& a,const T& b){if(a<b)a=b;}
ll N,L,T;
ll X[100100],W[100100];
vector<int> A;
int main(){
	cin >> N >> L >> T;
	for(int i=0;i<N;i++){
		cin >> X[i] >> W[i];
	}
	ll cnt = 0;
	ll K;
	for(int i=0;i<N;i++){
		int to;
		if(W[i]==1){
			to = (X[i]+T)%L;
		}else{
			to = (X[i]+L-T%L)%L;
		}
		if(i==0)K=to;
		A.pb(to);
		ll dist;
		if(W[i]!=W[0]){
			if(W[0]==1){
				dist = (X[i]-X[0]+L)%L;
			}else{
				dist = (X[0]-X[i]+L)%L;
			}
			if(dist<2*T)cnt += 1+(2*T-dist-1)/L;
		}
	}
	sort(all(A));
	ll id = 0;
	if(W[0]==1){
		id = cnt%N;
	}else{
		id = ((-cnt)%N+N)%N;
	}
	ll idx = -1;
	if(W[0]==2){
		for(int i=N-1;i>=0;i--){
			if(A[i]==K){
				idx = i;
				break;
			}
		}
	}else{
		for(int i=0;i<N;i++){
			if(A[i]==K){
				idx = i;
				break;
			}
		}
	}
	//cout << idx << ' ' << id << endl;
	ll st = (idx-id+N)%N;
	for(int i=0;i<N;i++){
		ll j = (st+i)%N;
		cout << A[j] << endl;
	}
	return 0;
}

Measured memory_bytes: 3320
n,k=map(int,input().split())
lst = [i for i in range(1, n+1)]
for j in range(k):
  kashi = int(input())
  s = input().rstrip().split(' ')
  for k in range(len(s)):
    if int(s[k]) in lst:
      lst.remove(int(s[k]))
print(len(lst))

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

#define fio() ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define pb push_back
#define mp make_pair

using namespace std;

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

const ll mod = 1e9 + 7;
const ll maxn = 1e5 + 6;
const ll N = 1e2 + 2;
const ll inf = 1e12;
const ld eps = 1e-6;

ll n, x;

int main() {
	fio();
	cin >> n >> x;
	cout << 3 * (n - __gcd(n, x)) << endl;
	return 0;
}


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

using namespace std;

#define int long long
#define PB push_back
#define PPB pop_back
typedef pair<int, int> pii;
static const int INF = 1LL<<61;
static const double PI = acos(-1.0);
//static const int MAX_N = 100005;
//static const int MOD = 1000000007;

int m, n, P[10005], dp[505][10005];
pii bx[505];

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

    cin >> m >> n;
    for (int i = 1; i <= m; ++i) {
        cin >> P[i];
    }
    sort(P + 1, P + m + 1, greater<int>());
    for (int i = 1; i <= m; ++i) {
        P[i] += P[i - 1];
    }

    for (int i = 1; i <= n; ++i) {
        cin >> bx[i].second >> bx[i].first;
    }

    fill(dp[0], dp[505], INF);
    dp[0][0] = 0;
    for (int i = 1; i <= n; ++i) {
        dp[i][0] = 0;
        for (int j = 1; j <= m; ++j) {
            dp[i][j] = min(dp[i - 1][j], dp[i - 1][max(j - bx[i].second, 0LL)] + bx[i].first);
        }
    }

    int ans = 0;
    for (int i = 1; i <= m; ++i) {
        ans = max(ans, P[i] - dp[n][i]);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 40776
a , b, c = map(int,input().split())
aaa = [a,b,c]
m = max(a,b,c)
aaaa = list(sorted(aaa))
x = aaaa[0]
y = aaaa[1]
z = aaaa[2]
sousa = 0

if (3 * m) % 2 == (a + b + c) % 2:
    truemax = m    
else:
    truemax = m + 1
    
    
while x <= truemax:
    sousa = sousa + 1
    x = x + 2
    
while y <= truemax:
    sousa = sousa + 1
    y = y + 2
    
b = list(sorted([x,y,z]))

xx = b[0]
yy = b[1]
zz = b[2]
    
sousa = sousa + (3 * truemax -xx -yy -zz) //2
print(sousa)

Measured memory_bytes: 3192
from collections import deque
import sys
sys.setrecursionlimit(10**7)
N = int(input())
S = [input().strip() for _ in range(N)]

flg = False
max_cnt = 1
for sp, row in enumerate(S):
    # start BFS
    C = [0]*N
    C[sp] = 1
    q = deque([])
    for i, v in enumerate(row):
        if v == '1':
            q.append(int(i))

    cnt = 1 # length
    c = -1 # color
    while q:
        for i in range(len(q)):
            np_ind = q.popleft()
            if C[np_ind] == -c:
                print(-1)
                exit()
            elif C[np_ind] == c:
                pass
            else:
                C[np_ind] = c
                for i, v in enumerate(S[np_ind]):
                    if v == '1' and C[i] == 0:
                        q.append(int(i))
        cnt += 1
        c *= -1
    if max_cnt < cnt:
        max_cnt = cnt

print(max_cnt)

Measured memory_bytes: 3572
import java.util.*

fun main(args: Array<String>) {
  val sc = Scanner(System.`in`)
  val n = sc.nextInt()

  val mod = 1_000_000_000 + 7

  var n10 = 1L
  for (i in 1..n) {
    n10 = n10 * 10 % mod
  }
  var n9 = 1L
  for (i in 1..n) {
    n9 = n9 * 9 % mod
  }
  var n8 = 1L
  for (i in 1..n) {
    n8 = n8 * 8 % mod
  }

  var ans = n10 - n9 - n9 + n8
  ans %= mod
  ans = (ans+mod)%mod

  println(ans)


}


Measured memory_bytes: 36344
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int N;
    int i;
    int cnt = 0;
    int MAX = 0;
    int MAX_ID = 0;
    int MAX2 = 0;

    cin >> N;
    vector<int>A(N);

    for (i = 0; i < N; i++){
      cin >> A.at(i);
      if (A.at(i) >= MAX){
        MAX2 = MAX;
        MAX = A.at(i);
        MAX_ID = i;
      }else if (A.at(i) >= MAX2){
        MAX2 = A.at(i);
      }
    }
    sort(A.begin(), A.end());
  
    for (i = 0; i < N; i++){
      if(i != MAX_ID){
        cout << MAX << endl;
      } else {
        if (A.at(N-1) == A.at(N-2)){
          cout << MAX << endl;
        } else {
          cout << MAX2 << endl;
        }
      }
    }
}

Measured memory_bytes: 2432