akhauriyash/Code-Regression huggingface dataset:
#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::io::prelude::BufRead;
#[allow(unused_imports)]
use std::io::{stdin, stdout, BufReader, BufWriter, Write};
#[allow(unused_imports)]
use std::mem::swap;
#[allow(unused_imports)]
use std::str::FromStr;

fn main() {
	let line = read_vector::<usize>();
	let (n, a, b) = (line[0], line[1], line[2]);
	let minimum = min(n * a, b);
	println!("{}", minimum);
}

#[allow(dead_code)]
fn read<T>() -> T where T: std::str::FromStr, T::Err: std::fmt::Debug {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    return buf
        .trim()
        .parse()
        .unwrap();
}

#[allow(dead_code)]
fn read_vector<T>() -> Vec<T> where T: std::str::FromStr, T::Err: std::fmt::Debug {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    return buf
        .split_whitespace()
        .map(|s| s.parse().unwrap())
        .collect();
}

#[allow(dead_code)]
fn read_matrix<T>() -> Vec<Vec<T>> where T: std::str::FromStr, T::Err: std::fmt::Debug {
    use std::io::prelude::*;
    let stdin = stdin();
    return stdin
        .lock()
        .lines()
        .map(|line| line
            .unwrap()
            .split_whitespace()
            .map(|s| s.parse().unwrap())
            .collect())
        .collect();
}

Measured memory_bytes: 4352
#include "bits/stdc++.h"

using namespace std;

int main() {

	cin.tie(0);
	ios::sync_with_stdio(false);

	string a, b;

	cin >> a >> b;

	if (a == "H")
		cout << b << endl;
	else {
		if (b == "H")
			cout << "D" << endl;
		else
			cout << "H" << endl;
	}

	return 0;

}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int W = sc.nextInt();
        int H = sc.nextInt();
        int x = sc.nextInt();
        int y = sc.nextInt();
        int r = sc.nextInt();  
        if(x - r < 0 || y - r < 0 || x + r > W || y + r > H){
        	System.out.println("No");
        	}
        else if(x - r >= 0 && y - r >= 0 && H >= x + r && W >= y + r){
        	System.out.println("Yes");
        	}
	}

}


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

int main(){
    int A, B, C, D;
    int res = 0;
    cin >> A >> B >> C >> D;

    if (A>B) res += B;
    else res += A;

    if (C>D) res += D;
    else res += C;

    cout << res << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define x first
#define y second
#define ndl '\n'
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define up_b upper_bound
#define low_b lower_bound
#define sz(x) (int)x.size()
#define bit __builtin_popcount
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

using namespace std;
using namespace __gnu_pbds;

template<typename T> using indexed_set = tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<int, ull> piu;
typedef vector<vector<int>> matrix;

const ll INF = 1e18 + 123;
const ld EPS = 1e-9;
const int inf = 1e9 + 123;
const int MOD = 1e9 + 7;
const int N = 5e5 + 13;
const int M = 1e6 + 123;
const double pi = acos(-1.0);
const int dx[] = {0, 0, 1, -1};
const int dy[] = {1, -1, 0, 0};

int main(){
    #ifdef KAZAKH
        freopen("input.txt", "r", stdin);
    #endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int t;
    cin >> t;
    string s;
    cin >> s;
    for (char c : s){
        c -= 'A';
        c += t;
        c %= 26;
        cout << char(c+'A');
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include<ext/pb_ds/assoc_container.hpp>
//#include<ext/pb_ds/tree_policy.hpp>
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define MAX 2000005
#define MOD 1000000007
#define MOD2 998244353
#define pb push_back
#define mp make_pair
#define pii pair<ll,ll>
#define vi vector<ll>
#define vp vector<pii>
#define all(v) v.begin(),v.end()
#define sz(x) (ll)x.size()
#define F first
#define S second
#define FOR(i,a,b) for(ll i=a;i<b;++i)
#define ROF(i,a,b) for(ll i=a;i>=b;--i)
#define trace(x) cerr<<#x<<": "<<x<<'\n';
typedef long long ll;
using namespace std;
//using namespace __gnu_pbds;
//#define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>

ll mexp(ll a, ll b){
    ll ans=1;
    a%=MOD;
    while(b){
        if(b&1) ans=ans*a%MOD;
        b>>=1;
        a=a*a%MOD;
    }
    return ans;
}


int main(){
    IOS
    int n;
    cin>>n;
    int d[n+1];
    FOR(i,1,n+1){
        cin>>d[i];
    }
    sort(d+1,d+n+1);
    cout<<d[n/2+1]-d[n/2];

    cerr<<"Time: "<<1.0/CLOCKS_PER_SEC<<" ms"<<endl;
    return 0;
}

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

int main(){
    string str;
    int num;
    cin >> num >> str;
    for (auto iter = cbegin(str), end = cend(str); iter != end; iter++){
        cout << static_cast<char>((*iter + num - 'A') % 26 + 'A');
    }
    cout << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.Arrays;
public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int givenNumber = scanner.nextInt();
        int givenLength = scanner.nextInt();
        scanner.nextLine();
        String[] array = new String[givenNumber];
        for(int i=0; i<givenNumber; i++) {
            array[i] = scanner.nextLine();
        }
        Arrays.sort(array);
        StringBuilder sb = new StringBuilder();
        for(int i=0; i<array.length; i++) {
            sb.append(array[i]);
        }
        System.out.println(sb);
    }
}


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

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

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

    int ans = 0;
    for (int i = 1; i <= N; ++i) {
        if (v[v[i]] == i) ++ans;
    }
    ans /= 2;
    cout << ans << endl;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define VI vector<int>
#define VVI vector<vector<int>>
#define REP(i,n) for(int i=0;i<(n);i++)
#define MOD 1000000007
#define INF 1e9
#define All(x) (x).begin(),(x).end()
typedef long long ll;
using namespace std;
using Graph = vector<vector<int>>;

int main(){
    int x,y,a,b,c;
    cin>>x>>y>>a>>b>>c;
    vector<ll> p(a),q(b),r(c);
    REP(i,a)cin>>p[i];
    REP(i,b)cin>>q[i];
    REP(i,c)cin>>r[i];

    sort(All(p));sort(All(q));sort(All(r));
    
    priority_queue<ll> que;
    for(int i=a-1;i>a-x-1;i--)que.push(p[i]);
    for(int i=b-1;i>b-y-1;i--)que.push(q[i]);
    for(int i=c-1;i>=max(0,c-x-y);i--)que.push(r[i]);
    ll ans=0;
    for(int i=0;i<x+y;i++){
        ans+=que.top();
        //cout<<ans<<endl;
        que.pop();
    }
    cout<<ans<<endl;
    
}


Measured memory_bytes: 8816
n = int(input())
d = [list(map(int, input().split())) for _ in range(n)]
x = 0
for d1, d2 in d:
    if d1 == d2:
        x += 1
    else:
        x = 0
    if x == 3:
        print('Yes')
        break
else:
    print('No')


Measured memory_bytes: 9180
(eval-when (:compile-toplevel :load-toplevel :execute)
  (defparameter OPT
    #+swank '(optimize (speed 3) (safety 2))
    #-swank '(optimize (speed 3) (safety 0) (debug 0)))
  #+swank (progn (ql:quickload '(:cl-debug-print))))
#+swank (cl-syntax:use-syntax cl-debug-print:debug-print-syntax)

(deftype int32 () '(signed-byte 32))
(deftype int64 () '(signed-byte 64))


;;macros
(defmacro println (n)
  `(format t "~a~%" ,n))
(defmacro vint-out (vec)
  `(progn
     (rep i (length ,vec)
          (princ (vref ,vec i))
          (princ " "))
     (fresh-line)))


;;vector
(defmacro vec (type &optional (num 100) (val 0))
  (let* ((g (gensym)))
    `(let* ((,g ,num))
       (make-array ,g :element-type ',type :initial-element ,val
                   :adjustable nil :fill-pointer ,g))))

(defmacro double-vec (type &optional (dim1 100) (dim2 100) (val 0))
  `(make-array '(,dim1 ,dim2) :element-type ',type :initial-element ,val))

(defmacro vint (&optional (num 0) (val 0))
  `(vec int32 ,num ,val))

(defmacro double-vec (type &optional (dim1 100) (dim2 100) (val 0))
  `(make-array '(,dim1 ,dim2) :element-type ',type :initial-element ,val))

(defmacro vref (vector pos &optional value)
  (let ((g (gensym)))
    `(let ((,g ,value))
       (if ,g
           (setf (aref ,vector ,pos) ,g)
           (aref ,vector ,pos)))))

(defmacro chvar (sym comp predicate)
  (let ((g (gensym)))
    `(let ((,g ,comp))
       (if (or (null ,sym) (not (funcall ,predicate ,sym ,g)))
           (setf ,sym ,g)))))

(defmacro chmax (sym comp &optional (predicate #'>))
  `(chvar ,sym ,comp ,predicate))

(defmacro chmin (sym comp &optional (predicate #'<))
  `(chvar ,sym ,comp ,predicate))

(defmacro defchangef (name op default-val)
  `(defmacro ,name (var &optional (val ,default-val))
     `(setq ,var (,',op ,val ,var))))

;;本体
(defun main()
  (let ((n (read))(i (read)))
    (println (- (1+ n) i))))

#-swank(main)


Measured memory_bytes: 9060
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <iostream>
using namespace std;

int main(){
    int n;
    cin>>n;
    int i, j;
    int ans = 1;
    int ret;
    for(i=2; i<=n; i++){
        if(i*i>n){
            break;
        }
        ret = i;
        while(ret*i<=n){
            ret *= i;
        }
        if(ans<=ret){
            ans=ret;
        }
    }

    cout<<ans<<endl;

    return 0;
}

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


int main(){
    ll n;
    cin >> n;
    string moji;
    while(n){
        n--;
        moji += 'a'+ n%26;
        n /= 26;
    }
    reverse(moji.begin(),moji.end());
    cout << moji << endl;
    return 0;
}

Measured memory_bytes: 3604
import java.text.ParseException;
import java.util.Scanner;

class Main {
	public static void main(String[] args) throws ParseException {
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int q = sc.nextInt();

		int[] ac = new int[n];

		String s = sc.next();

		char[] array = s.toCharArray();

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

			if (i != 0) {
				ac[i] = ac[i - 1];
			}

			if (array[i] == 'C') {
				if (array[i - 1] == 'A') {
					ac[i]++;
				}
			}
		}

		for (int i = 0; i < q; i++) {
			int l = sc.nextInt();
			int r = sc.nextInt();

			System.out.println(ac[r - 1] - ac[l - 1]);

		}
	}

}


Measured memory_bytes: 66664
# -*- coding: utf-8 -*-

def main():
    n = int(input())
    keihin_set = set()
    for i in range(n):
        s = input()
        if not s in keihin_set:
            keihin_set.add(s)
    print(len(keihin_set))
if __name__ == "__main__":
    main()

Measured memory_bytes: 31068
#include <iostream>
#include <math.h>
using namespace std;
int main(){

	int X;
  	
  	cin>>X;
  
  if(X==2)cout<<X;
  
  else{
	int flag=0;
    int k=X;
    while(1){
	
      for(int i=2;i<sqrt(k);i++){
		if(k%i==0){
			flag=1;
          	break;
        }
      }
	if(flag==0)break;
    flag=0;
	k++;
    }
    cout<<k<<endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define __ <<" "<<
#define ___ <<" "
#define bash push_back
#define ALL(x) x.begin(),x.end()
//#define int long long

struct IoSetup {
    IoSetup() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout <<fixed<<setprecision(12);
        cerr <<fixed<<setprecision(12);
    }
}IoSetup;

typedef long long ll;
typedef pair < int , int >  pii;
static constexpr const signed int INF = 0x3f3f3f3f;
static constexpr const signed long long LINF = 0x3f3f3f3f3f3f3f3fLL;
static constexpr const signed int SMOD = 1000000007;
static constexpr const signed int NMOD = 998244353;
static constexpr const signed int dx[]={1,0,-1,0,1,1,-1,-1};
static constexpr const signed int dy[]={0,1,0,-1,-1,1,-1,1};

inline bool inside(int x,int y,int w,int h){return (x>=0 && y>=0 && x<w && y<h);}
template<class T>bool chmax(T &a, const T &b){return(a<b?a=b,true:false);}
template<class T>bool chmin(T &a, const T &b){return(a>b?a=b,true:false);}
inline int qp(int a,ll b,int mo){ll ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}

ll com[200200];
ll y[200200];

signed main() {

    int n, a, b;

    cin >> n >> a >> b;

    ll sum = qp(2, n, SMOD) - 1;

    com[1] = n;
    y[1] = 1;
    for(int i = 2; i <= b; i++) {
        com[i] = com[i-1] * (n - i + 1) % SMOD;
        y[i] = y[i-1] * i % SMOD;
    }

    a = com[a] * qp(y[a], SMOD - 2, SMOD) % SMOD;
    b = com[b] * qp(y[b], SMOD - 2, SMOD) % SMOD;
    
    cout <<  (SMOD + sum - (a + b) % SMOD) % SMOD  << endl;

  
    return 0;
}



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

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 998244353

def LI(): return [int(x) for x in sys.stdin.readline().split()]
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 main():
    rr = []

    dd = [(1,1),(1,0),(0,1),(0,-1),(-1,0),(-1,-1)]

    while True:
        n,q = LI()
        if n == 0 and q == 0:
            break
        a = [LS() for _ in range(n)]
        a = [[_[0],int(_[1]),int(_[2])] for _ in a]
        b = [I() for _ in range(q)]
        for c in b:
            r = 'Unknown'
            for l,e,w in a:
                if w-e < c <= w:
                    r = '{} {}'.format(l, e-w+c)
            rr.append(r)

    return '\n'.join(map(str, rr))


print(main())




Measured memory_bytes: 10544
N,M = map(int,input().split())
KL = [list(map(int,input().split())) for _ in [0]*N]

E = [[] for _ in [0]*(N+M)]
for i,kl in enumerate(KL):
    for l in kl[1:]:
        E[i].append(N+l-1)
        E[N+l-1].append(i)

start = 0
d = [-1]*(N+M) #d[0] - d[N-1]:人, d[N] - D[N+M-1]:言語
d[start] = 0
q = [start]
while q:
    i = q.pop()
    for j in E[i]:
        if d[j]!=-1:continue
        d[j] = d[i]+1
        q.append(j)

ans = True
for b in d[:N]:
    ans = ans and (b>=0)
print("YES" if ans else "NO")

Measured memory_bytes: 48692
N = int(input())
A1 = list(map(int, input().split()))
A2 = list(map(int, input().split()))

counts1 = [0] * N
counts2 = [0] * N

counts1[0] = A1[0]
for j in range(1, N):
    counts1[j] = counts1[j-1] + A1[j]

counts2[0] = counts1[0] + A2[0]
for j in range(1, N):
    if counts1[j] > counts2[j-1]:
        counts2[j] = counts1[j] + A2[j]
    else:
        counts2[j] = counts2[j-1] + A2[j]

print(counts2[N-1])


Measured memory_bytes: 3064
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <string>
#include <vector>
#define ll long long
#define ull unsigned long long
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define yes cout << "Yes" << endl
#define no cout << "No" << endl
#define FOR(i,start,stop)  for(int i=(start); i < (stop); i++)
#define FORD(i,start,stop) for(int i=(start); i >= (stop); i--)
#define RIP(i,stop) FOR(i,0,stop)
#define PI 3.141592653589793
#define PRECISION(c,f) fixed << setprecision(c) << f
using namespace std;

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

  int ans = 0;
  if(s[2] == s[3]) ans++;
  if(s[4] == s[5]) ans++;

  if(ans == 2) yes;
  else no;

  return 0;
}


Measured memory_bytes: 3656
//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=2197

#include<iostream>
#include<map>
#include<vector>
#include<algorithm>
#include<cmath>
#include<climits>
#include<ctime>
#include<cstring>
#include<numeric>

#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;

using namespace std;

int main() {
	
	int N;

	while(cin >> N && N)
	{
		int count=0;
		int total=0;
		REP(i,1,N){
			REP(j,1,N){
				total=0;
				REP(k,0,j){
					total+=i+k;
				}
				if(total == N){count++;}
				total=0;
			}
		}
		cout << count << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#!/usr/bin/env python3
import sys

def ln(n: int):
    return pow(2,n+1) - 3

def pn(n: int):
    return pow(2,n) - 1

def calc(N: int, X: int):
    if N == 0:
        return 0
    if N == 1:
        return 1
    n1 = ln(N - 1)
    if X == 1:
        return 0
    elif X <= 1 + n1:
        return calc(N-1,X-1)
    elif X == 2 + n1:
        return 1 + calc(N-1,X-1)
    elif X <= 2 + 2*n1:
        return 1 + pn(N-1) + calc(N-1,X-2-n1)
    else:
        return 1 + pn(N-1)*2

def solve(N: int, X: int):
    print(calc(N + 1,X))
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    X = int(next(tokens))  # type: int
    solve(N, X)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
use std::io::*;
use std::str::FromStr;
use std::collections::HashMap;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n: u32 = read();
    let ai: Vec<u32> = (0..n).map(|_| read()).collect();
    
    let mut map: HashMap<u32, u32> = HashMap::new();

    for a in ai.into_iter() {
        if map.contains_key(&a) {
            if let Some(x) = map.get_mut(&a) {
                *x += 1;
            }
        } else {
            map.insert(a, 1);
        }
    }

    let mut ans: u32 = 0;
    for (k, v) in map {
        // println!("{} {}", k, v);
        if k <= v {
            ans += v - k;
        } else {
            ans += v;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 8444
#include <bits/stdc++.h>
using namespace std;
#define dump(x) cout << (x) << endl
typedef long long ll;
typedef pair<int, int> pi;
typedef vector<int> V;

int main() {
  int n;
  cin >> n;
  dump(n/100 == n%10 ? "Yes" : "No");
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
using namespace std;
const int maxn = 2e5+10;
char s[maxn];
int main(){
    int st,rn;
    scanf("%s",s);
    for(int i = 0 ; i < strlen(s);i++)
    if(s[i]=='A'){
        st = i;
        break;
    }
    for(int i = strlen(s)-1; i >= 0 ;i--)
    if(s[i] == 'Z'){
        rn = i;
        break;
    }
    if(rn < st) printf("0\n");
    else
    printf("%d\n",rn-st+1);
}


Measured memory_bytes: 384
n,m = map(int,input().split())
p = [0 for _ in range(n)]
pw = [0 for _ in range(n)]
# print(p)
ansWA = 0
ansAC = 0

for i in range(m):
    pi,ans=input().split()
    pi=int(pi)-1
    if p[pi] != -1:
        if ans == 'AC':
            p[pi] = -1
            ansAC += 1
            ansWA += pw[pi]
        else:
            pw[pi] += 1

# print(p)
print(ansAC,ansWA)

Measured memory_bytes: 4752
s=input()
ans=0
for i in range(2**(len(s)-1)):
	a=int(s[0])
	b=0
	for j in range(len(s)-1):
		if i&(1<<j)==0 :
			a=a*10+int(s[j+1])
		else:
			b+=a
			a=int(s[j+1])
	ans+=a+b
print(ans)

Measured memory_bytes: 9188
from collections import deque



# for #!/usr/bin/env python
import os
import sys
from io import BytesIO, IOBase


# region fastio

BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

def main():
    # n = int(input())
    # l = [int(j) for j in input().split()]
    

    # for t in range(int(input())):
        # n,m = [int(j) for j in input().split()]
    s = input()
    t = input()
    ans = 0
    for i in range(len(s)): 
        if s[i]!=t[i]:
            ans+=1
    print(ans)

# endregion

if __name__ == "__main__":
    main()



Measured memory_bytes: 70472
// Problem : A - Number of Multiples
// Contest : AtCoder - AIsing Programming Contest 2020
// URL : https://atcoder.jp/contests/aising2020/tasks/aising2020_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
using namespace std;
//#define int long long
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define all(x) begin(x),end(x)

int mod = 1e9+7;
//int inf = 4e18;
const int N = 5e5+5;
		
signed main()
{
    io
    int tt = 1;
    //cin>>tt;
    while(tt--)
    {
		int l,r,d;
		cin>>l>>r>>d;
		int ct = 0;
		for(int i=l;i<=r;++i)
		{
			if(i%d==0)
			++ct;
		}
		cout<<ct;
    }
    return 0;
}


Measured memory_bytes: 3604
using System;
using System.Collections.Generic;
using System.Globalization;

class Program
 {
    static void Main(string[] args)
    {
        string nyuryoku;
        string[] temp;
        int number ,total;
        double result = 0 ,avg;
        var final = new List<double>();

        while (true)
        {
            nyuryoku = Console.ReadLine();
            number = int.Parse(nyuryoku);
            if (number == 0)
                break;
            temp = new string[number];
            nyuryoku = Console.ReadLine();
            temp = nyuryoku.Split(' ');
            total = 0;
            for (int i = 0; i < number; i++)
            {
                total += int.Parse(temp[i]);
            }
            avg = (double)total / number;
            result = 0;
            for (int i = 0; i < number; i++)
            {
                result += Math.Pow(double.Parse(temp[i]) - avg, 2.0);
            }
            final.Add(Math.Sqrt(result / number));
        }
        for (int i = 0;i < final.Count; i++)
           Console.WriteLine("{0:F5}",final[i]);
    }
 }



Measured memory_bytes: 16004
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define MOD (1000000007)
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

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

const ll INF = 1LL << 60;

int main(){
  int n,c,k; cin >> n >> c >> k;
  vi t(n); rep(i, n) cin >> t[i];
  sort(all(t));

  int ans = 0;
  int i = 0;
  while(i < n){
    int tmp = t[i] + k;
    int cnt = 0;
    while (i < n && cnt < c && t[i] <= tmp) {
      cnt++;
      i++;
    }
    //printf("i:%d cnt:%d\n",i, cnt );
    ans++;
  }

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


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
typedef pair<ll,ll> P;
#define pb push_back
#define ft first
#define sd second
#define mp make_pair
#define fr(i,n) for(int i=0;i<n;i++)
#define Fr(i,n) for(int i=0;i++<n;)
#define ifr(i,n) for(int i=n-1;i>=0;i--)
#define iFr(i,n) for(int i=n;i>0;i--)

vector<ll> c[100010];
ll cnt[2]={};
bool vis[100010]={},pnt[100010],master=0;

void rec(int i=1,bool f=0){
  if(master) return;
  if(vis[i]){
    if(pnt[i]^f) master=1;
    return;
  }
  vis[i]=1;pnt[i]=f;cnt[f]++;
  fr(j,c[i].size()) rec(c[i][j],1-f);
}

int main(){
  ll n,m,a,b;
  cin>>n>>m;
  fr(i,m){
    cin>>a>>b;
    c[a].pb(b);
    c[b].pb(a);
  }
  rec();
  if(master) cout<<(n*(n-1))/2-m<<endl;
  else cout<<cnt[0]*cnt[1]-m<<endl;
}

Measured memory_bytes: 6912
fun main(args: Array<String>) {
    val s = readLine()!!
    val t = readLine()!!

    for (i in (0..(s.length - 1))) {
        if (s.substring(i) + s.substring(0, i) == t) {
            println("Yes")
            return
        }
    }

    println("No")
}

Measured memory_bytes: 33612
import math
x=[]
i=0
while 1:
    l=input().split()
    a=int(l[0])
    b=int(l[2])
    op=str(l[1])

    if op=="?":
        break
    elif op=="/":
        if b==0:
            pass
        else:
            x.append(math.floor(eval(str(a)+op+str(b))))
            i=i+1
    else:
        x.append(eval(str(a)+op+str(b)))
        i=i+1

m=0
while m<i:
    print(x[m])
    m=m+1


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

int main() {
    int H, W;

    while (true) {
        cin >> H >> W;
        if (H == 0 && W == 0) {
            break;
        }

        for (int i=0; i<H; i++) {
            for (int j=0; j<W; j++) {
                cout << "#";
            }
            cout << endl;
        }
        cout << endl;
    }

    return 0;
}


Measured memory_bytes: 3100
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
#include <iomanip>
#include <cassert>
//#include <boost/multiprecision/cpp_int.hpp>
#include <complex>
#include <cstdio>

using namespace std;
//std::ios::sync_with_stdio(false);
//std::cin.tie(0);
const long long MOD = 1e9 + 7;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ld, ll> pdl;
typedef pair<ld, ld> pdd;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
//typedef boost::multiprecision::cpp_int bigint;

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	ll N;
	vector<ll> A;
	cin >> N;
	A.reserve(N);
	ll a;
	ll suma = 0;
	for (ll n = 0; n < N; n++) {
		cin >> a;
		A.push_back(a);
		suma += a;
	}
	ll time = N * (N + 1) / 2;
	if (suma % time != 0)goto no;
	time = suma / time;
	for (ll n = 0; n < N; n++) {
		A[n] -= time * n;
	}
	suma = 0;
	for (ll i = 0; i < N - 1; i++) {
		if (A[i] - A[i+1] < 0)goto no;
		if ((A[i] - A[i + 1]) % N != 0)goto no;
		suma += (A[i] - A[i + 1]) / N;
	}
	if (suma > time)goto no;
	goto yes;
yes:
	cout << "YES\n";
	return 0;
no:
	cout << "NO\n";
	return 0;
}

Measured memory_bytes: 1024
N = int(input())
a = list(map(int,input().split()))
gou = 0
j=1
for i in range(1,len(a)):
  i=j
  if j >= len(a):
    break
  if a[i-1] == a[i]:
    gou += 1
    j = i+2
  else:
    j = i+1
print(gou)

Measured memory_bytes: 3060
import java.io.PrintWriter;
import java.util.Scanner;
import java.util.StringJoiner;

public class Main {
    public static void main(String[] args) {
        try (InputReader in = new InputReader(); PrintWriter out = new PrintWriter(System.out)) {
            new Main().solve(in, out);
            out.flush();
        }
    }

    void solve(InputReader in, PrintWriter out) {
        int h = in.nextInt();
        int w = in.nextInt();
        int n = in.nextInt();

        int[] row = new int[w];
        int index = 0;
        boolean goRight = true;
        for (int i = 1; i <= n; i++) {
            int a = in.nextInt();
            for (int j = 0; j < a; j++) {
                row[index] = i;
                index += (goRight) ? 1 : -1;

                if (index == w || index == -1) {
                    StringJoiner sj = new StringJoiner(" ");
                    for (int c : row) {
                        sj.add(String.valueOf(c));
                    }
                    out.println(sj);
                    row = new int[w];
                    goRight = !goRight;
                    index += (goRight) ? 1 : -1;
                }
            }
        }
    }
}

class InputReader implements AutoCloseable {
    private final Scanner sc = new Scanner(System.in);

    String next() {
        return this.sc.next();
    }

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

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

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

    @Override
    public void close() {
        this.sc.close();
    }
}


Measured memory_bytes: 30492
#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> ls(n);

    rep(i, n) {
        int l;
        cin >> l;
        ls[i] = l;
    }

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

    int count = 0;
    for (int x = 0; x < n; x++) {
        int a = ls[x];
        for (int y = x + 1; y < n; y++) {
            int b = ls[y];
            for (int z = y + 1; z < n; z++) {

                int c = ls[z];

                if (a >= (b + c)) {
                    break;
                }
                if (b >= (a + c)) {
                    break;
                }
                if (c >= (b + a)) {
                    break;
                }
                count++;
            }
        }
    }


    cout << count << endl;

}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <iostream>
#include <fstream>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int n, m, k;
	cin>>n>>m>>k;
    int x1, y1, x2, y2;
	cin>>x1>>y1>>x2>>y2;
	x1--;
	y1--;
	x2--;
	y2--;
	char grid[n][m];
	int dist[n][m];
	for (int i=0; i<n; i++) {
		for (int j=0; j<m; j++) {
			cin>>grid[i][j];
			dist[i][j] = INT_MAX;
		}
	}
 
    int d[4][2] = {{-1,0}, {0,-1}, {1,0}, {0,1}};
	queue<pair<int, int> > q;
	dist[x1][y1] = 0;
	q.push({x1, y1});
	while (!q.empty()) {
		int x = q.front().first;
		int y = q.front().second;
		q.pop();
 
		for (int i=0; i<4; i++) {
			int nx = x;
			int ny = y;
			int nd = dist[x][y]+1;
			for (int j=1; j<=k; j++) {
				nx += d[i][0];
				ny += d[i][1];
 
				if (nx<0 || nx>=n || ny<0 || ny>=m || grid[nx][ny]=='@' || dist[nx][ny]<nd) {
					break;
				}
				if (dist[nx][ny]>nd) {
					dist[nx][ny] = nd;
					q.push({nx, ny});
				}
			}
		}
	}
 
	int ans = dist[x2][y2];
	cout<<(INT_MAX==ans ? -1 : ans)<<endl;
	return 0;
}
 

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

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

  string s;
  cin >> s;
  int ans = 0;
  char bef = s[0];
  rep(i, 1, s.size()) {
    if (bef == s[i]) {
      if (s[i] == '1')
        s[i] = '0';
      else
        s[i] = '1';
      ans++;
    }
    bef = s[i];
  }
  cout << ans << endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

using Graph = vector<vector<int>>;
ll k = -1;
map<P, int> ans;

void dfs(const Graph &G, int v, int p, int e){
    ll now = 1;
    for(auto nv : G[v]){
        if(nv == p)continue;
        if(now == e)now++;
        P p = make_pair(min(v, nv), max(v, nv));
		ans[p] = now;
        k = max(k, now);
        dfs(G, nv, v, now);
        now++;
    }
}

int main() {
    int n;
    cin >> n;
    Graph G(n);
    vector<int> a(n-1), b(n-1);
    rep(i, n-1){
        cin >> a[i] >> b[i];
        a[i]--; b[i]--;
        G[a[i]].push_back(b[i]);
        G[b[i]].push_back(a[i]);
    }
    dfs(G, 0, -1, -1);
    cout << k << endl;
    rep(i, n-1){
        cout << ans[make_pair(a[i], b[i])] << endl;
    }
}

Measured memory_bytes: 14080
/*
 * aoj/dpl_5_i/main.cpp
 */

// C++ 14
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring> // memset
#include <cassert>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
template <class T> ostream & operator << (ostream & out, vector<T> const & v) {
  for (auto &&a: v) out << a << " "; out << endl; return out;
}
template <class T> void dump(T &a) { cout << a << endl; }
template <class T> bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false; }
template <class T> bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false; }

#define MOD 1000000007
struct mint {
  ll x;
  mint():x(0){}
  mint(ll x):x((x%MOD+MOD)%MOD){}
  mint& fix() { x = (x%MOD+MOD)%MOD; return *this;}
  mint operator-() const { return mint(0) - *this;}
  mint& operator+=(const mint& a){ if((x+=a.x)>=MOD) x-=MOD; return *this;}
  mint& operator-=(const mint& a){ if((x+=MOD-a.x)>=MOD) x-=MOD; return *this;}
  mint& operator*=(const mint& a){ (x*=a.x)%=MOD; return *this;}
  mint operator+(const mint& a)const{ return mint(*this) += a;}
  mint operator-(const mint& a)const{ return mint(*this) -= a;}
  mint operator*(const mint& a)const{ return mint(*this) *= a;}
  bool operator<(const mint& a)const{ return x < a.x;}
  bool operator==(const mint& a)const{ return x == a.x;}
};
ostream & operator << (ostream & out, mint const & v) {
  out << v.x;
  return out;
}

template<class T1, class T2>
T1 modpow(const T1& a, const T2 n) {
  if (n == 0) return 1;
  auto t = modpow(a, n / 2);
  t = t * t;
  if (n & 1) t = t * a;
  return t;
}

/* nCk */
template<class T> struct BiCoef {
    vector<T> fact_, inv_, finv_;
    constexpr BiCoef() {}
    constexpr BiCoef(int n) noexcept : fact_(n, 1), inv_(n, 1), finv_(n, 1) {
        init(n);
    }
    constexpr void init(int n) noexcept {
        fact_.assign(n, 1), inv_.assign(n, 1), finv_.assign(n, 1);
        for(int i = 2; i < n; i++){
            fact_[i] = fact_[i-1] * i;
            inv_[i] = -inv_[MOD%i] * (MOD/i);
            finv_[i] = finv_[i-1] * inv_[i];
        }
    }
    constexpr T com(int n, int k) const noexcept {
        if (n < k || n < 0 || k < 0) return 0;
        return fact_[n] * finv_[k] * finv_[n-k];
    }
    constexpr T fact(int n) const noexcept {
        if (n < 0) return 0;
        return fact_[n];
    }
    constexpr T inv(int n) const noexcept {
        if (n < 0) return 0;
        return inv_[n];
    }
    constexpr T finv(int n) const noexcept {
        if (n < 0) return 0;
        return finv_[n];
    }
};

// sum((-1)^(k-i)*kCi*i^n | for i in range(0, k+1))
int N, K;
BiCoef<mint> bc;
void solve() {
  cin >> N >> K;
  if (K > N) {
    cout << 0 << endl;
    return;
  }

  bc.init(1001);
  mint s = 0;
  for (int i=0; i<=K; i++) {
    mint sign = (K-i) % 2 == 1 ? -1 : 1;
    s += sign * bc.com(K, i) * modpow(mint(i), N);
  }
  s *= bc.finv(K);
  cout << s << endl;
}

int main() {
  // cout.precision(15); cout << fixed;

  solve();

  return 0;
}



Measured memory_bytes: 3132
#include<cstdio>
#include<algorithm>
using namespace std;
inline int read()
{
	int x,f=1;char c;
	while((c=getchar())<'0'||c>'9')if(c=='-')f=0;
	for(x=c-'0';(c=getchar())>='0'&&c<='9';)x=x*10+c-'0';
	return f?x:-x;
}
#define MN 100000
long long x[MN+5],ans[MN+5],n,k;
struct data{int p[MN+5];}A,B;
data operator*(const data&x,const data&y)
{
	data res;
	for(int i=1;i<=n;++i)res.p[i]=y.p[x.p[i]];
	return res;
}
int main()
{
	int m,i;
	for(n=read(),i=1;i<=n;++i)x[i]=read(),A.p[i]=B.p[i]=i;
	for(i=n;i;--i)x[i]-=x[i-1];
	m=read();scanf("%lld",&k);
	while(m--)i=read(),swap(B.p[i],B.p[i+1]);
	for(;k;k>>=1,B=B*B)if(k&1)A=A*B;
	for(i=1;i<=n;++i)printf("%lld.0\n",ans[i]=ans[i-1]+x[A.p[i]]);
}

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

typedef long long int int64;
static const int64 mod = 1000000007LL;

int64 exgcd(int64 a,int64 b,int64 &c,int64 &d)
{
	if(b == 0) {
		c = 1, d = 0;
		return a;
	}
	int64 x = exgcd(b,a % b,d,c);
	d -= c * (a / b);
	return a;
}
int64 finv(int64 x)
{
	int64 c,d;
	exgcd(x,mod,c,d);
	if(c < 0) c += mod;
	return c;
}

int a[200003];
int n;
int cnt[200003];
struct pair {
	int a,b;
	pair():a(0),b(0){}
	pair(int a,int b):a(a),b(b){}
	pair operator +(const pair &c) const {
		if(b > c.b || c.a == 0) return *this;
		if(c.b > b || a == 0) return c;
		return pair((a+c.a)%mod,b);
	}
	pair operator *(const pair &c) const {
		return pair((int64)a*c.a%mod,b+c.b);
	}
} arr[200003];
void add(int i,pair v)
{
	while(i <= n) {
		arr[i] = arr[i] + v;
		i += i&-i;
	}
}
pair sum(int i)
{
	pair ans = arr[i];i -= i&-i;
	while(i > 0) {
		ans = ans + arr[i];
		i -= i&-i;
	}
	return ans;
}
int arr2[200003];
void add2(int i,int v)
{
	while(i <= n) {
		arr2[i] = arr2[i] + v;
		i += i&-i;
	}
}
int sum2(int i)
{
	int ans = 0;
	while(i > 0) {
		ans += arr2[i];
		i -= i&-i;
	}
	return ans;
}
int64 inv[200003];
std::pair<pair,pair> calpair(int k)
{
	pair a = k == 0 ? pair(1,-1) : pair(k,0);
	pair b = k-1 == 0 ? pair(1,-1) : pair(k-1,0);
	return std::make_pair(pair(a.a*inv[b.a]%mod,a.b-b.b),pair(b.a*inv[a.a]%mod,b.b-a.b));
}
pair suf1[200003],suf2[200003]; // i/(i-1),(i-1)/i
pair pre1[200003],pre2[200003]; // i/(i-1),(i-1)/i
int main()
{
	scanf("%d",&n);
	inv[1] = 1;for(int i = 2;i <= n;++i) inv[i] = (mod-mod/i)*inv[mod%i]%mod;
	for(int i = 0;i < n;++i) {
		scanf("%d",&a[i]);--a[i];
		++cnt[a[i]];
	}
	for(int i = n-2;i >= 0;--i) {
		cnt[i] += cnt[i+1]-1;
	}
	int64 ians = 1;
	for(int i = 0;i < n;++i) {
		if(cnt[i] <= 0) {
			printf("0\n");
			return 0;
		}
		ians = ians * cnt[i] % mod;
	}
	for(int i = n-1;i >= 0;--i) {
		std::pair<pair,pair> p = calpair(cnt[i]);
		if(i == n-1) {
			suf1[i] = p.first;
			suf2[i] = p.second;
		} else {
			suf1[i] = p.first * suf1[i+1];
			suf2[i] = p.second * suf2[i+1];
		}
	}
	for(int i = 0;i < n;++i) {
		std::pair<pair,pair> p = calpair(cnt[i]);
		if(i == 0) {
			pre1[i] = p.first;
			pre2[i] = p.second;
		} else {
			pre1[i] = p.first * pre1[i-1];
			pre2[i] = p.second * pre2[i-1];
		}
	}
	/*
	for(int i = 0;i < n;++i) {
		printf("%d ", cnt[i]);
	}
	printf("\n");
	for(int i = 0;i < n;++i) {
		printf("%d;%d ", pre1[i].a, pre1[i].b);
	}
	printf("\n");
	for(int i = 0;i < n;++i) {
		printf("%d;%d ", pre2[i].a, pre2[i].b);
	}
	printf("\n");
	*/
	int64 ans = 0;
	// a[i] <= a[j] case
	for(int i = 0;i < n;++i) {
		pair val = sum(a[i]+1) * pre2[a[i]];
		assert(val.b <= 0);
		if(val.b == 0) ans += val.a;
		add(a[i]+1,pre1[a[i]]);
	}
	// a[i] > a[j] case
	memset(arr,0,sizeof(arr));
	int64 count = 0;
	for(int i = n-1;i >= 0;--i) {
		pair val = sum(a[i]) * pre2[a[i]];
		count += sum2(a[i]);
		assert(val.a == 0 || val.b <= 0);
		if(val.b == 0) ans -= val.a;
		add(a[i]+1,pre1[a[i]]);
		add2(a[i]+1,1);
	}
	ans = ans % mod * inv[2] % mod;
	ans = ians * (ans + count % mod) % mod;
	if(ans < 0) ans += mod;
	printf("%lld\n", ans);
}


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

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define REP(i,n) FOR(i,0,n)
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using mii = map<int, int>;
using msi = map<string, int>;
using pii = pair<int, int>;

const int di[] = {0,-1,0,1};
const int dj[] = {1,0,-1,0};

int main()
{
    ios::sync_with_stdio(false);

    int h, w;
    cin >> h >> w;
    string s[h];
    REP(i, h) cin >> s[i];

    queue<pii> q;
    vvi b(h, vector<int>(w, 1e9));

    int ini_kuro = 0;
    REP(i, h) REP(j, w) {
        if(s[i][j] == '#') ini_kuro++;
    }

    // startの設定
    q.emplace(0, 0);
    b[0][0] = 1;    // 塗れないので1手目とする．

    while(!q.empty()) {
        pii p = q.front(); q.pop();
        int i = p.first, j = p.second;

        // goalの設定
        if(i == h-1 && j == w-1) break;

        // update用関数
        auto update = [&](int i, int j, int x) {
            if(b[i][j] != 1e9) return;
            b[i][j] = x;
            q.push(pii(i,j));
        };
        
        // 全方向検索
        REP(dir, 4) {
            int ni = i + di[dir];
            int nj = j + dj[dir];
            if(ni < 0 || nj < 0 || ni >= h || nj >= w) continue;
            
            // 壁の設定
            if(s[ni][nj] == '#') continue;
            update(ni, nj, b[i][j] + 1);
        }
    }
    int ans = -1;
    if(b[h-1][w-1] != 1e9) ans = h*w - ini_kuro - b[h-1][w-1];

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
struct edge {
    int to;     // 辺の行き先
    int weight; // 辺の重み
    edge(int t, int w) : to(t), weight(w) { }
};
using Graph = vector<vector<int>>;
using dou =long double;
string yes="yes";
string Yes="Yes";
string YES="YES";
string no="no";
string No="No";
string NO="NO";

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define rep(i, n)         for(int i = 0; i < (int)(n); i++)
#define brep(n)           for(int bit=0;bit<(1<<n);bit++)
#define erep(i,container) for (auto i : container)
#define irep(i, n)        for(int i = n-1; i >= (int)0; i--)
#define rrep(i,m,n) for(ll i = m; i < (ll)(n); i++)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define all(x) (x).begin(),(x).end()
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define itn int
#define mp make_pair
#define sum(a) accumulate(all(a),0ll)
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<t>(n,a)));
#define vvvvector(name,t,k,l,m,n,a) vector<vector<vector<vector<t> > > > name(k,vector<vector<vector<t> > >(l, vector<vector<t> >(m, vector<t>(n,a)) ));
#define case std::cout <<"Case #" <<qqq+1<<": "
#define res resize
#define as assign
#define ffor for(;;)
#define ppri(a,b) std::cout << a<<" "<<b << std::endl
#define pppri(a,b,c) std::cout << a<<" "<<b <<" "<< c<<std::endl
#define aall(x,n) (x).begin(),(x).begin()+(n)
 
typedef long long ll;
typedef pair<int,int> P;
//typedef long long T;
const int INF = 2000000000;
const ll INF64 = 922337203685477580ll;
const ll MOD = 1000000007ll;
const dou pi=3.141592653589793;

int main(){
    int n,W;
    std::cin >> n>>W;
    //std::cout << n << std::endl;
    vvector(dp,int,n+1,12000,0);
    rep(i,n+1)dp[i][0]=0;
    std::vector<int> v(n),w(n);
    rep(i,n)std::cin >> v[i]>>w[i];
    rep(i,n){
        rep(j,10001){
            dp[i+1][j]=max(dp[i][j],dp[i+1][j]);
            dp[i][j+w[i]]=max(dp[i][j+w[i]],dp[i][j]+v[i]);
        }
    }
    int ans=0;
    rep(i,W+1){
        ans=max(ans,dp[n][i]);
    }
    std::cout << ans << std::endl;
}


Measured memory_bytes: 7688
#include <iostream>
#include <algorithm>
#include <cmath>

using namespace std;

int main()
{
    int n, a[101];
    double min;
    double sum = 0;
    int ans = 0;
    double ave;

    cin >> n;

    for (int i = 0; i < n; i++) {
        cin >> a[i];
        sum += a[i];
    }

    ave = sum / n;
    min = fabs(ave - a[0]);

    for (int i = 0; i < n; i++) {
        double num = fabs(ave - a[i]);
        
        if (min > num) {
            min = num;
            ans = i;
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
sum = 0
for i in reversed(range(1,N+1)):
    if B[i-1] <= A[i]:
        sum += B[i-1]
        A[i]-=B[i-1]
        B[i-1]=0
    else:
        sum += A[i]
        B[i-1]-= A[i]
        A[i]=0
        if B[i-1] <= A[i-1]:
            sum += B[i-1]
            A[i-1] -= B[i-1]
            B[i-1] = 0
        else:
            sum += A[i-1]
            B[i-1]-= A[i-1]
            A[i-1]=0
print(sum) 

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

#define whole(f, x, ...)                                 \
  ([&](decltype((x)) whole) {                            \
    return (f)(begin(whole), end(whole), ##__VA_ARGS__); \
  })(x)

using namespace std;
using ll = long long;

void solve() {
  double a, b, x;
  cin >> a >> b >> x;
  const double line = a * a * b / 2.0;
  if (x > line) {
    cout << atan(2 * (a * a * b - x) / (a * a * a)) * 180.0 / M_PI << endl;
  } else if (x == line) {
    cout << 45.00000000 << endl;
  } else {
    cout << atan(a * b * b / 2.0 / x) * 180.0 / M_PI << endl;
  }
}

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

  solve();
  return 0;
}


Measured memory_bytes: 384
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        // package-private
        final Scanner in = new Scanner(System.in);

        int N = in.nextInt();
        int M = in.nextInt();
        int X = in.nextInt();

        int[] cost = new int[N];
        int[][] contribution = new int[N][M];
        for(int i = 0; i < N; i++) {
            cost[i] = in.nextInt();
            for(int j = 0; j < M; j++) {
                contribution[i][j] = in.nextInt();
            }
        }

        long ans = -1;
        // Força bruta, cada bit significa que escolhi o i-ésimo livro
        for(int i = 0; i < (1 << N); i++) {
            int totalPrice = 0;
            int[] understanding = new int[M];

            for(int j = 0; j < N; j++) {
                // Caso a i-ésima posição é zero, retorna 0
                // 110 & 010 = 2; 110 & 001 = 0
                if((i & (1 << j)) > 0) {
                    // escolhido o j-ésimo livro
                    totalPrice += cost[j];
                    for(int k = 0; k < M; k++) {
                        understanding[k] += contribution[j][k];
                    }
                }
            }

            boolean valid = true;
            for(int j = 0; j < M; j++) {
                if(understanding[j] < X) {
                    valid = false;
                    break;
                }
            }

            if(valid) {
                if(ans == -1) {
                    ans = totalPrice;
                }
                else {
                    ans = Math.min(ans, totalPrice);
                }
            }
        }

        System.out.println(ans);
    }
}

Measured memory_bytes: 37080