akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define debug(x)        cout<<#x<<" :"<<x<<endl;
#define ff              first
#define ss              second
#define ar              array
#define int             long long
#define ld              long double
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define f(i,n)          for(int i=0;i<n;i++)
#define MOD             1000000007
#define pi              3.14159265
#define umii            unordered_map<int,int>
#define umci            unordered_map<char,int>
#define umsi            unordered_map<string,int>

void k_007()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

#ifndef ONLINE_JUDGE
	freopen("ip1.txt", "r", stdin);
	freopen("op1.txt", "w", stdout);
#endif
}

bool sortbysec(const pair<int, int> &a, const pair<int, int> &b)
{
	return (a.second < b.second);
}
int gcd(int a, int b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
int prime(int n) {
	int flag = 1;
	for (int i = 2; i <= sqrt(n); i++) {
		if (n % i == 0) {flag = 0; break;}
	}
	return flag;
}
int power(int x, int y)
{
	if (y == 0)
		return 1;
	else if (y % 2 == 0)
		return ((power(x, y / 2) % MOD) * ( power(x, y / 2) % MOD)) % MOD;
	else
		return ((x % MOD) * (power(x, y / 2) % MOD) * (power(x, y / 2) % MOD)) % MOD;
}
int lcm(int a, int b)
{
	return (a * b) / gcd(a, b);
}
int32_t main()
{
	k_007();
	// int JUDGE_ONLINE = 1;
	// if (fopen("ip1.txt", "r")) {
	// 	JUDGE_ONLINE = 0;
	// 	assert(freopen("ip1.txt", "r", stdin));
	// 	assert(freopen("op1.txt", "w", stdout));
	// }
	string s, t;
	int n;
	cin >> n;
	cin >> s >> t;
	for (int i = 0; i < n; i++)
	{
		cout << s[i] << t[i];
	}
	// if (!JUDGE_ONLINE) {
	// 	cout << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
	// }
}


Measured memory_bytes: 3640
#include<queue>
#include<string>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long LL;
int read()
{
	int s=0;int c=getchar(),f=1;
	while(c<48||c>57)
	{
		if(c==45) f=-1;
		c=getchar();
	}
	while(c>=48&&c<=57) s=(s<<3)+(s<<1)+(c^48),c=getchar();
	return s*f;
}
void write(int x)
{
	if(x>=10) write(x/10);
	putchar(x%10+48);
}
void W(int x)
{
	if(x<0) x=-x,putchar(45);
	write(x);
}
int main()
{
	int a=read();
	string s;
	cin>>s;
	int b=0,c=0;
	for(int i=0;i<a;++i) 
	{
		if(s[i]=='R') ++b;
		else ++c;
	}
	if(b>c) puts("Yes");
	else puts("No");
	return 0;
}

Measured memory_bytes: 256
// ~/Remember,remember the 6th of March

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const double PI = acos(-1.0);
const double  EPS = 1e-8;
const ll MOD = 1000000007;
const int N = 100000 + 7;

int n;
vector<int>arr;
ll ans;
int main()
{
    cin>>n;
    arr.resize(n);
    for(int &i:arr)cin>>i;
    sort(arr.begin(),arr.end());
    for(int i=0;i<n;i++)
        for(int j=i+1;j<n;j++)
            ans+=(lower_bound(arr.begin(),arr.end(),arr[i]+arr[j])-arr.begin())-j-1;
    cout<<ans<<endl;
    return 0;
}


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

using namespace std;

namespace {

    typedef double real;
    typedef long long ll;

    int N, M, S, T;
    vector< vector<int> > G;
    void input() {
        cin >> N >> M >> S >> T;
        S--; T--;
        G.resize(N);
        for (int i = 0; i < M; i++) {
            int x, y; cin >> x >> y; x--; y--;
            G[x].push_back(y);
            G[y].push_back(x);
        }
    }

    const int INF = 1<<28;

    void dist(int s, vector<int>& d) {
        d.clear(); d.resize(N, INF);
        d[s] = 0;
        queue< pair<int, int> > Q;
        Q.push(make_pair(s, 0));
        while (not Q.empty()) {
            pair<int, int> c = Q.front(); Q.pop();
            for (int i = 0; i < G[c.first].size(); i++) {
                int n = G[c.first][i];
                if (d[n] > c.second + 1) {
                    d[n] = c.second + 1;
                    Q.push(make_pair(n, c.second + 1));
                }
            }
        }
    }

    void solve() {
        vector<int> d1; dist(S, d1);
        vector<int> d2; dist(T, d2);
        int d = d1[T];
        vector<int> D = d2;
        sort(D.begin(), D.end());
        ll ans = 0;
        for (int i = 0; i < N; i++) {
            int k = d - d1[i] - 2;
            if (k < 0) continue;
            ans += upper_bound(D.begin(), D.end(), k) - lower_bound(D.begin(), D.end(), k);
        }
        cout << ans << endl;
    }
}

int main() {
    input(); solve();
    return 0;
}

Measured memory_bytes: 8632
#include <stdio.h>
#include <stdlib.h>

int compare(const void *a,const void *b){
    return *(int*)a-*(int*)b;
}
int main(void){
    int n;
    long sum=0;
    scanf("%d",&n);
    int a[n],i;
    for(i=0;i<n;i++){
        scanf("%d",&a[i]);
        sum+=a[i];
    }
    qsort(a,n,sizeof(int),compare);
    printf("%d %d %ld\n",a[0],a[n-1],sum);
    return 0;
}


Measured memory_bytes: 2056
import java.util.*;
class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        long n = sc.nextInt();
        long a = 0;
        a = n / 500;
        n = n % 500;
        n = n / 5;
        n = n * 5;
        a = a * 1000;
        System.out.println(a + n);
    } 
}

Measured memory_bytes: 21588
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <unordered_map>
#include <functional>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cstdlib>

using namespace std;
typedef long long llong;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<llong, llong> pll;

const int MAXN = 5e5 + 1;
int n, k;
int arr[MAXN];
int rev[MAXN];
int ord[MAXN];
int ans[MAXN];
vector<int> edge[MAXN];
int seg[1 << 20];

void update(int i, int s, int e, int x, int v) {
    seg[i] = min(seg[i], v);
    if (s == e) return;
    int m = (s + e) / 2;
    if (x <= m) update(i << 1, s, m, x, v);
    else update(i << 1 | 1, m + 1, e, x, v);
}

int query(int i, int s, int e, int x, int y) {
    if (e < x || y < s) return n + 1;
    if (x <= s && e <= y) return seg[i];
    int m = (s + e) / 2;
    return min(query(i << 1, s, m, x, y), query(i << 1 | 1, m + 1, e, x, y));
}

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0);
	cin >> n >> k;
	for (int i = 1; i < (1 << 20); ++i) seg[i] = n + 1;
	for (int i = 1; i <= n; ++i) {
        cin >> arr[i];
        rev[arr[i]] = i;
	}
	
	for (int i = n; --i; ) {
        update(1, 1, n, rev[i + 1], i + 1);
        int ret;
        if ((ret = query(1, 1, n, rev[i] + 1, rev[i] + k - 1)) <= n) {
            edge[rev[ret]].push_back(rev[i]);
            ++ord[rev[i]];
        }
        if ((ret = query(1, 1, n, rev[i] - k + 1, rev[i] - 1)) <= n) {
            edge[rev[ret]].push_back(rev[i]);
            ++ord[rev[i]];
        }
	}
	
	priority_queue<int> pq;
	for (int i = 1; i <= n; ++i) {
        if (ord[i] == 0) pq.push(i);
	}
	
	for (int i = n; i; --i) {
        int x = pq.top();
        pq.pop();
        ans[x] = i;
        for (int j : edge[x]) {
            if (--ord[j] == 0) pq.push(j);
        }
	}
	
	for (int i = 1; i <= n; ++i) {
        printf("%d\n", ans[i]);
	}
	
	return 0;
}


Measured memory_bytes: 43392
#include <iostream>
#include <vector>
#include <array>
#include <deque>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <complex>
#include <bitset>
#include <functional>

using namespace std;
using ll=long long int;

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    for (auto &e: a) cin >> e;

    int ans = 0;
    for (int h: a) {
        if (h >= k) ++ans;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 768
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <vector>
#include <algorithm>
#include <map>

int main (){
	int a[4];
	std::string S;
	std::cin>>S;
	a[0] = int(S[0]) - int('0');
	a[1] = int(S[1]) - int('0');
	a[2] = int(S[2]) - int('0');
	a[3] = int (S[3]) - int('0');
	for (int i=0; i<(1<<4); i++){
		int ans = a[0];
		for (int j=0; j<3; j++){
			if ((i & 1<<j) !=0){ // +のとき
				ans += a[j+1];
			} else { // -のとき
				ans -= a[j+1];
			}
		}
		if (ans==7){
			printf("%d%c%d%c%d%c%d=7\n",a[0],(i & 1<<0) !=0 ? '+' : '-', a[1], (i & 1<<1) !=0 ? '+' : '-',a[2], (i & 1<<2) !=0 ? '+' : '-',a[3]);
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
    long long x,y,p,i,q,r=0;
    cin>>x>>y;
    if(y%2!=0)
    {
        cout<<"No"<<endl;
    }
    else
    {
        p=y/2;
        q=y/4;
        if(y%4!=0)
        {
            q++;
        }
        for(i=p;i>=q;i--)
        {
            if(i==x)
            {
                r++;
                cout<<"Yes"<<endl;
                break;
            }
        }
        if(r==0)
        {
            cout<<"No"<<endl;
        }
    }
    return 0;
}

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

int main() {
  int K, S;
  cin >> K >> S;

  int count=0;
  int Z;
  for(int X=0; X<=K; X++)
    for(int Y=0; Y<=K; Y++) {
      Z=S-(X+Y);
      if(0<=Z && Z<=K) count++;
    }
  cout << count << endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    int N;
    int A[200];
    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }
    int count = 0;
    int is_even = true;
    while(is_even) {
        for (int i = 0; i < N; i++) {
            if (A[i] % 2 == 0) {
                A[i] /= 2;
            } else {
                is_even = false;
            }
        }
        if (is_even) {
            count++;
        }
    }
    cout << count << endl;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i, c) for(long long i=0; i<(long long)c; i++)
const ll INF=1000000000000001;
//146813779479510
//1000000000000001
int main() {
	ll n;
	int ans=0;
	string s,t;
	cin>>s>>t;
	rep(i,s.length()){
		if (s[i]!=t[i]) ans++;
	}
	cout <<ans << endl;
	return 0;
}


Measured memory_bytes: 3856
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        
        int a = scanner.nextInt();
        int b = scanner.nextInt();
        int c = scanner.nextInt();
        
        if (a < b) {
            if (b < c){
                System.out.println("Yes");
                return;
            }
        }
        
        System.out.println("No");
        
    }
}


Measured memory_bytes: 26272
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n,k; cin >> n >> k;
  vector<int> a(n);
  REP(i,n) cin >> a[i];
  if(n-1<=k){
    REP(i,n) cout << n << " ";
    cout << '\n';
    return 0;
  }

  REP(kk,k){
    vector<int> tmp(n, 0);
    REP(i,n){
      tmp[max(0,i-a[i])]++;
      if(i+a[i]+1<=n-1) tmp[i+a[i]+1]--;
    }
    REP(i,n-1) tmp[i+1] += tmp[i];

    a = tmp;
    bool flag = true;
    REP(i,n) if(a[i]<n) flag = false;
    if(flag) break;
  }

  REP(i,n) cout << a[i] << " ";
  cout << '\n';
  return 0;
}


Measured memory_bytes: 4812
package main

import (
	"fmt"
	"sort"
	"strconv"
	"strings"
)

func main() {
	var a, b int
	fmt.Scan(&a, &b)

	repeat_b := strings.Repeat(strconv.Itoa(b), a)
	repeat_a := strings.Repeat(strconv.Itoa(a), b)

	ans := []string{repeat_a, repeat_b}
	sort.Strings(ans)

	fmt.Println(ans[0])
}


Measured memory_bytes: 640
// include
// ------------------------------------------------
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;

// func
// ------------------------------------------------
int CalcSumOfDigit(int n);      // 各桁の和を計算する。
long long getDigit(long long n);      // 数字の桁数を取得する。
string upper(string str);       // 英字を大文字に変換する。
string lower(string str);       // 英字を小文字に変換する。

// define
// ------------------------------------------------
#define all(a)        (a).begin(),(a).end()
#define rall(a)       (a).rbegin(),(a).rend()
#define sz(a)         int((a).size())
#define rep(i,n)      for(int(i)=0;(i)<(n);(i)++)
#define repe(i,n)     for(int(i)=0;(i)<=(n);(i)++)
#define vsort(v)      sort((v).begin(),(v).end())
#define rvsort(v)     sort(rall((v)))
#define vi            vector<int>
#define GCD(a,b)      __gcd((a),(b))
#define LCM(a,b)      ((a)/GCD((a),(b))*(b))
#define kiriage(a,b)  ((a)+(b)-1)/(b)

const int INF = 1e9;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vll;

// code
// ------------------------------------------------
int main()
{
  ll n,m;
  cin >> n >> m;

  ll ans;
  if(n == 1 && m == 1)
  {
    ans = 1;
  }
  else if(n == 1)
  {
    ans = m - 2;
  }
  else if (m == 1)
  {
    ans = n - 2;
  }
  else if(n == 2 || m == 2)
  {
    ans = 0;
  }
  else
  {
    ans = (n - 2) * ( m - 2);
  }
  
  cout << ans << endl;


  return 0;
}
// funcの実体
// ------------------------------------------------
ll getDigit(ll n)
{
  int i = 1;
  while(1)
  {
    n = n / 10;
    if(n == 0)
      break;
    i++;
  }
  return i;
}
ll CalcSumOfDigit(ll n)
{
  ll s = 0;
  while(n)
  {
    s += n % 10;
    n = n / 10;
  }
  return s;
}

string upper(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(97 <= *itr && *itr <= 122)
    {
      *itr = *itr - 32;
    }
  }
  return str;
}

string lower(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(65 <= *itr && *itr <= 90)
    {
      *itr = *itr + 32;
    }
  }
  return str;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxn=1000000+10;
struct node{
    int a,b;
}x[maxn];
bool cmp(node i,node j){
    return i.a<j.a;
}
int main()
{
    int n,m;
    scanf("%d %d",&n,&m);
    for(int i=0;i<n;i++){
        scanf("%d %d",&x[i].a,&x[i].b);
    }
    sort(x,x+n,cmp);
    int ans=0,cur=0;
    priority_queue<int>que;
    for(int i=1;i<=m;i++){
        while(x[cur].a<=i && cur<n){
            que.push(x[cur].b);
            cur++;
        }
        if(que.empty()) continue;
        ans+=que.top();
        que.pop();
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 1660
def main():
    N, Y = map(int, input().split())
    for a in range(N+1):
        b = 0
        while a + b <= N:
            c = N - a - b

            total = 10000 * a + 5000 * b + 1000 * c
            if total == Y:
                print(a, b, c)
                return
            b += 1
    print(-1, -1, -1)


if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long m=1000000007,ans;
  int x,y,a,b;cin>>x>>y;
  if((x+y)%3==0){ 
    a=(2*y-x)/3;b=(2*x-y)/3;
    if(a<0||b<0)cout<<0<<endl;
    else{
    long long p=1,q=1;
    for(int i=a+b;i>a;i--){
      p*=i;
      p=p%m;
      q*=i-a;
      q=q%m;
    }
    for(int i=0;i<m;i++){
      if(i*q%m==p){ans=i;break;}
    }
    cout<<ans<<endl;  
    }
  }
  else cout<<0<<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;




    int main(){
        int n, d;
        std::cin >> n >> d;
        std::vector<std::vector<int>> x(n, std::vector<int> (d));
        rep(i, n){
            rep(j, d){
                std::cin >> x[i][j];
            }
        }

        int ans = 0;
        for (int i = 0; i < n; ++i)
        {
            for (int j = i+1; j < n; ++j)
            {
                int norm = 0;
                for (int k = 0; k < d; ++k)
                {
                    int diff = abs(x[i][k] - x[j][k]);
                    norm += diff * diff;
                    
                }
                bool flag = false;
                for (int k = 0; k <= norm; ++k)
                {
                    if (k * k == norm)
                    {
                        /* code */flag = true;
                    }
                }
                if(flag) ++ans;
            }
        }
        std::cout << ans << "\n";
    }


Measured memory_bytes: 256
#include <stdio.h>

int bubbleSort(int A[], int N)
{
  int flag=1,i,j,a,b,count=0;
  while(flag==1){
    flag=0;
    for(j=N-1;j>= 1;j--){
      if(A[j]<A[j-1]){
	a=A[j];
	b=A[j-1];
	
	A[j]=b;
	A[j-1]=a;
	flag=1;
	count++;
      }
    }
  }
  return count;
}


int main(){
  int i,j,N,count;
   scanf("%d",&N);
 
  int A[N];
  for(i=0; i<N ;i++){
    scanf("%d",&A[i]);
  }

  count=bubbleSort(A,N);

  for(j=0;j<N;j++){
    if(j>0) printf(" ");
    printf("%d",A[j]);
  }
  printf("\n");
  printf("%d\n",count);

  
  return 0;
}



Measured memory_bytes: 2048
/*Made by Shivam Solanki*/
#include<bits/stdc++.h> 
using namespace std;
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define ll long long int
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vll> vvl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef vector<pii> vp;
typedef vector<pll> vpll;
typedef map<int,int> mii;
typedef map<ll,ll> mll;
typedef set<int> sii;
typedef set<ll> sll;
typedef priority_queue<int> pq;
typedef unordered_map<int,int> umii;
typedef unordered_map<ll,ll> umll;
typedef queue<int> qii;
#define rep(i,k,n) for (int i = k; i < n; ++i) 
#define repr(i,k,n) for (int i = n; i>=k; --i)
#define repll(i,k,n) for (ll i = k; i < n; ++i) 
#define repllr(i,k,n) for (ll i = n; i >= k; --i) 
#define pb push_back
#define mp make_pair
#define gcd __gcd
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
const int INF = 1e9+5;
const int MOD = 1e9+7;

void solve(){
    int n,k;
    cin>>n>>k;
    vi h(n);
    rep(i,0,n) cin>>h[i];
    sort(all(h),greater<int>());
    ll sum=0;
    rep(i,k,n){
        sum+=h[i];
    }
    cout<<sum;
}
    
int main(){
    // #ifndef ONLINE_JUDGE  
        // freopen("input.txt", "r", stdin); 
        // freopen("output.txt", "w", stdout); 
    // #endif 
    // fastio;
    int t=1;
    // cin>>t;
    while(t--)
        solve();
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
using namespace std;
int main(){
	int car[100],num,i=0;
	while(cin>>num){
		if(num==0){
			i--;
			cout<<car[i]<<endl;
		}else{
			car[i]=num;
			i++;
		}
	}
	return 0;
}

Measured memory_bytes: 3012
using System;
using System.Linq;

namespace Sample101
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            int[,,] count = new int[4,3,10];
            for (int i = 0; i < n; i++)
            {
                var line = Console.ReadLine().Split(' ').Select(str => int.Parse(str)).ToArray();
                count[line[0] - 1, line[1] - 1, line[2] - 1] += line[3];
            }

            for (int k = 0; k < count.GetLength(0); k++)
            {
                for (int j = 0; j < count.GetLength(1); j++)
                {
                    for (int i = 0; i < count.GetLength(2); i++)
                    {
                        Console.Write(" " + count[k, j, i]);
                    }
                    Console.WriteLine();
                }
                if (k < count.GetLength(0) - 1)
                {
                    Console.WriteLine("####################");
                }
            }
        }
    }
}


Measured memory_bytes: 16232
import sys
from copy import deepcopy

sys.setrecursionlimit(10 ** 7)
rl = sys.stdin.readline


def solve():
    H, W, K = map(int, rl().split())
    c = [list(rl().rstrip()) for _ in range(H)]
    
    ans = 0
    for sh in range(1 << H):
        for sw in range(1 << W):
            cc = deepcopy(c)
            for y in range(H):
                if sh >> y & 1:
                    for x in range(W):
                        cc[y][x] = '.'
            for x in range(W):
                if sw >> x & 1:
                    for y in range(H):
                        cc[y][x] = '.'
            cnt = 0
            for y in range(H):
                for x in range(W):
                    cnt += cc[y][x] == '#'
            ans += cnt == K
    print(ans)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 72364
#include<bits/stdc++.h>
#define ll          long long int
#define lld          long double
#define pb          push_back
#define pii         pair<ll,ll>
#define mi          map<ll,ll>
#define vec         vector<ll>
#define all(a)     (a).begin(),(a).end()
#define F           first
#define S           second
#define mod         1000000007
#define nmod         -1000000007
#define N            1000000//31630=sqrt(pow(10,9))
#define rep(i,a,b)	for(ll  i=a;i<b;i++)
#define repi(i,a,b)	for(ll  i=a;i<=b;i++)
#define per(i,a,b)  for(ll i=a;i>=b;i--)
#define mp          make_pair
#define mit         map<ll,ll>::iterator
#define sit         set<ll>::iterator
#define pit         pair<ll,ll>::iterator
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
using namespace std;
ll xo(ll x, ll y) 
{ 
   return (x | y) & (~x | ~y); 
}  
ll bin_Expo(ll x,ll n)
{
		if(x==0)
		return 0;
    if(n==0)
        return 1;
    else if(n%2 == 0)        //n is even
        return bin_Expo(x*x,n/2);
    else                             //n is odd
        return x*bin_Expo(x*x,(n-1)/2);
}
ll mod_Expo(ll x,ll n,ll M)
{
		if(x==0)
		return 0;
    if(n==0)
        return 1;
    else if(n%2 == 0)        //n is even
        return mod_Expo((x*x)%M,n/2,M);
    else                             //n is odd
        return (x*mod_Expo((x*x)%M,(n-1)/2,M))%M;
 
}
//bool pf[N+1ll];
//vec prim;
//void sieve()
//{
//    repi(i,0,N)
//    pf[i]=true;
//	pf[0] = pf[1] = false;
//    for (int i = 2; i <= N; i++) {
//        if (pf[i]) 
//		{
//            prim.push_back(i);
//            for (int j = i + i; j <= N; j+=i) {
//                pf[j] = false;
//            }
//        }
//    }
//}
bool prime_check(ll x)
{
    bool prime = (x >= 2);
    for (ll i = 2; i * i <= x; i++) 
    {
        if (x % i == 0) 
        {
            prime = false;
            break;
        }
    }
    return prime;
}
ll logg(ll base,ll x) 
{
    return (ll)(log(x) / log(base));
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int TESTS=1;
//	cin>>TESTS; 
    while(TESTS--)
    {
    	ll m,i,l,h,j,mx,my,ans,d,n,r,g,b,e,f;
//    	cin>>m;
//    	cout<<fixed<<setprecision(10);
//    	lld k=M_PI;
//    	k=k*(2.00)*(m*1.00);
//    	cout<<k;
    	cin>>n;
    	ll a[n+5];
    	repi(i,0,n+3)
    	a[i]=0;
    	rep(i,0,n-1)
    	{
    		cin>>j;
    		a[j]++;
		}
    	repi(i,1,n)
    	cout<<a[i]<<'\n';
	}
	return 0;
} 

Measured memory_bytes: 5156
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<numeric>
#include<cmath>
#include<queue>
#include<stack>
#include<list>
#include<unordered_map>
#include<unordered_set>
#include<cctype>
#include<iomanip>

using namespace std;
typedef long long int ll;typedef pair<int, int> P;
const long long mod = 1e9 + 7;
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(a) (a).begin(),(a).end()
#define allg(a) (a).begin(),(a).end(),greater<>()
const double PI = 3.14159265359;

int main(void) {
	ll n, m; cin >> n >> m;
	priority_queue<ll> q;
	rep(i, n) { ll a; cin >> a; q.push(a); }
	rep(i, m) { ll a = q.top(); q.pop(); q.push(a / 2); }
	ll sum = 0;
	rep(i, n) {
		sum += q.top();
		q.pop();
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 1400
#include<iostream>
#include<vector>
#include<queue>
using namespace std;
using Graph = vector<vector<int> >;

int main(){
  int N,M; cin >> N >> M;
  Graph G(N + 1);
  for(int i=0;i<M;i++){
    int a,b;
    cin >> a >> b;
    G.at(a).push_back(b);
    G.at(b).push_back(a);
  }

  queue<int>que;
  vector<int>dist(N+1,-1);
  vector<int>ans(N+1);
  dist.at(1)=0;
  que.push(1);

  while(!que.empty()){
    int v = que.front();
    que.pop();

    for(int nv : G.at(v)){
      if(dist.at(nv) != -1) continue;
      dist.at(nv) = dist.at(v) + 1;
      que.push(nv);
      ans.at(nv) = v;
    }
  }
  for(int i=2;i<=N;i++){
    if(ans.at(i) == 0){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  for(int i=2;i<=N;i++){
    cout << ans.at(i) << endl;
  }
}


Measured memory_bytes: 10552
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define REP(i,a,b) for(inti=a;i<=b;i++)

#define MOD 1000000007
typedef long long int ll;
typedef vector<int>vi;
typedef pair<int,int>pi;



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

int n,a,b;
cin>>n>>a>>b;

cout<<min(b,a*n)<<endl;


 return 0;
}


Measured memory_bytes: 3524
N=int(input())
X=input()
Y=int(X,2)

J=X.count("1")

A=[0]*N
A[-1]=1
for i in range(2,N+1):
    A[-i]=(A[-(i-1)]*2)%(J+1)

B=[0]*N
if J>1:
    B[-1]=1
    for j in range(2,N+1):
        B[-j]=(B[-(j-1)]*2)%(J-1)


H=[0]*N

Q,R=divmod(Y,J+1)
if J>1:
    S,T=divmod(Y,J-1)
else:
    S=T=0

for i in range(N):
    if X[i]=="0":
        U=(R+A[i])%(J+1)
    else:
        if J==1:
            continue
        U=(T-B[i])%(J-1)
        
        
    I=1
    while U>0:
        U=U%bin(U).count("1")
        I+=1
    H[i]=I

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


Measured memory_bytes: 105652
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());

        System.out.println(Math.max(Math.max(a + b, a - b), a * b));

        sc.close();
    }
}

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

#define ll long long
#define pb push_back
#define mp make_pair
#define boost ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0)
#define f first
#define se second
#define lb lower_bound
#define ub upper_bound
#define pii pair<int, int>
#define all(x) x.begin(), x.end()

const int N = 1e5 + 144, mod = 1e9 + 7, inf = 1e9 + 7;
int n, m, dp[N];
vector <int> g[N];
bool was[N];

ll bp(ll x, ll y){
    if(y == 0)
        return 1;
    if(y & 1)
        return (x * bp(x, y - 1));
    ll z = bp(x, y / 2);
    return (z * z) % mod;
}

void dfs(int x){
    was[x] = true;
    for(auto to: g[x]){
        if(!was[to])
            dfs(to);
        dp[x] = max(dp[to] + 1, dp[x]);
    }
}

int main(){
    boost;
    cin >> n >> m;
    for(int i = 1; i <= m; i++){
        int x, y;
        cin >> x >> y;
        g[x].pb(y);
    }
    int ans = 0;
    for(int i = 1; i <= n; i++){
        if(!was[i])
            dfs(i);
        ans = max(ans, dp[i]);
    }
    cout << ans;
    return 0;
}



Measured memory_bytes: 8320
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,a,b) for (int i = a; i < (b); ++i)
#define all(x) (x).begin(),(x).end()
#define YY cout << "Yes" << endl
#define NN cout << "No" << endl
const int INF = 1000000007;
typedef long long ll;
using namespace std;
using Graph = vector<vector<int>>;
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; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a,b); }
int solve(){
  int k,n;
  cin >> n >> k;
  cout << n - (k - 1) << endl;
  return 0;
}
int main(){
  // ios::sync_with_stdio(false);cin.tie(nullptr);
  // cout << fixed;cout << setprecision(16) << endl; 
  solve();
  return 0;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define int ll
#define uptil(a, b, i) for(int i = (a), b_ = (b); i < b_; ++i)
#define upto(a, b, i) for(int i = (a), b_ = (b); i <= b_; ++i)
#define downtil(a, b, i) for(int i = (a), b_ = (b); i > b_; --i)
#define downto(a, b, i) for(int i = (a), b_ = (b); i >= b_; --i)
#define times(n, i) uptil(0, n, i)
#define rtimes(n, i) downto((n)-1, 0, i)

#define sp <<" "
#define ln <<"\n"
#define size(v) ((int)(v).size())
template<class T> using vec=vector<T>;
template<class T> using vvec=vec<vector<T>>;

constexpr int mod = 1e9 + 7;

void solve() {
  int N, M; cin >> N >> M;
  vvec<int> edges(N);
  times(M, i) {
    int U, V; cin >> U >> V;
    edges[--U].push_back(--V);
  }
  int S, T; cin >> S >> T; --S; --T;

  priority_queue<pair<int, int>> pq;
  pq.emplace(-0, S * 3);
  vec<int> dist(N * 3, 1LL << 50);

  while(!pq.empty()) {
    int d = -pq.top().first, v = pq.top().second; pq.pop();
    if(d >= dist[v]) continue;
    dist[v] = d;
    for(int u : edges[v / 3]) {
      pq.emplace(-(d + 1), u * 3 + (v + 1) % 3);
    }
  }

  cout << (dist[T * 3] == (1LL << 50) ? -1 : dist[T * 3] / 3) ln;
}

signed main() {
  // cin.tie(0);
  cout << fixed << setprecision(20);
  cerr << fixed << setprecision(10);
  solve();
  return 0;
}


Measured memory_bytes: 8064
// 2011/06/17 Tazoe

#include <iostream>
using namespace std;

int main()
{
	int num[5];
	for(int i=0; i<5; i++)
		cin >> num[i];

	for(int i=0; i<4; i++)
		for(int j=i+1; j<5; j++)
			if(num[i]<num[j]){
				int tmp = num[i];
				num[i] = num[j];
				num[j] = tmp;
			}

	for(int i=0; i<5; i++){
		cout << num[i];
		if(i<4)
			cout << ' ';
		else
			cout << endl;
	}

	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>

using namespace std;

int main(){
    
    long long n, som = 1, ant = 1;  
    bool ze = false, o = false;  

    cin >> n;

    vector<long long> v (n);   

    for(long long i = 0; i < n; i++){
        cin >> v[i];
        //cout << v[i] << endl;
        if(v[i] == 0)
            ze = true;
    }

    ant *= v[0]; 

    if(!ze){
        for(long long i = 1; i < n; i++){
            som = v[i] * ant;
            //cout << som << endl;
            if(som > 1000000000000000000 || som < 0 || som < ant){
                o = true;
                break;            
            }
            ant = som;
        }
    }

    if(ze){
        cout << "0" << endl;
    }else if(o){
        cout << "-1" << endl;
    }else{
        cout << som << endl;
    }

    return 0;
}


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


#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define MOD 1000000007
#define pii pair<int,int>
#define pll pair<ll,ll>
#define ll long long
#define el '\n'

using namespace std;

pll ar[100100];
ll n,m;

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

    //ll n,m;
    cin >> n >> m;

    for (ll i=0;i<n;i++){
        cin >> ar[i].fi >> ar[i].se;
    }

    sort(ar,ar+n);
    ll id=0;
    ll ans=0;
    priority_queue<ll> pq;
    for (ll sisa=1;sisa<=m;sisa++){
        if (id == n) {
            if (pq.empty()) continue;
            ans += pq.top();
            pq.pop();
            continue;
        }
        while (ar[id].fi <= sisa) {
            pq.push(ar[id].se);
            id++;
            if (id == n) break;
        }
        if (pq.empty()) continue;
        ans += pq.top();
        pq.pop();
    }
    cout << ans << '\n';

    return 0;
}

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N;
string S;
int Q;

template<class V, int ME> class BIT {
public:
	V bit[1<<ME];
	V operator()(int e) {if(e<0) return 0;V s=0;e++;while(e) s+=bit[e-1],e-=e&-e; return s;}
	void add(int e,V v) { e++; while(e<=1<<ME) bit[e-1]+=v,e+=e&-e;}
};
BIT<int,20> bt[26];


void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>S;
	FOR(i,N) bt[S[i]-'a'].add(i,1);
	cin>>Q;
	while(Q--) {
		cin>>i;
		if(i==1) {
			cin>>x>>s;
			x--;
			bt[S[x]-'a'].add(x,-1);
			S[x]=s[0];
			bt[S[x]-'a'].add(x,1);
		}
		else {
			int L,R;
			cin>>L>>R;
			L--,R--;
			int cnt=0;
			FOR(i,26) {
				if(bt[i](R)-bt[i](L-1)) cnt++;
			}
			cout<<cnt<<endl;
		}
	}
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 107292
#include<bits/stdc++.h>
#define ll                  long long
#define dl                 double
#define pb                push_back
#define F                  first
#define S                  second
#define endl              "\n"
#define rep(i,a,b)       for(i=a;i<b;i++)
#define all(v)             v.begin(),v.end()
#define allr(v)            v.rbegin(),v.rend()
#define mod              1000000007
#define CIN(V,s,n)      for(int i=s;i<n;i++){cin >> V[i];}
#define COUT(V,s,n)   {for(ll i2=s;i2<n;i2++){cout <<  V[i2] << " "  ;} cout << endl;}
#define fast               ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define CLEAR(V);      for(ll i=0;i<V.size();i++) V[i] = 0;
#define N                  500005LL
#define tmod            998244353
using namespace std;

bool sBs(const pair<int,int> &a,const pair<int,int> &b)
{   if(a.first!=a.second)return (a.first < b.first);
    else return a.second > b.second;}

ll SUMD(ll n);
ll BS(vector<ll> &PS,ll s,ll e,ll ser);
ll MI(ll a, ll m);
bool P[N+1];
ll LPF[N+1];
void Sieve(int n=N);
ll Powb(ll b,ll n);

int main()
{
fast;
ll t,q=1;
//cin >> q;
t = q;

while(q--)
{
    ll n,m,k,j,l,r,c=0,b,a,g,counter=0,u,v,d,e,p,x,y,flag=1;
    //n=m=i=j=l=r=a=t=b=c=u=v=w=p=x=y=0;
    cin >> n >> m;
    vector<int> V({0,300000,200000,100000});
    cout <<  ((V[(n<=3 ? n:0)] + V[(m<=3 ? m: 0)] ) +  ((n==1 and m==1) ? 400000:0)) << endl;

}
return 0;
}


ll Powb(ll b,ll n)
{
    if(n==0) return 1LL;
    if(n==1) return b;
    ll temp = Powb(b,n/2);
    if(n%2==0){return (temp*temp)%mod;}
    else{return (b*((temp*temp)%mod))%mod;}
}

ll SUMD(ll n)
{   ll sum=0;
    while(n>0){sum += n%10;n = n/10;}
    return sum;

}
ll BS(vector<ll> &PS,ll s,ll e,ll ser)
{
    if(s>e)
        return s;
    ll mid = (s+e)/2;
    if(PS[mid]==ser)
    {
        return mid;
    }
    else if(PS[mid] > ser)
    {
        return BS(PS,s,mid-1,ser);
    }
    else
        return BS(PS,mid+1,e,ser);
}
ll MI(ll a, ll m)
{
    ll m0 = m;
    ll y = 0, x = 1;
    if (m == 1)
      return 0;
    while (a > 1)
    {
        ll q = a / m;
        ll t = m;
        m = a % m, a = t;
        t = y;
        y = x - q * y;
        x = t;
    }
    if (x < 0)
       x += m0;
    return x;
}

void Sieve(int n)
{
    memset(P,true,sizeof(P));
    P[0] = false;
    P[1]= false;
    for(int i=1;i<=n;i++)
        LPF[i] = i;
    for(ll i=2;i*i<=n;i++)
    {
        if(P[i])
        {
            for(ll j=i+i;j<=n;j+=i)
            {
                P[j]=false;
                LPF[j] = i;
            }
        }
    }

}



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

using namespace std;

#define MAX 25252
#define INF (1LL<<55)
typedef long long ll;

ll N, M, K;
ll memo[MAX];
vector<ll> A;

ll solve(int n)
{
    if (n == N) return 0;
    ll &res = memo[n];

    if (res != -1) return res;
    res = INF;
    
    ll maxi = 0, mini = INF;
    for (int i = n; i < min(n + M, N); i++) {
        maxi = max(maxi, A[i]);
        mini = min(mini, A[i]);
        ll cost = K + (i+1 - n) * (maxi - mini);
        res = min(res, solve(i+1) + cost);
    }
    return res;
}

int main()
{
    cin >> N >> M >> K;
    A.resize(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }
    memset(memo, -1, sizeof(memo));
    cout << solve(0) << endl;
    return 0;
}

Measured memory_bytes: 5184
import sys
H,W,m = map(int, input().split())

high = [0] * H
width = [0] * W

stone = set()
for i in range(m):
    h, w = map(int,input().split())
    h -= 1
    w -= 1
    
    high[h] += 1
    width[w] += 1
    stone.add((h,w))
    
dic_h = {}
for i in range(len(high)):
    dic_h.setdefault(high[i], [])
    
    dic_h[high[i]].append(i)
    
dic_w = {}
for i in range(len(width)):
    dic_w.setdefault(width[i], [])
    
    dic_w[width[i]].append(i)
    
h_max = max(dic_h.keys())
w_max = max(dic_w.keys())

for i in dic_h[h_max]:
    for j in dic_w[w_max]:
        if (i,j) not in stone:
            print(h_max+w_max)
            sys.exit(0)
            
print(h_max+w_max-1)

Measured memory_bytes: 176924
#include<cstdio>
#define ll long long
using namespace std;
const int mod=1e9+7;
ll jc(int x){
	ll ans=1;
	for(int i=1;i<=x;i++) ans*=i,ans%=mod;
	return ans;
}
int main(){
	int n;
	scanf("%d",&n);
	printf("%lld\n",jc(n));
	return 0;
}

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

pair<int,int> match(const vector<vector<int> >& scenery, int x, int y, const vector<vector<int> >& picture)
{
  const int M = picture.size();
  pair<int,int> ans = make_pair(1000, 1000);

  for (int i = 0; i < M; i++) {
    for (int j = 0; j < M; j++) {
      if (picture[i][j] != -1 && picture[i][j] != scenery[x+i][y+j]) {
        goto L1;
      }
      if (picture[i][j] != -1 && x+i < ans.first) {
        ans.first = x+i;
        ans.second = min(ans.second, y+j);
      }
    }
  }
  return ans;
L1:
  ans = make_pair(1000, 1000);
  for (int i = 0; i < M; i++) {
    for (int j = 0; j < M; j++) {
      if (picture[j][M-i-1] != -1 && picture[j][M-i-1] != scenery[x+i][y+j]) {
        goto L2;
      }
      if (picture[j][M-i-1] != -1 && x+i < ans.first) {
        ans.first = x+i;
        ans.second = min(ans.second, y+j);
      }
    }
  }
  return ans;
L2:
  ans = make_pair(1000, 1000);
  for (int i = 0; i < M; i++) {
    for (int j = 0; j < M; j++) {
      if (picture[M-i-1][M-j-1] != -1 && picture[M-i-1][M-j-1] != scenery[x+i][y+j]) {
        goto L3;
      }
      if (picture[M-i-1][M-j-1] != -1 && x+i < ans.first) {
        ans.first = x+i;
        ans.second = min(ans.second, y+j);
      }
    }
  }
  return ans;
L3:
  ans = make_pair(1000, 1000);
  for (int i = 0; i < M; i++) {
    for (int j = 0; j < M; j++) {
      if (picture[M-j-1][i] != -1 && picture[M-j-1][i] != scenery[x+i][y+j]) {
        return make_pair(-1, -1);
      }
      if (picture[M-j-1][i] != -1 && x+i < ans.first) {
        ans.first = x+i;
        ans.second = min(ans.second, y+j);
      }
    }
  }
  return ans;
}

pair<int,int> solve(const vector<vector<int> >& scenery, const vector<vector<int> >& picture)
{
  const int N = scenery.size();
  const int M = picture.size();
  for (int i = 0; i <= N-M; i++) {
    for (int j = 0; j <= N-M; j++) {
      const pair<int,int> p = match(scenery, i, j, picture);
      if (p.first >= 0) {
        return p;
      }
    }
  }
  return make_pair(-1, -1);
}

int main()
{
  int N, M;
  while (cin >> N >> M && N != 0) {
    vector<vector<int> > scenery(N, vector<int>(N));
    for (int i = 0; i < N; i++) {
      for (int j = 0; j < N; j++) {
        cin >> scenery[i][j];
      }
    }
    vector<vector<int> > picture(M, vector<int>(M));
    for (int i = 0; i < M; i++) {
      for (int j = 0; j < M; j++) {
        cin >> picture[i][j];
      }
    }

    const pair<int,int> ans = solve(scenery, picture);
    if (ans.first == -1) {
      cout << "NA" << endl;
    } else {
      cout << ans.second+1 << ' ' << ans.first+1 << endl;
    }
  }
  return 0;
}

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

int rect[200][200];

int main(void){
	int w,h,n;
	cin>>w>>h>>n;
	int r = w*h;
	while(n--){
		int x,y,a;
		cin>>x>>y>>a;
		if(a == 1){
			for(int i = x-1; i >= 0; i--)
			  for(int j = 0; j < h; j++){
				if(!rect[i][j]) r--;
				rect[i][j] = 1;
			  }
		}else if(a == 2){
			for(int i = x; i < w; i++)
			  for(int j = 0; j < h; j++){
				if(!rect[i][j]) r--;
				rect[i][j] = 1;
			  }
		}else if(a == 3){
			for(int i = 0; i < w; i++)
			  for(int j = y-1; j >=0; j--){
				if(!rect[i][j]) r--;
				rect[i][j] = 1;
			  }
		}else{
			for(int i = 0; i < w; i++)
			  for(int j = y; j < h; j++){
				if(!rect[i][j]) r--;
				rect[i][j] = 1;
			  }
		}
	}
	cout<<r<<'\n';
	return 0;
}


Measured memory_bytes: 3712
N,*as=$<.read.split.map(&:to_i)

h=Hash.new(0)
as.each do |a|
    h[a] += 1
end

arr = h.select {|k,v|2<=v}.sort
if arr.size < 2
    puts 0
elsif 4 <= arr[-1][1]
    puts arr[-1][0] * arr[-1][0]
else
    puts arr[-1][0] * arr[-2][0]
end


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

#define PI 4*atan(1)
#define INF 1e8

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

int main(){
  int N, Q;
  int M;
  while(cin >> N >> Q, N||Q){
    vector<int> P(100, 0);
    for(int i = 0; i < N; i++){
      cin >> M;
      vector<int> Date(M);
      for(int j = 0; j < M; j++){
        cin >> Date[j];
        P[Date[j]]++;
      }
    }

    int m = 0, ans = 0;
    for(int i = 0; i < P.size(); i++){
      if(P[i] > m){
        ans = i;
        m = P[i];
      }
    }
    if(m >= Q)cout << ans << endl;
    else cout << 0 << endl;
  }
}

Measured memory_bytes: 3076
import java.util.*;
public class Main {
		
	public static void main(String[] args) {
		Scanner in=new Scanner (System.in);
		String w = in.next();
		int c=0;
		;int con=0;
		for (int i = 0; i < w.length(); i++) {
			for (int j = 0; j < w.length(); j++) {
				if(w.charAt(i)==w.charAt(j)) {
					c++;
				}
			}
			if(c%2!=0) {
				System.out.println("No");
				con++;
				break;
			}
			
		}
		if(con==0) {
			System.out.println("Yes");
		}
	}
}

Measured memory_bytes: 26916
#include <stdio.h>
#define min(a, b) ((a) < (b) ? (a) : (b))

int main(void)
{
    int n, m;

    while (scanf("%d %d", &n, &m), n){
        int p[2048] = {0};
        int i, j;
        int sum = 0;

        for (i = 0; i < n; i++){
            int tmp;

            scanf("%d", &tmp);
            for (j = i; j > 0 && tmp > p[j - 1]; j--){
                p[j] = p[j - 1];
            }
            p[j] = tmp;
        }

        for (i = 0; i < n / m + 1; i++){
            for (j = 0; j < m; j++){
                sum += p[i * m + j];
            }
            sum -= p[i * m + j - 1];
        }
        printf("%d\n", sum);
    }

    return 0;
}

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

int main()
{
  int nDivend, nDivsor, nRest;
  int nGCD;
  
  cin >> nDivend >> nDivsor;
  if (nDivend < nDivsor)
    swap(nDivsor, nDivsor);

  while (nDivend % nDivsor != 0)
  {
    nRest = nDivend % nDivsor;
    nDivend = nDivsor;
    nDivsor  = nRest;
  }

  nGCD = nDivsor;
  cout << nGCD << endl;
  return 0;
}



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

typedef long long ll;
const int N = 1e5 + 100, inF = 1e9 + 100;

int n, a[N], ps[N];
unordered_map<int, int> cnt;

ll check(ll num) {
	ll res = 0, now = 0;
	cnt.clear();
	cnt[0] = 1;
	for (int i = 0; i < n; i++) {
		ps[i] = (i? ps[i - 1]: 0) + (a[i] <= num? 1: -1);
		if(a[i] <= num)
			now += cnt[ps[i] - 1];
		else
			now -= cnt[ps[i]];
		cnt[ps[i]]++;
		res += now;
	}
	return res;
}

int main() {
	ios::sync_with_stdio(false), cin.tie(0);
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> a[i];
	ll want = 1LL * (n + 1) * n / 4 + 1;
	ll l = 0, r = inF;
	while(r - l > 1) {
		ll c = (l + r) >> 1;
		if(check(c) >= want)
			r = c;
		else
			l = c;
	}
	cout << r;
	return 0;
}

Measured memory_bytes: 5156
#include<stdio.h>
#define _USE_MATH_DEFINES
#include <math.h>
int main()
{ 
double r,pi,a,b;
scanf("%lf",&r); 
pi=M_PI; 
a=r*r*pi; 
b=2*r*pi;  
printf("%lf %lf",a,b);
return 0;
}

Measured memory_bytes: 648
#include <bits/stdc++.h>
using namespace std;
struct edge {
    int to;     // 辺の行き先
    int weight; // 辺の重み
    edge(int t, int w) : to(t), weight(w) { }
};
using Graph = vector<vector<int>>;
using dou =long double;
string Yes="Yes";
string YES="YES";
string NO="NO";
string No="No";
#define rep(i, n)         for(int i = 0; i < (int)(n); i++)
#define brep(n)           for(int bit=0;bit<(1<<n);bit++)
#define erep(i,container) for (auto i : container)
#define irep(i, n)        for(int i = n-1; i >= (int)0; i--)
#define rrep(i,m,n) for(int i = m; i < (int)(n); i++)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define all(x) (x).begin(),(x).end()
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define res resize
#define as assign
#define fi first
#define se second
#define itn int
#define mp make_pair
#define sum(a) accumulate(all(a),0)
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<t>(n,a)));
#define vvvvector(name,t,k,l,m,n,a) vector<vector<vector<vector<t> > > > name(k,vector<vector<vector<t> > >(l, vector<vector<t> >(m, vector<t>(n,a)) ));
 
typedef long long ll;
const int INF = 2000000000;
const ll INF64 = 9223372036854775806ll;
const int mod = 1000000007ll;
const ll  MOD = 1000000007LL;
const double pi=3.1415926535897932384626;
int main(){
    int n;
    std::cin >> n;
    std::vector<int> a(n),b(n),c(n);
    rep(i,n)std::cin >> a[i]>>b[i]>>c[i];
    vvector(dp,int,n+1,3,0);
    dp[0][0]=a[0];
    dp[0][1]=b[0];
    dp[0][2]=c[0];
    rrep(i,1,n){
        dp[i][0]=max(dp[i-1][1],dp[i-1][2])+a[i];
        dp[i][1]=max(dp[i-1][0],dp[i-1][2])+b[i];
        dp[i][2]=max(dp[i-1][1],dp[i-1][0])+c[i];
    }
    std::cout << max({dp[n-1][0],dp[n-1][1],dp[n-1][2]}) << std::endl;
}

Measured memory_bytes: 6912
#問題文3桁の整数 Nが与えられます。
#Nのいずれかの桁に数字の 7は含まれますか？
#含まれるなら Yes を、含まれないなら No を出力してください。

N = input()
yes = 0
for i in range(3):
  if N[i] in '7':
    yes =+ 1
if yes > 0:
  print('Yes')
else:
  print('No')

#117
#123
#777

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


int main() {
    int n;
    cin >> n;
    string x;
	map <string, int> mp;

    vector <string> s(n);
	for (int i = 0; i < n; i++) {
		cin >> s[i];
	}
	for(int i = 0; i < n; i++) {
		auto itr = mp.find(s[i]);
		if (itr != mp.end()) {
			mp[s[i]] += 1;
		} else {
			mp[s[i]] = 1;
		}
	}
	int ans = 0;
    for (auto x : mp) {
		if (x.second > ans) {
			ans = x.second;
		}
    }
	// cout << "----" << endl;
	for (auto x : mp) {
		if (x.second == ans) {
			cout <<  x.first << endl;
		}
    }


	return 0;
}


Measured memory_bytes: 26752
def resolve():
    S = input()

    if S == "SUN":
        ans=7
    elif S == "MON":
        ans=6
    elif S == "TUE":
        ans=5
    elif S == "WED":
        ans=4
    elif S == "THU":
        ans=3
    elif S == "FRI":
        ans=2
    elif S == "SAT":
        ans=1
    print(ans)
resolve()

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

int main(){
	int n;
	
	cin >> n;
	for(int i = 1; i <= n; i++){
		int x = i;
		if(x % 3 == 0){
			cout << " " << i;
			continue;
		}
		for(; x > 0; x /= 10){
			if(x % 10 == 3){
				cout << " " << i;
				break;
			}
		}
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 1160