akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder
{

    static class Program
    {
        static void Main()
        {

            Solve();

            //Console.WriteLine(ans);
            Console.ReadKey();
        }

        static void Solve()
        {
            int N = GetInt();
            var A = GetIntArray().ToList();
            A.Insert(0, 0);
            A.Add(0);

            int maxcost = 0;
            for(int i = 0; i < N + 1; i++)
            {
                maxcost += Math.Abs(A[i + 1] - A[i]);
            }
            for(int i = 1; i < N + 1; i++)
            {
                if ((A[i - 1] - A[i]) * (A[i] - A[i + 1]) >= 0)
                {
                    Console.WriteLine(maxcost);
                }
                else
                {
                    Console.WriteLine(maxcost - 2 * Math.Min(Math.Abs(A[i - 1] - A[i]), Math.Abs(A[i] - A[i + 1])));
                }
            }



            //Console.WriteLine(ans);
        }


        static public string GetStr() { return Console.ReadLine().Trim(); }
        static public int GetInt() { return int.Parse(Console.ReadLine()); }
        static public long GetLong() { return long.Parse(Console.ReadLine()); }
        static public string[] GetStrArray() { return Console.ReadLine().Split(' '); }
        static public int[] GetIntArray() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
        static public long[] GetLongArray() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
        static public List<double> GetDoubleList() { return Console.ReadLine().Split(' ').Select(double.Parse).ToList(); }
        static public void WriteObjects<T>(IEnumerable<T> values) { foreach (var o in values) { Console.Write(o + " "); } }
        static string yesno(this bool b) { return b ? "yes" : "no"; }
        static string YesNo(this bool b) { return b ? "Yes" : "No"; }
        static string YESNO(this bool b) { return b ? "YES" : "NO"; }

        static bool eq<T, U>() => typeof(T).Equals(typeof(U));
        static T ct<T, U>(U a) => (T)Convert.ChangeType(a, typeof(T));
        static T cv<T>(string s) => eq<T, int>() ? ct<T, int>(int.Parse(s))
                           : eq<T, long>() ? ct<T, long>(long.Parse(s))
                           : eq<T, double>() ? ct<T, double>(double.Parse(s))
                           : eq<T, char>() ? ct<T, char>(s[0])
                                             : ct<T, string>(s);
        static void Multi<T>(out T a) => a = cv<T>(GetStr());
        static void Multi<T, U>(out T a, out U b)
        {
            var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]);
        }
        static void Multi<T, U, V>(out T a, out U b, out V c)
        {
            var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]);
        }
    }
}

Measured memory_bytes: 29276
using System;
using System.Linq;
using System.Collections.Generic;
using System.IO;

namespace atcorder2
{
    class Program
    {
        public static long Read()
        {
            return long.Parse(Console.ReadLine());
        }

        public static long[] Reads()
        {
            return Console.ReadLine().Split().Select(long.Parse).ToArray();
        }

        
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            var s = Console.ReadLine().ToCharArray();
            var answer = 0;
            for (int i =s.Length-2; i >=0; i-=2)
            {
                bool f = false;
                for (int j = 0; j <=i/2-1 ; j++)
                {
                    if (s[j] != s[j + i / 2])
                        f = true;
                }
                if (!f)
                {
                    answer = i;
                    break;
                }
            }
            Console.WriteLine(answer);

            Console.Out.Flush();
        }
    }
}

Measured memory_bytes: 11092
import java.util.Scanner;
import java.util.List;
import java.util.ArrayList;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        List<Character> str = new ArrayList<>();
        for (int i = 0; i < s.length(); i++) {
            str.add(s.charAt(i));
        }
        int min = 101;
        for (char i = 'a'; i <= 'z'; i++) {
            min = Math.min(min, solve(str, i));
        }
        System.out.println(min);
    }
    private static int solve(List<Character> str, char ch) {
        boolean can = true;
        char x = str.get(0);
        for (Character it : str) {
            if (it != x) {
                can = false;
            }
        }
        if (can) {
            return 0;
        }
        List<Character> next = new ArrayList<>();
        for (int i = 0; i < str.size() - 1; i++) {
            if (str.get(i) == ch || str.get(i + 1) == ch) {
                next.add(ch);
            } else {
                next.add(str.get(i));
            }
        }
        return solve(next, ch) + 1;
    }
}


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

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> p(n);
  rep(i,n) cin >> p[i];
  sort(p.begin(), p.end());
  int ans = 0;
  rep(i,k) ans += p[i];
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
#define int long long
#define pb push_back
#define mp make_pair
using namespace std;
const int inf = 1e18 + 7;
const int N = 2e5 + 1;
const int md = 1e9 + 7;
int f[N], a[N];
void sol() {
  int n, v = 0;
  int ans = 0;
  cin >> n;
  for(int i=1; i<=n; i++) {
    cin >> a[i];
    f[a[i]]++;
  }
  
  for(int i=1; i<=n; i++) {
    if(f[i]) {
      ans += f[i]*(f[i] - 1)/2;
    }
  }
  //cout << ans << "\n";
  for(int i=1; i<=n; i++) {
    v = ans - f[a[i]]*(f[a[i]] - 1)/2;
    v += (f[a[i]] - 1)*(f[a[i]] - 2)/2;
    cout << v << "\n";
  }
}

int32_t main() 
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int T = 1;
  //cin >> T; while(T--) 
  sol();
  return 0;
}


Measured memory_bytes: 4736
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

import static java.util.Collections.swap;

/**
 * Wrong Answer
 */
class Main {
	public static void main(String[] args) throws IOException {
		Scanner in = new Scanner(System.in);

		int w = in.nextInt();
		int n = in.nextInt();

		List<Integer> ans = new ArrayList<Integer>();
		for(int i=1;i<=w;i++) {
			ans.add(i);
		}

		String buf = in.nextLine();

		for(int i=0;i<n;i++) {
			String line = in.nextLine();
			String arr[] = line.split(",");
			int a = Integer.parseInt(arr[0]);
			int b = Integer.parseInt(arr[1]);
			swap(ans, a-1, b-1);
		}
		for(int i=0;i<ans.size();i++) {
			System.out.println(ans.get(i));
		}
	}
}

Measured memory_bytes: 25852
#include "bits/stdc++.h"

#define rep(a,b) for(int a = 0;a < b;a++)
#define REP(i, x, n) for(int i = x; i < n; i++)
#define P(a) cout << a << endl
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define ssort(v) sort(v.begin(),v.end())
#define rev(v) reverse(v.begin(),v.end())
#define vP(v) for(int i = 0;i < v.size();i++){cout << v[i];if(i != v.size()-1)cout << endl;}
#define vcin(v,n) rep(i,n){int a;cin >> a;v.pb(a);}

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
int dx[] = { 1, -1 , 0 , 0 };
int dy[] = { 0,  0,  1, -1 };
ll MOD = 1000000007;

void solve() {
	ll n, a, b;
	cin >> n >> a >> b;
	if (n == 1) {
		if (a == b) {
			P(1);
		}
		else {
			P(0);
		}
		return;
	}
	if (a > b) {
		P(0);
		return;
	}
	ll ans = 1 + (b-a)*(n-2);
	P(ans);
}

int main() {
	solve();
	return 0;
}
/* 
4 5
5 4
4 6
6 4
5 6
6 5
*/

Measured memory_bytes: 256
# import sys
# sys.stdin = open("F:\\Scripts\\input","r")
# sys.stdout = open("F:\\Scripts\\output","w")


MOD = 10**9 + 7
I = lambda:list(map(int,input().split()))


s = []
for i in range(1,7):
	s.append(9**i)
	s.append(6**i)
n , = I()
a = [0]*100009
for i in range(1,100007):
	a[i] = a[i-1] + 1
	for j in s:
		if i - j >= 0:
			# print('hi',end='')
			# print(a[i-j]+1,i,a[i])
			a[i] = min(a[i - j] + 1,a[i])
print(a[n])

Measured memory_bytes: 3956
from sys import stdin
from itertools import groupby

n = int(stdin.readline().rstrip())
li = [int(stdin.readline().rstrip()) for _ in range(n)]

import fractions
def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)


point = li[0]
for i in range(n-1):
    point = lcm(point,li[i+1])

print(point)

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

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()
#define all2(a, b) (a).begin(), (a).begin() + (b)
#define debug(vari) cerr << #vari << " = " << (vari) << endl;

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

    int ans = 1001001001;
    rep(i, n)
    {
        int cnt = 0;
        int tmp = a[i];
        while (tmp % 2 == 0)
        {
            cnt++;
            tmp /= 2;
        }
        ans = min(ans, cnt);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3588
#include "bits/stdc++.h"

using namespace std;

void Main() {
    int a, b;
    cin >> a >> b;
    int ans = 0;
    if (b < a) {
        ans = a - 1;
    }
    else {
        ans = a;
    }
    cout << ans << endl;;
}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)

int main(){
    double T, X;
    cin >> T >> X;
    double ans;
    ans = T/X;
    printf("%.10lf\n", ans);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    long long L, R;
    cin >> L >> R;
    map<long long, long long> mp;
    for (long long i = L; i <= min(L + 4038, R); i++)
    {
        mp[i % 2019]++;
    }
    long long x = 2019;
    for (auto p : mp)
    {
        if (p.second == 2)
        {
            x = min(x, p.first * p.first % 2019);
        }
    }
    for (auto p : mp)
    {
        for (auto q : mp)
        {
            if (p.first != q.first)
                x = min(p.first * q.first % 2019, x);
        }
    }
    cout << x << endl;
}


Measured memory_bytes: 384
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    static Scanner sc = new Scanner(System.in);
    static final int inf = 0x3f3f3f3f;
    public static void main(String[] args) {
        int N = sc.nextInt(), k = sc.nextInt();
        int[] a = new int[N + 1],f = new int[N + 1];
        for(int i = 1; i <= N; i ++) a[i] = sc.nextInt();
        Arrays.fill(f,inf);
        f[1] = 0;

        for(int i = 2; i <= N; i++){
            for(int j = 1; j <= k; j ++){
//                if(i + j <= N){
//                    f[i + j] = Math.min(Math.abs(a[i] - a[i + j]) + f[i],f[i + j]);
//                }else break;
                if(i > j){
                    f[i] = Math.min(Math.abs(a[i] - a[i - j]) + f[i - j],f[i]);
//                    else f[i] = Math.abs(a[i] - a[i - j]) + f[i - j];
                }else break;
            }
        }
//        for(int i = 1; i <= N; i++) System.out.print(f[i] + " ");
        System.out.println(f[N]);
    }
}

Measured memory_bytes: 58348
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define show(x) cout << #x << " = " << x << endl;
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
int main(){
    int n;
    cin >> n;
    vector<int>a(n);
    rep(i,n)cin >> a[i];
    sort(a.rbegin(),a.rend());
    int c= 0,d=0;
    rep(i,n){
        if(i%2)d+=a[i];
        else c+=a[i];
    }
    cout <<c-d <<endl;
}

Measured memory_bytes: 888
a[50],b[50],c[50],d[50],p,v,i,j,k;main(n,m){for(scanf("%d%d",&n,&m);~scanf("%d%d",(i<n?a:c-n)+i++,i<n?b+i:d-n+i););for(;j<n;printf("%d\n",p,j++))for(v=1e9,p=i=0;i<m;v>k?p=i,v=k:0)k=abs(a[j]-c[i])+abs(b[j]-d[i++]);}

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

int main(){
  int sx,sy,tx,ty;
  cin >> sx >> sy >> tx >> ty;
  int sax = tx - sx,say = ty - sy;
  if(sax >= 0 && say >= 0){
    for(int i = 0;i < sax;i++){
      cout << "R";
    }
    for(int i = 0;i < say;i++){
      cout << "U";
    }
    for(int i = 0;i < sax;i++){
      cout << "L";
    }
    for(int i = 0;i < say;i++){
      cout << "D";
    }
    cout << "L";
    for(int i = 0;i < say+1;i++){
      cout << "U";
    }
    for(int i = 0;i < sax+1;i++){
      cout << "R";
    }
    cout << "D";
    cout << "R";
    for(int i = 0;i < say+1;i++){
      cout << "D";
    }
     for(int i = 0;i < sax+1;i++){
      cout << "L";
    }
    cout << "U" << endl;
  }
  else if(sax < 0 && say > 0){
    for(int i = 0;i < abs(sax);i++){
      cout << "L";
    }
    for(int i = 0;i < abs(say);i++){
      cout << "U";
    }
    for(int i = 0;i < abs(sax);i++){
      cout << "R";
    }
    for(int i = 0;i < abs(say);i++){
      cout << "D";
    }
    cout << "R";
    for(int i = 0;i < abs(say)+1;i++){
      cout << "U";
    }
    for(int i = 0;i < abs(sax)+1;i++){
      cout << "L";
    }
    cout << "D";
    cout << "L";
    for(int i = 0;i < abs(say)+1;i++){
      cout << "D";
    }
     for(int i = 0;i < abs(sax)+1;i++){
      cout << "R";
    }
    cout << "U" << endl;
  }
  else if(sax > 0 && say < 0){
    for(int i = 0;i < abs(sax);i++){
      cout << "R";
    }
    for(int i = 0;i < abs(say);i++){
      cout << "D";
    }
    for(int i = 0;i < abs(sax);i++){
      cout << "L";
    }
    for(int i = 0;i < abs(say);i++){
      cout << "U";
    }
    cout << "L";
    for(int i = 0;i < abs(say)+1;i++){
      cout << "D";
    }
    for(int i = 0;i < abs(sax)+1;i++){
      cout << "R";
    }
    cout << "U";
    cout << "R";
    for(int i = 0;i < abs(say)+1;i++){
      cout << "U";
    }
     for(int i = 0;i < abs(sax)+1;i++){
      cout << "L";
    }
    cout << "D" << endl;
  }
  else if(sax <= 0 && say <= 0){
    for(int i = 0;i < abs(sax);i++){
      cout << "L";
    }
    for(int i = 0;i < abs(say);i++){
      cout << "D";
    }
    for(int i = 0;i < abs(sax);i++){
      cout << "R";
    }
    for(int i = 0;i < abs(say);i++){
      cout << "U";
    }
    cout << "R";
    for(int i = 0;i < abs(say)+1;i++){
      cout << "D";
    }
    for(int i = 0;i < abs(sax)+1;i++){
      cout << "L";
    }
    cout << "U";
    cout << "L";
    for(int i = 0;i < abs(say)+1;i++){
      cout << "U";
    }
     for(int i = 0;i < abs(sax)+1;i++){
      cout << "R";
    }
    cout << "D" << endl;
  }
    
}
    
    
    

Measured memory_bytes: 256
import java.util.*;
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    int count = 0;
    int max = 0;
    
    for(int i = 0 ; i < s.length() ; ++i){
      if('A'==(s.charAt(i))||'C'==(s.charAt(i))||
        'G'==(s.charAt(i))||'T'==(s.charAt(i))){
        count +=1;
        for(int j = i+1 ; j < s.length() ; ++j){
          if('A'==(s.charAt(j))||'C'==(s.charAt(j))||
             'G'==(s.charAt(j))||'T'==(s.charAt(j))){
            count +=1;
          }else{
            break;
          }
        }
        if(max<count){
          max = count;
        }
      count = 0;
      }
     
    }

      System.out.println(max);
    
  }
}

Measured memory_bytes: 35652
void main(){
	int[int] dic;
	int ans;
	int[] colors = inln();
	foreach(elm; colors){
		dic[elm]++;
		if(dic.get(elm,0)==1)ans++;
	}
	ans.writeln();
}
     
import std.stdio, std.conv, std.algorithm, std.numeric, std.string, std.math, std.range;
const long mod = 10^^9+7;      
// 1要素のみの入力
T inelm(T= int)(){
	return to!(T)( readln().chomp() );
}
     
// 1行に同一型の複数入力
T[] inln(T = int)(){
	T[] ln;
	foreach(string elm; readln().chomp().split())ln ~= elm.to!T();
	return ln;
}


Measured memory_bytes: 2680
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define sz(a) int((a).size())

int main()
{
    ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
    ll h,n,i,j;
    cin>>h>>n;
    vector<ll> a(n);
    ll sum = 0;
    for(i=0;i<n;i++) cin>>a[i], sum+=a[i];
    if(sum>=h) cout<<"Yes";
    else cout<<"No";
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main() {
  string S, T;
  cin >> S >> T;
  int count = 0;
  for (int i = 0; i < S.length(); ++i) {
    if (S[i] != T[i]) {
      count++;
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 3916
#include<stdio.h>
int sum(int n)
{
    int i,s=0;
    while(n!=0)
    {
        i=n%10;
        s=s+i;
        n=n/10;
    }
    return s;
}
int main()
{
    int a,b,c,d,e,f=0;
    scanf("%d%d%d",&a,&b,&c);
    for(d=b;d<=a;d++)
    {
        e=sum(d);
        if(e>=b&&e<=c)
        {
            f=f+d;
        }
    }
    printf("%d\n",f);
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <algorithm>
#include <cassert>
#include <limits>
#include <numeric>
#include <type_traits>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <functional>
#include <utility>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <complex>

using namespace std;

typedef long long ll;
typedef vector<ll> vl;
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define REP(i,n)  FOR(i,0,n)
int main(){
	ll A, B;
	cin >> A >> B;
	if(A == B){
		cout << 1 << endl;
	} else if ((A + B) % 2 == 0){
		cout << (A + B) / 2 << endl;
	} else {
		cout << "IMPOSSIBLE" << endl;
	}
}

Measured memory_bytes: 256
/**
 * @copyright (c) 2020 Daisuke Hashimoto
 */

#include <bits/stdc++.h>
using namespace std;
using Pair = pair<int64_t, int64_t>;
constexpr int64_t kInf = INT64_MAX / 2L;

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

  constexpr int64_t kN = 26;
  int64_t D;
  cin >> D;
  vector<int64_t> C(kN + 1, 0);
  for (int64_t c = 1; c <= kN; ++c) {
    cin >> C[c];
  }
  vector<vector<int64_t>> S(D + 1, vector<int64_t>(kN + 1));
  for (int64_t d = 1; d <= D; ++d) {
    for (int64_t c = 1; c <= kN; ++c) {
      cin >> S[d][c];
    }
  }
  vector<vector<int64_t>> last(D + 1, vector<int64_t>(kN + 1, 0));
  vector<int64_t> contests(D + 1);
  for (int64_t d = 1; d <= D; ++d) {
    cin >> contests[d];
  }

  auto Score = [&](const int64_t day) -> int64_t {
    int64_t score = 0;
    for (int64_t d = 1; d <= day; ++d) {
      last[d] = last[d - 1];
      last[d][contests[d]] = d;
      score += S[d][contests[d]];
      for (int64_t c = 1; c <= kN; ++c) {
        score -= C[c] * (d - last[d][c]);
      }
    }
    return score;
  };

  int64_t M;
  cin >> M;
  for (int64_t m = 1; m <= M; ++m) {
    int64_t d, q;
    cin >> d >> q;
    contests[d] = q;
    cout << Score(D) << endl;
  }
  return 0;
}


Measured memory_bytes: 3788
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
using namespace std;
#define loop(i,a,b) for(int i=int(a); i<int(b); i++)
#define rep(i,b) loop(i,0,b)
typedef vector<int> vi;

int np(const vi& w, const vi& v, int W){
    vi cur(W+1);
    int n=w.size();
    rep(i,n){
        vi next(W+1);
        rep(j,W+1){
            if(j-w[i]>=0) next[j]=max({cur[j-w[i]]+v[i],next[j-w[i]]+v[i],cur[j]});
            else next[j] = cur[j];
        }
        swap(cur,next);
    }
    return cur[W];
}

int main(){
    int n,C;
    while(cin>>n>>C){
        vi c(n), s1(n), s2(n), s3(n);
        rep(i,n){
            string s;
            cin.ignore();
            getline(cin,s);
            cin >> c[i] >> s1[i] >> s2[i] >> s3[i];
        }

        int ans =-1;
        ans = max(ans, np(c,s1,C));
        ans = max(ans, np(c,s2,C));
        ans = max(ans, np(c,s3,C));
        cout << ans << endl;
    }
}

Measured memory_bytes: 1216
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<queue>
#include<stack>
#include<list>
#include<map>
#include<deque>
#include<cctype>
#include<math.h>
using namespace std;
#define ll long long
int main(){
    ll N;
    string S;
    cin >> N >> S;
    ll i,j,k;
    int tmp;
    bool t[10],m[100],d[1000];
    for(i=0;i<10;i++){
        t[i]=0;
    }
    for(i=0;i<100;i++){
        m[i]=0;
    }
    for(i=0;i<1000;i++){
        d[i]=0;
    }
    for(i=0;i<N;i++){
        tmp=S[i]-'0';
        for(j=0;j<10;j++){
            for(k=0;k<10;k++){
                if(m[k*10+j]==1)d[k*100+j*10+tmp]=1;
            }
        }
        for(j=0;j<10;j++){
            if(t[j]==1)m[10*j+tmp]=1;
        }
        t[tmp]=1;
    }
    ll ans=0;
    for(i=0;i<1000;i++){
        ans+=d[i];
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 256
#n,mを入力
n,m = map(int, input().split())

#suki = [[1,3],[1,2,3]]
suki = []
for i in range(n):
    suki.append(list(map(int, input().split())))

cnt = 0
j = 1
for j in range(m+1):
    for k in range(n):
        if suki[k][1:].count(j) == 0:
            break

        if k == (n-1):
            cnt += 1

print(cnt)
    


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

#define rep(i,s,n) for (int i = (int)s; i < (int)n; i++)
#define ll long long
#define pb push_back
#define All(x) x.begin(), x.end()
#define Range(x, i, j) x.begin() + i, x.begin() + j

// 左づめでの10進数xをdigits桁のN進数vectorにしてを返す
vector<int> baseNumber(int N, int digits, ll x) {
  vector<int> ret(digits, 0);
  // 商
  ll quotient = x;
  int counter = 0;
  while (quotient > 0) {
    // 余り
    int remainder = quotient % N;
    quotient /= N;
    ret[counter] = remainder;
    counter++;
  }

  return ret;
};

int main() {
  ll N, K;
  cin >> N >> K;
  vector<ll> A(N);
  vector<int> BiA[N];
  // Aにおいて桁数に0, 1が何個存在するか
  vector<int> digit0num(40, 0);
  vector<int> digit1num(40, 0);
  rep(i, 0, N) {
    cin >> A[i];
    BiA[i] = baseNumber(2, 40, A[i]);
    rep(j, 0, 40) {
      int tmp = BiA[i][j];
      if (tmp == 1) {
        digit1num[j]++;
      } else {
        digit0num[j]++;
      }
    }
  }

  vector<int> BiK = baseNumber(2, 40, K + 1);
  vector<ll> ans;
  rep(i, 0, 40) {
    ll ansi = 0;
    int Ki = BiK[i];
    if (Ki == 0) continue;
    rep(j, 0, 40) {
      if (j == i) {
        ansi += (1ll<<j) * digit1num[j];
      } else if (j < i) {
        ansi += (1ll<<j) * max(digit0num[j], digit1num[j]);
      } else {
        if (BiK[j] == 1) {
          ansi += (1ll<<j) * digit0num[j];
        } else {
          ansi += (1ll<<j) * digit1num[j];
        }
      }
    }
    ans.pb(ansi);
  }
  sort(All(ans));
  reverse(All(ans));
  cout << ans[0] << endl;
};


Measured memory_bytes: 20608
#include<stdio.h>
int main()
{
    int dice[24][7]=
    {
    { 0,1,2,3,4,5,6 },{ 0,1,3,5,2,4,6 },{ 0,1,4,2,5,3,6 },{ 0,1,5,4,3,2,6 },
    { 0,2,6,3,4,1,5 },{ 0,2,3,1,6,4,5 },{ 0,2,1,4,3,6,5 },{ 0,2,4,6,1,3,5 },
    { 0,3,1,2,5,6,4 },{ 0,3,2,6,1,5,4 },{ 0,3,5,1,6,2,4 },{ 0,3,6,5,2,1,4 },
    { 0,4,1,5,2,6,3 },{ 0,4,2,1,6,5,3 },{ 0,4,5,6,1,2,3 },{ 0,4,6,2,5,1,3 },
    { 0,5,1,3,4,6,2 },{ 0,5,3,6,1,4,2 },{ 0,5,4,1,6,3,2 },{ 0,5,6,4,3,1,2 },
    { 0,6,2,4,3,5,1 },{ 0,6,3,2,5,4,1 },{ 0,6,5,3,4,2,1 },{ 0,6,4,5,2,3,1 }
    };
    int dice1[7]={0},dice2[7]={0},i,j,assign[7]={0};

    for(i=1; i<7; i++)
    {
        scanf("%d",&dice1[i]);
    }
    for(i=1; i<7; i++)
    {
        scanf("%d",&dice2[i]);
    }
    for(i=0; i<24; i++)
    {
        for(j=0; j<7; j++)
        {
            assign[j]=dice1[dice[i][j]];
        }
        for(j=0; ; j++)
        {
            if(j>6)
            {
                printf("Yes\n");
                return 0;
            }
            if(assign[j]!=dice2[j])
                break;
        }
    }
    printf("No\n");
    return 0;
}




Measured memory_bytes: 2040
n = int(input())
ll = [list(map(int, input().split())) for _ in range(n)]

ll = ll[::-1]

ans = 0
res = 0
sub = 0

for a, b in ll:
    if (a + ans) % b == 0:
        continue
    res = (a + ans) % b
    sub = b - res

    ans += sub

print(ans)

Measured memory_bytes: 28148
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1001001001;
const ll LINF = 1LL << 60;
const int MOD = 1'000'000'007;

template <typename T>
void print(const T &v)
{
    for (int i = 0; i < v.size(); i++)
    {
        if (i)
            cout << ' ';
        cout << v[i];
    }
    cout << endl;
}

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

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

// const int MAX = 1010;

int main()
{
    int n;
    cin >> n;
    string s1, s2;
    cin >> s1 >> s2;
    ll ans = 0;
    int idx, mode;
    if (s1[0] == s2[0])
    {
        ans = 3;
        idx = 1;
        mode = 0;
    }
    else
    {
        ans = 6;
        idx = 2;
        mode = 1;
    }

    for (; idx < n; idx++)
    {
        if (s1[idx] == s2[idx])
        {
            if (mode == 0)
            {
                ans = (ans * 2) % MOD;
            }
            mode = 0;
        }
        else
        {
            if (mode == 0)
            {
                ans = (ans * 2) % MOD;
            }
            else
            {
                ans = (ans * 3) % MOD;
            }
            mode = 1;
            ++idx;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3596
{-# LANGUAGE BangPatterns #-}

module Main where

import Data.Char
import Data.List
import Control.Monad
import Control.Applicative
import Text.Printf


readInt :: IO Int
readInt = read <$> (input `seq` input)
    where input = do
            !c <- getChar
            if isDigit c || c == '-'
                then (c :) <$> input
                else return []

prints :: Show a => [a] -> IO ()
prints as = putStrLn $ concat $ intersperse " " $ map show as

main = do
    [h, w] <- replicateM 2 readInt
    if h == 0 && w == 0
        then return ()
        else draw h w >> putStrLn "" >> main

draw h w = forM_ [1..h] $ \r -> do
               forM_ [1..w] $ \c -> putStr ["#." !! ((r + c) `mod` 2)]
               putStrLn ""


Measured memory_bytes: 4100
#include <cmath>
#include <cstdio>
#include <limits>
#include <tuple>
#include <stack>
#include <queue>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <numeric>
#include <string>
#include <array>
#include <iomanip>

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rrep(i, n) for (int i = n-1; i >= 0; --i)
#define REP(i, s, n) for (int i = s; i< (int)(n); ++i)
#define all(x) x.begin(), x.end()

using namespace std;
using ll = long long;
ll inf = ll(1e18);
using ll1d = vector<ll>;
using ll2d = vector<ll1d>;
using ll3d = vector<ll2d>;

void solve(istream &ccin = cin, ostream &ccout = cout) {
  ll a, b;
  ccin >> a >> b;

  if (a == 2 or b == 2) {
    ccout << "No" << endl;
  } else {
    ccout << "Yes" << endl;
  }

}

int main() {
  ios::sync_with_stdio(false);
  solve();
  return 0;
}

Measured memory_bytes: 256
#pragma region template
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
/*
const long long MOD = 1e9 + 7, MAX = 1e18, larg = 1e5, INF = -1e9;
long long max_value = INF, max_index = -1;
long long min_value = MAX, min_index = -1;*/
long long A, B, C, D, E, F, G, H, I, J, K, L, N, M, O, P, Q, R, S, T, U, V, W, x, y, z;
typedef long long ll;
typedef pair<ll, ll> Pa;

/*
template <std::int_fast64_t Modulus> class modint {
	using u64 = std::int_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 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;
	}
};
#pragma endregion

typedef modint<MOD> m;
m func[400001];
void funcinit(int N)
{
	func[0] = 1;
	for (int i = 1; i <= N; i++)
	{
		func[i] = func[i - 1] * i;
	}
}
m comb(m n, m r)
{
	if (n.a <= 0 || n.a < r.a)
	{
		return 0;
	}
	return func[n.a] / (func[r.a] * func[(n - r).a]);
}*/

int main() {
	cin >> A >> B;
	for (int i = 1; i <= 1250; i++) {
		if (i * 8 / 100 == A && i / 10 == B) {
			cout << i;
			return 0;
		}
	}
	cout << -1;
}


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

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

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()
#define dump(x) cout << #x << " = " << (x) << endl
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

template<class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
	os<<"("<<p.first<<","<<p.second<<")";
	return os;
}

template<class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
	os<<"{";
	rep(i, v.size()) {
		if (i) os<<",";
		os<<v[i];
	}
	os<<"}";
	return os;
}

bool pr[310];
vector<pii> vec;
vi big;
int ans;
int q;
int m[310], x[310];
vi sum;
vi deg;
vi xdeg[310];

void check() {
	vi sum(big.size());
	int t = 0;

	rep(i, q) {
		bool ok = true;
		rep(j, vec.size()) {
			if (deg[j] < xdeg[i][j]) {
				ok = false;
			}
		}
		if (ok) {
			bool f = 1;
			rep(j, big.size()) {
				if (m[i] % big[j] == 0) {
					sum[j] += x[i];
					f = 0;
				}
			}
			if (f) {
				t += x[i];
			}
		}
	}
	rep(i, sum.size()) {
		t += max(0, sum[i]);
	}
	ans = max(ans, t);
}

void dfs(int p) {
	if (p == vec.size()) {
		check();
		return ;
	}

	for (int i = 0; i <= vec[p].se; ++i) {
		deg[p] = i;
		dfs(p + 1);
	}
}

int main() {
	for (int i = 2; i <= 300; ++i) {
		if (!pr[i]) {
			for (int j = i * 2; j <= 300; j += i) {
				pr[j] = 1;
			}
			if (i * i <= 300) {
				int c = 1, x = i;
				while (x * i <= 300) {
					x *= i;
					++c;
				}
				vec.eb(i, c);
			} else {
				big.pb(i);
			}
		}
	}

	cin >> q;
	rep(i, q) {
		cin >> m[i] >> x[i];
	}

	sum.resize(big.size());
	deg.resize(vec.size());

	rep(i, q) {
		xdeg[i].resize(vec.size());
		int c = 0;
		rep(j, vec.size()) {
			int v = m[i];
			int c = 0;
			while (v % vec[j].fi == 0) {
				c++;
				v /= vec[j].fi;
			}
			xdeg[i][j] = c;
		}
	}

	dfs(0);
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

#define debug(...) fprintf(stderr, __VA_ARGS__)
#define int long long int
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
typedef pair<int, int> pii;
typedef long long ll;
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;

int A[100010], B[100010];
signed main() {
    int N; cin >> N;

    int sumA = 0;
    for(int i=0; i<N; i++) {
        cin >> A[i];
        sumA += A[i];
    }

    int sumB = 0;
    for(int i=0; i<N; i++) {
        cin >> B[i];
        sumB += B[i];
    }

    if(sumA < sumB) {
        cout << -1 << endl;
    }
    else {
        vector<int> sub;
        for(int i=0; i<N; i++) {
            sub.push_back( A[i] - B[i] );
        }
        sort(sub.begin(), sub.end());

        int cnt_nega = 0, nega_sum = 0;
        for(int i=0; i<N; i++) {
            if(sub[i] >= 0) break;
            cnt_nega++;
            nega_sum += (-sub[i]);
        }

        reverse(sub.begin(), sub.end());
        int ans = cnt_nega;
        for(int i=0; i<N and nega_sum > 0; i++) {
            ans++;
            nega_sum = max(0LL, nega_sum - sub[i]);
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 2936
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using static System.Console;
using static System.Math;

namespace abc167A
{
  public class MainClass
  {
    public static void Main(string[] args)
    {
      long[] inputs = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
      long A = inputs[0];
      long B = inputs[1];
      Console.WriteLine(A*B);
    }
  }
}

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

#define pb push_back
#define pf push_front
#define pp pop_back
#define sz(a) (int)(a.size())
#define mp make_pair
#define F first
#define S second
#define next _next
#define prev _prev
#define left _left
#define right _right
#define y1 _y1
#define all(x) x.begin(), x.end()
#define what_is(x) #x << " is " << (x)
#define int ll

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int N = (int)1e5 + 123;
const ll INF = (ll)1e18 + 123;
const int inf = (int)1e9 + 123;
const int MOD = (int)1e9 + 7;

int a, b;

int gcd(int a, int b, int &x, int &y) {
    // cout << a << ' ' << b << ' ' << x << ' ' << y << '\n';
    if(b == 0) {
        x = 1, y = 0;
        return a;
    }
    int x1 = x, y1 = y;
    int _gcd = gcd(b, a % b, x1, y1);
    x = y1;
    y = x1 - (a/ b) * y1;
    return _gcd;
}

main() {
    cin >> a >> b;
    int x = 0, y = 0;
    int _gcd = gcd(a, b, x, y);
    cout << x << ' ' << y << '\n';
    return 0;
}



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

#define ll long long
#define vi vector<int>
#define vl vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
// pll pp; -> (pp.first,pp.second)
// vector<vl> pp(n,vl(2)); sort(pp.begin(),pp.end(),[](vl a,vl b){return a[0]<b[0];});

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define RREP(i,n) for(ll (i)=(n)-1;(i)>=0;(i)--)
#define FOR(i,a,b) for(ll (i)=(a);(i)<(b);(i)++)
#define FORR(i,a,b) for(ll (i)=(b)-1;(i)>=(a);(i)--)
#define DEBUG(x) cout << #x << ": " << x << endl
#define CHMAX(a,b) a=max((a),(b))
#define CHMIN(a,b) a=min((a),(b))
vl modinv;
void fillModInv(ll n, ll mod){
  modinv = vl(n+1);
  modinv[1] = 1;
  FOR(i,2,n+1){
    modinv[i] = modinv[mod%i] * (mod - mod/i) % mod;
  }
}
/*}}}*/
int main() {
  string s;
  cin >> s;
  ll Q;
  cin >> Q;

  string ini_head = "";
  string ini_tail = "";

  bool rev = false;

  REP(q,Q){
    ll t;
    cin >> t;
    if(t==1){
      rev = !rev;
      continue;
    }else{
      ll f;
      cin >> f;
      char c;
      cin >> c;
      if(!rev){
        if(f==1){
          ini_head += c;
        }else{
          ini_tail += c;
        }
      }else{
        if(f==1){
          ini_tail += c;
        }else{
          ini_head += c;
        }
      }
    }
  }
  if(!rev){
    RREP(i,ini_head.length()) cout << ini_head[i];
    cout << s << ini_tail << endl;
  }else{
    RREP(i,ini_tail.length()) cout << ini_tail[i];
    RREP(i,s.length()) cout << s[i];
    cout << ini_head << endl;
  }
  
  //cout << fixed << setprecision(10);
  return 0;
}


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

int main(void){
    long long n;
    long long ans=0;
    long long numr=0;
    cin >> n;
    vector<int> c(n);
    rep(i,n){
        char s;
        cin >> s;
        if(s == 'W'){
            c.at(i)=0;
        }else{
            c.at(i)=1;// W;0 R;1
            numr++;
        }
    }

        for(long long i=0; i < numr; i++){
            if(c.at(i)==0){
                ans++;
            }     
        }
    cout << ans << endl;
}

Measured memory_bytes: 4028
#include <iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<string>
#include<bitset>
using namespace std;
#define ll long long
const ll INF = 1LL << 60;

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; }

class UnionFind {
	vector<int> data;
public:
	UnionFind(int size) : data(size, -1) { }
	bool unionSet(int x, int y) {
		x = root(x); y = root(y);
		if (x != y) {
			if (data[y] < data[x]) swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
		return x != y;
	}
	bool findSet(int x, int y) {
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
};

//input
ll N,M,L;
string S;
int main() {
	cin >> S;
	bool flag = true;
	ll ans = 0;
	for (int i = 0; i<S.size(); i++) {
		if (flag) {
			if (S[i] == '0') {
				ans++;
			}
          	flag=false;
		}
		else {
			if (S[i] == '1') {
				ans++;
			}
          flag=true;
		}
	}
	if (ans > S.size() / 2) {
		ans = S.size() - ans;
	}
	cout << ans;
	return 0;
}

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

int main(){
    int K, N;
    cin >> N >> K;
    vector<int> d(200);
    vector<int> A(20000);

    for (int i = 0;i<K;++i){
        cin >> d.at(i);
        for (int j = 0; j<d[i];++j){
            cin >> A.at(i + 101 * j);
        }
    }
    std::sort(A.begin(), A.end());
    A.erase(std::unique(A.begin(), A.end()),A.end());

    int ans = A.size() - 1;
    ans = N - ans;

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

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

using ll = long long;

int main() {
  int X, N;
  cin >> X >> N;
  vector<int> p(N);
  if (N != 0) {
    for (int i = 0; i < N; i++) cin >> p.at(i);
  } else {
    int dust;
    // cin >> dust;
  }

  int candidate = 0;
  for (int i = 0; i <= 101; i++) {
    bool flag = true;
    for (int j = 0; j<N; j++) {
      if (p[j] == i) flag = false;
    }
    if (flag) {
      if (abs(candidate-X) > abs(i-X)) {
        candidate = i;
      }
    }
  }
  
  cout << candidate << endl;
  return 0;
}


Measured memory_bytes: 3600
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

int main() {
    int n, a, b;
    cin >> n >> a >> b;
    string s;
    cin >> s;

    int x = 0, y = 0;

    for (int i = 0; i < s.size(); ++i) {
        if (s[i] == 'a') {
            if (x < a + b) {
                x++;
                cout << "Yes" << endl;
            } else {
                cout << "No" << endl;
            }
        } else if (s[i] == 'b') {
            if (x < a + b && y < b) {
                cout << "Yes" << endl;
                x++;
                y++;
            } else {
                cout << "No" << endl;
            }
        } else {
            cout << "No" << endl;
        }
    }
}

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

using namespace std;

#define int long long

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

template <typename T> T gcd(T m, T n) { return n == 0 ? m : gcd(n, m % n); }
template <typename T> T lcm(T m, T n) { return n * m / gcd(n, m); }
template <typename T> T fact(T n) { return (n == 0 ? 1 : n * fact(n - 1)); }
template <typename T> T modpow(T a, T e, T m) { return (e == (T)0 ? 1 : ((a % m) * modpow((a % m), e - 1, m)) % m); }

constexpr int MOD = 1e9 + 7;

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

  int m = max(w, h);
  int num = n / m;
  if (n % m != 0) num++;
  cout << num << endl;
}


Measured memory_bytes: 256
import re

n = int(input())
ss = [input() for _ in range(n)]

count_ab = 0
b_a = 0
__a = 0
b__ = 0

for si in ss:
  count_ab += len(re.findall('AB',si))
  if si[0]=='B' and si[-1]=='A':
    b_a += 1
  elif si[0]=='B':
    b__ += 1
  elif si[-1]=='A':
    __a += 1
  else:
    pass

if b_a == 0:
  print(count_ab + min(__a,b__))
else:
  if __a == 0 and b__ == 0:
    print(count_ab + b_a - 1)
  else:
    print(count_ab + b_a + min(__a,b__))

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


int main(){	
	int N;
	scanf("%d",&N);
	vector<int> H(N-1+1);
	for(int i = 0 ; i <= N-1 ; i++){
		scanf("%d",&H[i]);
	}
	int res = 0, M = 0;
	for (int i=0; i<N; i++) {
		if (M<=H[i]) res++;
		M = max(M, H[i]);
	}
	cout << res << endl;
	return 0;
}



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

#define rep(n) for(int i=0;i<n;i++)
#define repp(j, n) for(int j=0;j<n;j++)
#define reppp(i, m, n) for(int i=m;i<n;i++)
#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define debug(x) cerr << #x << ": " << x << endl

using namespace std;

typedef long long ll;
typedef pair<ll, ll> Pll;
typedef pair<int, int> Pii;
struct Edge{int from, to; ll cost;};

const ll MOD = 1000000007;
const long double EPS = 10e-10;
const int MAX_N = 1000000;

template<typename T> class SegmentTree {
    public:
    int n;
    int init_value = INT_MAX;
    T data[2*MAX_N-1];

    SegmentTree(int n, T init_value=INT_MAX){
        // 2のべき乗にする
        this->n = 1;
        while(this->n < n) this->n <<= 1;
        this->init_value = init_value;
        rep(2*(this->n)-1){
            data[i] = init_value;
        }
    }

    void update(int i, int x){
        i += n-1;
        data[i] = x;
        while(i){
            i = (i-1)/2;
            data[i] = min(data[2*i+1], data[2*i+2]);
        }
    }

    T find(int s, int t, int k, int kl, int kr){
        if(kr <= s || t <= kl) return init_value;
        if(s <= kl && kr <= t) return data[k];
        int kc = (kl+kr)/2;
        int vl = find(s, t, 2*k+1, kl, kc);
        int vr = find(s, t, 2*k+2, kc, kr);
        return min(vl, vr);
    }
};

int main(){
    std::ios::sync_with_stdio(0); cin.tie(0);
    int n,q,com,x,y;
    cin >> n >> q;
    SegmentTree<int> tree = SegmentTree<int>(n);
    rep(q){
        cin >> com >> x >> y;
        if(com){
            cout << tree.find(x, y+1, 0, 0, tree.n) << endl;
        }else{
            tree.update(x, y);
        }
    }
}



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

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

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

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

int f[9];
void init()
{
    f[0] = 1;
    for (int i = 1; i < 9; ++i)
    {
        f[i] = i * f[i - 1];
    }
}

vector<int> x = vector<int>(8);
vector<int> y = vector<int>(8);
vector<int> p;

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

    init();

    int N;
    cin >> N;

    rep (i, N) cin >> x[i] >> y[i];

    p = vector<int>(8,0);
    rep (i, N) p[i] = i;
    double ans = 0.0;
    do
    {
        rep (i, N - 1)
        {
            ans += sqrt((x[p[i]] - x[p[i + 1]]) * (x[p[i]] - x[p[i + 1]]) + (y[p[i]] - y[p[i + 1]]) * (y[p[i]] - y[p[i + 1]]));
        }
    } while (next_permutation(p.begin(), p.begin() + N));

    cout << setprecision(10) << ans / f[N] << "\n";
    return 0;
}



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

using namespace std;

void solve()
{
    int n;
    cin >> n;
    double ans = 0;
   for (int i = 0; i < n; i++)
   {
       double x;
       cin >> x;
       ans += 1. / x;
   }
   ans = 1. / ans;
   cout << ans << endl;
}

int main()
{
    solve();
    cerr << "努力不足ですね！" << endl;
    return 0;
}


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

int main(){
    int N;
    cin >> N;
    int p = 0;
    int w = 0;
    int g = 0;
    int y = 0;
    for(int i = 0; i < N; i++){
        char tmp_char;
        cin >> tmp_char;
        if(tmp_char == 'P') p = 1;
        if(tmp_char == 'W') w = 1;
        if(tmp_char == 'G') g = 1;
        if(tmp_char == 'Y') y = 1;
    }
    int count = p+w+g+y;
    if (count == 3){
        cout << "Three" << endl;
    }else{
        cout << "Four" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
import static java.lang.Math.*;
import java.math.BigInteger;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int n = sc.nextInt();
		int[] t = new int[n];
		int[] v = new int[n];
		int sumT = 0;
		for(int i = 0; i < n; i++){
		    t[i] = sc.nextInt();
		    sumT += t[i];
		}
		for(int i = 0; i < n; i++){
		    v[i] = sc.nextInt();
		}
		
		// 計算
		double result = 0;
		int[] V = new int[sumT];
		int[] minV = new int[sumT+1];
		int index = 0;
		for(int i = 0; i < n; i++){
		    for(int j = 0; j < t[i]; j++){
		        V[index] = v[i];
		        index++;
		        if(index == sumT) continue;
		        if(j < t[i]-1){
		            minV[index] = v[i];
		        }else{
		            minV[index] = min(v[i], v[i+1]);
		        }
		    }
		}
		int[] minA = new int[sumT+1];
		for(int i = 0; i < (sumT+2)/2; i++){
		    minA[i] = i;
		    minA[sumT-i] = i;
		}
		int[] r = new int[sumT+1];
		for(int i = 1; i < sumT+1; i++){
		    r[i] = min(r[i-1]+1, min(minV[i], minA[i]));
		}
		int[] l = new int[sumT+1];
		for(int i = 1; i < sumT+1; i++){
		    l[sumT-i] = min(l[sumT-i+1]+1, min(minV[sumT-i], minA[sumT-i]));
		}
		int[] res = new int[sumT+1];
		for(int i = 0; i < sumT+1; i++){
		    res[i] = min(r[i], l[i]);
		}
		
		for(int i = 1; i < sumT+1; i++){
		    result += (double)abs(res[i]-res[i-1])/2 + min(res[i], res[i-1]);
		}
		for(int i = 1; i < sumT+1; i++){
		    if(res[i] == res[i-1] && res[i-1] < V[i-1]) result += 0.25;
		}
		//System.out.println(Arrays.toString(V));
		//System.out.println(Arrays.toString(minV));
		//System.out.println(Arrays.toString(minA));
		//System.out.println(Arrays.toString(r));
		//System.out.println(Arrays.toString(l));
		//System.out.println(Arrays.toString(res));
		
		//サンプル入力
		//6
		//2 1 2 2 1 1
		//1 3 5 4 1 2
		//サンプル出力
		//14.25
		
		// 出力
		System.out.println(result);
	}
}



Measured memory_bytes: 22356