akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(var,cnt) for(int (var)=0; (var)<(int)(cnt); ++(var))
#define Rep(var,init,cnt) for(int (var)=(init); (var)<(cnt); ++(var))
#define ran(var,vec) for(auto &(var):(vec))
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define SORT(v) sort(all(v))
#define RSORT(v) sort(rall(v))
#define SUM(v) accumulate(all(v),0)
#define tget(tp,idx) get<idx>(tp)
#define TF(flag) (flag)?1:0
#define yn(f) cout<<(f?"yes":"no")<<endl
#define Yn(f) cout<<(f?"Yes":"No")<<endl
#define YN(f) cout<<(f?"YES":"NO")<<endl
#define COUT(x) cout<<(x)<<endl
using namespace std;

using ll = long long;
using ull = unsigned long long;
using pi = pair<int,int>;
using pl = pair<ll,ll>;
using ti = tuple<int,int,int>;
using tl = tuple<ll,ll,ll>;

template<typename T>
using vec = vector<T>;
template<typename T>
using mat = vector<vec<T>>;
template<typename T>
using cub = vector<mat<T>>;
template<typename T>
using val = valarray<T>;

template<typename T>
using pq = priority_queue<T>;
template<typename T>
using rpq = priority_queue<T,vec<T>,greater<T>>;

template<typename T1,typename T2>
ostream &operator<<(ostream &os, const pair<T1,T2> &p){
  os<<"P("<<p.first<<", "<<p.second<<") ";
  return os;
}

template<typename T1,typename T2>
istream &operator>>(istream &is, pair<T1,T2> &p){
  is>>p.first>>p.second;
  return is;
}

template<typename T>
ostream &operator<<(ostream &os, const vector<T> &v){
  cout<<"V{";
  for(int i=0; i<(int)v.size(); ++i){
    os<<v[i]<<(i+1!=v.size()?" ":"");
  }
  cout<<"}";
  return os;
}

template<typename T>
istream &operator>>(istream &is, vector<T> &v){
  for(T &in:v) is>>in;
  return is;
}

template<typename T>
ostream &operator<<(ostream &os, const valarray<T> &v){
  cout<<"V{";
  for(int i=0; i<(int)v.size(); ++i){
    os<<v[i]<<(i+1!=v.size()?" ":"");
  }
  cout<<"}";
  return os;
}

template<typename T>
istream &operator>>(istream &is, valarray<T> &v){
  for(T &in:v) is>>in;
  return is;
}

// Usual Template End ================================================

// Template End ======================================================

constexpr int MOD=1e9+7;

int main(void){
  string s; cin>>s; int ans=0; rep(i,4) ans+=(s[i]=='+'?1:-1); COUT(ans);
}













Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<bitset>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
typedef long long int ll;
typedef pair<int,int> P;
struct edge{int to,cost;};
#define REP(i,n) for(int i=0;i<(n);i++)
const int INF=100000000;

int main(){
	ll a,b,c,k;
	cin>>a>>b>>c>>k;
	if(k%2!=0){
		cout<<(b-a)<<endl;
	}
	else{
		cout<<a-b<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
n,k = map(int,input().split())
n += 1
mod = 10**9 + 7
ans = 0

for i in range(k, n+1):
  ans += n * (n+1) // 2 - (n-i) * (n-i+1) // 2 - i * (i+1) // 2 + 1
  ans %= mod

print(ans)

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

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

	int c[n],b[n];
	int aa=1000,count=0;


	for (int i = 0; i < n; i++){
		cin>>c[i]>>b[i];

		if(t>=b[i]){
			if(aa>=c[i]){
				aa=c[i];
			}
			
		}else{
			count++;
		}

	}

	if(count==n){
		cout<<"TLE"<<endl;
	}else{
		cout<<aa<<endl;
	}

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/range/adaptor/reversed.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
typedef long long int ll;

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

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define dumparr(x) cerr << #x ; for(auto elem: x){cerr << " " << elem;} cerr << endl;
#define dumppairs(x) cerr << #x ; for(auto elem: x){cerr << "(" << elem.first << " " << elem.second << ") ";} cerr << endl;
#define dumpline cerr << "**********************" << endl;
#define dumpwline(x) cerr << "******** " << #x << "=" << (x) << " ********" << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))


ll d = 998244353;

ll gyaku(ll num){
    ll ret = 1;
    ll e = d-2;
    ll bai = num;
    while(e > 0){
        if (e%2 == 1){
            ret *= bai;
            ret %= d;
        }
        bai = bai*bai;
        bai %= d;
        e /= 2;
    }
    return ret;
}

int main(void){
    ll n; cin >> n;
    ll m; cin >> m;
    ll k; cin >> k;
    ll ans = 0;
    ll now = m;
    if ((m == 1) && n-k == 1){
        cout << 1 << endl;
        return 0;
    }
    REP(i, n-1){
        now *= (m-1);
        now %= d;
    }
    ans = now;
    for(int i=1; i<=k; i++){
        now *= gyaku(m-1); now %= d;
        now *= (n-i); now %= d;
        now *= gyaku(i); now %= d;
        ans += now;
        ans %= d;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3544
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <string>
#include <queue>

using namespace std;

typedef long long int ll;
typedef long int li;

int main(void){
    ll a,b,c;
    cin >> a >> b >> c;
    ll ans=0;
    if(c<=a+b+1)ans=c+b;
    if(c>=a+b+2){
        ans = a+b+b+1;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;
class Main{
	static final long MOD = 1_000_000_007; // 10^9+7
    static final int MAX = 2_147_483_646; // intMax 
    static final int INF = 1_000_000_000; // 10^9  
    public static void main(String[] args) throws Exception {
		hayami saori = new hayami();
		int n = saori.saori_hayami();
		int k = saori.saori_hayami();
		System.out.println(n-(k-1));
		saori.close();
    }
}

class hayami implements Closeable {
	private final InputStream in = System.in;
	private final byte[] hayami = new byte[1024];
	private int Hayami = 0;
	private int saori = 0;
	private boolean HayamiSaori() {
		if (Hayami < saori) {
			return true;
		}else{
			Hayami = 0;
			try {
				saori = in.read(hayami);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (saori <= 0) {
				return false;
			}
		}
		return true;
	}
	private int SaoriHayami() { 
		if (HayamiSaori()) {
            return hayami[Hayami++];
         }else{
             return -1;
         }
	}
	private static boolean hayami_saori(int hayami) { 
		return 33 <= hayami && hayami <= 126;
	}
	public boolean hayamisaori() { 
		while(HayamiSaori() && !hayami_saori(hayami[Hayami])) Hayami++; return HayamiSaori();
	}
	public String nextHayami() {
		if (!hayamisaori()) throw new NoSuchElementException();
		StringBuilder hayamin = new StringBuilder();
		int saori = SaoriHayami();
		while(hayami_saori(saori)) {
			hayamin.appendCodePoint(saori);
			saori = SaoriHayami();
		}
		return hayamin.toString();
	}
	public long saorihayami() {//nextLong
		if (!hayamisaori()) throw new NoSuchElementException();
		long hayami = 0;
		boolean misao = false;
		int saori = SaoriHayami();
		if (saori == '-') {
			misao = true;
			saori = SaoriHayami();
		}
		if (saori < '0' || '9' < saori) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= saori && saori <= '9') {
				hayami *= 10;
				hayami += saori - '0';
			}else if(saori == -1 || !hayami_saori(saori)){
				return misao ? -hayami : hayami;
			}else{
				throw new NumberFormatException();
			}
			saori = SaoriHayami();
		}
	}
	public int saori_hayami() {//nextInt
		long hayami = saorihayami();
		if (hayami < Integer.MIN_VALUE || hayami > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) hayami;
	}
	public double Hayamin() { //nextDouble
		return Double.parseDouble(nextHayami());
	}
	public void close() {
		try {
			in.close();
		} catch (IOException e) {
		}
    }
    
}

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

using namespace std;

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define between(a,x,b) ((a)<=(x)&&(x)<=(b))
#define F first
#define S second
#define INF 1 << 30

int main(){
  int n, half;
  scanf("%d", &n);
  string l, r, h, ts;
  while(n--){
    string key, res;
    cin >> key >> res;
    char tmp;
    for(int i = key.size()-1; i >= 0; i--){ //    rep(i, key.size()){
      switch(key[i]){
      case 'C': //      case 'J':
	tmp = res[0];
	res.erase(res.begin());
	res += tmp;
	break;
      case 'J': //      case 'C':
	tmp = res[res.size()-1];
	res.erase(res.begin()+res.size()-1);
	res.insert(res.begin(), 1, tmp);
	break;
      case 'E':
        half = (int)res.size()/2;
	l = res.substr(0, half);
	r = res.substr(res.size()-half, half);
	h = "";
	if((int)res.size()%2) h = res[half];
	res = r + h + l;
	break;
      case 'A':
	ts = "";
	for(int i = res.size()-1; i >= 0; i--) ts += res[i];
	res = ts;
	break;
      case 'M': //	case 'P':
	rep(i, res.size()) if(isdigit(res[i])) res[i] = (res[i]=='9')?'0':res[i]+1;
	break;
      case 'P': //      case 'M':
	rep(i, res.size()) if(isdigit(res[i])) res[i] = (res[i]=='0')?'9':res[i]-1;
	break;
      }
    }

    cout << res << endl;
  }
  return 0;
}

Measured memory_bytes: 1252
#include<iostream>
using namespace std;
int main() {
	int n, m;
	cin >> n >> m;
	int a[110][110];
	int c[110] = { 0 };
	for (int i = 0; i < n; i++){
		for (int j = 0; j < m; j++) {
			cin >> a[i][j];
		}
	}
	for (int i = 0; i < m; i++){
		int k; cin >> k;
		for (int j = 0; j < n; j++){
			a[j][i] *= k;
		}
	}
	for (int i = 0; i < n; i++){
		for (int j = 0; j < m; j++){
			c[i] += a[i][j];
		}
	}
	for (int i = 0; i < n; i++){
		cout << c[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 3132
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>

#define REP(n) for(int i = 0;i < n;i++)
#define LLREP(n) for(long long int  i = 0;i < n;i++)
typedef long long int ll;
using namespace std;
#define MAX_A 100005

int main(){


    ll d,n;
    cin >> d >> n;
    ll ans =  pow(100,d)*n;

    if(n == 100){
        ans = pow(100,d)*(n+1);
        cout << ans << endl;
    }else{
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define rep(i,n) for (int i=0;i<(int)(n);i++)
#define codefor int test;scanf("%d",&test);while(test--)
#define yn(ans) if(ans)printf("Yes\n");else printf("No\n")
#define YN(ans) if(ans)printf("YES\n");else printf("NO\n")
#define umap unordered_map
#define uset unordered_set
using namespace std;
using ll = long long;
//入力系
void scan(int& a){scanf("%d",&a);}
void scan(long long& a){scanf("%lld",&a);}
template<class T> void scan(T& a){cin>>a;}
template<class T> void scan(vector<T>& vec){for(auto&& it:vec)scan(it);}
void in(){}
template <class Head, class... Tail> void in(Head& head, Tail&... tail){scan(head);in(tail...);}
//出力系
void print(const int& a){printf("%d",a);}
void print(const long long& a){printf("%lld",a);}
void print(const double& a){printf("%.15lf",a);}
template<class T> void print(const T& a){cout<<a;}
template<class T> void print(const vector<T>& vec){if(vec.empty())return;print(vec[0]);for(auto it=vec.begin();++it!= vec.end();){putchar(' ');print(*it);}}
void out(){putchar('\n');}
template<class T> void out(const T& t){print(t);putchar('\n');}
template <class Head, class... Tail> void out(const Head& head,const Tail&... tail){print(head);putchar(' ');out(tail...);}
//デバッグ系
template<class T> void dprint(const T& a){cerr<<a;}
template<class T> void dprint(const vector<T>& vec){if(vec.empty())return;cerr<<vec[0];for(auto it=vec.begin();++it!= vec.end();){cerr<<" "<<*it;}}
void debug(){cerr<<endl;}
template<class T> void debug(const T& t){dprint(t);cerr<<endl;}
template <class Head, class... Tail> void debug(const Head& head, const Tail&... tail){dprint(head);cerr<<" ";debug(tail...);}

int main(){
    ll n,d;
    in(n,d);
    ll ans=0,x,y;
    rep(i,n){
        in(x,y);
        if(x*x+y*y<=d*d)ans++;
    }
    out(ans);
}

Measured memory_bytes: 3828
from collections import deque
n , m = map(int,input().split())
z = [[] for i in range(n)]
for i in range(m):
    l , r , d = map(int,input().split())
    z[l-1].append((r-1,d))
    z[r-1].append((l-1,-d))

visit = [False for i in range(n)]
x = [-1 for i in range(n)]
for i in range(n):
    if visit[i]:
        continue
    visit[i] = True
    q = deque()
    q.append(i)
    x[i] = 0
    while q:
        now = q.popleft()
        for t , d in z[now]:
            if not visit[t]:
                visit[t] = True
                x[t] = x[now] + d
                q.append(t)
            elif visit[t]:
                if x[t] - x[now] != d:
                    print("No")
                    exit()
print("Yes")

Measured memory_bytes: 116952
#include <algorithm>
#include <bitset>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, f, n) for (ll i = (f); i < (n); i++)
#define repv(v) for (auto it = (v).begin(); it != (v).end(); it++)
ll const INF = 1LL << 60;
ll const MAX_N = 510000;
ll const MOD = 1000000007;

int main() {
    ll N;
    string S;
    cin >> N >> S;

    vector<ll> alph(26);

    rep(i, N) alph[S[i] - 'a']++;

    sort(alph.begin(), alph.end(), greater<ll>());

    alph.erase(remove(alph.begin(), alph.end(), 0), alph.end());

    // repv(alph) cout << *it << " ";
    // cout << endl;

    ll ans = 1;
    rep(i, alph.size()) {
        ans *= (alph[i] + 1);
        ans = ans % MOD;
    }
    cout << ans - 1 << endl;

    // for (ll bit = 0; bit < (1 << alph.size()); bit++) {
    //     ll prod = 1;
    //     ll cnt = 0;
    //     for (ll i = 0; i < alph.size(); i++) {
    //         if (bit & (1 << i)) {
    //             cnt++;
    //             prod *= alph[i];
    //         }
    //     }

    //     if (cnt > 0) ans += (prod % MOD);

    //     // cout << showbase;
    //     // cout << bitset<10>(bit);
    //     // cout << noshowbase;
    //     // cout << ":" << prod << ", ans:" << ans << endl;
    // }
    // cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3652
//{{{
#include<algorithm>
#include<cmath>
#include<deque>
#include<fstream>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<random>
#include<set>
#include<sstream>
#include<sys/time.h>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(printde) FUNC(printdbe) FUNC(printdwe) FUNC(printdu);
#endif
template <template <class T, class = std::allocator<T>> class V, class E>
istream& operator >> (istream& in, V<E>& v){ for(auto& e : v){ in >> e; } return in; }
//}}}

vector<int> cnts;
struct Graph{
    struct Node{
        vector<int> dests;
        int id;
        int l;
    };
    vector<Node> nodes;
    Graph(int num): nodes(num){ }
    // int id(Node* n){ return n - &nodes[0]; }
    // int id(Node& n){ return &n - &nodes[0]; }
    // void print(){ for(auto& node : nodes){ prints(id(node), node.dests); } }
    void add1Edge(int from, int dest){
        nodes[from].dests.push_back(dest);
    }
    void add2Edge2(int from, int dest){
        add1Edge(from, dest);
        add1Edge(dest, from);
    }
    void dfs(int idx, int& cnt, int from = -1){
        nodes[idx].l = cnt;
        for(int didx : nodes[idx].dests){
            if(didx == from){ continue; }
            dfs(didx, cnt, idx);
        }
        nodes[idx].id = cnt;
        cnt++;
    }
};

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    int n, q;
    cin >> n >> q;
    Graph g(n);
    cnts.resize(n + 1);
    for(int i = 0; i < n - 1; i++){
        int a, b;
        cin >> a >> b;
        a--; b--;
        g.add2Edge2(a, b);
    }
    int cnt = 0;
    g.dfs(0, cnt);
    for(int i = 0; i < q; i++){
        int p, x;
        cin >> p >> x;
        p--;
        cnts[g.nodes[p].l] += x;
        cnts[g.nodes[p].id + 1] += -x;
    }
    printde(cnts);
    for(int i = 0; i < n; i++){
        cnts[i + 1] += cnts[i];
    }
    for(int i = 0; i < n; i++){
        cout << cnts[g.nodes[i].id] << ' ';
    }
}


Measured memory_bytes: 28160
#include <iostream>
using namespace std;
#define INF 1000000007
#define ll long long
#define rep(i, start, end) for(ll i=(ll)start; i<(ll)end; i++)
#define print(a) cout << a << endl;
#define printarray(a, len) rep(i,0,len) cout << a[i] << " ";

int main(){
  ll a;
  string s;
  cin >> a;
  cin >> s;
  
  if (a >= 3200){
    print(s); 
  }else {
    print("red");
  }
  
  return 0;
}


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

int main(){
  ll x;
  cin >> x;
  ll res = x/11 * 2;
  if (x%11 != 0) {
    if (x%11 < 7) res++;
    else res += 2;
  }
  cout << res << endl;
  return 0;
} 

Measured memory_bytes: 256
n = int(input())
xy = [tuple(map(int, input().split())) for _ in range(n)]
s_xy = set(xy)

count = 0
for i in range(n-1):
    for j in range(i+1, n):
        p, q = xy[j][0] - xy[i][0], xy[j][1] - xy[i][1]
        tc = sum((x-p,y-q) in xy for x, y in s_xy)
        count = max(count, tc)

print(n-count)

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

using ll = long long;
using db = double;
using pll = pair < ll, ll >;

#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template < typename Arg1 >
void __f(const char* name, Arg1&& arg1) {
	cerr << name << ':' << arg1 << std :: 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...);
}
#else
#define trace(...)
#endif

#define pb push_back
#define mp make_pair
#define fastIo() ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0)

const int MOD = 1e9 + 7, INF = INT_MAX, N = 1e5 + 10;
int main(){
	ll n, k; cin >> n >> k;
	n = n % k;
	if(abs(n - k) <= n) {
		cout << abs(n - k);
	}
	else cout << n;
}

Measured memory_bytes: 256
#include<algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<iostream>
#include<vector>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<string>
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define ll long long 
using namespace std;
int main(){
  int n,i;
  cin >>n;
  i=1;
  while(i<=n) i *= 2;
  cout <<i/2<<endl;
}

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


int main() {
	int n;
	cin >> n;
	vector<string> s(n);
	for (auto& i : s)cin >>i;
	int ab = 0;
	int b_x = 0;
	int x_a = 0;
	int b_a = 0;
	int ans = 0;
	for (auto i : s) {
		for (int j = 0; j < i.size() - 1; j++) {
			if (i[j] == 'A' && i[j + 1] == 'B')ab++;
		}
		if (i.front() != 'B' && i.back() == 'A')x_a++;
		if (i.front() == 'B' && i.back() != 'A')b_x++;
		if (i.front() == 'B' && i.back() == 'A')b_a++;
	}
	if (b_a == 0) {
		ans = min(b_x, x_a);
	}
	else {
		if (x_a == 0 && b_x == 0) {
			ans= b_a - 1;
		}
		else if (x_a == 0 || b_x == 0) {
			ans = b_a;
		}
		else {
			ans = b_a + 1 + min(b_x-1, x_a-1);
		}
	}
	cout << ans + ab << endl;
	return 0;
}

Measured memory_bytes: 768
import java.util.Scanner;

public class Main {

    public static void main(String[] args){

        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();

        for(int i=0; i<50000; i++) {
            if(n == (int)(i * 1.08d)) {
                System.out.println(i);
                return ;
            }
        }
        System.out.println(":(");


    }

}


Measured memory_bytes: 22228
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define vi vector<int>
#define all(a) a.begin(),a.end()
string c[10];
signed main(){
    int h,w,k;cin>>h>>w>>k;
    rep(i,h)cin>>c[i];

    int ans=0;
    rep(i,1<<h){
        rep(j,1<<w){
            int cnt=0;
            rep(l,h){
                rep(m,w){
                    if(i&(1<<l)&&j&(1<<m)&&c[l][m]=='#')cnt++;
                }
            }
            if(cnt==k)ans++;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5 + 10;
vector<int> frd[MAXN], block[MAXN];
bool vis[MAXN];
int siz[MAXN], idx[MAXN], nidx;

void dfs(int u){
	vis[u] = true;
	idx[u] = nidx;
	siz[nidx]++;
	for (int v : frd[u]){
		if (!vis[v]){
			dfs(v);
		}
	}
}

int main(){
	ios::sync_with_stdio(0);
	cout << setprecision(10) << fixed;
	int n, m, k;
	siz[0] = 1;
	cin >> n >> m >> k;
	for (int i = 0; i < m; ++i){
		int u, v;
		cin >> u >> v;
		frd[u].push_back(v);
		frd[v].push_back(u);
	}
	for (int i = 0; i < k; ++i){
		int u, v;
		cin >> u >> v;
		block[u].push_back(v);
		block[v].push_back(u);
	}
	for (int i = 1; i <= n; ++i){
		if (!vis[i]){
			nidx++;
			dfs(i);		
		}
	}
	vector<int> res(n + 1);
	for (int i = 1; i <= n; ++i){
		res[i] = siz[idx[i]] - frd[i].size() - 1;
		for (int cancel : block[i]){
			if (idx[i] == idx[cancel]){
				res[i]--;
			}
		}

	}
	for (int i = 1; i <= n; ++i){
		cout << res[i] << " ";
	}
	return 0;
}



Measured memory_bytes: 12800
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		// TODO ?????????????????????????????????????????????
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		while(true){
			String input = br.readLine();
			
			if(input.equals("-")){
				break;

			}
			
			int m = Integer.parseInt(br.readLine());

			//StringBuffer sb = new StringBuffer();
			for(int i = 0; i < m ; i++){
				StringBuffer sb = new StringBuffer();
				int h = Integer.parseInt(br.readLine());
				
				sb.append(input.substring(h, input.length()));
				sb.append(input.substring(0, h));
				
				input = sb.toString();
//				System.out.println("i = "+i+" "+input);
			}
			
			System.out.println(input);

		}
		
//		System.out.println(count);

//
//			if(Character.isLowerCase(c)){
//				System.out.print(Character.toUpperCase(c));
//			}
//
//			else if(Character.isUpperCase(c)){
//				System.out.print(Character.toLowerCase(c));
//			}
//			else {
//				System.out.print(c);
//			}
//		}
//		System.out.println();

//		String[] tmpArray = br.readLine().split(" ");
//		int n = Integer.parseInt(tmpArray[0]);
//		int m = Integer.parseInt(tmpArray[1]);
//		int l = Integer.parseInt(tmpArray[2]);
//
//		long[][] a = new long[n][m];
//		long[][] b = new long[m][l];
//		long[][] c = new long[n][l];
//
//		for(int i = 0; i < n; i ++){
//			tmpArray = br.readLine().split(" ");
//			for(int j = 0; j < m; j++){
//				a[i][j] = Long.parseLong(tmpArray[j]);
//			}
//		}
//
//		for(int i = 0; i < m; i ++){
//			tmpArray = br.readLine().split(" ");
//			for(int j = 0; j < l; j++){
//				b[i][j] = Integer.parseInt(tmpArray[j]);
//			}
//		}
//
//		for(int i = 0; i < n; i++){
//			for(int j = 0; j < l; j++){
//				for(int k = 0; k < m; k++){
//					c[i][j] += a[i][k]*b[k][j];
//				}
//
//				if(j != 0 ){
//					System.out.print(" ");
//				}
//				System.out.print(c[i][j]);
//			}
//			System.out.println();
//		}


	}

}

Measured memory_bytes: 24728
#include <bits/stdc++.h>
using namespace std;
#define     ll      long long
#define     pb      push_back
#define     F       first
#define     S       second
#define     n1      "\n"
#define     sz      size()
#define     cinfast ios_base::sync_with_stdio(false); cin.tie(NULL);
vector <int> v[100010];
vector < ll > x ;

int main ()
{
x.pb(0);
int n , m; cin >> n >> m ;
for (int i = 1; i<=n ; ++i){
    ll h ; cin >> h ;
    x.pb(h);
}
for (int i = 1; i<=m ; ++i){
    int a , b ;
    cin >> a >> b ;
    v[a].pb(b);
    v[b].pb(a);
}
int ans=0;
for (int i = 1; i<= n ; ++i){
        bool t=1;
    for (int j = 0 ; j< v[i].sz ; ++j){
        if (x[v[i][j]]>=x[i])t=0;
    }
    if (t)ans++;
}
cout << ans ;
}

Measured memory_bytes: 9228
#ライブラリインポート
from collections import defaultdict

#入力受け取り
def getlist():
	return list(map(int, input().split()))

#処理内容
def main():
	S = list(input())
	N = len(S)
	s = [0] * (N + 1)
	for i in range(N):
		if S[i] == "A":
			s[i + 1] += s[i] + 2
		else:
			s[i + 1] += s[i] + 1
	T = list(input())
	M = len(T)
	t = [0] * (M + 1)
	for i in range(M):
		if T[i] == "A":
			t[i + 1] += t[i] + 2
		else:
			t[i + 1] += t[i] + 1
	Q = int(input())
	for i in range(Q):
		a, b, c, d = getlist()
		if ((s[b] - s[a - 1]) - (t[d] - t[c - 1])) % 3 == 0:
			print("YES")
		else:
			print("NO")

if __name__ == '__main__':
	main()

Measured memory_bytes: 15068
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cstdio>
using namespace std;
typedef unsigned long long ull;
ull base=131;
ull a[200010];
char s[11];
int n,ans=1;
int prime=233317; 
ull mod=212370440130137957ll;
ull hashe(char s[])
{
    int len=strlen(s);
    ull ans=0;
    for (int i=0;i<len;i++)
    ans=(ans*base+(ull)s[i])%mod+prime;
    return ans;
}
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        scanf("%s",s);
        a[i]=hashe(s);
    }
    sort(a+1,a+n+1);
    for(int i=1;i<n;i++)
    {
        if(a[i]!=a[i+1])
        ans++;
    }
    printf("%d",ans);
} 

Measured memory_bytes: 5380
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v)   (v).begin(),(v).end()
#define debug(x) cerr<<#x<<": "<<(x)<<endl
#define INF      (int)1e9
#define MOD      ((int)1e9+7)
using namespace std;
typedef long long     llong;
typedef pair<int,int> pii;
typedef vector<int>   vi;
typedef vector<vi >   vvi;
typedef vector<vvi >  vvvi;
template<class Type> void line(const Type &a){int cnt=0;for(auto &elem:a){if(cnt++)cout<<' ';cout<<elem;}cout<<endl;}

int n,k;
int a[3];
string t;
vi tt;
vvi dp;

void f(){
	REP(i,n){
		if(i-k<0){
			REP(j,3){
				if(j==tt[i]) dp[i][j]=a[j];
				else dp[i][j]=0;
			}
		}else{
			REP(j,3){
				if(j==tt[i]){
					int tmp=0;
					REP(l,3) if(l!=j) tmp=max(tmp,dp[i-k][l]);
					dp[i][j]=tmp+a[j];
				}else{
					int tmp=0;
					REP(l,3) if(l!=j) tmp=max(tmp,dp[i-k][l]);
					dp[i][j]=tmp;
				}
			}
		}
	}
}

int main(){
	cin>>n>>k;
	REP(i,3) cin>>a[i];
	cin>>t;
	
	tt.resize(n);
	string hoge="spr";
	REP(i,n){
		REP(j,3){
			if(hoge[j]==t[i]){
				tt[i]=j;
				break;
			}
		}
	}
	
	dp.assign(n,vi(3,0));
	f();
	
	llong sum=0;
	for(int i=n-1,j=k;i>=0 and j>0;--i,--j){
		sum+=max({dp[i][0],dp[i][1],dp[i][2]});
	}
	
	cout<<sum<<endl;
}


Measured memory_bytes: 6272
string = input().strip()
ac = 0
bc = 0
cc = 0
ac2 = 0
bc2 = 0
bc3 = 0
bc4 = 0
cc2 = 0
cc3 = 0
cc4 = 0
cc5 = 0
cc6 = 0
cc7 = 0
cc8 = 0
for s in string:
    if s == 'A':
        ac += 1
    elif s == 'B':
        bc += ac
        bc2 += ac2
    elif s == 'C':
        cc += bc
        cc2 += bc2
        cc3 += bc3
        cc4 += bc4
    elif s == '?':
        cc5 += bc2
        cc6 += bc3
        cc7 += bc4
        cc8 += bc

        bc3 += ac
        bc4 += ac2

        ac2 += 1

#print(cc)
#print(cc3)
result = (cc7) + ((cc4+cc5+cc6) * 3) + ((cc2+cc3+cc8)*9) + (cc*27)
#print(ac2)
result *= pow(3, ac2-3)
print(int(result%(pow(10,9)+7)))


Measured memory_bytes: 3188
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		HashMap<String,Integer> tango = new HashMap<String,Integer>();
		ArrayList<String> eng = new ArrayList<String>();
		String retu;
		String abc;
		String hoji = null;
		String nagasa = null;
		int nagasa2 =0;
		int max = 0;
		Scanner scan = new Scanner(System.in);
		while(scan.hasNext()){
			retu = scan.next();
			eng.add(retu);
		}
		for(int i = 0 ; i < eng.size(); i++){
			eng.get(i);
			abc = eng.get(i);
			//??????????¨????
			if(!tango.containsKey(abc)){
				tango.put(abc,1);
			}else{
				int cnt = tango.get(abc);
				tango.put(abc,++cnt);

				if(max < cnt){
					max = cnt;
					hoji = abc;

				}
			}
			if(nagasa2 < abc.length()){
				nagasa2 = abc.length();
				nagasa = abc;
			}

		}



		System.out.println(hoji + " " + nagasa);

	}
}

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

//template
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(a);i>(b);i--)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll; typedef pair<ll, ll> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename A,size_t N,typename T>void Fill(A(&array)[N],const T &val){fill((T*)array, (T*)(array+N), val);}
const int inf = INT_MAX / 2; const ll INF = LLONG_MAX / 2;
//template end



int main(){
    string s,t; cin>>s>>t;
    int cnt=0;
    rep(i,0,3)if(s[i]==t[i])cnt++;
    printf("%d\n",cnt);
    return 0;
}

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

class BigInt{
public:
  vector<int> value;
  int sign;

  void set(int n){
    value.clear();
    if(n==0){
      sign = 0;
      value.push_back(0);
    }else if(n<0){
      sign = -1;
      n *= -1;
    }else{
      sign = 1;
    }
    while(n){
      value.push_back(n%10);
      n/=10;
    }
  }

  void set(string str){
    value.clear();
    if(str[0]=='-')sign = -1;
    else if(str[0]=='0')sign = 0;
    else sign = 1;
    int a = 0;
    if(sign<0)a = 1;
    for(int i=str.size()-1;i>=a;i--){
      value.push_back(str[i]-'0');
    }
  }

  void print(void){
    if(sign<0)cout << '-';
    for(int i=value.size()-1;i>=0;i--)cout << value[i];
    cout << endl;
  }

  BigInt add(BigInt x){
    int max,min;
    BigInt ans;

    if(sign == 0)return x;
    if(x.sign == 0)return *this;
       
    ans.sign = 1;
    ans.value.clear();
    if(value.size()>x.value.size()){
      max = value.size();
      min = x.value.size();
      for(int i=0;i<min;i++)ans.value.push_back(value[i]+x.value[i]);
      for(int i=min;i<max;i++)ans.value.push_back(value[i]);
    }else{
      max = x.value.size();
      min = value.size();
      for(int i=0;i<min;i++)ans.value.push_back(value[i]+x.value[i]);
      for(int i=min;i<max;i++)ans.value.push_back(x.value[i]);
    }
    for(int i=0;i<(int)ans.value.size()-1;i++){
      while(ans.value[i]>=10){
	ans.value[i]-=10;
	ans.value[i+1]++;
      }
    }
    if(ans.value[ans.value.size()-1]>=10){
      ans.value[ans.value.size()-1]-=10;
      ans.value.push_back(1);
    }
    return ans;
  }

  int cmp(BigInt a){
    if(sign<a.sign)return -1;
    if(sign>a.sign)return 1;
    if(sign == 0)return 0;

    if(value.size()<a.value.size())return -1;
    if(value.size()>a.value.size())return 1;
    for(int i=value.size()-1;i>=0;i--){
      if(value[i]<a.value[i])return -1;
      if(value[i]>a.value[i])return 1;
    }
    return 0;
  }

};

int main(){
  string str,tmp;
  string a,b,c;
  BigInt d,e,f;
  int mode;
  int i,j;

  while(cin >> str){
    for(i=0;i<10;i++){
      tmp = str;
      for(j=0;j<tmp.size();j++){
	if(tmp[j]=='X')tmp[j] = '0' + i;
      }
      a.clear();
      b.clear();
      c.clear();
      mode = 0;
      for(j=0;j<tmp.size();j++){
	if(tmp[j] == '+'){
	  mode++;
	}else if(tmp[j] == '='){
	  mode++;
	}else{
	  if(mode==0)a.push_back(tmp[j]);
	  else if(mode==1)b.push_back(tmp[j]);
	  else c.push_back(tmp[j]);
	}
      }
      if( (a.size()>1 && a[0]=='0') || (b.size()>1 && b[0]=='0') || (c.size()>1 && c[0]=='0') ){}
      else{
	d.set(a);
	e.set(b);
	f.set(c);
	if(f.cmp(d.add(e)) == 0){
	  cout << i << endl;
	  break;
	}
      }
    }
    if(i==10)cout << "NA" << endl;
  }
}

Measured memory_bytes: 0
#include <algorithm>
#include <vector>
#include <iostream>

using namespace std;
int main(){
  int n; cin >> n;
  vector<int> A;
  for(int i=0;i<3*n;i++){int a;cin >> a;A.push_back(a);}
  sort(A.begin(),A.end());
  reverse(A.begin(),A.end());
  long long int ans=0;
  for(int i=0;i<n;i++) ans+=A[2*i+1];
  cout << ans << endl;
}

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

int main(void){
    int k, s; cin >> k >> s;
    int cnt = 0;
    for (int a = 0; a <= k; a++){
        for (int b = 0; b <= k; b++){
            int c = s - a - b;
            if(c >= 0 && c <= k){
                cnt++;
                
            }
        }
    }
    cout << cnt << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	@SuppressWarnings("resource")
	public static void main(String args[]) {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		long[] l = new long[n + 1];

		l[0] = 2;
		l[1] = 1;

		for (int i = 2; i <= n; i++) {
			l[i] = l[i - 2] + l[i - 1];
		}

		System.out.println(l[n]);
	}
}


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

#define EPS (1e-10)
#define equals(a, b) (fabs((a) - (b)) < EPS)
#define pb push_back
#define rep(i, n) for(int i = 0; i < (n); i++)
#define INF (1 << 29)

using namespace std;

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

	string str;
	cin >> str;

	int red = 0, white = 0;
	for(int i = 0; i < n; i++){
		if(str[i] == 'W') white++;
		else red++;
	}

	int ans = red;
	int r = red, w = 0;
	for(int i = 0; i < n; i++){
		if(str[i] == 'W'){
			w++;
		}else{
			r--;
		}
		if(max(w, r) < ans){
			ans = max(w, r);
		}
	}

	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 3688
#include<stdio.h>
#define N 100

main(){
  int count = 0, i, j, k, l, mini, A[N];
  scanf("%d", &k);
  for(i = 0;i < k;i++){
    scanf("%d", &A[i]);
  }
  for(i = 0;i < k;i++){
    mini = i;
    for(j = i;j < k;j++){
      if(A[j] < A[mini]){
	mini = j;
      }
    }
    if(mini != i){
      l = A[i];
      A[i] = A[mini];
      A[mini] = l;
      count++;
    }    
  }
  for(i = 0;i < k-1;i++){
    printf("%d ", A[i]);
  }
  printf("%d\n%d\n", A[k-1], count);
  return 0;
}

Measured memory_bytes: 600
import sys
input = sys.stdin.readline
N,K = map(int,input().split())
E = [[] for _ in range(N)]
MOD = 10**9+7

for _ in range(N-1):
	u,v = map(int,input().split())
	u -= 1
	v -= 1
	E[u].append(v)
	E[v].append(u)

if N == 1:
	print(K)
	sys.exit()

color = [-1 for _ in range(N)]
dp = [-1 for _ in range(N)]

stack = []
color[u] = 1
ans = K
for i,v in enumerate(E[u]):
	stack.append(v)
	ans *= (K-i-1)
	ans %= MOD

while stack:
	u = stack.pop()
	color[u] = 1
	length = 0
	for v in E[u]:
		if color[v] == -1:
			stack.append(v)
			length += 1
	if dp[length] == -1:
		tmp = 1
		for i in range(K-1-length,K-1):
			tmp *= i
			tmp %= MOD
		ans *= tmp
		dp[length] = tmp
	else:
		ans *= dp[length]
	ans %= MOD

print(ans%MOD)


Measured memory_bytes: 24428
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse4,popcnt,abm,mmx,tune=native")
#include <bits/stdc++.h>

#define gc getchar_unlocked()
#define pc(x) putchar_unlocked(x)
template<typename T> void scan(T &x){x = 0;register bool _=0;register T c=gc;_=c==45;c=_?gc:c;while(c<48||c>57)c=gc;for(;c<48||c>57;c=gc);for(;c>47&&c<58;c=gc)x=(x<<3)+(x<<1)+(c&15);x=_?-x:x;}
template<typename T> void printn(T n){register bool _=0;_=n<0;n=_?-n:n;char snum[65];int i=0;do{snum[i++]=n%10+48;n/= 10;}while(n);--i;if (_)pc(45);while(i>=0)pc(snum[i--]);}
template<typename First, typename ... Ints> void scan(First &arg, Ints&... rest){scan(arg);scan(rest...);}
template<typename T> void print(T n){printn(n);pc(10);}
template<typename First, typename ... Ints> void print(First arg, Ints... rest){printn(arg);pc(32);print(rest...);}

using ll = long long;
using T = ll;
ll mod = 998244353;

ll gcd(ll gcd_a, ll gcd_b){return gcd_b == 0 ? gcd_a : gcd(gcd_b, gcd_a % gcd_b);}
ll fpow(ll fpow_b, ll fpow_exp, ll fpow_mod){if(fpow_exp == 0) return 1;ll t = fpow(fpow_b,fpow_exp/2,fpow_mod);if(fpow_exp&1) return t*t%fpow_mod*fpow_b%fpow_mod;return t*t%fpow_mod;}
ll divmod(ll divmod_i, ll divmod_j, ll divmod_mod){divmod_i%=divmod_mod,divmod_j%=divmod_mod;return divmod_i*fpow(divmod_j,divmod_mod-2,divmod_mod)%divmod_mod;}

int n;

T exgcd(T a, T b, T &x, T &y){
    if(a == 0){
        x = 0, y = 1;
        return b;
    }
    T x1, y1;
    T d = exgcd(b % a, a, x1, y1);
    x = y1 - (b / a) * x1;
    y = x1;
    return d;
}

int main(){
    
    scan(n);
    ll ans = fpow(3, n, mod)-2, bi = 2;
    for(int i = 1; i < n/2; i++){
        bi = bi*2*(n-i+1)%mod;
        //x2, others have two options
        ll inv, z;
        exgcd(i, mod, inv, z);
        if(inv < mod) inv += mod;
        bi = bi*inv%mod;
        
        ans -= bi; //A or B
        if(ans < 0)
            ans += mod;
    }
    print(ans);
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <math.h>
#include <vector>
#include <map>
#include <queue>
#include <utility>
#include <algorithm>
#include <string>
using namespace std;

int main() {
  int N, M;
  cin >> N >> M;
  vector <int> fav(M + 1, 0);
  for (int i = 0; i < N; i++) {
	  int K;
	  cin >> K;
	  for (int j = 0; j < K; j++) {
		  int A;
		  cin >> A;
		  fav[A]++;
		}
	}
  int ans = 0;
  for (int i = 1; i <= M; i++) {
	  if (fav[i] == N) {
		  ans++;
		}
	}
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define F first
#define S second
#define pii pair<int,int>
#define pb push_back

using namespace std ;

const int N = 410, M = 1e5 + 10;

bool c[N][N], bad[N];
pii e[M];

int32_t main() {
    ios_base::sync_with_stdio(0);
	int n, m; cin >> n >> m;
	for(int i=0; i<m; i++){
		int u, v; cin >> u >> v;
		e[i] = {u, v};
	}
	
	for(int i=1; i<=n; i++){
		c[i][i] = 1;
		for(int j=m-1; j>=0; j--){
			int u = e[j].F, v = e[j].S;
			if(c[i][u] && c[i][v]){
				bad[i] = true;
			}else if(!c[i][u] && !c[i][v])continue;
			else if(c[i][u] && !c[i][v])c[i][v] = true;
			else c[i][u] = true;
		}
	}

	int ans = 0;

	for(int i=1; i<=n; i++)
		for(int j=i+1; j<=n; j++){
			if(bad[i] || bad[j])continue;
			if(c[i][j] || c[j][i])continue;
			bool no = false;
			for(int k=1; k<=n; k++)
				if(c[i][k] && c[j][k])no = true;
			if(!no)ans++;
		}

	cout << ans << endl;

}


Measured memory_bytes: 1280
#include<iostream>
#include <cstdio>
#include<vector>
#include<queue>
#include<algorithm>
 
using namespace std;
int main(void){
    int N, count = 0;
    long long result = 0;
    char tmp[11];
    queue<long long> q;

    scanf("%d", &N);
    vector<string> S(N);
 
    //入力してソート
    for(int i = 0; i < N; i++){
        scanf("%s", tmp);
        S[i] = tmp;
        sort(S[i].begin(), S[i].end());
    }
    sort(S.begin(), S.end());
 
    //キューに同じ組み合わせの文字列の数を追加
    while (S.size() != 1){
        auto itr = S.end() - 1;
        if (*itr == *(itr - 1)){
            count++;
        }
        else{
            if(count != 0){
                q.push(count + 1);
                count = 0;
            }
            else
                count = 0;
        }
        S.pop_back();
    }
 
    if(count != 0){
        q.push(count + 1);
    }
 
    //キューに入った組み合わせの計算
    while(!q.empty()){
        long long num = q.front();
        //numC2の計算
        result += num * (num - 1) / 2;
        q.pop();
    }
 
    cout << result << endl;
    return 0;
}

Measured memory_bytes: 5888
/*** keep hungry and calm CoolGuang!***/
#pragma GCC optimize(3)
#include <bits/stdc++.h>
#define debug(x) cout<<#x<<":"<<x<<endl;
#define _CRT_SECURE_NO_WARNINGS
#pragma GCC optimize("Ofast","unroll-loops","omit-frame-pointer","inline")
#pragma GCC option("arch=native","tune=native","no-zero-upper")
#pragma GCC target("avx2")
#include<stdio.h>
#include<algorithm>
#include<queue>
#include<string>
#include<iostream>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pp;
const ll INF=1e17;
const int Maxn=2e7+10;
const int maxn =3e5+10;
const int mod=1e9+9;
const int Mod = 1e9+7;
///const double eps=1e-10;
inline bool read(ll &num)
{char in;bool IsN=false;
    in=getchar();if(in==EOF) return false;while(in!='-'&&(in<'0'||in>'9')) in=getchar();if(in=='-'){ IsN=true;num=0;}else num=in-'0';while(in=getchar(),in>='0'&&in<='9'){num*=10,num+=in-'0';}if(IsN) num=-num;return true;}
ll n,m,p;
ll dp[maxn];
ll a[maxn];
int main()
{
    read(n);read(m);
    for(int i=1;i<=n;i++) read(a[i]);
    for(int i=m+1;i<=n;i++){

        if(a[i-m]>=a[i]) printf("No\n");
        else printf("Yes\n");
    }
    return 0;
}
/**
a b c d
a*b*c > b*c*d
bc(a-d)>0
**/


Measured memory_bytes: 5196
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(false), cin.tie(0);
#define ll long long
#define endl '\n'

using namespace std;

main()
{
  fast;
  int a,b,c;
  cin>>a>>b>>c;
  set<int> s;
  s.insert(a);
  s.insert(b);
  s.insert(c);
  cout<<s.size()<<endl;
}


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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repi(i, a, b) for (int i = (a); i < int(b); i++)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ll << (b))
#define uniq(v) (v).erase(unique(all(v)), (v).end())
#define rsort(v) sort(all(v)); reverse(all(v))

using namespace std;
using i32 = int;
using i64 = long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void ioinit() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
inline vi32 plist(i32 n) { vi32 f(n, 1); f[0] = f[1] = 0; repi(i, 2, n) for (int j = i * 2; j < n; j += i) f[j] = 0; return f; }
inline bool isprime(i32 n) { if (n < 2) return 0; for (i32 i = 2; i * i <= n; i++) if (n % i == 0) return 0; return 1; }
template<class T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template<class T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template<class T> inline bool amax(T &x, T y) { if (x < y) return 0; x = y; return 1; }
template<class T> inline bool amin(T &x, T y) { if (x > y) return 0; x = y; return 1; }
template<class T> inline i64 lbi(vector<T> &v, T e) { return lower_bound(all(v), e) - v.begin(); }
template<class T> inline i64 ubi(vector<T> &v, T e) { return upper_bound(all(v), e) - v.begin(); }
template<class T> inline T power(T x, i64 n) { T r = 1; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }

vector<vi32> calcNext(const string &s) {
  int n = s.size();
  // 文字cが存在しないときのインデックスはn
  // 文字列の長さがnなので、nは範囲外を表すものとして最適なのかも
  vector<vi32> res(n + 1, vi32(26, n));
  rrep(i, n) {
    rep(j, 26) res[i][j] = res[i + 1][j];
    res[i][s[i] - 'a'] = i;
  }
  return res;
}

int main() {
  ioinit();
  string s;
  cin >> s;
  int n = s.size();
  auto next = calcNext(s);
  vi32 dp(n + 1, bit(30));
  dp[n] = 1;
  rrep(i, n) rep(j, 26) {
    if (next[i][j] == n) {
      dp[i] = 1;
    } else {
      amax(dp[i], dp[next[i][j] + 1] + 1);
    }
  }
  string ans = "";
  int i = 0;
  while (i < n) {
    rep(j, 26) {
      if (next[i][j] == n || dp[next[i][j] + 1] + 1 == dp[i]) {
        ans += 'a' + j;
        i = next[i][j] + 1;
        break;
      }
    }
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 27796
#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;

int main()
{
    int x,y,z;
    cin >> x >> y >> z;
    swap(x,y);
    swap(x,z);
    cout << x << " " << y << " " << z << endl;
    return 0;
}

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

bool student[31];

int main()
{
  int n;
  for (int i = 0; i < 28; i++){
    cin >> n;
    student[n] = true;
  }
  for (int i = 1; i < 31; i++){
    if (!student[i])  cout << i << endl;
  }
  return (0);
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1LL << 60;
ll MOD = 1e9 + 7;

int gcd(int a, int b) {
    if (a < b) {
        swap(a, b);
    }
    if (a % b) {
        return gcd(b, a % b);
    } else {
        return b;
    }
}

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }
    for (int i = 1; i < N; i++) {
        A[i] = gcd(A[i - 1], A[i]);
    }
    cout << A[N - 1] << endl;
    return 0;
}

Measured memory_bytes: 3684
#include <iostream>

#include <cmath>
#include <algorithm>

using namespace std;

int S[10001];
int Q[501];

int main(){
    int s,q;
    cin>>s;
    for(int i = 0;i < s;i++) {
        cin>>S[i];
    }

    int count = 0;

    cin>>q;
    for(int i = 0;i < q;i++) {
        cin>>Q[i];
        int temp = Q[i];
        for(int j = 0;j < s;j++) {
            if(S[j] == temp) {
                count++;
                break;
            }
        }

    }


    cout<<count<<endl;






    return 0;
}

Measured memory_bytes: 3136
#include<iostream>
#include<cstring>
#include<string>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<iomanip>
#include<vector>
#include<map>
using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	int n;
	while(cin>>n)
	{
		int i,j;
		if(n%4==0||n%7==0)
			cout<<"Yes"<<endl;
		else
		{
			int flag=0;
			for(i=1;i<100;i++)
			{
				for(j=1;j<100;j++)
					if(4*i+7*j==n)
					{
						flag=1;
						break;
					}
				if(flag)
					break;
			}
			if(flag==1)
				cout<<"Yes"<<endl;
			else
				cout<<"No"<<endl;
				
		}
	}
	return 0;
}

Measured memory_bytes: 256
import sys
readline = sys.stdin.readline
MOD = 10 ** 9 + 7

def main():
    S = readline().rstrip()
    N = 13
    dp = [0] * 13  # dp[k]: 13で割った余りがkのパターン数
    dp[0] = 1
    
    mul = 1
    for s in S[::-1]:
        next_dp = [0] * N
        if s == '?':
            for k in range(10):
                for j in range(N):
                    next_dp[(k * mul + j) % N] += dp[j]
                    next_dp[(k * mul + j) % N] %= MOD
        else:
            k = int(s)
            for j in range(N):
                next_dp[(k * mul + j) % N] += dp[j]
                next_dp[(k * mul + j) % N] %= MOD
        mul *= 10
        mul %= N
        dp = next_dp

    print(dp[5])

if __name__ == '__main__':
    main()

Measured memory_bytes: 43628
#include <iostream>
#include <cstdio>
#include <cctype>
#include <cstring>
using namespace std;

int main() {
	char str[1000];
	int sum;
	while(1){
		scanf("%s", str);
		if(str[0] == '0') break;
		sum=0;
		for(int i=0; i<strlen(str); i++){
			sum += str[i]-'0';
		}
		printf("%d\n",sum);
	}
	return 0;
}


Measured memory_bytes: 3208
five = int(input())
hund = int(input())
fif = int(input())

count = 0
total = int(input())

goukei = five + hund + fif 

lis = []
for f in range(five+1):
    for h in range(hund+1):
        for i in range(fif+1):
            lis.append(f*500+h*100+i*50)

# print(lis)
for li in lis:
    if total == li:
        count += 1
print(count)

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

int main() {
  int N;
  cin >> N;
  vector<int> vec (N);
  for(int i = 0;i < N;i++){
  	cin >> vec.at(i);
  }
  sort(vec.begin(),vec.end());
  int a = N;
  for(int i = 0;i < N - 1;i++){
  	if(vec.at(i) == vec.at(i+1)){
  		a -= 2;
  		i++;
  	}
  }
  cout << a << endl;
}

Measured memory_bytes: 640