akhauriyash/Code-Regression huggingface dataset:
/*      Welcome to my Code      */

#include <bits/stdc++.h>
#define ll                      long long int
#define i(a,n)                  int a=n;
#define l(a,n)                  ll a=n;
#define d(a,n)                  double a=n;
#define s(a)                    string a;
#define c(a)                    ll a; cin>>a;a
#define cd(a)                   double a; cin>>a;
#define cs(a)                   string a; cin>>a;
#define ci(a)                   cin>>a
#define co(a)                   cout<<a
#define cos(a)                  cout<<a<<" "
#define con(a)                  cout<<a<<endl
#define yes                     cout<<"YES"<<endl
#define no                      cout<<"NO"<<endl
#define nl                      cout<<endl
#define ca(arr,n)               for(ll i=0;i<n;i++) cin>>arr[i]
#define caa(arr,n)              c(n); ll arr[n]; for(ll i=0;i<n;i++) cin>>arr[i];
#define f0(i,a,n)               for(ll i=a;i>=n;i--)
#define f(i,n)                  for(ll i=0;i<n;i++)
#define f1(i,a,n)               for(ll i=a;i<n;i++)
#define lcm(a,b)                (a*b)/__gcd(a,b)
#define T                       ll t=1; cin>>t; while(t--)
#define sr(a,n)                 sort(a,a+n)
#define rv(a,n)                 reverse(a,a+n)
#define fast                    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define ret(x)                  return cout<<x,0;

using namespace std;

int main()
{
    fast;
    int n,x,t,ans=0;
    cin>>n>>x>>t;
    do
    {
        n-=x;
        ans++;
    } while (n>0);
    
    cout<<ans*t<<endl;
    return 0;
}

/*It's not who I am underneath, but what I do that defines me

MMMMMMMMMMMMMMMMMMMMM.                             MMMMMMMMMMMMMMMMMMMMM
 `MMMMMMMMMMMMMMMMMMMM           M\  /M           MMMMMMMMMMMMMMMMMMMM'
   `MMMMMMMMMMMMMMMMMMM          MMMMMM          MMMMMMMMMMMMMMMMMMM'
     MMMMMMMMMMMMMMMMMMM-_______MMMMMMMM_______-MMMMMMMMMMMMMMMMMMM
      MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
      MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
      MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
     .MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM.
    MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
                   `MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM'
                          `MMMMMMMMMMMMMMMMMM'
                              `MMMMMMMMMM'
                                 MMMMMM
                                  MMMM
                                   MM
*/


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

int main()
{
    int N;
    long long sum = 0;
    bool y ;
    string S;
    cin >> N >> S;
    for (int i = 1; i < N-1; i++)
    {
        if(S.at(i-1)==S.at(i))
        {
            S.at(i-1) = '?';
            //S.at(i) = '?';
            sum++;
        }
         if(S.at(i)==S.at(i+1))
        {
            //S.at(i+1) = '?';
            S.at(i) = '?';
            sum++;
        }
        //cout << S << endl;
    }
    cout << N-sum << endl;
}


Measured memory_bytes: 512
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
#include<iterator>
#include<list>
using namespace std;
typedef  long long int lint;
typedef pair<int, int> IP;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define llower(v,hoge) *lower_bound(v.begin(), v.end(), hoge)
#define lupper(v,hoge) *upper_bound(v.begin(), v.end(), hoge)

int main() {
	vector<int>A(3);
	rep(i, 3) {
		cin >> A[i];
	}
	sort(A);
	cout << A[0] << ' ' << A[2] << endl;
}




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

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<bool> VB;
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<char> VC;
typedef vector<VC> VVC;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SQ(a) ((a)*(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define LB lower_bound
#define UB upper_bound

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL INF = 1e9;
const LL MOD = 1e9+7;

//other
//-------------------------------------------
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define FI first
#define SE second

//memo
// setprecision()

LL Gcd(LL a, LL b) {
  return __gcd(a,b);
}

LL Lcm(LL a, LL b) {
  LL abd = Gcd(a,b);
  LL x = a / abd, y = b / abd;
  
  return x*y*abd;
}


LL RepSqu(LL N, LL P, LL M) {
  if(P == 0) {
    return 1;
  }
  if(P%2 == 0) {
    LL t = RepSqu(N, P/2, M);
    return t*t % M;
  }
  return (N * RepSqu(N, P-1, M)) % M;
}


int main() {
  
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  LL N,M;
  cin >> N >> M;
  
  if(N > M) swap(N,M);
  
  if(N == 1 && M == 1) {
    cout << 1 << endl;
  }
  else if(N == 1){
    cout << M-2 << endl;
  }
  else{
    cout << (N-2)*(M-2) << endl;
  }
  
  return 0;
}

Measured memory_bytes: 256
N = int(input())
hon = [2,4,5,7,9]
pon = [0,1,6,8]
 
if N % 10 in hon :
  print("hon")
 
elif N % 10 in pon :
  print("pon")
 
elif N % 10 == 3 :
  print("bon")

Measured memory_bytes: 9164
/* package codechef; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
public class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		// your code goes here
		FastScanner sc=new FastScanner();
		int t=sc.nextInt();
		int c0=0,c1=0,c2=0,c3=0;
		String s1="AC",s2="WA",s3="TLE",s4="RE";
for(int i=0;i<t;i++){
    String s=sc.next();
    if(s.equals(s1))
    c0++;
    else if(s.equals(s2))
    c1++;
    else if(s.equals(s3))
    c2++;
    else
    c3++;
    
}
System.out.println("AC x "+c0);
System.out.println("WA x "+c1);
System.out.println("TLE x "+c2);
System.out.println("RE x "+c3);
	
		
		
	}
		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: 38616
#include<iostream>
using namespace std;

int main(){
  int K,S,sum;
  cin >> K >> S;
  sum = 0;
  for(int x = 0 ; x <= K ; x++){
    for(int y = 0 ; y <= K ; y++){
      int z = S -(x + y);
      if(0 <= z && z <= K)sum++;
    }
  }
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
namespace FAST_IO
{
	template<typename T> void read(T &a)
	{
		a=0;
		int f=1;
		char c=getchar();
		while(!isdigit(c))
		{
			if(c=='-')
			{
				f=-1;
			}
			c=getchar();
		}
		while(isdigit(c))
		{
			a=a*10+c-'0';
			c=getchar();
		}
		a=a*f;
	}
	template <typename T> void write(T a)
	{
		if(a<0)
		{
			a=-a;
			putchar('-');
		}
		if(a>9)
		{
			write(a/10);
		}
		putchar(a%10+'0');
	}
	template <typename T> void writeln(T a)
	{
		write(a);
		puts("");
	}
}
int h(int a)
{
	int ans=0;
	string ab;
	stringstream q;
	q<<a;
	q>>ab;
	for(int i=0;i<ab.size();i++)
	{
		ans+=ab[i]-'0';
	}
	return ans;
}
int tot=0;
int main()
{
	int n,a,b;
	cin>>n>>a>>b;
	for(int i=1;i<=n;i++)
	{
		if(h(i)>=a&&h(i)<=b)
		{
			tot+=i;
		}
	}
	cout<<tot;
}

Measured memory_bytes: 256
#heapだけ？
#x<=a,y<=b
import heapq
x,y,a,b,c = map(int, input().split( ))

*p, = map(int, input().split( ))
*q, = map(int, input().split( ))
*r, = map(int, input().split( ))
#p = [(pi,0) for pi in p_]
#q = [(qi,1) for qi in q_]
#r = [(ri,2) for ri in r_]
p.sort();q.sort();r.sort()##
p = p[-x:]
q = q[-y:]
e = p+q
heapq.heapify(e)
for ri in r:
    heapq.heappush(e,ri)
    heapq.heappop(e)
print(sum(e))
    
    
    


Measured memory_bytes: 23456
N, M = map(int, input().split())
height = input().split()
area = [[] for i in range(N)]
for i in range(M):
    road = input().split()
    for place in road:
        area[int(road[0])-1].append(int(height[int(road[1])-1]))
        area[int(road[1])-1].append(int(height[int(road[0])-1]))
counter = 0
for i in range(N):
    if not area[i]:
        counter=counter+1
    elif int(height[i]) > max(area[i]):
        counter=counter+1
print(counter)

Measured memory_bytes: 40176
import java.util.Scanner;
class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		int c = scan.nextInt();
		System.out.println((a < b) && (b < c) ? "Yes" : "No");
	}
}

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

#define F first
#define S second
#define prev azaza
#define MP make_pair
#define PB push_back

using namespace std;
typedef long long ll;
typedef long double ld;

const int max_n = 1, inf = 1000111222;

int main()
{
    //freopen("input.txt", "r", stdin);
    int n, a, b;
    cin >> n >> a >> b;
    cout << min(n * a, b);

    return 0;
}




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

int main() {
    // 0:left 1:bottom 2:right 3:top
    int dx[4] = {-1, 0, 1, 0}, dy[4] = {0, 1, 0, -1};
    int n;
    while(cin >> n, n) {
        int min_x = 0, max_x = 0, min_y = 0, max_y = 0;
        vector<int> sq_x(n);
        vector<int> sq_y(n);
        sq_x[0] = 0;
        sq_y[0] = 0;
        for(int i=1; i<n; ++i) {
            int n_, d;
            cin >> n_ >> d;
            sq_x[i] = sq_x[n_] + dx[d];
            sq_y[i] = sq_y[n_] + dy[d];
            min_x = min(min_x, sq_x[i]);
            max_x = max(max_x, sq_x[i]);
            min_y = min(min_y, sq_y[i]);
            max_y = max(max_y, sq_y[i]);
        }
        cout << max_x - min_x + 1 << " " << max_y - min_y + 1 << endl;
    }
}


Measured memory_bytes: 3024
#include <iostream>
#include <cmath>
#include <stdio.h>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <cstring>
#include <fstream>
#include <cstdlib>
#include <cassert>
#include <utility>
#include <iomanip>
#include <chrono>
#include <random>
#include <bitset>
#include <unordered_map>
#include <unordered_set>

using namespace std;

#define f first
#define s second
#define pb push_back
#define mp make_pair
#define ll long long
#define pii pair < int, int >
#define pll pair < long long, long long>
#define ull unsigned long long
#define vi vector < int >
#define vll vector < long long >
#define sz(a) (int)a.size()
#define forit(it, s) for(__typeof(s.begin()) it = s.begin(); it != s.end(); it++)
#define all(a) a.begin(), a.end()
#define sqr(x) ((x) * (x))
#define fname "searching"

const int inf = (int)1e9;
const ll INF = (ll)1e18;
const double eps = 1e-9;
const double pi = acos(-1.0);
const int mod = (int)1e9 + 7;

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    // freopen("a_in", "r", stdin);
    // freopen("a_out", "w", stdout);
    string s, t, u;
    int a, b;
    cin >> s >> t >> a >> b >> u;
    a -= u == s;
    b -= u == t;
    cout << a << " " << b << "\n";
    return 0;
}


Measured memory_bytes: 256
import itertools

N = int(input())
xy = [list(map(int,input().split())) for _ in range(N)]

dis_count=[]
for i in itertools.permutations([i for i in range(1,N+1)],N):
    dis = 0
    for j in range(N-1):
        dis += ((xy[i[j]-1][0]-xy[i[j+1]-1][0])**2+(xy[i[j]-1][1]-xy[i[j+1]-1][1])**2)**0.5
    dis_count.append(dis)

print(sum(dis_count)/len(dis_count))


Measured memory_bytes: 10832
import sys
import bisect

stdin = sys.stdin


def ni(): return int(ns())


def na(): return list(map(int, stdin.readline().split()))


def naa(N): return [na() for _ in range(N)]


def ns(): return stdin.readline().rstrip()  # ignore trailing spaces


N, M = na()
A_array = na()
A_array.sort()

hap_min = 0
hap_max = 3 * (10 ** 5)

while(hap_max - hap_min > 1):
    hap = (hap_min + hap_max) // 2
    cnt = 0
    for a in A_array:
        idx = bisect.bisect_left(A_array, hap - a)
        cnt += N - idx
    # print(hap, hap_max, hap_min, cnt)
    if cnt >= M:
        hap_min = hap
    else:
        hap_max = hap

hap = hap_min
# print(hap)
cnt_array = [0] * N
sum_array = [0] * N

for i, a in enumerate(A_array):
    idx = bisect.bisect_left(A_array, hap - a)
    cnt_array[i] = N - idx
    if idx != N:
        sum_array[idx] += 1

# print(cnt_array, sum_array)

ans = 0
cusum = 0
cntsum = 0
for a, c, s in zip(A_array, cnt_array, sum_array):
    cusum += s
    cntsum += c
    ans += a * (cusum + c)

print(ans - (cntsum - M) * hap)


Measured memory_bytes: 84776
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;

int main() {        
    int n;
    cin >> n;
    cout << 800 * n - n / 15 * 200 << endl;
}


Measured memory_bytes: 3608
#include<bits/stdc++.h>
#define ll long long int
#define mk make_pair
#define pb push_back
#define INF (ll)1e18
#define pii pair<ll,ll>
#define mod 1000000007 //998244353
#define f(i,a,b) for(ll i=a;i<b;i++)
#define fb(i,a,b) for(ll i=a;i>b;i--)
#define ff first
#define ss second
#define PI 3.141592653589793238
#define pq priority_queue<ll>
#define pqr priority_queue<ll,vector<ll>,greater<ll>()>
using namespace std;
ll pow_mod(ll a,ll b)
{
	ll res=1;
	while(b!=0)
	{
		if(b&1)
		{
			res=(res*a)%mod;
		}
		a=(a*a)%mod;
		b/=2;
	}
	return res;
}
void solve()
{
   string s;
   
   cin>>s;
   
   ll ans=0;
   ll n=s.size();
   
   ll cnt=0;
   for(ll i=0;i<(ll)s.size();i++){
       if(s[i]=='1'){
           ans+=(pow_mod(3,n-i-1)*pow_mod(2,cnt))%mod;
           ans%=mod;
           cnt++;
       }
   }
   
   ans+=pow_mod(2,cnt);
   
   ans%=mod;
   
   cout<<ans<<endl;
   
}
int32_t main()
{    ios_base::sync_with_stdio(false);
     cin.tie(NULL);
     cout.tie(NULL);
     
//Start from Here.

  ll t;
  t=1;
 // cin>>t;
  while(t--)
  solve();
  
//Good Bye!
    return 0;
}

Measured memory_bytes: 3756
from sys import stdin
n,m = map(int,stdin.readline().split())
a = map(int,stdin.readline().split())
b = map(int,stdin.readline().split())
a.sort()
b.sort()
x = []
y = []
for i in xrange(1,n):
    x.append(a[i] - a[i-1])
for i in xrange(1,m):
    y.append(b[i] - b[i-1])   
fir = 0
sec = 0
n = len(x)
m = len(y)
for i in xrange(n):
    fir += (i+1) * (n-i)*x[i]
for i in xrange(m):
    sec += (i+1) * (m-i) * y[i]
mod = 10**9 + 7
print (fir * sec)%mod

Measured memory_bytes: 15312
#include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;

int main() {
  ll N, M;
  cin >> N >> M;
  vector<ll> H(N);
  priority_queue<pair<ll, int>> q_H;
  for (int i = 0; i < N; i++) {
    ll h;
    cin >> h;
    H[i] = h;
    q_H.push({h, i});
  }
  vector<vector<int>> g(N);
  for (int i = 0; i < M; i++) {
    ll a, b;
    cin >> a >> b;
    a--;
    b--;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  vector<bool> checked(N, false);
  ll ans = 0;
  while (!q_H.empty()) {
    ll hight = q_H.top().first;
    int index = q_H.top().second;
    q_H.pop();
    if (checked[index]) continue;
    bool flag = true;
    for (int i = 0; i < g[index].size(); i++) {
      int next = g[index][i];
      checked[next] = true;
      if (hight <= H[next]) flag = false;
    }
    if (flag) ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 10884
#include <bits/stdc++.h>
//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
//using namespace __gnu_pbds;

#define LL       long long
#define DS       pair<LL, LL>
#define READ(f)  freopen(f, "r", stdin)
#define WRITE(f) freopen(f, "w", stdout)

const int N = 1e5 + 5;
const int MOD = 1e9 + 7;
const double PI = 2 * acos(0.0);
//template<typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

int a[N], b[N];

int main() {
    //ios::sync_with_stdio(false);
    //cin.tie(0);
    int n, m, k;
    scanf("%d %d %d", &n, &m, &k);
    int mnR = 1e9;
    for (int i = 1; i <= n; i++) {
        scanf("%d", a + i);
        mnR = min(mnR, a[i]);
    }
    int mnO = 1e9;
    for (int i = 1; i <= m; i++) {
        scanf("%d", b + i);
        mnO = min(mnO, b[i]);
    }
    int ans = mnR + mnO;
    for (int i = 1; i <= k; i++) {
        int x, y, z;
        scanf("%d %d %d", &x, &y, &z);
        ans = min(ans, max(0, a[x] + b[y] - z));

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


Measured memory_bytes: 1024
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <cmath>

using namespace std;
using ll = long long;
using ull = unsigned long long;

constexpr ll LLINF {1001002003004005006};//ll = 9*LLINF
constexpr int INTINF {1000000000};//int = 2*INTINF

#define  rep(i,n)   for(int i = 0; i < (n); ++i)
#define rrep(i,n)   for(int i = 1; i <= (n); ++i)
#define drep(i,n)   for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for(int i = s; i < t;  ++i)

template<typename T>
void maxs(T& x, T&& y) {
  x=std::max(x,y);
}
template<typename T>
void maxs(T& x, T& y) {
  x=std::max(x,y);
}

template<typename T>
void mins(T& x, T&& y) {
  x=std::min(x,y);
}
template<typename T>
void mins(T& x, T& y) {
  x=std::min(x,y);
}

constexpr ll mod_target {1000000000+7};

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

  int n;
  cin >> n;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];

  vector<ll> b(n, 0);
  for (auto i = n-2;i >= 0;--i) {
    b[i] = a[i+1] + b[i+1];
    b[i] %= mod_target;
  }
  //rep(i, n) cout << b[i] << ' ';
  //cout << '\n';

  ll ans {};
  rep(i, n) {
    ans += a[i]*b[i];
    ans %= mod_target;
  }
  cout << ans << '\n';
}


Measured memory_bytes: 6344
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
int n, k;
main(){
  
  cin >> n >> k;
  vector<int> a(n,0);
  for (int i = 0; i < n;i++){
    cin >> a[i];
  }
  vector<int> num(n,0);
  for (int i = 0; i < n;i++){
    num[a[i]-1]++;
  }
  int count = 0;
  for (int i = 0; i < n;i++){
    if(num[i])
      count++;
  }
    sort(num.begin(), num.end());
    reverse(num.begin(), num.end());
    if (count <= k)
    {
      cout << 0 << endl;
      return 0;
  }
  int ans = 0;
  for (int i = 0; i < k;i++){
    ans += num[i];
  }
  cout << n - ans << endl;
}  


Measured memory_bytes: 1792
#include <bits/stdc++.h>
 
using namespace std;
 
#define ll long long int
 
#define REP(i, n) for(int i = 0; i < (n); i++)
#define SREP(i, s) for(int i = 0; i < (s.size()); i++)
#define SORT(v, n) sort(v, v+n);
#define GSORT(v, n) sort(v, v+n, greater<int>());
#define VSORT(v) sort(v.begin(),v.end());
#define VGSORT(v) sort(v.begin(),v.end(),greater<int>());
#define REV(a) reverse(begin(a),end(a));
 
ll gcd(ll x, ll y){
	if(x<y) swap(x,y);
	if(y==0) return x;
	return gcd(y,x%y);
}
 
ll lcm(ll x, ll y){
	return (x*y/gcd(x,y));
}

int main(){
	ios::sync_with_stdio(false);cin.tie(0);
////////////////////////////////////////////
	int h,w;
    cin >> h >> w;
    char a[h][w];
    REP(i,h){
        REP(j,w) cin >> a[i][j];
    }
    bool bh[h];
    bool bw[w];
    memset(bh,false,sizeof(bh));
    memset(bw,false,sizeof(bw));
    REP(i,h){
        REP(j,w){
            if(a[i][j]=='#'){
                bh[i]=1;
                bw[j]=1;
            }
        }
    }
    REP(i,h){
        if(bh[i]){
            REP(j,w){
                if(bw[j]){
                    cout << a[i][j];
                }
            }
                  cout << endl;
        }

    }
/////////////////////////////////////////////
}

Measured memory_bytes: 256
#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 x = 1;
  int a=0,b=0;
  for (int j=0; j<N; ++j) {
    x = vec.at(x-1);
    if (x == 2) {
      a = 1;
      b = j+1;
      break;
    }
  }
  if (a == 0) {
    cout << -1 << endl;
  }else{
    cout << b << endl;
  }
}
  
  

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


int main()
{
	LL n, m;
	scanf("%lld%lld", &n, &m);
	if(n==1 && m==1)
	{
		printf("1\n");
		return 0;
	} 
	if(n==1 || m==1)
	{
		printf("%lld\n", std::max(n, m)-2);
		return 0;
	}
	printf("%lld\n", (n-2)*(m-2));
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<cstring> 
using namespace std; 
int main()
{
	int N,A,B,temp;
	while(~scanf("%d%d%d",&N,&A,&B))
	{
	temp=B-A;
	if(temp%2)puts("Borys\n");
	else puts("Alice\n");  
    }
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <queue>

using namespace std;

int main(){
        int n,q;
        queue<pair<string,int>> que;
        cin >> n >> q;
        for(int i=0;i<n;i++){
                string name;
                int time;
                cin >> name >> time;
                que.push(make_pair(name,time));
        }
        long long int cur_time = 0;
        while(!que.empty()){
                pair<string,int> x = que.front();
                que.pop();
                if(x.second > q){
                        que.push(make_pair(x.first,x.second-q));
                        cur_time += q;
                } else {
                        cur_time += x.second;
                        cout << x.first << " " << cur_time << endl;
                }
        }
        return 0;
}

Measured memory_bytes: 4400
use std::cmp;

const INF: i64 = 1e17 as i64;

fn main() {
    let s = std::io::stdin();
    let mut sc = Scanner { reader: s.lock() };
    let n: usize = sc.read();
    let a: Vec<i64> = sc.read_vec(n);
    let mut graph = vec![vec![]; n];
    for _ in 0..(n - 1) {
        let v = sc.read::<usize>() - 1;
        let u = sc.read::<usize>() - 1;
        graph[v].push(u);
        graph[u].push(v);
    }

    let mut dp1 = vec![vec![]; n];
    let mut dp2 = vec![vec![]; n];
    dfs(0, 0, &graph, &a, &mut dp1, &mut dp2);

    for i in 1..(n + 1) {
        if dp1[0][i] < INF {
            println!("{}", i - 1);
            return;
        }
        if dp2[0][i] < 0 {
            println!("{}", i - 1);
            return;
        }
    }
}

fn dfs(
    v: usize,
    p: usize,
    graph: &Vec<Vec<usize>>,
    a: &Vec<i64>,
    dp1: &mut Vec<Vec<i64>>,
    dp2: &mut Vec<Vec<i64>>,
) {
    dp1[v].push(INF);
    dp1[v].push(if a[v] > 0 { a[v] } else { INF });
    dp2[v].push(INF);
    dp2[v].push(a[v]);
    for &next in graph[v].iter() {
        if next == p { continue; }
        dfs(next, v, graph, a, dp1, dp2);

        dp1[v] = connect(&dp1[v], &dp1[next], &dp2[next], true);
        dp2[v] = connect(&dp2[v], &dp1[next], &dp2[next], false);
    }
}

fn connect(dp: &Vec<i64>, child1: &Vec<i64>, child2: &Vec<i64>, power_only: bool) -> Vec<i64> {
    let mut ans = vec![INF; dp.len() + child1.len() - 1];
    assert_eq!(dp[0], INF);
    for groups in 0..dp.len() {
        if dp[groups] == INF { continue; }
        for child_groups in 0..child1.len() {
            let total_groups = groups + child_groups;

            if total_groups >= 1 {
                if child1[child_groups] != INF {
                    ch_min(&mut ans[total_groups - 1], dp[groups] + child1[child_groups]);
                }
                if child2[child_groups] != INF && !power_only {
                    ch_min(&mut ans[total_groups - 1], dp[groups] + child2[child_groups]);
                }
            }
            if child1[child_groups] != INF || child2[child_groups] < 0 {
                ch_min(&mut ans[total_groups], dp[groups]);
            }
        }
    }
    ans
}

fn ch_min<T: PartialOrd>(a: &mut T, b: T) {
    if *a > b {
        *a = b;
    }
}

pub struct Scanner<R> {
    reader: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .reader
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n')
            .take_while(|&b| b != b' ' && b != b'\n')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn read_vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


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

using namespace std;
using nagai = long long;
#define sz(x) int((x).size())

const int N=202;
const int mod=1e9+7;
int mu(int a,int b){
	 return (nagai)a*b%mod;
}
void ad(int&a,int b){
	 if((a+=b)>=mod)a-=mod;
}
int s[N];
const int M=100100;
int dp[N][M];

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n,x;
	cin>>n>>x;
	for(int i=0;i<n;++i)cin>>s[i];
	sort(s,s+n);
	reverse(s,s+n);
	dp[0][x]=1;
	for(int i=0;i<n;++i){
		for(int j=0;j<M;++j){
			ad(dp[i+1][j],mu(dp[i][j],n-i-1));
			ad(dp[i+1][j%s[i]],dp[i][j]);
		}
	}
	int ans=0;
	for(int i=0;i<M;++i){
//		cerr<<i<<' '<<dp[n][i]<<'\n';
		ad(ans,mu(i,dp[n][i]));
	}
	cout<<ans<<'\n';
	return 0;
}



Measured memory_bytes: 78464
#include <stdio.h>

int main(void){
  int a, b, c;
  
  scanf("%d %d %d", &a, &b, &c);
  
  if(a == b){
    if(a != c){
      printf("Yes");
      return 0;
    }
  }else if(b == c){
    if(b != a){
      printf("Yes");
      return 0;
    }
  }else if(c == a){
    if(c != b){
      printf("Yes");
      return 0;
    }
  }
  printf("No");
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define FOR(i, k, n) for(int i = (k); i < (n); i++)
#define FORr(i, k, n) for(int i = (k); i > (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORr(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;
using ll = long long;

int main(void){
  int n;
  cin >> n;
  vector<double> v(n);
  REP(i, n) cin >> v[i];

  sort(ALL(v));

  double ans = v[0];
  FOR(i, 1, n){
    ans += v[i];
    ans /= 2;
  }
  cout << fixed << setprecision(10) << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import numpy as np
A=[]
for _ in range(3):
  A.append(list(map(int,input().split())))

def bingo(x):
  a=False
  for s in range(3):
    if sum(x[s])==3:a=True
  
  for h in range(3):
    if x[0][h]+x[1][h]+x[2][h]==3:a=True
      
  if x[0][0]+x[1][1]+x[2][2]==3:a=True
  
  if x[0][2]+x[1][1]+x[2][0]==3:a=True
  
  return a

seen=[[0,0,0] for _ in range(3)]

for _ in range(int(input())):
  a=int(input())
  
  for i in range(3):
    for j in range(3):
      if A[i][j]==a:seen[i][j]=1

ff=bingo(seen)

if ff==True:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 27148
Sa=list(str(raw_input()))
Sb=list(str(raw_input()))
Sc=list(str(raw_input()))
state="a"
while True:
    if state=="a":
        if (len(Sa) == 0):
            break
        else:
            state=Sa.pop(0)

    elif state=="b":
        if (len(Sb) == 0):
            break
        else:
            state=Sb.pop(0)
    elif state=="c":
        if (len(Sc) == 0):
            break
        else:
            state=Sc.pop(0)
print(state.upper())


Measured memory_bytes: 2568
import java.util.*;
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);

    long a = sc.nextLong();
    long b = sc.nextLong();
    long c = sc.nextLong();
    long d = sc.nextLong();
    
    long max = 0;

    max = Math.max(Math.max(a*c,a*d),Math.max(b*c,b*d));
    
    System.out.println(max);

  }
}

Measured memory_bytes: 27060
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)n; ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
string speak(int n){
  vector<int> v;
  while(n!=0){
    v.push_back(n%26);
    n/= 26;
  }
  string res = "z";
  REP(i,v.size())res = (char)(v[i]+'a') + res;
  return res;
}

int main(){
  int count = 0;
  set<string> setc;
  char last = 'a';
  while(true){
    char ai[256];
    printf("?%c%s\n",last,speak(count++).c_str()); fflush(stdout);
    scanf("%s",ai);
    string ais(ai);
    last = ais[ais.size()-1];
    if(setc.find(ais) != setc.end()){
      cout<<"!OUT"<<endl;
      break;
    }
    if(ais[0] != 'z'){
      cout<<"!OUT"<<endl;
      break;
    }
    setc.insert(ais);
  }
  return 0;
}

Measured memory_bytes: 0
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <bitset>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> Pll;
typedef pair<int, int> Pii;

const ll MOD = 1000000007;
const long double EPS = 1e-10;
const int dyx[4][2] = {
    { 0, 1}, {-1, 0}, {0,-1}, {1, 0}
};

int main() {
    std::ios::sync_with_stdio(0); cin.tie(0);
    ll n, ans = 0;
    cin >> n;

    // for(ll i=1;i<=n;++i) {
    //     printf("%4lld%4lld%4lld\n", i, n/i, n%i);
    // }

    for(ll i=1;i*i<n;++i) {
        if(n % i != 0) continue;
        if(i * (i+1) == n) continue;
        ll m = (n - i) / i;
        // cerr << m << endl;
        ans += m;
    }

    cout << ans << endl;
}


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

#define                           int                         long long
#define                           fi                          first
#define                           si                          second
#define                           mp                          make_pair
#define                           pb                          push_back
#define                           pi                          pair<int,int>
#define                           f(i,l,r)                    for(int i=l;i<=r;i++)
#define                           rf(i,r,l)                   for(int i=r;i>=l;i--)
#define                           done(i)                     cout<<"done = "<<i<<endl;
#define                           fast                        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);




using namespace std;

const int inf=1e18;
const int mod=1e9+7;
const int M=100009;
inline int bigmod(int B,int P){int R=1;while(P>0){if(P&1){R=(R*B)%mod;}P>>=1;B=(B*B)%mod;}return R;}


 main()

{
    fast
    int n;
    cin>>n;
    set<string>s;
    while(n--)
    {
        string p;
        cin>>p;
        s.insert(p);
    }
    cout<<s.size()<<endl;
    return 0;

}
















Measured memory_bytes: 19084
#include <bits/stdc++.h>
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#define l_ength size
const int inf = (1<<30);
const int mod = 1000000007;	// 998244353
using ll = long long;
using namespace std;

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

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

	vector<int> a(n);
	for( auto &k : a ) cin >> k;

	const int a_bound = 1000010;
	vector<int> l(a_bound, 0);
	
	for( auto k : a ){
		if( k == 1 ) continue;
		int t = k;
		for( int p = 2; p*p <= k; ++p ){
			int cnt = 0;
			while( t % p == 0 ){
				t /= p;
				++cnt;
			}
			if( cnt > 0 ){
				l[p] = max(l[p], cnt);
			}
		}
		if( t != 1 ){
			l[t] = max(l[t], 1);
		}
	}
	
	const int p_bound = 100000;
	vector<int> pset(p_bound, 0);
	int sz = 0;
	for( int p = 2; p < a_bound; ++p ){
		if( l[p] > 0 ){
			pset[sz] = p;
			++sz;
		}
	}

	ll ans = 0;
	
	for( auto &t : a ){
		ll pro = 1;
		for( int i = 0; i < sz; ++i ){
			int p = pset[i];
			int cnt = 0;
			while( t % p == 0 ){
				t /= p;
				++cnt;
			}
			pro *= pow((ll)p, l[p]-cnt);
			pro %= mod;
		}
		ans += pro;
		ans %= mod;
	}

	cout << ans << endl;
}

Measured memory_bytes: 4608
#include <cmath>
#include <cstdio>
#include <vector>
#include <iterator>
#include <iostream>
#include <algorithm>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <map>
#include <stdio.h>
#include <functional>
#include <chrono>
#include <random>
#include <time.h>
using namespace std;

#define rep(i,s,n) for(ll i=s;i<(n);++i)
using ll = long long;
using pll = pair<ll, ll>;
constexpr ll INF = (1LL << 60);
constexpr ll MAX_INF = 9223372036854775807;
//constexpr ll MOD = (1e9 + 7);
constexpr ll MOD = (998244353);

using vl = vector<ll>;
using vvl = vector<vector<ll>>;

template<class T>
vector<vector<T>> vvt(T init, ll m, ll n) {
	vector<vector<T>> ans = vector<vector<T>>(m, vector<T>(n, init));
	return move(ans);
}

template<class T>
vector<T> vt(T init, ll n) {
	vector<T> ans = vector<T>(n, init);
	return move(ans);
}

template<class T>
T maxVec(vector<T>& v) {
	T ans = -INF;
	rep(i, 0, v.size()) {
		ans = max(ans, v[i]);
	}
	return ans;
}

// 素数判定
bool judge(ll n) {
	for (ll i = 2; i * i <= n; i++) if (n %= i)return false;
	return true;
}


template <class C>
void print(const C & c, std::ostream & os = std::cout)
{
	std::copy(std::begin(c), std::end(c), std::ostream_iterator<typename C::value_type>(os, ", "));
	os << std::endl;
}
/*
ll count(ll n,ll r) {
	ll ans = 0,check = 1;
	rep(i,0, r) {
		if ((n & check) > 0) {
			ans++;
		}
		check = check << 1;
	}
	return ans;
}
*/
bool sortreverse(ll a, ll b) {
	return a > b;
}


ll kiriage(ll a, ll b) {
	if (a % b == 0)return a / b;
	return a / b + 1;
}

void warshall_floyd(ll v_num,vector<vector<long long>> &d) {
	for (long long k = 0; k < v_num; k++) {       // 経由する頂点
		for (long long i = 0; i < v_num; i++) {    // 始点
			for (long long j = 0; j < v_num; j++) {  // 終点
				d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
			}
		}
	}
}

uniform_real_distribution<> dist(0.0, 1.0);
float judge(float p, mt19937& engine) {
	float f = dist(engine);
	return p >= f;
}

float prob(float delta, float tmp) {
	return exp(delta / tmp);
}


int main() {
	// ↓この２行が追加部分
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	random_device seed_gen;
	mt19937 engine(seed_gen());

	int d;
	cin >> d;
	int con = 1;
	rep(i, 0, d) {
		printf("%d\n", con);
		++con;
		con %= 27;
		if (con == 0)con = 1;
	}

	int start_tmp = 50,end_tmp = 10;
	
}

Measured memory_bytes: 3812
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <iomanip>
#include <bitset>
#include <set>
#include <map>
#include <stdio.h>
#include <numeric>

#define rep(i,n) for (long long int i = 0; i < (n); i++)
#define FOR(i,a,b) for (int i=(a); i < (b); i++)
#define INF 100000000000
#define MOD 1000000007 //10^9+7
using namespace std;
using ll = long long;
using P = pair<int, int>;

// 負の数にも対応した % 演算
long long mod(long long val, long long m) {
    long long res = val % m;
    if (res < 0) res += m;
    return res;
}

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

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

int main()
{
    string s;
    cin >> s;
    if(s[0] == s[1] && s[0] == s[2])
        cout << "No" << endl;
    else
        cout << "Yes" << endl;
    return 0;
}


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

int main() {
	vector<int> antenna(5);
	for(int i = 0; i < 5; i++) {
		cin >> antenna.at(i);
	}
	int k;
	cin >> k;

	int out = 0;
	for (int i = 0; i < 4; i++) {
		for (int j = i + 1; j <= 4; j++) {
			int distance = abs(antenna.at(i) - antenna.at(j));
			if (distance > k) {
				out = 1;
				break;
			}
		}
		if (out) { break; }
	}
	
	if (out == 1) {
		cout << ":(" << endl;
	} else {
		cout << "Yay!" << endl;
	}
}


Measured memory_bytes: 256
using System;
using System.Linq;
class Program{
  static void Main(string[] args){
    int a = int.Parse(Console.ReadLine());
    var l = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
    int ans = 0;
    int pre = 0;
    for(int i = 0; i < a ; i++){
      if(pre < l[i]){
        ans += l[i] - pre;
      }
      pre = l[i];
    }
    Console.Write(ans);
  }
}

Measured memory_bytes: 13268
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <cstring>
#include <string>
#include <sstream>
#include <algorithm>
#include <iomanip>
#include <iostream>

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

using namespace std;
/** Problem0088 : The Code A Doctor Loved **/
int main()
{
	string s;
	// 変換表 : http://refiute.hatenablog.com/entry/20111104/1320334135
	map<char,string> tbl1;
	tbl1['A']="00000";
	tbl1['B']="00001";
	tbl1['C']="00010";
	tbl1['D']="00011";
	tbl1['E']="00100";
	tbl1['F']="00101";
	tbl1['G']="00110";
	tbl1['H']="00111";
	tbl1['I']="01000";
	tbl1['J']="01001";
	tbl1['K']="01010";
	tbl1['L']="01011";
	tbl1['M']="01100";
	tbl1['N']="01101";
	tbl1['O']="01110";
	tbl1['P']="01111";
	tbl1['Q']="10000";
	tbl1['R']="10001";
	tbl1['S']="10010";
	tbl1['T']="10011";
	tbl1['U']="10100";
	tbl1['V']="10101";
	tbl1['W']="10110";
	tbl1['X']="10111";
	tbl1['Y']="11000";
	tbl1['Z']="11001";
	tbl1[' ']="11010";
	tbl1['.']="11011";
	tbl1[',']="11100";
	tbl1['-']="11101";
	tbl1['\'']= "11110";
	tbl1['?']="11111";
	map<string,char> tbl2;
	tbl2["101"]=' ';
	tbl2["000000"]='\'';
	tbl2["000011"]=',';
	tbl2["10010001"]='-';
	tbl2["010001"]='.';
	tbl2["000001"]='?';
	tbl2["100101"]='A';
	tbl2["10011010"]='B';
	tbl2["0101"]='C';
	tbl2["0001"]='D';
	tbl2["110"]='E';
	tbl2["01001"]='F';
	tbl2["10011011"]='G';
	tbl2["010000"]='H';
	tbl2["0111"]='I';
	tbl2["10011000"]='J';
	tbl2["0110"]='K';
	tbl2["00100"]='L';
	tbl2["10011001"]='M';
	tbl2["10011110"]='N';
	tbl2["00101"]='O';
	tbl2["111"]='P';
	tbl2["10011111"]='Q';
	tbl2["1000"]='R';
	tbl2["00110"]='S';
	tbl2["00111"]='T';
	tbl2["10011100"]='U';
	tbl2["10011101"]='V';
	tbl2["000010"]='W';
	tbl2["10010010"]='X';
	tbl2["10010011"]='Y';
	tbl2["10010000"]='Z';
	
	while (1) {
		getline(cin, s);
		if (cin.eof()) break;
		
		string code, sc, tmp, ans;
		rep(i, s.length()) {
			code += tbl1[s[i]];
		}
				
		rep(i, code.length()) {
			string t;
			for (; i<code.length(); i++) {
				t += code[i];
				if (tbl2[t]!=0) {
					ans+=tbl2[t];
					break;
				}
			}
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1208
use std::io::stdin;
use std::collections::HashMap;

fn main() {
    let mut st = String::new();
    stdin().read_line(&mut st).unwrap();
    let mut st = String::new();
    stdin().read_line(&mut st).unwrap();
    let a:Vec<String> = st.split_whitespace().map(|x| x.parse::<String>().unwrap()).collect();
    
    let mut dic:HashMap<&String, i64> = HashMap::new();
    for i in a.iter() {
        let count = dic.entry(&i).or_insert(0);
        *count += 1;
    };
    let mut result:i64 = 0;
    for (x, y) in dic.iter() {
        result += y*(y-1)/2;
    }

    for i in a.iter() {
        println!("{}", result-(dic[&i]-1));
    };
}

Measured memory_bytes: 24592
#include "bits/stdc++.h"
using namespace std;
int s[510][510];
int main(){
    int n,m,q;cin>>n>>m>>q;
    int l,r;
    for (int i=0; i<m; ++i){
        cin>>l>>r;
        ++s[l][r];
    }
    for (int i=1; i<=n; ++i)for (int j=1; j<=n; ++j)
        s[i][j]+=s[i-1][j]+s[i][j-1]-s[i-1][j-1];
    for (int i=0; i<q; ++i){
        cin>>l>>r;
        cout<<s[r][r]-s[r][l-1]-s[l-1][r]+s[l-1][l-1]<<endl;
    }
}

Measured memory_bytes: 4532
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <time.h>
#include <stdlib.h>
#include <string>
#include <bitset>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <sstream>
#include <stack>
#include <iomanip>
using namespace std;
#define pb push_back
#define mp make_pair
typedef pair<int,int> pii;
typedef long long ll;
typedef double ld;
typedef vector<int> vi;
#define fi first
#define se second
#define fe first
#define FO(x) {freopen(#x".in","r",stdin);freopen(#x".out","w",stdout);}
#define Edg int M=0,fst[SZ],vb[SZ],nxt[SZ];void ad_de(int a,int b){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;}void adde(int a,int b){ad_de(a,b);ad_de(b,a);}
#define Edgc int M=0,fst[SZ],vb[SZ],nxt[SZ],vc[SZ];void ad_de(int a,int b,int c){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;vc[M]=c;}void adde(int a,int b,int c){ad_de(a,b,c);ad_de(b,a,c);}
#define es(x,e) (int e=fst[x];e;e=nxt[e])
#define esb(x,e,b) (int e=fst[x],b=vb[e];e;e=nxt[e],b=vb[e])
string s;
int main()
{
	cin>>s; s=s+"#";
	string tg="AKIHABARA#";
	for(int i=0;i<s.size()&&i<tg.size()&&s.size()<tg.size();++i)
	{
		if(s[i]!=tg[i])
		{
			s.insert(s.begin()+i,'A'); --i; continue;
		}
	}
	if(s==tg) puts("YES");
	else puts("NO");
}


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

int main(){
  string s;
  
  cin >> s;
  
  if(s == "AAA" || s == "BBB")
    cout << "No" << endl;
  else
    cout << "Yes" << endl;
  
  return 0;
  
}

Measured memory_bytes: 256
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

A,B = map(int,input().split())
import fractions
gcd = fractions.gcd(A,B)
ans = 1 + len(factorization(gcd))
if factorization(gcd)[0][0] == 1:
    ans -= 1
print(ans)

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

#define pii pair<int, int>
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define ll long long
#define ld long double
#define sz(v) int(v.size())
#define all(v) v.begin(), v.end()
#define vec vector<int>
#define dead not_bad
#define bad gooood

#define left not_right
#define y1 what

using namespace std;

const int N = (int) 2e5 + 10;
const int M = (int) 350;
const int K = (int) 350;
const ll LINF = (ll) 1e18;
const int INF = (int) 1e9 + 7;
const int ALPHA = 26;
const int mod = INF + 2;
const double PI = 3.14159265359;
const ld EPS = (ld) 1e-12;

int n, m;
ll x;

struct edge {
  int from, to, cost;

  edge() {

  }
};

edge a[N];

bool cmp(edge x, edge y) {
  return x.cost < y.cost;
}

void add(int &x, int y) {
  x += y;
  if (x >= INF)
    x -= INF;
  if (x < 0)
    x += INF;
}

int sum(int x, int y) {  
  add(x, y);
  return x;
}

int mult(int x, int y) {
  return 1ll * x * y % INF;
}


ll min_cost;
int p[N], sz[N];

int get(int x) {
  return p[x] == x ? x : p[x] = get(p[x]);
}

void unite(int x, int y, int cost) {
  x = get(x);
  y = get(y);
  if (x == y)
    return;
  if (sz[x] > sz[y])
    swap(x, y);
  p[x] = y;
  sz[y] += sz[x];
  min_cost += cost;
}

ll solve(ll val) {
  for (int i = 0; i < n; i++) {
    p[i] = i;
    sz[i] = 1;
  }
  min_cost = 0;
  for (int i = 0; i < m; i++) {
    unite(a[i].from, a[i].to, a[i].cost);
  }
  int ans = 1;
  if (min_cost >= val) {
    for (int i = 0; i < m; i++) {
      ans = mult(ans, 2);    
    }   
    add(ans, -2);
    return ans;
  }
  // >= val
  for (int id = 0; id < m; id++) {
    for (int i = 0; i < n; i++) {
      p[i] = i;
      sz[i] = 1;
    }
    min_cost = 0;
    unite(a[id].from, a[id].to, a[id].cost);
    for (int i = 0; i < m; i++) {
      unite(a[i].from, a[i].to, a[i].cost);
    }
    if (min_cost >= val) {
      ans = mult(ans, 2);
    }
  } 
  add(ans, -1);
    ans = mult(ans, 2);
//  cout << "Here " << val << " = " << ans << endl;
  return ans;
}

int main() {
  #define fn "saddle"
  #ifdef witch
      freopen("input.txt", "r", stdin);
      freopen("output.txt", "w", stdout);
  #else
      //freopen(fn".in", "r", stdin);
      //freopen(fn".out", "w", stdout);
  #endif
  cin >> n >> m >> x;
  for (int i = 0; i < m; i++) {
    cin >> a[i].from >> a[i].to >> a[i].cost;
    a[i].from--;
    a[i].to--;
  }
  sort(a, a + m, cmp);
  //cout << solve(x) << endl;
  //cout << solve(x + 1) << endl;
  cout << sum(solve(x), -solve(x + 1));
  return 0;
}

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

int     main() {
        int N;
        string S;
        cin >>N;
        cin >>S;
        int SS=0;
        for (int i=1; i<S.size(); i++)
                if (S.at(i)=='E') SS++;
        int SSS=SS;
        for (int i=1; i<S.size(); i++) {
                if ('W'==S.at(i-1)) SS++;
                if ('E'==S.at(i)) SS--;
                SSS=min(SSS, SS);
        }
        cout <<SSS <<endl;
        return 0;
};

Measured memory_bytes: 900
N = int(input())
A = list(map(int, input().split()))
ans = 1

for _ in  A:
    if _ % 2 == 0:
        if _ % 3 == 0 or _ % 5 == 0:
            ans *= 1
        else:
            ans *= 0

if ans == 1:
    print('APPROVED')
else:
    print('DENIED')

Measured memory_bytes: 9188
# -*- coding: utf-8 -*-
N, M = map(int, input().split())
L = []
R = []
for i in range(M):
    l, r= map(int, input().split())
    L.append(l)
    R.append(r)
Lmax = max(L)
Rmax = min(R)
ans = Rmax-Lmax+1
if ans < 0:
  ans = 0
print(ans)

Measured memory_bytes: 55980
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
''' 
------------------------
author : iiou16
------------------------
'''


def main():
    N = int(input())
    A = list(map(int, input().split()))

    count = 0
    id = 1

    for i in range(N):
        if A[i] != id:
            count += 1
        else:
            id += 1
        # print(A[i], id, count)
    if id == 1:
        print(-1)
    else:
        print(count)


if __name__ == '__main__':
    main()

Measured memory_bytes: 24900
Uses math;
var
	n,i,x,y:Longint;
	a,b,c:int64;
begin
	readln(n);
	a:=1;
	for i:=1 to n do begin
		readln(x,y);
        c:=Max((a-1)div x,(b-1)div y)+1;
		a:=c*x;
		b:=c*y;
	end;
	writeln(a+b);
end.


Measured memory_bytes: 128