akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<string.h>

#define N 1000000
#define L 14

char H[N][L];

int judge(char x);
int Key(char str[]);
int h1(int key);
int h2(int key);
int search(char str[]);
int insert(char str[]);


int main(void){
  int i,n;
  int h;
  char com[9],str[L];
    
  for(i = 0;i < N;i++){
    H[i][0] = '\0';
  }
    
  scanf("%d",&n);
    
  for(i = 0;i < n;i++){
    scanf("%s %s",com,str);
        
    if(com[0] == 'i'){
      insert(str);
    } else {
      if(search(str) != 0){
	puts("yes");
      } else {
	puts("no");
      }
    }
  }
    
  return 0;
}







int judge(char x){
  if(x == 'A'){
    return 1;
      
  } else if(x == 'C'){
    return 2;
      
  } else if(x == 'G'){
    return 3;
      
  } else if(x == 'T'){
    return 4;
      
  } else {
    return 0;
  }
}



int Key(char str[]){
  int i;
  int sum = 0;
  int p = 1;

  for(i = 0;i < strlen(str);i++){ 
    sum += p*(judge(str[i]));
    p *= 5;
  }
  return sum;
}



int h1(int key){
  return key%N;
}



int h2(int key){
  return ( 1+(key%(N-1)) );
}



int search(char str[]){
  int i;
  int key,h;
   
  key = Key(str);
    
  for(i = 0;;i++)
    {
      h = (h1(key) + i*h2(key))%N;
	
      if(strcmp(H[h], str) == 0){
	return 1;
	  
      } else if(strlen(H[h]) == 0){
	return 0;
      }
    }
  return 0;
}



int insert(char str[]){
  int i,h;
  int key;
    
  key = Key(str);
    
  for(i = 0;;i++){
    h = (h1(key) + i*h2(key))%N;
	
    if(strcmp(H[h],str) == 0){
      return 1;
	  
    } else if(strlen(H[h]) == 0){
      strcpy(H[h],str);
      return 0;
    }
  }
    
  return 0;
}



Measured memory_bytes: 15460
#define _GLIBCXX_DEBUG
#include<algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<iostream>
#include<vector>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<string>
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define rep2(i,s,n) for(int i=s;i< (int)n; i++)
#define ll long long 
#define all(v) v.begin(),v.end()
using namespace std;
int main(){
  int h,w; cin >>h>>w;
  vector<string> a(h);
  rep(i,h) cin>>a[i];
  rep(i,w+1) cout <<'#';
  cout <<'#'<<endl;
  rep(i,h){
    cout <<'#';
    rep(j,w){
      cout <<a[i][j];
    }
    cout <<'#'<<endl;
  }
  rep(i,w+1) cout <<'#';
  cout <<'#'<<endl;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;

public class Main {
    BufferedReader br;
    PrintWriter out;
    StringTokenizer stok;

    String nextToken() throws IOException {
        while (stok == null || !stok.hasMoreTokens()) {
            String s = br.readLine();
            if (s == null) {
                return null;
            }
            stok = new StringTokenizer(s);
        }
        return stok.nextToken();
    }

    int nextInt() throws IOException {
        return Integer.parseInt(nextToken());
    }

    long nextLong() throws IOException {
        return Long.parseLong(nextToken());
    }

    double nextDouble() throws IOException {
        return Double.parseDouble(nextToken());
    }

    char nextChar() throws IOException {
        return (char) (br.read());
    }

    String nextLine() throws IOException {
        return br.readLine();
    }

    void solve() throws IOException {
        String[] s = nextLine().split(" ");
        if (s[0].charAt(0) < s[1].charAt(0)) out.println("<");
        if (s[0].charAt(0) > s[1].charAt(0)) out.println(">");
        if (s[0].charAt(0) == s[1].charAt(0)) out.println("=");

    }

    void run() throws IOException {
        // br = new BufferedReader(new FileReader("dragons.in"));
        //out = new PrintWriter("dragons.out");
        // br = new BufferedReader(new FileReader("input.txt"));
        // out = new PrintWriter("output.txt");
        br = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        solve();
        br.close();
        out.close();
    }

    public static void main(String[] args) throws IOException {
        // Locale.setDefault(Locale.US);
        new Main().run();
    }
}

Measured memory_bytes: 23124
#include <stdio.h>
#include <ctype.h>
 
int main(void)
{
    char string[1200];
    int i=0;
    gets(string);
     
    while(string[i]!='\0')
    {
        if(islower(string[i]))
                printf("%c",toupper(string[i++]));
         
        else if(isupper(string[i]))
            printf("%c",tolower(string[i++]));
        else
            printf("%c",string[i++]);       
    }
    printf("\n");
     
    return 0;
}

Measured memory_bytes: 524
parseInt(x)=parse(Int, x)
parseMap(x::Array{SubString{String},1})=map(parseInt, x)

function main()
	o = readline() |> chomp
	e = readline() |> chomp
	for i in 1:length(e)
		print(o[i])
		print(e[i])
	end
	if length(o)>length(e)
		println(o[length(o)])
	else
		println("")
	end
end

main()

Measured memory_bytes: 109448
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,n,s) for(int i = s; i < (n); ++i)
#define rsrep(i,n,s) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<x<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;

int main() {
    string s;
    ll k;
    cin >> s >> k;
    int o = 0;
    char f = '1';
    rep(i, s.length()) {
        if (s[i] != '1') {
            f = s[i];
            o = i;
            break;
        }
    }
    if (k <= o) puts("1");
    else cout << f << endl;

    return 0;
}

Measured memory_bytes: 256
object Main extends App {
  val sc = new java.util.Scanner(System.in)
  execute(sc.nextInt(), sc.nextInt())

  def execute(n: Int, x: Int): Unit = {
    (n, x) match {
      case (0, 0) => sc.close()
      case _ =>
        val counter = makeCounter
        countCombinations(n, x, counter)
        println(counter() - 1)
        execute(sc.nextInt(), sc.nextInt())
    }
  }

  def makeCounter: () => Int = {
    var cnt = 0
    () => cnt += 1; cnt
  }

  def countCombinations(end: Int, sum: Int, cnt: () => Int): Unit = {
    for (i <- 1 to end; j <- i + 1 to end; k <- j + 1 to end) {
      if (i + j + k == sum) cnt()
    }
  }
}

Measured memory_bytes: 48220
import std.stdio;
import std.c.stdio;
import std.algorithm;
import std.array;

void main() {
    int roulette; 
test:
    while (scanf("%d", &roulette), roulette) {
        int n; scanf("%d", &n);
        int[] d = new int[n + 2];
        foreach (i; 1 .. n + 1) scanf("%d", &d[i]);
        int next(int x) {
            int ans = x + d[x];
            if (ans < 0) ans = 0;
            if (ans > n + 1) ans = n + 1;
            return ans;
        }
        int[][] graph = new int[][n + 2];
        bool[] used = new bool[n + 2];
        void make(int cur) {
            used[cur] = true;
            foreach (i; 1 .. roulette + 1) {
                if (cur + i > n + 1) {
                    graph[cur] ~= n + 1;
                    break;
                }
                int x = next(cur + i);
                graph[cur] ~= x;
                if (!used[x]) make(x);
            }
        }
        make(0);
        foreach (ref g; graph) {
            g = g.sort.uniq.array;
        }
        used[] = false;

        bool cangoal(int cur) {
            if (cur == n + 1) return true;
            used[cur] = true;
            foreach (x; graph[cur]) {
                if (used[x]) continue;
                if (cangoal(x)) return true;
            }
            return false;
        }

        //graph.writeln;

        foreach (int i, ref g; graph) {
            if (g.empty) continue;
            used[] = false;
            if (cangoal(i)) continue;
            writeln("NG");
            continue test;
        }
        writeln("OK");
    }
}

Measured memory_bytes: 2264
n,m = map(int,input().split())
ft = [[int(i) -1 for i in input().split()] for _ in range(m)]
def dfs(f,n):

    visited[n] = True


    for value in renketu[n]:
        if value == f:
            continue
        if visited[value] == True:
            continue
        
        dfs(n,value)

    return
    

total = 0

for i in range(m):

    visited = [False for _ in range(n)]

    tmp = ft.pop(i)

    renketu = [[] for _ in range(n)]

    for value in ft:
        f,t = value
        renketu[f].append(t)
        renketu[t].append(f)

    dfs(0,0)
    
    
    if visited.count(True) != n:
        total += 1
    ft.insert(i,tmp)

print(total)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define INF LONG_LONG_MAX
#define int long long
#define ar array
#define db double
#define pi 3.14159265358979323846
#define pow pw
int pw(int a,int b){
    int ans=1;
    while(b){
    if (b%2) ans*=a;
    a*=a;
    b/=2;
    }
    return(ans);
}
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int k;
    cin>>k;
    int ans=0,du=0;
    do
    {
        ans++;
        du=(du*10+7)%k;
        if (ans>k) 
        {
            cout<<-1;
            return 0;
        }
    } while(du);
    cout<<ans;
    return 0;
}

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

using namespace std;

int main()
{
	string correct("CODEFESTIVAL2016");
	string input;
	cin >> input;

	int count = 0;
	for (int i = 0; i < correct.size(); i++)
	{
		if (correct[i] != input[i])
			count++;
	}
	cout << count << endl;

	return 0;
}

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

using namespace std;
int n;
long long a[101];
long long ok(long long x){
    long long cost = 0;
    for(int i = 1; i <= n; i++){
        cost += ((a[i] - x) * (a[i] - x));
    }
    return cost;
}
int main(){
    cin >> n;
    for(int i = 1; i <= n; i++){
        cin >> a[i];
    }
    int l = -100, r = 100;
    while(r - l > 1){
        int mid = (l + r) / 2;
        if(ok(mid) >= ok(mid + 1)){
            l = mid;
        }
        else{
            r = mid;
        }
    }
    cout << min(ok(l), ok(r));
}


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

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

int main() {
 int A,B,K;
 cin >> A >> B >> K;
 int S = 0;
 S = gcd(A,B);
 int counter = 0,div = S;
 while(counter <= K-1){
 if(S % div == 0){
 counter += 1;
 }
 div -=1;
 }
 cout << div+1;
}

Measured memory_bytes: 256
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstring>
#include <iterator>
#include <bitset>
#include <unordered_set>
#include <unordered_map>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <utility>
#include <memory>
#include <functional>
#include <deque>
#include <cctype>
#include <ctime>
#include <numeric>
#include <list>
#include <iomanip>

#if __cplusplus >= 201103L
#include <array>
#include <tuple>
#include <initializer_list>
#include <forward_list>

#define cauto const auto&
#else

#endif

using namespace std;


typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
    stringstream ss;
    ss << f;
    ss >> t;
}

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define F first
#define S second
#define mkp make_pair
#define RALL(v) (v).rbegin(),(v).rend()
#define DEBUG
#ifdef DEBUG
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#else
#define dump(x) 
#define debug(x) 
#endif

#define MOD 1000000007LL
#define EPS 1e-8
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)

int n,m;
vvint vv(100010);

//Fenwick tree(BIT)
template <class Tp>
class fenwick_tree{
	std::vector<Tp> bit;
public:
	fenwick_tree(){}
	explicit fenwick_tree(std::size_t n) : bit(n + 1) {}
	Tp sum(std::size_t i) const{
		i++;
		Tp s = 0;
		while(i){
			s += bit[i];
			i -= i & -i;
		}
		return s;
	}
	void add(std::size_t i, Tp x){
		i++;
		while(i < bit.size()){
			bit[i] += x;
			i += i & -i;
		}
	}
	void clear(){
		bit.clear();
	}
	void assign(std::size_t n){
		bit.assign(n + 1, Tp());
	}
	void swap(fenwick_tree &f){
		bit.swap(f.bit);
	}
};
fenwick_tree<int> bit(100010);

void mainmain(){
	cin>>n>>m;
	vector<pair<int,pii>> v(n);
	rep(i,n) cin>>v[i].S.F>>v[i].S.S;
	rep(i,n){
		v[i].F = v[i].S.S-v[i].S.F+1;
	}
	sort(ALL(v));
	int p = 0;
	reep(i,1,m+1){
		while(p<v.size()&&v[p].F<=i){
			bit.add(v[p].S.S+1,-1);
			bit.add(v[p].S.F,1);
			p++;
		}
		int ans = n-p;
		int pos = i;
		while(pos<m+1){
			ans += bit.sum(pos);
			pos+=i;
		}
		cout<<ans<<endl;
	}
}


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

Measured memory_bytes: 7296
#include<bits/stdc++.h>
using namespace std;
#define rep(i, l, r) for (int i = l; i<r;i++)
#define dec(i, l, r) for (int i = l; i>=r;i--)
#define vi vector<int>
#define all(v) v.begin(),v.end()
#define pb(c) push_back(c)
#define vii vector<pair<int,int>>
#define ii pair<int,int>
#define mp(i, j) make_pair(i,j)
#define ull unsigned long long int
#define ll  long long int
#define pie 3.141592653589793238
#define inf ((ll)1e18)
#define eps 1e-14
#define mod ((int)1e9+7)
#define maxlg 18
#define left(i) ((i)<<1)
#define right(i) (((i)<<1)+1)
const int maxn = 100501;
ll a,b;
int arr[maxn];
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
#ifndef ONLINE_JUDGE
 #endif
    int n;
    cin>>n>>a>>b;
    rep (i,0,n)
    cin>>arr[i];
    int diff = a-b;
    ll l=1,r = (int)3e9;
    while (l<=r) {
        int mid = (l+r)>>1;
        ll need=0;

        rep (i,0,n) {
            if (arr[i]-b*mid>0) {
               need +=(arr[i]-b*mid)/diff;
                if ((arr[i]-b*mid)%diff!=0)
                    need++;
            }
        }

        if (need<=mid) {
            r = mid-1;
        } else {
            l = mid+1;
        }
    }
    cout<<l;


     return 0;
}

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

const int INF = 1e9;
const int MOD = 1e9 + 7;

using namespace std;

typedef long long ll;

#define REP(i, n) for (int i = 0; i < int(n); i++)
#define REPD(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = a; i < int(b); i++)
#define FORD(i, a, b) for (int i = b - 1; i >= int(a); i--)
#define WRAP(y, x, h, w) (0 <= y && y < h && 0 <= x && x < w)

#define ALL(x) (x).begin(), (x).end()

int gcd(int a, int b)
{
    return b ? gcd(b, a % b) : a;
}
int dx[4] = { 1, 0, -1, 0 };
int dy[4] = { 0, 1, 0, -1 };

int main()
{
    vector<int> vi(5);
    REP(i, 5)
    cin >> vi[i];
    int ans = -1;
    REP(i, 5)
    if (vi[i] == 0) {
        ans = i + 1;
        break;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3616
def calc(D, C, S, T):
    s = 0
    l = [-1] * len(C)
    for d, t in enumerate(T):
        t -= 1
        s += S[d][t]
        l[t] = d
        s -= sum(c * (d - l[i]) for i, c in enumerate(C))
        print(s)
    return s


def main():
    D = int(input())
    C = list(map(int, input().split()))
    S = [list(map(int, input().split())) for _ in range(D)]

    T = [int(input()) for _ in range(D)]
    calc(D, C, S, T)

main()


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

class Stack {
  int top;
  int S[1000];
  int MAX;
  public:
  Stack() {
    top = 0;
    MAX = 1000;
  }
  void push(int x) {
    if ( !isFull() ) S[top++] = x;
    else throw;
  }
  int pop() {
    if ( !isEmpty() ) return S[--top];
    else throw;
  }
  bool isEmpty() {
    return top == 0;
  }
  bool isFull() {
    return top == MAX;
  }
};

int main() {
  char s[2];
  Stack stack;
  while( scanf("%s", s) != EOF ) {
    if ( s[0] == '+' ) {
      int a = stack.pop();
      int b = stack.pop();
      stack.push(a + b);
    } else if ( s[0] == '-' ) {
      int a = stack.pop();
      int b = stack.pop();
      stack.push(b - a);
    } else if ( s[0] == '*' ) {
      int a = stack.pop();
      int b = stack.pop();
      stack.push(a * b);
    } else {
      stack.push(atoi(s));
    }
  }

  printf("%d\n", stack.pop());
  return 0;
}


Measured memory_bytes: 2748
#include <cctype>
#include <cfloat>
#include <climits>
#include <cmath>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <ios>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <forward_list>
#include <random>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <unordered_map>
#include <unordered_set>
#endif

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define lcm( a, b ) (a)/__gcd((a),(b))*(b)
#define endl '\n'

using namespace std;

typedef long long LL;
typedef pair< int, int > P;
typedef pair< LL, LL > LP;
typedef pair< int, P > iP;
typedef pair< P, P > PP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1000000007;
static const int SIZE = 500005;

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

vector< int > Div( int n ) {
    vector< int > ret;
    for( int i = 1; i * i <= n; ++i ) {
        if( n % i == 0 ) {
            ret.pb( i );

            if( i * i != n ) ret.pb( n / i );
        }
    }
    sort( all( ret ) );
    return ret;
}

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

    LL n, k;
    cin >> n >> k;
    LL res = 0;
    for( LL i = k + 1; i <= n; ++i ) {
        res += ( n / i ) * ( i - k );
        res += max( (LL)0, n % i - k + 1 );

    }
    if( k == 0 ) res -= n;

    cout << res << endl;
    return 0;
}



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

int gcd(int x, int y) {
        int r;
        if(x < y) swap(x,y);
        while(y > 0) {
                r = x % y;
                x = y;
                y = r;
        }
        return x;
}

int main() {
        int x, y;
        cin >> x >> y;
        cout << gcd(x, y) << endl;
        return 0;
}

Measured memory_bytes: 3104
#include <algorithm>
#include <bitset>
#include <complex>
#include <cstdio>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

using namespace std;

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

typedef long long ll;

const int Inf = 100100100;
const double EPS = 1e-9;

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

int lcm(int a, int b) {
    return a * b / gcd(a, b);
}

int bitCount(long bits) {
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int age;
    cin >> age;
    if (age == 7 || age == 5 || age == 3) {
      cout << "YES" << '\n';
    } else {
      cout << "NO" << '\n';
    }

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<queue>
#include<algorithm>
#include<functional>
#define rep(i, n) for(int i = 0; i < n; i++)
#define repp(i, a, b) for(int i = a; i <= b; i++)
using namespace std;
using ll = long long;
using vel = vector<ll>;
using vvel = vector<vel>;

vvel maze;
ll w, h;

ll dfs(ll y, ll x) {
    if(maze[y][x]!=1) return 0;
    maze[y][x] = -1;
    repp(dy, -1, 1) {
        repp(dx, -1, 1) {
            if(y+dy < 0 || y+dy >= h || x+dx < 0 || x+dx >= w ) continue;
            if(dx == 0 && dy == 0) continue;
            dfs(y+dy, x+dx);
        }
    }
    return 1;
};

int main() {
    while(cin >> w >> h, w) {
        maze.assign(h, vel(w, 0));
        rep(y, h) rep(x, w) cin >> maze[y][x];
        ll ans = 0;
        rep(y, h) {
            rep(x, w) {
                if(maze[y][x] == 1) 
                    ans += dfs(y, x);
            }
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 3164
import fractions as f

n = int(input())
a = [int(_) for _ in input().split()]

left = [0] * (n+1)
left[0] = 0
for i in range(1, n+1):
    left[i] = f.gcd(left[i-1], a[i-1])

right = [0] * (n+1)
right[n] = 0
for i in range(1, n+1):
    right[n-i] = f.gcd(right[n-i+1], a[n-i])

ans = 0
for i in range(n):
    ans = max(ans, f.gcd(left[i], right[i+1]))
print(ans)

Measured memory_bytes: 16132
migi="yuiophjklnm"
hidari="qwertasdfgzxcvb"
while True:
  n=input()
  if n=="#":
    break
  count=0
  for i in range(len(n)):
    if i==0:
      if n[i] in migi:
        flag=1
      else:
        flag=0
    if i>=1:
      if n[i] in migi and flag==0:
        flag=1
        count+=1
      if n[i] in hidari and flag==1:
        flag=0
        count+=1
    #print(flag)
  print(count)


Measured memory_bytes: 5560
n = int(input())
S = [list(input()) for i in range(n)]
s1 = S.pop(0)
A = []
for s in s1:
	flag = 0
	for t in S:
		if s not in t:
			flag = 1
	if flag == 0:
		A.append(s)
		for i in range(len(S)):
			S[i].remove(s)
A.sort()
print("".join(A))

Measured memory_bytes: 3064
N = int(input())
List=list(map(int,input().split()))
ans = [[0,0] for i in range(N+1)]
for i in range(N):
  a = List[i]
  if i + a < N:
    ans[i+a][0] += 1
  if i-a >= 0:
    ans[i-a][1] += 1
    
cnt = 0
for i in range(N+1):
  a = ans[i][0]
  b = ans[i][1]
  
  cnt = cnt + a*b
     
print(int(cnt))

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

using namespace std;

int count(string S, string T){
  vector<bool> s(26, false), t(26, false);
  for(auto c : S) s[c - 'a'] = true;
  for(auto c : T) t[c - 'a'] = true;
  int ret = 0;
  for(int i = 0; i < 26; i++)
    if(s[i] && t[i]) ret++;
  return ret;
}

int main(void){
  int N;
  string S;
  cin >> N >> S;
  int ans = 0;
  for(int i = 0; i < N; i++){
    ans = max(ans, count(S.substr(0, i), S.substr(i, N - i)));
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
	int A,B,C,D,P,X = 0,Y = 0,result;
	scanf("%d %d %d %d %d",&A,&B,&C,&D,&P);
	X = A * P;
	if(P > C)Y = B + D * (P - C);
	else Y = B;
	if(X > Y)result = Y;
	else result = X;
	printf("%d\n",result);
	return 0;
}

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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define LCM(a, b) (a) / __gcd((a), (b)) * (b)
#define CEIL(a, b) (a)/(b)+(((a)%(b))?1:0)
#define ln '\n'

using namespace std;
using LL = long long;
using ldouble = long double;
using P = pair<int, int>;
using LP = pair<LL, LL>;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1e9 + 7;
static const int SIZE = 200005;

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

vector<LL> Div(LL n) {
    vector<LL> ret;
    for(LL i = 1; i * i <= n; ++i) {
        if(n % i == 0) {
            ret.pb(i);
            if(i * i != n) ret.pb(n / i);
        }
    }
    sort(all(ret));
    return ret;
}

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

    LL n, d, a;
    cin >> n >> d >> a;
    vector<LP> v(n);
    for(int i = 0; i < n; ++i) {
        cin >> v[i].F >> v[i].S;

    }
    sort(all(v));

    queue<LP> q;
    int pos = 0;
    LL res = 0;
    LL sum = 0;
    while(pos < n) {
        while(!q.empty() && v[pos].F > q.front().F) {
            sum -= q.front().S;
            q.pop();

        }

        v[pos].S -= sum;
        if(v[pos].S > 0) {
            LL tmp = v[pos].S / a;
            if(v[pos].S % a != 0) ++tmp;
            sum += a * tmp;
            res += tmp;
            q.push(MP(v[pos].F + d * 2, a * tmp));

        }
        ++pos;
    }
    cout << res << endl;

    return 0;
}



Measured memory_bytes: 4992
# -*- coding: utf-8 -*-
# B - バイナリハックイージー

s = input()
listAns = []

set1 = ['0', '1']
set2 = ['B']

listS = list(s)

# print(listS)

for i in listS:
    if i in set1:
        listAns.append(i)

    elif i in set2:
        if len(listAns) != 0:
            listAns.pop()

ans = "".join(listAns)

print(ans)

Measured memory_bytes: 8996
s = input()
n = len(s)
ans = 0
for i in range(2**n):
	l = []
	op = [""]*n
	for j in range(n):
		if ((i >> j) & 1) == 1:
			op[j] = '+'
	res = ""
	for a,b in zip(op+[""],s):
		res += a+b
	ans += eval(res)
print(ans//2)

Measured memory_bytes: 3064
N = int(input())
X = [0]*45
def fib(n):
    while 1:
        if n ==0 or n==1:
            return 1
        else:
            if X[n] != 0:
                return X[n]
            else:
                X[n] =fib(n-1)+fib(n-2)
            return X[n]


print(fib(N))


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

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

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

#define INF 1e16
#define mod 1000000007

ll n;
vector<P> ps;
bool used[100];

int main(){
  cin>>n;
  rep(i,n){
    ll a,b;
    cin>>a>>b;
    a--;
    ps.push_back(P(a,b));
  }
  ll cnt=0;
  rep(i,31){
    ll mnse=INF,mnidx=-1;
    rep(j,n){
      if(used[j])continue;
      if(ps[j].fi<=i&&i<ps[j].se){
        if(mnse>ps[j].se){
          mnse=ps[j].se;
          mnidx=j;
        }
      }
    }
    if(mnidx!=-1){
      used[mnidx]=true;
      cnt++;
    }
  }
  cout<<cnt*100+(31-cnt)*50<<endl;
  return 0;
}



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

double l[20],a[20],b[20];

int main() {
	int n,m;scanf("%d%d",&n,&m);
	rep(i,n){
		scanf("%lf%lf%lf",&l[i],&a[i],&b[i]);
	}
	double Max=0;
	rep(i,1<<n){
		list<int>ls;
		rep(j,n){
			if(i>>j&1)ls.push_back(j);
		}
		if(ls.size()!=m)continue;
		double cnt=0;
		for(auto j=ls.begin();j!=ls.end();j++){
			for(auto k=j;k!=ls.end();k++){
				if(j==k)continue;
				cnt+=pow(abs(l[*k]-l[*j]),2);
				cnt+=pow(abs(a[*k]-a[*j]),2);
				cnt+=pow(abs(b[*k]-b[*j]),2);
			}
		}
		Max=max(Max,cnt);
	}
	printf("%.12lf\n",Max);
}

Measured memory_bytes: 3232
#include<iostream>
#include<algorithm>
#include<vector>
#include <cmath>
#include <limits>
#include <iomanip>
using namespace std;
const long long INF=20000000000;

int main(){
	int a,b;
	cin>>a>>b;
	for(int i=b-a+1;i<=b+a-1;i++)cout<<i<<" ";
	cout<<endl;

	
}
	


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
	long n,l,ans=0,i,dif=99999;
	cin >> n >> l;
	long a[n];
	for(i=0;i<n;i++){
		a[i] = l+i;
		ans += a[i];
		if(abs(dif) > abs(a[i])){
			dif = a[i];
		}
	} 
	ans -= dif;
	cout << ans << endl;
	return 0;
}


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

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  
  if (a+b > c+d) {
  	cout << "Left" << endl;
  }
  else if (a+b == c+d) {
  	cout << "Balanced" << endl;
  }
  else {
  	cout << "Right" <<endl;
  }
}

Measured memory_bytes: 3564
#include <bits/stdc++.h>
#define DUMP(x)  cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define IFOR(i, m, n) for(int i = n - 1; i >= m; i-- )
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;
const int MOD = 1000000007;
/* テンプレートここまで */

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

  REP(i, n){
    cin >> a[i];
  }

  deque<int> d;

  REP(i, n){
    if((i - n)%2 == 0){
      d.push_back(a[i]);
    }else{
      d.push_front(a[i]);
    }
  }

  REP(i, d.size()){
    cout << d[i];
    if(i == d.size()-1){
      cout << endl;
    }else{
      cout << " ";
    }
  }

}

Measured memory_bytes: 3840
import math

A,B,DEGREE = map(int,input().split())

rad = math.radians(DEGREE)

S = A*B*math.sin(rad)/2.0
C = math.sqrt(A**2+B**2-2*A*B*math.cos(rad))
h = 2*S/A

print("%.10f %.10f %.10f"%(S,A+B+C,h))


Measured memory_bytes: 5712
// (c) 2020, redotter

// Roses are red
// The Tardis is blue
// The Doctor once said
// Rose Tyler...

#pragma GCC optimize("O3", "unroll-loops")
#pragma GCC target("avx2")
#include <bits/stdc++.h>
using namespace std;
#ifndef ONLINE_JUDGE
#pragma comment(linker, "/stack:500000000")
#endif

#define pb push_back
#define the(a) (a).begin(), (a).end()
#define ft first
#define sd second
#define endl "\n"
#define forn(i, n) for (int i = 0; i < (n); i++)
#define forr(i, s, n) for (int i = (s); i < (n); i++)

using i64 = long long;
using i32 = int;
using f64 = long double;

template <class T> using vec = vector<T>;
using str = string; using p64 = pair<i64, i64>;
using v64 = vec<i64>; using vv64 = vec<v64>;
using s64 = set<i64>; using m64 = map<i64, i64>;
template <size_t Size1> using a64 = array<i64, Size1>;
template <size_t Size1, size_t Size2> using aa64 = array<a64<Size2>, Size1>;
template <class T> using hash_set = unordered_set<T>;
template <class T, class U> using hash_map = unordered_map<T, U>;

mt19937 gen(998244353);
const i64 inf = numeric_limits<i64>::max() / 2;

template <class T> inline i64 len(const T& a) { return (i64)(a.size()); }
inline void fast() { ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); }
template <class T, class S>
inline bool check_min(T& a, S b) { if (a > b) return a = b, 1; return 0; }
template <class T, class S>
inline bool check_max(T& a, S b) { if (a < b) return a = b, 1; return 0; }

void read() {}
template<class T, class ...U>
void read(T& a, U& ...b) { cin >> a; read(b...); }
void print() {}
template<class T, class ...U>
void print(const T& a, const U& ...b) { cout << a << " "; print(b...); }
void println() { cout << "\n"; }
template<class T, class ...U>
void println(const T& a, const U& ...b) { cout << a << " "; println(b...); }

struct Problem {
	void files(str in, str out) {
#ifdef ONLINE_JUDGE
		freopen(in.c_str(), "r", stdin), freopen(out.c_str(), "w", stdout);
#endif
	}
	void solve(), input();
	void many() { i32 t; cin >> t; while (t--) input(), solve(); }
	void make(bool mt = 0) { if (mt) many(); else input(), solve(); }
} problem;

signed main() {
	fast();
	problem.make();
#ifdef _DEBUG
	println(); println("[finished]"); system("pause > nul");
#endif
	return 0;
}

const i64 R = 1e9 + 7;

i64 n, k;
v64 a;

void Problem::solve() {
	vv64 dp(n + 1, v64(k + 1, 0));
	dp[0][0] = 1;
	forr(i, 1, n + 1) {
		v64 pref(k + 1);
		forn(j, k + 1) {
			pref[j] = dp[i - 1][j] + (j ? pref[j - 1] : 0);
			pref[j] %= R;
		}
		forn(j, k + 1) {
			i64 who = min(i64(j), a[i]);
			i64 sum = pref[j] + R;
			if (j - who) sum -= pref[j - who - 1];
			sum %= R;
			dp[i][j] += sum % R;
		}
	}
	println(dp[n][k]);
}

void Problem::input() {
	read(n, k);
	a.resize(n + 1);
	forn(i, n) read(a[i + 1]);
}


Measured memory_bytes: 83160
#include <bits/stdc++.h>
using namespace std;
int main(){
  
  int N;
  string A;
  string B;
  string C;
  
  cin >> N;
  cin >> A;
  cin >> B;
  cin >> C;
  
  int num = 0;
 
  for(int i = 0;i < N;++i){
    num = num + 2;
    if(A[i] == B[i] && B[i] == C[i]){
      num = num - 2;
    }
    else if(A[i] == B[i] || B[i] == C[i] || A[i] == C[i]){
      num = num - 1;
    }
  }
  
  cout << num << endl;
}


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

int main() {
  int n,x;
  cin >>n>>x;
  int count=1;
  int d=0;
  for(int i=0;i<n;i++){
    int l;
    cin>>l;
    d+=l;
    if(d<=x) count++;
  }
  cout<<count<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, N) for (int i = 0; i < N; i++)
using namespace std;
int main()
{
    int N, M, max = 0;
    cin >> N;
    vector<string> s(N);
    rep(i, N)
    {
        cin >> s[i];
    }
    cin >> M;
    vector<string> t(M);
    rep(i, M)
    {
        cin >> t[i];
    }
    rep(i, N)
    {
        int count = 0;
        rep(j, N)
        {
            if (s[i] == s[j])
            {
                count++;
            }
        }
        rep(k, M)
        {
            if (s[i] == t[k])
            {
                count--;
            }
        }
        if (count > max)
        {
            max = count;
        }
    }
    cout << max << endl;
}


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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl




typedef long long ll;
const ll mod = 1e9+7;
const int maxn = 1e6 + 5;



// tested at: https://atcoder.jp/contests/dp/tasks/dp_r
// R - Walk

////////////////////////////////////////////////////////////////////
using matrix = vector<vector<ll>>;

void add(ll& x, ll y) {
    if (x>=mod) x%=mod;
    if (y>=mod) y%=mod;
    x += y;
    if (x>=mod) x%=mod;
}

void mul(ll& x, ll y) {
    if (x>=mod) x%=mod;
    if (y>=mod) y%=mod;
    x *= y;
    if (x>=mod) x%=mod;
}


matrix mul(matrix a, matrix b) {
    int n = a.size();
    assert(n>0);
    int m = a[0].size();
    assert(m == int(b.size()));
    int p = b[0].size();
    matrix res(n, vector<ll>(p));
    for (int i=0; i<n; i++) {
	for (int j=0; j<p; j++) {
	    for (int k=0; k<m; k++) {
		ll cur = 1;
		mul(cur, a[i][k]);
		mul(cur, b[k][j]);
		add(res[i][j], cur);
	    }
	}
    }
    return res;    
}


matrix matpw(matrix mat, ll k) {
    int n = mat.size();
    assert(mat.size() && mat.size()==mat[0].size()); //nxn
    matrix res(n,vector<ll>(n));
    for (int i=0; i<n; i++) {
	res[i][i]=1;
    }


    while (k>0) {
	if (k%2) {
	    res=mul(res,mat);
	}
	mat=mul(mat,mat);
	k=k/2;
    }

    return res;
}
////////////////////////////////////////////////////////////////////

ll n, k;

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

    cin>>n>>k;
    matrix mat(n,vector<ll>(n, 0));
    for (int i=0; i<n; i++) {
	for (int j=0; j<n; j++) {
	    cin>>mat[i][j];
	}
    }

    auto res = matpw(mat, k);
 


    ll ans=0;
    for (int i=0; i<n; i++) {
	for (int j=0; j<n; j++) {
	    add(ans, res[i][j]);
	}
    }

    cout<<ans<<endl;

    return 0;
}


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

int main(){
  int total = 0;
  char a;
  for(int i = 0; i < 4; i++){
    cin >> a;
    if(a == '+'){
      total++;
    }else{
      total--;
    }
  }
  cout << total << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
  int Q = sc.nextInt();
  for(int i=0;i<Q;i++){
    long f = sc.nextLong();
    long s = sc.nextLong();
    long a = Math.max(f, s);
    long b = Math.min(f, s);
    long K = a*b;
    long L = (long) Math.sqrt(K);
    long M = (K-1)/L;
    long N = Math.max(-1,M-b-1);
    System.out.println(L+N+b-1);
  }
}}


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

int main() {
  int n; cin >> n;
  long long out = 0;
  for(int i = 1; i <= n; i++){
    if(i % 3 == 0) continue;
    if(i % 5 == 0) continue;
    out += i;
  }
  cout << out;
}


Measured memory_bytes: 3620
#4
n,k=map(int,input().split())
s=str(input())

import numpy as np
line = np.zeros([2*n,],dtype=np.int)
counter1 = 0
counter0 = 0
ind = 0
for i in range(n):
    c = int(s[i])
    if ind%2 ==0:
        if c == 1:
            counter1 += 1
        else:
            counter0 += 1
            if ind == 0:
                line[ind] = counter1
            else:
                line[ind] = line[ind-1]+counter1
            counter1 = 0
            ind+=1
    elif ind%2 ==1:
        if c == 0:
            counter0 += 1
        else:
            counter1 += 1
            line[ind] = line[ind-1] + counter0
            counter0 = 0
            ind+=1

if ind%2 ==0:
        if ind == 0:
                line[ind] = counter1
        else:
                line[ind] = line[ind-1]+counter1
        ind+=1
elif ind%2 ==1:
        line[ind] = line[ind-1] + counter0
        ind+=1
        
if ind%2 ==0:
        line[ind] = line[ind-1]
        ind+=1
        
line[1:ind+1]  = line[:ind]   
line[0] = 0 
line = line[:ind+1]
#print(line)

if (len(line)//2)<=k:
    print(n)
else:
    maxchain = 0
    for i in range(0,len(line)-2*k,2):
        chain = line[i+2*k+1]-line[i]
        #print(chain)
        if chain>maxchain:
            maxchain=chain
    print(maxchain)

Measured memory_bytes: 14576
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef long double ld;

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define INF (ll)1e18
#define MOD (ll)1e9+7
#define print(a); for(auto x:a)cout<<x<<" "; cout<<"\n";
#define mset(a); memset(a,0,sizeof(a));

int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);
    ll k,a,b;cin>>k>>a>>b;
    bool state=1;
    for(ll i=a;i<=b;i++){
        if(i%k==0){
            cout<<"OK\n";state=0;break;
        }
    }
    if(state)cout<<"NG\n";
}


Measured memory_bytes: 3660
#include <iostream>
#include <set>
#include <queue>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstring>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
#include <numeric>
#include <functional>

using namespace std;
#define ALL(x)              (x).begin(),(x).end()
#define REP(i, n)           for (int (i) = 0 ; (i) < (ll)(n) ; ++(i))
#define REPN(i, m, n)       for (int (i) = m ; (i) < (ll)(n) ; ++(i))
#define INF                 (int)2e9
#define MOD                 (1000 * 1000 * 1000 + 7)
#define Ceil(x, n)          (((((x))+((n)-1))/n))
#define CeilN(x, n)         (((((x))+((n)-1))/n)*n)
#define FloorN(x, n)        ((x)-(x)%(n))
#define IsOdd(x)            (((x)&0x01UL) == 0x01UL)
#define IsEven(x)           (!IsOdd((x)))
#define M_PI                3.14159265358979323846
typedef long long           ll;
typedef pair<ll, ll>	    P;

/*-----------------------------------------------------------------------------
　処理
 -----------------------------------------------------------------------------*/
int main()
{
	int N;
	cin >> N;
	vector<ll> A(N);
	REP(i, N) cin >> A[i];

	map<ll, ll> mp;
	for (auto one : A) {
		mp[one]++;
	}

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

	for (auto one : A) {
		ll nowNum = mp[one];
		ll numPrv = (nowNum * (nowNum - 1)) / 2;
		ll numAft = ((nowNum - 1) * (nowNum - 2)) / 2;
		ll ans = allNum + numAft - numPrv;
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 11008
#include <stdio.h>
#include <string.h>

int main() {
  int i, length;
  char str[201];
  scanf("%s", str);
  length = strlen(str);
  if(length % 2 == 1) {
    str[length-1] = NULL;
    length -= 1;
  } else {
    str[length-2] = NULL;
    length -= 2;
  }
  char front_str[length/2+1], back_str[length/2+1];
  for(i = 0; i < length / 2; i++) {
    strncpy(front_str, str, length / 2 - i);
    front_str[length/2-i] = NULL;
    strncpy(back_str, str + length / 2 - i, length / 2 - i);
    back_str[length/2-i] = NULL;
    if(strcmp(front_str, back_str) == 0) {
      printf("%d\n", length - 2 * i);
      break;
    }
  }
  return 0;
}


Measured memory_bytes: 128
/**
 * Created by Sakib on 06/04/2018.
 */
#include <bits/stdc++.h>
using namespace std;

#define fast_io ios_base::sync_with_stdio(false); cin.tie(NULL);
#define debug(args...) { dbg,args; cerr<<"\n"; }
struct debugger{
template<typename T>debugger& operator,(const T& v){cerr<<v<<" ";return *this;}}dbg;

#define Fix( x ) setprecision( x ) << fixed
#define mem( a , x ) memset( a , x , sizeof( a ) )
#define bug( a , b ) cerr<< #a <<" = "<<a<<" , "<< #b <<" = "<<b<<"\n";
#define pb push_back
#define mp make_pair
#define ub upper_bound
#define lb lower_bound
#define FOR( i , a , b ) for( int i = a; i <= b; i++ )
#define ROF( i , a , b ) for( int i = a; i >= b; i-- )
#define sz( V ) (int)V.size( )
#define all( V ) V.begin( ),V.end( )
#define Found( S , val ) S.find( val ) != S.end( )
#define Unique( V ) sort( all( V ) ), V.erase( unique( all( V ) ), V.end() )
typedef pair < int , int > ii;
typedef pair < int , ii > iii;
typedef long long int LL;
typedef unsigned long long uLL;
const int inf = (int)1e9;
const LL INF = (LL)1e18;
const int N = 100005;
const int mod = 1000000007;
const double eps = 1e-8;
const double pi = acos( -1.0 );

int n , l;
vector <string> V;

bool cmp( string a , string b ) {
    if( a+b < b+a ) return true;
    return false;
}
int main( int argc, char const *argv[] ) {
    fast_io;
    cin >> n >> l;
    string s;
    FOR( i , 1 , n ) cin >> s , V.pb( s );
    sort( all(V) , cmp );
    for( auto x : V ) cout << x;
    return 0;
}











Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MAX 1000005
#define ll long long
#define upperlimit 1000100
#define INF 1e18
#define eps 1e-8
#define endl '\n'
#define pcc pair<char,char>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define tr(container,it) for(typeof(container.begin()) it=container.begin();it!=container.end();it++)
#define MOD 1000000007LL
#define slld(t) scanf("%lld",&t)
#define sd(t) scanf("%d",&t)
#define pd(t) printf("%d\n",t)
#define plld(t) printf("%lld\n",t)
#define mp(a,b) make_pair(a,b)
#define FF first
#define SS second
#define pb(x) push_back(x)
#define vi vector<int>
#define vll vector<ll>
#define clr(a) memset(a,0,sizeof(a))
#define debug(a) printf("check%d\n",a)
#define csl ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
 
ll gcd(ll n1,ll n2){
	if(n2==0)
		return n1;
	if(n1%n2==0)return n2;
	return gcd(n2,n1%n2);
}
ll powmod(ll base,ll exponent)
{
	if(exponent<0) exponent+=MOD-1;
	ll ans=1;
	while(exponent){
		if(exponent&1)ans=(ans*base)%MOD;
		base=(base*base)%MOD;
		exponent/=2;
	}
	return ans;
}
int arr[3][MAX];
int dp[3][MAX];
int main()
{
	int n;
	cin>>n;
	for(int i=1;i<=2;i++)
	for(int j=1;j<=n;j++)
	cin>>arr[i][j];

	for(int i=1;i<=2;i++)
	{
		for(int j=1;j<=n;j++)
		{
			dp[i][j]=max(dp[i][j],max(dp[i][j-1],dp[i-1][j]));
			dp[i][j]+=arr[i][j];
		}
	}	
	cout<<dp[2][n]<<endl;
}

Measured memory_bytes: 8448
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>

using std::cin;
using std::cout;
using std::endl;

using std::string;
using std::pair;

using std::vector;
using std::sort;

int main(){
    int x,y;
    cin >> x >> y;
    if(x%y==0){
        cout << -1 << endl;
    }
    else{
        cout << x << endl;
    }
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a[100],n,m,i,j;
	int ans;
	for(i=1;i<=5;i++)
	{
		cin>>n;
		if(n == 0)
		{
			ans = i;
		}
	}
	cout<<ans<<"\n";

return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define m_p make_pair
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define fi first
#define se second
typedef long long ll;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
mt19937 rnf(2106);
const int N = 502;
const int xx[4] = {0, 1, 0, -1};
const int yy[4] = {1, 0, -1, 0};

int n;
int b[N * N];
int u[N][N];

int a[N][N];

void solv()
{
    scanf("%d", &n);
    for (int i = 1; i <= n * n; ++i)
    {
        scanf("%d", &b[i]);
        int x, y;
        x = (b[i] - 1) / n + 1;
        y = (b[i] - 1) % n + 1;
        u[x][y] = i;
    }
    for (int i = 1; i <= n; ++i)
    {
        for (int j = 1; j <= n; ++j)
        {
            a[i][j] = min(min(i - 1, n - i), min(j - 1, n - j));
        }
    }
    int ans = 0;
    for (int i = 1; i <= n * n; ++i)
    {
        int x, y;
        x = (b[i] - 1) / n + 1;
        y = (b[i] - 1) % n + 1;
        ans += a[x][y];
        queue<pair<int, int> > q;
        q.push(m_p(x, y));
        while (!q.empty())
        {
            x = q.front().fi;
            y = q.front().se;
            q.pop();
            for (int j = 0; j < 4; ++j)
            {
                int hx = x + xx[j];
                int hy = y + yy[j];
                if (hx >= 1 && hx <= n && hy >= 1 && hy <= n)
                {
                    if (u[x][y] > i)
                    {
                        if (a[x][y] + 1 < a[hx][hy])
                        {
                            a[hx][hy] = a[x][y] + 1;
                            q.push(m_p(hx, hy));
                        }
                    }
                    else
                    {
                        if (a[x][y] < a[hx][hy])
                        {
                            a[hx][hy] = a[x][y];
                            q.push(m_p(hx, hy));
                        }
                    }
                }
            }
        }
    }
    printf("%d\n", ans);
}

int main()
{
    #ifdef SOMETHING
    freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    #endif // SOMETHING
    solv();
    return 0;
}

//while ((double)clock() / CLOCKS_PER_SEC <= 0.9){}


Measured memory_bytes: 6732