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

//scanf("%d",&x);
//printf("%d",x);
//for(i=0;i<N;i++){  }
//if( == ){  }else{  }
//while( ){  }

/*
int N, i;
int H[100];
scanf("%d", &N);
for (i = 0; i < N; i++) scanf("%s", &H[i]);
*/

int main()
{
	
	int N,M,X,Y,i,z;
	int x[201];
	int y[201];

	scanf("%d", &N);
	scanf("%d", &M);
	scanf("%d", &X);
	scanf("%d", &Y);

	for (i = 0; i < N; i++) scanf("%d", &x[i]);
	for (i = 0; i < M; i++) scanf("%d", &y[i]);

	
	int xmax = -100;
	int ymin = 100;

	for (i = 0; i < N; i++) {
		if (xmax < x[i]) xmax = x[i];
	}

	for (i = 0; i < M; i++) {
		if (ymin > y[i]) ymin = y[i];
	}

	if (ymin > xmax) {
		
		for (z = -100; z < 100; z++) {
			if (z > X && z <= Y && xmax<z && ymin>=z) {
				printf("No War");
				return 0;
			}
		}

	
	}
	printf("War");

}

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

#define int long long

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int N, K;
  cin >> N >> K;

  int ans = 0;
  for ( int i = 0; i < N; i++ ) {
    int a;
    cin >> a;
    if ( a >= K ) ans++;
  }

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;
using namespace std;
typedef tree<pair<int,int>,null_type,less<pair<int,int>>,rb_tree_tag,tree_order_statistics_node_update> oset;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
	*this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

using ll = long long;
#define ar array 

void test_case() {
	double d , t , s;
	cin >> d >> t >> s;
	if(t >= d/s)
		cout<<"Yes\n";
	else
		cout<<"No\n";
}
 
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int T = 1;
	//~ cin >> T;
	while(T--){
		test_case();
	}
}


Measured memory_bytes: 3736
x,y=map(int,input().split())
if y>0:
  l=list(map(int,input().split()))
  for i in range(len(l)+1):
    if x-i not in l:
      print(x-i)
      break
    if x+i not in l:
      print(x+i)
      break
else:
  print(x)

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

using namespace std;

typedef unsigned long long ull;
typedef long double ld;
typedef long long ll;
typedef pair<int,int> pi;

const int MAXN = 1e5 + 1;
vector<int> a;

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

    int n,x; cin >> n;
    for(int i=0;i<n;++i) cin >> x,a.push_back(x);
    sort(a.rbegin(),a.rend());
    int suma(0),sumb(0);
    for(int i =0;i<n;++i)
    {
        if(i%2==0) suma+=a[i];
        else sumb+=a[i];
    }
    cout << suma - sumb << endl;
}


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

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

int N;
int Q;
int V[200010];
vector<int> G[200010];

void dfs(int v, int par, int c)
{
	V[v] += c;
	for (auto e : G[v])
	{
		if (e == par)continue;
		dfs(e, v, V[v]);
	}
}

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

	cin >> N >> Q;
	int a, b;
	rep(i, 0, N-1)
	{
		cin >> a >> b;
		a--, b--;
		G[a].push_back(b);
		G[b].push_back(a);
	}

	int v, q;
	rep(i, 0, Q)
	{
		cin >> v >> q;
		v--;
		V[v] += q;
	}

	dfs(0, -1, 0);

	rep(i, 0, N)
	{
		cout << V[i] << " ";
	}
	cout << endl;

	return 0;
}

Measured memory_bytes: 24320
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N;
    string ans = "Three";
    cin >> N;
    vector<char> S(N);
    for(int i = 0;i < N;i ++){
        cin >> S[i];
        if(S[i] == 'Y') ans = "Four";
    }
    cout << ans << endl;
    
    return 0;
}

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

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

using namespace std;

class mint{
	static const int MOD=1e9+7;
	int x;
public:
	mint():x(0){}
	mint(long long y){ x=y%MOD; if(x<0) x+=MOD; }

	mint& operator+=(const mint& m){ x+=m.x; if(x>=MOD) x-=MOD; return *this; }
	mint& operator-=(const mint& m){ x-=m.x; if(x<   0) x+=MOD; return *this; }
	mint& operator*=(const mint& m){ x=1LL*x*m.x%MOD; return *this; }
	mint& operator/=(const mint& m){ return *this*=inverse(m); }
	mint operator+(const mint& m)const{ return mint(*this)+=m; }
	mint operator-(const mint& m)const{ return mint(*this)-=m; }
	mint operator*(const mint& m)const{ return mint(*this)*=m; }
	mint operator/(const mint& m)const{ return mint(*this)/=m; }

	friend mint inverse(const mint& m){
		int a=m.x,b=MOD,u=1,v=0;
		while(b>0){ int t=a/b; a-=t*b; swap(a,b); u-=t*v; swap(u,v); }
		return u;
	}

	friend istream& operator>>(istream& is,mint& m){ long long t; is>>t; m=mint(t); return is; }
	friend ostream& operator<<(ostream& os,const mint& m){ return os<<m.x; }
	int to_int()const{ return x; }
};

mint operator*(long long y,const mint& m){ return m*y; }

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

	// dp[i][j][s] := 左の頂点 {1,2,...,i} と右の頂点 {1,2,...,i} に対して,
	//                j 組がマッチング済みで, "その時点で確定したスコア" が s であるような場合の数
	static mint dp[51][51][2501];
	dp[0][0][0]=1;
	rep(i,n) rep(j,i+1) rep(s,k+1) {
		int s2;
		// 左の i+1 と右の i+1 をマッチング
		s2=s+2*(i-j);
		if(s2<=k) dp[i+1][j+1][s2]+=dp[i][j][s];
		// 左の i+1 も右の i+1 も保留
		s2=s+2*(i-j+1);
		if(s2<=k) dp[i+1][j][s2]+=dp[i][j][s];
		// 片方の i+1 をもう片方の保留にしていた頂点とマッチング, 残った i+1 は保留
		s2=s+2*(i-j);
		if(s2<=k) dp[i+1][j+1][s2]+=2*(i-j)*dp[i][j][s];
		// 左の i+1 を右の保留にしていた頂点とマッチング, 右の i+1 を右の保留にしていた頂点とマッチング
		s2=s+2*(i-j-1);
		if(s2<=k && j<i) dp[i+1][j+2][s2]+=(i-j)*(i-j)*dp[i][j][s];
	}
	printf("%d\n",dp[n][n][k].to_int());

	return 0;
}


Measured memory_bytes: 25600
def main
  n = gets.chomp.to_i
  p = gets.chomp.split.map(&:to_i)
  q = gets.chomp.split.map(&:to_i)
  
  array = p.sort
  perm = array.permutation.to_a

  p_idx = perm.index(p)
  q_idx = perm.index(q)

  puts (p_idx - q_idx).abs

end

main



Measured memory_bytes: 6780
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=1e5+10;


int main()
{
    ll n,ans=0;
    cin>>n;
    for(ll i=1;i*i<=n;i++)
    {
        if(n%i==0)
        {
            ll m,x;
            m=i-1;x=n/i;
            if(!m){}
            else if(n/m==x&&n%m==x)ans+=m;

            if(i*i<n)
            {
                m=n/i-1;x=i;
            if(!m){}
            else if(n/m==x&&n%m==x)ans+=m;

            }
        }
    }
    cout<<ans<<endl;

    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define repk(i,k,n) for (ll i = k; i < (ll)(n); ++i)
#define MAX 500000001000000000
#define MOD 1000000007
typedef long long  ll;

using namespace std;



int main() {

	ll K,N;
	cin >> N >> K;
	ll mae = N;
	while (1) {

		ll ab;
		if (N > K) {
			if (N % K == 0) {
				N = 0;
				break;
			}
			ab = N % K;
		}
		else {
			ab = abs(N-K);
		}
		
		
		if (ab <  mae) {
			N = ab;
		}
		else {
			break;
		}
		mae = N;

	}
	

	cout << N << endl;

	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <set>
#include <algorithm>

struct Node {
  std::vector<int> next;
  int is_removed = 0;
  int f = 0;
  int res = 0;
  int parent;

  std::vector<int> bad;
};

void merge_set(std::set<int> &dest, std::set<int> from) {
  if (from.size() > dest.size()) {
    std::swap(dest, from);
  }
  dest.insert(from.begin(), from.end());
}

void remove_dfs(int v, std::vector<Node> &nodes, int &children) {
  if (nodes[v].is_removed) {
    return;
  }
  nodes[v].is_removed = true;
  children--;
  for (auto u : nodes[v].next) {
    if (u == nodes[v].parent) {
      continue;
    }
    remove_dfs(u, nodes, children);
  }
}

void calc_res(int v, int depth, int carry, std::vector<Node> &nodes) {
  int sum = 0;
  for (auto u : nodes[v].next) {
    if (u == nodes[v].parent) {
      continue;
    }
    sum += nodes[u].f;
  }
  nodes[v].res += sum + depth + carry;
  //printf("%d: %d %d %d\n", v, sum, depth, carry);
  for (auto u : nodes[v].next) {
    if (u == nodes[v].parent) {
      continue;
    }
    calc_res(u, depth + 1, sum - nodes[u].f + carry, nodes);
  }
}

struct Event {
  int mx;
  int v;
};

void calc_bad(int v, int parent, int mx, std::vector<Node> &nodes, std::vector<Event> &events) {
  events.push_back({mx, v});
  for (auto u : nodes[v].next) {
    if (u == parent) {
      continue;
    }
    calc_bad(u, v, std::max(mx, parent), nodes, events);
  }

  int l = 0, r = (int)events.size();
  while (l + 1 < r) {
    int c = (l + r) / 2;
    if (events[c].mx < v) {
      l = c;
    } else {
      r = c;
    }
  }
  nodes[events[l].v].bad.push_back(v);

  events.pop_back();
}

void calc_f(int v, int parent, int mx, std::vector<Node> &nodes, int &children) {
  nodes[v].parent = parent;
  for (auto u : nodes[v].next) {
    if (u == parent) {
      continue;
    }
    int u_children = 0;
    calc_f(u, v, std::max(mx, parent), nodes, u_children);
    children += u_children;
  }

  children++;
  auto &bad = nodes[v].bad;

  for (auto u : bad) {
    remove_dfs(u, nodes, children);
  }

  nodes[v].f = children;
}

int main(void) {
  {
    //int n = 1 << 18;
    //std::vector<Node> nodes(n);
    //for (int i = 2; i <= n; i++) {
    //int a = n - i + 2;
    //int b = i / 2;
    //if (b != 1) {
    //b = n - b + 2;
    //}

    //a--;
    //b--;
    //nodes[a].next.push_back(b);
    //nodes[b].next.push_back(a);
    //}
    //std::set<int> children;
    //calc_f(0, -1, -1, nodes, children);
    //calc_res(0, 0, 0, nodes);
  }

  int n;
  while (scanf("%d", &n) == 1) {
    std::vector<Node> nodes(n);
    for (int i = 1; i < n; i++) {
      int a, b;
      scanf("%d%d", &a, &b);
      a--, b--;
      nodes[a].next.push_back(b);
      nodes[b].next.push_back(a);
    }
    int children = 0;
    std::vector<Event> events;
    calc_bad(0, -1, -1, nodes, events);
    calc_f(0, -1, -1, nodes, children);
    calc_res(0, 0, 0, nodes);
    //for (int i = 1; i < n; i++) {
    //printf("%d ", nodes[i].f);
    //}
    //printf("\n");
    for (int i = 1; i < n; i++) {
      printf("%d ", nodes[i].res);
    }
    printf("\n");
  }

  return 0;
}


Measured memory_bytes: 42484
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int M=200005;
ll n,i,ans;
int a[M],c[M];

int main(){
	cin>>n;
	
    for(i=1;i<=n;i++){
        cin>>a[i];
        c[a[i]]++;
    }
    
    for(i=1;i<=n;i++)
    ans+=(ll)(c[i]-1)*c[i]/2;
     
    for(i=1;i<=n;i++)
    cout<<ans-(ll)(c[a[i]]-1)<<endl;
    
    return 0;
}

Measured memory_bytes: 3712
#include <stdio.h>
int main(){

  int n,i,j,a=0,ans=0 ;
  for(;;){
  scanf("%d",&n);
  if(n==0){
    break;
  }
  for(i=n+1;i<=2*n;i++){
    for(j=2;j*j<=i;j++){
      if(i%j==0){
	a=1;
      }
    }
    if(a==0){
      ans++;
    }
    a=0;
    }

  printf("%d\n",ans);
  ans=0;
  a=0;
  }
  return 0;
}

    
   

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

namespace AtCoder
{
    class Program
    {
        static List<int> plus = new List<int>();
        static List<int> minus = new List<int>();
        
        static void Main(string[] args)
        {
            //[summary]A - Accepted...?
            string s = Console.ReadLine();
            
            Console.WriteLine(s.Count(x => x == '1'));
        }
    }
}

Measured memory_bytes: 11220
using System;

namespace ABC051B
{
    class Program
    {
        static void Main(string[] args)
        {
            var target = Console.ReadLine().Split(' ');
            int K = int.Parse(target[0]);
            int S = int.Parse(target[1]);
            int count = 0;
            for(int x = 0; x <= K; x++){
                for(int y = 0; y <= K; y++){
                    if(S-x-y >= 0 &&  S-x-y <= K)count++;
                }
            }
            Console.WriteLine(count);
        }
    }
}


Measured memory_bytes: 11092
#include<stdio.h>

int selectionSort(int A[], int N){
    int i,j,t,sw=0,minj;
    for (i = 0; i<N-1;i++){
        minj =i;
        for (j=i;j<N;j++){
            if(A[j]<A[minj]) minj = j;
        }
        t=A[i]; A[i]=A[minj]; A[minj]=t;
        if(i!=minj) sw++;
    }
    return sw;
}

int main(){
    int A[100], N, i, sw;
    
    scanf("%d", &N);
    
    for(i=0; i<N; i++) scanf("%d", &A[i]);
    
    sw=selectionSort(A,N);
    
    for(i=0; i<N; i++){
        if(i>0) printf(" ");
        printf("%d", A[i]);
    }
    printf("\n");
    printf("%d\n", sw);
    
    return 0;
}


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

int main()
{
	int a;
	std::string s;
	std::cin >> a;
	std::cin >> s;
	if(a>=3200){
		std::cout<< s << std::endl;
	}
	else{
		std::cout << "red" << std::endl;
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[]args) {
		try(Scanner scan = new Scanner(System.in)){
			
			int A = scan.nextInt();
			int B = scan.nextInt();
			
			int[]s = new int[2000];
			
			int ase = (double)((A*25)/2)==(A*25.0)/2.0?(A*25)/2:(A*25)/2+1;
			int ako = (double)(((A+1)*25)/2)==((A+1)*25.0)/2.0?((A+1)*25)/2-1:((A+1)*25)/2;
			
			int bse = B*10;
			int bko = B*10+9;
			
			for(int i = ase-1;i<ako;i++) {
				s[i]++;
			}
			for(int i = bse-1;i<bko;i++) {
				s[i]++;
			}
			
			int ok=0;
			for(int i = 0;i<2000;i++) {
				if(s[i]==2) {
					ok=1;
					System.out.println(i+1);
					break;
				}
			}
			
			if(ok==0)System.out.println(-1);
			
			
			
			
		}	
	}
}


Measured memory_bytes: 22996
N = int(input())

a = []

for i in range(N):
    a.append(int(input()) - 1)

done = [False] * N

i = 0

ans = 0

while True:
    if done[i] == False:
        done[i] = True
        ans += 1
        if a[i] == 1:
            break
        i = a[i]
    else:
        ans = -1
        break

print(ans)


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

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

    static class TaskB {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            char[] A = in.next().toCharArray();
            char[] B = in.next().toCharArray();
            char[] C = in.next().toCharArray();

            List<char[]> players = new ArrayList<>(Arrays.asList(A, B, C));
            int[] points = {A.length, B.length, C.length};
            int[] index = {0, 0, 0};
            char[] winner = {'A', 'B', 'C'};

            int cur = 0;
            while (true) {
                if (points[cur] == 0) {
                    out.println(winner[cur]);
                    break;
                }
                --points[cur];
                ++index[cur];
                cur = players.get(cur)[index[cur] - 1] - 'a';

            }
        }

    }

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

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

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

    }
}



Measured memory_bytes: 21460
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("Ofast")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
 
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <iterator>
#include <functional>
#include <limits>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <cassert>
#include <unordered_map>
#include <unordered_set>
#include <stack>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
 
typedef int64_t ll;
 
#define endl '\n'
#define int ll
ll mod=1e9+7;
ll mod1=1e9+5;
ll power(ll a,ll b)
{
    if(b==0) return 1;
    else if(b%2==0)
        return power((((a%mod)*(a%mod))%mod),b/2)%mod;
    else return ((a%mod)*(power((((a%mod)*(a%mod))%mod),b/2)%mod))%mod;
}
int b[800000];
int tree[1200000];
void update(int node, int start, int end, int idx, int val)
{
    if(start == end)
    {
        
        b[idx] = max(b[idx],val);
        tree[node] = val;
    }
    else
    {
        int mid = (start + end) / 2;
        if(start <= idx and idx <= mid)
        {
            update(2*node, start, mid, idx, val);
        }
        else
        {
            update(2*node+1, mid+1, end, idx, val);
        }
        tree[node] = max(tree[2*node],tree[2*node+1]);
    }
}
int query(int node, int start, int end, int l, int r)
{
    if(r < start or end < l)
    {
        return 0;
    }
    if(l <= start and end <= r)
    {
       return tree[node];
    }
    int mid = (start + end) / 2;
    return max(query(2*node, start, mid, l, r),query(2*node+1, mid+1, end, l, r));
}

int32_t main()
{
    IOS
    
    
    memset(tree,0,sizeof(tree));
    memset(b,0,sizeof(b));
    int n;
    cin>>n;
    int a[n],c[n];
    for(int i=0;i<n;++i)
        cin>>a[i];
    for(int j=0;j<n;++j)
        cin>>c[j];
    int dp[n+1];
    memset(dp,0,sizeof(dp));
    int ans=0;
    for(int i=1;i<=n;++i)
    {
        int q=query(1,1,300000,1,a[i-1]-1);
        dp[i]=q+c[i-1];
        update(1,1,300000,a[i-1],dp[i]);
        ans=max(ans,dp[i]);
    }
    cout<<ans;
}



Measured memory_bytes: 20608
import java.io.*;class Main{public static void main(String[]g)throws Exception{int i,a,x,y;float b;BufferedReader B=new BufferedReader(new InputStreamReader(System.in));for(String s;(s=B.readLine())!=null;){g=s.split(",");x=Integer.valueOf(g[10]);y=Integer.valueOf(g[11]);for(a=i=0;i<10;)a+=Integer.valueOf(g[i++]);b=x+y;b=a*x/b;for(a=i=0;i<10;i++){a+=Integer.valueOf(g[i]);if(b<=a){System.out.println(i+1);break;}}}}}


Measured memory_bytes: 24092
#include <iostream>
using namespace std;
int func(string s, string t){
    int len = s.length();
    string u = s;
    bool l, g;
    for(int i=0;i<len;i++){
        if(s[i] == '?')u[i] = 'a';
    }
    if(u > t)return 0;
    for(int i=0;i<len;i++){
        if(s[i] == '?')u[i] = 'z';
    }
    if(t <= u)return 2;
    return 1;
}
int main(void){
    int n, begin = 1, error = 0;
    string s[10000], t;
    cin >> n;
    for(int i=0;i<n;i++){
        cin >> s[i];
    }
    cin >> t;
    for(int i=0;i<n;i++){
        int r = func(s[i], t);
        if(r == 1)begin++;
        if(r == 2)error++;
    }

    cout << begin;
    for(int i=1;i<=error;i++){
        cout << " " << begin + i;
    }
    cout << endl;
}


Measured memory_bytes: 896
#define _USE_MATH_DEFINES 
#include <iomanip> 
#include <cmath>  
#include<iostream>
#include <fstream>
#include<vector>
#include<algorithm>
#include<bitset>
#include<map>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define repi(i,a,b) for(ll i = (ll)(a) ; i < (ll)(b) ; i++)
#define repd(i,a,b) for(ll i = (ll)(a) ; i > (ll)(b) ; i--)


int main() {
	ll N, A, B, ans;
	cin >> N >> A >> B;
	ans = min(N*A, B);
	cout << ans << endl;
	return 0;
}

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

long long ctoi(const char c)
{
    return (c - '0');
}

void solve(long long N, long long P, string S)
{
    long long cnt = 0;

    if (P == 2)
    {
        for (long long i = N; i >= 1; i--)
        {
            if (ctoi(S[i]) % 2 == 0)
            {
                cnt += i;
            }
        }
    }
    else if (P == 5)
    {
        for (long long i = N; i >= 1; i--)
        {
            if (ctoi(S[i]) == 0 || ctoi(S[i]) == 5)
            {
                cnt += i;
            }
        }
    }
    else
    {
        long long ten = 1;
        vector<long long> d(N + 2, 0), v(P, 0);
        for (long long i = N; i >= 1; i--)
        {
            long long m = (ctoi(S[i]) * ten) % P;
            d[i] = (d[i + 1] + m) % P;
            ten = (ten * 10) % P;
        }

        for (long long i = 1; i < N + 2; i++)
        {
            v[d[i]]++;
        }

        for (long long i = 0; i < P; i++)
        {
            cnt += v[i] * (v[i] - 1) / 2;
        }
    }

    cout << cnt << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main()
{
    long long N;
    cin >> N;
    long long P;
    cin >> P;
    string S;
    cin >> S;
    S = "0" + S + "0";
    solve(N, P, S);
    return 0;
}


Measured memory_bytes: 2240
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <queue>

using namespace std;

int main() {
	int n;
	cin >> n;
	vector<long long> as;
	long long sum = 0;
	for(int i=0;i<n;++i){
		long long a;
		cin >> a;
		as.push_back(a);
		sum += a;
	}
	long long sum_int = 0;
	long long minval = 1LL<<60;
	for (int i = 0; i < n; ++i) {
		sum_int += as[i];
		if (i + 1 != n) {
			minval = min(minval, abs(sum - 2 * sum_int));
		}
	}
	cout << minval << endl;
}

Measured memory_bytes: 2420
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.util.*;
import java.util.Map.Entry;

public class Main{
	public static void main(String[] args) {
		FastScanner fs = new FastScanner();
	    String s = fs.next();
	    if(s.charAt(s.length()-1)=='s') {
	    	s+="es";
	    }
	    else {
	    	s+='s';
	    }
	    System.out.println(s);
	  
	}
	static void sort(int[] a) {
		ArrayList<Integer> l = new ArrayList<>();
		for(int i:a) l.add(i);
		Collections.sort(l);
		for(int i=0;i<l.size();i++) a[i]=l.get(i);
	}
	static class FastScanner {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer("");
		String next() {
			while(!st.hasMoreTokens())
				try {
					st = new StringTokenizer(br.readLine());
				}catch(IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}
		int nextInt() {
			return Integer.parseInt(next());
		}
		int[] readArray(int n) {
			int[] a = new int[n];
			for(int i=0;i<n;i++)a[i]=nextInt();
			return a;
		}
		long nextLong() {
			return Long.parseLong(next());
		}
	}

}


Measured memory_bytes: 36544
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repi(i,a,n) for(int (i)=(a);(i)<(n);(i)++)
typedef long long ll;
int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n,q;
  ll k;
  cin>>n>>k>>q;
  vector<ll> ans(n,1);
  rep(i,q){
    int a;
    cin>>a;
    ans[a-1]++;
  }
  rep(i,n){
    int t=q-k+1;
    if(ans[i]>t)cout<<"Yes"<<"\n";
    else cout<<"No"<<"\n";
  }
  return 0;
}


Measured memory_bytes: 1408
import numpy as np
import itertools
n, k = map(int, input().split())
a = list(map(int, input().split()))

now = 1
town_list = [0]*n
town_list[0] = 1
tn_list = [1]

while(1):
    next = a[now-1]
    now = next
    if town_list[now-1] == 0:
        town_list[now-1] = 1
        tn_list.append(now)

    else:
        idx = tn_list.index(now)
        initial = tn_list[:idx]
        cycle = tn_list[idx:]
        break

if k >= len(initial):
    end_idx = (k-len(initial))%len(cycle)
    print(cycle[end_idx])
else:
    print(initial[k])

Measured memory_bytes: 51060
N, Q = map(int, input().split())
S = input()

memo = [0 for _ in range(N)]
cnt = 0
for i in range(1, N):
    if S[i - 1] == 'A' and S[i] == 'C':
        cnt += 1
    memo[i] = cnt

for _ in range(Q):
    x, y = map(int, input().split())
    x -= 1
    y -= 1
    print(memo[y] - memo[x])


Measured memory_bytes: 51984
/* ex4_2
  terakura */

#include <stdio.h>
#include <math.h>

int main(void){
    double short_hand, long_hand, hour, minute, angle, len;
    scanf("%lf %lf %lf %lf", &short_hand, &long_hand, &hour, &minute );


//短針と０時０分が為す角は(時間/12)＊2π + (π/6の”分”ぶんの60)、長針と０時０分が為す角は(”分”ぶんの60)*2π
    angle = ((hour / 12  *  2 * M_PI) +( M_PI / 6 * minute / 60)) -(minute / 60) * 2 * M_PI ;     //短針と長針のなす角度(ラジアン)
    len = sqrt( pow(short_hand, 2) + pow(long_hand, 2) - 2 * short_hand * long_hand * cos(angle));     //余弦定理で長さを計算

    printf("%.20lf\n", len);

    return 0;
}


Measured memory_bytes: 2500
n = int(input())
p_100 = [2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97]
p_n = []
for i in p_100:
  if i <= n:
    p_n.append(i)

# xはyで何回割れるか
class Div:
  def __init__(self):
    self.ans = 0
    self.ret = 0
    
  def divi(self,x,y):
    if x % y == 0:
      self.ans += 1
      return self.divi(x//y,y)
    else:
      self.ret = self.ans
      self.ans = 0
      return self.ret

Di = Div()

facto_n = [0] * 100 # facto_n[i] にn!を素因数分解した時のiの指数を格納
for i in range(1,n+1):
  for p in p_n:
    facto_n[p] += Di.divi(i,p)

#７５数が４パターンに分けられることに注意
f2, f4, f14, f24, f74 = 0, 0, 0, 0, 0
for i in range(1,100):
  if facto_n[i] >= 2:
    f2 += 1
  if facto_n[i] >= 4:
    f4 += 1
  if facto_n[i] >= 14:
    f14 += 1
  if facto_n[i] >= 24:
    f24 += 1
  if facto_n[i] >= 74:
    f74 += 1

ans = 0
if f4 >= 2 and f2 >= 3:
  ans += f4*(f4-1) // 2 * (f2-2)
if f14 >= 1 and f4 >= 2:
  ans += f14 * (f4-1)
if f24 >= 1 and f2 >= 2:
  ans += f24 * (f2-1)
if f74 >= 1:
  ans += f74

print(ans)

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

int main() {
	int n,k;
	cin>>n>>k;
	vector<int> v;
	while(n--) {
		int x;
		cin>>x;
		v.emplace_back(x);
	}
	sort(v.begin(),v.end());
	reverse(v.begin(),v.end());
	int m=0;
	for(int i=0;i<k;i++){
		m+=v[i];	
	}
		cout<<m;
	
	return 0;
}

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


int main() {
    long long h, n;
    std::cin>>h>>n;
    std::vector<int> a(n);
    for(long long i = 0; i < n; ++i) {
        std::cin>>a[i];
    }
    std::sort(std::begin(a), std::end(a));

    auto hp = h;

    for(const auto& aa : a) {
        hp -= aa;
        if(hp <= 0) {
            std::cout<<"Yes"<<std::endl;
            return 0;
        }
    }
    std::cout<<"No"<<std::endl;
}


Measured memory_bytes: 640
#include<iostream>
#include<cstdio>
#include<string>
using namespace std;
string st;
int main()
{
    cin>>st;
    for(int i=0;i<st.size();i++)
        if(st[i]=='C')
            for(int j=i+1;j<st.size();j++)
                if(st[j]=='F')
                {
                    cout<<"Yes\n";
                    return 0;
                }
    cout<<"No\n";
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
//#define cerr if(false) cerr
#ifdef DEBUG
#define show(...) cerr << #__VA_ARGS__ << " = ", debug(__VA_ARGS__);
#else
#define show(...) 42
#endif
using namespace std;
using ll = long long;
using pii = pair<int, int>;
template <typename T, typename S>
ostream& operator<<(ostream& os, pair<T, S> a) {
    os << '(' << a.first << ',' << a.second << ')';
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for (auto x : v) os << x << ' ';
    return os;
}
void debug() {
    cerr << '\n';
}
template <typename H, typename... T>
void debug(H a, T... b) {
    cerr << a;
    if (sizeof...(b)) cerr << ", ";
    debug(b...);
}

ll solve(string s, string t){
    int n = (int) s.size();
    vector<vector<int>> cost(n + 2, vector<int>(n + 2));
    vector<vector<int>> dp(n+1, vector<int>(n+1,1<<30));
    for(int i = n; i >= 0; i--){
        for(int j = n; j >= 0; j--){
            cost[i][j] = cost[i+1][j+1];
            if(i < n and j < n and s[i]==t[j])cost[i][j]++;
        }
    }
    show(cost);
    dp[0][0] = 0;
    for(int i = 0; i <= n; i++){
        for(int j = 0; j <= n; j++){
            if(i == 0 and j == 0)continue;
            if(i == 0){
                dp[i][j] = dp[i][j-1] + cost[i][j-1];
            }else if(j == 0){
                dp[i][j] = dp[i-1][j] + cost[i-1][j];
            }else{
                dp[i][j] = min(dp[i-1][j] + cost[i-1][j], dp[i][j-1] + cost[i][j-1]);
            }
        }
    }
    return dp[n][n];
}
int main(){
    int h, w;
    cin >> h >> w;
    vector<string>a(h);
    rep(i,h)cin >> a[i];
    ll ans = 0;
    rep(i,w-1){
        string s, t;
        rep(j,h){
            s += a[j][i];
            t += a[j][i+1];
        }
        reverse(s.begin(), s.end());
        reverse(t.begin(), t.end());
        ans += solve(s,t);
    }
    cout << ans << endl;
}


Measured memory_bytes: 1300
#include <iostream>
#include <cstdio>
#include <string>


int main()
{
	int x1, y1, x2, y2;
	std::cin >> x1 >> y1 >> x2 >> y2;

	int dx = x2 > x1 ? x2 - x1 : x1 - x2;
	int dy = y2 > y1 ? y2 - y1 : y1 - y2;

	std::string path;

	if (dx == 0 && dy == 0)
	{
		std::cout << std::endl;
		return 0;
	}

	if (dx == 0)
	{
		path += std::string(dy, 'U');
		path.push_back('R');
		path += std::string(dy, 'D');
		path.push_back('L');
		path.push_back('L');
		path += std::string(dy, 'U');
		path.push_back('R');
		path += "URR";
		path += std::string(dy + 2, 'D');
		path += "LLU";
	}
	else if (dy == 0)
	{
		path += std::string(dy, 'R');
		path.push_back('U');
		path += std::string(dy, 'L');
		path.push_back('D');
		path.push_back('D');
		path += std::string(dy, 'R');
		path.push_back('U');
		path += "RDD";
		path += std::string(dy + 2, 'L');
		path += "UUL";
	}
	else
	{
		path += std::string(dy, 'U');
		path += std::string(dx, 'R');
		path += std::string(dy, 'D');
		path += std::string(dx, 'L');
		path.push_back('L');
		path += std::string(dy + 1, 'U');
		path += std::string(dx + 1, 'R');
		path += "DR";
		path += std::string(dy + 1, 'D');
		path += std::string(dx + 1, 'L');
		path.push_back('U');
	}

	if (x2 < x1)
	{
		for (auto &c : path)
		{
			if (c == 'R')
				c = 'L';
			else if (c == 'L')
				c = 'R';
		}
	}

	if (y2 < y1)
	{
		for (auto &c : path)
		{
			if (c == 'U')
				c = 'D';
			else if (c == 'D')
				c = 'U';
		}
	}

	std::cout << path << std::endl;

	return 0;
}

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

int main  () {
  string s;
  cin >> s;
  sort(s.begin(), s.end());
  
  string ans;
  for (int i = 0; i < s.size()-1; i++) {
    if (s[i] == s[i+1]) {
      ans = "no";
      break;
    }
  }
  if (ans != "no") {
    ans = "yes";
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;
import java.awt.*;
import java.awt.geom.*;
import static java.lang.System.*;
import static java.lang.Math.*;
public class Main {
    public static void main(String[] $) {
        Scanner sc = new Scanner(in);
        int n=sc.nextInt();
        int[] h=new int[n+1];
        for (int i = 0; i < n; i++) {
            h[i]=sc.nextInt();
        }
        h[n]=0;
        long ans=0;
        int sum=1;
        while (sum>0) {
            sum=0;
            int c=0;
            for (int i = 0; i < n; i++) {
                if(h[i]>0){
                    h[i]--;
                    if(h[i+1]==0)c++;
                }
                sum+=h[i];
            }
            ans+=c;
        }
        out.println(ans);
    }
}

Measured memory_bytes: 21844
s = input()
t = input()
scnt = {}
tcnt = {}
sres = []
tres = []
for x in s:
    if x not in scnt:scnt[x] = 1
    else:scnt[x] +=1
for x in t:
    if x not in tcnt:tcnt[x] = 1
    else:tcnt[x] +=1
for k in scnt:
    sres.append(scnt[k])
for k in tcnt:
    tres.append(tcnt[k])
sres.sort()
tres.sort()
n = max(len(sres),len(tres))
ok = True
for i in range(n):
    if sres[i] != tres[i]:
        ok = False
        break
if ok:print('Yes')
else:print('No')

Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define REP(x,y,z) for(int x=y;x<=z;x++)
#define MSET(x,y) memset(x,y,sizeof(x))
#define M 105
using namespace std;
int n,m,w[M],v[M];
long long dp[100005];
int main()
{
    while (~scanf("%d %d",&n,&m)) {
        REP(i,1,n) scanf("%d %d",&w[i],&v[i]);
        MSET(dp, -1);
        dp[0] = 0;
        REP(i,1,n) for (int j=n*1000; j>=v[i]; j--)
            if (dp[j-v[i]] != -1) {
                if (dp[j]==-1) dp[j] = (1LL<<61);
                dp[j] = min(dp[j], dp[j-v[i]] + w[i]);
            }

        int ans = 0;
        REP(i,1,n*1000) if (dp[i]!=-1 && dp[i]<=m) ans = i;
        printf("%d\n", ans);
    }
    
    return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<cstdio>
#include<cstring>

using namespace std;

char a[10];

int main(){
	cin >> a;
	if(a[0] == 'S'){
		cout << "Cloudy" << endl;
		return 0;
	}
	if(a[0] == 'C'){
		cout << "Rainy" << endl;
		return 0;
	}
	if(a[0] == 'R'){
		cout << "Sunny" <<endl;
		return 0;
	}
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <inttypes.h>
#include <string.h>
#include <math.h>

int main (int argc, char const *argv[])
{
    int64_t A, B, C;
    int64_t ans = 0;

    scanf("%"PRId64"%"PRId64"%"PRId64, &A, &B, &C);

    ans = ((B / A) > C) ? C : (B / A);

    printf("%"PRId64"\n", ans);
}


Measured memory_bytes: 128
import java.util.*;

public class Main{

    public static void main(String args[]){

        //配列の宣言
        int[] number = new int[5];
        // スキャナーの宣言
        Scanner sc = new Scanner(System.in);
        // 整数の入力
		int a = sc.nextInt();
        int b = sc.nextInt();
        int ans;

        if(a >= 13){
            ans = b;
        }else if(a >= 6){
            ans = b/2;
        }else{
            ans = 0;
        }

        // 出力
        System.out.println(ans);

    }

}


Measured memory_bytes: 21716
#include <bits/stdc++.h>
#define int long long
using namespace std;

signed main() {
  int N, A, B;
  cin >> N >> A >> B;
  
  int P;
  int one = 0;
  int two = 0;
  int san = 0;
  for( int i = 0; i < N; i++ ){
    cin >> P;
    if( P <= A ) one++;
    else if( P <= B ) two++;
    else san++;
  }
  
  cout << min({one, two, san}) << endl;
    
}

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

#define lint long long
#define P pair<int, int>
#define LLP pair<long long, long long>
#define REP(i, x, n) for(int i = (x), i##_len = (int)(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = (int)(n) ; i < i##_len ; ++i)
#define repr(i, n) for(int i = (int)(n) - 1 ; i >= 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())
#define SORT_INV(x) sort((x).rbegin(), (x).rend())

const int IINF = 1e9 + 100;
const long long LLINF = 2e18 + 129;
const long long MOD = 1e9 + 7;
const int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};
const double EPS = 1e-8;

struct edge{
    int to;
    lint cost;
};

struct node{
    int id;
    lint cost;

    bool operator<(const node & right) const {
        return cost > right.cost;
    }
};

template<typename T>
bool chmin(T &a, T b){
    if(a > b){
        a = b;
        return true;
    }else{
        return false;
    }
}

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

    int n, m, l, k, a, h;
    while(cin >> n >> m >> l >> k >> a >> h, n){
        set<int> st;
        rep(i, l){
            int t;
            cin >> t;
            st.insert(t);
        }
        st.insert(a);
        st.insert(h);

        vector< vector<lint> > dis(n, vector<lint>(n, LLINF));
        rep(i, k){
            int x, y;
            lint t;
            cin >> x >> y >> t;
            chmin(dis[x][y], t);
            chmin(dis[y][x], t);
        }
        
        rep(o, n){
            rep(i, n){
                rep(j, n){
                    chmin(dis[i][j], dis[i][o] + dis[o][j]);
                }
            }
        }

        vector< vector<edge> > g(n);
        rep(i, n){
            rep(j, i){
                if(st.count(i) && st.count(j) && dis[i][j] <= m){
                    g[i].push_back({j, dis[i][j]});
                    g[j].push_back({i, dis[j][i]});
                }
            }
        }

        vector<lint> cost(n, LLINF);
        priority_queue<node> que;
        que.push({a, 0LL});
        while(!que.empty()){
            node now = que.top();
            que.pop();
            if(!chmin(cost[now.id], now.cost)){
                continue;
            }
            for(auto x : g[now.id]){
                if(cost[x.to] > now.cost + x.cost){
                    que.push({x.to, now.cost + x.cost});
                }
            }
        }

        if(cost[h] < LLINF){
            cout << cost[h] + max(cost[h] - m, 0LL) << endl;
        }else{
            cout << "Help!" << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 3452
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define itrfor(itr,A) for(auto itr = A.begin(); itr !=A.end();itr++)
typedef long long llong;
char moji[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
char moji2[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define print(a) cout << a << endl;


int main(){
    llong a,b,c,k;
    cin >> a >> b >> c >> k;
    if(k%2 == 0) cout << a - b << endl;
    else cout << b-a << endl;
}

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

using namespace std;
int main(int argc, char *argv[]) {
	int n;
	cin >> n;
	int x[n]; int y[n];
	for (int i = 0; i < n; i++) {
		cin >> x[i] >> y[i];
	}
	
	int p[n];
	for (int i = 0; i < n; i++) {
		p[i] = i;
	}
	
	double dis = 0.0;
	int ct = 0;
	do {
		for (int i = 0; i < n - 1; i++) {
			dis += sqrt(pow(x[p[i]] - x[p[i+1]], 2) + pow(y[p[i]] - y[p[i+1]], 2));
		}
		ct += 1;
	} while (next_permutation(p, p + n));
	dis /= ct;
	
	cout << fixed << setprecision(10) << dis << endl;
}

Measured memory_bytes: 256
from collections import Counter
n = int(input())
lst_a = list(map(int, input().split()))
c = Counter(lst_a)
def comb2(n):
    return n*(n-1)/2
s = sum([comb2(x) for x in c.values()])
for i in lst_a:
    print(int(s - c[i] + 1))

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


int main() {
  int N;
  cin>>N;
  
  vector<int> vec(N);
  for(int i=0;i<N;i++){
    cin>>vec.at(i);
  }
  
  int sum=0;
  for(int i=0;i<N;i++){
    for(int j=i+1;j<N;j++){
      sum+=vec.at(i)*vec.at(j);
    }
  }
  
  cout<<sum<<endl;
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long; 
int main(){
	string s;	cin >> s;
	if(s.back() == '0' || s.back() == '1' || s.back() == '6' || s.back() == '8'){
    	cout << "pon" << endl;
    }
  	else if(s.back() == '3') cout << "bon" << endl;
    else cout << "hon" << endl;
  
}

Measured memory_bytes: 3624
#include<stdio.h>
int main(){
  int a,b;
  scanf("%d %d",&a,&b);
  if(a<b){
    printf("a < b\n");
  }else if(a>b){
    printf("a > b\n");
  }else{
    printf("a == b\n");
  }
  return 0;
}


Measured memory_bytes: 2140
A,B,K=map(int, input().strip().split())

for i in range(K):
    if i%2==0:
        if A%2==1:
            A-=1
        B=B+A//2
        A=A//2
            
    if i%2==1:
        if B%2==1:
            B-=1
        A=A+B//2
        B=B//2

    
#    print(A,B)
    
print("{} {}".format(A, B))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(), (v).end()
#define siz(v) (ll)(v).size()
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repi(i, x, n) for (ll i = x; i < (ll)(n); i++)
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
const ll mod = 1000000007;
const ll INF = 1000000099;
vector<ll> dx = {-1, 1, 0, 0}, dy = {0, 0, -1, 1};
//cin.tie(0);
//ios::sync_with_stdio(false);

signed main()
{
    string s;
    cin >> s;
    ll ans = 0, n = siz(s);
    vector<ll> v(1,0);

    repi(i, 1, n)
    {
        if (s[i] != s[i - 1])
        {
            v.pb(i);
        }
    }
    v.pb(n);

    repi(i,1,siz(v)){
        ans=max(ans,min(v[i],n-v[i-1]));
    }
    cout << ans << endl;
}

Measured memory_bytes: 1020
/*input
6
0 6 7 6 7 0
*/
#include <bits/stdc++.h>
using namespace std;
const long long md=1e9+7;
long long a[1000005],n;

int main(){
	ios_base::sync_with_stdio(0);
	long long q,m,k,h,ans=0,sum=0,p,x=0,y;
	cin>>n;
	for(int i=0;i<n;cin>>a[i++]);
	deque<int> v;
	for(int i=0;i<n;++i){
		if(x==0) v.push_back(a[i]);
		else v.push_front(a[i]);
		x^=1;
	}
	if(x==0) for(int i:v) cout<<i<<" ";
	else{
		stack<int> s;
		for(int i:v) s.push(i);
		while(!s.empty()) {
			cout<<s.top()<<" ";
			s.pop();
		}
	}
}

Measured memory_bytes: 5148
#include<bits/stdc++.h>
using namespace std;
int main(){
    long n;
    cin>>n;
    long ans=0;
    for(auto i=1;i<=n;i++){
        long cnt=0,hi=0,lo=0;
        lo = i;
        hi = (n/i)*i;
        cnt = hi/i ; 
        ans += cnt*(lo+hi)/2;
        
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 3620
#include <iostream>
using namespace std;
 
int main(){  
    int H, W, i, j, k;
    for(i = 0; i < 90000; i++){
    cin >> H >>W;
    if ( H == 0 && W == 0) break;
     
    for (j = 0; j < H; j++){
        for(k = 0; k < W; k++){
        cout << "#";
        }
        cout << endl;
    }cout << endl;}
return 0;}



Measured memory_bytes: 3000
import java.util.*;
//import java.util.stream.Collectors;

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		int[] a = new int[3];
		Arrays.setAll(a, i -> sc.nextInt());
		int five = 0, seven = 0;
		for(int n : a){
			if(n == 5){
				five++;
			}else if(n == 7){
				seven++;
			}
		}
		System.out.println(five == 2 && seven == 1 ? "YES" : "NO");
	}
}


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

int main (void){
      
   char s[128];
   int len;
   scanf("%s", s);
    
   len = strlen(s);
   
   putchar(s[0]);    
   printf("%d", len-2);
   putchar(s[len-1]); 
    
    return 0;
    
}


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

//template
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(a);i>(b);i--)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll; const int inf = 0x3fffffff; const ll INF = 0x3fffffffffffffff;
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 end

ll dp[310][310];

int main(){
    int n,k; scanf("%d%d",&n,&k);
    vector<int> a(n+1,0);
    rep(i,1,n+1)scanf("%d",&a[i]);
    rep(i,0,310)rep(j,0,310)dp[i][j]=INF;
    dp[0][0]=0;
    rep(i,0,n+1)rep(j,0,n+1){
        ll sub=INF;
        rep(rot,0,i)chmin(sub,dp[rot][j]+max(0,a[i]-a[rot]));
        chmin(dp[i][j+1],sub);
    }
    ll ans=INF;
    rep(i,0,n+1)chmin(ans,dp[i][n-k]);
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 1024
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptor/reversed.hpp>
#include<boost/operators.hpp>
namespace adaptor = boost::adaptors;
template<class T>using p_queue = std::priority_queue<T, std::vector<T>, std::greater<>>;

void Main()
{
	int N;
	std::cin >> N;
	std::map<std::string, std::priority_queue<std::pair<int, int>>> map;
	for (int i : boost::irange(0, N))
	{
		std::string s;
		int p;
		std::cin >> s >> p;
		map[s].emplace(p, i + 1);
	}
	for (auto& q : map)
	{
		while (q.second.size())
		{
			std::cout << q.second.top().second << std::endl;
			q.second.pop();
		}
	}
}

int main()
{
	std::cin.tie(nullptr);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	Main();
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(x, to) for (int x = 0; x < (to); x++)
#define REP(x, a, to) for (int x = (a); x < (to); x++)
#define EPS (1e-14)
#define _PA(x,N) rep(i,N){cout<<x[i]<<" ";}cout<<endl;
#define _PA2(x,H,W) rep(i,(H)){rep(j,(W)){cout<<x[i][j]<<" ";}cout<<endl;}

using namespace std;

typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
typedef complex<double> Complex;
typedef vector< vector<int> > Mat;

const ll mod = 1e+9 + 7;

ll H, W, A, B;
ll ans;
ll fact[1000010];

ll powmod(ll a, ll p, ll mod) {
	ll res = 1;
	while (p > 0) {
		if (p & 1) {
			res *= a;
			res %= mod;
		}
		a *= a;
		a %= mod;
		p >>= 1;
	}
	return res;
}

ll inv(ll x) {
	return powmod(x, mod-2, mod);
}


ll Comb(ll p, ll q) {
	//cout << p << " " << q << endl;
	ll res = fact[p];
	res *= inv(fact[q] * fact[p - q] % mod) % mod;
	res %= mod;
	return res;
}

void solve() {
	fact[0] = 1;
	for (ll i = 0; i < 1000005; i++) {
		fact[i + 1] = (i + 1LL) * fact[i];
		fact[i + 1] %= mod;
	}

	for (ll i = 0; i < W - B; i++) {
		ll a = Comb(H - A - 1 + B + i, H - A - 1);
		ll b = Comb(A - 1 + W - B - 1 - i, A - 1);
		ans += (a * b) % mod;
		ans %= mod;
	}
	cout << ans << endl;
}

int main() {
	cin >> H >> W >> A >> B;
	solve();
	return 0;
}




Measured memory_bytes: 8064