akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

const int MX = 200010;
const int mod = 1e9 + 7;
ll inv[MX];
void calc(){
	inv[0] = inv[1] = 1;
	for (int i = 2; i < MX; i++) inv[i] = mod - mod / i * inv[mod % i] % mod;
}
int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	calc();
	
	int n, k; cin >> n >> k;
	k = min(k, n - 1);
	
	ll ans = 1, p = 1, q = 1;
	
	for(int i = 1; i <= k; i++){
		p = p * (n + 1 - i) % mod * inv[i] % mod;
		q = q * (n - i) % mod * inv[i]% mod;
		ans += p * q % mod;
	}
	
	cout << ans % mod << endl;
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
//----***やべーやつら***----
using namespace std;
#define int long long

//----***型定義***----
using ll = long long;
using P = pair<int,int>;

//----***Like a Pythonista***----
#define REP(ii,jj,nn) for (ll ii=jj;ii<(nn);ii++)
#define RREP(ii,nn,jj) for (ll ii = nn; jj<ii;ii--)
#define each(i,...) for (auto&& i:__VA_ARGS__)
#define ALL(vec) (vec).begin(),(vec).end()
#define sum(...) accumulate(ALL(__VA_ARGS__),0LL)
#define dsum(...) accumulate(ALL(__VA_ARGS__),0.0)
#define vec(type,name,...) vector<type> name(__VA_ARGS__)
template<class T> inline auto max(const T& a){ return *max_element(ALL(a)); }
template<class T> inline auto min(const T& a){ return *min_element(ALL(a)); }
inline ll gcd(ll a,ll b){if(b == 0) return a;return  gcd(b,a%b);}
inline ll lcm(ll a,ll b){ll g = gcd(a,b);return a / g * b;}

//----***定数***----
#define MOD 1000000007
#define INF 100000000000000000
#define EPS 1e-9
const vector<vector<int>> DXY={{-1,0},{1,0},{0,-1},{0,1}};

//----***パーツ***----
#define fr first
#define se second

//----***入出力***---
#define print(out) cout<< out  << "\n";
#define debug(var)  do{std::cerr << #var << " ↓ "<<"\n";view(var);}while(0);
#define dbg cerr<<"🥺🥺🥺🥺🥺🥺"<<endl;
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }

//----***初期時読み込み***----
struct initial{initial(){cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(15);};}initial_;

vector<vector<int>>dp(30,vector<int>(50010,0));

signed main(){
  int N,M;cin>>N>>M;
  vector<int> coins(M);
  REP(i,0,M)cin>>coins[i];
  REP(i,0,30)dp[i][0]=INF;
  REP(i,0,50010)dp[0][i]=INF;
  REP(i,0,M)REP(m,1,N+1){
    if(m-coins[i]>=0){
      int tmp=(dp[i+1][m-coins[i]]==INF?1:dp[i+1][m-coins[i]]+1);
      dp[i+1][m]=min(dp[i][m],tmp);
    }
    else{
      dp[i+1][m]=dp[i][m];
    }
  }
  // debug(dp)
  print(dp[M][N])

}



Measured memory_bytes: 14920
#include<bits/stdc++.h>
using namespace std;
int main() 
{
    string s;
    cin>>s;
    long long ans=0, res;
    int last=-1;
    for(int t=0; t<(1<<(s.size()-1)); t++)
    {
    	res=0;
    	for(int i=0; i<s.size()-1; i++)
    	{
    		if(t&(1<<i))
    		{
    			for(int j=last+1; j<=i; j++)
    				res*=10, res+=s[j]-'0';
    			last=i;
    			ans+=res;
    			res=0;
			}
		}
		for(int j=last+1; j<s.size(); j++)
			res*=10, res+=s[j]-'0';
		ans+=res;
		last=-1;
	}
	cout<<ans;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<queue>
#include<bitset>
#include<algorithm>
#include<climits>
#include<vector>
#include<deque>
#include<cmath>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> P;
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define dump(a) rep(i,a.size()){ cout<<a[i]<<" "; } cout<<endl;
#define dumparr(a,n) rep(i,n){ cout<<a[i]<<" "; } cout<<endl;
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define INF INT_MAX/3
#define FINF DBL_MAX/3
#define EPS 1e-7

/* string transformation
 * 一対一の文字置換で表現できるか？
 * 関数fが一対一とは [x_i=x_j] -> [f(x_i)=f(x_j)]
 */

int main(){
  string s,t;
  cin>>s>>t;
  int r[1000], q[1000];
  fill(r, r+1000, -1);
  fill(q, q+1000, -1);
  bool ok = true;

  rep(i,s.length()) {
    char x=s[i], y=t[i];
    if(r[(int)x] < 0){
      // まだ使ってない
      r[(int)x] = (int)y;
    } else {
      // 使っていた
      if(r[(int)x] != (int)y) {
        ok = false;
        break;
      }
    }

    if(q[(int)y] < 0) q[(int)y] = (int)x;
    else if(q[(int)y] != (int)x) {
      ok = false;
      break;
    }
  }
  if(ok) cout<<"Yes"<<endl;
  else   cout<<"No"<<endl;

  return 0;
}


Measured memory_bytes: 776
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cassert>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
#include <cassert>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())

int n;
bool go[305][305];
int main(){
	rep(i,305) go[i][i] = 1;
	int n,m; cin >> n >> m;
	rep(i,m){int a,b; cin>>a>>b; go[a][b]=1;}
	rep(k,305)rep(i,305)rep(j,305)go[i][j]|=(go[i][k]&go[k][j]);
	repn(i,n){
		vector<int>vi; repn(j,n) if(go[i][j]&&go[j][i]) vi.pb(j);
		rep(i,vi.size()) cout << vi[i] << (i+1==vi.size()?'\n':' ');
	}
}


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

int main() {
  int a,b,ans;
  cin >> a >> b ;
  ans = a*b;
  
  if(a < 10 && b < 10){
    cout << ans << endl;
  }
  else{
    cout << -1 << endl;
  }
  
}


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

bool palin(string s)
{
    bool flag = true;
    int i = 0;
    int j = s.size() - 1;
    while(i < j)
    {
        if(s[i] != s[j]){
            flag = false;
            break;
        }
        i++;
        j--;
    }
    return flag;
}

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

    if(palin(s) && palin(s.substr(0, (s.size()-1)/2)) && palin(s.substr((s.size() + 3)/2 -1, (s.size()-1)/2))) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

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

int main()
{
    int n,flg;

    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];

    sort(a.begin(), a.end());
    flg = 0;
    rep(i, n-1) {
        if (a[i] == a[i + 1]) {
            //一致あり
            ++flg;
            break;
        }
    }
    //結果
    if (flg>0)
        std::cout << "NO" << endl;
    else
        std::cout << "YES" << endl;
}



Measured memory_bytes: 4032
A, B, K = [int(x) for x in input().split()]

t1 = min(B, A + K - 1)
t2 = max(A + K, B - K + 1)
ans = []
for i in range(A, t1 + 1):
    ans.append(i)
for i in range(t2, B + 1):
    ans.append(i)

print("\n".join(map(str, ans)))


Measured memory_bytes: 3064
#include <stdio.h>

main () {
	int n, i;
	int fib[45];

	scanf("%d", &n);
	fib[0] = fib[1] = 1;
	for (i = 2; i < 45; i++) 
		fib[i] = fib[i - 1] + fib[i - 2];
	printf("%d\n", fib[n]);

	return 0;
}

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

int main(){
	char a[3],b[3];
	cin>>a;
	cin>>b;
	int ans=0;
	for(int i=0;i<3;i++){
		if(a[i]==b[i]){
			ans++;
		}
	}
	cout<<ans;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

	public static void main(String[] args) {
		// make new Scanner.
		Scanner sc = new Scanner(System.in);
		String str = sc.nextLine();
		int t = Integer.parseInt(sc.next());
		
		while (true) {
			if (t >= str.length()) {
				System.out.println(str.substring(0, 1));
				break;
			} else {
				System.out.print(str.substring(0, 1));
				str = str.substring(t);
			}
		}
		
		// Listに格納.
//		List<Integer> list = inList(sc,n);
		

		// close Scanner
		sc.close();

	}
	
	/**
	 *  入力した数字を配列に格納するメソッド.
	 * @param sc
	 * @param n
	 * @return
	 */
	public static List<Integer> inList(Scanner sc, int n) {
		List<Integer> list = new ArrayList<Integer>();
		for (int a=0;a<n;a++) {
			list.add(sc.nextInt());
		}
		return list;
	}

}

Measured memory_bytes: 23124
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int descending_compare(const void *a, const void *b){
    if (*(int*)a > *(int*)b){
        return -1;
    }else if (*(int*)a == *(int*)b){
        return 0;
    }else{
        return 1;
    }
}

int ascending_compare(const void *a, const void *b){
    if (*(int*)a < *(int*)b){
        return -1;
    }else if (*(int*)a == *(int*)b){
        return 0;
    }else{
        return 1;
    }
}


int lower_bound(int *a, int n, int key){
    int left, mid, right;
    left = 0, right = n;
    mid = (left + right)/2;
    while ((left+1 != mid || mid+1 != right) && mid != left){
        if (key > a[mid]){
            left = mid;
        }else{
            right = mid+1;
        }
        mid = (left + right)/2;
    }
    if (a[left] >= key)return left;
    if (a[mid] >= key)return mid;
    if (a[right] >= key)return right;
    return n;
}

unsigned long  gcd(unsigned long x, unsigned long y)
{
        if (y == 0) {
                return x;
        } else {
                return gcd(y, x % y);
        }
}


int a[200005];
int ans[200005];



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

    if (n % 2 == 0){
        for (i = n - 1; i > 0; i -= 2){
            ans[j] = a[i];
            j++;
        }
        ans[j] = a[0];
        j++;
        for (i = 2; i < n; i += 2){
            ans[j] = a[i];
            j++;
        }
    }

    if (n % 2 == 1){
        for (i = n - 1; i > 0; i -= 2){
            ans[j] = a[i];
            j++;
        }
        ans[j] = a[0];
        j++;
        for (i = 1; i < n; i += 2){
            ans[j] = a[i];
            j++;
        }
    }
    for (i = 0; i < n; i++){
        printf("%d ", ans[i]);
    }

    printf("\n");

    return 0;

}


Measured memory_bytes: 3712
X, K, D = map(int, input().split())

if int(abs(X) / D) <= K:
    if int(K - int(abs(X) / D)) % 2 == 0:
            print(abs(X) % D)
    else:
        print(abs(abs(X) % D - D))
else:
    print(abs(X) - D * K)

Measured memory_bytes: 9188
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <cmath>
#define REP(i,n) for(int i=0;i<(n);++i)
using namespace std;
using ll = long long;
constexpr int INF = 1e9;
constexpr int MOD = 1e9 + 7;
template<class T> inline void chmax(T &a,T b){if(a<b)a=b;}
template<class T> inline void chmin(T &a,T b){if(a>b)a=b;}

int digit(int n){
    int ret = 0;
    while(n){
        ret += n%10;
        n /= 10;
    }
    return ret;
}

int main(){
    cin.tie(0); ios_base::sync_with_stdio(false);
    int n; cin >> n;
    cout << (n%digit(n)==0 ? "Yes" : "No") << endl;
    return 0;
}

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

bool solve(string s, string p)
{
  int n = s.size();
  int m = p.size();
  for (int i = 0; i < n; i++)
  {
    string key;
    if (i + m - 1 < n)
    {
      key = s.substr(i, m);
      if (key == p)
      {
        return true;
      }
    }
    else
    {
      key = s.substr(i, n - i) + s.substr(0, m - n + i);
      if (key == p)
      {
        return true;
      }
    }
  }
  return false;
}

int main()
{
  string s, p;
  cin >> s >> p;
  if (solve(s, p))
  {
    cout << "Yes" << endl;
  }
  else
  {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 3224
#include <iostream>
#include <string>
int main() {

	std::string s;
	std::cin >> s;

	int sum = 0;
	for (int i = 0; i < s.size(); i++)
		sum += int(s[i] - '0');
	if (std::stoi(s) % sum == 0)
		std::cout << "Yes" << std::endl;
	else
		std::cout << "No" << std::endl;

	return 0;
}

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

int main() {
	int n, k;
	cin >> n >> k;
	vector<int> a(n);
	for (int i = 0; i < n; i++)
		cin >> a[i];

	for (int i = k; i < n; i++) {
		if (a[i-k] < a[i]) cout << "Yes" << endl;
		else cout << "No" << endl;
	}
}

Measured memory_bytes: 3976
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <functional>
#include <iomanip>
#include <bitset>
#include <numeric>
#include <queue>
#include <map>
#include <cstdint>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
const long long mod = 1000000007;
typedef long long int ll;
typedef pair<int, int> P;
const vector<int> di = { -1, 0, 1, 0 };
const vector<int> dj = { 0, 1, 0, -1 };


int main() {

	int a, b, c, d;
	cin >> a >> b >> c >> d;
	if (a * b > c * d) {
		cout << a * b << endl;
	}
	else {
		cout << c * d << endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
N, T = map(int, input().split())
A = [int(a) for a in input().split()]
mi = 10**9
madif = 0
madifcnt = 0
for a in A:
    if a < mi:
        mi = a
    elif a - mi > madif:
        madif = a - mi
        madifcnt = 1
    elif a - mi == madif:
        madifcnt += 1

print(madifcnt)

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

#define pp push_back
#define pf push_front
#define mp make_pair
#define fs first
#define sc second
#define sf scanf

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> ii;

const int N = (int) 2e5 + 7;
const int INF = (int) 1e9 + 7;

int cnt[N];

int main(int argc, char *argv[])
{
	// ios_base::sync_with_stdio(false);
	// cin.tie(NULL);

	int n;
	sf("%d", &n);
	ll ans = 0;
	for (int i = 1; i <= n; ++i) {
		int x;
		sf("%d", &x);
		if (i - x > 1) ans += cnt[i - x];
		if (i + x < N) {
			++cnt[i + x];
		}
	}
	printf("%lld", ans);

	return 0;
}


Measured memory_bytes: 4596
s = input()

g = 0
score = 0
for c in s:
    if c == 'g':
        if g:
            score += 1
            g -= 1
        else:
            g += 1
    else:
        if g:
            g -= 1
        else:
            g += 1
            score -= 1
print(score)


Measured memory_bytes: 3316
import java.util.Scanner;

class Main {
	public static void main(String[] args){
		
		Scanner sc = new Scanner(System.in);
		
		int a = sc.nextInt();
		int b = sc.nextInt();
		
		System.out.print(a * b + " ");
		System.out.println(a*2 + b*2);
		
	}
}


Measured memory_bytes: 26224
#include <iostream>
#include <utility>
#include <queue>
#include <memory>
#include <cstring>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>

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

using namespace std;
using ll = long long;
const int mod = 1e9+7;

int main(){
    int a,b,k;
    cin >> a >> b >> k;
    vector<int> vec;
    
    for(int i = max(a,b); i > 0; i--){
        if((a % i == 0) && (b % i == 0)){
            vec.push_back(i);
        }
    }

    cout << vec[k-1] << endl;
    return 0;
}

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

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) unique(v.begin(), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
#define all(v) (v).begin(), (v).end()
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

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

	int N;
	cin >> N;
	int h[N];
	rep(i, 0, N) cin >> h[i];

	int rsl = 0;

	while(true) {
		bool flag = false, changed = false, zero = false;
		rep(i, 0, N) {
			if(h[i] != 0) {
				h[i]--;
				flag = true;
				changed = true;
				zero = false;
			} else if(flag) {
				rsl++;
				flag = false;
				zero = true;
			}
		}
		if(changed and !zero) rsl++;

		if(!changed) {
			cout << rsl << endl;
			return 0;
		}
	}
}


Measured memory_bytes: 256
N=int(input())

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

ans=10**12
for i in make_divisors(N):
    j=N//i
    if ans>i+j:
        ans=i+j

print(ans-2)

Measured memory_bytes: 3264
#include <iostream>
#include <iomanip>
#include <math.h>
using namespace std;

int main()
{
  long int N;
  long int a;
  int b[10000];
  int i=0;
  char c='a', d;

  cin >> N;

  a = N;
  while(a)
  {
    a -= 1;
    b[i] = a%26;
    a /= 26;
    ++i;
  }

  for(int j=0; j<i; ++j)
  {
    d = c + b[i-1-j];
    cout << d;
  }
  cout << endl;

  //cout << fixed << setprecision(8) << s << " " << l << " " << endl;

  return 0;
}



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

string to_string(string s) {
  return '"' + s + '"';
}
 
string to_string(const char* s) {
  return to_string((string) s);
}
 
string to_string(bool b) {
  return (b ? "true" : "false");
}
 
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
 
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
 
void debug_out() { cerr << endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
 
#ifdef LOCAL
#define db(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define db(...) 42
#endif

using ll = long long;

const int N = 105;

int mat[N][N];

int h, w, n;

void col(int k, int x, int y) {
  for (int i = 1; i <= h; i++) {
    for (int j = 1; j <= w; j++) {
      if (j <= x && k == 1) mat[i][j] = 1;
      if (j > x && k == 2) mat[i][j] = 1;
      if (i <= y && k == 3) mat[i][j] = 1;
      if (i > y && k == 4) mat[i][j] = 1;
    }
  }
}

int main() {
  cin >> w >> h >> n;
  for (int i = 0; i < n; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    col(c, a, b);
  }
  int ans = 0;
  for (int i = 1; i <= h; i++) {
    for (int j = 1; j <= w; j++) {
      if (mat[i][j] == 0) {
        ans += 1;
      }
    }
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 256
N,M=map(int,input().split())
A=[0]*M
keys=[0]*M
for i in range(M):
  a,b=map(int,input().split())
  A[i]=a
  c=list(map(int,input().split()))
  for j in range(len(c)):
    keys[i]|=1<<(c[j]-1)
    
INF=10**9+1
dp=[INF]*(2**N)
dp[0]=0
for i in range(len(keys)):
  for j in range(len(dp)-1,-1,-1):
    if dp[j]!=INF:
      dp[j|keys[i]]=min(dp[j|keys[i]],dp[j]+A[i])
      
print((-1,dp[-1])[dp[-1]!=INF])

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << endl;
#define CFYN(n) cout << ( (n) ? "YES":"NO") << endl;
using ll = long long;
using ull = unsigned long long;

int main(void)
{
    IOS
    int k,x;
    cin >> k >> x;

    for(auto i = x-(k-1);i <= x+(k-1);i++) {
        cout << i << " ";
    }

    return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int A[] = new int[N];
		for(int i=0;i<N;i++)A[i]=sc.nextInt();
		sc.close();
		
		long X[] = new long[N];
		for(int i=0;i<N;i++)X[i]=0;//initialized
		
		for(int i=0;i<N;i++){
			if(i%2==0) X[0]+=A[i];
			else X[0]-=A[i]; 
		}
		for(int i=1;i<N;i++){
			X[i]=(long)2*A[i-1]-X[i-1];
		}
		
		StringBuilder sb = new StringBuilder();
		for(int i=0;i<N;i++){
			sb.append(X[i]+ " ");
		}
		System.out.println(sb.toString());
	}
}


Measured memory_bytes: 62548
h,w = map(int,input().split())
a = [[int(i) for i in input().split()] for _ in range(h)]
ans = []
for i in range(h):
    if i%2 == 0:
        for j in range(w):
            if a[i][j]%2 == 1:
                if j != w-1:
                    a[i][j+1] += 1
                    ans.append((i+1,j+1,i+1,j+2))
                elif i != h-1:
                    a[i+1][j] += 1
                    ans.append((i+1,j+1,i+2,j+1))
    else:
        for j in range(w)[::-1]:
            if a[i][j]%2 == 1:
                if j != 0:
                    a[i][j-1] += 1
                    ans.append((i+1,j+1,i+1,j))
                elif i != h-1:
                    a[i+1][j] += 1
                    ans.append((i+1,j+1,i+2,j+1))
print(len(ans))
for a in ans: print(*a)

Measured memory_bytes: 26172
#include<iostream>
#include <string> 
#include <vector>  
#include<math.h>

#define INF 1000000000
using namespace::std;



long Lmax(long x, long y) {
	if (x > y)return x;
	return y;
}

int max(int x, int y) {
	if (x > y)return x;
	return y;
}

long Lmin(long x, long y) {
	if (x < y)return x;
	return y;
}


int min(int x, int y) {
	if (x < y)return x;
	return y;
}

int abs(int x) {
	if (x < 0) {
		return -x;
	}
	return x;
}

long long N,wa, K,c,ans,a,b,d;

int main() {
	cin >> N;
	K = 1;
	c = 1;
	while (N > 0) {
		if (N%c == N) {
			c/=10;
			K--;
			break;
		}
		K++;
		c *= 10;
	}
	long k = 10;
	long n = N;
	while (n > 0) {
		wa += n % k;
		n -= n % k;
		n /= 10;
	}
	if (K > 1) {
		for (int i = 1; i <= 10; i++) {
			if (N - (c*i) < 0) {
				a = i - 1;
				break;
			}
		}
		for (int i = 1; i <= 10; i++) {
			if (N - ((c / 10)*i) - (a*c) < 0) {
				b = i - 1;
				break;
			}
		}
		d = 1;
		if (a + b <= a + 8&&a!=1){
			a--;
			b = 9;
			d = 0;
		}


		ans = Lmax(9 * (K-1), a+b+((K-2)*9)-d);
		ans = Lmax(ans, wa);
		cout << ans << endl;
	}
	else {
		cout << N << endl;
	}
	return 0;
}




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

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

Measured memory_bytes: 3856
#include<iostream>
using namespace std;
long long a,b,c,d;
int main()
{
	cin>>a>>b>>c>>d;
	if(a+b==c+d)
	cout<<"Balanced"<<endl;
	if(a+b>c+d)
	cout<<"Left"<<endl;
	if(a+b<c+d)
	cout<<"Right"<<endl;
	return 0;
}

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

using namespace std;
typedef long long ll;
//typedef unsigned long long ll;

#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define sz(x) ll(x.size())
//typedef pair<ll, int> P;
//typedef pair<ll, ll> P;
//const double INF = 1e10;
//const ll INF = LONG_LONG_MAX / 10;
//const ll INF = 1e15;
const ll MINF = LONG_LONG_MIN;
const int INF = INT_MAX / 10;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
//typedef pair<int, int> P;
typedef pair<double, double> P;

bool contain(set<P> &s, P a) { return s.find(a) != s.end(); }

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);


void print_line(vector<int> &line) {
    if (line.size() == 0ll) {
        cout << endl;
        return;
    }
    for (ll i = 0; i < line.size(); i++) {
        cout << line[i];
        if (i == line.size() - 1) cout << endl;
        else cout << ' ';
    }
}


typedef priority_queue<long long, vector<long long>, greater<long long>> PQ_ASK;
const int mod = 1000000007;

int main() {

    int n;
    double w;
    cin >> n >> w;

    vector<P> items(n);
    rep(i, n) cin >> items[i].first >> items[i].second;

    sort(items.begin(), items.end(), [](P p, P q) {
        return p.first / p.second > q.first / q.second;
    });

    double sum_weight = 0;
    double sum_value = 0;

    rep(i, n) {
        double nokori = w - sum_weight;
        P p = items[i];
        if (nokori >= p.second) {
            sum_weight += p.second;
            sum_value += p.first;
        } else {
            sum_weight += nokori;
            sum_value += (p.first / p.second) * nokori;
        }
    }

    printf("%.20f\n", sum_value);

}


Measured memory_bytes: 4472
import math
n,k=map(int,input().split())
a=list(map(int,input().split()))

left=1
right=10**9
while left<right:
  cnt=0
  mid=(left+right)//2
  for i in range(n):
    cnt+=math.ceil(a[i]/mid)-1
  if cnt<=k:
    right=mid
  else:
    left=mid+1
print(left)

Measured memory_bytes: 104484
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text.RegularExpressions;

namespace MyProject
{
    class Program
    {
        static void Main(string[] args)
        {
#if Local
            var sw = new Stopwatch();
            sw.Start();
            Console.SetIn(new StreamReader("input.in"));
#endif

            var solver = new Solver();
            solver.Solve();
#if Local
            Console.WriteLine($"{sw.ElapsedMilliseconds}ms");
#endif
        }
    }

    class Solver
    {
        public void Solve()
        {
            var regex = new Regex("^(hi)+$");
            var S = Console.ReadLine();
            var answer = regex.IsMatch(S) ? "Yes" : "No";
            Console.WriteLine(answer);
        }
    }
}


Measured memory_bytes: 14040
#include<stdio.h>
int main(void){
    int x;
    scanf("%d",&x);
    switch(x%7){
        case 0:
        printf("thu\n");
        break;
        case 1:
        printf("fri\n");
        break;
        case 2:
        printf("sat\n");
        break;
        case 3:
        printf("sun\n");
        break;
        case 4:
        printf("mon\n");
        break;
        case 5:
        printf("tue\n");
        break;
        case 6:
        printf("wed\n");
    }
    return 0;
}


Measured memory_bytes: 2056
#include <bits/stdc++.h>
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define sz(x) int((x).size())
#define debug(x) cout << #x << ":" << x << ' ';
#define debugg(x) cout << #x << ":" << x << ' ' << "\n";
#define endl '\n'
#define ff first
#define ss second
#define L(X) ((X)<<1)
#define R(X) (((X)<<1)|1)
#define M(X,Y) (((X)+(Y))>>1)

using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

const int MAXN = 1e5 + 5;
const int MOD = 1e9 + 7;
const int INF = 0x3f3f3f3f;
const long long int LLINF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-9;
const double PI = acos(-1);

template<typename T>   T max_self(T& a, T b) { if (a < b) a = b; return a; }
template<typename T>   T min_self(T& a, T b) { if (a > b) a = b; return a; }
template<typename T>   T add(T x, T y) { return ((x % MOD)  + (y % MOD)) % MOD;}
template<typename T>   T mul(T x, T y) { return ((x % MOD) * (long long)(y % MOD)) % MOD;}
template<typename T>   T sub(T x, T y) { return add(x, -y + MOD);}
template<typename T>   T gcd(T a, T b) { return b ? gcd(b, a % b) : a;}
template<typename T>   T lcm(T a, T b) { return a / gcd(a, b) * b;}
template<typename T>   vector<T> read(vector<T>& v, int n) {v.resize(n); for (auto &x : v) cin >> x;}
template<typename T>   void trav(vector<T> &v) {for (int i = 0 ; i < (int)v.size() ; ++i) {cout << v[i]; if (i != (int)v.size() - 1) cout << ' ';}}
int lg2(long long x)   {   return 64 - __builtin_clzll(x) - 1;	}
int lg2(int x)   {   return 32 - __builtin_clzll(x) - 1;	}

struct pair_hash{
	template<class T1, class T2>
	size_t operator() (const pair<T1, T2> &p) const {
		auto h1 = hash<T1>{}(p.first);
		auto h2 = hash<T2>{}(p.second);
		return h1 ^ h2;
	}
};

int fast_mod(int x, int m = MOD) {
	while(x <= m) x -= m;
	if(x < 0) x += m;
	return x;
}

int mod_add(int x, int y) {
	return fast_mod(x + y);
}

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

	ll n;
	cin >> n;

	if(n & 1) {
		cout << 0 << endl;
		return 0;
	}

	ll ans = 0;
	n /= 2;

	while(n) {
		ans += n / 5LL;
		n /= 5LL;
	}

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
const int maxn=2e5+10;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	char d;
	cin>>d;
	int x=d-'A';
	if(x>=30)
    {
        cout<<'a'<<'\n';
    }
    else
        cout<<"A"<<'\n';



}


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

int n;
long long w[110], v[110];
long long dp[110][100010];

#define INF 10000000000000
#define VMAX 100010

int main(){
  long long W;
  cin >> n >> W;

  for(int i = 0;i < n;i++){
    cin >> w[i] >> v[i];
  }

  for(int i = 0;i < n;i++){
    for(int j = 0;j < VMAX;j++){
      dp[i][j] = INF;
    }
  }

  dp[0][0] = 0;

  for(int i = 0;i < n;i++){
    for(int j = 0;j < VMAX;j++){
      if(j < v[i]){
        dp[i+1][j] = dp[i][j];
      }else{
        dp[i+1][j] = min(dp[i][j], dp[i][j-v[i]] + w[i]);
      }
    }
  }

  int ans = 0;
  for(int i = 0;i < VMAX;i++) if(dp[n][i] <= W) ans = i;

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 80128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
bool ispalin(string s)
{
    ll n=s.length();
    bool fg=true;
	    for(int i=0;i<n/2;i++)
            if(s[i]!=s[n-i-1])
            fg=false;
            return fg;
}
int main()
{
	ll t;
	t=1;
	for(int x=1;x<=t;x++)
	{
	    string s;
	    cin>>s;
	    bool fg=true;
	    ll n=s.length();
	    string s1,s2;
	    for(int i=0;i<n;i++)
        {
            if(i==n/2)
                continue;
            if(i<n/2)
                s1+=s[i];
            else
                s2+=s[i];
        }
        if(ispalin(s) && ispalin(s1) && ispalin(s2))
            cout<<"Yes";
        else
            cout<<"No";
	}
}


Measured memory_bytes: 256
#include <string>
#include <vector>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<functional>
#include<list>
#include<deque>
#include<bitset>
#include<set>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include<cstring>
#include<sstream>
#include<complex>
#include<iomanip>
#include<numeric>
#include<cassert>
#include<random>
#define X first
#define Y second
#define pb push_back
#define rep(X,Y) for (int (X) = 0;(X) < (int)(Y);++(X))
#define reps(X,S,Y) for (int (X) = (int)(S);(X) < (int)(Y);++(X))
#define rrep(X,Y) for (int (X) = (int)(Y)-1;(X) >=0;--(X))
#define rreps(X,S,Y) for (int (X) = (int)(Y)-1;(X) >= (int)(S);--(X))
#define repe(X,Y) for ((X) = 0;(X) < (Y);++(X))
#define peat(X,Y) for (;(X) < (Y);++(X))
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()
#define eb emplace_back
#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())
#define Endl endl
#define NL <<"\n"

using namespace std;
using ll=long long;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
template<class T> using vv=vector<vector<T>>;
template<class T> inline bool MX(T &l,const T &r){return l<r?l=r,1:0;}
template<class T> inline bool MN(T &l,const T &r){return l>r?l=r,1:0;}
//#undef NUIP
#ifdef NUIP
#include "benri.h"
#else
#define out(args...)
#endif
#ifdef __cpp_init_captures
template<typename T>vector<T> table(int n, T v){ return vector<T>(n, v);}
template <class... Args> auto table(int n, Args... args){auto val = table(args...); return vector<decltype(val)>(n, move(val));}
#endif
const ll MOD=1e9+7; //998244353

int solve(vector<ll> a,string s){
	const int n=a.size();
	reverse(all(a));
	reverse(all(s));
	vector<ll> bs(60);
	auto add=
		[&](ll x)->bool{
			rep(d,60)if(x>>d&1)if(bs[d]) x^=bs[d];
			if(x==0) return false;
			rep(d,60)if(x>>d&1)if(bs[d]==0){
					rep(e,60)if(bs[e]>>d&1) bs[e]^=x;
					bs[d]=x;
					break;
				}
			return true;
		};
	rep(i,n)if(add(a[i]) && s[i]=='1') return true;
	return false;
}
		

int main(){
  ios_base::sync_with_stdio(false); cin.tie(0);
  cout<<fixed<<setprecision(0);
	int T;
	cin>>T;
	while(T--){
		int n;
		cin>>n;
		vector<ll> a(n);
		for(auto &x:a) cin>>x;
		string s;
		cin>>s;
		cout<<solve(a,s) NL;
	}
  return 0;
}


Measured memory_bytes: 3664
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>

using namespace std;

int main()
{
	int n;
	cin >> n;
	vector<int> c(n-1),s(n-1),f(n-1);
	for(int i=0;i<n-1;i++)
		cin >> c[i] >> s[i] >> f[i];
	
	vector<long long> ans(n,0);

	for(int i=0;i<n;i++)
	{
		for(int j=i;j<n-1;j++)
		{
			if(ans[i]<s[j])ans[i]=s[j];
			ans[i]+=(f[j]-((ans[i]-1)%f[j]+1)+c[j]);
		}
	}

	for(int i=0;i<n;i++)
		cout << ans[i] << endl;



	
}

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

int main() {
  int N;
  cin >> N;
  vector<int> a(N);
  for(int i=0; i<N; i++) cin >> a.at(i);
  
  sort(a.begin(),a.end());
  int Alice = 0;
  int Bob = 0;
  for(int i=N-1; i>=0; i-=2){
    Alice += a.at(i);
    if(i>0)  Bob += a.at(i-1);
  }
  cout << Alice-Bob << endl;
}



Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String a = sc.next();
        String b = sc.next();
        String c = sc.next();

        int ans = 0;

        for(int i=0; i<n; i++){
            int tmp = 0;
            char ca = a.charAt(i);
            char cb = b.charAt(i);
            char cc = c.charAt(i);
            if(ca == cb) tmp++;
            if(cb == cc) tmp++;
            if(cc == ca) tmp++;
            if(tmp == 0) ans += 2;
            if(tmp == 1) ans += 1;
        }

        System.out.println(ans);
    }
}

Measured memory_bytes: 22996
import java.util.Scanner;

public class Main {
	public static void main(String[] args){

		Scanner scan = new Scanner(System.in);

		int a = scan.nextInt();
		int b = scan.nextInt();

		if(a < b){
			System.out.println("a < b");
		}else if(a>b){
			System.out.println("a > b");
		}else if(a == b){
			System.out.println("a == b" );

		}
	}

}

Measured memory_bytes: 26144
import java.util.Scanner;

public class Main {


	void run() {
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int m = 100000;

		for(int i = 0; i < n; i++) {
			m += m * 5 / 100;

			int r = m % 1000;
			if(r != 0) {
				m += 1000 - r;
			}
		}

		System.out.println(m);

		sc.close();
	}

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

}

Measured memory_bytes: 17160
import java.util.*;
import java.io.PrintWriter;
public class Main{
	static int[][] xd;
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		long mod=998244353;
		xd=new int[n][2];
		SegTree st=new SegTree(n);
		for(int i=0; i<n; i++){
			xd[i][0]=sc.nextInt();
			xd[i][1]=sc.nextInt();
		}
		Arrays.sort(xd,(x,y)->(x[0]-y[0]));
		int[] max=new int[n];
		for(int i=n-1; i>=0; i--){
			int idx=bs(i,n,xd[i][0]+xd[i][1]-1);
			max[i]=Math.max(i,st.query(i+1,idx+1));
			st.set(i,max[i]);
		}
		long[] dp=new long[n+1];
		dp[n]=1;
		dp[n-1]=2;
		for(int i=n-2; i>=0; i--){
			dp[i]+=dp[i+1]+dp[max[i]+1];
			dp[i]%=mod;
		}
		System.out.println(dp[0]);
	}
	static int bs(int left,int right,int dis){
		int l=left;
		int r=right;
		while(r-l>1){
			int m=(r+l)/2;
			if(xd[m][0]<=dis){
				l=m;
			}else{
				r=m;
			}
		}
		return l;
	}
	static class SegTree{
		int n=1;
		int[] v;
		
		public SegTree(int n) {
			while(this.n<n)this.n*=2;
			v=new int[2*this.n-1];
		}
		
		void set(int k,int val) {
			k+=n-1;
			v[k]=val;
			while(k>0) {
				k=(k-1)/2;
				v[k]=Math.max(v[2*k+1],v[2*k+2]);
			}
		}
		
		int query(int a,int b) {
			return query(0,n,a,b,0);
		}
		
		int query(int l,int r,int a,int b,int k) {
			if(r<=a||b<=l)return 0;
			else if(a<=l&&r<=b)return v[k];
			else {
				int vl=query(l,(l+r)/2,a,b,2*k+1);
				int vr=query((l+r)/2,r,a,b,2*k+2);
				return Math.max(vl,vr);
			}
		}
	}
}


Measured memory_bytes: 123520
#include <iostream>
#include <vector>
#define rep(i, n) for(int i = 0; i < (n); ++i)
using namespace std;

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

  int n; cin >> n;
  vector<int> a(n);
  rep(i, n) {
    int t; cin >> t;
    a[i] = --t;
  }

  int now = 0;
  int cnt = 0;
  bool flag = false;
  while(n--) {
    if(now == 1) {
      flag = true;
      break;
    }
    cnt++;
    now = a[now];
  }
  cout << (flag ? cnt : -1) << '\n';
  return 0;
}


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



Measured memory_bytes: 3592
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <set>
#include <sstream>
#include <string>
#include <queue>
#include <vector>
using namespace std;

#define rep(i,n) for(int i=0; i<(n); ++i)
#define rrep(i,n) for(int i=1; i<=(n); ++i)
#define drep(i,n) for(int i=(n)-1; i>=0; --i)
#define foreach(it, v) for(typeof(v.begin()) it=v.begin(); it!=v.end(); ++it)
#define pb push_back
#define sz(x) (int)(x).size()
#define fi first
#define se second

typedef unsigned int uint;
typedef long long int ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector<pii> vpii;
typedef set<int> si;

//MOD//
const ll MOD = 1000000007;
struct big;
big ex(big a, ll tms);
typedef struct big{
  ll val;
  big():val(0){}
  big(ll val):val((val%MOD+MOD)%MOD){}
  big& operator += (const big& obj){ (val+=obj.val)%=MOD; return *this;}
  big& operator -= (const big& obj){ (val+=MOD-obj.val)%=MOD; return *this;}
  big& operator *= (const big& obj){ (val*=obj.val)%=MOD; return *this;}
  big& operator /= (const big& obj){ (val*=ex(obj,MOD-2).val)%=MOD; return *this;}
  big operator + (const big& obj)const{ return big(*this) += obj;}
  big operator - (const big& obj)const{ return big(*this) -= obj;}
  big operator * (const big& obj)const{ return big(*this) *= obj;}
  big operator / (const big& obj)const{ return big(*this) /= obj;}
  bool operator < (const big& obj)const{ return val < obj.val;}
  bool operator == (const big& obj)const{ return val == obj.val;}
} big;
istream& operator >> (istream& i, big& obj){ i>>obj.val; return i;}
ostream& operator << (ostream& o, const big& obj){ o<<obj.val; return o;}
big ex(big obj, ll tms){
  if(!tms) return 1;
  big ret = ex(obj, tms/2);
  ret *= ret;
  return (tms&1) ? ret*obj : ret;
}
//MOD//

ll pow(ll n, int m){
  if(!m) return 1;
  ll ret = pow(n, m/2);
  ret *= ret;
  return (m&1) ? ret*n : ret;
}

template <class F, class T>
void convert(const F &f, T &t){
  stringstream ss;
  ss << f;
  ss >> t;
}

int  N, M;
int cou[100000];
int red[100000];
int x,y;

int main(){
  scanf("%d%d",&N,&M);
  red[0] = 1;
  rep(i,N) cou[i] = 1;
  rep(i,M) {
    scanf("%d%d",&x,&y);
    x--;y--;
    if (red[x]) {
      red[y] = 1;
      if (cou[x]==1) red[x] = 0;
    }
    cou[x]--;
    cou[y]++;
  }
  int ans = 0;
  rep(i,N){
    ans += red[i];
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int n,i,len=0,c=0,p=0;
    cin>>n;
    long long int a[n+2];
    for(i=0; i<n; i++)
    {
        cin>>a[i];

    }
    len=(n/2);
    p=0;
    //cout<<p<<endl;
    for(i=0; i+1<n; i++)
    {
        if(a[i]>=a[i+1])
        {
            //cout<<a[i+1]<<endl;
            c++;
        }
        else
        {
            p=max(c,p);
            c=0;
        }
//cout<<c<<endl<<p<<endl;
    }


    cout<<max(c,p)<<endl;


}


Measured memory_bytes: 1024
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		while(scan.hasNext()){
			int n = scan.nextInt();
			int k = scan.nextInt();
			int x = 0;
			int y = 0;
			int t = 0;
			for(int i = 0;i < k;i++){
				x = scan.nextInt();
				y = scan.nextInt();
				x = (x > n/2)?n+1-x:x;
				y = (y > n/2)?n+1-y:y;
				t = (x < y)?x%3:y%3;
				System.out.println((t==0)?3:t);
			}
		}
	}
}

Measured memory_bytes: 25184
#include <stdio.h>
#include <iostream>
#include <climits>
#include <map>
#include <cmath>
#include <algorithm>
#include <set>
#include <stack>
#include <deque>
#include <vector>
#include <stdlib.h>
#include <string>
#include <string.h>
#include <utility>
#include <queue>

using namespace std;

#define ll long long
#define sl(n) scanf("%lld", &n)
#define sf(n) scanf("%lf", &n)
#define si(n) scanf("%d", &n)
#define ss(n) scanf("%s", n)
#define pii pair <int, int>
#define pll pair <int, int>
#define plp pair <int, pll >
#define pb push_back

int main ()
{
  //  freopen("in.txt", "r", stdin);
   // freopen("out.txt", "w", stdout);
  //  ios_base::sync_with_stdio(0); // no printf/scanf must be present
    ll cs, t, i, j, k, x, y, z, ans, q, m, n;

    sl(x);
    sl(y);

    if (x > y)
        swap(x, y);

    if ((y-x) >= 2)
        printf("Alice\n");
    else printf("Brown\n");

    return 0;
}


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

int main()
{
    int n;
    std::vector<int> a;
    std::vector<int> b;
    std::cin>>n;
    a.resize(n);
    b.resize(n);
    for(int i=0;i<n;i++)std::cin>>a[i];
    b = a;
    std::sort(b.begin(),b.end(),std::greater<int>());
    for(int i=0;i<n;i++){
        if(a[i]==b[0])std::cout<<b[1]<<std::endl;
        else std::cout<<b[0]<<std::endl;
    }
    return 0;
}


Measured memory_bytes: 3200
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <deque>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <utility>
#include <algorithm>
#include <numeric>
#include <typeinfo>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <ctime>

using namespace std;

#define dump(n) cout<<"# "<<#n<<"="<<(n)<<endl
#define debug(n) cout<<__FILE__<<","<<__LINE__<<": #"<<#n<<"="<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,n) repi(i,0,n)
#define iter(c) __typeof((c).begin())
#define foreach(i,c) for(iter(c) i=(c).begin();i!=(c).end();i++)
#define allof(c) (c).begin(),(c).end()
#define mp make_pair

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;

typedef complex<double> Point;

const double EPS=1e-10;

bool Equal(double a,double b)
{
	return abs(a-b)<EPS;
}

bool Less(double a,double b)
{
	return a+EPS<b;
}

bool LessEqual(double a,double b)
{
	return a-EPS<b;
}

bool Greater(double a,double b)
{
	return a>b+EPS;
}

bool GreaterEqual(double a,double b)
{
	return a>b-EPS;
}

double Cross(Point a,Point b)
{
	return imag(conj(a)*b);
}

int main()
{
	for(string s;cin>>s,s!="0";){
		double d=atof(s.c_str());
		Point p,v;
		cin>>real(p)>>imag(p)>>real(v)>>imag(v);
		if(Greater(abs(p),1))
			puts("impossible");
		else if(!Equal(Cross(p,v),0)){
			puts("impossible");
		}
		else{
			double res;
			if(Equal(arg(p),arg(v)))
				res=2-abs(p);
			else
				res=abs(p);
			if(Greater(res,d))
				puts("impossible");
			else
				printf("%f\n",res);
		}
	}
	
	return 0;
}

Measured memory_bytes: 0
#include<stdio.h>
int main(void){
	int a,b;
	int i = 1;
	int outlet;
	scanf("%d %d",&a,&b);
	if(b == 1) {
	    puts("0");
	    return 0;
	}
	outlet = a;
	while(outlet < b){
		outlet += a - 1;
		i++;
	}
	printf("%d",i);
	return 0;
}


Measured memory_bytes: 128
from collections import Counter
import sys

input = sys.stdin.readline
n = int(input())
str_list = [''.join(sorted(input().rstrip())) for i in range(n)]
ans = 0
count_list = list(Counter(str_list).values())
for i in count_list:
  sum = 0
  for j in range(int(i)):
    sum += j
  ans +=sum
print(ans)

Measured memory_bytes: 19760
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int T = sc.nextInt();
        int minc = 1001;
        for(int i=0; i<n; i++){
            int c = sc.nextInt();
            int t = sc.nextInt();
            if(T >= t){
                if(minc > c) minc = c;
            }
        }
        if(minc == 1001) System.out.println("TLE");
        else System.out.println(minc);
    }
}

Measured memory_bytes: 21716
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define PI 3.1415926535897932
#define MOD 1000000007;
using namespace std;
long long GCD(long long A,long long B){
  if(B==0){
    return A;
  }
  else{
    return GCD(B,A%B);
  }
}
long long LCM(long long A,long long B){
  long long g=GCD(A,B);
  return A/g*B;
}
long long num_order(long long X){
  long long ans=0;
  while(true){
    if(X==0){
      break;
    }
    else{
      X/=10;
      ans++;
    }
  }
  return ans;
}
int main() {
  
  int N,H,W;
  cin>>N>>H>>W;
  
  cout<<(N-(H-1))*(N-(W-1));
}

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

int main(){
  int N;
  cin >> N;
  vector<int> a(N);
  int count = 0;
  for (int i=0; i<N; i++)
    cin >> a[i];
  set<int> s;
  for (int i=0; i<N; i++){
    if (a[i] < 3200)
      s.insert(a[i]/400);
    else count++;
  }
  int maxi = s.size() + count;
  int mini;
  if (s.size() == 0)
    mini = 1;
  else
    mini = s.size();
  cout << mini << ' ' << maxi << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N,K,A,answer = 0;
  map<int,int> B;
  for (cin >> N >> K; N; N--, B[A]++) {
    cin >> A;
  }
  int C[B.size()], n = 0;
  for (auto p : B) {
    C[n++] = p.second;
  }
  sort(C,C+n);
  for (int i = 0; i < n-K; i++) {
    answer += C[i];
  }
  cout << answer;
}

Measured memory_bytes: 13756