akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

void solve(std::istream &in, std::ostream &out);

int main() {
#ifdef LOCAL
//  freopen("../IO/e.in", "r", stdin);
//  freopen("../IO/e.out", "w", stdout);
#else
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(nullptr);
  std::cout.tie(nullptr);
#endif
  solve(std::cin, std::cout);
  return 0;
}

int n;
char buff[10];
int ask1(int p) {
  cout << "? ";
  for (int i = p; i < p + n; ++i) {
    cout << i + 1;
    if (i == p + n - 1) {
      cout << endl;
    } else {
      cout << ' ';
    }
  }
  cin >> buff;
  return buff[0] == 'R';
}

vector<int> gs[2];
int ask2(int p, int g) {
  cout << "? " << p + 1 << ' ';
  for (int i : gs[g]) {
    cout << i + 1 << ' ';
  }
  cout << endl;
  cin >> buff;
  return buff[0] == 'R';
}

void solve(std::istream &in, std::ostream &out) {
  in >> n;
  int x = ask1(0);
  int l = -1, r = n;
  while (r - l > 1) {
    int mid = l + r >> 1;
    int y = ask1(mid);
    if (x != y) {
      r = mid;
    } else {
      l = mid;
    }
  }
  for (int i = l + 1; i < l + n; ++i) gs[0].push_back(i);
  for (int i = l + n + 1; i < 2 * n; ++i) gs[1].push_back(i);
  for (int i = 0; i < l; ++i) gs[1].push_back(i);
  vector<int> ans(2 * n);
  ans[l] = x, ans[l + n] = 1 - x;
  for (int i : gs[0]) ans[i] = ask2(i, 1);
  for (int i : gs[1]) ans[i] = ask2(i, 0);
  out << "! ";
  for (int i = 0; i < 2 * n; ++i) {
    out << (ans[i] ? 'R' : 'B');
  }
  out << endl;
}


Measured memory_bytes: 724
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define INF (1LL<<50)
#define MOD 1000000007

int main(){
    int N;
    cin >> N;
    vector<int> D(N);
    rep(i,N) cin >> D[i];
    int M;
    cin >> M;
    vector<int> T(M);
    rep(i,M) cin >> T[i];
    sort(D.begin(),D.end());
    sort(T.begin(),T.end());
    int ix=0;
    for(int i=0;i<M;i++){
        while(ix<N){
            if(D[ix]==T[i]){
                ix++;
                break;
            }
            ix++;
            if(ix==N){
                cout << "NO" << endl;
                return 0;
            }
        }
    }
    cout << "YES" << endl;
    return 0;
}

Measured memory_bytes: 1792
#include<cstdio>
using namespace std;

const int mod=998244353,maxn=3e5+7;
int a,b,n;
long long k;
long long x,y,ans;

long long c[maxn]={1},inv[maxn]={1},fac[maxn]={1};

long long poww(int x,int y)
{
	long long ans=1,base=x;
	while(y){
		if(y&1)ans=(ans*base)%mod;
		base=(base*base)%mod;
		y>>=1;
	}
	return ans;
}

void pre()
{
	fac[0]=1,fac[1]=1;
    for(int i=2;i<=n+1;i++) fac[i]=fac[i-1]*i%mod;
    inv[n+1]=poww(fac[n+1],mod-2);
    for(int i=n;i>=0;i--) inv[i]=inv[i+1]*(i+1)%mod;
}

long long get_c(int x)
{
	return ((1ll*fac[n]*inv[n-x])%mod*inv[x])%mod;
}

int main()
{
//	freopen("a.txt","r",stdin);
	scanf("%d %d %d %lld",&n,&a,&b,&k);
	if(k==0){printf("1"); return 0;}
	pre();
	for(x=1;x<=n;++x){
		if((k-x*a)%b)continue;
		y=(k-a*x)/b;
		if(y>n||y<0)continue;
		ans+=get_c(x)*get_c(y);
		ans%=mod;
	}
	printf("%lld",ans%mod);
	return 0;
}

Measured memory_bytes: 4864
#include <iostream>
#include <vector>
#include <queue>
#include <utility>

using namespace std;
typedef long long ll;
int main() {
    string s;
    cin >> s;
    int ans = 0;
    for(int i=0;i<6;i++) {
        if(s[i] == '1') ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 764
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n) for(ll i = 0; i < n; i++)
#define rep2(i,start,end) for(ll i = start; i < end; i++)
#define dwn(i,n) for(int i = n; i >= 0; i--)
#define dwn2(i,start,end) for(ll i = start; i >= end; i--)
#define pll pair<ll,ll>
#define mk(x,y) make_pair(x,y)
#define pdl pair<double, ll>
const ll N = 4e5 + 200;
const ll INF = 0x3f3f3f;
const ll Mode = 1e9 + 7;

int main(){
	int n,m;
	cin>>n;
	vector<double> v(n);
	double sum = 0;
	rep(i,n){
		double x;
		cin>>x;
		v[i] = 1.0/x;
	}
	rep(i,n){
		sum += v[i];
	}
	printf("%.6lf\n",1.0/sum);
	return 0;
}

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

int main() {
  int h,n,s;
  cin >> h >> n;
  int i=0;
  s=0;
  while(i<n){
    int A_i;
    cin >> A_i;
    s +=A_i;
    i++;
  }
  if(s>=h) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <queue>
#include <set>

typedef std::pair<int, int> ii;
typedef std::vector<int> vi;

struct union_find {
  int n;  vi p; union_find(int n) : n(n), p(n, -1) { }
  int find(int x) { return p[x] < 0 ? x : p[x] = find(p[x]); }
  bool unite(int x, int y) {
    int xp = find(x), yp = find(y);
    if (xp == yp)       return false;
    if (p[xp] > p[yp])  std::swap(xp,yp);
    p[xp] += p[yp], p[yp] = xp;
    n--;
    return true;
  }
  int size(int x) { return -p[find(x)]; }
};

struct graph {
  int n;
  std::set<int>  *adj;
  int *dist;
  graph(int n) : n(n) {
    adj = new std::set<int>[n];
    dist = new int[n];
  }
  void add_edge(int u, int v) {
    adj[u].insert(v);
    adj[v].insert(u);
  }
  void bfs(int s) {
    for (int i = 0; i < n; ++i)
      dist[i] = -1;
    dist[s] = 0;
    std::queue<int> q;
    q.push(s);
    while (!q.empty()) {
      int u = q.front();  q.pop();
      for (int v : adj[u]) {
        if (dist[v] == -1) {
          dist[v] = dist[u] + 1;
          q.push(v);
        }
      }
    }
  }
};

int H, W, Ch, Cw, Dh, Dw;
std::string grid[1005];

int coord(int i, int j) {
  return i*W + j;
}

bool inside(int i, int j) {
  return 0 <= i and i < H and 0 <= j and j < W;
}

int main() {
  std::cin >> H >> W;
  std::cin >> Ch >> Cw;
  std::cin >> Dh >> Dw;
  for (int i = 0; i < H; ++i)
    std::cin >> grid[i];

  union_find uf(H*W);
  for (int i = 0; i < H; ++i) {
    for (int j = 0; j < W; ++j) {
      if (i > 0 and grid[i][j] == '.' and grid[i-1][j] == '.')
        uf.unite(coord(i, j), coord(i-1, j));
      if (j > 0 and grid[i][j] == '.' and grid[i][j-1] == '.')
        uf.unite(coord(i, j), coord(i, j-1));
    }
  }

  /*for (int i = 0; i < H; ++i) {
    for (int j = 0; j < W; ++j) {
      std::cout << uf.find(coord(i, j)) << " ";
    }
    std::cout << "\n";
  }*/

  graph g(H*W);
  for (int i = 0; i < H; ++i) {
    for (int j = 0; j < W; ++j) {
      if (grid[i][j] != '.')  continue;
      int c1 = uf.find(coord(i, j));
      for (int ki = -2; ki <= 2; ++ki) {
        for (int kj = -2; kj <= 2; ++kj) {
          if (!inside(i + ki, j + kj))  continue;
          int c2 = uf.find(coord(i + ki, j + kj));
          if (grid[i + ki][j + kj] == '.')
            g.add_edge(c1, c2);
        }
      }
    }
  }

  g.bfs(uf.find(coord(Ch-1, Cw-1)));

  std::cout << g.dist[uf.find(coord(Dh-1, Dw-1))] << "\n";

  return 0;
}


Measured memory_bytes: 84052
n = int(input())
ans_ac = 0
ans_wa = 0
ans_tle = 0
ans_re = 0

for i in range(n):
    s = input()
    if s == 'AC':
        ans_ac += 1
    elif s == 'WA':
        ans_wa += 1
    elif s == 'TLE':
        ans_tle += 1
    else:
        ans_re += 1
        
print('AC x '+str(ans_ac))
print('WA x '+str(ans_wa))
print('TLE x '+str(ans_tle))
print('RE x '+str(ans_re))

Measured memory_bytes: 9096
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repm(i, m, n) for (int i = (m); i < (int)(n); i++)
#define repr(i, n) for (int i = (n); i > 0; i--)
#define all(vec) vec.begin(), vec.end()
using namespace std;

int main(){
  int a, b, c, d;
  string A, B, C, D;
  cin >> a >> b;

  int ans = 0;
  //string ans = "Yes";
  //string ans = "No";
  //string ans = "YES";
  //string ans = "NO";
  int cnt = 0;
  cnt++;
  while(cnt < b){
    cnt--;
    cnt += a;
    ans++;
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxn=2e5+5;
typedef long long ll;
ll a[maxn];
int main()
{
    ll t,ans;
    int n;
    cin>>n>>t;
    ans=t;
    for(int i=0;i<n;i++) cin>>a[i];
    for(int i=0;i<n-1;i++)
    {
        if(a[i+1]-a[i]>t)
            ans+=t;
        else ans+=a[i+1]-a[i];
    }
    cout<<ans<<endl;
}


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

	int n,k;
	cin>>n>>k;
	vector <int> vect(n);
    for(int i = 0; i < n; i++)
    {
        cin>>vect[i];
    }
    sort(vect.begin(),vect.end());
    int res = 0;
    for(int i = 0; i < k; i++)
    {
        res = res + vect[i];
    }
    cout<<res<<endl;
}

Measured memory_bytes: 3644
#include <iostream>
#include <cmath>

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

using namespace std;

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

    REP(i, 8){
        if (N < pow(2, i)){
            num = pow(2, i-1);
            break;
        }
    }

    cout << num << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <utility>
#include <map>

using namespace std;

int main(){
	long long H, W, N;
	cin >> H >> W >> N;

	map<pair<int, int>, int> m;
	for (int i = 0; i < N; i++){
		int a, b;
		cin >> a >> b;
		a--;
		b--;

		if (0 <= a-0 && a-0 <= H-3 && 0 <= b-0 && b-0 <= W-3) m[make_pair(a-0, b-0)]++;
		if (0 <= a-0 && a-0 <= H-3 && 0 <= b-1 && b-1 <= W-3) m[make_pair(a-0, b-1)]++;
		if (0 <= a-0 && a-0 <= H-3 && 0 <= b-2 && b-2 <= W-3) m[make_pair(a-0, b-2)]++;
		if (0 <= a-1 && a-1 <= H-3 && 0 <= b-0 && b-0 <= W-3) m[make_pair(a-1, b-0)]++;
		if (0 <= a-1 && a-1 <= H-3 && 0 <= b-1 && b-1 <= W-3) m[make_pair(a-1, b-1)]++;
		if (0 <= a-1 && a-1 <= H-3 && 0 <= b-2 && b-2 <= W-3) m[make_pair(a-1, b-2)]++;
		if (0 <= a-2 && a-2 <= H-3 && 0 <= b-0 && b-0 <= W-3) m[make_pair(a-2, b-0)]++;
		if (0 <= a-2 && a-2 <= H-3 && 0 <= b-1 && b-1 <= W-3) m[make_pair(a-2, b-1)]++;
		if (0 <= a-2 && a-2 <= H-3 && 0 <= b-2 && b-2 <= W-3) m[make_pair(a-2, b-2)]++;
	}

	long long sum = 0, ans[10] = {0};
	for (auto itr = m.begin(); itr != m.end(); itr++){
		// cerr << "(" << itr->first.first << "," << itr->first.second << "), " << itr->second << endl;
		ans[itr->second]++;
		sum++;
	}
	ans[0] = (H - 2) * (W - 2) - sum;
	for (int i = 0; i < 10; i++){
		cout << ans[i] << endl;
	}
	return 0;
}


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

int main(){
	string s,t;
	cin>>s>>t;
	vector<string> v;
	for(int i=0;i<s.size()-t.size()+1;i++){
		bool flag=true;
		string t2=s;
		for(int j=0;j<t.size();j++){
			if(t2[i+j]=='?')t2[i+j]=t[j];
			if(t2[i+j]!='?'&&t2[i+j]!=t[j]){
				flag=false;
				break;
			}
		}
		if(flag){
			for(int j=0;j<t2.size();j++){
				if(t2[j]=='?'){
					t2[j]='a';
				}
			}
			v.push_back(t2);
		}
	}
	if(v.size()==0){
		cout<<"UNRESTORABLE"<<endl;
		return 0;
	}
	sort(v.begin(),v.end());
	cout<<v[0]<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
main(){
  int i;
  double v,minv;

  while(scanf("%lf",&v)!=EOF){
  minv=4.9*v/9.8*v/9.8;
  for(i=0;;i++){
    if((5*i-5)>=minv)break;
}
  printf("%d\n",i);
  }
}

Measured memory_bytes: 0
/*
    Author: Alam Khan
    AUST CSE 40th Batch

*/

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

typedef long long ll;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef deque<ll> dl;
typedef stack<ll> stl;
typedef set<ll> sl;
typedef map<string, ll> msl;
typedef map<ll,ll> mll;
#define sf(n)     scanf("%lld",&n)
#define sff(n,m)     scanf("%lld %lld",&n,&m)
#define sfff(n,m,r)     scanf("%lld %lld %lld",&n,&m,&r)
#define sfs(n)     scanf("%s",n)
#define pf(n)     printf("%lld\n",n)
#define pff(n,m)     printf("%lld %lld\n",n,m)
#define pfff(n,m,r)     printf("%lld %lld %lld\n",n,m,r)
#define pfs(n)     printf("%s\n",n)
#define pfcs(i,n)     printf("Case %lld: %lld\n",i,n)
#define pb     push_back
#define prf     printf
#define inf     2e18
#define low     -1000000000000
#define PI        acos(-1.0)
#define rep1(i,n) for(i=1;i<n;i++)
#define rep0(i,n) for(i=0;i<n;i++)
#define rep(i,a,n) for(i=a;i<n;i++)
#define repe1(i,n) for(i=1;i<=n;i++)
#define repe0(i,n) for(i=0;i<=n;i++)
#define repe(i,a,n) for(i=a;i<=n;i++)
#define endl  "\n"
#define FAST  ios_base::sync_with_stdio(false);cin.tie(NULL);
#define fr freopen("input.txt","r",stdin)
#define fw freopen("output.txt","w",stdout)
ll r[4009],g[4009],b[4009];
int main()
{
    ll i,n,t,k,j,x=0,y=0,m;
    cin>>n;
    string str;
    cin>>str;
    r[n] = g[n] = b[n] = 0;
    for(i=n-1;i>=0;i--)
    {
        if(str[i] =='R')
            r[i] = r[i+1]+1;
        else r[i] = r[i+1];
        if(str[i] =='G')
            g[i] = g[i+1]+1;
        else g[i] = g[i+1];
        if(str[i] =='B')
            b[i] = b[i+1]+1;
        else b[i] = b[i+1];
    }
    /*for(i=0;i<n;i++)
    {
        cout<<i<<" "<<r[i]<<" "<<g[i]<<" "<<b[i]<<endl;
    }*/
    ll ans = 0,diff,ans2=0;
    for(i=0;i<n;i++)
    {
        for(j=i+1;j<n;j++)
        {

            if((str[i]=='R' && str[j]=='G') || (str[i]=='G' && str[j]=='R'))
            {
                ans+= b[j+1];
                diff=  j-i;
                if(j+diff<n && str[j+diff]=='B')
                    ans--;

            }
            else if((str[i]=='R' && str[j]=='B') || (str[i]=='B' && str[j]=='R'))
            {
                ans+= g[j+1];
                diff=  j-i;
                if(j+diff<n && str[j+diff]=='G')
                    ans--;

            }
            else if((str[i]=='B' && str[j]=='G') || (str[i]=='G' && str[j]=='B'))
            {
                ans+= r[j+1];
                diff=  j-i;
                if(j+diff<n && str[j+diff]=='R')
                    ans--;

            }

        }
    }
    cout<<ans<<endl;

    return 0;
}



Measured memory_bytes: 3696
import java.util.HashMap;
import java.util.Scanner;
public class Main{
    public static Scanner scan  = new Scanner(System.in);
    public static void main(String[]args){
        long a,b,k;
        a=nextLong();
        b=nextLong();
        k=nextLong();
        if(a-k>0){
            print(a-k+" "+b);
        }
        else{
            b+=a-k;
            if(b<0) print(0+" "+0);
            else print(0+" "+b);
        }
    }



    public static int nextInt(){
        return Integer.parseInt(scan.next());
    }
    public static long nextLong(){
        return Long.parseLong(scan.next());
    }
    public static String next(){
        return scan.next();
    }
    public static double nextDouble(){
        return Double.parseDouble(scan.next());
    }
    public static float nextFloat(){
        return Float.parseFloat(scan.next());
    }

    //Yes or No
    public static void yesNo(boolean flag){
        if(flag) System.out.println("Yes");
        else System.out.println("No");
    }
    public static void print(Object a){
        System.out.println(a);
    }
}


Measured memory_bytes: 23124
import java.util.*;class Main{public static void main(String[]g){Scanner S=new Scanner(System.in);float[]l=new float[8];for(int i,n=S.nextInt();n-->0;System.out.println((l[2]-l[0])*(l[7]-l[5])==(l[6]-l[4])*(l[3]-l[1])?"YES":"NO"))for(i=0;i<8;)l[i++]=S.nextFloat();}}


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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    string S; cin >> S;
    string ans = "Good";
    rep(i, S.size() - 1){
        if (S[i] == S[i + 1]){ans = "Bad";}
    }
    cout << ans << endl;
}

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


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <math.h>
using namespace std;

const int MAXN = 2e6 + 10;
const int Mod = 1e9 + 7;
int X1, X2, X3, X4, X5, X6;
int Y1, Y2, Y3, Y4, Y5, Y6;
int fac[MAXN], inv[MAXN];
int f[4][3], g[4][3];
int ans;

inline int fastpow_mod(int a, int b) {
	int x = 1;
	while(b) {
		if(b & 1) x = 1ll * x * a % Mod;
		a = 1ll * a * a % Mod; b >>= 1;
	}
	return x;
}

inline void init() {
	register int i;
	for(fac[0] = i = 1; i <= 2000000; ++i) fac[i] = 1ll * fac[i - 1] * i % Mod;
	for(inv[2000000] = fastpow_mod(fac[2000000], Mod - 2), i = 2000000; i; --i) inv[i - 1] = 1ll * inv[i] * i % Mod;
}

inline int C(int n, int k) {
	return 1ll * fac[n + k] * inv[n] % Mod * inv[k] % Mod;
}

inline int calc(int c1, int x1, int y1, int c2, int x2, int y2) {
	register int x, y;
	int res = 0;
	for(x = X3; x <= X4; ++x)
		res = (res - 1ll * C(x - x1, Y3 - 1 - y1) * (x + Y3) % Mod * C(x2 - x, y2 - Y3) % Mod + Mod) % Mod,
		res = (res + 1ll * C(x2 - x, y2 - Y4 - 1) * (x + Y4 + 1) % Mod * C(x - x1, Y4 - y1) % Mod) % Mod;
	for(y = Y3; y <= Y4; ++y)
		res = (res - 1ll * C(y - y1, X3 - 1 - x1) * (y + X3) % Mod * C(y2 - y, x2 - X3) % Mod + Mod) % Mod,
		res = (res + 1ll * C(y2 - y, x2 - X4 - 1) * (y + X4 + 1) % Mod * C(y - y1, X4 - x1) % Mod) % Mod;
	return res = (res * c1 * c2 + Mod) % Mod;
}

int main() {
	register int i, j; init();
	scanf("%d%d%d%d%d%d", &X1, &X2, &X3, &X4, &X5, &X6);
	scanf("%d%d%d%d%d%d", &Y1, &Y2, &Y3, &Y4, &Y5, &Y6);
	f[0][0] = 1, f[0][1] = X1 - 1, f[0][2] = Y1 - 1;
	f[1][0] = -1, f[1][1] = X1 - 1, f[1][2] = Y2;
	f[2][0] = -1, f[2][1] = X2, f[2][2] = Y1 - 1;
	f[3][0] = 1, f[3][1] = X2, f[3][2] = Y2;
	g[0][0] = 1, g[0][1] = X6 + 1, g[0][2] = Y6 + 1;
	g[1][0] = -1, g[1][1] = X6 + 1, g[1][2] = Y5;
	g[2][0] = -1, g[2][1] = X5, g[2][2] = Y6 + 1;
	g[3][0] = 1, g[3][1] = X5, g[3][2] = Y5;
	for(i = 0; i < 4; ++i)
		for(j = 0; j < 4; ++j)
			ans = (ans + calc(f[i][0], f[i][1], f[i][2], g[j][0], g[j][1], g[j][2])) % Mod;
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 15744
#include <iostream>
#include <iomanip>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <cmath>
#include <algorithm>
#include <iterator>
#define r(i, n) for (int i = 0; i < n; i++)
#define R(i, c, n) for (int i = c; i < n; i++)
#define DEBUG(x) cerr << #x << ": " << x << endl;
#define DUMP(a)            \
  REP(d, a.size())         \
  {                        \
    cout << a[d];          \
    if (d != a.size() - 1) \
      cout << " ";         \
    else                   \
      cout << endl;        \
  }
#define ALL(v) v.begin(), v.end()
#define UNIQUE(v) \
  sort(ALL(v));   \
  v.erase(unique(ALL(v)), v.end());
#define pb push_back
using namespace std;
const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const double PI = 3.14159265358979323846;

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

  char a;
  cin >> a;
  switch(a){
    case 'A':
    cout << 'T' << endl;
    break;
    case 'C':
    cout << 'G'<<endl;
    break;
     case 'G':
     cout << 'C' << endl;
     break;
    case 'T':
    cout << 'A' << endl;
    break;
  }

  return 0;
}

Measured memory_bytes: 256
S = []
H = []
C = []
D = []
for i in range(14):
    S.append(False)
    H.append(False)
    C.append(False)
    D.append(False)
n = input()
for i in range(n):
    c, a = raw_input().split()
    if(c == "S"):
        S[int(a)] = True
    elif(c == "H"):
        H[int(a)] = True
    elif(c == "C"):
        C[int(a)] = True
    elif(c == "D"):
        D[int(a)] = True
for i in range(1, 14):
    if(S[i] == False):
        print("S %d" %(i))
for i in range(1, 14):
    if(H[i] == False):
        print("H %d" %(i))
for i in range(1, 14):
    if(C[i] == False):
        print("C %d" %(i))
for i in range(1, 14):
    if(D[i] == False):
        print("D %d" %(i))

Measured memory_bytes: 4280
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

bool ac[100010];
ll wa[100010];
int main() {
	ll n,m;
	cin>>n>>m;
	for(ll i=0;i<m;i++){
		ll x;string s;
		cin>>x>>s;
		x--;
		if(ac[x]==true){
			continue;
		}
		if(s=="AC"){
			ac[x]=true;
		}
		else if(s=="WA"){
			if(ac[x]==false){
				wa[x]++;
			}
		}
	}
	ll ans=0;
	ll cnt=0;
	for(ll i=0;i<n;i++){
		if(ac[i]){
			cnt++;
			ans+=wa[i];
		}
	}
	cout << cnt<< " "<<ans;
	return 0;
}

Measured memory_bytes: 4464
import math
from functools import reduce
from collections import deque
import sys
sys.setrecursionlimit(10**7)

# スペース区切りの入力を読み込んで数値リストにして返します。
def get_nums_l():
    return [ int(s) for s in input().split(" ")]

# 改行区切りの入力をn行読み込んで数値リストにして返します。
def get_nums_n(n):
    return [ int(input()) for _ in range(n)]

# 改行またはスペース区切りの入力をすべて読み込んでイテレータを返します。
def get_all_int():
    return map(int, open(0).read().split())

def log(*args):
    print("DEBUG:", *args, file=sys.stderr)

n = int(input())
s = input()

ruisekiR = [0] * (n+1)
ruisekiG = [0] * (n+1)
ruisekiB = [0] * (n+1)

for i,c in enumerate(s):
    ruisekiR[i+1] = ruisekiR[i] + ( 1 if c == "R" else 0)
    ruisekiG[i+1] = ruisekiG[i] + ( 1 if c == "G" else 0)
    ruisekiB[i+1] = ruisekiB[i] + ( 1 if c == "B" else 0)

# log(ruisekiR)
# log(ruisekiG)
# log(ruisekiB)

ans = 0

for i in range(n-2):
    for j in range(i+1, n-1):
        if s[i] == s[j]:
            continue
        c = "R"
        if "R" in (s[i], s[j]):
            c = "G"
            if "G" in (s[i], s[j]):
                c = "B"

        # log(s[i], s[j], c)

        if c == "R":
            ans += (ruisekiR[n] - ruisekiR[j])
        if c == "G":
            ans += (ruisekiG[n] - ruisekiG[j])
        if c == "B":
            ans += (ruisekiB[n] - ruisekiB[j])

        if j+(j-i)<n and s[j+(j-i)] == c:
            ans -= 1

print(ans)


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

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

int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  REP(i,N) cin >> A[i];

  multiset<int> ms;
  REP(i, N) {
    auto itr = ms.upper_bound(-A[i]);
    if (itr != ms.end()) {
      ms.erase(itr);
    }
    ms.insert(-A[i]);
  }

  cout << ms.size() << endl;
  return 0;
}


Measured memory_bytes: 5376
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#define _GLIBCXX_DEBUG
#define INF 100000010
 #define PI 3.14159265359

using namespace std;
const int mod = 1000000007;
const int tmpMod = 998244353;

int main() {
 
  int64_t a,b,c,d,e;
  cin>>a>>b>>c>>d>>e;
  if(a==0)cout<<1<<endl;
  else if(b==0)cout<<2<<endl;
  else if(c==0)cout<<3<<endl;
  else if(d==0)cout<<4<<endl;
  else if(e==0)cout<<5<<endl;
  //vector<int64_t> A(N);
  //for(int i=0; i<N; i++){cin>>A[i];}
  //vector<vector<int> > A(N,vector<int>(M));
  //for(int i=0; i<N; i++){for(int j=0; j<M; j++){cin>>A[i][j];}}
  //sort(A.begin(),A.end());
  //for (int i = 0; i < N; i++) { maximum = max(maximum , A[i]);}
  //for (int i = 0; i < N; i++) { minimum = min(minimum , A[i]);}
  //cout << N << endl;
}

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

int main() {
    int64_t N;
    cin >> N;
    vector<int64_t> A(N);
    for (int64_t& a : A) {
        cin >> a;
    }

    struct Element {
        int64_t from, cost;
        bool operator<(const Element& rhs) const {
            return cost < rhs.cost;
        }
        bool operator>(const Element& rhs) const {
            return cost > rhs.cost;
        }
    };
    priority_queue<Element> pq;

    for (int64_t i = 0; i < N; i++) {
        pq.push({i, A[i]});
    }


    vector<vector<int64_t>> dp(N + 1, vector<int64_t>(N + 1, 0));
    int64_t num = 0;
    while (!pq.empty()) {
        Element top = pq.top();
        pq.pop();

        //左に詰める
        for (int64_t i = 0; i <= num; i++) {
            //今左にi個あるとする
            //そのとき右側にはnum - i個ある
            dp[i + 1][num - i] = max(dp[i + 1][num - i], dp[i][num - i] + abs(top.from - i) * top.cost);
        }

        //右に詰める
        for (int64_t i = 0; i <= num; i++) {
            dp[num - i][i + 1] = max(dp[num - i][i + 1], dp[num - i][i] + abs(top.from - (N - 1 - i)) * top.cost);
        }

        num++;
    }

    int64_t ans = 0;
    for (int64_t i = 0; i <= N; i++) {
        ans = max(ans, dp[i][N - i]);
    }

    cout << ans << endl;
}

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

bool is_Prime(long long N){
  if(N == 1)return false;
  for(long long i = 2; i*i <=N; i++){
    if(N %  i== 0)return false;
  }
  return true;
}

int main(){
  long long N;
  cin >> N;
  if(is_Prime(N)){
    cout << N - 1 << endl;
    return 0;
  }
  long long ans = 0;
  
  for(long long i = 1; i*i <=N; i++){
    if(N % i == 0){//割り切れるとき
      long long a = i;
      long long b = N / a;
      ans = a + b -2; //1,1スタートなので(下に1,右に1移動してからスタート)2を引く
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3592
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cmath>
#include <map>
#include <set>
#define ull unsigned long long
#define ll long long
using namespace std;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int h,w;
    cin >> h >> w;
    string p[h];
    for(int i=0;i<h;i++){
        cin >> p[i];
    }
    bool jadge=0;
    for(int i=0;i<w;i++){
        for(int j=0;j<h;j++){
            if(p[j][i]=='#'){
                if(j==0 && i==0){
                    if(p[0][1]=='.' && p[1][0]=='.'){
                        jadge=1;
                    }
                }
                else if(j==0 && i==h-1){
                    if(p[h-1][1]=='.' && p[h-2][0]=='.'){
                        jadge=1;
                    }
                }
                else if(j==w-1 && i==0){
                    if(p[0][w-2]=='.' && p[1][w-1]=='.'){
                        jadge=1;
                    }
                }
                else if(j==w-1 && i==h-1){
                    if(p[h-1][w-2]=='.' && p[h-2][w-1]=='.'){
                        jadge=1;
                    }
                }
                else if(i==0 && (j!=0 || j!=w-1)){
                    if(p[j-1][0]=='.' && p[j+1][0]=='.' && p[j][1]=='.'){
                        jadge=1;
                    }
                }
                else if(j==0 && (i!=0 || i!=h-1)){
                    if(p[j][i-1]=='.' && p[j][i+1]=='.' && p[j+1][i]=='.'){
                        jadge=1;
                    }
                }
                else if(j==w-1 && (i!=0 || i!=h-1)){
                    if(p[j][i-1]=='.' && p[j][i+1]=='.' && p[j-1][i]=='.'){
                        jadge=1;
                    }
                }
                else if(i==h-1 && (j!=0 || j!=w-1)){
                    if(p[j-1][i]=='.' && p[j+1][i]=='.' && p[j][i-1]=='.'){
                        jadge=1;
                    }
                }
                
                else if(p[j+1][i]=='.' && p[j-1][i]=='.' && p[j][i+1]=='.' && p[j][i-1]=='.'){
                    jadge=1;
                }
            }
            else continue;
            
            if(jadge==1){
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
    
    return 0;
}

Measured memory_bytes: 256
import sys
import math,bisect
sys.setrecursionlimit(10 ** 5)
from itertools import groupby,accumulate
from heapq import heapify,heappop,heappush
from collections import deque,Counter,defaultdict
def I(): return int(sys.stdin.readline())
def neo(): return map(int, sys.stdin.readline().split())
def Neo(): return list(map(int, sys.stdin.readline().split()))
def dfs(t):
    vis[t] = 1
    for i in G[t]:
        if not vis[i]:
            dfs(i)
N,M = neo()
G = defaultdict(list)
vis = [0]*(N+1)
for i in range(M):
    x,y = neo()
    G[x] += [y]
    G[y] += [x]
c = 0
for i in range(1,N+1):
    if not vis[i]:
        dfs(i)
        c += 1
print(c-1)


Measured memory_bytes: 49544
#include<stdio.h>

int main(void) {
	int n = 0, m = 0, i, j;

	scanf("%d %d", &n, &m);

	int a[101][101];
	int b[101];
	int c[101];

	for (i = 0; i < n; i++) {
		for (j = 0; j < m; j++) {
			scanf("%d", &a[i][j]);
		}
	}

	for (j = 0; j < m; j++) {
		scanf("%d", &b[j]);
	}

	for (i = 0; i < n; i++) {
			c[i] = 0;
		for (j = 0; j < m; j++) {
			c[i] += a[i][j] * b[j];
		}
		printf("%d\n", c[i]);
	}


	return 0;
}



Measured memory_bytes: 2788
#include<stdio.h>
int main(){
    int n,m;
    scanf("%d %d",&n,&m);
    int h[n+5],s[n+5];
    //初始化
    for(int i=0;i<n;i++){
        scanf("%d",&h[i]);
    }
    //将所有所在点都设为good，即为0；
    for(int t=0;t<n;t++){
       s[t]=0;
    }
    for(int j=0;j<m;j++){
        int x,y;
        scanf("%d%d",&x,&y);
        if(h[x-1]>=h[y-1]) s[y-1]=1;
        if(h[x-1]<=h[y-1]) s[x-1]=1;       
    }
    int cnt=0;
    for(int i=0;i<n;i++){
        if(s[i]==0) cnt++;
    }
    printf("%d",cnt);
    return 0;
}

Measured memory_bytes: 2468
#include <bits/stdc++.h>
#define REP(i, a, n) for (long long i = (a); i < (long long)(n); ++i)
#define REPC(i, a, n) for (long long i = (a); i <= (long long)(n); ++i)
#define ALL(t) t.begin(), t.end()
#define RALL(t) t.rbegin(), t.rend()
#define MATINIT(type, row, col, init) \
  vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout << (cond ? "Yes" : "No") << endl;
#define YES(cond) cout << (cond ? "YES" : "NO") << endl;
using namespace std;
using LL = long long;
using ULL = unsigned long long;
template <class T>
using VEC = std::vector<T>;
template <class T>
using MAT = std::vector<std::vector<T>>;
void DUMP() { cerr << endl; }
template <class Head, class... Tail>
void DUMP(Head &&head, Tail &&... tail) {
  cerr << head << ", ";
  DUMP(std::move(tail)...);
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> &vec) {
  os << "{";
  for (auto v : vec) os << v << ",";
  os << "}";
  return os;
}
template <typename T>
ostream &operator<<(ostream &os, set<T> &s) {
  os << "{";
  for (auto p : s) os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, map<T1, T2> &m) {
  os << "{";
  for (auto p : m) os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2> p) {
  os << "[" << p.first << " " << p.second << "]";
  return os;
}
int main() {
  string S;
  cin >> S;
  int p = 0, g = 0;
  REP(i, 0, S.length()) {
      if(S[i]=='g'){
          g++;
      }else {
          p++;
      }
  }
  cout<<S.length()/2-p<<endl;
}

Measured memory_bytes: 512
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int h = sc.nextInt();
		int w = sc.nextInt();
		for (int i=0;i<h;i++) {
			for (int j=0;j<w;j++) {
				String temp = sc.next();
				if ("snuke".equals(temp)) {
					System.out.print((char)(j+'A'));
					System.out.print(i+1);
					break;
				}
			}
		}
	}
}

Measured memory_bytes: 21716
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(a) a.begin(), a.end()
#define P pair<int, int>
#define F first
#define S second
#define mod 1000000007
#define INF 9000000000000000000
signed main() {
    int a,b;cin>>a>>b;
    if((a+b)%2==0)cout<<(a+b)/2<<endl;
    else cout<<"IMPOSSIBLE"<<endl;
}

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

using namespace std;


int main(int argc, char const *argv[]) {
  long long l, r, i, j; cin >> l >> r;
  long long ans = 100000;

  // int ans = 2020;
  for ( i = l; i < r + 1; i++) {
    for ( j = i + 1; j < r + 1; j++) {
      ans = min(ans, i % 2019 * j % 2019);
      if (ans == 0) break;
    }
    if (ans == 0) break;
  }
  std::cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 256
s = input()
dp = [0]*(len(s) + 1)
dp[0] = 1
judge = 'NO'
words = ['dream', 'dreamer', 'erase', 'eraser']
for i in range(len(s)):
  if dp[i] == 0:
    continue
  for w in words:
    if s[i:i+len(w)] == w:
      dp[i+len(w)] = 1
    if dp[len(s)] == 1:
      judge = 'YES'
      break
print(judge)

Measured memory_bytes: 3956
#include <bits/stdc++.h>
using namespace std;
 
typedef long long LL;
#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, N) for (int i = 0; i < (N); ++i)

int main(){
  int a,b;
  int ans=10000;
  cin>>a>>b;
  REP(i,a){
    int c,t;
    cin>>c>>t;
    if(t>b){continue;}
    else{ans=min(ans,c);}
  }
  if(ans==10000){cout<<"TLE"<<endl;}
  else{cout<<ans<<endl;}
}

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

int main(){
  long long n; cin>>n;
  string abc="abcdefghijklmnopqrstuvwxyz";
  string ans="";
  
  while (n!=0){
    int t_ans=n%26;
    
    if (t_ans==0){
      ans+='z';
      n-=1;
    } else {
      ans+=abc[t_ans-1];
    }
    n/=26;
  }
  reverse(ans.begin(),ans.end());
  cout<<ans<<endl;
}

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

using namespace std;

using ll = long long;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define FORE(i, a, b) for(int i=(a);i<=(b);++i)
#define rep(i, n) for(int i=0;i<(n);++i)
#define repe(i, n) for(int i=0;i<=(n);++i)
#define ALL(v) (v).begin(),(v).end()
#define SP cout<<fixed<<setprecision(10)
typedef pair<int, int> P;
const int INF = (int) 1e9;
const int MOD = (int) 1e9 + 7;

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

int main(void) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int n;
	cin >> n;
	int p[n];
	rep(i, n) cin >> p[i];
	
	sort(p, p + n);
	
	int sum = 0;
	rep(i, n) {
		if (i == n - 1) sum += p[i] / 2;
		else sum += p[i];
	}
	
	cout << sum << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int x,y,z;
  int l;
  
  scanf("%d %d %d",&x,&y,&z);
  
  l=x;
  x=y;
  y=l;
  
  l=x;
  x=z;
  z=l;
  
  printf("%d %d %d",x,y,z);
  return 0;
}
  

Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<cstdio>
#include<queue>
#include<deque>
#include<map>
#include<stack>
#include<set>
#include<utility>
using namespace std;
typedef pair<int,int> ii;
typedef long long ll;
typedef pair<int,int> P;
typedef unsigned long long int ull;
const int MOD=1e9+7;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
const int MAXN=100000;
const int MAXE=100000;
const int MAXV=10000;
const int INF=1e9;

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

Measured memory_bytes: 3916
#G
import pprint
H,W,K=map(int,input().split())
import copy
x1,y1,x2,y2=map(int,input().split())
#raw=["#"]+["."]*(601)+["#"]
lastraw=["@"]*(W+2)
field=[["@"]*(W+2)]
for i in range(H):
  field.append(["@"]+list(input())+["@"])

field.append(lastraw)

#print(field)

goal_point=(y2,x2)

[sy,sx]=[y1,x1]
[gy,gx]=[y2,x2]

field[x1][y1]=0
queue=[[sy,sx]]
tests = ((-1,0),(0, 1),(1, 0),(0, -1))
moves=0

while True:
  if len(queue)==0:
    moves=-1
    break
  queue_next = []
  moves += 1
  #pprint.pprint(field)
  for y, x in queue:
    for ny, nx in tests:
      ty, tx = y + ny, x + nx
      if field[tx][ty] == '.':
        field[tx][ty] = moves
        queue_next.append((ty, tx))
        #print(ty,tx)
        for i in range(K-1):
          ty, tx = ty + ny, tx + nx
          if field[tx][ty] == '.':
            field[tx][ty] = moves
            queue_next.append((ty, tx))
            #print(ty,tx)
          elif field[tx][ty] ==moves:
            pass
          else:
            break
      elif field[tx][ty] ==moves:
        #field[tx][ty] = moves
        #queue_next.append((ty, tx))
        #print(ty,tx)
        for i in range(K-1):
          ty, tx = ty + ny, tx + nx
          if field[tx][ty] == '.':
            field[tx][ty] = moves
            queue_next.append((ty, tx))
            #print(ty,tx)
          elif field[tx][ty] ==moves:
            pass
          else:
            break
  queue = queue_next
  if goal_point in queue:
    break
#pprint.pprint(field)
print(moves)

Measured memory_bytes: 200000
#include<stdio.h>

int main()
{
	int n, x;
	
	while(scanf("%d %d", &n, &x))
	{
		int ans = 0;
		if(n == 0 && x == 0) 
			break;
		for(int i = 1; i < n - 1; i++)
		{
			for(int j = i + 1; j < n; j++)
			{
				for(int k = j + 1; k < n + 1; k++)
				{
					if(i + j + k == x)
					{
						ans++;
					}
				}
			}
		}
		printf("%d\n", ans);
	}
	
	return 0;
}


Measured memory_bytes: 2036
S = input()
S_front = S[:2]
S_rear = S[2:4]
S_front_int = int(S_front)
S_rear_int = int(S_rear)

YYMM_YY = False
YYMM_MM = False
MMYY_MM = False
MMYY_YY = False
YYMM = False
MMYY = False
if 0 <= S_front_int <= 99:
    YYMM_YY = True
if 1 <= S_rear_int <= 12:
    YYMM_MM = True
if 1 <= S_front_int <= 12:
    MMYY_MM = True
if 0 <= S_rear_int <= 99:
    MMYY_YY = True
if YYMM_YY == True and YYMM_MM == True:
    YYMM = True
if MMYY_MM == True and MMYY_YY == True:
    MMYY = True
if YYMM == True and MMYY == True:
    print('AMBIGUOUS')
elif YYMM == False and MMYY == False:
    print('NA')
elif YYMM == True and MMYY == False:
    print('YYMM')
elif YYMM == False and MMYY == True:
    print('MMYY')

Measured memory_bytes: 38256
macro_rules! scan_sub {
    ( $itr:ident, $t:ty ) => {
        let mut buf = String::new();
        let $itr = {
            while buf.trim().len() == 0 {
                buf = String::new();
                std::io::stdin().read_line(&mut buf).unwrap();
            }
            buf.split_whitespace().map(|n| n.parse::<$t>().unwrap())
        };
    };
}

macro_rules! scan {
    ( $x:ident; Vec<$t:ty> ) => {
        scan_sub!(itr, $t);
        let $x = itr.collect::<Vec<_>>();
    };
    ( $( $x:ident ),*; $t:ty ) => {
        scan_sub!(itr, $t);
        let mut itr = itr;
        $(
            let $x = itr.next().unwrap();
        )*
    };
}

use std::collections::{HashMap, HashSet};

fn main() {
    scan!(_n; usize);
    scan!(array; Vec<usize>);

    let mut tmp_set = HashSet::new();
    let mut duplicates = HashSet::new();
    let mut book = array
        .iter()
        .map(|&v| {
            if tmp_set.contains(&v) {
                duplicates.insert(v);
            }
            tmp_set.insert(v);
            (v, true)
        })
        .collect::<HashMap<_, _>>();

    let mut array = array;
    array.sort();

    let max = array[array.len() - 1];

    for &a in array.iter() {
        if !book.get(&a).unwrap() {
            continue;
        }

        if duplicates.contains(&a) {
            let cell = book.get_mut(&a).unwrap();
            *cell = false;
        }

        let mut t = 2 * a;
        while t <= max {
            if let Some(cell) = book.get_mut(&t) {
                *cell = false;
            }
            t += a;
        }
    }

    let res = book.values()
        .filter(|&&b| b)
        .collect::<Vec<_>>().len();
    println!("{}", res);
}


Measured memory_bytes: 14684
#include "bits/stdc++.h"
using namespace std;
int main(){
    
    long long int k,a,b,ans;
    cin >> k >> a >> b;
    if(b-a<2){
        cout << k+1 << endl;
        return 0;
    }
    if(k<a+1){
        cout << k+1 << endl;
        return 0;
    }
    ans = b+((k-a-1)/2)*(b-a)+((k-a-1)%2);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
#include<string>
#include<iostream>
#include<vector>
#include<queue>
#include<map>

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

int n,m;
char from,to,tmp;

int main(){
  cin >> n;
  while(n){
      map<char,char>dict;
      REP(i,n){
        cin >> from >> to;
        dict[from] = to;
      }
      cin >> m;
      REP(i,m){
        cin >> tmp;
        if(dict.find(tmp) == dict.end()) cout << tmp;
        else cout << dict[tmp];
      }
      cout << endl;
      cin >> n;
  }
  return 0;
}


Measured memory_bytes: 3084
#include <iostream>
#include <climits>
#include <algorithm>
using namespace std;
typedef long long ll;

//#define DEBUG

int main()
{
//#ifdef DEBUG
   //freopen("in.txt", "r", stdin);
   //freopen("out.txt","w",stdout);
//#endif
   //while (!cin.eof()) {
      ll n = 0l;// 149696127901;
      cin >> n;

      ll sMin = LLONG_MAX;
      if (n < 7) sMin = 1;
      else {
         for (int i = 11; i >= 7; --i) {
            ll s = 2 * (n / i);
            if (s > 0) {
               ll rem = n % i;
               if (rem > 6) s += 2;
               else if (rem != 0) s += 1;
               sMin = min<>(sMin, s);
            }
         }
      }

      cout << sMin << endl;
   //}
   return 0;
}



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

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> a(M), b(M), city(N);
  
  for (int i = 0; i < M; i++) {
    cin >> a.at(i) >> b.at(i);
  }
  
  for (int j = 0; j < N; j++) {
    for (int i = 0; i < M; i++) {
      city.at(j) += (a.at(i) == j +1) + (b.at(i) == j + 1);
    }
  }
  
  for (int j = 0; j < N; j++) {
    cout << city.at(j) <<endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>
#include <algorithm>
#include <cstring>
using namespace std;
double t[200005];
int main()
{
    int n,m;
    scanf("%d %d",&n,&m);
    for(int i=1;i<=n;i++)
    {
        scanf("%lf",&t[i]);
        t[i]=(t[i]+1)/2;
    }
    double max1,sum;
    for(int i=0;i<m;i++)
        max1+=t[1+i];
    sum=max1;
    for(int i=2;i<=n-m+1;i++)
    {
        sum=sum-t[i-1]+t[i+m-1];
        max1=sum>max1?sum:max1;
    }
    printf("%.12lf\n",max1);

    return 0;
}


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

int main(){
  int a,b;
  cin >> a >> b;
  int x = 0, y = 0;
  for(int i=1;i<999;++i){
    x+=i;
    y=x+i+1;
    if(x-a<=0) continue;
    else{
      if(x-a == y-b) break;
    }
  }
  cout << x-a << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<ll,ll>;
const ll mod = 1e9+7;
#define ALL(x) (x).begin(),(x).end()
#define pow(x,y) modpow(x,y)
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define REPS(i,n) for(ll (i)=1;(i)<=(n);(i)++)
#define RREP(i,n) for(ll (i)=(n-1);(i)>=0;(i)--)
#define RREPS(i,n) for(ll (i)=(n);(i)>0;(i)--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());

template <class T = int>T in(){
    T x;
    cin >> x;
    return (x);
}

template<class T> inline void chmin(T& a, T b){
    if (a > b){
        a = b;
    }
}

template<class T> inline void chmax(T& a, T b){
    if (a < b){
        a = b;
    }
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(10);
    ll N = in<ll>();
    vector<ll> eve(N+1/2+1);
    vector<ll> odd(N/2+1);//累積
    vector<ll> eves(N+1/2);
    vector<ll> odds(N/2);
    REP(i,N){
        if(i %2 == 0){
            ll tmp = in<ll>();
            eve[i/2+1] = eve[i/2]+tmp;
            eves[i/2] = tmp;
        }else{
            ll tmp = in<ll>();
            odd[i/2+1] = odd[i/2]+tmp;
            odds[i/2] = tmp;
        }
    }
    if(N %2 == 0){
        ll answer = odd[N/2]-odd[0]+eve[0];
        REP(i,N/2+1){
            chmax(answer,odd[N/2]-odd[i]+eve[i]);
        }
        cout << answer << "\n";
    }else{
        ll max0 = 0;
        ll max1 = 0;
        ll max2 = 0;
        REP(i,N/2){
            ll max0b = max0;
            ll max1b = max1;
            ll max2b = max2;
            max0 = max0b+eves[i];
            max1 = max(max1b + odds[i],max0b + odds[i]);
            max2 = max({max0b + eves[i+1],max1b + eves[i+1],max2b + eves[i+1]});
        }
        cout << max({max0,max1,max2}) << "\n";
    }
}

Measured memory_bytes: 7952
#include <iostream>
#include <vector>
#include <queue>

typedef long long ll;

using namespace std;

const int N_MAX = 100000;

vector<int> graph[N_MAX + 5];
ll colors[N_MAX + 5];
ll ncon[N_MAX + 5];
int visited[N_MAX + 5];

const ll base = 1000000000 + 7;
int main(){
    int n, k;
    cin >> n >> k;
    for(int i = 0; i < n - 1;i++){
        int a, b;
        cin >> a >> b;
        graph[a - 1].push_back(b - 1);
        graph[b - 1].push_back(a - 1);
        colors[i] = k;
        ncon[i] = 0;
        visited[i] = 0;
    }
    colors[n - 1] = k;
    ncon[n - 1] = 0;
    visited[n - 1] = 0;
    queue<int> que;
    que.push(0);
    while(!que.empty()){
        int c = que.front();
        que.pop();
        visited[c] = 1;
        for(ll i : graph[c]){
            if(visited[i]){
                ncon[i]++;
                ncon[c]++;
                colors[c] -= ncon[i];
            }else{
                que.push(i);
            }
        }
    }
    ll comb = 1;
    for(int i = 0; i <n;i++){
        comb *= colors[i];
        comb %= base;
    }
    cout << comb << endl;
}

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

using namespace std;
#define INF 1000000001


int napZack01(  const vector<int> &val, 
                const vector<int> &weight, 
                vector<vector<bool> > &state_mat,
                vector<vector<int> > &sum_weight,
                int W){
    int N = (int)sum_weight.size() - 1;
    int V = (int)sum_weight[0].size() - 1;
    
    for(int i = 1;i <= N;i++) sum_weight[i][val[i]] = weight[i];

    for(int i = 2;i <= N;i++){
        for(int v = 1;v <= V;v++){
            sum_weight[i][v] = min(sum_weight[i][v],sum_weight[i-1][v]);
            if(v-val[i] >= 0){
                sum_weight[i][v] = min(sum_weight[i-1][v-val[i]]+weight[i],sum_weight[i][v]);
            }
        }
    }

    for(int v = V;v >= 0;v--){
        for(int i = N;i >= 0;i--){
            if(sum_weight[i][v] <= W) return v;
        }
    }
    return 0;
}

int main()
{
    int N,W;
    int v_temp,w_temp;
    int sum = 0;
    scanf("%d %d",&N,&W);
    vector<int> val(N+1,0);
    vector<int> weight(N+1,0);
    
    for(int i = 0;i < N;i++){
        scanf("%d %d",&v_temp,&w_temp);
        val[i+1] = v_temp;
        weight[i+1] = w_temp;
        sum += v_temp;
    }
    vector<vector<int> > sum_weight(N+1,vector<int>(sum+1,INF) );
    vector<vector<bool> > state_mat(N+1,vector<bool>(sum+1,false) );
    
    int max_val = napZack01(val,weight,state_mat,sum_weight,W);
    printf("%d\n",max_val);
    return 0;
}




Measured memory_bytes: 7164