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

namespace AtCoder
{
	class Program
	{
		static void Main(string[] args)
		{
			var Instance = new Question();
			Instance.Exec();
		}
	}

	public class Question
	{
		public void Exec()
		{
			long N = long.Parse(Console.ReadLine());
			List<string> nlist = new List<string>();
			for (int i = 0; i < N; ++i) {
				nlist.Add(Console.ReadLine());
			}

			long M = long.Parse(Console.ReadLine());
			List<string> mlist = new List<string>();
			for (int i = 0; i < M; ++i) {
				mlist.Add(Console.ReadLine());
			}

			int max = 0;
			for (int i = 0; i < nlist.Count; ++i) {
				int total = 0;
				for (int j = 0; j < nlist.Count; ++j) {
					if (nlist[i] == nlist[j]) {
						++total;
					}
				}

				for (int j = 0; j < mlist.Count; ++j) {
					if (nlist[i] == mlist[j]) {
						--total;
					}
				}

				if (max < total) {
					max = total;
				}
			}

			Console.WriteLine($"{max}");
			Console.Out.Flush();
			Console.ReadKey();
		}
	}
}

Measured memory_bytes: 13268
#include <algorithm>
#include <boost/optional.hpp>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define REP(i, n) for(int i = 0, i##_MACRO = (n); i < i##_MACRO; i++)
#define RANGE(i, a, b) for(int i = (a), i##_MACRO = (b); i < i##_MACRO; i++)
#define EACH(e, a) for(auto&& e : a)
#define ALL(a) std::begin(a), std::end(a)
#define RALL(a) std::rbegin(a), std::rend(a)
#define FILL(a, n) memset((a), n, sizeof(a))
#define FILLZ(a) FILL(a, 0)
#define INT(x) (static_cast<int>(x))

using namespace std;

using ll = long long;
using VI = vector<int>;
using VI2D = vector<vector<int>>;

constexpr int INF = 2e9;
constexpr double EPS = 1e-10;
constexpr double PI = acos(-1.0);

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

template <typename T>
constexpr int sign(T x) {
	return x < 0 ? -1 : x > 0 ? 1 : 0;
}

template <>
constexpr int sign(double x) {
	return x < -EPS ? -1 : x > EPS ? 1 : 0;
}

template <typename T, typename U>
constexpr void chmax(T& m, U x) {
	m = max(m, x);
}

template <typename T, typename U>
constexpr void chmin(T& m, U x) {
	m = min(m, x);
}

template <typename T>
constexpr T square(T x) {
	return x * x;
}

bool check(VI2D& a) {
	REP(i, 3) {
		if(!a[i][0] && !a[i][1] && !a[i][2]) {
			return true;
		}
	}
	REP(i, 3) {
		if(!a[0][i] && !a[1][i] && !a[2][i]) {
			return true;
		}
	}
	if(!a[0][0] && !a[1][1] && !a[2][2]) {
		return true;
	}
	if(!a[2][0] && !a[1][1] && !a[0][2]) {
		return true;
	}
	return false;
}

int main() {
	VI2D a(3, VI(3));
	REP(i, 3) {
		REP(j, 3) { cin >> a[i][j]; }
	}
	int n;
	cin >> n;
	VI b(n);
	REP(i, n) { cin >> b[i]; }
	REP(i, 3) {
		REP(j, 3) {
			REP(k, n) {
				if(a[i][j] == b[k]) {
					a[i][j] = 0;
					break;
				}
			}
		}
	}

	cout << (check(a) ? "Yes" : "No") << endl;

	return 0;
}


Measured memory_bytes: 256
import sys
import fractions
input = sys.stdin.readline

N = int(input())
A = list(map(int, input().split()))
g = 1
MOD = 10**9+7
ans = 0

for i in A:
    tmp = g*i//fractions.gcd(g, i) # それまでのLCM
    ans *= tmp//g
    g = tmp
    ans += g//i

print(ans%MOD)

Measured memory_bytes: 69848
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
const ll INF = 1e+14;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second

int n;
vector<int> b;
vector<int> ans;
void solve() {
	cin >> n; b.resize(n);
	rep(i, n) {
		cin >> b[i];
	}
	rep(i, n) {
		per(j, b.size()) {
			if (j + 1 == b[j]) {
				ans.push_back(j + 1);
				b.erase(b.begin() + j);
				break;
			}
		}
	}
	if (ans.size() == n) {
		per(i, n) {
			cout << ans[i] << endl;
		}
	}
	else {
		cout << -1 << endl;
	}
}
int main() {
	solve();
	//stop
	return 0;
}


Measured memory_bytes: 256
from collections import defaultdict

n = int(input())
alst = list(map(int, input().split()))
ans = 0
dd = defaultdict(int)
for a in alst:
    dd[a] += 1
for _, num in dd.items():
    ans += num * (num - 1) // 2
for a in alst:
    num = dd[a]
    ret = ans - num * (num - 1) // 2 + (num - 1) * (num - 2) // 2
    print(ret)

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

using namespace std;
 
// macro
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define MOD 1000000007
#define M_PI 3.14159265358979323846
#define ll long long
#define ull unsigned long long
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define SORT(ary) sort(begin(ary), end(ary))
 
// Factorial
// need init
ll factorial_memo[5001];
ll factorial(ll n) {
  factorial_memo[0] = 1;
  if(factorial_memo[n] != -1) return factorial_memo[n];
  factorial_memo[n] = (factorial(n-1) * n) % MOD;
  return factorial_memo[n];
}
 
// Combination(nCr)
// need init
ll nCr_memo[5001][5001];
ll nCr(ll n, ll r) {
  if(r*2 > n) r = n-r;
  if(r == 1) return n;
  if(r == 0) return 1;
  if(nCr_memo[n][r] != -1) return nCr_memo[n][r];
  nCr_memo[n][r] = (nCr(n-1, r) + nCr(n-1, r-1)) % MOD;
  return nCr_memo[n][r];
}
 
void solve() {
  ll N, K;
  cin >> N >> K;
  vector<ll> x(N), y(N);
  vector<ll> xlst(0), ylst(0);
  REP(i, N) {
    cin >> x[i] >> y[i];
    xlst.push_back(x[i]);
    ylst.push_back(y[i]);
  }
  SORT(xlst);
  SORT(ylst);
  ll ans = (xlst[N-1] - xlst[0]) * (ylst[N-1] - ylst[0]);
  REP(xl, N) FOR(xr, xl+1, N) REP(yl, N) FOR(yr, yl+1, N) {
    int cnt = 0;
    REP(i, N) {
      if(xlst[xl]<=x[i] && x[i]<=xlst[xr] && ylst[yl]<=y[i] && y[i]<=ylst[yr]) cnt++;
    }
    if(K <= cnt) {
      ans = min(ans, (xlst[xr]-xlst[xl]) * (ylst[yr]-ylst[yl]));
    }
  }
  cout << ans << "\n";
}
 
int main() {
  // init
  cin.tie(0);
  ios::sync_with_stdio(false);
  solve();
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(p,a,b)    for(int p=a;p<b;p++)
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(), (v).end()
#define INF 0x3f3f3f3f

bool is_palin(string s)
{
    string t(s.rbegin(),s.rend());
    return (s==t);
}


int main() {
    
    
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    int i,j,k,l,n,flag=1;
    string s;
    cin>>s;
    n = (int)s.length();

    
    if(is_palin(s.substr(0,(n-1)/2)) && is_palin(s.substr((n+1)/2,(n-1)/2)) && is_palin(s))cout<<"Yes";
    else cout<<"No";
    return 0;
}

Measured memory_bytes: 256
import sys
import time
import math
def inpl():
    return list(map(int, input().split()))
st = time.perf_counter()
# ------------------------------

N = int(input())
for i in range(1, 9+1):
	if N % i == 0:
		if N // i < 10:
			print('Yes')
			sys.exit()
print('No')

# ------------------------------
ed = time.perf_counter()
print('time:', ed-st, file=sys.stderr)


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

int main(){
  int N;
  cin >> N;
  
  int div;
  int cnt = 0;
  
  for(int i = 1; i <= N; i += 2){
    div = 0;
    for(int j = 1; j <= i; j++){
      if(i % j == 0){
        ++div;
      }
    }
    if(div == 8)  ++cnt;
  }
  
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 256
n = gets.to_i
a = [0] + gets.split.map(&:to_i)

check = [0] + Array.new(n,0)
(1..n).reverse_each do |i|

    if 2 * i > n then
        check[i] = a[i]
    else
        count = 0

        (1..n).each do |j|
            break if ((key = j * i) > n)
            count += check[key]
        end
        
        check[i] = 1 if count % 2 != a[i]
    end
end

ans = []
check.each_with_index do |x,index|
    ans << index if x == 1
end

puts (s = ans.size)
puts ans.join(" ") if s != 0

Measured memory_bytes: 24644
#include<bits/stdc++.h>
using namespace std;
double calcAngle(double h, double m)  
{  

    double hour_angle = 0.5 * (h * 60 + m);  
    double minute_angle = 6 * m; 
  
   
    double angle = (hour_angle - minute_angle);  
   
    angle = min(360 - angle, angle);  
  
    return angle;  
}

int main()
{
 
  double a,b,h,m,mid_angle,ans,pi;
 
  cin>>a>>b>>h>>m;
  pi=acos(-1);
  mid_angle=calcAngle(h,m);
  mid_angle=mid_angle*(pi/180.00);
  mid_angle=cos(mid_angle);
  ans=sqrt(a*a+b*b-(2*a*b*mid_angle));
  cout<<fixed;
   cout << setprecision(20) << ans << '\n'; 
   
return 0;

}


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

int main(){
  int k,x;
  cin >> k >> x;
  int min = x - k + 1;
  int max = x + k - 1;
  for(int i = min ; i <= max ; i++){
    cout << i << " ";
  }
  cout << endl;
  return 0;
}

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

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

typedef vector<vector<int>> vvi;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef vector<ll> vll;

typedef pair<int, int> pii;

typedef queue<int> qi;
typedef queue<string> qs;


#define rep(i, n) for(int i=0; i<(n); ++i)
#define repp(i, a, b) for(int i = (a); i <= (b); i++)
#define repm(i, a, b) for(int i = (a); i >= (b); i--)

#define all(v) v.begin(), v.end()
//sort( all(v) )　などと使える



using pint = pair<int, int>;

int n;
vector<vector<pint>> v;


//bitが正直、不親切の条件をみたすかどうかをboolで返す
bool judge(int bit){
    bool res = true;

    
    //i人目の発言を検証
    rep(i, n){

        //そもそもi人目が不親切ならfalse
        if(!(bit & (1 << i)))  continue;

        rep(j, v[i].size()){
            if(v[i][j].second == 1 && !(bit & (1 << v[i][j].first))) res = false;
            if(v[i][j].second == 0 && (bit & (1 << v[i][j].first))) res = false;
        }
    }

    return res;
}

//bitの1をカウントする
int bit_count(int bit){
    int res = 0;

    rep(i, n){
        if(bit & (1 << i)) res++;
    }

    return res;
}



int main(){
    cin >> n;
    v.resize(n);

    //入力
    rep(i, n){
        int A;
        cin >> A;

        v[i].resize(A);

        rep(j, A){
            cin >> v[i][j].first >> v[i][j].second;
            v[i][j].first--;
        }
    }

    //bit全探索する
    //各bitが正直、不親切の条件をクリアしているなら
    // その正直な人の数をカウントしmaxをとる
    int ans = 0;
    for(int bit = 0; bit < (1 << n); bit++){
        if(judge(bit)) ans = max(ans, bit_count(bit));
    }

    cout << ans << endl;
}

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

using namespace std;

#define ll long long
int main()
{
    int n, res = 0;  cin >> n;
    for (int i = 1; i <= n; i++)
    {
        for (int j = 1; j <= n; j++)
        {
            for (int k = 1; k <= n; k++)
            {
                res += __gcd(i, __gcd(j, k));
            }
            
        }
    }
    cout << res << "\n";
    
}

Measured memory_bytes: 3632
package main

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

var (
	readString func() string
	readBytes  func() []byte
	stdout     *bufio.Writer
)

func init() {
	readString, readBytes = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) (func() string, func() []byte) {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	f1 := func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
	f2 := func() []byte {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Bytes()
	}
	return f1, f2
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readFloat64() float64 {
	f, err := strconv.ParseFloat(readString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(stdout, f, args...)
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdout, args...)
}

func eprintln(args ...interface{}) (int, error) {
	return fmt.Fprintln(os.Stderr, args...)
}

func eprintf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(os.Stderr, f, args...)
}

// readString() string
// readInt() int
// readInt64() int64
// readFloat64() float64

// -----------------------------------------------------------------------------

func main() {
	defer stdout.Flush()

	M := readInt()
	K := readInt()

	if !solvable(M, K) {
		println(-1)
		return
	}
	if M == 0 {
		if K == 0 {
			println("0 0")
		} else {
			println("-1")
		}
		return
	}
	if M == 1 {
		if K == 0 {
			println("0 0 1 1")
		} else {
			println("-1")
		}
		return
	}

	N := int(math.Pow(2, float64(M)))

	sp := ""
	for i := 0; i < N; i++ {
		if i == K {
			continue
		}
		printf("%s%d", sp, i)
		sp = " "
	}
	printf(" %d", K)
	for i := N - 1; 0 <= i; i-- {
		if i == K {
			continue
		}
		printf(" %d", i)
	}
	printf(" %d", K)
	println()

}

func solvable(M, K int) bool {
	if K < int(math.Pow(2, float64(M))) {
		return true
	}
	return false
}

// -----------------------------------------------------------------------------


Measured memory_bytes: 6400
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <algorithm>

using namespace std;

typedef pair<int,int> P;
typedef long long ll; 

ll mod = 1e9 + 7;


int main(){
	int n;
	int x[10],y[10];

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

	double ans = 0.0;
	for(int i=0;i<n;i++){
		for(int j=i+1;j<n;j++){
			ans += sqrt((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j]));
		}
	}
	
	ans = ans * 2 / n;

	printf("%.10f\n",ans);

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int n,sum=0;
    cin>>n;
    int v[n],c[n];
    for(int i=0; i<n; i++)
        cin>>v[i];
    for(int i=0; i<n; i++){
        cin>>c[i];
        if (v[i]-c[i] > 0)
            sum += v[i]-c[i];
    }
    cout<<sum<<endl;
}


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


using namespace std;
long long a[100005];
int main(){
    int n;cin >> n;
    for(int i=1;i<=n;++i){
        scanf("%lld",&a[i]);
    }
    sort(a+1,a+n+1);
    long long ans1=a[n];
    long long check=a[n]/2;
    long long diff=-1;long long ans2;
    for(int i=n-1;i>0;--i){
        long long temp=abs(a[i]-check);
        if(diff==-1){
            diff=temp;
            ans2=a[i];
        }
        else{
            if(temp<diff){
                diff=temp;ans2=a[i];
            }
        }
    }
    cout << ans1 << " " << ans2 << endl;
    return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdio>
#include<cstdlib>
#define rep(i,a) for( int i = 0; i != (a); ++i )

std::string intToStr( int n )
{
	char str[5];
	sprintf( str, "%04d", n );

	return str;
}

int main()
{
	std::string L, S;
	while( std::cin >> L, L != "0000" )
	{
		bool fl = true;

		rep( i, 3 )
			fl &= L[i+1] == L[i];
		if( fl )
		{
			std::cout << "NA" << std::endl;
			continue;
		}

		int ans = 0;
		while( L != "6174" )
		{
			S = L;
			std::sort( L.rbegin(), L.rend() );
			std::sort( S.begin(), S.end() );

			++ans;

			L = intToStr( atoi( L.c_str() ) - atoi( S.c_str() ) );
		}

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

	return 0;
}

Measured memory_bytes: 1264
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
using namespace std;
int main()
{
  string S;
  cin >> S;
  int N = S.length();
  stack<char> st;
  int ans = 0;
  for (int i = 0; i < N; i++)
  {
    if (S[i] == '0')
    {
      if (0 < st.size() && st.top() == '1')
      {
        ans++;
        ans++;
        st.pop();
      }
      else
        st.push(S[i]);
    }
    else
    {
      if (0 < st.size() && st.top() == '0')
      {
        ans++;
        ans++;
        st.pop();
      }
      else
        st.push(S[i]);
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <cstring>
#include <string>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <set>

using namespace std;

int main() {
    int N, K;
    int count = 0;
    cin >> N >> K;
    int A[N + 10];
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }

    int num[N + 10] = {0};
    for (int i = 0; i < N; i++) {
        num[A[i]]++;
    }

    sort(num, num + N, greater<int>());

    for (int i = 0; i < K; i++) {
        count += num[i];
    }

    cout << N - count << endl;

    return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<cstdio>

using namespace std;

int main(int argc, char const *argv[])
{
    int n,q,C=0;
    int S[10001], T[501];
    cin >> n;
    for (int i = 0; i < n; ++i)
    {
        scanf("%d", &S[i]);
    }
    cin >> q;
    for (int i = 0; i < q; ++i)
    {
        scanf("%d", &T[i]);
    }
    for (int i = 0; i < q; ++i)
    {
        for (int j = 0; j < n; ++j)
        {
            if (T[i]==S[j])
            {
                C++; break;
            }
        }
    }

    cout << C << endl;
    return 0;
}

Measured memory_bytes: 3244
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
#define COUT(x) cout << (x) << endl
#define ALL(a) (a.begin()),(a.end())
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll, ll> LP;
const ll LINF = 1LL<<60;
const int INF = 1001001001;
const int MOD = 1000000007;

/* --------------------------------------------------- */


int main() {
    string s;
    cin >> s;
    rep(i, 3) {
        if(s[i] == s[i + 1]) {
            COUT("Bad");
            return 0;
        }
    }
    
    COUT("Good");

    return 0;
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        WhereIsTheBoundary solver = new WhereIsTheBoundary();
        solver.solve(1, in, out);
        out.close();
    }

    static class WhereIsTheBoundary {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int N = in.nextInt();
            int M = in.nextInt();
            String[] d = new String[M];
            for (int i = 0; i < M; i++) {
                d[i] = in.next();
            }
            int[] wsum = new int[N + 1];
            int[] esum = new int[N + 1];
            boolean west = false, east = false;
            for (int i = 0; i < M; i++) {
                for (int j = 0; j < N; j++) {
                    if (d[i].charAt(j) == 'E') {
                        esum[j + 1]++;
                        east = true;
                    } else {
                        wsum[j + 1]++;
                        west = true;
                    }
                }
            }
            if (!east) {
                out.println(N + " " + (N + 1));
                return;
            }
            if (!west) {
                out.println(0 + " " + 1);
                return;
            }
            for (int i = 0; i < N; i++) {
                wsum[i + 1] += wsum[i];
                esum[i + 1] += esum[i];
            }
            int l = -1;
            int diff = (int) 1e9;
            for (int i = 0; i < N - 1; i++) {
                if (esum[i + 1] + wsum[N] - wsum[i + 1] < diff) {
                    l = i + 1;
                    diff = esum[i + 1] + wsum[N] - wsum[i + 1];
                }
            }
            if (wsum[N] <= diff) {
                l = 0;
                diff = wsum[N];
            }
            if (esum[N] < diff) {
                l = N;
            }
            out.println(l + " " + (l + 1));
        }

    }
}

Measured memory_bytes: 37324
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <cmath>
#include <deque>
#include <iterator>
#include <map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
template<class T> inline bool chmax(T& a, T b) {if (a<b) {a=b; return true;} return false;}
template<class T> inline bool chmin(T& a, T b) {if (a>b) {a=b; return true;} return false;}

const ll MOD = 1000000007;
const ll HIGHINF = (ll)1e18;

int main() {
  ll n; cin >> n;
  string s; cin >> s;
  ll ans = 0, x = 0;
  REP(i, n) {
    if (s[i] == 'I') x++;
    else x--;
    chmax(ans, x);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
S = input()
min = 1000
#print(len(S))
for i in range(len(S)-2):
  #print(int(S[i] + S[i+1] + S[i+2]))
  if abs(int(S[i] + S[i+1] + S[i+2])-753) < min:
    min = abs(int(S[i] + S[i+1] + S[i+2])-753)
print(min)

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

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rep2(i, a, b) for (ll i = (a); i < (b); i++)
typedef uint64_t ull;
typedef int64_t ll;
typedef std::pair<ll, ll> PLL;

using namespace std;

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


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
typedef long long ll;
typedef double dd;
#define For(i,j,k) for (int i=j;i<=k;++i)
#define Forr(i,j,k) for (int i=j;i>=k;--i)
#define Set(a,p) memset(a,p,sizeof(a))
using namespace std;
 
template<typename T>bool chkmax(T& a,T b) {return a<b?a=b,1:0;}
template<typename T>bool chkmin(T& a,T b) {return a>b?a=b,1:0;}
 
const int maxn=100000+100;
const ll inf=1e15;
int n;
ll m,ans=-inf;
ll dis[maxn],val[maxn],pre_val[maxn],suf_val[maxn];
ll pre_big[maxn],suf_big[maxn];
 
inline void read(ll &x) {
	x=0;
	ll p=1;
	char c=getchar();
	while (!isdigit(c)) {if (c=='-') p=-1; c=getchar();}
	while (isdigit(c)) {x=(x<<1)+(x<<3)+(c-'0'); c=getchar();}
	x*=p;
}
 
inline void file() {
	freopen("D.in","r",stdin);
	freopen("D.out","w",stdout);
}
 
int main() {
//	file();
	scanf("%d",&n); read(m);
	For (i,1,n) {
		read(dis[i]); read(val[i]);
		pre_val[i]=suf_val[i]=val[i];
	}
	For (i,1,n) pre_val[i]+=pre_val[i-1];
	Forr (i,n,1) suf_val[i]+=suf_val[i+1];
	For (i,1,n) pre_big[i]=max(pre_big[i-1],pre_val[i]-dis[i]*2);
	Forr (i,n,1) suf_big[i]=max(suf_big[i+1],suf_val[i]-(m-dis[i])*2);
	For (i,1,n) chkmax(ans,suf_big[i+1]+pre_val[i]-dis[i]);
	Forr (i,n,1) chkmax(ans,pre_big[i-1]+suf_val[i]-(m-dis[i]));
	printf("%lld\n",max(ans,0ll));
	return 0;
}

Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define lli long long int
#define ulli unsigned long long int
#define ld long double
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define loop(i,a,b) for(lli i=a;i<b;i++)
#define initialize(array,size,value) for(lli i=0;i<size;i++) array[i]=value
#define couta(array,size) for(lli i=0;i<size;i++) cout<<array[i]<<" "
#define vl vector<lli>
#define vp vector< pair <lli,lli> >
#define sl set<lli>
#define msp multiset < pair < long long , long long > > S;
#define pll pair<lli, lli>
#define mll map<lli, lli>              //for( map<lli, lli>::iterator i=result.begin();i!=result.end();i++)cout<<i->fi<<" "<<i->se<<endl;
#define mvl map<lli, vl>
#define umll unordered_map<lli, lli>
#define vt vector<pair<lli, pll >  >
#define vf vector<pair<pll,pll > >
#define qu queue<lli>
//#define pq priority_queue<lli>
#define dq deque <lli>
#define ptr vector<lli>::iterator
#define bs(array,x) binary_search(array.begin(),array.end(),x)
#define lb(array,x) lower_bound(array.begin(),array.end(),x)
#define ub(array,x) upper_bound(array.begin(),array.end(),x)
#define nobw(array,i,j) upper_bound(array.begin(), array.end(), j)-lower_bound(array.begin(), array.end(), i) //number of numbers between i & j
#define vc clear()
#define endl '\n'
#define sp system("pause");
#define INF 9223372036854775807
#define MINF -9223372036854775808
typedef tree<pll,null_type,less<pll>,rb_tree_tag,
tree_order_statistics_node_update> indexed_set;

int main()
{
	ios::sync_with_stdio(0);
    cin.tie(0);
    lli n;
   cin>>n;
  lli a[n];
  for(lli i=0;i<n;i++)cin>>a[i];
  lli maxi=0;
  for(lli i=0;i<n;i++)maxi=max(maxi,a[i]);
  lli ct=0,in=-1;
  for(lli i=0;i<n;i++)if(maxi==a[i])in=i,ct++;
  if(ct>1)in=-1;
  lli maxi2=0;
  for(lli i=0;i<n;i++)if(in!=i)maxi2=max(maxi2,a[i]);
  for(lli i=0;i<n;i++){
    if(i!=in)cout<<maxi<<endl;
    else cout<<maxi2<<endl;
  }









    return 0;
}


Measured memory_bytes: 3200
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define pb push_back
#define vec vector<int>
#define fo(i,n) for(int i=0;i<n;i++)
#define foo(i,a,b) for(int i=a;i<=b;i++)A
#define mp make_pair
#define deb(x) cout<<#x<<"-->"<<x<<endl;
#define deb1a(v) for(auto it:v) {cout<<it<<" ";} cout<<endl;
#define deb2a(v) for(auto it:v){for(auto it1:it) {cout<<it1<<" ";}cout<<endl;}
int32_t main()
{
ios_base::sync_with_stdio(false);
    cin.tie(NULL);
float a,b;
cin>>a>>b;
cout<<ceil((b-1)/(a-1));


}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define all(x) x.begin(),x.end()
#define dbg(x) cout<<#x<<":"<<x<<endl
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,P> PP;

int main(){
  ll n,q;
  cin>>n>>q;
  vector<int> a(n);

  ll tsum=0;
  for(int i=0;i<n;i++){
    cin>>a[i];
    if(i>=n/2)tsum+=a[i];
  }
  reverse(all(a));
  
  ll suma[111111]={};
  ll sump[111111]={};
  suma[0]=a[0];
  sump[n-1]=a[n-1];
  sump[n-2]=a[n-2];
    
  for(int i=1;i<n;i++){
    suma[i]=suma[i-1]+a[i];
    if(i>1)sump[n-1-i]=sump[n+1-i]+a[n-1-i];
  }
  
  for(int i=0;i<q;i++){
    ll x;
    cin>>x;

    if(abs(x-a[n-1])<=abs(x-a[n-2])){
	 cout<<tsum<<endl;
	 continue;
    }

    if(abs(x-a[0])<abs(x-a[1])){
	 cout<<sump[0]<<endl;
	 continue;
    }
    
    ll ok=(n-1)/2,ng=-1,mid;
    while(ok-ng>1){
	 mid=(ok+ng)/2;
	 //	 dbg(mid);
	 ll l=abs(x-a[mid+1]);
	 ll r=abs(x-a[mid*2+2]);
	 if(l<r)ok=mid;
	 else ng=mid;
    }
    //    dbg(ok);
    cout<<suma[ok]+sump[ok*2+2]<<endl;
  }

  return 0;
}


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

int main()
{
    string name1, name2, name3;
    string answer;
    cin >> name1 >> name2 >> name3;
    answer.push_back(name1.at(0));
    answer.push_back(name2.at(0));
    answer.push_back(name3.at(0));
    cout << answer << endl;
}

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


int main()
{

	int N=0,K=0,cnt=0;
	int d[100],A[100][100],sunuke[100]={};

	scanf("%d %d", &N,&K);

	int i,j;


	for(i=0;i<K;i++){
		scanf("%d", &d[i]);

		for(j=0;j<d[i];j++){
			scanf("%d",&A[j][i]);
			sunuke[A[j][i]-1]++;
		}
		
	}

		for(i=0;i<N;i++){
			if(sunuke[i]==0){cnt++;}
		}

		printf("%d", cnt);



	return 0;
}


Measured memory_bytes: 1752
#include <stdio.h>

int main(){
        int N;
        int i, j, k, count;
        scanf("%d", &N);

        count = 0;
        for(i = 1; i <= N; i+=2){
                k = 0;
                for(j = 1; j <= i; j++){
                        if(i % j == 0) k++;
                }
                if(k == 8) count++;
        }
        printf("%d\n", count);
        return 0;
}

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

using namespace std;

typedef long long int ll;

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

typedef pair<int,int> pair;

int main(){
    int k,n;cin >> k >> n;
    vector<int>a(n); for(int i=0;i<n;i++) cin >> a[i];

    int max=k-(a[n-1]-a[0]);

    for(int i=1;i<n;i++){
        int val=a[i]-a[i-1];
        if(max<val){
            max=val;
        }
    }

    int ans=k-max;

    cout << ans << endl;

}

Measured memory_bytes: 1024
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<queue>
#include<string>
#include<cstring>
#include<algorithm>
#include<set>
#include<map>
#include<iomanip>

#define REP(i,n) for(int i=0;i<(n);i++)
#define EPS (1e-7)
#define INF (2e9)
#define MAX_M 100002
// cout << setprecision(10)

using namespace std;
typedef long long int ll;
const ll MOD = 1000000007;


ll dp[MAX_M][2];
string S;
int main(void){
    cin >> S;
    dp[0][0] = 2;
    dp[0][1] = 1;
    for(int i=1;i<S.length();i++){
        if(S[i] == '0'){
            dp[i][0] = dp[i-1][0];
            dp[i][1] = (dp[i-1][1] * 3) % MOD;
        }else{
            dp[i][0] = (dp[i-1][0] * 2) % MOD;
            dp[i][1] = (dp[i-1][0] + dp[i-1][1] * 3)% MOD;
        }
    }
    cout << (dp[S.length()-1][0] + dp[S.length()-1][1])%MOD << endl;
    return 0;
}



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

main() {
  int N; cin >> N;
  vi rate(9, 0);
  rep(i, N) {
    int a;
    cin >> a;
    a = (a < 3200) ? a / 400 : 8;
    rate[a]++;
  }

  int cmin = 0, cmax = 0;
  rep(i, 8) {
    if (rate[i] > 0) cmin++;
  }
  cmax = cmin + rate[8];
  if (cmin == 0) cmin = 1;

  cout << cmin << ' ' << cmax << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define p_b push_back
#define pll pair < ll , ll >
#define lt(v) v[v.size()-1]
#define fori(n) for( int i = 0; i < n; i++)
#define s second
#define f first
using namespace std;
ll M = 1000000007;

int main()
{
    char a;
    cin >> a;
    if(a>='A' && a<='Z')
    {
        cout << 'A';
    }
    else
    {
        cout << 'a';
    }
}


Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <string>

#define rep(x,to) for(int x=0;x<to;x++)
#define rep2(x,from,to) for(x=from;x<to;x++)

using namespace std;


int main(void){

int sg;
int bn[] = {1,2,4,8,16,32,64,128,256,512};

	while(cin >>  sg){
		bool ck[10] ={false};
		rep(i,10){
			if(sg >= bn[9-i]){
				sg -= bn[9-i];
				ck[9-i] = true;
			}
		}
		int cnt=0;
		bool dsw=false;
		rep(i,10)
			if(ck[i]){
				cout << (dsw ? " ":"") << bn[i] ;
				dsw=true;
			}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <cstring>
using namespace std;
int main(){
	char str[101]; char ans[101];
	while(cin >> str){
		int len=strlen(str); int n=0;
		for(int i=0;i<len;i++){
		if(str[i]!='@') ans[n++]=str[i] ;
		else if(str[i]=='@') {
			char j=str[++i]; char ch=str[++i] ;
			for(int k=0;k<j-'0';k++) ans[n++]=ch;
			};
		};
		ans[n]='\0';
		cout << ans << '\n' ;
	};
}

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

int main() {
	int n, x;
	cin >> n >> x;
	int m[n];
	int ans = 0;
	for (int i = 0; i < n; i++) {
		cin >> m[i];
		x -= m[i];
		ans++;
	}

	sort(m, m+n);
	ans += x / m[0];
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <algorithm>
#include <bitset>
#include <cstdlib>
#include <cmath>
#define INF 100000000
#define ll long long int
using namespace std;

/*
vector <int> dx = {1,0,-1,0};
vector <int> dy = {0,1,0,-1};

*/

ll to_int(string s){
  ll ans = atol(s.c_str());

  return ans;
}

int main(){
  string s;
  cin>>s;

  ll ans=0;

  for(int i=0;i<pow(2,s.size()-1);i++){

    bitset <13> bitflag = i;

    ll preans = 0;

    string part;
    part += s[0];

    for(int j=1;j<s.size();j++){

      if(bitflag[j-1] == 1){
        preans += to_int(part);
        part.clear();
        part += s[j];
      } else{
        part += s[j];
      }

    }

    preans += to_int(part);
    part.clear();

    //cout<<preans<<endl;

    ans += preans;

    //cout<<ans<<endl;


  }

  cout<<ans<<endl;




  return 0;
}

Measured memory_bytes: 512
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define MOD 1000000007
using namespace std;

typedef pair<int, int> P;
typedef pair<long long, long long> LLP;

int main() {
    int N, M;
    cin >> N >> M;
    vector<int> A, B, C;
    vector<P> pairs;
    for (int i = 0; i < N; i++) {
        int temp_A;
        scanf("%d", &temp_A);
        A.push_back(temp_A);
    }
    for (int i = 0; i < M; i++) {
        int temp_B, temp_C;
        scanf("%d %d", &temp_B, &temp_C);
        B.push_back(temp_B);
        C.push_back(temp_C);
        pairs.push_back(make_pair(C[i], B[i]));
    }

    sort(A.begin(), A.end(), greater<int>());
    sort(pairs.begin(), pairs.end(), greater<P>());

    long long int sum = 0;
    int now_indexA = 0;
    int now_indexB = 0;
    int now_count = 0;

    for (int i = 0; i < N; i++) {
        if (A[now_indexA] >= pairs[now_indexB].first) {
            sum += A[now_indexA];
            now_indexA++;
        } else {
            sum += pairs[now_indexB].first;
            now_count++;
            if (pairs[now_indexB].second <= now_count) {
                now_count = 0;
                now_indexB++;
            }
        }
    }

    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 2548
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
/* main */
int main(){
    int N, K;
    cin >> N >> K;
    vector<int> a(N);
    for (int i = 0; i < N; i++) cin >> a[i];
    sort(a.begin(), a.end());

    int minD = INF;
    for (int i = 0; i + K - 1 < N; i++) {
        int d = a[i + K - 1] - a[i];
        minD = min(minD, d);
    }
    cout << minD << '\n';
}


Measured memory_bytes: 640
n = int(input())
anslist = []

Y = 1000
M = 1
D = 1
ans = 195 * (Y - 1)
ans += (Y - 1) // 3 * 5
ans += 20 * (M - 1)
ans += D
if Y % 3 != 0:
    ans -= (M - 1) // 2
milenium = ans

for i in range(n):

    Y, M, D = map(int, input().split())
    ans = 195 * (Y - 1)
    ans += (Y - 1) // 3 * 5
    ans += 20 * (M - 1)
    ans += D
    if Y % 3 != 0:
        ans -= (M - 1) // 2
    anslist.append(milenium - ans)


for i in anslist:
    print(i)


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

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

    int n, x, y;
    cin >> n >> x >> y;
    int ans[n] = {};

    for (int i = 1; i < n; i++)
        for (int j = i + 1; j <= n; j++) {
            int cur = min(j - i, abs(x - i) + abs(y - j) + 1);
            ans[cur]++;
        }

    for (int i = 1; i < n; i++)
        cout << ans[i] << '\n';
}


Measured memory_bytes: 3556
#include <bits/stdc++.h>
#include <queue>
#include <algorithm>

using namespace std;

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

Measured memory_bytes: 4036
m,d = gets.split.map(&:to_i)

ans = 0

(1..m).each do |i|
  (1..d).each do |j|
    d1 = j%10
    d10 = j/10
    ans += 1 if d1 >= 2 && d10 >= 2 && d1 * d10 == i
  end
end

puts ans


Measured memory_bytes: 1788
N = int(raw_input())
A = map(int, raw_input().split())
print " ".join(map(str, A))
for i in xrange(1, len(A)):
  key = A[i]
  j = i-1
  while j >= 0 and A[j] > key:
    A[j+1] = A[j]
    j -= 1
  A[j+1] = key
  print " ".join(map(str, A))

Measured memory_bytes: 6476
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<char> vc;
typedef queue<ll> ql;
typedef deque<ll> dql;
typedef priority_queue<ll, vl/*, greater<ll>*/> pql; //降順(/*昇順*/)
typedef set<ll> sl;
typedef pair<ll, ll> pl;
typedef vector<vl> vvl;
typedef vector<pl> vpl;
#define rep(i, n) for(ll i = 0; i < ll(n); ++i)
#define rep2(i, n) for(ll i = 1; i <= ll(n); ++i)
//#define rep(i, k, n) for(ll i = k-1; i < ll(n); ++i)
//#define rep2(i, k, n) for(ll i = k; i <= ll(n); ++i)
#define all(v) (v).begin(), (v).end()
bool chmin(ll &a, ll b) {if(b < a) {a = b; return 1;} return 0;}
bool chmax(ll &a, ll b) {if(b > a) {a = b; return 1;} return 0;}
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;
const ll MAX = 1e9;
const char newl = '\n';

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

  string n;
  cin >> n;
  ll ans=0;
  rep(i, 4) if(n[i]=='2') ans++;
  cout << ans << newl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
//#define ll long long
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
#define rep(i, n) REP(i, 0, n)
#define rep_rev(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
#define all(x) (x).begin(),(x).end()
ll t1,t2,t3;
const ll mod = 1000000007;
const int INF = 1e9;
const ll INFLONG = 1e18;

int main(){
  ll s,w;
  cin >> s >> w;
  string ans;
  if(w >= s){
    ans = "unsafe";
  }else{
    ans = "safe";
  }
  cout << ans << endl;
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
ll mod=1e9+7;

int main(){
  int N;
  ll A[200000];
  ll B[200000];
  cin>>N; 
  for (int i(0);i<N;i++) cin>>A[i];
  for (int i(0);i<N;i++)B[i]=A[i];
  sort(A,A+N);
  int maxi(A[N-1]),maxi2(A[N-2]);
  cerr << maxi <<" " <<  maxi2 << endl;
  if (maxi==maxi2){
    for (int i(0);i<N;i++){
      cout << maxi << endl;
    }
  }else{
    for (int i(0);i<N;i++){
      if (B[i]==maxi) cout << maxi2 << endl;
      else cout << maxi << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 4736
r = 0
N, M = map(int, input().split())
sw_p = [0 for _ in range(N)]
for i in range(M):
  ks = list(map(int, input().split()))
  for s in ks[1:]:
    sw_p[s-1] |= 1 << i

P = list(map(int, input().split()))
p = 0
for i in range(M):
  p |= P[i] << i

for j in range(1 << N):
  t = 0
  for k in range(N):
    if j >> k & 1:
      t ^= sw_p[k]
  if t == p:
    r += 1

print(r)

Measured memory_bytes: 39664
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <tuple>
using namespace std;

int a, b, k;

signed main() {
	int i;
	
	cin >> a >> b >> k;
	
	for (i = a; i >= 1; i--) {
		if (a % i == 0 && b % i == 0) {
			k--;
		}
		if (k == 0) {
			break;
		}
	}
	cout << i << endl;
	return 0;
}

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

using namespace std;

int main(){
	int N;
	int T,A;
	cin >> N >> T >> A;
	int H[N];
	for (int i = 0; i < N; ++i)
		cin >> H[i];

	double min = 100000000;
	int ret;

	for (int i = 0; i < N; ++i){
		double t = abs((double)A-(double)T+ ((double)H[i] * 6 / 1000));
		if (min > t){
			min = t;
			ret = i+1;
		}
	}
	cout << ret << endl;

	return 0;
}

Measured memory_bytes: 256
import Data.List

solve xs 
    | length xs == 1 = head xs
    | otherwise = solve xs'
    where
        xs' = sort $ foldl' step [head xs] (tail xs)
        step (y:ys) z
            | r == 0 = (y:ys) 
            | otherwise = (r:y:ys)
                where
                    r = z `rem` y

main = do 
    getLine
    xs <- sort . map read . words <$> getLine :: IO [Int]
    print $ solve xs

Measured memory_bytes: 39932
n,a,b,c,d = gets.split.map(&:to_i)
a, b = 0, b-a
b *= -1 if b < 0
ranges = [[0,0]]
ret = false
(n-1).times do |i|
  r = [(n-1-i)*c - i*d, (n-1-i)*d - i*c]
  if r[0] <= b && r[1] >= b
    ret = true
    break
  end
end
puts ret ? "YES" : "NO"


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

int main(){
    int n; bool can = false;
    cin >> n;
    for(int i = 0; i < n; i++){
        for(int j = 0; i + j < n; j++){
            if(i*4+7*j == n){ can = true; break; }
        }
        if(can) break;
    }
    if(can) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

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

int main(void) {
  string s;
  cin >> s;
  
  //use flags
  bool yymm = false;
  bool mmyy = false;
  
  
  //Whether yymm or not
  if (0 < (s.at(2) - '0') * 10 + (s.at(3) - '0') * 1 &&  (s.at(2) - '0') * 10 + (s.at(3) - '0') * 1 <= 12) {
    yymm = true;
  }
  
  //Whether mmyy or not
   if (0 < (s.at(0) - '0') * 10 + (s.at(1) - '0') * 1 &&  (s.at(0) - '0') * 10 + (s.at(1) - '0') *1 <= 12) {
    mmyy = true;
  }
  
  if (yymm && mmyy) {
    cout << "AMBIGUOUS" << endl;
  }
  else if (yymm) {
    cout << "YYMM" << endl;
  }
  else if (mmyy) {
    cout << "MMYY" << endl;
  }
  else {
    cout << "NA" << endl;
  }
  
  return 0;
}




Measured memory_bytes: 384
/**
 * C - Multiple Gift
 * https://atcoder.jp/contests/abc083/tasks/arc088_a
 **/
#include<iostream>
#include<math.h>

using namespace std;

int main() {
    long long int x,y;
    int count = 0;
    cin >> x >> y;
    while (x<=y) {
        x=x*2;
        count++;
    }
    cout << count << endl;
}

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

#define fast ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define int long long
#define endl '\n'

using namespace std;

const int N = 2e5 + 77;
// int A[N];

void sol(){
    string s ,t ; cin >> s >> t ;
    int n = s.length() , m = t.length();

    for(int i = n-m; i >=0  ; --i){
        string a = s;
        bool ok = 1;
        for(int j = 0 ; j < m ; ++j){
            if(!(s[i+j]==t[j] || s[i+j]=='?')){ok = 0;break;}
            a[i+j] = t[j];
        }
        if(ok){
            for(int ii = 0; ii < n ; ++ii){
                if(a[ii]=='?') cout << 'a';
                else cout << a[ii] ;
            }
            cout << endl;
            return;
        }
    }

    
    cout << "UNRESTORABLE" << endl;
}

int32_t main(){
    fast;
    int t = 1; 
    // cin >> t; 
    while(t--) sol();    
    return 0;
}

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

int main(){
    int n;
    cin >> n;
    int a[n];
    int even = 0, four = 0;
    for(int i = 0;i < n; i++){
        cin >> a[i];
        if(a[i] % 4 == 0) four++;
        else if (a[i] % 2 == 0 && a[i] % 4 != 0) even++;
    }
    if(four + even / 2 >= n / 2){
        cout << "Yes" << endl;
    } else{
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 640
from fractions import gcd
# from datetime import date, timedelta
# from heapq import *
import heapq
import math
from collections import defaultdict, Counter, deque
from bisect import *
import itertools
import fractions
import sys
sys.setrecursionlimit(10 ** 7)
MOD = 10 ** 9 + 7
# input = sys.stdin.readline


# def lcm(a, b):
#     return a * b / fractions.gcd(a, b)


# def make_divisors(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()
#     return divisors


# def factorize(n):
#     fct = []  # prime factor
#     b, e = 2, 0  # base, exponent
#     while b * b <= n:
#         while n % b == 0:
#             n = n // b
#             e = e + 1
#         if e > 0:
#             fct.append((b, e))
#         b, e = b + 1, 0
#     if n > 1:
#         fct.append((n, 1))
#     return fct


# def is_prime(n):
#     if n == 1:
#         return False

#     for k in range(2, int(math.sqrt(n)) + 1):
#         if n % k == 0:
#             return False

#     return True


# def primes(n):
#     is_prime = [True] * (n + 1)
#     is_prime[0] = False
#     is_prime[1] = False
#     for i in range(2, int(n**0.5) + 1):
#         if not is_prime[i]:
#             continue
#         for j in range(i * 2, n + 1, i):
#             is_prime[j] = False
#     return [i for i in range(n + 1) if is_prime[i]]

# def modpow(a, n, mod):
#     res = 1
#     while n > 0:
#         if n & 1:
#             res = res * a % mod
#         a = a * a % mod
#         n >>= 1
#     return res


# def modinv(a, mod):
#     return modpow(a, mod - 2, mod)


# def cnk(a, b):
#     MOD = 10**9+7
#     ret = 1
#     for i in range(b):
#         ret *= (a-i)
#         ret %= MOD
#         ret = ret * modinv(i+1, MOD) % MOD
#     return ret


# class UnionFind:
#     def __init__(self, n):
#         self.sz = [-1 for i in range(n)]

#     # 検索
#     def find(self, x):
#         if self.sz[x] < 0:
#             return x
#         else:
#             self.sz[x] = self.find(self.sz[x])
#             return self.sz[x]

#     # 併合
#     def union(self, x, y):
#         x = self.find(x)
#         y = self.find(y)
#         if x == y:
#             return False
#         if self.sz[x] > self.sz[y]:
#             x, y = y, x
#         self.sz[x] += self.sz[y]
#         self.sz[y] = x

#     # 同じ集合に属するか判定
#     def same(self, x, y):
#         return self.find(x) == self.find(y)

#     # xが含まれている集合のサイズを求める
#     def size(self, x):
#         return -self.sz[self.find(x)]


def main():
    s = input()
    if (len(s)) % 2 == 1:
        print("No")
        exit()
    for i in range(0 , len(s),2):
        if s[i] == "h" and s[i + 1] == "i":
            pass
        else:
            print("No")
            exit()


    print("Yes")
  


if __name__ == '__main__':
    main()


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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back
#define pii pair<int, int>
#define pll pair<ll, ll>

using namespace std;

typedef long long ll;

/* --- INFやMODの値が適切か確認する --- */
// const int INF = 1 << 30;
// const ll INF = 1LL << 60;
// const ll MOD = 1000000007;

bool dp[81][81][160 * 80];
int a[80][80], b[80][80];

int main() {
  int h, w;
  cin >> h >> w;
  rep(i, h) rep(j, w) cin >> a[i][j];
  rep(i, h) rep(j, w) cin >> b[i][j];

  memset(dp, false, sizeof(dp));
  dp[0][0][0] = 1;

  rep(i, h) rep(j, w) {
    int v = abs(a[i][j] - b[i][j]);
    rep(k, (h + w) * 80) if (dp[i][j][k]) {
      dp[i + 1][j][k + v] = dp[i + 1][j][abs(k - v)] = 1;
      dp[i][j + 1][k + v] = dp[i][j + 1][abs(k - v)] = 1;
    }
  }

  rep(k, 160 * 80) if (dp[h - 1][w][k] || dp[h][w - 1][k]) {
    cout << k << endl;
    return 0;
  }
}


Measured memory_bytes: 82304