akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define ALL(A) (A).begin(),(A).end()
#define ll long long
const ll mod = 1e9+7;
const ll INF = 2*1e18;
const int inf = 1e9+7;

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int A,B;
	cin >> A >> B;
	if(A>=0&&A<10 && B>=0&& B<10)cout << A*B << endl;
	else cout << -1 << endl;
}

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

using ll = long long;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define sz(v) (int)v.size()
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 MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
const char EOL = '\n';

void solve();

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

void solve() {
    int m;
    cin >> m;
    ll ans = 0;
    ll r = 0;
    ll d;
    ll c;
    REP(i, m) {
        cin >> d >> c;
        while (c >= 10) {
            ans += (ll)(d + 9) * (c / 10);
            c = c / 10 + c % 10;
        }
        REP(j, c) {
            r += d;
            ans++;
            if (r >= 10) {
                r = 1 + r % 10;
                ans++;
            }
        }
    }
    cout << ans - 1 << EOL;
}


Measured memory_bytes: 892
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;

int main() {
  int n, k;
  cin >> n >> k;
  cout << k * (int)pow(k - 1, n - 1) << endl;
  return 0;
}


Measured memory_bytes: 384
import sys
import heapq
import math
import fractions
import bisect
import itertools
from collections import Counter
from collections import deque
from operator import itemgetter
def input(): return sys.stdin.readline().strip()
def mp(): return map(int,input().split())
def lmp(): return list(map(int,input().split()))

n=int(input())
p=lmp()
q=lmp()
l=list(itertools.permutations([i for i in range(1,n+1)]))
print(abs(l.index(tuple(p))-l.index(tuple(q))))

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

using namespace std;

const int N = 100000 + 77;
int n , q , m , cur = 2;
long long a[N];
set < pair < long long , long long > > S;
int main() {
   scanf("%d %d" , & n , & q);
   a[1] = n;
   while(q --) {
      scanf("%lld" , a + cur);
      while(cur > 1 && a[cur - 1] > a[cur])
         swap(a[cur] , a[cur - 1]) , -- cur;
      ++ cur;
   }
   m = cur - 1;
   S.insert(make_pair(a[m] , 1));
   for(int i = m;i > 1;-- i) {
      vector < pair < long long , long long > > V;
      while(! S.empty()) {
         auto it = S.rbegin();
         long long f = (* it).first;
         long long s = (* it).second;
         if(f <= a[i - 1])
            break ;
         long long x = f / a[i - 1];
         long long y = f % a[i - 1];
         S.erase(make_pair(f , s));
         V.push_back(make_pair(a[i - 1] , x * s));
         V.push_back(make_pair(y , s));
      }
      for(auto x : V) {
         auto it = S.lower_bound(make_pair(x.first , - 1));
         if(it != S.end() && (* it).first == x.first)
            x.second += (* it).second , S.erase(it);
         S.insert(x);
      }
   }
   memset(a , 0 , sizeof(a));
   for(auto x : S)
      a[x.first] += x.second;
   for(int i = n;i > 0;-- i)
      a[i] += a[i + 1];
   for(int i = 1;i <= n;++ i)
      printf("%lld\n" , a[i]);
   return 0;
}


Measured memory_bytes: 14084
#include<stdio.h>
int main(){
  int N,K,answer,judge,k;
  scanf("%d%d",&N,&K);
  answer=1;
  k=K;
  while(1){
    judge=N/k;
    if(judge==0)
      break;
    else{
      k=k*K;
      answer=answer+1;
    }
  }
  printf("%d\n",answer);
  return 0;
}  
    

Measured memory_bytes: 128
require 'pp'
n, x = gets.split.map(&:to_i)
a = gets.split.map(&:to_i)
cnt = 0
(a.size-1).times do |i|
  if a[i] + a[i+1] > x
    if x >= a[i]
      cnt += a[i] + a[i+1] - x
      a[i+1] = x - a[i]
    else
      cnt += a[i+1]
      cnt += a[i] - x
      a[i+1] = 0
      a[i] = x
    end
  end
end
p cnt


Measured memory_bytes: 8828
# -*- coding: utf-8 -*-

N = int(input())
T = [0]*N

for i in range(N):
	T[i] = int(input())


#a, bの最大公約数を求める
def gcd(a, b):
	r = max(a, b) % min(a, b)
	


	if (r == 0):
		return min(a, b)

	else:
		return gcd(r, min(a, b))


#a, bの最小公倍数を求める
def lcm(a, b):
	return a * b // gcd(a, b)



#リストTの全要素の最小公倍数を求める
def LCM(T):
	l = len(T)



	if(l == 1):
		return T[0]

	elif(l == 2):
		return lcm(T[0], T[1])



	T1, T2 = [], []

	for i in range(l // 2):
		T1.append(T[i])

	for j in range(l - l // 2):
		T2.append(T[j + l // 2])



	return lcm(LCM(T1), LCM(T2))



print(LCM(T))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define ll long long int
#define ss second
#define ff first
#define Mem(x,val) memset(x,val,sizeof x)
#define pb push_back
#define all(v) v.begin(),v.end()
#define unik(v)  v.erase(unique(v.begin(),v.end()),v.end())
#define cerr(x) cerr << __LINE__ << " th Line : " << #x << " = " << x << "\n"
#define debug(a,b) cerr << #a<<" = "<<a<<"   |   "<<#b<<" = "<<b<<'\n'
#define endl '\n'
#define SZ(a) ((int)a.size())
using namespace std;
typedef pair<int, int> pi32;
typedef pair<ll, ll> pi64;
typedef vector<int> vi32;
typedef vector<ll> vi64;
typedef vector<pi32> vp32;
typedef vector<pi64> vp64;
const ll mod = 1e9 + 7;
const int MX = 2e5+7;
//vector<int>adj[MX];

int dist[MX];
int ans[MX];
int main()
{
      int n,m;
      cin>>n>>m;
      vector<vector<int>>adj(n+1);
      for(int i=0;i<m;i++){
		  int u,v;cin>>u>>v;
		  adj[u].pb(v);
		  adj[v].pb(u);
	  }
	  //for(int i=1;i<=n;i++){
		  //cout<<i<<" : "; 
		  //for(auto it:adj[i])cout<<it<<' ';
		  //cout<<endl;
	  //}
	   
	   for(int i=1;i<=n;i++)dist[i]=1e9;
	   dist[1]=0;
	   queue<int>q;q.push(1);
	   Mem(ans,0);
	   while(!q.empty()){
		   int node=q.front();
		   cerr(node);
		   q.pop();
		   for(auto child:adj[node]){
			   if(dist[child]!=1e9)continue;
			   dist[child]=dist[node]+1;
			   ans[child]=node;
			   q.push(child);
		   }
	   }
	   cout<<"Yes\n";
	   for(int i=2;i<=n;i++)cout<<ans[i]<<endl;
      
    return 0;
}


Measured memory_bytes: 11156
class priorityQueue {
  constructor() {
    this.keys = [];
    Number.prototype.parentIdx = function() { return (this- 1) >> 1; };
    Number.prototype.leftIdx = function() { return (this << 1) + 1; };
    Number.prototype.rightIdx = function() { return (this << 1) + 2; };
  }

  insert(key) { this.heapIncrease(this.keys.push(key) - 1); }

  heapIncrease(idx) {
    const keys = this.keys;
    for (let i=idx, p=idx.parentIdx(); i > 0 && keys[i] > keys[p]; i=p, p=i.parentIdx())
      keys[p] = [keys[i], keys[i] = keys[p]][0];
  }

  extract() {
    const res = this.keys[0];
    this.keys[0] = this.keys.pop();
    this.maxHeapify(0);
    return res;
  }

  maxHeapify(idx) {
    const keys = this.keys, n = keys.length;
    const innerMaxHeapify = (i) => {
      let left = i.leftIdx(), right = i.rightIdx(), largest = i;
      if (left < n && keys[left] > keys[largest]) largest = left;
      if (right < n && keys[right] > keys[largest]) largest = right;
      if (largest != i) {
        keys[largest] = [keys[i], keys[i] = keys[largest]][0];
        innerMaxHeapify(largest);
      }
    };
    innerMaxHeapify(idx);
  }
}

(function main() {
  const lines = require('fs').readFileSync('/dev/stdin', 'utf8').trim().split('\n').slice(0, -1);
  const queue = new priorityQueue();
  let str = '';
  lines.forEach(function(cmd) {
    switch(cmd.charAt(0)) {
      case 'i': queue.insert(Number(cmd.split(' ')[1])); break;
      case 'e': str += `${queue.extract()}\n`; break;
    }
  });
  process.stdout.write(str);
})();


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

int main()
{
	string s;
	int sum = 0;
	
	cin >> s;
	
	for(long unsigned int i = 0; i < s.length(); i++)
	{
		char c = s[i];
		sum += atoi(&c);
	}
	
	if(sum % 9 > 0)
	{
		cout << "No" << endl;
	}
	else
	{
		cout << "Yes" << endl;
	}
	
	return 0;
}


Measured memory_bytes: 3764
import java.util.Scanner;

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

		int problemCount = sc.nextInt();
		int[] problemSolveSpeed = new int[problemCount];

		for (int i = 0; i < problemCount; i++) {
			problemSolveSpeed[i] = sc.nextInt();
		}

		int drinkCount = sc.nextInt();

		int[] ans = new int[drinkCount];
		for (int i = 0; i < drinkCount; i++) {
			int total = 0;
			int[] tmp = problemSolveSpeed.clone();//クローンにしないとproblemSolveSpeedも変わる

			int p = sc.nextInt();
			int x = sc.nextInt();
			tmp[p - 1] = x;
			for (int k : tmp) {
				total += k;
			}
			ans[i] = total;
		}
		sc.close();
		for (int i : ans) {
			System.out.println(i);
		}
	}
}

Measured memory_bytes: 22612
//2^tのペアをtが大きい方から貪欲に作る？
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#define int long long
#define rep(i, n) for(i = 0; i < n; i++)
using namespace std;
typedef pair<int, int> P;

int n;
int a[200000];
map<int, int> mp;

signed main() {
	int i;
	
	cin >> n;
	rep(i, n) {
		cin >> a[i];
		if (mp.find(a[i]) == mp.end()) mp[a[i]] = 0;
		mp[a[i]]++;
	}
	
	int ans = 0;
	for (int t = 30; t >= 0; t--) {
		map<int, int>::iterator it;
		for (it = mp.begin(); it != mp.end(); it++) {
			int num = (1LL << t) - (*it).first;
			if (mp.find(num) == mp.end()) continue;
			int pairCnt = min(mp[num], (*it).second);
			if (num == it->first) { pairCnt = it->second / 2; }
			ans += pairCnt;
			mp[num] -= pairCnt;
			it->second -= pairCnt;
			
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 14336
#include <iostream>
#include <iomanip>

#include <cmath>
#define EPS (1e-10)
#define equals(a, b) (fabs((a) - (b)) < EPS)

using namespace std;

class Point {
public:
	double x, y;
	Point(double x = 0, double y = 0) : x(x), y(y) {}

	Point operator + (Point p) { return Point(x + p.x, y + p.y); }
	Point operator - (Point p) { return Point(x - p.x, y - p.y); }
	Point operator * (double a) { return Point(a*x, a*y); }
	Point operator / (double a) { return Point(x / a, y / a); }

	double norm() { return x*x + y*y; }
	double abs() { return sqrt(norm()); }

	bool operator < (const Point &p) const {
		return x != p.x ? x < p.x : y < p.y;
	}

	bool operator == (const Point &p) const {
		return fabs(x - p.x) < EPS && fabs(y - p.y) < EPS;
	}
};

typedef Point Vector;

struct Segment {
	Point p1, p2;
};

typedef Segment Line;

class Circle {
public:
	Point c;
	double r;
	Circle(Point c = Point(), double r = 0.0) : c(c), r(r) {}
};


double dot(Vector a, Vector b) {
	return a.x*b.x + a.y*b.y;
}

double cross(Vector a, Vector b) {
	return a.x*b.y - a.y*b.x;
}

bool isOrthogonal(Vector a, Vector b) {
	return equals(dot(a, b), 0.0);
}

bool isOrthogonal(Point a1, Point a2, Point b1, Point b2) {
	return isOrthogonal(a1 - a2, b1 - b2);
}

bool isOrthogonal(Segment s1, Segment s2) {
	return isOrthogonal(s1.p1, s1.p2, s2.p1, s2.p2);
}

bool isParallel(Vector a, Vector b) {
	return equals(cross(a, b), 0.0);
}

bool isParallel(Point a1, Point a2, Point b1, Point b2) {
	return isParallel(a1 - a2, b1 - b2);
}

bool isParallel(Segment s1, Segment s2) {
	return isParallel(s1.p1, s1.p2, s2.p1, s2.p2);
}

Point project(Segment s, Point p) {
	double alpha = dot(p - s.p2, s.p1 - s.p2) / (s.p1 - s.p2).norm();
	return s.p2 + (s.p1 - s.p2)*alpha;
}

int main() {
	Line l;
	cin >> l.p1.x >> l.p1.y >> l.p2.x >> l.p2.y;
	int q;
	cin >> q;
	Point p;
	for (int i = 0; i < q; i++) {
		cin >> p.x >> p.y;
		Point x = project(l, p);
		cout << fixed << setprecision(15);
		cout << x.x << " " << x.y << endl;
	}

	return 0;
}

Measured memory_bytes: 1300
#include <bits/stdc++.h>
#define _USE_MATH_DEFINES
#include <math.h>
#define PI 3.14159265358979323846264338327950L
using namespace std;
int main()
{
    int a,b,h,m;
    long double rad1,rad2,rad,d;
    cin>>a>>b>>h>>m;
    rad2 = 2.0*PI*(long double)m * 6.0/360.0;
    rad1 = 2.0*PI*((long double)h * 30.0 + 0.5*(long double)m)/360.0;
    
    if(rad2>rad1)
    {
        if(rad2 - rad1 > PI)
        {
            rad = PI*2.0 - (rad2 - rad1);
        }else{
            rad = rad2 - rad1;
        }
    }else{
        if(rad1 - rad2 > PI)
        {
            rad = PI*2.0 - (rad1 - rad2);
        }else{
            rad = rad1 - rad2;
        }
    }
    if(rad == 0.0)
    {
        if(a>b)
        {
            d = (long double)(a-b);
        }else{
            d = (long double)(b-a);
        }
    }else if(rad == PI)
    {
        d = (long double)(a+b);
    }else{
        d = sqrt((long double)(a*a)+(long double)(b*b)-2.0*(long double)(a)*(long double)(b)*cosl(rad));
    }
    
    rad = rad1 - rad2;
    // long double rsq = (long double)(a * a + b * b) - (long double)(2 * a *
    // b) * cosl(rad);

    d = (long double)(a*a+b*b)-(long double)(2*a*b*cosl(rad));
    printf("%20.20Lf\n", sqrtl(d));
    // cout<<sqrt(d)<<endl;
}

Measured memory_bytes: 4140
n,m = map(int,input().split())
s = [list(map(int,input().split())) for i in range(m)]
p = list(map(int,input().split()))
ans = 0
for i in range(2 ** n):
    t = ['off'] * n
    x = i
    j = 0
    while x > 0:
        if x % 2 != 0:
            t[j] = 'on'
        x = x // 2
        j += 1
    flg = True
    for j in range(m):
        z = 0
        for k in range(1,s[j][0]+1):
            if t[s[j][k]-1] == 'on':
                z += 1
        if z % 2 != p[j]:
            flg = False
            break
    if flg:
        ans += 1
print(ans)

Measured memory_bytes: 9148
n = int(input())
nums =list(map(int,input().split()))

import copy

ans_num = copy.deepcopy(nums)

for i in range(n):
    f_n = nums[i]
    ans_num[f_n -1] = i +1
    
map(str,ans_num)
print(' '.join(map(str,ans_num)))

Measured memory_bytes: 18756
"use strict";
function Main(input) {
  input = input.split("\n");
  let n = Number(input[0]);
  let place_array = input[1].split(" ").map(Number);
  let min = 0;
  for (let cp = 0; cp < 100; cp++) {
    let tmp_total = 0;
    for (let i = 0; i < n; i++) {
      tmp_total += Math.pow((cp - place_array[i]), 2);
      //console.log(`${point} - ${place_array[index]}の2乗 = ${(point - place_array[index]) ** 2}`);
    }
    if (cp === 0) min = tmp_total;
    min = min < tmp_total ? min : tmp_total;
  }
  console.log(min);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

typedef long long ll;
typedef long double ld;

int prod(int x){
    if(x%10 < 2 || x/10 < 2) return 150;
    return (x%10)*(x/10);
}

int main(){
    ios_base::sync_with_stdio(false);
    cout.precision(10);
    cout<<fixed;

    int m, d;
    cin >> m >> d;
    int cnt = 0;
    for(int i=10; i<=d; i++){
        if(prod(i) <= m) cnt++;
    }
    cout << cnt;
    return 0;
}


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

int search(int A[], int n, int key){
    int i=0;
    A[n]=key;
    while(A[i]!=key)i++;
    return i != n;
}

int main(){
    int i, n, A[10000+1], q, key, sum=0;
    
    scanf("%d",&n);
    for(i=0; i<n; i++)scanf("%d",&A[i]);
    
    scanf("%d",&q);
    for(i=0; i<q; i++){
        scanf("%d",&key);
        if(search(A, n, key))sum++;
    }
    printf("%d\n",sum);
    return 0;
}


Measured memory_bytes: 3220
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<iostream>
#include<algorithm>

using namespace std;

typedef long long ll;
ll ans1, ans2;

int main(){
	int n, m, a, b;
	while(~scanf("%d %d %d %d", &n, &m, &a, &b)){
		ans1 = n * m;
		ans2 = a * b;
		if(ans1 > ans2) cout << ans1 << endl;
		else  cout << ans2 << endl;
	}
	return 0;
}

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

board = [[1]*W for _ in range(H)]

for _ in range(N):
    x, y, a = map(int, input().split())
    t = 0
    b = H
    l = 0
    r = W
    if a == 1:
        r = x
    if a == 2:
        l = x
    if a == 3:
        b = y
    if a == 4:
        t = y
    
    for h in range(t, b):
        for w in range(l, r):
            board[h][w] = 0
    
print(sum([sum(r) for r in board]))

Measured memory_bytes: 9204
n = int(input())
A = [*map(int, input().split())] + [0]
yen = 1000
kabu_yen = kabu_n = 0
for i in range(1,n+1):
    if A[i-1] < A[i]: # buy
        m = yen // A[i-1]
        cost = m * A[i-1]
        yen -= cost
        kabu_yen += cost
        kabu_n += m
    elif A[i-1] > A[i]: # sell
        yen += A[i-1] * kabu_n
        kabu_yen = 0
        kabu_n = 0
print(yen)


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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl




typedef long long ll;
const ll mod = 1e9+7;
const int maxn = 1e6 + 5;


int n;
vector<ll> a;
int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);  cout.tie(0);
    cin>>n;
    a.resize(n);
    for (int i=0; i<n; i++) {
	cin>>a[i];
    }
    sort(a.begin(), a.end());
    if (a.front()==0) out(0);

    ll res=a.front();
    for (int i=1; i<n; i++) {
	ll top = 1e18;
	if (res>top/a[i]) out(-1);
	res=res*a[i];
    }
    out(res);

    return 0;
}


Measured memory_bytes: 3916
N=int(input())
for h in range(1,3501):
    for n in range(1,3501):
        if 4*h*n-(n+h)*N>0 and (h*n*N)%(4*h*n-(n+h)*N)==0:
            print(n,h,(h*n*N)//(4*h*n-(n+h)*N))
            exit()


Measured memory_bytes: 66604
n = int(input())
b = [0] + list(map(int, input().split()))
a = [0] * (n + 1)

a[1] = b[1]
a[-1] = b[-1]

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

print(sum(a))

Measured memory_bytes: 9112
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll> Pll;
typedef pair<P,P> PP;
#define rep(i,a,n) for(int i = a;i < n;i++)
#define repr(i,a,n) for(int i = n-1;i >= a;i--)
#define sort(x) sort(ALL(x))
#define ALL(v) v.begin(), v.end()
#define LINF (ll)1e17
#define INF (int)1e9
#define MOD (ll)1e9+7
#define sMOD 1e5
#define fs first
#define sc second

ll gcd(ll a,ll b){
	if(!b) return a;
	return gcd(b,a%b);
}

void YNout(bool check){
	if(check)cout << "Yes" << endl;
	else cout << "No" << endl;
	
	return;
}

void Yayout(bool check){
	if(check) cout << "Yay!" << endl;
	else cout << ":(" << endl;
	
	return;
}

/*
template <typename T>
void vecout(vector<T>& vecout_vec){
	
	rep(i,0,vecout_vec.size()){
		cout << vecout_vec.at(i) << endl;
	}
	
	return ;
}

template <typename T>
void vecin(vector<T>& vecin_vec, ll n){
	
	ll temp ;
	
	rep(i,0,n){
		cin >> temp;
		vecin_vec.push_back(temp);
		
	}
}

template <typename T>
void in(T& literal_in, T& literal_in2, ...){
	cin >> literal_in;
	in(literal_in2, ...);
	
	return;
}

template <typename T>
void in(T& literal_in){
	
	cin >> literal_in;
	
	return;
}

template <typename T>
void out(T& literal_out, T& literal_out2, ...){
	cout << literal_out << endl;
	out(literal_out2, ...);
	
	return;
}

template <typename T>
void out(T& literal_out){
	
	cout << literal_out << endl;
	
	return;
}
*/
signed main(){
	ll n,m;
	cin >> n >> m;
	ll k[n] = {};
	vector<ll> s[m];
	ll p[m] = {};
	
	rep(i,0,m){
		cin >> k[i];
		rep(j,0,k[i]){
			ll temp;
			cin >> temp;
			s[i].push_back(temp);
		}
	}
	
	rep(i,0,m){
		cin >> p[i];
	}
	
	ll ans = 0,cnt = 0;
	bool flag = true;
	rep(i,0,(1 << n)){
		flag = true;
		rep(j,0,m){
			cnt = 0;
			rep(l,0,k[j]){
				ll temp = i;
				if(temp >> (s[j][l]-1) & 1){
					cnt++;
				}
			}
			
			if(cnt % 2 != p[j]) flag = false;
		}
		if(flag) ans++;
	}
	
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(a)  (a).begin(),(a).end()
#define PI 3.14159265358979
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll mod = 1e9+7LL;

long long dpa[100010];
long long dpb[100010];
long long dpc[100010];

int main() {
    int N; cin >> N;
    vector<int> a(N);
    vector<int> b(N);
    vector<int> c(N);
    rep(i, N) cin >> a.at(i) >> b.at(i) >> c.at(i);
    
    rep(i, 100010){
        dpa[i] = 0;
        dpb[i] = 0;
        dpc[i] = 0;
    }
    dpa[0] = a[0];
    dpb[0] = b[0];
    dpc[0] = c[0];

    for(int i = 1; i < N; ++i){
        dpa[i] = a[i] + max(dpb[i-1], dpc[i-1]);
        dpb[i] = b[i] + max(dpa[i-1], dpc[i-1]);
        dpc[i] = c[i] + max(dpa[i-1], dpb[i-1]);
    }

    cout << max(dpa[N-1], max(dpb[N-1], dpc[N-1])) << endl;
}

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

int main()
{
  int N;
  long long K;
  cin >> N >> K;
  vector<int> A(N);
  for (int i = 0; i < N; i++)
  {
    cin >> A.at(i);
    A.at(i)--;
  }
  vector<int> B;
  int index = 0;
  int count = 0;
  set<int> gone;
  gone.insert(0);
  long long right = 0, left = 0;
  while (count < N)
  {
    B.push_back(A.at(index));
    // cout << "B = " << B.at(count) << endl;
    if (gone.count(A.at(index)))
    {
      right = A.at(index);
      left = count;
      break;
    }
    gone.insert(A.at(index));
    index = A.at(index);
    count++;
  }
  if (right == 0) right = -1;
  // cout << "count = " << count << endl;
  // cout << "right = " << right << endl;
  for (int i = 0; i < count; i++)
  {
    if (B.at(i) == right)
    {
      right = i;
      break;
    }
  }
  int ans = 0;
  if (left+1 >= K) ans = B.at(K-1);
  else
  {
    // cout << "left = " << left << ", right = " << right << endl;
    long long loop = left - right;
    // cout << "loop = " << loop << endl;
    long long pos;
    if (loop) pos = right + (K-right-1) % loop;
    else pos = right;
    // cout << "pos = " << pos << endl;
    if (pos != -1) ans = B.at(pos);
    else ans = 0;
  }
  cout << ans+1 << endl;
}


Measured memory_bytes: 13904
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <string.h>
#include <vector>
#include <functional>
#include <queue>
#include <unordered_set>
#include <climits>
#include <set>
#include <list>
#include <cmath>
#include <map>

using namespace std;
typedef long long ll;

int main()
{
	string S, T;
	cin >> S >> T;
	int ans = 1000000;
	for(int i = 0; i <= S.length() - T.length(); i++){
		int count = 0;
		for(int j = 0; j < T.length(); j++){
			if(S[i+j] != T[j]){
				count++;
			}
		}
		ans = min(ans, count);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3628
N,M=map(int,input().split())
P=10**9+7
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr
a=factorization(M)
ans=1
for x in a:
    c=1
    for i in range(x[1]):
        c*=(N+x[1]-i-1)
    for i in range(x[1]):
        c//=(i+1)
    ans*=c
    ans=ans%P
if M==1:
    ans=1
print(ans)

Measured memory_bytes: 38580
#include <iostream>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <algorithm>
using namespace std;

template <typename T = int>
T in();

int main() {
    int a(in()), b(in()), k(in());
    int abk = max(a, b);
    int j = 0;
    int ans = abk;
    int i;
    for (i = abk; 0 < i; i--) {
        if ((a % i) == 0 && (b % i) == 0) j++;
        if (j == k) break;
    }
    cout << i << endl;

    return 0;
}

template <typename T = int>
T in() {
    T temp;
    cin >> temp;
    return temp;
}



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

#define int long long
#define ll long long
#define f1(i,a,b) for(i=a;i<b;i++)
#define f2(i,a,b) for(i=a;i>=b;i--)
#define endl '\n'
#define pb push_back
#define gp " "
#define ff first
#define ss second
#define mp make_pair

const int mod=1000000007;
int i,j;
ll temp;
int a[1000001];
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    memset(a,0,1000001*sizeof(int));
    int s;
    cin>>s;
    a[s]=1;
    int counter=1;
    while(1)
    {
        counter++;
        int b;
        if(s&1)
        b=3*s+1;
        else
        b=s/2;
        if(a[b]==1)
        {
            cout<<counter;
            break;
        }
        s=b;
        a[b]=1;
    }

    return 0;
}


Measured memory_bytes: 8064
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n];
		int count = 0;

		for (int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
		}

		int flag=1;

		loop:
		while (flag==1) {
			for (int i = 0; i < n; i++) {
				if (a[i] % 2 == 1) {
					flag=0;
					break loop;
				} else {
					a[i] /= 2;
				}
			}
			count++;
		}

		System.out.print(count);
	}
}

Measured memory_bytes: 21844
#include <stdio.h>

int main(void)
{
	int tyou=0, hisi=0;
	int a, b, c;
	
	while(scanf("%d,%d,%d", &a, &b, &c)!=EOF) {
		if(c*c==a*a+b*b) tyou++;
		if(a==b) hisi++;
	}
	
	printf("%d\n%d\n", tyou, hisi);
	
	return 0;
}


Measured memory_bytes: 596
#include <bits/stdc++.h>
#define ALL(x) begin(x), end(x)

using namespace std;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using ll = int64_t;
constexpr int MOD = 1000000007;

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

    int n, m, tmp;
    cin >> n >> m;
    set<int> a;
    for (int i = 1; i < m + 1; i++) {
        cin >> tmp;
        a.insert(tmp);
    }

    int dp[n + 1];
    dp[0] = 1;

    auto it = a.find(1);
    if (it != a.end()) {
        dp[1] = 0;
    } else {
        dp[1] = 1;
    }

    for (int i = 2; i < n + 1; i++) {
        it = a.find(i);
        if (it == a.end()) {
            dp[i] = (dp[i - 1] + dp[i - 2]) % MOD;
        } else {
            dp[i] = 0;
        }
    }

    cout << dp[n];

    return 0;
}


Measured memory_bytes: 5376
#include <iostream>
#include <vector>

int main(int argc, char *argv[]) {
  int n;
  std::cin >> n;
  std::vector<int> a(n);
  for (int i = 0; i < n; ++i)
    std::cin >> a.at(i);

  int j = 1, count = 0;
  for (int i = 0; i < n; ++i) {
    if (a.at(i) != j) {
      ++count;
      continue;
    }
    ++j;
  }

  if (count < n)
    std::cout << count << std::endl;
  else
    std::cout << -1 << std::endl;
}


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

int main() {
  int n; cin >> n;
  
  vector<int> d(n);
  for(int i=0; i<n; i++){
    cin >> d.at(i);
  }
  sort(d.begin(), d.end());
  
  int count = 1;
  for(int i=0; i<n-1; i++){
    if(d.at(i) < d.at(i+1)) count++;
    else continue;
  }
  
  cout << count << endl;
}




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

#define INF 200000
int main(){
  typedef pair<int,int> Edge;
  typedef pair<int,vector<Edge> > Node;
  priority_queue<Node,vector<Node>,greater<Node> >que;
  int n,m;
  int starts,goal,maxm,hasira;
  int a,b,c,d;
  Node node[21];
  cin>>n>>m;
  for(int i=0;i<m;i++){
    scanf("%d,%d,%d,%d",&a,&b,&c,&d);
    node[a].second.push_back(Edge(c,b));
    node[b].second.push_back(Edge(d,a));
  }
  scanf("%d,%d,%d,%d",&starts,&goal,&maxm,&hasira);
  for(int i=1;i<=n;i++){
    node[i].first=INF;
  }
  node[starts].first=0;
  que.push(node[starts]);
  while(!que.empty()){
    Node n=que.top();que.pop();
    for(int i=0;i<n.second.size();i++){
      if(node[n.second[i].second].first>n.first+n.second[i].first){
	node[n.second[i].second].first=n.first+n.second[i].first;
	que.push(node[n.second[i].second]);
      }
    }
  }
  int koutuuhi=node[goal].first;

    for(int i=1;i<=n;i++){
    node[i].first=INF;
  }
  node[goal].first=0;
  que.push(node[goal]);
  while(!que.empty()){
    Node n=que.top();que.pop();
    for(int i=0;i<n.second.size();i++){
      if(node[n.second[i].second].first>n.first+n.second[i].first){
	node[n.second[i].second].first=n.first+n.second[i].first;
	que.push(node[n.second[i].second]);
      }
    }
  }
  koutuuhi+=node[starts].first;
  cout<<maxm-koutuuhi-hasira<<endl;
}

Measured memory_bytes: 1252
import java.util.*;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		int sum=0;

		for(int i=1; i<n+1; i++) {
			sum += i;
		}

		System.out.print(sum);

		sc.close();
	}

}

Measured memory_bytes: 21844
n = int(input())
s = []
t = []
for _ in range(n):
    name,time = map(str,input().split())
    s.append(name)
    t.append(int(time))
target = input()
start = s.index(target)
ans = 0
for i in range(start+1,n):
    ans += t[i]
print(ans)

Measured memory_bytes: 3064
import java.util.LinkedList;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Main p = new Main();
	}

	int h;
	int w;
	StringBuilder map;
	List<int[]> c;
	public Main() {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		for(int i=0;i<n;i++){
			c = new LinkedList<int[]>();
			h = sc.nextInt();
			w = sc.nextInt();
			map = new StringBuilder();
			for(int j=0;j<h;j++)
				map.append(sc.next());
			
			System.out.println(solve() ? "SAFE" : "SUSPICIOUS");
		}
		
	}

	public boolean solve() {
		int[][] alpha = new int[26][5];
		for(int i=0;i<alpha.length;i++){
			alpha[i][1] = alpha[i][2] = 10000000;
		}
		
		for(int i=0;i<h;i++){
			for(int j=0;j<w;j++){
				int ch = map.charAt(i*w+j) - 'A';
				if(ch+'A'=='.')
					continue;
				
				alpha[ch][0]++;
				alpha[ch][1] = Math.min(alpha[ch][1], i);
				alpha[ch][2] = Math.min(alpha[ch][2], j);
				alpha[ch][3] = Math.max(alpha[ch][3], i);
				alpha[ch][4] = Math.max(alpha[ch][4], j);
				
			}
		}
		for(int i=0;i<alpha.length;i++){
			if(alpha[i][0]>0){
				alpha[i][0] = i+'A';
				c.add(alpha[i]);
			}
		}
		
		int cur = 0;
		StringBuilder sb = new StringBuilder();
		for(int i=0;i<h*w;i++)
			sb.append('.');
		return rec(cur, sb);
		
	}

	private boolean rec(int cur, StringBuilder sb) {
		if(cur == (1<<c.size())-1)
			return isOk(sb);
		
		boolean res = false;
		
		for(int i=0;i<c.size();i++){
			if(((1<<i) & cur) > 0)
				continue;
			
			int[] ca = c.get(i);
			char ch = (char) ca[0];
			for(int j=ca[1];j<=ca[3];j++){
				for(int k=ca[2];k<=ca[4];k++){
					sb.setCharAt(j*w+k, ch);
				}
			}
			res |= rec(cur|(1<<i), sb);
		}
		
		return res;
	}

	private boolean isOk(StringBuilder sb) {
		for(int i=0;i<sb.length();i++)
			if(map.charAt(i) != sb.charAt(i))
				return false;
		
		return true;
	}

}

Measured memory_bytes: 42996
//compiledef
#include <bits/stdc++.h>
#define rep(i, n) for(i=0;i<(n);i++)
#define per(i, n) for(i=(n);i>0;i--)
#define repx(i, n, x) for(i=(x);i<=(n);i++)
#define xper(i, n, x) for(i=(n);i>=(x);i--)
#define pback push_back

//c++def
using namespace std;
typedef long long int ll;
const ll MOD = 1e9+7;
typedef struct{
	char suit;
	int value;
}card;
void BSort(card c[], int n){
	int i, j;
	rep(i, n){
		xper(j, n-1,i+1){
			if(c[j].value<c[j-1].value) swap(c[j], c[j-1]);
		} 
	}
}
void SSort(card c[], int n){
	int i, j, min;
	rep(i, n){
		min = i;
		repx(j, n-1, i){
			if(c[j].value<c[min].value) min = j;
		}
		swap(c[i],c[min]);
	}
}
bool isstable(card c1[], card c2[], int n){
	int i;
	rep(i, n){
		if(c1[i].suit != c2[i].suit) return false;
	}
	return true;
}
void prt(card c[], int n){
	int i;
	rep(i, n){
		printf("%c%d", c[i].suit, c[i].value);
		if(i!=n-1) printf(" ");
	}
	printf("\n");
}

int main(){
	int i;
	card c1[36], c2[36];
	int n;
	cin >> n;
	rep(i, n) cin >> c1[i].suit >> c1[i].value;
	rep(i, n) c2[i] = c1[i];
	BSort(c1, n);
	SSort(c2, n);
	prt(c1, n);
	printf("Stable\n");
	prt(c2, n);
	if(isstable(c1, c2, n)){
		cout << "Stable" << endl;
	}else{
		cout << "Not stable" << endl;
	}
}



Measured memory_bytes: 3224
#include<iostream>
#include<stdio.h>
using namespace std;
int main(){
  int n,mi=10000000,ma=-10000000;
    long long sum=0;
  cin >> n;
  int i,b;
  for(i=0;i<n;i++){
    cin >> b;
    mi=min(mi,b);
    ma=max(ma,b);
    sum+=b;
  }
  cout << mi <<  " " << ma << " " << sum << endl;
  return 0;
}



Measured memory_bytes: 3116
//#include <tourist>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#include <iomanip>
#include <limits>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <list>
#include <queue>
#include <tuple>
#include <deque>
#include <algorithm>
#include <numeric>
#include <iomanip>
#include <utility>
#include <complex>
#include <functional>
using namespace std;
const int MOD = 1000000007;
typedef long long ll;
const int INF = (1 << 28);
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 9223372036854775807
#define ALL(v) v.begin(), v.end()
//setprecision(15)有効数字15桁
//-std=c++14
//LLONG_MAX=9223372036854775807
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b)
{
    return a * b / gcd(a, b);
}
int n, m, s, t;
//ダイクストラ
struct edge{ll to, cost;};
typedef pair<ll,ll> P;
struct graph{
  ll V;
  vector<vector<edge> > G;
  vector<ll> d;
//vector<vector<int> > prev((int)G.size()); // prev[v] := v から復元できる辺たち
  graph(ll n){
    init(n);
  }

  void init(ll n){
    V = n;
    G.resize(V);
    d.resize(V);
    REP(i,V){
      d[i] = INF;
    }
  }

  void add_edge(ll s, ll t, ll cost){
    edge e;
    e.to = t, e.cost = cost;
    G[s].push_back(e);
  }

  void dijkstra(ll s){
    REP(i,V){
      d[i] = INF;
    }
    d[s] = 0;
    priority_queue<P,vector<P>, greater<P> > que;
    que.push(P(0,s));
    while(!que.empty()){
      P p = que.top(); que.pop();
      ll v = p.second;
      if(d[v]<p.first) continue;
      for(auto e : G[v]){
        if(d[e.to]>d[v]+e.cost){
          d[e.to] = d[v]+e.cost;
          que.push(P(d[e.to],e.to));
          // 復元のための
          //prev[e.first].clear();
          //prev[e.first].push_back(v);
        }
      }
    }
  }
};

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n>>m>>s>>t;
    graph gs(n);
    graph gt(n);
    s--;
    t--;
    for (int i = 0; i < m; i++)
    {
        ll u, v, a, b;
        cin >> u>>v>>a>>b;
        u--;
        v--;
        gs.add_edge(u,v,a);
        gs.add_edge(v,u,a);
        gt.add_edge(u,v,b);
        gt.add_edge(v,u,b);
    }
    vector<ll> le;
    ll ans=1000000000000000;
    gs.dijkstra(s);
    gt.dijkstra(t);
    ll ansm=9223372036854775807;
    for(int i=n-1;i>=0;i--){
        ansm=min(ansm,gs.d[i]+gt.d[i]);
        le.push_back(ansm);
    }
    for(int i=n-1;i>=0;i--){
        cout<<ans-le[i]<<"\n";
    }
}



Measured memory_bytes: 19964
N,M=map(int,input().split())
L=[tuple(map(int,input().split())) for i in range(N)]
#s = sorted(L, key = lambda x: x[1])
s = sorted(L)
cnt=0
ans=0
while cnt<M:
  for i in range(N):
    if (M-cnt)<s[i][1]:
      ans+=(M-cnt)*s[i][0]
      cnt+=(M-cnt)
      
    else:
      ans+=s[i][0]*s[i][1]
      cnt+=s[i][1]
print(ans)

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

int main() {
    ios::sync_with_stdio(false);
    int W, H, N;
    cin >> W >> H >> N;
    int x1 = 0;
    int x2 = W;
    int y1 = 0;
    int y2 = H;
    for (int n = 0; n != N; ++n){
        int x, y, a;
        cin >> x >> y >> a;
        switch (a){
            case 1:
                x1 = max(x1, x);
                break;
            case 2:
                x2 = min(x2, x);
                break;
            case 3:
                y1 = max(y1, y);
                break;
            case 4:
                y2 = min(y2, y);
                break;
        }
    }
    cout << max(0, x2 - x1) * max(0, y2 - y1) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;
using pii = pair<int, int>;

//const ll INF = 1e18L + 5;
//const int INF = 1e9 + 5;
//const double pi = 3.14159265358979323846;

int		main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	ll a, b, c, x, y;
	cin >> a >> b >> c >> x >> y;
	ll ans = 0;
	if (2 * c >= a + b) {
		cout << a * x + b * y << endl;
		return 0;
	} else {
		int min_v = min(x, y);
		ans += 2 * c * min_v;
		x -= min_v;
		y -= min_v;
		if (x) ans += min(x * a, 2 * c * x);
		if (y) ans += min(y * b, 2 * c * y);
	}
	cout << ans << endl;
}


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

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

#define fill(a,x) memset(a,x,sizeof(a))
#define pb push_back
#define sz(x) (int)x.size()
#define F first
#define S second
#define FOR(i,a,b) for(int i = a; i<=b; ++i)
#define NFOR(i,a,b) for(int i = a; i>=b; --i)
#define fast ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
const ll INF = 1e18;
const ll mod = 1e9+7;
const int N = 2e5+10;

ll a[N];
ll suffixsum[N];

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

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

suffixsum[n+1]=0;
for(int i=n;i>=0;i--) {
    suffixsum[i]=suffixsum[i+1]+a[i];
}

ll ans=0;
ll nodes=0;
for(int i=0;i<=n;i++) {
    if(i==0) {
        nodes = min(1LL, suffixsum[i]);
        if(nodes < a[i]) {
            cout<<-1<<endl;
            return 0;
        }
    } else {
        nodes = min(2*(nodes-a[i-1]),suffixsum[i]);
        if(nodes < a[i]){
            cout<<-1<<endl;
            return 0;
        }
    }
    ans+=nodes;
}

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

Measured memory_bytes: 5160
#include<bits/stdc++.h>
#define fo(i,a,b) for(int i=(a);i<(b);i++)
#define qi queue<int>
#define vi vector<int>
#define ll long long
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define pii pair<int,int>
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define fi first
#define se second
#define prq priority_queue
#define foreach(it,c) for(__typeof((c).begin()) it=c.begin();it!=c.end();it++)
//#define KEY_DOWN(VK_NONAME) ((GetAsyncKeyState(VK_NONAME) & 0x8000) ? 1:0)
using namespace std;
inline ll read(){
	ll x=0;
	int f=1;
	char c=getchar();
	for(;!isdigit(c);c=getchar()) if(c=='-')f=-f;
	for(;isdigit(c);c=getchar())x=x*10+(c-'0');
	return x*f;
}
inline void out(int x){
	if(x>=10)out(x/10);
	putchar(x%10+'0');
}
int main(){
	//freopen("a.in","r",stdin);
	//freopen("a.out","w",stdout);
	int d,s,t;
	cin>>d>>s>>t;
	if(s*t>=d)cout<<"Yes\n";
	else cout<<"No\n"; 
	return 0;
}


Measured memory_bytes: 3624
A=int(input())
B=int(input())
 
if A==1 and B==2:
  print("3")
if A==2 and B==3:
  print("1")
if A==1 and B==3:
  print("2")
if A==2 and B==1:
  print("3")
if A==3 and B==2:
  print("1")
if A==3 and B==1:
  print("2")

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main(void){
  long long a,b,c,d; cin>>a>>b>>c>>d;
  long long e=a*c,f=a*d,g=b*c,h=b*d;
  cout<<max(max(max(e,f),g),h);
  return 0;
}

Measured memory_bytes: 3636
H,W = map(int, input().split())

str = []
for i in range(H):
    str.append("."+input()+".")
    
#for i in range(H):
#    print(str[i])

H+=2
W+=2

str.insert(0, "."*(W))
str.append("."*(W))

for i in range(1,H-1):
    for j in range(1,W-1):
        if(str[i][j]=='.'):
            continue

        diff = [0,1,0,-1,0]
        is_ok = False
        for d in range(4):
            if str[i+diff[d]][j+diff[d+1]] == '#':
                is_ok = True
        if is_ok==False:
            print("No")
            exit(0)
            
print("Yes")

Measured memory_bytes: 3064
/*input
7
6 7 8
8 8 3
2 5 2
7 8 6
4 6 8
2 3 4
7 5 1
*/
#include<bits/stdc++.h>
using namespace std;

#define int long long 
#define double long double
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define RE(i,n) for (int i = 1; i <= n; i++)
#define RED(i,n) for (int i = n; i > 0; i--)
#define REPS(i,n) for(int i = 1; (i*i) <= n; i++)
#define REP(i,n) for (int i = 0; i < n; i++)
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REPD(i,n) for (int i = n-1; i >= 0; i--)
#define FORD(i,a,b) for (int i = a; i >= b; i--)
#define remax(a,b) a = max(a,b)
#define remin(a,b) a = min(a,b)
#define all(v) v.begin(),v.end()
#define pii pair<int,int>
#define mii map<int,int>
#define vi vector<int>
#define vvi vector<vi>
#define WL(t) while(t --)
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
#define print(arr) for (auto it = arr.begin(); it != arr.end(); ++it) cout << *it << " "; cout << endl;
#define debug(x) cout << x << endl;
#define debug2(x,y) cout << x << " " << y << endl;
#define debug3(x,y,z) cout << x << " " << y << " " << z << endl;
const int INF = 1e18+1;
const int MOD = 1e9+7;
const double PI = 3.14159265358979323846264338;

int fast_ex(int a,int n,int m){
  if(n == 0)return 1;
  if(n == 1)return a;
  int x = 1;
    x *= fast_ex(a,n/2,m);
    x %= m;
    x *= x;
    x %= m;
    if(n%2)x*= a;
    x %= m;
    return x;
}

const int N = 1e5+1;
int n;
int a[N][3];
int dp[N][3];

void solve(){
	cin >> n;
	RE(i,n)cin >> a[i][0] >> a[i][1] >> a[i][2];
	dp[0][0] = dp[0][1] = dp[0][2] = 0;
	RE(i,n){
		for(int j = 0;j < 3;j++){
			for(int k = 0;k < 3;k++){
				if(j == k)continue;
				dp[i][j]= max(dp[i][j],dp[i-1][k]+a[i][j]);
			}
		}
	}
	cout << max(max(dp[n][0],dp[n][1]),dp[n][2]);
}

signed main(){
  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
  //freopen(".in","r",stdin);freopen(".out","w",stdout);
  int t = 1;//cin >> t;
  WL(t)solve();
  return 0;
}

Measured memory_bytes: 4992
def kaibun(s):
    n = len(s)
    for i in range(n):
        if s[i]!=s[-1-i]:
            return False
    return True

S = input()
N = len(S)
if kaibun(S) and kaibun(S[:(N-1)//2]) and kaibun(S[(N+3)//2 -1:]):
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3060
//by yjz
#include<bits/stdc++.h>
using namespace std;
#define FF first
#define SS second
#define PB push_back
#define MP make_pair
#define bged(v) (v).begin(),(v).end()
#define foreach(it,s) for(__typeof((s).begin()) it=(s).begin();it!=(s).end();it++)
typedef long long ll;
const int Imx=2147483647;
const ll Lbig=2e18;
const int mod=1e9+7;
//My i/o stream
struct fastio
{
	char s[100000];
	int it,len;
	fastio(){it=len=0;}
	inline char get()
	{
		if(it<len)return s[it++];it=0;
		len=fread(s,1,100000,stdin);
		if(len==0)return EOF;else return s[it++];
	}
	bool notend()
	{
		char c=get();
		while(c==' '||c=='\n')c=get();
		if(it>0)it--;
		return c!=EOF;
	}
}_buff;
#define geti(x) x=getnum()
#define getii(x,y) geti(x),geti(y)
#define getiii(x,y,z) getii(x,y),geti(z)
#define puti(x) putnum(x),putchar(' ')
#define putii(x,y) puti(x),puti(y)
#define putiii(x,y,z) putii(x,y),puti(z)
#define putsi(x) putnum(x),putchar('\n')
#define putsii(x,y) puti(x),putsi(y)
#define putsiii(x,y,z) putii(x,y),putsi(z)
inline ll getnum()
{
	ll r=0;bool ng=0;char c;c=_buff.get();
	while(c!='-'&&(c<'0'||c>'9'))c=_buff.get();
	if(c=='-')ng=1,c=_buff.get();
	while(c>='0'&&c<='9')r=r*10+c-'0',c=_buff.get();
	return ng?-r:r;
}
template<class T> inline void putnum(T x)
{
	if(x<0)putchar('-'),x=-x;
	register short a[20]={},sz=0;
	while(x)a[sz++]=x%10,x/=10;
	if(sz==0)putchar('0');
	for(int i=sz-1;i>=0;i--)putchar('0'+a[i]);
}
inline char getreal(){char c=_buff.get();while(c==' '||c=='\n')c=_buff.get();return c;}
int n,m,q;
char g[2011][2011];
int sum[2011][2011],sumh[2011][2011],sumv[2011][2011];
int main()
{
	getiii(n,m,q);
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
		{
			g[i][j]=getreal();
			if(g[i][j]=='1')sum[i][j]=1;
		}
	}
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
		{
			if(g[i][j]!='1')continue;
			if(g[i][j+1]=='1')
			{
				sumh[i][j+1]=1;
			}
			if(g[i+1][j]=='1')
			{
				sumv[i+1][j]=1;
			}
		}
	}
	for(int i=1;i<=n+1;i++)for(int j=1;j<=m+1;j++)
	{
		sum[i][j]+=sum[i-1][j]+sum[i][j-1]-sum[i-1][j-1];
		sumh[i][j]+=sumh[i-1][j]+sumh[i][j-1]-sumh[i-1][j-1];
		sumv[i][j]+=sumv[i-1][j]+sumv[i][j-1]-sumv[i-1][j-1];
	}
	for(int i=1;i<=q;i++)
	{
		int xa,ya,xb,yb;
		getii(xa,ya);
		getii(xb,yb);
		int ans=sum[xb][yb]-sum[xa-1][yb]-sum[xb][ya-1]+sum[xa-1][ya-1];
//		cerr<<ans<<endl;
		ans-=sumh[xb][yb]-sumh[xa-1][yb]-sumh[xb][ya]+sumh[xa-1][ya];
		ans-=sumv[xb][yb]-sumv[xa][yb]-sumv[xb][ya-1]+sumv[xa][ya-1];
		putsi(ans);
	}
	return 0;
}


Measured memory_bytes: 53248
using System;

public class Hello
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine().Trim());
        var a = Convert.ToString(n, 2);
        var aL = a.Length;
        Console.WriteLine(a.Replace("1", "").Length == 0 ? aL : aL - 1);
    }
}




Measured memory_bytes: 9236
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i <(n); ++i)
#define ALL(v) v.begin(), v.end()
using namespace std;

/* 4 方向への隣接頂点への移動を表すベクトル */
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };


int main() {

    ////////////////////////////////////////
    /* 入力受け取り */
    ////////////////////////////////////////

    /* 縦と横の長さ */
    int height, width;
    cin >> height >> width;

    // /* スタート地点とゴール地点 */
    // int sx, sy, gx, gy;
    // cin >> sx >> sy;
    // cin >> gx >> gy;
    // sx--,sy--,gx--,gy--;

    /* 盤面 */
    vector<string> field(height);
    for (int h = 0; h < height; ++h) cin >> field[h];


    ////////////////////////////////////////
    /* 幅優先探索の初期設定 */
    ////////////////////////////////////////

    // 各セルの最短距離 (訪れていないところは -1 としておく)
    int mxdist = 0;
    REP(i,height) REP(j,width){
      int sx = i;
      int sy = j;
      if(field[sx][sy] == '#') continue;

      vector<vector<int> > dist(height, vector<int>(width, -1));
      dist[sx][sy] = 0; // スタートを 0 に

      // 「一度見た頂点」のうち「まだ訪れていない頂点」を表すキュー
      queue<pair<int, int> > que;
      que.push(make_pair(sx, sy)); // スタートを push


      ////////////////////////////////////////
      /* 幅優先探索を実施 */
      ////////////////////////////////////////

      /* キューが空になるまで */
      while (!que.empty()) {
          pair<int, int> current_pos = que.front(); // キューの先頭を見る (C++ ではこれをしても pop しない)
          int x = current_pos.first;
          int y = current_pos.second;
          que.pop(); // キューから pop を忘れずに

          // 隣接頂点を探索
          for (int direction = 0; direction < 4; ++direction) {
              int next_x = x + dx[direction];
              int next_y = y + dy[direction];
              if (next_x < 0 || next_x >= height || next_y < 0 || next_y >= width) continue; // 場外アウトならダメ
              if (field[next_x][next_y] == '#') continue; // 壁はダメ

              // まだ見ていない頂点なら push
              if (dist[next_x][next_y] == -1) {
                  que.push(make_pair(next_x, next_y));
                  dist[next_x][next_y] = dist[x][y] + 1;
              }
          }
      }



    //cout << "strat; "<< sx << " " << sy << endl;
    REP(hi, height) REP(wi,width){
      //cout << dist[hi][wi] << endl;
      mxdist = max(dist[hi][wi], mxdist);
    }

    }

    cout << mxdist << endl;

    return 0;
}


Measured memory_bytes: 3596