akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <vector>
#define MOD 1000000007
using namespace std;
typedef long long ll;

int calc(int x) {
  int res = 0, cnt = 0;
  if (x == 0) {
    return 1;
  }
  for (int i = 0; i < 30; i++) {
    if (x & (1 << i)) {
      cnt++;
    }
  }
  return calc(x % cnt) + 1;
}

int main() {
  int n, cnt = 0, sum[3] = {};
  string s;
  cin >> n >> s;
  vector<int> a(n), b(n), c(n);
  for (int i = 0; i < n; i++) {
    if (s[i] == '1') {
      cnt++;
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 3; j++) {
      sum[j] *= 2;
    }
    if (s[i] == '1') {
      if (cnt > 1) {
        sum[0]++;
      }
      sum[2]++;
    }
    if (cnt > 1) {
      sum[0] %= (cnt - 1);
    }
    sum[2] %= (cnt + 1);
  }
  if (cnt > 1) {
    a[0] = 1 % (cnt - 1);
    for (int i = 1; i < n; i++) {
      a[i] = a[i - 1] * 2;
      a[i] %= (cnt - 1);
    }
  }
  c[0] = 1 % (cnt + 1);
  for (int i = 1; i < n; i++) {
    c[i] = c[i - 1] * 2;
    c[i] %= (cnt + 1);
  }
  for (int i = 0; i < n; i++) {
    if (s[i] == '1' && cnt == 1) {
      cout << 0 << endl;
    } else if (s[i] == '1' && cnt == 2) {
      cout << 1 << endl;
    } else if (s[i] == '1') {
      cout << calc((sum[0] - a[n - 1 - i] + cnt - 1) % (cnt - 1)) << endl;
    } else {
      cout << calc((sum[2] + c[n - 1 - i] + cnt + 1) % (cnt + 1)) << endl;
    }
  }
}

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

public class Main {
	private static void solve(){
	//Implement solution here.
			int a = ni();
			int b = ni();
			if((a + b) % 2 == 0) {
				System.out.println((a + b) / 2);
			} else {
				System.out.println("IMPOSSIBLE");
			}
	}

    //Switch input source (stdin/file)
	private static BufferedReader br  = new BufferedReader(new InputStreamReader(System.in));
	public static void main(String[] args){
        String debugDataPath = System.getenv("DD_PATH");        
        if(debugDataPath != null){
            try{
            	br = new BufferedReader(new InputStreamReader(new FileInputStream(new File(debugDataPath))));
            }catch(Exception e){
                throw new RuntimeException(e);
            }
        } 
        solve();
	}

    //Input read utility
	private static StringTokenizer tokenizer = null;
	public static String next() {
		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(br.readLine());
			} catch (Exception e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}
    //Get next single int
	private static int ni() {
		return Integer.parseInt(next());
	}
    //Get next single long
	private static long nl() {
		return Long.parseLong(next());
	}
    //Get next single double
	private static double nd() {
		return Double.parseDouble(next());
	}
    //Get next int array from one line
	private static int[] na(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = ni();
		return a;
	}
	//Get next char array from one line
	private static char[] ns() {
		return next().toCharArray();
	}
    //Get next long array from one line
	private static long[] nal(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nl();
		return a;
	}
}

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

int main() {
    int n,temp;
    cin>>n;
    set<int> st;
    rep(i,n) {
        cin>>temp;
        st.insert(temp);
    }
    cout<<st.size()<<endl;
} 


Measured memory_bytes: 3624
<>=~/ (.*) /,$
$`{$1}=$$1{$`}=$' for 2..<>;@s=<>=~$"*$';map{$d[$_]or$d[$_]=$d[$u]+$$u{$_},push@s,$_}keys%{$u=$_}for@s;/ /,print$d[$`]+$d[$'],$/for<>

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

int main (){
  int a, b;
  char op;
  cin >> a >> op >> b;

  if (op == '+') {
    cout << a + b << endl;
  }
  else if (op == '-') {
    cout << a - b << endl;
  }
}
  

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

signed main(){
	int n;cin>>n;
	vector<int> a(n),b(n),c(n);
	for(auto&& w:a)cin>>w;
	for(auto&& w:b)cin>>w;
	for(auto&& w:c)cin>>w;
	sort(a.begin(),a.end());
	sort(b.begin(),b.end());
	sort(c.begin(),c.end());
	int ans=0;
	for(int i=0;i<n;i++){
	int x=lower_bound(a.begin(),a.end(),b[i])-a.begin();
	int y=c.end()-upper_bound(c.begin(),c.end(),b[i]);
        int z=n-(lower_bound(c.begin(),c.end(),b[i])-c.begin());
 	ans+=x*y;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 2560
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <vector>
#include <cstdio>
#include <cmath>

using namespace std;

int main(){
    int x,a,b;
  cin>>x>>a>>b;
  if(b<=a){
	cout<<"delicious";
  }else if(b<=(a+x)&&b>=(1+a)){
	cout<<"safe";
  }else if(b>=(a+x+1)){
    cout<<"dangerous";
  }
    return 0;
}

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

using namespace std;

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

        long double d_n = (long double)n;
        long double a = sqrt(n);
        long b = (long)a;
        long c;
        for (int i=b; i>=1; --i) {
                if (n%i==0) {
                        b = i;
                        c = n/b;
                        break;
                }
        }
        int b_digits, c_digits;
        b_digits = c_digits = 0;
        while (b>0) {
                b /= 10;
                b_digits++;
        }
        while (c>0) {
                c /= 10;
                c_digits++;
        }
        if (b_digits>c_digits) cout << b_digits << endl;
        else cout << c_digits << endl;
        return 0;
}


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

using ll = long long;
using pii = pair<int, int>; using pll = pair<ll, ll>;

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

template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}
template<class F, class S> istream& operator >> (istream& s, pair<F, S>& p)
{ s >> p.first >> p.second; return s;}

int main()
{
    int X, N; cin >> X >> N;
    set<int> P;
    rep(i, N) {
        int p; cin >> p;
        P.insert(p);
    }
    int ans = INT_MAX;
    rep(d, 110) {
        if (P.count(X-d) == 0) {
            ans = X-d;
            break;
        } else if (P.count(X+d) == 0) {
            ans = X+d;
            break;
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 3600
import sys
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())


input = sys.stdin.readline
N, M = map(int, input().split())
AB  = [list(map(int, input().split())) for _ in range(M)]
uf = UnionFind(N)
for a, b in AB:
    a -= 1
    b -= 1
    uf.union(a, b)
print(uf.group_count()-1)


Measured memory_bytes: 87240
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e6 + 5;

int n, MAX;
int a[N];
multiset <int> s;

int main() {
    ios::sync_with_stdio(false); cin.tie(0);
    cin >> n;
    MAX = 1 << n;
    for(int i = 1; i <= MAX; i++) cin >> a[i];
    sort(a + 1, a + MAX + 1);
    for(int i = 1; i <= MAX; i++) s.insert(a[i]);
    vector <int> V;
    V.push_back(a[MAX]);
    for(int i = 1; i <= n; i++) {
        vector <int> W = V;
        for(auto it : V) {
            auto p = s.lower_bound(it);
            if(p == s.begin()) {
                cout << "No"; return 0;
            }
            --p;
            W.push_back(*p);
            s.erase(p);
        }
        sort(W.begin(), W.end());
        reverse(W.begin(), W.end());
        swap(W, V);
    }
    cout << "Yes";
    return 0;
}


Measured memory_bytes: 13568
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define vl vector<ll>
#define pl pair<ll,ll>
#define TC int t;cin>>t;while(t--)
#define in(n) ll n;cin>>n;
#define inarr(n) ll n;cin>>n;vector<ll>arr;
int main(void){
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    inarr(n);
    ll sum=0;
    ll check[100005];
    memset(check,0,sizeof(check));
    for(int i=0;i<n;i++){
        in(temp);arr.push_back(temp);
        sum+=temp;
        check[temp]++;
    }
    in(q);
    while (q--){
        in(b);in(c);
        ll t = check[b];
        sum = sum-t*b+t*c;
        check[b]=0;
        check[c]+=t;
        cout<<sum<<endl;
    }
    return 0;
}

Measured memory_bytes: 5044
//
//  main.cpp
//  A
//
//  Created by Hashizo on 2020/02/09.
//  Copyright © 2020 Hashizo. All rights reserved.
//

#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <regex>
#include <cmath>

using namespace std;
 
#undef LONG_MAX
#undef LONG_MIN
 
#define LONG_MAX    9223372036854775807
#define LONG_MIN    (-LONG_MAX  -1)
 
#define ll long long
 
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
 
#define SORT(c) sort((c).begin(), (c).end())
#define REVERSE(v) reverse((v).begin(), (v).end())


int main(int argc, const char * argv[]) {

	string s,t,u;
	cin >> s >> t;

	ll a,b;
	cin >> a >> b;

	cin >> u;

	if (s == u) {
		a--;
	}
	else {
		b--;
	}

	cout << a << " " << b << 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 std;
using namespace __gnu_pbds;  
typedef tree<int, null_type, less<int>, rb_tree_tag,  tree_order_statistics_node_update>  ordered_set; 
typedef long long ll;
#define pb push_back
#define MP make_pair
#define F first
#define S second
#define ff(i, c, n) for (ll i = c; i < n; i++)
#define fr(i, c, n) for (ll i = c; i >= n; --i)

// DEBUGGING TEMPLATE
#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__) << "] "
const ll mod=1000000007;
const ll mod1=998244353;

ll modpow(ll a, ll b, ll c)
{ //a^b%c in O(logb)
	ll res = 1;
	while (b > 0)
	{
		if (b & 1)
		{
			res = (res * a) % c;
		}
		a = (a * a) % c;
		b >>= 1;
	}
	return res;
}
ll modinv(ll m, ll n)
{ //modular inverse of n w.r.t m provided 1<=n<=(m-1) in O(logn) and m is prime
	ll inv[n + 1];
	inv[1] = 1;
	for (int i = 2; i < n + 1; ++i)
		inv[i] = (m - (m / i) * inv[m % i] % m) % m;
	return inv[n];
}

void solve(){
	string s;
	cin >> s;
	ff(i, 0, s.length()){
		if(s[i] == '?') s[i] = 'D';
	}
	cout << s;
}

//a+b=a^b+2*(a&b)
int main()
{
	// your code goes here
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll t;
	t=1;
	while(t--){
		solve();
	}


	return 0;
}


Measured memory_bytes: 3752
#include<iostream>
using namespace std;
int main()
{
    string a;
    cin >> a;
  a = a[a.size()-1];
  if(a == "2" or a == "4" or a == "5" or a == "7" or a == "9"){
    cout << "hon";
  }else if(a == "3"){
    cout << "bon";
  }else{
    cout << "pon";
 
  }
    
    return 0;
}

Measured memory_bytes: 3592
#include <stdio.h>
#include <math.h>

int main(){
  
  int i,n,j3;
  int a[200];
  
  scanf("%d",&n);
  j3=2*n;
  
  for(i=0;i<j3;i++){
    a[i]=0;
    scanf("%d",&a[i]);
  }

  int i3,i4;
  int alpha;
  //---narabekae //bubble sort
  for(i3=0;i3<(j3-1);i3++){
    for(i4=(j3-1);i4>i3;i4=i4-1){
      if(a[i4-1]>a[i4]){
        alpha=a[i4-1];
        a[i4-1]=a[i4];
        a[i4]=alpha;
      }      
    }
  }
  
  int count;
  count=0;
  for(i=0;i<n;i++){
    count=count+a[2*i];
              //a[2*i+1];
  }
  printf("%d",count);

  return 0;
}

Measured memory_bytes: 128
#include <malloc.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

//ABC171D
//ABC171C
//ABC171B
//ABC171A

int main(void) {
  int n, k, i, cou=0, tmp;
  char a;
  scanf("%c", &a);
  if(a>=65&&a<=90) printf("A");
  else printf("a");

}


Measured memory_bytes: 1556
#include <stdio.h>

int main(){

int a,b,c;
int n,count;
scanf("%d %d %d\n", &a, &b, &c);

n = a;
count = 0;
for (int i = 0; i<(b - a + 1); i++){

if (c % n == 0 ) count++;
n++; 

}

printf("%d\n", count);

}


Measured memory_bytes: 2088
package main
 
import (
  "fmt"
  "os"
  "bufio"
  "strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func nextStr() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
    sc.Scan()
    i, e := strconv.Atoi(sc.Text())
    if e != nil {
        panic(e)
    }
    return i
}

func main() {
  sc.Split(bufio.ScanWords)
  A := nextInt()
  B := nextInt()
  C := nextInt()
  
  count := 0
  if A != B {
    count++
  }
  if B != C {
    count++
  }
  if C != A {
    count++
  }
  
  if count == 2 {
    fmt.Println("Yes")
  } else {
    fmt.Println("No")
  }
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll=long long;using ull=unsigned ll;
using vi=vector<int>;using vvi=vector<vi>;using vl=vector<ll>;
using P=pair<int,int>;using PL=pair<ll,ll>;
const int INF=1<<30,MOD=1000000007;const ll LINF=1ll<<60;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) _repi(i,0,n)
#define _repi(i,a,b) for(int i=a,i##_l=(b);i<i##_l;++i)
#define REP(...) _overload3(__VA_ARGS__,_repi,_rep,)(__VA_ARGS__)
#define REPR(i,n) for(int i=n-1;i>=0;--i)
#define REPARR(i,v) for(int i=0;i<v.size();++i)
#define all(v) (v).begin(),(v).end()
#define uniq(v) sort(all(v));v.erase(unique(all(v)),v.end())
#define bit(n) (1ll<<(n))
template<class T>bool chmax(T&a,const T&b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T&a,const T&b){if(a>b){a=b;return 1;}return 0;}
#define cut(n, Min, Max) max(min(n,Max),Min)
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define yes(n) cout<<((n)?"yes":"no")<<endl
#define poss(n) cout<<((n)?"":"im")<<"possible"<<endl
#define Poss(n) cout<<((n)?"P":"Imp")<<"ossible"<<endl
template<typename T>ostream&operator<<(ostream&o,const vector<T>&v){for(T i:v)o<<i<<' ';return o;}
template<typename T>istream&operator>>(istream&i,vector<T>&v){for(T&j:v)i>>j;return i;}
template<typename T>ostream&operator<<(ostream&o,const set<T>&v){for(T i:v)o<<i<<' ';return o;}
template<typename T,typename U>ostream&operator<<(ostream&o,const pair<T,U>&v){o<<v.first<<' '<<v.second;return o;}
ll f(ll n) {
    switch (n%4) {
        case 0: return n;
        case 1: return 1;
        case 2: return n^1;
        default: return 0;
    }
}

int main() {
    ll a,b;
	cin >> a >> b;

    ll res = f(b);
    if (a) res ^= f(a-1);
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int sort(int *a,int *b){
  return *b-*a;
}
int main(void){
  int n,m,sum=0,count=0;
  scanf("%d%d",&n,&m);
  int a[n];
  for(int i=0;i<n;i++){
scanf("%d",&a[i]);
    sum+=a[i];
  }
  
  qsort(a,n,sizeof(a[0]),sort);
  double x=(double)sum/4/m;
 
  for(int i=0;i<n;i++){
    if(a[i]>=x)count++;
  }
if(count>=m)printf("Yes");
  else printf("No");
  return 0;
}

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

#define int         long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define sz(x)       (int)x.size()
#define endl        "\n"
#define repp(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a,b) 	for(int i=a;i<=b;i++)
#define IOS         ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);

const int N=1e5 + 5;

int32_t main()
{
	IOS;
	int n;
	cin >> n;
	int a[n+5];
	int b[n+5];
	rep(i,1,n-1)
	{
		cin >> b[i];
	}
	a[1] = b[1];
	a[2] = b[1];
	rep(i,2,n-1)
	{
		a[i] = min(a[i],b[i]);
		a[i+1] = b[i];
	}
	int sum=0;
	rep(i,1,n)
	{
		sum += a[i];
	}
	cout << sum << endl;
}


Measured memory_bytes: 256
# 入力
A,B,C,D=map(int,input().split())

if B<=C:
  print(0)
elif A<=C and C<=B and B<=D:
  print(B-C)
elif C<=A and B<=D:
  print(B-A)
elif C<=A and A<=D and D<=B:
  print(D-A)
elif D<=A:
  print(0)
elif C<=A and A<=D and D<=B:
  print(D-A)
elif A<=C and D<=B:
  print(D-C)
elif A<=C and C<=B and C<=D:
  print(C-A)
elif B<=C:
  print(0)

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

#define DEBUG(x) cout<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cout<<#v<<":";for(int i=0;i<v.size();i++) cout<<" "<<v[i]; cout<<endl

typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
const int inf = 1000000001;
const ll INF = 1e18 * 2;
#define MOD 1000000007
#define mod 1000000009
#define pi 3.14159265358979323846
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };

int main() {
	int n, k, i, j;
	cin >> n >> k;
	vi a(n);
	for (i = 0; i < n; i++) {
		cin >> a[i];
	}
	sort(a.begin(), a.end());
	vi kazu;
	int cnt = 1;
	int pre = a[0];
	for (i = 1; i < n; i++) {
		if (a[i] == pre) {
			cnt++;
		}
		else {
			kazu.push_back(cnt);
			pre = a[i];
			cnt = 1;
		}
	}
	kazu.push_back(cnt);
	sort(kazu.begin(), kazu.end());
	reverse(kazu.begin(), kazu.end());
	if (kazu.size() <= k) {
		cout << 0 << endl;
		return 0;
	}
	else {
		int ans = 0;
		for (i = k; i < kazu.size(); i++) {
			ans += kazu[i];
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 2168
x,n=map(int,input().split())
if n==0:
    print(x)
else:
    p=list(map(int,input().split()))

    for xi in range(x,102):
        if not xi in p:
            break
        
    for xi2 in range(x,-1,-1):
        if not xi2 in p:
            break

    if xi-x<x-xi2:
        print(xi)
    else:
        print(xi2)

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

		// 文字列の入力
		String[] s = sc.next().split("");
      
        String ans = "";
        if (!s[1].equals(s[2])) {
          ans = "No";
        } else {
          ans = s[0].equals(s[1]) || s[1].equals(s[3]) ? "Yes" : "No";
        }
        
    
		// 出力
		System.out.println(ans);
	}
}


Measured memory_bytes: 23892
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <unordered_map>
#include <set>
#include <map>
#define INCANT cin.tie(0), cout.tie(0), ios::sync_with_stdio(0), cout << fixed << setprecision(20);
#define rep(i,n) for (int i=0; i<n;++i)
#define ALL(a)  (a).begin(),(a).end()
#define PI 3.14159265358979
typedef long long ll;
using namespace std;
const ll MOD = 1e9+7LL;
const int INF = 2e9;
int N, X, T;

int main() {
  INCANT;
  cin >> N >> X >> T;
  
  cout << (N+X-1)/X*T << "\n";
  return 0;
}

Measured memory_bytes: 3636
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cstdlib>
#include<queue>
#include<set>
#include<cstdio>

using namespace std;

#define ll long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define P pair<int, int>

typedef vector<int> vec;
typedef vector<vec> mat;

const ll mod = 1000000007;

int main(){
    int n;
    cin >> n;
    cout << n * n * n << endl;
}

Measured memory_bytes: 3640
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Jaynil
 */
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);
        DFaceProducesUnhappiness solver = new DFaceProducesUnhappiness();
        solver.solve(1, in, out);
        out.close();
    }

    static class DFaceProducesUnhappiness {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int k = in.nextInt();
            String x = in.next();
            StringBuilder ans = new StringBuilder("");
            int count = 0;
            ans.append(x.charAt(0));
            for (int i = 1; i < n; i++) {
                if (x.charAt(i) == ans.charAt(ans.length() - 1)) {
                    count++;
                    continue;
                }
                ans.append(x.charAt(i));
            }
            int l = ans.length();
            if (l % 2 == 1) {
                int temp = l / 2;
                if (temp > k) {
                    count += k * 2;
                } else {
                    count += temp * 2;
                }
            } else {
                int temp = (l - 1) / 2;
                if (temp > k) {
                    count += k * 2;
                    k = 0;
                } else {
                    count += temp * 2;
                    k -= temp;
                }
                if (k > 0) {
                    count++;
                }
            }
            out.println(count);

        }

    }

    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();
        }

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

    }
}



Measured memory_bytes: 26324
#include <stdio.h>

int main()
{
    int x;
    int i = 1;
    do
    {
        // printf("%d\n", i);
        scanf("%d", &x);

        if (x != 0)
            
        {
            printf("Case %d: %d\n", i, x);
        }
        i++;

    } while (x != 0);

    return 0;
}


Measured memory_bytes: 2108
n,m,p=map(int,input().split())
l=[list(map(int,input().split())) for i in range(m)]
I=float('inf')
d=[0]*2+[I]*n
for i in range(n-1):
  for a,b,c in l:
    d[b]=min(d[b],d[a]-c+p)
x=d[n]
for i in range(n):
  for a,b,c in l:
    if d[b]>d[a]-c+p:d[b]=-I
print([max(-d[n],0),-1][d[n]!=x])

Measured memory_bytes: 51544
N = int(input())
D = {}
ans = []
ansval = 0
for _ in range(N):
    s = input()
    if s not in D:
        D[s] = 1
    else:
        D[s] += 1
    if ansval == D[s]:
        ans.append(s)
    elif ansval < D[s]:
        ans = [s]
        ansval = D[s]
ans.sort()
for a in ans:
    print(a)

Measured memory_bytes: 97368
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<string>
#include<iostream>
#include<cctype>
#include<cstdio>
#include<vector>
#include<stack>
#include<queue>
#include <algorithm>
#include<math.h>
#include<set>
#include<map>
#include<iomanip>

//#include<bits/stdc++.h>


using namespace std;



int main() {

	long long int ans = 0;
	long long int a, b;
	cin >> a >> b;
	long long int n=2*a;
	n = min(n, b);
	if (n % 2)n--;

	ans += n / 2;
	b -= n;


	
	ans += b / 4;
	cout << ans << endl;

	return 0;

}




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

int main() {
  int n, k, total;
  cin >> n >> k;
  total = 0;

  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;

    if (abs(x - 0) <= abs(x - k)) {
      total += 2 * abs(x - 0);
    }
    else {
      total += 2 * abs(x - k);
    }
  }
  cout << total << endl;
}

Measured memory_bytes: 256
n = gets.to_i
count = 0
n.times do |i|
  if (i + 1) / 100000 >= 1 then
  elsif (i + 1) / 10000 >= 1 then
    count += 1
  elsif (i + 1) / 1000 >= 1 then
  elsif (i + 1) / 100 >= 1 then
    count += 1
  elsif (i + 1) / 10 >= 1 then
  elsif (i + 1) / 1 >= 1 then
    count += 1
  end
end

puts count


Measured memory_bytes: 1788
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<iomanip>
#include<map>
#include<set>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
using namespace std;
#define DEBUG(x) cout<<#x<<"="<<x<<endl
#define DEBUG2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<endl
typedef long long ll;
class Solver{
public:
    static const int MAXN =1e2+10;
    int N;
    int cnt[MAXN];
    int left[MAXN];
    int isprime[MAXN];
    int stdn[5]={2,4,14,24,74};
    ll num[5];
    void solve(){
        cin>>N;
        for(int i=0;i<MAXN;i++)left[i]=i;
        for(int u=2;u<=N;u++)isprime[u]=true;
        for(int u=2;u<=N;u++){
            if(!isprime[u])continue;
            for(int v=u;v<=N;v+=u){
                isprime[v]=false;
                while(left[v]&&left[v]%u==0){
                    left[v]/=u;
                    cnt[u]++;
                }
            }
            isprime[u]=true;
        }
        //先大再减,类似于前缀和
        for(int u=1;u<=N;u++){
            for(int v=0;v<5;v++){
                if(cnt[u]>=stdn[v])num[v]++;
            }
        }
        ll ans=0;
        ans+=num[4];
        ans+=num[3]*max(0ll,num[0]-1);
        ans+=num[2]*max(0ll,num[1]-1);
        ans+=num[1]*max(0ll,num[1]-1)*max(0ll,num[0]-2)/2;
        cout<<ans;
    }
};
int main()
{
    // freopen("in.txt","r",stdin);
    (new Solver())->solve();
}

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




int main()
{
    char s[4]={0};

    scanf("%s",s);
    for(int i=0;i<4;i++){
        int k=s[i],cot=1;
        for(int j=0;j<4;j++){
            if(i==j)continue;
            if(s[j]==k)cot++;
        }
        if(cot!=2){printf("No");return 0;}
    }
    printf("Yes");


}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define fr first
#define se second
#define ll long long
#define pb push_back
using namespace std;
 
const ll INF = 1e16 + 1;
const ll N = 2e3 + 5;			
const ll mod = 1e9 + 7;
const long double eps = 1E-7;
 
int res;
int u[1001];
int main()
{
	int x , n , k;
    cin >> x >> n;
    map < int , int > mp;
    for(int i = 1; i <= n; ++ i){
        cin >> k;
        mp[k] = 1;
    }
    int mn = 1e9 , idx;
    for(int i = 0; i <= 1000; ++ i){
        if(!mp[i]){
            if(mn > abs(x - i)){
                idx = i;
                mn = abs(x - i);
            }
        }
    }
    cout << idx;
}

Measured memory_bytes: 3640
#include<stdio.h>
int main(void)
{
    int r, d, x, ans, i;
    scanf("%d%d%d", &r, &d, &x);
    ans = r * x - d;
    for(i = 1; i <= 10; i++)
    {
        printf("%d\n", ans);
        ans = ans * r - d;
    }
    return 0;
}


Measured memory_bytes: 128
#include <algorithm>
#include<iostream>
#include<vector>
#include<deque>
#include<queue>
#include<list>
#include<stack>
#include<map>
#include<set>
#include<string>
#include <sstream>
#include<bitset>

#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<limits.h>

using namespace std;


int gcd(int x,int y){
  int mi,ma;
  ma = max(x,y);
  mi = min(x,y);
  if(ma % mi == 0){
    return mi;
  }
  else{
    return gcd(mi,ma % mi);
  }
}

int main(){
  long ii,jj,kk;
  vector<int> a;
  set<string> s;
  int n;
  string com,str;

  cin >> n;

  for(ii=0;ii<n;ii++){
    cin >> com >> str;
    if(com == "insert"){
      s.insert(str);
    }
    else{
      if(s.find(str) != s.end()){
        cout << "yes" << endl;
      }
      else{
        cout << "no" << endl;
      }
    }
  }
  

  return 0;
}



Measured memory_bytes: 32496
#include<cstdio>
int a[100005];
int main()
{
	int n,ans=0;scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		int x;scanf("%d",&x);
		if(x>n) ans++;else a[x]++;
	}
	for(int i=1;i<=n;i++)
	{
		if(a[i]==i||a[i]==0) continue;
		if(a[i]>i) ans+=a[i]-i;else ans+=a[i];
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
void dfs(vector<vector<vector<int>>> &g,vector<bool> &f,int i,int v){
  f.at(v)=1;
  for(auto e:g.at(v)){
    int ei=e.at(0);
    int ev=e.at(1);
    if(ei!=i&&!f.at(ev))
      dfs(g,f,i,ev);
  }
  return;
}
int main(){
  int n,m;
  cin>>n>>m;
  vector<vector<vector<int>>> g(n);
  for(int i=0;i<m;i++){
    int a,b;
    cin>>a>>b;
    a--;
    b--;
    g.at(a).push_back({i,b});
    g.at(b).push_back({i,a});
  }
  int c=0;
  for(int i=0;i<m;i++){
    vector<bool> f(n,0);
    dfs(g,f,i,0);
    bool a=1;
    for(int j=0;j<n;j++)
      a&=f.at(j);
    c+=(a?0:1);
  }
  cout<<c<<endl;
}

Measured memory_bytes: 3592
import sys
input=sys.stdin.readline

n,q=map(int,input().split())

hor=[0]*(n-2)
ver=[0]*(n-2)
a=n-2
b=n-2

ans=(n-2)**2
for _ in range(q):
    y,x=map(int,input().split())
    if y==1:
        if x-1>b:
            ans-=ver[x-2]
        else:
            ans-=a
            for i in range(x-2,b):
                ver[i]=a
            b=x-2

    else:
        if x-1>a:
            ans-=hor[x-2]
        else:
            ans-=b
            for i in range(x-2,a):
                hor[i]=b
            a=x-2


print(ans)

Measured memory_bytes: 71356
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
#include <random>
#include <cassert>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define MEM(a,b) memset((a),(b),sizeof(a))
const LL INF = 1e9 + 7;
const int N = 2e5 + 10;
int a[N];
double u = 180 / (acos(0.0) * 2);
int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int a, b, x;
	cin >> a >> b >> x;
	if (x * 2 > a* a* b)
	{
		double h = (a * a * b - x) * 2.0 / (a * a);
		printf("%.15f\n", atan(h / a) * u);
	}
	else
	{
		double h = x * 2.0 / (a * b);
		printf("%.15f\n", atan(b / h) * u);
	}
	return 0;
}


Measured memory_bytes: 512
#include<iostream>
using namespace std;
int n;
string x;
string s[50];
int t[50];
int main() {
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> s[i] >> t[i];
    }
    cin >> x;
    int k;
    for (int i = 0; i < n; i++) {
        if (s[i] == x) {
            k = i;
            break;
        }
    }
    int sum = 0;
    for (int i = k + 1; i < n; i++) {
        sum += t[i];
    }
    cout << sum << endl;
}


Measured memory_bytes: 256
T1, T2=(int(i) for i in input().split())
A1, A2=(int(i) for i in input().split())
B1, B2=(int(i) for i in input().split())

if T1*A1+T2*A2==T1*B1+T2*B2:
    print("infinity")
elif ((A1>B1) & (T1*A1+T2*A2-(T1*B1+T2*B2)>0)) or ((A1<B1) & (T1*A1+T2*A2-(T1*B1+T2*B2)<0)):
    print(0)
else:
    d=abs(T1*A1+T2*A2-(T1*B1+T2*B2))#T1+T2だけ走った後離れている距離
    ss=0
    if abs(T1*(A1-B1))%d==0:
        ss=1
        
    print(abs(T1*(A1-B1))//d*2-ss+1)


Measured memory_bytes: 38384
#include <stdio.h>
#include <math.h>


using ll = long long;
using llu = long long unsigned;

int main(void)
{
    //scanf("%d", );
    //scanf("%llu", );
    //scanf("%ll", );
    //printf("%d");
    //printf("%lli");
    //printf("%llu");

    int k,a,b;
//    int mult[2000] = {};

    scanf("%d", &k);
    scanf("%d %d", &a, &b);
    if (a<=k && k<=b) {
                printf("OK");
                return 0;
    } else {
        int divisor = a/k;
        int start = k*divisor;
        for (int i=start; i<=b;) {
            if (i>=a && i<=b) {
                printf("OK");
                return 0;
            }
            i+=k;
        }
    }
    printf("NG");



    return 0;
}


Measured memory_bytes: 1732
//コンパイラ最適化用
#pragma GCC optimize("Ofast")

//インクルード(アルファベット順)
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<climits>//INT_MAXなど
#include<chrono>//実行時間計測
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm,accumulate
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//順序保持しないmap
#include<unordered_set>//順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;

// clang++ main.cc -std=c++11 -stdlib=libc++

/*
  cin >> N;
  vector<int> a(N);
  for (int i = 0; i < N; i++)
    cin >> a[i];
*/

signed main(){
  string A, B;
  cin >> A >> B;

  int x = stoi(A + B);
  for (int i = 0; i <= 100000; i++) {
    if (i * i == x) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;

  return 0;
}

Measured memory_bytes: 3636
//#pragma GCC optimize("Ofast")
//#pragma GCC target ("avx2")
//#pragma GCC optimization ("O3")
//#pragma GCC optimization ("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//typedef tree < int , null_type, less <int>, rb_tree_tag, tree_order_statistics_node_update> TREE;
#define ll long long
#define ull unsigned long long int
#define pb push_back
#define mp make_pair
#define vi vector<int>
#define pii pair<int,int>
#define pss pair<short,short>
#define pld pair<long double,long double >
#define ld long double
#define piii  pair<pii,int>
#define vii vector<pair<int,int> >
#define st first
#define nd second
#define pll pair<ll,ll>
#define speed ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define M_PI 3.14159265358979323846
//#define int long long
const int mod=1000000007;
//const int mod=1009;
//const int mod=998244353;
const int inf=1000000009;
const long long INF=1000000000000000009;
const long long big=1000000000000000;
const long double eps=0.000000000000000000001;
using namespace std;
int A[100005],B[100005];
int main()
{
    speed
    int n,m,q;
    cin>>n>>m>>q;
    int x=inf,y=inf;
    for(int i=1;i<=n;i++)
        cin>>A[i],x=min(x,A[i]);
    for(int i=1;i<=m;i++)
        cin>>B[i],y=min(y,B[i]);
    int wynik=x+y;
    for(int i=1;i<=q;i++)
    {
        int a,b,c;
        cin>>a>>b>>c;
        wynik=min(wynik,A[a]+B[b]-c);
    }
    cout<<wynik;
    return 0;
}


Measured memory_bytes: 1024
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;

/*
<url:https://arc061.contest.atcoder.jp/tasks/arc061_b>
問題文============================================================
 縦 H 行、横 W 列のマス目からなる盤があります。最初、どのマス目も白く塗られています。
 
 すぬけ君が、このうち N マスを黒く塗りつぶしました。
 i 回目 ( 1≤i≤N ) に塗りつぶしたのは、 上から ai 行目で左から bi 列目のマスでした。
 
 すぬけ君がマス目を塗りつぶした後の盤の状態について、以下のものの個数を計算してください。
 
 各整数 j ( 0≤j≤9 ) について、盤の中に完全に含まれるすべての 3 行 3 列の連続するマス目のうち、
 黒いマスがちょうど j 個あるもの。

 制約
 3≤H≤10^9
 3≤W≤10^9
 0≤N≤min(10^5,H×W)
 1≤ai≤H (1≤i≤N)
 1≤bi≤W (1≤i≤N)
 (ai,bi)≠(aj,bj) (i≠j)
=================================================================

解説=============================================================

 範囲が広い。　＝＞　座標圧縮してもいいけど400にしては面倒臭いしメモリが心配
 
 別の考え方をする。
 今回調べるますは3x3と小さく限定されている。
 ここであるマスが3x3の正方形の領域に含まれる可能性があるのは
 
 正方形の左上のマスを基準とした書き方だと
 マス(a,b)に対して
 
 (a - i, b - j) : ΣΣ{i,j} { -2 -> 0 }
 
 の9通り（範囲外に注意）
 
 黒塗りの頂点数は高々10^5 なので、
 黒ますを内部にもつ正方形としてあり得る個数は 高々 9 * 10^5 個
 ０個の個数に関しては後であり得る正方形の個数から引けばいいので すぐもとまる。
 
 連想配列などで特定マスの位置だけ所持しておけば O(NlogN)で求まる
 
 
================================================================
*/
int main(void) {
	cin.tie(0); ios::sync_with_stdio(false);
    ll H,W,N; cin >> H >> W >> N;
    vector<ll> a(N),b(N);
    for(int i = 0; i < N;i++) cin >> a[i] >> b[i];
    
    map<pll,ll> mp;
    for(int i = 0; i < N;i++){
        for(int j = -2; j <= 0; j++){
            for(int k = -2; k <= 0; k++){
                ll nx = a[i] + j,ny = b[i] + k;
                if(nx <= 0 || nx >= H - 1 || ny <= 0 || ny >= W - 1) continue;
                mp[pll(nx,ny)]++;
            }
        }
    }
    ll ans[10] = {0};
    for(auto it = mp.begin(); it != mp.end(); it++) ans[it->second]++;
    
    ll sum = (H - 2) * (W - 2);
    for(auto v:ans){
        sum -= v;
    }
    ans[0] += sum;
    for(auto v:ans){
        cout << v << endl;
    }
    
	return 0;
}


Measured memory_bytes: 58112
n = gets.chomp!.to_i
h_n = gets.chomp!.split(" ").map(&:to_i)

sum = 0
h_n[0, n].each_with_index {|h_i, i|
    sum += (h_n[0, i].all?{|x| x <= h_i } ? 1 : 0)
}

puts sum


Measured memory_bytes: 3836
h,w = map(int,input().split())
u = [list(input()) for _ in range(h)]
from collections import deque
q = deque([])
dist = [[-1 for i in range(w)] for j in range(h)]
for i in range(h):
    for j in range(w):
        if u[i][j]=='#':
            q.append((i,j))
            dist[i][j]=0

while q:
    (i,j) = q.popleft()
    if 0<=i-1<h:
        if u[i-1][j]=='.' and dist[i-1][j]==-1:
            u[i-1][j]='#'
            q.append((i-1,j))
            dist[i-1][j]=dist[i][j]+1
    if 0<=i+1<h:
        if u[i+1][j]=='.' and dist[i+1][j]==-1:
            u[i+1][j]='#'
            q.append((i+1,j))
            dist[i+1][j]=dist[i][j]+1
    if 0<=j-1<w:
        if u[i][j-1]=='.' and dist[i][j-1]==-1:
            u[i][j-1]='#'
            q.append((i,j-1))
            dist[i][j-1]=dist[i][j]+1
    if 0<=j+1<w:
        if u[i][j+1]=='.' and dist[i][j+1]==-1:
            u[i][j+1]='#'
            q.append((i,j+1))
            dist[i][j+1]=dist[i][j]+1

z=[]
for b in dist:
    z.append(max(b))

print(max(z))

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

int dp[30];

int main(){

    dp[0] = 1;dp[1] = 2;dp[2] = 4;
    for(int i=3;i<30;++i){
        dp[i] = dp[i-3] + dp[i-2] + dp[i-1];
    }

    while(1){
        int n;
        scanf("%d",&n);
        if(n == 0)break;
        printf("%.0f\n",ceil(dp[n-1]/(365.0*10.0)));
    }

    return 0;
}

Measured memory_bytes: 1220
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
using bint = boost::multiprecision::cpp_int;
using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repSE(i,s,n) for (int i = (s); i < (n); i++)
#define rrepSE(i,s,e) for (int i = (s); i > (e); i--)
#define ssort(v) sort(v.begin(), v.end())
#define gsort(v) sort(v.rbegin(), v.rend())
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &vec){ os << "["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const deque<T> &vec){ os << "deq["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &pa){ os << "(" << pa.first << "," << pa.second << ")"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const unordered_map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
template<typename T> bool chmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T> bool chmin(T &m, const T q) { if (q < m) {m = q; return true;} else return false; }
#define DEBUG_PRINT(var) std::cout << #var << " = " << var << "\n";

int main()
{
    int x[5];
    int ans;
    rep(i,5) {
        cin >> x[i];
        if (x[i] == 0) ans = i+1;
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 3568
#include<iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <functional>
#include <iomanip>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
const long long mod = 1000000007;
typedef long long ll;

int main() {
	
	ll a, b;
	cin >> a;
	cin >> b;

	ll x, r;

	x = a * b;


	if (a > b) {
		r = a % b;
		while (r != 0) {
			a = b;
			b = r;
			r = a % b;
		}
		cout << x / b << endl;
	}
	else {
		r = b % a;
		while (r != 0) {
			b = a;
			a = r;
			r = b % a;
		}
		cout << x / a << endl;
	}

	
	
	return 0;
}

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


#define PB push_back
#define PF push_front
#define LB lower_bound
#define UB upper_bound
#define fr(x) freopen(x,"r",stdin)
#define fw(x) freopen(x,"w",stdout)
#define iout(x) printf("%d\n",x)
#define lout(x) printf("%lld\n",x)
#define REP(x,l,u) for(int x = (l);x<=(u);x++)
#define RREP(x,l,u) for(int x = (l);x>=(u);x--)
#define mst(x,a) memset(x,a,sizeof(x))
#define PII pair<int,int>
#define PLL pair<ll,ll>
#define MP make_pair
#define se second
#define fi first
#define dbg(x) cout<<#x<<" = "<<(x)<<endl;
#define sz(x) ((int)x.size())
#define cl(x) x.clear()

typedef  long long ll;
typedef unsigned long long ull;
typedef double db;
typedef double ld;
using namespace std;

const int maxn = 200010;
const int mod = 1e9+7;
const int MAX = 1000000010;
const double eps = 1e-6;
const double PI = acos(-1);

template<typename T> inline void read(T &x){
x=0;T f=1;char ch;do{ch=getchar();if(ch=='-')f=-1;}while(ch<'0'||ch>'9');do x=x*10+ch-'0',ch=getchar();while(ch<='9'&&ch>='0');x*=f;
}

template<typename A,typename B> inline void read(A&x,B&y){read(x);read(y);}
template<typename A,typename B,typename C> inline void read(A&x,B&y,C&z){read(x);read(y);read(z);}
template<typename A,typename B,typename C,typename D> inline void read(A&x,B&y,C&z,D&w){read(x);read(y);read(z);read(w);}
template<typename A,typename B> inline A fexp(A x,B p){A ans=1;for(;p;p>>=1,x=1LL*x*x%mod)if(p&1)ans=1LL*ans*x%mod;return ans;}
template<typename A,typename B> inline A fexp(A x,B p,A mo){A ans=1;for(;p;p>>=1,x=1LL*x*x%mo)if(p&1)ans=1LL*ans*x%mo;return ans;}

int n;

int x[maxn],y[maxn];

ld fix(ld x){
	if(x<0)x+=PI*2;
	if(x>PI*2)x-=PI*2;
	return x;
}

int vi[maxn];

ld hs[maxn];int cnt;

void Work(){
	REP(i,1,n){
		cnt=0;
		REP(j,1,n)if(i!=j){
			ld _x=fix(atan2(y[j]-y[i],x[j]-x[i]));
			_x=fix(_x+PI/2);
			ld y=fix(_x+PI);
			hs[++cnt]=_x;hs[++cnt]=y;
		}
		sort(hs+1,hs+cnt+1);cnt=unique(hs+1,hs+cnt+1)-hs-1;
		REP(j,1,cnt)vi[j]=0;
//		REP(j,1,cnt)cout<<hs[j]<<' ';cout<<endl;
		REP(j,1,n)if(i!=j){
			ld _x=fix(atan2(y[j]-y[i],x[j]-x[i]));
			_x=fix(_x+PI/2);
			ld y=fix(_x+PI);
			int xx=LB(hs+1,hs+cnt+1,_x)-hs;
			int yy=LB(hs+1,hs+cnt+1,y)-hs;
			while(xx!=yy){
				vi[xx]=1;
				xx++;if(xx>cnt)xx=1;
			}
		}
		double ans=0;
		REP(j,1,cnt)if(!vi[j])if(j==cnt)ans+=fix(hs[1]-hs[j]);else ans+=fix(hs[j+1]-hs[j]);
		printf("%.15lf\n",ans/PI/2);
	}
}

void Init(){
	read(n);
	REP(i,1,n)read(x[i],y[i]);
}

int main(){
	Init();
	Work();
	return 0;
}


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

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  sort(a.begin(), a.end());
  a.erase(unique(a.begin(), a.end()), a.end());
  if (n == a.size()) cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}

Measured memory_bytes: 1024
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int N=2005;
#define Get(a,x1,y1,x2,y2) (a[x2][y2]-a[x1][y2]-a[x2][y1]+a[x1][y1])
int n,m,q;
int sv[N][N],sh[N][N],sum[N][N];
char s[N][N];
int main()
{
	scanf("%d%d%d",&n,&m,&q);
	for(int i=1;i<=n;i++)
        scanf("%s",s[i]+1);
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++){
			sv[i][j]=sv[i-1][j];
            sh[i][j]=sh[i][j-1];
            sum[i][j]=sum[i][j-1];
			if(s[i][j]=='1')
                sv[i][j]+=(s[i-1][j]=='1'),sh[i][j]+=(s[i][j-1]=='1'),sum[i][j]++;
		}
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
            sum[i][j]+=sum[i-1][j];
    for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
            sh[i][j]+=sh[i-1][j];
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
            sv[i][j]+=sv[i][j-1];
	while(q--)
	{
		int x1,y1,x2,y2;
		scanf("%d%d%d%d",&x1,&y1,&x2,&y2);
		printf("%d\n",Get(sum,x1-1,y1-1,x2,y2)-Get(sh,x1-1,y1,x2,y2)-Get(sv,x1,y1-1,x2,y2));
	}
}


Measured memory_bytes: 52736
N = int(input())
A = list(map(int,input().split()))

ls = [0] * (N + 1)
for a in A:
  ls[a] += 1

C = 0
for i in set(A):
  n = ls[i]
  C += n * (n - 1) //2
  
for a in A:
  n = ls[a]
  print(C - (n - 1))

Measured memory_bytes: 32340
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int n;
    cin>>n;
    for(int i=1;i<=n;i++){
        int x=i;
        for(int j=0;j<5;j++){
            if(i%3==0){
                cout<<" "<<i;
                break;
            }
            if(x%10==3){
                cout<<" "<<i;
                break;
            }
                x=x/10;
        }
    }
    cout<<endl;
}



Measured memory_bytes: 3104
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

bool isPalin(string &S, int left, int right) {
  while (left < right) {
    if (S[left] != S[right]) {
      return false;
    }
    left++;
    right--;
  }
  return true;
}
int main() {
  string S;
  cin >> S;
  int n = S.size();
  if (isPalin(S, 0, n - 1) && 
      isPalin(S, 0, (n - 1) / 2 - 1) && 
      isPalin(S, (n + 3) / 2 - 1, n - 1)) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  
  return 0;
}

Measured memory_bytes: 256