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

using namespace std;

const int N = 1e6 + 7;
int n, q;

int ls[N];
int arr[N];
int a[N];
vector<int> mst[N];

void add(int ix, int x)
{
        for (; ix < N; ix += ix & -ix)
                mst[ix].push_back(x);
}

int upto(int ix, int x)
{
        int ret = 0;
        for (; ix; ix -= ix & -ix)
                ret += upper_bound(mst[ix].begin(), mst[ix].end(), x) - mst[ix].begin();
        return ret;
}

int get(int l, int r, int L)
{
        return upto(r, L - 1) - upto(l - 1, L - 1);
}

int main()
{

        ios_base::sync_with_stdio(0);
        cin.tie(0);
        //freopen("in.in", "r", stdin);

        cin >> n >> q;
        for (int i = 1; i <= n; i++)
        {
                cin >> a[i];
                if (!ls[a[i]])
                {
                        add(i, -1);
                }
                else
                        add(i, ls[a[i]]);

                ls[a[i]] = i;
        }

        for (int i = 0; i < N; i++)
        {
                sort(mst[i].begin(), mst[i].end());
        }

        for (int i = 0; i < q; i++)
        {
                int l, r;
                cin >> l >> r;
                cout << get(l, r, l) << "\n";
        }

        return 0;
}

Measured memory_bytes: 63688
#include <cstdio>
#include <algorithm>
#include <cstring>
using namespace std;

int N, A[100005];

int work() {
  int even = 0, odd = 0, one = 0;
  for (int i = 1; i <= N; ++i)
    if (A[i] == 1) one++;
    else if (A[i] & 1) odd++;
    else even++;
  
  if (one) return even & 1;

  if (even & 1) return 1;

  if (!(even & 1) && odd >= 2) return 0;

  for (int i = 1; i <= N; ++i)
    if (A[i] & 1) A[i]--;
  int g = A[1];
  for (int i = 2; i <= N; ++i)
    g = __gcd(g, A[i]);
  for (int i = 1; i <= N; ++i)
    A[i] /= g;
  return work() ^ 1;
}

int main() {
  scanf("%d", &N);
  for (int i = 1; i <= N; ++i)
    scanf("%d", &A[i]);
  
  int res = work();

  if (res) puts("First");
  else puts("Second");
  
  return 0;
}


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

using namespace std;

vector<int> t;


int main(){
	int n,c,k;
	int tt,cnt=1;
	int c_temp, t_temp;
	cin >> n >> c >> k;
	for(int i=0; i<n; i++){
		cin >> tt;
		t.push_back(tt);
	}
	
	sort(t.begin(), t.end());

	int j=0;
	c_temp=0;
	t_temp=t[0];
	while(j<t.size()){
		if(c_temp<c && t[j]<=t_temp+k){
			c_temp++;
			j++;
		}
		else{
			cnt++;
			c_temp=0;
			t_temp=t[j];
		}
	}
	cout << cnt << endl;
	return 0;
}

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

int bubbleSort(int A[], int N){
  int sw = 0;
  bool flag = 1;
  for(int i = 0; flag; i++){
    flag = 0;
    for(int j = N - 1; j >= i + 1; j--){
      if(A[j] < A[j-1]){
      swap(A[j], A[j-1]);
      flag = 1;
      sw++;
    }
  }
  }
  return sw;
}

int main(){
  int A[100], N, sw;
  cin >> N;
  for(int i = 0;i < N; i++){
    cin >> A[i];
  }
  sw = bubbleSort(A, N);
  for(int i = 0; i < N; i++){
    if(i) cout << " ";
    cout << A[i];
  }
  cout << endl;
  cout << sw << endl;
  return 0;
}


Measured memory_bytes: 3080
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

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

    long long ans = 0L;
    sort(A.begin(), A.end(), greater<int>());
    ans = A[0];
    int idx = 1;
    int r = N - 2;
    while(r > 0) {
        if(r == 1) {
            ans += A[idx];
            r -= 1;
        } else {
            ans += 2 * A[idx];
            r -= 2;
        }
        idx++;
    }
    cout << ans << endl;
}

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

#include <iostream>
#include <iomanip>
#include <sstream>
#include <stdint.h>
#include <string.h>

#define _USE_MATH_DEFINES
#include <math.h>

#include <vector>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <deque>
#include <string>

#include <algorithm>
#include <functional>
#include <bitset>
#include <functional>
#include <chrono>
#include <random>

#define sqr(x) (x) * (x)

typedef unsigned int u32;
typedef int i32;
typedef unsigned long long int u64;
typedef long long int i64;
typedef uint16_t u16;
typedef int16_t i16;
typedef uint8_t u8;
typedef int8_t i8;

using namespace std;
using namespace std::chrono;

const i64 mod = 1000000007ll;
const i64 smod = 998244353ll;
const i64 inf = 10000000000000007ll;

const double eps = 1e-10;

struct less_key {
    bool operator()(const std::pair<i64,i64> &left, const std::pair<i64,i64> &right) {
        return left.first < right.first;
    }
};

i64 gcd (i64 a, i64 b, i64 & x, i64 & y) {
    if (a == 0) {
        x = 0;
        y = 1;
        return b;
    }
    i64 x1, y1;
    i64 d = gcd (b % a, a, x1, y1);
    x = y1 - (b / a) * x1;
    y = x1;
    return d;
}

i64 rev(i64 a, i64 m) {
    i64 x, y;
    i64 g = gcd(a, m, x, y);
    if (g != 1) {
        throw g;
    }
    return (x % m + m) % m;
}

i64 binpow(i64 a, i64 p) {
    if (p == 0) {
        return 1;
    }
    if (p == 1) {
        return a;
    }
    i64 t = binpow(a, p / 2);
    t *= t;
    t %= mod;

    if (p % 2) {
        t *= a;
        t %= mod;
    }

    return t;
}

const i64 MAXN = 300005;

i64 n, k;

i64 a[MAXN];
i64 f[MAXN];

i64 cnk(i64 n, i64 k) {
    if (n == k || k == 0) {
        return 1;
    }
    i64 R = f[n];
    R *= rev(f[k], mod);
    R %= mod;
    R *= rev(f[n - k], mod);
    R %= mod;
    return R;
}

int main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout.precision(15); cout.setf(ios::fixed);

    cin >> n >> k;

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

    sort(a + 1, a + n + 1);

    f[0] = 1;
    for (i64 i = 1; i <= n; i++) {
        f[i] = f[i - 1] * i;
        f[i] %= mod;
    }

    i64 smin = 0;
    for (i64 i = 1; i <= n; i++) {
        i64 cn = n - i;
        i64 ck = k - 1;

        if (cn < ck) {
            break;
        }
        i64 c = cnk(cn, ck) * a[i];
        c = (c % mod + mod) % mod;
//        c %= mod;

        smin += c;
        smin %= mod;
    }

    i64 smax = 0;
    for (i64 i = n; i >= 1; i--) {
        i64 cn = i - 1;
        i64 ck = k - 1;

        if (cn < ck) {
            break;
        }

        i64 c = cnk(cn, ck) * a[i];
        c = (c % mod + mod) % mod;

        smax += c;
        smax %= mod;
    }

    i64 R = smax - smin;
    R = (R % mod + mod) % mod;

    cout << R << endl;

    return 0;
}

Measured memory_bytes: 3072
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(int)(a); (i)<(int)(b); ++(i))
#define rFor(i, a, b) for(int (i)=(int)(a)-1; (i)>=(int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;
template<class T> bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T> bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}
template<class T> T div_floor(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>=0 ? a/b : (a+1)/b-1;
}
template<class T> T div_ceil(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>0 ? (a-1)/b+1 : a/b;
}

constexpr lint mod = 1000000007;
constexpr lint INF = mod * mod;
constexpr int MAX = 200010;

void input(char *a, int *al, int &an){
    while(true){
        scanf(" %c", &a[an]);
        if(a[an] == '$') break;
        scanf("%d", &al[an++]);
    }
}

void push(deque<pair<char, int>> &dq, pair<char, int> p){
    if(p.se == 0) return;
    else if(!dq.empty() && dq.rbegin()->fi == p.fi) dq.rbegin()->se += p.se;
    else dq.push_back(p);
}

int main(){
    char a[1010], b[1010], c[1010];
    int al[1010], bl[1010], cl[1010];
    int an = 0, bn = 0, cn = 0;
    input(a, al, an);
    input(b, bl, bn);
    input(c, cl, cn);

    deque<pair<char, int>> dq;
    if(bn == 1){
        rep(i, an)if(a[i] == b[0] && al[i] >= bl[0]){
            al[i] -= bl[0];
            rep(j, i) push(dq, {a[j], al[j]});
            rep(j, cn) push(dq, {c[j], cl[j]});
            For(j, i, an) push(dq, {a[j], al[j]});
            break;
        }
    }
    else{
        rep(i, an)if(a[i] == b[0] && al[i] >= bl[0] && a[i+bn-1] == b[bn-1] && al[i+bn-1] >= bl[bn-1]){
            bool flag = true;
            For(j, 1, bn-1)if(a[i+j] != b[j] || al[i+j] != bl[j]){
                flag = false;
                break;
            }
            if(flag){
                al[i] -= bl[0];
                al[i+bn-1] -= bl[bn-1];
                rep(j, i+1) push(dq, {a[j], al[j]});
                rep(j, cn) push(dq, {c[j], cl[j]});
                For(j, i+bn-1, an) push(dq, {a[j], al[j]});
                i = MAX;
                break;
            }
        }
    }

    if(!dq.empty()){
        for(auto p: dq) printf("%c %d ", p.fi, p.se);
    }
    else{
        rep(i, an) printf("%c %d ", a[i], al[i]);
    }
    printf("%c\n", '$');
}


Measured memory_bytes: 3312
n = gets.to_i

def calc(num)
	return num if num < 10
		
	sum = num
	i = 10
	loop do
		if i < num
			sum += calc(num/i) + (num % i) * (2 ** ((num/i).to_s.size-1))
			i *= 10
		else
			break
		end
	end
	return sum
end

puts calc(n)

Measured memory_bytes: 1788
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <map>
#include <vector>
using namespace std;

int main(int argc, char const *argv[]) {
  int N, M, C;
  cin >> N >> M >> C;
  vector<int> B(M);
  vector<vector<int>> A;
  for (int i = 0; i < M; i++) {
    cin >> B[i];
  }
  for (int i = 0; i < N; i++) {
    vector<int> temp(M);
    for (int j = 0; j < M; j++) {
      cin >> temp[j];
    }
    A.push_back(temp);
  }
  int res = 0;
  for (int i = 0; i < N; i++) {
    int ans = 0;
    for (int j = 0; j < M; j++) {
      ans += A[i][j] * B[j];
    }
    ans += C;
    if (ans > 0) res++;
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
  cin>>n;
  for(int i=0;i<n;i++){
  	int k;
    cin>>k;
    if(k%2 == 0 && !(k%3==0 || k%5==0)){
    	cout<<"DENIED"<<endl;
      return 0;
    }
  }
   cout<<"APPROVED"<<endl;
}

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

int main(){
  char ch;
//  int cnt[26]={0};
  vector<int> cnt(26);

  while ( cin >> ch ){
    if (isupper(ch)) cnt.at(ch-'A') += 1;
    if (islower(ch)) cnt.at(ch-'a') += 1;
    else continue;
  }
  for (int i=0;i<cnt.size();i++){
    cout << (char)(i+'a') << " : " << cnt.at(i) << endl;
  }
  return 0;
}





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

int main(){
  int n;
  string s;
  cin >> n >> s;
  int r=0,w=0;
  for(int i=0;i<n;i++){
    if(s[i]=='R') r++;
    else w++;
  }
  int ans=0;
  for(int i=0;i<r;i++){
    if(s[i]=='W') ans++;
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 3728
#include <bits/stdc++.h>
#define rep(i,l,r)for(int i=(l);i<(r);i++)
const int INF = 2147483647;//int max
const long long int MOD = 1000000007;
using namespace std;
using ll = long long;
using P = pair<int,int>;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//ミョ(-ω- ?)
int main() {
    int a,b;
    cin >> a >> b;
    if(a*b%2)cout << "Yes\n";
    else cout << "No\n";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void)
{
	int n;
	cin >>n;
	int arr[n][3];
	int dp[n][3];
	for(int i=0;i<n;i++)
	{
		cin>>arr[i][0]>>arr[i][1]>>arr[i][2];
	}
	dp[0][0]=arr[0][0];
	dp[0][1]=arr[0][1];
	dp[0][2]=arr[0][2];
	for(int i=1;i<n;i++)
	{
		for(int j=0;j<3;j++)
		{
			dp[i][j]=arr[i][j]+max(dp[i-1][(j+1)%3],dp[i-1][(j+2)%3]);
		}
	}
	cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]))<<"\n";
	return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define ll long long
#define ld long double
#define pii pair<int,int>
#define fi first
#define se second
#define mex 1000005
#define fast  ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
vector<int> adj[mex];
#define pi 3.141592653589793238462643383279502884197169399375
int used[mex];
int p[mex];

void bfs(){
	queue<int> q;
	
	q.push(1);
	used[1] = 1;
	p[1] = -1;
	while (!q.empty()) {
		int v = q.front();
		q.pop();
		for (int u : adj[v]) {
			if (!used[u]) {
				used[u] = 1;
				q.push(u);
				p[u] = v;
			}
		}
	}
}
int main(){
	int n,m;
	cin>>n>>m;
	for(int i=0;i<m;i++){
		int x,y;
		cin>>x>>y;
		adj[x].push_back(y);
		adj[y].push_back(x);
	}
	bfs();
	int q=0;
	for(int i=1;i<=n;i++){
		if(used[i]==0){
			q=1;
			break;
		}
	}
	if(q==1)
	 cout<<"No";
	else{
		cout<<"Yes\n";
		for(int i=2;i<=n;i++)
		 cout<<p[i]<<endl;
	 } 
}



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

int main()
{
  string S;
  cin >> S;
  
  if ('7' == S[3]){
    S[3] = '8';
  }

  cout << S;
    
  return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader
import java.io.InputStream
import java.io.InputStreamReader
import java.util.*
import kotlin.math.abs
import kotlin.math.max
import kotlin.math.min

val MOD = 998244353
class Solver(stream: InputStream, private val out: java.io.PrintWriter) {
  fun solve() {
    val N = ni()
    val M = ni()
    val X = nl()
    val g = Array(N){nal(M + 1)}
    val INF = 1e18.toLong()
    var ans = INF
    for (bit in 0 until (1 shl N)) {
      val sum = LongArray(M)
      var cost = 0L
      for (i in 0 until N) {
        if ((bit shr i and 1) == 1) {
          for (j in 0 until M) {
            sum[j] += g[i][j + 1]
          }
          cost += g[i][0]
        }
      }
      val ok = sum.all { it >= X }
      if (ok && cost > 0) {
        debug{"bit:${Integer.toBinaryString(bit)} cost:$cost sum:${sum.joinToString(" ")}"}
        ans = min(cost, ans)
      }
    }
    if (ans == INF) {
      out.println(-1)
    } else {
      out.println(ans)
    }
  }













































  private val isDebug = try {
    // なんか本番でエラーでる
    System.getenv("MY_DEBUG") != null
  } catch (t: Throwable) {
    false
  }

  private var tokenizer: StringTokenizer? = null
  private val reader = BufferedReader(InputStreamReader(stream), 32768)
  private fun next(): String {
    while (tokenizer == null || !tokenizer!!.hasMoreTokens()) {
      tokenizer = StringTokenizer(reader.readLine())
    }
    return tokenizer!!.nextToken()
  }

  private fun ni() = next().toInt()
  private fun nl() = next().toLong()
  private fun ns() = next()
  private fun na(n: Int, offset: Int = 0): IntArray {
    return map(n) { ni() + offset }
  }
  private fun nal(n: Int, offset: Int = 0): LongArray {
    val res = LongArray(n)
    for (i in 0 until n) {
      res[i] = nl() + offset
    }
    return res
  }

  private fun na2(n: Int, offset: Int = 0): Array<IntArray> {
    val a  = Array(2){IntArray(n)}
    for (i in 0 until n) {
      for (e in a) {
        e[i] = ni() + offset
      }
    }
    return a
  }

  private inline fun map(n: Int, f: (Int) -> Int): IntArray {
    val res = IntArray(n)
    for (i in 0 until n) {
      res[i] = f(i)
    }
    return res
  }

  private inline fun debug(msg: () -> String) {
    if (isDebug) System.err.println(msg())
  }

  private fun debug(a: LongArray) {
    debug { a.joinToString(" ") }
  }

  private fun debug(a: IntArray) {
    debug { a.joinToString(" ") }
  }

  private fun debug(a: BooleanArray) {
    debug { a.map { if (it) 1 else 0 }.joinToString("") }
  }

  private fun debugDim(A: Array<LongArray>) {
    if (isDebug) {
      for (a in A) {
        debug(a)
      }
    }
  }

  /**
   * 勝手にimport消されるのを防ぎたい
   */
  private fun hoge() {
    min(1, 2)
    max(1, 2)
    abs(-10)
  }
}

fun main() {
  val out = java.io.PrintWriter(System.out)
  Solver(System.`in`, out).solve()
  out.flush()
}

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

int main(){
	int x,n;
	int p[152];

	cin>>x>>n;
	for(int i=0;i<=150;i++){
		p[i]=0;
	}
	for(int i=0;i<n;i++){
		int a;
		cin>>a;
		p[a] = 1;
	}
	int ans = 110,dif=10000;
	for(int i=110;i>=-100;i--){
		if(0<=i){
			if(p[i]==0 && abs(x-i)<=dif){
				dif=abs(x-i);
				ans = i;
			}
		}
		else{
			if(abs(x-i)<=dif){
				dif=abs(x-i);
				ans = i;
			}
		}
	}

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


Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define IO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define DB(x) cerr << __LINE__ << ": " << #x << " = " << (x) << "\n"
using namespace std;
using ll = long long;

signed main() {
    IO;
    ll n, m, k;
    cin >> n >> m >> k;
    
    vector<ll> a(n + 1, 0), b(m + 1, 0), pa(n + 1, 0), pb(m + 1, 0);
    for(int i = 1; i <= n; ++i) {
    	cin >> a[i];
    	pa[i] = pa[i - 1] + a[i];
    }
    for(int i = 1; i <= m; ++i) {
    	cin >> b[i];
    	pb[i] = pb[i - 1] + b[i];
    }
    ll ans = 0;
    for(ll i = 0; i <= n; ++i) {
    	if(pa[i] > k) {
    		break;
    	}
    	ll idx = lower_bound(pb.begin(), pb.end(), k - pa[i]) - pb.begin();
    	if(idx == m + 1) {
    		--idx;
    	}
    	else if(pb[idx] > k - pa[i]) --idx;
    	ans = max(ans, i + idx);
    }
    cout << ans;
    return 0;
}

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

using namespace std;

bool is_palindrome(string s){
	string tmp = s;
	reverse(s.begin(),s.end());
	return s == tmp;
}


int main(){
	string s;
	cin >> s;
	int len = s.size();
	bool ok = is_palindrome(s) & is_palindrome(s.substr(0,len / 2)) & is_palindrome(s.substr(len / 2 + 1,len));
	if(ok){
		cout << "Yes";
	} else{
		cout << "No";
	}
	return 0;
}


Measured memory_bytes: 3632
N, M = map(int, input().split())
D = {}
for i in range(M):
    p, y = map(int, input().split())
    if p not in D:
        D[p] = [(i, y)]
    else:
        D[p].append((i, y))

for p in D.keys():
    D[p].sort(key=lambda p: p[1])

ans = [None for i in range(M)]
for p, pairs in D.items():
    for x, pair in enumerate(pairs):
        x += 1
        i = pair[0]
        y = pair[1]
        out = "{0:06d}{1:06d}".format(p, x)
        ans[i] = out
        # ans.append((i, out))
# ans.sort(key=lambda p: p[0])
for an in ans:
    print(an)


Measured memory_bytes: 42952
#PyPy必須？
n,w=map(int,input().split())
v=10**5
WV=[list(map(int,input().split())) for i in range(n)]
#dp[i][v] 価値vでの最低体重
dp=[[10**10]*(v+1) for i in range(n+1)]
for i in range(n):
    dp[i][0]=0
for i in range(n):
    for j in range(v+1):
        if j-WV[i][1]>=0 and j-WV[i][1]<=v:
            dp[i+1][j]=min(dp[i][j-WV[i][1]]+WV[i][0], dp[i][j])
        else:
            dp[i+1][j]=dp[i][j]
for j in range(v, -1, -1):
    if dp[n][j]<=w:
        print(j)
        break

Measured memory_bytes: 120172
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(n);i++)
using namespace std;
typedef unsigned long long ull;
typedef long long 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; }
const ll INF=1e18;
const ll MOD=1e9+7;
const double pi=acos(-1);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n,k;
  cin >> n >> k;
  vector<int>a(n);
  rep(i,n) cin >> a[i];
  int dp[k+1]={};
  dp[0]=0;
  for(int i=1;i<=k;i++){
    rep(j,n){
      if(i-a[j]>=0 && dp[i-a[j]]==0)dp[i]=1;
    }
  }
  if(dp[k]>0)cout << "First" << endl;
  else cout<<"Second"<<endl;
    
}

Measured memory_bytes: 640
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
const int maxn = 1005;
int a[maxn];
int dis[maxn];
int main(){
	int n,t,aa;
	scanf("%d%d%d",&n,&t,&aa);
	for(int i = 1;i<=n;i++){
		scanf("%d",&a[i]);
		dis[i] = abs(t*1000-6*a[i]-aa*1000);
	}
	int res = 0x3f3f3f3f;
	int num;
	for(int i = 1;i<=n;i++){
		//printf("%d %d\n",i,dis[i]);
		if(res>dis[i]){
			res = dis[i];
			num = i;
		}
	}
	printf("%d\n",num);
	return 0;
} 

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
using namespace std;
#define i64  long long
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000

// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template<typename T> void DEBUG(T e){std::cout << e << std::endl;}
template<class T> void DEBUG(string str, T e){std::cout <<str << ">>" << e << std::endl;}
template<typename T> void DEBUG(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ DEBUG(v); } }
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

void solve(void)
{
  string x;
  cin>>x;
  for (int i = 0; i < x.size(); i++)
  {
    cout<<"x";
  }
  cout<<endl;
  

  
  return; 
}


int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();

 
  return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;

public class Main {
	int DATAKIND = 26;
	int[] count;
	public static void main(String[] args) 
	throws IOException{
		// TODO Auto-generated method stub
		new Main().run();
	}
	
	public Main(){
		count = new int[DATAKIND];
		for (int i=0; i<count.length; i++)
			count[i] = 0;
		
	}

	void run () 
		throws IOException{
		StandardIn buf = new StandardIn();
		
		ArrayList<String> al = buf.getlines(0);
		for(int i=0; i<al.size(); i++)
			countData(al.get(i).toCharArray());
		
		
		printResult(count);
	}
	
	private void printResult(int[] count){
		for(int i=0; i<count.length; i++)
			System.out.println(gethashkey(i)+" : "+count[i]);
	}
	private int[] countData(char[] data){

		for (int i=0; i<data.length; i++)
			if(Character.isAlphabetic(data[i]))
				count[hashdata(Character.toLowerCase(data[i]))] ++;
		
		return count;
	}
	
	private int hashdata(char data){
		return (int)(data-'a');
	}
	
	private String gethashkey(int data){
		return Character.toString((char)(data+'a'));
	}
}

class TempReaderCall{
	/*
	static ArrayList<String> getStdInReadlines(BufferedReader br, int line) throws IOException {
		ArrayList<String> list = new ArrayList<String>();
		for (int i = 0; i < line; i++)
			list.add(br.readLine());
		return list;
	}
	
	static ArrayList<String> getStdInReadlines(BufferedReader br, String end) throws IOException {
		ArrayList<String> list = new ArrayList<String>();
		String newdata;
		do{
			newdata =br.readLine();
			if (end.compareTo(newdata)==0)
				break;
			list.add(newdata);
		}while(newdata!=null);
		
		return list;
	}
	
	static String getStdInRead(BufferedReader br) throws IOException {
		return (br.readLine());
	}
	*/
	
	static int[] splitIntArrayFromString(String st) {
		String[] sts = st.split(" ");
		int[] data = new int[sts.length];
		
		for (int i=0;i<sts.length;i++){
			data[i] = Integer.parseInt(sts[i]);
		}
		
		return data;
	}
}

class StandardIn{
	private BufferedReader br;
	
	StandardIn(){
		br = new BufferedReader (new InputStreamReader(System.in));
	}
	
	ArrayList<String> getlines(int line) throws IOException {
		ArrayList<String> list = new ArrayList<String>();
		if (line==0){
			String tmplinedata;
			while(null != (tmplinedata = br.readLine())){
				list.add(tmplinedata);
			}
		}
		else {
			for (int i = 0; i < line; i++)
				list.add(br.readLine());
		}
		return list;
	}
	
	ArrayList<String> getlines(String end) throws IOException {
		ArrayList<String> list = new ArrayList<String>();
		String newdata;
		do{
			newdata =br.readLine();
			if (end.compareTo(newdata)==0)
				break;
			list.add(newdata);
		}while(newdata!=null);
		
		return list;
	}
	
	String getaline() throws IOException {
		return (br.readLine());
	}
}

Measured memory_bytes: 24392
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <stdio.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int N, K;
ll V[55], ans = 0;

int main(){
  scanf("%d%d", &N, &K);
  for (int i = 0; i < N; i++) scanf("%lld", V + i);

  for (int L = 0; L <= min(N, K); L++){
    for (int R = 0; L + R <= min(N, K); R++){

      priority_queue <ll, vector<ll>, greater<ll> > que;
      ll now = 0;
      for (int i = 0; i < L; i++){
        now += V[i];
        if (V[i] < 0) que.push(V[i]);
      }
      for (int i = 0; i < R; i++){
        now += V[N - 1 - i];
        if (V[N - 1 - i] < 0) que.push(V[N - 1 - i]);
      }

      int cnt = 0;
      while (!que.empty() && cnt < K - (L + R)){
        ll Q = que.top(); que.pop();
        cnt++;
        now -= Q;
      }
      ans = max(ans, now);
    }
  }
  cout << ans << endl;


  return 0;
}


Measured memory_bytes: 3668
#include <bits/stdc++.h>
#define INF 990000000
//
using namespace std;

long long int a,b;

int main() {

cin>>a>>b;

int a2=a/0.08;
int b2=b/0.1;
int flag=0;

for(int i=(b2-10);i<=(a2+10);i++){
int r=i*0.08;
int s=i*0.1;

if(r==a && s==b){
cout << i<<endl;
flag=1;
break;
}
}

if(flag==0)
cout <<-1<<endl;


}






Measured memory_bytes: 256
(function main(){
  let lines = require('fs').readFileSync('/dev/stdin', 'utf8').trim().split("\n");
  let [n, k] = lines.shift().split(' ').map(Number);
  let w = lines.map(Number);

  const canAllStack = (p) => {
    let cnt = 0;
    for (let i = 0; i < k; i++){
      let sum = 0;
      for (;sum + w[cnt] <= p;) {
        sum += w[cnt++];
        if (cnt === n) return true;
      }
    }
    return false;
  };

  let p = Math.floor(w.reduce((a, b) => a + b) / k) - 1;
  while (!canAllStack(++p));
  console.log(p);

})();



Measured memory_bytes: 32296
import sys
def can_load(num_baggages, baggages, num_truck, max_load):
    bag_no = 0

    for i in range(num_truck):
        load_cap = max_load
        while load_cap > 0:
            if bag_no >= num_baggages:
                #print(max_load, "True")
                return True
            if load_cap >= baggages[bag_no]:
                load_cap -= baggages[bag_no]
                bag_no += 1
            else:
                break
    #print(max_load, bag_no >= num_baggages)
    return bag_no >= num_baggages

def main():
    num_baggages, num_trucks = map(int, input().split())
    baggages = list(map(int, sys.stdin.read().splitlines()))

    start = max(sum(baggages) // num_trucks, min(baggages))
    end = sum(baggages)

    while start < end:
        mid = (start + end) // 2
        if can_load(num_baggages, baggages, num_trucks, mid):
            end = mid
        else:
            start = mid + 1

    print(start)
    return


main()


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

int main()
{
  ll n;
  ll M = 1000000007;
  cin>>n;
  ll A[n];
  ll B[n];
  ll ans = 0;
  for(ll i = 0;i < n;i++)
    cin>>A[i];
  B[n-1] = A[n-1];
  for(ll i = n-2;i >= 0;i--)
  {
    B[i] = (A[i] + B[i+1])%M;
  }
  for(ll i = 0;i < n-1;i++)
  {
    ans = (ans + ((A[i]%M)*(B[i+1]%M))%M)%M;
  }
  cout<<ans<<"\n";
}
  

Measured memory_bytes: 6712
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define REP(i,n) for (ll i = 0; i < (n); ++i)

ll K;
ll cnt = 0;

void search(ll pos, ll nd, ll num){
    if(pos == nd){
        if(cnt == K - 1){
            cout << num << endl;
            exit(0);
        }
        cnt++;
        return;
    }

    ll start, end;
    if(pos == 0){
        start = 1;
        end = 9;
    }else{
        start = max(0LL, num % 10 - 1);
        end = min(9LL, num % 10 + 1);
    }
    for(ll x = start; x <= end; ++x){
        search(pos + 1, nd, 10 * num + x);
    }
}

int main(){
    cin >> K;
    for(ll nd = 1; nd <= 10; ++nd){
        search(0, nd, 0);
    }
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define rep(i,n) for(int (i)=0;(i)<(ll)(n);++(i))
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(x,y) (x=min(x,y))
#define chmax(x,y) (x=max(x,y))
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}

int main(){
	string s[2];
	cin>>s[0]>>s[1];
	reverse(all(s[1]));
	cout<<(s[0]==s[1]?"YES":"NO")<<endl;

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rint register int
#define ll long long 
using namespace std;
ll ans[1000010],q[1011000],Seq[1010000],cnt,Num[1010000];
int N,Q;
inline void Gao(ll a,ll b) {
	int pos=upper_bound(Seq+1,Seq+cnt+1,a)-Seq-1;
	if(!pos) {
		ans[1]+=b;ans[a+1]-=b;
		return ;
	}
	else {
		Num[pos]+=b*(a/Seq[pos]);
		Gao(a%Seq[pos],b);
	}
}
int main(){
	cin>>N>>Q;
	Seq[++cnt]=N;
	for(rint i=1;i<=Q;++i) {
		ll x;cin>>x;
		while(cnt&&Seq[cnt]>=x) cnt--;
		Seq[++cnt]=x;
	}
	Num[cnt]=1;
	for(rint i=cnt;i>1;--i){
		Num[i-1]+=Num[i]*(Seq[i]/Seq[i-1]);
		Gao(Seq[i]%Seq[i-1],Num[i]);
	}
	ans[1]+=Num[1];
	ans[Seq[1]+1]-=Num[1];
	cout<<ans[1]<<endl;
	for(rint i=2;i<=N;++i) {
		ans[i]+=ans[i-1];
		cout<<ans[i]<<endl; 
	} 
	return 0;
} 

Measured memory_bytes: 5980
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 4000000000000000000LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(6);
  std::cerr << std::fixed << std::setprecision(6);

  int A, B;

  std::cin >> A >> B;

  for (int C = 1; C <= 3; C ++)
     if (A * B * C % 2) {
      std::cout << "Yes" << std::endl;

      return 0;
    }

  std::cout << "No" << std::endl;

  return 0;
}


Measured memory_bytes: 256
import numpy as np

n,p =input().split()
n = int(n)
p = int(p)

a_list = input().split()
a_list = [int(x) for x in a_list]
a_array = np.array(a_list)

amari = a_array % 2

zero_count = np.sum(amari == 0)
one_count = np.sum(amari == 1)

zero_pattern = 2**zero_count
if p == 0:
    if one_count >= 2:
        one_pattern = 2**one_count/2
    else:
        one_pattern = 1
else:
    if one_count >= 1:
        one_pattern = 2**one_count/2
    if one_count < 1:
        one_pattern = 0
        
print(int(zero_pattern * one_pattern))

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

multiset<int> ms;
int n, a[200010];

int main(){
    scanf("%d", &n);
    for(int i = 1; i <= n; i++){
        scanf("%d", &a[i]);
        ms.insert(a[i]);
    }

    sort(a + 1, a + 1 + n);
    int ans = 0;
    for(int i = n; i >= 1; i--){
        int val = a[i];
        if(ms.find(val) != ms.end()){
            ms.erase(ms.find(val));
            for(int j = 0; j <= 30; j++){
                if(val < (1 << j)){
                    int need = (1 << j) - val;
                    if(ms.find(need) != ms.end()){
                        ms.erase(ms.find(need));
                        ans++;
                    }
                    break;
                }
            }
        }
    }
    printf("%d\n", ans);
    return 0;
}

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

    int n,k;
    cin>>n>>k;

    int wk;
    if(n%2==0)
        wk=n/2;
    else
        wk=n/2+1;

    if(wk>=k)
        cout<<"YES"<<endl;
    else
        cout<<"NO"<<endl;

    return 0; 
} 

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

int main() {
	int l,r,d,counter=0;
	cin>>l>>r>>d;
	for(int i=l;i<=r;i++)
	{
		if(i%d==0)
		{
			counter++;
		}
	}
	cout<<counter<<endl;
	return 0;
}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
#define ls p<<1
#define rs p<<1|1 
#define fast ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define mm make_pair
#define pi 2*acos(0.0)
#define lcm(a,b) (a*b)/__gcd(a,b)
#define cp(i,ans) printf("%.if",ans);
#define cpp(i,ans) cout.precision(i);cout<<fixed<<ans<<endl;
#define lowbit(x) (x)&(-x)
#define out(x) {cout<<x<<endl;return 0;} 
#define all(v) v.begin(),v.end() 
#define mem(x,i) memset(x,i,sizeof(x)) 
#define mec(x,y) memcpy(x,y,sizeof(y))
#define eps 1e-8 
#define ull unsigned long long
#define cps CLOCKS_PER_SEC
using namespace std;
typedef long long ll;
const int mod=1e9+7;
const int inf=0x3f3f3f3f;
ll gcd(ll x,ll y){if(y==0) return x;else return gcd(y,x%y);} 
ll ksm(ll a,ll b){ll r=1;while(b){if(b&1) r=(r*a)%mod;a=a*a%mod;b>>=1;}return r;} 
void exgcd(ll a, ll b, ll &x, ll &y, ll &d){if(!b) d=a,x=1,y=0;else exgcd(b,a%b,y,x,d),y-=a/b*x;}
ll inv(ll a, ll p){ll x,y,d;exgcd(a,p,x,y,d);x=(x%p+p)%p;return x;}
inline int read()
{
    char c=getchar();int x=0,f=1;
    while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
    while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}
    return x*f;
}
const int maxn=1e5+100;
int n,m,k,t;
string s;
vector<int> g[maxn];
int vis[maxn],h[maxn],val[maxn];
void dfs(int u)
{
	
}
int main()
{
	cin>>n>>m;
	FOR(i,1,n) cin>>h[i];
	FOR(i,1,n) val[i]=1;
	FOR(i,1,m)
	{
		int x=read(),y=read();
		int u=h[x],v=h[y];
		if(u>v) val[y]=0;
		else if(v>u) val[x]=0;
		else val[x]=val[y]=0;
	}
	int sum=0;
	FOR(i,1,n) if(val[i]) sum++;
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 6756
#include <stdio.h>

int main(void)
{

	int n, ii, idx;
	int a[100];
	char c;

	scanf("%d", &n);
	for (idx = n - 1; idx >= 0; idx--) {
		scanf("%d", &a[idx]);
		scanf("%c", &c);
	}
	for (ii = 0; ii < n; ii++) {
		if (ii != 0) {
			printf(" ");
		}
		printf("%d", a[ii]);
	}

	printf("\n");

	return 0;

}

Measured memory_bytes: 600
// Wed Jul 29 19:48:22 IST 2020    
#include <bits/stdc++.h>        
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#define forn(ii,a,b)        for(int ii = (int)a ; ii < (int)b  ; ii++ )
#define debug(x)           cerr << #x << " " << x << " -- \n"
#define I__O               ios::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define int64              long long   
#define all(x)             (x).begin(),(x).end() 
#define precise(x)         cout << fixed << setprecision(12) << x << '\n'; 
using namespace std ;    
// policy based   
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set ; 
 
const int MOD = 1e9+7;
const double pi = 3.141592653589793238;
const int N = 2e5+7; 
const int INF = INT_MAX;
  
int tests(){ 
    int64 n,ans = 0;
    int64 d,x,y;
    cin >> n >> d;
    for(int i = 0 ; i <  n ; i++){
        cin >> x >> y;
        ans += (x*x + y*y <= d*d);
    }
    cout << ans << '\n';
  return 0;
}   

int32_t main(){
    I__O ;     
    int cases = 1 ;  
    // cin >> cases ;
    for(int test = 1 ; test <= cases ; test++){ 
        // cout << "Case #" << test << ":" << '\n';
        tests();
    }    
    return 0 ; 
}


Measured memory_bytes: 3636
from itertools import *
N,A,B,C = map(int, input().split())
L = [int(input()) for n in range(N)]
ans = []

for i in product(range(4),repeat=N):
  a = 0
  b = 0
  c = 0
  d = 0
  for j in range(N):
    if i[j]:
      d+=1
      if i[j]==1:
        a+=L[j]
      elif i[j]==2:
        b+=L[j]
      else:
        c+=L[j]
  if a*b*c:
    ans+=[abs(A-a)+abs(B-b)+abs(C-c)+10*(d-3)]

print(min(ans))

Measured memory_bytes: 10852
#include <string>
#include <vector>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<functional>
#include<list>
#include<deque>
#include<bitset>
#include<set>
#include<map>
#include<cstring>
#include<sstream>
#include<complex>
#include<iomanip>
#define X first
#define Y second
#define pb push_back
#define rep(X,Y) for (int (X) = 0;(X) < int(Y);++(X))
#define rrep(X,Y) for (int (X) = int(Y-1);(X) >=0;--(X))
#define repe(X,Y) for ((X) = 0;(X) < int(Y);++(X))
#define peat(X,Y) for (;(X) < int(Y);++(X))
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<int,double> pid;
typedef pair<double,int> pdi;
typedef pair<ll,ll> pll;

double INF=1e9;
int n;

void dij(int s,vector<vector<pid>> &g,vector<double> &d){
  priority_queue<pdi,vector<pdi>,greater<pdi>> que;
  que.push(pdi(0,s));
  while(!que.empty()){
    double di=que.top().X;
    int p=que.top().Y;
  //  cout<<p<<":"<<di<<endl;
    que.pop();
    if(d[p]>di){
      d[p]=di;
      rep(i,g[p].size())
        que.push(pdi(di+g[p][i].Y,g[p][i].X));
    }
  }
  return;
}

int main(){
  ios_base::sync_with_stdio(false);
  cout<<fixed<<setprecision(5);
  int i,j,k,n,m,p,a,b;
  while(1){
    cin>>n>>m>>p>>a>>b;
    a--,b--;
    if(!n)
      break;
    vector<int> t(n);
    vector<vector<pid>> g((1<<n)*m);
    rep(i,n)
      cin>>t[i];
    int fr,to,di;
    rep(i,p){
      cin>>fr>>to>>di;
      fr--,to--;
      rep(j,(1<<n)){
        rep(k,n){
          if(j>>k&1)continue;
          g[(fr<<n)+j].pb(pid((to<<n)+(j|(1<<k)),1.0*di/t[k]));
          g[(to<<n)+j].pb(pid((fr<<n)+(j|(1<<k)),1.0*di/t[k]));
        }
      }
    }
    vector<double> d((1<<n)*m,INF);
    dij(a<<n,g,d);
    double re=INF;
    rep(i,1<<n){
  //    cout<<(b<<n)+i<<"::"<<d[(b<<n)+i]<<endl;
      re=min(re,d[(b<<n)+i]);
    }
    if(re>=INF)
      cout<<"Impossible"<<endl;
    else
      cout<<re<<endl;
  }
  return 0;
}

Measured memory_bytes: 40484
#include <cstdio>
#include <algorithm>
using namespace std;
const int mod = 2019,inf = 0x3f3f3f3f;
int L,R,ans = inf;
int main() {
    scanf("%d%d",&L,&R);
    if (R-L+1 >= mod) return printf("0\n"),0;
    for (int i = L;i < R;i++) for (int j = L+1;j <= R;j++) ans = min(ans,(int)(1LL*i*j%mod));
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
typedef long long ll;
int main(void){
  int n,i,j,k,d[100010];
  ll dp[100010][15]={};
  const int mod=1e9+7;
  string s;
  cin >> s;
  n=s.size();
  d[0]=1;
  for (i=1;i<=n;i++) d[i]=(d[i-1]*10)%13;
  dp[0][0]=1;
  for (i=0;i<n;i++){
    for (j=0;j<10;j++){
      if (s[n-i-1]!='?') j=s[n-i-1]-'0';
      int e=(d[i]*j)%13;
      for (k=0;k<13;k++){
        dp[i+1][(k+e)%13]=(dp[i+1][(k+e)%13]+dp[i][k])%mod;
      }
      if (s[n-i-1]!='?') break;
    }
  }
  
  cout << dp[n][5] << endl;
  return 0;
}

Measured memory_bytes: 12544
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const int MOD = 1e9 + 7;

signed main(){
    int n;
    cin >> n;
    string s1,s2;
    cin >> s1;
    cin >> s2;
    int now, pre;
    ll ans;
    if(s1[0] == s2[0]){
        ans = 3;
        now = 1;
        pre = 1;
    }else{
        ans = 6;
        now = 2;
        pre = 2;
    }
    while(now < n){
        if(s1[now] == s2[now]){
            if(pre == 1){
                ans *= 2;
            }
            now += 1;
            pre = 1;
        }else{
            if(pre == 1){
                ans *= 2;
            }else{
                ans *= 3;
            }
            now += 2;
            pre = 2;
        }
        ans %= MOD;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <cmath>
#include <iomanip>
#include <bitset>
#include <string>
#include <stdlib.h>
using namespace std;
//cout <<  << endl;
typedef long long int ll;
typedef long double ld;

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


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

int main(){
	int N, i, j;
	scanf("%d", &N);
	vector<vector<int>> A(N, vector<int>(N - 1));
	vector<int> now(N, 0);
	for(i = 0; i < N; i++){
		for(j = 0; j < N - 1; j++){
			scanf("%d", &A[i][j]);
			A[i][j]--;
		}
	}
	vector<vector<int>> cands(1, vector<int>(N));
	for(i = 0; i < N; i++){
		cands[0][i] = i;
	}
	vector<int> will_use(N, 0);
	int count = 0;
	for(i = 0; count < N && cands[i].size() > 0; i++){
//		printf("i = %d\n", i);
		for(j = 0; j < cands[i].size(); j++){
			will_use[cands[i][j]] = 1;
		}
/*		printf("will_use:\n");
		for(j = 0; j < N; j++){
			printf("%d ", will_use[j]);
		}
		printf("\n");
*/		cands.push_back(vector<int>(0));
		vector<int> gc(0);
		for(j = 0; j < cands[i].size(); j++){
//			printf("j = %d\n", j);
			int k = cands[i][j];
			if(will_use[k] <= 0){
				continue;
			}
			will_use[k] = -1;
			gc.push_back(k);
//			printf("k = %d\n", k);
			if(now[k] == N - 1){
				continue;
			}
			int l = A[k][now[k]];
//			printf("l = %d\n", l);
			if(now[l] == N - 1){
				continue;
			}
			if(will_use[l] >= 0 && A[l][now[l]] == k){
				cands[i + 1].push_back(k);
				cands[i + 1].push_back(l);
				now[k]++;
				now[l]++;
				will_use[l] = -1;
				gc.push_back(l);
				if(now[k] == N - 1){
					count++;
				}
				if(now[l] == N - 1){
					count++;
				}
			}
		}
		for(j = 0; j < gc.size(); j++){
			will_use[gc[j]] = 0;
		}
	}
	for(j = 0; j < N; j++){
		if(now[j] < N - 1){
			printf("-1\n");
			return 0;
		}
	}
	printf("%d\n", i);
	return 0;
}

Measured memory_bytes: 31784
import math
a,b = map(int,input().split())
for i in range(10**9):
    if math.floor(i * 0.08) == a  and math.floor(i * 0.1) == b:
        print(i)
        break
    if math.floor(i * 0.08) > a  or math.floor(i * 0.1) > b:
        print("-1")
        break

Measured memory_bytes: 38384
use std::io;
use std::cmp;
use std::collections::BinaryHeap;
use std::collections::HashMap;
use std::collections::HashSet;

fn read_line() -> String {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).ok();
    buf
}

fn check(a: &Vec<i64>, tar: i64, k: i64) -> bool {
    let mut b = Vec::with_capacity(a.len());

    for &x in a.iter() {
        if x % tar != 0 {
            b.push(x % tar);
        }
    }
    b.sort();
    let mut c = vec![0; b.len()+1];
    let mut d = vec![0; b.len()+1];

    for i in 0..b.len() {
        c[i+1] = c[i] + b[i];
    }
    for i in (0..b.len()).rev() {
        d[i] = d[i+1] + (tar - b[i]);
    }
    for i in 0..b.len() {
        if (c[i] - d[i])%tar == 0 && cmp::max(c[i], d[i]) <= k {
            return true;
        }
    }
    false
}


fn main() {
    let mut line: Vec<i64> = read_line().split_whitespace().map(|s| s.parse().unwrap()).collect();
    let n = line[0] as usize;
    let k = line[1];
    let mut a: Vec<i64> = read_line().split_whitespace().map(|s| s.parse().unwrap()).collect();
    a.sort();

    let mut sum = 0;
    for i in a.iter() {
        sum += i;
    }

    let mut ans = 1;
    for i in 1..sum {
        if i*i > sum { 
            break;
        }
        if sum % i > 0 {
            continue;
        }
        let tar = sum / i;

        if check(&a, tar, k) {
            ans = tar;
            break;
        } else if check(&a, i, k) {
            ans = i;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 2200
from collections import defaultdict
from heapq import heappush, heappop, heapify
from bisect import bisect_left

class Solution:
    def main(self):
        N = int(input())
        B = [float('inf')] + list(map(lambda x: int(x), input().split())) + [float('inf')]

        # print(B)
        res = 0
        for i in range(N):
            res += min(B[i], B[i+1])

        print(res)


if __name__ == '__main__':
    Solution().main()


Measured memory_bytes: 3436
from collections import defaultdict, Counter
from heapq import heapify, heappop, heappush
from sys import stdin

def main():
    S = str(input())
    ans = 0
    pre = ""
    pre_index = 0
    index = 1
    while (index <= len(S)):
        now = S[pre_index:index]
        if pre == now:
            index += 1
            continue
        else:
            ans += 1
            pre_index = index
            index = pre_index + 1
            pre = now
    print(ans)

input = lambda: stdin.readline().rstrip()
main()

Measured memory_bytes: 3880
#include<stdio.h>
int main(void)
{
	int n, m;
	while(scanf("%d %d", &n, &m))
	{
		if(n == 0 && m == n)
		{
		    break;
        }
        int i =0;
	    for( i= 0; i < n; i++)
	    {
	    	int j = 0;
		    for( j= 0; j < m; j++)
		    {
			    printf("#");
		    }
		    printf("\n");
	    }
	    printf("\n");
    }
}


Measured memory_bytes: 2100