akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<bits/stdc++.h>
#include<set>
#define ll long long
using namespace std;
int main()
{
    int n,k;
    cin>>n>>k;
    set<int>s;
    for(ll i=1;i<=k;i++)
    {
        int d;
        cin>>d;
        while(d)
        {
            ll t;
            cin>>t;
            s.insert(t);
            d--;
        }
    }
    cout<<n-s.size()<<endl;
     return 0;
}

Measured memory_bytes: 3576
#include<iostream>
#include<vector>
using namespace std;
int main(){
    string o,e;
    cin>>o>>e;
    for(int i=0;i<o.size();i++)
    {
        cout<<o[i];
        if(i<e.size()){
            cout<<e[i];
        }
    }
    if(o.size()<e.size()){
        cout<<e[e.size()-1];
    }
}

Measured memory_bytes: 3628
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>

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

typedef int long long ll;
using namespace std;
typedef pair<int, int> P;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const ll MOD = 1e9 + 7;
static const int MAX = 100;
static const int INF = (1 << 23);

string change(string s){
    string ret;
    int i=0;
    while(i<s.size()) {
        if (s[i] == '\"'){
            i++;
            while(i<s.size()&&s[i]!='\"'){
                i++;
            }
            ret+='\"';
            i++;
    }else{
            ret+=s[i];
            i++;
        }
    }
    return ret;
}
vector<string> nuke(string s){
    vector<string> res;
    int i=0;
    while(i<s.size()) {
        if (s[i] == '\"'){
            string ret;
            i++;
            while(i<s.size()&&s[i]!='\"'){
                ret+=s[i];
                i++;
            }
            res.push_back(ret);
            i++;
        }else{
            i++;
        }
    }
    return res;
}
int main() {
    string s1,s2;
    while(true){
        cin>>s1;
        if(s1[0]=='.'&&s1.size()==1)break;
        cin>>s2;

        vector<string> d1;
        vector<string> d2;
        string ss1=change(s1);
        string ss2=change(s2);
        d1=nuke(s1);
        d2=nuke(s2);
        if(s1==s2){
            cout<<"IDENTICAL"<<endl;
        }else if(ss1!=ss2) {
            cout<<"DIFFERENT"<<endl;
        }else{
                vector<string> d3;
                vector<string> d4;
                if(d1.size()>d2.size()){
                    d3=d1;
                    d4=d2;
                }else{
                    d3=d2;
                    d4=d1;
                }
                if(d3.size()-d2.size()>=2){
                    cout<<"DIFFERENT"<<endl;
                }else {
                    int c=0;
                if(d3.size()==d4.size()){
                    rep(i,d3.size()){
                        if(d3[i]!=d4[i])c++;
                    }
                    if(c==1){
                        cout<<"CLOSE"<<endl;
                    }else{
                        cout<<"DIFFERENT"<<endl;
                    }
                }else{
                    for(int i=0;i<d3.size();i++){
                        int d=0;
                        while(d<d4.size()){
                            if(i!=d){
                                if(d3[i]!=d4[d])c++;
                                d++;
                            }else{
                            }
                        }
                        if(c==0){
                            cout<<"CLOSE"<<endl;
                        }else{
                            cout<<"DIFFERENT"<<endl;
                        }
                    }



                }

            }
        }

    }


    return 0;
}



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

int main() {
  string s; cin >> s;
  int a=0,b=0,c=0;
  for(int i = 0;i < (int)s.size();i++) {
    if(s[i] == 'a') { a++; }
    else if(s[i] == 'b') { b++; }
    else if(s[i] == 'c') { c++; }
  }

  if( abs(a-b)<=1 && abs(b-c)<=1 && abs(c-a)<=1 ) { cout << "YES\n"; }
  else { cout << "NO\n"; }

  return 0;
}

Measured memory_bytes: 3724
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 2e3 + 5, mod = 1e9 + 7, inf = 0x3f3f3f3f;
ll dp[maxn][maxn];
int a[maxn], b[maxn];
ll ps[maxn], pt[maxn];;
int main()
{
    ios::sync_with_stdio(0); cin.tie(0);
    int n, l;
    cin >> n >> l;
    int mint = inf, sum = 0;
    for (int i = 1; i <= n; ++i){
        sum += l + i - 1;
        if (abs(l + i - 1) < abs(mint)) mint = l + i - 1;
    }
    cout << sum - mint << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>//Carefully Crafted by hetp111
using namespace std;
#define int long long
#define double long double
#define all(v) (v).begin(),(v).end()
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int,int>
#define vii vector<pii>
#define MOD 1000000007
#define MOD2 998244353
#define MOD3 1000000009
#define PI acos(-1)
#define eps (1e-8)
#define INF (1e18)
#define FASTER ios_base::sync_with_stdio(0);cin.tie(0)
template<class A,class B>ostream&operator<<(ostream&out,const pair<A,B>&a){return out<<"("<<a.first<<","<<a.second<<")";}
template<class A>ostream&operator<<(ostream&out,const vector<A>&a){for(const A &it:a)out<<it<<" ";return out;}
template<class A,class B>istream&operator>>(istream&in,pair<A,B>&a){return in>>a.first>>a.second;}
template<class A>istream&operator>>(istream&in,vector<A>&a){for(A &i:a)in>>i;return in;}
ifstream cinn("ride.in");ofstream coutt("ride.out");
int poww(const int &a,int b,const int &m=MOD){if(b==0)return 1;int x=poww(a,b/2,m);x=x*x%m;if(b&1)x=x*a%m;return x;}
int ceil(const int &a,const int &b){return (a+b-1)/b;}
////Read:
//Check corner cases, n==1;
//
////Some function:
//__builtin_popcountll(), 

int n,nC;
vi adj[200001];
map<pii,int> mp;

void dfs(int cur,int par,int last){
    
    int k=0;
    vi col(nC);
    for(int i=1;i<=nC;i++)col[i-1]=i;
    for(int ch:adj[cur]){
        if(ch==par)continue;
        if(col[k]==last)swap(col[k],col[k+1]);
        mp[{ch,cur}]=col[k];
        mp[{cur,ch}]=col[k];
        dfs(ch,cur,col[k]);
        k++;
    }
}

signed main(){
    FASTER;
    cin>>n;
    vii v;
    for(int i=1;i<n;i++){
        int a,b;cin>>a>>b;
        v.push_back({a,b});
        adj[a].push_back(b);
        adj[b].push_back(a);
    }
    int st=-1;
    for(int i=1;i<=n;i++){
        if(nC<adj[i].size()){
            nC=adj[i].size();
            st=i;
        }
    }
    dfs(st,-1,-1);
    cout<<nC<<"\n";
    for(pii i:v){
        cout<<mp[{i.first,i.second}]<<"\n";
    }
}

Measured memory_bytes: 29744
#include<bits/stdc++.h>
#define fo(i,a,b) for((i)=(a);i<=(b);i++)
#define rfo(i,a,b) for((i)=(a);i>=(b);i--)
#define inrange(x,y,z) (((x)>=(y))&&((x)<=(z)))
#define ALL(vec) ((vec).begin(),(vec).end())
#define SOR(vec) sort(ALL(vec))
#define UNI(vec) (vec).erase(unique(ALL(vec)),(vec).end())
using namespace std;
long long inv[200100],fac[200100],ifac[200100],MOD=998244353,res,m,cu;
int n,k;
void init_math(int N){
	//initialize math
	//define MOD first!
	inv[1]=1LL;
	for(int i=2;i<=N;i++)
		inv[i]=(MOD-((MOD/i)*inv[MOD%i])%MOD);
	fac[0]=1LL;
	ifac[0]=1LL;
	for(int i=1;i<=N;i++){
		fac[i]=(fac[i-1]*(long long)(i))%MOD;
		ifac[i]=(ifac[i-1]*inv[i])%MOD;
	}
}
long long C(int x,int y){
	//answer of xCy
	return ((fac[x]*ifac[y])%MOD*ifac[x-y])%MOD;
}
long long D(int x,int y){
	//divide length of x into y parts
	return C(x-1,y-1);
}
int main(){
	#ifdef FILIN
		#ifndef DavidDesktop
			freopen(FILIN,"r",stdin);
			freopen(FILOUT,"w",stdout);
		#endif
	#endif
	ios::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>n>>m>>k;
	k=n-k;
	res=0LL;
	cu=1LL;
	init_math(n);
	for(int i=1;i<=k;i++){
		if(i==1) cu=cu*m%MOD;
		else cu=cu*(m-1LL)%MOD;
	}
	for(int i=k;i<=n;i++){
		res=(res+D(n,i)*cu%MOD)%MOD;
		cu=(cu*(m-1LL))%MOD;
	}
	cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 8340
#include <stdio.h>
#include <stdlib.h>
typedef long long ll;

int comp(const void *a, const void *b) {
  return *(ll*)b - *(ll*)a;
}

int main(void) {
  ll n, i, j, k;
  while( 1 ) {
    ll sum = 0, cnt, p, ans = 0;
    scanf("%lld", &n);
    if(!n) break;
    cnt = n;
    ll j[n - 1];
    for(i = 0; i < n; ++i) {
      scanf("%lld", &p);
      sum += p;
    }
    for(i = 0; i < n - 1; ++i) scanf("%lld", &j[i]);
    qsort(j, n - 1, sizeof(ll), comp);
    for(i = 0; i < n - 1; ++i) {
      if(ans < sum * cnt) ans = sum * cnt;
      sum += j[i];
      cnt--;
    }
    if(ans < sum) ans = sum;
    printf("%lld\n", ans);
  }
  return 0;
}


Measured memory_bytes: 3336
#include<bits/stdc++.h>
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int mod = 1000000007;

int main() {
  int l, r, d;
  cin >> l >> r >> d;
  int ans = 0;
  for (int i = l; i <= r; ++i) {
    if (i % d == 0) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3596
#include<iostream>
#include<math.h>
using namespace std;

int main() {
	int a;
	int i;
	cin >> a;
	for (i = 1; i <= a; i++) {
		if ((int)pow(2, i) > a) { break; }
	}
	printf("%d", (int)pow(2,i-1));
	system("pause");
	return 0;
}

Measured memory_bytes: 512
#include <cstdio>
#include <climits>
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <stack>
#include <algorithm>
#include <iomanip>
#include <map>
#include <queue>
#include <functional>
#include <numeric>
#include <chrono>
#include <cstdlib>
using ll = long long;
using namespace std;

const ll MOD = 1e9 + 7;
const double pi = acos(-1);
typedef pair<int, int> P;
#define REP(i, n) for (int(i) = 0; (i) < (n); ++(i))
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
#define EPS 1e-4
#define OUTPUT(i) (cout << (ll)i << endl)
#define ALL(a) ((a).begin(), (a).end())

bool operator<(const pair<ll, ll> &a, const pair<ll, ll> &b)
{

    if (a.first == b.first)
        return a.second < b.second;

    return a.first < b.first;
}

ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
vector<ll> v;

int tab1[26];
int tab2[26];
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    //cout << fixed << setprecision(15);

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

    int n = s.size();

    for (int i = 0; i < 26; ++i)
    {
        tab1[i] = -1;
        tab2[i] = -1;
    }
    bool f = true;

    for (int i = 0; i < n; ++i)
    {
        if (tab1[s[i] - 'a'] == -1)
            tab1[s[i] - 'a'] = t[i] - 'a';
        else
        {
            if (tab1[s[i] - 'a'] != t[i] - 'a')
                f = false;
        }

        if (tab2[t[i] - 'a'] == -1)
        {
            tab2[t[i] - 'a'] = s[i] - 'a';
        }
        else
        {
            if (tab2[t[i] - 'a'] != s[i] - 'a')
                f = false;
        }
    }
    if (f)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 916
import java.util.*;

class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n=sc.nextInt();
    double[] a=new double[n];
    for(int i=0;i<n;i++){
      a[i]=sc.nextDouble();
    }
    double[][] dp = new double[n+2][n+2];
    dp[0][0] = 1-a[0];
    dp[0][1] = a[0];
    for(int i=0;i<n-1;i++){
      for(int j=0;j<=i+1;j++){
        dp[i+1][j]+=dp[i][j]*(1-a[i+1]);
        dp[i+1][j+1]+=dp[i][j]*a[i+1];
      }
    }
    double total=0;
    for(int i=n/2+1;i<=n;i++){
      total+=dp[n-1][i];
    }
    System.out.println(total);
  }
}

Measured memory_bytes: 124076
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
using namespace std;
 
int main() {
    int n;
    long long int ans = 0;
    cin >> n;
    int a[n], b[n];
    for(int i = 0; i < n-1; ++i) {
        cin >> b[i];
    }
    a[0] = b[0];
    a[1] = b[0];
    for(int i = 1; i < n-1; ++i) {
        if(a[i] > b[i]) {
            a[i] = b[i];
        }
        a[i+1] = b[i];
    }
    for(int i = 0; i < n; ++i) {
        ans += a[i];
    }
    cout << ans << '\n';
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define ALL(A) A.begin(), A.end()

using namespace std;

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

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int N; cin >> N;
	string s,t; cin >> s >> t;

	int res = 2 * N + 1;
	for (int i = 0; i <= N; ++i){
		string u = s;
		if (i < N){
			u += t.substr(i);
		} // end if

		bool ok = true;
		for (int j = 0; j < i; ++j){
			if (s[N-i+j] == t[j]){
				continue;
			}else{
				ok = false;
			} // end if
		} // end for

		if (ok){
//			cerr << u << endl;
			res = min(res, (int)u.length());
		} // end if
	} // end for

	cout << res << endl;		

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
typedef long long ll;
const ll maxn=4e3+10;
ll n,ans=0,cr=0,cg=0,cb=0;
char s[maxn];
int main(){
	cin>>n>>s;
	for(int i=0;i<n;i++){
		if(s[i]=='R') ans += cg*cb,cr++;
		if(s[i]=='G') ans += cr*cb,cg++;
		if(s[i]=='B') ans += cr*cg,cb++;
	}
	for(int i=0;i<n;i++){
		for(int j=i+1;j+j-i<n;j++){
			if(s[i]!=s[j] && s[i]!=s[j+j-i] && s[j]!=s[j+j-i]) ans--;
		}
	}
	cout<<ans<<endl;
	
}

Measured memory_bytes: 3648
#include<iostream>
using namespace std ;
const int maxx = 1e5+10;
int main()
{
    int A,B,M,a[maxx],b[maxx],am=1e9+5,bm=1e9+5,ans=1e9+5,ans1;
    cin >> A >> B >> M ;
    for(int i=1;i<=A;i++){int x;cin >>x ;a[i]=x;am=min(am,x);}
    for(int i=1;i<=B;i++){int x;cin >>x ;b[i]=x;bm=min(bm,x);}
    for(int i=1;i<=M;i++)
    {
        int x,y,z;
        cin >> x >> y >> z ;
        ans=min(ans,a[x]+b[y]-z);
    }
    ans1=am+bm;
    ans=min(ans1,ans);
    cout << ans << endl;
    return 0 ;
}


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

using namespace std;

#define FOR(i,n) for(int i=0; i<n; ++i)
#define FORR(i,a,n) for(int i=a; i<n; ++i)
#define ALL(c) (c).begin(), (c).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
 
int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }
void printfv(VI a){ int n = a.size(); FOR(i, n) cout << a[i] << " "; }

int main(void){

    char b;
    cin >> b;

    switch(b){
        case 'A': cout << 'T'; break;
        case 'C': cout << 'G'; break;
        case 'G': cout << 'C'; break;
        case 'T': cout << 'A'; break;
    }

    return 0;
}


Measured memory_bytes: 256
N,A,B = map(int,(input().split()))
X = list(map(int,(input().split())))
ans = 0
now = X[0]
for i in range(1,N):
    if (X[i]-now)*A <= B:
        ans += (X[i]-now)*A
    else:
        ans += B
    now = X[i]
print(ans)

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

n, k = map(int, input().split())
h = list(map(int, input().split()))
dp = [0] * n
dp_memo = [10 ** 4] * k

for i in range(1, n):
    for j in range(min(k, i)):
        dp_memo[j] = abs(h[i] - h[i - j - 1]) + dp[i - j - 1]
    dp[i] = min(dp_memo)
    dp_memo = [10 ** 4] * k

print(dp[n - 1])


Measured memory_bytes: 52444
from collections import Counter
a,b=map(int, input().split())
c = Counter(list(map(int, input().split())))
cnt = 0
l = []
m = []

for x,y in c.items():
    l += [y]
    m += [x]

M = len(m)
L = sorted(l)
if M <= b:
    print(0)
if M > b:
    for i in range(M-b):
        cnt += L[i]
    print(cnt)

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

int main() {
  int A, B, C, K;
  cin >> A >> B >> C >> K;
  
  for (int i = 0; i < K; i++){
    if (A < C && B < C)
      C *= 2;
    else if  (A < B && C <= B)
      B *= 2;
    else if (B <= A && C <= A)
      A *= 2;
  }
  
  cout << A + B + C <<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define ll long long int
#define ld long double
#define pb push_back
#define pq priority_queue
#define pll pair<long long int,long long int>
#define pii pair<int,int>
#define vvll vector<vector<ll>>
#define vvi vector<vector<int>>
#define vi vector<int>
#define vll vector<ll>
#define vs vector<string>
#define MODNUM 1000000007
#define lp(i,a,b) for(ll i=a; i<b; i++)
 
using namespace std;
 
ll mex(ll a, ll b, ll m) {
	if(b==0) return 1;
	if(b%2) return a*mex((a*a)%m,(b-1)/2,m)%m;
	else return mex((a*a)%m,b/2,m);
}
 
int x,y;
void exteu(ll a, ll m) {
	if(m==0) { x=1;y=0; }
	else {
		exteu(m,a%m);
		ll temp = x;
		x=y;
		y=temp-(a/m)*y;
	}
}
 
ll fact(ll n) 
{	ll prod=1;
	for(ll i=2; i<=n; i++) {
		prod*=i;
	}
	return prod;
}
 
ll gcd(ll a, ll b) {
	if(b==0) return a;
	return gcd(b, a%b);
}
 
// bool isprime[100001];
// void makesieve() {
// 	memset(isprime, true, sizeof(isprime));
// 	for (int i = 2; i <= sqrt(200000); ++i)
// 	{
// 		if(isprime[i]) {
// 			for (int j = i*i; j <= 200000; j+=i)
// 			{
// 				isprime[j]=false;
// 			}
// 		}
// 	}
// }
// 
// 1 2 4 5 8
vvll D = {{-1,-1}, {1,1}, {1,-1}, {-1,1}};
void solve() {
	ll n; cin>>n;
	map<string, int> m;
	m["AC"]=0; m["WA"]=0; m["TLE"]=0; m["RE"]=0;
	for (int i = 0; i < n; ++i)
	{
		string s; cin>>s;
		m[s]++;
	}
	cout<< "AC x "<<m["AC"]<<endl;
	cout<<"WA x "<<m["WA"]<<endl;
	cout<<"TLE x "<<m["TLE"]<<endl;
	cout<<"RE x "<<m["RE"]<<endl;
}
 
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	ll TESTS=1;
	// cin >> TESTS;
	// makesieve();
	while(TESTS--) {
		solve();
	}
	return 0;
}

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

int main() {
  string s, t;
  cin >> s >> t;
  int n = s.size();
  int ans = 0;
  for (int i = 0; i < n; i++) if (s[i] != t[i]) ans++;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3912
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll INF = 100000000;
#define rep1(i, n) for (ll i=0; i<(n); i++) 
#define rep2(i, k, n) for (ll i=k; i<(n); i++)


int main() {
    ll n, k;
    cin >> n >> k;
    //vector<ll> d(n);
    //vector<vector<ll>> a(k,vector<ll>(m,0));
    vector<ll> kun(n);
    ll d, a;
    rep1(i, n){
        cin >> d;
        rep1(j, d){
            cin >> a;
            kun[a-1]++;
        }
    }
    ll ans = 0;
    rep1(i,n){
        if (kun[i] == 0) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;

#define repr(i, n) for(int i = n; i >= 0; i--)
#define reprl(i, n) for(ll i = n; i >= 0; i--)
#define all(v) v.begin(), v.end()
ll gcd(ll a,ll b) {
  return b? gcd(b,a%b): a;  
}
ll lcm(ll a,ll b) {
  return a*b/gcd(a,b);
}
bool isLowerCase(char c){
  return (c>='a'&&c<='z');
}
const string outputYesNo(bool ans){
  return (ans?"Yes":"No");
}
int main() {
  int a,b;cin>>a>>b;
  if(a+b>9){
    cout<<"error"<<endl;
  }else{
    cout<<a+b<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
from sys import stdin
import math

N,K = [int(x) for x in stdin.readline().rstrip().split()]
prob1 = 0
prob2 = 0

# ケース1
if (N >= K):
	prob1 += (N-K+1) / N

# ケース2
for p in range(1, min(N+1, K)):
  prob2 += (0.5) ** math.ceil(math.log2(K/p)) / N
  
print(prob1 + prob2)

Measured memory_bytes: 3060
package main
import "fmt"
func main(){
    var n int
    var s string
    
    fmt.Scan(&n)
    fmt.Scan(&s)
    
    str := []rune(s)
    
    cnt := 0
    for i:=0;i<n-2;i++ {
        sub := string(str[i:i+3])
        if sub == "ABC" {
            cnt++
        }
    }
    fmt.Println(cnt)
}


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

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define DUMP(v) REP(aa, (v).size()) { cout << v[aa]; if (aa != v.size() - 1)cout << " "; else cout << endl; }
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll max(ll a, int b) { return max(a, ll(b)); }
ll max(int a, ll b) { return max(ll(a), b); }
ll min(ll a, int b) { return min(a, ll(b)); }
ll min(int a, ll b) { return min(ll(a), b); }


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	ll ans = 0;
	REP(i, n) {
		int l, r;
		cin >> l >> r;
		ans += r - l + 1;
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<utility>
#include<algorithm>
#include<stdlib.h>
using namespace std;

int main()
{
		int n, k, q;
		int s = 0;

		cin >> n >> k >> q;
		vector<int> a(n);

		for (int i = 0; i < q; i++)
		{
			cin >> s;
			a[s-1]++;
		}

		for (int j = 0; j < n; j++)
		{
			if (k + a[j] - q > 0)
			{
				cout << "Yes" << endl;
			}
			else
			{
				cout << "No" << endl;
			}
		}
	return 0;
}

Measured memory_bytes: 1024
#ifdef __APPLE__
#include <iostream>
#include <vector>
#include <utility>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <random>
#else
#include <bits/stdc++.h>
#endif

using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define tc(t) for (int tc=1; tc<=t; tc++)
typedef vector<int> VI;
typedef vector<long long int> VLLI;
typedef vector<pair<int, int> > VPI;
typedef long long ll;
typedef pair<int,int> PII;
typedef pair<ll, ll> PLL;
mt19937 mrand(random_device{}()); 
const ll mod=1000000007;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll modInverse (ll a) {ll p = mod - 2; return powmod(a, p);}
// head

int main() {
    int n;
    cin >> n;
    unordered_set<string> data;
    string s;
    while (n--) {
        cin >> s;
        data.insert(s);
    }
    cout << data.size() << "\n";
}



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

const long long INF = 1000000000;

typedef long long ll;

#define writeln(n) cout<<n<<"\n";

typedef pair<int, int> P;
typedef pair<string, int> Psi;

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

	return gcd(b, a%b);
}

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


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

	ll a, b, c, d;cin>>a>>b>>c>>d;

	ll s = b/c-(a-1)/c;
	ll ss = b/d-(a-1)/d;
	ll sss = b/lcm(c,d)-(a-1)/lcm(c,d);

	writeln((b-a+1)-s-ss+sss);


}




Measured memory_bytes: 256
s1 = list(input())
s2 = list(reversed(s1))
n = len(s1)
if s1 == s2:
    s3 = [i for i in s1[0:(n-1)//2]]
    s4 = list(reversed(s3))
    if s3 == s4:
        s5 = [i for i in s1[(n+3)//2-1:n]]
        s6 = list(reversed(s5))
        if s5 == s6:
            print('Yes')
        else:
            print('No')
    else:
        print('No')
else:
    print('No')

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

#define ll long long int
#define ull unsigned long long int
#define IO ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);


using namespace std;

const int INF = 1e9 + 7;
const int N = 1e5+5;

int main() {

	IO; 

	int n;
	cin >> n;
	if (n == 3 || n == 5 || n == 7) {
		cout << "YES";
	}
	else {
		cout << "NO";
	}
		
}



Measured memory_bytes: 3628
#include<bits/stdc++.h>
 #include<iostream>
using namespace std;
int main()
{
	ios::sync_with_stdio(0);cin.tie(0);
	long long h,n,sum=0;
	cin>>h>>n;
	while(n--)
	{
		long long a;
		cin>>a;
		sum=sum+a;
	}
	if(sum>=h)
	cout<<"Yes";
	else cout<<"No";
 } 

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

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

  int tmp;
  if (a > b) {
    tmp = b; b = a; a = tmp;
  }
  if (b > c) {
    tmp = c; c = b; b = tmp;
  }
  if (a > b) {
    tmp = b; b = a; a = tmp;
  }

  cout << a << " " << b << " " << c << endl;
  return 0;
}



Measured memory_bytes: 3080
import java.util.Scanner



object Main {

  def read(): (String, String) = {
    val sc: Scanner = new Scanner(System.in)
    val s = sc.next
    val t = sc.next
    sc.close()
    (s, t)
  }


  def solve(s: String, t: String): Int = {
    var cnt = 0
    for(i <- 0 until s.length) {
      if(s(i) == t(i)) cnt += 1
    }
    cnt
  }


  def main(args: Array[String]): Unit = {
    val (s, t) = read()
    println(solve(s, t))
  }

}


Measured memory_bytes: 27336
#include<bits/stdc++.h>
using namespace std;
long long arr[1000000];
int main()
{
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
	string s;   
    long long n,i,j,k,x,y,z,xx,ans;
    cin>>n;
    cin>>s;
    x=0;
    y=0;
    z=0;
    for (i=0;i<n;i++)
    {
    	if (s[i]=='R')
    	{
    		x++;
		}
    	if (s[i]=='G')
    	{
    		y++;
		}
    	if (s[i]=='B')
    	{
    		z++;
		}
	}
	ans=x*y*z;
	xx=0;
	for (i=0;i<n;i++)
	{
		if (s[i]=='R')
		{
			for (j=i+1;j<n;j++)
			{
				if (s[j]=='G')
				{
					x=j-i;
					if (j+x<n)
					{
						if (s[j+x]=='B')
						{
							ans--;
						}
					}
				}
				if (s[j]=='B')
				{
					x=j-i;
					if (j+x<n)
					{
						if (s[j+x]=='G')
						{
							ans--;
						}
					}
					else
					{
						break;
					}
				}
			}
		}
		if (s[i]=='G')
		{
			for (j=i+1;j<n;j++)
			{
				if (s[j]=='R')
				{
					x=j-i;
					if (j+x<n)
					{
						if (s[j+x]=='B')
						{
							ans--;
						}
					}
				}
				if (s[j]=='B')
				{
					x=j-i;
					if (j+x<n)
					{
						if (s[j+x]=='R')
						{
							ans--;
						}
					}
					else
					{
						break;
					}
				}
			}
		}
		if (s[i]=='B')
		{
			for (j=i+1;j<n;j++)
			{
				if (s[j]=='G')
				{
					x=j-i;
					if (j+x<n)
					{
						if (s[j+x]=='R')
						{
							ans--;
						}
					}
					else
					{
						break;
					}
				}
				if (s[j]=='R')
				{
					x=j-i;
					if (j+x<n)
					{
						if (s[j+x]=='G')
						{
							ans--;
						}
					}
					else
					{
						break;
					}
				}
			}
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 3672
import sys
sys.setrecursionlimit(100000)

N, M = map(int, input().split())
AB = [list(map(int, input().split())) for _ in range(M)]
ans = [0] * M

parent = [-1] * (N + 1)
size = [1] * (N + 1)
combi = N * (N - 1) // 2
count = 0

def get_parent(a):
    global parent
    temp = parent[a]
    if temp == -1:
        return a
    else:
        temp = get_parent(temp)
        parent[a] = temp
        return temp

def union(a, b):
    global count, size
    parent_a = get_parent(a)
    parent_b = get_parent(b)

    if parent_a != parent_b:
        parent[parent_b] = parent_a
        count -= size[parent_a] * (size[parent_a] - 1) // 2
        count -= size[parent_b] * (size[parent_b] - 1) // 2
        size[parent_a] += size[parent_b]
        count += size[parent_a] * (size[parent_a] - 1) // 2

for i in range(M - 1, -1, -1):
    ans[i] = combi - count

    a, b = AB[i]
    union(a, b)

for temp in ans:
    print(temp)




Measured memory_bytes: 44808
n, k = [int(i) for i in input().split()]
snuke = [False]*n
for i in range(k):
    d = int(input())
    a = [int(j) for j in input().split()]
    for j in a:
        snuke[j-1] = True
ans = 0
for i in snuke:
    if i == False:
        ans += 1
print(ans)

Measured memory_bytes: 67636
s =input().split()
N = int(s[0])
L = int(s[1])

apple = []
for i in range(N):
    apple.append(L+i)

MIN = 10000000000
num = 0
for i in range(N):
    if MIN > abs(apple[i]):
        MIN = abs(apple[i])
        num = i
apple.pop(num)

print(sum(apple))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int r[100005],r2[100005],r3[1000005];
int main()
{
    long long int a,b,c,d,e,f,g,k;

    string s;

    while(cin>>a)
    {
        vector<int>v;
       b=a/2.;
       for(c=1;c<=a;c++)
       {
           cin>>d;
           v.push_back(d);
       }
       sort(v.begin(),v.end());
       if(v[b-1]==v[b])
       {
           cout<<"0"<<endl;
       }
       else
       {
          c=v[b-1];
          cout<<v[b]-c<<endl;
       }
      v.clear();

    }








    return 0;
}


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

int linearSearch(int*,int,int);

int main(){
  int i,j,n,q,*S,*T;

  scanf("%d",&n);
  if(n > 10000)exit(1);
  S = malloc((n+1) * sizeof(int));
  for(i=0;i < n;i++){
    scanf("%d",&S[i]);
    if(S[i] < 0)exit(2);
  }
  scanf("%d",&q);
  if(q > 500)exit(3);
  T = malloc(q * sizeof(int));
  for(i=0;i < q;i++){
    scanf("%d",&T[i]);
    if(T[i] < 0)exit(4);
    for(j=0;j < i;j++){
      if(T[j] == T[i])exit(5);
    }
  }
  j = 0;
  for(i=0;i < q;i++){
    if(linearSearch(S,T[i],n))j++;
  }
  printf("%d\n",j);
  return 0;  
}

int linearSearch(int *S,int t,int n){
  int i = 0;
  S[n] = t;
  while(S[i] != t){
    i++;
  }
  if(i == n)return 0;
  return 1;
}



Measured memory_bytes: 2104
#include <iostream>
#include <cstdio>
#include <vector>
#include <deque>
#include <set>
#include <list>
#include <stack>
#include <queue>
#include <string>

using namespace std;

int main(){
    char str[11];
    
    scanf("%s",str);

    if(str[0]!='Y'){
        printf("No\n");
        return 0;
    }
    if(str[1]!='A'){
        printf("No\n");
        return 0;
    }
    if(str[2]!='K'){
        printf("No\n");
        return 0;
    }
    if(str[3]!='I'){
        printf("No\n");
        return 0;
    }

    printf("Yes\n");
    return 0;
}

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

class Dice{
    public:
    int f[7];
    Dice(){}
        void roll_x(){roll(1,4,6,3);} // to E
        void roll_y(){roll(1,2,6,5);} // to N
        void roll_z(){roll(2,3,5,4);} // 上から見て時計回り
        void roll(int a, int b, int c, int d){
            int t=f[a]; f[a]=f[b]; f[b]=f[c]; f[c]=f[d]; f[d]=t;
        }
        void move(char ch){
            if(ch=='E') roll_x();
            if(ch=='S') for(int i=0;i<3;i++) roll_y();
            if(ch=='W') for(int i=0;i<3;i++) roll_x();
            if(ch=='N') roll_y();
        }
};

bool eq(Dice d1,Dice d2){
    for(int i=1;i<=6;i++){
        if(d1.f[i]!=d2.f[i]) return false;
    }
    return true;
}

bool equal(Dice d1, Dice d2){
    for(int i=0;i<6;i++){
        for(int j=0;j<4;j++){
            if(eq(d1,d2)) return true;
            d1.roll_z();
        }
        if(i%2==0) d1.roll_x();
        else d1.roll_y();
    }
    return false;
}

int main(){
    Dice d1, d2;
    
    for(int i=1;i<=6;i++) cin >> d1.f[i];
    for(int i=1;i<=6;i++) cin >> d2.f[i];

    if(equal(d1,d2)) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


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

using namespace std;

using ll = long long;
using ld = long double;

typedef pair<ll, ll> P;

#define bit(n) (1LL << (n))

//#define int long long

#define all(v) v.begin(), v.end()
#define sortAl(v) sort(all(v))
#define sortAlr(v)          \
  sort(v.begin(), v.end()); \
  reverse(v.begin(), v.end())

#define rep(i, n) for (ll i = 0; i < n; i++)
#define REP(i, n) for (ll i = 1; i < n; i++)

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define FORm(i, m) for (auto i = m.begin(); i != m.end(); i++)

template <class T>
inline void chmax(T &a, T b) {
  a = std::max(a, b);
}
template <class T>
inline void chmin(T &a, T b) {
  a = std::min(a, b);
}

#define mod (ll)(1e9 + 7)
#define INF LLONG_MAX

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

  string s;
  cin >> s;
  int k;
  cin >> k;
  int n = s.size();

  // dp[桁数][k(1〜9を何個含むか)][未満フラグ]
  vector<vector<vector<ll>>> dp(n + 1, vector<vector<ll>>(k + 2, vector<ll>(2)));
  dp[0][0][0] = 1;

  for (int i = 0; i < n; i++) {
    for (int j = 0; j <= k; j++) {
      int D = s[i] - '0';

      // ============================================ この桁を0にする場合
      //未満フラグが立っているものはそのまま引き継ぎ
      dp[i + 1][j][1] += dp[i][j][1];

      if (D == 0) {
        // 未満フラグOffを引き継ぎ
        dp[i + 1][j][0] += dp[i][j][0];
      } else {
        // 該当桁の値Dが1以上なら未満フラグOff→Onで引き継ぎ
        dp[i + 1][j][1] += dp[i][j][0];
      }
      // ============================================

      // ============================================ この桁を0以外にする場合([k]が変化する)
      for (int h = 1; h <= 9; h++) {
        // 未満フラグOnのものはそのまま引き継ぎ
        dp[i + 1][j + 1][1] += dp[i][j][1];

        if (h < D) {
          // 未満フラグOnで引き継ぎ
          dp[i + 1][j + 1][1] += dp[i][j][0];
        } else if (h == D) {
          // 未満フラグOffで引き継ぎ
          dp[i + 1][j + 1][0] += dp[i][j][0];
        }
      }
      // ============================================
    }
  }
  ll ans = dp[n][k][0] + dp[n][k][1];
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cmath>
#include<algorithm>
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;

class Mo{
    public:
    int N,Q,ans=0;
    struct query{int l,r;};
    vector<int>data,order;
    vector<query>q;

    vector<int>cnt;
    void add(int idx){ans+=(++cnt[data[idx]]==1);}
    void del(int idx){ans-=(--cnt[data[idx]]==0);}

    Mo(int N,int Q):N(N),Q(Q),data(N+1),order(Q),q(Q),cnt(N+1,0){}

    void input_data(){for(int i=0;i<N;i++)scanf("%d",&data[i]);}

    /*[l, r) 0-idx*/
    void input_query(){for(int i=0;i<Q;i++){scanf("%d%d",&q[i].l,&q[i].r);q[i].l--;}}

    vector<int>solve(){
        //iota(begin(order), end(order), 0);
        for(int i=0;i<Q;i++)order[i]=i;

        //sort query
        sort(order.begin(),order.end(),
        [&](const int a,const int b){
            return ((q[a].l/(int)sqrt(N))!=(q[b].l/(int)sqrt(N))?q[a].l<q[b].l:q[a].r<q[b].r);
        });

        vector<int>answer(Q);//answer for query
        int L,R,i;
        for(L=R=i=0;i<Q;i++){
            //add
            while(L>q[order[i]].l)add(--L);
            while(R<q[order[i]].r)add(R++);
            //del
            while(L<q[order[i]].l)del(L++);
            while(R>q[order[i]].r)del(--R);
            answer[order[i]] = ans;
        }
        return answer;
    }
};

int N,Q,l,r;
int main(){
    scanf("%d%d",&N,&Q);
    Mo mo(N,Q);
    mo.input_data();
    mo.input_query();
    auto ans=mo.solve();
    for(int i=0;i<Q;i++)printf("%d\n",ans[i]);
    return 0;
}

Measured memory_bytes: 15484
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); i++)
typedef long long ll;
const int mod = 1e9 + 7;
int main() {

    int n, k;
    cin >> n >> k;
    ll r, s, p;
    cin >> r >> s >> p;
    string t;
    cin >> t;

    ll ans = 0;
    rep(i, t.length()){
        if(i >= k){
            if(t[i-k] == t[i]){
                t[i] = 'z';
                continue;
            }
        }

        if(t[i] == 'r'){
            ans += p;
        }
        else if(t[i] == 's'){
            ans += r;        
        }
        else{
            ans += s;
        }
    }
    std::cout << ans << endl;

    return 0;
}

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


int main() {

	cin.tie( 0 );
  ios::sync_with_stdio( false );

	string str;
	cin >> str;

	int del;

	cin >> del;

	string result;
	result = str[ 0 ];

	for( int i = del; i <= (int)str.size(); i += del ) {
		result += str.substr( i, 1 );
	}


	cout << result << endl;

}


Measured memory_bytes: 256
# ABC079D - Wall
import sys
input = sys.stdin.readline

def warshall_floyd():
    for k in range(10):
        for i in range(10):
            for j in range(10):
                if C[i][k] + C[k][j] < C[i][j]:
	                C[i][j] = C[i][k] + C[k][j]
    return C


def main():
    global C
    H, W = tuple(map(int, input().split()))
    C = list(list(map(int, input().split())) for _ in range(10))
    A = tuple(tuple(map(int, input().split())) for _ in range(H))
    warshall_floyd()
    ans = sum(sum(C[i][1] for i in a if i != -1) for a in A)
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 3316
#include <iostream>
using namespace std;
int n, mn=1e9;

int f(int p) {
	int s=0;
	for(; p; p/=10) s += p%10;
	return s;
}

int main() {
	cin>>n;
	for(int i=1; i<n; i++) mn = min(mn, f(i) + f(n-i));
	cout<<mn;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main()
{
       int n,sm,j=0,k,box;
       scanf("%d",&n);
       k = n-1;
       int a[n];
       for(int i=0;i<n;i++){
           scanf("%d ",&sm);
           a[i]=sm;
        }
        while(j<k){
            box = a[j];
            a[j]= a[k];
            a[k]=box;
            j++;
            k--;
        }
        int i=0;
    if(i != n-1){
       printf("%d ",a[i]);
       i++;
       while(i<n-1){
            printf("%d ",a[i]);
            i++;
       }
    }
       printf("%d\n",a[i]);
       return 0;
}


Measured memory_bytes: 2040
#include<set>
#include<map>
#include<cmath>
#include<queue>
#include<bitset>
#include<string>
#include<cstdio>
#include<cctype>
#include<cassert>
#include<cstdlib>
#include<cstring>
#include<sstream>
#include<iostream>
#include<algorithm>

#define For(i,x,y) for (int i=x;i<y;i++)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define lf else if

#define dprintf(...) fprintf(stderr,__VA_ARGS__)
using namespace std;

typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> Vi;

int IN(){
	int c,f,x;
	while (!isdigit(c=getchar())&&c!='-');c=='-'?(f=1,x=0):(f=0,x=c-'0');
	while (isdigit(c=getchar())) x=(x<<1)+(x<<3)+c-'0';return !f?x:-x;
}

const int N=200000+19;
const db pi=acos(-1.0);

vector<pii> V;
int x[N],y[N];
int X1,Y1,X2,Y2,n,tmp;
db ans;

int cal(){
	static int stk[N],top;
	For(i,0,V.size()){
		int pos=lower_bound(stk+1,stk+top+1,V[i].se)-stk;
		stk[pos]=V[i].se;
		if (pos==top+1) top++;
	}
	return top;
}

int main(){
	X1=IN(),Y1=IN(),X2=IN(),Y2=IN();
	n=IN();
	For(i,1,n+1) x[i]=IN(),y[i]=IN();
	if (X1>X2) swap(X1,X2),swap(Y1,Y2);
	if (Y1>Y2){
		Y1*=-1;Y2*=-1;
		For(i,1,n+1) y[i]*=-1;
	}
	For(i,1,n+1)
		if (X1<=x[i]&&x[i]<=X2&&Y1<=y[i]&&y[i]<=Y2){
			V.pb(mp(x[i],y[i]));
		}
	sort(V.begin(),V.end());
	tmp=cal();
	ans=100ll*(abs(X1-X2)+abs(Y1-Y2));
	ans+=tmp*(5*pi-20);
	if (tmp==abs(X2-X1)+1||tmp==abs(Y2-Y1)+1) ans+=5*pi;
	printf("%.20lf\n",ans);
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef complex<double> P;
typedef pair<int,int> pii;
#define REP(i,n) for(ll i=0;i<n;++i)
#define REPR(i,n) for(ll i=1;i<n;++i)
#define FOR(i,a,b) for(ll i=a;i<b;++i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define MOD (ll)(1e9+7)
#define ADD(a,b) a=((a)+(b))%MOD
#define FIX(a) ((a)%MOD+MOD)%MOD

int main(){
  int n;
  cin>>n;
  int p[n][3];
  REP(i,n){
    REP(j,3)cin>>p[i][j];
  }
  vi r(n,0);
  REP(i,3){
    map<int,int> S;
    REP(j,n) S[p[j][i]]++;
    REP(j,n) if(S[p[j][i]] == 1) r[j]+=p[j][i];
  }
  REP(i,n) cout<<r[i]<<endl;
  return 0;
}

Measured memory_bytes: 1200
#include <bits/stdc++.h>
const int mod=1e9+7;
using LL=long long;
using namespace std;
namespace ndifix{

}//end of namespace ndifix

int main(){
  int a,b;cin>>a>>b;
  if((a+b)%2==0)cout<<(a+b)/2<<endl;
  else cout<<"IMPOSSIBLE"<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>

int main(){
    int a[10];
    for(int i = 0; i < 10; i++){
        std::cin >> a[i];
    }
    
    for(int k = 0; k < 3; k++){
        int idx = 0;
        for(int i = 0; i < 10; i++){
            if(a[idx] < a[i]){
                idx = i;
            }
        }
        std::cout << a[idx] << std::endl;
        a[idx] = 0;
    }
    return 0;
}

Measured memory_bytes: 3112
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <vector>
using namespace std;

string a[5010];
int b[5010];
int x[5010];
int n, m;
int color[5010];
int minVal[5010];
int id[5010];
vector<vector<int> > g;

int main(){
    while(cin >> n){
        g.resize(n);
        vector<string> ss(n);
        for(int i = 0; i < n; i++){
            color[i] = -1, g[i].clear(), minVal[i] = 1e9;
        }
        for(int i = 0 ; i < n; i++){
            cin >> a[i] >> x[i];
            ss[i] = a[i];
        }
        sort(ss.begin(), ss.end());
        for(int i = 0; i < n; i++){
            int id = lower_bound(ss.begin(), ss.end(), a[i]) - ss.begin();
            b[id] = x[i];
        }
        cin >> m;
        for(int i = 0; i < m; i++){
            string p,q;
            cin >> p >> q;
            int pi = lower_bound(ss.begin(), ss.end(), p) - ss.begin();
            int qi = lower_bound(ss.begin(), ss.end(), q) - ss.begin();
            g[pi].push_back(qi);
            g[qi].push_back(pi);
        }
        int col = 0;
        for(int i = 0; i < n; i++){
            if(color[i] != -1) continue;
            vector<int> S;
            S.push_back(i);
            int m = 1e9;
            while(S.size()){
                int v = S.back(); S.pop_back();
                color[v] = col;
                m = min(m, b[v]);
                for(int j = 0; j < (int)g[v].size(); j++){
                    int d = g[v][j];
                    if(color[d] == -1) S.push_back(d);
                }
            }
            minVal[col] = m;
            col++;
        }
        int ans = 0;
        for(int i = 0; i < n; i++){
            int id = lower_bound(ss.begin(), ss.end(), a[i]) - ss.begin();
            ans += minVal[color[id]];
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 1812
#include <bits/stdc++.h>
using namespace std;
#define rep(i,e) for(int i= 0; i< (int)(e); i++)
#define reps(i,s,e) for(int i = s; i < (int)(e); i++)
#define repr(i,s,e) for(int i = s; i > (int)(e); i--)
#define pb push_back
typedef long long ll;
const ll INF = 1LL << 60;

int main()
{
    ll n;
    cin >> n;
    vector<ll> a(n),s(n+1);
    s[0] = 0;
    rep(i,n){
        cin >> a[i];
        s[i+1] = s[i] + a[i];
    }
    ll ans = INF;
    reps(i,2,n-1){
        ll tmp_ans;
        ll ng = 0;
        ll ok = i-1;
        while(abs(ng-ok)>1){
            int mid = (ng+ok)/2;
            if(s[mid] > s[i]-s[mid]){ok = mid;}
            else{ng = mid;}
        }
        ll p1 = s[ng];
        ll p2 = s[ok];
        ll q1 = s[i]-s[ng];
        ll q2 = s[i]-s[ok];
        ll p,q;
        if(abs(p1-q1)<abs(p2-q2)){p=p1;q=q1;}
        else{p=p2;q=q2;}

        ng = i+1;
        ok = n-1;
        while(abs(ng-ok)>1){
            int mid = (ng+ok)/2;
            if(s[mid]-s[i] > s[n]-s[mid]){ok = mid;}
            else{ng = mid;}
        }
        ll r1 = s[ng]-s[i];
        ll r2 = s[ok]-s[i];
        ll s1 = s[n]-s[ng];
        ll s2 = s[n]-s[ok];
        ll r,s;
        if(abs(r1-s1)<abs(r2-s2)){r=r1;s=s1;}
        else{r=r2;s=s2;}

        tmp_ans = max(max(p,q),max(r,s)) - min(min(p,q),min(r,s));
        ans = min(ans,tmp_ans);
    }
    cout << ans;
}

Measured memory_bytes: 3328
import kotlin.math.*
import java.util.*

const val MOD = 1_000_000_007L

fun readI() = readLine()!!.toInt()
fun readL() = readLine()!!.toLong()
fun readD() = readLine()!!.toDouble()
fun readIs() = readLine()!!.split(' ').map(String::toInt)
fun readLs() = readLine()!!.split(' ').map(String::toLong)
fun readDs() = readLine()!!.split(' ').map(String::toDouble)

fun main(args: Array<String>) {
  val n = readI()
  val ans = readIs().filterIndexed { idx, it -> idx % 2 == 0 && it % 2 == 1 }.count()
  println(ans)
}


Measured memory_bytes: 36420
#include<iostream>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
using namespace std;
#define LL long long

struct edge{
    int to, cost;
};
struct node{
    int n, cost;
    bool operator<(const node & n1) const {
        return n1.cost < cost;
    }
};
int N, M, K;
int a[100010], b[100010], l[100010];
vector<edge> G[3010];
int main(){
    cin >> N >> M >> K;
    for(int i = 0; i < M; i++){
        cin >> a[i] >> b[i] >> l[i];
        G[a[i]].push_back(edge{b[i], l[i]});
        G[b[i]].push_back(edge{a[i], l[i]});
    }
    int D[3010] = {};
    fill(D, D + (N + 1), 1 << 30);
    priority_queue<node> pq;
    for(int i = 0; i < K; i++){
        int c = 0;
        cin >> c;
        D[c] = 0;
        pq.push(node{c, 0});
    }
    while(!pq.empty()){
        node n = pq.top();
        pq.pop();
        if(D[n.n] < n.cost) continue;
        for(auto u : G[n.n]){
            int c = n.cost + u.cost;
            if(c < D[u.to]){
                D[u.to] = c;
                pq.push(node{u.to, c});
            }
        }
    }
    int ans = 0;
    for(int i = 1; i <= N; i++){
        ans = max(ans, D[i]);
    }
    for(int i = 0; i < M; i++){
        int cost = (D[a[i]] + D[b[i]] + l[i] + 1) / 2;
        ans = max(cost, ans);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 7192
/**
*  author: rits1272
*  created: Aug 23, 2020
**/
#include<bits/stdc++.h>
using namespace std;

#define int long long
#define print(x) cout << "[" << #x << ":" << x << "] "; 
#define println(x) cout << "[" << #x << ":" << x << "]\n";

const int mxN = 3e5 + 1;
int h, w, m;
int X[mxN], Y[mxN];
int row[mxN], col[mxN];

int32_t main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> h >> w >> m;
    int xmax = 0, ymax = 0;
    for(int i=0; i<m; i++){
	cin >> X[i] >> Y[i];
	xmax = max(xmax, ++row[X[i]]);
	ymax = max(ymax, ++col[Y[i]]);
    }

    int cnt_row = 0, cnt_col = 0;
    for(int i=1; i<=h; i++){
	if(row[i] == xmax)
	    cnt_row++;
    }
    
    for(int i=1; i<=w; i++){
	if(col[i] == ymax)
	    cnt_col++;
    }

    int dup = 0;
    for(int i=0; i<m; i++){
	if(row[X[i]] == xmax && col[Y[i]] == ymax){
	    dup++;
	}
    }

    int ans = xmax + ymax - (dup == cnt_row*cnt_col ? 1 : 0);
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 12988
#include <bits/stdc++.h>
#define INF 1000000000
#define LINF 1000000000000000000
#define MOD 1000000007
#define mod 1000007
#define INF63 1061109567
#define INF127 9187201950435737471
#define F first
#define S second
#define ll long long
#define N 310
using namespace std;
double dp[N][N][N];
int n,val,n1=0,n2=0,n3=0;
double dfs(int a,int b,int c)
{
	if(a<0||b<0||c<0)
	{
		return 0;
	}
	if(a==0&&b==0&&c==0)
	{
		return 0;
	}
	if(dp[a][b][c]!=-1)
	{
		return dp[a][b][c];
	}
	dp[a][b][c]=(double)n/(double)(a+b+c);
	dp[a][b][c]+=dfs(a-1,b,c)*(double)a/(double)(a+b+c);
	dp[a][b][c]+=dfs(a+1,b-1,c)*(double)b/(double)(a+b+c);
	dp[a][b][c]+=dfs(a,b+1,c-1)*(double)c/(double)(a+b+c);
	return dp[a][b][c];
}
int main(){
	int i,j,k;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d",&val);
		if(val==1) n1++;
		else if(val==2) n2++;
		else n3++;
	}
	for(i=0;i<=n;i++)
	{
		for(j=0;j<=n;j++)
		{
			for(k=0;k<=n;k++)
			{
				dp[i][j][k]=-1;
			}
		}
	}
	printf("%.15f\n",dfs(n1,n2,n3));
	return 0;
}

Measured memory_bytes: 227584
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll inf = 3e18;
const char sp = ' ';

int N, A[500000];
ll res;
string S;

int main() {
	cin >> S;
	N = S.size() + 1;
	for (int i = 0; i < N - 1; i++) {
		if (S[i] == '<') {
			A[i + 1] = A[i] + 1;
		}
	}
	for (int i = N - 1; i >= 0; i--) {
		if (S[i] == '>') {
			A[i] = max(A[i], A[i + 1] + 1);
		}
	}
	for (int i = 0; i < N; i++) {
		res += A[i];
	}
	cout << res << endl;
}

Measured memory_bytes: 2820