akhauriyash/Code-Regression huggingface dataset:
h, w = map(int, input().split())
s = [['#' for _ in range(w + 2)]]
s = s + [['#'] + list(input()) + ['#'] for _ in range(h)]
s = s + [['#' for _ in range(w + 2)]]
n_white = 0
for i in range(1, h + 1):
    n_white += s[i].count('.')
q = [[1, 1]]
a = []
d = 1
while(True):
    qq = []
    for i in range(len(q)):
        if q[i] in a:
            continue
        x = q[i][0]
        y = q[i][1]
        if s[x][y - 1] == '.' and [x, y - 1] not in qq:
            qq.append([x, y - 1])
        if s[x - 1][y] == '.' and [x - 1, y] not in qq:
            qq.append([x - 1, y])
        if s[x + 1][y] == '.' and [x + 1, y] not in qq:
            qq.append([x + 1, y])
        if s[x][y + 1] == '.' and [x, y + 1] not in qq:
            qq.append([x, y + 1])
    d += 1
    if [h, w] in qq:
        break
    elif qq == []:
        print(-1)
        exit()
    a = a + q
    q = qq
print(n_white - d)

Measured memory_bytes: 3572
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<cmath>
#include<deque>
#include<queue>
#include<numeric>
using namespace std;

using ll = long long;
const int INF = 1001001001;
const ll LLINF = 1001001001001001001;
const int MOD = 1000000007;

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

int main()
{
  ll h, w, m;
  cin >> h >> w >> m;
  vector<ll> tate(h+1, 0);
  vector<ll> yoko(w+1, 0);
  set<pair<ll, ll>> bomb;

  rep (i, m) {
    ll tmph, tmpw;
    cin >> tmph >> tmpw;
    tate[tmph]++;
    yoko[tmpw]++;
    bomb.insert(make_pair(tmph, tmpw));
  }

  ll result = 0;

  ll maxh = 0;
  ll maxhSum = 0;
  for (int i = 1; i <= h; i++) {
    if (maxhSum <= tate[i]) {
      maxhSum = tate[i];
      maxh = i;
    }
  }

  // hを固定してwをさがす
  for (int i = 1; i <= w; i++) {
    ll now = yoko[i];
    ll j = 0;
    if (bomb.find(make_pair(maxh, i)) != bomb.end()) j++;
    if (result < (maxhSum + now - j)) {
      result = (maxhSum + now - j);
    }
  }

  ll maxw = 0;
  ll maxwSum = 0;
  for (int i = 1; i <= w; i++) {
    if (maxwSum <= yoko[i]) {
      maxwSum = yoko[i];
      maxw = i;
    }
  }

  // wを固定してhをさがす
  for (int i = 1; i <= h; i++) {
    ll now = tate[i];
    ll j = 0;
    if (bomb.find(make_pair(i, maxw)) != bomb.end()) j++;
    if (result < (maxwSum + now - j)) {
      result = (maxwSum + now - j);
    }
  }
  
  cout << result << endl;
}


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

using namespace std;

typedef long long ll;

mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());

const int inf = 1e9 + 7;
const int mod = 1e9 + 7;

inline void add(int &a, int b) {
  a += b;
  if (a >= mod) a -= mod;
  if (a < 0) a += mod;
}

inline int mul(int a, int b) {
  return (a * (ll) b) % mod;
}

inline int pw(int x, int n) {
  int res = 1;
  while (n > 0) {
    if (n % 2) {
      res = mul(res, x);
      n--; 
    } else {
      x = mul(x, x);
      n /= 2;
    }
  }
  return res;
}

const int N = 2e5 + 7;

ll t[4 * N];

void upd(int v, int tl, int tr, int p, ll x) {
  if (tl == tr) {
    t[v] = max(t[v], x);
  } else {
    int tm = (tl + tr) / 2;
    if (p <= tm) upd(2 * v + 1, tl, tm, p, x);
    else upd(2 * v + 2, tm + 1, tr, p, x);
    t[v] = max(t[2 * v + 1], t[2 * v + 2]);
  }
}

ll get(int v, int tl, int tr, int l, int r) {
  if (tl > r || tr < l) {
    return 0;
  } else if (tl >= l && tr <= r) {
    return t[v];
  } else {
    int tm = (tl + tr) / 2;
    return max(get(2 * v + 1, tl, tm, l, r), get(2 * v + 2, tm + 1, tr, l, r));
  }
}

ll dp[N];

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  vector <int> h(n), a(n);
  for (int i = 0; i < n; i++) {
    cin >> h[i];
  }
  for (int i = 0; i < n; i++){
    cin >> a[i];
  }
  for (int i = 0; i < n; i++) {
    dp[i] = get(0, 0, n - 1, 0, h[i] - 1) + a[i];
    upd(0, 0, n - 1, h[i], dp[i]);
  }
  cout << get(0, 0, n - 1, 0, n - 1) << '\n';
  return 0;
}

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


using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0; i<int(n); i++)
#define FOR(i,m,n) for(int i=int(m); i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VLL vector<long long>
#define VVI vector<vector<int>>
#define VVLL vector<vector<long long>>
#define VC vector<char>
#define VS vector<string>
#define VVC vector<vector<char>>
#define fore(i,a) for(auto &i:a)

typedef pair <int, int> P;
template<class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
const int  INF = 1 << 30;
const ll INFL = 1LL<<60;
const ll mod = 1000000007;		





int main() {

	cin.tie(0);
	ios::sync_with_stdio(false);

	int n;
	cin >> n;
	
	string s;
	cin >> s;

	int ans = INF;

	int a = 0;
	int b = 0;
	REP(i, n) {
		if (s[i] == '.')a++;
		else b++;
	}
	int c = 0, d = 0;

	ans = a;


	REP(i, n) {
		if (s[i] == '.') {
			a--;
		}
		else {
			b--; c++;
		}
		ans = min(ans, a + c);

	}

	cout << ans << endl;


	return 0;
}




Measured memory_bytes: 720
#include <bits/stdc++.h>
 
const int N = 200000 + 10;
 
int n, a[N], cnt[N];
int ans;
 
int tag[N];
 
void add(int x) {
  int z = x - cnt[x]++;
  if (z > 0) ans += !tag[z]++;
}
 
void del(int x) {
  int z = x - --cnt[x];
  if (z > 0) ans -= --tag[z] == 0;
}
 
int main() {
  int m;
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; ++i) scanf("%d", &a[i]), add(a[i]);
  while (m--) {
    int x, y;
    scanf("%d%d", &x, &y);
    del(a[x]);
    add(a[x] = y);
    printf("%d\n", n - ans);
  }
  return 0;
}

Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll,ll> P;
using VP = vector<P>; using VVP = vector<VP>;
using VI = vector<ll>; using VVI = vector<VI>; using VVVI = vector<VVI>;
const int inf=1e9+7;
const ll INF=1LL<<61;
const ll mod=1e9+7;

template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

struct tri{
    int a;
    int b;
    int c;
};

int main(){
    int i,j;
    int a,b,c;
    int n;
    while(1){
        cin>>a>>b>>c;
        if(a==0) break;
        cin>>n;
        int  s=a+b+c;
        int x,y,z,p;
        vector<tri> t;
        VI v(s,2);
        for(i=0;i<n;i++){
            cin>>x>>y>>z>>p;
            x--; y--; z--;
            if(p){
                v[x]=1;
                v[y]=1;
                v[z]=1;
            }   
            else t.pb({x,y,z});
        }
        for(auto d:t){
            if(v[d.a]==1&&v[d.b]==1) v[d.c]=0;
            if(v[d.b]==1&&v[d.c]==1) v[d.a]=0;
            if(v[d.c]==1&&v[d.a]==1) v[d.b]=0;
        }
        for(i=0;i<s;i++){
            cout<<v[i]<<endl;
        }
    }

}


Measured memory_bytes: 3196
#include <iostream>
#include <cstdio>
#include <string>

int main()
{
    char s[3];
  
    std::cin >> s[0] >> s[1] >>s[2];

    int count = 0;
    for (int loop=0;loop < 3; ++loop){
        if('1' == s[loop]) {
            ++count;
        }
    }
    std::printf("%d", count);

  return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import math

if __name__ == "__main__":
    list = input().split(" ")
    N = int(list[0])
    M = int(list[1])
    list = []
    for i in range(1,int(math.sqrt(M)+1)):
        if M%i == 0:
            list.append(i)
    for i in range(len(list)):
        list.append(int(M/list[i]))
    print(max([i for i in list if i <= M // N]))

Measured memory_bytes: 3188
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < n; i++)

using namespace std;

void solve() {
  long A, B;
  cin >> A >> B;

  long ans = 0;

  for (long i = A; i <= B; i++) {
    string foo = to_string(i);
    string bar = foo;
    reverse(bar.begin(), bar.end());
    if (foo == bar) ans++;
  }

  cout << ans << endl;
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  solve();
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<math.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()

using namespace std;
using ll = long long int;

int main(void) {
    string s; cin >> s;
    int cnt = 0, n = s.size();
    REP(i, n / 2) {
        if (s[i] != s[n - 1 - i]) cnt++;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
  private static class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;

    public FastScanner(InputStream in) {
      reader = new BufferedReader(new InputStreamReader(in));
      tokenizer = null;
    }

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

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

      return tokenizer.nextToken("\n");
    }

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

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

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

    public int[] nextIntArray(int n) {
      int[] a = new int[n];
      for (int i = 0; i < n; i++)
        a[i] = nextInt();
      return a;
    }

    public long[] nextLongArray(int n) {
      long[] a = new long[n];
      for (int i = 0; i < n; i++)
        a[i] = nextLong();
      return a;
    }
  }

  public static void main(String[] args) {
    FastScanner sc = new FastScanner(System.in);
    int n = sc.nextInt();
    int r = sc.nextInt();
    int diff = 100 * (10 - n);
    if (n < 10) {
      System.out.println(r + diff);
    } else {
      System.out.println(r);
    }
  }
}

Measured memory_bytes: 21460
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<vector>
#include<set>
#include <string>
using namespace std;
int s[100005];
int x[100005];
bool cmp(int a,int b)
{
    return s[a]<s[b];
}
int main()
{
   int N;
   int i,j;
   scanf("%d",&N);
   for(i=0;i<N;i++)
   {
        scanf("%d",&s[i]);
        x[i]=i;
   }
   sort(x,x+N,cmp);
  for(i=0;i<N;i++)
    printf("%d ",x[i]+1);


    return 0;

}


Measured memory_bytes: 1536
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++) //for文マクロ
using namespace std;

typedef unsigned long ul;
typedef long long ll;
typedef pair<ul, ul> P; //ペア　タイプでふ

int main()
{
    int a, b;
    cin >> a>>b;
    cout << a * b - a - b + 1;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(){

int A = 0;
int B = 0;
scanf("%d%d", &A, &B);


if((A - B) > (16 - (A + B))) {
    printf(":(");
    }
else if((B -A) > (16 - (A + B))){
    printf(":(");
}
else{
    printf("Yay!");}


return 0;}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair< ll, ll > Pi;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
const ll INF = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}
#define all(x) x.begin(), x.end()
#define mp make_pair
bool compare(Pi a, Pi b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}


bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}
const vector<ll> dx{1,0,-1,0};
const vector<ll> dy{0,1,0,-1};


int main() {
    ll a,b;
    cin >>a>>b;
    ll sum=0;
    ll n=b-a;
    cout << (n-1)*(n)/2-a << endl;


    return 0;
    

}

Measured memory_bytes: 3576
//$g++ -std=c++11 Template.cpp 

//#include <bits/stdc++.h>
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <climits>
#include <iomanip>

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define ROF(i, j, k) for(int i = (int)(j); i >= (int)(k); --i)
#define FORLL(i, n, m) for(long long i = n; i < (long long)(m); i++)
#define SORT(v, n) sort(v, v+n)
#define REVERSE(v) reverse((v).begin(), (v).end())

using namespace std;
using ll = long long;
const ll MOD=1000000007LL;
typedef pair<int, int> P;

ll ADD(ll x, ll y) { return (x+y) % MOD; }
ll SUB(ll x, ll y) { return (x-y+MOD) % MOD; }
ll MUL(ll x, ll y) { return x*y % MOD; }
ll POW(ll x, ll e) { ll v=1; for(; e; x=MUL(x,x), e>>=1) if (e&1) v = MUL(v,x); return v; }
ll DIV(ll x, ll y) { /*assert(y%MOD!=0);*/ return MUL(x, POW(y, MOD-2)); }

priority_queue<int> q_descending;
priority_queue<int, vector<int>, greater<int> > q_ascending;

//int a[100100];
map<int, int> mp;

int
main(void){  
  ios_base::sync_with_stdio(false);

  int n;
  cin >> n;
  REP(i, n) {
    int a;
    cin >> a;
    mp[a]++;
  }

  ll ans = 0LL; 
  for(auto i=mp.begin(); i!=mp.end(); ++i){
    if(i->first == i->second) continue;
    if(i->second > i->first) ans += i->second - i->first;
    else ans += i->second;
  }

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


Measured memory_bytes: 4736
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define rep(i,s,f) for(i=s;i<f;i++)
#define print(v) for(auto &z:v) cout<<z<<' ';cout<<'\n'
#define db cout<<"db: "
#define pb push_back
#define pii pair<int,int>
#define F first
#define S second
#define B begin()
#define E end()
#define all(v) v.B,v.E
#define sz(v) (int)((v).size())
#define vi vector<int>
#define vii vector<pair<int,int>>
#define boost ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define clk1 clock_t start_time=clock()
#define clk2 cout<<(clock()-start_time)/(double)CLOCKS_PER_SEC
#define clean(arr) memset(arr,0,sizeof(arr))
#define mod 1000000007
#define mod2 998244353
#define space 100005
//<<fixed << setprecision(9)

int main()
{
    int n,i,j,t;
    boost;
    cin>>n;
    
    int x,y,z;
    map<int,int> mp;
    rep(x,1,101)
    {
        rep(y,1,101)
        {
            rep(z,1,101)
            {
                int val = x*x + y*y + z*z +z*y + y*x + x*z;
                mp[val]++;
            }
        }
    }
    rep(i,1,n+1) cout<<mp[i]<<"\n";

    return 0;
}

Measured memory_bytes: 5468
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        List<Integer> h = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            h.add(sc.nextInt());
        }
        int count = 0;
        for (int i = 0; i < n; i++) {
            int target = h.get(i);
            boolean canSee = true;
            if (i == 0) {
                count++;
                continue;
            }
            for (int j = 0; j < i; j++) {
                int height = h.get(j);
                if (target < height) {
                    canSee = false;
                    break;
                }
            }
            if (canSee) {
                count++;
            }
        }
        System.out.println(count);
    }

}


Measured memory_bytes: 22608
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

int main() {
    ll h, w, K;
    cin >> h >> w >> K;
    K--;

    vvl dp(h+1, vl(w));  // dp[i+1][j] : i行目を通過した直後にj列目にいる場合の数(i,jは0-index)
    dp[0][0] = 1;
    rep(i, h) {
        rep(j, w) {
            rep(b, 1<<(w-1)) {  // bのkビット目が1ならk列目とk+1列目の間に横棒を引く

                vl v(w);  // v[k] : k列目とk+1列目の間に横棒を引くとき1
                rep(k, w-1) {
                    if(b & (1<<k)) {
                        v[k] = 1;
                    }
                }
                
                ll flag = 0;  // 2つの横棒が端点を共有するとき1
                rep(k, w-2) {
                    if(v[k] && v[k+1]) {
                        flag = 1;
                    }
                }
                if(flag) {  // 2つの横棒が端点を共有するときはダメ
                    continue;
                }

                // 右から左に横棒を通過する場合
                if(j > 0 && v[j-1]) {
                    dp[i+1][j-1] += dp[i][j];
                    dp[i+1][j-1] %= mod;
                }
                // 左から右に横棒を通過する場合
                else if(j < w-1 && v[j]) {
                    dp[i+1][j+1] += dp[i][j];
                    dp[i+1][j+1] %= mod;
                }
                // 横棒を通過しない場合
                else {
                    dp[i+1][j] += dp[i][j];
                    dp[i+1][j] %= mod;
                }
            }
        }
    }

    out(dp[h][K]);
    re0;
}

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

using namespace std;

#define int long long

constexpr long long INF = (long long)1e18;

class ford_fulkerson{
	int maxv;
	struct edge{ int to, cap, rev; };
public:
	vector<vector<edge>> G;
	vector<bool> used;

	
	ford_fulkerson(int maxv = 0) : maxv(maxv){
		resize(maxv);
	}
	
	void init(){
		G.clear();
		used.clear();
	}
	
	void resize(int v){
		G.resize(v);
		used.resize(v);
	}
	
	void add_edge(int from, int to, int cap){
		G[from].push_back((edge){to,cap,(int)G[to].size()});
		G[to].push_back((edge){from, 0, (int)G[from].size()-1});
	}

	int dfs(int v, int t, int f){
		if(v == t) return f;
		used[v] = true;
		for(int i = 0; i < G[v].size(); i++){
			edge &e = G[v][i];
			if(!used[e.to] && e.cap > 0){
				int d = dfs(e.to, t, min(f,e.cap));
				if(d > 0){
					e.cap -= d;
					G[e.to][e.rev].cap += d;
					return d;
				}
			}
		}
		return 0;
	}

	int max_flow(int s, int t){
		int flow = 0;
		for(;;){
			fill(used.begin(), used.end(), false);
			int f = dfs(s,t,INF);
			if(f == 0) return flow;
			flow += f;
		}
	}
};

signed main(){
	int X, Y, E; 
	ford_fulkerson ff;
	
	cin>>X>>Y>>E;
	
	ff.resize(X+Y+2);
	
	for(int i = 0; i < E; i++){
		int x, y;
		
		cin>>x>>y;
		
		ff.add_edge(x, y + X, 1);
	}
	
	for(int i = 0; i < X; i++){
		ff.add_edge(X+Y, i, 1);
	}
	
	for(int i = 0; i < Y; i++){
		ff.add_edge(i + X, X+Y+1, 1);
	}
	
	cout<<ff.max_flow(X+Y, X+Y+1)<<endl;
	
}



Measured memory_bytes: 3340
n=int(input())
cnt=[50]*26

for _ in range(n):
    s=input()
    curcnt=[0]*26

    for c in s:
        curcnt[ord(c)-ord('a')]+=1
    
    for i in range(26):
        cnt[i]=min(cnt[i],curcnt[i])
    
ans=''
for i in range(26):
    c=chr(i+ord('a'))
    while cnt[i]>0:
        ans=ans+c
        cnt[i]-=1
    

print(ans)

Measured memory_bytes: 65164
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <sstream>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <numeric>
#include <cmath>
#include <climits>
#include <limits>
#include <cfloat>
#include <fstream>
using namespace std;

int main()
{
	string str = "";
	map <string, set<int> > Index;

	while (getline (cin, str ) ){

		string word = "";
		int page = 0;

		stringstream ss(str);
		ss >> word >> page;

		Index[word].insert (page );

	} // end loop

	map <string, set<int> >::iterator it = Index.begin();

	for (; it != Index.end(); ++it){

		string w = (*it).first;
		cout << w << endl;
	
		set<int>::iterator its = Index[w].begin();
		int n = Index[w].size();

		for (int i = 0; its != Index[w].end(); ++its, ++i){
			cout << (*its);
			if (i != n - 1){
				cout << ' ';
			} // end if
		} // end for

		cout << endl;	

	} // end for

	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <algorithm>
using namespace std;
int main()
{
    int 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[i] = {a, b};
    }
    sort(AB.begin(), AB.end());
    int sumhon = 0;
    long long summoney = 0;
    for (int i = 0; i < N; i++)
    {
        long long Ai = AB[i].first;
        long long Bi = AB[i].second;
        if (sumhon + Bi >= M)
        {
            summoney += (M - sumhon) * Ai;
            break;
        }
        else
        {
            summoney += Ai * Bi;
            sumhon += Bi;
        }
    }
    cout << summoney << endl;
}

Measured memory_bytes: 1792
n = int(input())
data = []
datb = []
res = 0
import math
for _ in range(n):
    a,b = map(int, input().split())
    data.append(a)
    datb.append(b)

for i in range(n-1, -1, -1):
    a,b = data[i], datb[i]
    a += res
    t = math.ceil(a / b)
    t = b * t
    res += t - a
print(res)


Measured memory_bytes: 59096
#include<cstdio>
#include<algorithm>
using namespace std;
int main(void)
{
	int p1,p2,p3,j1,j2;
	int mnp,mnj,kin;
	scanf("%d %d %d %d %d",&p1,&p2,&p3,&j1,&j2);
	mnp=min(min(p1,p2),p3);
	mnj=min(j1,j2);
	kin=mnp+mnj-50;
	printf("%d\n",kin);
	return 0;
}


Measured memory_bytes: 1020
k = int(input())
ku = k
a = [0]*ku
c = [0]*ku
b = [0]*ku

for i in range(ku):
    if i == 0:
        b[i] = 7%k
    else:
        b[i] = (b[i-1]*10+7)%k

if 0 in b:
    print(b.index(0)+1)
else:
    print(-1)

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

const int Mx = 1 << 10;
char A[Mx][Mx];
int n, m, Ax, Ay, Bx, By,
	 cc = 1, C[Mx][Mx],
	 Nx[4] = {-1, 0, +1, 0},
	 Ny[4] = {0, -1, 0, +1};
set<int> CN[Mx * Mx];
int H[Mx * Mx];

void DFS0(int x, int y) {
//	cout << "DFS " << x << " " << y << "\n";
	C[x][y] = cc;
	for(int d = 0; d < 4; d++) {
		int ux = x + Nx[d], uy = y + Ny[d];
		if(ux < 0 || n <= ux || uy < 0 || m <= uy || A[ux][uy] == '#' || C[ux][uy]) continue;
		DFS0(ux, uy);
	}
	for(int ux = max(x - 2, 0); ux <= min(x + 2, n - 1); ux++)
		for(int uy = max(y - 2, 0); uy <= min(y + 2, m - 1); uy++) {
//			cout << "(" << x << ", " << y << ")-(" << ux << ", " << uy << ") ";
			if(C[ux][uy] && C[ux][uy] != C[x][y]) {
//				cout << "+\n";
				CN[C[ux][uy]].insert(cc);
				CN[cc].insert(C[ux][uy]);
			} 
//			else cout << "-\n";
		}
}

int main() {
	cin >> n >> m >> Ax >> Ay >> Bx >> By;
	Ax--; Ay--; Bx--; By--;
	for(int i = 0; i < n; i++) 
		for(int j = 0; j < m; j++)
			cin >> A[i][j];
	for(int i = 0; i < n; i++) 
		for(int j = 0; j < m; j++)
			if(A[i][j] == '.' && !C[i][j]) {
				DFS0(i, j);
				cc++;
			}
//	for(int i = 0; i < n; i++) {
//		for(int j = 0; j < m; j++)
//			cout << C[i][j] << " ";
//		cout << "\n";
//	}
//	for(int i = 1; i <= 3; i++) {
//		cout << i << ": ";
//		for(int x : CN[i]) cout << x << " ";
//		cout << "\n";
//	}
	H[C[Ax][Ay]] = 1;
	queue<int> Q;
	Q.push(C[Ax][Ay]);
	while(Q.size()) {
		int v = Q.front();
		Q.pop();
		if(v == C[Bx][By]) {
			cout << H[v] - 1;
			exit(0);
		}
		for(int u : CN[v]) 
			if(!H[u]) {
				H[u] = H[v] + 1;
				Q.push(u);
			}
	}
	cout << -1 << "\n";
}


Measured memory_bytes: 76720
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <cstring>
#include <iomanip>
#include <utility>
 
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n) for(int i=1;i<=(n);i++)
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
using namespace std;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    string s,x;
    cin>>n>>s>>x;

    rep(i,n){
      cout<<s[i]<<x[i];
    }
    cout<<'\n';
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <limits>
#include <algorithm>
#include <functional>

using namespace std;

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

	int H, A;
	cin >> H >> A;

	int result = H / A;
	result = (H % A) > 0 ? result + 1 : result;

	cout << result;

	return 0;
}

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

#define all(v) begin(v), end(v)
#define endl   '\n';
#define int    long long
#define pii    pair<int, int>

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

    int a, b; cin >> a >> b;
    cout << a * b << endl;

}

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

int main()
{
    string w;
    cin >> w;
    // sort(w.begin(), w.end());
    int flag = 1;
    rep(i, w.size()){
        int cnt = 0;
        rep(j, w.size()){
            if(w[i] == w[j]){
                cnt++;
            }
        }
        if(cnt%2!=0){flag= 0;}
    }
    if(flag) cout << "Yes" <<endl;
    else cout << "No" <<endl;

    return 0;
}

Measured memory_bytes: 3624
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <sstream>
#include <cassert>
#include <list>
using namespace std;
static const double EPS = 1e-10;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> PI;
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define SZ(a) (int(a.size()))
#define F first
#define S second
const double pi=acos(-1);
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};



typedef struct _state{
  int from,vis;
  double cost;
  _state(double ic,int ifr,int iv):cost(ic),from(ifr),vis(iv){
  };
  bool operator<(const _state&r)const{
    return cost>r.cost;
  };
}state;

vector<PI> V[30];
bool cost[1<<8][30];


main(){
  int n,m,p,a,b;
  while(cin>>n>>m>>p>>a>>b,n){
    --a,--b;
    int ti[n];
    rep(i,n)cin>>ti[i];

    rep(i,m)V[i].clear();

    rep(i,p){
      int x,y,z;
      cin>>x>>y>>z;
      --x,--y;
      V[x].pb(mp(y,z));
      V[y].pb(mp(x,z));
    }

    priority_queue<state> Q;
    Q.push(state(0,a,0));

    //bool cost[1<<n][m];
    memset(cost,0,sizeof(cost));
    double ans=-1;

    while(!Q.empty()){
      int from=Q.top().from,cti=Q.top().vis;
      double ccost=Q.top().cost;
      Q.pop();
      if(cost[cti][from])continue;
      cost[cti][from]=true;
      if(from==b){
        ans=ccost;
        break;
      }

      rep(i,n){
        if(cti>>i&1)continue;
        rep(j,V[from].size()){
          int to=V[from][j].first;
          int cc=V[from][j].second;
          if(cost[cti|1<<i][to])continue;
          double ncost=ccost+1.0*cc/ti[i];
          Q.push(state(ncost,to,cti|1<<i));
        }
      }
    }
    if(ans<0)cout<<"Impossible"<<endl;
    else cout<<ans<<endl;
  }
}

Measured memory_bytes: 7788
#include "bits/stdc++.h"
using namespace std;
const int MOD = 1e9 + 7;
typedef long long lint;
const int INF =1e7;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define trep(i, k, n) for (int i = (k); i < (int)(n); ++i)
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
int main(){
    int n;
    int a;
    cin >> n;
    cin >> a;
    n %= 500;
    if(a>=n){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int digits(int n){
	int an = 0;
	while(n){
		n = n / 10;
		++an;
	}
	return an;
}

int main(){
	int n;
	scanf(" %d",&n);
	int dp[3];
	dp[0] = 9;
	dp[1] = 999-100;
	++dp[1];
	dp[2] = 99999-10000;
	++dp[2];
	int d = digits(n);
	//printf("%d\n",d);
	int ans = 0;
	if(d & 1){
		int le = 1;
		for(int i = 0; i < d-1;++i){le*= 10;}
	//	printf("%d\n",le);
		ans += n - le;
		++ans;
	}
	//printf("here %d\n",ans);
	for(int i = 0; i <= (d/2)-1;++i)
		ans += dp[i];
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
using namespace std;


int main()
{
	
	int a,b;
	cin >> a >> b;

	if (a > b * 2)
		cout << a - b * 2 << endl;
	else
		cout << 0 << endl;
}


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


int main(){
  int N,M;
  cin >> N >> M;
  vector <int> H(N);
  for(int i=0;i<N;i++) cin >> H[i];
  Graph G(N);
  for(int i=0;i<M;i++){
    int A,B;
    cin >> A >> B;
    G.at(A-1).push_back(B-1);
    G.at(B-1).push_back(A-1);
  }
  
  set <int> count;
  
  for(int i=0;i<N;i++){
    int rel = G.at(i).size();
    count.insert(i);
    for(int j=0;j<rel;j++){
      if(H.at(i) <= H.at(G.at(i).at(j))){
        count.erase(i);
        break;
      }
    }
  }
  
  cout << count.size() << endl;
}

Measured memory_bytes: 12072
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;


int main()
{
	ll n,sum=0;
	cin>>n;
	for(ll i=1;i<=n;i++)
	{
		if(i%15!=0&&i%3!=0&&i%5!=0)sum+=i;
	}
	cout<<sum<<endl;
	return 0;
}

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

   typedef long long ll;
   typedef pair<ll, ll> Pii;
   typedef vector<ll> Vi;
   typedef vector<Vi> VVi;

   const double EPS = (1e-7);
   const ll INF =(1e13);
   const double PI = (acos(-1));
   const ll MOD = ll(1e9) + 7;

   #define REP(i, n) for(ll i = 0; i < (ll)(n); i++)
   #define REPR(i, n) for(ll i = n; i > -1; i--)
   #define FOR(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
   #define ALL(x) (x).begin(),(x).end()
   #define SORT(x) sort((x).begin(), (x).end())
   #define RSORT(x) sort((x).rbegin(), (x).rend())
   #define REVERSE(x) reverse((x).begin(), (x).end())
   #define SZ(x) ((ll)(x).size())
   #define pb push_back
   #define mp make_pair

   //chmax(a, b): a>bならaをbで更新　更新したときにtrueを返す
   //chmin(a, b): a<bならaをbで更新　更新したときにtrueを返す
   template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
   template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

   #define dump(x) cerr<< #x << "= " << (x) << endl;

   ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
   ll pow(ll a, ll b){if (b == 0) return 1; else if (b % 2 == 0) return pow(a * a, b / 2); else return pow(a * a, b / 2) * a;}
   ll pow(ll a, ll b, ll m){if (b == 0) return 1; else if (a == 0) return 0; else if (b % 2 == 0) return (pow((a * a) % m, b / 2, m) % m); else return (pow((a * a) % m, b / 2, m) * a) % m;}
   ll residue(ll a, ll m){return ((a % m) + m) % m;};

   ll dx[4]={1,0,-1,0};
   ll dy[4]={0,1,0,-1};

ll h, w;
bool in_grid(ll x, ll y){
  return (0 <= x && x < h && 0 <= y && y < w);
}
int main(){
  cin >> h >> w;
  VVi grid(h, Vi(w, INF));
  REP(i, h) REP(j, w){
    char c; cin >> c;
    if(c == '#') grid[i][j] = 0;
  }
  queue<Pii> q;
  REP(i, h) REP(j, w) if(!grid[i][j]) q.push(mp(i, j));
  while(!q.empty()){
    Pii p = q.front(); q.pop();
    ll x = p.first, y = p.second;
    REP(k, 4){
      if(in_grid(x + dx[k], y + dy[k])) if(chmin(grid[x + dx[k]][y + dy[k]], grid[x][y] + 1)) q.push(mp(x + dx[k], y + dy[k]));
    }
  }
  ll ans = 0;
  REP(i, h) REP(j, w) chmax(ans, grid[i][j]);
  // REP(i, h){
  //   REP(j, w){
  //     printf("%lld\t", grid[i][j]);
  //   }
  //   printf("\n");
  // }
  cout << ans << endl;

}


Measured memory_bytes: 24500
#include <bits/stdc++.h>
using namespace std;
long long ans = 0;
unordered_set<string>st;
vector<string> split(string &s) {
  stringstream ss(s);
  string st;
  vector<string>splitted;
  while(getline(ss, st, '+')) {
    splitted.push_back(st);
  }
  return splitted;
} 
void calc(string &s) {
  auto it = st.find(s);
  if(it != st.end())return;
  st.insert(s);
  vector<string> splitted = split(s);
  for(auto ss : splitted) {
    long long cur = 0;
    for(auto c : ss) {
      cur = cur * 10 + (c - '0');
    }
    ans+= cur;
  }
}
void go(string s) {
  calc(s);
  // cout << s << endl;
  for(int i = 1; i < s.size(); ++i) {
    if(s[i] != '+' && s[i - 1] != '+') {
      // cout << s << " -> " <<  s.substr(0, i)  << " + " <<  s.substr(i, string::npos) << endl;
      go(s.substr(0, i) + "+" + s.substr(i, string::npos));
    }
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);

  string s;
  cin >> s;
  go(s);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
H = list(map(int, input().split()))
BAD = []
for i in range(m):
    a, b = map(int, input().split())
    if H[a-1] > H[b-1]:
        BAD.append(b-1)
    elif H[a-1] < H[b-1]:
        BAD.append(a-1)
    else:
        BAD.append(a-1)
        BAD.append(b-1)

ALL = []
for i in range(n):
    ALL.append(i)
# print(ALL, BAD)
print(len(set(BAD)^set(ALL)))

Measured memory_bytes: 31864
#include<iostream>
using namespace std;
const int INFTY =1<<21;
int L[200005],R[200005];

void merge(int A[],int left,int mid,int right){
    int n1=mid-left;
    int n2=right-mid;
    for(int i=0;i<n1;i++) L[i]=A[left+i];
    for(int i=0;i<n2;i++) R[i]=A[mid+i];
    L[n1] =R[n2]=INFTY;
    int i=0,j=0;
    for(int p=left;p<right;p++){
        if(L[i]<=R[j]) A[p]=L[i++];
        else A[p]=R[j++];
    }
}

void sort(int A[],int left,int right){
    if(left+1<right){
        int mid=(left + right)/2;
        sort(A,left,mid);
        sort(A,mid,right);
        merge(A,left,mid,right);
    }
}

int main(){
    int n,max=0,p;
    cin>>n;
    int A[200005];
    for(int i=0;i<n;i++){
        cin>>A[i];
        if(A[i]>max){
            max=A[i];
            p=i;
        }
    }
    sort(A,0,n);
    for(int i=0;i<n;i++){
        if(i==p) cout<<A[n-2]<<endl;
        else cout<<A[n-1]<<endl;
    }
    return 0;
}

Measured memory_bytes: 3200
import sys
MAX_INT = int(10e10)
MIN_INT = -MAX_INT
mod = 1000000007
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

A,B = IL()

print(max(0,A-B))

Measured memory_bytes: 3060
n, m, l = map(int, input().split())

matrix1 = []
matrix2 = []

for i in range(n):
    row1 = list(map(int, input().split()))
    matrix1.append(row1)

#print(matrix1)

for j in range(m):
    row2 = list(map(int, input().split()))
    matrix2.append(row2)

#print(matrix2)

matrix3 = []
for i in range(n):
    row3 =[]
    for k in range(l):
        a = 0
        for j in range(m):
            a += matrix1[i][j]*matrix2[j][k]
        row3.append(a)
    matrix3.append(row3)

for row in matrix3:
    print(*row)


Measured memory_bytes: 7060
N, M = map(int, input().split())
P = [int(p) for p in input().split()]

Par = [int(i) for i in range(N+1)]
Rank = [0 for i in range(N+1)]

def find(i, Par):
    if Par[i] == i:
        return i
    else:
        Par[i] = find(Par[i], Par)
        return Par[i]
def Unite(x, y):
    rx, ry = find(x, Par), find(y, Par)
    if rx == ry: return
    if Rank[rx] < Rank[ry]: Par[rx] = ry
    else: 
        Par[ry] = rx
        if Rank[rx] == Rank[ry]: Rank[rx] += 1
def Same(x, y): return find(x, Par) == find(y, Par)
    

for i in range(M):
    x, y = map(int, input().split())
    x, y = min(x, y), max(x, y)
    Unite(x, y)
    
Count = 0
for i in range(N):
    Count += (1 if Same(P[i], i+1) else 0)
print(Count)

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

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;

const int T = 100005;
int r[35][100005] = {};
vector<int> ans(T, 0);

int main()
{
    int n, c;
    cin >> n >> c;
    rep(i, n)
    {
        int s, t, ch;
        cin >> s >> t >> ch;
        --ch;
        r[ch][s]++;
        r[ch][t]--;
    }

    rep(i, c) rep(j, T - 1) r[i][j + 1] += r[i][j];

    rep(i, c)
    {
        rep(j, T - 1)
        {
            if (r[i][j + 1] > 0 && r[i][j] == 0)
                r[i][j]++;
        }
    }

    rep(i, c) rep(j, T) ans[j] += r[i][j];

    OP(*max_element(ALL(ans)));
    return 0;
}

Measured memory_bytes: 12928
inf = 9999999999
N, Ma, Mb = map(int, input().split())
d = [{} for i in range(N + 1)]
for i in range(N):
    a, b, c = map(int, input().split())
    for (j, k) in d[i]:
        d[i + 1][j, k] = d[i][j, k]
    d[i + 1][a, b] = min(c, d[i].get((a, b), inf))
    for (j, k) in d[i]:
        d[i + 1][j + a, k + b] = min(d[i][j, k] + c, d[i].get((j + a, k + b), inf))
ans = inf
for (j, k) in d[N]:
    if j * Mb == k * Ma:
        ans = min(ans, d[N][j, k])
if ans == inf:
    ans = -1
print(ans)

Measured memory_bytes: 39808
#include <iostream>

using namespace std;

int main() {
    int n;
    cin>>n;
    int result = 0;
    for(int i=1;i<=n;i++) {
        if(i%2==1) {
            int br = 0;
            for(int j=1;j<=i;j++) {
                if(i % j ==0) br++;
            }
            if(br==8) result++;
        }
    }
    cout<<result;
    return 0;
}


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

int main(){
  int P[2];
  for(int i = 0; i < 2; i++){
    vector<int> point(10);
    for(int j = 0; j < 10; j++){
      cin >> point[j];
    }
    sort(point.rbegin(), point.rend());
     P[i] = point[0] + point[1] + point[2];
  }
  cout << P[0] << " " << P[1] << endl;
}

Measured memory_bytes: 3088
import java.util.*;

class Main {
    public static void main(String[] args) throws java.lang.Exception {
        Scanner sc = new Scanner(System.in);
        double n = sc.nextInt();
        double d = sc.nextInt();
        int ret = (int) (n / (d * 2 + 1));
        if (n % (d * 2 + 1) != 0) {
            ret++;
        }
        System.out.println(ret);
        sc.close();
    }
}


Measured memory_bytes: 23252
from sys import exit, stdin
N = int(stdin.readline().rstrip())
for i in range(1, 3501):
    for j in range(1, 3501):
            div = 4*i*j-N*i-N*j
            if div <= 0:
                continue
            if (N*i*j) % div == 0:
                print(i, j, (N*i*j) // div)
                exit()

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

int main() {
  int n, a, m;
  bool c = true;
  cin >> n >> m;
  rep(i, n-1) {
    cin >> a;
    if(a-m<-1) {
      c = false;
      break;
    } else if(a > m) {
      m = a;
    }
  }
  cout << (c ? "Yes" : "No") << endl;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef pair<double, double> pdd;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef vector<pii> vii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
//const int mod = ;

int main() {
  std::ios::sync_with_stdio(false); std::cin.tie(0);
  int a, b, m;
  cin >> a >> b >> m;
  vi c1(a), c2(b);
  int mia = 1e9, mib = 1e9;
  for (int i = 0; i < a; ++i) {
    cin >> c1[i];
    mia = min(mia, c1[i]);
  }
  for (int i = 0; i < b; ++i) {
    cin >> c2[i];
    mib = min(mib, c2[i]);
  }
  int mi = mia + mib;
  for (int i = 0; i < m; ++i) {
    int x, y, z;
    cin >> x >> y >> z;
    --x; --y;
    mi = min(mi, c1[x] + c2[y] - z);
  }
  cout << mi << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, from, to) for (int i = from; i < (to); ++i)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
using ll = long long;
using vin=vector<int>;
using vll=vector<ll>;
using P = pair<int, int>;
const int inf=1e9+7;
const ll INF=1e18;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

int main() {
  string s;
  cin>>s;
  bool ans=true;
  rep(i,0,3){
   if(s[i]==s[i+1]) ans=false; 
  }
  if(ans) cout<<"Good"<<endl;
  else cout<<"Bad"<<endl;
}



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

int main(){
    int n;
    cin >> n;
    vector<ll> a(n);
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    sort(a.begin(),a.end());
    ll sum = 0, l = 0;
    for(int i = 0; i < n-1; i++){
        sum += a[i];
        if(sum*2 < a[i+1]){l = i+1;}
    }
    cout << n - l << endl;

    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main(void){
    long long n;
    cin >> n;
    vector<long long> a(n), b(n);
    for(long long i=0; i<n; i++){
        cin >> a[i];
    }
    for(long long i=0; i<n; i++){
        cin >> b[i];
    }
    long long sum=0;
    for(long long i=0; i<n; i++){
        sum += b[i] - a[i];
    }
    long long aplus=0;
    long long bplus=0;
    for(long long i=0; i<n; i++){
        if(a[i]>=b[i]){
            bplus += a[i] - b[i];
        }else{
            aplus += ceil((b[i]-a[i])/2.0);
        }
    }

    if(aplus <= sum && bplus<=sum){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 384
fn main() {
    let n: usize = {
        let mut buf = String::new();
        std::io::stdin().read_line(&mut buf).unwrap();
        buf.trim_end().parse().unwrap()
    };
    let a: Vec<usize> = {
        let mut buf = String::new();
        std::io::stdin().read_line(&mut buf).unwrap();
        let iter = buf.split_whitespace();
        iter.map(|x| x.parse().unwrap()).collect()
    };

    let p = a[0] + a[1];
    let q = (2..n).fold(0, |sum, i| sum ^ a[i]);
    if p < q || (p - q) % 2 == 1 {
        println!("-1");
        return;
    }
    let mut p = (p - q) >> 1;
    if (p & q) > 0 || p > a[0] {
        println!("-1");
        return;
    }

    for i in (0..40).rev() {
        let b = 1 << i;
        if q & b > 0 && p + b <= a[0] {
            p += b;
        }
    }

    let ans = a[0] - p;
    if ans == a[0] {
        println!("-1");
    } else {
        println!("{}", ans);
    }
}

Measured memory_bytes: 2168
N = gets.to_i
x = []
y = []
t = []
N.times do
  line = gets.split.map(&:to_i)
  t << line[0]
  x << line[1]
  y << line[2]
end
s = 0
while s < N
  if s == 0
      if x[s]+y[s] > t[s]
        puts "No"
        exit
      end
      if (x[s]+y[s])%2 != t[s]%2
        puts "No"
        exit
      end
  else
    if((x[s]-x[s-1]).abs+(y[s]-y[s-1]).abs) > t[s]-t[s-1]
      puts "No"
      exit
    end
    if(((x[s]-x[s-1]).abs+(y[s]-y[s-1]).abs)%2 != (t[s]-t[s-1])%2)
      puts "No"
      exit
    end
  end
  s+=1
end
puts "Yes"

Measured memory_bytes: 4248
N, T = map(int, input().split())
AB = [tuple(map(int, input().split())) for _ in range(N)]
AB.sort()
DP = [[0] * (T + 1) for _ in range(N + 1)]
for n in range(1, N + 1):
    a, b = AB[n - 1]
    for t in range(1, T + 1):
        if t - a >= 0:
            DP[n][t] = max(DP[n - 1][t - a] + b, DP[n - 1][t])
        else:
            DP[n][t] = DP[n - 1][t]

T = [DP[n][T - 1] + AB[n][1] for n in range(N)] + [DP[N][T]]
print(max(T))


Measured memory_bytes: 117976
#include <iostream>
#include <set>
#include <utility>
using namespace std;

class torio{
public:
  long long int first, second, third;
  
  torio(long long int a,
        long long int b,
        long long int c)
    :first(a),
     second(b),
     third(c)
  {}

  bool operator<(const torio& another) const {
    if (first != another.first)
      return first < another.first; 
    if (second != another.second)
      return second < another.second;
    return third < another.third;
  }
  
};

int main(void){
  long long int a, b, c;
  cin >> a >> b >> c;

  int count;
  set<torio> used;
  for(count = 0; (a % 2 == 0) && (b % 2 == 0) && (c % 2 == 0); ++count){
    long long int tmp_a = a / 2;
    long long int tmp_b = b / 2;
    long long int tmp_c = c / 2;
    a += tmp_b + tmp_c;
    b += tmp_c + tmp_a;
    c += tmp_a + tmp_b;


    
    if(used.count(torio(a, b, c)) != 0
       || used.count(torio(a, c, b)) != 0
       || used.count(torio(b, a, c)) != 0
       || used.count(torio(b, c, a)) != 0
       || used.count(torio(c, a, b)) != 0
       || used.count(torio(c, b, a)) != 0){
      cout << -1 << endl;
      return 0;
    }

    used.insert(torio(a, b, c));
  }

  cout << count << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr long long MOD = 1000000007;
constexpr long long INF = 1LL << 60;
const long double PI = acosl(-1.0);
constexpr long double EPS = 1e-11;
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int main(){
    ll n, k;
    cin >> n >> k;
    vector<ll> mp(n+1,0);
    for (ll i = 0; i < n;i++){
        ll t;
        cin >> t;
        mp[t]++;
    }
    ll ans = 0;
    ll siz=0;
    for(auto i:mp)
        if (i!=0) siz++;
    sort(mp.begin(), mp.end());
    for(auto i:mp){
        if (siz <= k) break;
        if (i!=0) {
            siz--;
            ans += i;
        }
        if (siz <= k) break;
    }
    cout << ans << endl;
}

Measured memory_bytes: 4728