akhauriyash/Code-Regression huggingface dataset:
import itertools
N, M, Q = [int(x) for x in input().split(" ")]

conditions = [[int(x) for x in input().split(" ")] for _ in range(Q)]

def add(l, N):
    if len(l) == 0:
        b = 1
    else:
        b = l[-1]
    ans = []
    for i in range(b, N+1):
        ans.append(l + [i])
    return ans

L = [[]]
for _ in range(N):
    nex = []
    for l in L:
        nex.extend(add(l, M))
    L = nex

smax = 0
for l in L:
    s = 0
    for c in conditions:
        if l[c[1]-1] - l[c[0]-1] == c[2]:
            s += c[3]
    if s > smax:
        smax = s
print(smax)


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

ll N;
int main(){
	cin >> N;
	
	vector<int> A(N+1), B(N);
	for ( int i = 0; i < N+1; i++ )
		cin >> A[i];
	for ( int i = 0; i < N; i++ )
		cin >> B[i];
	
	ll result = 0;
	for ( int i = 0; i < N; i++ ){
		int x = min( A[i], B[i] );
		A[i] -= x;
		B[i] -= x;
		result += x;
		
		int y = min( A[i+1], B[i] );
		A[i+1] -= y;
		B[i] -= y;
		result += y;
	}
	
	
	
	cout << result << endl;
	
	return 0;
}



Measured memory_bytes: 1024
#include <iostream>
#include <vector>
using namespace std;
using Int = long long int;
using UInt = unsigned long long int;
using VI = vector<Int>;
using VVI = vector<vector<Int> >;

int in_rec(VVI& v, int n, int target, VI check_table) {
    //cout << target << endl;
    Int ret = 0;
    Int size = v[target].size();
    check_table[target] = 1;
    bool filled = true;
    for (Int i = 0; i < n; ++i) {
        if (check_table[i] == 0) {
            filled = false;
        }
    }
    if (filled == true) {
        ret += 1;
    }

    for (Int i = 0; i < size; ++i) {
        if (check_table[v[target][i]] == 0) {
            ret += in_rec(v, n, v[target][i], check_table);
        }
    }

    //cout << target << " " << ret << endl;
    return ret;
}

int rec(VVI& v, int n) {
    Int ret = 0;
    VI table(n, 0);
    Int i = 0;
    ret += in_rec(v, n, i, table);
    return ret;
}

int main(void) {
    Int n, m;
    cin >> n >> m;
    VVI v(n);
    Int s, t;
    for (Int i = 0; i < m; ++i) {
        cin >> s >> t;
        --s;--t;
        v[s].push_back(t);
        v[t].push_back(s);
    }
    cout << rec(v, n) << endl;
    return 0;
}


Measured memory_bytes: 3544
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)  
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define RVSORT(v) sort(v.rbegin(), v.rend());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int gcd(int a,int b){return b?gcd(b,a%b):a;}

ll modpow(ll n,ll k){
  if(k == 1){
    return n;
  }else if(k == 0){
    return 1;
  }else if(k%2==0){
    ll memo = modpow(n,k/2)%MOD;
    return memo*memo%MOD;
  }else{
    return n * modpow(n,k-1)%MOD;
  }
}

int main(){

  int n;cin>>n;
  string s;cin>>s;

  char c;
  ll  ans = 1;

  REP(i,n){
    if(i==0){
      c = s[i];
    }else{
      if(c != s[i]){
        c = s[i];
        ans++;
      }
    }
  }

  cout<<ans<<endl;
 

  return 0;
}

Measured memory_bytes: 512
#include <queue>
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <map>
#include <stdio.h>
using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for(int i = (a); i < (int)(b); i++)
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vint;
typedef vector<string> vstr;
typedef pair<ll, ll> pint;
unsigned long long inf = (1LL << 62);
ll MOD = (ll)pow(10.0, 9.0) + 7;
pint dx[4] = { {0, 1}, {0, -1}, {1, 0}, {-1, 0} };
char da[4] = { 'R', 'L', 'D', 'U' };
char dad[4] = { 'L', 'R', 'U', 'D' };
ll min(ll a, ll b)
{

	return (a < b) ? a : b;
}
ll max(ll a, ll b) { return (a > b) ? a : b; }





ll H, W, N;
ll sr, sc;
string S, T;
int main() {

	cin >> H >> W >> N >> sr >> sc >> S >> T;

	auto in = [&](int x, int y) {return x >= 0 && y >= 0 && x < H && y < W; };
	string A;
	sr--;
	sc--;
	for (int i = 0; i < 2 * N; i++) {

		if (i % 2 == 0) {
			A.push_back(S[i / 2]);
		}
		else {
			A.push_back(T[i / 2]);
		}
	}

	bool flag = true;



	

	rep(k, 4) {
		ll sx = sr, sy = sc;

		for (int i = 0; i < 2 * N; i++) {
			if (i % 2 == 0 && A[i] == da[k]) {
				sx += dx[k].first;
				sy += dx[k].second;

				if (!in(sx, sy)) {

					flag = false;
				}

			}

			if (i % 2 == 1 && A[i] == dad[k] && in(sx - dx[k].first, sy - dx[k].second)) {
				

				sx += -dx[k].first;
				sy += -dx[k].second;
			}



		}

	}


	cout << ((flag) ? "YES" : "NO") << endl;


	
	return 0;
}

Measured memory_bytes: 1292
package main

import (
	"bufio"
	"fmt"
	"os"
)

var sc = bufio.NewScanner(os.Stdin)

const inf = 1 << 60

func ri() (n int) {
	sc.Scan()
	for _, v := range sc.Bytes() {
		n = n*10 + int(v-48)
	}
	return
}

func push(s []int, x int) []int { return append(s, x) }
func pop(s []int) ([]int, int)  { return s[:len(s)-1], s[len(s)-1] }

func main() {
	sc.Split(bufio.ScanWords)
	n, m := ri(), ri()
	al := make([][]int, n)
	for i := 0; i < m; i++ {
		x, y, _ := ri()-1, ri()-1, ri()
		al[x] = push(al[x], y)
		al[y] = push(al[y], x)
	}

	cost := 0
	isDetermined := make([]bool, n)
	s := make([]int, 0, n)
	var x int
	for i := 0; i < len(isDetermined); i++ {
		if isDetermined[i] {
			continue
		}
		cost++
		isDetermined[i] = true
		s = push(s, i)
		for len(s) != 0 {
			s, x = pop(s)
			for _, v := range al[x] {
				if !isDetermined[v] {
					isDetermined[v] = true
					s = push(s, v)
				}
			}
		}
	}
	fmt.Println(cost)
}


Measured memory_bytes: 8064
n,m = map(int,input().split())
leave = []
arrive = []
for i in range(m):
    a,b = map(int,input().split())
    if a == 1:
        leave.append(b)
    elif b == n:
        arrive.append(a)
if list(set(leave) & set(arrive)):
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

Measured memory_bytes: 27740
def main():
    N = int(input())
     
    testimony = [[] for _ in range(N)]
     
    for i in range(N):
        num = int(input())
        for j in range(num):
            person, state = map(int, input().split())
            testimony[i].append([person-1, state])
            
    honest = 0
    for i in range(1, 2**N):
        flag = 0
        for j in range(N):
            if (i>>j)&1 == 1: # j番目は正直と仮定
                for x,y in testimony[j]:
                    if (i>>x)&1 != y: # j番目は正直だが矛盾を発見
                        flag = 1
                        break
        if flag == 0:  # 矛盾がある場合はflag == 1になる
            honest = max(honest, bin(i)[2:].count('1'))  # 1の数をカウントし最大となるものを選択
    print(honest)
if __name__=="__main__":
    main()

Measured memory_bytes: 3188
#include<bits/stdc++.h>
#define int long long
#define for0(i, n) for(int i = 0; i < (n); i++)
#define for1(i, n) for(int i = 1; i <= (n);i++)
#define mp make_pair
#define all(x) x.begin(),x.end()
#define puts(x) cout << (x) << "\n"
constexpr int mod = 1000000007;
using namespace std;
int input() { int t; cin >> t; return t; }
int n, ans;
signed main() {
	int n; cin >> n;
	for1(i, n)ans += i * (i + 1) / 2;
	for1(i, n - 1) {
		int a, b; cin >> a >> b;
		if (a > b)swap(a, b);
		ans -= a * (n - b + 1);
	}
	cout << ans << endl;
}

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

using namespace std;

int main() {

    string S;
    cin >> S;
    int ans;
    int N = S.length();
    vector<char> A(4);
    A[0] = 'A';
    A[1] = 'C';
    A[2] = 'G';
    A[3] = 'T';
    int max = -1;
    for (int i = 0; i < N; ++i) {
        int count = 0;
        for (int k = i; k < N; ++k) {
            char temp = S[k];
            bool can = false;
            for (int j = 0; j < 4; ++j) {
                // cout << temp << ":" << temp ;
                if (temp == A[j]) {
                    can = true;
                }
            }
            if (can) {
                count++;
            }
            if (!can) {
                break;
            }
        }
        // cout << count << endl;
        if (count > max) {
            max = count;
        }
    }
    ans = max;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define int long long
#define double long double
#define mod 1000000007
#define F first
#define S second
#define P pair<long long,long long>
#define all(a) a.begin(),a.end()
#define INF 5000000000000000
#define endl '\n'
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; }
using namespace std;

int gcd(int a,int b){
    if(a<b)swap(a,b);
    if(b==0)return a;
    return gcd(b,a%b);
}

signed main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin>>n;
    vector<int> a(n);
    rep(i,n)cin>>a.at(i);
    int cnt=0,cnt2=0;
    rep(i,n){
        if(a.at(i)<0)cnt++;
        if(a.at(i)==0)cnt2++;
    }
    if(cnt2>0){
        int sum=0;
        rep(i,n)sum+=abs(a.at(i));
        cout<<sum<<endl;
    }else{
        if(cnt%2==0){
            int sum=0;
            rep(i,n)sum+=abs(a.at(i));
            cout<<sum<<endl;
        }else{
            rep(i,n)a.at(i)=abs(a.at(i));
            sort(all(a));
            int sum=0;
            rep(i,n)sum+=a.at(i);
            sum-=a.front()*2;
            cout<<sum<<endl;
        }
    }
}

Measured memory_bytes: 1024
#include <cstdio>
#include <algorithm>
#include <vector>
#include <utility>
#include <map>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <stack>
#include <queue>
#include <cstring>
#include <iterator>

#define FOR(n) for(int i=0;i<(n);++i)
#define FOR_R(it,cont) for(auto it=rbegin(cont);it!=rend(cont);++it)
#define FOR_F(it,cont) for(auto it=begin(cont);it!=end(cont);++it)
#define ALL(cont) begin(cont), end(cont)
#define LB(b,e,v) lower_bound(b,e,v)
#define UB(b,e,v) upper_bound(b,e,v)
#define AS_MOD(a,b) ((((a) % (b) ) + (b)) % (b))

using namespace std;
typedef pair<int,int> P;
typedef pair<P, P> PP;
typedef long long ll;
int A,B,C,D,E,F;
vector<int> water;
int getMAXS(int maxSugar) {
  int ret=0;
  for(int i=0;i*C<=maxSugar;++i) {
    ret = max(ret, i*C+((maxSugar-i*C)/D)*D);
  }
  return ret;
}
int main() {
  scanf("%d%d%d%d%d%d", &A, &B, &C, &D, &E, &F);
  for(int i=0;100*A*i<=F;++i) {
    for(int j=0;100*A*i+100*B*j<=F;++j) {
      if(i==0&&j==0)continue;
      water.push_back(100*A*i+100*B*j);
    }
  }
  double max=-1;
  int ansW=0;
  int ansS=0;
  for(int i=0;i<water.size();++i) {
    int V=water[i];
    int MAXS=V/100*E;

    int maxSugar = getMAXS(min(MAXS, F-V));
    double newD=(maxSugar+V*1.0) / (V*1.0);
    if (max < newD) {
      max = newD;
      ansW=V;
      ansS=maxSugar;
    }
  }

  printf("%d %d\n", ansW+ansS, ansS);

  return 0;
}


Measured memory_bytes: 256
n,m = map(int,input().split())

def md(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort(reverse = True)
    return divisors

a = md(m)
ans = 1
for i in a:
    if i >= n:
        ans = m//i
        
print(ans)

Measured memory_bytes: 38640
#include <iostream>
#include <vector>
#include <utility>

using namespace std;

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

	typedef pair<int, int> int_pair;
	vector<int_pair> a;

	while (true)
	{
		int H, W;
		cin >> H >> W;

		a.push_back(int_pair(H, W));

		if (H == 0 && W == 0)
			break;
	}

	for (int i = 0; a[i].first != 0 && a[i].second != 0; ++i)
	{
		for (int h = 0; h < a[i].first; ++h) {
			for (int w = 0; w < a[i].second; ++w)
				cout << "#";
			cout << endl;
		}

		cout << endl;
	}

	return 0;
}

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

//int _; 

int r,g,b;
 
int main()
{
	//for(scanf("%d",&_);_;_--)
	cin >> r >> g >> b;
	cout << ((g*10+b)%4 ? "NO\n":"YES\n");
	return 0;
}



Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using static System.Math;
 
public class Hello{
    public static void Main(){
/*        string[] input = ReadLine().Split(' ');
        int n = int.Parse(input[0]);
        int m = int.Parse(input[1]);
        int a = int.Parse(input[2]);
        int b = int.Parse(input[3]);*/
//        string temp = ReadLine();
//        int a = int.Parse(ReadLine());
//        int b = int.Parse(ReadLine());
//        int c = int.Parse(ReadLine());
        string a = ReadLine();
        string b = ReadLine();
        string c = ReadLine();
        Write(a[0]);
        Write(b[1]);
        Write(c[2]);
        WriteLine();
    }
}

Measured memory_bytes: 11092
#include<iostream>
#include<iomanip>
#include<cstdio>

#include<vector>
#include<queue>
#include<set>
#include<map>
#include<string>

#include<algorithm>
#include<cmath>

using namespace std;
typedef long long ll;
template <class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}
template <class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}
const int INF = 1e9+1;

int N, K;
int h[100000];

int main() {
    cin >> N >> K;
    for (int i = 0; i < N; i++) cin >> h[i];
    sort(h,h+N);
    int res = INF;
    for (int i = 0; i < N-K+1; i++) {
        chmin(res,h[i+K-1]-h[i]);
    }
    cout << res << endl;
}


Measured memory_bytes: 640
n,m = map(int,input().split())
anslist=[1]+[0]*(n-1)
caplist=[]
for i in range(m):
    a,b=map(int,input().split())
    if not a in caplist:
        anslist[a-1]=(anslist[a-1])*0+b
        caplist.append(a)
    elif b!=anslist[a-1]:
        print(-1)
        break
else:
    if n==1 and anslist==[0]:
      print(0)
    elif n==1 and m==0 and anslist==[1]:
      print(0)
    elif anslist[0]==0:
      print(-1)
    else:
      map=map(str,anslist)
      print(''.join(map))


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define ll long long
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;

//定数
//円周率
const double pi = 3.141592653589793238462643383279;
//天井
const int INF = 1000000000; // = 10^9
const ll LINF = 100000000000000000; // = 10^17
//ABC文字列
const string ABC = "ABCDEFGHIJKLMNOPQRSTUVWXYZABC";
const string abc = "abcdefghijklmnopqrstuvwxyzabc";
//よくあるmodくん
const ll MOD = 1000000007; // = 10^9 + 7

//データ構造
//隣接リスト用構造体（有向グラフ向け）
struct edge {
  ll to; // E.toでその辺の終点へアクセスできる
  ll cost; // e.costでその辺の重みにアクセスできる
};
//Union_Find木
struct UnionFind {
  vector<int> UF; // UF.at(i) : iの親の番号
  vector<int> SIZE; // SIZE.at(root(i)) : iと連結されてる要素の数
  UnionFind(int N) : UF(N), SIZE(N, 1) { // 最初は全てが根であるとして初期化
    for(int i = 0; i < N; i++) {
      UF.at(i) = i;
    }
  }
  int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
    if (UF.at(x) == x) {
      return x;
    }
    return UF.at(x) = root(UF.at(x));
  }
  void unite(int x, int y) { // xとyの木を併合
    int rx = root(x); // xの根をrx
    int ry = root(y); // yの根をry
    if (rx == ry) {
      return; // xとyの根が同じ(=同じ木にある)時はそのまま
    }
    // xとyの根が同じでない(=同じ木にない)時：小さい方の根を大きい方の根につける
    if (SIZE.at(rx) < SIZE.at(ry)) {
      UF.at(rx) = ry;
      SIZE.at(ry) += SIZE.at(rx);
      SIZE.at(rx) = 0;
    }
    else {
      UF.at(ry) = rx;
      SIZE.at(rx) += SIZE.at(ry);
      SIZE.at(ry) = 0;
    }
  }
  bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
    int rx = root(x);
    int ry = root(y);
    return rx == ry;
  }
  int size(int x) { // xと連結されてる要素の数を返す
    return SIZE.at(root(x));
  }
};

//関数 (計算量)
//ctoi (O(1))
int ctoi(char c){
  if (c == '0') return 0;
  if (c == '1') return 1;
  if (c == '2') return 2;
  if (c == '3') return 3;
  if (c == '4') return 4;
  if (c == '5') return 5; 
  if (c == '6') return 6;
  if (c == '7') return 7;
  if (c == '8') return 8;
  if (c == '9') return 9;
  return -1;  
}
//to_char (O(1))
char to_char(int i){
  if (i == 0) return '0';
  if (i == 1) return '1';
  if (i == 2) return '2';
  if (i == 3) return '3';
  if (i == 4) return '4';
  if (i == 5) return '5';
  if (i == 6) return '6';
  if (i == 7) return '7';
  if (i == 8) return '8'; 
  if (i == 9) return '9';
  return ' ';  
}
//素数判定 
//一つ一つの判定ではこっちの方が速い(一つ当たりO(√N))
//一方100までに何個あるかなどはEratosthenesの篩の方が良い（O(NlogN))
bool PN(int x) {
  if (x <= 1) return false; // 1や0,-1は素数ではない
  if (x == 2) return true; // √2 + 1 > 2 なので下でやると 2 ％ 2 = 0 となり判定できない
  for (int i = 2; i < sqrt(x) + 1; i++) {
    if (x % i == 0) return false; // 割れたら素数じゃない
  }
  return true;
}
// A^N mod M を計算する。modしたくなかったらM = LINFとかにすればよい。(O(√N))
ll modpow(ll A, ll N, ll M) {
  ll ans = 1;
  while (N > 0) {
    if (N & 1) ans = ans * A % M;
      A = A * A % M;
      N >>= 1;
   }
  return ans;
}
  
//メイン処理
int main() {
  cout << fixed << setprecision(16); //精度向上
  //ここまでテンプレ
  ll A, B, C;
  cin >> A >> B >> C;
  if (C - A - B < 0) {
    cout << "No" << endl;
  }
  else if (4 * A * B < (C - A - B) * (C - A - B)) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3680
import java.util.*;

public class Main{
        public static void main(String[] args)throws Exception{
                Scanner sc = new Scanner(System.in);

                int[] res = new int[3];

                for(int i = 0; i < 10; i++){
                        int now = sc.nextInt();

                        if(now >= res[0]){
                                int x = res[0];
                                int y = res[1];
                                res[0] = now;
                                res[1] = x;
                                res[2] = y;
                        }else{
                                if(now >= res[1]){
                                        int x = res[1];
                                        res[1] = now;
                                        res[2] = x;
                                }else{
                                        if(now >= res[2]){
                                                res[2] = now;
                                        }
                                }
                         }
                }

                for(int j = 0; j < res.length; j++){
                        System.out.println(res[j]);
                }
        }
}

Measured memory_bytes: 12000
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int max = Math.max(Math.max(a, b), c);
        
        int difSum = max * 3 - a - b - c;
        if (difSum % 2 == 0) {
            System.out.println(difSum / 2);
        } else {
            System.out.println(difSum / 2 + 2);
        }
    }
}


Measured memory_bytes: 21844
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::{Bytes, Chars};
#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
	input! {
		k: usize,
	}

	if k % 2 == 0 {
		println!("-1");
		return;
	}

	let mut ans = 1;
	let mut n = 7usize;
	loop {
		if n % k == 0 {
			println!("{}", ans);
			return;
		}
		n = (n*10 + 7) % k;
		ans += 1;
		if ans > 99999999 {
			println!("-1");
			return;				
		}
	}
}



Measured memory_bytes: 2172
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<iomanip>
using namespace std;

int main(){
    int h,w;
    cin>>h>>w;
    vector<string>s(1000);
    for(int i=0;i<h;i++){
        cin>>s[i];
    }
    for(int i=0;i<h;i++){
        cout<<s[i]<<endl;
        cout<<s[i]<<endl;
    }
    return 0;
}


Measured memory_bytes: 3676
#include<vector>
#include<iostream>
using namespace std;
int main() {
	int n; cin >> n;int b = 0;
	vector<int> v;int h = 0;
	for (int y = 0; y < n; y++) {
		int d; cin >> d;
		v.push_back(d);
	}
	for (int i = 0; i < n;i++) {
		for (int j = 0; j < n; j++) {
			h = b;
			if (i == j)
				continue;
			if (i != j) {
				b = h + (v[i] * v[j]);
			}
		}
	}
	cout << "" << b / 2 <<  endl;
}

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

using namespace std;

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


Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
using namespace std;
int n,m,a[1000];
main()
{
	while(cin>>n>>m,n)
	{
		int ans=0;
		for(int i=0;i<n;i++)
		{
			cin>>a[i];
			ans+=a[i];
		}
		sort(a,a+n);
		for(int i=n-m;i>=0;i-=m)
		{
			ans-=a[i];
		}
		cout<<ans<<endl;
	}
}



Measured memory_bytes: 3040
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<functional>
#include<map>
#include<cstdlib>
#include<complex>
#include<numeric>
#include<set>
#include<deque>
#include<queue>

using namespace std;
using Int = long long;
Int INF = 1LL << 60;
const Int MOD = 1000000000 + 7;

int main() {

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

	Int x, y;
	cin >> x >> y;

	if (x==1&&y==1) {
		cout << 1000000 << "\n";
	}
	else if (x==1) {
		if (y==2) {
			cout << 500000 << "\n";
		}
		else if (y==3) {

			cout << 400000 << "\n";
		}
		else {
			cout << 300000 << "\n";
		}
	}
	else if (y==1) {
		if (x == 2) {
			cout << 500000 << "\n";
		}
		else if (x == 3) {

			cout << 400000 << "\n";
		}
		else {
			cout << 300000 << "\n";
		}
	}
	else if (x==2) {
		if (y == 2) {
			cout << 400000 << "\n";
		}
		else if (y == 3) {

		cout << 300000 << "\n";
		}
		else {
			cout << 200000 << "\n";
		}
	}
	else if (y == 2) {
		if (x == 2) {
			cout << 400000 << "\n";
		}
		else if (x == 3) {

			cout << 300000 << "\n";
		}
		else {
			cout << 200000 << "\n";
		}
	}
	else if (x == 3) {
		
		if (y == 3) {

			cout << 200000 << "\n";
		}
		else {
			cout << 100000 << "\n";
		}
	}
	else if (y == 3) {

		if (x == 3) {

			cout << 200000 << "\n";
		}
		else {
			cout << 100000 << "\n";
		}
	}
	else {
		cout << 0 << "\n";
	}
}


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

int main(void)
{
	double mt, maxi = -1, mini = 1000001;

	while (cin >> mt)
	{
		mini = min(mini, mt); maxi = max(maxi, mt);
	}
	printf("%.2f\n",maxi-mini);
	return 0;
}


Measured memory_bytes: 3116
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#define N 200010
#define ll long long
#define inf 1000000000
using namespace std;
ll f[N<<2],g[N<<2];
int a,b;
void update(int u)
{
	f[u]=min(f[u<<1],f[u<<1|1]);
	g[u]=min(g[u<<1],g[u<<1|1]);
}
void build(int u,int l,int r)
{
	if(l==r)
	{
		if(l==a) f[u]=-l,g[u]=l;
		else f[u]=g[u]=inf;
		return;
	}
	int mid=(l+r)>>1;
	build(u<<1,l,mid);
	build(u<<1|1,mid+1,r);
	update(u);
}
ll answer(int u,int l,int r,int L,int R,int d)
{
	if(L<=l && r<=R) return d?g[u]:f[u];
	int mid=(l+r)>>1;
	ll ans=inf;
	if(L<=mid) ans=min(ans,answer(u<<1,l,mid,L,R,d));
	if(R>mid) ans=min(ans,answer(u<<1|1,mid+1,r,L,R,d));
	return ans;
}
void change(int u,int l,int r,int pos,ll v)
{
	if(l==r)
	{
		f[u]=min(f[u],v-l);
		g[u]=min(g[u],v+l);
		return;
	}
	int mid=(l+r)>>1;
	if(pos<=mid) change(u<<1,l,mid,pos,v);
	else change(u<<1|1,mid+1,r,pos,v);
	update(u);
}
ll ans=inf;
void getmin(int u,int l,int r)
{
	if(l==r){ans=min(ans,f[u]+l);return;}
	int mid=(l+r)>>1;
	getmin(u<<1,l,mid);
	getmin(u<<1|1,mid+1,r);
}
ll num[N];
int main()
{
	int n,m;
	scanf("%d%d%d%d",&n,&m,&a,&b);
	ll sum=0;
	num[0]=b;
	build(1,1,n);
	for(int i=1;i<=m;i++)
	{
		scanf("%lld",&num[i]);
		ll res1=num[i]+answer(1,1,n,1,num[i],0)+sum;
		ll res2=answer(1,1,n,num[i],n,1)-num[i]+sum;
		sum+=abs(num[i]-num[i-1]);
		change(1,1,n,num[i-1],min(res1,res2)-sum);
	}
	getmin(1,1,n);
	printf("%lld\n",sum+ans);
	return 0;
}


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

    //組み合わせの数nCrを計算
    int combi(int n, int r){
        int num = 1;
        for(int i = 1; i <= r; i++){
            num = num * (n - i + 1) / i;
        }
        return num;
    }

int main() {
  int N, M;
  cin >> N >> M;
 
  // N 偶数の数
  // M 奇数の数
  
  int r = 0;
  
  r += combi(N, 2);
  r += combi(M, 2);
  
  cout << r << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
long long M = 1e9+7;
long long power(long long a, long long p)
    {
        if(p==0) return 1;
        long long ans= power(a,p/2);
        ans =(ans * ans) % M;
        if(p%2) ans = (ans*a) % M;
        return ans;
    }

    bool isPrime(long long n)
    {
        if (n <= 1)
            return false;
        for (long long i = 2; i < n; i++)
            if (n % i == 0)
                return false;
        return true;
    }
    long long SieveOfEratosthenes(long long n, long long a)
    {
        bool prime[n+1];
        memset(prime, true, sizeof(prime));
        for (long long p=2; p*p<=n; p++)
        {
            if (prime[p] == true)
            {
                for (long long i=p*p; i<=n; i += p)
                    prime[i] = false;
            }
        }
        for (long long p=2; p<=n; p++)
           if (prime[p])
           {
               if(a%p==0)
               {
                   return (a-p);
               }
           }
    }
    long long nCr(int n, int r)
    {
        if(r > n - r) r = n - r; // because C(n, r) == C(n, n - r)
        long long ans = 1;
        int i;
        for(i = 1; i <= r; i++) {
            ans *= n - r + i;
            ans /= i;
        }
        return ans;
    }
int main()
{
    IOS;
    long long a,b,c,d,e,h,n,t,f,m,f1=0,flag=0,flag1=0,co=0,co1=0,co2=0,arr1[100001]={0},sum=0,sum1=0,ma=0,ma1=0,mi=1000000000000000001;
    long long g,co3=0,co4=0,co5=0,co6=0,co7=0,co8=0,mul=1,sum2=0,sum3=0,mu=1,mu1=1;
    long long a1,b1,a2,b2,a3,b3,a4,b4,a5,b5,b6;
    double pi=2 * acos (0.0);
    string str,str1,str2,str3,str4,str5,str6;
    char ch,ch1;
    //vector<long long>v; //vector<long long> v(n+1);
    //vector<long long>v1;
    // vector<string>vs;
    // vector<string>vs1;
    vector<char>vc;
    //map<long long,long long>mp;
    map<char,int>mp1;
    //set<long long>s;
    set<long long>s1;
    queue<long long> q;
    //stack<long long> stk;
    //vector< pair<long long,long long> >v3;
    //map<long long,long long>::iterator it;
    //map<string,string>::iterator it;
    // vector<pair<char, pair<int,int> > > v3;
    //vector< pair<char,int > > v1;
    int x[]={1,1,1,0,0,-1,-1,-1};
    int y[]={0,1,-1,1,-1,1,-1,0};
    cin>>n;
    a=n;
    while(a>0)
    {
        sum+=a%10;
        a=a/10;
    }
    if(n%sum==0)
        cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
N, M = list(map(int, input().split()))
ABL = []
for i in range(N):
	ABL.append(list(map(int, input().split())))

ABL = sorted(ABL)

c = 0
for i in range(N):
	if M > ABL[i][1]:
		M -= ABL[i][1]
		c += ABL[i][0] * ABL[i][1]
	else:
		c += M * ABL[i][0]
		break

print(c)

Measured memory_bytes: 28656
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <string>
#include <map>
#include <functional>

using namespace std;


int main() {
	int N, K,ans = 1;
	cin >> N >> K;
	
	for (int i = 0; i < N;i++) {
		if (ans < K) {
			ans *= 2;
		}
		else {
			ans += K;
		}
	}
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
  int k;
  cin >> k;
  int a[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2,
  1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  cout << a[k-1] << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

int main(){
  char s[210] = {};
  int l;
  int flag;

  scanf("%s", s);
  l = strlen(s);//s[]の初期の長さ

  for(int i = 1; i <= l/2; i++){
    s[l-(2*i-1)] = 0;
    s[l-(2*i  )] = 0;

    flag = 1;
    for(int j = 0; j <= strlen(s)/2 - 1; j++){
      if(s[j] != s[j+strlen(s)/2]){
        flag = 0;
        break;
      }
    }

    if(flag == 1){
      printf("%lu\n", strlen(s));
      return 0;
    }
  }
  return 0;
}


Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		//int h=sc.nextInt();
		//int w=sc.nextInt();
		//int[][] res=new int[h][w];
		//long n=sc.nextLong(),y=sc.nextLong();
		char buffs='z',bufft='a';
		String ress="",rest="";
		int count=0;
		String s= sc.next();
		String t=sc.next();
		StringBuilder s1=new StringBuilder(s);
		StringBuilder t1=new StringBuilder(t);

		for(int i=0;i<s.length();i++) {
			for(int j=0;j<s1.length();j++) {
				if(s1.charAt(j)<=buffs) {
					buffs=s1.charAt(j);
					count=j;
				}
			}
			ress+=buffs;
			s1.deleteCharAt(count);
			buffs='z';
		}
		for(int i=0;i<t.length();i++) {
			for(int k=0;k<t1.length();k++) {
				if(t1.charAt(k)>=bufft) {
					bufft=t1.charAt(k);
					count=k;
				}
			}
			rest+=bufft;
			t1.deleteCharAt(count);
			bufft='a';
		}

		if(ress.compareToIgnoreCase(rest)<0) {
			System.out.println("Yes");
		}else if(ress.compareToIgnoreCase(rest)>0){
			System.out.println("No");
		}else {
			if(ress.length()<rest.length()) {
				System.out.println("Yes");
			}else {
				System.out.println("No");
			}
		}

	}

}


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

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;

//REPEAT
//------------------------------------------
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define REP(i,n)  FOR(i,0,n)

//container util
//------------------------------------------
#define pb(a) push_back(a)
#define SORT(V) sort((V).begin(),(V).end())

//constant
//------------------------------------------
const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

//main
//------------------------------------------
int main() {
  int H, W, h, w;
  cin >> H >> W >> h >> w;
  cout << H* W - ( W*h + H*w - h*w) << endl;

}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int count(long long x) {
    int ret = 0;
    while(x > 0) {
        ret += x & 1;
        x /= 2;
    }
    return ret;
}

int main () {
    long long k;
    cin >> k;
    int ans = count(k);
    int ket = 0;
    while(k > 0) {
        ket++;
        k /= 2;
    }
    ans = max(ans, ket - 1);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3100
n = int(input())
s = {}

for i in range(n):
  #c = "{}".format(sorted(Counter(input()).most_common()))
  c = "".join(sorted(input()))
  v = s.get(c, 0)
  s[c] = v + 1

result = 0

for v in s.values():
  result += v * (v-1) / 2

print(int(result))


Measured memory_bytes: 17852
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#include <map>
#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 2e9
#define ALL(v) v.begin(), v.end()
typedef long long ll;


int main() { 
    ll N;
    cin>>N;
    vector<ll> h(N);
    ll DP[N];
    REP(i,N){
        cin >> h.at(i);
        DP[i] = INF;
    }
    DP[0] = 0;
    DP[1] = abs(h.at(1) - h.at(0));
    FOR(i,2,N){
        DP[i] = DP[i-1] + abs(h.at(i)-h.at(i-1));
        if(DP[i] > DP[i-2]+abs(h.at(i)-h.at(i-2))){
            DP[i] = DP[i-2]+abs(h.at(i)-h.at(i-2));
        }
    }
    cout << DP[N-1] << endl;
    
}


Measured memory_bytes: 1792
use proconio::input;

// ordtools {{{
#[allow(dead_code)]
mod ordtools {
    pub trait Ordtools: PartialOrd + Clone + Sized {
        fn change_min(&mut self, rhs: &Self) {
            if rhs < self {
                *self = rhs.clone();
            }
        }

        fn change_max(&mut self, rhs: &Self) {
            if rhs > self {
                *self = rhs.clone();
            }
        }
    }

    impl<T: PartialOrd + Clone + Sized> Ordtools for T {}
}
// }}}
use ordtools::Ordtools;

fn main() {
    input!(
        n: usize,
        clim: usize,
        d: [[u32; clim]; clim],
        c: [[proconio::marker::Usize1; n]; n]
    );
    let mut a = [0; 3];
    let mut cnt = vec![[0; 3]; clim];
    for i in 0..n {
        for j in 0..n {
            cnt[c[i][j]][(i + j) % 3] += 1;
        }
    }
    let mut ans = std::u32::MAX;
    loop {
        if a[0] != a[1] && a[1] != a[2] && a[2] != a[0] {
            let mut now = 0;
            for k in 0..clim {
                for l in 0..3 {
                    now += d[k][a[l]] * cnt[k][l];
                }
            }
            ans.change_min(&now);
        }

        if let Some(s) = (0..3).rfind(|&s| a[s] != clim - 1) {
            a[s] += 1;
            a[s + 1..].iter_mut().for_each(|x| *x = 0);
        } else {
            break;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 4820
N = [int(x) for x in list(input())] # 例："1234" → [0, 1, 2, 3, 4]

def dfs(L):
    global N
    if len(L) == len(N):
        if L <= N and L.count(7) > 0 and L.count(5) > 0 and L.count(3) > 0:
            return 1
        else:
            return 0

    ans = 0
    if len(L) == 0 or L[-1] == 0:
        ans += dfs(L + [0])
    for j in [3, 5, 7]:
        ans += dfs(L + [j])
    return ans

print(dfs([]))

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

ans = sum(b)

for i in range(n-1):
    if a[i+1] - a[i] == 1:
        ans += c[a[i]-1]

print(ans)


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

using namespace std;
using ll = long long;

inline int Calcu(int a,int b){
    return min(a, b);
}

class SegTree{
    public:
        int n;
        int g;
        std::vector<int> data;

        SegTree(std::vector<int> a, int _g){
            g = _g;
            for (n = 1; n < (int) a.size(); n *= 2);
            data.resize(n * 2, g);
            //for (int i = 0; i < (int) a.size(); i++) data[i + n] = a[i];
            //for (int i = n - 1; i >= 1; i--)
            //    data[i] = min(data[i], Calcu(data[i * 2], data[i * 2 + 1]));
        }

        int rec(int l, int r, int node, int node_l, int node_r, int val) {
            if (node_r <= l || node_l >= r) return g;
            if (node_l >= l && node_r <= r) return data[node] = min(data[node], val);
            int mid = (node_l + node_r) / 2;
            return Calcu(
                rec(l, r, node * 2, node_l, mid, val),
                rec(l, r, node * 2 + 1, mid, node_r,val));
        }

        void query(int l,int r, int val){
            rec(l,r,1,0,n,val);
        }

        int get(int index){
            int res = data[index += n];
            for(;index /= 2;)
                res = min(res, data[index]);
            return res;
        }
};


int main()
{
    int n, q; cin >> n >> q;
    vector<tuple<int,int,int>> p(n);
    vector<int> c(q);
    for(int i = 0; i < n; i++) {
        int a, b, c; cin >> a >> b >> c;
        a -= c;
        b -= c;
        p[i] = tie(a, b, c);
    }
    for(int i = 0; i < q; i++)cin >> c[i];
    map<int,int> mp;
    for(int i = 0; i < n; i++)mp[get<0>(p[i])] = -1, mp[get<1>(p[i])] = -1;
    for(int i = 0; i < q; i++)mp[c[i]] = -1;

    int za = 0;
    for(auto &i : mp)i.second = za++;

    for(int i = 0; i < n; i++)get<0>(p[i]) = mp[get<0>(p[i])], get<1>(p[i]) = mp[get<1>(p[i])];
    for(int i = 0; i < q; i++)c[i] = mp[c[i]];

    const int INF = 2e9;
    SegTree tree(vector<int>(za), INF);
    for(int i = 0; i < n; i++) {
        int a, b, c; tie(a, b, c) = p[i];
        tree.query(a, b, c);
    }

    for(int i = 0; i < q; i++) {
        cout << (tree.get(c[i]) == INF ? -1 : tree.get(c[i])) << endl;
    }

}

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

int main() {
  int n,point=0,tmp,a[105];

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

  sort(a,a+n,greater<int>());

  for(int i=0;i<n;i++) {
    if(i%2==0) {
      point+=a[i];
    } else {
      point-=a[i];
    }
  }
  cout << point << endl;
}


Measured memory_bytes: 256
s = input()

N = len(s)
if s==s[::-1] and s[:(N-1)//2]==s[:(N-1)//2][::-1] \
                            and s[(N+3)//2-1:]==s[(N+3)//2-1:][::-1]:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=500000004;
const double EPS=1e-6;
const double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
vector<int>g[110000];
bool dame=false;
int M;
int v[110000];
int dfs(int a,int b){
	vector<int>tmp;
	int sz=0;
	for(int i=0;i<g[a].size();i++){
		if(b==g[a][i])continue;
		sz++;
		int t=dfs(g[a][i],a);
		if(t>M)dame=true;
		if(dame)return 0;
		tmp.push_back(t);
	}
	std::sort(tmp.begin(),tmp.end());
	if(b==-1){
		for(int i=0;i<tmp.size()/2;i++){
			if(tmp[i]+tmp[tmp.size()-1-i]>M)dame=true;
		}
		return 0;
	}else if(sz%2==0){
		bool ok=true;
		for(int i=0;i<tmp.size()/2;i++){
			if(tmp[i]+tmp[tmp.size()-1-i]>M)ok=false;
		}
		if(ok)return 1;
		int cnt=0;
		for(int i=0;i+1<tmp.size()/2;i++){
			v[i]=tmp[i+1]+tmp[tmp.size()-2-i];
			if(v[i]>M)cnt++;
		}
		int at=-1;
		if(cnt==0)at=0;
		for(int i=1;at==-1&&i+1<tmp.size();i++){
			int x=i-1;
			if(1+x>=tmp.size()/2)x=tmp.size()/2-2-(x-tmp.size()/2+1);
			if(v[x]>M&&v[x]+tmp[i-1]-tmp[i]<=M)cnt--;
			v[x]+=tmp[i-1]-tmp[i];
			if(cnt==0){
				at=i;break;
			}
		}
		if(at!=-1)ok=true;
		if(ok)return tmp[at]+1;
		else dame=true;
		return 0;
	}else{
		int cnt=0;
		for(int i=0;i<tmp.size()/2;i++){
			v[i]=tmp[i+1]+tmp[tmp.size()-1-i];
			if(v[i]>M)cnt++;
		}
		int at=-1;
		if(cnt==0)at=0;
		for(int i=1;at==-1&&i<tmp.size();i++){
			int x=i-1;
			if(x>=tmp.size()/2)x=tmp.size()/2-1-(x-tmp.size()/2);
			if(v[x]>M&&v[x]+tmp[i-1]-tmp[i]<=M)cnt--;
			v[x]+=tmp[i-1]-tmp[i];
			if(cnt==0){
				at=i;break;
			}
		}
		if(at==-1){dame=true;return 0;}
		return tmp[at]+1;
	}
}
int main(){
	int a;scanf("%d",&a);
	for(int i=0;i<a-1;i++){
		int p,q;scanf("%d%d",&p,&q);p--;q--;
		g[p].push_back(q);g[q].push_back(p);
	}
	int req=1;
	for(int i=0;i<a;i++){
		if(g[i].size()>2)req+=(g[i].size()-1)/2;
	}
	int left=0;
	int right=a;
	while(left+1<right){
		M=(left+right)/2;
		dame=false;
		dfs(0,-1);
		if(dame==false){
			right=M;
		}else left=M;
	}
	printf("%d %d\n",req,right);
}

Measured memory_bytes: 15232
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.IO.Compression;
using System.Linq;
using System.Numerics;
using System.Runtime.CompilerServices;
using System.Security.Cryptography.X509Certificates;
using System.Text;
using System.Text.RegularExpressions;
using Console = System.Console;

namespace Atcoder
{

    class Program
    {
        private const long COMDIV = 1000000007;

        static void Main(string[] args)
        {
            var K = int.Parse(Console.ReadLine());
            var ret = Enumerable.Repeat("ACL", K).ToArray();
            Console.WriteLine(string.Join("",ret));
        }
    }
}

Measured memory_bytes: 28160
import bisect

n,m = map(int, input().split())

n_facs_s = []
n_facs_l = []
for i in range(1, int(-(-m**0.5//1))+1):
    if m%i == 0:
        n_facs_s.append(i)
        n_facs_l.append(m//i)


n_faces = n_facs_s + n_facs_l[::-1]
ind = bisect.bisect_right(n_faces, n)
if n_faces[ind-1] == n:
    ind-=1
print(m//n_faces[ind])


Measured memory_bytes: 38640
#include <cstdio>

int main(void)
{
    int x,y,z;
    scanf("%d%d%d",&x,&y,&z);
    if(x<y)
    {
        if(x<z && z<y)
            printf("Yes\n");
        else
            printf("No\n");
    }
    else
    {
        if(y<z && z<x)
            printf("Yes\n");
        else
            printf("No\n");
    }
    return 0;
}


Measured memory_bytes: 128
#include <algorithm>
#include<iostream>
#include<stdio.h>
#include <algorithm>
#include<iostream>
#include<stdio.h>
#include<vector>
#include<set>
#include<string>
#include<iomanip>
#include<queue>
#include<functional>
#include<cmath>
#define rep(i,n) for(int i=0; i<(int)n; i++)//n回繰り返す
using namespace std;
using ll = long long;
using P = pair<int, int>;
using graph = vector<vector<int>>;
int main() {
	int N;
	cin >> N;
	int a=N/100;
  int  b=(N-(a*100))/10;
  int c=N%10;
  if(a==7||b==7||c==7){
    cout<<"Yes"<<endl;
  }
else{
  cout<<"No"<<endl;
}



}






















































				






























	
	





	
	


	


	


		






Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int N;
    cin >> N;
    vector<long long> A(N);
    set<long long> B;
    for(int i=0; i<N; i++){
        cin >> A.at(i);
        if(B.find(A.at(i))==B.end())
        {
            B.insert(A.at(i));
        }
        else
        {
            B.erase(A.at(i));
        }
    }
    cout << B.size() << endl;
}

Measured memory_bytes: 5760
#include <bits/stdc++.h>
using namespace std;
 
int main() {

  int N;

  cin>>N;

  vector<int> A(N),B(N);

  for(int i=0;i<N;i++) cin>>A.at(i);
  for(int i=0;i<N;i++) cin>>B.at(i);//入力終了

  // Aの累積和
  vector<int> suma(N+1, 0); // suma[0] = 0 になる
  for (int i = 0; i < N; ++i) suma.at(i+1) = suma.at(i) + A.at(i);

  // Bの累積和
  vector<int> sumb(N+1, 0); // sumb[0] = 0 になる
  for (int i = 0; i < N; ++i) sumb.at(i+1) = sumb.at(i) + B.at(i);

  int ans=0;

  for(int i=1;i<=N;i++){
      int sum=(suma.at(i)-suma.at(0))+(sumb.at(N)-sumb.at(i-1));
      if(sum>ans) ans=sum;
  }

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
	char a[101],b[101],c[101];
	int n,ans = 0;
	cin >> n ;
	cin >> a ;
	cin >> b ;
	cin >> c ;
	for (int i = 0; i != n; i++){
		if(a[i] != b[i] && b[i] != c[i] && c[i] != a[i]) ans += 2;
		else if(a[i] != b[i] || b[i] != c[i] || c[i] != a[i]) ans += 1;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.HashSet;
import java.util.InputMismatchException;
import java.util.NoSuchElementException;

public class Main {

	static PrintWriter out;
	static InputReader ir;

	static void solve() {
		out.println(ir.nextInt()*ir.nextInt());
	}

	public static void main(String[] args) throws Exception {
		ir = new InputReader(System.in);
		out = new PrintWriter(System.out);
		solve();
		out.flush();
	}

	static class InputReader {

		private InputStream in;
		private byte[] buffer = new byte[1024];
		private int curbuf;
		private int lenbuf;

		public InputReader(InputStream in) {
			this.in = in;
			this.curbuf = this.lenbuf = 0;
		}

		public boolean hasNextByte() {
			if (curbuf >= lenbuf) {
				curbuf = 0;
				try {
					lenbuf = in.read(buffer);
				} catch (IOException e) {
					throw new InputMismatchException();
				}
				if (lenbuf <= 0)
					return false;
			}
			return true;
		}

		private int readByte() {
			if (hasNextByte())
				return buffer[curbuf++];
			else
				return -1;
		}

		private boolean isSpaceChar(int c) {
			return !(c >= 33 && c <= 126);
		}

		private void skip() {
			while (hasNextByte() && isSpaceChar(buffer[curbuf]))
				curbuf++;
		}

		public boolean hasNext() {
			skip();
			return hasNextByte();
		}

		public String next() {
			if (!hasNext())
				throw new NoSuchElementException();
			StringBuilder sb = new StringBuilder();
			int b = readByte();
			while (!isSpaceChar(b)) {
				sb.appendCodePoint(b);
				b = readByte();
			}
			return sb.toString();
		}

		public int nextInt() {
			if (!hasNext())
				throw new NoSuchElementException();
			int c = readByte();
			while (isSpaceChar(c))
				c = readByte();
			boolean minus = false;
			if (c == '-') {
				minus = true;
				c = readByte();
			}
			int res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res = res * 10 + c - '0';
				c = readByte();
			} while (!isSpaceChar(c));
			return (minus) ? -res : res-1;
		}

		public long nextLong() {
			if (!hasNext())
				throw new NoSuchElementException();
			int c = readByte();
			while (isSpaceChar(c))
				c = readByte();
			boolean minus = false;
			if (c == '-') {
				minus = true;
				c = readByte();
			}
			long res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res = res * 10 + c - '0';
				c = readByte();
			} while (!isSpaceChar(c));
			return (minus) ? -res : res;
		}

		public double nextDouble() {
			return Double.parseDouble(next());
		}

		public int[] nextIntArray(int n) {
			int[] a = new int[n];
			for (int i = 0; i < n; i++)
				a[i] = nextInt();
			return a;
		}

		public long[] nextLongArray(int n) {
			long[] a = new long[n];
			for (int i = 0; i < n; i++)
				a[i] = nextLong();
			return a;
		}

		public char[][] nextCharMap(int n, int m) {
			char[][] map = new char[n][m];
			for (int i = 0; i < n; i++)
				map[i] = next().toCharArray();
			return map;
		}
	}
}


Measured memory_bytes: 21332
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int inf = 1e9 + 7;
const ll longinf = 1LL << 60;
const ll mod = 1e9 + 7;

int main() {
    int A, B;
    cin >> A >> B;
    cout << A * B - A - B + 1;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,k,q,m,a[100010],b[100010];
int main()
{
	cin>>n>>k>>q;
	m=q-k;
	for(int i=1;i<=q;i++)
	{
		cin>>a[i];
		b[a[i]]++;
	}
	for(int i=1;i<=n;i++)
	{
		if(b[i]>m)cout<<"Yes"<<endl;
		else cout<<"No"<<endl;
	}
	return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
typedef long long ll;
typedef vector<vector<ll>> vvl;
typedef vector<ll> vl;
typedef vector<vector<char>> vvc;
typedef vector<char> vc;
typedef pair<ll,ll> pll;
ll max(ll x,ll y){
if(x>y)return x;
else return y;
}
ll min(ll x,ll y){
  return x+y-max(x,y);
}


int main() {
  double t,x;
  cin >> t >> x;
  double ans=t/x;
  cout << fixed << setprecision(10);
  cout << ans << endl;
}

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

using namespace std;

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

#define sz(c) int((c).size())
#define all(c) (c).begin(), (c).end()
#define pb push_back

#define INF int(1e9)
#define EPS 1e-9
#define MOD int(1e9 + 7)

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	int a, b;
	cin >> a >> b;
	if((a + b) % 2 == 0)
		cout << (a + b) / 2 << '\n';
	else
		cout << "IMPOSSIBLE" << '\n';
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <utility>
#include <string>
#include <algorithm>
#include <cmath>

typedef long long ll;
using namespace std;


int main()
{
    string o, e;
    cin >> o >> e;

    for(int i = 0; i < e.size(); i++){
        cout << o[i] << e[i];
    }
    if(o.size() - e.size() == 1){
        cout << o.back(); 
    }
    cout << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REP(i,b) FOR(i,0,b)
#define RFOR(i,a,b) for (int i = a-1; i >= b; i--)
#define RREP(i,a) RFOR(i,a,0)
#define REPALL(v) for (int i = 0; i < v.size(); i++)
#define SORT(v) sort(v.begin(), v.end())
typedef long long ll;
typedef unsigned long long ull;
const int INF = 1e7;
const ll MOD = 1e9 + 7;

int main()
{
  ll n, m;
  cin>>n>>m;
  cout<<(1900 * m + 100 * (n-m)) * (1<<m)<<endl;

  return 0;
}


Measured memory_bytes: 256
S=input()
N=8

for i in range(1<<3):
   output=[S[0]]
   count=int(S[0])
   for j in range(3):
      if((i>>j)&1)==1:
         output.append("+")
         output.append(S[j+1])
         count+=int(S[j+1])

      else:
         output.append("-")
         output.append(S[j+1])
         count-=int(S[j+1])
   
   if count==7:
      T="".join(output)
      T+="=7"
      print(T)
      break

Measured memory_bytes: 3064