akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

#define   REP(i, n) for(int i = 0;            i <  (int)(n);        i++)
#define  CREP(i, n) for(int i = 1;            i <= (int)(n);        i++)
#define  RREP(i, n) for(int i = (int)(n) - 1; i >= 0;               i++)
#define RCREP(i, n) for(int i = (int)(n);     i >  0;               i++)

#define INF  std::numeric_limits<int>::max()
#define NINF std::numeric_limits<int>::min()

using namespace std;
using ll = long long;

int digits[4];

string solve() {
    string formula;

    // bit全探索
    for(int bit = 0; bit < (1 << 3); bit++) {
        formula = to_string(digits[0]);
        int ans = digits[0];
        for(int i = 0; i < 3; i++) {
            if(bit & (1 << i)) {
                formula += "+";
                ans += digits[i + 1];
            }
            else {
                formula += "-";
                ans -= digits[i + 1];
            }
            formula += to_string(digits[i + 1]);
        }
        if(ans == 7) {
            break;
        }
    }

    return formula + "=7";
}

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

    string s;
    std::cin >> s;

    REP(i, 4) {
        digits[i] = stoi(s.substr(i, 1));
    }

    std::cout << solve() << std::endl;

    return 0;
}


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

void solve(long long A, long long B, long long K){
    long long a, b;
    if (K >= A) a = 0;
    else a = A - K;
    if (K - A > 0) b = max(B - (K - A), (long long)0);
    else b = B;
    cout << a  << ' ' << b << '\n';
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    long long K;
    scanf("%lld",&K);
    solve(A, B, K);
    return 0;
}


Measured memory_bytes: 256
/****************************************************************************
Is this the real life? Is this just fantasy?
Caught in a landslide, no escape from reality
Open your eyes, look up to the skies and see
I'm just a poor boy, I need no sympathy
Because I'm easy come, easy go, little high, little low
Any way the wind blows doesn't really matter to me, to me!!!
--------------------------------------------------
CP is quite cool.It becomes cooler when you enjoy learning new things
******************************************************************************/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define mp make_pair
#define endl "\n"
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,a,b) for(int i=a;i<=b;i++)
#define pool(i,a,b) for(int i=a;i>=b;i--)
#define pi pair<int,int>
#define pll pair<ll,ll>
#define vi vector<int>
#define vpi vector<pair<int,int>>
#define vll vector<ll>
#define vb vector<bool>
#define all(x) x.begin(),x.end()
#define sz(a) a.size()
#define ff first
#define ss second
#define debug(x) cout<<#x<<" = "<<x<<endl;
const int mod=1e9+7;

void solve()
{
  int n,m,t;
  cin>>n>>m>>t;
  vi row(n+1,0),col(m+1,0);
  map< pi,bool> list;
  rep(i,t)
  {
    int u,v;
    cin>>u>>v;
    row[u]++;
    col[v]++;
    list[{u,v}]=1;
  }
  int x=*max_element(all(row));
  int y=*max_element(all(col));

  vi maxrow;
  loop(i,1,n)
  {
    if(row[i]==x)
      maxrow.pb(i);
  }

  loop(i,1,m)
  {
    if(col[i]==y)
    {
      for(auto v:maxrow)
      {
        if(list.find({v,i})==list.end())
        {
          cout<<x+y<<endl;
          return;
        }
      }
    } 
  }

  cout<<x+y-1<<endl;

} 

int main()
{

  #ifndef ONLINE_JUDGE
  freopen("input.txt","r",stdin);
  freopen("output.txt","w",stdout);
  #endif

  ios::sync_with_stdio(false);
  cin.tie(0);

  int t=1;
  // cin>>t;
  while(t--)
  {
    solve();
  }

  return 0;
}


Measured memory_bytes: 26404
#include <algorithm>
#include <cstdlib>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef long long LL;

int main() {
  string S, T; cin >> S >> T;
  int Ls = S.size(), Lt = T.size();
  int vmin = 1e9;
  for (int i = 0; i< Ls; ++i) {
    if (i + Lt > Ls) break;
    int x = 0;
    for (int j = 0; j < Lt; ++j) {
      if (S[i + j] != T[j]) ++x;
    }
    vmin = min(vmin, x);
  }
  cout << vmin << endl;
}


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

using namespace std;

typedef long long ll;
typedef long double ld;
#define gap ' '
#define L(i) ((i) - (&i))

const int MAXN = 1000010;
const int MAX = 1e6 + 1;
const int MOD = 1e9;
const int INF = 1e9;

int main(){	
	int n; cin >> n;
	vector<int> a(n);
	for(int i = 0; i < n; ++i)
		cin >> a[i];
	vector<int> dp(n,INF);
	dp[0] = 0;
	for(int i = 0; i < n; ++i){
		for(int j : {i+1,i+2}){
			if(j < n){
				dp[j] = min(dp[j], dp[i]+abs(a[i]-a[j]));
			}
		}
	}
	cout << dp[n-1] << endl;
	return 0;
}

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

#define scd second;
#define fst first;
#define mkp make_pair
#define pb push_back
#define pf push_front

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vlong;
typedef vector<vint> vvint;
typedef vector<vlong> vvlong;

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

	int s, w;
	cin>>s>>w;
	if(w>=s) cout<<"unsafe\n";
	else cout<<"safe\n";
}

Measured memory_bytes: 3648
object Main {
  import scala.io.StdIn.readLine
  def main(args: Array[String]): Unit = {
    val sc = new java.util.Scanner(System.in)
    val n = sc.nextInt
    val v = List.fill(n,2)(sc.nextInt).map(a=>(a(0), a(1)))
    println( new QD(31, v).ans())

  }
}

class QD(blen: Int, l: List[(Int, Int)]) {
  val hIsHorEv = (l.head._1+l.head._2).abs % 2
  val oddOrEven = l.tail.find(a=> (a._1+a._2).abs %2 != hIsHorEv) match {
    case Some(x) => Left(-1)
    case None => Right(hIsHorEv)
  }
  val bits = oddOrEven match {
    case Left(x) => List()
    case Right(x) if hIsHorEv == 1 =>
      (1 to blen).map(a=>Math.pow(2, a-1).toInt)
    case Right(x) if hIsHorEv == 0 =>
      List(1) ++ (1 to blen).map(a=>Math.pow(2, a-1).toInt)
  }

  def bitExpand(a: Long): List[Boolean] = {
    val f = (a: Long) => (a/2, a%2==1)
    lsAccum(f, (b:Long)=>b==0, a)
  }

  def lsAccum(f: Long=>(Long,Boolean), condition:Long=> Boolean, state: Long): List[Boolean] = {
    if(condition(state)) {
      List()
    } else {
      val (next, res) = f(state)
      List(res) ++ lsAccum(f, condition, next)
    }
  }

  def sigmaBit(m:Int) = {
    val sb = bitExpand((m+Math.pow(2,blen).toLong-1)/2)
    sb ++ List.fill(blen-sb.length)(false)
  }

  def solver(a:(Int, Int)):String = {
    val n = hIsHorEv match {
      case 1 => ((a._1+a._2, a._1-a._2), "")
      case 0 => ((a._1+a._2-1, a._1-a._2-1), "R")
    }
    sigmaBit(n._1._1).zip(sigmaBit(n._1._2)).foldLeft(n._2)((acc, c)=> {
      c match {
        case (true, true) => acc+"R"
        case (true, false) => acc+"U"
        case (false, true) => acc+"D"
        case (false, false) => acc+"L"
      }
    }) + "\n"
  }

  def solverTest(a: String) = {
    a.toCharArray.zip(bits).foldLeft((0, 0))((acc, c) => {
      c._1 match {
        case 'R' => (acc._1+c._2, acc._2)
        case 'U' => (acc._1, acc._2+c._2)
        case 'D' => (acc._1, acc._2-c._2)
        case 'L' => (acc._1-c._2, acc._2)
      }
    })
  }

  def ans(): String = {
    oddOrEven match {
      case Left(x) => "-1"
      case Right(x) =>
        bits.length.toString + "\n" + bits.mkString(" ") + "\n" +
          l.foldLeft("")((acc,c) => acc+solver(c))
    }
  }
}

Measured memory_bytes: 74584
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

defeat_monster = 0
for i in range(n):
    defeat_monster += min(b[i], a[i])
    defeat_monster += min(b[i] - min(b[i], a[i]), a[i + 1])
    a[i + 1] -= min(b[i] - min(b[i], a[i]), a[i + 1])

print(defeat_monster)

Measured memory_bytes: 24344
a=0
num=[]
list_ans=[]
num.append([int(w) for w in input().split()])
while not num[a]==[0,0]:
    num.append([int(w) for w in input().split()])
    ran=[int(w) for w in range(num[a][0]+1)]
    ans=0
    
    for w in range(num[a][0]-2):
        
        for i in range(num[a][0]-2-w):
            
            for n in range(num[a][0]-2-i-w): 
                
                if ran[w+1]+ran[i+2+w]+ran[n+3+i+w]==num[a][1]:
                    ans+=1
    list_ans.append(ans)                
    a+=1
for i in list_ans:
    print(i)


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

using namespace std;

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define FOR(i, a, b) for(int i=(a);i<(b);i++)
#define REP(i, n) FOR(i, 0, n)
#define RFOR(i, a, b) for(int i=(a);i>=(b);i--)
#define RREP(i, n) RFOR(i, n, 0)
#define MFOR(i, m) for(auto i=(m).begin();i!=(m).end();i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((int)(x).size())

typedef long long int ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll << 50;

template<typename T>
void printv(vector<T> const& s) {
  REP(i, SZ(s)) {
    cout << s[i] << " ";
  }
  cout << endl;
}

int main () {
  cin.tie(0);
  cout << setprecision(10);

  int n; cin >> n;
  vll a2(n);
  multiset<ll> a1, a3;

  REP(i, n) {
    int tmp; cin >> tmp;
    a1.insert(tmp);
  }
  REP(i, n) cin >> a2[i];
  REP(i, n) {
    int tmp; cin >> tmp;
    a3.insert(tmp);
  }

  ll su1 = 0;
  for(auto i=a1.begin();i!=a1.end();i++) {
    su1 += *i;
  }

  vll sum1(n+1);
  sum1[0] = su1;
  // cout << 0 << ":" << su1 << endl;
  // printv(a1);
  REP(i, n) {
    if(*(a1.begin()) < a2[i]) {
      su1 += (a2[i] - *(a1.begin()));
      a1.erase(a1.begin());
      a1.insert(a2[i]);
    }
    sum1[i+1] = su1;
    // cout << su1 << endl;
  }


  
  ll su2 = 0;
  for(auto i=a3.begin();i!=a3.end();i++) {
    su2 += *i;
  }

  vll sum2(n+1);
  sum2[n] = su2;
  // cout << 0 << ":" << su2 << endl;
  // printv(a3);
  REP(i, n) {
    if(*(--(a3.end())) > a2[n-1-i]) {
      su2 += (a2[n-1-i] - *(--(a3.end())));
      a3.erase(--(a3.end()));
      a3.insert(a2[n-1-i]);
    }
    sum2[n-1-i] = su2;
    // cout << su2 << endl;
  }

  // printv(sum1);
  // printv(sum2);


  
  ll ma = -LINF;
  REP(i, n+1) {
    ma = max(ma, sum1[i] - sum2[i]);
  }

  cout << ma << endl;
}


Measured memory_bytes: 12032
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int R, C, K;
int val[3000][3000];
ll memo[3000][3000][4];
bool visited[3000][3000][4];
ll f(int x, int y, int z) {
	if (x >= R || y >= C) return 0;
	if (visited[x][y][z]) return memo[x][y][z];
	visited[x][y][z] = true;
	auto r = f(x+1, y, 0) + (z < 3 ? val[x][y] : 0);
	if (z < 3 && val[x][y]) r = max(r, f(x, y+1, z+1) + val[x][y]);
	r = max(r, f(x, y+1, z));
	return memo[x][y][z] = r;
}
int main() {
	cin >> R >> C >> K;
	for (int i = 0; i < K; ++ i) {
		int r, c, v;
		cin >> r >> c >> v;
		-- r; -- c;
		val[r][c] = v;
	}
	cout << f(0, 0, 0) << endl;
}


Measured memory_bytes: 355744
#include<algorithm>
#include<iostream>
#include<string.h>
#include<cstdio>
using namespace std;
int a[105];
int cmp(int a,int b)
{
    return a>b;
}
int main()
{
    int n,m;
    cin>>n>>m;
    for(int i=1;i<=n;i++)cin>>a[i];
    int ans=0;
    sort(a+1,a+1+n,cmp);
    for(int i=1;i<=m;i++)ans+=a[i];
    cout<<ans<<endl;
    return 0; 
}

Measured memory_bytes: 256
N, M = list(map(int, input().split()))
s = []

for i in range(M):
    s.append(list(map(int, input().split())))

p = list(map(int, input().split()))

ans = 0
for i in range(2 ** N):
    f = 0
    for j in range(M):
        cc = 0
        for k in range(1, len(s[j])):
            if (i >> (s[j][k] - 1)) % 2 == 1:
                cc += 1
        if cc % 2 != p[j]:
            f = 1
            break
    if f == 0:
        ans += 1

print(ans)






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

int main(){
    int N,a;
    scanf("%d",&N);
    int *n=(int*)malloc(sizeof(int)*N);
    for(int i=0;i<N-1;i++){
        scanf("%d",&a);
        n[a-1]++;
    }
    for(int i=0;i<N;i++){
        printf("%d\n",n[i]);
    }
}

Measured memory_bytes: 2516
#include "bits/stdc++.h"
using namespace std;
#define rep(i,a,n) for(ll i=a;i<n;i++)
#define ALL(s) s.begin(),s.end()
#define P pair<ll,ll>
#define vl vector<ll>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vvl vector<vector<ll>>
#define print(n) cout<<n<<endl
const int M=100010;
const int inf=1000000007;
const long long INF=1000000000000000007;
using ll=long long;
int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

vector<ll> enum_div(ll n)//nの約数を列挙
{
	vector<ll> ret;
	for(ll i=1;i*i<=n;++i){
		if(n%i==0){
			ret.push_back(i);
			if(i!=1 && i*i!=n){
				ret.push_back(n/i);
			}
		}
	}
	return ret;
}

int main(){
	ll n,m,a=0,b=0,ans=1;
	cin>>n>>m;
	vector<ll> v=enum_div(m);
	sort(ALL(v));
	rep(i,0,v.size()){
		if(v[i]>=n){
			ans=m/v[i];
			break;
		}
	}
	print(ans);
}

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

#define       sf                 scanf
#define       pf                 printf
#define       pb                 push_back
#define       sz                 200005
#define       inf                0x3f3f3f3f
#define       MOD                1000000007
#define       READ               freopen("in.txt", "r", stdin);
#define       WRITE              freopen("out.txt", "w", stdout);
#define       optimize           ios::sync_with_stdio(0);cin.tie(0);

using namespace std;

typedef       long long int      ll;

int main()
{
    //READ
    optimize

    int x;
    

    cin >> x;

    if(x==0) cout << 1 << endl;
    else cout << 0 << endl;

    return 0;
}


Measured memory_bytes: 3580
#include <stdio.h>

int main (void){
	int ss,h,m,s;
	scanf("%d",&ss);
	h = ss / 3600;
	m = (ss - h * 3600) / 60;
	s = (ss - h * 3600 - m * 60);
	printf("%d:%d:%d\n",h,m,s);
	return 0;
}

Measured memory_bytes: 592
import Data.List
import Control.Applicative

main = do
  [k,s] <- map read . words <$> getLine :: IO [Int]
  print $ sum
   $ map (\x -> 1-s+x+k+k)
          [max 0 (s-k-k)..min k (s-k)]
   ++ map (\x -> 1+s-x)
           [max 0 (s-k+1)..min k (s-0-0)]


Measured memory_bytes: 508
#include<cstdio>
#include<algorithm>
using namespace std;
int w[3][110], n, D[3][110];
int main() {
	int i, j;
	scanf("%d", &n);
	for (i = 1; i <= 2; i++)for (j = 1; j <= n; j++) {
		scanf("%d", &w[i][j]);
		D[i][j] = max(D[i - 1][j], D[i][j - 1]) + w[i][j];
	}
	printf("%d\n", D[2][n]);
}

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

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

int main() {
	ll x;
	cin >> x;
	ll a = 100;
	ll count = 0;
	while (a < x) {
		count++;
		a += a / 100;
	}
	cout << count << endl;
	return 0;
}


Measured memory_bytes: 3584
#include<iostream>
using namespace std;
int main(){
    int N;
    cin >> N;
    int cnt=0;
    for(int i=9;i>0;i--){
        for(int j=0;j<2;j++){
            if(N%i==0&&cnt<2){
                N = N / i;
                cnt++;
            }
        }
    }
    if(N==1) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<algorithm>
#include<cmath>
#include<iostream>
#include<vector>
#include<string>
using namespace std;
typedef long long ll;

#define REP(i, n) for(ll i=0;i<ll(n); i++)

int main(){
    int N, M;
    cin >> N >> M;
    cout << N * (N-1) / 2 + M * (M-1) / 2 << endl;

    return 0;
}


Measured memory_bytes: 3132
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
)

var sc *bufio.Scanner

const BufferSize = 1024

func nextInt() int {
	if !sc.Scan() {
		panic(nil)
	}
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

var production bool

func debugf(format string, v ...interface{}) {
	if !production {
		fmt.Printf(format, v...)
	}
}

func GCD(a, b uint64) uint64 {
	for b != 0 {
		t := b
		b = a % b
		a = t
	}
	return a
}

func LCM(a, b uint64, integers ...uint64) uint64 {
	result := a * b / GCD(a, b)

	for i := 0; i < len(integers); i++ {
		result = LCM(result, integers[i])
	}

	return result
}

func answer(reader io.Reader, writer io.Writer) {
	sc = bufio.NewScanner(reader)
	buf := make([]byte, BufferSize)
	sc.Buffer(buf, 1e+6)
	sc.Split(bufio.ScanWords)
	n := nextInt()
	s := make([]int, n)

	for i := range s {
		s[i] = nextInt()
	}
	a := uint64(s[0])
	for i := range s {
		a = LCM(a, uint64(s[i]))
	}

	b := uint64(0)
	for i := range s {
		b += a / uint64(s[i])
	}

	ans := float64(a) / float64(b)

	_, _ = fmt.Fprintf(writer, "%.10f", ans)
}

func main() {
	production = true
	answer(os.Stdin, os.Stdout)
}


Measured memory_bytes: 640
#include "iostream"
#include <string.h>
using namespace std;
 
int main(){
 
  int N;
  double M;
  
  int A[101]={0};
  double all=0.0;
  int cnt=0;
  double a;
 
  cin >> N >> M;
  
  for(int i=1; i<=N ; i++){
   
    cin >> A[i];
    
   all+=A[i];
    
  }
 
  a = (all/(4*M));
  
  for(int i=1; i<=N ; i++){
 
    if((double)A[i] >= a) cnt++;
    
  }
  
  if(cnt >= M) cout << "Yes";
  else cout << "No";
  
  return 0;
  
}

Measured memory_bytes: 256
N,Q = map(int, input().split())

data = [0]*(N+1)
def add(k, x,y):
    while k <= N:
        data[k] += y
        k += k & -k
    x+=1
    while x <= N:
        data[x] -= y
        x += x & -x
def get(k):
    s = 0
    while k:
        s += data[k]
        k -= k & -k
    return s
for i in range(Q):
    t = list(map(int, input().split()))
    if t[0] == 1:
        print(get(t[1]))
    else:
        add(t[1],t[2],t[3])


Measured memory_bytes: 8440
import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
# def LF(): return [float(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  x=I()
  if 30<=x:
    return 'Yes'
  return 'No'

# main()
print(main())


Measured memory_bytes: 10740
using System;
class test{
    static void Main(){
        int w,h,x,y,r;
        string[] str = Console.ReadLine().Split(' ');
        w=int.Parse(str[0]);
        h=int.Parse(str[1]);
        x=int.Parse(str[2]);
        y=int.Parse(str[3]);
        r=int.Parse(str[4]);
        if(x-r>=0&&x+r<=w&&y-r>=0&&y+r<=h){
            Console.WriteLine("Yes");
        }else
        {
            Console.WriteLine("No");
        }
    }
}


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

int main() {
  int K,S;
  cin >> K >> S;
  int count =0;
  
  for(int i=0;i<K+1;i++){
    for(int j=0;j<K+1;j++){
      if(0<=S-i-j&&S-i-j<=K) count++;
    }
  }
  cout << count << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define inf INT_MAX
#define INF LLONG_MAX
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
#define vi vector<int>
#define IP pair<int,P>
#define PI pair<P,int>
#define PP pair<P,P>
#define Yes(f){cout<<(f?"Yes":"No")<<endl;}
#define YES(f){cout<<(f?"YES":"NO")<<endl;}


signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(20);

  int h,w,n;
  cin>>h>>w>>n;
  int ans=0;
  int s=0;
  while(s<n){
    if(h>w){
      s+=h;
      w--;
    }else{
      s+=w;
      h--;
    }
    ans++;
  }

  cout<<ans<<endl;


}

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

using namespace std;

int64_t five(int64_t n,int64_t k){
  if(k > n)return 0;
  int64_t res = 0;
  res += n / k;
  res += five(n,k*5);
  return res;
}

int main(){
  int64_t n,res = 0;
  cin >> n;
  if(n & 1){
    cout << 0;
    return 0;
  }
  res = five(n,10);
  cout << res;
  return 0;
}

Measured memory_bytes: 256
#n = int(input())
#s = input()
#n, k= map(int,input().split())
#da = list(map(int,input().split()))
class UnionFind:
    def __init__(self, n):
        self.size = n
        self.par = [i for i in range(n)]
        self.rank = [0 for i in range(n)]
    def root(self, x):
        if self.par[x] != x:
            self.par[x] = self.root(self.par[x])
        return self.par[x]
    def unite(self, x, y):
        if self.root(x) == self.root(y):
            return
        if self.rank[x] > self.rank[y]:
            self.par[self.root(y)] = self.root(x)
        else:
            self.par[self.root(x)] = self.root(y)
        if self.rank[x] == self.rank[y]:
            self.rank[x]+=1
    def check(self, x, y):
        return self.root(x) == self.root(y)

n,m,k = map(int,input().split())
uf = UnionFind(n)
ans = [0 for i in range(n)]
for i in range(m):
    a,b = map(int,input().split())
    a-=1
    b-=1
    uf.unite(a,b)
    ans[a]-=1
    ans[b]-=1
co = [0 for i in range(n)]
for i in range(n):
    co[uf.root(i)]+=1
for i in range(n):
    ans[i] += co[uf.root(i)]-1
for i in  range(k):
    c,d = map(int,input().split())
    if uf.check(c-1,d-1):
        ans[c-1]-=1
        ans[d-1]-=1
for i in range(n):
    if i == n-1:
        print(ans[i])
    else:
        print(ans[i],end=' ')

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

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<=(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define Eback(s) s.erase(s.end()-1,s.end())
#define rev(v) reverse(all(v))
#define minvec(v) *min_element(all(v))
#define maxvec(v) *max_element(all(v))
#define sumvec(v) accumulate(all(v),0)
#define pb push_back
#define pf push_front
#define mod 1000000007
#define m_p make_pair
#define DOUBLE fixed << setprecision(15)
#define OK puts("OK")
#define OK1 puts("OK1")
#define OK2 puts("OK2")
#define SIZE(s) (int)s.size()
#define INF ((1LL<<62)-(1LL<<31))
#define zero(x,n) setw(x) << setfill('0') << n

typedef long long ll;

typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<double> vd;
typedef vector<char> vc;
typedef vector<string> vs;

typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpii;
typedef vector<pair<ll,ll>> vpll;

const double pi = acos(-1.0);

template<class A, class B>
ostream& operator<<(ostream& ost, const pair<A, B>&p) {
	ost << "{" << p.first << ", " << p.second << "} ";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost, const vector<T>&v) {
	ost << "{";
	for (int i = 0; i<(int)v.size(); i++) {
		if (i)ost << " ";
		ost << v[i];
	}
	ost << "} \n";
	return ost;
}

template<class A, class B>
ostream& operator<<(ostream& ost, const map<A, B>&v) {
	ost << "{";
	for (auto p:v) {
		ost << "{" << p.first << ", " << p.second << "} ";
	}
	ost << "} ";
	return ost;
}

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

ll gcd(ll x, ll y) {return __gcd(x,y);}
ll lcm(ll x, ll y) {return x/__gcd(x,y)*y;}

int main()
{
	ll a,b,c;
	cin >> a >> b >> c;
	cout << a+b+c-max({a,b,c}) << endl;
	return 0;
}

Measured memory_bytes: 256
//file_name:ABC85_B.cpp
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
const int MX = 200005;

    // int scan
    /*
    int x;
    scanf("%d",&x);
    int y;
    scanf("%d",&y);
    int z;
    scanf("%d",&z);

    // matrix scan
    /*
    ll a[n] = {};
    rep(i,n){
        scanf("%lld",&a[i]);
    }
    */

    // string scan
    /*
    string s;
    cin >> s;
    */


int main() {
    int n;
    scanf("%d",&n);
    ll a[n] = {};
    rep(i,n){
        scanf("%lld",&a[i]);
    }
    sort(a,a+n);


    ll ans = 1;

    rep(i,n-1){
        if(a[i]!=a[i+1]){
            ans++;
        }
    }

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



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


int mod(string num, int a) { 
    int res = 0; 
    for (int i = 0; i < num.length(); i++){ 
        res = (res*10 + (int)num[i] - '0') %a;
    } 
  
    return res; 
} 

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll k;
    cin>>k;
    ll num = 7;
    ll ans = -1;
    ll prod = 10;
    for(int i=0;i<=1e6;i++){
        if(num % k == 0){
            ans = i+1;
            break;
        }
        else{
            num = ((num*10) + 7)%k;
        }
    }
    cout<<ans;
    
}

Measured memory_bytes: 3612
N,M=map(int,input().split())
start=set()
goal=set()
for i in range(M):
    a,b=map(int,input().split())
    if a==1:
        start|={b,}
    if a==N:
        goal|={b,}
    if b==1:
        start|={a,}
    if b==N:
        goal|={a,}
if len(start&goal)>0:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')

Measured memory_bytes: 18992
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <string>
#include <set>

using namespace std;

#define int long long

signed main() {
	double n;

	cin >> n;

	double b = 0;

	vector<double>a(n);
	
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		a[i] = 1 / a[i];
		b = b + a[i];

	}

	cout << 1 / b;

	return 0;
}


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

#define endl '\n'
#define pb push_back

string s, t;
int dp[3003][3003];

int lcs(int a, int b){
  if(a==0 || b==0) return dp[a][b]=0;
  if(dp[a][b]!=-1) return dp[a][b];
  if(s[a-1]==t[b-1]) return dp[a][b]=lcs(a-1, b-1) + 1;
  return dp[a][b]=max({lcs(a-1,b), lcs(a, b-1), lcs(a-1, b-1)});
}

string ans;
void lcs_rec(int a, int b){
  //cout << a << " "  << b << endl;
  if(a==0 || b==0) return;
  int up=dp[a-1][b], left=dp[a][b-1], diag=dp[a-1][b-1], cur=dp[a][b];
  //cout << up << " " << left << " " << diag << " " << cur << endl;
  if(diag>=max(up, left)){
    if(diag<cur) {
      ans.pb(s[a-1]);
    }
    lcs_rec(a-1, b-1);
  }
  else if(up>=left) lcs_rec(a-1, b);
  else lcs_rec(a, b-1);
}

int main(){
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> s >> t;

  for(int i=0; i<=s.size(); i++){
    for(int j=0; j<=t.size(); j++){
      dp[i][j]=-1;
    }
  }

  lcs(s.size(), t.size());
  /*
  for(int i=0; i<=s.size(); i++){
    for(int j=0; j<=t.size(); j++){
      cout << dp[i][j] << "\t";
    }
    cout << endl;
  }
  */
  lcs_rec(s.size(), t.size());
  reverse(ans.begin(), ans.end());
  cout << ans << endl;
}

Measured memory_bytes: 35968
#include<stdio.h>

//探索再帰関数
bool tansaku(int count,int ans[],int a_max,int b_max,bool flg)
{
	//カウントが１０なら終了
	if (count == 10)
	{
		return true;
	}
	//trueじゃないなら探索を続ける
	if (flg == false)
	{
		//aの最大より新しいやつの方が大きいとき
		if (a_max < ans[count])
		{
			//aの上に格納
			a_max = ans[count];
			//答え配列のカウント変数をインクリメント
			count++;
			//再帰関数からの戻り値を格納
			bool hozon = tansaku(count,ans,a_max,b_max,flg);
			//trueを消さないように
			if (hozon == true)
			{
				flg = true;
			}
		}
		//bの最大より大きいとき
		if (b_max < ans[count])
		{
			//bに入力配列[count]を格納
			b_max = ans[count];
			count++;
			bool hozon = tansaku(count,ans,a_max,b_max,flg);
			if (hozon == true)
			{
				flg = true;
			}
		}
	}
	return flg;
}
int main(void)
{
	//回数を指定する変数
	int N = 0;
	//入力配列
	int a[10] = {0};
	//まとめて解答するflg
	bool ans_flg[100] = {false};
	scanf("%d",&N);
	for (int i = 0;i < N;i++)
	{
		//１０個のボールの入力
		scanf("%d %d %d %d %d %d %d %d %d %d",&a[0],&a[1],&a[2],&a[3],&a[4],&a[5],&a[6],&a[7],&a[8],&a[9]);
		//count = 0、入力配列、a_max = 0,b_max = 0,flg = falseを送る
		if (tansaku(0,a,0,0,false) == true)
		{
			ans_flg[i] = true;
		}
	}
	//N回文の解答を出力
	for (int i = 0;i < N;i++)
	{
		if (ans_flg[i] == true)
		{
			printf("YES\n");
		}
		else
		{
			printf("NO\n");
		}
	}
	return 0;
}

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

int max(int a,int b){
  if(a > b){
    return a;
  }else{
    return b;
  }
}

int main(){
  int N;
  scanf("%d",&N);
  int a[N+1][3];
  for(int i = 1;i <= N;i++){
    scanf("%d%d%d",&a[i][0],&a[i][1],&a[i][2]);
  }
  
  int w[N+1][3];
  for(int i = 0;i <= N;i++){
    w[i][0] = 0;
    w[i][1] = 0;
    w[i][2] = 0;
  }
  for(int i = 1;i <= N;i++){
    for(int j = 0;j < 3;j++){
      w[i][j] = max(w[i-1][(j+1)%3] + a[i][j], w[i-1][(j+2)%3] + a[i][j]);
    }
  }
  printf("%d\n",max(w[N][0],max(w[N][1],w[N][2])));
  return 0;
}


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

#define MAX 200000
#define SENTINEL 2000000000
typedef long long llong;

int L[MAX / 2 + 2], R[MAX / 2 + 2];

llong merge(int A[], int n, int left, int mid, int right)
{
    int i, j, k;
    llong cnt = 0;
    int n1 = mid - left;
    int n2 = right - mid;
    for (int i = 0; i < n1; i++)
        L[i] = A[left + i];
    for (int i = 0; i < n2; i++)
        R[i] = A[mid + i];
    L[n1] = R[n2] = SENTINEL;
    i = j = 0;
    for (int k = left; k < right; k++)
    {
        if (L[i] <= R[j])
        {
            A[k] = L[i++];
        }
        else
        {
            A[k] = R[j++];
            cnt += n1 - i;
        }
    }
    return cnt;
}

llong mergeSort(int A[], int n, int left, int right)
{
    int mid;
    llong v1, v2, v3;
    if (left + 1 < right)
    {
        mid = (left + right) / 2;
        v1 = mergeSort(A, n, left, mid);
        v2 = mergeSort(A, n, mid, right);
        v3 = merge(A, n, left, mid, right);
        return v1 + v2 + v3;
    }
    else
    {
        return 0;
    }
}

int main()
{
    int A[MAX], n, i;

    cin >> n;
    for (i = 0; i < n; i++)
        cin >> A[i];

    llong ans = mergeSort(A, n, 0, n);
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 4676
#include <cstdio>

int main(){
    int N;
    scanf("%d",&N);
    int p[N];
    int count=0;
    for (int i = 0; i < N; i++){
        scanf("%d",&p[i]);
        if(p[i]!=i+1) count++;
    }
    if(count==2||count==0) printf("YES");
    else printf("NO");
}

Measured memory_bytes: 128
#include <iostream>
#include <map>
#include <vector>
#include <queue>
#include <algorithm>
using namespace std;
static const int INF = 10000000;

int encode(const int *a)
{
  int n = 0;
  for (int i = 0; i < 8; i++) {
    n = n*8 + a[i];
  }
  return n;
}

void decode(int *a, int n)
{
  for (int i = 0; i < 8; i++) {
    a[7-i] = n%8;
    n /= 8;
  }
}

int main()
{
  int N;
  cin >> N;
  int c[8][8] = {{0}};
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      cin >> c[i][j];
    }
  }

  int init;
  {
    int a[8] = {0};
    for (int i = 0; i < N; i++) {
      a[i] = i;
    }
    init = encode(a);
  }
  map<int,int> dist;
  dist[init] = 0;
  priority_queue<pair<int,int> > q;
  q.push(make_pair(0, init));
  while (!q.empty()) {
    const int cost = -q.top().first;
    const int n = q.top().second;
    q.pop();
    if (dist[n] < cost) {
      continue;
    }
    int a[8];
    decode(a, n);
    for (int i = 0; i < N; i++) {
      for (int j = 0; j < N; j++) {
        swap(a[i], a[j]);
        const int cc = cost + c[i][j];
        const int m = encode(a);
        map<int,int>::iterator it = dist.find(m);
        if (it == dist.end() || cc < it->second) {
          dist[m] = cc;
          q.push(make_pair(-cc, m));
        }
        swap(a[i], a[j]);
      }
    }
  }
  int ans = 0;
  for (map<int,int>::const_iterator it = dist.begin(); it != dist.end(); ++it) {
    ans = max(ans, it->second);
  }
  cout << ans << endl;
  return 0;
}

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

using f64 = double;
using i64 = long long;

vector<i64> ariv;

int main() {
#ifdef HOME
	freopen("agc13c.in", "r", stdin);
	freopen("agc13c.out", "w", stdout);
#endif
	ios::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);
	i64 n, l, t, pos, dir, ord(0);

	cin >> n >> l >> t;
	ariv.resize(n);

	for (int i = 0; i < n; ++i) {
		cin >> pos >> dir;

		pos = pos + ((dir == 1 ? 1 : -1) * t);
		ord+= pos / l;
		pos%= l;
		if (pos < 0) {
			ariv[i] = pos + l;
			--ord; }
		else
			ariv[i] = pos; }

	ord = (ord % n + n) % n;
	sort(begin(ariv), end(ariv));

	for (int i = 0; i < n; ++i)
		cout << ariv[(ord + i) % n] << '\n';

	return 0; }


Measured memory_bytes: 2048
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;}
typedef long long ll;
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N; cin >> N;
  vector<bool> dp(N+10, false);
  dp[0] = true;
  REP(i, N+1){
    if(dp[i]){
      dp[i+4] = true;
      dp[i+7] = true;
    }
  }
  if(dp[N]){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <random>
#include <cstdio>
#include <cmath>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
 
int main() {
    int n,q; cin >> n >> q;
    string s; cin >> s;
    vector<pair<int, int>> index(q);
    rep(i,q) {
        cin >> index[i].first >> index[i].second;
        index[i].first--; index[i].second--;
    }
    // 左にAがあるCの数を数える
    vector<int> cnt(n,0);
    for (int i = 1; i < n; i++)
    {
        if (s[i-1] == 'A' && s[i] == 'C')
        {
            cnt[i]++;
        }
        cnt[i] += cnt[i-1];
    }
    
    rep(i,q) {
        int ans = cnt[index[i].second] - cnt[index[i].first];
        cout << ans << endl;
    }
    return 0;
}

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

int main(){
  string s;
  cin>>s;
  int n=s.size();
  long long int p=0;
  vector<string> a(n);
  for(int i=0;i<n;i++){
    a.at(i)=s.at(i);
  }
  for (int tmp = 0; tmp < (1 << 9); tmp++) {
    bitset<9> u(tmp);
    string t=a.at(0);
    for(int i=0;i<n-1;i++){
      if(u.test(i)){
        t+=a.at(i+1);
      }
      else{
        long long int b=stoll(t);
        p+=b;
        t=a.at(i+1);
      }
    }
    long long int b=stoll(t);
    p+=b;
  }
  cout<<fixed<<setprecision(0);
  cout<<p/pow(2,10-n)<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <algorithm>
 
using namespace std;
int main(){
  int N=0;
  cin>>N;
  vector<int> vec(N);  
  for(int i=0;i<N;i++){
  cin>>vec.at(i);
  }
  sort(vec.begin(), vec.end());
  for(int i=0;i<N-1;i++){
  if(vec.at(i)==vec.at(i+1)){
  cout<<"NO"<<endl;
        return 0;
  }
  }
      cout<<"YES"<<endl;
  }

Measured memory_bytes: 1024
#include<cstdio>

inline void read(short &x){
	char c=getchar(); short cnt=0,fa=1;
	while(c>'9'||c<'0') c=getchar();
	while(c>='0'&&c<='9') cnt=(cnt<<1)+(cnt<<3)+c-'0',c=getchar();
	x=cnt*fa;
}

int main(){
	short n,m; read(n),read(m);
	std::printf("%d",(n-1)*(m-1));
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;
typedef long long ll;

struct int_hash {
    static uint64_t splitmix64(uint64_t x) {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

struct pair_hash {
    size_t operator()(pair<int, int> x) const {
        return int_hash{}(x.first) ^ (int_hash{}(x.second) << 16);
    }
};

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const ll MOD = 1000000007;
const ll INF = numeric_limits<ll>::max();
const int inf = 1e7;
const int MX = 100001; //check the limits, dummy

ll p(ll n, ll x) {
    ll ans = 1, cur = n;
    while(x) {
        if(x & 1) ans = (cur * ans) % MOD;
        cur = (cur * cur) % MOD;
        x >>= 1;
    }
    return ans;
}

struct Res {
    ll g, x, y;
};

Res modinv(ll a, ll b) {
    if(b == 0) return {a, 1, 0};
    Res prev = modinv(b, a % b);
    return {prev.g, prev.y, prev.x - a / b * prev.y};
}

ll ncr(ll n, ll r) {
    ll ans = 1, den = 1;
    for(int i = n; i > n - r; i--) ans = (ans * i) % MOD;
    for(int i = 2; i <= r; i++) den = (den * i) % MOD;
    ll inv = modinv(den, MOD).x;
    return (ans * inv) % MOD;
}

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

    ll n, a, b;
    cin >> n >> a >> b;
    ll x = p(2, n);
    ll y = ncr(n, a);
    ll z = ncr(n, b);
    cout << (x - y - z - 1 + MOD) % MOD << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(a,n) for (ll a = 0; a < (n); ++a)
using namespace std;
using ll = long long;
typedef pair<ll,ll> P;
typedef pair<P,ll> PP;
typedef vector<vector<ll> > Graph;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF = 1e18;

string l;
ll k;

const int mod = 1000000007;
//const int mod = 998244353;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

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

mint dp[100100][2];

int main(){
    cin >> l;
    k = l.size();
    dp[0][0]=1;
    for(int i=0;i<k;i++){
        if(l[i]=='1')dp[i+1][0]+=dp[i][0]*2;
        else dp[i+1][0]+=dp[i][0];
        dp[i+1][1]=dp[i][1]*3;
        if(l[i]=='1')dp[i+1][1]+=dp[i][0];
    }
    cout << dp[k][0] + dp[k][1] << endl;


    return 0;
}


Measured memory_bytes: 5324
typedef long long ll;
#include<bits/stdc++.h>
using namespace std;
ll maxl(ll a, ll b){ return ((a<b)?b:a);}
ll minl(ll a, ll b){ return ((a>b)?b:a);}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    string s;
    cin >> s;
    int count = 0;
    int ans = 0;
    for (int i=0;i<3;i++){
        if (s[i] == 'S'){
            count = 0;
            continue;
        }
        count++;
        ans = max(ans,count);
    }
    cout << ans << "\n";
}


Measured memory_bytes: 3636
#include <iostream>
#include<algorithm>
#include<sstream>
#include<cmath>
#include<vector>
#include<iomanip>
#include<map>
#include<set>
#include<queue>
using namespace std;
int dx[8] = { 1, 0, -1, 0, 1, -1, -1, 1 };
int dy[8] = { 0, 1, 0, -1, 1, 1, -1, -1 };
typedef long long ll;
#define rep(i,n) for(int i = 0; i < n;i++)
int main(void) {
	int n, m,sum = 0;cin >> n >> m;char c[50][50];
	rep(i, n) {
		rep(j, m) {
			cin >> c[i][j];
		}
	}
	rep(i, n) {
		rep(j, m) {
			if (c[i][j] == '.') {
				sum = 0;
				rep(k, 8) {
					int nx = j + dx[k];
					int ny = i + dy[k];
					if (nx < 0 || ny < 0 || nx >= m || ny >= n)  continue;
					if (c[ny][nx] == '#') sum++;
				}
				cout << sum;
			}
			else cout << c[i][j];
		}
		cout << endl;
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
	ll a,b,c,x,y,z,k,m=ll(1e18);
	cin>>a>>b>>c>>k;
	x=abs(a-b);
	y=a-b;
	z=b-a;
	//if(x%m)cout<<"Unfair\n";
	if(k%2)cout<<z<<endl;
	else cout<<y<<endl;
}

Measured memory_bytes: 256
def bfs(d,visit,i):
    q=[i]
    visit[i]=1
    count=1
    while(len(q)!=0):
        val=q.pop()
        for k in d[val]:
            if(visit[k]==0):
                count+=1
                visit[k]=1
                q.append(k)
    return count
    

n,m=map(int,input().split())
d=dict()
for i in range(1,n+1):
    d[i]=set()
for i in range(m):
    l,r=map(int,input().split())
    d[l].add(r)
    d[r].add(l)

visit=[0]*(n+1)

count=0
for i in range(1,n+1):
    if(visit[i]==0 and len(d[i])!=0):
        count=max(count,bfs(d,visit,i))
if(count==0):
    print(1)
else:
    print(count)



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

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define LOOP(i) while(i--)
#define PRINTALL(c) for(auto pitr=c.begin();pitr!=c.end();++pitr){cout<<*pitr;if(next(pitr,1)!=c.end())cout<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

ll powermod(ll a,ll b,ll m){
	if(b==0){
		return 1LL;
	}
	if(b%2){
		return (a*powermod(a,b-1LL,m))%m;
	}
	return powermod((a*a)%m,b/2LL,m);
}

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

	int K[3]={0,0,0};
	int P[3]={2,3,5};
	REP(i,3){
		int V=1000000;
		while(V){
			K[i]++;
			V /= P[i];
		}
	}
	vector<ll> H(1000001,0),S(1000002,0);
	for(int i=0;i<=K[0];i++){
		for(int j=0;j<=K[1];j++){
			for(int k=0;k<=K[2];k++){
				auto V = 1LL*powermod(2,i,atcoder_mod)*powermod(3,j,atcoder_mod)*powermod(5,k,atcoder_mod);
				if(V<=1000000LL){
					H[V]=1;
				}
			}
		}
	}
	for(int i=0;i<1000001;i++){
		S[i+1]=S[i]+H[i];
	}

	while(true){
		ll N=in();
		if(!N) break;

		ll M=in();

		out(S[M+1]-S[N]);
	}
	
	return 0;
}



Measured memory_bytes: 18212
//██████╗ ██╗   ██╗██╗      ██████╗ ███████╗
//██╔══██╗██║   ██║██║      ██╔══██╗██╔════╝
//██████╔╝██║   ██║██║█████╗██║  ██║█████╗
//██╔══██╗██║   ██║██║╚════╝██║  ██║██╔══╝
//██║  ██║╚██████╔╝██║      ██████╔╝███████╗
//╚═╝  ╚═╝ ╚═════╝ ╚═╝      ╚═════╝ ╚══════╝
#include <bits/stdc++.h>

// #pragma GCC target("sse,sse2,sse3,ssse3,sse4")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
using namespace std;

#define fst first
#define snd second
#define mp make_pair
// #define mt make_tuple
#define pb push_back
#define eb emplace_back

#define all(v) (v).begin(), (v).end()
#define sz(v) ((int)(v).size())
#define sqr(x) ((x) * (x))

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

#define next ajksdslk
#define prev aklsfjk

mt19937_64 mt_rand(chrono::system_clock::now().time_since_epoch().count());

template<typename T1, typename T2> inline bool upmax(T1& a, T2 b) { return (a < b ? (a = b, true) : false); }
template<typename T1, typename T2> inline bool upmin(T1& a, T2 b) { return (b < a ? (a = b, true) : false); }

const int maxn = (int) 3e5 + 100;
const int maxlog = 21;
const int base = 1e9 + 7;
const ld eps = (ld) 1e-9;
const ld PI = acos(-1.);
//const int pp = 41;
const int inf = 2e9;
const ll llinf = 1e18;

vector<int> f[101][101];
int a[101][101];

int b[101][101];
int c[101][101];

bool used[101];
vector<int> g[101];
int mt[101];

bool try_kuhn (int v) {
  if (used[v])  return false;
  used[v] = true;
  for (size_t i=0; i<g[v].size(); ++i) {
    int to = g[v][i];
    if (mt[to] == -1 || try_kuhn (mt[to])) {
      mt[to] = v;
      return true;
    }
  }
  return false;
}

int main() {
  // freopen("input.txt", "r", stdin);
  ios_base::sync_with_stdio(0);
  cin.tie(nullptr);

  int n, m;
  cin >> n >> m;

  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> a[i][j];
      a[i][j]--;
      f[i][a[i][j] / m].pb(a[i][j]);
    }
  }

  for (int j = 0; j < m; j++) {
    for (int i = 0; i < n; i++) 
      mt[i] = -1, g[i].clear();
    for (int i = 0; i < n; i++) {
      for (int k = 0; k < n; k++) {
        if ((int)f[k][i].size()) {
          g[i].pb(k);
        }
      }
    }
    for (int i = 0; i < n; i++) {
      memset(used, 0, sizeof(used));
      try_kuhn(i);
    }
    for (int i = 0; i < n; i++) {
      assert(mt[i] != -1);
      assert(f[i][mt[i]].size());
      b[i][j] = f[i][mt[i]].back();
      f[i][mt[i]].pop_back();
    }
  }

  for (int i = 0; i < n; i++) { 
    for (int j = 0; j < m; j++) {
      cout << b[i][j] + 1 << ' ';
    }
    cout << endl;
  }

  // return 0;
  for (int i = 0; i < n; i++) {
    int fnd=0;
    for (int j = 0; j < m; j++) {
      for (int k = 0; k < n; k++) {
        if (b[k][j] / m == i) {
          c[i][j] = b[k][j];
          fnd++;
        }
      }
    }
    assert(fnd);
  }
  for (int i = 0; i < n; i++) { 
    for (int j = 0; j < m; j++) {
      cout << c[i][j] + 1 << ' ';
    }
    cout << endl;
  }  
  return 0;
}

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

#define int long long int
#define main signed main()
#define die return 0

#define rep(i, n) for (int i = 0; i < (n); i++)
#define each(p, v) for (auto p = (v).begin(); p != (v).end(); p++)
#define all(v) (v).begin(), (v).end()
#define sum(v) accumulate(all(v), 0)
#define cinv(v, n) rep(i, n) cin >> v[i]
#define prec(n) fixed << setprecision(n)
#define odd(n) ((n) % 2)
#define even(n) (!((n) % 2))

#define INF 1e9
#define MOD 1e9 + 7

#define pb push_back
#define mt make_tuple
#define fi first
#define se second
#define vi vector<int>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>

using namespace std;

main {
  int a, b;
  cin >> a >> b;
  if (0 <= a) {
    cout << "Positive" << endl;
    die;
  }
  if (a < 0 && 0 <= b) {
    cout << "Zero" << endl;
    die;
  }
  cout << (odd(b - a) ? "Positive" : "Negative") << endl;
  die;
}


Measured memory_bytes: 256