akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } else return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } else return 0; }
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const ll INF = 1e9+100;
const ll INFL = 1e18+100;
const ll MOD = 1e9+7;
const bool debug = 0;

int main() {
	int N;
	cin >> N;
	
	bool ans = false;
	REP(i, 100) {
		int cur = N - i * 7;
		if (cur < 0) break;
		if (cur % 4 == 0) ans = true;
	}
	
	puts(ans ? "Yes" : "No");
	
	return 0;
}

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

int main(){
    string s,t;
    cin >> s >> t;
    int count = 0;
    for(int i = 0; i < s.size(); i ++){
        if(s[i] != t[i])
        count++;
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 3856
#include <bits/stdc++.h>
#include<string.h>
using namespace std;
#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define endl "\n"
#define Max(x,y,z) max(x,max(y,z))
#define Min(x,y,z) min(x,min(y,z))
#define fr(i,s,e) for(i=s;i<e;i++)
#define rf(i,s,e) for(i=s-1;i>=e;i--)
#define pb push_back
#define eb emblace_back
#define mp make_pair
#define ff first
#define ss second
//#define int   long long
#define ll   long long
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define vl vector<long long>
#define inf (1LL<<61)
#define vi vector<int>
#define vii vector< vector<int> >
#define vll vector< vector<long long> >
#define vpi vector< pair<int,int> >
#define vpl vector< pair<ll,ll> >
#define viii vector< vector<vector<int> > >
typedef pair<pair<int, int>,int> P;
#define cd complex<double>
#define PI 4*atan(1)
#define mod %1000000007
#define pi 3.14159265358979323846//20 decimals
#define ld long double

ll dp[401][401];
ll o[401][401];
ll a[401];
ll n;

ll pro(ll i, ll j)
{
	ll t1, t2;
	if(i == j)
	{
		dp[i][j] = 0;
		return 0;
	}
	else if((j - i) == 1)
	{
		dp[i][j] = a[i] + a[j];
		return dp[i][j];
	}
	else
	{
		ll mn = 10000000000000;
		for(ll k = i; k < j; k++)
		{
			ll t1, t2;
			if(o[i][k] == 0)
			{
				pro(i,k);
				o[i][k] = 1;
			}
			t1 = dp[i][k];
			if(o[k+1][j] == 0)
			{
				pro(k+1, j);
				o[k+1][j] = 1;
			}
			t2 = dp[k+1][j];
			if(t1 + t2 < mn)
				mn = t1 + t2;
		}
		for(ll k = i;k<=j;k++)
			mn += a[k];
		dp[i][j] = mn;
		return mn;
	}
}

int main()
{
	FAST;
	ll i, j;
	cin >> n;
	fr(i,0,n)
		cin >> a[i];	
	cout << pro(0, n-1);
//	cout << endl;
//	fr(i,0,n)
//		fr(j,i,n)
//			trace3(i,j,dp[i][j]);
}


Measured memory_bytes: 2816
# coding: utf-8
# Your code here!
import sys

S = input()

keyence = 'keyence'

for i in range(8):
    # print(S[:i],S[len(S)+i-7:])
    if S[:i] == keyence[:i] and S[len(S)+i-7:] == keyence[i-7:]:
        print('YES')
        sys.exit()
        
print('NO')

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

string S;
int main(){
  cin >> S;
  int N = S.size();
  for(int i=N-1;i>=1;i--){
    if(i%2==1) continue;
    string s = S.substr(0,i/2),t = S.substr(i/2,i/2);
    if(s==t){
      cout << i << endl;
      return 0;
    }
  }
  cout << 0 << endl;
}

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

#include<vector>
#include<string>

#include<algorithm>
#include<cmath>

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

int ctoi(const char c){
  switch(c){
    case '0': return 0;
    case '1': return 1;
    case '2': return 2;
    case '3': return 3;
    case '4': return 4;
    case '5': return 5;
    case '6': return 6;
    case '7': return 7;
    case '8': return 8;
    case '9': return 9;
    default : return -1;
  }
}

int A, B[3];
int main() {
    char w[10];
    cin >> w;
    A = ctoi(w[0]);
    B[0] = ctoi(w[1]);
    B[1] = ctoi(w[2]);
    B[2] = ctoi(w[3]);
    int E = 7 - A;
    int res = -1;
    for (int i = 0; i < (1 << 3); i++) {
        int tmp = 0;
        for (int j = 0; j < 3; j++) {
            if (i & (1 << j)) {
                tmp += B[j];
            } else {
                tmp -= B[j];
            }
        }
        if (tmp == E) {
            res = i;
            break;
        }
    }
    cout << A;

    if (res & 1) cout << "+";
    else cout << "-";
    cout << B[0];
    
    if (res & 2) cout << "+";
    else cout << "-";
    cout << B[1];

    if (res & 4) cout << "+";
    else cout << "-";
    cout << B[2] << "=7\n";
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Arrays;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {
	Scanner sc = new Scanner(System.in);
	public static void main(String[] args){
		new Main();
	}
	public Main(){
//		new A().doIt();
		new B().doIt();
//		new C().doIt();
//		new D().doIt();
	}
	class A{
		void doIt() {
			int a = sc.nextInt();
			int b = sc.nextInt();
			int h = sc.nextInt();
			System.out.println((a + b)*h/2);
		}
	}
	class B{
		void doIt() {
			String A = sc.next();
			String B = sc.next();
			String C = sc.next();
			
			char Ac[] = A.toCharArray();
			char Bc[] = B.toCharArray();
			char Cc[] = C.toCharArray();
			
			int AL = A.length();
			int BL = B.length();
			int CL = C.length();
			
			System.out.println(Battle(Ac,Bc,Cc,AL,BL,CL));
		}
		String Battle(char Ac[],char Bc[],char Cc[],int AL,int BL,int CL) {
			int a = 0,b = 0,c = 0;
			char start = 'a';
			while(true) {
				if(start == 'a') {
					a++;
					if(a == AL+1)return "A";
					start = Ac[a-1];
				}else if(start == 'b') {
					b++;
					if(b == BL+1)return "B";
					start = Bc[b-1];
				}else {
					c++;
					if(c == CL+1)return "C";
					start = Cc[c-1];
				}
			}
		}
	}
}


Measured memory_bytes: 21844
import java.util.*;

public class Main{
	private static final Scanner scan = new Scanner(System.in);

	public static void main(String[] args){
		List<Integer> listH = new ArrayList<Integer>();
		List<Integer> listW = new ArrayList<Integer>();
		for(;;){
			int H = scan.nextInt();
			int W = scan.nextInt();
			if(H == 0 && W == 0){
				break;
			}
			listH.add(H);
			listW.add(W);
		}

		for(int i = 0; i < listH.size(); i++){
			for(int j = 0; j < listH.get(i); j++){
				StringBuffer sb = new StringBuffer();
				for(int k = 0; k < listW.get(i); k++){
					sb.append("#");
				}
				sb.append("\n");
				String str = sb.toString();
				System.out.print(str);
			}
			System.out.println("");
		}
	}
}

Measured memory_bytes: 28736
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define rep2(i,s,n) for (int i = s; i < n; ++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define tmax(a,b,c) max(a,max(b,c))
#define tmin(a,b,c) min(a,min(b,c))
#define pb push_back
#define eb emplace_back
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vs vector<string>
#define vc vector<char>
#define vb vector<bool>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using LP = pair<ll,ll>;
inline void Yes(bool b) { cout << (b ? "Yes" : "No") << endl; }
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;}
template<class T> inline void operator>>(istream& is,vector<T>& v) { for(int& i : v){ is>>i; } }
template<class T> inline void operator<<(ostream& os,const vector<T>& v) { for(int i : v){ os<<i<<" "; } os<<endl; }
const int inf = 1001001001;
const ll linf = 1001001001001001001;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    int k;
    cin >> k;
    int ans = 0;
    rep2(a,1,k+1) rep2(b,1,k+1) rep2(c,1,k+1) {
        int g = gcd(a,b);
        ans += gcd(g,c);
    }
    cout << ans << endl;
}


Measured memory_bytes: 3648
/* ***************************************
Author        :Scau.ion
Created Time  :2017/10/22 20:09:29 UTC+8
File Name     :ion.cpp
*************************************** */

#include <bits/stdc++.h>
using namespace std;

#define LL long long
#define ULL unsigned long long
#define PB push_back
#define MP make_pair
#define PII pair<int,int>
#define VI vector<int>
#define VPII vector<PII>
#define X first
#define Y second
#define IOS ios::sync_with_stdio(0);cin.tie(0);
#define IN freopen("in", "r", stdin);
#define OUT freopen("out", "w", stdout);

int main()
{
	IOS;
	int n;
	cin>>n;
	LL sum = 1;
	LL sub = 1;
	for (int j = 1; j <= n; ++ j)
	{
		int x;
		cin>>x;
		if (x % 2) sub *= 1;
		else sub *= 2;
		sum *= 3;
	}
	sum -= sub;
	cout<<sum<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <map>
const int MOD = 1e9+7;
typedef long long ll;
using namespace std;

int main(){
	int n, ans = 0;
	cin >> n;
	vector<int> p(n);
	for (int i = 0; i < n; i++){
		cin >> p[i];
	}
	for (int i = 1; i < n-1; i++){
		if ((p[i-1] < p[i] && p[i] < p[i+1]) || (p[i-1] > p[i] && p[i] > p[i+1])){
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}



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



int main()
{
 string s,t;
 cin>>s;
 cin>>t;
 ll c=0;
 for(ll i=0;i<s.length();i++)
 {
     
     if(s[i]!=t[i])
     c++;
     
     
 }
 cout<<c;
 
}

Measured memory_bytes: 3916
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(false);cin.tie(NULL)
using namespace std;
#define int long long
#define MOD 1000000007
typedef vector<int> vi;
typedef pair<int,int> pi;
#define inf 1e18
#define For(i,a,b) for (int i = a; i < b; i++)
#define Rep(i,a,b) for (int i = a; i <= b; i++)
#define ps(x,y) fixed << setprecision(y) << x 
#define pb push_back 
#define mp make_pair 
 
int32_t main()
{
    fast;
    int n; cin >> n;
    int c1 = 0, c2 = 0, c3 = 0, c4 = 0;
    while(n--) {
        string s; cin >> s;
        if(s == "AC") c1++;
        else if (s == "WA") c2++;
        else if(s == "TLE") c3++;
        else c4++;
    }
    cout << "AC x " << c1 << "\n";
    cout << "WA x " << c2 << "\n";
    cout << "TLE x " << c3 << "\n";
    cout << "RE x " << c4 << "\n";
    
    return 0;
}

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

static const int N = 100;

int main(){
  int n, p[N+1], m[N+1][N+1];
  cin >> n;
  for( int i = 1; i <= n; i++){
    cin >> p[i-1] >> p[i];
  }

  for(int i = 1; i <= n; i++) m[i][i] = 0;
  for(int l = 2; l <= n; l++) {
    for(int i = 1; i <= n - l + 1; i++){
      int j = i + l - 1;
      m[i][j] = ( 1 << 21);
      for(int k = i; k <= j - 1; k++){
	m[i][j] = min(m[i][j], m[i][k] + m[k+1][j] + p[i-1]*p[k]*p[j]);
      }
    }
  }
  cout << m[1][n] << endl;

  return 0;
}
    



Measured memory_bytes: 3140
package main

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

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

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

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

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

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

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

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

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

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

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

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

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func min64(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a < b {
		return b
	}
	return a
}

func max64(a, b int64) int64 {
	if a < b {
		return b
	}
	return a
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func abs64(a int64) int64 {
	if a < 0 {
		return -a
	}
	return a
}

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

func gcd64(a, b int64) int64 {
	if b == 0 {
		return a
	}
	return gcd64(b, a%b)
}

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

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

func main() {
	defer stdout.Flush()
	N := readInt()
	L := readInt()
	lmin := L
	lmax := L + N - 1
	if lmax <= 0 {
		var ans int
		for i, l := 0, L; i < N-1; i, l = i+1, l+1 {
			ans += l
		}
		println(ans)
	} else if 0 <= lmin {
		var ans int
		for i, l := 0, L+1; i < N-1; i, l = i+1, l+1 {
			ans += l
		}
		println(ans)
	} else {
		var ans int
		for i, l := 0, L; i < N; i, l = i+1, l+1 {
			ans += l
		}
		println(ans)
	}
}

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


Measured memory_bytes: 640
S = input()
T = input()
len_S = len(S)
len_T = len(T)
N = len_S-len_T+1
max_cnt = 0
for i in range(N):
    cnt = 0
    for j in range(len_T):
        if S[i+j]==T[j]:
            cnt+=1
        if j==len_T-1:
            if max_cnt<cnt:
                max_cnt=cnt
print(len_T-max_cnt)

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

int main() {
  int a, b, c, d ;
  cin >> a ;
  b = a % 10 ; //一の位
  c = a / 10 % 10 ; //十の位
  d = a / 10 / 10 ; //百の位
  cout << b + c + d << endl;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES

#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <utility>
#include <climits>
#include <vector>
#include <map>
#include <queue>
using namespace std;

#define ll long long
const int MOD = 1000000007;//10^9+7
const string SPACE = " ";

ll max(ll a, ll b) {

	if (a > b)return a;
	else return b;

}
double max(double a, double b) {

	if (a > b)return a;
	else return b;

}
//a??¨b?????§?????????

ll min(ll a, ll b) {

	if (a < b)return a;
	else return b;

}
//a??¨b????°??????????

ll avd_i(ll a, ll b) {

	if (a > b)return a - b;
	else return b - a;

}
double avd_d(double a, double b) {

	double re;
	if (a > b)re = a - b;
	else re = b - a;
	return re;

}
//a??¨b???????????¶??????

ll powsur(ll a, ll b, ll p) {

	if (b == 0) {

		return 1;

	}
	else if (b % 2 == 0) {

		ll d = powsur(a, b / 2, p);
		return ((d%p)*(d%p)) % p;

	}
	else {

		return ((a%p)*powsur(a, b - 1, p) % p) % p;

	}

}
//p????´???°,a???b??????p??§?????£?????????

ll CMOD(ll n, ll r, ll p) {

	ll a = 1, b = 1, c = 1, re;
	for (int i = 1; i <= n; i++) {

		a *= i;
		a = a%p;

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

		b *= i;
		b = b%p;

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

		c *= i;
		c = c%p;

	}
	b = powsur(b, p - 2, p);
	c = powsur(c, p - 2, p);
	re = ((a%p)*(b%p)) % p;
	re = ((re%p)*c%p) % p;

	return re;

}
//p????´???°,(nCr)%p

ll gcd(ll a, ll b) {

	if (a > b) {

		ll tmp = a;
		a = b;
		b = tmp;

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

}
//?????§??¬?´???°

ll lcm(ll a, ll b) {

	return (a / gcd(a, b))*b;

}
//????°???¬?????°

int main() {
	
	int r, c, table[105][105], asum[105], bsum[105], sum = 0;

	cin >> r >> c;
	for (int i = 0; i < r; i++)asum[i] = 0;
	for (int i = 0; i < c; i++)bsum[i] = 0;
	for (int i = 0; i < r; i++) {
		for (int j = 0; j < c; j++) {

			cin >> table[i][j];
			asum[i] += table[i][j];
			bsum[j] += table[i][j];
			sum += table[i][j];

		}
	}

	for (int i = 0; i < r; i++) {

		for (int j = 0; j < c; j++) {

			cout << table[i][j] << " ";

		}
		cout << asum[i] << endl;

	}
	for (int i = 0; i < c; i++)cout << bsum[i] << " ";
	cout << sum << endl;

	return 0;
}

Measured memory_bytes: 3052
#include <iostream>
#include <functional>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <queue>
#include <map>
#include <iomanip>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;++i)
#define repi(i,n) for(ll i=n-1;i>=0;--i)
#define sll(n) scanf("%lld", &n);
#define slf(n) scanf("%lf", &n);
typedef long long ll;
typedef double lf;
static const ll max_n = 100010;
static const ll mod = 1000000007;
static const ll max_value = 100000000000100;
// vector<vector<vector<ll>>> dp(max_n, vector<vector<ll>>(max_n, vector<ll>(max_n*max_n, 0)));
vector<ll> dp(max_n, 0);
vector<ll> dp_sum(max_n, 0);
// static const ll max_x = max_value * max_value;
vector<ll> A(max_n);
// vector<ll> cards(max_n);
// vector<ll> S(max_n);
// vector<pair<ll, ll>> times_vec(max_n);


void Main(){
    // bool is_ok = true;
    // printf("------------- V=%lld---------\n", V);
    ll N, K, d, a;
    set<ll> peoples;
    sll(N);
    sll(K);
    rep(i, K){
        sll(d);
        rep(j, d){
            sll(a);
            peoples.insert(a);
        }
    }

    printf("%lld\n", N-(ll)peoples.size());

    // cout<<fixed<<setprecision(10)<<num<<endl;
    // cout << num << endl;

}

int main(){
    Main();

    return 0;

}

Measured memory_bytes: 5012
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	int n;
	cin >> n;
	for(int i = 0; i < n; i++){
		int l[3];
		cin >> l[0] >> l[1] >> l[2];
		sort(l,l+3);
		if(l[2]*l[2] == l[1]*l[1] + l[0]*l[0])
			cout << "YES" << endl;
		else
			cout << "NO" << endl;
	}
      return 0;
}

Measured memory_bytes: 1168
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		string[] str = Console.ReadLine().Split();
		int N = int.Parse(str[0]);
		int Q = int.Parse(str[1]);
		string s = Console.ReadLine();
		string[]T = new string[Q];
		string[]D = new string[Q];
		for(var i=0;i<Q;i++){
			string[] str2 = Console.ReadLine().Split();
			T[i] = str2[0];
			D[i] = str2[1];
		}
		int min = 0;
		int max = N;
		while(min<max){
			int m = (min+max)/2;
			int m1 = m;
			for(var j=0;j<Q;j++){
				if(s.Substring(m1,1)==T[j]){
					if(D[j]=="L"){
						m1--;
						if(m1==-1){
							min = m+1;
							break;
						}
					} else {
						m1++;
						if(m1==N){
							max = m;
							break;
						}
					}
				}
			}
			if(m1>=0){
				max = m;
			}
		}
		int a1 = min;
		min = 0;
		max = N;
		while(min<max){
			int m = (min+max)/2;
			int m1 = m;
			for(var j=0;j<Q;j++){
				if(s.Substring(m1,1)==T[j]){
					if(D[j]=="L"){
						m1--;
						if(m1==-1){
							min = m+1;
							break;
						}
					} else {
						m1++;
						if(m1==N){
							max = m;
							break;
						}
					}
				}
			}
			if(m1<N){
				min = m+1;
			}
		}
		int ans = min-a1;
		Console.WriteLine(ans);
	}
}

Measured memory_bytes: 32372
import java.util.*;

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

		Scanner sc = new Scanner(System.in);
		long prime = (long)(1e9+7);
		long N = sc.nextLong() + 1;
		long K = sc.nextLong();
		long sum = 0;
		for(long i = K; i <= N; i++) {
			long L = ((i-1)*i)/2;
			long R = (i*(2*(N - i)+(i - 1)))/2;
			sum += (R - L + 1) % prime;
		}
		System.out.println(sum % prime);
	}
}

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

string S;
int w;

int main(void){
    
    cin >> S >> w;
    string ans;
    for(int i = 0; i < S.size(); i += w){
        ans += S[i];
    }
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() 
{
	int i, j;
	for (i = 1; i <= 9; i++) {
		for (j = 1; j <= 9; j++) {
        			cout << i << 'x' << j << '=' << i * j << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 3000
from collections import defaultdict
n,x = open(0).read().split()
n = int(n)
cnt = x.count('1') 
digits = list(map(int, list(x)))
x = int(x, 2)

d = defaultdict(int)
d[0] = 0
def calc(m):
    if m not in d:
        nxt = m % bin(m).count('1')
        d[m] = calc(nxt) + 1
    return d[m]

mmod = cnt - 1
pmod = cnt + 1

if mmod > 0:
    mx = x % mmod
px = x % pmod

mbase = 1
pbase = 1

ans = []
while digits:
    digit = digits.pop()
    
    if digit and mmod <= 0:
        ans.append(0)
    else:
        if digit:
            nx = (mx - mbase)%mmod
        else:
            nx = (px + pbase)%pmod
        ans.append(calc(nx) + 1)

    if mmod > 0:
        mbase = (mbase * 2) % mmod
    pbase = (pbase * 2) % pmod

while ans:
    print(ans.pop())

Measured memory_bytes: 101268
#include<iostream>
using namespace std;
typedef long long ll;

const int MAX_N = 1e5 + 1;

ll A[MAX_N];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    for (int i = 0; i < N; i++) cin >> A[i];
    ll sum = 0;
    bool is_add = true;
    for (int i = N - 2; i >= 0; i--) {
        if (is_add) sum += A[i];
        else sum -= A[i];
        is_add ^= 1;
    }
    ll X = (A[N - 1] - sum) / 2;

    for (int i = 0; i < N; i++) {
        cout << 2 * X << " \n"[i == N - 1];
        X = A[i] - X;
    }
    return 0;
}

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

using namespace std;

typedef long long ll;

const int INF = 1000000000;
const ll MOD = (ll)1e9 + 7;

ll mod_fact(ll n)
{
  ll ret = 1;
  for (int i = 1; i <= n; ++i) {
    ret = (ret * i) % MOD;
  }
  return ret;
}

int main()
{
  int N, M; scanf("%d %d", &N, &M);
  ll ans = 1;
  if (abs(N - M) > 1) {
    printf("0\n");
    return 0;
  }
  else if (N == M) {
    ans = (mod_fact(N) * mod_fact(M)) % MOD;
    ans = (ans * 2) % MOD;
  }
  else {
    if (N < M) { swap(N, M); }
    ans = (mod_fact(N) * mod_fact(M)) % MOD;
  }
  printf("%lld\n", ans);
  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<long long> vll;
typedef vector<pair<int, int>> vpi;
typedef vector<pair<long long, long long>> vpl;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define FOR(i, k, n) for (int i = (k); i < (int)(n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.begin(), a.end(), greater<int>()
#define ROT(a) a.begin(), a.begin() + 1, a.end()
#define RROT(a) a.begin(), a.end() - 1, a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
#define sz(a) a.size()
const ll MOD = 1e9 + 7;
const int MAX = 10000000;
template <typename T1, typename T2>
inline bool chmin(T1& a, T2 b)
{
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T1, typename T2>
inline bool chmax(T1& a, T2 b)
{
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
T gcd(T a, T b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
//cout << 'H' << endl;
/*--------------------------------------------*/

int main()
{
    //cout << fixed << setprecision(10)
    cin.tie(0);
    ios::sync_with_stdio(false);

    ll N;
    cin >> N;

    map<string, int> mp;
    rep(i, N)
    {
        string s;
        cin >> s;

        mp[s]++;
    }

    cout << sz(mp) << endl;
}


Measured memory_bytes: 19248
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;

int main() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    int k;
    cin >> k;
    for (int i = 0; i < s.size(); i++) {
        if (s[i] != s[k - 1]) {
            s[i] = '*';
        }
    }
    cout << s << endl;
}


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

const int N=100000;

int sum,n,a[N+9];

int main(){
  scanf("%d%d",&sum,&n);
  for (int i=1;i<=n;++i){
	scanf("%d",&a[i]);
    sum-=a[i];
  }
  puts(sum<=0?"Yes":"No");
  return 0;
}

Measured memory_bytes: 640
#![allow(non_snake_case)]
#![allow(unused_variables)]
#![allow(dead_code)]

fn main() {
    let N: i64 = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        line.trim().parse().unwrap()
    };
    let S: &str = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        &(line.trim().parse::<String>().unwrap())
    };

    fn bis<P>(ok: i64, ng: i64, p: P) -> i64
        where P: Fn(i64) -> bool {
        let mid = (ok + ng) / 2;
        if (ok - ng).abs() == 1 {
            ok
        } else if p(mid) {
            bis(mid, ng, p)
        } else {
            bis(ok, mid, p)
        }
    }
    let ans = bis(0, N / 2 + 1, |L| {
        (0..(N - L)).any(|i|
            S[((i + L) as usize)..].find(&S[(i as usize)..((i + L) as usize)]) != None)
    });

    println!("{}", ans);
}


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

int main() {
    ll x, k, d;
    cin >> x >> k >> d;
    ll cnt = abs(x) / d;
    if (cnt >= k) {
        if (x < 0) cout << abs(x + d * k) << endl;
        else cout << x - d * k << endl;
        return 0;
    }
    k -= cnt;
    if (x < 0) x = abs(x + d * cnt);
    else x =  x - d * cnt;
    if (k % 2 == 0) cout << abs(x) << endl;
    else cout << abs(x - d) << endl;
}


Measured memory_bytes: 3628
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <cmath>
using namespace std;

#define FOR(i,s,e) for (int i = int(s); i < int(e); i++)
#define FORIT(i,c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); i++)
#define ISEQ(c) (c).begin(), (c).end()

int SURP = 1000000007;

int keta_sum(int i){
	int sum = 0;
	while(i > 0){
		sum += i%10;
		i = i/10;
	}
	return sum;
}

int main(){
	int N,A,B;
	cin >> N >> A >> B;
	int sum = 0;

	FOR(i,1,N+1){
		if(A <= keta_sum(i) && B >= keta_sum(i)) sum += i;
	}

	cout << sum << endl;
	return 0;

}

Measured memory_bytes: 384
import numpy as np
import collections

N=int(input().split()[0])
A=[]
for i in range(N):
  A.append(input().split()[0])

C=collections.Counter(A)
c= C.most_common()
m=c[0][1]
x=[]
for c,n in c:
  if n==m:
    x.append(c)
  else:
    break
x=sorted(x)
for i in x:
  print(i)


Measured memory_bytes: 53792
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <math.h>
#include <complex>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <functional>
#include <assert.h>
using ll=long long;
#define int ll
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define SZ(x) x.size()
#define fi first
#define se second
const int INF = 1e15;
using namespace std;

template<class T> using vc=vector<T>;
template<class T> using vvc=vc<vc<T>>;

using pi=pair<int,int>;
using vi=vc<int>;

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;}

struct SCC{
  vector< vector<int> > G,R,T,C;
  vector<int> vs,used,blg,dps;
  SCC(){}
  SCC(int n):G(n),R(n),used(n),blg(n),dps(n){}

  void add_edge(int u,int v){
    G[u].emplace_back(v);
    R[v].emplace_back(u);
  }

  void dfs(int v){
    used[v]=1;
    for(int u:G[v])
      if(!used[u]) dfs(u);
    vs.emplace_back(v);
  }

  void rdfs(int v,int k){
    used[v]=1;
    blg[v]=k;
    C[k].emplace_back(v);
    for(int u:R[v]){
      if(!used[u]) rdfs(u,k);
      chmax(dps[v],dps[u]+1);
    }
  }

  int build(){
    int n=G.size();
    for(int v=0;v<n;v++)
      if(!used[v]) dfs(v);

    fill(used.begin(),used.end(),0);
    int k=0;
    for(int i=n-1;i>=0;i--){
      if(!used[vs[i]]){
        T.emplace_back();
        C.emplace_back();
        rdfs(vs[i],k++);
      }
    }

    for(int v=0;v<n;v++)
      for(int u:G[v])
        if(blg[v]!=blg[u])
          T[blg[v]].push_back(blg[u]);

    for(int i=0;i<k;i++){
      sort(T[i].begin(),T[i].end());
      T[i].erase(unique(T[i].begin(),T[i].end()),T[i].end());
    }
    return k;
  }

  int operator[](int k) const{return blg[k];}
};

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(20);

    int N; cin >> N;
    SCC scc((N+1)*(N+1));
    rep(i,N){
        vi a(N-1);
        for(auto &t:a) cin >> t;
        rep(j,N-1) a[j]=min(i+1,a[j])*N+max(i+1,a[j]);
        rep(j,N-2){
            scc.add_edge(a[j],a[j+1]);
        }
    }
    if(scc.build()!=(N+1)*(N+1)) {
        cout << -1 << endl;
        return 0;
    }
    int ans=0;
    rep(i,(N+1)*(N+1)){
        chmax(ans,scc.dps[i]);
    }
    cout << ans+1 << endl;
}

Measured memory_bytes: 204376
readline = open(0).readline
writelines = open(1, 'w').writelines

N = int(readline())
A = map(int, readline().split())

N0 = 2**(N-1).bit_length()
D1 = [0]*(2*N0); D2 = [0]*(2*N0)

for i, a in enumerate(A):
    D1[i+N0-1] = D2[i+N0-1] = a

for i in range(N0-2, -1, -1):
    D1[i] = min(D1[2*i+1], D1[2*i+2])
    D2[i] = max(D2[2*i+1], D2[2*i+2])

def query_min(l, r):
    L = l + N0; R = r + N0
    s = 1e9
    while L < R:
        if R & 1:
            R -= 1
            s = min(s, D1[R-1])

        if L & 1:
            s = min(s, D1[L-1])
            L += 1
        L >>= 1; R >>= 1
    return s
def query_max(l, r):
    L = l + N0; R = r + N0
    s = -1e9
    while L < R:
        if R & 1:
            R -= 1
            s = max(s, D2[R-1])

        if L & 1:
            s = max(s, D2[L-1])
            L += 1
        L >>= 1; R >>= 1
    return s


C = [query_min, query_max].__getitem__
Q = int(readline())
ans = []
for q in range(Q):
    t, b, e = map(int, readline().split())
    ans.append("%d\n" % C(t)(b, e))
writelines(ans)



Measured memory_bytes: 5800
#include<algorithm>
#include<complex>
#include<ctype.h>
#include<iomanip>
#include<iostream>
#include<fstream>
#include<map>
#include<math.h>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<stdio.h>
#include<string>
#include<string>
#include<vector>

using namespace std;
typedef long long ll;

#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("Yes")
#define p_no() p("No")

const ll mod = 1e9 + 7;
const ll inf = 1e18;

template < typename T >
void vprint(T &V){
	for(auto v : V){
    	cout << v << " ";
	}
	cout << endl;
}

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

    // input
    ll N, x;
    cin >> N >> x;

    vector<ll> A(N);
    ll min_cost = 0;
    FOR(i, 0, N){
        cin >> A.at(i);
        min_cost += A[i];
    }

    // B[i][k]
    ll B[N][N+1];
    FOR(i, 0, N){
        B[i][0] = A[i];
    }

    // k回魔法
    FOR(k, 1, N+1){
        ll cost = k * x;
        FOR(i, 0, N){
            ll index = i-k;
            if(index<0){
                index += N;
            }
            B[i][k] = min(B[i][k-1], A[index]);
            cost += B[i][k];
        }
        min_cost = min(min_cost, cost);
    }

    p(min_cost);
    
    return 0;
}

Measured memory_bytes: 31488
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<functional>
#include<fstream>
#include<utility>
#include<bitset>
#include<map>
#include<deque>
#define rep(N) for (int i = 0; i < N; i++)
#define For(i, N) for (i = 0; i < N; i++)
#define rev(N) 	for (int i = N - 1; i >= 0; --i)
#define all(v) v.begin(), v.end()
#define mod 1000000007
#define re return 0

using namespace std;
using ll = long long int;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
using vs = vector<string>;
using pii = pair<int, int>;
using pis = pair<int, string>;

template<typename T>
void say(T s) {
	cout << s << endl;
}

template<typename T1, typename T2>
void say(T1 s1, T2 s2) {
	cout << s1 << " " << s2 << endl;
}

int main() {
	ll N;
	ll x;
	ll ans = 0;
	ll plus = 0;
	ll minus = 0;
	vll a, b;
	cin >> N;
	rep(N) {
		cin >> x;
		a.push_back(x);
	}
	rep(N) {
		cin >> x;
		b.push_back(x);
	}
	rep(N) {
		ll dif = b[i] - a[i];
		if (dif > 0)plus += dif / 2;
		else minus -= dif;
	}
	if (plus >= minus)say("Yes");
	else say("No");
}

Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <cstring>
#define ll long long
#define INF 1000000007
using namespace std;

const int MAXN=1e5+5;

int n,l,r;
ll cnt,sum;
int a[MAXN],b[MAXN],c[MAXN];

void work(int begin,int end){
	if(begin==end)
		return;
	int mid=(begin+end)/2;
	work(begin,mid);
	work(mid+1,end);
	int i=begin,j=mid+1,k=begin;
	while(i<=mid && j<=end){
		if(b[i]<b[j])
			c[k++]=b[i++];
		else{
			cnt+=(i-begin);
			c[k++]=b[j++];
		}
	}
	while(i<=mid)
		c[k++]=b[i++];
	while(j<=end){
		cnt+=(i-begin);
		c[k++]=b[j++];
	}
	for(int l=begin;l<=end;l++)
		b[l]=c[l];
}

bool check(int m){
	cnt=0;
	for(int i=1;i<=n;i++){
		if(a[i]<=m)
			b[i]=1;
		else
			b[i]=-1;
	}
	for(int i=1;i<=n;i++){
		b[i]+=b[i-1];
	}
	work(0,n);
	if(cnt>=(sum/2+1))
		return true;
	return false;
}

int main(){
	scanf("%d",&n);
	l=INF;r=0;sum=0;
	for(int i=1;i<=n;i++){
		scanf("%d",&a[i]);
		l=min(l,a[i]);
		r=max(r,a[i]);
		sum+=i;
	}
	while(l<r){
		int m=(l+r)/2;
		if(check(m)){
			r=m;
		}else{
			l=m+1;
		}
	}
	printf("%d\n",r);
	return 0;
}



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

int main() {
	ios :: sync_with_stdio(false);
	char t;
	int c1 = 0, c2 = 0;
	for(int a, b, c; cin >> a >> t >> b >> t >> c; ) {
		if(a * a + b * b == c * c)
			c1 ++;
		if(a == b)
			c2 ++;
	}
	cout << c1 << '\n' << c2 << '\n';
	return 0;
}

Measured memory_bytes: 3080
#include "bits/stdc++.h"
#define PRECISION(x) cout << fixed << setprecision(x)
#define FAST_IO ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define ALLR(X) (X).rbegin(), (X).rend()
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define F first
#define S second

using namespace std;
 
template<class T> void max_self(T & a, const T & b) { if(a < b) a = b; }
template<class T> void min_self(T & a, const T & b) { if(a > b) a = b; }
typedef long long LL;
const int INF = 1e9 + 7;
const double PI = acos(-1.0);
const double EPS = (1e-9);

int main(){
  FAST_IO

  int a, b; cin >> a >> b;

  if(b < a) cout << a - 1 << '\n';
  else cout << a << '\n';

  return 0;
}


Measured memory_bytes: 256
N, M, C, = map(int,input().split())
B = list(map(int,input().split()))
ans = 0
for i in range(N):
    A = list(map(int, input().split()))
    s = 0
    for j in range(M):
        s += A[j] * B[j]
    if s + C > 0:
        ans += 1
print(ans)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int H, W, K;
int MAP[1000][1000];
int x, y, vis[1000][1000];
int ans = 2147483647;
const int dx[4] = {0, 1, 0, -1};
const int dy[4] = {1, 0, -1, 0};
struct PR {
    int x, y, now;
    PR() {x = y = now = 0;}
    PR(int _x, int _y, int _now) {x = _x, y = _y, now = _now;}
};
bool check(int x, int y) {
    if (x < 0 || x > H) return 0;
    if (y < 0 || y > W) return 0;
    if (MAP[x][y]) return 0;
    return 1;
}
int main() {
    cin >> H >> W >> K;
    for (int i = 1; i <= H; i ++) {
        string s;
        cin >> s;
        for (int j = 1; j <= W; j ++) {
            if (s[j - 1] == '#') MAP[i][j] = 1;
            else {
                MAP[i][j] = 0;
                if (s[j - 1] == 'S') x = i, y = j; 
            }
        }
    }
    queue<PR> Q; Q.push((PR){x, y, 0});
    while (!Q.empty()) {
        PR tmp = Q.front(); Q.pop();
        if (tmp.now > K) continue;
        if (vis[tmp.x][tmp.y] <= tmp.now && vis[tmp.x][tmp.y] != 0) continue;
        vis[tmp.x][tmp.y] = tmp.now;
        ans = min(ans, min(min((int)ceil((double)(tmp.x - 1) / K), (int)ceil((double)(tmp.y - 1) / K)), min((int)ceil((double)(H - tmp.x) / K), (int)ceil((double)(W - tmp.y) / K))) + 1);
        for (int i = 0; i < 4; i ++) {
            if (check(tmp.x + dx[i], tmp.y + dy[i])) Q.push((PR){tmp.x + dx[i], tmp.y + dy[i], tmp.now + 1});
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 7296
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<climits>
#define MOD 1000000007
typedef long long ll;
using namespace std;

int c[10][10];
// int d[10][10];
void warshall_floyd(){
  for(int k=0;k<10;k++){
    for(int i=0;i<10;i++){
      for(int j=0;j<10;j++){
        c[i][j] = min(c[i][j], c[i][k] + c[k][j]);
      }
    }
  }
}

int main(){
  int h,w; cin >> h >> w;
  for(int i=0;i<10;i++){
    for(int j=0;j<10;j++) cin >> c[i][j];
  }
  warshall_floyd();

  int a[205][205];
  int ans = 0;
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      int a; cin >> a;
      if(a>=0) ans += c[a][1];
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
n,m=map(int,input().split())
mod=10**9+7

NG=[0]*(n+1)
dp=[0]*(n+1)
dp[0]=1

for _ in range(m):
    a=int(input())
    NG[a]=1

for i in range(n):
    if i==0:            #一段目
        dp[i+1]=dp[i] if NG[i+1]==0 else 0
        continue

    if NG[i+1]==1:
        dp[i+1]=0
    else:
        dp[i+1]=dp[i]+dp[i-1]
        dp[i+1]%=mod

print(dp[n])

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

constexpr int INF = 1e9;

int main() {
    int N;
    cin >> N;
    vector<vector<int>> dp(N / 2 + 2, vector<int>(2, INF));
    dp[1][0] = 0;
    for(int i = 0; i < N - 1; ++i) {
        int t;
        cin >> t;
        vector<vector<int>> next(N / 2 + 2, vector<int>(2, INF));
        for(int j = 0; j < N / 2 + 1; ++j) {
            next[j + 1][0] = min(dp[j][0], dp[j][1] + t);
            next[j][1] = min(dp[j][0] + t, dp[j][1]);
        }
        dp.swap(next);
    }
    cout << min(dp[N / 2][0], dp[N / 2][1]) << endl;
}


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

#define ALL(obj) (obj).begin(),(obj).end()
#define SPEED cin.tie(0);ios::sync_with_stdio(false);

template<class T> using PQ = priority_queue<T>;
template<class T> using PQR = priority_queue<T,vector<T>,greater<T>>;

constexpr long long MOD = (long long)1e9 + 7;
constexpr long long MOD2 = 998244353;
constexpr long long HIGHINF = (long long)1e18;
constexpr long long LOWINF = (long long)1e15;
constexpr long double PI = 3.1415926535897932384626433L;

template <class T> vector<T> multivector(size_t N,T init){return vector<T>(N,init);}
template <class... T> auto multivector(size_t N,T... t){return vector<decltype(multivector(t...))>(N,multivector(t...));}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o;}
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const multiset<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {o << "{" << obj.first << ", " << obj.second << "}"; return o;}
template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
void print(void) {cout << endl;}
template <class Head> void print(Head&& head) {cout << head;print();}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head << " ";print(forward<Tail>(tail)...);}
template <class T> void chmax(T& a, const T b){a=max(a,b);}
template <class T> void chmin(T& a, const T b){a=min(a,b);}
void YN(bool flg) {cout << (flg ? "YES" : "NO") << endl;}
void Yn(bool flg) {cout << (flg ? "Yes" : "No") << endl;}
void yn(bool flg) {cout << (flg ? "yes" : "no") << endl;}

int main() {
	int N; cin >> N;
	vector<ll> A(N);
	for(int i = 0; i < N; ++i) cin >> A[i];
	map<ll,ll> mp;
	for(ll i = 0; i < N; ++i) {
		mp[(i+1)-A[i]]++;
	}
	ll ans = 0;
	for(ll i = 0; i < N; ++i) {
		mp[(i+1)-A[i]]--;
		if(mp.count(i+1+A[i])) ans += mp[i+1+A[i]];
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 16396
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, core.bitop;

enum inf3 = 1_001_001_001;
enum inf6 = 1_001_001_001_001_001_001L;
enum mod = 1_000_000_007L;

alias R = Tuple!(long, "a", long, "b");

void main() {
    int n;
    scan(n);
    auto r = new R[](n);
    foreach (i ; 0 .. n) {
        int a, b;
        scan(a, b);
        r[i] = R(a, b);
    }

    r.sort!"a.a + a.b > b.a + b.b"();

    debug {
        foreach (i ; 0 .. n) {
            writeln(r[i]);
        }
    }

    long ans;

    foreach (i ; 0 .. n) {
        if (i % 2 == 0) {
            ans += r[i].a;
        }
        else {
            ans -= r[i].b;
        }
    }

    writeln(ans);
}






void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}


Measured memory_bytes: 4860
#include <bits/stdc++.h>
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#pragma GCC optimize(4)
#pragma GCC optimize("Ofast,no-stack-protector")
#define ll long long
#define res register ll
#define N 2005
using namespace std;
ll inv[N*N+N+N],jie[N*N+N+N],k,n,f[N][N];
const ll mod=1e9+7;
inline ll read()
{
  ll X=0,w=0;
  char ch=0;
  while(!isdigit(ch))
  {
    w|=ch=='-';
    ch=getchar();
  }
  while(isdigit(ch)) X=(X<<3)+(X<<1)+(ch^48),ch=getchar();
  return w?-X:X;
}
inline ll quickpow(res base,res num)
{
  res ans=1;
  for(; num; num>>=1,base=1LL*base*base%mod)
    if(num&1)
      ans=1LL*ans*base%mod;
  return ans;
}
inline void init()
{
  jie[0]=jie[1]=inv[0]=inv[1]=1;
  for(res i=2; i<=n*k+n+k; i++)
  {
    jie[i]=1LL*jie[i-1]*i%mod;
    inv[i]=quickpow(jie[i],mod-2);
  }
}
inline ll C(ll m,ll n)
{
  return 1LL*jie[m]*inv[n]%mod*1LL*inv[m-n]%mod;
}
int main()
{
  n=read(),k=read()-1;
  if(!k)
  {
    puts("1");
    return 0;
  }
  init();
  f[0][0]=1;
  for(res i=0; i<=n; i++)
    for(res j=i; j<=n; j++)
    {
      if(i) f[i][j]=(f[i][j]+f[i-1][j])%mod;
      if(j) f[i][j]=(f[i][j]+1LL*f[i][j-1]*C(i+j*k-1,k-1)%mod)%mod;
    }
  printf("%lld\n",1LL*f[n][n]*jie[n]%mod);
  return 0;
}

Measured memory_bytes: 94464
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
    unordered_map<string,int>m;
    int n;
    string s;
    cin>>n;
    while(n--)
    {
        cin>>s;
        m[s]++;
    }
    cout<<"AC x "<<m["AC"]<<"\n";
    cout<<"WA x "<<m["WA"]<<"\n";
    cout<<"TLE x "<<m["TLE"]<<"\n";
    cout<<"RE x "<<m["RE"]<<"\n";
}


Measured memory_bytes: 3612
#include<iostream>
#include<stdio.h>
#include<cstring>
#include<cmath>
#include<vector>
#include<set>
#include<map>
#include<algorithm>
#include<unordered_map>
#define ll long long 
#define dd double
using namespace std;
 
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  
  int a,p;
  cin>>a>>p;
  a=a*3;
  int total=a+p;
  cout<<total/2<<endl;
  
  return 0;
}

Measured memory_bytes: 3624
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(){
  int c[3][3], i, j;
  for(i=0;i<3;i++)
    for(j=0;j<3;j++)
      scanf("%d", &c[i][j]);
  
  if((c[0][0]-c[1][0]==c[0][1]-c[1][1]) &&
     (c[0][1]-c[1][1]==c[0][2]-c[1][2]) &&
     (c[1][0]-c[2][0]==c[1][1]-c[2][1]) &&
     (c[1][1]-c[2][1]==c[1][2]-c[2][2]) &&
     
     (c[0][0]-c[0][1]==c[1][0]-c[1][1]) &&
     (c[1][0]-c[1][1]==c[2][0]-c[2][1]) &&
     (c[0][1]-c[0][2]==c[1][1]-c[1][2]) &&
     (c[1][1]-c[1][2]==c[2][1]-c[2][2]) )
    printf("Yes\n");
  else
    printf("No\n");
  
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#define int long long int
#define pb push_back
#define  fill(st,et,val,arr) for(int i=st;i<=et;i++)arr[i]=val;
#define all(v) v.begin(),v.end()
template <class T>
inline void read(T &x) {
    x = 0;
    char ch = getchar(), w = 0;
    while (!isdigit(ch)) w = ch == '-', ch = getchar();
    while (isdigit(ch)) x = (x << 1) + (x << 3) + (ch ^ 48), ch = getchar();
    x = w ? -x : x;
    return;
}
 
const int M=1e9 + 7;
const int MAX=1e5+7;
using namespace std;
bool comp(int a,int b)
{	
	return a>b;
}
void printQ(vector<int> q)
{   
    cout<<"v->  ";
	for(int i=0;i<q.size();i++)
	{
		cout<<q[i]<<" ";
	}
	cout<<endl;
}
int cel(int d,int n)
{
	int ans=d/(n+1);
	if((d%(n+1))!=0)ans++;
	return ans;
}
int32_t main() 
{
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int n,m;
    cin>>n>>m;
    string s1="";
    string s2="";
    for(int i=0;i<n;i++)
    {
    	string tt="-";
    	tt[0]=m+'0';
    	s1+=tt;
	}
	for(int i=0;i<m;i++)
    {
    	string tt="-";
    	tt[0]=n+'0';
    	s2+=tt;
	}
	string ans=min(s1,s2);
	cout<<ans<<endl;
	return 0;
}













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

int n;
int a[1001];

int main(void){
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	for(int i=0;i<n;i++){
		for(int j=i+1;j<n;j++){
			int di=abs(a[i]-a[j]);
			if(di%(n-1)==0){
				printf("%d %d\n",a[i],a[j]);
				return 0;
			}
		}
	}
	return 0;
}


Measured memory_bytes: 3220