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

using namespace std;

typedef long long int ll;
int INF = 0x3f3f3f3f;

string s;
int x, y;
vector<int> vx;
vector<int> vy;
int sumx, sumy;
int countF, countT;

bool cmp(int a, int b) {
    return a > b;
}

int main() {

    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> s;
    cin >> x >> y;
    
    for (int i = 0; i < s.size(); i++) {
        if (s[i] == 'F')
            countF++;
        else {
            if (countT % 2 == 0)
                vx.push_back(countF);
            else
                vy.push_back(countF);
            countT++;
            countF = 0;
        }
    }
    if (countF > 0) {
        if (countT % 2 == 0)
            vx.push_back(countF);
        else
            vy.push_back(countF);
    }
    
    
    sort(vx.begin()+1, vx.end(), cmp);
    sort(vy.begin(), vy.end(), cmp);
    sumx += vx[0];
    for (int i = 1; i < vx.size(); i++) {
        if (sumx <= x)
            sumx += vx[i];
        else
            sumx -= vx[i];
    }
    for (int i = 0; i < vy.size(); i++) {
        if (sumy <= y)
            sumy += vy[i];
        else
            sumy -= vy[i];
    }
    
    if (sumx == x && sumy == y)
        cout << "Yes\n";
    else
        cout << "No\n";
}


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

int main()
{
	int n, k;
	cin >> n >> k;
	vector<int> v(n, 0);
	for (int i = 0; i < k; ++i) {
		int d;
		cin >> d;
		for (int j = 0; j < d; ++j) {
			int a;
			cin >> a;
			v[a-1]++;
		}
	}
	int ret = 0;
	for (auto& i : v) {
		if (i == 0) {
			++ret;
		}
	}
	cout << ret << endl;

	return 0;
}

Measured memory_bytes: 3624
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.util.TreeMap;

public class Main {

   private static final String INPUT_FILE_PATH = "";

   static void solve(InputReader in, PrintWriter out) {
      int n = in.nextInt();
      int m = in.nextInt();
      long k = in.nextLong();

      long[] a = new long[n + 1];
      long[] psa = new long[n + 1];
      long[] b = new long[m + 1];
      long[] psb = new long[m + 1];
      TreeMap<Long, Integer> tm = new TreeMap();
      for (int i = 1; i <= n; i++) {
         a[i] = in.nextLong();
         psa[i] = psa[i - 1] + a[i];
      }
      for (int i = 1; i <= m; i++) {
         b[i] = in.nextLong();
         psb[i] = psb[i - 1] + b[i];
         tm.put(psb[i], i);
      }
      int ans = 0;
      for (int i = 0; i <= n; i++) {
         if (psa[i] > k) break;
         long diff = k - psa[i];

         if (tm.firstKey() > diff) {
            ans = Math.max(ans, i);
         } else {
            ans = Math.max(ans, i + tm.floorEntry(diff).getValue());
         }
      }
      out.println(ans);
   }

   private static class InputReader {
      private BufferedReader br;
      private StringTokenizer st;

      public InputReader(InputStream inputStream) {
         this.br = new BufferedReader(new InputStreamReader(inputStream), 32768);
         this.st = null;
      }

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

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

      public long nextLong() {
         return Long.parseLong(nextToken());
      }

      public double nextDouble() {
         return Double.parseDouble(nextToken());
      }
   }

   public static void main(String[] args) throws Exception {
      InputStream inputStream = INPUT_FILE_PATH.isEmpty()
         ? System.in
         : new FileInputStream(new File(INPUT_FILE_PATH));
      OutputStream outputStream = System.out;

      InputReader inputReader = new InputReader(inputStream);
      PrintWriter printWriter = new PrintWriter(outputStream);

      solve(inputReader, printWriter);

      printWriter.close();
   }

}


Measured memory_bytes: 83928
#include<bits/stdc++.h>
using namespace std;
 
#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.begin(), v.end(),greater<int>());
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return
#define lb(v,n) lower_bound(v.begin(),v.end(),n)
#define ub(v,n) upper_bound(v.begin(),v.end(),n)
#define mae(v) max_element(v.begin(),v.end())
#define mie(v) min_element(v.begin(),v.end())
#define INF 0x7FFFFFFF
#define mod 1000000007
typedef long long ll;
////////////////////////////////////////////////////////////

int main(){
	int n;
	cin >> n;
	ll a[n];
	rep(i,0,n) cin >> a[i];
	
	if(n==1){
		cout << a[0]/2 << endl;
		ret 0;
	}

	int i=0,j=n-1;
	ll ans = 0;
	while( i <= j ){
		ans += a[i]/2;
		a[i]%=2;
		
		if(a[i]){
			if(a[i+1]){
				a[i]--;
				a[i+1]--;
				ans++;
			}
		}
		
		ans += a[j]/2;
		a[j]%=2;
		
		if(a[j]){
			if(a[j-1]){
				a[j]--;
				a[j-1]--;
				ans++;
			}
		}
		
		i++;
		j--;

	}
	
	cout << ans << endl;
	ret 0;
}

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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define ALL(a) (a).begin(), (a).end()
#define rALL(a) (a).rbegin(), (a).rend()
#define SZ(x) ((int)(x).size())
using ll = long long;
using P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 29;
const ll INF64 = 1ll << 40;
const int mod = 1000000007;
//const int mod = 998244353;

template <class T>inline bool chmin(T &a, const T b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline bool chmax(T &a, const T b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline void line_out(const vector<T> vec) {
  int n = SZ(vec);
  rep(i, n) {
    cout << vec[i];
    if(i < n-1) cout << " ";
  }
  cout << endl;
  return;
}

struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};



int main()
{
  string s; cin >> s;
  map<char, int> mp;
  rep(i, 4) {
    if(mp.find(s[i]) == mp.end()) mp[s[i]] = 0;
    ++mp[s[i]];
  }
  if(mp.size() == 2) {
    for(auto x : mp) if(x.second != 2) {
      cout << "No" << endl;
      return 0;
    }
    cout << "Yes" << endl;
  }
  else cout << "No" << endl;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigInteger;

final class Main {

    private Main() {
    }

    public static final int MAX_LENGTH = 80;

    public static void main(final String[] argv) throws IOException {
        final BufferedReader inputReader =
                new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(inputReader.readLine());
        while (n-- != 0) {
            BigInteger x = new BigInteger(inputReader.readLine());
            BigInteger y = new BigInteger(inputReader.readLine());
            if (x.toString().length() > MAX_LENGTH
                    || y.toString().length() > MAX_LENGTH) {
                System.out.println("overflow");
                continue;
            }
            x = x.add(y);
            String message;
            if (x.toString().length() > MAX_LENGTH) {
                message = "overflow";
            } else {
                message = x.toString();
            }
            System.out.println(message);
        }
    }
}

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

int main(){

    int64_t N, A, B;
    cin >> N >> A >> B;

    int64_t div, mod, temp;
    div = N/(A+B);
    mod = N%(A+B);
    temp = mod - A;

    if (temp>0){
        cout << (div+1)*A << endl;
        return 0;
    }
    else{
        cout << div*A+mod << endl;
        return 0;
    }    
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <cmath>
#include <numeric>
#include <fstream>
#include <queue>
using namespace std;
#define fol(i,n) for (int i=0;i<n;i++)
#define db(a) cout << a<< endl;
typedef pair <int,int>P;
int main(){
    string a,b[2]={"yes","no"};
    cin >>a;
    int r=0;
    fol(i,a.size()){
        fol(j,a.size()){
            if (a[i]==a[j]&&i!=j) {r=1;break;}
        }
    }
    cout << b[r]<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxn=2e5+10;
inline int qr()
{
	int x=0,f=0;
	char ch=0;
	while(!isdigit(ch))
	{
		f=ch=='-';
		ch=getchar();
	}
	while(isdigit(ch))
	{
		x=(x<<1)+(x<<3)+(ch^48);
		ch=getchar();
	}
	return f?-x:x;
}
int n;
int a[maxn],b[maxn];
int p[maxn];
int cnt;
int val;
int main()
{
	n=qr();
	for(int i=1;i<=n;i++)
	{
		a[i]=qr();
	}
	for(int i=1;i<=n;i++)
	{
		b[i]=qr();
	}
	reverse(b+1,b+n+1);
	for(int i=1;i<=n;i++)
	{
		if(b[i]!=a[i])continue;
		cnt++;
		p[cnt]=i;//相等的位置;
		val=b[i]; 
	}
	for(int i=1;i<=n;i++)
	{
		if(!cnt) break;
		if(a[i]!=val&&b[i]!=val)//可以交换 
		swap(b[p[cnt--]],b[i]);
	}
	if(cnt) //位置不够 
	{
	printf("No");return 0;	
	}
	else {
		printf("Yes\n");
		for(int i=1;i<=n;i++)
		{
			printf("%d ",b[i]);
		}
	}
	return 0;
}

Measured memory_bytes: 5984
#include <iostream>
#include <string>

using namespace std;

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

	int n;
	cin >> n;
	string s;
	cin >> s;
	int rightMostRed = -1;
	int leftMostWhite = -1;
	for (int i = 0; i < n; i++)
	{
		if (s[i] == 'W' && leftMostWhite == -1)
			leftMostWhite = i;
		if (s[i] == 'R')
			rightMostRed = i;
	}
	if (rightMostRed < 0 || leftMostWhite < 0)
	{
		cout << 0 << "\n";
		return 0;
	}
	int ans = 0;
	while (leftMostWhite < rightMostRed)
	{
		ans++;
		s[leftMostWhite] = 'R';
		s[rightMostRed] = 'W';
		while (leftMostWhite < rightMostRed && s[leftMostWhite] != 'W')
			leftMostWhite++;
		while (leftMostWhite < rightMostRed && s[rightMostRed] != 'R')
			rightMostRed--;
	}
	//cout << s << "\n";
	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 3772
N, W = map(int, input().split())
w = [0] * N
v = [0] * N
for i in range(N):
    w[i], v[i] = map(int, input().split())
V = sum(v)
INF = float('inf')
# the min weight to hold value j
dp = [INF] * (V+1)
dp[0] = 0
for i in range(N):
    for j in range(v[i], V+1)[::-1]:
        dp[j] = min(dp[j], dp[j-v[i]] + w[i])
for j in range(V+1)[::-1]:
    if dp[j] <= W:
        print(j)
        break

Measured memory_bytes: 90452
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, n, s) for (int i = (s); i < (n); i++)
#define MOD 1000000007
typedef long long ll;
using namespace std;
using Graph = vector<vector<int>>;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    int d, x;
    cin >> d >> x;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    int ans = x;

    rep(j, n)
    {
        int i = 0;
        while (i * a[j] + 1 <= d)
        {
            ans += 1;
            i++;
        }
    }
    cout << ans << endl;
 //   system("pause");
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
using namespace std;
int main()
{
	int n, i, j, k, c, x;
	char s[1001], r[1001], t[8] = "Hoshino";
	cin >> n;
	cin.ignore(1024, '\n');
	for (i = 0; i < n; i++)
	{
		cin.getline(s, sizeof(s));
		c = 0;
		for (j = 0; j < strlen(s); j++)
		{
			r[c] = s[j];
			c++;
			if (s[j] == 'H')
			{
				for (k = j+1, x = 0; k < j+7; k++, c++)
				{
					if (s[k] == t[k-j])
					{
						if (k == j+6)
							r[c] = 'a';
						else
							r[c] = t[k-j];
						x++;
					}
					else
					{
						r[c] = s[k];
						break;
					}
				}
				j+=x;
			}
		}
		r[strlen(s)] = '\0';
		cout << r << endl;
	}
}

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

using ll = long long;
using ull = unsigned long long;
using namespace std;
constexpr int inf = 1<<30;
constexpr int mo = 1e9+7;
constexpr ll infl = 1ll<<60;

int main(){
    cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    
    int n;
    cin>>n;
    string s;
    cin>>s;
    int count = 0;
    int l=0;
    int r=n-1;
    while(true){
        if(l >= n or l >= r)break;
        if(s[l] == 'W'){
            while(true){
                if(r < 0 or l >= r)break;
                if(s[r] == 'R'){
                    count++;
                    r--;
                    break;
                }
                r--;
            }  
        }
        l++;
    }
    cout << count << endl;
    return 0;
    
}

Measured memory_bytes: 3644
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <vector>
#include <functional>
#include<map>
using namespace std;
typedef long long ll;

int main() {
    ll n, x, m;
    cin >> n >> x >> m;
    ll a = x;
    ll ans = 0;
    map<ll, int> mp;
    vector<ll> fir;
    ll dup = -1;
    for (int i = 0; i < n;i++){
        if(mp[a]){
            dup = a;
            break;
        }
        fir.push_back(a);
        ans += a;
        mp[a] = i;
        a = a * a % m;
        
    }
    if(dup == -1){  //还没重复就完事了
        cout << ans;
    }else{
        ll sum1 = 0;
        for (int i = 0; i < mp[dup];i++)
            sum1 += fir[i];
        int cnt1 = mp[dup];

        ll sum2 = 0;
        for (int i = mp[dup]; i < fir.size();i++)
            sum2 += fir[i];
        int cnt2 = fir.size() - mp[dup];
        //cout << sum1 << ' ' << sum2;
        //cout << cnt1 << ' ' << cnt2;

        ll re = (n - cnt1) / cnt2;
        sum2 *= re;

        int cnt3 = (n - cnt1) % cnt2;
        ll sum3 = 0;
        for (int i = mp[dup]; i < mp[dup] + cnt3;i++)
            sum3 += fir[i];

        cout << sum1 + sum2 + sum3;
    }


        
}

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

using namespace std;

typedef long long ll;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef pair<ll,ll> pll;

const ll mod=1000000007;
const ll inf=1000000000000; 

#define rep(i,m,n) for(ll i=m;i<n;i++)

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

 ll n;
  cin >> n;
  vector<pll> p(2*n);
  rep(i,0,n) {
    cin >> p[i].first;
    p[i].second=-1; 
  }
  rep(i,n,2*n) {
    cin >> p[i].first;
    p[i].second=1; 
  }
  sort(p.begin(),p.end());
  
 ll res=1; 
  stack<ll> a,b;
  
  rep(i,0,2*n){
   if(p[i].second==-1){
    if(!b.empty()) {
      res*=b.size();
      res%=mod;
      b.pop();
   }
     else a.push(p[i].first);
   }
     else if(p[i].second==1){
    if(!a.empty()) {
      res*=a.size();
      res%=mod;
      a.pop();
   }
     else b.push(p[i].first);
   }
     
  }
  
  cout << res << endl;
  
}


Measured memory_bytes: 4224
a,b,c,d,e = map(int,input().split()) 

if a == 0:
    print(1)
    
elif b == 0:
    print(2)
    
elif c == 0:
    print(3)
    
elif d == 0:
    print(4)
    
elif e == 0:
    print(5)

Measured memory_bytes: 9176
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n; cin >> n;
    for(int i=0;i<n;i++){
        int a,b; cin >> a >> b;
        int cur,ret = 0;
        while(1){
            cur = abs(a);
            for(int i=30;i>=0;i--){
                if(cur % (1<<i) == 0 && a+(1<<i) <= b){
                    a += (1<<i);
                    ret++;
                    break;
                }
            }
            if(a==b){ cout << ret << endl; break; }
        }
    }
}

Measured memory_bytes: 3092
n = int(input())
p = list(map(int, input().split()))

res = 0
for i in range(n-2):
    tmp_list = [p[i], p[i+1], p[i+2]]
    tmp_list_sorted = sorted(tmp_list)

    if tmp_list_sorted[1] == tmp_list[1]:
        res += 1

print(res)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, n) for(int i=0; i<int(n); i++)
#define RNG(i, f, t) for(int i=int(f); i<=int(t); i++)
bool RELAXED = false;
template<int,typename T> struct MINMAX{ T val; MINMAX(T val) : val(val) {} };
template<typename T> MINMAX<1,T> MAX(T val) { return MINMAX<1,T>(val); };
template<typename T> MINMAX<2,T> MIN(T val) { return MINMAX<2,T>(val); };
template<typename T, typename U> inline T& operator|=(T &lhs, MINMAX<1,U> rhs) { return lhs = (rhs.val > lhs ? (RELAXED=true,rhs.val) : (RELAXED=false,lhs)); }
template<typename T, typename U> inline T& operator|=(T &lhs, MINMAX<2,U> rhs) { return lhs = (rhs.val < lhs ? (RELAXED=true,rhs.val) : (RELAXED=false,lhs)); }
template<typename T> inline vector<T> readVector(int n) { vector<T> vec(n); FOR(i,n) cin>>vec[i]; return vec; }
template<typename T> void EXIT(T answer) { cout<<answer<<endl; exit(0); }
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pii> vpii;
typedef signed long long int ll;

const int MAXN=3005;
double dp[MAXN][MAXN];

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

    int n; cin>>n;
    dp[0][0]=1;
    FOR(i,n) {
        double p; cin>>p;
        for(int h=i; h>=0; h--) {
            dp[i+1][h+1] += p*dp[i][h];
            dp[i+1][h] += (1-p)*dp[i][h];
        }
    }
    cout<<setprecision(12)<<accumulate(dp[n]+n/2+1, dp[n]+n+1, 0.)<<endl;
    return 0;
}



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

int n, t, a = INT_MAX, r, w[105];
int main(){
    cin >> n;
    for(int i = 0; i < n; i++){ cin >> w[i]; t += w[i]; }
    for(int i = 0; i < n; i++){
        r += w[i];
        a = min(a, abs(r-(t-r)));
    }
    cout << a;
}


Measured memory_bytes: 256
import Control.Monad
import Data.List

bitterAlchemy :: [Int] -> Int -> Int
bitterAlchemy ms x = makeDonut order 0
    where
        order = ms ++ (repeat . head $ ms)
        makeDonut (m:ms) result =
            if (result + m > x)
                then 0
                else 1 + makeDonut ms (result + m)

main :: IO ()
main = do
    [n,x] <- map read . words <$> getLine
    ms <- replicateM n (read <$> getLine)
    putStrLn . show $ bitterAlchemy (sort ms) x

Measured memory_bytes: 1788
n=int(input())
a=list(map(int,input().split()))
a=sorted(a,reverse=True)
ans=1
mem=a[0]
flag=1
cnt=0
for i in range(1,n):
    if a[i]==mem and flag==1:
        ans*=mem
        flag=0
        cnt+=1
    else:
        mem=a[i]
        flag=1
    if cnt==2:
        print(ans)
        exit()
print(0)


Measured memory_bytes: 14252
#include<bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
  int n, m; cin >> n >> m;
  vector<int> a(n << 1, 0); // 可能总共不够2n个，全赋值为0即可
  for(int i = 0; i < n; i++) cin >> a[i];
  vector<pair<int, int>> v(m);
  for(auto &x: v) cin >> x.second >> x.first;
  sort(v.begin(), v.end()); // 先以first为基准再以second为基准
  reverse(v.begin(), v.end());
  int j = n;
  for(auto &x: v) {
    for(int i = 0; i < x.second && j < (n << 1); i++, j++) {
      a[j] = x.first;
    }
  }
  sort(a.begin(), a.end());
  reverse(a.begin(), a.end());
  long long ans = 0;
  for(int i = 0; i < n; i++) ans += a[i];
  cout << ans << "\n";
}

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

int main() {
  int N,i;
  ll r=0;
  cin >> N;
  unordered_map<string, int> m;
  
  for(i=0; i<N; i++) {
    string x;
    cin >> x;
    sort(x.begin(), x.end());
    
    if(!m.count(x))
      m[x] = 1;
    else {
      r += m.at(x);
      m.at(x)++;
    }
  }

  cout << r << endl;
}

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

string solve(int y, int m, int d) {
  if(y < 2019) {
    return "Heisei";
  }
  if(y > 2019) {
    return "TBD";
  }
  // 2019
  if(m <= 4) {
    return "Heisei";
  }
  return "TBD";
}

int main() {
  string S;
  cin >> S;
  int y = stoi(S.substr(0, 4));
  int m = stoi(S.substr(5, 2));
  int d = stoi(S.substr(8, 2));
  cout << solve(y, m, d) << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define IOS {ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);}
#define endl "\n"
#define float long double
#define int long long int
#define f(i, a, b) for(int i=a; i<b; i++)
#define fb(i, a, b) for(int i=a; i>=b; i--)
#define all(v) (v).begin(), (v).end()
#define pb push_back
#define fi first
#define se second
#define vi vector <int>
#define pi pair <int, int>
#define LB lower_bound
#define UB upper_bound
#define g(t, n) get<n>(t)
#define fp(x, y) fixed<<setprecision(y)<<x
#define PI 3.141592653589793238462643383279502884
using namespace std;

const int M = (int)2e5+5;
const int mod = (int)1e9+7;

void solve()
{
    int n, d, x, y, ans = 0;
    cin>>n>>d;
    while(n--)
    {
    	cin>>x>>y;
    	ans += (x*x+y*y-d*d <= 0);
    }
    cout<<ans<<endl;
}

int32_t main()
{
    IOS
    int t = 1;
    // cin>>t;
    f(tno, 1, t+1)
    {
        // cout<<"Case #"<<tno<<": ";
        solve();
    }
    return 0;
}

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

using namespace std;
 
#define MD 1000000007
typedef long long int ll;

int main(){
    string s;
    cin>>s;
    for(int i=0;i<s.length();i++){
        if(s[i]=='9'){
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
from scipy.sparse import *
N=int(input())
Z=[[i]+list(map(int,input().split())) for i in range(N)]
P=set()
for j in [1,2]:
 Z.sort(key=lambda a:a[j])
 for i in range(1,N):
  a,b,c=Z[i-1]
  d,e,f=Z[i]
  P.add((min(abs(e-b),abs(f-c)),a,d))
d,i,j=zip(*P)
print(int(csgraph.minimum_spanning_tree(csr_matrix((d,(i,j)),(N,N))).sum()))

Measured memory_bytes: 81556
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
    static Scanner in = new Scanner(System.in);

    public static void main(String[] args) {
        int n = in.nextInt(), m = in.nextInt();
        ArrayList<Integer> list = new ArrayList<>();
        boolean[] f = new boolean[n + 1];
        for (int i = 0; i < m; i++) {
            int a = in.nextInt(), b = in.nextInt();
            if (a == 1) {
                f[b] = true;
            }
            if (b == n) {
                list.add(a);
            }
        }

        for (int i : list) {
            if (f[i]) {
                System.out.println("POSSIBLE");
                return;
            }

        }
        System.out.println("IMPOSSIBLE");
    }
}

Measured memory_bytes: 95400
n,k=map(int, input().split())
a=[int(x)-1 for x in list(input().split())]
way=[0]
seen=[0 for i in range(n)]
while True:
        now=way[-1]
        way.append(a[now])
        
        if seen[a[now]]==1:
                break
        seen[a[now]]=1


last=way[-1]
st=way.index(last)
en=len(way)-1
step=en-st
rest=(k-st+1)%step
if k>=st:
        if rest==0:
                ans=way[st-1+step]+1
        else:
                ans=way[st-1+rest]+1

else:
        ans=way[k]+1
print(ans)

        

        



Measured memory_bytes: 30880
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back

int32_t main(){
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int x;
    cin>>x;
    if(x==1){
    	cout<<0<<endl;
    }
    else{
    	cout<<1<<endl;
    }
    return 0;
}

Measured memory_bytes: 3644
def limit():
    """
    i=44721

    全探索
    0 = [0]
    1 = [1,-1,0]と0の組合せ
    2 = [2,-2,0]と1の組合せ
    3**44721 => 無理
    """
    s = 0
    x = 10 ** 9
    for i in range(x):
        s += i
        if s >= x:
            print(i)
            break


def TLE(X):
    """
    11
    1 {0, 1, -1}
    2 {0, 1, 2, 3, -3, -1, -2}
    3 {0, 1, 2, 3, 4, 5, 6, -6, -5, -4, -3, -1, -2}
    4 {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, -10, -9, -8, -7, -6, -5, -4, -3, -1, -2}
    ans: 5
    """
    from itertools import product
    pos = set([0])
    for i in range(1, X + 1):
        for x, y in product(pos, (i, -i, 0)):
            if x + y == X:
                return i
            pos.add(x + y)
        print(i, pos)


def main():
    X = int(input())

    s = 0
    for i in range(1, X + 1):
        s += i
        if X <= s:
            print(i)
            break

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
n, k = map(int, input().split())
h = list(map(int, input().split()))

c = [0 for i in range(n)]

for i in range(1, n):
    l = max(0, i-k)
    c[i] = min(cj + abs(hj - h[i]) for hj, cj in zip(h[l:i], c[l:i]))

print(c[n-1])


Measured memory_bytes: 13928
#include <bits/stdc++.h>
#define ALL(v) (v).begin(), (v).end()
#define INF 1e9
#define pb push_back
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
using namespace std;
typedef long long lint;
typedef long double ld;
using pil = pair<lint, lint>;
template<class T>using numr=std::numeric_limits<T>;
#define MOD 1000000007
#define MOD2 998244353


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

    cin >> S;
    for(int s=0;s<(1<<S.size()-1);s++){
        string now = "";
        now += S[0];
        for(int i=0;i < S.size()-1;i++){
            if(s&(1<<i)){
                now += "+";
            }
            else now += "-";
            now += S[i+1];
        }
        //cout << now << endl;

        int ans = 0;
        for(int i =0;i<7;i++){
            if(i == 0) ans += (now[i] -'0'); //先頭だけ例外
            else if(now[i] == '+') ans += (now[i+1] - '0'); 
            else if(now[i] == '-') ans -= (now[i+1] - '0');
            else continue; 
        }
        if(ans == 7){
            cout << now + "=7" << endl;
            break;
        }
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <utility>
#include <cmath>
#include <functional>
#include <queue>
//#include <stack>
#include <climits>
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,n1,n2) for(int i=n1;i<n2;i++)
#define put(a) cout<<a<<endl;
using namespace std;
typedef long long ll;
//typedef unsigned long long ull;
typedef pair<int, int> P;

int n,a;

int main(){
    cin >> n >> a;
    put(n*n-a);
    return 0;
}


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

bool check(int a[9]){
  int b[10] = {};
  b[0] = 1;
  for(int i = 0;i < 9;++i){
    if(b[a[i]] == 1){
      return false; // 重複してたらfalse
    }
    b[a[i]] = 1;
  }

  return true;
}

bool check_iq(int a[9], int b[9]){
  //b[]は入力
  for(int i = 0;i < 9;++i){
    if(b[i] != -1 && a[i] != b[i]){
      return false;
    }
  }

  return true;
}

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  int a[9];
  int in[9];
  int t1, t2; 
  int ans = 0;

  for(int i = 0;i < 9;++i){
    cin >> in[i];
  }

  for(int i = 1;i <= 9;++i){
    a[0] = i;
    for(int j = 1;j <= 9;++j){
      a[1] = j;
      for(int k = 1;k <= 9;++k){
	a[2] = k;
	for(int l = 1;l <= 9;++l){
	  a[3] = l;
	  for(int m = 1;m <= 9;++m){
	    a[4] = m;
	    for(int n = 1;n <= 9;++n){
	      a[5] = n;

	      t1 = a[0] + a[2] + a[5];
	      a[8] = t1 % 10;
	      t2 = a[1] + a[4] + t1 / 10;
	      a[7] = t2 % 10;
	      a[6] = a[3] + t2 / 10;
	      if(a[6] >= 10) continue;
	      if(!check(a)) continue;
	      if(!check_iq(a, in)) continue;
	      ++ans;
	    }
	  }
	}
      }
    }
  }

  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 3188
n1=int(input())
#数字列を数値の配列に直す(一旦、イテラブルな文字列を経由することで簡単に書ける)
n2=[int(x) for x in str(n1)]
if n1%sum(n2)==0:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 2940
import java.util.*;
import java.io.*;

class Main {

	void solve () {

		int n = in.nextInt();
		System.out.println(n*n*n);
		
	}

	public static PrintWriter out = new PrintWriter(System.out);
	public static Scanner in = new Scanner(System.in);
	public static void main(String[] args) {
		new Main().solve();
		out.flush();
	}

}

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

int main() {
  long long N, M;
  cin >> N >> M;
  vector<pair<long long, long long>> AB(N);
  for (int i = 0; i < N; i++) {
    long long A, B;
    cin >> A >> B;
    AB.at(i) = make_pair(A, B);
  }
  sort(AB.begin(), AB.end());
  long long index = 0;
  long long cost = 0;
  while (M > 0) {
    if (AB.at(index).second <= M) {
      cost += AB.at(index).first * AB.at(index).second;
      M -= AB.at(index).second;
      index++;
    }
    else {
      cost += AB.at(index).first * M;
      M -= AB.at(index).second;
      index++;
    }
  }
  cout << cost << endl;
}

Measured memory_bytes: 1792
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;

constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr double EPS = 1e-12;

//int N, M, K, T, H, W, L, R;
long long int N, M, K, T, H, W, L, R;

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

	while (cin >> N, N) {
		vector<int>p(N);
		vector<int>t(N);
		for (int i = 0; i < N; i++) {
			cin >> p[i] >> t[i];
		}
		vector<vector<int>>dp(N + 1, vector<int>(4, MOD));
		dp[0][0] = 0;
		int befp = 0;
		int beft = 0;
		for (int i = 0; i < N; i++) {
			for (int j = 0; j <= 3; j++) {
				if (j < 3 && abs(befp - p[i])*(j + 1) <= t[i] - beft) {
					dp[i + 1][j + 1] = min(dp[i + 1][j + 1], dp[i][j] + abs(befp - p[i]));
				}
				if (befp*(j + 1) + p[i] <= t[i] - beft) {
					dp[i + 1][1] = min(dp[i + 1][1], dp[i][j] + befp + p[i]);
				}
			}
			befp = p[i];
			beft = t[i];
		}
		int ans = *min_element(dp.back().begin(), dp.back().end());
		if (ans != MOD)cout <<"OK " << ans+befp << endl;
		else {
			int ret = 0;
			for (int i = 1; i <= N; i++) {
				if (*min_element(dp[i].begin(), dp[i].end()) == MOD) {
					ret = i;
					break;
				}
			}
			cout << "NG " << ret << endl;
		}
	}
}


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

int main(void)
{
  std::string s;
  std::cin >> s;

  std::string ans;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == '0') {
      ans += "0";
    }
    else if (s[i] == '1') {
      ans += "1";
    }
    else {
      if (!ans.empty()) {
        ans.pop_back();
      }
    }
  }

  std::cout << ans << std::endl;

  return 0;
}

Measured memory_bytes: 3608
#include<iostream>
#include<vector>
#include<cmath>
#include<string>
#include<map>
#include<list>
#include<cctype>
#include<utility>
#include<algorithm>
#include<cmath>
#include<cctype>
using namespace std;

enum FACE { TOP,BACK, RIGHT ,LEFT , FRONT,  BOTTOM};
template <class T>
class dice {
public:
  dice() {
    id[TOP] = 0; id[FRONT] = 1; id[LEFT] = 2;
    id[RIGHT] = 3; id[BACK] = 4; id[BOTTOM] = 5;
  }
  T& operator[] (int f) { return var[id[f]]; }
  const T& operator[] (int f) const { return var[id[f]]; }
  bool operator==(const dice<T>& b) const {
    const dice<T> &a = *this;
    return a[TOP] == b[TOP] && a[BOTTOM] == b[BOTTOM] &&
           a[FRONT] == b[FRONT] && a[BACK] == b[BACK] &&
           a[LEFT] == b[LEFT] && a[RIGHT] == b[RIGHT];
  }
  void roll_n() { roll(TOP, BACK, BOTTOM, FRONT); }
  void roll_s() { roll(TOP, FRONT, BOTTOM, BACK); }
  void roll_e() { roll(TOP, LEFT, BOTTOM, RIGHT); }
  void roll_w() { roll(TOP, RIGHT, BOTTOM, LEFT); }
  void roll_z() { roll(FRONT, RIGHT, BACK, LEFT); }
  vector<dice> all_rolls() {
    vector<dice> ret;
    for (int k = 0; k < 6; (k&1?roll_w():roll_s()),++k)
      for (int i = 0; i < 4; roll_z(), ++i)
        ret.push_back(*this);
    return ret;
  }
  bool equivalent_to(const dice& di) {
    for (int k = 0; k < 6; (k&1?roll_w():roll_s()),++k)
      for (int i = 0; i < 4; roll_z(), ++i)
        if (*this == di) return true;
    return false;
  }
private:
  void roll(FACE a, FACE b, FACE c, FACE d) {
    T tmp = id[a];
    id[a] = id[b]; id[b] = id[c];
    id[c] = id[d]; id[d] = tmp;
  }
  T var[6];
  int id[6];
};

int main()
{
	dice<int> d;
	for(int i=0;i<6;i++){
		int n; cin >>n;
		d[i] = n;
	}

	string s;
	cin >> s;
	for(int i=0;i<s.size();i++){
		if(s[i]=='N'){
			d.roll_n();
		}else if(s[i]=='E'){
			d.roll_e();
		}else if(s[i]=='W'){
			d.roll_w();
		}else if(s[i]=='S'){
			d.roll_s();
		}
	}
	cout << d[TOP] << endl;
    return 0;
}

Measured memory_bytes: 1208
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
typedef pair<int, int> P;
ll Mod = 1000000007;
int main() {
  ll N;
  cin >> N;
  ll K;
  cin >> K;
  ll A[N];
  for (int i = 0; i < N; i++) cin >> A[i];
  ll ans = 0;
  map<ll,ll> mp;
  ll R[N+1];
  R[0] = 0;
  for (int i = 0; i < N; i++) {
    R[i+1] = R[i] + A[i];
  }
  ll res[N+1];
  for (int i = 0; i <= N; i++) {
    res[i] = (R[i] - i) % K;
  }
  for (int i = 0; i < min(N+1,K); i++) {
    mp[res[i]]++;
  }
  for (auto p : mp) {
    if (p.second > 0) {
      ans += ((p.second - 1) * p.second) / 2;
    }
  }
  
  for (int i = 0; i < N - K + 1; i++) {
    mp[res[i]]--;
    mp[res[i+K]]++;
    ans += mp[res[i+K]] - 1;
  }
  cout << ans << endl;
  return 0;
}

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

int main() {
  int N ; cin >> N ; 
  vector<int64_t> A(N+1) ; 

  int64_t ans = 0 ; 
  for(int i = 1 ; i <= N ; i++){
    
    for(int j = i ; j <= N ; j += i ){
      A.at(j)++ ; 

    }
    //cout << i <<" "  << cnt << endl ; 
  }
  for(int i = 1 ; i <= N ; i++){
    ans += i*A.at(i) ; 
  }
  
  cout << ans << endl ; 

  
}

Measured memory_bytes: 81396
#include <iostream>
#include <algorithm>
#include <string>
#include <stack>
#include <cstdlib>
#include <queue>
#include <vector>
#include <set>
#include <stdio.h>
#include <cstdio>
#include <cmath>
#include <complex>
using namespace std;
typedef complex<double> xy_t;
xy_t P[30];
int N;
double x,y;
int main() {
cin >> N;
double s =0.0;
for(int i = 0;i < N;i++) {
    cin >> x >> y;
    P[i] = xy_t(x,y);
}
for ( int i = 0; i+2 < N;i++ ){
    xy_t a = P[i+1] - P[0], b = P[i+2]-P[0];
    s +=  (a.real()*b.imag()-a.imag()*b.real())/2;
}
printf("%.1f\n", abs(s));
}

Measured memory_bytes: 3284
n = int(input())
S = input()

rlist= []
glist = []
bset = set()
for i,s in enumerate(S):
    if s == "R":
        rlist.append(i)
    elif s=="G":
        glist.append(i)
    else:
        bset.add(i)
blist = [0 for i in range(n)]
cnt = 0
for i,s in enumerate(S[::-1]):
    if s == "B":
        cnt += 1
    blist[n-1-i] = cnt

res = 0
for r in rlist:
    for g in glist:
        res += len(bset)
        l, s = max(r,g), min(r,g)
        possible =  [s-(l-s), l+(l-s)]
        if (l-s) % 2 == 0: possible.append(s+(l-s)//2)
        for x in possible:
            if x in bset:
                res -= 1
print(res)

Measured memory_bytes: 9360
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7


X = INT()
X += 0.1
 
ans = 1
for i in range(2, 10):
	if int(X**(1/i)) <= 1:
		break
	else:
		ans = max(ans, int(X**(1/i))**i)
 
print(ans)


Measured memory_bytes: 5200
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long a,b,t,t1;
	int sum=0,n,i;
	scanf("%d %lld %lld",&n,&a,&b);
	for(i=0;i<n;i++)
	{
		scanf("%lld %lld",&t,&t1);
		if(t>=a&&t1>=b)
			sum++;
	}
	printf("%d",sum);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    int H = -1, W = -1;
    cin >> H >> W;

    while (H != 0 && W != 0) {
        for (int i = 0; i < H; i++) {
            for (int j = 0; j < W; j++) {
                cout << "#";
            }
            cout << endl;
        }
        cout << endl;
        cin >> H >> W;
    }
}


Measured memory_bytes: 3124
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using datas=pair<ll,ll>;
using ddatas=pair<double,double>;
using tdata=pair<ll,datas>;
using vec=vector<ll>;
using mat=vector<vec>;
using pvec=vector<datas>;
using pmat=vector<pvec>;
#define For(i,a,b) for(i=a;i<(ll)b;i++)
#define bFor(i,a,b) for(i=a;i>=(ll)b;i--)
#define rep(i,N) For(i,0,N)
#define rep1(i,N) For(i,1,N)
#define brep(i,N) bFor(i,N-1,0)
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define vsort(v) sort(all(v))
#define vrsort(v) sort(allr(v))
#define endl "\n"
#define pb push_back
#define printyes cout<<"Yes"<<endl
#define printno cout<<"No"<<endl
#define output(v) do{bool f=0;for(auto outi:v){cout<<(f?" ":"")<<outi;f=1;}cout<<endl;}while(0)
const ll mod=1000000007;
const ll inf=1LL<<60;
const double PI = acos(-1);
const double eps = 1e-9;
template<class T> inline bool chmax(T& a,T b){bool x=a<b;if(x)a=b;return x;} 
template<class T> inline bool chmin(T& a,T b){bool x=a>b;if(x)a=b;return x;} 

void startupcpp(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(15);
}

double distance(ddatas& x,ddatas& y){
  double a=x.first-y.first,b=x.second-y.second;
  return sqrt(a*a+b*b);
}

ll modinv(ll a) {
  ll b=mod,u=1,v=0,t;
  while(b){
    t=a/b;
    a-=t*b; swap(a,b);
    u-=t*v; swap(u,v);
  }
  return (u+mod)%mod;
}

ll moddevide(ll a,ll b){return (a*modinv(b))%mod;}

vec modncrlistp,modncrlistm;

ll modncr(ll n,ll r){
  ll i,size=modncrlistp.size();
  if(size<=n){
    modncrlistp.resize(n+1);
    modncrlistm.resize(n+1);
    if(!size){
      modncrlistp[0]=modncrlistm[0]=1;
      size++;
    }
    For(i,size,n+1){
      modncrlistp[i]=modncrlistp[i-1]*i%mod;
      modncrlistm[i]=modinv(modncrlistp[i]);
    }
  }
  return modncrlistp[n]*modncrlistm[r]%mod*modncrlistm[n-r]%mod;
}

ll modpow(ll a,ll n){
  ll res=1;
  while(n){
    if(n&1)res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

ll gcd(ll a,ll b){if(!b)return a;return (a%b==0)?b:gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

ll countdigits(ll n){
  ll ans=0;
  while(n){n/=10;ans++;}
  return ans;
}

ll sumdigits(ll n){
  ll ans=0;
  while(n){ans+=n%10;n/=10;}
  return ans;
}

int main(){
  ll i,j,H,W,ans;
  cin>>H>>W;
  mat v;
  string s;
  vec ch(W);
  rep(i,H){
    cin>>s;
    ans=0;
    rep(j,W){
      ans+=ch[j]=s[j]=='#';
    }
    if(ans)v.pb(ch);
  }
  H=v.size();
  rep(i,H)rep(j,W)ch[j]|=v[i][j];
  rep(i,H){
    rep(j,W)if(ch[j]){
      if(v[i][j])cout<<"#";
      else cout<<".";
    }
    cout<<endl;
  }
  return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using vec=vector<ll>;
using mat=vector<vec>;
#define For(i,a,b) for(i=a;i<b;i++)
#define rep(i,N) For(i,0,N)
#define rep1(i,N) For(i,1,N)
#define all(v) (v).begin(),(v).end()
#define vsort(v) sort(all(v))
#define mod 1000000007
using data=pair<ll,ll>;

long mmid(long a,long b,long c){return a<b?(b<c?b:max(a,c)):(b>c?b:min(a,c));}

ll modinv(ll a) {
  ll b=mod,u=1,v=0,t;
  while(b){
    t=a/b;
    a-=t*b; swap(a,b);
    u-=t*v; swap(u,v);
  }
  return (u+mod)%mod;
}

ll moddevide(ll a,ll b){return (a*modinv(b))%mod;}

ll modncr(ll n,ll r){
  ll i,plus=1;
  rep(i,r){
    plus=(plus*(n-i))%mod;
    plus=moddevide(plus,i+1);
  }
  return plus;
}

ll euclidean_gcd(ll a, ll b) {
  if(a<b) return euclidean_gcd(b, a);
  ll r;
  while ((r=a%b)){a=b;b=r;}
  return b;
}

ll countdigits(ll n){
  ll ans=0;
  while(n){n/=10;ans++;}
  return ans;
}

ll sumdigits(ll n){
  ll ans=0;
  while(n){ans+=n%10;n/=10;}
  return ans;
}

void printmap(vector<ll>& a,ll H,ll W){
  ll i,j;
  For(i,0,H+2){
    For(j,0,W+2){cout<<a[i*(W+2)+j];}
    cout<<endl;
  }
}
void inputmap(vector<ll>& a,ll H,ll W){
  ll i,j;
  string ss;
  For(i,1,H+1){
    cin>>ss;
    For(j,1,W+1){
      if(ss[j-1]=='#'){
        a[i*(W+2)+j]=1;
      }else{
        a[i*(W+2)+j]=0;
      }
    }
  }
}


int main(){
  ll i,j,N,M,K;
  cin>>N>>M;
  for(i=M-N+1;i<M+N;i++){
    cout<<i<<" ";
  }
  return 0;
}

Measured memory_bytes: 256
import java.util.*;

class Main{
    public static void main(String[] args) {
        Scanner stdIn = new Scanner(System.in);
        int n = stdIn.nextInt();
        int d = stdIn.nextInt();

        if(n % (2 * d + 1) == 0 )
        System.out.println(n / (2 * d + 1));
        else 
        System.out.println(n / (2 * d + 1) + 1);   
    }
}


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


using namespace std;

int main() {
    unordered_set<int> s1;
    for(int i=0;i<3;i++){
        int x;
        cin>>x;
        s1.insert(x);
    }
    if(s1.size()==2){
        cout<<"Yes";
    }else{
        cout<<"No";
    }
}

Measured memory_bytes: 256
/*************************************************************************
	> File Name: 1.cpp
	> Author: Knowledge_llz
	> Mail: 925538513@qq.com 
	> Blog: https://blog.csdn.net/Pig_cfbsl 
	> Created Time: 2020/5/10 20:00:32
 ************************************************************************/

#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<algorithm>
#define For(i,a,b) for(register int i=(a);i<=(b);++i)
#define LL long long
using namespace std;
int read(){
	char x=getchar(); int u=0,fg=0;
	while(!isdigit(x)){ if(x=='-') fg=1; x=getchar(); }
	while(isdigit(x)){ u=(u<<3)+(u<<1)+(x^48); x=getchar(); }
	return fg?-u:u;
}
int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.in", "r", stdin);
	freopen("output.out", "w", stdout);
#endif
	int a=read(),b=read(),c=read(),k=read(),ans=0;
	if(k>a) ans+=a;
	else ans=k;
	k-=a;
	k-=b;
	if(k>c) ans-=c;
	else{
		if(k>0) ans-=k;
	}
	printf("%d\n",ans);

	return 0;
}


Measured memory_bytes: 3752
//
// Created on 2020/08/30.
//


#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <ios>
#include <iomanip>
#include <numeric>

#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
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; }
typedef long long ll;
using namespace std;
const long long LINF =1e18;
const int INF = 1e9;



int main() {
    int n,a;
    cin>>n>>a;
    n %= 500;
    if(a >= n){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
    return 0;
}


Measured memory_bytes: 3608
#include <stdio.h>
#define MAX_N 44

int fibonach(int);
int recurFib(int);

int Fib[MAX_N];

int main()
{
  int n;

  scanf("%d", &n);

  printf("%d\n", fibonach(n));

  return 0;
}

int fibonach(int n)
{
  int i;

  for(i = 0; i <= n; i++)
    {
      Fib[i] = 0;
    }

  return recurFib(n);
}

  int recurFib(int n)
{
  if(n == 0 || n == 1)
    Fib[n] = 1;

  else if(Fib[n] == 0)
    Fib[n] = recurFib(n - 1) + recurFib(n - 2);

  return Fib[n];
}

Measured memory_bytes: 596
#include <iostream>
#include <algorithm>
#include <iterator>
#include <vector>
#include <unordered_set>

using namespace std;

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  copy_n(istream_iterator<int>(cin), N, A.begin());
  unordered_set<int> s;
  const char* result = "YES";
  for (int item : A) {
    if (s.count(item)) {
      result = "NO";
      break;
    }
    s.insert(item);
  }
  cout << result << endl;
  return 0;
}


Measured memory_bytes: 9288
#include <cstdio>

using namespace std;

int main(void){
	int n, i;
	double debt = 100000, up;
	scanf("%d",&n);
	for(i = 0;i < n;i++){
		debt *= 1.05;
		up = debt - ((int)(debt / 1000) * 1000);
		if(up > 0){
			debt += 1000 - up;
		}
	}
	printf("%d\n",(int)debt);
	return 0;
}

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

int main(){
    int N;
    string S;
    cin >> N >> S;
    int ans = N;

    rep(i,N-1){
        if(S[i] == S[i+1]){
            ans --;
        }
    }

    cout << ans << endl;
}
    

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main(){
    string s;
    cin >> s;
    if(s.at(0)==s.at(1)&&s.at(1)==s.at(2)){
        cout << "Yes" << endl;
    }else if(s.at(1)==s.at(2)&&s.at(2)==s.at(3)){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}




Measured memory_bytes: 256
<?php
list($n, $x) = explode(" ", fgets(STDIN));
$jump_length = explode(" ", fgets(STDIN));

$answer = 1;
$length = 0;

foreach($jump_length as $jump) {
  $length += $jump;
  
  if($length <= $x) {
    $answer++;
  } else {
    break;
  }
}

echo $answer . "\n"; 

?>

Measured memory_bytes: 4856
#pragma GCC optimize(3)
#include<cstdio>
int n,t,a[100005][5],pos[100005],res[2];
char ch[2000005],*p=ch;
inline int rd(){register int res=0;while(*p<'0'||*p>'9'){p++;}while(*p>='0'&&*p<='9'){res=res*10+*p-'0';p++;}return res;}
int main(){
	fread(ch,2000000,1,stdin);n=rd();for(int i=1;i<=3;i++)for(int j=1;j<=n;j++)a[j][i]=rd();
	for(int i=1;i<=n;i++){
		pos[i]=a[i][2]/3+1;
		if(a[i][2]%3-2||(i-pos[i])&1||!((a[i][1]-a[i][2]==1&&a[i][2]-a[i][3]==1)||(a[i][1]-a[i][2]==-1&&a[i][2]-a[i][3]==-1)))return puts("No"),0;
		res[i&1]^=a[i][1]>a[i][2];
	}
	for(int i=1;i<=n;i++)while(pos[i]^i)res[(i&1)^1]^=1,t=pos[pos[i]],pos[pos[i]]=pos[i],pos[i]=t;
	return puts(res[0]+res[1]?"No":"Yes"),0;
}

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

int main() {
  int n;
  cin >> n;
  map<int, int> a;
  for(int i = 0; i < n; i++){
    int c;
    cin >> c;
    a[c]++;
  }
  
  int ans = 0;
  for(auto p : a){
    if(p.second % 2) ans++;
  }
  cout << ans << endl;
}

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

using namespace std;

int main() {

	string str;
	vector<int> stnum(27, 0);

	while (1) {
		getline(cin, str);
		if (str == "") { break; }
		for (int i = 0; i < str.size(); i++) {
			if (str[i] >= 'a' && str[i] <= 'z') {
				stnum[str[i] - 'a']++;
			}
			else if (str[i] >= 'A' && str[i] <= 'Z') {
				stnum[str[i] - 'A']++;
			}
		}
	}
	for (int i = 0; i < 26; i++) {
		cout << char('a' + i) << " : " << stnum[i] << endl;
	}
}


Measured memory_bytes: 3172