akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) (r).begin(),(r).end()
#define rall(r) (r).rbegin(),(r).rend()
#define fi first
#define se second
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

int main(){
#ifdef LOCAL_TEST
    freopen("in", "r", stdin);
    freopen("out", "w", stdout);
#endif
    string s;
    cin >> s;
    vi a(4);
    rep(i, 4) a[i] = s[i]-'0';
    string ope = "+-";
    rep(mask, 1<<3) {
        int sum = a[0];
        rep(i, 3) {
            if((mask>>i)&1) {
                sum -= a[i+1];
            }
            else {
                sum += a[i+1];
            }
        }
        if(sum == 7) {
            cout << a[0];
            rep(i, 3) {
                cout << ope[(mask>>i)&1]<<a[i+1];
            } 
            cout << "=7" << endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		char[] S = sc.next().toCharArray();
 		int x = 0, max = 0;
		for(int i = 0; i < N; i++) {
			if(S[i] == 'I') {
				x++;
			}
			if(S[i] == 'D') {
				x--;
			}
			max = Math.max(max, x);
		}
		System.out.println(max);
	}

}


Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
using P = pair<int, int>;

int main(){
    int n;
    cin >> n;
    long long a, ans = 1;
    long long lim = pow(10, 18);
    bool flag = false;
    for(int i = 0; i < n; i++){
        cin >> a;
        if(a == 0){
            cout << 0 << endl;
            return 0;
        }
        if(lim / a >= ans) ans *= a;
        else flag = true;
    }
    if(flag) cout << -1 << endl;
    else cout << ans << endl;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
 
#define int long long 
 
struct Ant
{
  int x, y, angle, num;
   
  Ant () {}
  Ant (int x, int y, int angle, int num) : x(x), y(y), angle(angle), num(num) {}
   
  void input(int i)
  {
    char c;
    scanf(" %lld %lld %c", &x, &y, &c);
    if(c == 'E') angle = 0;
    else angle = 1;
    num = i;
  }
 
  int getDist(int w, int h)
  {
    if(angle == 0) return (w - x + 1);
    return (h - y + 1);
  }
   
  int getSum()
  {
    return (x + y);
  }
   
};
 
int w, h, n;
bool lessDist(const Ant &a, const Ant &b) {
  Ant ta = a, tb = b;
  int ad = ta.getDist(w, h), bd = tb.getDist(w, h);
  if(ad < bd) return (true);
  if(ad > bd) return (false);
  return (a.num < b.num);
}
 
bool PPMX(const Ant &a, const Ant &b) {
  Ant ta = a, tb = b;
  int asum = ta.getSum(), bsum = tb.getSum();
  if(asum < bsum) return (true);
  if(asum > bsum) return (false);
  return (a.x > b.x);
}
 
main()
{
  Ant dista[200005];
   
  cin >> w >> h >> n;
   
  for(int i = 0; i < n; i++) {
    dista[i].input(i + 1);
  }
   
  sort(dista, dista + n, PPMX);
   
  int i = 0;
  while(i < n) {
    int l = i;
    int s = dista[i].getSum();
    queue < int > que[2];
    
    while(i < n && dista[i].getSum() == s) i++;
    if(s % 2) {
      for(int j = l; j < i; j++) {
	que[(dista[j].angle + dista[j].x) % 2].push(dista[j].num);
      }
      for(int p = 0; p <= 1; p++) {
	for(int j = l; j < i; j++) {
	  if(dista[j].angle == p) {
	    if(dista[j].x % 2 == p) {
	      dista[j].num = que[0].front(); que[0].pop();
	    } else {
	      dista[j].num = que[1].front(); que[1].pop();
	    }
	  } 
	}
      }
    } else {
      for(int j = l; j < i; j++) {
	que[dista[j].x % 2].push(dista[j].num);
      }
      for(int q = 0; q <= 1; q++) {
	for(int p = 0; p <= 1; p++) {
	  for(int j = l; j < i; j++) {
	    if(dista[j].x % 2 == q && dista[j].angle == p) {
	      dista[j].num = que[q].front(); que[q].pop();
	    }
	  }
	}
      }
    }
  }
   
  sort(dista, dista + n, lessDist);
   
  for(int i = 0; i < n; i++) {
    cout << dista[i].num << endl;
  }
 
  return (0);
} 

Measured memory_bytes: 10692
#include <iostream>
#include <vector>
#include <map>
using namespace std;
#define lli long long int

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n,i;
	vector<int> a;
	cin>>n;
	int m1 = 0;
	int m2 = 0;
	a.resize(n);
	for(i=0;i<n;i++)
	{
		cin>>a[i];
		if(a[i]>m1)
		{
			m2 = m1;
			m1 = a[i];
		}
		else if(a[i]>m2)
			m2 = a[i];
	}
	for(i=0;i<n;i++)
	{
		if(a[i]==m1)
			cout<<m2<<'\n';
		else
			cout<<m1<<'\n';
	}
	return 0;
}

Measured memory_bytes: 2432
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()

ll mpow(ll a, ll b){
	if(b==0){
		return a;
	}else if(b%2==0){
		ll memo = mpow(a,b/2);
		return memo*memo%MOD;
	}else{
		return mpow(a,b-1) * a % MOD;
	}
}

int main(void){
	int n,x;
	cin>>n>>x;
	int l;
	ll memo = 0;
	ll ans = 1;
	rep(i,n){
		cin>>l;
		memo += l;
		if(memo <= x){
			ans++;
		}else{
			break;
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 636
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<int> h(n);
  for (int i = 0; i < n; i++) {
    cin >> h[i];
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    if (h[i] == 0) continue;
    int mizuyari_value = h[i];
    ans += mizuyari_value;
    for (int j = i; j < n; j++) {
      if (h[j] < mizuyari_value) mizuyari_value = h[j];
      h[j] -= mizuyari_value;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {

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

	    String S=gs();
	    int a=S.length() - S.replace("x", "").length();
	    if(a<8) {
	    	System.out.println("YES");
	    }else {
	    	System.out.println("NO");
	    }
	}

	public static double f(double r, double n, double m, double i) {
		double a = 0;
		double b=0;
		if(0<i&&i<n) {
			a=Math.abs(r-((2*r/n)*i));
			a= Math.sqrt(Math.pow(r, 2) - Math.pow(a, 2));
		}
		if(0<i-m&&i-m<n) {
			b=Math.abs(r-(2*r*(i-m)/n));
			b=Math.sqrt(Math.pow(r, 2) - Math.pow(b, 2));
		}
		return 2* Math.max(a, b);
	}
	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}

	// doubleとして入力を取得
	public static double gd() {
		return Double.parseDouble(scanner.next());
	}
}

Measured memory_bytes: 35660
/*
*                                 Name : chaitanya
*
*                         Institute : ANITS,Visakhapatnam
*   "Don't regret anything you do, because in the end it makes you who you are."
*
*/
#include<cstdio>
#include<iostream>
#include<sstream>
#include<fstream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<complex>
#include<cstring>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<numeric>
#include<limits>
#include<climits>
#include<cfloat>
#include<functional>
#include<iterator>
#include <random>
#include<sstream>
#define infy  1000000000
#define all(x) begin(x),end(x)
#define ll long long int
#define ff first
#define ss second
#define pb push_back
const ll m = 1000000007;
#pragma GCC optimization ("O3")
using namespace std;

int main()
{

    int n;
    vector<int>v(100000);
    cin >> n;
    for (int i = 1; i <= sqrt(n) ; ++i)
    {
        for (int j = 1; j <= sqrt(n); ++j)
        {
            for (int k = 1; k <= sqrt(n); ++k)
            {
                v[i*i+j*j+k*k+i*j+j*k+k*i]++;
            }
        }
    }
    for (int i = 1; i <= n; ++i)
    {
        cout << v[i] << "\n";
    }
    return 0;
}

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

typedef pair<int, int> ii;

char S[1000005];

vector<ii> A;
vector<ii> B;

bool cmp1(ii x, ii y){
    return ii(-x.second, x.first) < ii(-y.second, y.first);
}

bool cmp2(ii x, ii y){
    return ii(x.second, -x.first) < ii(y.second, -y.first);
}


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

    int total_sum = 0;
    for(int i = 0; i < N; i ++){
        scanf(" %s", S);
        int len = strlen(S);

        int x = 0; // final sum
        int y = 0; // minimum sum encountered

        for(int j = 0; j < len; j ++){
            if(S[j] == '('){
                x ++;
            }else{
                x --;
            }
            y = min(y, x);
        }

        if(x >= 0){
            A.emplace_back(x, y);
        }else{
            B.emplace_back(-x, y-x);
        }

        total_sum += x;
    }

    if(total_sum != 0){
        printf("No");
        return 0;
    }

    sort(A.begin(), A.end(), cmp1);
    sort(B.begin(), B.end(), cmp1);

    int sum = 0;
    for(ii temp: A){
        int x = temp.first;
        int y = temp.second;
        //printf("A: ii(%d, %d)\n", x, y);
        if(sum+y < 0){
            printf("No");
            return 0;
        }
        sum += x;
    }

    sum = 0;
    for(ii temp: B){
        int x = temp.first;
        int y = temp.second;
        //printf("B: ii(%d, %d)\n", x, y);
        if(sum+y < 0){
            printf("No");
            //throw;
            return 0;
        }
        sum += x;
    }

    printf("Yes");
    return 0;
}


Measured memory_bytes: 11256
#include <bits/stdc++.h>
using namespace std;
typedef int64_t ll;

int main() {
  ll N;
  ll A;
  cin >> N;
  for (int i=1;i <= sqrt(N); i++) {
    if (N%i == 0)  A = i;
  }
  cout << A + N/A - 2 << endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <iomanip>

using namespace std;

long long MOD = 1000000007;

vector<long long> fact(200000,1);
void factorial(int N){
    for(int i=1; i<N; i++){
        fact[i+1]=(i+1)*fact[i]%MOD;
    }
}

map<long long, long long> inv_fact;
long long inv_factorial(long long x){
    if (inv_fact.count(x)){
        return inv_fact[x];
    }
    long long p=MOD-2;
    long long ret=1;
    long long tmp=x;
    while(p>0){
        if(p%2==1)ret=ret*tmp%MOD;
        tmp=tmp*tmp%MOD;
        p/=2;
    }
    inv_fact[x]=ret;
    return ret;
}

long long comb(int a, int b){
    long long ret=fact[a]*inv_factorial(fact[a-b])%MOD;
    return ret*inv_factorial(fact[b])%MOD;
}

long long pw(long long a, long long b){
    if(b==0)return 1;
    else if(b==1)return a;
    long long ret=pw(a,b/2);
    ret=(ret*ret)%MOD;
    if(b%2){
        ret=(ret*a)%MOD;
    }
    return ret;
}

int main(){
    int N;
    cin >> N;
    vector<long long> C(N,0);

    for(int i=0; i<N; i++){
        cin >> C[i];
    }
    sort(C.rbegin(), C.rend());
    /*for(int i=0; i<N-1; i++){
        C[i+1]=(C[i+1]+C[i])%MOD;
    }*/

    long long ans=0;
    factorial(N);
    for(int i=0; i<N; i++){
        ans=(ans+C[i]*(i+2))%MOD;
    }
    cout << (ans*pw(4,N-1))%MOD << endl;
}

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

using namespace std;

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

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

ll C[30];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S;
    cin >> S;
    ll N = S.length();
    ll ans = N * (N + 1) / 2;
    REP(i, N) {
        C[S[i] - 'a']++;
    }

    REP(i, 26) {
        ans -= C[i] * (C[i] + 1) / 2;
    }
    cout << ans + 1 << endl;
    return 0;
}

Measured memory_bytes: 720
//
//  3.cpp
//  practice
//
//  Created by ???????¢???? on 2017/06/11.
//  Copyright ?? 2017??´ ???????¢????. All rights reserved.
//

#include <bits/stdc++.h>
using namespace std;
#define pb push_back
map<vector<int>,int>ma,ma2;
set<vector<int> >se,se2;
vector<int>a,b;
int n;
int main(){
    cin >> n;
    for(int i=1;i<=n;i++){
        int x; cin >> x;
        a.pb(i); b.pb(x);
    }
    queue<pair<vector<int>,int> >que;
    que.push(make_pair(a,0)); ma[a] = 0;
    while(!que.empty()){
        pair<vector<int>,int> pv = que.front(); que.pop();
        if(se.find(pv.first) != se.end()) continue;
        if(pv.second == 4) continue;
        if(pv.first == b) { printf("%d",pv.second); puts(""); return 0;}
        se.insert(pv.first);
        vector<int> v = pv.first;
        for(int i=0;i<n;i++){
            for(int j=i+1;j<n;j++){
                int x = i,y = j;
                while(x<y){
                    swap(v[x],v[y]);
                    x++; y--;
                }
                if(ma.find(v) == ma.end()) ma[v] = pv.second+1;
                else ma[v] = min(ma[v],pv.second+1);
                if(se.find(v) == se.end()){
                    que.push(make_pair(v,ma[v]));
                }
                x = i,y = j;
                while(x<y){
                    swap(v[x],v[y]);
                    x++; y--;
                }
            }
        }
    }
    que.push(make_pair(b,0)); ma2[b] = 0;
    while(!que.empty()){
        pair<vector<int>,int> pv = que.front(); que.pop();
        if(se2.find(pv.first) != se2.end()) continue;
        if(pv.second == 4) continue;
        se2.insert(pv.first);
        vector<int> v = pv.first;
        for(int i=0;i<n;i++){
            for(int j=i+1;j<n;j++){
                int x = i,y = j;
                while(x<=y){
                    swap(v[x],v[y]);
                    x++; y--;
                }
                if(ma2.find(v) == ma2.end()) ma2[v] = pv.second+1;
                else ma2[v] = min(ma2[v],pv.second+1);
                if(se2.find(v) == se2.end()){
                    que.push(make_pair(v,ma2[v]));
                }
                x = i,y = j;
                while(x<=y){
                    swap(v[x],v[y]);
                    x++; y--;
                }
            }
        }
    }
    int res = 9;
    for(map<vector<int> ,int>::iterator it=ma.begin();it!=ma.end();++it){
        if(ma2.find(it->first) != ma2.end()){
            res = min(res,it->second+ma2[it->first]);
        }
    }
    cout << res << endl;
}

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

int main(){
    string s;
    cin >> s;
    bool check=false;
    int num=s.length();
    //cout << num << endl;
    
    for(int i=0; i<num; i++){
        for(int j=i+1; j<num; j++){
            if(s.at(i)==s.at(j)){
                check=true;
            }
        }
    }
    if(check) cout << "no" << endl;
    else cout << "yes" << endl;
}

Measured memory_bytes: 3584
import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long yono = 0;
        for(int i = 1 ; i <= n ; i++){
            if(i % 3 != 0 && i % 5 != 0){
                yono += i;
            }
        }
        System.out.println(yono);
    }
}

Measured memory_bytes: 35608
import java.io.*;
import java.util.StringTokenizer;

public class Main {
    public static final long mod = (long)1e9+7;
    public static final int inf = Integer.MAX_VALUE/10;

    static void solve(InputReader in, PrintWriter out){
        int a = in.ni();
        int b = in.ni();
        int c = in.ni();
        if(a==b)out.println(c);
        else if(c==b)out.println(a);
        else if(a==c)out.println(b);
    }

    public static void main(String[] args) throws Exception{
        InputReader in = new InputReader(System.in);
        PrintWriter out = new PrintWriter(System.out);
        solve(in, out);
        out.close();
    }
    public static class InputReader{
        private BufferedReader br;
        private StringTokenizer st;
        public InputReader(InputStream is){
            br = new BufferedReader(new InputStreamReader(is));
            st = null;
        }
        public String ns(){
            if(st == null || !st.hasMoreTokens()){
                try{
                    st = new StringTokenizer(br.readLine());
                }catch (Exception e){
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }
        public long nl(){
            return Long.parseLong(ns());
        }
        public int ni(){
            return Integer.parseInt(ns());
        }
        public Double nd(){
            return Double.parseDouble(ns());
        }
        public int[] ni(int n){
            int[] a = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = ni();
            }
            return a;
        }
        public long[] nl(int n){
            long[] a = new long[n];
            for (int i = 0; i < n; i++) {
                a[i] = nl();
            }
            return a;
        }
        public double[] nd(int n){
            double[] a = new double[n];
            for (int i = 0; i < n; i++) {
                a[i] = nd();
            }
            return a;
        }
    }
}

Measured memory_bytes: 21076
#include "bits/stdc++.h"
#define MAXN 100009
#define INF 1000000007
#define mp(x,y) make_pair(x,y)
#define all(v) v.begin(),v.end()
#define pb(x) push_back(x)
#define wr cout<<"----------------"<<endl;
#define ppb() pop_back()
#define tr(ii,c) for(__typeof((c).begin()) ii=(c).begin();ii!=(c).end();ii++)
#define ff first
#define ss second
#define my_little_dodge 46
#define debug(x)  cerr<< #x <<" = "<< x<<endl;
using namespace std;

typedef long long ll;
typedef pair<int,int> PII;
template<class T>bool umin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T>bool umax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
PII arr[MAXN];
bool cmp(PII x,PII y){
	if(x.ff!=y.ff)
		return (x<y);
	return (x.ss>y.ss);	
}
int main(){
    //~ freopen("file.in", "r", stdin);
    int n,m;
    scanf("%d%d",&n,&m);
    for(int i=0;i<m;i++)
		scanf("%d%d",&arr[i].ff,&arr[i].ss);
	sort(arr,arr+m,cmp);
	int ans=0,mn=INF;
	for(int i=0;i<m;i++){
		umin(mn,arr[i].ss);
		if(arr[i].ff>=mn){
			ans++;
			mn=arr[i].ss;
		}
		else
			umin(mn,arr[i].ss);
	}	
	printf("%d\n",ans+1);
	return 0;
}


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

#define ALL(obj) (obj).begin(),(obj).end()
#define SPEED cin.tie(0);ios::sync_with_stdio(false);

template<class T> using PQ = priority_queue<T>;
template<class T> using PQR = priority_queue<T,vector<T>,greater<T>>;

constexpr long long MOD = (long long)1e9 + 7;
constexpr long long MOD2 = 998244353;
constexpr long long HIGHINF = (long long)1e18;
constexpr long long LOWINF = (long long)1e15;
constexpr long double PI = 3.1415926535897932384626433L;

template <class T> vector<T> multivector(size_t N,T init){return vector<T>(N,init);}
template <class... T> auto multivector(size_t N,T... t){return vector<decltype(multivector(t...))>(N,multivector(t...));}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o;}
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const multiset<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {o << "{" << obj.first << ", " << obj.second << "}"; return o;}
template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
void print(void) {cout << endl;}
template <class Head> void print(Head&& head) {cout << head;print();}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head << " ";print(forward<Tail>(tail)...);}
template <class T> void chmax(T& a, const T b){a=max(a,b);}
template <class T> void chmin(T& a, const T b){a=min(a,b);}
void YN(bool flg) {cout << (flg ? "YES" : "NO") << endl;}
void Yn(bool flg) {cout << (flg ? "Yes" : "No") << endl;}
void yn(bool flg) {cout << (flg ? "yes" : "no") << endl;}

int main() {
    int N,K; cin >> N >> K;
    vector<int> B(N,0);
    for(int i = 0; i < K; ++i) {
        int d; cin >> d;
        for(int j = 0; j < d; ++j) {
            int A; cin >> A;
            A--;
            B[A]=1;
        }
    }
    cout << N - accumulate(ALL(B),0) << endl;
    return 0;
}


Measured memory_bytes: 3632
#include<stdio.h>
#define _USE_MATH_DEFINES
#include<math.h>
int main(void)
{
	double a,b,r;
	scanf("%lf",&r);
	a=r*r*M_PI;
	b=2*M_PI*r;
	printf("%lf %lf",a,b);
	return 0;
}

Measured memory_bytes: 648
#include<iostream>
#include<algorithm>
#include<cstdio>
using namespace std;
int a[510][510],b[510][510];
int c[510][510];char s[510];
int main()
{
	int h,w;scanf("%d%d",&h,&w);
	for(int i=1;i<=h;i++)
	{
		scanf("%s",s);
		for(int j=0;j<w;j++)c[i][j+1]=s[j]=='.'?0:1;
	}
	for(int i=1;i<=h;i++)a[i][1]=1,b[i][w]=1;
	for(int i=1;i<=h;i+=2)
		for(int j=2;j<w;j++)a[i][j]=1;
	for(int i=2;i<=h;i+=2)
		for(int j=2;j<w;j++)b[i][j]=1;
	for(int i=1;i<=h;i++)for(int j=1;j<=w;j++)if(c[i][j]==1)a[i][j]=b[i][j]=1;
	for(int i=1;i<=h;i++,printf("\n"))
	for(int j=1;j<=w;j++)
	{
		if(a[i][j]==0)printf(".");
		else printf("#");
	}
	cout<<endl;
	for(int i=1;i<=h;i++,printf("\n"))
	for(int j=1;j<=w;j++)
	{
		if(b[i][j]==0)printf(".");
		else printf("#");
	}
	return 0;
}

Measured memory_bytes: 3712
n = int(input())
tbl = []

for i in range(n):
    l = list(map(str,input().split()))
    l[1] = int(l[1])
    l2 = [l[1], l[0], i + 1]
    tbl.append(l2)

tbl.sort(key = lambda x:(x[1], -x[0]))
for i in range(n):
    print(tbl[i][2])


Measured memory_bytes: 8916
import java.util.*;

public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		String s[] = new String[n];
		long m = 0;
		long a = 0;
		long r = 0;
		long c = 0;
		long h = 0;
		for (int i = 0; i < n; i++) {
			s[i] = scan.next();
			char head = s[i].charAt(0);
			if (head == 'M') {
				m++;
			} else if (head == 'A') {
				a++;
			} else if (head == 'R') {
				r++;
			} else if (head == 'C') {
				c++;
			} else if (head == 'H') {
				h++;
			}
		}
		long sum = m*a*r + m*a*c + m*a*h + m*r*c + m*r*h + m*c*h + a*r*c + a*r*h + a*c*h + r*c*h;
		System.out.println(sum);
	}
}

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

int main(){
  int N;
  cin>>N;
  int F[N][10];
  for(int i=0;i<N;i++){
    for(int j=0;j<10;j++){
      cin>>F[i][j];
    }
  }
  int P[N][11];
  for(int i=0;i<N;i++){
    for(int j=0;j<11;j++){
      cin>>P[i][j];
    }
  }  
  
  int maxpro=(-1000000000);
  int pro=0;

  
  for(int i=1;i<(1<<10);i++){
    int C[N]={0};
    pro=0;
    for(int j=0;j<10;j++){
      if(i & (1<<j)){
        for(int k=0;k<N;k++){
          if(F[k][j]==1){
            C[k]++;
          }
        }
      }
    }
    for(int l=0;l<N;l++){
      pro+=P[l][C[l]];
    }
    maxpro=max(pro,maxpro);
  } 
  cout<<maxpro<<endl;   

  return 0;
}

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

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<ll>())
#define vunique(v) unique(v.begin(), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

ll rsl = 0;

vector<ll> divisor(ll n) {
    vector<ll> res;
	for(ll i = 1ll; i * i <= n; i++) {
		if(n % i == 0) {
			res.push_back(i);
            ll j = n / i;
			if(i != j) {
                res.push_back(j);
            }
		}
	}
    return res;
}

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

    ll n;
    cin >> n;
    vector<ll> div = divisor(n);

    for(auto r: div) {
        if(r > 1000000) continue;
        if(n > r * r + r) rsl += (n - r) / r;
    }

    cout << rsl << endl;
}


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

int main () {

	int i=0,c=0, x=0, n=0, k=0;
	double res=0;

	//cin >> n >> k;
	scanf("%d %d", &n, &k);

	for (i=1; i<=n; i++) {

		x = i; c=0;
		while (x < k) {c++; x*=2;}

		res += (1.00/(double)(n)) * pow((1.00/2.00), c);

		//cout << c << endl;
	}

	printf("%.15lf\n", res);

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, double> Pid;
typedef pair<double, int> Pdi;
typedef pair<ll, int> Pl;
typedef pair<int, pair<int, int>> PP;
const double PI = 3.1415926535897932;   // acos(-1)
const double EPS = 1e-15;
const int INF = 1001001001;
const int mod = 1e+9 + 7;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define chadd(x, y) x = (x + y) % mod

ll dp[105][4][4][4];

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

    int n;
    cin >> n;

    dp[0][3][3][3] = 1;
    for(int i = 0; i < n; ++i){
        for(int x = 0; x < 4; ++x){
            for(int j = 0; j < 4; ++j){
                for(int k = 0; k < 4; ++k){
                    for(int l = 0; l < 4; ++l){
                        if(dp[i][j][k][l] == 0) continue;

                        if(x == 1){
                            if(k == 0 && l == 2)    continue;
                            if(k == 2 && l == 0)    continue;
                            if(j == 0 && k == 2)    continue;
                            if(j == 0 && l == 2)    continue;
                        }
                        if(x == 2 && k == 0 && l == 1)  continue;

                        chadd(dp[i+1][k][l][x], dp[i][j][k][l]);
                    }
                }
            }
        }
    }

    ll res = 0;
    for(int i = 0; i < 4; ++i){
        for(int j = 0; j < 4; ++j){
            for(int k = 0; k < 4; ++k){
                chadd(res, dp[n][i][j][k]);
            }
        }
    }
    cout << res << endl;
}

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

int main()
{


    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

   int n,x;
   cin>>n>>x;
   int a[n+1]={0};
   for(int i=1;i<=n;i++)
   		cin>>a[i];
   	int c=0,d=0;
   	for(int i=1;i<=n;i++)
   	{
   		a[i]=a[i]+a[i-1];
   		if(a[i]>x)
   		{
   			d=1;
   			cout<<i<<endl;
   			break;

   		}
   	}
   	if(d!=1)
   	{
   		cout<<n+1<<endl;
   	}



}

Measured memory_bytes: 256
use std::io::{stdin, BufRead, BufReader};
fn main() {
    let input = BufReader::new(stdin());
    for line in input.lines() {
        let n: u32 = line.unwrap().trim().parse::<u32>().unwrap();
        println!("{}", combination(n));
    }
}

fn combination(n: u32) -> u32 {
    let mut c = 0;
    for i in 0..10 {
        for j in 0..10 {
            for k in 0..10 {
                for l in 0..10 {
                    if i + j + k + l == n {
                        c += 1;
                    }
                }
            }
        }
    }
    return c;
}



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

#define pb push_back
#define fst first
#define snd second
#define ALL(s) s.begin(),s.end()
#define fore(i,x,y) for(ll i=x;i<y;i++)
#define SZ(x) ((int)(x).size())
#define PI acos(-1)
#define FIN ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)

typedef long long ll;
using namespace std;

const ll mod = 1e9+7;
const int MAXN = 1e5+10;
ll dp[105][MAXN];

int main() {FIN;
    int n,k; cin>>n>>k;
    memset(dp,0,sizeof(dp));
    vector<int> v(n);
    fore(i,0,n) cin>>v[i];
    fore(i,0,v[0]+1) dp[0][k-i] = 1;
    fore(i,1,n){
        ll sum = 0;
        for(int j = k; j >=0; j--){
            sum = (sum +dp[i-1][j])%mod;
            dp[i][j] = sum;
            if(k-j>=v[i]) sum = (sum - dp[i-1][j+v[i]] + mod)%mod;
        }
    }
    cout<<dp[n-1][0]<<"\n";
    return 0;
}



Measured memory_bytes: 85656
#include <cstdio>
#include <cstdint>
#include <algorithm>
#include <utility>
#include <vector>
#include <numeric>
#include <type_traits>

intmax_t constexpr mod = 1e9+7;

template <typename Tp, size_t N>
std::vector<Tp> make_vector_detail(std::vector<size_t>& sizes, typename std::enable_if<(N == 1), const Tp&>::type x) {
  return std::vector<Tp>(sizes[0], x);
}
template <typename Tp, size_t N>
auto make_vector_detail(std::vector<size_t>& sizes, typename std::enable_if<(N > 1), const Tp&>::type x) {
  size_t size = sizes[N-1];
  sizes.pop_back();
  return std::vector<decltype(make_vector_detail<Tp, N-1>(sizes, x))>(size, make_vector_detail<Tp, N-1>(sizes, x));
}

template <typename Tp, size_t N>
auto make_vector(const size_t(&sizes)[N], const Tp& x) {
  std::vector<size_t> s(N);
  for (size_t i = 0; i < N; ++i) s[i] = sizes[N-i-1];
  return make_vector_detail<Tp, N>(s, x);
}

int main() {
  size_t N, W;
  scanf("%zu %zu", &N, &W);

  std::vector<size_t> w(N);
  for (auto& wi: w) scanf("%zu", &wi);
  std::sort(w.begin(), w.end());

  auto dp = make_vector<intmax_t>({W+1, N+1}, 0);
  dp[0][0] = 1;
  for (size_t i = 0; i < N; ++i) {
    auto next = dp;
    for (size_t j = 0; j <= W; ++j) {
      if (j + w[i] <= W) {
        (next[j+w[i]][i+1] += dp[j][i]) %= mod;
        for (size_t k = 0; k < i; ++k)
          (next[j+w[i]][k] += dp[j][k]) %= mod;
      }
    }
    dp = std::move(next);
  }

  intmax_t res = 0;
  for (size_t j = 0; j <= W; ++j) {
    (res += dp[j][N]) %= mod;
    for (size_t k = 0; k < N; ++k) {
      if (j + w[k] > W)
        (res += dp[j][k]) %= mod;
    }
  }

  printf("%jd\n", res);
}



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

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

    int ans = 0, p = 0;
    for(int i = 0; i < n; i++) {
        int h; cin >> h;
        if (p < h) ans += h - p;
        p = h;
    }

    cout << ans << endl;

    return 0;
}

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



int main()
{
    int X, Y, Z, K;
    cin >> X >> Y >> Z >> K;
    vector<long long> A(X), B(Y), C(Z);
    for(size_t i = 0; i < X; i++) cin >> A[i];
    for(size_t i = 0; i < Y; i++) cin >> B[i];
    for(size_t i = 0; i < Z; i++) cin >> C[i];
    

    sort( A.begin(), A.end(), greater<long long>() );
    sort( B.begin(), B.end(), greater<long long>() );
    sort( C.begin(), C.end(), greater<long long>() );

    vector<long long> ans;
    for(size_t i = 0; i < X; i++){
        for(size_t j = 0; j < Y; j++){
            for(size_t k = 0; k < X; ++k ){
                if( (i+1)*(j+1)*(k+1) <= K ) ans.push_back( A[i]+B[j]+C[k] );
                else break;
            }
        }
    }
    sort( ans.begin(), ans.end(), greater<long long>() );
    for(size_t i = 0; i < K; i++) cout << ans[i] << endl;

    return 0;
}


Measured memory_bytes: 1404
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long a,b,x,kari=0;
    int ans=0;
    int N=10,S=10, E=10, W=10;
    char direction[1005];

    cin>>direction;

    kari=strlen(direction);
    for(int i=0;i<kari;i++){
        if(direction[i]=='N')N=0;
        if(direction[i]=='S')S=0;
        if(direction[i]=='E')E=0;
        if(direction[i]=='W')W=0;
    }

    if(N==S&&E==W){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }

}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define int long long
#define double long double
#define all(a) a.begin(), a.end()
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; }
using namespace std;

//ABC135
signed main(void){

    int n; cin >> n;
    vector<int> a(n+1), b(n);
    rep(i, n+1)cin >> a[i];
    rep(i, n)cin >> b[i];
    int ans = 0;
    rep(i, n){
        if(a[i]>=b[i]){
            ans += b[i];
            a[i] -= b[i];
        }else{
            if(b[i]>=a[i]+a[i+1]){
                ans += a[i] + a[i+1];
                a[i] = a[i+1] = 0;
            }else{
                a[i+1] -= b[i] - a[i];
                ans += b[i];
                a[i] = 0;
            }
        }
    }
    cout << ans << endl;

}

Measured memory_bytes: 1792
n, k = map(int, input().split())
a = list(map(int, input().split()))
mod = 10 ** 9 + 7

mia = sorted([i for i in a if i < 0], reverse=True)
pla = sorted([i for i in a if i >= 0])
ans, num = 1, []

if len(pla) == 0 and k % 2 == 1:
    for i in mia[:k]:
        ans = ans * i % mod
    print(ans)
    exit()

for _ in range(k):
    if len(mia) > 0 and len(pla) > 0:
        if abs(mia[-1]) <= pla[-1]:
            tmp = pla.pop()
        elif abs(mia[-1]) > pla[-1]:
            tmp = mia.pop()
    elif len(mia) == 0:
        tmp = pla.pop()
    elif len(pla) == 0:
        tmp = mia.pop()
    num.append(tmp)

cnt = sum(i < 0 for i in num)
for i in num:
    ans = ans * i % mod

if cnt % 2 == 1:
    if len(mia) > 0 and cnt != k:
        for i in num[::-1]:
            if i >= 0:
                p, q = i, mia[-1]
                break
        if len(pla) == 0:
            ans *= q * pow(p, mod - 2, mod)
    if len(pla) > 0:
        for i in num[::-1]:
            if i < 0:
                r, s = i, pla[-1]
                break
        if len(mia) == 0 or cnt == k:
            ans *= s * pow(r, mod - 2, mod)
    if len(mia) > 0 and len(pla) > 0 and cnt != k:
        if q * r >= p * s:
            ans *= q * pow(p, mod - 2, mod)
        if q * r < p * s:
            ans *= s * pow(r, mod - 2, mod)
    ans %= mod
print(ans)


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

long long mod=1000000007ll;
long long v[10010],P[10010],rP[10010];

void pre(int N)
{
  v[1]=1;
  for(int i=2;i<N;i++){
    v[i]=(mod-mod/i)*v[mod%i]%mod;
  }
  P[0]=rP[0]=1ll;
  for(int i=1;i<N;i++){
    P[i]=P[i-1]*i%mod;
    rP[i]=rP[i-1]*v[i]%mod;
  }
}

long long C(int a,int b)
{
  return P[a]*rP[b]%mod*rP[a-b]%mod;
}

int main()
{
  pre(10010);
  int n,a,b,c;
  scanf("%d%d%d%d",&n,&a,&b,&c);
  if(b%2!=0){
    printf("0\n");
    return 0;
  }
  b/=2;
  long long ans=0ll;
  for(int x=0;x<=a;x++){
    for(int y=0;(a-x)+3*y<=c;y++){
      int m=a+y,r=c-(a-x)-3*y;
      long long P=C(m,a)%mod*C(a,x)%mod,Q;
      if(b==0){
	Q=(r==0?1:0);
      }
      else{
	Q=C(b+m,m)*C(r+b-1,b-1)%mod;
      }
      ans+=P*Q%mod;
      ans%=mod;
    }
  }
  printf("%lld\n",ans);
  return 0;
}


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

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

    static class ABeginner {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int contesrrate = in.nextInt();
            if (n >= 10) out.println(contesrrate);
            else out.println(contesrrate + (100 * (10 - n)));
        }

    }

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

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

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

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

    }
}



Measured memory_bytes: 20052
#include<bits/stdc++.h>
#define INF 9223372036854775807LL
#define inf 1000000007
#define SYOU(x) setprecision(x+1)
#define abs(x,y) (max(x,y)-min(x,y))
#define lol long long
#define mp make_pair
#define fi first
#define se second
using namespace std;
lol a,b,c,d;
int mem[600][600];
signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,M,Q;
    cin >>N>>M>>Q;
    for(int i=0;i<M;i++){
	cin >>c>>d;
	mem[c][d]++;
    }
    for(int i=1;i<=N;i++){
	for(int j=1;j<=N;j++){
	    mem[i][j]+=mem[i-1][j]+mem[i][j-1]-mem[i-1][j-1];
	}
    }
    for(int i=0;i<Q;i++){
	cin >>c>>d;
	cout <<mem[d][d]-mem[c-1][d]-mem[d][c-1]+mem[c-1][c-1]<<'\n';
    }
    return (0);
}


Measured memory_bytes: 2176
#include <iostream>

//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <tuple>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

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

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

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

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

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

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0, sizeof(a))

//debug
// #define dump(x) cerr << #x << " = " << (x) << endl;
// #define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
//                       << " " << __FILE__ << endl;

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

    VI B;
    REP(i, n - 1)
    {
        int b;
        cin >> b;
        B.push_back(b);
    }

    int answer = 0;

    //first
    answer += B[0];

    FOR(i, 1, n - 1)
    {
        answer += min(B[i], B[i - 1]);
    }
    answer += B[n - 2];

    cout << answer << endl;
}


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

int main(){
  int n,k;
  cin >> n >> k;
  vector<int> d(k);
  vector<bool> a(10,true);
  for(int i=0;i<k;i++){
    cin >> d[i];
    a[d[i]]=false;
  }
  while(n){
    int t=n;
    bool b=true;
    while(t){
      if(!a[t%10]){
        b=false;
        break;
      }
      t/=10;
    }
    if(b){
      cout << n << endl;
      return 0;
    }
    n++;
  }
}

Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author ParsaAlizadeh
 */

#include <bits/stdc++.h>
using namespace std;

typedef long long int   ll;
typedef long double     ld;
typedef pair<ll, ll>    pll;
typedef pair<int, int>  pii;

#define all(x)          x.begin(), x.end()
#define kill(x)         return cout << x << endl, 0
#define X               first
#define Y               second
#define sep             ' '
#define endl            '\n'
#define file_io         freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);

ll pw(ll a, ll b, ll mod) {
    if (!b)    return 1;
    if (b & 1) return a * pw(a * a % mod, b / 2, mod) % mod;
    return pw(a * a % mod, b / 2, mod) % mod;
}

const ll MAXN  = 1e5 + 10;
const ll INF   = 8e18;
const ll MOD   = 1e9 + 7; // 998244353;

ll n, m, mark[MAXN], col[MAXN], ans, cnt[3], degsm;
vector<pll> adj[MAXN];
bool flag = true;

void DFS(ll u) {
    mark[u] = 1;
    degsm += adj[u].size();
    cnt[col[u]]++;
    for (const pll e : adj[u]) {
        ll c = (col[u] + e.Y + 3) % 3;
        if (mark[e.X]) {
            flag &= (col[e.X] == c);
            continue;
        }
        col[e.X] = c;
        DFS(e.X);
    }
}

int main() {
    ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
    cin >> n >> m;
    for (ll i = 0; i < m; i++) {
        int u, v; cin >> u >> v;
        adj[u].emplace_back(v, +1);
        adj[v].emplace_back(u, -1);
    }
    for (ll i = 1; i <= n; i++) {
        if (mark[i]) continue;
        cnt[0] = cnt[1] = cnt[2] = degsm = 0;
        flag = true;
        DFS(i);
        if (!flag)
            ans += (cnt[0] + cnt[1] + cnt[2]) * (cnt[0] + cnt[1] + cnt[2]);
        else if (cnt[0] && cnt[1] && cnt[2])
            ans += cnt[0] * cnt[1] + cnt[1] * cnt[2] + cnt[2] * cnt[0];
        else
            ans += degsm / 2;
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 13568
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using VI = vector<int>;
using VL = vector<ll>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);--(i))
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define END(a) {cout << (a) << "\n"; return 0;}
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
const long double pi = acos(-1);
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; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& input, vector<T>& v) { for (auto& elemnt : v)input >> elemnt; return input; }

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

int main() {
    init();

    ll a, b; cin >> a >> b;
    ll x = gcd(a, b);

    map<ll, int> map;
    for (ll i = 2; i * i <= x; ++i) {
        while (x % i == 0) {
            ++map[i];
            x /= i;
        }
    }
    if (x != 1)++map[x];
    cout << map.size() + 1 << "\n";
}

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

using namespace std;
typedef long long i64;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef unordered_set<int> si;
typedef pair<int, int> ii;

#define mp make_pair
#define all(n) (n).begin(), (n).end()

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)


template <typename T>
void printV(vector<T> A) {
    if (A.empty()) cerr << "EMTPY\n";
    else { 
        cerr << "\n[";
        for (int i = 0; i < A.size() -1 ; ++i) {
            cerr << A[i] << ", ";
        }
        if (A.size()) cerr << A.back() << "]\n";
    }
}


template <typename T>
void printVV(vector<vector<T>> A) {
    cerr << "\n[";
    for (auto v : A) {
        printV<T>(v);
    }
    cerr << "]\n";
}

template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
    cerr << name << ": " << arg1 << endl;
}

template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&& ...args) {
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << ": " << arg1 << " |";
    __f(comma + 1, args...);
}


int helper(string s) {
    int a = 0, b = s.size() -1;
    int ret = 0;
    while (a < b) {
       ret += s[a++] != s[b--]; 
    }
    return ret;
}

int main(int argc, char **argv) {
    string s;
    cin >> s;
    cout << helper(s) << endl;
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <ios> 
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>
#include <map>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define sz(c) ((int)(c).size())

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
//const int MAX=;

void ans(bool x){
	if(x)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}

int main(){
	int N,A,B,C,D;
	cin>>N>>A>>B>>C>>D;
	A--;B--;C--;D--;
	string S;
	cin>>S;
	bool rs=true, rf=true;
	for(int i=A; i<C; i++)if(S[i]=='#' && S[i+1]=='#')rs=false;
	for(int i=B; i<D; i++)if(S[i]=='#' && S[i+1]=='#')rf=false;
	if(D<C){
		bool jump=false;
		for(int i=B; i<=D; i++)if(S[i-1]=='.' && S[i]=='.' && S[i+1]=='.') jump=true;
		ans(rs && rf && jump);
	}
	else{
		ans(rs && rf);
	}
}

Measured memory_bytes: 640
#include<iostream>
using namespace std;
int main()
{

while(1)
{
int n,num;
string sig="0000000",str;
cin>>n;
if(n==-1)break;
for(int k=0;k<n;k++)
{
cin>>num;
string ans="";

if(num==0)str="0111111";
else if(num==1)str="0000110";
else if(num==2)str="1011011";
else if(num==3)str="1001111";
else if(num==4)str="1100110";
else if(num==5)str="1101101";
else if(num==6)str="1111101";
else if(num==7)str="0100111";
else if(num==8)str="1111111";
else str="1101111";
for(int i=0;i<7;i++)
{
if(sig.at(i)!=str.at(i))ans+='1';
else ans+='0';
}
sig=str;
cout<<ans<<endl;
}
}
return 0;
}

Measured memory_bytes: 1204