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

using namespace std;

#define mp make_pair
#define fi first
#define se second
#define all(v) v.begin(),v.end()
#define allarr(a) a , a + n
#define ll long long
#define ull unsigned long long 
#define pb push_back
#define fastio ios_base::sync_with_stdio(false) ; cin.tie(NULL); cout.tie(NULL)
typedef pair<int, int> pi;
typedef pair<ll,ll> pll; 
typedef pair<int,pi> trp ;
typedef vector<pi> vpi;
typedef vector<pll> vpll ;
// int ab  (int  x ) { return (x>0?x:-x); }m
const int N = 2505 ; 
ll dist[N]; 
vpi adj[N] ;
set<int> con[N];
int cur ;
bool visited[N];   
void dfs(int u ){
	visited[u] = 1 ; 
	for(pi v : adj[u]){
			con[cur].insert(v.fi) ;
		if (!visited[v.fi]){
			dfs(v.fi) ; 
		}
	}
}
bool relax(int u , int v , int w){
	if( dist[v] < dist[u]+1LL*w ){
		dist[v] = dist[u]+1LL*w ;
		return 1; 
	}return 0; 
}
int main(){
	int n , m , p ; 
	cin >> n >> m >> p ; 
	
	for(int i = 0 ; i < m ; i++ ){
		int x , y , c ; 
		cin >> x >> y >> c ; 
		adj[x].pb({y,c-p});
	}

	for(int i = 1 ; i <= n ; i++ ){
		cur = i ; 
		memset(visited,0,sizeof visited ); 
		dfs(i); 
	}
	bool cycle = 0 ; 
	fill(dist,dist+n+1,-1e12); 
	dist[1]=0; 
	for(int i = 0 ; i < n-1; i++ ){
		for(int u = 1 ; u <= n ; u++ ){
			for(pi v : adj[u]){
				relax(u,v.fi,v.se); 
			}
		}
		
	}for(int u = 1 ; u <= n && !cycle; u++ ){
			for(pi v : adj[u]){
				if( dist[v.fi] < dist[u]+1LL*v.se ){
					if( con[v.fi].count(n) && con[1].count(u)){
						cycle = 1 ; 
						break ; 
					}
				}
			}
		}
	cout << (cycle?-1:max(dist[n],0LL)) << endl; 
}

Measured memory_bytes: 295680
import java.util.Scanner;

public class Main {

	static boolean[][] graph;
	static boolean[] vis;
	static int n, m, count;
	static int[] a, b;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		n = sc.nextInt();
		m = sc.nextInt();
		a = new int[m];
		b = new int[m];
		vis = new boolean[n];
		graph = new boolean[n][n];
		for(int i = 0 ; i < m ; i++) {
			a[i] = sc.nextInt() - 1;
			b[i] = sc.nextInt() - 1;
			graph[a[i]][b[i]] = graph[b[i]][a[i]] = true;
		}
		for(int i = 0 ; i < n ; i++) vis[i] = false;
		vis[0] = true;
		dfs(0);
		System.out.println(count);
	}

	public static void dfs(int v) {
		boolean all_ok = true;
		for(int i = 0 ; i < n ; i++) {
			if(vis[i] == false) all_ok = false;
		}
		if(all_ok) count++;
		for(int i = 0 ; i < n ; i++) {
			if(graph[v][i] == false) continue;
			if(vis[i] == true) continue;
			vis[i] = true;
			dfs(i);
			vis[i] = false;
		}
		return;
	}

}


Measured memory_bytes: 23380
#include<map>
#include<set>
#include<cmath>
#include<ctime>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<vector>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
#define lb(x) x&-x
#define il inline
#define ll long long
#define llu unsigned long long
#define mem(x) memset(x,0,sizeof(x))
#define mem3(x) memset(x,0x3f,sizeof(x))
#define ccA() puts("耐心冷静查代码")
#define cc() puts("谁知盘中餐，粒粒皆辛苦")
#define fo(i,a,b) for(register int i=a;i<=b;++i)
#define fd(i,a,b) for(register int i=a;i>=b;--i)
#define fk(i,j) for(register int i=fir[j];i;i=nxt[i])
#define fv(i,q) for(int i=0;i<q.size();i++)
using namespace std;
inline ll read(){
    ll x=0,f=1;char c;
    for(c=getchar();c<'0'||c>'9';f=((c=='-')?-1:f),c=getchar());
    for(;c>='0'&&c<='9';x=x*10+c-'0',c=getchar());
    return x*f;
}
inline void write(ll a){
    if(a==0){putchar('0');return;}
    if(a<0)putchar('-'),a=-a;
    char c1[120];
    ll h=0;
    while(a)c1[++h]=a%10+'0',a/=10;
    fd(i,h,1)putchar(c1[i]);
    return;
}
inline void write_(ll a){write(a);putchar(' ');}
inline void writeln(ll a){write(a);putchar('\n');}
//-----------------------------------------------------------------
const int N=1e5;
int n,a,b,ans;
int f[N];

int main(){
	n=read();a=read();b=read();
	writeln(min(n*a,b));
	return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
//#define DEBUG
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>

int main(void) {
#ifdef DEBUG
	printf("");
#endif

	int N, K;
	int i;
	int ans;
	scanf("%d", &N);
	scanf("%d", &K);
	ans = K;
	for (i = 1; i < N; i++) {
		ans *= K - 1;
	}
	

	printf("%d\n",ans);

	return 0;
}

Measured memory_bytes: 128
#include <iostream>
using namespace std;
int main(void){
    int n = 0;
    cin >> n;
    long A[1000];
    for(int i = 0; i < 1000; i++){
        A[i] = 0;
    }
    for(int i = 0; i < n; i++){
        cin >> A[i];
    }
    int q = 0;
    cin >> q;
    for(int i = 0; i < q; i++){
        int b = 0, e = 0;
        cin >> b >> e ;
        for(int j = 0; j < (e-b)/2; j++){
            int temp = A[b+j];
            A[b+j] = A[e-1-j];
            A[e-1-j] = temp;
        }
    }
    for(int i = 0; i < n-1; i++){
        cout << A[i] << " ";
    }
    cout << A[n-1] << endl;
    return 0;
}



Measured memory_bytes: 3112
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int main(){
    long long int A,B,C,D;

    cin >> A >> B >> C >> D;
    cout << max(A*B,C*D);
    }

Measured memory_bytes: 256
package main

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

func main() {
	list := getStdinIntArr()
	for idx, val := range list {
		if val == 0 {
			fmt.Printf("%d\n", idx+1)
		}
	}
}

var sc = bufio.NewReaderSize(os.Stdin, 1024*1024*1)

func getStdin() string {
	return readLine()
}
func getStdinIntArr() []int {
	str := getStdin()
	list := strings.Split(str, " ")
	rtn := make([]int, len(list))
	for idx, val := range list {
		rtn[idx], _ = strconv.Atoi(val)
	}
	return rtn
}
func readLine() string {
	buf := make([]byte, 0, 0)
	for {
		l, p, _ := sc.ReadLine()
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}


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

int main()
{
    long long int H;
    long long int W;
    cin >> H >> W;

    long long int ans;

    if (H == 1) {
        ans = 1;
    } else if (W == 1) {
        ans = 1;
    } else {
        if (H % 2 == 0) {
            if (W % 2 == 0) {
                ans = H * W / 2;
            } else {
                ans = H * W / 2;
            }
        } else {
            if (W % 2 == 0) {
                ans = H * W / 2;
            } else {
                ans = H * W / 2 + 1;
            }
        }
    }
    cout << ans;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define dd double
#define endl "\n"
#define pb push_back
#define all(v) v.begin(),v.end()
#define mp make_pair
#define fi first
#define se second
#define vll vector<ll>
#define pll pair<ll,ll>
#define fo(i,n) for(int i=0;i<n;i++)
#define fo1(i,n) for(int i=1;i<=n;i++)
ll mod=1000000007;
ll n,k,t,m,q,flag=0;
ll power(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// using namespace __gnu_pbds; 
// #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// ordered_set s ; s.order_of_key(a) -- no. of elements strictly less than a
// s.find_by_order(i) -- itertor to ith element (0 indexed)
ll min(ll a,ll b){if(a>b)return b;else return a;}
ll max(ll a,ll b){if(a>b)return a;else return b;}
ll gcd(ll a , ll b){ if(b > a) return gcd(b , a) ; if(b == 0) return a ; return gcd(b , a%b) ;}
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    #ifdef NOOBxCODER
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #else 
    #define NOOBxCODER 0
    #endif
    //cin>>t;
    t=1;
    while(t--){
        cin>>n>>k;
        ll a[n];
        fo(i,n)cin>>a[i];
        for(int i=k;i<n;i++){
            if(a[i]>a[i-k])cout<<"Yes"<<endl;
            else cout<<"No"<<endl;
        }





        
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
    return 0;
}


Measured memory_bytes: 5376
N = int(input())
S = list(input())
s = set(S)
count = 0
maxx = 0
for i in range(N): #切断場所
    for k in range(i):
        if S[k] in S[:i] and S[k] in S[i:] and S[k] not in S[:k]:
            count += 1
    maxx = max(maxx, count)
    count = 0
print(maxx)

Measured memory_bytes: 3064
def slove():
    import sys
    import bisect
    import collections
    import fractions
    import heapq
    input = sys.stdin.readline
    h, w = list(map(int, input().rstrip('\n').split()))
    a = [list(str(input().rstrip('\n'))) for _ in range(h)]
    hl = [True] * h
    wl = [True] * w
    for i in range(h):
        if a[i].count("#") == 0:
            hl[i] = False
    for i in range(w):
        b = False
        for j in range(h):
            if a[j][i] == "#":
                b = True
                break
        if not b:
            wl[i] = False
    for i in range(h):
        if hl[i]:
            l = []
            for j in range(w):
                if wl[j]:
                    l.append(a[i][j])
            print("".join(l))


if __name__ == '__main__':
    slove()


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

vector<int> F;

int fibonacci(int N)
{
	F.push_back(1);
	F.push_back(1);
	for (int i = 2; i <= N; i++)
	{
		F.push_back(F[i - 2] + F[i - 1]);
	}
	return F[N];
}

int main(void)
{
	int N, ans;
	cin >> N;

	ans = fibonacci(N);

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3144
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <cstdlib>
#include <algorithm>
using namespace std;


int main(int argc, char *argv[])
{
    long long int a, b, c, k;
    long long int r;

    scanf("%lld%lld%lld%lld", &a, &b, &c, &k);

    r = 0;
    if (k > 0) {
        const long long int d = min(a, k);
        r += d;
        k -= d;
    }
    if (k > 0) {
        const long long int d = min(b, k);
        k -= d;
    }
    if (k > 0) {
        r -= k;
    }
    printf("%lld\n", r);

    return EXIT_SUCCESS;
}


Measured memory_bytes: 1728
#!/usr/bin/env ruby
s = gets.chomp

s = s.reverse
counts = [0] * 2019
counts[0] = 1

sum_of_digits = 0
d = 1
s.chars.each do |s_i|
  sum_of_digits += s_i.to_i * d
  sum_of_digits %= 2019
  counts[sum_of_digits] += 1
  d *= 10
  d %= 2019
end

ans = 0

counts.each do |count|
  ans += count * (count - 1) / 2
end

puts ans


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

int main(){
    int N; cin >> N;
    vector <int> P(N),Q(N);
    rep(i,N) cin >> P[i];
    rep(i,N) cin >> Q[i];
    
    vector<int> a(N);
    rep(i,N) a[i]=i+1;
    
    map<vector<int>,int> mp;
    do{
        mp[a]=mp.size();
    }while(next_permutation(a.begin(),a.end()));
    
    int ans=abs(mp[P]-mp[Q]);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 5248
#include<iostream>
#define INF 2 << 23
using namespace std;
int main(){
  int n,m;
  while(cin >> n >> m){
    if(n==0&&m==0) break;
    int cost[m+1][m+1];
    int time[m+1][m+1];

    for(int i=0;i<=m;i++)
      for(int j=0;j<=m;j++){
        if(i==j)
          cost[i][j] = time[i][j] = 0;
        else
          cost[i][j] = time[i][j] = INF;
      }

    for(int i=0;i<n;i++){
      int a,b;
      cin >> a >> b;
      cin >> cost[a][b] >> time[a][b];
      cost[b][a] = cost[a][b]; time[b][a] = time[a][b];
    }

    for (int i = 1; i <= m; i++)      // ?????±????????????
      for (int j = 1; j <= m; j++)    // ????§???????
        for (int k = 1; k <= m; k++){  // ??????
          cost[j][k] = min(cost[j][k], cost[j][i] + cost[i][k]);
          time[j][k] = min(time[j][k], time[j][i] + time[i][k]);
        }

    int k;
    cin >> k;
    int p,q,r;
    for(int i=0;i<k;i++){
      cin >> p >> q >> r;
      switch(r){
      case 0: cout << cost[p][q] << endl; break;
      case 1: cout << time[p][q] << endl; break;
      default: break;
      }
    }
  }
}

Measured memory_bytes: 3172
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

N, K, Q = map(int, input().split())
L = [0]*N
for _ in range(Q):
    a = int(input())
    L[a-1] += 1
ans = 0
for l in L:
    if l+K-Q > 0:
        print("Yes")
    else:
        print("No")


Measured memory_bytes: 4680
import sys
stdin = sys.stdin

def li(): return [int(x) for x in stdin.readline().split()]
def li_(): return [int(x)-1 for x in stdin.readline().split()]
def lf(): return [float(x) for x in stdin.readline().split()]
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(ns())
def nf(): return float(ns())

x,y = li()

if abs(x-y)<=1:
    print("Brown")
else:
    print("Alice")

Measured memory_bytes: 3064
n = int(input())
l = []
sum = 0
for i in range(1, n+1):
  sum += i
  if i % 3 == 0 and i % 5 == 0:
    sum -= i
  elif i % 3 == 0:
    sum -= i
  elif i % 5 == 0:
    sum -= i
print(sum)

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

int main(){
	int n;
	cin >> n;
	vector<int> a(n);
	int ans = 0;
	rep(i,n) cin >> a[i];
	for(int i = 0;i < n-1;i++){
		for(int j = i+1;j < n;j++){
			ans = max(ans,abs(a[i]-a[j]));
		}
	}
	cout << ans << endl;
}

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


#define	ll_int	long long int


int Binary_Search(ll_int *box, int n, ll_int num)
{
	int mid;
	int left, right;


	left = 0;
	right = n - 1;
	while(left <= right){
		mid = (left + right) / 2;

		if(num == box[mid])
			return mid;
		else if(num < box[mid])
			right = mid - 1;
		else if(box[mid] < num)
			left = mid + 1;
	}

	return left;
}


int main()
{
	int n, q;
	ll_int *box, num;
	int pos;
	int i, j;


	scanf("%d", &n);

	box = (ll_int *)malloc(sizeof(ll_int) * n);

	for(i = 0; i < n; i++)
		scanf("%lld", &box[i]);


	scanf("%d", &q);

	for(i = 0; i < q; i++){
		scanf("%lld", &num);

		pos = Binary_Search(box, n, num);
		if(0 <= pos && pos < n){
			while(0 <= pos && num <= box[pos])
				pos--;
			printf("%d\n", pos + 1);
		}else
			printf("%d\n", n);
	}

	return 0;
}


Measured memory_bytes: 2644
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
#define fi first
#define se second
#define endl '\n'
#define y1 holyshit
#define all(x) x.begin(),x.end()
const int inf=0x3f3f3f3f;

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    int A,B,C,D; cin>>A>>B>>C>>D;
    while(1){
        C-=B;
        if(C<=0){
            cout<<"Yes";
            break;
        }
        A-=D;
        if(A<=0){
            cout<<"No";
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 3612
// 問題文
// N個の足場があります。 足場には 1,2,…,N と番号が振られています。 各 i(1≤i≤N) について、足場 i の高さは hi です。
// 最初、足場 1にカエルがいます。 カエルは次の行動を何回か繰り返し、足場 Nまで辿り着こうとしています。足場 iにいるとき、足場 
// i+1,i+2,…,i+K のどれかへジャンプする。 このとき、ジャンプ先の足場を jとすると、コスト |hi−hj|を支払う。
// カエルが足場 Nに辿り着くまでに支払うコストの総和の最小値を求めてください。
// 制約
// 入力はすべて整数である。
// 2≤N≤105の5乗
// 1≤K≤100
// 1≤hi≤10の４乗
// 入力
// 入力は以下の形式で標準入力から与えられる。
// N K
// h1
// h2 
// … 
// hN
// 出力
// カエルが支払うコストの総和の最小値を出力せよ。
// 入力例 1 
// 5 3
// 10 30 40 50 20
// 出力例 1 
// 30
// 足場 
// 1→ 2 → 5と移動すると、コストの総和は |10−30|+|30−20|=30となります。
// 入力例 2 
// 3 1
// 10 20 10
// 出力例 2 
// 20
// 足場 
// 1→ 2 → 3と移動すると、コストの総和は |10−20|+|20−10|=20 となります。
// 入力例 3 
// 2 100
// 10 10
// 出力例 3 
// 0
// 足場 1→ 2と移動すると、コストの総和は |10−10|=0となります。
// 入力例 4 
// 10 4
// 40 10 20 70 80 10 20 70 80 60
// 出力例 4 
// 40
// 足場 
// 1 → 4 → 8 → 10と移動すると、コストの総和は |40−70|+|70−70|+|70−60|=40となります。
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
using namespace std;
int main(void){
	int N,H[100100],K=0;
	long long dp[100100];
	long long inf=1e12;
	cin>>N>>K;
	for(int i=0;i<N;i++){
		cin>>H[i];
	}
	for(int i=0;i<N;i++){
		dp[i]=inf;
	}
	dp[0]=0;
	for(int i=0;i<N;i++){
		for(int j=1;j<=K;j++){
			dp[i+j]=min(dp[i+j],dp[i]+abs(H[i]-H[i+j]));
		}
	}
	cout<<dp[N-1]<<endl;
	return 0;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
const int N = 110;
int n;
int a[N];
int res = 0;
int calc(int x){
	int r = 0;
	for(int i  = 1;i<=n;i++) r += (a[i]-x)*(a[i]-x);
	return r;
}
int ans = 2147483647;
int main(){
	scanf("%d",&n);
	for(int i = 1;i<=n;i++){
		scanf("%d",&a[i]);
		res += a[i];
	}
	res /= n;
	for(int i = -100;i<=100;i++) ans = min(ans,calc(i));
	printf("%d",ans);
	return 0;
} 

Measured memory_bytes: 256
import sys
import re
import math
import collections
import decimal
import bisect
import itertools

# import copy
# import heapq
# from collections import deque
# import decimal

# sys.setrecursionlimit(100001)
INF = sys.maxsize
# MOD = 10 ** 9 + 7

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))


# ===CODE===


def main():
    n = ni()
    d = na()
    c = collections.Counter(d)

    total = 0
    for v in c.values():
        total += v * (v - 1) // 2

    for i in range(n):
        v = c[d[i]]

        print(int(total - v + 1))


if __name__ == '__main__':
    main()


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

using namespace std;

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

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    ll sum = 0;
    REP(i, N) {
        sum += i + 1;
        if (sum >= N) {
            vector<ll> v;
            for (ll j = i + 1; j > 0; --j) {
                if (j <= N) {
                    v.push_back(j);
                    N -= j;
                }
            }

            REP(j, v.size()) {
                cout << v[j] << endl;
            }
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 384
//2019.4.13 by ljz
#include<bits/stdc++.h>
using namespace std;
#define res register int
#define LL long long
#define inf 0x3f3f3f3f
#define eps 1e-15
#define RG register
inline int read(){
    res s=0,ch=getchar();
    bool w=0;
    while(ch<'0'||ch>'9'){if(ch=='-')w=1;ch=getchar();}
    while(ch>='0'&&ch<='9')s=s*10+ch-'0',ch=getchar();
    return w?-s:s;
}
inline LL Read(){
    RG LL s=0;
    res ch=getchar();
    bool w=0;
    while(ch<'0'||ch>'9'){if(ch=='-')w=1;ch=getchar();}
    while(ch>='0'&&ch<='9')s=s*10+ch-'0',ch=getchar();
    return w?-s:s;
}
inline void swap(res &x,res &y){
    x^=y^=x^=y;
}
const int N=1e5+10;
namespace MAIN{
    int n,k;
    char str[N];
    int pos[N],tot,sum;
    inline bool check(const res &lim){
        tot=0;
        for(res i=1;i<=lim-1;){
            if(str[i]=='1')i++;
            else {
                tot++;
                res j=i;
                while(str[j]=='0'&&j<=lim-1)j++;
                j--;
                i=j+1;
            }
        }
        res las=str[lim-1]-'0';
        for(res i=lim;i<=n;i++){
            if(str[i]=='0'){
                if(las==1)tot++;
            }
            if(str[i-lim]=='0'&&str[i-lim+1]=='1')tot--;
            if(tot<=k)return 1;
            las=str[i]-'0';
        }
        return 0;
    }
    inline void MAIN(){
        n=read(),k=read();
        scanf("%s",str+1);
        for(res i=1;i<=n;){
            if(str[i]=='0'){
                res j=i;
                while(str[j]=='0'&&j<=n)j++;
                j--;
                pos[++tot]=j-i+1;
                i=j+1;
            }
            else i++,sum++;
        }
        sort(pos+1,pos+tot+1);
        if(k>=tot)printf("%d\n",n);
        else {
            tot=0;
            res l=1,r=n,ret=0;
            while(l<=r){
                res mid=(l+r)>>1;
                if(check(mid))ret=mid,l=mid+1;
                else r=mid-1;
            }
            printf("%d\n",ret);
        }
    }
}
int main(){
    MAIN::MAIN();
    return 0;
}

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

int main() {
  int H, W;
  cin >> H >> W;
  
  string s;
    for (int i = 0; i < W + 2; i++) {
      s += '#';
    }
  
  vector<string> a(H);
    for (int i = 0; i < H; i++) {
      cin >> a.at(i);
    }
  
  cout << s << endl;
  for (int i = 0; i < H; i++) {
    cout << '#' + a.at(i) + '#' << endl;
  }
  cout << s << endl;
  
}


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

int main(){
    int n,m,memo = 0,memo2 = 0;
    vector< pair<int,int> > time(210);
    bool flag = false,p_flag = false;
    cin >> n;

    rep(i,0,n){
        cin >> memo >> memo2;
        time[i].first = memo;
        time[i].second = memo2;
    }
    
    cin >> m;

    rep(i,0,m){
        cin >> memo >> memo2;
        time[n+i].first = memo;
        time[n+i].second = memo2;
    }
    
    rep(i,0,24){
        rep(j,0,60){
            flag = false;
            rep(k,0,n+m){
                if(i == time[k].first && j == time[k].second){
                    flag = true;
                    break;
                }
            }
            
            if(flag){
                if(j < 10){
                    cout << ((p_flag) ? " ":"") << i << ":0" << j;
                }
                else{
                    cout << ((p_flag) ? " ":"") << i << ":" << j;
                }
                p_flag = true;
            }
        }
    }
    
    cout << endl;
    
    
    return 0;
}


Measured memory_bytes: 3140
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		double p[] = new double[n + 1];
		double q[] = new double[n + 1];
		for ( int i = 1; i <= n; i++ ) {
			p[i] = in.nextDouble();
			q[i] = 1 - p[i];
		}
		in.close();

		//		for(int i = 0; i<= n; i++) {
		//			System.out.println(p[i] + "  " + q[i]);
		//		}

		int row = n / 2 + 1;
		double dp[][] = new double[row + 1][n + 2];
		dp[1][1] = 1;
		for ( int r = 1; r <= row; r++ ) {
			for ( int c = 1; c <= n + 1; c++ ) {
				int idx = r + c - 2;
				dp[r][c] += dp[r][c - 1] * p[idx];
				dp[r][c] += dp[r - 1][c] * q[idx];
				if ( idx >= n ) break;
			}
		}

//		for ( double[] ds : dp ) {
//			for ( double d : ds ) {
//				System.out.printf("%1.3f   ", d);
//			}
//			System.out.println();
//		}

		double ans = 0.0;
		for ( int r = 1, c = n + 1; r <= row; r++, c-- ) {
			ans += dp[r][c];
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 69908
#include <stdio.h>
int a[200000];
int b[200000];
    
int main(void){
    int n,i,j,itest;
    scanf("%d",&n);
    //printf("n=%d\n",n);
    for(i=0;i<n;i++){
        scanf("%d",&a[i]);
    };
    for(j=0;j<n;j++){
            itest=n-2*j-1;
            if(itest<0) i=2*j-n; else i=itest;
            b[j]=a[i];
            //printf("b[%d]=a[%d]=%d\n",j,i,a[i]);
    };
    printf("%d",b[0]);
    for(j=1;j<n;j++){
        printf(" %d",b[j]);
    };
    return 0;
};

Measured memory_bytes: 3712
n = gets.to_i
h = gets.split.map(&:to_i)
h << h.last + 1

count = 0
ans = 0
n.times do |i| 
    if h[i] >= h[i+1] then
        count += 1
    else
        ans = count if ans < count
        count = 0
    end
end

puts ans

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

#define ran 3033

int n, T;
pair<int, int> a[ran];
int v[ran];

void upd(int &a, int b) {
	if(a<b) a = b;
}

int main() {
	scanf("%d%d", &n, &T);
	for(int i=0;i<n;i++)
		scanf("%d%d", &a[i].first, &a[i].second);
	sort(a, a+n);
	
	memset(v, -1, sizeof v);
	v[0] = 0;
	int ans = 0;
	for(int i=0;i<n;i++) {
		int cost = a[i].first, val = a[i].second;
		for(int i=T-1;i>=0;i--) {
			if(v[i]<0) continue;
			if(i+cost<T) upd(v[i+cost], v[i]+val);
			upd(ans, v[i]+val);
		}
	}
	printf("%d\n", ans);
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <queue>
#include <math.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll mod = 998244353;
const ll INF = 1000000000000000;
ll N;

double x[10], y[10], sum;

ll pow(ll x, ll y)
{
	if (y == 0) return 1;
	if (y % 2)
	{
		return pow(x, y - 1) * x % mod;
	}
	else
	{
		ll yyy = pow(x, y / 2);
		return yyy * yyy % mod;
	}
}

ll pow_ll(ll x, ll y)
{
	if (y == 0) return 1;
	return x * pow_ll(x, y - 1);
}

ll div(ll x)
{
	return pow(x, mod - 2);
}



int main(void)
{
	cin >> N;

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

	for (int i = 0; i < N; i++)
	{
		for (int j = i + 1; j < N; j++)
		{
			sum += sqrt((x[i] - x[j]) * (x[i] - x[j]) + (y[i] - y[j]) * (y[i] - y[j]));
		}
	}

	sum *= N - 1;
	sum /= N * (N - 1) / 2;

	printf("%f\n", sum);

	int xxx;
	cin >> xxx;
}


Measured memory_bytes: 256
// C - Takahashi's Information
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
#define rp(i,s,e) for(int i=(s);i<(e);++i)
#define rpz(i,e) rp(i,0,e)

int main(){
	vi C(9); rpz(i,9) cin>>C[i];
	puts(C[0]+C[4]+C[8]==C[1]+C[5]+C[6] && C[0]+C[4]+C[8]==C[2]+C[3]+C[7]? "Yes":"No");
}

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
//const ull mod = 1e9 + 7;
const ll mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

// debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

// conversion number to bit
string num2bit(ll num, ll len){
  string bit = "";
  REP(i, len){
    bit += char('0'+(num>>i & 1));
  }
  return bit;
}

struct UnionFindSize {
    vector<int> par;
    
    UnionFindSize(int n) : par(n, -1) { }
    void init(int n) { par.assign(n, -1); }
    
    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }
    
    bool issame(int x, int y) {
        return root(x) == root(y);
    }
    
    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }
    
    int size(int x) {
        return -par[root(x)];
    }
};

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

    ll N, M, K;
    cin >> N >> M >> K;
    UnionFindSize uf(N);
    vector<ll> d(N);
    REP(i, M){
    	ll a, b;
    	cin >> a >> b;
    	a--, b--;
    	uf.merge(a, b);
    	d[a]++;
    	d[b]++;
    }

    vector<vector<ll>> G(N);

    REP(p, K){
    	ll a, b;
    	cin >> a >> b;
    	a--, b--;
    	G[a].push_back(b);
    	G[b].push_back(a);
    }

    //cerr << d << endl;

    REP(i, N){
    	ll sz = uf.size(uf.root(i));
    	//dump(sz)
    	sz--;
    	sz -= d[i];
    	for(auto x: G[i]){
    		if(uf.issame(i, x)) sz--;
    	}
    	cout << sz << " ";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 7936
/*
 author : arush gupta
 date :26.01.2020
 */
 #include<bits/stdc++.h>
 using namespace std;
 typedef long long ll;
 int main() {
 ios::sync_with_stdio(false);
 cin.tie(0);
 cout.tie(0);
ll n,k,x;
vector<ll> v;
cin >> n >> k;
for(ll i=0;i<n;i++){
	cin>> x;
	v.push_back(x);
}
if(k>= n){
	cout<<0;
	return 0;
}
sort(v.begin(),v.end());
for(ll i=0;i<k;i++){
	v.pop_back();
}
ll sum =0 ;
for(ll i=0;i<v.size();i++){
	sum+= v[i];
}
cout << sum << endl;
 return 0;
 }


Measured memory_bytes: 2420
// 2020-07-28 04:10:07
#include<bits/stdc++.h>
#ifdef LOCAL
#include "lib/debug.hpp"
#else
#define debug(...) 1
#endif
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) REP(i, 0, (n))
#define repc(i, n) REPC(i, 0, (n))
#define REP(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define REPC(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define REPCM(i, n, m) for (int i = (int)(n); i >= (int)(m); i--)
using namespace std;
using ll = long long;
using ld = long double;
using pr = pair<ll, ll>;
using vll = vector<ll>;
using vpr = vector<pr>;
using P = pair<int, int>;
template<class T> inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } else return false; }
template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; }

const int k = 43;
ll dp[k][2];
void answer() {
  int n;
  cin >> n;
  vector<ll> v(n);
  rep(i, n) cin >> v[i];
  ll a = v[0], b = v[1];
  ll s = a + b;
  ll x = a ^ b;
  rep(i, n) x ^= v[i];
  ll y = (s - x) / 2;
  if(y < 0 || x & y || s != x + 2 * y) {
    cout << -1 << '\n';
    return;
  }
  memset(dp, -1, sizeof dp);
  dp[k-1][0] = 0;
  REPCM(ki, k-2, 0) rep(smaller, 2) {
    if(dp[ki+1][smaller] == -1) continue;
    int ca = (a>>ki)&1;
    int cx = (x>>ki)&1;
    int cy = (y>>ki)&1;
    rep(na, 2) rep(nb, 2) {
      if((na ^ nb) != cx) continue;
      if((na & nb) != cy) continue;
      if(!smaller && ca < na) continue;
      chmax(dp[ki][smaller || na < ca], dp[ki+1][smaller] | (ll(na) << ki));
    }
  }
  ll res = max(dp[0][0], dp[0][1]);
  if(res == -1 || res == 0) {
    cout << -1 << '\n';
    return;
  }
  cout << a - res << '\n';
}
int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  answer();
  return 0;
}

Measured memory_bytes: 3648
#include<stdio.h>
#include<string.h>
char s[100010],*p;
int main(){
	int L,r,i,w,n,m;
	scanf("%d",&L);
	for(r=0;1<<r<=L;r++);
	r--;
	n=r+1;
	m=0;
	p=s;
	for(i=1;i<=r;i++){
		sprintf(p,"%d %d %d\n",i,i+1,1<<(i-1));
		p+=strlen(p);
		sprintf(p,"%d %d %d\n",i,i+1,0);
		p+=strlen(p);
		m+=2;
	}
	w=1<<r;
	for(i=r;i>0;i--){
		if(L>>(i-1)&1){
			sprintf(p,"%d %d %d\n",i,r+1,w);
			p+=strlen(p);
			m++;
			w|=1<<(i-1);
		}
	}
	printf("%d %d\n%s",n,m,s);
}

Measured memory_bytes: 128
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int n = scanner.nextInt();
			int[] a = new int[n];
			IntStream.range(0, n).forEach(i -> a[i] = scanner.nextInt());
			// sum[i]=a[0]+...+a[i]
			long[] sum = new long[n];
			sum[0] = a[0];
			IntStream.range(1, n).forEach(i -> sum[i] = sum[i - 1] + a[i]);
			System.out.println(
					IntStream.range(0, n - 1).mapToLong(i -> Math.abs(sum[n - 1] - 2 * sum[i])).min().getAsLong());
		}
	}
}


Measured memory_bytes: 65452
#include <bits/stdc++.h>
using namespace std;
 
int main() 
{
  int n , p, even = 0 , odd = 0 ;
  cin>>n>>p;
  int arr[n];
  for (int i = 0; i < n; i++) 
  {
    cin>>arr[i];
    if ( arr[i] % 2 == 0 )
    {
      even++;
    }
    else 
    {
      odd++;
    }
  }
  long long int ans = pow(2,n);
  if (odd == 0)
  {
    if ( p % 2 == 0 )
    {
        cout<<ans<<endl;
    }
    else 
    {
        cout<<0<<endl;
    }
  }
  else
  {
    cout<<ans/2<<endl;
  }
  return 0;
}

Measured memory_bytes: 512
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class Main{

	public static void main(String args[]){
		new Main().mainrun();
	}

	private Scanner scan;
	private int n;
	private int[] A;



	public void mainrun() {
		scan = new Scanner(System.in);

		n = scan.nextInt();
		A = new int[n];
		for(int i = 0;i < n ; i++) {
			A[i] = scan.nextInt();
		}

		shellSort();

		System.out.println(m);
		G.forEach(System.out::print);

		System.out.println(cnt);
		Arrays.stream(A).forEach(System.out::println);
	}

	private void insertionSort(int g) {
		int v,j;
		for(int i = g;i < n;i++) {
			v = A[i];
			j = i - g;
			while(j >= 0 && A[j] > v) {
				A[j + g] = A[j];
				j = j - g;
				cnt++;
			}
			A[j + g] = v;
		}
	}

	int cnt,m;
	List<String> G ;

	private void shellSort() {
		cnt = 0;
		G = new ArrayList<>();

		int add = 0;
		int num = 0;
		
		while(true){
			add += Math.pow(3, num);
			if(add > n) {
				break;
			}
			G.add(Integer.toString(add) + " ");
			m++;
			num++;
	    }

		G.sort((e1 , e2) -> Integer.parseInt(e2.trim()) - Integer.parseInt(e1.trim()));
		G.set(m - 1, G.get(m - 1).trim() + "\n");

		for(String s : G) {
			insertionSort(Integer.parseInt(s.trim()));
		}
	}

}


Measured memory_bytes: 307836
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF (1ll << 60)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
using ll = long long;
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;
}

void print(const std::vector<int> &v) {
    std::for_each(v.begin(), v.end(), [](int x) { std::cout << x << " "; });
    std::cout << std::endl;
}

int N;
int M;
vector<string> A;
vector<string> B;
bool check(int i, int j) {
    for(int k = i; k < M + i; k++) {
        for(int l = j; l < M + j; l++) {
            if(A[k][l] != B[k - i][l - j]) {
                return false;
            }
        }
    }
    return true;
}
int main() {
    cin >> N >> M;
    A.resize(N);
    REP(i, N) { cin >> A[i]; }
    B.resize(M);
    REP(i, M) { cin >> B[i]; }
    for(int i = 0; i <= N - M; i++) {
        for(int j = 0; j <= N - M; j++) {
            if(check(i, j)) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
import sys
import math
import heapq
import bisect

sys.setrecursionlimit(10**7)
INTMAX = 9223372036854775807
INTMIN = -9223372036854775808
DVSR = 1000000007
def POW(x, y): return pow(x, y, DVSR)
def INV(x, m=DVSR): return pow(x, m - 2, m)
def DIV(x, y, m=DVSR): return (x * INV(y, m)) % m
def LI(): return [int(x) for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LS(): return input().split()
def II(): return int(input())
def FLIST(n):
    res = [1]
    for i in range(1, n+1): res.append(res[i-1]*i%DVSR)
    return res
def gcd(x, y):
    if x < y: x, y = y, x
    div = x % y
    while div != 0:
        x, y = y, div
        div = x % y
    return y

N,M=LI()
As=LI()
As.sort()
len_As = len(As)
Acum=[As[0]]
for i in range(1, len_As):
    Acum.append(Acum[i-1]+As[i])
# print(As)
# print(Acum)

ok = 0
ng = 2*max(As)+1

pat = 0
sm = 0
while ng - ok > 1:
    mid_sum = (ok + ng)//2
    pat = 0
    sm = 0
    for A in As:
        A2 = mid_sum - A
        # print(A2)
        lft = bisect.bisect_left(As, A2)
        pat += len_As - lft
        sm += Acum[len_As-1] - (lft and Acum[lft-1]) + (len_As - lft)*A
    # print(pat, M, ok, ng)

    if pat < M: ng = mid_sum
    else: ok = mid_sum

pat = 0
sm = 0
for A in As:
    A2 = ok - A
    # print(A2)
    lft = bisect.bisect_left(As, A2)
    pat += len_As - lft
    sm += Acum[len_As-1] - (lft and Acum[lft-1]) + (len_As - lft)*A

# print("lo:{} hi:{} pat:{} sum:{}".format(ok, ng, pat, sm))

print(sm - (pat-M)*ok)


Measured memory_bytes: 57356
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();

		double sum = 0;
		for (int i = 1; i <= N; i++) {
			double x = 1;
			while (i * x < K) {
				x *= 2;
			}
			sum += (1 / x);
		}
		System.out.println(sum / N);
	}
}


Measured memory_bytes: 20948
#include<bits/stdc++.h>
#include<cstdio>
#include<iostream>
#include<map>
#include<string>
#include<queue>
#include<map>
#include<vector>
#include<set>
#include<cstring>
using namespace std;
typedef long long ll;
int main()
{
	ll a,b,c;
	cin>>a>>b>>c;
	cout<<c<<" "<<a<<" "<<b; 
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
	void main() {
		try(Scanner sc=new Scanner(System.in)) {
			int a=sc.nextInt();
			int b=sc.nextInt();
				System.out.println((a*b)+" "+((a+b)*2));
			}
		}
	public static void main(String[] args) {
		new Main().main();
	}

}


Measured memory_bytes: 26128
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
class Simple{
    private string s;
    void Solve(){
        //input
        s = io.String;
        //cal
        var indexed = s.Select((c, i) => new{Value = c, Index = i}).ToArray();
        var a = indexed.First(v => v.Value == 'A').Index;
        var z = indexed.Last(v => v.Value == 'Z').Index;
        var len = z - a + 1;
        //ret
        Console.WriteLine(len);
    }
    SimpleIO io = new SimpleIO();
    public static void Main(string[] args) { new Simple().Stream(); }
    void Stream(){
        Solve();
        io.writeFlush();
    }
}
class SimpleIO{
    string[] nextBuffer;
    int BufferCnt;
    char[] cs = new char[]{' '};
    StreamWriter sw = new StreamWriter(Console.OpenStandardOutput()){AutoFlush = false};
    public SimpleIO(){
        nextBuffer = new string[0];
        BufferCnt = 0;
        Console.SetOut(sw);
    }
    public string Next(){
        if(BufferCnt < nextBuffer.Length) return nextBuffer[BufferCnt++];
        string st = Console.ReadLine();
        while(st == "") st = Console.ReadLine();
        nextBuffer = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        BufferCnt = 0;
        return nextBuffer[BufferCnt++];
    }
    public string String => Next();
    public char Char => char.Parse(String);
    public int Int => int.Parse(String);
    public long Long => long.Parse(String);
    public double Double => double.Parse(String);
    public void writeFlush() { Console.Out.Flush(); }
}


Measured memory_bytes: 30684
/*
[dp] D - Knapsack 1
*/

#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;

const int MAX_N = 100;
const int MAX_W = 1e5;

int N, W;
int w[MAX_N + 1], v[MAX_N + 1];
ll dp[MAX_N + 1][MAX_W + 1];

ll solve() {
    for (int i = 1; i <= N; i++) {
        for (int j = 0; j <= W; j++) {
            dp[i][j] = (j - w[i] >= 0)
                           ? max(dp[i - 1][j], dp[i - 1][j - w[i]] + v[i])
                           : dp[i - 1][j];
        }
    }

    return dp[N][W];
}

int main() {
    cin >> N >> W;
    for (int i = 1; i <= N; i++) {
        cin >> w[i] >> v[i];
    }

    cout << solve() << endl;

    return 0;
}


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



int main() {
  int N;
  cin>>N;
  vector<string> vec(N);
  for(int i=0;i<N;i++){
    cin>>vec.at(i);
  }
  bool can=true;
  for(int i=0;i<N;i++){
    for(int j=i+1;j<N;j++){
      if(vec.at(i)==vec.at(j)){
        can=false;
        break;
      }
    }
    if(can) continue;
    else break;
  }
  
  for(int i=0;i<N-1;i++){
    if(vec.at(i).back()!=vec.at(i+1).front()){
      can=false;
      break;
    }
  
  }
  if(can) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
   
 
}

Measured memory_bytes: 3644
a,b,n=map(int,input().split())
i=b-1
ans=(min(n,b-1)*a)//b;
while(i<=n):
    if((i*a)//b-a*(i//b)<=ans):
        break;
    ans=max(ans,(i*a)//b-a*(i//b));
    print(ans+"\n")
    i+=b;
print(ans);


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

// M A F I A - M A F I A - M A F I A - M A F I A - M A F I A - M A F I A //

#define int                                       long long
#define lop(i,s,e)                                for(int i=s;i<(int)e;i++)
#define rlop(i,e,s)                               for(int i=e;i>=s;i--)
#define prvec(v)                                  lop(R15,0,v.size())cout << v[R15] <<" "; cout << endl;
#define prarr(arr,s1,e1)                          lop(R15,s1,e1)cout << arr[R15] << " "; cout << endl;

#define endl                                      '\n'
#define ff                                        first
#define ss                                        second
#define pii                                       pair<int,int>

#define pb                                        push_back
#define all(v)                                    v.begin(),v.end()

// M A F I A - M A F I A - M A F I A - M A F I A - M A F I A - M A F I A //

const int N = 3e6 + 7, M = 1000000007, inf = INT_MAX;
const long long INF = LLONG_MAX;

int n, Q;
int arr[N + 2];


void solve()
{
	string s, t; cin >> s >> t;
	int n = s.size();
	int ans = 0;
	lop(i, 0, n)if ( s[i] != t[i] ) ans++;
	cout << ans << endl;

}

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

	int test = 1;
	// cin >> test;
	while (test--)solve();


}





Measured memory_bytes: 3884
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
 


public class Main {
	private static Scanner sc = new Scanner(System.in);
	//result = Math.pow(num1, num3)
	//StringBuffer str = new StringBuffer(hoge1);
	//String hoge2 = str.reverse().toString();
	//map.containsKey(A)

	//Map<String, Integer> map = new HashMap<String, Integer>(n);
	/*for ( キーのデータ型 key : マップの名前.keySet() ) {
		データのデータ型 data = マップの名前.get( key );
		
		// keyやdataを使った処理;
	}*/
	//int i = Integer.parseInt(s);
	//Queue<String> qq=new ArrayDeque<>(); //add,poll,peek
	//Deque<String> qq=new ArrayDeque<>();//push,pop,peek
	//ArrayList<String> cc = new ArrayList<>(n);
	//Collections.sort(list);
	//Array.sort(list);   cc.contains(tmp)
	//Arrays.asList(c).contains("a")
	//list.set(1,"walk");//1 1 2 3 5
	static long mod =1000000007;
	//static 	ArrayList<Integer> cc = new ArrayList<>(100);
	public static void main(String[] args) {
		int N=sc.nextInt();
		
		int t[]=new int[N+1];
		int x[]=new int[N+1];
		int y[]=new int[N+1];
		
		boolean f=true;
		
		for(int i=1;i<=N;i++) {
			t[i]=sc.nextInt();
			x[i]=sc.nextInt();
			y[i]=sc.nextInt();
			
			int a=t[i]-t[i-1];
			int b=x[i]+y[i]-x[i-1]-y[i-1];
			
			int ama=a-b;
			
			if(a<b||ama%2!=0) {
				f=false;
				break;
			}
			
			
		}
		if(f)p("Yes");
		else p("No");
		
		
		
		
		
		
		
		
	}
	
	
	
	
	/*static boolean v(int i,long sum1,long sum2) {
		if(i==N) {
			long b=Math.abs(sum1-sum2);
			if(b==0) {
				if(sum1<=K) {
					return true;
				}else return false;
			}else if(b%D==0) {
				if(Math.max(sum1, sum2)<=K)return true;
				else return false;
			}
			else return false;
		}
		
		if(v(i+1,sum1,sum2+v[i]%D))return true;
		
		if(v(i+1,sum1+D-v[i]%D,sum2))return true;
		return false;
		
	}*/
	
	
	
	
	

	


	
	static void p(String ans) {System.out.println(ans);};
	static void p(int ans) {System.out.println(ans);};
	static void p() {System.out.println();};
	static void p(long ans) {System.out.println(ans);};
	static void p(double ans) {System.out.println(ans);};
	public static int gcd(int a, int b) {
        return b == 0 ? a: gcd(b, a % b);
	}
	static String nextPermutation(String s) {
		ArrayList<Character> list=new ArrayList<>();
		for(int i=0;i<s.length();i++) {
			list.add(s.charAt(i));
		}
		int pivotPos=-1;
		char pivot=0;
		for(int i=list.size()-2;i>=0;i--) {
			if(list.get(i)<list.get(i+1)) {
				pivotPos=i;
				pivot=list.get(i);
				break;
			}
		}
		if(pivotPos==-1&&pivot==0) {
			return "Final";
		}
		int L=pivotPos+1,R=list.size()-1;
		
		
		
		int minPos=-1;
		char min =Character.MAX_VALUE;
		
		for(int i=R;i>=L;i--) {
			if(pivot<list.get(i)) {
				if(list.get(i)<min) {
					min=list.get(i);
					minPos=i;
				}
			}
		}
		
		Collections.swap(list, pivotPos, minPos);
		Collections.sort(list.subList(L, R+1));
		
		
		StringBuilder sb=new StringBuilder();
		for(int i=0;i<list.size();i++) {
			sb.append(list.get(i));
		}
		return sb.toString();
	}
}
	


Measured memory_bytes: 88392
import java.util.Scanner;

public class Main {
	static int[] m;
	static int min;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int x = sc.nextInt();
		m = new int[n];

		min = 0;
		int count = 0;

		for (int i = 0; i < n; i++) {
			m[i] = sc.nextInt();
			if (x - m[i] > 0) {
				x -= m[i];
				count++;
			}
		}
		sc.close();
		getMin();
		while (x >= min) {
			x -= min;
			count++;
		}
		System.out.println(count);
	}

	public static void getMin() {
		
		min = m[0];
		for(int i = 1; i < m.length; i++) {
			if(m[i] < min) {
				min = m[i];
			}
		}
	}
}


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

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip> 
//setbase - cout << setbase (16); cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 << endl; prints xxx77
//setprecision - cout << setprecision (4) << f << endl; Prints x.xxxx


using namespace std;
#define f(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define ss second
#define ff first
#define ll long long
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000*1000*1000+7)
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >

//std::ios::sync_with_stdio(false);   

int main(){
	std::ios::sync_with_stdio(false);
	int n;
	cin>>n;
	int i,val,counti=0;
	rep(i,n){
		cin>>val;
		if(val%2==1)
			counti++;
	}
	if(counti%2){
		cout<<"NO";
	}
	else{
		cout<<"YES";
	}

}


Measured memory_bytes: 764