akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define fs first
#define sc second
#define mp make_pair
using namespace std;
typedef pair<pair<int,int>,int> pii;

bool l(const pii &a,const pii &b){
  int s1 = a.fs.sc*b.fs.fs, s2 = a.fs.fs*b.fs.sc;
  if(s1==s2)return a.sc<b.sc;
  if(a.fs.fs==0)return false;
  if(b.fs.fs==0)return true;
  return s1<s2;
}

int main(){
  int h,w;
  string f[999];
  cin >> h >> w;

  vector<pii> v;
  rep(i,h){
    cin >> f[i];
    rep(j,w){
      if( (i==0&&f[i][j]=='#') || (i!=0&&f[i][j]!=f[i-1][j]) ){
	v.push_back(mp(mp(j,h-i),-1));
	v.push_back(mp(mp(j+1,h-i),1));
      }
      if( (j==w-1&&f[i][j]=='#') || (j!=w-1&&f[i][j]!=f[i][j+1])){
	v.push_back(mp(mp(j+1,h-i),-1));
	v.push_back(mp(mp(j+1,h-i-1),1));
      }
    }
  }

  int res = 0, tmp = 0;
  sort(v.begin(),v.end(),l);
  rep(i,v.size()){
    tmp += v[i].sc;
    res = max(res,tmp);
  }
  cout << (res+3)/2 << endl;
}

Measured memory_bytes: 15364
#include <stdio.h>
int main(void){
    int a,b,d,r;
    double f;
    scanf("%d",&a);
    scanf("%d",&b);
    
    d=a/b;
    r=a%b;
    f=(double)a/(double)b;
    
    printf("%d %d %.5lf\n",d,r,f);
    
    return 0;

}


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

double dp[303][303][303];
int n, cnt[4], i, x, vs[303][303][303];
double solve(int a,int b,int c){
    if(a==0&&b==0&&c==0) return 0.0;
    else if(vs[a][b][c]) return dp[a][b][c];
    vs[a][b][c]=1; dp[a][b][c]=1.0;
    if(a) dp[a][b][c] += a/(double)n*solve(a-1,b,c);
    if(b) dp[a][b][c] += b/(double)n*solve(a+1,b-1,c);
    if(c) dp[a][b][c] += c/(double)n*solve(a,b+1,c-1);
    dp[a][b][c] *= (n)/(double)(a+b+c);
    return dp[a][b][c];
}
int main(){
    for(scanf("%d",&n),i=1;i<=n;i++){
        scanf("%d",&x);
        cnt[x]++;
    }
    printf("%.10f\n",solve(cnt[1],cnt[2],cnt[3]));
    return 0;
}


Measured memory_bytes: 325888
#include <iostream>

using namespace std;
int a[51];
long long int dp[51][5001] = {};
int main() {
    int n,avg;
    cin >> n;
    cin >> avg;
    for(int i = 1; i <= n; i++){
        cin >> a[i];
        a[i] -= avg;
    }
    dp[0][2500] = 1;
    for(int i = 1; i<=n; i++){
        for(int j = 0; j<5001; j++){
            if(j-a[i]>=0){
                dp[i][j] = dp[i-1][j-a[i]] + dp[i-1][j];
            }else {
                dp[i][j] = dp[i-1][j];
            }
        }
    }
    cout << dp[n][2500]-1 << "\n";
    return 0;
}

Measured memory_bytes: 2176
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <math.h>
#include <iomanip>
#include <bitset>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <utility>
#include <set>
using namespace std;
typedef long long int ll;
typedef long double ld;
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; }
const long long INF = 1LL << 60;
typedef pair<ll,ll> pairs;
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}
#define MAX_N 1000100
bool x[MAX_N];
ll num[MAX_N];
ll fibl[MAX_N]={0};
// 四方向への移動ベクトル
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
 
ll fib(ll a){
    if (fibl[a]!=0)return fibl[a];
    if (a==0){
        return 0;
    }else if (a==1){
        return 1;
    }
    return fibl[a]=fib(a-1)+fib(a-2);
}
 
ll eratosthenes(ll n) {
    int p = 0;
    for (ll i=0; i<=n; ++i) x[i] = true;
    x[0] = x[1] = false;
    for(int i=2; i<=n; ++i) {
        if(x[i]) {
            p++;
            for(int j=2*i; j<=n; j+=i) x[j] = false;
        }
        
        num[i] = p;
    }
    return p;
}
 
ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}
 
ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}


int main(){
    ll x;
    cin>>x;
    ll flag=0;
    for(ll i=1;i<=x;++i){
        for(ll j=2;j<10;++j){
            if(pow(i,j)<=x){
                if(pow(i,j)>flag){
                    flag=pow(i,j);
                }
            }
        }
    }
    cout<<flag<<endl;
}


Measured memory_bytes: 512
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <functional>
#include <map>
#include <queue>
#include <stdio.h>
    
#define REP(i,n) for(int (i)=0; (i)<(n); (i)++)

using namespace std;
using ll = long long;
using P = pair<int, int>;
using TP = tuple<ll, ll, ll>;
ll MOD = 1e9+7;
const int INF = 1e6;
const ll LINF = (ll)1e19;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll N, T;
    cin >> N >> T;
    vector<ll> A(N);
    vector<ll> Amin(N);
    REP(i, N){
        cin >> A[i];
    }
    ll tmpmin = A[0];
    REP(i, N){
        Amin[i] = min(A[i], tmpmin);
        tmpmin = Amin[i];
    }
    
    vector<ll> d;
    ll m = 0;
    ll mc = 0;
    for(int i = N-1; i > 0; i--){
            ll tmp = A[i]-Amin[i-1];
            if(tmp > m){
                m = tmp;
                mc = 1;
            }else if(tmp == m){
                mc++;
            }
    }
    cout << mc << endl;
    return 0;    
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
const int mod = 1000000007;

int main(){
  int n;
  cin >> n;
  vector<ll> a(n), cnt(n + 1);
  rep(i, n) {
    cin >> a[i];
    cnt[a[i]]++;
  }
  vector<ll> comb(n + 1);
  ll sum = 0;
  rep(i, n + 1) {
    comb[i] = cnt[i] * (cnt[i] - 1) / 2;
    sum += comb[i];
  }
  rep(i, n) {
    ll cur = a[i];
    ll ans = sum;
    ans -= comb[cur];
    ans += (cnt[cur] - 1) * (cnt[cur] - 2) / 2;
    cout << ans << endl;
  }
}

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

int main() {
  ll N; cin >> N;
  ll x[N], y[N], h[N];
  ll x0, y0, h0;
  for (ll i = 0; i < N; i++) {
    cin >> x[i] >> y[i] >> h[i];
    if (h[i] > 0) {x0 = x[i]; y0 = y[i]; h0 = h[i];}
  }
  ll CX, CY, height;
  for (ll cx = 0; cx <= 100; cx++) {
    for (ll cy = 0; cy <= 100; cy++) {
      ll H = h0 + abs(cx-x0) + abs(cy-y0);
      bool ok = true;
      for (ll i = 0; i < N; i++) {
        if (h[i] != max(0LL, H-abs(cx-x[i])-abs(cy-y[i]))) {
          ok = false;
        }
      }
      if (ok) {CX = cx; CY = cy; height = H;}
    }
  }
  cout << CX << " " << CY << " " << height << endl;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Rep(i, n) for (int i = 1; i <= (int)(n); i++)
#define fore(i, a) for (auto &i:a)
#define ll long long
#define pll vector<pair<ll, ll>>
#define mod 1000000007
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define popcount(x) __builtin_popcountll(x)

using namespace std;

const long double PI = acos(-1);

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;}
ll stringcount(string s, char c){return count(s.cbegin(), s.cend(), c);}

bool isInteger(double x){return floor(x) == x;}

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

	int a,b,c,d;cin >> a >> b >> c >> d;

	cout << min(a,b)+min(c,d) << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		new Main().run();
	}

	void run() {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		int a[] = new int[n];
		for(int i=0; i<n; i++) a[i] = sc.nextInt();
		sc.close();

		int ans = 1, val = k-1;
		while(k < n) {
			k += val;
			ans++;
		}
		System.out.println(ans);
	}
	
}

Measured memory_bytes: 48844
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
const ll INF=1e18;


int main() {
  int n,ans=0,t=-10000000;
  cin>>n;
  vector<P> p(n);
  rep(i,n){
    int a,b;
    cin >> a>>b;
    p[i]=P(a+b,a-b);
  }
  sort(p.begin(),p.end());
  rep(i,n){
    if(t<=p[i].second){
      t=p[i].first;
      ans++;
    }
  }
  cout <<ans<<endl;
}

Measured memory_bytes: 4060
import sys

sys.setrecursionlimit(10 ** 8)
ini = lambda: int(sys.stdin.readline())
inl = lambda: [int(x) for x in sys.stdin.readline().split()]
ins = lambda: sys.stdin.readline().rstrip()
debug = lambda *a, **kw: print("\033[33m", *a, "\033[0m", **dict(file=sys.stderr, **kw))


X, K, D = inl()


def solve():
    if X >= K * D:
        return X - K * D
    if X <= -K * D:
        return abs(X + K * D)
    y = X + K * D
    assert y > 0
    r = y // (2 * D)

    ans = y
    for k in range(r - 10, r + 10):
        if k < 0 or k > K:
            continue
        z = y - k * 2 * D
        ans = min(ans, abs(z))

    return ans


print(solve())


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

int main(){
  int a,b,c;
  cin >> a >> b >> c;
  if ((a == b && a == c && b == c) || (a != b && a != c && b != c)) {
    cout << "No" << endl;
  } else {
    cout << "Yes" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (int64_t)(n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

#define chmax(a, b) (a) = max(a, b)
#define chmin(a, b) (a) = min(a, b)

int main() {
  int N;
  cin >> N;
  vector<int> d(N);
  rep(i, N) { cin >> d[i]; }

  int M;
  cin >> M;
  vector<int> t(M);
  rep(i, M) { cin >> t[i]; }

  if (N < M) {
    cout << "NO" << endl;
    return 0;
  }

  sort(d.begin(), d.end());
  sort(t.begin(), t.end());

  int s = 0;
  int j = 0;
  rep(i, M) {
    while (j < N && d[j] < t[i]) {
      j++;
    }
    if (d[j] == t[i]) {
      s++;
      j++;
    }
  }
  cout << (s == M ? "YES" : "NO") << endl;
  return 0;
}

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

#define BR "\n"
#define SP " "
#define SHOW(x) for(int i = 0; i < x.size(); i++) { cout << x[i] << SP; } cout << BR;
#define SHOW2(x) for(int j = 0; j < x.size(); j++) { SHOW(x[j]); } cout << BR;

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

  vector<ll> l(2 * N + 2, 0);
  vector<ll> r(2 * N + 2, 0);

  vector<ll> c(2 * N + 2, 0);
  ll check = 0;

  for (int i = 0; i < N; i++) {
    if ( s[2 * i] == 'B' ) {
      check++;
    } else {
      check--;
    }
    c[2 * i] = check;

    if (s[2 * i + 1] == 'W') {
      check++;
    } else {
      check--;
    }
    c[2 * i + 1] = check;
  }
  if (check != 0){
    cout << 0;
    return 0;
  }

  ll ans = 0;

  ll MOD = 1e9 + 7;
  ll temp = 1;
  for (int i = 1; i <= N; i++) {
    temp = (temp * i) % MOD;
  }
  ans = temp;
  for (int i = 2 * N; i > 0; i--) {
    if (c[i-1] < c[i]) {
      ans = (ans * c[i]) % MOD;
    }
  }

  cout << ans << "\n";
  return 0;
}

Measured memory_bytes: 5252
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ldb = long double;
using pa = pair < ll, ll >;
using vec = vector < ll >;
#define pb push_back
#define F  first
#define S  second
#define int ll
#define f(i,x,n) for(ll i=x;i<n;i++) 
#define all(c) c.begin(),c.end()
#define edl "\n"
#define ceils(s,n) (s+n-1)/n
#define str string
#define add insert
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL)
const ll LINF = LLONG_MAX;

int solution(vector<int>& A, int k) 
{ 
    
    const int N = A.size(); 


    // bases cases 
    if (N < k || N < 1 || k < 1) 
        return 0; 
    if (N == k) 
        return 1; 
 
    // Prepare arrays for recursion 
    vector<int> v1(N, 0); 
    vector<int> v2(N, 0); 
    vector<int> v3(N+5, 0); 

    // initiate separately for k = 1 
    // intiate the last element 
    v2[N - 1] = 1; 
    v3[A[N - 1] - 1] = 1; 

    // initiate all other elements of k = 1 
    for (int i = N - 2; i >= 0; i--) { 

 
        v2[i] = v2[i + 1]; 

       
        if (v3[A[i] - 1] == 0) { 
            v2[i]++; 
            v3[A[i] - 1] = 1; 
        } 
    } 


    // iterate for all possible values of K 
    for (int j = 1; j < k; j++) { 
     
      
        fill(v3.begin(), v3.end(), 0); 

        // fill(v1.begin(), v1.end(), 0) 
        // the last must be 0 as from last no unique 
        // subarray can be formed 
        v1[N - 1] = 0; 

        // Iterate for all index from which unique 
        // subsequences can be formed 
        for (int i = N - 2; i >= 0; i--) { 
            
            v1[i] = v1[i + 1]; 

            v1[i] = v1[i] + v2[i + 1]; 

            v1[i] = v1[i] - v3[A[i] - 1]; 

           
            v3[A[i] - 1] = v2[i + 1]; 
        } 

       
        v2 = v1; 
    } 

    return v1[0]; 
} 

// Function to push the vector into an array 
// and print all the unique subarrays 
void solve(int a[], int n, int k) 
{ 
    vector<int> v; 

    // fill the vector with a[] 
    v.assign(a, a + n); 
    // for(auto s:v){
    //     cout<<s<<" ";
    // }

    // Function call to print the count 
    // of unique susequences of size K 
    cout << solution(v, k); 
} 

int32_t main() {
    fast();
    int n,k=3;
    cin >> n;
    string s;
    cin >> s;
    int a[s.size()]={0};
    
    for(int i=0;s[i]!='\0';i++){
        a[i]=s[i]-47;
     
    }

    solve(a,n,k);


    cerr << "\nTime taken: " << int((clock() * 1000.) / CLOCKS_PER_SEC) << "ms\n";
    return 0;
}
 


Measured memory_bytes: 1536
/**
 ____ ____ ____ ____ ____
||a |||t |||o |||d |||o ||
||__|||__|||__|||__|||__||
|/__\|/__\|/__\|/__\|/__\|

**/

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

ll n;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> n;
    int cntc = 0;
    int first = 0;
    bool all9 = true;
    while(n > 0)
    {
        cntc++;
        if(n > 9)
            all9 &= (n % 10 == 9);
        first = n % 10;
        n /= 10;
    }
    if(all9)
        cout << first + (cntc - 1) * 9 << "\n";
    else
        cout << first - 1 + (cntc - 1) * 9 << "\n";
    return 0;
}


Measured memory_bytes: 3612
n = int(input())
h = list(map(int, input().split()))
progress = [0]*n
ans = 0
MAX = max(h)

for i in range(MAX):
  for j in range(n):
    if progress[j] < h[j]:
      progress[j] += 1
      if j+1 >= n:
        ans += 1
      else:
        if progress[j+1] == h[j+1]:
          ans += 1

print(ans)


Measured memory_bytes: 3060
s = gets.to_s.chomp

result = true
unless s[0] == 'A'
    result = false
end

cntC = 0
for i in 2..s.length-2 do
    if s[i] == 'C'
        cntC += 1
    end
end

for i in 1...s.length do
    if s[i].ord >= 65 && s[i].ord <= 90 && i != s.index('C')
        result = false
    end
end

if result && cntC == 1
    puts "AC"
else
    puts "WA"
end


Measured memory_bytes: 3836
#include "bits/stdc++.h"
using namespace std;
#define mod 1000000007
#define ll long long int
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)

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

    int n;
    cin >> n;
    vector<int> a(n);
    ll sum=0;
    F0R(i,n) {
      cin >> a[i];
      sum+=a[i];
      sum%=mod;
    }
    ll ans = 0;
    F0R(i,n) {
      sum-=a[i];
      if(sum<0) sum+=mod;
      ans += a[i]*sum;
      ans = ans % mod;
    }
    cout << ans;

    return 0;
  }

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

using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

int main() {

    ll n, a, b; cin >> n >> a >> b;

    vector<ll> x(n);
    for (ll i = 0; i < n; ++i) {
        cin >> x[i];
    }

    ll ans = 0;
    for (ll i = 1; i < n; ++i) {
        ll t = x[i] - x[i-1];

        if (t * a > b) {
            ans += b;
        } else {
            ans += t * a;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
vector<string>v;
double d(double a, double b, double c, double d) { return sqrt((a - c) * (a - c) + (b - d) * (b - d)); }
double f(string a, string b, string c) {
	double a1, a2, b1, b2, c1, c2;
	int n = 1; bool b00l = 0; double pk = 1, pk1 = 1, p = 0;
	a += ','; b += ','; c += ',';
	for (char ch : a) {
		if (ch == ',') {
			p *= pk1;
			if (n == 1)a1 = p;
			if (n == 2)a2 = p;
			n++; if (n > 2)n %= 2; b00l = 0; pk = 1; p = 0; pk1 = 1;
		}
		else if (ch == '.') {
			b00l = 1; pk /= 10;
		}
		else if (ch == '-') {
			pk1 = -1;
		}
		else if (b00l) {
			p += (double)(ch - '0') * pk;
			pk /= 10;
		}
		else {
			p *= 10; p += (double)(ch - '0');
		}
	}
	for (char ch : b) {
		if (ch == ',') {
			p *= pk1;
			if (n == 1)b1 = p;
			if (n == 2)b2 = p;
			n++; if (n > 2)n %= 2; b00l = 0; pk = 1; p = 0; pk1 = 1;
		}
		else if (ch == '.') {
			b00l = 1; pk /= 10;
		}
		else if (ch == '-') {
			pk1 = -1;
		}
		else if (b00l) {
			p += (double)(ch - '0') * pk;
			pk /= 10;
		}
		else {
			p *= 10; p += (double)(ch - '0');
		}
	}
	for (char ch : c) {
		if (ch == ',') {
			p *= pk1;
			if (n == 1)c1 = p;
			if (n == 2)c2 = p;
			n++; if (n > 2)n %= 2; b00l = 0; pk = 1; p = 0; pk1 = 1;
		}
		else if (ch == '.') {
			b00l = 1; pk /= 10;
		}
		else if (ch == '-') {
			pk1 = -1;
		}
		else if (b00l) {
			p += (double)(ch - '0') * pk;
			pk /= 10;
		}
		else {
			p *= 10; p += (double)(ch - '0');
		}
	}
	double ad = d(b1, b2, c1, c2), bd = d(c1, c2, a1, a2), cd = d(a1, a1, b1, b2);
	double z = (ad + bd + cd) / 2;
	return sqrt(z * (z - ad) * (z - bd) * (z - cd));
}
signed main() {
	string s; double ans = 0;
	while (cin >> s) {
		v.push_back(s);
		if (v.size() >= 3)ans += f(v[0], v.back(), v[v.size() - 2]);
	}
	cout << ans << endl;
}


Measured memory_bytes: 3284
N, M = map(int, input().split())
peaks = list(map(int, input().split()))
ng_peaks = set([])
for j in range(M):
    A_j, B_j = map(int, input().split())
    if peaks[A_j-1] >= peaks[B_j-1]:
        ng_peaks.add(B_j)
    if peaks[A_j-1] <= peaks[B_j-1]:
        ng_peaks.add(A_j)
print(N-len(ng_peaks))

Measured memory_bytes: 20100
//templates
#include <iostream>
#include <algorithm>
#include <string>
#include <numeric>
#include <vector>
#include <unordered_map>
#include <map>
#include <cmath>
#include <iomanip>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define ALL(x) (x).begin(),(x).end()
#define sort_key(struct_name,key_name) [](const struct_name &x, const struct_name &y){return x.key_name < y.key_name;}
typedef long long ll;
using namespace std;

//main
int main(){
    struct lists{
        int number;
        int town;
        int year;
        int count;
    };
    int N,M;
    vector<int> c(N,1);
    cin >> N >> M;
    vector<lists> L(M);
    rep(i,M){
        L[i].number = i;
        L[i].count = 0;
        cin >> L[i].town >> L[i].year;
    }
    sort(ALL(L),sort_key(lists,year));
    rep(i,M){
        L[i].count = c[L[i].town];
        c[L[i].town] += 1;
    }
    sort(ALL(L),sort_key(lists,number));
    rep(i,M){
        cout << setfill('0') << right << setw(6) << L[i].town;
        cout << setfill('0') << right << setw(6) << L[i].count << endl;
    }
}


Measured memory_bytes: 19456
#include<stdio.h>
int main()
{
	int a,b[10000],i=0;
	while(scanf("%d",&a)!=EOF)
	{
		if(a==0) break;
		i++;
		b[i]=a;
	}
	for(int k=1;k<=i;k++)
		printf("Case %d: %d\n",k,b[k]);
	return 0;
}


Measured memory_bytes: 2044
"use strict";
var input=require("fs").readFileSync("/dev/stdin","utf8");
var cin=input.split(/ |\n/),cid=0;
function next(a){return a?cin[cid++]:+cin[cid++];}
function nexts(n,a){return a?cin.slice(cid,cid+=n):cin.slice(cid,cid+=n).map(a=>+a);}
function nextm(h,w,a){var r=[],i=0;if(a)for(;i<h;i++)r.push(cin.slice(cid,cid+=w));else for(;i<h;i++)r.push(cin.slice(cid,cid+=w).map(a=>+a));return r;}
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill().map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill().map(x=>"+r+")";return eval(r);}

var myOut = main();
if(myOut !== undefined)console.log(myOut);
function main(){
  var n = next(1);
  var nl = n.length;
  while(n[nl-1] === "0")nl--;
  var ans1 = 2, ans2 = 0;
  for(var i = nl; i--;){
    var x = +n[i];
    var t = Math.min(ans2 + 2, ans1);
    ans2 = Math.min(ans1,ans2)+x;
    ans1 = t - x + 9;
  }
  return Math.min(ans1,ans2);
}

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

using namespace std;

#define el				'\n'
#define sz(v)			((int)((v).size()))
#define all(v)          ((v).begin()),((v).end())
#define clr(v, d)		memset(v, d, sizeof(v))

double const EPS = 1e-8, PI = acos(-1);
const int N = 2e5 + 9, M = 50 + 9, OO = (int) 1e9 + 1;
const long long MOD = 1e9 + 7;

typedef long long ll;

void OUTPUT() {
	cout << fixed << setprecision(12);
	ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
}

void INPUT() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
#endif
	cout << fixed << setprecision(12);
//	ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
}

vector<vector<int>> edges(N);
ll n, q, x, y;
ll counter[N];
bool vis[N];

int main() {
	OUTPUT();
//	INPUT();
	cin >> n;
	x = n;
	x--;
//	ll ans = (double(1 + x) / 2.0) * x;
	ll ans = x + (x * x);
	ans /= 2;
	cout << ans;
//	for (int i = 1; i <= n; i++) {
//		y += i % x;
//		cout << i % x << " " << i << el;
//		x--;
//	}
//	cout << y;

	return 0;

}


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

using namespace std;

#define ll long long
ll cmmdc(ll a,ll b)
{
    if(b==0)
        return a;
    return cmmdc(b,a%b);
}
ll x,y,G;
int main()
{
    cin>>x>>y;
    G=x*y/cmmdc(x,y);
    if(G==x)
    {
        cout<<-1;
        return 0;
    }
    cout<<G-x;
    return 0;
}
/**
**/


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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define a first
#define b second
#define sz size()
#define pb(x) push_back(x) 
#define bg begin()
#define ed end()
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define mp(x,y) make_pair(x,y)
const ll MOD=1000000007;

ll maxx(ll x,ll y,ll z){
	return max(max(x,y),z);
}
ll minn(ll x,ll y,ll z){
	return min(min(x,y),z);
}
ll gcd(ll x,ll y){
	if(x%y==0) return y;
    else return gcd(y,x%y);
}
ll lcm(ll x,ll y){
	return x*(y/gcd(x,y));
}

//a,b x
int main(){
	ll N; cin>>N;
  ll ma=0,price=0;
	rep(i,N){
      ll m; cin>>m;
      if(m>ma) ma=m;
      price+=m;
    }
  cout<<price-ma/2;
}

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

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

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

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

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

    int N, Y;
    cin >> N >> Y;
    Y /= 1000;

    int x, y, z;
    int l, r;
    int t = Y - N;
    l = CEIL(2 * t, 9);
    r = MIN(t / 4, Y / 5);
    if (t < 0 || l > r)
    {
        x = y = z = -1;
    }
    else
    {
        x = -4 * l + t;
        y = 9 * l - 2 * t;
        z = Y - 5 * l;
    }

    cout << x << " " << y << " " << z << "\n";
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;

struct ST {
  int p;
  int i;
};
bool operator<(const ST& x, const ST& y){
  return x.i < y.i;
}

int main(){
  int N;
  cin >> N;
  vector<ST> v;
  rep(i,N){
    ST st;
    cin >> st.p;
    st.i = i;
    v.push_back(st);
  }
  sort(ALLOF(v),[](const ST& x, const ST& y){ return x.p > y.p; });

  ll ret = 0;
  set<ST> s;
  s.insert((ST){-1,-1});
  s.insert((ST){-1,-2});
  s.insert((ST){-1,N});
  s.insert((ST){-1,N+1});
  
  rep(i,N){
    ST st = v[i];
    s.insert(st);

    int rhs2 = N;
    int rhs1 = N;
    int pos = st.i;
    int lhs1 = -1;
    int lhs2 = -1;

    auto itr = s.find(st);
    itr++;
    rhs1 = itr->i;
    itr++;
    rhs2 = itr->i;
    rhs2 = min(rhs2, N);
    
    auto itl = s.find(st);
    itl--;
    lhs1 = itl->i;
    itl--;
    lhs2 = itl->i;
    lhs2 = max(lhs2, -1);

    //cout << lhs2 << " " << lhs1 << " " << pos << " " << rhs1 << " " << rhs2 << endl;

    ll a = pos - lhs1;
    ll b = lhs1 - lhs2;
    ll c = rhs1 - pos;
    ll d = rhs2 - rhs1;

    //cout << a << " " << b << " " << c << " " << d << endl;
    ret += st.p * (b*c + a*d);
  }
  
  cout << ret << endl;
  
  return 0;
}



Measured memory_bytes: 5748
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#define lld long long int
#define DBG1(vari1) cerr<<#vari1<<" = "<<(vari1)<<endl;
#define DBG2(vari1,vari2) cerr<<#vari1<<" = "<<(vari1)<<" "<<#vari2<<" = "<<(vari2)<<endl;
#define DBG3(vari1,vari2,vari3) cerr<<#vari1<<" = "<<(vari1)<<" "<<#vari2<<" = "<<(vari2)<<" "<<#vari3<<" = "<<(vari3)<<endl;
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	// freopen("input.txt", "r", stdin);  
	string s;
	int c=0;
	cin >> s;
	for(int i=0;i<s.size()-1;i++)
	{
		if(s[i]!=s[i+1])
			c++;
	}
	cout << c;
}

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

using namespace std;

typedef long long ll;
typedef vector<ll> vl;
typedef long double ld;
typedef vector<ld> vd;
typedef bool bl;
typedef vector<bl> vb;
typedef unordered_map<ll,unordered_map<ll,ll>> graph;

const ll e5 = 1 << 20;
const ll mod = 1000000007;
const ll e3 = 1 << 11;
const ll INF = 1ll << 60;

string s;
ll dp[2][e5];


int main(){
  cin >> s;
  dp[0][0] = 1;
  for(ll i = 0;i < s.size();i++){
    dp[0][i] %= mod;
    dp[1][i] %= mod;
    if(s[i] == '0'){
      dp[0][i+1] += dp[0][i];
      dp[1][i+1] += dp[1][i]*2 + dp[1][i];
      dp[0][i+1] %= mod;
      dp[1][i+1] %= mod;
    }else if(s[i] == '1'){
      dp[0][i+1] += dp[0][i]*2;
      dp[1][i+1] += dp[0][i] + dp[1][i] + dp[1][i]*2;
      dp[0][i+1] %= mod;
      dp[1][i+1] %= mod;
    }
  }
  cout << (dp[0][s.size()]+dp[1][s.size()])%mod << endl;
}


Measured memory_bytes: 3328
class Dice(object):
    def __init__(self, nums):
        from collections import deque
        self.ns = deque([nums[4], nums[0], nums[1]])
        self.we = deque([nums[3], nums[0], nums[2]])
        self.bk = deque([nums[5]])

    def __str__(self):
        return str({"ns": self.ns, "we": self.we, "bk": self.bk})

    def operation(self, o):
        if o == "N":
            self.n()
        elif o == "S":
            self.s()
        elif o == "W":
            self.w()
        elif o == "E":
            self.e()
        else:
            raise BaseException("invalid", o)

    def n(self):
        self.ns.append(self.bk.popleft())
        self.bk.append(self.ns.popleft())
        self.we[1] = self.ns[1]

    def s(self):
        self.ns.appendleft(self.bk.pop())
        self.bk.appendleft(self.ns.pop())
        self.we[1] = self.ns[1]

    def w(self):
        self.we.append(self.bk.popleft())
        self.bk.append(self.we.popleft())
        self.ns[1] = self.we[1]

    def e(self):
        self.we.appendleft(self.bk.pop())
        self.bk.appendleft(self.we.pop())
        self.ns[1] = self.we[1]

    def rotate_right(self):
        tmp = self.ns
        tmp.reverse()
        self.ns = self.we
        self.we = tmp

    def fit_top_s(self, top, s):
        while self.get_top() != top:
            if top in self.ns:
                self.n()
            elif top in self.we:
                self.w()
            else:
                self.n()
                self.n()
        while self.get_s() != s:
            self.rotate_right()

    def get_top(self):
        return self.ns[1]

    def get_s(self):
        return self.ns[2]

    def get_e(self):
        return self.we[2]


def resolve():
    nums = [int(i) for i in input().split()]
    dc = Dice(nums)
    q = int(input())
    for _ in range(q):
        top, s = [int(i) for i in input().split()]
        dc.fit_top_s(top, s)
        print(dc.get_e())


resolve()



Measured memory_bytes: 6028
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>


using namespace std;
typedef long long ll;
ll gcd(ll a,  ll b) {
    if(b==0) return a;
    return gcd(b, a%b);
}
int main() {
    ll n;
    cin >> n;
    vector<ll> t(n);
    for(int i=0;i<n;i++)
        cin >> t[i];
    ll ans = t[0];
    if(n == 1) {
        ans = t[0];
    } else {
    for(int i=1;i<n;i++) {
        ans = ans/gcd(ans, t[i])*t[i];
    }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define int long long
#define vec(a,n) vector<int> (a)((n));
#define Vec(a,n) vector<string> (a)((n));
#define twovec(a,n,m) vector<vector<int>> a(n,vector<int>(m,0));
#define Twovec(a,n,m) vector<vector<double>> a(n,vector<double>(m,0));
#define P pair<int,int>
#define All(a) (a).begin(),(a).end()
#define Sort(a) sort(All(a));
#define Reverse(a) reverse(All(a));
#define PQ(n) priority_queue<P,vector<P>,greater<P>> (n)
#define pq(n) priority_queue<int> (n)
#define print(a) cout << (a) << endl
#define printD(a) cout << setprecision(15) << (a) << endl;
using namespace std;
int max_int = 1000000007;
void Debug(auto a);
int nibul(auto a,auto b);
int nibuu(auto a,auto b);
void input(vector<auto>& a,int n);
double PI = 3.14159265358979;
int n;

int gcd(int u, int v) {
  int r;
  while (0 != v) {
    r = u % v; u = v; v = r;
  }
  return u;
}
int lcm(int u,int v){
    int r = gcd(u,v);
    r = (u / r)*v;
    return r;
}



signed main(){
    int a,b;
    cin >> a >> b;
    print(lcm(a,b));

    return 0;
}

void Debug(auto a){
    cout << "{ ";
    for(auto b: a){
        cout << b << " ";
    }
    cout << "}" << endl;
}

//key以上の初めてのitr
int nibul(auto a,auto b){return lower_bound(All(a),b) - a.begin();}
//key以下の最後のitr
int nibuu(auto a,auto b){return upper_bound(All(a),b) - a.begin()-1;}

void input(vector<auto>& a,int n){
    REP(i,n){
        cin >> a[i];
    }
}


Measured memory_bytes: 256
import Control.Applicative ((<$>), (<*>))
import Control.Monad
import Data.List

main :: IO ()
main = do
  n <- getl toInt
  unless (n == 0) $ do
    solve <$> replicateM n getLine >>= print
    main

solve :: [String] -> Int
solve = sum . map head . scanl f [1,2,3,4,5,6]
  where
    f [d1,d2,d3,d4,d5,d6] s
      | s == "North" = [d2,d6,d3,d4,d1,d5]
      | s == "East" = [d4,d2,d1,d6,d5,d3]
      | s == "West" = [d3,d2,d6,d1,d5,d4]
      | s == "South" = [d5,d1,d3,d4,d6,d2]
      | s == "Right" = [d1,d3,d5,d2,d4,d6]
      | otherwise = [d1,d4,d2,d5,d3,d6]

toInt :: String -> Int
toInt = read

getl :: (String -> a) -> IO a
getl f = f <$> getLine

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

int main() {
	string s,t;
	getline(cin,s);
	getline(cin,t);
	int i,j,m=s.length(),n=t.length();
	int a[m+1][n+1];
	for(i=0;i<=m;i++)
	{
	    for(j=0;j<=n;j++)
	    {
	        if(i==0 || j==0)
	        a[i][j]=0;
	        else if(s[i-1]==t[j-1])
	        a[i][j]=a[i-1][j-1]+1;
	        else
	        a[i][j]=max(a[i-1][j],a[i][j-1]);
	    }
	}
	
	
	int index = a[m][n]; 
   char lcs[index+1]; 
   lcs[index] = '\0'; 

   i = m, j = n; 
   while (i > 0 && j > 0) 
   { 
      if (s[i-1] == t[j-1]) 
      { 
          lcs[index-1] = s[i-1];  
          i--; j--; index--;     
      } 
      else if (a[i-1][j] > a[i][j-1]) 
         i--; 
      else
         j--; 
   } 
   cout <<lcs; 
	
	
	
	return 0;
}

Measured memory_bytes: 38628
import sys

num = int(input())

num_list = []

for i in range(num):
  num_list.append(list(map(int,input().split())))

true_count = 0
  
for item in num_list:
  if(item[0] == item[1]):
    true_count += 1
    if(true_count >= 3):
      print("Yes")
      sys.exit()
  else:
    true_count = 0

print("No")
      

Measured memory_bytes: 9168
#include<bits/stdc++.h>
#define ha 1000000007
#define inv2 500000004
using namespace std;

const int S=(1<<20)+5;
char buf[S],*H,*T;
inline char Get()
{
    if(H==T) T=(H=buf)+fread(buf,1,S,stdin);
    if(H==T) return -1;return *H++;
}
inline int read()
{
    int x=0;char c=Get();
    while(!isdigit(c)) c=Get();
    while(isdigit(c)) x=x*10+c-'0',c=Get();
    return x;
}

const int N=200010;
const int M=8000;
int fac[M+10],ifac[M+10];
int f[M/2+10][M/2+10],base=M/4+2;
int n,A[N],B[N];

int Pow(int a,int b)
{
    int ans=1;
    for(;b;b>>=1,a=1ll*a*a%ha)
        if(b&1) ans=1ll*ans*a%ha;
    return ans;
}

void Init()
{
    fac[0]=1;
    for(int i=1;i<=M;i++)
        fac[i]=1ll*fac[i-1]*i%ha;
    ifac[M]=Pow(fac[M],ha-2);
    for(int i=M-1;i>=0;i--)
        ifac[i]=1ll*ifac[i+1]*(i+1)%ha;
}

int C(int n,int m){return 1ll*fac[n]*ifac[m]%ha*ifac[n-m]%ha;}

int main()
{
    Init(); n=read();
    for(int i=1;i<=n;i++)
    {
        A[i]=read(),B[i]=read();
        f[base-A[i]][base-B[i]]++;
    }
    for(int i=1;i<=M/2+2;i++)
        for(int j=1;j<=M/2+2;j++)
            f[i][j]=(f[i][j]+(f[i-1][j]+f[i][j-1])%ha)%ha;
    int ans=0;
    for(int i=1;i<=n;i++)
    {
        ans=(ans+f[A[i]+base][B[i]+base])%ha;
        ans=(ans-C(2*A[i]+2*B[i],2*A[i]))%ha;
    }
    ans=(ans+ha)%ha;
    ans=1ll*inv2*ans%ha;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 65536
from functools import reduce


def add(x, y):
    return x + y


n, m, c = list(map(int, input().split()))
a, *b = [list(map(int, input().split())) for i in range(n + 1)]
success = 0

for i in range(n):
    if reduce(add, list(x * y for (x, y) in zip(a, b[i]))) + c > 0:
        success += 1

print(success)


Measured memory_bytes: 3700
#include<iostream>
#include<queue>
#define f first
#define s second
#define inf 100000001
using namespace std;

int main()
{
  string a[11],b[11],x,y;
  int n;

  while(1){
    cin>>n;
    if(n==0)break;
    for(int i=0;i<n;i++)cin>>a[i]>>b[i];
    cin>>x>>y;

    queue<pair<string,int> > Q;
    Q.push(make_pair(x,0));
    int ans=inf;
   
    while(!Q.empty()){
      pair<string,int> u=Q.front();
      string s=u.f;
      Q.pop();
      for(int i=0;i<n;i++){
	string ss="";
	for(int j=0;j<s.length();j++){
	  //cout<<s.substr(j,a[i].length())<<" "<<a[i]<<endl;
	  if(s.substr(j,a[i].length())==a[i]){
	    ss+=b[i];
	    j+=a[i].length()-1;
	  }
	  else ss+=s[j];
	}
	//cout<<s<<" "<<ss<<" "<<i<<endl;
        if(ss==y){
	  ans=min(u.s+1,ans);
	  break;
	}
        if(ss.length()>y.length()){
	  continue;
	}
        if(s!=ss)Q.push(make_pair(ss,u.s+1));
      }
    }
    if(ans==inf)cout<<-1<<endl;
    else cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 1560
h,w,k = map(int, input().split())
mod = 10**9+7
row_amida = []
def make_amida(pre, li):
	if len(li) == w-1:
		row_amida.append(li)
	else:
		if pre == 0:
			make_amida(1, li + [1])
		make_amida(0, li + [0])
make_amida(0,[])
dp = [[0 for i in range(w+1)] for j in range(h+1)]
dp[0][1] = 1 #dp[i][j] := i行目まで決めたときのj列目にたどり着くあみだの本数
for i in range(1,h+1):
	for j in range(1,w+1):
		left_to_cur = 0
		up_to_cur = 0
		right_to_cur = 0
		for p in range(len(row_amida)):
			upflag = True
			if j != 1 and row_amida[p][j-2] == 1:
				left_to_cur += 1
				upflag = False
			if j != w and row_amida[p][j-1] == 1:
				right_to_cur += 1
				upflag = False
			if upflag:
				up_to_cur += 1
		if j != 1:
			left_to_cur = (left_to_cur * dp[i-1][j-1]) % mod
		if j != w:
			right_to_cur = (right_to_cur * dp[i-1][j+1]) % mod
		up_to_cur = (up_to_cur * dp[i-1][j]) % mod
		dp[i][j] = right_to_cur + left_to_cur + up_to_cur
		dp[i][j] %= mod
print(dp[-1][k])







  


Measured memory_bytes: 43504
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

/*--------switch header--------*/
#define ALGORITHM   1
#define CASSERT     0
#define CMATH       0
#define DEQUE       0
#define FUNCTIONAL  1
#define IOMANIP     1
#define IOSTREAM    1
#define LIST        0
#define MAP         0
#define QUEUE       0
#define SET         0
#define STRING      1
#define UTILITY     1
#define VECTOR      1
#define VEC_DEBUG   1

using namespace std;

#pragma region headers
#if VEC_DEBUG
#define _GLIBCXX_DEBUG
#endif
#if ALGORITHM
#include <algorithm>
#endif
#if CASSERT
#include <cassert>
#endif
#if CMATH
#include <cmath>
#endif
#if DEQUE
#include <deque>
#endif
#if FUNCTIONAL
#include <functional>
#endif
#if IOMANIP
#include <iomanip>
#endif
#if IOSTREAM
#include <iostream>
#endif
#if LIST
#include <list>
#endif
#if MAP
#include <map>
#endif
#if QUEUE
#include <queue>
#endif
#if SET
#include <set>
#endif
#if STRING
#include <string>
#endif
#if UTILITY
#include <utility>
#endif
#if VECTOR
#include <vector>
#endif
#pragma endregion


/*----------macros----------*/

//output================
#define endl '\n'
#define fcout cout << fixed << setprecision(15)

//typedef===============
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;

//const number==========
constexpr ll INF9   = (ll)1e9 + 1;
constexpr ll INF18  = (ll)1e18 + 1;
constexpr ll MOD    = 1000000007;
constexpr ld PI     = 3.141592653589793L;

//member================
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second

//others================
#define ALL(x)          (x).begin(), (x).end()
#define rALL(x)         (x).rbegin(), (x).rend()
#define REP(i, n)       for(int i = 0; (i) < (n); (i)++)
#define rREP(i, n)      for(int i = n - 1; (i) >= 0 ; (i)--)
#define FOR(i, a, b)    for(int i = (a); (i) < (b) ; (i)++)
#define CtoI(c)         int((c)) - int('0')

//functions=============
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

//vector<int> dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};
//vector<int> dx2 = { 1,1,0,-1,-1,-1,0,1 }, dy2 = { 0,1,1,1,0,-1,-1,-1 };



/*--------additional--------*/



/*----------main------------*/

int main() {
/*----------fastio----------*/
    std::cin.tie(nullptr);
    std::cout.tie(nullptr);
    std::ios::sync_with_stdio(false);
/*----------solve-----------*/

    int n, k; cin >> n >> k;
    int d[k], a[n];


    int ans[n];
    REP(i, n) ans[i] = 1;

    REP(i, k){
        cin >> d[i];
        REP(j, d[i]){
            cin >> a[j];
            ans[a[j]-1] = 0;
        }
    }

    int cnt = 0;
    REP(i, n){
        if(ans[i] != 0)
        cnt++;
    }

    cout << cnt << endl;

return 0;
}

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

int main() {
    string s;
    cin>>s;
    int ans = 0;
    int temp = 0;
    for (size_t i = 0; i < s.length(); i++)
    {
        if (s.at(i)=='A'||s.at(i)=='T'||s.at(i)=='G'||s.at(i)=='C'){
            temp++;
            ans = std::max(ans,temp);
        }
        else {
            temp=0;
        }

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
using namespace std;
const long mod=1000000007;
int main(){
    int n;
    cin>>n;
    vector<long>ans(n+1),ag(n+1),ac(n+1),ga(n+1),at(n+1),a(n+1),g(n+1),c(n+1),t(n+1);
    ans[1]=4;
    ans[2]=16;
    ag[1]=ac[1]=ga[1]=0;
    ag[2]=ac[2]=ga[2]=at[2]=1;
    a[2]=g[2]=c[2]=t[2]=4;
    for(int i = 3; i <= n; i++){
        a[i]=ans[i-1];
        g[i]=ans[i-1]-ac[i-1];
        c[i]=ans[i-1]-ag[i-1]-ga[i-1]-ag[i-2]*2-at[i-2];
        t[i]=ans[i-1];
        ag[i]=a[i-1];
        ac[i]=a[i-1]-ga[i-1];
        ga[i]=g[i-1];
        at[i]=a[i-1];
        ans[i]=((a[i]+g[i]+c[i]+t[i])%mod+mod)%mod;
    }
    cout<<ans[n]<<endl;
}

Measured memory_bytes: 256
from collections import deque
n,q=map(int,input().split())
tree=[deque([]) for _ in range(n+1)]
for i in range(n-1):
  a,b=map(int,input().split())
  tree[a].append(b)
  tree[b].append(a)
ans=[0]*(n+1)
for i in range(q):
  p,x=map(int,input().split())
  ans[p]+=x
seen=[0]*(n+1)
stack=[]
def dfs():
  stack.append(1)
  seen[1]=1
  while stack:
    s=stack.pop()
    if not tree[s]:
      continue
    for j in range(len(tree[s])):
      g_NO = tree[s].popleft()
      if seen[g_NO]:
        continue
      seen[g_NO] = 1
      stack.append(g_NO)
      ans[g_NO] += ans[s]


dfs()
print(*ans[1:])



Measured memory_bytes: 231968
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)x.size()
#define D(x) cerr << #x << " = " << (x) << '\n'
using ll = long long;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	int n, k;
	cin >> n >> k;
	vector<int> h(n), dp(n, INT_MAX);
	for(int i = 0; i < n; ++ i) cin >> h[i];
	dp[0] = 0;
	for(int i = 1; i < n; ++ i) {
		for(int j = 1; j <= k; ++ j) {
			if(i - j < 0) continue;
			dp[i] = min(dp[i], abs(h[i - j] - h[i]) + dp[i - j]);
		}
	}
	cout << dp[n - 1] << '\n';
}


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

int main()
{
	int n;
	cin >> n;
	
	int a[n];
	int b[n];
	memset(a,0,sizeof(a));
	memset(b,0,sizeof(b));
	for(int i = 0;i < n - 1;i++)
		scanf("%d",&b[i]);
	b[n - 1] = b[n - 2];
	a[0] = b[0];a[1] = b[0];
	for(int i = 1;i < n;i++){
		a[i] = min(b[i - 1],b[i]);
	}
	long long sum = 0; 
	for(int i = 0;i < n;i++){
		sum += a[i];
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <limits>
#include <queue>
#include <vector>

template<typename CapacityType>
struct Dinic {
  using value_type = CapacityType;
  struct Edge {
    CapacityType cap;
    const int to, rev;
    const bool is_rev;
    Edge(int to, CapacityType cap, int rev, bool is_rev) : cap(cap), to(to), rev(rev), is_rev(is_rev) {}
  };

  static constexpr auto inf = std::numeric_limits<CapacityType>::max();
  const int UNREACHABLE = -1;

  std::vector<std::vector<Edge>> G;
  std::vector<int> level, iter;
  Dinic(int V) : G(V), level(V), iter(V) {}

  void add_edge(int from, int to, CapacityType cap) {
    int trev = G[from].size();
    int frev = G[to].size();
    G[from].emplace_back(to, cap, frev, false);
    G[to].emplace_back(from, 0, trev, true);
  }

  CapacityType max_flow_value(int s, int t) {
    CapacityType value = 0;
    while (labeling(s), level[t] != UNREACHABLE) {
      std::fill(iter.begin(), iter.end(), 0);
      CapacityType bf;
      while (bf = blocking_flow(s, t, inf), bf > 0) {
        value += bf;
      }
    }
    return value;
  }
  bool labeling(int s) {
    std::fill(level.begin(), level.end(), UNREACHABLE);
    level[s] = 0;
    static std::queue<int> Q;
    Q.push(s);
    for (; !Q.empty(); Q.pop()) {
      auto v = Q.front();
      for (auto&& e : G[v]) {
        if (level[e.to] != UNREACHABLE) continue;
        if (e.cap == 0) continue;
        level[e.to] = level[v] + 1;
        Q.push(e.to);
      }
    }
    return true;
  }
  CapacityType blocking_flow(int v, int t, CapacityType f) {
    if (v == t) return f;
    auto& V = G[v];
    for (int& i = iter[v]; i < V.size(); ++i) {
      auto& e = V[i];
      if (e.cap == 0) continue;
      if (level[v] >= level[e.to]) continue;
      auto bf = blocking_flow(e.to, t, std::min(f, e.cap));
      if (bf > 0) {
        e.cap -= bf;
        G[e.to][e.rev].cap += bf;
        return bf;
      }
    }
    return 0;
  }

  struct Flow {
    const int to;
    const CapacityType out;
    Flow(int to, CapacityType out) : to(to), out(out) {}
  };
  std::vector<std::vector<Flow>> build_flow() const {
    const int V = G.size();
    std::vector<std::vector<Flow>> F(V);
    for (int i = 0; i < V; i++) {
      for (auto&& e : G[i]) {
        if (not e.is_rev) continue;
        if (e.cap == 0) continue;
        F[e.to].emplace_back(i, e.cap);
      }
    }
    return F;
  }
};

#include <cstdio>
#define mygc(c) (c) = getchar_unlocked()
#define mypc(c) putchar_unlocked(c)
template<typename T=int>inline T rd(){T x=0,m=0,k;for(;;){mygc(k);if(k=='-'){m=1;break;}if('0'<=k&&k<='9'){x=k-'0';break;}}for(;;){mygc(k);if(k<'0'||'9'<k)break;x=x*10+k-'0';}return x;}
template<typename T=int>inline void wr(T x,char c='\n'){int s=0,m=0;char b[32];if(x<0)m=1,x=-x;for(;x;x/=10)b[s++]=x%10;if(!s)b[s++]=0;if(m)mypc('-');for(;s--;)mypc(b[s]+'0');mypc(c);}

int main() {
  int V = rd(), E = rd();
  Dinic<int> dinic(V);
  for (int i = 0; i < E; i++) {
    int u = rd(), v = rd(), c = rd();
    dinic.add_edge(u, v, c);
  }
  wr(dinic.max_flow_value(0, V - 1));
  return 0;
}

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

int main()
{
  int N;
  cin >> N;
  vector<int> a(N);
  rep(i,N) cin>>a[i];
  sort(a.begin(), a.end());
  int ret=0;
  for (int i = 0; i < a.size(); i++)
  {
    if (i%2==0) {
      ret += a[i];
    } else {
      ret -= a[i];
    }
  }
  cout << abs(ret) << endl;
}


Measured memory_bytes: 256
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

#define debug(...) fprintf(stderr, __VA_ARGS__)
#define int long long int
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
typedef pair<int, int> pii;
typedef long long ll;
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;

int N, K, V[55];
int dp[55][55][105];

int solve(int l, int r, int k) {
    int &val = dp[l][r][k];
    if(val != -INF) return val;

    val = 0;
    if(r - l > 0) {
        // 左の宝石について
        {
            // 手に入れる
            if(k+1 <= K) {
                chmax(val, solve(l+1, r, k+1) + V[l]);
            }
            
            // 捨てる
            if(k+2 <= K) {
                chmax(val, solve(l+1, r, k+2));
            }
        }
        // 右の宝石について
        {
            // 手に入れる
            if(k+1 <= K) {
                chmax(val, solve(l, r-1, k+1) + V[r-1]);
            }
            
            // 捨てる
            if(k+2 <= K) {
                chmax(val, solve(l, r-1, k+2));
            }
        }
    }
    return val;
}

signed main() {
    cin >> N >> K;
    for(int i=0; i<N; i++) cin >> V[i];

    fill(dp[0][0], dp[N+1][0], -INF);
    cout << solve(0, N, 0) << endl;
    return 0;
}


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

typedef long long ll;
const int maxn=1e6+7;
const int inf=INT_MAX;
const ll inff=1e18;
const ll mod=1e9+7;
#define pii pair<int,int>
#define mkp make_pair
#define F first
#define S second
#define pb push_back
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(),(v).end()
//#define int ll

#ifdef HNO2
#define IOS
#else
#define endl '\n'
#define IOS ios::sync_with_stdio(0); cin.tie(0);
#endif // HNO2

int32_t main()
{
    IOS
    int a,b;
    cin>>b>>a;
    cout<<(a-1+b-1-1)/(b-1)<<endl;
}



Measured memory_bytes: 256