akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<ll, ll> PLL;
#define chmax(x, y) do { x = max(x, y); } while(0)
#define chmin(x, y) do { x = min(x, y); } while(0)
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) \
  for (ll i = static_cast<ll>(a); i < static_cast<ll>(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, ) (__VA_ARGS__)  // NOLINT
template<typename T>
using reversed_priority_queue = std::priority_queue<T, std::vector<T>, std::greater<T> >;

bool ans[40000];

signed main() {
  ll N;
  cin >> N;
  if (N == 3) {
    cout << "2 5 63" << endl;
    return 0;
  } else if (N == 4) {
    cout << "2 5 20 63" << endl;
    return 0;
  } else if (N == 5) {
    cout << "2 3 6 9 10" << endl;
    return 0;
  } else if (N == 6) {
    cout << "2 3 6 9 10 12" << endl;
    return 0;
  }

  ans[2] = ans[3] = true;
  ll n = 2, x = 4, s = 2 + 3;
  while (n < N) {
    while (x % 6 == 1 || x % 6 == 5)
      x++;
    ans[x] = true;
    s += x, n++, x++;
  }

  if (s % 6 == 1) {
    ans[9] = false;
    while (x % 6 != 2)
      x++;
    ans[x] = true;
  } else if (s % 6 == 2) {
    ans[8] = false;
    while (x % 6 != 0)
      x++;
    ans[x] = true;
  } else if (s % 6 == 3) {
    ans[9] = false;
    while (x % 6 != 0)
      x++;
    ans[x] = true;
  } else if (s % 6 == 4) {
    ans[6] = false;
    while (x % 6 != 2)
      x++;
    ans[x] = true;
  } else if (s % 6 == 5) {
    ans[9] = false;
    while (x % 6 != 4)
      x++;
    ans[x] = true;
  }

  rep(i, 40000) {
    if (ans[i]) {
      cout << i << " ";
    }
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std ;
typedef long long ll ;
typedef long double ld ;
#define F first
#define S second
#define pb push_back 
#define mp make_pair
#define vi vector <int>
#define vb vector <bool>
#define vc vector <char>
#define vll vector <ll>
#define vs vector <string>
#define pll pair < ll , ll >
#define pld pair < ld , ld >
#define pii pair < int , int >
#define vpld vector < pld >
#define vpii vector < pii >
#define vpll vector < pll >
#define vvi vector < vector < int > >
#define vvll vector < vector < ll > >
#define vvld vector < vector < ld > >
#define vvb vector < vector < bool > >
#define vvpii vector < vector < pii > >
#define all(v) (v).begin() , (v).end()
#define allrev(v) (v).rbegin() , (v).rend()
#define dist(x1 , y1 , x2 , y2) sqrt((x2 - x1)*(x2 - x1) + (y2 - y1)*(y2 - y1))
const int MOD = 1e9 + 7 ;
const int infi = INT_MAX ;
const ll infll = LLONG_MAX ;
const int dx4[] = {0 , -1 , 0 , 1} ;
const int dy4[] = {-1 , 0 , 1 , 0} ;
const int dx8[] = {-1 , -1 , -1 , 0 , 1 , 1 , 1 , 0} ;
const int dy8[] = {-1 , 0 , 1 , 1 , 1 , 0 , -1 , -1} ;
const ld PI = 3.1415926535897932384626 ;

///////////////////////////////////////////////////////////////////////////////////////

ll pow_mod (ll a , ll b , ll m) {
	ll ans = 1 ;
	while(b) {
		if (b&1) ans = (ans*a) % m ;
		b /= 2 ;
		a = (a*a) % m ;
	}
	return ans ;
}

bool isprime (ll num) {
    for (ll i = 2 ; i * i <= num ; ++i) {
		if (num % i == 0) return false ;
	}
    return true;
}

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

ll lcm (ll a, ll b) {
    return ((a / gcd(a , b)) * b) ;
}

ll cel (ll x1, ll y1) {
    if ((x1) <= 0) return (x1) / (y1) ;
    return (((x1) / (y1)) + (((x1) % (y1)) != 0)) ;
}

///////////////////////////////////////////////////////////////////////////////////////

void solve (int test_case) {
	int tc ;
	cin >> tc ;
	int ac = 0 , rte = 0 , tle = 0 , wa = 0 ;
	while (tc--) {
		string a ;
		cin >> a ;
		if (a == "AC") ++ac ;
		if (a == "WA") ++ wa ;
		if (a == "TLE") ++tle ;
		if (a == "RE") ++rte ;
	}
	cout << "AC x " << ac << "\nWA x " << wa << "\nTLE x " << tle << "\nRE x " << rte ;  
}

int main() {
	ios_base :: sync_with_stdio (false) ;
	cin.tie(0) ;
	cout.tie(0) ;
	int tc = 1 ;
	//cin >> tc ;
	while (tc--) {
		solve (tc) ;
	}
	return 0 ;
}

Measured memory_bytes: 3656
#include<stdio.h>
int main()
{
    int n, a, b;
    scanf("%d %d %d", &n, &a, &b);
    int ans = 0;
    int i;
    int k, x;
    for (i = 1; i <= n; i++)
    {
        x = 0;
        k = i;
        while (k > 0)
        {
            x += (k % 10);
            k /= 10;
        }
        if (a <= x && x <= b)
            ans += i;
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 128
# データ構造：ヒープ
import heapq
class heapque:
    def __init__(self, *args):
        self.que = []
        for arg in args:
            self.push(arg)
    def push(self, v):
        heapq.heappush(self.que, v)
    def pop(self):
        return heapq.heappop(self.que)

# 定数
INF = float("inf")
MOD = int(1e9 + 7)

# エントリーポイント
def main():
    X, Y, Z, K = map(int, input().split())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))
    C = list(map(int, input().split()))

    a = sorted(A, reverse=True)
    b = sorted(B, reverse=True)
    c = sorted(C, reverse=True)
    heap = heapque((-(a[0] + b[0] + c[0]), (0, 0, 0)))
    used = {(0, 0, 0)}
    for _ in range(K):
        cur = heap.pop()
        print(-cur[0])

        ai, bi, ci = cur[1]
        ns = ((min(ai + 1, X - 1), bi, ci), (ai, min(bi + 1, Y - 1), ci), (ai, bi, min(ci + 1, Z - 1)))
        for n in ns:
            if n in used: continue
            heap.push((-(a[n[0]] + b[n[1]] + c[n[2]]), n))
            used |= {n}

main()


Measured memory_bytes: 4672
#include <bits/stdc++.h>
#define typeof(x) __typeof__(x)
#define int long long int
#define double long double
#define mod(x) ((x % MOD) + MOD) % MOD
#define REP(i,a,b) for(int i=(a);i<(b);++i)
#define RREP(i,a,b) for(int i=(b)-1;i>=(a);--i)
#define ALL(c) (c).begin(),(c).end()
#define RALL(c) (c).rbegin(),(c).rend()
#define SZ(c) (int)((c).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))
#define LB(c,x) (int)(lower_bound(ALL(c),x)-(c).begin())
#define UB(c,x) (int)(upper_bound(ALL(c),x)-(c).begin())
#define COUNT(c,x) (UB(c,x)-LB(c,x))
#define UNIQUE(c) SORT(c); (c).erase(unique(ALL(c)),(c).end());
#define COPY(c1,c2) copy(ALL(c1),(c2).begin())
#define EXIST(s,e) (s).find(e)!=(s).end()
#define PB push_back
#define MP make_pair
#define vec vector
#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define NL cerr << endl;

using namespace std;

typedef pair<int,int> P;
struct edge { int from, to; int cost; };
ostream& operator << (ostream& s, const edge& e) {
   s << "(" << e.from << "->" << e.to << ": " << e.cost << ")";
   return s;
}
bool operator< (const edge &edge1, const edge &edge2){
   return edge1.cost < edge2.cost;
};

const int INF = 1e18;
const int MOD = 1e9+7;

template<typename T> ostream& operator << (ostream& s, const vector<T>& v) {
   s << "[";
   for (int i = 0; i < v.size(); i++) { s << v[i]; if (i < v.size() - 1) s << " "; }
   s << "]";
   return s;
}
template<typename T1, typename T2> ostream& operator << (ostream& s, const pair<T1,T2>& p) {
   s << "(" << p.first << "," << p.second << ")";
   return s;
}
template<typename T1, typename T2> ostream& operator << (ostream& s, const map<T1,T2>& m) {
   s << "{";
   for (auto i = m.begin(); i != m.end(); ++i) {
      s << i->first << ":" << i->second;
      if (next(i) != m.end()) s << ", ";
   }
   s << "}";
   return s;
}

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

   if ((SZ(s) % 2) ^ (s[0] == s[SZ(s)-1])) {
      cout << "First" << endl;
   } else {
      cout << "Second" << endl;
   }
   return 0;
}


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

int main()
{
    int n, a[100][100], b[100][100];

    while( cin >> n )
    {
        if( n == 0 )
            break;

        for( int i = 0; i < 100; i++ )
            for( int j = 0; j < 100; j++ )
                b[i][j] = 0;
        
        for( int i = 0; i < n; i++ )
        {
            int min = 100000000, s = 0, t = 0;
            for( int j = 0; j < n; j++ )
            {
                cin >> a[i][j];
                if( a[i][j] < min )
                    min = a[i][j];
            }
            for( int j = 0; j < n; j++ )
                if( a[i][j] == min )
                    b[i][j]++;
        }

        for( int i = 0; i < n; i++ )
        {
            int max = 0, s = 0, t = 0;
            for( int j = 0; j < n; j++ )
                if( a[j][i] > max )
                    max = a[j][i];

            for( int j = 0; j < n; j++ )
                if( a[j][i] == max )
                    b[j][i]++;
        }

        bool judge = true;
        for( int i = 0; i < 100; i++ )
            for( int j = 0; j < 100; j++ )
                if( b[i][j] == 2 && judge )
                {
                    cout << a[i][j] << endl;
                    judge = false;
                }
        if( judge )
            cout << 0 << endl;
    }
}


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

int main() {
	// your code goes here
    int a, b, c;
    cin >> a >> b >> c;
    if(a == b and (a != c) and (b != c))
        cout << "Yes";
    else if(a == c and a != b and b != c)
        cout << "Yes";
    else if(b == c and b != a and c != a)
        cout << "Yes";
    else {
        cout << "No";
    }
	return 0;
}



Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

/**
 * Built using CHelper plug-in Actual solution is at the top
 */
public class Main {
	public static void main(String[] args) {
		InputReader in = new InputReader(System.in);
		PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)), true);
		TaskB solver = new TaskB();
		solver.solve(1, in, out);
		out.flush();
		out.close();
	}
}

class Pair {
	long first;
	long second;

	Pair(long first, long second) {
		this.first = first;
		this.second = second;
	}
}

class TaskB {

	public void solve(int testNumber, InputReader in, PrintWriter pw) {
		int N = in.nextInt();
		int arr[] = new int[N + 1];
		for (int i = 0; i < N + 1; i++) {
			arr[i] = in.nextInt();
		}
		Arrays.sort(arr);
		int ans = arr[1] - arr[0];
		for (int i = 1; i < N; i++) {
			int temp = arr[i + 1] - arr[i];
			ans = __gcd(temp, ans);
		}
		pw.println(ans);
	}

	int __gcd(int a, int b) {
		if (b == 0)
			return a;
		return __gcd(b, a % b);

	}

	public int getInt(int num) {
		int ret = -1;
		switch (num) {
		case 0:
			ret = 6;
			break;
		case 1:
			ret = 2;
			break;
		case 2:
			ret = 5;
			break;
		case 3:
			ret = 5;
			break;
		case 4:
			ret = 4;
			break;
		case 5:
			ret = 5;
			break;
		case 6:
			ret = 6;
			break;
		case 7:
			ret = 3;
			break;
		case 8:
			ret = 7;
			break;
		case 9:
			ret = 6;
			break;
		}
		return ret;
	}

	public int isPow(long num) {
		int count = 0;
		while (num > 0) {
			num /= 2;
			count++;
		}
		return count;
	}
}

class InputReader {
	BufferedReader br;
	StringTokenizer st;

	public InputReader(InputStream in) {
		br = new BufferedReader(new InputStreamReader(in));
		st = null;
	}

	public String next() {
		while (st == null || !st.hasMoreTokens()) {
			try {
				st = new StringTokenizer(br.readLine());
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return st.nextToken();
	}

	public int nextInt() {
		return Integer.parseInt(next());
	}

	public long nextLong() {
		return Long.parseLong(next());
	}

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


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

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

    ll n, a, b;
    cin >> n >> a >> b;

    if(abs(a-b)%2){
        ll step = min(min(a, b) - 1, n - max(a, b));
        cout << step + 1 + (abs(a-b)-1)/2 << endl;;
        return 0;
    }
    cout << abs(a-b) / 2 << endl;

    return 0;
}

Measured memory_bytes: 256
parseInt(x::String) = parse(Int, x)
parseInt(x::SubString{String}) = parse(Int, x)
parseInt(x::Char) = parse(Int, x)
parseInt(x::Float64) = trunc(Int, x)
parseFloat(x::String) = parse(Float64, x)
parseFloat(x::Int) = trunc(Float64, x)
parseFloat(x::SubString{String}) = parse(Float64, x)
parseFloat(x::Char) = parse(Float64, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
    h,w=parseMap(split(readline()))
    s=[readline() for i in 1:h]
    ans=""
    for i in 1:h
        for j in 1:w
            if s[i][j]=='#'
                ans=join([ans,'#'])
                continue
            end
            res=0
            for (y,x) in [(i-1,j-1),(i-1,j),(i-1,j+1),(i,j-1),(i,j+1),(i+1,j-1),(i+1,j),(i+1,j+1)]
                try
                    if s[y][x]=='#'
                        res+=1
                    end
                catch
                    1+1
                end
            end
            ans=join([ans,string(res)])
        end
        ans=join([ans,"\n"])
    end
    println(ans)
end
main()

Measured memory_bytes: 135816
#include <iostream>
#include <string>
using namespace std;
int main(void){
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    int ans=0;
    for(int i=1;i<101;i++){
        if(i>a&&i<=b&&i>c&&i<=d)ans++;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;

public class Main {
    public static void main(String[] args) throws Exception {

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));

        int k = Integer.parseInt(br.readLine());
        String[] in = br.readLine().split(" ");
        int a = Integer.parseInt(in[0]);
        int b = Integer.parseInt(in[1]);

        br.close();

        String ans = "NG";

        for (int i = a; i <= b; i++) {
            if (i % k == 0) {
                ans = "OK";
            }
        }

        bw.write(ans);

        bw.flush();

    }
}

Measured memory_bytes: 32560
import java.io.*;
import java.util.*;

public class Main {
    
    public static void main(String[] args) {
        try (CustomReader in = new CustomReader()) {
            new Main().execute(in);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    public void execute(CustomReader in) throws IOException {
        int[] nk = in.readLineAsIntArray();
        int N = nk[0];
        int K = nk[1];
        int cnt = 0;
        for (int i = 1; i <= N; i++) {
            if (i + K - 1 <= N) {
                cnt++;
            }
        }
        System.out.println(cnt);
    }

    static class CustomReader extends BufferedReader {

        public CustomReader() throws IOException {
            super(new InputStreamReader(System.in));
        }

        public int[] readLineAsIntArray() throws IOException {
            String[] strArray = this.readLine().split(" ");
            int[] intArray = new int[strArray.length];
            for (int i = 0, n = strArray.length; i < n; i++) {
                intArray[i] = Integer.parseInt(strArray[i]);
            }
            return intArray;
        }

        public int[][] readAsIntMatrix(int rows, int columns) throws IOException {
            int[][] matrix = new int[rows][columns];
            for (int i = 0; i < rows; i++) {
                String[] r = this.readLine().split(" ");
                for (int j = 0; j < columns; j++) {
                    matrix[i][j] = Integer.parseInt(r[j]);
                }
            }
            return matrix;
        }

    }
}

Measured memory_bytes: 21716
#include <algorithm>
#include <iostream>
#include <string>
#include <random>
#include <cassert>
#include <cstring>
#include <chrono>
#include <set>
#include <map>

using namespace std;

typedef long long ll;

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

  int result = 1 << 30;
  for (int mask = 0; mask < (1 << (n - 1)); ++mask) {
    vector<int> col(n);
    int curColor = 0;
    int curResult = 0;
    for (int i = 0; i < n; ++i) {
      col[i] = curColor;
      if ((mask >> i) & 1) {
        curColor++;
        curResult++;
      }
    }

    vector<int> cur(n);
    for (int j = 0; j < m; ++j) {
      for (int i = 0; i < n; ++i) {
        if (s[i][j] == '1') cur[col[i]]++;
      }

      bool ok = true;
      for (int x : cur) if (x > k) ok = false;
      if (!ok) {
        curResult++;
        //cerr << "curResult = " << curResult << endl;
        fill(cur.begin(), cur.end(), 0);
        for (int i = 0; i < n; ++i) {
          cur[col[i]] += s[i][j] - '0';
        }
      }

      ok = true;
      for (int x : cur) if (x > k) ok = false;
      
      if (!ok) curResult += n * m;

      //cerr << "cur: "; for (int x : cur) cerr << x << " "; cerr << endl;
    }
    //cerr << mask << " " << curResult << endl;
    result = min(result, curResult);
  }

  cout << result << endl;
  
  return 0;
}


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

#define ASC(vec) vec.begin(), vec.end()		// 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend()	// 降順ソート 例:sort(DESC(vec));
#define rep(i, n) for(int i = 0; i < n; i++)
#define Rep(i, n) for(int i = 1; i < n; i++)
#define In(vec) rep(i, n) cin>>vec[i];
#define ANS(s) cout << s << endl
#define inc(a, b) cin >> a >> b;

const int mod = 1000000007;
const int inf = (int)1e9 + 7;
const long long INF = 1LL << 60;

using ll = long long;
using vi = vector<int>;
using vd = vector<double>;
using vb = vector<bool>;
using vl = vector<ll>;
using vs = vector<string>;
using vvi = vector<vector<int> >;
using vii = vector<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; }

ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
int round_int(int a, int b) { return (a + (b - 1)) / b; }


// 4,8方向に探索する際に用いる配列
//int dx[4] = { 0,  0, 1, -1 };
//int dy[4] = { 1, -1, 0,  0 };
int dx[8] = { 1, 0, -1,  0, 1, -1, -1,  1 };
int dy[8] = { 0, 1,  0, -1, 1,  1, -1, -1 };

constexpr auto MAX = 100010;

// ────────────────────────────────────────────────────

int main() {
	ll n; cin >> n;
	ll ans = n * (n - 1) / 2;
	cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    String S = sc.next();
    String T = sc.next();
    char[] s = new char[n];
    char[] t = new char[n];
    int i;
    int m;
    char[] b = new char[2*n];
    for(i=0;i<n;i++){
      s[i] = S.charAt(i);
    }
    for(i=0;i<n;i++){
      t[i] = T.charAt(i);
    }
    for(i=0,m=0;i<n;i++,m=m+2){
      b[m] = s[i];
    }
    for(i=0,m=1;i<n;i++,m=m+2){
      b[m] = t[i];
    }
    String str = String.valueOf(b);
    System.out.println(str);
    }
 }



Measured memory_bytes: 21332
//catoonさんを参考に実装

function main(input) {
  const n = parseInt(input[0]);

  //素因数分解してmapにぶち込む
  const map = {};
  let k = n;
  for(let i = 2; i*i <= k; i++){
    if(k % i === 0){
      map[i] = 0;
      while(k % i === 0){
        map[i]++;
        k /= i;
      }
    }
  }

  //N自体が素数の場合は上で引っかからないのでここで処理
  if(k > 1){
    map[k] = 1;
  }

  //素数の値ではなく数のみを配列に入れる
  const primeCnt = [];
  for(let i in map){
    primeCnt.push(map[i])
  };

  //同じ素数でも複数に分けれる場合がある
  let cnt = 0;
  for(let i = 0; i < primeCnt.length; i++){
    for(let j = 1; j <= primeCnt[i]; j++){
      cnt++;
      primeCnt[i] -= j;
    }
  }
  console.log(cnt);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8').trim().split("\n"));

Measured memory_bytes: 33168
#!/usr/bin/env python3
import sys
from itertools import accumulate

MOD = 1000000007  # type: int

def solve(N: int, K: int):
    a = list(range(0,N+1))

    left_a = list(accumulate(a))
    right_a = list(accumulate(a[::-1]))

    answer = 0
    for i in range(K,N+2):
        l = left_a[i-1]
        r = right_a[i-1]
        answer += r-l+1
        answer %= MOD
    
    print(answer)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    solve(N, K)

if __name__ == '__main__':
    main()


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

typedef long long ll;

const int N = 1e6;
ll n;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin >> n;
    ll res = LLONG_MAX;
    for (int i = 1; i <= N; ++i) {
        if (n % i == 0) {
            res = min(res, i + n / i);
        }
    }
    cout << res - 2 << endl;

    return 0;
}



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

#define SZ(x) (int)(x).size()
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define RFOR(i, a, b) for (int i=a;i>=b;--i)

const int MX_N = 3005;
const int MX_Q = 3005;
const int MOD = 1e9+7;

int N, Q, A[MX_N];

int dp[MX_N][MX_N];

int expo(int b, int p) {
    int x = 1;
    while (p > 0) {
        if (p&1) x = 1LL * x * b % MOD;
        b = 1LL * b * b % MOD;
        p >>= 1;
    }
    return x;
}

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

    cin >> N >> Q;
    FOR(i,1,N){
        cin >> A[i];
    }

    FOR(i,1,N) FOR(j,1,N) dp[i][j] = A[i] > A[j];

    long long half = expo(2,MOD-2), all = expo(2,Q);
    FOR(i,1,Q){
        int X, Y; cin >> X >> Y;

        dp[X][Y] = dp[Y][X] = (half * dp[X][Y] % MOD + half * dp[Y][X] % MOD) % MOD;
        FOR(Z,1,N) if (Z != X and Z != Y) {
            dp[X][Z] = dp[Y][Z] = (half * dp[X][Z] % MOD + half * dp[Y][Z] % MOD) % MOD;
            dp[Z][X] = dp[Z][Y] = (half * dp[Z][X] % MOD + half * dp[Z][Y] % MOD) % MOD;
        }
    }

    int ans = 0;
    FOR(i,1,N) FOR(j,i+1,N) ans = (ans + dp[i][j] * all % MOD) % MOD;
    cout << ans;
}



Measured memory_bytes: 35456
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair< ll, ll > Pi;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
const ll INF = 1LL << 60;
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 (b<a) { a=b; return 1; } return 0; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}
#define all(x) x.begin(), x.end()
#define mp make_pair
bool compare(Pi a, Pi b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}


bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}
const vector<ll> dx{1,0,-1,0};
const vector<ll> dy{0,1,0,-1};


int main() {
    ll N,M;
    cin >>N>>M;
    vector<ll>ans(M);

    rep(i,N){
        ll k;
        cin>>k;
        rep(j,k){
            ll a;
            cin>>a;
            a--;
            ans[a]++;
        }
    }
    ll cnt = 0;
    rep(i,M){
        if(ans[i]==N){
            cnt++;
        }
    }
    
    cout << cnt << endl;


    return 0;
    

}

Measured memory_bytes: 3608
A, B, M = [int(_) for _ in input().split()]
a = [int(_) for _ in input().split()]
b = [int(_) for _ in input().split()]
xyc = [[int(_) for _ in input().split()] for i in range(M)]

rets = [min(a) + min(b)]

for x, y, c in xyc:
    rets += [a[x-1] + b[y-1] - c]
print(min(rets))

Measured memory_bytes: 36460
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll N=1e6+5,inf=1e18,mod=1e9+7;
#define test ll testcases;cin>>testcases; while(testcases--)
#define lp(var,start,end) for (ll var = start; var <end ; ++var)
#define rlp(var,start,end) for(ll var = start; var>=end ; var--)
#define pb push_back
#define mp make_pair
#define pf push_front
#define ff first
#define ss second
#define vll vector<ll>
#define vld vector<ld>
#define pll pair<ll,ll> 
#define pld pair<ld,ld> 
#define vpll vector<pll>
#define vpld vector<pld>
#define all(X) X.begin(),X.end()
#define sz(x) ((ll)((x).size()))
const ld pi=3.141592653589793238;

bool check_prime(ll n)
{
	ll flag=0,i;
	for(i=2;i*i<=n;i++)
	{
		if(n%i==0)
		{
			flag=1;
			break;
		}
	}
	if(n==1)
	{
		return false;
	}
	else if(flag==0 || n==2 || n==3)
	{
		return true;
	}
	else
	{
		return false;
	}
}

ll fastexpo(ll a,ll b,ll MOD) 
{
	ll result=1;
	while(b>0)
	{
		if(b%2==1)
		{
			result=(result*a)%MOD;
		}
		a=(a*a)%MOD;
		b=b/2;
	}
	return result;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,i,c,x,f;
    c=1;
    cin>>n;
    f=0;
    for(i=0;i<n;i++)
    {
    	cin>>x;
    	if(x==c)
    	{
    		f=1;
    		c++;
    	}
    }
    if(f==1)
    {
    	cout<<n-c+1<<"\n";
    }
    else
    {
    	cout<<"-1\n";
    }
	return 0;
}

Measured memory_bytes: 3600
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
    long long K, A, B, i, ans=0;
    cin >> K >> A >> B;

    if (A+2 >= B) ans  = K + 1;
    else if (K < A+1) ans = K + 1;
    else {
        long long ite = (K - (A-1)) / 2;
        long long res = (K - (A-1)) % 2;
        ans += A;
        ans += ite * (B-A);
        if (res) ans++;
    }

    cout << ans << '\n';
}
   

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


int main() {
    int n;
    vector<pair<int, int> > r, b;
    cin >> n;
    FOR(i, n){
        int x, y;
        cin >> x >> y;
        P temp = make_pair(x, y);
        r.push_back(temp);
    }
    FOR(i, n){
        int x, y;
        cin >> x >> y;
        P temp = make_pair(x, y);
        b.push_back(temp);
    }
    sort(b.begin(), b.end());
    int ans = 0;
    FOR(i, n){
        int ymax = -1, jmax = -1;
        for(unsigned j = 0; j < r.size(); j++) {
            if(r[j].first < b[i].first && r[j].second < b[i].second) {
                if(r[j].second > ymax) {
                    ymax = r[j].second;
                    jmax = j;
                }
            }
        }
        if(ymax != -1) {
            ans++;
            r.erase(r.begin() + jmax);
        }
    }
    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int ze(int a, int b) {
  return max(a - b, b - a);
}
int main () {
  const int INF = 10000000;
  int N, X, Y;
  cin >> N >> X >> Y;
  int load[2020][2020];
  for (int i = 1; i <= N; i ++) {
    for (int j = i + 1; j <= N; j ++) {
      int k = ze(i, X) + 1 + ze(j, Y);
      load[i][j] = min(j - i, k);
    }
  }
  vector<int>ans(N, 0);
  for (int i = 1; i <= N; i ++) {
    for (int j = i + 1; j <= N; j ++) {
      ans[load[i][j]] ++;
    }
  }
  for (int i = 1; i < N; i ++) cout << ans[i] << endl;
}



Measured memory_bytes: 16128
S = input()
Q = int(input())

front = ''
back = ''

T_count = 0

for i in range(Q):
    command = input().split()
    if command[0] == '1':
        T_count = (T_count+1)%2
    else:
        if (int(command[1]) + T_count)%2 == 1:
            front += command[2]
        else:
            back += command[2]

if T_count == 0:
    print(front[::-1]+S+back)
else:
    print(back[::-1]+S[::-1]+front)


Measured memory_bytes: 4468
#include <bits/stdc++.h>
using namespace std;
 
#define int long long 
 
int32_t main () {
    string s; cin >> s;
    if ((s[2] == s[3]) && (s[4] == s[5])) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long[] arr = new long[n];
		for (int i = 0; i < n; i++) arr[i] = sc.nextLong();
		int[] dp1 = new int[n];
		int[] dp2 = new int[n];
		dp1[0] = dp2[0] = 1;
		for (int i = 1; i < n; i++) {
			if (arr[i] > arr[i-1]) {
				dp1[i] = Math.min(dp1[i-1], dp2[i-1] + 1);
				dp2[i] = Math.min(dp1[i-1] + 1, dp2[i-1] + 1);
			} else if (arr[i] < arr[i-1]) {
				dp1[i] = Math.min(dp1[i-1] + 1, dp2[i-1] + 1);
				dp2[i] = Math.min(dp1[i-1] + 1, dp2[i-1]);
			} else {
				dp1[i] = dp1[i-1];
				dp2[i] = dp2[i-1];
			}
		}
		
		System.out.println(Math.min(dp1[n-1], dp2[n-1]));
	}
}


Measured memory_bytes: 50176
#include<iostream>
#include<string>
#include<algorithm>

using namespace std;

void PersonA(string&);
void PersonB(string&);
void PersonC(string&);
void PersonD(string&);
bool UsingSeat(const char&);

int main(){
  int i, n, m;
  string c;

  while(1){
    cin >> n >> m;
    if(n == 0 && m == 0) break;
    string chair(n, '#');

    for(i=0; i<m; ++i){
      cin >> c;
      if(c == "A") PersonA(chair);
      else if(c == "B") PersonB(chair);
      else if(c == "C") PersonC(chair);
      else if(c == "D") PersonD(chair);
    }
    cout << chair << endl;
  }
  return 0;
}

void PersonA(string& s){
  string::iterator i;
  i = find(s.begin(), s.end(), '#');
  *i = 'A';
}

void PersonB(string& s){
  string::reverse_iterator i, j;
  string::iterator k;
  for(j=s.rbegin(); i!=s.rend(); j=i+1){
    i = find(j, s.rend(), '#');
    if((i == s.rbegin() && *(i+1) != 'A') ||
       (i == s.rend()-1 && *(i-1) != 'A') ||
       (*(i-1) != 'A' && *(i+1) != 'A')){
      *i = 'B';
      return;
    }
  }
  k = find(s.begin(), s.end(), '#');
  *k = 'B';
}

void PersonC(string& s){
  string::iterator i, j;
  i = find_if(s.begin(), s.end(), UsingSeat);
  if(i == s.end()){
    s[s.size()/2] = 'C';
    return;
  }
  while(i != s.end()){
    j = find_if(i, s.end(), UsingSeat);
    if(*(j+1) == '#'){
      *(j+1) = 'C';
      return;
    }
    if(*(j-1) == '#'){
      *(j-1) = 'C';
      return;
    }
    ++i;
  }
}

void PersonD(string& s){
  string::iterator i, j, k;
  i = find_if(s.begin(), s.end(), UsingSeat);
  if(i == s.end()){
    s[0] = 'D';
    return;
  }
  int empty, _empty;
  empty = i - s.begin();
  k = s.begin();
  ++i;
  while(1){
    j = find_if(i, s.end(), UsingSeat);
    if(j == s.end()) break;
    _empty = j - i;
    if(_empty%2 == 0 && _empty/2 > empty){
      empty = _empty/2;
      k = i + empty - 1;
    }
    else if(_empty%2 == 1 && _empty/2 + 1 > empty){
      empty = _empty/2 + 1;
      k = i + empty - 1;
    }
    i = j + 1;
  }
  _empty = s.end() - i;
  if(_empty > empty) k = s.end()-1;
  *k = 'D';
}

bool UsingSeat(const char& c){
  if(c == '#') return false;
  else return true;
}

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

typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> pll;
#define endl "\n";
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

ll const inf = 1e18;
ll const maxn = 1e6+5;
ll const mod = 1e9+7;

// code begins here

vector<ll> v[maxn], parent(maxn, 0);

void bfs(){
    queue<ll> q;
    q.push(1);
    
    while(!q.empty()){
        ll val = q.front();
        q.pop();
        
        for(auto u: v[val]){
            if(!parent[u]){
                parent[u] = val;
                q.push(u);
            }
        }
    }
}

int main(){
    fast;
    
    ll n,m,x,y;
    cin>>n>>m;
    
    for(ll i=0;i<m;i++){
        cin>>x>>y;
        v[x].push_back(y);
        v[y].push_back(x);
    }
    
    bfs();
    
    cout<<"Yes"<<endl;
    
    for(ll i=2;i<=n;i++)
        cout<<parent[i]<<endl;
    
    return 0;
}

Measured memory_bytes: 40996
#include <stdio.h>

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

int W, N, v[1001], w[1001], dp[1001][1001];

int main(void){
    int n_case = 1;
    while(1){
        int x, y;
        scanf("%d", &W);
        if(W == 0) break;
        scanf("%d", &N);
        for(x = 1; x <= N; x++){
            scanf("%d,%d", &v[x], &w[x]);
        }
        for(x = 0; x <= W; x++){
            dp[0][x] = 0;
        }
        for(x = 1; x <= N; x++){
            for(y = 0; y <= W; y++){
                if(y < w[x]) dp[x][y] = dp[x-1][y];
                else dp[x][y] = max(dp[x-1][y],
                                    dp[x-1][y-w[x]] + v[x]);
            }
        }
        int max_v = 0, weight;
        for(x = 0; x <= W; x++){
            if(dp[N][x] > max_v){
                max_v = dp[N][x];
                weight = x;
            }
        }
        printf("Case %d:\n%d\n%d\n", n_case, max_v, weight);
        n_case++;
    }
    return 0;
}

Measured memory_bytes: 4520
//#include<bits/stdc++.h>
#include<iostream>
#include<cstring>
#include<stdio.h>
#include<cmath>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<string>
#include<cstdlib>
#include<bitset>
#include<sstream>
#include<queue>
#include<stack>
#include<list>
#include<limits>
#include<iomanip>

using namespace std;

typedef long long int ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> pt;
typedef pair<ll,ll> pll;

#define Max 1000001
#define intinf 2147483647
#define longlonginf 9223372036854775807
#define MOD 998244353
#define MOD2 1000000007
#define fastio ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define vint vector<int>
#define vll vector<long long>
#define endl '\n'
#define fi first
#define se second
#define pb push_back
#define F(i,n) for(int i = 0;i<n;i++)
#define Fr(i,l,r) for(int i = l;i <= r;i++)
#define rF(i,n) for(int i = n-1;i>=0;i--)


//#define min(a,b) a>b?b:a
//#define max(a,b) a>b?a:b
#define all(arr) arr.begin(),arr.end()
//#define sort(vec) sort(vec.begin(),vec.end())
//#define reverse(vec) reverse(vec.begin(),vec.end())


ll Lpow(ll a,ll b)
{
    ll ans = 1;
    while(b > 0)
    {
        if(b%2)
            ans = (ans*a);
        a = (a*a);
        b = b/2;
    }
    return ans;
}

ll gcd(ll a,ll b)
{
    if(a%b==0)
        return b;
    else
        return gcd(b,a%b);
}

ll dp[3005][3005];
string s,t;

int n,m;

signed main()
{
    fastio;
    
    cin >> s >> t;
    
    n = (int)s.length();
    m = (int)t.length();
    
    s = '0' + s;
    t = '0' + t;
    
    for(int i = 1;i<=n;i++)
    {
        for(int j = 1;j<=m;j++)
        {
            dp[i][j] = max(dp[i][j-1],dp[i-1][j]);
            
            if(s[i] == t[j])
                dp[i][j] = max(dp[i-1][j-1] + 1,dp[i][j]);
        }
    }
    
    int i = n;
    int j = m;
    
    string k = "";
    while(i > 0 && j > 0)
    {
        if(s[i] == t[j])
        {
            k += s[i];
            i--;
            j--;
        }
        else if(dp[i-1][j] > dp[i][j-1])
            i--;
        else
            j--;
    }
    
    reverse(all(k));
    
    cout << k << endl;
    
    
    return 0;
}


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

int main(){
    int N, j;
    int sum = 0;
    cin >> N;
    vector<int> d(N);
    for(int i=0; i<N; i++) cin >> d[i];

    for(int k=0; k < N - 1; k++){
        j = k+1;        
        while(j < N){
            sum += d[k]*d[j];
            j++;
        }
    }
    cout << sum <<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream> 
#include<unordered_map>      

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;

const int inf = numeric_limits<int>::max() >> 2;
const ll linf = numeric_limits<ll>::max() >> 2;
const ull ulinf = numeric_limits<ull>::max() >> 2;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define umap(i,j) unordered_map<i,j>
#define P(p) cout<<(p)<<endl
#define PS(p) cout<<(p)<< " "
#define PN cout << endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i = (n-1); i >= (int)(m); i--)
#define inrep(n,a) for(int i = 0; i < (int)(n); i++)cin >> a[i];
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end())
#define rvsort(v,c) sort(v.begin(), v.end(), greater<c>()) 
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - (a)) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - (a)) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

/*
ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
*/

/*
vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}
*/

/*
ll ncr[100][100];
ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

ll npr[100][100]={};
ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

ll nHr(int n,int r){ret nCr(n+r-1,r);}
*/

///////////////////////////////////////////////////////////////////////////



int main(){
    int a,b;
    cin >> a >> b;
    P((a+b-1)/b);
    return  0;
}


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

int a,b;
string op;
while(1){

cin >>a>>op>>b;

if(op=="?"){
break;
}

else if(op=="+"){
a+=b;
cout <<a<<endl;
}

else if(op=="-"){
a-=b;
cout <<a<<endl;
}

else if(op=="*"){
a*=b;
cout<<a<<endl;
}

else {
a/=b;
cout<<a<<endl;
}

}

}


Measured memory_bytes: 3152
#include <bits/stdc++.h>
#define fast ios_base::sync_with_stdio(0); cin.tie(0)
#define int int64_t
#define ii pair<int, int>
#define endl '\n'
#define vi vector<int>
#define vii vector<ii>
#define vvi vector<vi>
#define vvii vector<vii>
#define F first
#define S second
#define pb push_back
#define FOR(i,l,r) for(int i=l; i<r; ++i)
#define ROF(i,r,l) for(int i=r; i>l; --i)
#define all(x) x.begin(), x.end()
#define amin(a,b) a = min(a,b)
#define amax(a,b) a = max(a,b)
#define test int t; cin >> t; while(t--) solve();

using namespace std;
typedef long long ll;

const int MAXN = 1e5+2;
const int MAXINT = 2147483098;
const int MAXLL = 9223372036854775258LL;
const int MOD = 1e9 + 7;
//const int MOD = 998244353;








int32_t main()
{
    //freopen("holiday.in", "r", stdin);
    fast;
    //test;

    string s,t;
    cin >> s >> t;

    int ans = MAXLL;
    FOR(i,0,s.size()-t.size()+1){
        int cur = 0;
        FOR(j,0,t.size()){
            if (s[i+j]!=t[j]) cur++;
        }
        ans = min(ans,cur);
    }
    cout << ans;




   return 0;
}


Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define dup(x,y) (((x)+(y)-1)/(y))
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> pii;
const double EPS = 1e-10;
const int INF = 1e9;
const ll LINF = 1e15;
const int MOD = 1000000007;
const double PI = acos(-1);
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

int main() {
	int n;
	cin >> n;
	vector<int> v(n);
	rep(i,n) cin >> v[i];
	reverse(ALL(v));
	if (v[0] != 2) cout << -1 << endl;
	else {
		ll l = 2;
		ll r = 3;
		for (int i = 0; i < n; i++) {
			ll k = v[i];
			l = dup(l,k) * k;
			r = dup(r,k) * k;
			if (r - l <= 1) {	
				cout << -1 << endl;
				return 0;
			}
		}
		cout << l << " " << r-1 << endl;
	}
}

Measured memory_bytes: 3776
using System;
class c
{
    static void Main()
    {
        var abc = Array.ConvertAll(Console.ReadLine().Split(), long.Parse);
        long a = abc[0], b = abc[1], c = abc[2];
        Console.WriteLine(4*a*b < c*c + a*a + b*b - 2*a*c - 2*b*c + 2*a*b && c-a-b > 0? "Yes" : "No");
    }
}


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

#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define mod 1000000007
#define inf 1000000000000000001
#define all(c) c.begin(),c.end()
#define mp(x,y) make_pair(x,y)
#define mem(a,val) memset(a,val,sizeof(a))
#define eb emplace_back
#define f first
#define s second

using namespace std;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i : x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

/*****************************************************START******************************************************************/



int main()
{
	std::ios::sync_with_stdio(false);
	cin.tie(0);
	int T = 1;
	 //cin >> T;
	// cin.ignore(); must be there when using getline(cin, s)
	while (T--)
	{
		int x,y; cin >> x >> y; 
		if(2*x <= y && 4*x >= y && y % 2 == 0){
			cout << "Yes" << endl;
		}else{
			cout << "No" << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))
#define gcd(a, b) __gcd(a, b)
#define lcm(a, b) (a * b) / gcd(a, b)
#define GOLD ((1 + sqrt(5)) / 2)
const double PI = 3.14159265358979323846264338327950288419716939937510582097494459230;
void swaps(char *x, char *y)
{
    char temp;
    temp = *x;
    *x = *y;
    *y = temp;
}
void swapi(int *a, int *b)
{
    int temp;
    temp = *a;
    *a = *b;
    *b = temp;
}

void preprocess()
{
} //end prepreprocess

void refresh()
{
} //end refresh

void compute()
{
    int n, m, temp, count = 0;
    double min;
    cin >> n >> m;
    vector<int> a(n);
    for (int i = 0; i < n; ++i)
    {
        cin >> a[i];
        count += a[i];
    }
    min = 1.0 * count / (4.0 * m);
    count = 0;
    for (int i = 0; i < n; ++i)
    {
        if (a[i] >= min)
            ++count;
    }
    if (count >= m)
    {
        cout << "Yes";
    }
    else
    {
        cout << "No";
    }
} //end compute

int main()
{
#ifdef debug
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    freopen("log.txt", "w", stderr);
#endif
    int t;
    compute();
#ifdef debug
    fprintf(stdout, "\nTIME: %.3lf sec\n", (double)clock() / (CLOCKS_PER_SEC));
#endif
    return 0;
} //end main*

Measured memory_bytes: 3636
s=input()
even=[int(x) for i,x in enumerate(s) if i%2==0]
odd=[int(x)for i,x in enumerate(s) if i%2==1]

tmp=sum([x!=0 for x in even])+sum([x!=1 for x in odd])
tmp=min(sum([x!=1 for x in even])+sum([x!=0 for x in odd]),tmp)
print(tmp)

Measured memory_bytes: 4340
import sys
import collections

sys.setrecursionlimit(10**6)
readline = sys.stdin.readline
#read = sys.stdin.buffer.read

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

def main():
    N = int(input())
    pf = prime_factorize(N)
    if len(pf) == 0:
        print(0)
        return
    pfitems = list(zip(*collections.Counter(pf).items()))
    cnt = 0
    for i in pfitems[1]:
        tmp = i
        for j in range(1, i+1):
            tmp -= j
            if tmp < 0:
                break
            cnt += 1

    print(cnt)

if __name__ == "__main__":
    main()


Measured memory_bytes: 9488
class LevenshteinDistance {
  // Verify: http://judge.u-aizu.ac.jp/onlinejudge/review.jsp?rid=4313161#1
  /**
   * 編集距離の DP 配列
   * _dist[v][w]: 入力文字列を v 文字、word を w 文字見たときの、それ以前の編集距離
   */

  constructor(word) {
    this._dist = [[...Array(word.length + 1)].map((_, i) => i)];
    this._prev = [[...Array(word.length + 1)].map((_, i) => [0, i - 1])];
    this._prev[0][0] = [-1, -1];
    this._word = word.split("");
    this._input = [];
  }

  /**
   * 入力の i 番目以降を suffix で置き換える。O(|word||suffix|)
   * @param {Number} i
   * @param {String} suffix
   */
  updateInputSuffix(i, suffix) {
    if (i > this._input.length) {
      throw new Error("入力の長さより後ろの位置が指定されました");
    }
    this._input.length = i;
    this._input.push(...suffix.split(""));

    this._dist.length = i + 1;
    for (let v = this._dist.length; v < this._input.length + 1; v++) {
      this._dist[v] = [...Array(this._word.length + 1)].map(() => Infinity);
      this._dist[v][0] = v;
      this._prev[v] = [...Array(this._word.length + 1)].map(() => [-1, -1]);
      this._prev[v][0] = [v - 1, 0];

      for (let w = 1; w < this._word.length + 1; w++) {
        this._updateDp({
          v,
          w,
          pv: v - 1,
          pw: w - 1,
          cost: this._input[v - 1] === this._word[w - 1] ? 0 : 1
        });
        this._updateDp({ v, w, pv: v, pw: w - 1, cost: 1 });
        this._updateDp({ v, w, pv: v - 1, pw: w, cost: 1 });
      }
    }
  }

  _updateDp(params) {
    const { v, w, pv, pw, cost } = params;
    if (this._dist[pv][pw] + cost < this._dist[v][w]) {
      this._dist[v][w] = this._dist[pv][pw] + cost;
      this._prev[v][w] = [pv, pw];
    }
  }

  /**
   * ワードと入力の文字ごとに正解かどうかを表す配列を構成する。O(|input|+|word|)
   */
  buildCorrections() {
    const inputCorrections = [...Array(this._input.length)].map(() => false);
    const wordCorrections = [...Array(this._word.length)].map(() => false);
    let v = this._input.length;
    let w = this._word.length;
    while (v > 0 || w > 0) {
      const [nv, nw] = this._prev[v][w];
      // コストがゼロの遷移ができたら正解
      if (this._dist[nv][nw] === this._dist[v][w]) {
        for (let i = nv; i < v; i++) inputCorrections[i] = true;
        for (let i = nw; i < w; i++) wordCorrections[i] = true;
      }
      [v, w] = [nv, nw];
    }
    return { input: inputCorrections, word: wordCorrections };
  }

  get dist() {
    return this._dist;
  }
}

const main = stdin => {
  const [word, input] = stdin.split("\n");
  const ld = new LevenshteinDistance(word);
  ld.updateInputSuffix(0, input);
  console.log(ld.dist[input.length][word.length]);
};
// 標準入力
main(require("fs").readFileSync("/dev/stdin", "utf8"));



Measured memory_bytes: 127300