akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define ft first
#define sd second
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)

template <class T> struct Dinic{
    const T inf;
    struct edge{
        int cd;
        T c;
        size_t rv;
        bool f;
    };
    vector<vector<edge>> v;
    vector<int> m,it;
    Dinic(int n):inf(numeric_limits<T>::max()),v(n){}
    void ad(int dm,int cd,T c){
        v[dm].emplace_back((edge){cd,c,v[cd].size(),0});
        v[cd].emplace_back((edge){dm,0,v[dm].size()-1,1});
    }
    bool bfs(int s,int t){
        m.assign(v.size(),-1);
        queue<int> q;
        m[s]=0;
        q.push(s);
        while(!q.empty()&&m[t]==-1){
            int p=q.front();q.pop();
            for(auto &e:v[p]){
                if(e.c>0&&m[e.cd]==-1){
                    m[e.cd]=m[p]+1;
                    q.push(e.cd);
                }
            }
        }
        return m[t]!=-1;
    }
    T dfs(int i,int t,T f){
        if(i==t) return f;
        for(int j=it[i];j<v[i].size();++j){
            edge &e=v[i][j];
            if(e.c>0&&m[i]<m[e.cd]){
                T d=dfs(e.cd,t,min(f,e.c));
                if(d){
                    e.c-=d;
                    v[e.cd][e.rv].c+=d;
                    return d;
                }
            }
        }
        return 0;
    }
    T mf(int s,int t){
        T fl=0;
        while(bfs(s,t)){
            it.assign(v.size(),0);
            T f=0;
            while((f=dfs(s,t,inf))>0) fl+=f;
        }
        return fl;
    }
};

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n,m,u,v,c;
    cin>>n>>m;
    Dinic<int> d(n);
    fr(i,m){
        cin>>u>>v>>c;
        d.ad(u,v,c);
    }
    cout<<d.mf(0,n-1)<<endl;
}


Measured memory_bytes: 3300
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

long long calcNumOfCombination(long long n, long long r){
    long long num = 1;
    for(long long i = 1; i <= r; i++){
        num = num * (n - i + 1) / i;
    }
    return num;
}

int main(void)
{
    int n;
    cin >>n;

    vector<int> ct(n+1, 0);
    vector<int> as;
    long long all = 0;
    for(int i = 0; i < n; i++){
        int tmp;
        cin >>tmp;
        as.push_back(tmp);
        ct[tmp]++;
    }

    for(int i = 0; i <= n; i++){
        all += calcNumOfCombination(ct[i], 2);
    }
    for(int i = 0; i < n; i++){
        int cc = ct[as[i]];

        long long minus = calcNumOfCombination(cc, 2);
        long long plus = calcNumOfCombination(cc-1, 2);
        printf("%lld\n", all - minus + plus);
    }
    return 0;
}

Measured memory_bytes: 4340
#define _GIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
const double EPS = 1e-10;


int main(void) {
  ll A, B, N;
  cin >> A >> B >> N;

  // x%Bの最大値numをBで割ってA倍してfloor
  ll num = min(B - 1, N);
  ll ans = floor((double)num / (double)B * (double)A);
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 3740
#include <iostream>
#define D 10
#define P 100

// 実装難しすぎて断念
using namespace std;
int G, d, ans = D * P + 1;
int p[D], c[D];

int main(int argc, char const *argv[])
{
    int S, target = 0, j, ans = 10 * P + 1;
    cin >> d >> G;
    for(int i = 0; i < d; i ++){
        cin >> p[i] >> c[i];
    }
    for(int bit = 0; bit < (1 << d); bit ++){
        S = 0;
        j = 0;
        for(int i = 0; i < d; i ++){
            if (bit & (1 << i)){
                S += (i + 1) * p[i] * 100 + c[i];
                j += p[i];
            }else{
                target = i;
            }
        }
        if (S >= G){
            ans = j < ans ? j : ans;
        }else{
            if(G - S + (target + 1) * 100 <= p[target] * (target + 1) * 100){
                j += (G - S + (target + 1) * 100 - 1) / ((target + 1) * 100);
                ans = j < ans ? j : ans;
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <numeric>
using namespace std;
#define ll long long
#define mod 100000007
#define rep(i, n) for (int i = 0; i < n; ++i)
using Graph = vector<vector<int>>;
#define grepq  priority_queue<double, std::vector<double>, std::greater<double>>

int lcm(ll a, ll b)
{
    return a * b / __gcd(a, b);
}

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




int main(){
    int N, M;
    cin >> N >> M;
    vector<int> LIKE(M+1);
    for (int i = 0; i < N;i++)
    {
        int K;
        cin >> K;
        int A;
        for (int j = 0; j < K; j++)
        {
            cin >> A;
            LIKE[A]++;
        }
    }
    ll ans = 0;
    for (int i = 0; i <= M; i++)
    {
        if(LIKE[i] == N){
            ans++;
        }

    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree < pairs ,  null_type , greater<pairs>,  rb_tree_tag ,  tree_order_statistics_node_update > 
#define ll long long
#define lld long double
#define vc vector<ll>
const ll MOD=(1e9 +7);
typedef pair<ll,ll>pairs;
ll power(ll a, ll b){ll res=1;a=a%MOD;while(b>0){if(b&1){res=(res*a)%MOD;b--;}a=(a*a)%MOD;b>>=1;}
    return res;}

int main() {
	// your code goes here
	std::ios::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
	ll t,m,n,i,j,k,c,f,x,y;
	cin>>n>>m;f=0;
	vc red(n+1),balls(n+1,1);
	red[1]=1;
	ll cnt=0;
	for(i=1;i<=m;i++)
	{
	    cin>>x>>y;
	    if(red[x])red[y]=1;
	    balls[x]--;balls[y]++;
	    if(balls[x]==0)red[x]=0;
	}
	for(i=1;i<=n;i++)cnt+=red[i];
	cout<<cnt;
	return 0;
}


Measured memory_bytes: 4728
#include <bits/stdc++.h>
using namespace std;
signed main () {
    
    int n;
    int a[300000];
    int b[300000];
    int m;
    vector<int> ans;
    cin >> n;
    for(int i = 1; i <= n; i++) {
        cin >> a[i];
    }
    for(int i = n; i >= 1; i--){
        int x = 0;
        for(int j = i; j <= n; j+=i){
            x ^= b[j];
        }
        if(b[i]=(x^a[i])) ans.push_back(i);
    }
    reverse(ans.begin(),ans.end());
    cout << ans.size() << endl;
    for(int i = 0; i < ans.size(); i++) {
        cout << ans[i];
        cout << (ans.size()==1+i?"\n":" ") ;
    }

    
    return 0;
}


Measured memory_bytes: 3320
#include<iostream>
#include<string>
#include<typeinfo>
#include<vector>
#include<algorithm>
#include<map>
#include<iomanip>
using namespace std;
int main()
{
	int n;
	cin >> n;

	int cnt=0;
	int ans=0;
	for(int i=11; i<=n; i+=2){
		cnt=0;
		for(int k=1; k<=i; k++){
			if(i%k==0){
				cnt++;
			}
		}
		if(cnt==8){
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

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

int main()
{
   int i,sx,sy,tx,ty;
   cin>>sx>>sy>>tx>>ty;
   int dx=tx-sx,dy=ty-sy;
   for(i=0;i<dy;i++)
     cout<<"U";
   for(i=0;i<dx;i++)
     cout<<"R";
   for(i=0;i<dy;i++)
     cout<<"D";
   for(i=0;i<dx;i++)
     cout<<"L";
     cout<<"L";
   for(i=0;i<dy+1;i++)
     cout<<"U";
   for(i=0;i<dx+1;i++)
     cout<<"R";
     cout<<"DR";
     for(i=0;i<dy+1;i++)
     cout<<"D";
   for(i=0;i<dx+1;i++)
     cout<<"L";
     cout<<"U";
   return 0;
}


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

    int main()
    {
       long long int N,K,X,Y;
        while(~scanf("%lld%lld%lld%lld",&N,&K,&X,&Y))
        {  if(N>K)
             printf("%lld\n",K*X+(N-K)*Y);
        else printf("%lld\n",N*X);
        }return 0;}



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

int main(){
  int n;
  cin >> n;
  vector<string> s(n);
  rep(i,n) cin >> s[i];
  sort(s.begin(),s.end());
  int ans = 1;
  rep(i,n-1){
    if(s[i] != s[i+1]){
      ++ans;
    }
  }
  cout << ans << endl;
  return 0;
}


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

int main() {
	int h,n;
	cin >> h>>n;

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

	int total = 0;
	for (int ii = 0; ii < n; ii++)
		total += a[ii];

	if(h<=total)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;


}

Measured memory_bytes: 640
fun main(args: Array<String>) {
    val (n, k, q) = readLine()!!.split(' ').map { it.toInt() }
    val p = IntArray(n + 1)
    repeat(q) {
        val a = readLine()!!.toInt()
        p[a]++
    }

    p.slice(1..n)
            .joinToString("\n") { if (k - (q - it) > 0) "Yes" else "No" }
            .let { println(it) }
}


Measured memory_bytes: 41736
x,y=map(int,input().split())
a=[1,3,5,7,8,10,12]
b=[4,6,9,11]
c= [2]
if x in a and y in a:
	print("Yes")
elif x in b and y in b:
    print("Yes")
elif x in c and y in c:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
#include<iostream>
#include<stdio.h>

using namespace std;

int main()
{
    int l,a;
    cin>>l;
    double f=l*l*l;
    f=f/27;
    cout.unsetf(std::ios::scientific);
    std::cout.setf (std::ios::fixed);
    cout<<f;
    return 0;
}


Measured memory_bytes: 256
from copy import deepcopy
from sys import exit,setrecursionlimit
import math
from collections import defaultdict,Counter,deque
from fractions import Fraction as frac
import bisect
import sys
input = sys.stdin.readline

setrecursionlimit(1000000)

dp = defaultdict(lambda x:-1)

def main():
	n = int(input())
	l = list(map(int,input().split()))
	l.sort()
	ans = 0
	for mx in reversed(range(1,n)):
		for sc in reversed(range(1,mx)):
			tr_mx = l[mx] - l[sc] + 1
			tr = bisect.bisect_left(l,tr_mx)
			if(sc - tr > 0):
				ans += sc-tr
	print(ans)

def zip(a):
	mae = a[0]
	ziparray = [mae]
	for i in range(1,len(a)):
		if(mae != a[i]):
			ziparray.append(a[i])
			mae = a[i]
	return ziparray

def is_prime(n):
	if n < 2: return False

	for k in range(2, int(math.sqrt(n)) + 1):
		if n % k == 0:
			return False

	return True

def list_replace(n,f,t):
	return [t if i==f else i for i in n]

def base_10_to_n(X, n):
	X_dumy = X
	out = ''
	while X_dumy>0:
		out = str(X_dumy%n)+out
		X_dumy = int(X_dumy/n)
	if(out == ''): return '0'
	return out

def gcd(l):
	x = l.pop()
	y = l.pop()
	while(x%y!=0):
		z = x%y
		x = y
		y = z
	l.append(min(x,y))
	return gcd(l) if len(l) > 1 else l[0]

class Queue():
	def __init__(self):
		self.q = deque([])
	def push(self,i):
		self.q.append(i)
	def pop(self):
		return self.q.popleft()
	def size(self):
		return len(self.q)
	def debug(self):
		return self.q

class Stack():
	def __init__(self):
		self.q = []
	def push(self,i):
		self.q.append(i)
	def pop(self):
		return self.q.pop()
	def size(self):
		return len(self.q)
	def debug(self):
		return self.q

class graph():
	def __init__(self):
		self.graph = defaultdict(list)
	def addnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].append(t)
		self.graph[t].append(f)
	def rmnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].remove(t)
		self.graph[t].remove(f)
	def linked(self,f):
		return self.graph[f]

class dgraph():
	def __init__(self):
		self.graph = defaultdict(set)
	def addnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].append(t)
	def rmnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].remove(t)
	def linked(self,f):
		return self.graph[f]

main()


Measured memory_bytes: 68820
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  ll a, b;
  cin >> a >> b;
  rep(i, 10101) {
    ll ta = i * 8 / 100;
    ll tb = i / 10;
    if(ta != a || tb != b) continue;
    cout << i << endl;
    return 0;
  }
  cout << -1 << endl;
}

Measured memory_bytes: 256
N, M, X = list(map(int, input().split()))
A = [list(map(int, input().split())) for _ in range(N)]
kouho = []
for i in range(2**N):
  skill = [0]*M
  price = 0
  for j in range(N):
    if ((i>>j) & 1):
      skill = [x+y for (x, y) in zip(skill, A[j][1:])]
      price += A[j][0]
  flag = 1
  for k in skill:
    if k < X:
      flag = 0
  if flag:
    kouho.append(price)
if len(kouho):
  print(min(kouho))
else:
  print(-1)
    


Measured memory_bytes: 68660
import           Data.Bits
import qualified Data.ByteString.Char8 as BS
import           Data.Maybe

-- compulte a^n `mod` p                                                                                                                      
modpow :: Int -> Int -> Int -> Int
modpow a n p =
    let modpow' a n res | n == 0    = res
                        | otherwise =
                            modpow' (a*a`mod`p)
                                    (n `shiftR` 1)
                                    (if (n .&. 1) == 1 then res * a `mod` p else res)
    in modpow' a n 1

-- compute a^(-1) `mod` p                                                                                                                    
modinv :: Int -> Int -> Int
modinv a p = modpow a (p-2) p

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine


main = do
  [n, a, b] <- getIntList

  let m = 10^9 + 7 :: Int

      fact i j | i == j = j
               | otherwise = i * fact (i-1) j `mod` m

      nCr n r = let num = fact n (n-r+1)
                    den = fact r 1
                in num * modinv den m `mod` m

      ans = (((modpow 2 n m - 1) `mod` m  - nCr n a) `mod` m  - nCr n b) `mod` m

  print ans

Measured memory_bytes: 8204
#include <stdio.h>
#pragma warning(disable:4996)

int main()
{
	int a, b;
	char str1[101], str2[101], str3[205];
	scanf("%d", &a);
	scanf("%s %s", str1, str2);
	sprintf(str3, "%c%c", str1[0], str2[0]);
	for (b = 1; b != a; b++) 
	{
		sprintf(str3, "%s%c%c", str3, str1[b], str2[b]);
	}
	printf("%s", str3);
	return 0;
}

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

int main(){
  string S;
  int count=0;
  cin>>S;
  for(int i=0;i<S.size()/2;i++){
    if(S[i]!=S[S.size()-i-1]) count++;
  }
  cout<<count<<endl;
return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

ll k = 0;
vector<ll> color;

struct Edge {
  ll to, id;
  Edge(ll to, ll id) : to(to), id(id){};
};

vector<vector<Edge>> g;

void dfs(ll cv, ll par, ll usedColor) {
  ll c = 0;
  for (Edge e : g[cv]) {
    ll nv = e.to, id = e.id;
    if (nv == par) {
      continue;
    }
    if (c == usedColor) {
      c = (c + 1) % k;
    }
    color[id] = c;
    dfs(nv, cv, c);
    c = (c + 1) % k;
  }
}

int main() {
  ll n;
  cin >> n;
  g = vector<vector<Edge>>(n);
  REP(i, n - 1) {
    ll a, b;
    cin >> a >> b;
    a--, b--;
    g[a].push_back(Edge(b, i));
    g[b].push_back(Edge(a, i));
  }
  REP(i, n) { k = max(k, SZ(g[i])); }

  cout << k << "\n";
  color = vector<ll>(n - 1);

  dfs(0, -1, -1);

  REP(i, n - 1) { cout << color[i] + 1 << "\n"; }
}

Measured memory_bytes: 9728
n = int(input())
d = {'M':0, 'A':0, 'R':0, 'C':0, 'H':0}
ans = 0
for i in range(n):
    s = input()
    if s[0] in d:
        d[s[0]] += 1
va = list(d.values())
v = len(va)

for i in range(v):
    for j in range(i+1,v):
        for k in range(j+1,v):
            ans += va[i]*va[j]*va[k]
print(ans)



Measured memory_bytes: 3064
#include <stdio.h>
#include <math.h>

int main(void)
{
  int n;
  scanf("%d", &n);

  int i;
  for(i=0; i<n; ++i){
    double x1,y1,x2,y2,x3,y3;
    scanf("%lf %lf %lf %lf %lf %lf", &x1, &y1, &x2, &y2, &x3, &y3);
    double det = x1*y2-x1*y3+x2*y3-x2*y1+x3*y1-x3*y2;
    double a = ((y2-y3)*(-x1*x1-y1*y1)+(y3-y1)*(-x2*x2-y2*y2)+(y1-y2)*(-x3*x3-y3*y3))/det;
    double b = ((x3-x2)*(-x1*x1-y1*y1)+(x1-x3)*(-x2*x2-y2*y2)+(x2-x1)*(-x3*x3-y3*y3))/det;
    double c = ((x2*y3-x3*y2)*(-x1*x1-y1*y1)+(x3*y1-x1*y3)*(-x2*x2-y2*y2)+(x1*y2-x2*y1)*(-x3*x3-y3*y3))/det;
    double xp = -a/2;
    double yp = -b/2;
    double r = sqrt(xp*xp+yp*yp-c);

    printf("%.3f %.3f %.3f\n", xp, yp, r);
  }

  return 0;
}

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

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

using namespace std;

template<class G>
class Fenwick_tree{
	vector<G> a;
public:
	Fenwick_tree(int n):a(n){}
	void add(int i,G val){
		for(i++;i<=a.size();i+=i&-i) a[i-1]+=val;
	}
	G sum(int l,int r)const{
		if(l==0){
			G res{};
			for(;r>0;r-=r&-r) res+=a[r-1];
			return res;
		}
		return sum(0,r)-sum(0,l);
	}
	int lower_bound(G val)const{
		if(val<=G{}) return 0;
		int x=0,k;
		for(k=1;k<=a.size();k<<=1);
		for(k>>=1;k>0;k>>=1) if(x+k<=a.size() && a[x+k-1]<val) val-=a[x+k-1], x+=k;
		return x;
	}
	int upper_bound(G val)const{
		if(val<G{}) return 0;
		int x=0,k;
		for(k=1;k<=a.size();k<<=1);
		for(k>>=1;k>0;k>>=1) if(x+k<=a.size() && a[x+k-1]<=val) val-=a[x+k-1], x+=k;
		return x;
	}
};

int n,bad[100000],deg[100000],ans[100000];

set<pair<int,int>> Deg;
Fenwick_tree<int> F(0);

bool dfs(int i){
	if(i==n) return true;

	int x=Deg.rbegin()->second;
	if(deg[x]==n-i-1){
		if(i==0 || bad[ans[i-1]]!=x){
			int y=bad[x];
			bool b=F.sum(y,y+1);

			Deg.erase({deg[x],x});
			if(b){
				Deg.erase({deg[y],y});
				deg[y]--;
				Deg.emplace(deg[y],y);
			}
			F.add(x,-1);

			ans[i]=x;
			if(dfs(i+1)) return true;

			F.add(x,1);
			if(b){
				Deg.erase({deg[y],y});
				deg[y]++;
				Deg.emplace(deg[y],y);
			}
			Deg.emplace(deg[x],x);
		}
		return false;
	}

	for(int p=1;;p++){
		int x=F.lower_bound(p);
		if(x==n) break;
		if(i==0 || bad[ans[i-1]]!=x){
			int y=bad[x];
			bool b=F.sum(y,y+1);

			Deg.erase({deg[x],x});
			if(b){
				Deg.erase({deg[y],y});
				deg[y]--;
				Deg.emplace(deg[y],y);
			}
			F.add(x,-1);

			ans[i]=x;
			if(dfs(i+1)) return true;

			F.add(x,1);
			if(b){
				Deg.erase({deg[y],y});
				deg[y]++;
				Deg.emplace(deg[y],y);
			}
			Deg.emplace(deg[x],x);
		}
	}
	return false;
}

int main(){
	scanf("%d",&n);
	rep(i,n) scanf("%d",&bad[i]), bad[i]--;

	rep(i,n) deg[bad[i]]++;
	rep(i,n) Deg.emplace(deg[i],i);

	F=Fenwick_tree<int>(n);
	rep(i,n) F.add(i,1);

	if(dfs(0)){
		rep(i,n) printf("%d%c",ans[i]+1,i<n-1?' ':'\n');
	}
	else{
		puts("-1");
	}

	return 0;
}


Measured memory_bytes: 18048
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace test
{

    class Program
    {
        static void Main(string[] args)
        {
            int rectangle = 0;
            int lozenges = 0;

            string input;
            while ((input = Console.ReadLine()) != null)
            {
                string[] array = input.Split(',');
                int a = int.Parse(array[0]);
                int b = int.Parse(array[1]);
                int c = int.Parse(array[2]);
                if (a * a + b * b == c * c)
                {
                    rectangle++;
                }

                if (a == b)
                {
                    lozenges++;
                }
                
            }

            Console.WriteLine(rectangle);
            Console.WriteLine(lozenges);

        }

        
    }
}

Measured memory_bytes: 5604
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
using namespace std;
typedef long long ll;

int main(){
  int N;
  ll x,a[1000];
  cin>>N>>x;
  for(int i=0;i<N;i++){
    cin>>a[i];
  }
  sort(a,a+N);
  int count=0;
  while(true){
    if(a[count]>x) break;
    x-=a[count++];
    if(count==N) break;
  }
  if(count==N && x>0) count--;
  cout<<count++;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define res register int
#define ll long long
//#define cccgift
//#define getchar()(p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++)
//char buf[1<<21],*p1=buf,*p2=buf;
template<typename T>
inline void read(T &x)
{
    static char ch;bool f=1;
    for(x=0,ch=getchar();!isdigit(ch);ch=getchar()) if(ch=='-') f=0;
    for(;isdigit(ch);x=(x<<1)+(x<<3)+(ch^48),ch=getchar());x=f?x:-x;
}
template<typename T>
void print(T x)
{
    if (x<0) x=-x,putchar('-');
    if (x>9) print(x/10);
    putchar(x%10+48);
}
template<typename T>
inline void print(T x,char ap) {print(x);if (ap) putchar(ap);}
template<typename T>
inline void chkmax(T &x,const T &y) {x=x<y?y:x;}
template<typename T>
inline void chkmin(T &x,const T &y) {x=x<y?x:y;}
char s[101];
int main()
{
	ios::sync_with_stdio(false);
	cin>>s;
	for(res i=1;i<=strlen(s);++i) cout<<'x';cout<<'\n';
	cout<<flush;
	return 0;
}
/* stuff you should look for
    * int overflow, array bounds
    * special cases (n=1?), set tle
    * do something instead of nothing and stay organized
*/ 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
#define eps 1e-13
#define PI 3.141592653589793238L
#define INF 1000000011
#define INFLL 1000000000000000011LL
#define space printf(" ")
#define endl printf("\n")
#define vi vector<int>
#define vll vector<long long>
#define vc vector<char>
#define vs vector<string>
#define pii pair<int, int>
#define pll pair<long long, long long>
#define pil pair<int, long long>
#define pli pair<long long, int>
#define pcc pair<char, char>
#define pdd pair<double, double>
#define mp make_pair
#define F first
#define S second
#define pb(x) push_back(x)
#define fo(i,a,n) for(i = (a); i < (n); i++)
#define sd(x) scanf("%d", &(x))
#define pd(x) printf("%d", (x))
#define pdn(x) printf("%d\n", (x))
#define slld(x) scanf("%lld", &(x))
#define plld(x) printf("%lld", (x))
#define plldn(x) printf("%lld\n", (x))
#define sllf(x) scanf("%llf", &(x))
#define pllf(x) printf("%.9llf", (x))
#define pllfn(x) printf("%.9llf\n", (x))
#define sch(x) scanf("%c", &(x))
#define pch(x) printf("%c", (x))
#define pchn(x) printf("%c\n", (x))
#define gtl(x) getline(cin, (x))
#define flsh fflush(stdout)
#define sws ios_base::sync_with_stdio(false); cin.tie(0)
#define gcd __gcd
#define clr(x) memset(x,0,sizeof(x))
#define all(a) (a).begin(), (a).end()
#define foreach(i,a) for(__typeof((a).begin()) i = (a).begin(); i != (a).end(); ++i)
#define sz(a) (int)((a).size())
#define io_file freopen("D:/Coding Problems/Contest/input_file.in", "r", stdin);freopen("D:/Coding Problems/Contest/output_file.out", "w", stdout)

ll modx(ll Base, ll exponent)
{
	ll ans = 1;
	if(Base == 1)
		return Base;
	while(exponent)
	{
		if(exponent & 1)
			ans = (ans * Base)%mod;
		Base = (Base * Base)%mod;
		exponent = exponent >> 1;
	}
	return ans;
}

ll inmodx(ll num)
{
	return (modx(num, mod-2LL));
}

bool cmp()//true for a before b
{
	bool ans = 0;
	return ans;
}

struct ST_Node
{

	ST_Node()
	{
		return;
	}
	void assign_value_(int val)
	{
		return;
	}
	void merge_nodes_(ST_Node& left, ST_Node& right)
	{
		return;
	}
};

const int N = (1e5) + 9;
const int M = (N<<2) + 9;
const int LOGN = ((int)log2(N)) + 3;
const int LOGM = ((int)log2(M)) + 3;

ll a[N];

int main()
{
	sws;
	// clock_t clk;
	// clk = clock();
	// io_file;
	// srand (time(NULL));

	//Code here
	int n, i;
	ll k, g;
	cin >> n >> k;
	fo(i,1,n+1)
		cin >> a[i];
	g = a[1];
	fo(i,2,n+1)
		g = gcd(g, a[i]);
	fo(i,1,n+1)
	{
		if(k <= a[i] && (a[i]-k) % g == 0LL)
		{
			cout << "POSSIBLE";
			return 0;
		}
	}
	cout << "IMPOSSIBLE";
	// Code ends here

	// clk = clock() - clk;
	// cout << fixed << setprecision(6) << "Time: " << ((double)clk)/CLOCKS_PER_SEC << "\n";
	return 0;
}

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

using namespace std;

void solve() {
  long N;
  cin >> N;
  cout << "ABC" << N << endl;
}

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


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
 
int main(){
    int n;
    string s;
    cin >> n;
    set<int> st;
    REP(i,n){
        int x;
        cin >> x;
        if (st.count(x)) st.erase(x);
        else st.insert(x);
    }
    cout << st.size() << endl;
 
    return 0;
}

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

int addtax(int n,int p){
    return n*(100+p)/100;
}

int remtax(int n,int p){
    int ans = n*100/(100+p);
    if(addtax(ans,p)!=n)ans++;
    return (addtax(ans,p)==n ? ans : 0);
}

int main(void)
{
    int x,y,a,b,s;
    int max_sy;

    while(1){
        cin>>x>>y>>s;
        if(x==0 && y==0 && s==0)break;
        for(a=max_sy=1;;++a){
            b = remtax(s-addtax(a,x),x);
            if(!b)continue;
            if(a>b)break;
            max_sy = max(max_sy , addtax(a,y)+addtax(b,y));
        }
        cout<<max_sy<<endl;
    }

    return 0;
}

Measured memory_bytes: 1160
//https://atcoder.jp/contests/dp/tasks/dp_y
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
#ifdef BTK
#define DEBUG if(1)
#else
#define CIN_ONLY if(1)
struct cww {cww() {CIN_ONLY{ios::sync_with_stdio(false); cin.tie(0);}}}star;
#define DEBUG if(0)
#endif
#define ALL(v) (v).begin(),(v).end()
#define REC(ret, ...) std::function<ret (__VA_ARGS__)>
template <typename T>inline bool chmin(T &l, T r){bool a = l>r; if (a)l = r; return a;}
template <typename T>inline bool chmax(T &l, T r){bool a = l<r; if (a)l = r; return a;}
template <typename T>istream& operator>>(istream &is, vector<T> &v){for (auto &it : v)is >> it;return is;}
class range {private: struct I { int x; int operator*() { return x; }bool operator!=(I& lhs) { return x<lhs.x; }void operator++() { ++x; } }; I i, n;public:range(int n) :i({ 0 }), n({ n }) {}range(int i, int n) :i({ i }), n({ n }) {}I& begin() { return i; }I& end() { return n; }};
constexpr int mod = 1e9+7;
int R,C,N;
int r[3123];
int c[3123];
// mを法とするaの逆元
// O(log a)
inline LL invMod(LL a, LL m=mod){
  LL b = m, u = 1, v = 0;
  while (b) {
    LL t = a / b;
    swap(a -= t * b, b);
    swap(u -= t * v, v);
  }
  return (u % m + m) % m;
}


// 階乗
// O(n)
constexpr int SZ = 1123456;
LL fact[SZ];
LL rfact[SZ];
struct fact_{
    fact_(){
        fact[0]=1;
        for(int i=1;i<SZ;i++)
            fact[i]=fact[i-1]*i%mod;
        rfact[SZ-1]=invMod(fact[SZ-1]);
        for(int i=SZ-1;i>0;i--){
            rfact[i-1]=rfact[i]*i%mod;
        }
    }
}fact_init;


// 組み合わせnCk (mod mod)
// O(1)
LL Comb(LL n,LL k){
    LL u=fact[n];
    LL d=(rfact[k]*rfact[n-k])%mod;
    return u*d%mod;
}
pair<int,int> a[3123];
LL dp[3123][2];
LL calc(LL dr,LL dc){
    return Comb(dr+dc,dr);
}
int main(){
    cin>>R>>C>>N;
    for(int i:range(N)){
        cin>>r[i+1]>>c[i+1];
        a[i+1]={r[i+1]+c[i+1],i+1};
    }
    r[0]=1;c[0]=1;
    r[N+1]=R;c[N+1]=C;
    a[0]={2,0};
    a[N+1]={R+C,N+1};
    sort(a,a+N+2);
    dp[0][0]=1;
    for(int e:range(1,N+2)){
        int i = a[e].second;
        for(int j:range(N+2)){
            if(i!=j&&r[i]>=r[j]&&c[i]>=c[j]){
                dp[i][1]+=dp[j][0]*calc(r[i]-r[j],c[i]-c[j])%mod;
                dp[i][0]+=dp[j][1]*calc(r[i]-r[j],c[i]-c[j])%mod;
            }
        }
        dp[i][0]%=mod;
        dp[i][1]%=mod;
    }
    cout<<(mod+dp[N+1][1]-dp[N+1][0])%mod<<endl;
    return 0;
}

Measured memory_bytes: 17920
#include<stdio.h>
int main(void)
{
	int a, b;
	scanf("%d%d", &a, &b);
	
	if (a < b)
	{
		printf("a < b\n");
	}
	else if (a > b)
	{
		printf("a > b\n");
	}
	else
	{
		printf("a == b\n");
	}
	return 0;
}


Measured memory_bytes: 2108
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {

            int a = int.Parse(Console.ReadLine());//500
            int s = int.Parse(Console.ReadLine());//100
            int d = int.Parse(Console.ReadLine());//50
            int target = int.Parse(Console.ReadLine());
            int kazu=0;

            int i,j,k;
            for (i = 0; i <= a; i++)
            {
                for (j = 0; j <= s; j++)
                {
                    for (k = 0; k <= d; k++)
                    {
                        if((i*500+j*100+50*k)== target) { kazu++;}
                    }
                }
            }

            Console.WriteLine(kazu);




        }
    }
}

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

int main() {
  int A, B, C, X;
  cin >> A >> B >> C >> X;
  int pattern = 0;

  for (int i = 0; i <= A; i++) {
    for (int j = 0; j <= B; j++) {
      for (int k = 0; k <= C; k++) {
        if(500 * i + 100 * j + 50 * k == X) {
          pattern++;
        }
      }
    }
  }

  cout << pattern << endl;
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
#define FOR(i,a,b) for(int (i)=(a); (i)<=(b); (i)++)
#define REP(i,N) FOR((i), 0, (N)-1)
int gcd(int a, int b){if(a>b) swap(a,b); return a==0 ? b : gcd(b%a,a);}

int main(){
    double N,X,ans=0.0;
    string U;
    cin >> N;
    REP(i,N){
        cin >> X >> U;
        if(U == "JPY") ans += X;
        if(U == "BTC") ans += X * 380000.0;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
// while( !(succeed == try()) );

#include "bits/stdc++.h"
using namespace std;

// Alpha // Alpha // Alpha // Alpha // Alpha // Alpha // Alpha // Alpha // Alpha // Alpha


#define int long long int
#define loop(i,s,e) for(int i=s; i<e; i++)
#define endl '\n'
#define vii vector<int>
#define pii pair<int, int>
#define ff first
#define ss second
#define N 100001
#define pb push_back
#define INF LLONG_MAX
#define inf INT_MAX

void INP();

#define bug(...)        __f (#__VA_ARGS__, __VA_ARGS__)
#define rtn                                       if(0)return;
template <typename Arg1>
void __f (const char* name, Arg1&& arg1) { rtn cout << name << " : " << arg1 << endl; }
template <typename Arg1, typename... Args>
void __f (const char* names, Arg1&& arg1, Args&&... args)
{     rtn 
     const char* comma = strchr (names + 1, ',');
     cout.write (names, comma - names) << " : " << arg1 << " | "; __f (comma + 1, args...);
}

// Alpha // Alpha // Alpha // Alpha // Alpha // Alpha // Alpha // Alpha // Alpha // Alpha


void alpha()
{	
	int n;
	cin>>n;

	string str;
	cin>>str;

	int pre[n][3];
	int post[n][3];

	memset(pre, 0, sizeof(pre));
	memset(post, 0, sizeof(post));

	loop(i,0,str.size()){
		if(str[i]=='R') pre[i][0]++;
		else if(str[i]=='G') pre[i][1]++;
		else pre[i][2]++;

		if(i<n-1){
			for(int j=0; j<3; j++){
				pre[i+1][j] = pre[i][j];
			}
		}

	}


	for(int i=str.size()-1; i>=0; i--){

		if(str[i]=='R') post[i][0]++;
		else if(str[i]=='G') post[i][1]++;
		else post[i][2]++;

		if(i>0){
			for(int j=0; j<3; j++){
				post[i-1][j] = post[i][j];
			}
		}

	}

	// loop(j,0,3){
	// 	loop(i,0,n){
	// 		cout<<post[i][j]<<" ";
	// 	}
	// 	cout<<endl;
	// }

	int ans = 0;
	loop(i,0,str.size()){
		if(str[i]=='R'){
			ans += pre[i][1]*post[i][2];
			ans += pre[i][2]*post[i][1];

			loop(j,0,i){
				if(str[j]=='G' and i+i-j < n and str[i+i-j]=='B') ans--;
				if(str[j]=='B' and i+i-j < n and str[i+i-j]=='G') ans--;
			}
		}
		else if(str[i]=='G'){
			ans += pre[i][0]*post[i][2];
			ans += pre[i][2]*post[i][0];

			loop(j,0,i){
				if(str[j]=='R' and i+i-j < n and str[i+i-j]=='B') ans--;
				if(str[j]=='B' and i+i-j < n and str[i+i-j]=='R') ans--;
			}
		}
		else{
			ans += pre[i][0]*post[i][1];
			ans += pre[i][1]*post[i][0];

			loop(j,0,i){
				if(str[j]=='R' and i+i-j < n and str[i+i-j]=='G') ans--;
				if(str[j]=='G' and i+i-j < n and str[i+i-j]=='R') ans--;
			}

		}
	}

	cout<<ans;
}

int32_t main(){

	ios_base:: sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	//INP();
    int t=1;
	//cin>>t;

  	while(t--) alpha();

	return 0;

}






















inline void INP()
{
      #ifndef ONLINE_JUDGE
          freopen("input.txt",  "r",  stdin);
          freopen("output.txt", "w", stdout);
      #endif
}
 
 

Measured memory_bytes: 3748
#include <bits/stdc++.h>
using namespace std;
#define ll          long long int
#define pb          push_back
#define pll         pair<ll,ll>
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define mod         1000000007
#define inf         1000000000000000000LL
#define vl          vector<ll>
#define F           first
#define S           second
#define db          long double
#define sz(x)       (ll)x.size()
#define fix(n)      cout<<fixed<<setprecision(n)
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define all(x)      x.begin(),x.end()
#define pi          3.14159265358979323

const int  N = 1e5+5;
ll color[N], n;
vl g[N];
map<pll,ll>edg;


void dfs(ll s, ll c)
{
       color[s]=c;
       for(ll d : g[s])
       {
              if(color[d]) continue;
              if(edg[{s,d}]&1) dfs(d,3-c);
              if(edg[{s,d}]%2==0) dfs(d,c);
       }
}


void solve()
{
       cin>>n;
       memset(color, 0, sizeof color);
       rep(i,0,n-1)
       {
              ll x,y,w;
              cin>>x>>y>>w;
              g[x].pb(y);
              g[y].pb(x);
              edg[{x,y}]=w;
              edg[{y,x}]=w;
       }
       dfs(1,1);
       //rep(i,1,n+1) cout<<color[i]<<" ";

       for(ll i=1; i<=n; i++)
       {
              if(color[i]==1) cout<<0<<"\n";
              else cout<<1<<"\n";
       }
}

int main()
{
       speed_up;
       ll T=1;
       //cin>>T;
       while(T--) solve();
	return 0;
}


Measured memory_bytes: 23552
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, std.bitmanip;

void main() {
    auto s = readln.split.map!(to!int);
    auto N = s[0] * 2;
    auto Q = s[1];
    auto A = readln.split.map!(to!long).array;
    auto B = readln.split.map!(to!long).array;
    
    auto rbt = new RedBlackTree!(long, "a > b", true)();
    long sm = 0;
    int cnt = 0;
    foreach (i; 0..N) {
        if (i == 0 || i == N-1) {
            sm += A[i];
        } else if (A[i] >= B[i]) {
            sm += A[i];
            rbt.insert(B[i] - A[i]);
        } else {
            sm += B[i];
            cnt += 1;
            rbt.insert(A[i] - B[i]);
        }
    }

    while (Q--) {
        s = readln.split.map!(to!int);
        auto p = s[0] - 1;
        auto x = s[1].to!long;
        auto y = s[2].to!long;
        if (p == 0 || p == N - 1) {
            sm = sm - A[p] + x;
            A[p] = x;
            B[p] = y;
        } else {
            sm = sm - max(A[p], B[p]) + max(x, y);
            rbt.removeKey(-abs(A[p] - B[p]));
            rbt.insert(-abs(x - y));
            if (A[p] < B[p]) cnt -= 1;
            if (x < y) cnt += 1;
            A[p] = x;
            B[p] = y;
        }
        writeln(cnt % 2 ? sm + rbt.front : sm);
    }
}


Measured memory_bytes: 51072
#include<bits/stdc++.h>
using namespace std;
int n,num[4];
string s;

int main()
{	cin>>n;
	while(n--)
	{
		cin>>s;
		if(s=="AC")
			num[0]++;
		else if(s=="WA")
			num[1]++;
		else if(s=="TLE")
			num[2]++;
		else
			num[3]++;
	}
	cout<<"AC x "<<num[0]<<endl;
	cout<<"WA x "<<num[1]<<endl;
	cout<<"TLE x "<<num[2]<<endl;
	cout<<"RE x "<<num[3]<<endl;
	return 0;
}

Measured memory_bytes: 3632
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<queue>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<map>
#include<complex>
#define INF 2147483647
#define llINF 9223372036854775807
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long

using namespace std;
int main(){
  int n;
  while(cin>>n,n){
    int po=-1;
    vector<vector<int> > vvi(n);
    for(int i=0;i<n;i++){
      int m;cin>>m;
      for(int j=0;j<m;j++){
	int a;cin>>a;
	vvi[i].pb(--a);
      }
    }
    int k;cin>>k;
    bool flag2[1000]={};
    for(int i=0;i<k;i++){
      int a;cin>>a;
      flag2[--a]=true;
    }
    int ans=0;
    for(int i=0;i<n;i++){
      //cout<<i<<endl;
      bool flag[1000]={};
      int cnt=0;
      for(int j=0;j<vvi[i].size();j++)
	flag[vvi[i][j]]=true;
      for(int j=0;j<1000;j++){
	if(flag[j]&&flag2[j])
	  cnt++;
      }
      if(cnt==k){
	//cout<<"!"<<" "<<i<<endl;
	ans++;
	po=i+1;
	//	break;
      }
    }
    if(ans==1)
      cout<<po<<endl;
    else
      cout<<-1<<endl;
  }
  return 0;
}



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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reps(i,s,n) for(int (i)=(s);(i)<(n);(i)++)
#define repr(i,n) for(int (i)=(n)-1;(i)>=0;(i)--)
#define all(v) (v).begin(),(v).end()
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define mp make_pair
#define pb push_back
#define mod 1000000007
#define inf 1000000000
#define llinf 1000000000000000


typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef pair<int,int> pint;
typedef pair<ll,ll> pll;
typedef vector<pint> vpint;

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

int main(){
    int h,w;
    cin>>h>>w;
    char a[h][w];
    rep(i,h)rep(j,w)cin>>a[i][j];
    queue<pint> que;
    rep(i,h)rep(j,w){
        if(a[i][j]=='#')que.push(mp(i,j));
    }
    rep(loop,20001){
        int nowsize=que.size();
        if(nowsize==0){
            cout<<loop-1<<endl;
            return 0;
        }
        rep(i,nowsize){
            pint nowp=que.front();
            que.pop();
            rep(j,4){
                int x=nowp.first+dx[j];
                int y=nowp.second+dy[j];
                if(x<0 || x>=h || y<0 || y>=w)continue;
                if(a[x][y]=='.'){
                    a[x][y]='#';
                    que.push(mp(x,y));
                }
            }
        }
    }
}

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

constexpr int INF = 1e9;
int dy[] = {1,-1};
int dx[] = {0,0}; 
int main(){
  int h, w, k;
  cin >> h >> w >> k;
  vector<vector<char>> g(h,vector<char>(w));
  vector<vector<int>> d(h,vector<int>(w,INF));
  queue<P> que, que2;
  int cnt = 1;
  rep(i,h) rep(j,w) {
    cin >> g[i][j];
    if (g[i][j] == '#') {
      d[i][j] = cnt++;
    }
  }
  vector<int> c;
  rep(i,h) {
    bool ok = true;
    rep(j,w) {
      if (g[i][j] == '#') {
        ok = false;
        for (int k = j+1; k < w; k++) {
          if (d[i][k] != INF) break;
          d[i][k] = d[i][j];
        }
      }
    }
    if (ok) c.push_back(i);
  }

  rep(i,h) {
    rep(j,w) {
      if (j > 0 && d[i][j] != INF && d[i][j-1] == INF) {
        for (int k = j-1; k >= 0; k--) {
          if (d[i][k] != INF) break;
          d[i][k] = d[i][j];
        }
      }
    }
  }

  for (auto i : c) {
    rep(j,w) {
      if (i == 0) d[i][j] = d[i+1][j];
      else d[i][j] = d[i-1][j];
    }
  }
  reverse(c.begin(), c.end());
  for (auto i : c) {
    rep(j,w) {
      if (d[i][j] != INF) continue;
      if (i == h-1) d[i][j] = d[i-1][j];
      else d[i][j] = d[i+1][j];
    }
  }


  rep(i,h) {
    rep(j,w) {
      if (j < w-1) cout << d[i][j] << " ";
      else cout << d[i][j] << endl;
    }
  }


  return 0;
} 

Measured memory_bytes: 1280
# AOJ 0010 Circumscribed Circle of a Triangle
# Python3 2018.6.22 bal4u

import math
EPS = 1e-8

def cross(a, b):
	return a.real*b.imag - a.imag*b.real
def dist(a, b):
	return math.hypot(a.real-b.real, a.imag-b.imag)
	
# 両直線の交点
def crossPointLL(ln1, ln2):
	u = ln1[1]-ln1[0]
	v = ln2[1]-ln2[0]
	return ln1[0] + u*(cross(v, ln2[0]-ln1[0])/cross(v, u))

# 入力:３点座標、リターン:外接円の円心座標、半径を表すリスト
def circumscribed_circle(p1, p2, p3):
	p12 = (p1+p2)/2
	p23 = (p2+p3)/2
	ln1 = [p12, p12+(p1-p2)*complex(0, 1)]
	ln2 = [p23, p23+(p2-p3)*complex(0, 1)]
	c = crossPointLL(ln1, ln2)
	return [c, dist(c, p1)]

for i in range(int(input())):
	p = list(map(float, input().split()))
	p1 = complex(p[0], p[1])
	p2 = complex(p[2], p[3])
	p3 = complex(p[4], p[5])
	ans = circumscribed_circle(p1, p2, p3)
	print(format(ans[0].real+EPS, ".3f"), format(ans[0].imag+EPS, ".3f"), format(ans[1]+EPS, ".3f"))



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

int main(){
    int N, R;
    cin >> N >> R;
    int n = 100*(10-N);
    if(N<10){
        cout << R+n << endl;
    }
    else{
        cout << R << endl;
    }
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;

public class CSharp{
    public static void Main(){
        Kyopuro chokudai = new Kyopuro();
	    chokudai.AtCoder();
	}
}

public class Kyopuro{

	int a,b;
	
    public void AtCoder(){
        string[] input;
		input = Console.ReadLine().Split(' ');
		a = int.Parse(input[0]);
		b = int.Parse(input[1]);
      
        int c = a + b;
      	if (c % 2 == 0) Console.WriteLine(c / 2);
      	else Console.WriteLine("IMPOSSIBLE");
		
		
    }
    public static void DebugWL(object x){ System.Diagnostics.Debug.WriteLine(x); }
}


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

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}

int main() {
	int n = ri();
	int k = ri();
	int a[n];
	for (auto &i : a) i = ri();
	std::sort(a, a + n);
	int64_t res = 0;
	for (int i = 0; i < n - k; i++) res += a[i];
	printf("%lld\n", (long long) res);
	return 0;
}



Measured memory_bytes: 1024
// Aizu Vol-1 0184: Tsuruga Castle
// 2017.8.2

#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>

char *gets(char *);
char buf[100], *p;

int getInt(void)
{
	int n = 0;
	//	while (isspace(*p)) p++;
	while (isdigit(*p)) n = 10 * n + (*p++ - '0');
	return n;
}

int cnt[15];

#if 0
int main()
{
	int i, n, k;

	while (1) {
		gets(p = buf);
		if (!(n = getInt())) break;
		memset(cnt, 0, sizeof(cnt));
		for (i = 0; i < n; i++) {
			gets(p = buf);
			cnt[getInt() / 10]++;
		}
		for (i = k = 0; i < 6; i++) printf("%d\n", cnt[i]), k += cnt[i];
		printf("%d\n", n - k);
	}
	return 0;
}
#else
int main()
{
	int i, n, k;

	while (1) {
		gets(buf);
		if (!(n = atoi(buf))) break;
		memset(cnt, 0, sizeof(cnt));
		for (i = 0; i < n; i++) {
			gets(buf);
			cnt[atoi(buf) / 10]++;
		}
		for (i = k = 0; i < 6; i++) printf("%d\n", cnt[i]), k += cnt[i];
		printf("%d\n", n - k);
	}
	return 0;
}

#endif

Measured memory_bytes: 524
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define sz(v) (int)(v).size()
#define pb push_back
#define sc second
#define fr first
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
using namespace std;
typedef long long int ll;
typedef pair <int, int> P;

const ll MOD=1000000007;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N;
    string S;
    cin>>N;
    cin>>S;
    vector<char> v;
    rep(i,0,N){
        if(sz(v)==0||!(v.back()=='('&&S[i]==')')) v.pb(S[i]);
        else {
            v.pop_back();
        }
    }
    int l=0,r=0;
    rep(i,0,sz(v)){
        if(v[i]==')') l++;
        else r++;
    }
    rep(i,0,l){
        cout <<'(';
    }
    rep(i,0,N){
        cout <<S[i];
    }
    rep(i,0,r){
        cout <<')';
    }
    cout<<"\n";
}

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

using namespace std;

const int maxn = 3e3+10;
const int maxh = 2e5+10;
const long long mod = 1e9+7;

typedef long long ll;
typedef pair<int, int> pii;

pii num[maxn];

ll dp[maxn], fat[maxh];

ll pot(ll a, ll b)
{
	if (!b) return 1;

	ll t = pot(a, b/2);

	if (b%2) return ( ((a*t)%mod) * t)%mod;
	return (t*t)%mod;
}

ll choose(ll a, ll b)
{
	ll x = pot((fat[b]*fat[a-b])%mod, mod-2);
	return (fat[a]*x)%mod;
}

int main(void)
{
	int h, w, n;
	cin >> h >> w >> n;

	fat[0] = 1LL;
	for (int i = 1; i < maxh; i++)
		fat[i] = (fat[i-1]*i)%mod;

	for (int i = 1; i <= n; i++)
		cin >> num[i].first >> num[i].second;

	sort(num+1, num+n+1);

	dp[n] = choose(h-num[n].first+w-num[n].second, h-num[n].first);
	for (int i = n-1; i >= 1; i--)
	{
		dp[i] = choose(h-num[i].first + w-num[i].second, h-num[i].first);
		for (int j = i+1; j <= n; j++)
		{
			ll dx = num[j].first-num[i].first;
			ll dy = num[j].second-num[i].second;

			if (dx < 0 || dy < 0) continue;

			ll x = choose(dx+dy, dx);

			dp[i] = (dp[i]-((x*dp[j])%mod)+mod)%mod;
		}
	}

	ll ans = choose(h+w-2, h-1);
	for (int i = 1; i <= n; i++)
	{
		ll x = choose(num[i].first+num[i].second-2, num[i].first-1);
		ans = (ans-((x*dp[i])%mod)+mod)%mod;
	}

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

Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		while (true) {
			int judge = sc.nextInt();
			if (judge == 0)
				break;

			int[] score = new int[judge];
			int max = 0, min = 1000, sum = 0;

			for (int i = 0; i < judge; i++) {
				score[i] = sc.nextInt();
				sum += score[i];
				if (score[i] > max)
					max = score[i];
				if (score[i] < min)
					min = score[i];
			}

			System.out.println((int) Math.floor((double) (sum - max - min)
					/ (double) (judge - 2)));
		}
	}
}

Measured memory_bytes: 28608
s = input()[::-1]
mod_cnt = [0] * 2019
mod_cnt[0] = 1
t = 0
d = 1
for c in s:
    t += int(c) * d
    t %= 2019
    mod_cnt[t] += 1
    d *= 10
    d %= 2019
print(sum([m * (m - 1) // 2 for m in mod_cnt]))

Measured memory_bytes: 9404