akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"

#define MOD 1000000007
#define rep(i, n) for(ll i=0; i < (n); i++)
#define rrep(i, n) for(ll i=(n)-1; i >=0; i--)
#define ALL(v) v.begin(),v.end()
#define rALL(v) v.rbegin(),v.rend()
#define FOR(i, j, k) for(ll i=j;i<k;i++)
#define debug_print(var) cerr << #var << "=" << var <<endl;
#define DUMP(i, v)for(ll i=0;i<v.size();i++)cerr<<v[i]<<" "
#define fi first
#define se second

using namespace std;
typedef long long int ll;
typedef vector<ll> llvec;
typedef vector<double> dvec;
typedef pair<ll, ll> P;
typedef long double ld;
struct edge{ll x, c;};

ll mod(ll a, ll mod){
  ll res = a%mod;
  if(res<0)res=res + mod;
  return res;
}

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

ll modinv(ll a, ll mod){
  return modpow(a, mod-2, mod);
}

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

bool is_prime(ll n){
  ll i = 2;
  if(n==1)return false;
  if(n==2)return true;
  bool res = true;
  while(i*i <n){
    if(n%i==0){
      res = false;
    }
    i = i+1;
  }

  //if(i==1)res = false;
  if(n%i==0)res=false;
  return res;
}

struct UnionFind{
  ll N;
  llvec p;
  llvec cnt;
  UnionFind(ll n){
    N = n;
    p=llvec(N);
    cnt=llvec(N, 0);
    rep(i, N){
      p[i] = i;
      cnt[i] = 1;
    }
  }

  void con(ll a, ll b){
    P at = root(a);
    P bt = root(b);
    if(at.second!=bt.second){
      if(at.first>bt.first){
        swap(at, bt);
        swap(a, b);
      }
      p[at.second] = bt.second;
      cnt[bt.second]+=cnt[at.second];
      p[a]=bt.second;
    }
  }

  P root(ll a){
    ll atmp = a;
    ll c=0;
    while(atmp!=p[atmp]){
      atmp = p[atmp];
      c++;
    }
    p[a] = atmp;
    return {c, atmp};
  }

  bool is_con(ll a, ll b){
    P at=root(a);
    P bt=root(b);
    return at.second == bt.second;
  }
  
};

struct dijkstra{
  ll N;
  llvec d;
  vector<vector<edge> > e;
  dijkstra(ll n){
    N = n;
    //d = llvec(N, 1e18);
    e = vector<vector<edge> >(N);
  }

  void add_edge(ll from, ll to, ll cost){
    e[from].push_back({to, cost});
  }

  void run(ll start){
    priority_queue<P, vector<P>, greater<P> > que;
    que.push({0, start});
    d = llvec(N, 1e18);
    d[start]=0;
    while(!que.empty()){
      P q = que.top();que.pop();
      ll dc = q.first;
      ll x = q.second;
      if(dc>d[x]){
        continue;
      }else{
        for(auto ip: e[x]){
          if(d[ip.x]<=d[x]+ip.c){
            continue;
          }else{
            d[ip.x]= d[x]+ip.c;
            que.push({d[ip.x], ip.x});
          }
        }
      }
    }
  }  
};


/**************************************
** A main function starts from here  **
***************************************/
int main(){
  ll N, Q;
  cin >> N >> Q;
  llvec a(N);rep(i, N)cin >> a[i];
  rep(cases, Q){
    ll x;
    cin >> x;
    ll ans = 0;
    for(ll l = 0, r=0, sum=0;l<N;){
      for(;r<N and sum+a[r]<=x;){
        sum += a[r++];
      }
      ans += r-l;
      if(l<r){
        sum-=a[l++];
      }else{
        l++;
        r++;
      }
    }
    cout << ans<<endl;
  }
  return 0;
}



Measured memory_bytes: 3588
#include<iostream>
#include<algorithm>
using namespace std;
int main() {
	int a1, a2, a3, a4, b1, b2, b3, b4;
	cin >> a1 >> a2 >> a3 >> a4 >> b1 >> b2 >> b3 >> b4;
	cout << max(a1 + a2 + a3 + a4, b1 + b2 + b3 + b4) << endl;
	return 0;
}

Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v).begin(), (v).end()
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define DEBUG
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<"\n";}
typedef long long ll;
int a[100010];
int main(){
    int n,m;
    cin>>n>>m;
    ll cnt1=0;
    for (int i = 0; i < n; i++)
    {
        cin>>a[i];
        a[i]%=m;
    
    }
    ll sum=0;
    vector<ll>v;
    for (int i = 0; i < n; i++)
    {   sum+=a[i];
        if(sum%m==0) cnt1++;
        v.push_back(sum%m);
    }
    sort(ALL(v));
    ll ans=0;
    ll cnt=0;
    map<ll,ll>mp;
    set<ll>st(ALL(v));
    vector<ll>w(st.begin(),st.end());
    for (int i = 0; i < n; i++)
    {
        mp[v[i]]++;
    }
    for (int i = 0; i < w.size(); i++)
    {
        ll x=mp[w[i]];
        ans+=x*(x-1)/2;
    }
    
    //cerr<<cnt1<<endl;
    cout<<ans+cnt1<<endl;
    


    


    return 0;
}

Measured memory_bytes: 8820
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
#include<cassert>
#include<numeric>
#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)
using namespace std;
const int INF = 1001001001;
const long long LINF = 1001002003004005006ll;
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 (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int,int> P;

const double eps = 1e-9;

struct V {
  double x, y;
  V(double x=0, double y=0): x(x), y(y) {}
  V& operator+=(const V& v) { x += v.x; y += v.y; return *this;}
  V operator+(const V& v) const { return V(*this) += v;}
  V& operator-=(const V& v) { x -= v.x; y -= v.y; return *this;}
  V operator-(const V& v) const { return V(*this) -= v;}
  V& operator*=(double s) { x *= s; y *= s; return *this;}
  V operator*(double s) const { return V(*this) *= s;}
  V& operator/=(double s) { x /= s; y /= s; return *this;}
  V operator/(double s) const { return V(*this) /= s;}
  double dot(const V& v) const { return x*v.x + y*v.y;}
  double cross(const V& v) const { return x*v.y - v.x*y;}
  double norm2() const { return x*x + y*y;}
  double norm() const { return sqrt(norm2());}
  V rotate90() const { return V(y, -x);}
  int ort() const { // orthant
    if (abs(x) < eps && abs(y) < eps) return 0;
    if (y > 0) return x>0 ? 1 : 2;
    else return x>0 ? 4 : 3;
  }
  bool operator<(const V& v) const {
    int o = ort(), vo = v.ort();
    if (o != vo) return o < vo;
    return cross(v) > 0;
  }
};
istream& operator>>(istream& is, V& v) {
  is >> v.x >> v.y; return is;
}
ostream& operator<<(ostream& os, const V& v) {
  os<<"("<<v.x<<","<<v.y<<")"; return os;
}

int main(){
  int n;
  cin >> n;
  vector<V> v(n);
  rep(i,n)cin >> v[i];
  double ans = 0;
  sort(v.begin(),v.end());
  rep(i,n){
    V res;
    rep(j,n){
      res += v[(i+j)%n];
      chmax(ans,res.norm());
    }
  }
  printf("%.11f\n",ans);
}

Measured memory_bytes: 3184
#include<bits/stdc++.h>
#define MAX INT_MAX
using namespace std;
int main(void)
{
	int v,e,r;
	int s[2000],t[2000],d[2000];
	
	int i,j;
	int length[2000];
 	bool flg;
	
	cin>>v>>e>>r;
	
	for(i=0;i<e;i++)	cin>>s[i]>>t[i]>>d[i];
	for(i=0;i<v;i++)	length[i]=MAX;
	
	length[r]=0;
	
	for(i=0;i<=v;i++){
			flg=false;
			for(j=0;j<e;j++){
				if(length[s[j]]!=MAX&&length[t[j]]>length[s[j]]+d[j]){
					length[t[j]]=length[s[j]]+d[j];
					flg=true;
				}
			}
			if(!flg)	break;
	}
	if(i>v&&flg) cout<<"NEGATIVE CYCLE"<<endl;
	else{
		for(i=0;i<v;i++){
			if(length[i]==MAX){
				cout<<"INF"<<endl;
			}
			else{
				cout<<length[i]<<endl;
			}
		}
	}
	return 0;
}
	


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

#define true 1
#define false 0
  int *A;
  int n;

int solve(int i, int m){
  int res;
   if(m==0)return true;
   if(i>=n)return false;

   res = solve(i + 1, m) || solve(i + 1, m - A[i]);
   return res;
 }
int main(){
  int i, j;
  int y,m,c;

  scanf("%d",&n);
  A=(int*)malloc(sizeof(int)*n);
  for(i=0 ; i<n ; i++){
    scanf("%d",&A[i]);
  }
  scanf("%d",&y);

  for(i=0 ; i<y ;i++){
    scanf("%d",&m);
    c=solve(0,m);
    if(c==true)printf("yes\n");
    else printf("no\n");
  }
  return 0;
}


Measured memory_bytes: 2048
N,M = map(int,input().split())
num_list = []
for i in range(N):
    num_list.append(list(map(int,input().split())))
#print(N,M,num_list)

'''
[x,y,z]としてx+y+z,x-y+z,x+y-z,x-y-z,-x+y+z,-x-y+z,-x+y-z,-x-y-zの8パターン
を計算してソート
'''
list_xyz1 = []
list_xyz2 = []
list_xyz3 = []
list_xyz4 = []
list_xyz5 = []
list_xyz6 = []
list_xyz7 = []
list_xyz8 = []

for i in range(N):
    list_xyz1.append(num_list[i][0] + num_list[i][1] + num_list[i][2])
    list_xyz2.append(num_list[i][0] - num_list[i][1] + num_list[i][2])
    list_xyz3.append(num_list[i][0] + num_list[i][1] - num_list[i][2])
    list_xyz4.append(num_list[i][0] - num_list[i][1] - num_list[i][2])
    list_xyz5.append(-num_list[i][0] + num_list[i][1] + num_list[i][2])
    list_xyz6.append(-num_list[i][0] - num_list[i][1] + num_list[i][2])
    list_xyz7.append(-num_list[i][0] + num_list[i][1] - num_list[i][2])
    list_xyz8.append(-num_list[i][0] - num_list[i][1] - num_list[i][2])

list_xyz1.sort()
list_xyz2.sort()
list_xyz3.sort()
list_xyz4.sort()
list_xyz5.sort()
list_xyz6.sort()
list_xyz7.sort()
list_xyz8.sort()

xyz1 = 0
xyz2 = 0
xyz3 = 0
xyz4 = 0
xyz5 = 0
xyz6 = 0
xyz7 = 0
xyz8 = 0

for i in range(M):
    xyz1 += list_xyz1[N-i-1]
    xyz2 += list_xyz2[N-i-1]
    xyz3 += list_xyz3[N-i-1]
    xyz4 += list_xyz4[N-i-1]
    xyz5 += list_xyz5[N-i-1]
    xyz6 += list_xyz6[N-i-1]
    xyz7 += list_xyz7[N-i-1]
    xyz8 += list_xyz8[N-i-1]

#print(list_xyz1)
print(max(xyz1,xyz2,xyz3,xyz4,xyz5,xyz6,xyz7,xyz8))

Measured memory_bytes: 3700
/* Don't try to hack it :|
 
            _/﹋\_
            (҂`_´)
            <,︻╦╤─҉- - - - - - - - - - - - - - -
            _/﹋\_
*/

#include <bits/stdc++.h>
#define ll long long 
#define all(v) v.begin() , v.end()
#define pb push_back
#define f first
#define s second
#define mp make_pair
#define tr(con) for(auto it = con.begin(); it!= con.end() ; it++)
#define INF 1e9+7   // 1 * 10^9+ 7
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define fo(i,n) for(ll i=0;i<n;i++)
using namespace std;

int main(){
	
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n; cin >> n;
	vector < ll> v;
	for(ll i = sqrt(n) ; i>0;i--){
		if(n % i==0) v.pb( i + n/i - 2);
	}
	sort(all(v));
	cout << v[0];
	return 0;
}



Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int cost[10] = {2,5,5,4,5,6,3,7,6};
string chmax(string x, string a){
   if(x.size()<a.size()){
       return a;
   }
   if(x.size()>a.size()){
       return x;
   }
   if(x.size()==a.size()){
       if(x<a) return a;
       else return x;
   }
   return  x;
}
string solve(int n, vector <char> &A){
    vector <string> dp(10010, "-");
    dp[0] = "";
    for(int i=0;i<10000;i++){
        if(dp[i] == "-") continue;
        for(int j=0;j<A.size();j++){
            
dp[i+ cost[A[j]-'0'-1]]=chmax(dp[i+ cost[A[j]-'0'-1]],dp[i] + A[j] );
dp[i+ cost[A[j]-'0'-1]]=chmax(dp[i+cost[A[j]-'0'-1]], A[j] + dp[i]);
            
        }
    }
    return dp[n];
}
int main(void){
    int n,m; cin>>n>>m;
    vector <char> A(m);
    for(int i=0;i<m;i++){
        cin>>A[i];
    }
    cout<<solve(n,A)<<endl;
}

Measured memory_bytes: 41088
macro_rules !input {(source =$s :expr ,$($r :tt ) *) =>{let mut iter =$s .split_whitespace () ;let mut next =||{iter .next () .unwrap () } ;input_inner !{next ,$($r ) *} } ;($($r :tt ) *) =>{let stdin =std ::io ::stdin () ;let mut bytes =std ::io ::Read ::bytes (std ::io ::BufReader ::new (stdin .lock () ) ) ;let mut next =move ||->String {bytes .by_ref () .map (|r |r .unwrap () as char ) .skip_while (|c |c .is_whitespace () ) .take_while (|c |!c .is_whitespace () ) .collect () } ;input_inner !{next ,$($r ) *} } ;}
macro_rules !input_inner {($next :expr ) =>{} ;($next :expr ,) =>{} ;($next :expr ,$var :ident :$t :tt $($r :tt ) *) =>{let $var =read_value !($next ,$t ) ;input_inner !{$next $($r ) *} } ;}
macro_rules !read_value {($next :expr ,($($t :tt ) ,*) ) =>{($(read_value !($next ,$t ) ) ,*) } ;($next :expr ,[$t :tt ;$len :expr ] ) =>{(0 ..$len ) .map (|_ |read_value !($next ,$t ) ) .collect ::<Vec <_ >>() } ;($next :expr ,chars ) =>{read_value !($next ,String ) .chars () .collect ::<Vec <char >>() } ;($next :expr ,usize1 ) =>{read_value !($next ,usize ) -1 } ;($next :expr ,$t :ty ) =>{$next () .parse ::<$t >() .expect ("Parse error" ) } ;}

fn main() {
   input! {
      n: usize,
      wm: usize,
      wv: [(usize, usize); n]
   }
   let mut dp = vec![0; wm + 1];
   for (w, v) in wv {
      for i in (w..wm + 1).rev() {
         dp[i] = std::cmp::max(dp[i], dp[i - w] + v);
      }
   }
   println!("{}", dp[wm]);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define REP(i,n) for(int64_t i=0;i<(n);i++)
#define ALL(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define REV(c) reverse((c).begin(),(c).end())
#define YES cout << "YES" << endl;
#define NO cout << "NO" << endl;
#define Yes cout << "Yes" << endl;
#define No cout << "No" << endl;
#define COUTDOUBLE(d,i) cout << setprecision((i)) << (d) << endl;
#define VIN(v) for(int64_t i=0;i<(v).size();i++){cin >> (v).at(i);}
#define MREP(i,m) for(auto i=(m).begin(); i != (m).end(); ++i) // auto key = i->first;auto value = i->second;

using namespace std;
typedef int64_t I;
typedef pair<I,I> P;
typedef vector<I> V;

I MOD = pow(10,9)+7;
I MAX = LONG_MAX;
I MIN = LONG_MIN;

// 最大公約数
I gcd(I a, I b) {
  return b != 0 ? gcd(b, a % b) : a;
}

// 最小公倍数
I lcm(I a, I b) {
  return a * b / gcd(a, b);
}

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

int main(){
  I a,b;
  cin >> a >> b;
  if (a==b){
    cout << a << endl;
    return 0;
  }
  I s=a+1,e=b;
  bool aChk = false;
  if (a % 2 == 0){
    aChk = true;
    s = a;
  }
  bool bChk = false;
  if (b % 2 == 0){
    bChk = true;
    e=b-1;
  }
  I c = ((e-s +1)/2)%2;
  if (bChk){
    if (aChk){
      auto bb = b ^ c;
      cout << bb << endl;
    }else{
      auto bb = a ^ b ^ c;
      cout << bb << endl;
    }
  }else{
    if (aChk){
      cout << c << endl;
    }else{
      auto bb = a ^ c;
      cout << bb << endl;
    }
  }
  return 0;
}



Measured memory_bytes: 256
N ,M = map(int,input().split())
H = list(map(int,input().split()))
A = [0]*M
B = [0]*M
for i in range(M):
  A[i],B[i]= map(int,input().split())

s = set()
for i in range(M):
  a = A[i]-1
  b = B[i]-1
  if H[a]>H[b]:
    s.add(b)
  elif H[a] == H[b]:
    s.add(a)
    s.add(b)
  else:
    s.add(a)
print(N - len(s))

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

using namespace std;

#ifdef LOCAL
#include "rfd_wrap.h"
#endif

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

#define bt(x) (1LL << (x))
#define all(x) (x).begin(), (x).end()
#define FastIO ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);

const int inf = 0x3f3f3f3f;
const ll INF = 2e18;

int main() {
	FastIO;

	int n, m;
	cin >> n >> m;

	vector<int> a(n), c(n + 1, 0);
	for(int i=0; i<n; ++i) {
		cin >> a[i];
		c[i + 1] = (c[i] + a[i]) % m;
	}

	map<int, int> cnt;
	for(int i=0; i<=n; ++i) cnt[c[i]]++;

	ll res = 0;
	for(auto& qq : cnt) {
		res += 1LL * qq.second * (qq.second - 1) / 2;
	}

	cout << res << "\n";

	return 0;
}

Measured memory_bytes: 6728
#include<iostream>
using namespace std;
struct pt{
    int x;
    int y;
};
int main(){
    pt p;
    p.x = p.y = 0;
    int n;
    cin >> n;
    int flag = 1;
    int ti = 0;
    for(int i = 1 ; i <= n ; ++i){
        int t, x, y;
        cin >> t >> x >> y;
        if(flag){
            int time = (abs(x - p.x) + abs(y - p.y));
            int req  =  t - ti;
            int dif = req - time;
            if(dif < 0 || dif % 2) flag = 0;
        }
        p.x = x;
        p.y = y;
        ti = t;
    }
    if(flag)
        cout << "Yes"; else
            cout << "No";
}


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

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

int main() {
    int a, b, c, k;
    cin >> a >> b >> c >> k;

    if(a >= k) {
        cout << k << endl;
        return 0;
    } else if(a+b >= k) {
        cout << a << endl;
        return 0;
    } else {
        cout << 2*a + b - k << endl;
        return 0;
    }
}

Measured memory_bytes: 3228
program main
	implicit none
	character*100 s,a,b
	integer abss
	read(*,*)s
	abss=len_trim(s)-2
	a=s(1:1)
	b=s(len_trim(s):len_trim(s))
	if(abss<10)then
		write(*,'(a1,i1,a1)')a,abss,b
	else
		write(*,'(a1,i2,a1)')a,abss,b
	endif
end program main


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

#define fi first
#define se second
#define lch (o << 1)
#define rch (o << 1 | 1)

typedef double db;
typedef long long ll;
typedef unsigned int ui;
typedef pair<int, int> pint;

const int N = 2e5 + 5;
const int INF = 0x3f3f3f3f;
const ll INF_LL = 0x3f3f3f3f3f3f3f3f;

char s[N];
int pow2[N][2];

int F(int x) {
	return x == 0 ? 0 : F(x % __builtin_popcount(x)) + 1;
}

int main() {
	ios::sync_with_stdio(0);

	int n;
	cin >> n;
	int cnt = 0;
	for (int i = 0; i < n; i++) {
		cin >> s[i];
		cnt += (s[i] == '1');
	}

	int MOD[2] = {cnt - 1, cnt + 1};
	int sum[2] = {0, 0};

	for (int i = 0; i < 2; i++) {
		if (MOD[i] <= 0) continue;
		pow2[0][i] = 1;
		for (int j = 1; j < N; j++)
			pow2[j][i] = 2LL * pow2[j - 1][i] % MOD[i];
		for (int j = 0; j < n; j++)
			sum[i] = (sum[i] * 2LL + s[j] - '0') % MOD[i];
	}

	for (int i = 0; i < n; i++) {
		int o = 0;
		if (s[i] == '0') o = 1;
		if (MOD[o] == 0) {
			cout << 0 << endl;
			continue;
		}
		int x = (sum[o] + (o ? 1 : -1) * pow2[n - i - 1][o] + MOD[o]) % MOD[o];
		cout << F(x) + 1 << endl;
	}

	return 0;
}


Measured memory_bytes: 5400
#include<bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
  int N,K;
  cin >> N >> K;
  string S;
  cin>>S;
  K = K - 1;
  if(S[K]=='A'){
    S[K]='a';
  }
  else if(S[K]=='B'){
    S[K]='b';
  }
  else if(S[K]=='C'){
    S[K]='c';
  }
  cout << S << endl;
}

Measured memory_bytes: 256
#input of int(split by space)
def get_i()
  return gets.chomp.split(" ").map(&:to_i)
end
#input of float(split by space)
def get_f()
  return gets.chomp.split(" ").map(&:to_f)
end
#input of string(split by space)
def get()
  return gets.chomp.split(" ")
end
#input of string(split per one character)
def get_nsp()
  return gets.chomp.split("")
end
#yes or no decision
def yn_judge(bool,y="Yes",n="No")
  return bool ? y : n 
end
#create of array
def array(size1,init=nil,size2=-1)
  if size2==-1
    return Array.new(size1){init}
  else
    return Array.new(size2){Array.new(size1){init}}
  end
end

def max(a,b)
    return a>b ? a : b
end

def min(a,b)
    return a>b ? b : a
end

INF=Float::INFINITY

S=gets.chomp
if S=~/^.*C.*F.*$/
    puts "Yes"
else
    puts "No"
end

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

int main() {
	int a, b;
	cin >> a >> b;
	int res = 0;
	int in = min(a, b);
	int ax = max(a, b);
	res += ax;
	ax--;
	res += max(in, ax);
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 3528
r,g,b,n = map(int,input().split())

res = 0
v = 0
for i in range(n//r+1):
    for j in range(n//g+1):
        v = n-(i*r+j*g)
        #print('r,g,b=',i,j,v)
        if 0 <= v and v % b == 0:
            res += 1
        if v<0:break
print(res)

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

int main() {
    int N; cin >> N;
    vector<int> l(N);
    for (int i = 0; i < N; i++) {
        cin >> l[i];
    } 
    int ans = INF;
    int tmp;
    for (int i = -100; i <= 100; i++) {
        tmp = 0;
        for (int j = 0; j < N; j++) {
            tmp += (i - l[j]) * (i - l[j]);
        }
        ans = min(ans, tmp);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
pub fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

pub fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

pub fn read_vec2<T: std::str::FromStr>(n: usize) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

pub fn read_col<T: std::str::FromStr>(n: usize) -> Vec<T> {
    (0..n).map(|_| read()).collect()
}

const R: u64 = 1000000007;

fn pow(a: u64, r: u64) -> u64 {
    if r == 0 {
        return 1;
    }
    let tmp = pow(a, r / 2);
    let mut ans = (tmp * tmp) % R;
    if r % 2 == 1 {
        ans = (ans * a) % R;
    }
    ans
}

fn main() {
    let xy: Vec<usize> = read_vec();
    let x = xy[0];
    let y = xy[1];
    if (x + y) % 3 != 0 || 2 * x < y || 2 * y < x {
        println!("0");
        return;
    }
    let n = (x + y) / 3;
    let r = 2 * n - x;
    let mut fact: Vec<u64> = vec![1; n + 1];
    for i in 1..n + 1 {
        fact[i] = (i as u64 * fact[i - 1]) % R;
    }
    let t1 = pow(fact[r], R - 2);
    let t2 = pow(fact[n - r], R - 2);
    let ans = (((fact[n] * t1) % R) * t2) % R;
    println!("{}", ans);
}


Measured memory_bytes: 10492
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
int main(){
  int k,a,b;
  cin >> k >> a >> b;
  if(b / k - (a - 1) / k > 0)cout << "OK" << endl;
  else cout << "NG" << endl;
  return 0;
}

Measured memory_bytes: 3636
// https://atcoder.jp/contests/agc006/tasks/agc006_b

#include <algorithm>
#include <iostream>
#include <list>
#include <numeric>
#include <vector>
using namespace std;

int main() {
    int n, x, len;
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> x;
    len = 2 * n - 1;
    list<int> ls(len);
    iota(ls.begin(), ls.end(), 1);
    if (n >= 3) {
        ls.remove(x - 1);
        ls.remove(x);
        ls.remove(x + 1);
        auto itr = ls.begin();
        advance(itr, n - 2);
        ls.insert(itr, x - 1);
        ls.insert(itr, x);
        ls.insert(itr, x + 1);
    }

    if (x == 1 || x == len) {
        cout << "No\n";
    } else {
        cout << "Yes\n";
        for (auto i : ls) {
            cout << i << '\n';
        }
    }

    return 0;
}


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



int main(){
        int n, k,max,temp,num,total;
        while(true) {  //ベクターに格納
                cin >> n>>k;
                if(n==k!=0){
                  break;
                }
                vector<double> v;
                total=0;
                v.push_back(total);
                for(int i=0;i<n;i++){
                  cin>>num; //入力をnumに代入
                  total+=num;
                  v.push_back(total); //ベクターvにプッシュ
                }

                max=0;
                temp=0;
                for(int i=0; i+k<=n; i++) {
                        temp=v[i+k]-v[i];
                        if(temp>max) max=temp; //tempが最も大きい数値ならmaxを更新
                        temp=0; //tempの初帰化
                }
                cout<<max<<endl;
        }
}


Measured memory_bytes: 3932
#include <iostream>

using namespace std;

int main(){
    int n;
    char a[100];
    cin>>n;
    for(int i=0; i<n; ++i) cin>>a[i];
    if(n%2) cout<<"No";
    else{
        for(int i=0; i<n/2; ++i){
            if(a[i]!=a[n/2+i]){
                cout<<"No";
                return 0;
            }
        }
        cout<<"Yes";
    }
    return 0;
}

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

int main(void){
  vector<int>hight;
  int a[10];
 for(int i=0;i<10;i++)
   cin>>a[i];

  for(int i=0;i<10;i++)
    hight.push_back(a[i]);

  sort(hight.begin(),hight.end());

  vector<int>::iterator it = hight.end()-1;

  for(int i=0;i<3;i++){
    cout<<*it<<endl;
    it--;
  }

  return 0;
}

Measured memory_bytes: 0
while True:
	h,w=map(int,input().split())
	if h==w==0:break
	for hh in range(h):
		ol=''
		for ww in range(w):
			if hh == h - 1 and ww == w - 1:
				ol+='#\n'
			elif hh == 0 or ww == 0 or hh == h - 1 or ww == w - 1:
				ol+='#'
			else:
				ol+='.'
		print(ol)

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

using namespace std;

int main()
{
    int x1, y1, x2, y2; cin >> x1 >> y1 >> x2 >> y2;
    cout << x2 - y2 + y1 << " " << y2 + x2 - x1 << " " << x1 - y2 + y1 << " " << y1 + x2 - x1 << endl;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
char s[210][210];
int bcj[210];
void init(){
    for(int i=0;i<210;i++) bcj[i]=i;
}
int findf(int x){
    if(x==bcj[x]) return x;
    return bcj[x]=findf(bcj[x]);
}
void uni(int x,int y){
    x=findf(x);y=findf(y);bcj[x]=y;
}
bool vis[210];
int col[210];
bool succ=true; int n;
void dfs(int now){
    vis[now]=1;
    for(int i=1;i<=n;i++){
        if(s[now][i]=='0') continue;
        if(vis[i]){
            if(col[i]==col[now]) succ=false;
        }else{
            col[i]=1-col[now];
            dfs(i);
        }
    }
}
int main(){
   scanf("%d",&n);
    for(int i=1;i<=n;i++) scanf("%s",s[i]+1);

    for(int i=1;i<=n;i++) {memset(vis,0,sizeof(vis));dfs(i);}
    if(!succ) return 0*puts("-1");
    int ans=0;
    for(int i=1;i<=n;i++){
        queue<pair<int,int> > q;
        memset(vis,0,sizeof(vis));
        vis[i]=1;
        q.push(make_pair(i,1));
        while(!q.empty()){

            int now=q.front().first;int dis=q.front().second;
            q.pop();
            ans=max(ans,dis);
            for(int j=1;j<=n;j++){
                if(s[now][j]=='1'){
                    if(!vis[j]){
                        vis[j]=1;
                        q.push(make_pair(j,dis+1));
                    }
                }
            }
        }
    }
    cout<<ans<<endl;

    return 0;
}


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

const int64_t MOD=pow(10,9)+7;

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

  vector<int64_t> A(N);
  for(int i=0;i<N;++i){
    cin>>A.at(i);
  }

  int64_t sum=0;

  for(int n=0;n<60;++n){
    int64_t sub_sum1=0;
    
    for(int i=0;i<N;++i){
      bitset<60> s(A.at(i));
      if(s.test(n)){++sub_sum1;}
    }
    
    int64_t aux1=sub_sum1*(N-sub_sum1)%MOD;
    int64_t aux2=int64_t(pow(2,n))%MOD;
    sum=(sum+aux1*aux2)%MOD;
  }

  cout<<sum<<endl;
}

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

multiset<pair<int,int>  > s;
int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int n;
    cin>>n;
    for (int i=0;i<n;i++){
        int a,b;
        cin>>a>>b;
        s.insert({b, a});
    }
    int T=0;
    while(!s.empty()){
        auto p = *s.begin();
        s.erase(s.begin());
        int deadline = p.first - p.second;
        int len = p.second;
        if (deadline<T){
            cout<<"No"<<endl;
            return 0;
        }
        T+=len;
    }
    cout<<"Yes"<<endl;
}

Measured memory_bytes: 9600
n = int(input())
H = list(map(int, input().split()))

i = -1
for _ in range(n - 1):
    if H[i - 1] - H[i] > 1:
        ans = "No"
        print(ans)
        exit()
    elif H[i - 1] - H[i] == 1:
        H[i - 1] -= 1
    i -= 1

ans = "Yes"
print(ans)


Measured memory_bytes: 14396
def main():
    n = int(input())
    card = {}
    for _ in range(n):
        s = input()
        if s in card:
            card[s] += 1
        else:
            card[s] = 1
    m = int(input())
    for _ in range(m):
        t = input()
        if t in card:
            card[t] -= 1
        else:
            card[t] = -1
    card = sorted(card.items(), key=lambda x: x[1], reverse=True)
    print(max(card[0][1], 0))


if __name__ == '__main__':
    main()



Measured memory_bytes: 3064
#include <iostream>


using namespace std;


int main() 
{
    int a, b, c;
    cin >> a >> b >> c;
    if(a <= b && b <= c)
        cout << a << " " << b << " " << c << endl;
    else if(a <= c && c <= b)
        cout << a << " " << c << " " << b << endl;
    else if(b <= c && c <= a)
        cout << b << " " << c << " " << a << endl;
    else if(b <= a && a <= c)
        cout << b << " " << a << " " << c << endl;
    else if(c <= b && b <= a)
        cout << c << " " << b << " " << a << endl;
    else if(c <= a && a <= b)
        cout << c << " " << a << " " << b << endl;
}






Measured memory_bytes: 3104
#include<bits/stdc++.h>
#define inf 0x7fffffff
#define RG register
#define maxn 1000005
#define maxm 205
using namespace std;
typedef long long ll;
const ll mod = 1e9 + 7;
inline ll read(){
    ll x = 0, f = 1;
    char ch = getchar();
    while(ch > '9' || ch < '0') {if(ch == '-') f = -1;ch = getchar();}
    while(ch >= '0' && ch <= '9'){x = x *10 + ch -'0';ch = getchar();}
    return x * f;
}
 
int n, m, k,sum;
char s[1005][1005];
int vis[1005][1005], cnt, X[4] = {0, 0, 1, -1}, Y[4] = {1, -1, 0, 0};
bool isb[1005][1005];
pair<int,int> Q[1000005];
int H,T;
void bfs(int x,int y){
	int i,xx,yy;
	H = T = 0;
	Q[H]={x,y};
	while(H<=T){
		x = Q[H].first, y = Q[H].second;
		++H;
		vis[x][y] = cnt;
		for(i = 0;i <4;i++){
			xx = x + X[i], yy = y + Y[i];
			if(xx > n || xx < 1) continue;
			if(yy > m || yy < 1) continue;
			if(vis[xx][yy]) continue;
			if(s[xx][yy]=='#') continue;
			vis[xx][yy] = cnt;
			Q[++T] = {xx,yy};
		}
	}
}
int inde[2000005], tot;
struct p{
	int u,v,w,nxt;
}e[20000005];
map<pair<int,int>, int> mp;
void add(int u,int v,int w){e[++tot]=(p){u,v,w,inde[u]},inde[u] = tot;}
void ins(int x,int y){
	int u,v;
	for(int i = 0;i <= 2;i++){
		for(int j = -2;j <= 2;j++){
			int xx = x + i, yy = y + j;
			if(xx > n || xx < 1) continue;
			if(yy > m || yy < 1) continue;
			if(s[xx][yy]=='#') continue;
			if(vis[x][y] == vis[xx][yy]) continue;
			u = vis[x][y], v= vis[xx][yy];
			add(u,v,1),add(v,u,1);
		}
	}
}
bool inst[2000005];
int dis[2000005],cx,cy,dx,dy;
struct node
{
    int w,now;
    inline bool operator <(const node &x)const
    {
        return w>x.w;
    }
};
priority_queue<node>que;
void dij(int u){
	for(int i = 1;i <=cnt;i++)dis[i] = 0x3f3f3f3f;
	dis[u] = 0;
	int i,v;
	que.push(node{0,u});
	while(!que.empty()){
		node x = que.top();
		que.pop();
		u = x.now;
		if(inst[u]) continue;
		if(u == vis[dx][dy]) break;
		inst[u] = 1;
		for(i=inde[u];i;i=e[i].nxt){
			v = e[i].v;
			if(dis[v] > dis[u] + e[i].w){
				dis[v] = dis[u] + e[i].w;
				que.push(node{dis[v],v});
			}
		}
	}
}
int main(){
	int i, j, x;
	n =read(), m = read();
	cx=read(),cy=read(),dx=read(),dy=read();
	for(i = 1;i <= n;i++) scanf("%s", s[i] + 1);
	for(i = 1;i <= n;i++){
		for(j = 1;j <= m;j++){
			if(s[i][j] == '#') continue;
			if(i == 1 || i == n || j == 1 || j == m || s[i -1][j] == '#'|| s[i][j - 1] == '#'|| s[i][j + 1] == '#'|| s[i+1][j] == '#')
				isb[i][j] = 1;
			if(vis[i][j]) continue;
			cnt ++;
			bfs(i,j);
		}
	}
	for(i = 1;i <= n;i++){
		for(j = 1;j <= m;j++){
			if(s[i][j]=='#') continue;
			if(isb[i][j]) ins(i,j);
		}
	}
	dij(vis[cx][cy]);
	if(dis[vis[dx][dy]] == 0x3f3f3f3f) puts("-1");
	else printf("%d\n",dis[vis[dx][dy]]);
	return 0;
}

Measured memory_bytes: 41540
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
int main() {
    // ifstream in("data1.txt");
    // cin.rdbuf(in.rdbuf());
    int N;
    cin >> N;
    vector<int> v(N);
    int sum = 0;
    rep(i, N) {
        cin >> v[i];
        sum += v[i];
    }
    sort(v.begin(), v.end());

    cout << v[N - 1] / 2 + sum - v[N - 1] << endl;
}


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

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

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

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

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

int getgroup(int x){

  if(x == 2){
    return 2;
  }else if(x == 4 || x == 6 || x == 9 || x == 11){
    return 1;
  }else{
    return 0;
  }
}

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

  int x, y;
  cin >> x >> y;
  if(getgroup(x) == getgroup(y)){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		int a[][] = new int[M][2];
		//int b[] = new int[M];
		for(int i = 0; i < M; i++) {
			a[i][0] = sc.nextInt();
			a[i][1] = sc.nextInt();
		}
		Arrays.sort(a, Comparator.comparingInt(o -> o[1]));
		
		int temp_a = a[0][0];
		int temp_b = a[0][1];
		int ans_cnt = 1;
		for(int i = 0; i < M; i++) {
			if(temp_a != a[i][0] && temp_b <= a[i][0]) {
				temp_a = a[i][0];
				temp_b = a[i][1];
				ans_cnt++;
			} else {
				temp_b = Math.min(temp_b, a[i][1]);
			}
		}
		
		System.out.println(ans_cnt);
	}
}


Measured memory_bytes: 94808
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		for (int i2 = 0; i2 <= 14; i2++) {
			for (int i1 = 0; i1 <= 25; i1++) {
				if (N == (4 * i1 + 7 * i2)) {
					System.out.println("Yes");
					return;
				}
			}
		}
		System.out.println("No");
		return;
	}
}

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

char S[112345];
int ans[2] = { 0 };

int main(void) {
	while (true) {
		memset(S, '\0', sizeof(S));
		ans[0] = 0, ans[1] = 0;
		scanf("%s", &S);
		if (S[0] == '\0') { break; }

		for (int i = 0; i < strlen(S) - 2; ++i) {
			if (S[i] == 'J'&&S[i + 1] == 'O'&&S[i + 2] == 'I') { ++ans[0]; }
			if (S[i] == 'I'&&S[i + 1] == 'O'&&S[i + 2] == 'I') { ++ans[1]; }
		}

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

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

m = n
lsn = []
d = 0
while m > 0:
    lsn.append(m%10)
    m //= 10
    d += 1
lsn.reverse()

ans = 0
for i in range(1, n+1):
    ls = []
    while i > 0:
        ls.append(i%10)
        i //= 10
    
    sentou = ls[0]
    matsubi = ls[len(ls)-1]

    if sentou == 0 or matsubi == 0:
        continue

    for j in range(1, d+1):
        if j == 1:
            if sentou == matsubi:
                ans += 1
        elif j < d:
            ans += 10**(j-2)
        else:
            dp = [[0 for k in range(2)] for l in range(d+1)]
            dp[0][0] = 1

            for k in range(d):
                for l in range(2):
                    if k == 0:
                        if l == 1 or sentou < lsn[0]:
                            dp[k+1][1] += dp[k][l]
                        elif sentou <= lsn[0]:
                            dp[k+1][0] += dp[k][l]
                    elif k == d-1:
                        if l == 1 or matsubi < lsn[d-1]:
                            dp[k+1][1] += dp[k][l]
                        elif matsubi <= lsn[d-1]:
                            dp[k+1][0] += dp[k][l]
                    else:
                        lim = lsn[k]
                        if l == 1:
                            lim = 9
                        for o in range(lim+1):
                            if l == 1 or o < lsn[k]:
                                dp[k+1][1] += dp[k][l]
                            elif o <= lsn[k]:
                                dp[k+1][0] += dp[k][l]
            
            ans += dp[d][0]+dp[d][1]

print(ans)

Measured memory_bytes: 48720
/// Bismillahir Rahmanir Rahim
//Author: Tanvir Hussain
//ICE,NSTU
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

using namespace std;

const long long MOD = 1000000007;
#define SET(x) memset(x, 0, sizeof(x))
#define SET2d(x,m,n) memset(x, 0, sizeof(x[0][0]) * m * n)
#define SETBOOL(x) memset(x,false,sizeof(x))
#define CLR(x) memset(x, -1, sizeof(x))
#define mp make_pair
#define PII pair<int, int>
#define pf printf

#define sf scanf

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

#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define np std::string::npos
#define for0(i,n) for(int i=0;i<n;i++)
#define forn(i,n) for(int i=n-1;i>=0;i--)
#define highest(x) numeric_limits<x>::max()
#define lowest(x) numeric_limits<x>::min()
#define Inf INFINITY
#define minv(v) *min_element(v.begin(),v.end())
#define maxv(v) *max_element(v.begin(),v.end())
#define cases(cs,t) for(int cs=1;cs<=t;cs++)
#define PI acos(-1)
#define no1 __builtin_popcount
#define BOUNDARY(i, j) ((i >= 0 && i < row) && (j >= 0 && j < column))
#define uniq(vec) vec.resize(distance(vec.begin(),unique(vec.begin(),vec.end())))
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
typedef long long ll;
typedef tree<pair<int, int>,null_type,less<pair<int, int>>,rb_tree_tag,tree_order_statistics_node_update> ordered_multiset;
int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1};
int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1};
int dx4[] = {0, 0, 1, -1};
int dy4[] = {1, -1, 0, 0};
const int maxx=100005;

//this fuction sorts vector pair according to first element in descending order.
bool sortinrev(const pair<int,int> &a,const pair<int,int> &b)
{
    return a.first>b.first;
}

template<typename T>inline T Bigmod(T base, T power, T MOD){
    T ret=1;
    while(power)
    {
        if(power & 1)ret=(ret*base)%MOD;
        base=(base*base)%MOD;
        power>>=1;
    }
    return ret;
}
double sq(double x) {return x*x;}
int ext_gcd(int a, int b, int & x, int & y) {
    //for finding modular inverse
    //if its return 1 ,then a has a mod inverse x mod b.
    if (a == 0) {
        x = 0;
        y = 1;
        return b;
    }
    int x1, y1;
    int d = ext_gcd(b % a, a, x1, y1);
    x = y1 - (b / a) * x1;
    y = x1;
    return d;
}

int main()

{
    IOS;
    //freopen("input.txt", "r", stdin);
     //freopen("output.txt", "w", stdout);
     int n;
     while(cin>>n){
        ll arr[n];
        map<ll,ll>mm;
        for(int i=0;i<n;i++){
            cin>>arr[i];
            mm[arr[i]]++;
        }
        ll ans=0;
        for(auto it:mm){
            ll val=it.second;
            ans+=((val*(val-1))/2);
        }
        for(int i=0;i<n;i++){
            cout<<ans-mm[arr[i]]+1<<endl;
        }
     }

     return 0;

}
///Alhamdulillah


Measured memory_bytes: 11136
#include<bits/stdc++.h>
using namespace std;
string s[10],a,b;

int main()
{
	cin>>a;
	s[0]+="Sunny";
	s[1]+="Cloudy";
	s[2]+="Rainy";
	if(a==s[0]) cout<<s[1];
	if(a==s[1]) cout<<s[2];
	if(a==s[2]) cout<<s[0];
	
	return 0;
}

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

int main(){
  int N;
  cin >> N;
  pair<pair<string, int>, int> p[N];
  for(int i=0;i<N;i++){
    string S;
    int b;
    cin >> S >> b;
    b *= -1;
    p[i].first.first = S;
    p[i].first.second = b;
    p[i].second = i+1;
  }
  sort(p,p+N);
  for(int i=0;i<N;i++){
    cout << p[i].second << endl;
  }
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

template <typename T>
void print(T x) {
    cout << x << "\n";
}

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REVFOR(i, m, n) for (int i = (n - 1); i >= (m); --i)
#define REP(i, n) FOR(i, 0, n)
#define REVREP(i, n) REVFOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

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

    int n;
    cin >> n;

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

    sort(ALL(a), greater<>());

    ll s1 = 0, s2 = 0;

    REP(i, a.size()) {
        if (i & 1) s1 += a[i];
        else s2 += a[i];
    }

    print(s2 - s1);

}

Measured memory_bytes: 3660
#整数の入力
N = int(input())
#スペース区切りの整数の入力
A, B = map(int, input().split())

a = int(A/N)
b = int(B/N)

if(b>a):
  print("OK")
elif(((B%N)==0)or((A%N)==0)):
  print("OK")
elif((b==0)or(a==0)):
  print("NG")
else:
  print("NG")


Measured memory_bytes: 9184
#include <bits/stdc++.h>
// iostream is too mainstream
#include <cstdio>
// bitch please
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <cmath>
#include <iomanip>
#include <time.h>
#define dibs reserve
#define OVER9000 1234567890
#define ALL_THE(CAKE,LIE) for(auto LIE =CAKE.begin(); LIE != CAKE.end(); LIE++)
#define tisic 47
#define soclose 1e-8
#define chocolate win
// so much chocolate
#define patkan 9
#define ff first
#define ss second
#define abs(x) ((x < 0)?-(x):x)
#define uint unsigned int
#define dbl long double
#define pi 3.14159265358979323846
using namespace std;
// mylittledoge

#ifdef DONLINE_JUDGE
	// palindromic tree is better than splay tree!
	#define lld I64d
#endif

long long pw(long long a, long long e, long long mod) {
	if(e <= 0) return 1;
	long long x =pw(a,e/2,mod);
	x =(x*x)%mod;
	if(e%2 != 0) x =(x*a)%mod;
	return x;}

int main() {
	cin.sync_with_stdio(0);
	cin.tie(0);
	cout << fixed << setprecision(10);
	int N,K;
	cin >> N >> K;
	if(K == 1) {cout << "1\n"; return 0;}
	long long mod =1000000007;
	vector<long long> fac(N*K+tisic,1),inv(N*K+tisic,0);
	for(int i =1; i <= N*K; i++) fac[i] =(i*fac[i-1])%mod;
	inv[0] =inv[1] =1;
	for(int i =2; i <= N*K; i++) if(inv[i] == 0) {
		inv[i] =pw(i,mod-2,mod);
		for(int j =2; j <= (N*K)/i; j++) inv[i*j] =(inv[i]*inv[j])%mod;}
	for(int i =2; i <= N*K; i++) inv[i] =(inv[i]*inv[i-1])%mod;
	vector< vector<long long> > P(N+1,vector<long long>(N+1,0));
	P[1][1] =1;
	vector<long long> S(N+2,0);
	for(int i =2; i <= N; i++) {
		for(int j =N; j >= 0; j--) S[j] =(S[j+1]+P[i-1][j])%mod;
		for(int j =1; j <= i; j++) {
			if(i*K-j-1 < K-2) break; 
			P[i][j] =(S[j-1]*fac[i*K-j-1])%mod;
			P[i][j] =(P[i][j]*inv[K-2])%mod;
			P[i][j] =(P[i][j]*inv[(i-1)*K-j+1])%mod;}
		}
	long long ansF =0;
	for(int i =1; i <= N; i++) ansF =(ansF+P[N][i])%mod;
	ansF =(ansF*fac[N])%mod;
	if(ansF < 0) ansF +=mod;
	cout << ansF << "\n";
	return 0;}

// look at my code
// my code is amazing


Measured memory_bytes: 94080
#include <iostream>
#include <string>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cmath>
#include <array>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include <cstdint>
#include <unordered_set>
typedef long long int llint;

int main(void){
  int n, m;
  std::cin >> n >> m;

  std::vector<bool> aced(n);
  std::vector<int> num_wa(n, 0);

  for(int i=0; i<m; i++){
    int p;
    std::string s;
    std::cin >> p >> s;
    p--;
    if(s == "WA" && aced[p]==false) num_wa[p]++;
    if(s == "AC") aced[p]=true;
  }

  int total_ac = 0;
  int total_wa = 0;
  for(int i=0; i<n; i++){
    if(aced[i]){
      total_ac++;
      total_wa += num_wa[i];
    }
  }
  std::cout << total_ac << " " << total_wa << std::endl;

  return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int N, h[22];
int main(){
	cin>>N;
	for(int i = 1;i <= N; i++)cin>>h[i];
	int ans = 1;
	for(int i = 2;i <= N; i++){
		int flag = 1;
		for(int j = i - 1;j >= 1; j--){
			if(h[j] > h[i]){
				flag = 0;
				break;
			}
		}
		ans += flag;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
using ll = long long;
using P = pair<int, int>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define F first
#define S second
typedef vector<ll> vi;
const int MOD = 1000000007;
template<class T> void print(const T& t){ cout << t << endl; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
  ll a, b;
  cin >> a >> b;
  if(a%3==0||b%3==0||(a+b)%3==0){
    print("Possible");
  }
  else{
    print("Impossible");
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
using namespace std;

int main(){
  int n;
  string ans="";
  cin >> n;
  vector<string> s(n);
  vector<int> c(n,0);
  char abc[26] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};
  rep(i, n){
    cin >> s.at(i);
    sort(all(s.at(i)));
  }
  rep(i, 26){
    rep(j, n){
      rep(k, s.at(j).size())if(s.at(j)[k] == abc[i])c.at(j)++;
    }
    rep(j, *min_element(all(c)))ans+=abc[i];
    rep(j, n) c.at(j)=0;
  }
  cout << ans;
}

Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
l=[]
for i in range(n):
  if i==0:
    l.append(0)
  elif i==1:
    l.append(abs(a[0]-a[i]))
  else:
    l.append(min(l[i-1]+abs(a[i]-a[i-1]),l[i-2]+abs(a[i]-a[i-2])))
print(l[-1])

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

class Program {
    static void Main(string[] args) {
        int n = int.Parse(Console.ReadLine());
        var a = Console.ReadLine().Trim().Split(' ').Select(x => int.Parse(x)).ToArray();
        Array.Sort(a);
        Array.Reverse(a);
        int count = 0;
        for (int i = 0; i < n; i++) {
            if (i % 2 == 0) {
                count += a[i];
            } else {
                count = count - a[i];
            }
        }
        Console.WriteLine(count);
    }
}

Measured memory_bytes: 13396
#include <iostream>
using namespace std;
int main(){
  int d;
  cin>>d;
  switch(d){
    case 25:
      cout<<"Christmas";
      break;
    case 24:
      cout<<"Christmas Eve";
      break;
    case 23:
      cout<<"Christmas Eve Eve";
      break;
      case 22:
          cout<<"Christmas Eve Eve Eve";
          break;
  }
  return 0;}


Measured memory_bytes: 256