akhauriyash/Code-Regression huggingface dataset:
import sys
import math

stdin = sys.stdin


def ni(): return int(ns())


def na(): return list(map(int, stdin.readline().split()))


def naa(N): return [na() for _ in range(N)]


def ns(): return stdin.readline().rstrip()  # ignore trailing spaces


N = ni()
a_array = naa(N)

mod = 10 ** 9 + 7
ans = [-1] * (2 ** N)


def solve(n, c):
    # print(n,c)
    # print(ans)
    if ans[n] != -1:
        return ans[n]
    ans[n] = 0
    if c == N - 1:
        ans[n] = a_array[c][int(math.log2(n))]
        return ans[n]
    for i in range(N):
        if a_array[c][i] == 0 or n & (1 << i) == 0:
            continue
        ans[n] = (ans[n] + solve(n - (1 << i), c+1)) % mod
    return ans[n]


print(solve(2**N-1, 0))


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

#define MOD 1000000007LL

using namespace std;

const int N = 60;

typedef long long ll;

char s1[N], s2[N];;
int n;
int other(int a, int b){
    if(a != 1 && b != 1) return 1;
    if(a != 2 && b != 2) return 1;
    if(a != 3 && b != 3) return 1;
}

ll dp[100][5][5];
ll f(int i, int a, int b){
    if(i == n) return 1;

    ll &ans = dp[i][a][b];

    if(~ans) return ans;
    ans = 0;

    if(s1[i] == s2[i]){ // vertical
        for(int c = 1; c < 4; c++) if(c != a && c != b){
            ans = (ans + f(i+1, c, c)) % MOD;
        }
    }
    else{
        for(int c = 1; c < 4; c++) if(c != a){
            for(int c2 = 1; c2 < 4; c2++) if(c2 != c && c2 != b){
                ans = (ans + f(i+2, c, c2)) % MOD;
            }
        }
    }
    return ans;
}

int main(){


    scanf("%d %s %s", &n, s1, s2);

    memset(dp, -1, sizeof dp);
    printf("%lld\n", f(0, 0, 0));


    return 0;
}


Measured memory_bytes: 256
import math
def equation(A):
  n=len(A)
  for i in range(n):
    j=i
    while A[j][i]==0:j+=1
    A[i],A[j]= A[j],A[i]
    A[i]=[e/A[i][i] for e in A[i]]
    for j in range(n):
      if j==i: continue
      tmp=A[j][i]
      for k in range(n+1):A[j][k]-=tmp*A[i][k]
  return
n=input()
for i in range(n):
  A=[]
  seq=map(float,raw_input().split())
  for j in range(0,6,2):
    x,y=seq[j:j+2]
    A+=[[x,y,1,-(x**2+y**2)]]
  equation(A)
  x0=-A[0][3]/2
  y0=-A[1][3]/2
  r=((x-x0)**2+(y-y0)**2)**.5
  print "%.3f %.3f %.3f" %(x0,y0,r)

Measured memory_bytes: 4500
//ehhhhh...... i hate you......

/* optimizations and other useless stuff*/
#pragma warning(disable:4996)
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize ("-ffloat-store")
#include<bits/stdc++.h>
#define FastIO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define MOD 1000000007
#define INF 1e14
#define ull unsigned long long int
using namespace std;
/* TYPE DEFINITIONS */
typedef     long long int   ll;
typedef     vector<ll>      vi;
typedef     pair<ll,ll>     pi;


/* Basic  Math!!! */
bool isPrime(ull n) 
{ 
    if (n <= 1)  return false; 
    if (n <= 3)  return true; 
    if (n%2 == 0 || n%3 == 0) return false; 
  
    for (ull i=5; i*i<=n; i=i+6) 
        if (n%i == 0 || n%(i+2) == 0) 
           return false; 
  
    return true; 
} 
ll ncr(int n, int k)  
{  
    ll res = 1;  
    if ( k > n - k )  
        k = n - k;  
    for (int i = 0; i < k; ++i)  
    {  
        res *= (n - i);  
        res /= (i + 1);  
    }  
  
    return res;  
} 

/* MACROS */
#define  all(A)         (A).begin() , (A).end()
#define  rall(A)        (A).rbegin() , (A).rend()
#define  sz(A)          (int)(A).size()
#define  pb             push_back
#define  ppb            pop_back
#define  mp             make_pair
#define  ln(X)          (int)(X).length()
#define  square(X)      ((X)*(X))
#define  cube(X)        ((X)*(X)*(X))
#define  forn(i, n)  for (int i = 0; i < int(n); i++)
#define  forr(i, n)  for (int i = int(n - 1); i >= 0; i--)
#define  fora(i, a, b)  for (int i = int(a); i <= int(b); i++)
#define  forb(i, a, b)  for (int i = int(a); i >= int(b); i--)
#define  fore(it, a)    for(__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)  
void solve()
{
    string s1,s2;
    cin>>s1>>s2;
    int c=0;
    forn(i,ln(s1))if(s1[i]==s2[i])c++;
    cout<<c<<endl;
}

int main()
{
    FastIO;
    ll c=0;
    ll t=1;
    //cin>>t;
    while(t--)
    {
        //cout<<"Case "<<++c<<": ";
        solve();
    }
    return 0;
}

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

int main() {
    ll n, p;   cin >> n >> p;
    int odd=0, even=0;
    for(int i=0; i<n; i++){
        int x;  cin >> x;
        if(x%2==0) even+=1;
        else odd += 1;
    }
    ll ans=0;
    if(p){
        if(odd>=1) ans = pow(2.0, n-1);
        else ans = 0;
    }else{
        if(odd>=1) ans = pow(2.0, n-1);
        else ans = pow(2.0, n);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <cstdio>

bool grid[25][25];

int N,M;

int main(){

    while(scanf("%d",&N)&&N){
        for(int i=0;i<N;i++) {
            int x,y;
            scanf("%d%d",&x,&y);
            grid[x][y]=true;
        }

        scanf("%d\n",&M);
        int count=0,curx=10,cury=10;
        
        for(int k=0;k<M;k++){
            char D;
            int i;
            scanf("%c",&D);
            // printf("D=%c\n",D);
            scanf("%d",&i);
            getchar();
            // printf("i=%d\n",i);
            switch (D)
            {
            case 'N':
                for(int s=0;s<i;s++,cury++)
                    if (grid[curx][cury]) count++,grid[curx][cury]=false;
                break;
            case 'S':
                for(int s=0;s<i;s++,cury--)
                    if (grid[curx][cury]) count++,grid[curx][cury]=false;
                break;
            case 'E':
                for(int s=0;s<i;s++,curx++)
                    if (grid[curx][cury]) count++,grid[curx][cury]=false;
                break;
            case 'W':
                for(int s=0;s<i;s++,curx--)
                    if (grid[curx][cury]) count++,grid[curx][cury]=false;
                break;
            default:
                puts("err");
                return -1;
            }
            if (grid[curx][cury]) count++,grid[curx][cury]=false;
        }

        // printf("count=%d\n",count);
        if (count==N) puts("Yes");
        else puts("No");

        for(int i=0;i<=20;i++)
            for(int j=0;j<=20;j++)
                grid[i][j]=false;
    }

    return 0;   
}


Measured memory_bytes: 2564
#include <bits/stdc++.h>
#define ll long long

using namespace std;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n,temp;
	cin >> n;
	for(int i=0;i<n;++i) {
		cin >> temp;
		if(temp%2==0) {
			if(temp%3==0 || temp%5==0) {}
			else {
				cout << "DENIED";
				return 0;
			}
		}
	}
	cout << "APPROVED";

	return 0;
}



Measured memory_bytes: 3608
//
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
//
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

// solution 
use std::collections::{BinaryHeap, HashSet};
#[allow(unused_mut)]
#[allow(non_snake_case)]
fn main() {
    input!{
        X: usize,
        Y: usize,
        Z: usize,
        K: usize,
        A: [usize; X],
        B: [usize; Y],
        C: [usize; Z],
    }

    A.sort();
    B.sort();
    C.sort();
    let mut pool = PriorityQueue::new(6000);
    let mut pick = Point(A[X-1]+B[Y-1]+C[Z-1], X-1, Y-1, Z-1);
    println!("{}", pick.0);
    K = K - 1;
    while K > 0 {
        if pick.1 > 0 {
            let p = Point(A[pick.1-1]+B[pick.2]+C[pick.3], pick.1-1, pick.2, pick.3); 
            pool.push(p);
        }
        if pick.2 > 0 {
            let p = Point(A[pick.1]+B[pick.2-1]+C[pick.3], pick.1, pick.2-1, pick.3);
            pool.push(p);
        }
        if pick.3 > 0 {
            let p = Point(A[pick.1]+B[pick.2]+C[pick.3-1], pick.1, pick.2, pick.3-1);
            pool.push(p);
        }
        pick = pool.pop();
        println!("{}", pick.0);
        K -= 1;
    }
}

#[derive(Copy, Clone, Debug, PartialEq, PartialOrd, Eq, Ord, Hash)]
struct Point(usize, usize, usize, usize);
struct PriorityQueue {
    selected: HashSet<Point>,
    candidates: BinaryHeap<Point>,
}
impl PriorityQueue {
    fn new(size: usize) -> PriorityQueue {
        PriorityQueue {
            selected: HashSet::with_capacity(size),
            candidates: BinaryHeap::with_capacity(size),
        }
    }

    fn push(&mut self, p: Point) {
        if self.selected.insert(p) {
            self.candidates.push(p);
        }
    }

    fn pop(&mut self) -> Point {
        self.candidates.pop().unwrap()
    }
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c;
  cin>>a>>b;
  for(int i=0;i<b;i++){
    cin>>c;
    a-=c;
  }
  if(a>=0)cout<<a<<endl;
  else cout<<-1<<endl;
}



Measured memory_bytes: 3632
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String input = sc.nextLine();
      	if(input.equals("Sunny"))
           System.out.println("Cloudy");
        else if(input.equals("Cloudy"))
                System.out.println("Rainy");
        else
                System.out.println("Sunny");
		
	}
}

Measured memory_bytes: 23252
/*  -*- coding: utf-8 -*-
 *
 * b.cc: D: Menagerie
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 100000;

/* typedef */

/* global variables */

bool as[MAX_N];

/* subroutines */

/* main */

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

  for (int d0 = 0; d0 <= 1; d0++)
    for (int d1 = 0; d1 <= 1; d1++) {
      //printf("d0=%d,d1=%d\n", d0, d1);
      as[0] = d0, as[1] = d1;
      bool ok = true;
      for (int x = 1; ok && x <= n; x++) {
	bool &a0 = as[x - 1];
	bool a1 = (as[x % n] ^ (s[x % n] == 'x')) ? (! a0) : a0;
	int x1 = (x + 1) % n;
	//printf(" s[%d]=%c -> (%d,%d,%d)\n",
	//x % n, s[x % n], a0, as[x % n], a1);
	if (x1 <= 1 && as[x1] != a1) ok = false;
	else as[x1] = a1;
      }
      if (ok) {
	for (int i = 0; i < n; i++) putchar(as[i] ? 'W' : 'S');
	putchar('\n');
	return 0;
      }
    }

  puts("-1");
  return 0;
}


Measured memory_bytes: 640
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
// #define USE_LLONG_AS_INT
#ifdef USE_LLONG_AS_INT
#define int long long
#define inf (1ll<<60)
#else
#define inf (1<<30)
#endif
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=(n)-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())

using namespace std;

const int mod=1e9+7;
const string sp=" ";

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

int w,h;
char rl[50][50],rr[50][50];
int syl,sxl,syr,sxr;
bool used[50][50][50][50];

bool bfs(){
    int dx[]={1,0,-1,0},dy[]={0,-1,0,1};
    queue<pi> ql,qr;
    memset(used,false,sizeof(used));
    ql.push({syl,sxl}),qr.push({syr,sxr});
    used[syl][sxl][syr][sxr]=true;
    while(!ql.empty()){
        pi l=ql.front(),r=qr.front();
        ql.pop(),qr.pop();
        int yl=l.fi,xl=l.se,yr=r.fi,xr=r.se;
        if(rl[yl][xl]=='%'&&rr[yr][xr]=='%'){
            return true;
        }
        if(rl[yl][xl]!='%'&&rr[yr][xr]!='%'){
            rep(i,4){
                int nyl=min(h-1,max(0,yl+dy[i]));
                int nxl=min(w-1,max(0,xl+dx[i]));
                int nyr=min(h-1,max(0,yr+dy[i]));
                int nxr=min(w-1,max(0,xr-dx[i]));
                if(rl[nyl][nxl]=='#')nyl=yl,nxl=xl;
                if(rr[nyr][nxr]=='#')nyr=yr,nxr=xr;
                if(!used[nyl][nxl][nyr][nxr]){
                    used[nyl][nxl][nyr][nxr]=true;
                    ql.push({nyl,nxl}),qr.push({nyr,nxr});
                }
            }
        }
    }
    return false;
}

void run(){
    cin>>w>>h;
    if(!w)return;
    rep(i,h){
        rep(j,w)cin>>rl[i][j];
        rep(j,w)cin>>rr[i][j];
    }
    rep(i,h){
        rep(j,w){
            if(rl[i][j]=='L')sxl=j,syl=i;
            if(rr[i][j]=='R')sxr=j,syr=i;
        }
    }
    Yes(bfs());
    run();
}


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

#define MAX 100000
#define ROOT 0
#define INODE 1
#define LEAF 2

struct CHILDREN {
	int id;
	struct CHILDREN *next;
};
typedef struct CHILDREN CHILDREN;

struct NODE {
	int parent;
	short depth;
	short type;
	CHILDREN *children;
};
typedef struct NODE NODE;

int main( void ) 
{   
    int n;
    int id,k,c;
    int i,j,depth;
    char types[3][32] = { "root", "internal node", "leaf" };
	NODE nodes[ MAX+1 ];
	CHILDREN *child=NULL,*pre=NULL;
	       
    scanf( "%d", &n );
    for( i=0; i<n; i++ ) {
        scanf( "%d%d", &id, &k );
        if( k ) {
       		child = (CHILDREN *)malloc( sizeof( CHILDREN ) );
       		nodes[id].children=child;
       		pre=child;
        	for( j=0; j<k; j++ ) {
	           	scanf( "%d", &c );
	           	if( !nodes[c].type ) {
          			nodes[c].type=INODE;        	
        		}
	           	nodes[c].parent=id;
	           	nodes[c].depth=nodes[id].depth+1;
	           	child->id=c;
	           	pre->next=child;
	           	pre=child;
	           	child = (CHILDREN *)malloc( sizeof( CHILDREN ) );
        	}
        	free( child );
        	pre->next=NULL;
        	if( 0 == nodes[id].depth ) {
        		nodes[id].parent = -1; 
        		nodes[id].type=ROOT;
        	}
       	} else {
       		nodes[id].type=LEAF;
	   		nodes[id].children=NULL;
       	}
    }
    if( 1 == n ) {
    	nodes[id].parent = -1; 
    	nodes[id].type=ROOT;
   	}
    
    for( i=0; i<n; i++ ) {
    	depth=(-1 == nodes[i].parent)? 0: nodes[ nodes[i].parent ].depth+1;
		printf( "node %d: parent = %d, depth = %d, %s, ", i, nodes[i].parent,  depth,  types[ nodes[i].type ] );
		if( NULL != nodes[i].children ) {
			child=nodes[i].children;
			printf( "[%d", child->id );
			child=child->next;
			while( NULL != child ) {
				printf( ", %d", child->id );
				child=child->next;
			}
			printf( "]\n" );
		} else {
			printf( "[]\n" );
		}
	}

    return 0;
}

Measured memory_bytes: 5300
#include<cstdio>
#include <string.h>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
using namespace std;

int main(){
  int a,b,c,x,count=0;
  cin>>a>>b>>c>>x;

  for(int i=0;i<=a;i++){
    for(int j=0;j<=b;j++){
      for(int k=0;k<=c;k++){
        if(500*i+100*j+k*50==x) count++;
      }
    }
  }

  cout<<count<<endl;

  return 0;
}


Measured memory_bytes: 256
def SelectionSort(A, N):

    changenum = 0

    for i in range(0, N):
        minj = i

        for j in range(i, N):
            if A[j] < A[minj]:
                minj = j
                
        if minj != i:
            changenum += 1
            A[minj], A[i] = A[i], A[minj]
        
    
    print(' '.join([str(x) for x in A]))
    print(changenum)

N = int(input())
A = [int(x) for x in input().split()]

SelectionSort(A, N)


Measured memory_bytes: 5608
#include <iostream>
using namespace std;
int main(){
  long long int N, K;
  cin >> N >> K;
  long long int A[N], B[N];
  for(int i = 0; i < N; ++i){
    cin >> A[i] >> B[i];
  }
  long long int ans = 0LL;
  for(int i = 0; i < N; ++i){
    if((K | A[i]) == K){
      ans += B[i];
    }
  }
  long long int L = 1LL;
  while(L < K) L = 2*L + 1;
  L -= K;
  long long int t = 1LL;
  while(t <= K){
    if(!(t & K)){
      t *= 2;
      continue;
    }
    long long int s = 0LL;
    for(int i = 0; i < N; ++i){
      if(A[i] <= K && (!(t & A[i])) && ((L&A[i]) <= t)){
	s += B[i];
      }
    }
    ans = max(ans, s);
    t *= 2LL;
  }

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


Measured memory_bytes: 1920
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools
import time,random,resource

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def pe(s): return print(str(s), file=sys.stderr)
def JA(a, sep): return sep.join(map(str, a))
def JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)


def main():
    h,w,k = LI()
    y1,x1,y2,x2 = LI_()
    ca = [S() for _ in range(h)]

    aa = [[-1 if c == '@' else inf for c in s] for s in ca]
    aa[y1][x1] = 0
    q = [(y1,x1)]
    v = collections.defaultdict(bool)
    t = 0
    while q:
        t += 1
        nq = []
        for y,x in q:
            for dy, dx in dd:
                for i in range(1, k+1):
                    ty = y + dy * i
                    tx = x + dx * i
                    if ty < 0 or ty >= h or tx < 0 or tx >= w or aa[ty][tx] < t:
                        break

                    if aa[ty][tx] == t:
                        continue

                    aa[ty][tx] = t
                    nq.append((ty,tx))

        q = nq

    if aa[y2][x2] == inf:
        return -1

    return aa[y2][x2]


print(main())




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

using namespace std;

#define INF 1001001001  //int32_t
#define MOD 1000000007
#define MOD2 998244353

#define all(a)  (a).begin(),(a).end()

#define pb push_back
#define eb emplace_back
#define mkp make_pair

#define se second
#define fi first

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


int main(){

    bool flag=false;
    ll ans=0,sum=0;

    int n;
    string s;
    cin >>n>>s;

    for (int i = 1; i < n; i++){
        map<char,int> m; int cnt=0;

        for (int j = 0; j < i; j++){
            if(m[s[j]] == 0)++m[s[j]];
        }

        for (int j = i; j < n; j++){
            if(m[s[j]] == 1)++m[s[j]];
        }
        
        for(auto p:m){
            if(p.se == 2)++cnt;
        }

        ans = max((int)ans,cnt);
    }
    

    //cout <<fixed<<setprecision(16)<< << endl;
    cout << ans << endl;

    //if(flag)cout << "Yes" <<endl;
    //else cout << "No" <<endl;
    
    return 0;
}


Measured memory_bytes: 256
n, k = [int(i) for i in input().split()]
h = [int(input()) for i in range(n)]

s = sorted(h)
sa = max(s)-min(s)

for i in range(n-k+1):
    a = s[i+k-1] - s[i]
    if a < sa:
        sa = a

print(sa)

Measured memory_bytes: 8280
#include <algorithm>
#include <cmath>
#include <complex>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>
#include <functional>
#include <cstring>
#include <regex>
#include <random>
#include <cassert>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, s, n) for (int i = (s); i < (int)(n); i++)
#define revrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define revrepr(i, s, n) for (int i = (n) - 1; i >= s; i--)
#define debug(x) cerr << #x << ": " << x << "\n"
#define popcnt(x) __builtin_popcount(x)

using ll = long long;
using P = pair<int, int>;

const long long MOD = 1e9+7;

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

template<class T>
istream& operator >>(istream &is, vector<T> &v) {
    for (int i = 0; i < (int)v.size(); i++) cin >> v.at(i);
    return is;
}

template<class T, class U>
ostream& operator <<(ostream &os, pair<T, U> p) {
    cout << '(' << p.first << ", " << p.second << ')';
    return os;
}

template<class T>
void print(const vector<T> &v, const string &delimiter) { rep(i, v.size()) cout << (0 < i ? delimiter : "") << v.at(i); cout << endl; }

template<class T>
void print(const vector<vector<T>> &vv, const string &delimiter) { for (const auto &v: vv) print(v, delimiter); }

int main() {
    int h, w, K;
    cin >> h >> w >> K;
    vector<vector<int>> s(h, vector<int>(w));
    rep(i, h) rep(j, w) {
        char c;
        cin >> c;
        s[i][j] = c - '0';
    }

    int ans = 100000;
    rep(bit, 1 << (h - 1)) {
        bool ok = true;
        vector<int> sep(1);
        rep(i, h - 1) if (bit >> i & 1) sep.push_back(i + 1);
        sep.push_back(h);

        vector<int> sum(sep.size() - 1);

        int cnt = popcnt(bit);

        rep(i, w) {
            bool done = false;
            rep(j, sep.size() - 1) {
                repr(k, sep[j], sep[j + 1]) {
                    sum[j] += s[k][i];
                    if (K < sum[j]) done = true;
                }
            }

            if (done) {
                cnt++;
                rep(j, sep.size() - 1) sum[j] = 0;

                rep(j, sep.size() - 1) {
                    repr(k, sep[j], sep[j + 1]) {
                        sum[j] += s[k][i];
                        if (K < sum[j]) ok = false;
                    }
                }
            }
        }

        if (!ok) continue;

        if (chmin(ans, cnt)) {
            //cout << ans << endl;
            //cout << bitset<10>(bit) << endl;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import sys
readline = sys.stdin.readline
N, K = map(int, input().split())
W = tuple(int(readline()) for _ in range(N))
ma = max(W)
def check(x):
    if x < ma:
        return False
    use = 1
    rest = x
    for w in W:
        if rest >= w:
            rest -= w
        else:
            rest = x - w
            use += 1
    return use <= K
l = 0
r = sum(W)
while r - l > 1:
    m = (r + l) // 2
    if check(m):
        r = m
    else:
        l = m
print(r)


Measured memory_bytes: 9588
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
//repマクロ定義
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
//allマクロ定義
#define all(v) v.begin(),v.end()
using namespace std;

int main(){
  int x;
  cin >> x;
  switch(x){
    case 3 : puts("YES"); break;
    case 5 : puts("YES"); break;
    case 7 : puts("YES"); break;
    default : puts("NO"); break;
  }
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"math"
)

var A, B, ans int

func main() {
	fmt.Scan(&A, &B)

	if A%3 == 0 || B%3 == 0 || (A+B)%3 == 0 {
		fmt.Println("Possible")
	} else {
		fmt.Println("Impossible")
	}
}

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

func gcd(x, y uint64) uint64 {
	if x%y == 0 {
		return y
	} else {
		r := x % y
		return gcd(y, r)
	}
}

func combination(x, y int) int {
	return permutation(x, y) / permutation(y, y)
}

func permutation(x, y int) int {
	var ans int = 1
	for i := x - y; 0 < i; i-- {
		ans *= i
	}
	return ans
}

func max(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Max(float64(x[i]), float64(res)))
	}
	return res
}

func min(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Min(float64(x[i]), float64(res)))
	}
	return res
}

func pow(x, y int) uint64 { return uint64(math.Pow(float64(x), float64(y))) }
func abs(x int) int       { return int(math.Abs(float64(x))) }
func floor(x int) int     { return int(math.Floor(float64(x))) }

type XY struct {
	x int
	y int
}

type SortBy [][]int

func (a SortBy) Len() int      { return len(a) }
func (a SortBy) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
func (a SortBy) Less(i, j int) bool {
	if a[i][0] == a[j][0] {
		return a[i][1] > a[j][1]
	}
	return a[i][0] > a[j][0]
}


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

// dump macro{{{
// http://www.creativ.xyz/dump-cpp-652
#define DUMPOUT cerr // 変数ダンプ先。coutかcerr

#ifdef PCM
// 引数はいくつでもどんな型でも可（ストリーム出力演算子があればOK）
#define dump(...) DUMPOUT<<"  "; \
  DUMPOUT<<#__VA_ARGS__; \
  DUMPOUT<<":=> "; \
  dump_func(__VA_ARGS__); DUMPOUT<<"in ["<<__LINE__<<":"<<__FUNCTION__<<"]"<<endl;
#define dump_1d(x,n) DUMPOUT <<"  " \
  <<#x<<"["<<#n<<"]"<<":=> {"; \
  rep(i,n){ DUMPOUT << x[i] << (((i)==(n-1))?"}":", "); } DUMPOUT <<" in [" << __LINE__ << "]" << endl;

#define dump_2d(x,n,m) DUMPOUT <<"  " \
    <<#x<<"["<<#n<<"]"<<"["<<#m<<"]"<<":=> \n"; \
    rep(i,n)rep(j,m){ DUMPOUT << ((j==0)?"     |":" ") << x[i][j] << (((j)==(m-1))?"|\n":" "); } \
    DUMPOUT <<"  in [" << __LINE__ << "]" << endl;
#else
#define dump(...) 42
#define dump_1d(...) 42
#define dump_2d(...) 42
#endif

// デバッグ用変数ダンプ関数
void dump_func() {
}
template <class Head, class... Tail>
void dump_func(Head&& head, Tail&&... tail)
{
    DUMPOUT << head;
    if (sizeof...(Tail) == 0) {
        DUMPOUT << " ";
    }
    else {
        DUMPOUT << ", ";
    }
    dump_func(std::move(tail)...);
}

// vector出力
template<typename T>
ostream& operator << (ostream& os, vector<T>& vec) {
    os << "{";
    for (int i = 0; i<vec.size(); i++) {
        os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
    }
    os << "}";
    return os;
}/*}}}*/

#define rep(i, x) for(int i = 0; i < (int)(x); i++)/*{{{*/
#define reps(i,x) for(int i = 1; i <= (int)(x); i++)
#define rrep(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define rreps(i,x) for(int i=((int)(x));i>0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define RFOR(i, m, n) for(int i = m;i >= n;i--)
#define foreach(x,a) for(auto& (x) : (a) )
#define all(x) (x).begin(),(x).end()
#define sum(v) accumulate(all(v), 0)
#define sz(x) ((int)(x).size())
#define fill(x,y) memset(x,y,sizeof(x))
#define pb(a) push_back(a)
#define INF 2147483647
#define INFLL 1000000000000000000LL
#define MOD 1000000007/*}}}*/

struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;/*{{{*/
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long> vll;
typedef vector<vll> vvll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<pii> vii;
typedef vector<vii> vvii;
typedef tuple<int,int,int> iii;
typedef set<int> si;
typedef complex<double> pnt;
typedef vector<pnt> vpnt;
typedef priority_queue<pii,vii,greater<pii> > spq;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

/*}}}*/

// global variables

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

  int res = 0;
  rep(i, 4){
    if (s[i]=='-') res--;
    if (s[i]=='+') res++;
  }
  cout << res << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <queue>
#include <string>
using namespace std;
int main(void){
    string S;
    cin >> S;
    int ans = 0;
    int count = 0;
    for(int i=0;i<S.length();i++){
        if(S[i] == 'A' || S[i] == 'C' || S[i] == 'G' || S[i] == 'T'){
            count++;
        }
        else{
            count = 0;
        }
        ans = max(ans,count);
    }
    cout << ans << endl;
}


Measured memory_bytes: 3108
using System;

class MainClass : MyUtil {
	public static void Main (string[] args){
		while (true) {
			int[] ins = ReadIntMap ();
			int n = ins [0], m = ins [1];
			if (n == 0 && m == 0)
				break;	

			int[] c = new int[11];

			for (int i = 0; i < n; i++) {
				ins = ReadIntMap ();
				c [ins [1]] += ins [0];
			}

			for (int i = 10; i >= 0; i--) {
				int use = Math.Min (c [i], m);
				m -= use;
				c [i] -= use;
			}

			int psum = 0;
			for (int i = 0; i < 11; i++) {
				psum += i * c [i];
			}
			Console.WriteLine (psum);
		}
	}
}

class MyUtil : MyIO {
}

class MyIO{
	public static String ReadLine(){return Console.ReadLine ();}
	public static int[] ReadIntMap(){
		string[] strs = Console.ReadLine().Split(' ');
		int[] ret = new int[strs.Length];
		for (int i = 0; i < strs.Length; i++) {

			ret [i] = int.Parse (strs [i]);
		}
		return ret;
	}
}

Measured memory_bytes: 5812
/*     *******************Bismillahir Rahmanir Rahim************************
                          MD. ASFAKUL GHANI!
                          *ProMAGFAT*!
 SECRET_warning :)->FAT   CSE-25!
                          JAHANGIRNAGAR UNIVERSITY!
                          Dhaka,Bangladesh!
*/

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

#define           fasterIO ios_base::sync_with_stdio(false);cin.tie(NULL)
#define           Im int main()
#define           ll long long
#define           sc scanf
#define           pf printf
#define           rn0 return 0
#define           rn return
#define           f0(i,n) for(ll i=0;i<n;i++)
#define           f1(i,n) for(ll i=1;i<=n;i++)
#define           f2(i,n) for(ll i=n-1;i>=0;i--)
#define           pi 2*acos(0.0)
#define           modulo 1000003
#define           dd double
#define           PI 3.14159265358979
#define           pi 2*acos(0.0)
#define           p_b push_back
#define           ps push

/*
ll for_binarySearch(ll a,ll b,ll aa[],ll x){while(a<=b){ll mid=(a+b)/2;if(aa[mid]==x) return 1;else if(aa[mid] > x) b=mid-1;else a=mid+1;}return -1;}
ll for_gcd(ll a,ll b){if(a==0) return b;else return for_gcd(b%a,a);}
ll for_prime(ll x){for (ll i=2;i*i<=x;i++){if(x%i==0) return 0;}return 1;}
void for_swap(char *x,char *y){char temp;temp=*x;*x=*y;*y=temp;}
ll for_big_mod(ll b,ll p,ll m){if(p==0) return 1;else if(p%2==0){ll k=for_big_mod(b,p/2,m);return (k*k)%m;}else return ((b%m)*(for_big_mod(b,p-1,m)))%m;}
ll for_josephus(ll n,ll k){if(n==1) return 1;return (for_josephus(n-1,k)+k-1)%n+1;}
ll for_gcdExtended(ll a,ll b,ll *x,ll *y){if(a==0){*x=0;*y=1;return b;}ll x1,y1;ll gcd=for_gcdExtended(b%a,a,&x1,&y1);*x=y1-(b/a)*x1;*y=x1;return gcd;}
*/

void debug1()
{
    cout << "***" << endl;
}

void debug11(ll n)
{
    cout << n << endl;
}

ll m,n;
vector <ll> v1[101010];
ll in_dg[101010];

void FAT_topSort()
{
    memset(in_dg,0,sizeof(in_dg));

    for (ll i = 0; i < n; i += 1){
        vector <ll> ::iterator it;
        for (it = v1[i].begin(); it != v1[i].end(); it += 1){
            in_dg[*it] += 1;
        }
    }
    queue <ll> q1;
    for (ll i = 0; i < n; i += 1){
        if (in_dg[i]==0) q1.ps(i);
    }
    vector <ll> v2;
    ll cnt = 0;
    while (!q1.empty()){
        ll u = q1.front();
        q1.pop();
        v2.p_b(u);
        vector <ll> ::iterator it;
        for (it = v1[u].begin(); it != v1[u].end(); it += 1){
            //in_dg[*it] -= 1;
            if (--in_dg[*it]==0) q1.ps(*it);
        }
        cnt += 1;
    }

    for (ll i = 0; i < v2.size(); i += 1){
        cout << v2[i] << endl;
    }
    rn;
}

Im
{
    /*#ifdef FAT
       freopen("input.txt","w",stdin);
    #endif // FAT*/

    //fasterIO;

    cin>>n>>m;

    for (ll i = 0; i < m; i += 1){
        ll u,v;
        cin>>u>>v;
        v1[u].p_b(v);
    }

    FAT_topSort();

   // main();

    rn0;
}

Measured memory_bytes: 7044
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef map<int,int> mii;
typedef map<ll,ll> mll;
typedef vector<pii> vii;
typedef vector<pll> vll;
#define fi first
#define se second
#define pi 3.141592653589793
#define mod 998244353
#define pb push_back
#define all(v) v.begin(),v.end()
#define tc int t;cin>>t;while(t--)
#define pqmax priority_queue<int>
#define pqmin priority_queue<int,vi,greater<int>>
#define fast_io ios_base::sync_with_stdio(0), cin.tie(NULL)
#define tc_g int tt;cin>>tt;for(int ti=1;ti<=tt;ti++)
#define case_g "Case #"<<ti<<": "
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_multiset;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef tree<int, int, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_map;

int main() {
	fast_io;
	ll a, b, n;
	cin >> a >> b >> n;
	ll ans = a * n / b - a * (n / b);
	ll m = (n / b) * b - 1;
	if (m >= 0)
		ans = max(ans, a * m / b - a * (m / b));
	cout << ans << '\n';
}


Measured memory_bytes: 3656
//--- pA ---//
import java.util.*;
import java.lang.*;
import java.io.*;
public class Main {
	public static void main (String[] args) throws java.lang.Exception {
		new Solution();
	}
}
class Solution {
	Reader reader;
	public Solution () {
		reader = new Reader();
		while (reader.hasNext()) {
			run_case();
		}
	}

	int[] fact;
	private void run_case() {
		int N = reader.ni(), M = reader.ni();

		fact = buildFact(105);

		long res = nCr(N, 2) + nCr(M, 2);
		System.out.println(res);

		return;
	}

	private int[] buildFact(int n) {
		int[] fact = new int[n+1];
		fact[0] = 1;
		for (int i=1; i<n+1; i++) {
			fact[i] = fact[i-1] * i;
		}
		return fact;
	}

	private long nCr(int n, int r) {
		if (n < r) return 0;
		long res = 1;
		for (long i=n-r+1; i<=n; i++) {
			res *= i;
		}
		for (long i=2; i<=r; i++) {
			res /= i;
		}
		return res;
	}
}


class Reader {
	BufferedReader br;
	StringTokenizer st;
	public Reader(){
		try {
			br = new BufferedReader(new InputStreamReader(System.in));
			st = new StringTokenizer(br.readLine());
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	public String next() {
		if (st.hasMoreTokens()) return st.nextToken();
		try {
			st = new StringTokenizer(br.readLine());
		} catch (Exception e) {
			e.printStackTrace();
		}
		return st.nextToken();
	}
	public boolean hasNext() {
		try {
			if (!st.hasMoreTokens() && !br.ready()) return false;
			else return true;
		} catch (Exception e) {
			e.printStackTrace();
		}
		return false;
	}
	public int ni() {return Integer.parseInt(this.next());}
	public String ns() {return this.next();}
}


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

using namespace std;

#define MAX(a,b) ((a)>(b)?(a):(b))

int main()
{
    int n,k;
    vector<int> num;
    int temp;
    bool wildcard;
    int ans;

    cin >> n >> k;
    while(n!=0 && k!=0) {
        ans=0;
        for(int i=0; i<k; ++i) {
            cin >> temp;
            num.push_back(temp);
        }

        sort(num.begin(),num.end());

        if(num[0]==0){
            wildcard=true;
        } else {
            wildcard=false;
        }

        if(wildcard) {
            for(int i=1; i<(int)num.size(); ++i) {
                for(int j=0; i+j<(int)num.size(); ++j) {
                    if(num[i+j]==num[i]+j) {
                        if(num[i]+j!=n || num[i]!=1) {
                            ans=MAX(ans,j+2);
                        } else {
                            ans=MAX(ans,j+1);
                        }
                    } else if(num[i+j]==num[i]+j+1) {
                        ans=MAX(ans,j+2);
                    } else {
                        break;
                    }
                }
            }
        } else {
            for(int i=0; i<(int)num.size(); ++i) {
                for(int j=0; i+j<(int)num.size(); ++j) {
                    if(num[i+j]==num[i]+j) {
                        ans=MAX(ans,j+1);
                    } else {
                        break;
                    }
                }
            }
        }

        cout << ans << endl;
        num.clear();
        cin >> n >> k;
    }
    return 0;
}

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

string a,b;

int main(){
	cin >> a >> b;
	for(int i=0;i<max(a.length(),b.length());i++){
		if(a.length()!=b.length()){
			cout << (a.length()>b.length()?"GREATER":"LESS") << endl;
			return 0;
		}else if(a[i]>b[i]){
			cout << "GREATER" << endl;
			return 0;
		}else if(a[i]<b[i]){
			cout << "LESS" << endl;
			return 0;
		}else{
			continue;
		}
	}
	
	cout << "EQUAL" << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
string s;
 cin >> s;
  int ans = 0;
  int m = 0;
  for(int i = 0; i<s.size(); i++){
    if(s[i] == 'S')
      m = 0;
  	else{
      m++;
      ans = max(ans, m);
 	}
  }
  cout <<ans <<endl;
  
return 0;
}


Measured memory_bytes: 3588
a = gets.split(' ')
a[0], a[1] = a[0].to_i, a[1].to_i
b = [a[0].to_f, a[1].to_f]
printf("%d %d %.10f\n", a[0] / a[1], a[0] % a[1], b[0] / b[1])



Measured memory_bytes: 6896
#include <cstdio>
#include <algorithm>
const int MOD = 1000000007;
int N, K;
int f[2002], g[2002];
inline void add(int &x, int y)
{
	x = x + y < MOD ? x + y : x + y - MOD;
}
int main()
{
	scanf("%d%d", &N, &K);
	f[N - 1] = 1;
	for (int i = 0; i < K - 1; i++)
	{
		for (int j = 0; j < N - i - 1; j++)
			g[j] = f[j + 1];
		for (int j = N - i - 3; j >= 0; j--)
			add(g[j], g[j + 1]);
		for (int j = 0; j < N - i - 1; j++)
			add(f[j], g[j]);
	}
	int O = 0;
	for (int i = 0; i <= N - K; i++)
		add(O, f[i]);
	for (int i = N - K - 1; i > 0; i--)
		add(O, O);
	printf("%d\n", O);
	return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <climits>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <deque>
#define INF_INT (INT_MAX / 2)
#define INF_LONG (LONG_MAX / 2)
//#define DEBUG true
#define DEBUG false
using namespace std;

const int MAX = 100001;
const int MOD = 1000000007;

typedef long long ll;
typedef pair< int, int > pii;
typedef pair< ll, ll > pll;
typedef pair< ll, int > pli;
typedef pair< int, ll > pil;

int ceil(int x, int y){
  return (x % y == 0) ? x / y : x / y + 1;
}

int gcd(int x, int y){
  return y ? gcd(y, x % y) : x;
}

int lcm(int x, int y){
  return x / gcd(x, y) * y;
}

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

  int p, q, r;
  cin >> p >> q >> r;

  int ans = min(p + q, min(p + r, q + r));

  cout << ans << endl;

  return 0;
}


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

int main() {
    long long int W, H;
    int x, y;
    cin >> W >> H >> x >> y;

    cout << W * H / 2.f << " ";
    if(W/2.0 == x && H/2.0 == y){
        cout << 1 << endl;
    }
    else{
        cout << 0 << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
#include<math.h>
#include<map>
#include<set>
using namespace std;
#define INF 11000000000
#define MOD 1000000007
typedef long long ll;
typedef pair<int,int> P;

int main(){
  int N;
  cin>>N;
  cout<<"ABC"<<N<<endl;
}


Measured memory_bytes: 256
/*
Author: Racer5x
 ***************************************   UNAUTHORISED COPYING OF CODE PROHIBITED   **********************************
*/

/*#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")*/

#include<bits/stdc++.h>
#define int         long long
#define double      long double
#define pb          emplace_back
#define pf          emplace_front
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define rall(a)     (a).rbegin(),(a).rend()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        998244353 
#define PI          3.141592653589
#define tezz        ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define MAX         1000000000000000000
using namespace std;

int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); }
int power(int x,int n){
    int result=1;
    while(n>0)
    {
        if(n % 2 ==1)
            result=result * x;
        x=x*x;
        n=n/2;
    }
    return result;
}

int n,w,dp[105][100005],mat[105][2];
int mx(int curr, int weight){
    if(curr==n) return 0;
    if(weight==0) return 0;
    if(dp[curr][weight]) return dp[curr][weight];
    //cout<<'g';

    if(weight<mat[curr][0]) dp[curr][weight] = mx(curr+1,weight);
    else{
        dp[curr][weight] = max(mx(curr+1,weight), mx(curr+1,weight-mat[curr][0]) + mat[curr][1]);
    }

    //cout<<curr<<' '<<weight<<" -> "<<dp[curr][weight]<<endl;
    return dp[curr][weight];
}

signed main()
{
    tezz

/*#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif*/

    memset(dp,0,sizeof(dp));
    cin>>n>>w;
    for(int i=0;i<n;i++) {cin>>mat[i][0]; cin>>mat[i][1];}
    cout<<mx(0,w);
}

Measured memory_bytes: 82432
s = input()
v = 1
c = 0
cc = 0
for i in s:
    if i == '0' and v == -1:
        c+=1
    if i == '1' and v == 1:
        c+=1
    v*=-1

v = -1
for i in s:
    if i == '0' and v == -1:
        cc+=1
    if i == '1' and v == 1:
        cc+=1
    v*=-1
print(min(c,cc))


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vi2 = vector<vector<int>>;
using vb = vector<bool>;
using vb2 = vector<vector<bool>>;
using vc = vector<char>;
using vc2 = vector<vector<char>>;
using vs = vector<string>;
using vs2 = vector<vector<string>>;
using pii = pair<int, int>;
using mii = map<int, int>;
const int INF = 1e9;
const ll LINF = 1e18;
#define MP(a,b) make_pair((a),(b))
#define MT(...) make_tuple(__VA_ARGS__)

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)

#define ALL(x) (x).begin(),(x).end()
#define IN(type,a) type a;cin >> a
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define COUT(x) cout << (x) << endl
#define DCOUT(x,n) cout << fixed << setprecision(n) << (x) << endl
int gcd(int x, int y){
    if ((x==1)||(y==1)) return 1;
    if (x>y) {
        if (x%y==0) {
            return y;
        }else{
            return gcd(y, x%y);
        }
    }else{
        if (y%x==0) {
            return x;
        }else{
            return gcd(x, y%x);
        }
    }
}
int main() {
    IN(int, n);
    IN(int, x);
    int ans = 1;
    int now = 0;
    REP(i, n){
        IN(int, k);
        now += k;
        if (now > x) {
            break;
        }
        ans++;
    }
    COUT(ans);
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
static const int MAX_N=10e5;
int A[MAX_N+1];
int main(void){
	int N;
		cin >> N;
	for(int i=1;i<=N;i++)
		cin >> A[i];
	int ans=0;
	for(int i=1;i<=N;i++){
		if(A[i]-A[i-1]>=0){
			ans++;
		}else{
			A[i]=A[i-1];
		}
	}
	cout << ans << endl;
	return 0;
}

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

int main(){
    int n;
    cin >> n;

    vector<int> a(n);

    //maxの値と位置，max-nextの値

    int max, nmax;
    cin >> max;
    cin >> nmax;
    int place;

    if(max >= nmax) place = 0;
    else{
        int tmp = max;
        max = nmax;
        nmax = tmp;
        place = 1;
    }
    
    for(int i=2;i<n;i++){
        int tmp;
        cin >> tmp;
        if(max < tmp){
            nmax = max;
            max = tmp;
            place = i;
        }
        else if(nmax < tmp){
            nmax = tmp;
        }
    }

    rep(i, n){
        if(i==place) cout << nmax << endl;
        else cout << max << endl;
    }


    return 0;
}

Measured memory_bytes: 2432
import java.util.Scanner

object Main {
  def solve2(i: Int, sc: => Scanner): (Int, Int) = {
    if (i == 0) ((0, 0)) else {
      val ret = solve2(i - 1, sc)
      val A, B = sc.next
      if (A == B) {
        (ret._1 + 1, ret._2 + 1)
      } else if (A < B) {
        (ret._1, ret._2 + 3)
      } else {
        (ret._1 + 3, ret._2)
      }
    }
  }

  def solve(sc: => Scanner): Unit = {
    val ans = solve2(sc.nextInt, sc)
    println(ans._1 + " " + ans._2)
  }

  def main(args: Array[String]): Unit = {
    val sc: Scanner = new Scanner(System.in)
    solve(sc)
  }
}

Measured memory_bytes: 47604
import java.util.*;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(true){
			String[] s = sc.nextLine().split(" ");
			if(s[0].compareTo("END")==0 && s[1].compareTo("OF")==0 && s[2].compareTo("INPUT")==0)break;
			for(int i=0;i<s.length;i++){
				System.out.print(s[i].length());
			}
			System.out.println();
		}
	}	
}

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

int main(){
    int n;
    cin >> n;
    vector<vector<array<int, 2>>> E(n);
    for (int i = 0; i < n - 1; i++){
        int a, b, c;
        cin >> a >> b >> c;
        a--; b--;
        E[a].push_back({b, c});
        E[b].push_back({a, c});
    }


    vector<int> C(n);
    auto dfs = [&](int i, int par, int d, auto self) -> void{
        C[i] = d & 1;
        for (const auto &e: E[i]){
            if (e[0] == par) continue;
            self(e[0], i, d + e[1], self);
        }
    };

    dfs(0, -1, 0, dfs);

    copy(C.begin(), C.end(), ostream_iterator<int>(cout, "\n"));
}

Measured memory_bytes: 7424
#include <iostream>
#include <vector>
#include <stack>
#include <algorithm>
#include <string>
const int INF = 1e7;

int main()
{
	int N; std::cin >> N;
	int K; std::cin >> K;
	std::vector<int> D;
	for(int i=0; i<10; i++) D.push_back(i);
	for(int k=0; k<K; k++)
	{
		int tmp; std::cin >> tmp;
		D.erase(std::remove(D.begin(),D.end(),tmp),D.end());
	}

	std::stack<std::string> s;
	for(int k=0; k<D.size(); k++)
	{
		s.push(std::to_string(D[k]));
	}
	int min = INF;
	while(!s.empty())
	{
		std::string current = s.top(); s.pop();
		int n = std::stoi(current);
		if(n>=N && n<min) min = n;
		if(current.size()<(int)log10(N)+1)
		{
			for(int k=0; k<D.size(); k++)
			{
				std::string child = current;
				child.insert(0,std::to_string(D[k]));
				s.push(child);
			}
		}
	}
	if(min==INF)
	{
		int j = (D[0]==0 ? 1 : 0);
		int digit = (int)log10(N)+1;
		std::string str;
		for(int i=0; i<digit; i++)
		{
			str.insert(0,std::to_string(D[0]));
		}
		str.insert(0,std::to_string(D[j]));
		min = std::stoi(str);
	}
	std::cout << min << std::endl;
	return 0;
}

Measured memory_bytes: 256
N,M=(int(x) for x in input().split())
L=0
R=N
for i in range(M):
  Li,Ri=(int(x) for x in input().split())
  L=Li if Li>L else L
  R=Ri if Ri<R else R
ans=R-L+1 if R>=L else 0
print(ans)

Measured memory_bytes: 3060