akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtTest.Virtual
{
    class ABC099_C
    {
        static void Main(string[] args)
        {
            Method(args);
            ReadLine();
        }

        static void Method(string[] args)
        {
            int n = ReadInt();
            int length = n / 9 + 1;
            List<int> sixes = new List<int>();
            int val = 1;
            while (val < n)
            {
                val *= 6;
                sixes.Add(val);
            }
            List<int> nines = new List<int>();
            val = 1;
            while (val < n)
            {
                val *= 9;
                nines.Add(val);
            }
            int res = int.MaxValue;
            for(int i = 0; i < length; i++)
            {
                int now = n - 9 * i;
                int cnt = 0;
                for(int j = sixes.Count-1; j >= 0; j--)
                {
                    cnt += now / sixes[j];
                    now %= sixes[j];
                }
                cnt += now;

                now = 9 * i;
                for(int j = nines.Count-1; j >= 0; j--)
                {
                    cnt += now / nines[j];
                    now %= nines[j];
                }
                res = Min(res, cnt);
            }
            WriteLine(res);
        }

        private static string Read() { return ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


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

int main(){
  int N,M;
  cin >> N >> M;
  
  if(N%2==1){
    for(int i=1;i<=M;i++) cout << i << " " << N-i << endl;
  }
  
  else if(N==4) cout << 1 << " " << 2 << endl;
  
  else{
    cout << N-2 << " " << N << endl;
    int a=1,b=N-3;
    vector<bool> V(N/2+1,false);
    V[N/2] = true;
    V[2] = true;
    for(int i=1;i<M;i++){
      if(V[min(b-a,N-(b-a))] == true) b--;
      cout << a << " " << b << endl;
      V[min(b-a,N-(b-a))] = true;
      a++;
      b--;
    }
  }
  
  return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <cmath>
using namespace std;
typedef long long ll;
#define MOD 1000000007
ll factorial(int n) {
    ll ret = 1;
    for (int i = 1; i <= n; i++) {
        ret = ret * i % MOD;
    }
    return ret;
}
int main (void) {
    ll N;
    ll M;

    cin >> N >> M;

    if (abs(N - M) > 1) {
        cout << 0 << endl;
        return 0;
    }

    ll ans = factorial(N) * factorial(M) % MOD;
    if (abs(N - M) == 0) {
        ans = ans * 2 % MOD;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
program main
  integer, allocatable :: i(:, :)
  read (*, *) n
  allocate(i(3, 0:n))
  i(:, 0) = (/0, 0, 0/)
  read (*, *) i(:, 1:n)
  do k = 1, n
    jx = abs(i(2, k) - i(2, k - 1)) + abs(i(3, k) - i(3, k - 1))
    jt = i(1, k) - i(1, k - 1)
    if (jx > jt .or. ibits(jx, 0, 1) /= ibits(jt, 0, 1)) then
      write (*, *) "No"
      stop
    endif
  enddo
  write (*, *) "Yes"
end


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

typedef long long ll;
typedef int keytype;

int main(){
    int a, b, c;

    scanf("%d %d %d", &a, &b, &c);

    int h_a, h_b, h_c;
    ll cnt = 0;
    while((a % 2) == 0 && (b % 2) == 0 && (c % 2) == 0){
        if(a == b && b == c){
            puts("-1");
            return 0;
        }
        h_a = (a / 2); h_b = (b / 2); h_c = (c / 2);
        a = (h_b + h_c);
        //printf("%d %d %d\n", a, h_b, h_c);
        b = (h_a + h_c);
        c = (h_b + h_a);
        cnt++;
    }

    printf("%lld\n", cnt);

    return 0;
}


Measured memory_bytes: 1712
#include<iostream>

using namespace std;
int main(){
    int *a;
    int N;
    int def;
    int i;
    cin >> N;

    a = new int[N];
    def = 0;
    for(i=0;i<N;i++){
        cin >> a[i];
        def ^= a[i];
    }
    for(i=0;i<N;i++){
        cout << (a[i] ^ def )<< " ";
    }
    cout << endl;
}

Measured memory_bytes: 4320
#include<bits/stdc++.h>
#define endl "\n"
#define pb push_back
#define ll long long
#define d1(x)  cerr << #x << "--> " << x << endl
#define d2(x,y)  cerr << #x << "--> " << x << " | " << #y << "--> " << y <<endl
#define d3(x,y,z)  cerr << #x << "--> " << x << " | " << #y << "--> " << y <<" | " << #z << "--> "<< z<< endl
#define d4(x,y,z,w)  cerr << #x << "--> " << x << " | " << #y << "--> " << y <<" | " << #z << "--> "<< z << " | "<< #w << "--> " << w <<endl
#define vpll vector<pair<ll,ll>>
#define F first
#define S second
#define T ll tt; cin>>tt; while(tt--)
using namespace std;
ll mode=1e9+7;
const long long maxn=2*1e5+10;
const long long inf=99999999999;
ll lcm(ll a, ll b){ return (a*b)/__gcd(a,b); }
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
ll getRand(ll l, ll r){ uniform_int_distribution<ll> uid(l, r); return uid(rng); }

ll power(ll x, ll y){  
	ll p=mode, res=1;
    x = x % p;
    while (y > 0) {  
        if (y & 1)  
            res = (res*x) % p;  
        y = y>>1;
        x = (x*x) % p;  
    }  
    return res;  
}

vector<ll> adj[maxn];

void solve(){
	
	ll n,m,x;
	cin>>n>>m>>x;
	vector<ll> price(n);
	for (int i=0;i<n;i++){
		cin>>price[i];
		for (int j=0;j<m;j++){
			ll algo;
			cin>>algo;
			adj[i].pb(algo);
		}
	}
	
	ll ans=LLONG_MAX;
	for (ll mask=0;mask<(1ll<<n);mask++){
		vector<ll> temp(m,0);
		ll sum=0;
		for (ll j=0;j<n;j++){
			if (mask&(1ll<<j)){
				sum+=price[j];
				for (int k=0;k<m;k++) temp[k]+=adj[j][k];
			}
		}
		bool ok=true;
		for (int j=0;j<m;j++){
			ok&=(temp[j]>=x);
		}
		if (ok) ans=min(ans, sum);
	}
	
	if (ans!=LLONG_MAX) cout<<ans<<endl;
	else cout<<-1<<endl;
	
	
	return;
}
 
int main(){ 
    
    #ifndef ONLINE_JUDGE
		//freopen("input.txt", "r", stdin);
    #endif
    srand(time(0)); 
    
    ios::sync_with_stdio(0);
    cin.tie(0);
 	
	//T{ solve(); }
	solve();
	
	return 0;
}


Measured memory_bytes: 8252
#include <bits/stdc++.h>
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fod(i,a,b) for(int i=a;i>=b;i--)
#define me0(a) memset(a,0,sizeof(a))
#define me1(a) memset(a,-1,sizeof(a))
#define op freopen("in.txt", "r", stdin)
#define op1 freopen("C:\\acm\\Cproj\\in.txt","r",stdin);
#define pr freopen("C:\\acm\\Cproj\\out.txt","w",stdout)
#define pr2 freopen("C:\\acm\\Cproj\\std.txt","w",stdout)
#define pii pair<int,int>
using namespace std;
const int INF = 0x3f3f3f3f;
typedef long long LL;
template <class T>
void read(T &val) { T x = 0; T bz = 1; char c; for (c = getchar(); (c<'0' || c>'9') && c != '-'; c = getchar()); if (c == '-') { bz = -1; c = getchar(); }for (; c >= '0' && c <= '9'; c = getchar()) x = x * 10 + c - 48; val = x * bz; }
const int maxn = 1e6 + 11;
const int mod=1e9+7;
int n,m,x,y,t;

vector<int> col[maxn],row[maxn];
int num[maxn];


int main(){
    int h,w;read(h);read(w);
    read(m);
    fo(i,1,m){
        int x,y;read(x);read(y);
        row[x].push_back(y);
        col[y].push_back(x);
    }
    multiset<int>ms;
    fo(i,1,w) ms.insert(col[i].size()),num[i]=col[i].size();


    int ans = 0;
    fo(i,1,h){
        for(auto to:row[i]){
            ms.erase(ms.lower_bound(num[to]));
            num[to]--;
            ms.insert(num[to]);
        }
        ans = max(ans,(int)row[i].size()+*ms.rbegin());
        for(auto to:row[i]){
            ms.erase(ms.lower_bound(num[to]));
            num[to]++;
            ms.insert(num[to]);
        }
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 84484
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using ld = long double;
const int INF = (1<<30)-1;
const long long LINF = (1LL<<62)-1;
const long double PI = acos(-1.0L);
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int a, b;
  cin >> a >> b;
  if (a <= 5)
    cout << 0 << endl;
  else if (a <= 12)
    cout << b/2 << endl;
  else
    cout << b << endl;
  return 0;
}

Measured memory_bytes: 256
S = gets.chomp
Q = gets.to_i

s = S
before = []
after = []
reverse = false

Q.times do
  t, f, c = gets.split

  if t == '1'
    reverse = !reverse
  else
    if (f == '1' && !reverse) || (f == '2' && reverse)
      before << c
    else
      after << c
    end
  end
end

(reverse ? after : before).reverse.each do |c|
  print c
end

print reverse ? s.reverse : s

(reverse ? before : after).each do |c|
  print c
end

print "\n"

Measured memory_bytes: 17788
#include <stdio.h>
 
int xstack[20000];
int xtop;
int lefts[20000];
int vols[20000];
int pooltop;
 
int main(){
    int c;
    for(int x = 0; (c = getchar()) != '\n'; x++){
        if(c == '\\'){
            xstack[xtop++] = x;
        } else if (c == '/'){
            if(xtop == 0) continue;
            int last_x = xstack[--xtop];
            int new_vol = x - last_x;
            while(pooltop > 0 && last_x < lefts[pooltop-1]){
                new_vol += vols[--pooltop];
            }
            lefts[pooltop] = x;
            vols[pooltop] = new_vol;
            pooltop++;
        }
    }
    int sum = 0;
    for(int i=0; i<pooltop; i++){
        sum += vols[i];
    }
    printf("%d\n%d", sum, pooltop);
    for(int i=0; i<pooltop; i++){
        printf(" %d", vols[i]);
    }
    puts("");
}



Measured memory_bytes: 2136
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        int a;
        boolean just = false;
        Scanner scan = new Scanner(System.in);

        a = Integer.parseInt(scan.next());


        for (int donuts = 0; donuts <= a; donuts++) {
                for (int cake = 0; cake <= a; cake++) {
                    int total = (4 * donuts) + (7 * cake);
                    if (total == a) {
                        just = true;
                    }
            }
        }

        System.out.println(just ? "Yes" : "No");
    }
}


Measured memory_bytes: 23124
/**
  * http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP1_9_C&lang=jp
  * ITP1_9_C
  */
object Main {
  def main(args: Array[String]): Unit = {
    val turns = io.StdIn.readInt()
    val finalScores = Iterator.continually(io.StdIn.readLine()).takeWhile(_ != null).take(turns)
      .map(_.split(" ")).map { case Array(tarosCard, hanakosCard) => (tarosCard, hanakosCard) }
      .foldLeft((0, 0)) { (currentScores, cards) =>
        cards match {
          case (tarosCard, hanakosCard) if tarosCard > hanakosCard => (currentScores._1 + 3, currentScores._2)
          case (tarosCard, hanakosCard) if tarosCard == hanakosCard => (currentScores._1 + 1, currentScores._2 + 1)
          case (tarosCard, hanakosCard) if tarosCard < hanakosCard => (currentScores._1, currentScores._2 + 3)
        }
      }
    println(s"${finalScores._1} ${finalScores._2}")
  }
}

Measured memory_bytes: 44964
package main

import (
    "fmt"
    "sort"
    "os"
)

func main() {
  var n int
  fmt.Scan(&n)
  a := make([]int, n)
  
  for i:= 0; i<n; i++ {
    fmt.Scan(&a[i])
  }
  sort.Ints(a)

  r := 1
  for _, v := range(a) {
    if v == 0 {
      fmt.Println(0)
      os.Exit(0)
    }
    
    if v <= 1e18/r {
		r *= v
    } else {
      fmt.Println(-1)
      os.Exit(0)
    }
  }
  fmt.Println(r)
}

Measured memory_bytes: 6324
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {
	public static void main (String[] args) throws IOException {
		BufferedReader tec=new BufferedReader(new InputStreamReader(System.in));
		PrintWriter out=new PrintWriter(System.out);
		for(String line;(line=tec.readLine())!=null;){
			StringTokenizer st=new StringTokenizer(line);
			int n=Integer.parseInt(st.nextToken());
			int m=Integer.parseInt(st.nextToken());
			int[]arr=new int[n];
			Arrays.fill(arr, 1);
			int cont=1;
			boolean []pos=new boolean[n];
			pos[0]=true;
			for (int i = 0; i < m; i++) {
				st=new StringTokenizer(tec.readLine());
				int a=Integer.parseInt(st.nextToken())-1;
				int b=Integer.parseInt(st.nextToken())-1;
				arr[a]--;
				arr[b]++;
				if(pos[a]){
					if(!pos[b])
						cont++;
					pos[b]=true;					
				}
				if(arr[a]==0){
					if(pos[a])
						cont--;
					pos[a]=false;					
				}				
			}
			out.println(cont);
		}
		out.close();
	}
}


Measured memory_bytes: 41968
from math import sqrt

while True:
    e=int(input())
    if e==0:
        break
    m=e
    for z in range(e):
        if(z**3>e):
            break
        temp=e-z**3
        y=int(sqrt(temp))
        x=temp-y**2
        m=min(m,x+y+z)
    print(m)


Measured memory_bytes: 5676
A, B, C, X = 4.times.map {gets.to_i}

res = 0
(A + 1).times do |a|
  (B + 1).times do |b|
    (C + 1).times do |c|
      res += 1 if 500 * a + 100 * b + 50 * c == X
    end
  end
end
puts res


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

int main() {
  int N;
  cin >> N;
  vector<tuple<string,int,int>> a(N);
  for (int i;i<N;i++){
    string x;
    int y;
    cin >> x >>y;
    a.at(i)=make_tuple(x,100-y,i+1);
  }
  sort(a.begin(), a.end());

  for (tuple<string,int, int> t : a) {
    string x;
    int y,i;
    tie(x,y,i) = t;
    cout << i << endl;
  }
}

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

#define loop(v, f, l) for(int v = (f), v##_ = (l); v < v##_; ++v)

using namespace std;

typedef long long int lint;
static inline int in(){ int x; scanf("%d", &x); return (x); }
static inline lint inl(){ lint x; scanf("%lld", &x); return (x); }

int main()
{
	for(int i = 0; i < 7; i++)
	{
		int max_t = in();
		int min_t = in();
		printf("%d\n", max_t - min_t);
	}
	return (0);
}

Measured memory_bytes: 1188
using System;

namespace ConsoleApplication17
{
    class Program
    {
        static void Main(string[] args)
        {
            {
                string[] s = Console.ReadLine().Split(' ');
  
            int[] n = new int[3];
            n[0] = int.Parse(s[0]);
            n[1] = int.Parse(s[1]);
            n[2] = int.Parse(s[2]);
  
            Array.Sort(n);
            Console.WriteLine(n[0] + " " + n[1] + " " + n[2]);

                }
            }
         }
     }

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

bool comp(string a, string b){
    return (a.length()==b.length())? a < b : a.length() < b.length();
}

int main(){
    int n;
    cin >> n;
    vector<string> a(n);
    for(int i=0; i<n; i++) cin >> a[i];
    string f,s,t;
    f = s = t = "9999999999";
    for(int i=0; i<n; i++){
        for(int j=0; j<n; j++){
            if(i==j) continue;
            string per = a[i]+a[j];
            if(comp(per, t)){
                t = per;
                if(comp(t, s)){
                    swap(t, s);
                    if(comp(s, f)) swap(s, f);
                }
            }
        }
    }
    cout << t << endl;
    return 0;
}


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

using namespace std;

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	int a, b;
	cin >> a >> b;
	for(int i = 0; i < max(a, b); ++i) cout << min(a, b);

	return 0;
}



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

#define int long long
#define uint unsigned long long
#define double long double
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, n) for (int i = 1; i <= (n); i++)
#define all(x) (x).begin(), (x).end()
#define uniq(x) (x).erase(unique(all(x)), (x).end());
#define bit(n) (1LL << (n))
#define dump(x) cerr << #x " = " << (x) << endl
using vint=vector<int>;
using vvint=vector<vint>;
using pint=pair<int, int>;
using vpint=vector<pint>;
template<typename T> using priority_queue_rev=priority_queue<T, vector<T>, greater<T>>;
constexpr double pi = 3.1415926535897932384626433832795028;
constexpr int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b) {
    while (b) { swap(a %= b, b); }
    return a;
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
template<typename T1, typename T2> bool chmax(T1 &a, const T2 &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T1, typename T2> bool chmin(T1 &a, const T2 &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &rhs) {
    os << "(" << rhs.first << ", " << rhs.second << ")";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const vector<T> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
struct Setup {
    static constexpr int PREC = 20;
    Setup() {
        cout << fixed << setprecision(PREC);
        cerr << fixed << setprecision(PREC);
    };
} setup;

signed main() {
    int N;
    cin >> N;
    vint A(N), cnt(N + 1);
    rep(i, N) {
        cin >> A[i];
        cnt[A[i]]++;
    }
    sort(all(cnt));
    cnt.push_back(LLONG_MAX);
    int replaced = 0, cum = 0;
    vint f(N + 1);
    f[0] = LLONG_MAX;
    reps(i, N) {
        while (cnt[replaced] < i) { cum += cnt[replaced], replaced++; }
        f[i] = (cum + (N+1 - replaced) * i) / i;
    }
    int idx = N;
    reps(i, N) {
        while (f[idx] < i) { idx--; }
        cout << idx << endl;
    }
}

Measured memory_bytes: 9828
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <map>
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
using namespace std;
int main() {
	int64_t x, y;
	cin >> x >> y;
	if (x > 1) {
		x -= 2;
	}
	if (y > 1) {
		y -= 2;
	}
	cout << x*y;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
typedef unsigned long long int ull;
typedef long double ldb;
typedef long long int ll;
 
#define for01(k,n)  for (ll i=k; i<n; i++)
#define for02(k,n)  for (ll j=k; j<n; j++)
#define for03(k,n)  for (ll k=k; k<n; k++)
#define for11(k,n)  for (ll i=k; i<=n; i++)
#define for12(k,n)  for (ll j=k; j<=n; j++)
#define for13(k,n)  for (ll k=k; k<=n; k++)

#define pb push_back
#define mp make_pair
#define pf push_front
#define popf pop_front
#define popb pop_back
#define vll vector<ll>
#define F first
#define S second
#define pp pair <ll, ll>
#define lb lower_bound
#define ub upper_bound
#define emp empty()
#define beg begin()
#define en end()
#define si size()
#define bk back()
#define deci(n)  fixed<<setprecision(n)

#define p0(a) cout << a << " "
#define p1(a) cout << a << "\n"

#define mem(a,n) memset(a, n, sizeof(a)); // n = 0 OR -1 only

#define MAX LLONG_MAX
#define MIN LLONG_MIN
#define MOD 1000000007
#define MOD2 998244353

using namespace std;


int main()
{
  ll H,W,n;
  cin >> W >> H >>n;
  
  ll x1 = 0, x2 = W, y1 = 0, y2 = H;
  ll xi = 0, yi = 0 ,a;
  
  while(n--)
  {
    cin >> xi >> yi >> a;
    
    switch(a)
    {
      case 1: x1 = max(x1,xi);break;
      case 2: x2 = min(x2,xi);break;
      case 3: y1 = max(y1,yi);break;
      case 4: y2 = min(y2,yi);break;
    }
    //cout << n << " = " << x1 << " " << x2 << " - " << y1 << " " << y2 << "\n";
  }
  
  //cout << x1 << " " << x2 << "\n" << y1 << " " << y2 << "\n"; 
  p1( max( x2-x1, 0ll) * max( y2-y1, 0ll));
  
  return 0;
}

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

int main() {
  int n;
  while (cin >> n, n) {
    vector<int> a(n);
    int s = 0;
    for (auto &e : a) {
      cin >> e;
      s += e;
    }
    double m = (double)s / n;
    int r = 0;
    for (auto e : a) {
      r += e <= m;
    }
    cout << r << endl;
  }
}



Measured memory_bytes: 3108
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define ALL(x) (x).begin(), (x).end()
#define REP(i ,n) for(int i = 0; i < (int)(n); i++)
#define pb push_back
typedef vector<int>vint;
typedef vector<ll>vll;
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

int main(){
    ll H;
    cin >> H;
    int cnt=0;
    ll ans = 0;
    while(true){
        if(0 >= H){
            break;
        }
        H /= 2;
        ans += (ll)pow(2,cnt);
        cnt++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

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

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

const int inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

// -------------------------------------------------------
ll N;
vector<ll> A, B, C;

int main() {
  cin >> N;
  rep(i, 0, N) {
    ll a;
    cin >> a;
    A.push_back(a);
  }
  rep(i, 0, N) {
    ll b;
    cin >> b;
    B.push_back(b);
  }
  rep(i, 0, N) {
    ll c;
    cin >> c;
    C.push_back(c);
  }
  sort(A.begin(), A.end());
  sort(B.begin(), B.end());
  sort(C.begin(), C.end());

  ll ans = 0;
  for (auto e : B) {
    auto lb = lower_bound(A.begin(), A.end(), e);
    ll lidx = lb - A.begin();

    auto ub = upper_bound(C.begin(), C.end(), e);
    ll uidx = ub - C.begin();
    ll unum = N - uidx;

    ans += lidx * unum;
  }

  cout << ans << endl;
}


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

using namespace std;

#define INF 1000000007
#define LINF (1LL << 60)
#define PI 3.14159265358979

typedef long long i64;
typedef pair<i64,i64> P;

inline i64 mod(i64 a, i64 m) { return (a % m + m) % m; }

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }



int n, a[10101];
int cnt[1010101];
i64 mod_pow(i64 x, i64 y, i64 mod){
	i64 res = 1;
	while(y > 0){
		if(y & 1) res = res * x % mod;
		x = x*x %mod;
		y >>= 1;
	}
	return res;
}
i64 extgcd(i64 a, i64 b, i64 &p, i64 &q){
	if(b == 0){
		p = 1;
		q = 0;
		return a;
	}
	i64 c = extgcd(b, a%b, q, p);
	q -= a/b * p;
	return c;
}
i64 modinv(i64 a, i64 m) {
    i64 x, y;
    extgcd(a, m, x, y);
    return mod(x, m);
}
i64 fract(i64 x, i64 y, i64 mod){
	return x*modinv(y, mod) % mod;
}
void solve(){
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> a[i];
	}
	
	for(int i = 0; i < n; i++){
		int aa = a[i];
		for(int j = 2; j*j <= a[i]; j++){
			int c = 0;
			if(aa % j) continue;
			while(aa % j == 0){
				c++;
				aa /= j;
			}
			chmax(cnt[j], c);
		}
		chmax(cnt[aa],1);
	}
	
	i64 sum = 1;
	for(int i = 2; i < 1010101; i++){
		sum *= mod_pow(i,cnt[i],INF);
		sum %= INF;
	}
	i64 ans = 0;
	for(int i = 0; i < n; i++){
		ans += fract(sum, a[i], INF);
		ans %= INF;
	}
	cout << ans << endl;
}

int main(){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	int t = 1;
	//cin >> t;
	while(t--){
		solve();
	}
	
	return 0;
}


Measured memory_bytes: 2944
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
using namespace std;
typedef long long ll;

namespace mp = boost::multiprecision;
using Bint = mp::cpp_int;
using Real = mp::number<mp::cpp_dec_float<1024>>;

#define INCANT cin.tie(0), ios::sync_with_stdio(false), cout << fixed << setprecision(20)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) FOR(i,0,n)
#define all(x) (x).begin(),(x).end()
#define out(a) cout << a << endl
#define PRINT(V) for (auto v : (V)) cout << v << " "

const int MOD = 1000000007;
const double PI = acos(-1.0);

void solve() {
    int x;
    rep(i, 5){
        cin >> x;
        if(x==0){
            out(i+1);
            return;
        }
    }
}
int main() {
    INCANT;
    solve();
    return 0;
}




Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <random>
#include <cassert>
#include <numeric>
#define ll long long int
#define LL unsigned long long
#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
using namespace std;

int mx8[] = {0,0,1,-1,-1,1,-1,1};
int my8[] = {-1,1,0,0,-1,-1,1,1};
int mx4[] = {1,-1,0,0};
int my4[] = {0,0,-1,1};
const int MOD = 1000000007;



int main() {
    vector<ll> a(3);
    rep(i,3) cin >> a[i];
    if(a[0] % 2 == 0 || a[1] % 2 == 0 || a[2] % 2 == 0){
        cout << 0 << endl;
    }else{
        sort(a.begin(),a.end());
        cout << a[0] * a[1] * (a[2] - 2 * (a[2] / 2)) << endl;
    }
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
void pr(){ln;}
template<Z A,Z...B>void pr(const A &a,const B&...b){cout<<a<<' ';pr(b...);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[8]={-1,0,1,0,-1,-1,1,1},dy[8]={0,1,0,-1,-1,1,1,-1};
typedef pair<ll,ll> P;

vector<ll> v[222222];
ll n,dp[222222],a[222222],ans[222222];

void dfs(int x,int p) {
  ll k=lower_bound(dp,dp+n,a[x])-dp;
  ll d=dp[k];
  dp[k]=a[x];
  ans[x]=lower_bound(dp,dp+n,MAX)-dp;
  rep(i,v[x].size()) {
    ll y=v[x][i];
    if(y==p) continue;
    dfs(y,x);
  }
  dp[k]=d;
}
void Main() {
  R n;
  rep(i,n) R a[i];
  rep(i,n-1) {
    int x,y;
    cin >> x >> y;
    x--,y--;
    v[x].pb(y);
    v[y].pb(x);
  }
  fill(dp,dp+n,MAX);
  dfs(0,-1);
  rep(i,n) pr(ans[i]);
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


Measured memory_bytes: 34136
#include<bits/stdc++.h>
using namespace std;
//Optimisations
#pragma GCC target ("avx2")
#pragma GCC optimization ("unroll-loops")
#pragma GCC optimize("O2")
//shortcuts for functions
#define pb push_back
#define mp make_pair
#define ff first 
#define ss second
#define all(v) v.begin(),v.end()
#define prec(n) fixed<<setprecision(n)
#define n_l '\n'
// make it python 
#define gcd __gcd
#define append push_back
#define str to_string
// utility functions shortcuts
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define sswap(a,b) {a=a^b;b=a^b;a=a^b;}
#define swap(a,b) {auto temp=a; a=b; b=temp;}
#define init(dp) memset(dp,-1,sizeof(dp));
#define set0(dp) memset(dp,0,sizeof(dp));
#define bits(x) __builtin_popcount(x)
#define SORT(v) sort(all(v))
#define endl "\n"
#define forr(i,n) for(ll i=0;i<n;i++)
// declaration shortcuts
#define ll long long
// Constants
constexpr int dx[] = {-1, 0, 1, 0, 1, 1, -1, -1};
constexpr int dy[] = {0, -1, 0, 1, 1, -1, 1, -1};
constexpr ll INF = 1999999999999999997; 
constexpr int inf= INT_MAX;
constexpr int MAXSIZE = int(1e6)+5;
constexpr auto PI  = 3.14159265358979323846L;
constexpr auto oo  = numeric_limits<int>::max() / 2 - 2;
constexpr auto eps = 1e-6;
constexpr auto mod = 1000000007;
constexpr auto MOD = 1000000007;
constexpr auto MOD9 = 1000000009;
constexpr auto maxn = 100006;
//void IOfile(){
//freopen(file_name, reade_mode, stdin);
//freopen(file_name, write_mode, stdout);
//}
void fastio(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
}

ll dp[1002][1002];

char a[1002][1002];

int n,m;

ll solve(int i, int j){

	if(i==n-1 && j==m-1) return 1;

	ll &res = dp[i][j];

	if(res!=-1) return res;

	res = 0;

	if(i+1<n && a[i+1][j]!='#'){
		res+=solve(i+1,j);
		res%=mod;
	}
	if(j+1<m && a[i][j+1]!='#'){
		res+=solve(i,j+1);
		res%=mod;
	}
	res%=mod;
	return res;

}

int main(){
	fastio();
	cin>>n>>m;

	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
			cin>>a[i][j];
		}
	}
	for(int i=0;i<=1000;i++) for(int j=0;j<=1000;j++) dp[i][j]=-1;
	ll ans=0;
	if(a[0][1]!='#'){
		ans+=solve(0,1);
		ans%=mod;
	}
	if(a[1][0]!='#'){
		ans+=solve(1,0);
		ans%=mod;
	}
	cout<<ans;
}

Measured memory_bytes: 9216
import java.util.Scanner;


public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        while(true){
            int h = sc.nextInt();
            int w = sc.nextInt();
            StringBuffer sb1 = new StringBuffer();
            StringBuffer sb2 = new StringBuffer();
            if(h == 0 && w == 0){
                break;
            }
            for(int i =0;i<w;i++){
                sb1.append("#");
            }
            for(int i =0;i<w;i++){
                if(i == 0 || i == w-1){
                    sb2.append("#");
                }else{
                    sb2.append(".");
                }
            }
            for(int j=0;j<h;j++){
                if(j == 0 || j == h-1){
                    System.out.println(sb1.toString());
                }else{
                    System.out.println(sb2.toString());
                }
            }
            System.out.println();
        }
    }
}




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

#define rep(i, x, n) for (int i = x; i < n; i++)
typedef long long ll;

using namespace std;

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

	int n;
	cin >> n;

	int res = 0;
	int tmp = 1;
	while (n > 0) {
		int mod = n % 10;
		if (mod == 1)
			res += (9 * tmp);
		else if (mod == 9)
			res += (1 * tmp);
		else
			res += (mod * tmp);
		n /= 10;
		tmp *= 10;
	}

	cout << res << endl;
	return 0;
}


Measured memory_bytes: 256
//
//  main.cpp
//  biggner20200419
//
//  Created by zer0 on 2020/04/19.
//  Copyright © 2020 zer0. All rights reserved.
//

#include <iostream>

int main(int argc, const char * argv[]) {
    int MAX_N = 2*100000;
    int n;
    std::cin >> n;
    int a[MAX_N];
    int b[MAX_N];
    
    for(int i=1; i<=n; i++){
        a[i]=0;
        b[i]=0;
        std::cin >> a[i];
    }
    
    for(int i=1; i<=n; i++){
        int m=a[i];
        b[m]=b[m]+1;
    }
    
    for(int i=1; i<=n; i++){
         std::cout << b[i] << std::endl;
    }
    
    return 0;
}


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

int main(void){
  int n, ans = 0;
  long long w,h;
  
  cin >> n >> w >> h;
  for (int i=0; i<n; i++){
    long long a, b; cin >> a >> b;
    ans += a>=w&&b>=h;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3596
n=int(input())
s=[input() for i in range(n)]
a=[0,0,0,0,0]
for i in s:
  if i[0]=="M":
    a[0]+=1
  elif i[0]=="A":
    a[1]+=1
  elif i[0]=="R":
    a[2]+=1
  elif i[0]=="C":
    a[3]+=1
  elif i[0]=="H":
    a[4]+=1
cnt=0
for i in range(3):
  for j in range(i+1,4):
    for k in range(j+1,5):
      cnt+=a[i]*a[j]*a[k]
print(cnt)

Measured memory_bytes: 9776
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
using namespace std;
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
using namespace std;
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef long double ld;
const ll inf=1e9+7;
const ll mod=998244353;
ll gcd(ll a,ll b){
    ll k=max(a,b),s=min(a,b);
    if(k%s==0)return s;
    return gcd(s,k%s);
}
int main(){
    ll n,m;cin>>n>>m;
    vector<ll>a(n);
    vector<ll>z(0);
    rep(i,n){
        cin>>a[i];
        a[i]/=2;
    }
    rep(i,n){
        ll k=a[i];
        ll cnt=0;
        while(k%2==0){
            cnt++;
            k/=2;
        }
        z.pb(cnt);
    }
    ll lcm=1;
    rep(i,n){
        ll k=lcm;
        lcm=(k/gcd(a[i],k)*a[i]);
        if(lcm>m){
            m=0;
            break;
        }
    }
    sort(all(z));
    if(z[0]!=z[n-1])m=0;
    cout<<(m/lcm+1)/2<<endl;
}

Measured memory_bytes: 2168
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
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;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
const ll mod=1e9+7;
const int inf=1<<30;

ll dp[310][310];
ll dp2[310][310];

int main(){
  ll n,m,l; cin >> n >> m >> l;
  rep(i,n)rep(j,n) dp[i][j]=inf;
  rep(i,n) dp[i][i]=0;
  rep(i,n)rep(j,n) dp2[i][j]=inf;
  rep(i,n) dp2[i][i]=0;
  rep(i,m){
    ll a,b,c; cin >> a >> b >> c;
    a--; b--;
    dp[a][b]=c;
    dp[b][a]=c;
    if(c<=l){
      dp2[a][b]=1;
      dp2[b][a]=1;
    }
  }
  rep(k,n)rep(i,n)rep(j,n) chmin(dp[i][j],dp[i][k]+dp[k][j]);
  rep(i,n)rep(j,n) if(dp[i][j]<=l) dp2[i][j]=1;
  rep(k,n)rep(i,n)rep(j,n) chmin(dp2[i][j],dp2[i][k]+dp2[k][j]);
  ll q; cin >> q;
  vector<ll> ans(q);
  rep(i,q){
    ll s,t; cin >> s >> t;
    s--; t--;
    if(dp2[s][t]!=inf) ans[i]=dp2[s][t]-1;
    if(dp2[s][t]==inf) ans[i]=-1;
  }
  rep(i,q){
    cout << ans[i] << endl;
  }
}

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

using namespace std;

int main() {
    int n;
    cin >> n;
    vector <long long> v;
    for (int i = 1; i <= 9; i++) {
        v.push_back(i);
    }
    for (int i = 0; i < n; i++) {
        long long x = v[i];
        int m = v[i] % 10;
        for (int j = -1; j <= 1; j++) {
            if (m + j >= 0 && m + j <= 9) {
                long long y = x * 10 + m + j;
                v.push_back(y);
            }
        }
    }
    cout << v[n - 1];
}


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

#define REP(i ,n) for(int i=0 ;i < n; i++)
#define REPB(i ,n) for(int i=n; i >= 0; i--)
#define FOR(i ,m ,n) for(int i=m; i < n; i++)
#define FORB(i, m, n) for(int i=m; i>= n; i--)
#define ll long long
#define pb push_back
#define popb pop_back
#define debug(i) cout << i << endl
using namespace std;
int main(){
  int a, b, t;
  cin >> a >> b >> t;

  cout << ((t / a) * b) << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(vec) vec.begin(), vec.end()
#define eb emplace_back
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
constexpr ll INF = (1LL << 30) - 1LL;
constexpr ll LINF = (1LL << 60) - 1LL;
constexpr ll MOD = 1e9 + 7;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }
template <std::uint_fast64_t Modulus> class modint {
    using u64 = std::uint_fast64_t;

  public:
    u64 a;
    constexpr modint(const u64 x = 0) noexcept : a(x % Modulus) {}
    constexpr u64 &value() noexcept { return a; }
    constexpr const u64 &value() const noexcept { return a; }
    constexpr modint operator+(const modint rhs) const noexcept {
        return modint(*this) += rhs;
    }
    constexpr modint operator-(const modint rhs) const noexcept {
        return modint(*this) -= rhs;
    }
    constexpr modint operator*(const modint rhs) const noexcept {
        return modint(*this) *= rhs;
    }
    constexpr modint operator/(const modint rhs) const noexcept {
        return modint(*this) /= rhs;
    }
    constexpr modint operator^(const u64 rhs) const noexcept {
        return modint(*this) ^= rhs;
    }
    constexpr modint &operator+=(const modint rhs) noexcept {
        a += rhs.a;
        if (a >= Modulus) {
            a -= Modulus;
        }
        return *this;
    }
    constexpr modint &operator-=(const modint rhs) noexcept {
        if (a < rhs.a) {
            a += Modulus;
        }
        a -= rhs.a;
        return *this;
    }
    constexpr modint &operator*=(const modint rhs) noexcept {
        a = a * rhs.a % Modulus;
        return *this;
    }
    constexpr modint &operator/=(modint rhs) noexcept {
        u64 exp = Modulus - 2;
        while (exp) {
            if (exp % 2) {
                *this *= rhs;
            }
            rhs *= rhs;
            exp /= 2;
        }
        return *this;
    }
    constexpr modint &operator^=(u64 exp) {
        modint rhs = modint(*this);
        a = 1;
        while (exp) {
            if (exp % 2) {
                *this *= rhs;
            }
            rhs *= rhs;
            exp /= 2;
        }
        return *this;
    }
};
using mint = modint<MOD>;
vector<mint> f, fi;
void comb(int n) {
    f.resize(n + 1);
    fi.resize(n + 1);
    f[0] = 1;
    for (ll i = 1; i <= n; i++) {
        f[i] = f[i - 1] * mint(i);
    }
    fi[n] = mint(1) / f[n];
    for (ll i = n - 1; i >= 0; i--) {
        fi[i] = fi[i + 1] * mint(i + 1LL);
    }
}
mint ncr(ll n, ll r) {
    if (n < r) {
        return mint(0);
    }
    if (r == 0) {
        return mint(1);
    }
    return f[n] * fi[n - r] * fi[r];
}
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, k;
    cin >> n >> k;
    mint res = 0;
    comb(n + 10);
    for (ll i = 0; i <= min(n - 1, k); i++) {
        res += ncr(n, i) * ncr(n - 1, i);
    }
    cout << res.a << endl;
}
/*
「k人以下がちょうど一回移動した」として良い
bの満たすべき条件？
bi=0なる個数<=k
bi=0なる個数iを固定すればOK(0<=i<=min(n-1,k)) i=0:k>=2より、必ずOK
*nCi に加えて、i個をn-i-1個の仕切りで分けたい n-1CiでOK
*/

Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007

long long gcd(long long a,long long b) {
  if(b == 0) return a;
  else return gcd(b,a%b);
}
 
int main() {
  
  int N;
  string S;
  cin >> N >> S;

  long long ans = 0;
  vector<vector<int>> num(3,vector<int>(N));
  for(int i = 0;i < N;i++) {
    if(S[i] == 'R') num[0][i]++;
    if(S[i] == 'G') num[1][i]++;
    if(S[i] == 'B') num[2][i]++;
  }

  
  for(int i = 0;i < N-1;i++) {
    num[0][i+1] += num[0][i];
    num[1][i+1] += num[1][i];
    num[2][i+1] += num[2][i];
  }

  for(int i = 0;i < N;i++) {
    for(int j = i+1;j < N;j++) {
      if(S[i] == S[j]) continue;
      int k = j-i+j;
      if(k < N) {
        if(S[i] != S[k] && S[j] != S[k]) ans--;
      } 
      int n;
      if(S[j] == 'R' && S[i] == 'G') ans += num[2][N-1]-num[2][j];
      if(S[j] == 'R' && S[i] == 'B') ans += num[1][N-1]-num[1][j];
      if(S[j] == 'G' && S[i] == 'R') ans += num[2][N-1]-num[2][j];
      if(S[j] == 'G' && S[i] == 'B') ans += num[0][N-1]-num[0][j];
      if(S[j] == 'B' && S[i] == 'R') ans += num[1][N-1]-num[1][j];
      if(S[j] == 'B' && S[i] == 'G') ans += num[0][N-1]-num[0][j];

    }
  }

  cout << ans << endl;

}


Measured memory_bytes: 3704
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
int main()
{
	ll n,m;
	cin>>n>>m;
	int count=0;
	for(int i=0;i<n;i++){

		ll x,y;
		cin>>x>>y;
		ll add=x*x+y*y;
		if(sqrt(add)<=m)
			count++;
	}
	cout<<count<<endl;
	return 0;
}

Measured memory_bytes: 3676
#include <bits/stdc++.h>
using namespace std;;
#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 FORR(i, m, n) for(int i = m;i >= n;i--)
#define INF 1<<30
#define LINF 1LL<<62
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define pb push_back
const int MOD = 1000000007;
 
typedef long long ll;
typedef long double ld;
typedef vector<ll> vl;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll A,B,M;cin >> A >> B >> M;
  vector<ll> a(A), b(B);
  vector<PP> m(M);
  ll ma=LINF,mb=LINF;
  rep(i,A){
    cin >> a[i];
    ma  = min(a[i],ma);
  }
  rep(i,B){
    cin >> b[i];
    mb= min (mb,b[i]);
  }
  rep(i,M){
    ll x,y,c;cin >> x >> y >> c;
    x--;y--;
    m[i] = mp(x,mp(y,c));
  }
  ll ans = ma+mb;
  rep(i,M){
    ll x = m[i].first;
    ll y = m[i].second.first;
    ll c = m[i].second.second;
    ans = min(ans , a[x] + b[y] - c);
  }
  cout << ans << endl;
  
}

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

using namespace std;

void solve() {
  long a, b;
  cin >> a >> b;
  long ans = a + b;
  ans = max(ans, a-b);
  ans = max(ans, a*b);
  cout << ans << endl;
}

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string>
#include <cstring>
#include <algorithm>
#include <math.h>
#include <map>
#include <bitset>
#include <cmath>
#include <set>
#include <utility>

#define INF 1000000000000
#define MOD 1000000007 //10^9+7:合同式の法

using namespace std;
typedef long long ll;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)


int main(){
    int N,D;
    cin >> D >> N;

    if(D == 0){
        int k = 0;
        for(int i = 0;i < N;i++)
            k++;
        if(N == 100)
            cout << 101 << endl;
        else
            cout << k << endl;
    }else if(D == 1){
        int k = 0;
        for(int i = 0;i < N;i++)
            k+=100;
        if(N == 100)
            cout << 10100 << endl;
        else
            cout << k << endl;
    }else{
        ll k = 0;
        for(int i = 0;i < N;i++)
            k += 10000;
        if(N == 100)
            cout << 101 * 10000 << endl;
        else
            cout << k << endl;
    }

}

Measured memory_bytes: 3640
//#define NDEBUG

#include <bits/stdc++.h>
#include <bits/extc++.h>

#define StarBurstStream ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define iter(a) a.begin(), a.end()
#define riter(a) a.rbegin(), a.rend()
#define lsort(a) sort(iter(a))
#define gsort(a) sort(riter(a))
#define mp(a, b) make_pair(a, b)
#define pb(a) push_back(a)
#define eb(a) emplace_back(a)
#define pf(a) push_front(a)
#define pob pop_back()
#define pof pop_front()
#define F first
#define S second
#define printv(a, b) {bool pvaspace=false; \
for(auto pva : a){ \
    if(pvaspace) b << " "; pvaspace=true;\
    b << pva;\
}\
b << "\n";}
#define pii pair<int, int>
#define pll pair<ll, ll>
#define tiii tuple<int, int, int>
#define mt make_tuple
#define gt(t, i) get<i>(t)
#define iceil(a, b) ((a) / (b) + !!((a) % (b)))

//#define TEST

typedef long long ll;
typedef unsigned long long ull;

using namespace std;
using namespace __gnu_pbds;

const ll MOD = 1000000007;
const ll MAX = 2147483647;

template<typename A, typename B>
ostream &operator<<(ostream &o, pair<A, B> p){
    return o << '(' << p.F << ',' << p.S << ')';
}

int main(){
    StarBurstStream

    vector<ll> two(200001);
    two[0] = 1;
    for(int i = 1; i <= 200000; i++) two[i] = two[i - 1] * 2 % MOD;
//    printv(two, cerr);

    int n;
    cin >> n;

    map<pll, pll> cnt;
    ll z = 0;
    for(int i = 0; i < n; i++){
        ll a, b;
        cin >> a >> b;
        if(a == 0 && b == 0){
            z++;
            continue;
        }
        if(a == 0){
            cnt[mp(0, 1)].F++;
            continue;
        }
        if(b == 0){
            cnt[mp(0, 1)].S++;
            continue;
        }

        ll g = __gcd(a, b);
        a /= g; b /= g;

        if((a ^ b) < 0){
            pll t = mp(abs(b), abs(a));
            cnt[t].S++;
        }
        else{
            pll t = mp(abs(a), abs(b));
            cnt[t].F++;
        }
    }

    ll ans = 1;
    for(auto it : cnt){
//        cerr << it << "\n";
        ans = ans * (two[it.S.F] + two[it.S.S] - 1) % MOD;
    }

    cout << ((ans - 1 + z) % MOD + MOD) % MOD << "\n";

    return 0;
}

Measured memory_bytes: 20176
s = int(input())
a = []
ans = 0
a.append(s)
while (1):
    if s % 2 == 0:
        s = s / 2
    else :
        s = 3*s + 1
    sea = (s in a)
    if sea:
        print(len(a)+1)
        break
    a.append(s)



Measured memory_bytes: 2940
(r, c) = [int(i) for i in input().split()]
last_row = [0 for _ in range(c+1)]
 
for _ in range(r):
    row = [int(i) for i in input().split()]
    for cc in range(c):
        last_row[cc] += int(row[cc])
        print(row[cc], end=' ')
 
    print(sum(row))
 
last_row[-1] = sum(last_row)
print(' '.join([str(a) for a in last_row]))

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

#define MOD 1000000007ll
#define all(v) v.begin() , v.end()
#define allr(v) v.rbegin(), v.rend()
#define for0(i,n) for(__typeof(n) i = 0; i < n ; i++)  
#define forc(c,it) for(__typeof(c.begin()) it = c.begin(); it != c.end(); it++)
#define pb     push_back
#define mp     make_pair
#define MAX 100005
template<typename T, template<typename ELEM, typename ALLOC=std::allocator<ELEM> > class Container>
std::ostream& operator<< (std::ostream& o, const Container<T>& container)
{ typename Container<T>::const_iterator beg = container.begin();
  /*o << "[";*/ while(beg != container.end()) o << " " << *beg++; /*o << " ]";*/ return o; }

string s1 , s2 , s3;

int main(int argc, char const *argv[])
{
  ios_base::sync_with_stdio(false);
  
cin>>s1>>s2>>s3;
cout << (char)('A' + s1[0] - 'a') << (char)('A' + s2[0] - 'a')  << (char)('A' + s3[0] - 'a');

  return 0;
}  

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
    int h,w;
    char a[100][101];
    scanf("%d %d",&h,&w);
    for(int i=0;i<h;i++) scanf("%s",&a[i]);

    bool x[100]={};
    bool y[100]={};
    for(int i=0;i<h;i++)
    {
        bool tmp=false;
        for(int j=0;j<w;j++)
        {
            if(a[i][j]=='#')
            {
                tmp=true;
                break;
            }
        }
        if(tmp) x[i]=true;
    }
    for(int i=0;i<w;i++)
    {
        bool tmp=false;
        for(int j=0;j<h;j++)
        {
            if(a[j][i]=='#')
            {
                tmp=true;
                break;
            }
        }
        if(tmp) y[i]=true;
    }

    for(int i=0;i<h;i++)
    {
        bool judge=false;
        for(int j=0;j<w;j++)
        {
            if(x[i]&&y[j]) 
            {
                printf("%c",a[i][j]);
                judge=true;
            }
        }
        if(judge)printf("\n");
    }
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define iton for(int i=0;i<=n;i++)
#define itok for(int i=0;i<k;i++)
#define jton for(int j=0;j<=n;j++)
void dfs(vector<ll> input[], int dp[], bool visited[], int val)
{
    visited[val] = true;
    for(int i=0;i<input[val].size();i++)
    {
        if(!visited[input[val][i]])
        dfs(input,dp,visited,input[val][i]);

        dp[val] = max(1+dp[input[val][i]] , dp[val]);
    }
}
int  main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    long n,k,x,y;
    cin>>n>>k;
    vector<ll> input[n+1];
    itok
    {
        cin>>x>>y;
        input[x].push_back(y);
    }
    
    int dp[n+1];
    memset(dp, 0 , sizeof dp);

    bool visited[n+1];
    memset(visited,false, sizeof visited);
    
    for(int i=1;i<=n;i++)
    {
        if(!visited[i])
        dfs(input,dp,visited,i);
    }
    int ans=0;
    for (int i = 1; i <= n; i++) { 
        ans = max(ans, dp[i]); 
    } 
    cout<< ans; 
}


Measured memory_bytes: 9600