akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.*;
import java.util.stream.Collectors;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }
    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int N = scan.nextInt();
        int K = scan.nextInt();
        int L = scan.nextInt();
        UnionFind road = new UnionFind(N);
        UnionFind train = new UnionFind(N);
        for (int i = 0; i < K; i++) {
            int p = scan.nextInt() - 1;
            int q = scan.nextInt() - 1;
            road.merge(p, q);
        }
        for (int i = 0; i < L; i++) {
            int p = scan.nextInt() - 1;
            int q = scan.nextInt() - 1;
            train.merge(p, q);
        }
        Map<Long, Integer> count = new HashMap<>();
        for (int i = 0; i < N; i++) {
            long r_p = road.parent(i);
            long t_p = train.parent(i);
            long key = r_p * 1000000 + t_p;
            count.merge(key, 1, Integer::sum);
        }
        int[] answers = new int[N];
        for (int i = 0; i < N; i++) {
            long r_p = road.parent(i);
            long t_p = train.parent(i);
            long key = r_p * 1000000 + t_p;
            answers[i] = count.get(key);
        }
        System.out.println(Arrays.stream(answers).mapToObj(i -> Integer.toString(i)).collect(Collectors.joining(" ")));
    }
    class UnionFind {
        private int[] par;
        private Set<Integer>[] neighbors;
        UnionFind(int N) {
            this.par = new int[N];
            for (int i = 0; i < N; i++) {
                par[i] = i;
            }
            this.neighbors = new HashSet[N];
            for (int i = 0; i < N; i++) {
                this.neighbors[i] = new HashSet<>();
                this.neighbors[i].add(i);
            }
        }
        int parent(int N) {
            if (this.par[N] == N) {
                return N;
            }
            return this.par[N] = parent(this.par[N]);
        }
        boolean same(int x, int y) {
            int parent_x = parent(x);
            int parent_y = parent(y);
            return parent_x == parent_y;
        }
        void merge(int x, int y) {
            int parent_x = parent(x);
            int parent_y = parent(y);
            if (parent_x == parent_y) {
                return;
            }
            int size_x = this.neighbors[parent_x].size();
            int size_y = this.neighbors[parent_y].size();
            if (size_x < size_y) {
                this.par[parent_x] = parent_y;
                this.neighbors[parent_y].addAll(this.neighbors[parent_x]);
                this.neighbors[parent_x] = new HashSet<>();
                return;
            }
            this.par[parent_y] = parent_x;
            this.neighbors[parent_x].addAll(this.neighbors[parent_y]);
            this.neighbors[parent_y] = new HashSet<>();
        }
        Set<Integer> neighbors(int N) {
            return this.neighbors[parent(N)];
        }
    }
}


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

const int INF=10000;
int N, M;
string s[110], t[110];
int counter[110];
int ans;
int main(){
  cin >> N;
  for(int i=0; i<N; ++i){
    cin >> s[i];
    counter[i] =0;
  }
  cin >> M;
  for(int i=0; i<M; ++i){
    cin >> t[i];
  }
  for(int i=0; i<N; ++i){
    for(int j=0; j<N; ++j){
      if (s[i] == s[j]) ++counter[i];
    }
    for(int k=0; k<M; ++k){
      if (s[i] == t[k]) counter[i] -= 1;
    }
  }
  int max = -INF;
  for(int i=0; i<N; ++i){
    if( counter[i] > max) max = counter[i];
  }
  if (max <0) ans =0;
  else ans =max;
  
  cout << ans <<endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef unsigned long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	
	int n, k; string s; cin >> n >> k >> s;
	deque<int> q;
	vector<ll> base(n + 1, 1);
	map<pair<ll, int>, int> m;
	ll h = 0, hb = 0;
	
	rep(i, n) base[i + 1] = base[i] * 29;
	rep(i, n){
		q.push_back(s[i] - 'A');
		h += base[n - i - 1] * (s[i] - 'A' + 1);
		hb += base[n - i - 1] * 3;
	}
	
	int r = 0;
	for(; k; k--){
		if(m.count(pair<ll, int>(h, r))){
			k %= m[pair<ll, int>(h, r)] - k;
			if(!k) break;
		}
		m[pair<ll, int>(h, r)] = k;
		
		if(q[0] == r){
			q[0] = 1 ^ r;
			h += base[n - 1];
		}
		else{
			q.pop_front();
			r ^= 1;
			q.push_back(r);
			h -= base[n - 1] * 2;
			h = hb - h * 29 - 2;
		}
	}
	
	string ans;
	rep(i, n) ans += (q[i] ^ r) + 'A';
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 27796
package main

import (
	"bufio"
	"fmt"
	"os"
)

func out(x ...interface{}) {
	fmt.Println(x...)
}

func main() {
	r := bufio.NewReaderSize(os.Stdin, 100000)

	s, _, err := r.ReadLine()
	if err != nil {
		panic(err)
	}

	pr := -1
	prr := -1
	prrr := -1
	start := -1
	end := -1
	for i, v := range s {
		pr, prr, prrr = int(v), pr, prr
		if pr == prr {
			start = i
			end = i + 1
			break
		}
		if pr == prrr {
			start = i - 1
			end = i + 1
			break
		}
	}
	fmt.Println(start, end)
}


Measured memory_bytes: 640
import sys
p=["pre-meiji","meiji","taisho","showa","heisei"]
q=[-999999,18680908,19120730,19261225,19890108,99999999]
for line in sys.stdin.readlines():
    y,m,d=map(int,line.strip().split())
    t=y*10000+m*100+d
    i=0
    while not (q[i]<=t<q[i+1]):
        i+=1
    if i==0:print p[i]
    else:print p[i],y-q[i]/10000+1,m,d

Measured memory_bytes: 4232
use std::io::*;
use std::str::*;

struct Scanner<R: BufRead> {
    handle: R,
    buffer: String,
    token: Vec<String>,
}

impl<R: BufRead> Scanner<R> {
    fn new(input: R) -> Self {
        Scanner {
            handle: input,
            buffer: String::new(),
            token: Vec::new(),
        }
    }
    fn next<T: FromStr>(&mut self) -> T {
        loop {
            if let Some(s) = self.token.pop() {
                match s.parse::<T>() {
                    Ok(v) => {
                        return v;
                    },
                    _ => panic!("Scanner error"),
                }
            }
            self.buffer.clear();
            self.handle.read_line(&mut self.buffer).ok();
            let mut i = 0;
            for s in self.buffer.split_whitespace().rev() {
                if i >= self.token.len() {
                    self.token.push(String::new());
                }
                self.token[i].clear();
                self.token[i].push_str(s);
                i += 1;
            }
        }
    }
}

fn main() {
    let stdin = std::io::stdin();
    let sc = &mut Scanner::new(stdin.lock());
    run(sc);
}

fn run(sc: &mut Scanner<StdinLock>) {
    let n: usize = sc.next();
    let m: usize = sc.next();
    let mut a = vec![(false, false); n + 1];
    for _ in 0..m {
        let x: usize = sc.next();
        let y: usize = sc.next();
        if x == 1 {
            a[y].1 = true;
        }
        if y == n {
            a[x].0 = true;
        }
    }
    if a.iter().any(|p| p.0 && p.1) {
        println!("POSSIBLE");
    } else {
        println!("IMPOSSIBLE");
    }
}


Measured memory_bytes: 4352
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <cfloat>
#include <complex>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

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

int main() {
  string str;

  cin >> str;

  int dsum = 0;
  int num = 0;
  for (size_t i = 0; i < str.length(); i++) {
    dsum += str[i] - '0';
  }
  num = stoi(str);

  string ans = (num % dsum == 0) ? "Yes" : "No";
  
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <ccomplex>
#include <vector>
#include <cassert>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <numeric>
#include <list>
#include <assert.h>
#include <math.h>
#include <valarray>
#include <stdio.h>
#include <algorithm>
#include <set>
#include <complex>
#include <list>
#include <time.h>
#include <stack>
#include <locale>
#include <clocale>
#include <ctype.h>
#include <wchar.h>
#include <random>
#include <vector>
#include <unordered_map>
#include <bitset>

using namespace std;
typedef long long int LL;
typedef long long int ll;
typedef pair<long long int, long long int> pii;
typedef pair<double, double> pdd;

#define SORT(c) sort((c).begin(),(c).end())
#define BACKSORT(c) sort((c).begin(),(c).end(),std::greater<LL>())
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

LL mod = 1000000007;

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

  string S;
  cin >> S;
  LL cnt0 = 0;
  LL cnt1 = 0;
  REP(i,S.size()){
    if(S[i]=='0'){
      cnt0++;
    }else{
      cnt1++;
    }
  }
  cout << min(cnt0, cnt1) *2<< endl;
}


Measured memory_bytes: 1144
# ABC109
import fractions
from functools import reduce
def gcd_list(lst):
    return reduce(fractions.gcd, lst)

N, X = map(int, input().split())
x = list(map(int, input().split()))
x.append(X)
x.sort()

diff_list = [0] * (N)
for i in range(N):
    diff_list[i] = x[i+1] - x[i]


ans = gcd_list(diff_list)
print(ans)

Measured memory_bytes: 16280
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)

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; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }


int a[3];

int main() {
    for (int i = 0; i < 3; ++i) cin >> a[i];
    sort(a, a+3);
    if (a[0] == a[1]) cout << a[2] << endl;
    else cout << a[0] << endl;
}





Measured memory_bytes: 256
#include <stdio.h>

int main(){

    char a[200001];
    char b[200001];

    int d = 0;


    scanf("%s %s",a,b);

    for(int i = 0;a[i] != '\0'; ++i){
        if(a[i] != b[i])
            ++d;
    }
    printf("%d\n",d);

    return 0;
}

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

int main() {
  string s;
  cin >> s;

  cout << s.substr(0, 3) << endl;
  return 0;
}

Measured memory_bytes: 3628
import java.util.Scanner;

public class Main {
    public static void main (String[] args)
    {
        Scanner sc = new Scanner(System.in);
        String str;
        str = sc.nextLine();
        sc.close();
        char[] w = new char[str.length()];

        for (int i = 0; i < str.length(); i++)
        {
            w[i] = str.charAt(i);
            if ('a' <= w[i] && w[i] <= 'z') w[i] -= 32;
            else if ('A' <= w[i] && w[i] <= 'Z') w[i] += 32;
        }
        str = new String(w);

        System.out.println(str);
    }
}


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

int main(void) 
{
    int A,B,C,K;
    cin >> A >> B >> C;
    cin >> K;
    for(int i=0;i<K;i++){
        if(C<=A || C<=B) C *= 2;
        else if(B<=A) B *= 2;
        else break;
    }
    if(A<B && B<C) printf("Yes");
    else printf("No");
    
}

Measured memory_bytes: 3808
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define eb emplace_back
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
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; }
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}
int const INF = 1001001001;
ll const MOD = 1000000007;


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

int N;
cin >> N;

vl dp(N+1);

//初期条件
dp[0] = 2;
dp[1] = 1;

for(int i=2;i <= N;i++) {
    dp[i] = dp[i-1] + dp[i-2];
}

cout << dp[N] << endl;

return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

typedef struct flag{
  int connection;
} Flag;

Flag arr[100][100];



void def(){
  int i,j;
  for(i=0;i<100;i++){
    for(j=0;j<100;j++){
      arr[i][j].connection = 0;
    }
  }
}


int main () {
  int i,j,num,u,k,v;

  scanf("%d",&num);

  for(i=1;i<=num;i++){
    scanf("%d%d",&u,&k);
    for(j=1;j<=k;j++){
      scanf("%d",&v);
      arr[u][v].connection = 1;
    }
  }

  for(i=1;i<=num;i++){
    for(j=1;j<=num;j++){
      if(j==1){
	printf("%d",arr[i][j].connection);
      }
      else printf(" %d",arr[i][j].connection);
    }
    printf("\n");
  }

  return 0;
}
    



Measured memory_bytes: 2112
N, M, Q = map(int, input().split())
xy = [[0 for _ in range(N)] for _ in range(N)]
for _ in range(M):
    L, R = map(int, input().split())
    L = N - L + 1
    xy[L - 1][R - 1] += 1

xy_cum = [[0 for _ in range(N + 1)] for _ in range(N + 1)]
for i in range(1, N + 1):
    for j in range(1, N + 1):
        xy_cum[i][j] = xy[i - 1][j - 1] + xy_cum[i - 1][j] + xy_cum[i][j - 1] - xy_cum[i - 1][j - 1]

for q in range(Q):
    p, q = map(int, input().split())
    p = N - p + 1
    print(xy_cum[p][q])


Measured memory_bytes: 59608
#include <stdio.h>
#include <math.h>
#include <stdlib.h>

void dump(int N,int *p){
	int i;
	for(i=0;i<N;i++){
		printf("%d",p[i]);
		if(i==N-1)printf("\n");
		else printf(" ");
	}
	
}
int 
main(){
	int N,a[100];	
	scanf("%d",&N);
	int i;
	for(i=0;i<N;i++)scanf("%d",&a[i]);
	int j=0,k=0;
	int key=0,sumR=0;
	
	dump(N,a);
	for(i=1;i<=N-1;i++){
		key = a[i];
		j=i-1;
		while(j>=0 && a[j]>key){
			a[j+1] = a[j];
			a[j]=key;
			j--;
			
			
		}
		a[j+1]=key;
		dump(N,a);
	}

 return 0;
}


Measured memory_bytes: 2040
#include <stdio.h>
int main(void){
  int N,i;
long long P;
  P=1;
  scanf("%d",&N);
  for(i=1;i<=N;i++){
    P*=i;
P=P%(1000000000+7);
 }
  printf("%lld",P);
  
  return 0;
 
}

Measured memory_bytes: 128
#include <iostream>

using namespace std;

int main() {
	int A1, A2, A3;
	cin >> A1 >> A2 >> A3;

	if ((A1 + A2 + A3) >= 22) {
		cout << "bust" << endl;
	}
	else {
		cout << "win" << endl;
	}
}

Measured memory_bytes: 256
fizzBuzz = []
inputNumber = int(input())
for i in range(inputNumber + 1):
    if i % 3 == 0 and i % 5 == 0:
        metCondition = 'FizzBuzz'
    elif i % 5 == 0:
        metCondition = 'Buzz'
    elif i % 3 == 0:
        metCondition = 'Fizz'
    else:
        metCondition = i
    fizzBuzz.append(metCondition)
metCondition_2 = [num for num in fizzBuzz if isinstance(num, (int, float))]
print(sum(metCondition_2))

Measured memory_bytes: 37744
#from math import gcd
from fractions import gcd

A,B = map(int,input().split())
C = gcd(A,B)
def factorize(n):
    b = 2
    fct = set()
    while b * b <= n:
        while n % b == 0:
            n //= b
            fct.add(b)
        b = b + 1
    if n > 1:
        fct.add(b)
    return fct

tmp = factorize(C)
print(len(tmp)+1)

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

// clang-format off
template <typename T> T gcd(T a, T b) { return b == 0 ? a : gcd(b, a % b); }
template <typename T> T lcm(T a, T b) { return a * b / gcd(a, b); }
template <typename T> T clamp(T val, T min, T max) { return val < min ? min : (max < val ? max : val); }
template <typename T> size_t max_index(T begin, T end) { return distance(begin, max_element(begin, end)); }
template <typename T> size_t min_index(T begin, T end) { return distance(begin, min_element(begin, end)); }
// clang-format on

// #define int long long
#define YES "Possible"
#define NO  "No"

using namespace std;

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

  int num;
  bool flag;

  num = 0;
  flag = false;

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

  
  if (b - a <= 0) cout << "delicious";
  else if (b - a <= x) cout << "safe";
  else cout << "dangerous";
  cout << endl;
  
  // cout << num << endl;
  // cout << (flag ? YES : NO) << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <ios>
#include <iomanip>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <cstdlib>
#include <cstring>
#include <cmath>
using namespace std;

#define MOD 1000000007
#define INF 1e9+7
#define rep(i, n) for(int i=0; i<n; ++i)
typedef long long ll;

#define MAX_N 100000
#define MAX_M 100000
#define MAX_V 100
#define MAX_E 100

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

int ddx[] = {-1, 0, 1, 0, -1, 1, -1, 1};
int ddy[] = {0, -1, 0, 1, 1, 1, -1, -1};

//--------------------------

ll N, M, A;
ll a[MAX_N+1];
ll dp[MAX_N+1];

int main() {

  cin >> N >> M;
  rep(i, M) {
    cin >> A;
    a[A] = 1;
  }

  dp[0] = 1;

  rep(i, N) {
    if(a[i]==1) dp[i] = 0;
    dp[i+1] += dp[i]; dp[i+1]%=MOD;
    dp[i+2] += dp[i]; dp[i+2]%=MOD;
  }

  cout << dp[N] << endl;

  return 0;
}


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

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

  if(N>=65&&N<=90){
    cout << 1 <<endl;
      }
  else if(N>=97&&N<=122){
    cout <<2 <<endl;
  }
  else cout << 0 <<endl;
}



Measured memory_bytes: 3128
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
	"strings"
)

const (
	BUFSIZE   = 10000000
	MOD       = 1000000007
	INF_INT   = math.MaxInt32
	INF_INT64 = math.MaxInt64
)

var rdr = bufio.NewReaderSize(os.Stdin, BUFSIZE)

func main() {
	solve()
}

func solve() {
	A, B, K := ReadInt64_3()
	if A >= K {
		fmt.Println(A-K, B)
	} else if A+B >= K {
		fmt.Println(0, B+(A-K))
	} else {
		fmt.Println(0, 0)
	}
}

func ReadLineInt64() []int64 {
	buf := make([]byte, 0, BUFSIZE)
	for {
		l, p, e := rdr.ReadLine()
		if e != nil {
			fmt.Println(e.Error())
			panic(e)
		}

		buf = append(buf, l...)

		if !p {
			break
		}
	}
	str := strings.Split(string(buf), " ")
	l := len(str)

	ret := make([]int64, l)

	for i, s := range str {
		ret[i] = s2i64(s)
	}
	return ret
}

func ReadLineInt() []int {
	values := ReadLineInt64()
	ret := make([]int, len(values))
	for i, v := range values {
		ret[i] = int(v)
	}
	return ret
}

func ReadInt() int {
	v := ReadLineInt()
	return v[0]
}
func ReadInt2() (int, int) {
	v := ReadLineInt()
	return v[0], v[1]
}
func ReadInt3() (int, int, int) {
	v := ReadLineInt()
	return v[0], v[1], v[2]
}
func ReadInt4() (int, int, int, int) {
	v := ReadLineInt()
	return v[0], v[1], v[2], v[3]
}

func ReadInt64() int64 {
	v := ReadLineInt64()
	return v[0]
}
func ReadInt64_2() (int64, int64) {
	v := ReadLineInt64()
	return v[0], v[1]
}
func ReadInt64_3() (int64, int64, int64) {
	v := ReadLineInt64()
	return v[0], v[1], v[2]
}
func ReadInt64_4() (int64, int64, int64, int64) {
	v := ReadLineInt64()
	return v[0], v[1], v[2], v[3]
}

func s2i64(s string) int64 {
	v, ok := strconv.ParseInt(s, 10, 64)
	if ok != nil {
		panic("Faild : " + s + " can't convert to int64")
	}
	return v
}

// For int64
func Bool2Int64(b bool) int64 {
	if b {
		return 1
	} else {
		return 0
	}
}

func Abs64(v int64) int64 {
	if v < 0 {
		return -v
	}
	return v
}

func Min64(a, b int64) int64 {
	if a > b {
		return b
	} else {
		return a
	}
}

func Max64(a, b int64) int64 {
	if a > b {
		return a
	} else {
		return b
	}
}

func Distance64(a, b int64) int64 {
	return Abs64(a - b)
}

// For int
func Bool2Int(b bool) int {
	if b {
		return 1
	} else {
		return 0
	}
}

func Abs(v int) int {
	if v < 0 {
		return -v
	}
	return v
}

func Min(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}

func Max(a, b int) int {
	if a > b {
		return a
	} else {
		return b
	}
}

func Distance(a, b int) int {
	return Abs(a - b)
}


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

l = [input() for i in range(n)]

m = []
a = []
r = []
c = []
h = []

for i in l:
    if i[0] == 'M':
        m.append(i)
    if i[0] == 'A':
        a.append(i)
    if i[0] == 'R':
        r.append(i)
    if i[0] == 'C':
        c.append(i)
    if i[0] == 'H':
        h.append(i)
        
m = len(m)
a = len(a)
r = len(r)
c = len(c)
h = len(h)

cnt = 0

cnt += m*a*r
cnt += m*a*c
cnt += m*a*h
cnt += m*r*c
cnt += m*r*h
cnt += m*c*h
cnt += a*r*c
cnt += a*r*h
cnt += a*c*h
cnt += r*c*h

print(cnt)


Measured memory_bytes: 10796
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace AtCoder.AGC027
{
    class Program
    {
        static void Main()
        {
            var sc = new Scanner();
            var n = sc.Nextint();
            var x = sc.NextLong();
            var a = sc.ArrayLong(n);

            if (a.Sum() == x)
            {
                Console.WriteLine(n);
                return;
            }
            Array.Sort(a);
            var total = 0L;
            for (var i = 0; i < n; i++)
            {
                total += a[i];
                if (total > x)
                {
                    Console.WriteLine(i);
                    return;
                }
            }
            Console.WriteLine(n - 1);
            return;
        }
    }
    class Scanner
    {
        string[] s;
        long i;

        char[] cs = new char[] { ' ' };

        public Scanner()
        {
            s = new string[0];
            i = 0;
        }

        public string Next()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            if (s.Length == 0) return Next();
            i = 0;
            return s[i++];
        }

        public int Nextint()
        {
            return int.Parse(Next());
        }
        public int[] Arrayint(int N, int add = 0)
        {
            int[] Array = new int[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = Nextint() + add;
            }
            return Array;
        }

        public long NextLong()
        {
            return long.Parse(Next());
        }

        public long[] ArrayLong(int N, long add = 0)
        {
            long[] Array = new long[N];
            for (long i = 0; i < N; i++)
            {
                Array[i] = NextLong() + add;
            }
            return Array;
        }

        public double NextDouble()
        {
            return double.Parse(Next());
        }

        public double[] ArrayDouble(long N, double add = 0)
        {
            double[] Array = new double[N];
            for (long i = 0; i < N; i++)
            {
                Array[i] = NextDouble() + add;
            }
            return Array;
        }

        public decimal NextDecimal()
        {
            return decimal.Parse(Next());
        }

        public decimal[] ArrayDecimal(long N, decimal add = 0)
        {
            decimal[] Array = new decimal[N];
            for (long i = 0; i < N; i++)
            {
                Array[i] = NextDecimal();
            }
            return Array;
        }
    }
}

Measured memory_bytes: 11348
///Astalavista Code........~CodeSlayer007
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define Br cout<<endl;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define int long long
#define double long double
#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
#define PT(x) cout << (x) << endl;
#define SPD_emergency ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
const int M = 1e9 + 7;
int IM = 1e16;
void PV(vi v) { for (int i = 0 ; i < v.size() ; i++) cout << v[i] << " "; cout << endl;}
void PA(int v[], int n) {for (int i = 0 ; i < n ; i++)cout << v[i] << " " ; cout << endl;}
void IN(int a[], int n, int x = 0) {for (int i = x; i < n + x; i++)cin >> a[i];}
inline void PTN(int n = 1, int a = 0, int b = 0, int c = 0) { if (n--)cout << a << " "; if (n--)cout << b << " "; if (n--)cout << c << " "; cout << endl; }
inline void op() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}
// <-------------------------------------------------------------------------------------------------------------------------------------------------------------------------> Ignore This--> memset substr pop_back  insert tuple first second push_back string continue make_pair break deque stack queue sort reverse accumulate  count lower_bound upper_bound next_permutation copy_n __builtin_popcount make_tuple
// <========================================================================================================================================================================

signed  main() {
    SPD_emergency
    
    int i, j, k, x, y, u;
    //int t; cin >> t; while (t--)
    {
        int n, m;
        cin >> n >> m;
        cin >> x;
        vi v;
        int a[n + 10][m + 10];
        for (i = 0; i < n; i++) {
            cin >> y;
            v.push_back(y);
            for (j = 0; j < m; j++) {
                cin >> a[i][j];
            }
        }
        k = u = 0;
        bool f = 0;
        int ans = IM;
        int p = 1;
        for(i=0;i<n;i++)
            p=p*2;
        int pp = p; //PT(p);
        pp--;
        while (pp) {  //PT(pp);
            k = pp;
            i = j = 0;
            int cj[m + 10] = {0};
            u = 0;
            while (k > 0) {
                if (k % 2) { //if(pp==7)PT(i);
                    u += v[i];
                    for (j = 0; j < m; j++) {
                        cj[j] += a[i][j];
                    }
                }
                i++;
                k = k / 2;
            }
            //PA(cj,m+1);

            pp--;
            bool ck = 1;
            for (j = 0; j < m; j++) {
                if (cj[j] < x) {
                    ck = 0;
                    break;
                }
            }
            if (ck) { 
                f = 1;
                ans = min(ans, u);
            }

        }
        if(f==1)
            cout<<ans<<endl;
        else if(f==0)
            cout << -1;/**/


    }
    return 0;
}

Measured memory_bytes: 3656
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var Arr = (input.trim()).split("\n");

const binarySearch = (key, arr, N) => {
  let mid;
  let left = 0;
  let right = N;
  if (key < arr[0] || arr[N-1] < key) return 0;
  while (left < right) {
    mid = Math.floor((left + right) / 2);
    if (key < arr[mid]) right = mid;
    else if (key > arr[mid]) left = mid + 1;
    else return 1;
  }
  return 0;
}


(function() {
  const N1 = Number(Arr[0]);
  const arr1 = Arr[1].split(" ").map(Number);
  // const N2 = Number(Arr[2]);
  const arr2 = Arr[3].split(" ").map(Number);
  const summing = (a, b) => a + b;
  console.log(arr2.map(e => binarySearch(e, arr1, N1)).reduce((a, b) => a + b, 0));
})();



Measured memory_bytes: 34932
// Author: Vamsi Krishna Reddy Satti
// With love for Competitive Programming!
 
#include <bits/stdc++.h>
using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H);
    debug_out(T...);
}
#ifdef LOCAL
    #define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
    #define debug(...) 3
#endif

#define fast_io ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
#define cout_precision cout.setf(ios::fixed); cout.precision(32);
using ll = int64_t; using ull = uint64_t; using ld = long double;

// -----------------------------------------------------------------------------

int f(ll n) {
    int ret = 0;
    while (n) {
        n /= 10;
        ++ret;
    }
    return ret;
}

int main() {
    ll n; cin >> n;
    int ans = INT_MAX;
    for (ll i = 1; i * i <= n; ++i) {
        if (n % i == 0) {
            ans = min(ans, max(f(i), f(n / i)));
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 384
#!usr/bin/env python3
from collections import defaultdict, deque, Counter, OrderedDict
from bisect import bisect_left, bisect_right
from functools import reduce, lru_cache
from heapq import heappush, heappop, heapify

import itertools, bisect
import math, fractions
import sys, copy

def L(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline().rstrip())
def S(): return list(sys.stdin.readline().rstrip())
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI1(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LS(): return [list(x) for x in sys.stdin.readline().split()]
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def LIR1(n): return [LI1() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
def LR(n): return [L() for _ in range(n)]

alphabets = "abcdefghijklmnopqrstuvwxyz"
ALPHABETS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"

sys.setrecursionlimit(1000000)
dire = [[1, 0], [0, 1], [-1, 0], [0, -1]]
dire8 = [[1, 0], [1, 1], [0, 1], [-1, 1], [-1, 0], [-1, -1], [0, -1], [1, -1]]
MOD = 1000000007

def main():
    N = I()
    A = LI()
    s = set(A)
    print("YES" if len(s) == len(A) else "NO")

if __name__ == '__main__':
    main()

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

using namespace std;

int main(){
	int n, m;
	cin >> n >> m;
	if(n==1){
		if(m==0){
			cout<<0;
			return 0;
		}
		if(m==1){
				cin >> n >> m;
				cout<<m;
				return 0;
		}
	}
	vector<int> ass(n, 0);
	unordered_set<int> repeats;
	int x, y;
	for(int i = 0; i<m; i++){
		cin >> x >> y;
		if(x==1&&y==0){
			cout<< -1;
			return 0;
		}
		if(repeats.count(x) >= 1 && ass[x-1]!=y){
				cout<<-1;
				return 0;
		}
		repeats.insert(x);
		
		
		ass[x-1] = y; 
	}
	if(ass[0] == 0)
		ass[0] = 1;
		
	int a = ass.size(); 
	for(int i = 0; i<a; i++){
		cout<<ass[i];
	}
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstdio>
#include <iomanip>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <stdlib.h>
#include <set>
typedef long long ll;
using namespace std;

int main() {
	int n;
	cin>>n;
	cout<<2*n/__gcd(2,n)<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long double LD; 
typedef long long ll; 
#define int ll 
#define ff(i,a,b) for (int i = a; i < b; i++) 
#define bf(i,a,b) for (int i = a; i >= b; i--) 
#define all(v) v.begin(),v.end() 
#define show(a) for(auto xyz:a)cout<<xyz<<" ";cout<<endl;
#define F first 
#define S second
#define pb push_back
#define mp make_pair
#define lb lower_bound   
#define ub upper_bound
#define yes cout<<"YES"<<endl
#define no cout<<"NO"<<endl
#define one cout<<"-1"<<endl
#define pi 3.141592653589793238
#define intmx INT_MAX 
#define intmi INT_MIN
const int MOD=1e9+7;
int mod(int x){
    return ((x%MOD + MOD)%MOD);
}
int add(int a,int b){
    return mod(mod(a)+mod(b));
}
int mul(int a,int b){
    return mod(mod(a)*mod(b));
}
void solve(){
   string s;
   cin>>s;
   int sum=0;
   ff(i,0,s.size()){
       sum+=s[i]-'0';
   }
   if(sum%9==0)
   cout<<"Yes\n";
   else
   cout<<"No\n";
}
signed main() {
    int t=1;
    //cin>>t;
    while(t--){
        solve();
    }
}

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

#define MOD 1000000007
#define vi vector<int>
#define vll vector<ll>
#define vpll vector<pair<ll,ll>>
#define vvi vector<vector<int>>
#define INF (int)1e9
#define fora(i,a,b) for(ll i=a;i<b;i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define si size()
#define be begin()
#define en end()
#define le length()
#define mp(x,y) make_pair(x,y)
#define mli map<ll,int>
#define mll map<ll,ll>

#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)



int main()
{
fast;
ll t=1;
//cin>>t;

while(t--)
{

    ll n;
    cin>>n;
    ll o=(1000-(n%1000))%1000;
cout<<o;
}

    return 0;
}

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

int main() {
	
	int n;
	cin >> n;
	vector<int> a(n+1), b(n+1);
	for(int i=1; i<=n; i++){
		cin >> a[i];
		b[i] = a[i];
	}
	
	vector<set<int>> s(n+1);
	for(int i=n; i>1; i--){
		if(b[i] == 1){
			//2以上のiの約数をすべて求め、s[i]に格納
			int k = i;
			for(int j=2; j*j<=k; j++){
				if(k%j == 0){
					s[i].insert(j);
					if(i*i != k) s[i].insert(k/j);
				}
			}
			// int j = 2;
			// while(j*j <= k){
			// 	if(k%j == 0){
			// 		s[i].insert(j);
			// 		k /= j;
			// 	}else{
			// 		j++;
			// 	}
			// }
			// s[i].insert(k);
			for(auto v: s[i]){
				//i未満の約数vを論理反転
				if(v < i) b[v] ^= 1;
			}
		}
	}
	
	//i = 1
	for(int i=2; i<=n; i++){
		if(b[i] == 1) b[1] ^= 1;
	}
	
	int m = 0;
	for(int i=1; i<=n; i++){
		if(b[i] == 1) m++;
	}
	if(m == 0){
		cout << m << endl;
	}else{
		cout << m << endl;
		for(int i=1; i<=n; i++){
			if(b[i] == 1) cout << i << " ";
		}
		cout << endl;
	}
	
	
	// for(int i=1; i<=n; i++) cout << b[i] << " ";
	// cout << endl;
	
	// for(int i=1; i<=n; i++){
	// 	cout << i << ": ";
	// 	for(auto v: s[i]){
	// 		cout << v << " ";
	// 	}
	// 	cout << endl;
	// }
	
	
	return 0;
}

Measured memory_bytes: 74112
(let* ((n (read))
    (a (make-array (+ n 1)))
    (ans 0))
    (loop for i from 1 to n do
        (setf (aref a i) (read))
    )
    (loop for i from 1 to n do
        (let ((b (aref a i)))
            (if (= i (aref a b))
                (incf ans)
            )
        )
    )
    (princ (/ ans 2))
)

Measured memory_bytes: 76988
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define Rep(i, a, b) for(int i = a; i <= b; i++)
#define _GLIBCXX_DEBUG
#define Vl vector<ll>
#define Vs vector<string>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
using namespace std;


void solve(){
    ll n; cin >> n;
    string s; cin >> s;
    ll r = 0, g = 0, b = 0;
    rep(i, 0, n){
        if(s[i] == 'R') r++;
        if(s[i] == 'G') g++;
        if(s[i] == 'B') b++;
    }
    ll ans = r*g*b;
    int m = 1;
    while(m*2+1 <= n) m++;
    m--;
    Rep(i, 1, m){ // i 差
        int o = n-2*i;
        rep(j, 0, o){
            // cout << j << " " << i << endl;
            if(s[j] != s[j+i] && s[j+i] != s[j+2*i] && s[j] != s[j+2*i]) ans--;
        }
    }
    cout << ans << endl;
}

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

Measured memory_bytes: 3664
n, k = gets.chomp.split(" ").map(&:to_i)
ans = 1
mod = 10 ** 9 + 7
dp = [0]

if n < k then
    puts 1
    exit
end

n.times do |i|
    dp << dp[i] + i + 1
end

k.upto(n) do |i|
    ans += dp[n] - dp[n-i] - dp[i-1] + 1
end

puts ans % mod

Measured memory_bytes: 16008
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <vector>
#include <stack>
using namespace std;
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define OUT(a) cout << (a) << "\n"
#define ll long long
ll MOD = 10e9 + 7;

int main() {
    int n,l;
    cin >> n >> l;
    int m = 0;
    int saishou = 10000000;
    int saidai = -10000000;
    int tmp;
    REP(i, n) {
        tmp = l + i;
        saishou = min(saishou, tmp);
        saidai = max(tmp, saidai);
        m += tmp;
    }
    if (saishou <= 0 && 0 <= saidai) {
        OUT(m);
    } else if(0 <= saishou) {
        OUT(m - saishou);
    }
     else if(saidai <= 0) {
         OUT(m - saidai);
    }
    return 0;
}

Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author toshibablack
 */

#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstring>
#include <fstream>
#include <functional>
#include <iostream>
#include <iomanip>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

#define ll long long int
#define FOR(i, a, b) for(int i=(a);i<=(b);++i)
#define REP(i, n) for(int i=0;i<n;++i)
#define FOREACH(x, a) for(auto& (x) : (a))
#define ALL(a) (a).begin(),(a).end()
#define OUT(x) out << (x) << endl;
#define M0(x) memset(x,0,sizeof(x))
#define MINF(x) memset(x,0x3f,sizeof(x))
#define MMINUS(a) memset(a,0xff,sizeof(a))
#define ten(n) ((int)1e##n)

const int INF = 0x3f3f3f3f;
const int MOD = 1e9+7;
const ll LINF = 1e18;
const double EPS = 1.0/LINF;
const char ENDL = '\n'; // for JetBrains IDE only supports yen

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 gcd(int a,int b){return b?gcd(b,a%b):a;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}

using namespace std;

class DEqueue {
public:
    int N, K;
    int V[100]{0};

    void solve(std::istream& in, std::ostream& out) {
        in >> N >> K;
        REP(i, N) in >> V[i];
        int ans = 0;

        FOR(l, 0, min(N, K)) {
            FOR(r, 0, min(N, K)-l) {
                vector<int> v;
                int sum = 0;
                REP(i, l) {
                    sum += V[i];
                    v.push_back(V[i]);
                }
                REP(i, r) {
                    sum += V[N-1-i];
                    v.push_back(V[N-1-i]);
                }

                sort(ALL(v));
                int nokori = max(K - l - r, 0);
                REP(i, nokori) {
                    if (i == v.size()) break;
                    sum += max(-v[i], 0);
                }
                chmax(ans, sum);
            }
        }
        OUT(ans);
    }
};


int main() {
    DEqueue solver;
    std::istream& in(std::cin);
    std::ostream& out(std::cout);
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 256
#!/usr/bin/perl

my ($n) = map { $_ - 0 } split(/\s+/,<STDIN>);
my @aa = map { $_ - 0 } split(/\s+/,<STDIN>);

my $md = 10 ** 9 + 7;

my $sum = 0;
for(my $i=0;$i<$n;$i++){
  $sum += $aa[$i];
}

my $r = 0;
for(my $i=0;$i<$n-1;$i++){
  $sum -= $aa[$i];
  $r = ( $r + ( $sum % $md ) * $aa[$i] ) % $md;
}

print "$r\n";




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

int main()
{
    vector<char> s(3);
    rep(i,3) cin >> s.at(i);
    int ans = 0;
    for(int i: s) {
        if(i == '1') ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3572
#include <bits/stdc++.h>
#define reg register

using namespace std;

const int mod = 1e9 + 7;
int N;
long long ans;
char s[11];

string str;
map<string, int> M;

inline int Rd() {
	int x = 0; char ch = getchar();
	while(ch < '0' || ch > '9') ch = getchar();
	while(ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
	return x;
}
inline long long ksm(long long base, int mi) {
	long long res = 1;
	while(mi) {
		if(mi & 1) (res *= base) %= mod;
		(base *= base) %= mod, mi >>= 1;
	}
	return res;
}

int main() {
	ios::sync_with_stdio(0);
	cin >> N;
	for(int i = 1; i <= N; ++i) {
		cin >> s, str.clear();
		sort(s, s + 10);
		for(int i = 0; i < 10; ++i)
			str += s[i];
		ans += M[str]++;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 12800
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        try (Scanner s = new Scanner(System.in)) {
            int d = s.nextInt();
            s.nextLine();
            int[] c = Arrays.stream(s.nextLine().split(" "))
                        .mapToInt(Integer::parseInt)
                        .toArray();
            int[] count = new int[26];
            int sum = Arrays.stream(c).sum();
            int negate = 0;
            int fill = 0;
            for (int i = 0; i < d; i++) {
                int[] sd = Arrays.stream(s.nextLine().split(" "))
                            .mapToInt(Integer::parseInt)
                            .toArray();
                negate += sum;
                int index = 0;
                int subsum = Integer.MIN_VALUE;
                for (int j = 0; j < 26; j++) {
                    count[j]++;
                    int temp = sd[j] + c[j] * count[j];
                    if (temp > subsum) {
                        index = j;
                        subsum = temp;
                    }
                }
                fill += subsum;
                count[index] = 0;
                System.out.println(index + 1);
            }
        }
    }
}


Measured memory_bytes: 40372
# -*- coding: utf-8 -*-
"""
Created on Mon May 27 22:22:26 2019

@author: Yamazaki Kenichi
"""
def _int(x):
    try:
        return int(x)
    except:
        return x

N = int(input())
sp = [list(map(_int,input().split()))+[i+1] for i in range(N)]

sp.sort(reverse=True, key = lambda x: x[1])
sp.sort(key = lambda x: x[0])

for i in range(N):
    print(sp[i][2])


Measured memory_bytes: 3064
#include <iostream>
#include <array>
#include <map>
#include <algorithm>
#include <cmath>
#include <vector>

using namespace std;

using ll = long long int;

ll arr[200010] = {};

int main(void) {

	ll k = 0;

	cin >> k;

	for (int i = 0; i < 50; i++) {
		arr[i] += 49;
		arr[i] += k / 50;
	}

	for (ll i = 0; i < k%50; i++) {
		arr[i%50] += 51;

		for (ll j = 0; j < 50; j++) {
			arr[j] -= 1;
		}
	}

	cout << 50 << endl;

	for (int i = 0; i < 50; i++) {
		cout << arr[i] << (i == 49?'\n' : ' ');
	}


}


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

typedef long long int ll;
typedef long double ld;

#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
#define pll pair<ll,ll>
#define MP make_pair
#define ff first
#define ss second
#define PB push_back
#define mod 1000000007
#define lp(i,start,end) for(ll i=start;i<=end;i++) 
#define deb1(a) cout<<#a<<" = "<<(a)<<endl;
#define deb2(a,b) cout<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<endl;
#define deb3(a,b,c) cout<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<", "<<#c<<" = "<<(c)<<endl;


ll modu(ll a, ll b)
{
	ll ans =1;
	while(b>0)
	{
		if(b&1)
		ans = (ans*a)%mod;
		b/=2;
		a = (a*a)%mod;
	}
	return ans;
}

int main()
{
	fastio
	ll n;
	cin>>n;
	ll a[n];
	ll al;
	cin>>a[0]>>a[1];
	al=a[0]^a[1];
	lp(i,2,n-1){
		cin>>a[i];
		al=al^a[i];
	}
	for(ll i=0; i<n; i++)
		cout<<(al^a[i])<<" ";
	cout<<endl;

	return 0;	
}


Measured memory_bytes: 5184
#include <stdio.h>

int main(void)
{
	int a,i,b=0;
	char s[101];
	
	scanf("%d",&a);
	
	for(i=0;i<a;i++){
		scanf("%c",&s[i]);
		if(s[i]=='Y') b=1;
	}
	
	if(b==1)printf("Four\n");
	else printf("Three\n");
	
	return 0;
}

Measured memory_bytes: 128
a = [list(map(int, input().split()))for _ in range(3)]
n = int(input())
b = [list(map(int, input().split()))for _ in range(n)]

for i in range(n):
    for j in range(3):
        for k in range(3):
            if a[j][k] == b[i][0]:
                a[j][k] = 0

ans = "No"

for i in range(3):
    if a[0][i] == a[1][i] == a[2][i] == 0:
        ans = "Yes"
    if a[i][0] == a[i][1] == a[i][2] == 0:
        ans = "Yes"

if a[0][0] == a[1][1] == a[2][2] == 0:
    ans = "Yes"
if a[2][0] == a[1][1] == a[0][2] == 0:
    ans = "Yes"

print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int N;
    cin >> N;
    map<string, int> M;
    string S;
    while (cin >> S) {
        sort(S.begin(), S.end());
        M[S]++;
    }
    long ans = 0;
    for (auto m : M) ans += (long)m.second * (m.second - 1) / 2;
    cout << ans << "\n";
}

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

const int MAX = 1000000;
const int MAX_P = 999983;
int prseq[MAX] = {};
int count[MAX + 1] = {};

void prime(){
	prseq[0] = 1;
	
	for(int i = 2; i <= MAX; ++i){
		int k = i * 2;
		while(k <= MAX_P){
			prseq[k - 1] = 1;
			k += i;
		}
	}
	for(int i = MAX_P + 1; i <= MAX; ++i){
		prseq[i - 1] = 1;
	}
	
	for(int i = 1; i <= MAX; ++i){
		count[i] = count[i - 1] + (prseq[i - 1] ? 0 : 1);
	}
}

int main(){
	int n, p, m;
	
	prime();
	
	while(cin >> n, n){
		int sum = 0;
		for(int i = 0; i < n; ++i){
			cin >> p >> m;
			int x = count[p + m > MAX ? MAX : p + m] - count[p - m < 1 ? 0 : p - m - 1];
			sum += x - 1;
		}
		cout << sum << endl;
	}
}

Measured memory_bytes: 8968
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <functional>

using namespace std;

int main()
{
	int n, x;
	int res;
	int cnt1 = 0;
	int cnt2 = 0;
	int cnt3 = 0;

	cin >> n;
	for (int i = 0; i < n; i++){
		cin >> x;
		if (x % 2 == 0 && x % 4 != 0) {
			cnt1++;
		}
		if (x % 4 == 0) {
			cnt2++;
		}
		if (x % 2 == 1) {
			cnt3++;
		}
	}
	if (cnt1 == 0 && cnt3 <= cnt2 + 1) {
		cout << "Yes" << endl;
	} else 
	if (cnt1 % 2 == 0 && cnt3 <= cnt2 + 1) {
		cout << "Yes" << endl;
	} else
	if (cnt1 % 2 == 1 && cnt3 <= cnt2) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
}

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

#define fast_io ios_base::sync_with_stdio(false) ; cin.tie(0); cout.tie(0);

int main() {
    fast_io;
    int n,k;
    cin>>n>>k;

    int ans=0;
    while(n>0) {
        n/=k;
        ans++;
    }
    cout<<ans<<endl;
}




Measured memory_bytes: 3620