akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
// type alias
typedef long long LL;
typedef pair<int,int> II;
typedef tuple<int,int,int> III;
typedef vector<int> VI;
typedef vector<string> VS;
typedef unordered_map<int,int> MAPII;
typedef unordered_set<int> SETI;
template<class T> using VV=vector<vector<T>>;
// minmax
template<class T> inline T SMIN(T& a, const T b) { return a=(a>b)?b:a; }
template<class T> inline T SMAX(T& a, const T b) { return a=(a<b)?b:a; }
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// collection
#define ALL(c) (c).begin(),(c).end()
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// stdout
#define println(args...) fprintf(stdout, ##args),putchar('\n');
// debug cerr
template<class Iter> void __kumaerrc(Iter begin, Iter end) { for(; begin!=end; ++begin) { cerr<<*begin<<','; } cerr<<endl; }
void __kumaerr(istream_iterator<string> it) { (void)it; cerr<<endl; }
template<typename T, typename... Args> void __kumaerr(istream_iterator<string> it, T a, Args... args) { cerr<<*it<<"="<<a<<", ",__kumaerr(++it, args...); }
template<typename S, typename T> std::ostream& operator<<(std::ostream& _os, const std::pair<S,T>& _p) { return _os<<"{"<<_p.first<<','<<_p.second<<"}"; }
#define __KUMATRACE__ true
#ifdef __KUMATRACE__
#define dump(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); __kumaerr(_it, args); }
#define dumpc(ar) { cerr<<#ar<<": "; FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }
#define dumpC(beg,end) { cerr<<"~"<<#end<<": "; __kumaerrc(beg,end); }
#else
#define dump(args...)
#define dumpc(ar)
#define dumpC(beg,end)
#endif

// $ cp-batch Management | diff Management.out -
// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG -fsanitize=address Management.cpp && ./a.out

/*
 
 4/19/2020
 
 5:15-
 
 */

const int MAX_N=1e6+1;
int A[MAX_N];
int N;

void solve() {
  VI cnt(N,0);
  REP(i,N-1)cnt[A[i]-1]++;
  REP(i,N) cout<<cnt[i]<<endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout<<setprecision(12)<<fixed;
  
  cin>>N;
  REP(i,N-1) cin>>A[i];
  solve();
  
  return 0;
}


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

int main(){
  string str, str1="";
  cin >> str;
  int len=str.size();
  
  for(int i=0 ; i<len ; i++){
    if(str[i]=='0')
      str1+='0';
    else if(str[i]=='1')
      str1+='1';
    else if(str[i]=='B')
      if(str1.size()!=0)
        str1=str1.substr(0, str1.size()-1);
  }
  
  cout << str1 << endl;
}

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

int main(){
    int N, K; cin >> N >> K;
    string S ; cin >> S;
    int l = 0, r = 0;
    int cnt = 0, ans = 0;
    if(S[0] == '0') cnt++;
    while(r < N){
        while(1){
            if(r >= N) break;

            if(S[r] != S[r-1]){
                if(S[r-1] == '1') cnt++;
            }

            if(cnt > K) break;

            r++;
        }
        //cout << r << endl;
        ans = max(ans, r - l);
        r++;
        while(cnt > K){
            l++;
            if(S[l-1] == '0' && S[l] == '1') cnt--;
        }
        //cout << l << endl;
    }
    cout << ans << endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <map>
#include <vector>
#include <cstring>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <string>
#include <stack>
#include <set>
#include <deque>
#define mp make_pair
using namespace std;
long long k,p,a[50];
int main(){
	ios::sync_with_stdio(false);
	cin>>k;
	p=k/50;
	k%=50;
	a[0]=49+p+k*50;
	for (int i=1;i<50;i++) a[i]=49-k+p;
	if (k*50>=2000){
		a[0]-=2040;
		a[1]+=510;
		a[2]+=510;
		a[3]+=510;
		a[4]+=510;
	}else if (k*50>=1000){
		a[0]-=1020;
		a[1]+=255;
		a[2]+=255;
		a[3]+=255;
		a[4]+=255;
	}
	cout<<50<<endl;
	for (int i=0;i<50;i++) cout<<a[i]<<' ';
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;
int main(int argc, char *argv[]) {
	string n;
	cin >> n;
	
	for(int i= 0; i<3; i++){
		if(n[i]=='1'){
			n[i] = '9';
		}else{
			n[i] = '1';
		}
	}
	cout << n << "\n";
}

Measured memory_bytes: 256
INF=-10**10
N=int(input())
v=[0]*N
dic=[[] for i in range(N)]
for i in range(N-1):
    a,b=map(int,input().split())
    dic[a-1].append(b-1)
    dic[b-1].append(a-1)
    v[a-1]+=1
    v[b-1]+=1

a=[[] for i in range(N)]
for i in range(N):
    a[v[i]].append(i)

c=list(map(int,input().split()))
c.sort()

ans=[-1]*N

answer=0
tmp=0
while tmp<N:

    if a[tmp]==[]:
        tmp+=1
        continue
    j=a[tmp][0]
    ans[j]=c.pop(0)
    itiji=INF
    for k in dic[j]:
        if v[k]>0:
            answer+=ans[j]
            a[v[k]].remove(k)
            a[v[k]-1].append(k)
            v[k]-=1
            if v[k]<tmp: itiji=tmp-1
    a[tmp].pop(0)
    v[j]=-1
    if itiji>INF: tmp-=1
    elif a[tmp]==[]: tmp+=1
      
print(answer)
for i in range(N):
    print(ans[i],end=" ")

Measured memory_bytes: 7160
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> 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; }

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll x;
	cin >> x;
	ll ans = (x / 11) * 2;
	x %= 11;
	if(x == 0) ;
	else if(x <= 6) ++ans;
	else ans += 2;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3692
#include <iostream>

using namespace std;

int main(int argc, char const* argv[])
{
	int n, y;
	cin >> n >> y;
	for(int i = 0; i <= y / 10000; i++){
			int rem1 = y - 10000 * i;
			for(int j = 0; j <= rem1 / 5000; j++){
					int rem2 = rem1 - j * 5000;
					if(rem2 < 0)break;
					if(rem2 / 1000 == n - i - j){
							cout << i << " " << j << " " << n - i - j << endl;
							return 0;
					}
			}
	}
	cout << -1 << " " << -1 << " " << -1 << endl;
	return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>

using namespace std;
typedef long long int ll;
typedef long double lld;

const ll MOD = 1000000007;
vector<vector<int>> adj;
vector<int> path;

void topo(int x) {
	if(path[x] >= 0) return; // already visited.
	path[x] = 0;
	for(int i = 0; i < adj[x].size(); i++) {
		int v = adj[x][i];
		topo(v);
		path[x] = max(path[x], path[v] + 1);
	}
}

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

	int n, m; cin >> n >> m;
	path.resize(n, -1); adj.resize(n, vector<int>());

	for(int i = 0; i < m; i++) {
		int u, v; cin >> u >> v; --u; --v;
		adj[u].push_back(v);
	}

	for(int i = 0; i < n; i++) {
		if(path[i] < 0) topo(i);
	}

	int ans = 0;
	for(int i = 0; i < n; i++) {
		ans = max(ans, path[i]);
	}
	cout << ans << endl;
}

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

struct UnionFind{
    vector<int> parent;
    vector<int> size;
    vector<int> rank;

    /* constructor (initialize) */
    UnionFind(int n){
        parent.resize(n);
        size.resize(n);
        rank.resize(n);
        for(int i=0; i<n; i++){
            parent[i] = i;// completely-disjoint
            size[i] = 1;
            rank[i] = 0;// union by rank
        }
    }

    int root(int x){
        // terminal case
        if(parent[x] == x){
            return x;// by definition
        }

        // recursion
        parent[x] = root(parent[x]);// path compression : keep tree as shallow as possible
        return parent[x];
    }

    void merge(int x, int y){
        int rx = root(x);
        int ry = root(y);

        // if (root(x) == root(y)) do nothing;
        if (rx != ry){
            if(rank[rx] < rank[ry]){
                parent[rx] = ry;// root of merged tree = ry
                size[ry] += size[rx];
            }
            else if(rank[rx] == rank[ry]){
                parent[rx] = ry;
                size[ry] += size[rx];
                rank[ry] += 1;
            }
            else if(rank[rx] > rank[ry]){
                parent[ry] = rx;// root of merged tree = rx
                size[rx] += size[ry];
            }
        }
        return;
    }

    bool same(int x, int y){
        return root(x) == root(y);
    }

    int nodes(int x){
        return size[root(x)];
    }
};

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

    vector<int> p(n);
    for(int i=0; i<n; i++){
        cin >> p[i];
        p[i] -= 1;
    }

    vector<int> a(m), b(m);
    for(int i=0; i<m; i++){
        cin >> a[i] >> b[i];
        a[i] -= 1;
        b[i] -= 1;
    }
    
    UnionFind uf(n);
    for(int i=0; i<m; i++){// for each edge
        if(uf.same(a[i],b[i]) == false) uf.merge(a[i], b[i]);
    }
    
    long long int ans = 0;
    for(int i=0; i<n; i++){
        if(uf.same(i,p[i]) == true) ans += 1;
    }
    cout << ans << endl;
    return 0;
}

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

#define MAX_VERTEX 100
#define INF 1000000

int vertex_num;   // ???????????°

int cost[MAX_VERTEX][MAX_VERTEX]; // ????????????cost[?§????][??????]??§?§?????????????????????????????????¨???
int d[MAX_VERTEX];                // ????????????d[u]??§?§??????¨u??????????????¢?????¨??????
bool used[MAX_VERTEX];            // ????????????????????£????????¢????±???????????????????

void Input() {
	cin >> vertex_num;

	// (a1) ??\???????????¶??§?????????
	// d??¨cost?????¨???INF
	// used????????????false
	for (int i = 0; i < vertex_num; i++){
		d[i] = INF;
		used[i] = false;
		for (int j = 0; j < vertex_num; j++){
			cost[i][j] = INF;
		}
	}



	for (int i = 0; i < vertex_num; i++) {
		int from, out_num;
		cin >> from >> out_num;
		for (int j = 0; j < out_num; j++) {
			int to, c;
			cin >> to >> c;
			cost[from][to] = c;
		}
	}
}

void Dijkstra() {
	// (b1) ?§????????????????
	d[0] = 0;
	while (true) {
		// ????????????????????¨???
		int vertex = -1;

		// (b2) ????????????????????£????????¢????±??????????????????????
		// ?????????????????????????????????????????§????????¢???????°???????????????¢???
		for (int u = 0; u < vertex_num; u++){
			if (!used[u] && (vertex == -1 || d[u] < d[vertex])){
				vertex = u;
			}
		}


		// ??¨????????????????????????????¨?????????????????????´????????????????????????
		if (vertex == -1) break;

		used[vertex] = true;

		// ???????????¢????¨????????????????
		for (int u = 0; u < vertex_num; u++) {
			d[u] = min(d[u], d[vertex] + cost[vertex][u]);
		}

	}

}

void Output() {
	for (int i = 0; i < vertex_num; i++) {
		cout << i << " " << d[i] << endl;
	}
}

int main() {

	Input();
	Dijkstra();
	Output();

	return 0;
}

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


int main(){
  int N ;
  cin >> N ; 
  vector<int> d(N) ; 
  int cnt = 0 ; 
  
  for ( int i = 0 ; i < N ; i++){
    cin >> d[i] ; 
  }
  
  for(int i = 0 ; i < N ; i++){
    for(int j = i+1 ; j < N ; j++){
      cnt = cnt + d[i]*d[j] ; 
    }
  }
  cout << cnt << endl ; 
  
}

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

long long dp[51][51][2501], x[51], n, A;

int main () {
	dp[0][0][0] = 1;
	std::cin >> n >> A;
	for (int i = 1; i <= n; ++i) std::cin >> x[i];
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j <= i; ++j) {
			for (int k = 0; k <= 2500-x[i+1]; ++k) {
				if (!dp[i][j][k]) continue;
				dp[i+1][j+1][k+x[i+1]] += dp[i][j][k];
				dp[i+1][j][k] += dp[i][j][k];
			}
		}
	}
	long long ans = 0;
	for (int i = 1; i <= n; ++i) ans += dp[n][i][A*i];
	std::cout << ans << "\n";
	return 0;
}

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

int main(){
    ll n,ans=2;
    cin>>n;
    if(n==2) ans=1;
    for(ll k=2;k*k<=n;k++){
        ll m=n;
        while(m>=k) m%k?m%=k:m/=k;
        if(m==1) ans++;
        if((n-1)%k==0 && k*k!=(n-1)) ans++;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;


int main() {
    fast

    long long a,b;
    cin>>a>>b;

    cout<<max(max(a*b,a+b),a-b);


	return 0;
}


/*
ll  modularExponentiation(ll x,ll n,ll M)
{

    ll result=1;

    while(n>0)
    {

	if(n%2==1)

 result=(result*x)%M;

  x=(x*x)%M;

  n=n/2;

}

  return result;
}



*/




Measured memory_bytes: 256
#include <bits/stdc++.h>
#define IO_OP std::ios::sync_with_stdio(0); std::cin.tie(0);
#define F first
#define S second
#define V vector
#define PB push_back
#define MP make_pair
#define EB emplace_back
#define ALL(v) (v).begin(), (v).end()
#define debug(x) cerr << #x << " is " << x << endl
#define int ll

using namespace std;

typedef long long ll;
typedef pair<int, int> pi;
typedef V<int> vi;

const int INF = 1e9 + 7;

int go(int n, int m) {
	if(m > n) return 0;
	int ret = 1;
	for(int i = 0; i < m; i++)
		ret *= 9;
	for(int i = 1; i <= m; i++) {
		ret *= n--;
		ret /= i;
	}
	return ret;
}

signed main()
{
	IO_OP;
	
	string s;
	int k;
	cin >> s >> k;
	int cnt = 0, ans = 0;
	for(char c : s) if(c != '0') cnt++;
	if(cnt == k) ans++;
	cnt = 0;
	for(int i = 0; i < s.size(); i++) {
		if(cnt <= k && s[i] != '0') {
			int req = k - cnt;
			ans += go(s.size()-i-1, req);
			if(req && s[i] > '1') ans += (s[i] - '1') * go(s.size()-i-1, req-1);
		}
		cnt += s[i] != '0';

	}	
	cout << ans << endl;
}





Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int n,ans;
struct node
{
	int x,id;
}a[101010];
bool cmp1(node u,node w)
{
	return u.x<w.x;
}
bool cmp2(node u,node w)
{
	return u.id<w.id;
}
int main()
{
	scanf("%d",&n);
	for (int i=1;i<=n;++i)
		scanf("%d",&a[i].x),a[i].id=i;
	sort(a+1,a+1+n,cmp1);
	for (int i=1;i<=n;++i)
		a[i].x=i;
	sort(a+1,a+1+n,cmp2);
	for (int i=1;i<=n;++i)
		if (i%2 != a[i].x%2) ++ans;
	printf("%d\n",ans/2);
	return 0;
}
	

Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<queue>
#include<map>
#include<math.h>
#include<string>
#include <cctype>
#include <cstdlib>
#include<bitset>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for (int i = s; i < (int)(n); i++)
#define out(x) cout << x << endl
#define INF 1ll<<60;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

using namespace std;
using ll = long long;
typedef pair<int, int> P;

int main(){
    int n, k;
    cin >> n >> k;
    int count = 0;
    rep(i, n){
        int h;
        cin >> h;
        if(h>=k) count++;
    }
    out(count);
}

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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;
typedef pair<ll, ll> PL;
typedef pair<P, ll> PPL;

#define INF INT_MAX/3

#define MAX_N 1000

int n,m;

int main(){
	cin.sync_with_stdio(false);
  cin>>n>>m;
  int a;
  rep(i,m)cin>>a;
  cout<<(n-m-1)<<endl;
	return 0;
}

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

#define ll         long long int
#define pb         push_back
#define mk         make_pair
#define vec        vector<int>
#define iter       vector<int>:: iterator
#define f(n)       for(int i=0 ; i<n ; i++)
#define sz         size()
#define sort(v)    sort(v.begin() , v.end())

#define fast       ios_base::sync_with_stdio(false);cin.tie(NULL)

using namespace std;

int main(){

       fast;

       int n , d;
       cin>>n>>d;

       int a[n][d] ,c[n][n];

       for(int i=0 ; i<n ; i++){
        for(int j=0 ; j<d ; j++){
            cin>>a[i][j];

        }
       }
       f(n){
         for(int j=0 ; j<n ; j++){
            c[i][j]=0;
         }
       }

      ll kt=0 ,sum=0,duk=0;

       for(int i=0 ; i<n ; i++){
        for(int j=0 ; j<n ; j++){

            if(c[i][j]==0 && (i!=j)){
               //duk++;
              for(int k=0 ; k<d ; k++){
              sum += ((a[i][k]-a[j][k])*(a[i][k]-a[j][k]));
              }
              ll s = sqrt(sum);
              double  s1 =  double(sqrt(sum));
              if(s==s1) ++kt;
              sum=0;
              c[i][j]=1,c[j][i]=1;
            }

        }
       }
        cout<<kt<<endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define sz(arr) (int)(arr).size()
#define rng(arr) arr.begin(), arr.end()
#define show(x) cout << #x << " = " << x << endl;

using namespace std;
typedef long long ll;

void _cin() {}
template <class Head, class... Tail>
void _cin(Head&& head, Tail&&... tail) {
  cin >> head;
  _cin(forward<Tail>(tail)...);
}

#define Cin(T, ...) \
  T __VA_ARGS__;    \
  _cin(__VA_ARGS__)

#define Cins(T, n, xs) \
  vector<T> xs(n);     \
  for (int i = 0; i < n; ++i) cin >> xs[i]

void Main() {
  Cin(ll, a, b, c);

  ll ans = 0;
  if (b >= c) {
    ans = b + c;
    cout << ans << endl;
    return;
  }

  ans = b * 2;
  c -= b;
  ans += min(a + 1, c);
  cout << ans << endl;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(15);
  Main();
  return 0;
}

Measured memory_bytes: 256
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        n: usize,
        mut a: [u64; n],
    }
    a.sort();
    let mut count = 0;
    let mut i: usize = 0;
    while i < n {
        let mut char_count: u64 = 0;
        let now = a[i];
        while i < n && now == a[i] {
            char_count += 1;
            i += 1;
        }
        count += if now <= char_count {
            char_count - now
        } else {
            char_count
        };
    }

    println!("{}", count);
}


Measured memory_bytes: 4148
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <stack>
#include <algorithm>
#include <iostream>
#include <string>
#include <map>

using namespace std;

int main() {

    string S;
    string T;
    cin >> S >> T;

    int cnt = 0;
    for (int i = 0; i < 3; ++i) {
        if (S[i] == T[i]) {
            cnt += 1;
        }
    }

    cout << cnt << "\n";

    return 0;
}


Measured memory_bytes: 256
n,x = map(int, input().split())
l = list(map(int,input().split()))
a = 0
for i in range(len(l)):
  a += l[i]
  if a > x:
    print(i+1)
    break
  if a == x:
    print(i+2)
    break
  if i == len(l)-1:
    print(i+2)

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

using namespace std;

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

int H, W, size;
char map[101][101];
int owner[101][101];
void dfs(int i, int j, int size) {
    char c = map[i][j];
    owner[i][j] = size;
    if(j+1<W && map[i][j+1]==c && owner[i][j+1]==-1) dfs(i, j+1, size);
    if(j>0 && map[i][j-1]==c && owner[i][j-1]==-1) dfs(i, j-1, size);
    if(i+1<H && map[i+1][j]==c && owner[i+1][j]==-1) dfs(i+1, j, size);
    if(i>0 && map[i-1][j]==c && owner[i-1][j]==-1) dfs(i-1, j, size);
}
int main() {
    while(cin >> H >> W && H!=0 && W!=0) {
        rep(i, H) {
            rep(j, W) {
                cin >> map[i][j];
                owner[i][j]=-1;
            }
        }
        bool isFinished = false;
        size = -1;
        while(isFinished==false) {
            isFinished = true;
            rep(i, H) {
                rep(j, W) {
                    if(owner[i][j]==-1) {
                        dfs(i, j, ++size);
                        isFinished = false;
                    }
                }
            }
        }
        cout << size+1 << endl;
        }
    return 0;
}

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

int main()
{
    string S, SS, T, C;
    cin >> SS >> T;
    {
        C="|";
        for(int j=0; j<(SS.length()-T.length()+1); j=j+1)
        {
            int satisfy=1;
            for(int i=0; i<T.length(); i=i+1)
            {
                if(SS[i+j]!=T[i] && SS[i+j]!='?')
                {
                    satisfy=0;
                }
            }
            if (satisfy == 1)
            {
                S="";
                for(int s=0; s<SS.length(); s=s+1)
                {
                    if(SS[s]!='?')
                    {
                        S+=SS[s];
                    }
                    else
                    {
                        S+='a';
                    }
                }
                for(int t=0; t<T.length(); t=t+1)
                {
                    S[j+t]=T[t];
                }
                if(S<C)
                {
                    C="";
                    for(int n=0; n<S.length(); n=n+1)
                    {
                        C+=S[n];
                    }
                }
            }
        }
        if(C=="|")
        {
            cout << "UNRESTORABLE" << endl; 
        }
        else
        {
            cout << C << endl;
        }              
    }
    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.regex.Pattern;

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		Pattern p = Pattern.compile("[A-Z]");

		String str = br.readLine();
		char[] upper = str.toUpperCase().toCharArray();
		char[] origin = str.toCharArray();
		for(int i=0; i<origin.length;i++){
			if(origin[i]==upper[i]){
				if(p.matcher(String.valueOf(origin[i])).find()){
					upper[i] = String.valueOf(origin[i]).toLowerCase().charAt(0);
				}
			}
		}

		System.out.println(String.valueOf(upper));
	}
}

Measured memory_bytes: 25356
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>

using namespace std;



int main(){
    int ss;
    cin >> ss;
    int h,m,s;
    h = ss/3600;
    m = (ss%3600)/60;
    s = ss%60;
    printf("%d:%d:%d\n",h,m,s);
    
    return 0;
}

Measured memory_bytes: 1148
#include<bits/stdc++.h>
using namespace std; 
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
template<typename T> string join(vector<T> &vec ,string &sp){
    int si = vec.length;
    if(si==0){
        return "";
    }else{
        stringstream ss;
        rep(i,si-1){
            ss << vec[i] << sp;
        }
        ss << vec[si - 1];
        return ss.str();
    }
}
vector<int> uf(200010);
int root(int p){
    if(p == uf[p]) return p;
    else{
        
        return uf[p] = root(uf[p]);
    }
}
int main(void){
    int n,m;
    cin >> n >> m;
    n++;
    rep(i,n+1){
        uf[i] = i;
    }
    rep(i,m){
        int a,b;
        cin >> a >> b;
        int rx = root(uf[a]);
        int ry = root(uf[b]);
        if(rx!=ry){
            uf[rx] = ry;
        }
    }

  vector<int> vec(n+1,0);
  
  rep(i,n){
    vec[root(uf[i])] = 1;
  }
  int sum = 0;
  rep(i,n){
    if(vec[i]==1) sum++;
 //   cout << root(uf[i]) << endl;
  }
  cout << sum-2 << endl;
}


Measured memory_bytes: 4496
def bishop(n, m):
	if n == 1 or m == 1:
		return 1
	if n % 2 == 0:
		return (n // 2) * m
	else:
		return (((n // 2)+1) * m) - (m // 2)
n, m = map(int, input().split())
print(bishop(n, m))

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

using namespace std;

int main()
{
    int n,i;
    cin>>n;
    vector<long long> ara(n),ans(n+1);

    ans[0]=0;
    for(i=0;i<n;i++) {
        cin>>ara[i];
        if(i%2==0) ans[0]+=ara[i];
        else ans[0]-=ara[i];
    }
    for(i=1;i<n;i++){
        ans[i]=2*ara[i-1]-ans[i-1];
        cout << ans[i-1] << ' ';
    }
    cout<< ans[i-1]<< endl;

    return 0;
}


Measured memory_bytes: 2944
#define _LIBCPP_DEBUG 0
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=int(a);i<int(b);i++)
typedef vector<int> vi;
typedef long long ll;



int main(){
    
    int H,W;
    cin>>H>>W;
    int t[9][9];
    rep(i,0,9)rep(j,0,9)t[i][j]=0;

    char c[9][9];
    rep(i,0,9)rep(j,0,9)c[i][j]='.';
    
    rep(i,0,H){
        rep(j,0,W)cin>>c[i][j];
    }
    if(c[0][0]!='#'||c[H-1][W-1]!='#'){
        cout<<"Impossible"<<endl;
        return 0;
    }
    t[0][0]=1;t[H-1][W-1]=1;

    int nowx=0,nowy=0;
    while(1){
        if(nowx==H-1&&nowy==W-1)break;
        if(c[nowx+1][nowy]=='#'&&c[nowx][nowy+1]=='.'){
            t[nowx+1][nowy]=1;
            nowx++;
           // cout<<"d"<<nowx<<nowy;
        }
        else if(c[nowx][nowy+1]=='#'&&c[nowx+1][nowy]=='.'){
            t[nowx][nowy+1]=1;
            nowy++;
          //  cout<<"r"<<nowx<<nowy;
        }
        else{
            cout<<"Impossible"<<endl;
            return 0;
        }
    }
    rep(i,0,H){
        rep(j,0,W){
            if(c[i][j]=='#'&&t[i][j]==0){
                cout<<"Impossible"<<endl;
                return 0;
            }
        }
    }
    cout<<"Possible"<<endl;
}






Measured memory_bytes: 256
main(){float a,b,c,d,e,f,x;for(;~scanf("%f%f%f%f%f%f",&a,&b,&c,&d,&e,&f);printf("%.3f %.3f\n",(e*c-b*f)/x+0.0,(a*f-d*c)/x+0.0))x=a*e-b*d;exit(0);}

Measured memory_bytes: 648
s = input()
if s =="SUN":
    print("7")
elif s=="MON":
    print("6")
elif s=="TUE":
    print("5")
elif s=="WED":
    print("4")
elif s=="THU":
    print("3")
elif s=="FRI":
    print("2")
elif s=="SAT":
    print("1")

Measured memory_bytes: 2940
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def IS(): return sys.stdin.readline()[:-1]
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LII(rows_number): return [II() for _ in range(rows_number)]
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]

def main():
	A,B = MI()
	if(A <= B*2):
		print(0)
	else:
		print(A-2*B)

main()

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

using namespace std;

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin>>n;
    vector<int>v(n);
    for(int i=0;i<n;i++)
        cin>>v[i];
    unordered_map<int,int>mp;
    long long ttl=0ll;
    for(int i=1;i<n;i++){
        int dif=(i-v[i])-v[0];
        mp[dif]++;
        if(dif==0)
            ttl++;
    }

    for(int i=1;i<n;i++){
        int dif=(i-v[i])-v[0];
        ///mp[dif]--;
        ttl+=(long long)mp[i+v[i]-v[0]];
    }
    cout << ttl << endl;
    return 0;
}
/***
32
3 1 4 1 5 9 2 6 5 3 5 8 9 7 9 3 2 3 8 4 6 2 6 4 3 3 8 3 2 7 9 5

6
2 3 3 1 3 1
*/


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

def main():
    N, M =map(int, input().split())
    a = [int(input()) for i in range(M)]

    sep = []
    pre = -1
    ok = True
    for t in a:
        tmp = t - pre - 1
        if tmp == 0:
            ok = False
            break
        sep.append(tmp)
        pre = t
    sep.append(N-pre)
    # print(sep)

    if not ok:
        print(0)
        return
    max_sep = max(sep)

    MOD = 1000000007
    fib = [1] * (max_sep)
    for i in range(2, max_sep):
        fib[i] = fib[i-2] + fib[i-1]
        fib[i] %= MOD
    
    ans = 1
    for s in sep:
        ans *= fib[s-1]
        ans %= MOD
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 7076
let () =
  let n = read_int () in
  let x = Array.make 6 0 in
  for i = 0 to n-1 do
    let m = read_float () in
    if m < 165. then x.(0) <- x.(0)+1
    else if m >= 165. && m < 170. then x.(1) <- x.(1)+1
    else if m >= 170. && m < 175. then x.(2) <- x.(2)+1
    else if m >= 175. && m < 180. then x.(3) <- x.(3)+1
    else if m >= 180. && m < 185. then x.(4) <- x.(4)+1
    else if m >= 185. then x.(5) <- x.(5)+1
  done;
  let print n cnt =
    Printf.printf "%d:" n;
    for i = 0 to cnt-1 do
      Printf.printf "%c" '*'
    done;
    print_newline ()
  in
  Array.iteri (fun i x -> print (i+1) x) x
;;

Measured memory_bytes: 2128
#include <iostream>
#include <cstdio>
#include <math.h>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <string.h>
#include <array>
#include <bitset>

using namespace std;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int n;
	cin >> n;
	if(n%10==7 || n/10%10==7 || n/100==7){
		cout << "Yes\n";
	}
	else{
		cout << "No\n";
	}
	return 0;
}

Measured memory_bytes: 3612
#include <algorithm>
#include <cctype>
#include <cmath>
#include <iostream>
#include <queue>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <set>
#include <numeric>

using namespace std;


class ListNode {
public:
    int val;
    ListNode *next;
    ListNode(int val) {
        this->val = val;
        this->next = NULL;
    }
};

struct TreeNode {
    int val;
    TreeNode *left;
    TreeNode *right;
    TreeNode(int x) : val(x), left(NULL), right(NULL) {}
};



int main() {
  int n, k; cin >> n >> k;
  vector<int> vi(n);
  for (int i = 0; i < n; ++i) cin >> vi[i];
  sort(vi.begin(), vi.end());
  int res = 0;
  for (int i = n - 1, j = 0; j < k; ++j, --i) res += vi[i];
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 256
import sys

# キー入力
key = input()

display = ""
for i in key:
    if i == '0':
        # '0'を追加
        display += '0'
    if i == '1':
        # '1'を追加
        display += '1'
    if i == 'B':
        # 一番後ろの文字を削除
        display = display[:-1]

print(display)

Measured memory_bytes: 2940
#include <algorithm>
#include <array>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 4000000000000000000LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(6);

  int N, K, A[111111], B[111111];

  std::cin >> N >> K;

  for (int i = 0; i < N; i ++)
    std::cin >> A[i] >> B[i];

  long long s = 0, sp = 0;

  uint32_t mask = ~K;

  for (int j = 0; j < N; j ++)
    if ((A[j] & mask) == 0)
      s += B[j];

  sp = s;

  for (int i = 0; (1 << i) <= K; i ++) {
    if ((K & (1 << i)) == 0)
      continue;

    uint32_t mask = ~(K & ~(1LL << i)) & ~ ((1LL << i) - 1);

    long long s = 0;

    for (int j = 0; j < N; j ++)
      if ((A[j] & mask) == 0)
        s += B[j];

    sp = std::max(s, sp);
  }

  std::cout << sp << std::endl;

  return 0;
}


Measured memory_bytes: 1024
from scipy.sparse.csgraph import floyd_warshall

n,m=map(int,input().split())
l=[list(map(int,input().split())) for i in range(m)]

ans=0
for i in range(m):
    ll=l[:i]+l[i+1:]

    d=[[float('inf')]*n for i in range(n)]
    for i in range(n):
        d[i][i]=0

    for j in ll:
        d[j[0]-1][j[1]-1]=1
        d[j[1]-1][j[0]-1]=1

    d=floyd_warshall(d)

    if float('inf') in d:
        ans+=1

print(ans)

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

#define pb push_back
#define eb emplace_back
#define rep(i,a,b) for(auto i=(a);i!=(b);++i)
#define REP(i,n) rep(i,0,n)
#define all(v) (v).begin(), (v).end()
#define rs resize
#define x first
#define y second

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;

ostream& operator<<(ostream &out, const pii &a) { return out << '(' << a.x << ", " << a.y << ')'; }
istream& operator>>(istream &in, pii &a) { return in >> a.x >> a.y; }

const int INF = 2147483647;
const ll LLINF = 9223372036854775807LL;

// lambda-expression: [] (args) -> retType { body }

const int maxk2 = 2010;

int N, K, cntW[maxk2][maxk2] = {}, cntB[maxk2][maxk2] = {};

// sum (lx, ..., rx] \times (ly, ..., ry]
int sumW(int lx, int rx, int ly, int ry) {
	int r = cntW[rx][ry] - cntW[rx][ly] - cntW[lx][ry] + cntW[lx][ly];
	// cerr << "(" << lx << ", " << rx << "] x (" << ly << ", " << ry << "]: " << cntW[rx][ry] << " - " << cntW[rx][ly] << " - " << cntW[lx][ry] << " + " << cntW[lx][rx] << " == " << r << endl;
	return r;
}
int sumB(int lx, int rx, int ly, int ry) { return cntB[rx][ry] - cntB[rx][ly] - cntB[lx][ry] + cntB[lx][ly]; }

void run()
{
	cin >> N >> K;
	int k2 = K * 2;
	REP(i, N) {
		int x, y;
		char ch;
		cin >> x >> y >> ch;
		((ch == 'W') ? cntW : cntB)[1 + x % k2][1 + y % k2]++;
	}
	// calculate the 2D prefix sum
	rep(i, 1, k2 + 1) {
		rep(j, 1, k2 + 1) {
			cntW[i][j] += cntW[i - 1][j] + cntW[i][j - 1] - cntW[i - 1][j - 1];
			cntB[i][j] += cntB[i - 1][j] + cntB[i][j - 1] - cntB[i - 1][j - 1];
		}
	}

	/*
	REP(i, k2 + 1) {
		REP(j, k2 + 1) cerr << cntW[i][j] << " ";
		cerr << endl;
	}
	*/

	int nw = cntW[k2][k2];
	int nb = cntB[k2][k2];

	assert(nw + nb == N);

	int ans = 0;

	// now try every possible primitive start.
	for (int i = 1; i <= K; i++) {
		for (int j = 1; j <= K; j++) {
			// take (i, j) as the beginning of a whole square
			/*
			int kw = nw
				- (cntW[i + K][k2] + cntW[k2][j + K])
				+ (cntW[i][k2] + cntW[k2][j])
				+ 2 * sumW(i, i + K, j, j + K);

			int kb = nb
				- (cntB[i + K][k2] + cntB[k2][j + K])
				+ (cntB[i][k2] + cntB[k2][j])
				+ 2 * sumB(i, i + K, j, j + K);
			*/

			int kw = sumW(i + K, k2, j + K, k2)
					+ sumW(0, i, j + K, k2)
					+ sumW(i + K, k2, 0, j)
					+ sumW(0, i, 0, j)
					+ sumW(i, i + K, j, j + K);
			int kb = sumB(i + K, k2, j + K, k2)
					+ sumB(0, i, j + K, k2)
					+ sumB(i + K, k2, 0, j)
					+ sumB(0, i, 0, j)
					+ sumB(i, i + K, j, j + K);

			// cerr << "PRIM AT " << i << ", " << j << ": " << kw << ", " << kb << endl;

			int Kw = kw + (nb - kb);
			int Kb = kb + (nw - kw);

			ans = max(ans, max(Kw, Kb));
		}
	}
	cout << ans << endl;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	// cerr << boolalpha;
	(cout << fixed).precision(10);

	run();

	return 0;
}

Measured memory_bytes: 31744
def tak_and_hotels(N: int, K: int, X: int, Y: int) -> int:
    return min(N, K) * X + max(0, N - K) * Y


if __name__ == "__main__":
    N = int(input())
    K = int(input())
    X = int(input())
    Y = int(input())
    ans = tak_and_hotels(N, K, X, Y)
    print(ans)


Measured memory_bytes: 2940
# https://atcoder.jp/contests/abc151/tasks/abc151_c

N,M = map(int, input().split()) # 複数数値入力
p = []
S = []
for i in range(M):
    a,b = input().split() # 複数数値入力
    p.append(int(a)-1)
    S.append(b)

# 正答数
flag = [False for e in range(N)]
corr = 0
# 各問題iについて
for i in range(M):
    # これまで一度でもACを出していればskip
    if flag[p[i]]:
        continue
    else:
        # ACなら1足してflagを立てる
        if S[i] == "AC":
            corr += 1
            flag[p[i]] = True

# 誤答数
flag = [False for e in range(N)]
error = 0
# 各問題のerror
errors = [0 for e in range(N)]
# 各問題iについて
for i in range(M):
    # これまで一度でもACを出していればskip
    if flag[p[i]]:
        continue
    else:
        # WAなら1足す
        if S[i] == "WA":
            errors[p[i]] += 1
        # ACなら集計してflagを立てる
        else:
            error += errors[p[i]]
            flag[p[i]] = True

print(corr,error)


Measured memory_bytes: 14920
N, A, B, C, D = map(int, input().split())

if N%A == 0:x = N//A *B    
else:       x = (N//A +1) *B

if N%C == 0:y = N//C *D
else:       y = (N//C +1) *D

if x<=y: print(x)
else:    print(y) 







Measured memory_bytes: 5596
#include<bits/stdc++.h>
#define MAXN ((int)(1e5+10))
#define INF ((int)(1e9))
using namespace std;
typedef long long LL;
int n,k;
LL a[MAXN],sum=0,ans=-INF,tmp=0;
int main()
{
	cin>>n>>k;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
		tmp+=a[i];
		if(a[i]>0)
			sum+=a[i];
	}
	LL integer=0,fu=0;
	for(int i=0;i<k;i++)
	{
		if(a[i]>0)
			integer+=a[i];
		else
			fu+=(0-a[i]);
	}
	for(int i=0;i<=n-k;i++)
	{
		LL rec;
		if(integer>=fu)
			rec=sum-fu;
		else
			rec=sum-integer;
		ans=max(ans,rec);
		if(a[i]>0)
			integer-=a[i];
		else
			fu-=(0-a[i]);
		if(a[i+k]>0)
			integer+=a[i+k];
		else
			fu+=(0-a[i+k]);
	}
	cout<<ans<<endl;
	return 0;
} 

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define FOR0(i,n) for(i=0;i<n;i++)
#define FOR(i,j,n) for(i=j;i<n;i++)
#define FORD(i,j,k) for(i=j;i>=k;i--)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define inf 1000000000
#define ninf -1000000000
#define endl '\n' 
#define she_told_me_dont_worry ios_base::sync_with_stdio (false) ; cin.tie(0) ; cout.tie(0) ;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// Use cout.flush() for interactive problems.
// Use this for increased stack size: g++ -o a.exe -Wl,--stack=256000000 -O2 source.cpp
inline long long  MAX2(long long  a, long long int b){return (a)>(b)?(a):(b);}
inline long long  MAX3(long long  a, long long  b,long long  c){return (a)>(b)?((a)>(c)?(a):(c)):((b)>(c)?(b):(c));}
inline long long  MIN2(long long  a, long long  b){return (a)<(b)?(a):(b);}
inline long long  MIN3(long long  a, long long b,long long c){return (a)<(b)?((a)<(c)?(a):(c)):((b)<(c)?(b):(c));}
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef pair<int,int> ii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector< ii > vii;
int main()
{
    she_told_me_dont_worry
    ll k;
    cin>>k;
    ll a, b, c;
    ll ans = 0;
    FOR(a, 1, k+1)FOR(b, 1, k+1)FOR(c, 1, k+1)
    {
        ll cur = __gcd(a, b);
        cur = __gcd(cur, c);
        ans += cur;
    }
    cout<<ans<<endl;
    cerr <<endl<< "Time elapsed : " << clock() * 1000.0 / CLOCKS_PER_SEC << " ms" << '\n';
}

Measured memory_bytes: 3788
#!/usr/bin/env python3

n, a, b = map(int, input().split())
mod = 10**9 + 7
a = min(a, n-a)
b = min(b, n-b)
com = [1] * (max(a, b) + 1)
for i in range(1,len(com)):
    com[i] = (com[i-1] * pow(i, mod-2, mod) * (n-i+1)) % mod
print((pow(2, n, mod) + mod - 1 - com[a] - com[b]) % mod)

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

using namespace std;

int main()
{
    ios_base::sync_with_stdio(0), cin.tie(0);

    int a, b;
    cin >> a >> b;
    int c = min(a, b), d = max(a, b);
    if ((16-2*c)/2 >= d-c)
    	cout << "Yay!";
    else
    	cout << ":(";
    cout << "\n";

    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cstdlib>
#include<iostream>
#include<vector>
#include<map>
#include<cmath>
using namespace std;
int N;




int main(int argc, char const *argv[])
{
    cin>>N;
    std::vector<int> L(N);
    for(size_t i=0;i<L.size();i++){
        cin>>L[i];
    }
int max = *std::max_element(L.begin(), L.end());
int sum_length=0;
for(size_t i=0;i<L.size();i++){
    sum_length+=L[i];
}
if(sum_length-max>max){
    cout<<"Yes"<<endl;
}else{
    cout<<"No"<<endl;
}
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Math;

namespace CSharp
{
    static class Program
    {
        static void Main(string[] args)
        {
            int x, y;
            ReadInt(out x, out y);

            int ans = x + y / 2;
            Console.WriteLine(ans);
        }

        #region Helpers

        static int[] ReadIntArray() => Console.ReadLine().Split().Select(s => int.Parse(s)).ToArray();
        static long[] ReadLongArray() => Console.ReadLine().Split().Select(s => long.Parse(s)).ToArray();

        static int[] ReadLineIntArray(int count) => Enumerable.Repeat(0, count).Select(_ => int.Parse(Console.ReadLine())).ToArray();
        static long[] ReadLineLongArray(int count) => Enumerable.Repeat(0, count).Select(_ => long.Parse(Console.ReadLine())).ToArray();

        static string ReadString() => Console.ReadLine();
        static int ReadInt() => int.Parse(Console.ReadLine());
        static long ReadLong() => long.Parse(Console.ReadLine());

        static void ReadInt(out int first)
        {
            var array = ReadIntArray();
            first = array[0];
        }

        static void ReadInt(out int first, out int second)
        {
            var array = ReadIntArray();
            first = array[0];
            second = array[1];
        }

        static void ReadInt(out int first, out int second, out int third)
        {
            var array = ReadIntArray();
            first = array[0];
            second = array[1];
            third = array[2];
        }

        static void ReadInt(out int first, out int second, out int third, out int fourth)
        {
            var array = ReadIntArray();
            first = array[0];
            second = array[1];
            third = array[2];
            fourth = array[3];
        }

        static void ReadLong(out long first)
        {
            var array = ReadLongArray();
            first = array[0];
        }

        static void ReadLong(out long first, out long second)
        {
            var array = ReadLongArray();
            first = array[0];
            second = array[1];
        }

        static void ReadLong(out long first, out long second, out long third)
        {
            var array = ReadLongArray();
            first = array[0];
            second = array[1];
            third = array[2];
        }

        static void ReadLong(out long first, out long second, out long third, out long fourth)
        {
            var array = ReadLongArray();
            first = array[0];
            second = array[1];
            third = array[2];
            fourth = array[3];
        }

        #endregion
    }
}

Measured memory_bytes: 13268
#include<stdio.h>
#include<ctype.h>
#include<stdlib.h>
void call (int n) {
    int i=1,x;
    
    do {
            x=i;
            if (x % 3 == 0) {
                printf(" %d",i);    
            } else {
                 do {
                        if(x % 10 == 3) {
                            printf (" %d",i);
                            x=0; //while(x)抜ける
                        } else {
                            x/=10;
                        }
                    } while (x);
              }
            
        } while (++i <= n);
    printf("\n");
    
}

int main () {
    int n;
    scanf("%d",&n);
    call(n);
    
    return 0;
}


Measured memory_bytes: 2080
import sys
from collections import Counter
from math import gcd

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

N = INT()
C = Counter()
zero = 0
for i in range(N):
    a, b = MAP()
    if a == b == 0:
        zero += 1
    elif a == 0:
        C[(0, 1, 0)] += 1
    elif b == 0:
        C[(1, 0, 1)] += 1
    else:
        g = gcd(a, b)
        ga, gb = a // g, b // g
        C[((a < 0) ^ (b < 0), abs(ga), abs(gb))] += 1

ans = 1
for k, v in C.items():
    if v == 0:
        continue
    op, a, b = k
    ans *= pow(2, C[(op, a, b)], MOD) + pow(2, C[(1-op, b, a)], MOD) - 1
    ans %= MOD
    if (1-op, b, a) in C:
        C[(1-op, b, a)] = 0
print((zero+ans-1)%MOD)


Measured memory_bytes: 46880
import Control.Applicative
import Control.Monad
import Data.Array
import Data.Array.ST
import Data.Char
import Data.List
import qualified Data.Map as M
import qualified Data.Set as S
import Text.Printf

readInts :: IO [Int]
readInts = map read . words <$> getLine

data Dice = Dice 
  { top :: Int
  , bottom :: Int
  , north :: Int
  , south :: Int
  , east :: Int
  , west :: Int
  }

main :: IO ()
main = do
  [t,s,e,w,n,b] <- readInts
  xs <- getLine
  let d0 = Dice t b n s e w
  let d1 = foldl rotate d0 xs
  print $ top d1

rotate :: Dice -> Char -> Dice
rotate d@(Dice t b n s e w) 'N' = d { top = s, north = t, south = b, bottom = n }
rotate d@(Dice t b n s e w) 'S' = d { top = n, north = b, south = t, bottom = s }
rotate d@(Dice t b n s e w) 'E' = d { top = w, east = t, west = b, bottom = e }
rotate d@(Dice t b n s e w) 'W' = d { top = e, east = b, west = t, bottom = w }



Measured memory_bytes: 3628
n, m = map(int, input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))
MOD = 10**9 + 7

r = [0] # r[i] : xiと、xiより左の縦の直線を使用した長方形の横の辺の長さの総和
for i in range(1, n):
    r.append(r[-1] + (x[i] - x[i-1]) * i)

dp_h = [0] * n # dp[i] : 左からi本目までの縦の直線のうち2本を使用したときの長方形の横の辺の長さの総和
for i in range(1, n):
    dp_h[i] = (dp_h[i-1] + r[i]) % MOD

u = [0]
for i in range(1, m):
    u.append(u[-1] + (y[i] - y[i-1]) * i)

dp_v = [0] * m
for i in range(1, m):
    dp_v[i] = (dp_v[i-1] + u[i]) % MOD

print((dp_h[n-1] * dp_v[m-1]) % MOD)

Measured memory_bytes: 28688
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include <cctype>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
typedef long long ll;

int main(){
    int x;
    cin >> x;
    cout << (1200>x ? "ABC" : "ARC") << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,a,i,y=0;
  map<int,int> m;
  cin>>n;
  for(i=0;i<n;i++){
    cin>>a;
    if(m.count(a)) m.at(a)++;
    else m[a]=1;
  }
  for(auto z:m){
    if(z.first<z.second) y+=z.second-z.first;
    else if(z.first>z.second) y+=z.second;
  }
  cout<<y<<endl;
}

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

int main () {
    ll n, d, ans = 0;
    cin >> n >> d;

    for (int i = 0; i < n; i++) {
        double a, b;
        cin >> a >> b;
        if (a*a+b*b <= d*d) {
            ans ++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
#define IO_OP std::ios::sync_with_stdio(0); std::cin.tie(0);
#define F first
#define S second
#define PB push_back
#define MP make_pair

using namespace std;

typedef long long ll;
typedef pair<int, int> pi;
typedef vector<int> vi;

const int INF = 1e9 + 7;

int l[10], a, b, c, n, ca, cb, cc, cnt = -30;
int ans = INF;

void f(int i) {
	if(i == n) {
		if(ca && cb && cc)
			ans = min(ans, cnt + abs(a-ca) + abs(b-cb) + abs(c-cc));
		return;
	}
	ca += l[i];
	cnt += 10;
	f(i+1);
	ca -= l[i];
	cb += l[i];
	f(i+1);
	cb -= l[i];
	cc += l[i];
	f(i+1);
	cc -= l[i];
	cnt -= 10;
	f(i+1);
}

int main()
{
	IO_OP;
	
	cin >> n >> a >> b >> c;
	for(int i=0;i<n;i++)
		cin >> l[i];
	f(0);
	cout << ans << endl;
	
}



Measured memory_bytes: 256