akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
#define INF 1e8
typedef long long int ll;
const double PI = acos(-1);

using Graph = vector<vector<int>>;
int main()
{
  int n, m;
  cin >> n >> m;
  int ans = 0;
  vector<int> a;
  rep(i, n) a.push_back(2);
  rep(i, m) a.push_back(3);
  for (int i = 0; i < n + m; i++)
  {
    for (int j = i + 1; j < n + m; j++)
    {
      if ((a[i] + a[j]) % 2 == 0)
        ans++;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3596
import java.io.*;
import java.util.*;
class Main{
	static final long MOD = 1_000_000_007; // 10^9+7
    static final int MAX = 2_147_483_646; // intMax 
    static final int INF = 1_000_000_000; // 10^9  
    public static void main(String[] args) throws Exception {
		hayami saori = new hayami();
		int n = saori.saori_hayami();
		int a = saori.saori_hayami();
		int b = saori.saori_hayami();
		if(n*a >= b){
			System.out.println(b);
		} else {
			System.out.println(n*a);
		}
		
		saori.close();
    }
}

class hayami implements Closeable {
	private final InputStream in = System.in;
	private final byte[] hayami = new byte[1024];
	private int Hayami = 0;
	private int saori = 0;
	private boolean HayamiSaori() {
		if (Hayami < saori) {
			return true;
		}else{
			Hayami = 0;
			try {
				saori = in.read(hayami);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (saori <= 0) {
				return false;
			}
		}
		return true;
	}
	private int SaoriHayami() { 
		if (HayamiSaori()) {
            return hayami[Hayami++];
         }else{
             return -1;
         }
	}
	private static boolean hayami_saori(int hayami) { 
		return 33 <= hayami && hayami <= 126;
	}
	public boolean hayamisaori() { 
		while(HayamiSaori() && !hayami_saori(hayami[Hayami])) Hayami++; return HayamiSaori();
	}
	public String nextHayami() {
		if (!hayamisaori()) throw new NoSuchElementException();
		StringBuilder hayamin = new StringBuilder();
		int saori = SaoriHayami();
		while(hayami_saori(saori)) {
			hayamin.appendCodePoint(saori);
			saori = SaoriHayami();
		}
		return hayamin.toString();
	}
	public long saorihayami() {//nextLong
		if (!hayamisaori()) throw new NoSuchElementException();
		long hayami = 0;
		boolean misao = false;
		int saori = SaoriHayami();
		if (saori == '-') {
			misao = true;
			saori = SaoriHayami();
		}
		if (saori < '0' || '9' < saori) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= saori && saori <= '9') {
				hayami *= 10;
				hayami += saori - '0';
			}else if(saori == -1 || !hayami_saori(saori)){
				return misao ? -hayami : hayami;
			}else{
				throw new NumberFormatException();
			}
			saori = SaoriHayami();
		}
	}
	public int saori_hayami() {//nextInt
		long hayami = saorihayami();
		if (hayami < Integer.MIN_VALUE || hayami > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) hayami;
	}
	public double Hayamin() { //nextDouble
		return Double.parseDouble(nextHayami());
	}
	public void close() {
		try {
			in.close();
		} catch (IOException e) {
		}
    }
    
}

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

int main() {
  int n;
  cin>>n;
  string a,b;
  cin>>a>>b;
  string c="";
  for(int i=0;i<n;i++){
    c+=a.at(i);
    c+=b.at(i);
  }
  cout<<c<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
int main(){
	int box[100001] = {},n,a;
	cin >> n;
	for(int i=0;i<n;i++){
		cin >> a;
		box[a]++;
		box[a+1]++;
		if(a)
			box[a-1]++;
	}
	cout << *max_element(&box[0],&box[100001]) << endl;
}

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

int main(int argc, char const *argv[])
{
  int x = 0;
  int max = 0;
  int n;
  string s;
  cin >> n >> s;

  for(int i = 0; i < n; i++)
  {
    if(s[i] == 'I')
    {
      x++;
      if(x > max)
        max = x;
    }
    else
      x--;
  }
  cout << max << endl;
  return 0;
}


Measured memory_bytes: 256
A, B, M = list(map(int, input().split()))

a = list(map(int, input().split()))
b = list(map(int, input().split()))

ans = min(a)+min(b)
for i in range(M):
    tmpx, tmpy, tmpc = list(map(int, input().split()))
    val = a[tmpx-1]+b[tmpy-1]-tmpc
    if ans > val:
        ans = val

print(ans)

Measured memory_bytes: 18736
#include<bits/stdc++.h>
#define pb push_back
#define ll long long
#define rep(i,l,r)  for(int i=l;i<=r;i++)
#define pre(i,r,l)  for(int i=r;i>=l;i--)
#define pii pair<int,int>
using namespace std;
const int inf = 0x3f3f3f3f;
const int mod = 1000000007;
const int maxn = 1000005;
inline int read(){
    int x=0,f=1;char c=getchar();
    for(;!isdigit(c);c=getchar()) if(c=='-') f=-1;
    for(;isdigit(c);c=getchar()) x=x*10+c-'0';
    return x*f;
}

int k[maxn];

int main() {
   string s; cin >> s;
   int now = 0, p = 1;
   ll ans = 0;
   k[0] = 1;
   pre(i, s.size()-1, 0) {
     now = (now + (s[i]-'0')*p)%2019;
     ans += k[now]++;
     p = p*10%2019;
   }
   cout << ans << endl;
}


Measured memory_bytes: 3684
#define _GLIBCXX_DEBUG
#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <queue>
#include <bitset>
#include <stack>
#include <set>

typedef long long ll;
typedef std::vector< int > VI;

const double EPS = 1e-10;
const double PI  = acos(-1);
const ll     INF = 1 << 30;

ll gdb_exec(ll a, ll b) {
  if (b == 0) return a;
  return gdb_exec(b, a % b);
}

ll gdb(ll a, ll b) {
  if (a < b) std::swap(a, b);
  if (a == 0 || b == 0) return -999999999;
  ll ans = gdb_exec(a, b);
  return ans;
}

ll lcm(ll a, ll b) {
  ll gdb_val = gdb(a, b);
  if (a % gdb_val == 0) {
    return (a / gdb_val) * b;
  }
  return (b / gdb_val) * a;
}

int main(int argc, char* argv[])
{
  ll n;
  std::cin >> n;

  std::vector< ll > vt(n, 0);
  std::vector< ll >::iterator it;

  for (ll i = 0; i < n; i++) {
    std::cin >> vt[i];
  }

  ll ans = 1;
  for (it = vt.begin(); it != vt.end(); it++) {
    ans = lcm(*it, ans);
  }

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


Measured memory_bytes: 256
parse :: String -> (Int , Int , Int)
parse xs = case break (== ',') xs of
    (y,ys) -> case break (== ',') (tail ys) of
        (z,zs) -> (read y , read z , read $ tail zs)

count :: (a -> Bool) -> [a] -> Integer
count f = foldr (\ x -> if f x then succ else id) 0

isRectangle :: (Int , Int , Int) -> Bool
isRectangle (x,y,z) = x ^ 2 + y ^ 2 == z ^ 2

isRhombus :: (Int , Int , Int) -> Bool
isRhombus (x,y,_) = x == y

solve :: [(Int , Int , Int)] -> IO ()
solve xs = print (count isRectangle xs) >> print (count isRhombus xs)

main :: IO ()
main = getContents
    >>= solve . map parse . lines

Measured memory_bytes: 3788
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = (int)(a); i <= (int)(n); ++i)
#define rrep(i, a, n) for (int i = (int)(a); i >= (int)(n); --i)
#define debug(x) cerr << #x << " = " << x << "\n"
#define debugv(x) \
  rep(f, 0, (x.size() - 1)) cerr << x[f] << (f == (x.size() - 1) ? "\n" : " ")
#define debug2(x, y)                       \
  cerr << "(" << #x << "," << #y << ") = " \
       << "(" << x << "," << y << ")\n"
#define all(x) x.begin(), x.end()
#define each(a, x) for (auto& a : (x))
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define int long long
#define yn(x) puts((x ? "Yes" : "No"))
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
const int MX = 1e5 + 5, INF = 5LL << 57, MOD = 1e9 + 7;

int N, M;
vi H;
vi A,B;
priority_queue<int> br[MX];

void input() {
  ;
  cin>>N>>M;
  H.resize(N);
  rep(i,0,N-1){
    cin>>H[i];
  }
  A.resize(M);
  B.resize(M);
  rep(i,0,N-1){
    br[i].push(0);
  }
  rep(i,0,M-1){
    cin>>A[i]>>B[i];
    A[i]--;B[i]--;
    br[A[i]].push(H[B[i]]);
    br[B[i]].push(H[A[i]]);
  }
}

void solve() {
  int ans = 0;
  rep(i,0,N-1){
    if ( br[i].top() < H[i]){
      ans++;
    }
  }
  cout<<ans<<endl;
}
signed main() {
  cout << setprecision(12);
  input();
  solve();
  return 0;
}

Measured memory_bytes: 14060
#include <iostream>
#define REP(i, a, n) for(int i = (a); i < (n); i++)
using namespace std;

int N, M, S1[100], S2[100];

int main(void) {
  while(cin >> N >> M, N && M) {
    int sum1 = 0, sum2 = 0;
    REP(i, 0, N) cin >> S1[i], sum1 += S1[i];
    REP(i, 0, M) cin >> S2[i], sum2 += S2[i];

    int p1 = 100000000, p2 = 100000000;
    REP(i, 0, N) REP(j, 0, M) {
      if(sum1 - S1[i] + S2[j] == sum2 + S1[i] - S2[j]) {
        if(p1 + p2 > S1[i] + S2[j]) {
          p1 = S1[i];
          p2 = S2[j];
        }
      }
    }

    if(p1 + p2 >= 100000000) {
      cout << -1 << endl;
    } else {
      cout << p1 << " " << p2 << endl;
    }
  }

  return 0;
}

Measured memory_bytes: 2960
#include <bits/stdc++.h>
#define lli long long int
#define endl '\n'
#define deb(x) cout << #x << " = " << x << endl
#define deb2(x, y) cout << #x << " = " << x << ", " << #y << " = " << y << endl
#define deb3(x, y, z) cout << #x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " << z << endl
#define fastio 	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;

int main()
{
	fastio;

    int n;
    cin >> n;

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

    lli ans = 0;
    lli x = a[0];

    for (int i = 1; i < n; i++) {
        x = max(x, a[i]);
        ans += x - a[i];
        // deb2(x, x - a[i]);
    }

    cout << ans << endl;

	return 0;
}




Measured memory_bytes: 4740
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n,l,r;
  while(cin>>n>>l>>r&&n) {
    int a[n];
    for(int i=0;i<n;i++)cin>>a[i];
    sort(a,a+n,greater<int>());
    int x,M=0;
    for(int i=l-1;i<r;i++) {
      if(M<=a[i]-a[i+1]) {
        M=a[i]-a[i+1];
        x=i+1;
      }
    }
    cout << x << endl;
  }
  return 0;
}


Measured memory_bytes: 3144
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// スペース区切りの整数の入力
		int b = sc.nextInt();
		int c = sc.nextInt();
      if(b<c){
        for(int i=0;i<c;i++){
		System.out.print(""+b);
      }
        System.out.println("");
      }else{
        for(int i=0;i<b;i++){
		System.out.print(""+c);
      }
        System.out.println("");
      }
	}
}

Measured memory_bytes: 22740
#include <bits/stdc++.h>
#define BIT(n) (1LL << (n))
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPB(i, n) for (int i = 0; i < BIT(n); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); 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 FORA(i, n) for (auto &&i : n)
#define FORS(i, m, n) for (int i = m; i <= n; i++)
#define DEBUG(x) cerr << #x << ": " << x << "\n"
#define PRINTALL(V)                                                            \
  for (auto v : (V)) {                                                         \
    cerr << v << " ";                                                          \
  }                                                                            \
  cerr << "\n";
#define ALL(v) v.begin(), v.end()
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
#define epb emplace_back
#define int long long
using namespace std;
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 (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template < class T > using vec = std::vector< T >;
template < class T > void print(const T &x) { cout << x << "\n"; }
const int MOD = 1000000007, INF = 1061109567, INF2 = INF * INF;
const double EPS = 1e-10, PI = acos(-1.0);
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const int CALCSIZE = 51;
int C[CALCSIZE][CALCSIZE];
signed main() {
  for (int i = 0; i < CALCSIZE; ++i) {
    C[i][i] = C[i][0] = 1;
    for (int j = 1; j < i; ++j) {
      C[i][j] = (C[i - 1][j - 1] + C[i - 1][j]);
    }
  }

  cin.tie(0), ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  int N, A, B;
  cin >> N >> A >> B;
  map< int, int > a;
  REP(i, N) {
    int p;
    cin >> p;
    a[-p]++;
  }

  int count = A;
  int sum = 0;
  int comb = 0;
  bool flg = true;
  FORA(e, a) {
    if (count - e.second <= 0) {
      sum += e.first * count;
      if (!flg) {
        comb = C[e.second][count];

      } else {
        FORS(i, count, min(e.second, B)) { comb += C[e.second][i]; }
      }
      break;
    }
    flg = false;
    count -= e.second;
    sum += e.first * e.second;
  }
  print(-sum * 1.0 / A);
  print(comb);
}
//勝手に1e9+7にしない。

Measured memory_bytes: 256
#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 ll = long long;
using P = pair<int, int>;

int main(){
    int n, m;
    cin >> n >> m;
    vector<string> a(n), b(m);
    rep(i, n) cin >> a[i];
    rep(i, m) cin >> b[i];
    int c = 0;
    rep(i, n-m+1) {
        rep(j, n-m+1) {
            rep(k, m)rep(l, m) {
                if (a[j+l][i+k]==b[l][k]) {
                    c++;
                } else {
                    c = 0;
                    break;
                }
                
                if (c == m*m) {
                    puts("Yes");
                    return 0;
                }
            }
        }
    }
    puts("No");
    return 0;
}

Measured memory_bytes: 256
N=int(input())
F=[list(map(int,input().split()))for _ in range(N)]
P=[list(map(int,input().split()))for _ in range(N)]

ans=-10**9
for i in range(2**10-1):
    Bit=[1]*10
    for j in range(10):
        if (i>>j)&1:
            Bit[j]=0
    count=0
    for k in range(N):
        op=sum(b&f for b,f in zip(Bit,F[k]))
        count+=P[k][op]
    ans=max(ans,count)
print(ans)

Measured memory_bytes: 9092
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
using Graph = vector<vector<int>>;
const int INT_INF = 1001001001;
//stoi(s) : string→int stoll(s) :string→longlong  int→string to_string(i)
const double PI = acos(-1.0);
//小数点の表し方 cout << fixed << setprecision(5);
const ll MOD = 1e9 + 7;
const int MAX = 1e5 *2;
vector<long long> fact_inv, inv;
 
/*  init_nCk :二項係数のための前処理
    計算量:O(k)
*/
void init_nCk(int SIZE) {
    fact_inv.resize(SIZE + 5);
    inv.resize(SIZE + 5);
    fact_inv[0] = fact_inv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < SIZE + 5; i++) {
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        fact_inv[i] = fact_inv[i - 1] * inv[i] % MOD;
    }
}
 
/*  nCk :MODでの二項係数を求める(前処理 int_nCk が必要)
    計算量:O(k)
*/
long long nCk(ll n, ll k) {
    assert(!(n < k));
    assert(!(n < 0 || k < 0));
    long long ans = 1;
    for (int i = n; i >= n - k + 1; i--) {
        ans *= i;
        ans %= MOD;
    }
    return ans * fact_inv[k] % MOD;
}

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

int main(){
    ll n,a,b;
    cin >> n >> a >> b;
    ll temp = modpow(2,n,MOD);
    temp--;
    //cout << temp << endl;
    init_nCk(max(a,b));
    temp = temp - nCk(n,a) + MOD;
    //cout << temp << endl;
    temp = temp - nCk(n,b) + MOD;
    //cout << temp << endl;
    //cout << COM(n,a) << endl;
    temp = temp%MOD;
    cout << temp << endl;
}

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

#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
using namespace std;


int main() {
    int N, M;
    cin >> N >> M;
    vector<int>Hs(N);
    for (int i=0; i<N; i++)cin >> Hs[i];

    vector<vector<int>>graph(N);
    map<pair<int,int>,bool>mp;
    for (int i=0; i<M; i++){
        int ai, bi;
        cin >> ai >> bi;
        ai--;
        bi--;
        // ai >= biとなるようにする
        // 二重辺をなくす
        if (bi > ai)swap(ai,bi);
        pair<int,int>p;
        p.first = ai;
        p.second = bi;
        if (mp[p] == false){
            graph[ai].push_back(bi);
            graph[bi].push_back(ai);
        }
        mp[p] = true;
    }
    int cnt = 0;
    for (int i=0; i<N; i++){
        vector<int>vec = graph[i];
        int size = vec.size();
        int height = Hs[i];

        if (size == 0)cnt++;
        else {
            bool is_good = true;
            for (int j=0; j<size; j++){
                if (Hs[vec[j]] >= height)is_good = false;
            }
            if (is_good)cnt++;
        }
    }
    cout << cnt << endl;

}

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

#define ll long long
#define pp pair<int, int>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPU(i, a, b, s) for(int i = a; i < b; i += s)
#define REPD(i, a, b, s) for(int i = a; i > b; i -= s)
#define endl "\n"

ll INF = 2e18;
ll MOD = 1e9 + 7;
int i, j, k, t;

int main() {
    double T, X;
    cin >> T >> X;
    printf("%.15lf\n", T / X);
}

Measured memory_bytes: 3764
using System;
using System.Linq;
using System.Collections.Generic;

namespace atcoder.abc166.c
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] paramArray = getIntParams();
            int N = paramArray[0];
            int M = paramArray[1];

            int[] H = getIntParams();

            List<int>[] route = new List<int>[N + 1];
            for (int c = 0; c <= N; c++)
            {
                route[c] = new List<int>();
            }

            for (int i = 1; i <= M; i++)
            {
                int[] data = getIntParams();
                int A = data[0];
                int B = data[1];

                if (!route[A].Contains(B))
                {
                    route[A].Add(B);
                }
                if (!route[B].Contains(A))
                {
                    route[B].Add(A);
                }
            }

            int ret = 0;
            for (int x = 1; x <= N; x++)
            {
                if (route[x].Count == 0)
                {
                    ret++;
                }
                else
                {
                    int err = 0;
                    for (int y = 0; y < route[x].Count; y++)
                    {
                        if (H[x - 1] <= H[route[x][y] - 1])
                        {
                            err++;
                            break;
                        }
                    }
                    if (err == 0)
                    {
                        ret++;
                    }
                }
            }
            Console.WriteLine(ret);
        }
        static int getIntParam()
        {
            return int.Parse(Console.ReadLine());
        }
        static int[] getIntParams()
        {
            return Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
        }
        static long getLongParam()
        {
            return long.Parse(Console.ReadLine());
        }
        static long[] getLongParams()
        {
            return Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();
        }
        static string getStringParam()
        {
            return Console.ReadLine();
        }
        static string[] getStringParams()
        {
            return Console.ReadLine().Split(' ');
        }
        static decimal getDecimalParam()
        {
            return decimal.Parse(Console.ReadLine());
        }
        static decimal[] getDecimalParams()
        {
            return Console.ReadLine().Split(' ').Select(i => decimal.Parse(i)).ToArray();
        }
    }
}


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

vector<int> adjl1[200005];
vector<int> adjl2[200005];
int dist2[200005];
int p[200005];

void dfs2(int node, int parent){
    for (auto x : adjl2[node]){
        if (x==parent) continue;
        dist2[x]=dist2[node]+1;
        p[x] = node;
        dfs2(x,node);
    }
}

int dfs(int node, int parent,int d){
    int ans = dist2[node]*2;
    for (auto x : adjl1[node]){
        if (x==parent) continue;
        if (p[x]==node||p[node]==x||p[x]==p[node]||p[p[x]]==node||p[p[node]]==x){
            if (d+1<dist2[x]){
                int t = dfs(x,node,d+1);
                if (t==-1) return -1;
                ans = max(ans,t);
            }
        }
        else return -1;

    }
    return ans;
}

int n,X,Y;
int main(){
    scanf("%d%d%d",&n,&X,&Y);
    for (int x = 0; x<n-1; x++){
        int a,b;
        scanf("%d%d",&a,&b);
        adjl1[a].push_back(b);
        adjl1[b].push_back(a);
    }
    for (int x = 0; x<n-1; x++){
        int a,b;
        scanf("%d%d",&a,&b);
        adjl2[a].push_back(b);
        adjl2[b].push_back(a);
    }
    dist2[Y] = 0;
    dfs2(Y,-1);
    p[Y]=-1;
    printf("%d",dfs(X,-1,0));

}


Measured memory_bytes: 33536
import sys
input = sys.stdin.readline

def func(D, C):
    A, B = D, D
    rests = []
    num = 0
    while True:
        if C%2:
            rests.append(A)
            C -= 1
        if C == 0:
            break
        num += C//2
        X = A+B
        if X >= 10:
            A, B = X//10, X%10
        else:
            A, B = X, X
            C //= 2

    rests = rests[::-1]
    ret, E = func_naive(rests)
    return num+ret, E

def func_naive(Xs):
    num = 0
    while True:
        if len(Xs) == 1:
            break
        B = Xs.pop()
        A = Xs.pop()
        X = A+B
        if X >= 10:
            Xs.append(X//10)
            Xs.append(X%10)
        else:
            Xs.append(X)
        num += 1
    return num, Xs[0]

M = int(input())
dcs = [tuple(map(int, input().split())) for _ in range(M)]

ans = 0
Es = []
for d, c in dcs:
    num, E = func(d, c)
    ans += num
    Es.append(E)

num, E = func_naive(Es)
ans += num

print(ans)


Measured memory_bytes: 91612
#include <bits/stdc++.h>
#define rep(i, n) for(long long int i = 0; i < n; i++)
#define _rep(i, m, n) for(long long int i = m; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
//const int N = 1000000;
const ll mod = 1000000007;
using Graph = vector<vector<int>>;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
  
ll gcd(ll A, ll B){
    if(B == 0)return A;
    return gcd(B, A % B);
}
ll lcm(ll A, ll B){
    return A * (B / gcd(A, B));
}
  
/*------------------------------------------------------------------*/
int main(){
    ll n; cin >> n;
    vector<ll> x(n);
    vector<ll> y(n);
    rep(i, n){
        cin >> x[i];
        y[i] = x[i];
    }
    sort(y.begin(), y.end());
    rep(i, n){
        if(x[i] < y[n / 2])cout << y[n / 2] << endl;
        else cout << y[n / 2 - 1] << endl;
    }
}

Measured memory_bytes: 5376
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n, m, i, j, a[5],k;
    for(i=0; i<5; i++)
    {
        cin>>a[i];
    }
    cin>>k;
    bool x=0;
    for(i=0; i<4; i++)
    {
        for(j=i+1; j<5; j++)
        {
            if((a[j]-a[i])>k)
            {
                x=1;
                break;
            }
        }
    }
    if(x==1)
    {
        cout<<":("<<endl;
    }
    else
        cout<<"Yay!"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define err(args...) {}
#ifdef DEBUG
#include "_debug.cpp"
#endif
using namespace std;
using ll = long long;
using ld = long double;
template <typename T> using lim = numeric_limits<T>;
template <typename T> istream& operator>>(istream& is, vector<T>& a) { for(T& x : a) { is >> x; } return is; }
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    set<int> s;
    for(int i = 0; i < n; i++) {
        int ai;
        cin >> ai;
        s.insert(ai);
    }
    cout << s.size() - (s.size() % 2 == 0) << endl;
    return 0;
}


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

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
#include <string>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cmath>
#include <climits>
#include <bitset>
#include <array>
#include <deque>
#include <queue>
#include <map>
#define all(x) (x).begin(),(x).end()

void solve(){

}
int main(){
    int A,B,C,X,Y;
    cin >> A >> B >> C >> X >> Y;
    //AとBのみ
    ll sum1 = A*X+B*Y;
    //ABのみ
    ll sum2 = 2*C*max(X,Y);
    //ABの最大数とA,B
    ll sum3 = 0;
    sum3 += 2*C*min(X,Y);
    ll af_X = X - min(X,Y);
    ll af_Y = Y - min(X,Y);
    sum3 += af_X * A + af_Y * B;

    cout << min(sum1,min(sum2,sum3)) << endl;




    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, P> P3;
typedef pair<P ,P> PP;
constexpr ll MOD = ll(1e9) + 7;
constexpr int IINF = INT_MAX;
constexpr ll LLINF = LLONG_MAX;
constexpr int MAX_N = int(1e5) + 5;
constexpr double EPS = 1e-9;
constexpr int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i > 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define SORTR(v) sort((v).rbegin(), (v).rend())
#define ALL(v) (v).begin(), (v).end()

int main() {
    int n,x,l[105],ans=1,p=0;
    cin >> n >> x;
    REP(i,n) cin >> l[i];
    REP(i,n){
        p+=l[i];
        if(p<=x)ans++;
    }
    cout << ans << endl;
    return 0;
}


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

typedef uint64_t u64;
typedef int64_t i64;
typedef uint32_t u32;
typedef int32_t i32;
typedef uint16_t u16;
typedef int16_t i16;
typedef uint8_t u8;
typedef int8_t i8;

using namespace std;

#define REP(idx, N) for (u64 idx = 0; idx < N; idx++)

int main() {
  u64 N = 0, a;
  map<u64, u64> Amap;
  vector<pair<u64, u64>> A;

  cin >> N;

  REP(i, N) {
    cin >> a;
    Amap[a] = Amap[a] + 1;
  }

  for (auto &a : Amap) {
    A.push_back(pair<u64, u64>(a.first, a.second));
  }

  bool dp[A.back().first + 1];

  for (auto &d : dp) {
    d = true;
  }

  for (auto &a : A) {
    for (int i = 2; i * a.first <= A.back().first; i++) {
      auto m = i * a.first;
      dp[m] = false;
    }
  }

  u64 ans = 0;
  for (auto &a : A) {
    if (dp[a.first] && a.second == 1) {
      ans++;
    }
  }

  cout << ans;
  return 0;
}


Measured memory_bytes: 19760
#include<stdio.h>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<cmath>
#include<iostream>
#include<queue>
#include<string>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<long long,long long> pll;
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define rep(i,j,k)  for(register int i=(int)(j);i<=(int)(k);i++)
#define rrep(i,j,k) for(register int i=(int)(j);i>=(int)(k);i--)

ll read(){
	ll x=0,f=1;char c=getchar();
	while(c<'0' || c>'9'){if(c=='-')f=-1;c=getchar();}
	while(c>='0' && c<='9'){x=x*10+c-'0';c=getchar();}
	return x*f;
}

int n;
int a[100100];
int b[100100];
int ans;

int main(){
	n=read();
	rep(i,1,n){
		a[i]=read();
		if(a[i]<=n) b[a[i]]++;
		else ans++;
	}
	rep(i,1,n){
		if(b[i]>=i) ans+=b[i]-i;
		else ans+=b[i];
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring> 
#include<queue>
#include<stack> 
#include<string.h>
#include<set>
#define ll long long
using namespace std;
int main()
{
	int n,m;
	scanf("%d%d",&n,&m);
	char a[100],b[100],c[100];
	scanf("%s%s%s",a,b,c);
	int la=strlen(a);
	int lb=strlen(b);
	int lc=strlen(c);
	if(a[la-1]==b[0]&&b[lb-1]==c[0])
	{
		printf("YES\n");
	}
	else
	printf("NO\n");
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<map>
#include<stack>
#include<queue>
#include<set>
using namespace std;
typedef long long ll;
const ll mod = 1e9+7;
int main(){
	ll m,n;
	cin>>m>>n;
	if(m==1||n==1){
		cout<<"1";
		return 0;
	}
	ll t;
	if(n%2==0){
		t=n/2;
		cout<<m*t;
	}
	else{
		t=n/2+1;
		cout<<(m/2*t)+(m/2*(t-1))+(m%2*t);
	}
	
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define ArraySizeOf(array)     (sizeof(array) / sizeof(array[0]))
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define int long long
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define _GLIBCXX_DEBUG
unsigned NthDayOfWeekToDay(unsigned n, unsigned dow, unsigned dow1)
{
unsigned day;
if(dow < dow1) dow += 7;
day = dow - dow1;
day += 7 * n - 6;
return day;
}
unsigned DayToWeekNumber(unsigned day)
{
  return (day - 1) / 7 + 1;
}
unsigned AnotherDayOfWeek(unsigned day, unsigned day0, unsigned dow0)
{
  return (dow0 + 35 + day - day0) % 7;
}
using namespace std;
signed main(){
  int N,K,S;
  cin>>N>>K>>S;
  for(int i=0;i<K;i++)cout<<S<<" ";
  for(int i=K;i<N-1;i++)cout<<(S==1000000000? 1:S+1)<<" ";
  if(K!=N)cout<<(S==1000000000? 1:S+1)<<endl;
}

Measured memory_bytes: 3628
// tsukasa_diary's programing contest code template
#include <bits/stdc++.h>
using namespace std;
#define TSUKASA_DIARY_S_TEMPLATE
// define
#define for_(i,a,b) for(int i=(a);i<(b);++i)
#define for_rev(i,a,b) for(int i=(a);i>=(b);--i)
#define allof(a) (a).begin(),(a).end()
#define minit(a,b) memset(a,b,sizeof(a))
#define size_of(a) int((a).size())
#define cauto const auto
// typedef
typedef long long lint;
typedef double Double;
typedef pair< int, int > pii;
template< typename T > using Vec = vector< T >;
template< typename T > using Matrix = Vec< Vec< T > >;
template< typename T > using USet = unordered_set< T >;
template< typename T, class C > using MyUSet = unordered_set< T, C >;
template< typename T, typename F > using UMap = unordered_map< T, F >;
template< typename T, typename F, class C > using MyUMap = unordered_map< T, F, C >;
// hash
class PiiHash { public: size_t operator () (const pii& p) const { return (p.first << 16) | p.second; } };
// popcount
inline int POPCNT(int x) { return __builtin_popcount(x); }
inline int POPCNT(lint x) { return __builtin_popcount(x); }
// inf
const int iINF = 1L << 30;
const lint lINF = 1LL << 60;
// eps
const Double EPS = 1e-9;
const Double PI = acos(-1);
// inrange
template< typename T >
inline bool in_range(T v, T mi, T mx) { return mi <= v && v < mx; }
template< typename T >
inline bool in_range(T x, T y, T W, T H) { return in_range(x,0,W) && in_range(y,0,H); }
// neighbor clockwise
const int DX[4] = {0,1,0,-1}, DY[4] = {-1,0,1,0};
const int DX_[8] = {0,1,1,1,0,-1,-1,-1}, DY_[8] = {-1,-1,0,1,1,1,0,-1};
// variable update
template< typename T > inline void modAdd(T& a, T b, T mod) { a = (a + b) % mod; }
template< typename T > inline void minUpdate(T& a, T b) { a = min(a, b); }
template< typename T > inline void maxUpdate(T& a, T b) { a = max(a, b); }
// converter
template< typename F, typename T >
inline void convert(F& from, T& to) {
	stringstream ss;
	ss << from; ss >> to;
}





int main() {
	lint A, B, C;
	cin >> A >> B >> C;
	
	if (A % 2 == 0 || B % 2 == 0 || C % 2 == 0) {
		puts("0");
	} else {
		lint ans = min(A * B, min(A * C, B * C));
		cout << ans << endl;
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <iomanip>
#include <algorithm>
#include <queue>
#include <bitset>
#include <map>
#include <math.h>
#include <utility>

using namespace std;

int main(){

    int N, D;
    cin >> N >> D;

    vector<vector<int>> X(N, vector<int>(D));
    for (int i = 0; i < N; i++){
        for (int j = 0; j < D; j++){
            cin >> X[i][j];
        }
    }

    int count = 0, dist = 0;
    for (int i = 0; i < N-1; i++){
        for (int j = i+1; j < N; j++){
            // cout << "i: " << i << ", j: " << j << endl;
            int sum = 0;
            for (int k = 0; k < D; k++){
                sum += (X[i][k] - X[j][k]) * (X[i][k] - X[j][k]);
            }
            // cout << sum << endl;
            dist = (int)sqrt(sum);
            if(sum == dist*dist) count++;
        }
    }

    cout << count << endl;

    return 0;
}


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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<P> VP;
typedef vector<vector<ll>> VV;
typedef vector<vector<int>> VVi;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
const ll INF=1e18+18;
const ll MAX=100005;
const ll MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
#define ALL(v) v.begin(), v.end()
#define rALL(v) v.rbegin(), v.rend()
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define REPM(i, mp) for (auto i = mp.begin(); i != mp.end(); ++i)
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbgmap(mp) cerr << #mp << ":"<<endl; for (auto i = mp.begin(); i != mp.end(); ++i) { cerr << i->first <<":"<<i->second << endl;}
#define dbgarr(n,m,arr) rep(i,n){rep(j,m){cerr<<arr[i][j]<<" ";}cerr<<endl;}
#define dbgdp(n,arr) rep(i,n){cerr<<arr[i]<<" ";}cerr<<endl;
#define Uniq(v) v.erase(unique(v.begin(), v.end()), v.end())
#define fi first
#define se second

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

template<typename T1, typename T2>
ostream &operator<<(ostream &s, const pair<T1, T2> &p) { return s<<"("<<p.first<<", "<<p.second<<")"; }

// vector
template<typename T>
ostream &operator<<(ostream &s, const vector<T> &v) {
    int len=v.size();
    for(int i=0; i<len; ++i) {
        s<<v[i];
        if(i<len-1) s<<"	";
    }
    return s;
}

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<std::setprecision(10);

    ll h,w;
    cin>>h>>w;

    VV dist(10,Vec(10));

    rep(i,10)rep(j,10){
        cin>>dist[i][j];
    }
    rep(k,10){
        rep(i, 10){
            rep(j, 10) {
                dist[i][j] = min(dist[i][j], dist[i][k]+dist[k][j]);
            }
        }
    }

    ll ans=0;

    rep(i,h)rep(j,w){
        ll x;
        cin>>x;
        if(x!=-1){
            ans += dist[x][1];
        }
    }

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
int N, M;
cin >> N >> M; 
int A[60] = {0}; 
for(int i = 1; i <= M * 2; i++){
int x; 
cin >> x; 
A[x] ++; 
}
for(int i = 1; i <= N; i++){
cout << A[i] << endl; 
}
}

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

class Program
{
    static void Main(string[] args)
    {
        var N = sc.ReadInt();
        var ok = false;
        for (int i = 0; i <= N / 4; i++)
        {
            for (int j = 0; j <= N/7; j++)
            {
                var sum = i * 4 + j * 7;
                if (sum == N) ok = true;
            }
        }
        Console.WriteLine(ok ? "Yes" : "No");
    }

    static Scanner sc = new Scanner();
}

class Scanner
{
    string[] S = new string[0];
    int Index = 0;
    char[] Separators = new char[] { ' ' };

    public string Next()
    {
        if (this.Index < this.S.Length) return this.S[this.Index++];
        var line = "";
        while (line == "") line = Console.ReadLine();
        this.S = line.Split(this.Separators, StringSplitOptions.RemoveEmptyEntries);
        if (this.S.Length == 0) return this.Next();
        this.Index = 0;
        return this.S[this.Index++];
    }
    public string ReadStr()
    {
        return this.Next();
    }
    public char ReadChar()
    {
        return this.Next()[0];
    }
    public int ReadInt()
    {
        return int.Parse(this.Next());
    }
    public uint ReadUInt()
    {
        return uint.Parse(this.Next());
    }
    public long ReadLong()
    {
        return long.Parse(this.Next());
    }
    public double ReadDouble()
    {
        return double.Parse(this.Next());
    }
    public int[] ReadIntArray(int n)
    {
        var array = new int[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadInt();
        }
        return array;
    }
    public long[] ReadLongArray(int n)
    {
        var array = new long[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadLong();
        }
        return array;
    }
    public double[] ReadDoubleArray(int n)
    {
        var array = new double[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadDouble();
        }
        return array;
    }
    public char[] ReadCharArray(int n)
    {
        var array = new char[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadChar();
        }
        return array;
    }
    public string[] ReadStrArray(int n)
    {
        var array = new string[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadStr();
        }
        return array;
    }
}


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

static const ll INF = 1e18;

ll G[305][305];
ll G2[305][305];

int main(){
  rep(i,305){
    rep(j,305){
      G[i][j] = INF;
      G2[i][j] = INF;
    }
    G[i][i] = 0;
  }
  
  int N, M, L;
  cin >> N >> M >> L;
  vector<vector<int>> v;
  rep(i,M){
    int a, b, c;
    cin >> a >> b >> c;
    a--;
    b--;
    G[a][b] = c;
    G[b][a] = c;
    v.push_back({a,b,c});
  }

  rep(k,N) rep(i,N) rep(j,N) G[i][j] = min(G[i][j], G[i][k]+G[k][j]);

  rep(i,v.size()){
    int a = v[i][0];
    int b = v[i][1];
    int c = v[i][2];
    if(c <= L){
      G2[a][b] = 1;
      G2[b][a] = 1;
    }
  }
  
  rep(i,N){
    rep(j,N){
      if(G[i][j] <= L){
        G2[i][j] = 1;
      }
    }
  }

  rep(k,N) rep(i,N) rep(j,N) G2[i][j] = min(G2[i][j], G2[i][k]+G2[k][j]);

  int Q;
  cin >> Q;
  rep(i,Q){
    int a, b;
    cin >> a >> b;
    a--;
    b--;

    if(G2[a][b] == INF) cout << -1 << endl;
    else cout << G2[a][b]-1 << endl;
  }
  
  return 0;
}



Measured memory_bytes: 4280
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
typedef pair<ll,ll> P;
#define pb push_back
#define ft first
#define sd second
#define mp make_pair
#define fr(i,n) for(int i=0;i<(n);i++)
#define Fr(i,n) for(int i=0;i++<(n);)
#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,class E> struct LSeg{
    typedef function<T(T,T)> F;
    typedef function<T(T,E)> G;
    typedef function<E(E,E)> H;
    typedef function<E(E,int)> P;
    int n;F f;G g;H h;T et;E ee;P p;
    vector<T> dat;
    vector<E> lazy;
    LSeg(int n_,F f_,G g_,H h_,T et_,E ee_,P p_=[](E a,int b){return a;}){
        f=f_;g=g_;h=h_;et=et_;ee=ee_;p=p_;
        n=1;
        while(n<n_) n*=2;
        dat.resize(2*n-1,et);
        lazy.resize(2*n-1,ee);
    }
    inline void prop(int k,int l,int r){
        if(lazy[k]==ee) return;
        dat[k]=g(dat[k],lazy[k]);
        if(r-l>1){
            lazy[k*2+1]=h(lazy[k*2+1],p(lazy[k],-1));
            lazy[k*2+2]=h(lazy[k*2+2],p(lazy[k],-1));
        }
        lazy[k]=ee;
    }
    void ud(int be,int en,E t,int k,int l,int r){
        prop(k,l,r);
        if(r<=be||en<=l) return;
        if(be<=l&&r<=en){
            lazy[k]=h(lazy[k],p(t,r-l));
            prop(k,l,r);
            return;
        }
        ud(be,en,t,k*2+1,l,(l+r)/2);
        ud(be,en,t,k*2+2,(l+r)/2,r);
        dat[k]=f(dat[2*k+1],dat[k*2+2]);
    }
    void ud(int be,int en,E t){
        ud(be,en,t,0,0,n);
    }
    T gt(int be,int en,int k,int l,int r){
        prop(k,l,r);
        if(r<=be||en<=l) return et;
        if(be<=l&&r<=en) return dat[k];
        return f(gt(be,en,k*2+1,l,(l+r)/2),gt(be,en,k*2+2,(l+r)/2,r));
    }
    T gt(int be,int en){
        return gt(be,en,0,0,n);
    }
};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,q,s,t,x;
    bool f;
    cin>>n>>q;
    auto mn=[](ll a,ll b){return min(a,b);};
    auto as=[](ll a,ll b){return b;};
    LSeg<ll,ll> sg(n,mn,as,as,INT_MAX,-1);
    fr(i,q){
        cin>>f;
        if(f){
            cin>>s>>t;
            cout<<sg.gt(s,t+1)<<endl;
        }
        else{
            cin>>s>>t>>x;
            sg.ud(s,t+1,x);
        }
    }
}


Measured memory_bytes: 7080
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define i_7 (ll)(1E9+7)
#define i_5 (ll)(1E9+5)
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    else return c+i_7;
}
typedef pair<int,int> i_i;
typedef pair<ll,ll> l_l;
ll inf=(ll)1E12;//10^12
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
////////////////////////////////////////



int main(){
    ios::sync_with_stdio(false);cin.tie(0);
    
    map<string,int>m;
    int n;cin>>n;
    while(n--){
        string s;cin>>s;
        m[s]++;
    }
    cin>>n;
    while(n--){
        string s;cin>>s;
        m[s]--;
    }
    int ans=0;
    for(auto ite=m.begin();ite!=m.end();ite++){
        if(ite->second>ans)ans=ite->second;
    }cout<<ans<<endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/rope>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#define int long long
#define pb push_back
#define x first
#define y second
#define mk(a,b) make_pair(a,b)
#define rr return 0
#define sqr(a) ((a)*(a))
#define all(a) (a).begin(), (a).end()
#define sz(a) (int)(a).size()

using namespace std;
using namespace __gnu_cxx;
using namespace __gnu_pbds;

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

template<class value, class cmp = less<value> >
using ordered_set = tree<value, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
template<class value, class cmp = less_equal<value> >
using ordered_multiset = tree<value, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
template<class key, class value, class cmp = less<key> >
using ordered_map = tree<key, value, cmp, rb_tree_tag, tree_order_statistics_node_update>;

/// find_by_order()
/// order_of_key()
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
inline int randll(int l = INT_MIN, int r = INT_MAX) {
    return uniform_int_distribution<int>(l, r)(rng);
}

const int INF = 1e9, MOD = 998244353; /// think
const ll LINF = 1e15;

const int dx[] = {0, 0, 1, -1}, dy[] = {1, -1, 0, 0};
inline bool inside (int x, int y, int n, int m) {
    return 0 <= x && 0 <= y && x < n && y < m;
}

template<class T> bool umin (T &a, T b) {return a > b ? (a = b, true) : false; }
template<class T> bool umax (T &a, T b) {return a < b ? (a = b, true) : false; }

main()
{
    ios::sync_with_stdio(0);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n, m;
    cin >> n >> m;
    vector <int> a(m), b(m);
    vector <int> c(m);
    for (int i = 0; i < m; i++) {
        cin >> a[i] >> b[i];
        for (int j = 0, x; j < b[i]; j++) {
            cin >> x;
            --x;
            c[i] |= 1 << x;
        }
    }
    vector <int> dp(1 << n, INF);
    dp[0] = 0;
    for (int i = 0; i < m; i++) {
        for (int j = 0; j < (1 << n); j++) {
            umin(dp[j | c[i]], dp[j] + a[i]);
        }
    }
    if (dp.back() >= INF) {
        cout << "-1\n";
    }
    else cout << dp.back() << '\n';
}


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

int main(){
	string s;
	cin>>s;
	if(s=="SUN") cout<<7;
	if(s=="MON") cout<<6;
	if(s=="TUE") cout<<5;
	if(s=="WED") cout<<4;
	if(s=="THU") cout<<3;
	if(s=="FRI") cout<<2;
	if(s=="SAT") cout<<1;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
#define pb push_back
#define mii map <int, int>
#define mll map <ll, ll>
#define pii pair <int, int>
#define pll pair <ll, ll>
#define vi vector <int>
#define vd vector <double>
#define vll vector <ll>
#define fi first
#define se second
#define si set <int>
#define sll set <ll>
#define spii set <pii>
#define vs vector <string>
#define vpii vector <pair <int,int> >
#define vpll vector <pair <long long,long long> >
#define vvi vector <vector <int> >
#define vvpii vector <vector <pii > >
#define forn(i, n) for (int i = 0; i < (n); i++)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define for1(i, n) for (int i = 1; i < (n); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(),(x).rend()


using namespace std;
const ll INFLL = 1e18;
const int MAXN = 1e6+100;
const ll INF = 1e9;
const ll mod1=1e9+7;
const ll mod2=2e9+11;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    #ifdef LOCAL
    freopen("a.in","r",stdin);
    #endif
    ll n,m;
    cin>>n>>m;
    map <int,int> mm;
    ll pen=0,ac=0;
    rep(i,m)
    {
        int p;
        string s;
        cin>>p>>s;
        p--;
        if (mm[p]==-1)
        {
           continue;
        }
        if (s=="AC")
        {
            pen+=mm[p];
            ac++;
            mm[p]=-1;
        } else
            mm[p]++;
    }
    cout<<ac<<" "<<pen;





}

Measured memory_bytes: 4992