akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <algorithm>
#include <ctime>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cassert>
#include <bitset>
#include <list>
#include <cstdio>
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <math.h>
#include <cmath>
#include <tuple>
#include <cassert>
#include <array>
#include <iomanip>

using namespace std;
using ll = long long;
using pii = pair<int, int>;
using ti = tuple<int, int, int>;

const double eps=1e-14;
const int mod = 1e9 + 7;
const int inf = ((1<<30)-1);
const ll linf = (1LL<<60);

int h[100005];
bool ans[100005];


int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    for(int i=0; i<n; i++)
    {
      cin >> h[i];
      ans[i] = true;
    }
    for(int i=0; i<m; i++)
    {
      int a, b;
      cin >> a >> b;
      a--; b--;
      if(h[a] > h[b]) ans[b] = false;
      else if(h[a] == h[b]) ans[a] = ans[b] = false;
      else ans[a] = false;
    }
    int answer = 0;
    for(int i=0; i<n; i++)
    {
      if(ans[i]) answer++;
    }
    cout << answer << endl;
    return 0;
}


Measured memory_bytes: 4104
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt(),k=sc.nextInt();
		int[] p_array = new int[n];
		double[] ex = new double[1001];
		for(int i=0;i<n;i++) 	p_array[i]=sc.nextInt();
		for(int i=1;i<1001;i++) ex[i] = (double)(i+1)/2;
		double sum=0;
		for(int i=0;i<k;i++) sum+=ex[p_array[i]];
		double max=sum;
		for(int top=0;top+k<=n-1;top++) {
			sum-=ex[p_array[top]];
			sum+=ex[p_array[top+k]];
			if(sum>=max) max=sum;
		}
		System.out.printf("%.10f\n",max);
	}
}

Measured memory_bytes: 79736
// input macro
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 $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")
    };
}

// body
fn main() {
    input! {
        n: usize,
        a: usize,
        b: usize
    };
    println!("{}", std::cmp::min(n * a, b));
}


Measured memory_bytes: 4352
n = int(input())
alp = [chr(i) for i in range(97, 97+26)]
edge = [0] * 15
for i in range(1, 15):
    edge[i] = edge[i - 1] + pow(26, i)

d = 0
length = 0
for e in edge[::-1]:
    if n - e > 0:
        d = n - e - 1 #!
        length = edge.index(e) + 1 # 文字数
        break

digit = []
for _ in range(length):
    digit.append(d % 26)
    d //= 26

res = ''
for di in digit:
    res += alp[di]

print(res[::-1])

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

using i64 = int64_t;

int main(){
    int m, k;
    cin >> m >> k;
    int n=1;
    for(int i=0;i<m;++i)n<<=1;
    if(k >= n){
        cout << -1 << endl;
    }else if(k == 0){
        for(int i=0;i<n;++i){
            if(i)cout << " ";
            cout << i << " " << i;
        }
        cout << endl;
    }else if(n <= 2){
        cout << -1 << endl;
    }else{
        deque<bool> used(n);
        vector<int> ans;
        for(int i=0;i<n;++i){
            if(used[i])continue;
            int j = i ^ k;
            ans.push_back(i);
            ans.push_back(j);
            used[i] = true;
            used[j] = true;
            int a = i + 1;
            while(a < n && used[a])a++;
            int b = a ^ k;
            if(j >= n || a >= n || b >= n){
                cout << -1 << endl;
                return 0;
            }
            ans.push_back(a);
            ans.push_back(b);
            ans.push_back(j);
            ans.push_back(i);
            ans.push_back(b);
            ans.push_back(a);
            used[a] = true;
            used[b] = true;
        }

        for(int i=0;i<(int)ans.size();++i){
            if(i)cout << " ";
            cout << ans[i];
        }
        cout << endl;
    }

    return 0;
}

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

using namespace std;

int main(){
  string s;
  cin >> s;
  for(int i=0; i<3; i++) {
  	if(s[i]=='1') cout << 9 ;
  	else cout << 1 ;
  }
  cout << endl;
  
  return 0;
}

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

int main(){
  int N,W;
  cin>>N>>W;
  int v[N];
  int w[N];
  for(int i=0;i<N;i++){
    cin>>v[i]>>w[i];
  }
  int data[W];
  for(int i=0;i<W+1;i++){
    data[i]=0;
  }
  for(int i=0;i<N;i++){
    for(int j=0;j<W+1;j++){
      if(j>=w[i]){
        if(data[j]<=data[j-w[i]]+v[i]){
          data[j]=data[j-w[i]]+v[i];
        }
      }
    }
  }
  int max=0;
  for(int i=0;i<W+1;i++){
    if(max<data[i]){
      max=data[i];
    }
  }
  cout<<max<<endl;
  return 0;
}


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

#define print cout <<
#define printl(s) cout << s << endl;
#define rep(i,n) for (int i = 0; i < (n); ++i)
using ll = long long;

const ll modseed = pow(10,9) + 7;

template <typename T>
vector<T> getValues(int num){
    vector<T> values(num);
    for(int i=0;i<num;i++){
        cin >> values.at(i);
    }
    return values;
}

ll calculateMod(ll n, ll expo, ll modSeed){
  ll ret = 1;
  rep(i, expo){
    ret *= n;
    ret = ret%modSeed;
  }
  return ret;
}

int main(){
    ll N;
    cin >> N;
    vector<ll> inputs(N);
    vector<ll> s(N+1,0);
    rep(i, N){
      cin >> inputs.at(i);
      s.at(i+1) = s.at(i) + inputs.at(i);
    }

    ll ans = 0;
    rep(i,N){
      ll sum = (s.at(N) - s.at(i+1))%modseed;
      ans += sum* inputs[i];
      ans %= modseed;
    }
    
    printl(ans);
}


Measured memory_bytes: 6392
#include<iostream>
#include<algorithm>
#include<cmath>
#include<string>
#include<vector>
using namespace std;
using ll =long long;
int main() {
	ll N;
	cin >> N;
	
	vector<ll>A;
	vector<ll>B;
	vector<ll>C;
	ll g;
	for (int i = 0; i < N; i++) {
		cin >> g;
		A.push_back(g);
		cin >> g;
		B.push_back(g);	
		C.push_back(A[i]%B[i]);	
	}
	ll sum=0;
	for (ll i = N-1; i>=0; i--) {

		if (C[i] != 0) {

			sum += B[i] - C[i];
		}
		if (i - 1 >= 0) {

			C[i - 1] = (A[i - 1] + sum) % B[i - 1];

		}
	}

	cout << sum;

}


Measured memory_bytes: 2912
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n) ; i++)
#define rrep(i,n) for(int i = n-1; i >= 0 ; i--)
typedef long long ll;
constexpr auto INFI = 2147483647;
const ll INFL = 9223372036854775807;

int main(){
	int x, n, tmp, tmp_dist;
	int min_dist = INFI;
	int ans = INFI;
	vector<bool> num_list(102, true);
	cin >> x >> n;
	rep(i,n){
		cin >> tmp;
		num_list[tmp] = false;
	}
	rep(i, 102){
		if (!num_list[i]) continue;
		tmp_dist = abs(i-x);
		if (tmp_dist < min_dist) {
			ans = i;
			min_dist = tmp_dist;
		} else if (abs(x - i) == min_dist) {
			ans = min(ans, i);
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3564
#include<iostream>
#include <cmath>
using namespace std; int l[100000]; int k[100000];
int main(){
	int n; cin >> n;
	for (int i=0; i<n; i++){
	 	cin >> l[i];
	}
	int zb=0; k[0]=0; k[1]=abs(l[0]-l[1]);
	for (int i=2; i<n; i++){
	
			k[i]=min(k[i-2]+abs(l[i]-l[i-2]),k[i-1]+abs(l[i-1]-l[i]));
	}
	cout << k[n-1];
	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <cmath>
#include <string>
#include <map>

#define pb push_back
#define mp make_pair

using namespace std;

typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef unsigned long long ull;
typedef long long ll;

int main() {
	int n, a, b;
	cin >> n >> a >> b;
	
	string s;
	cin >> s;
	
	int passed = 0;
	int current_b_rank = 0;
	for (int i = 0; i < s.size(); ++i) {
		char c = s.at(i);
		
		if (c == 'a') {
			if (passed < (a+b)) {
				passed++;
				cout << "Yes";
			} else {
				cout << "No";
			}
		} else if (c == 'b') {
			current_b_rank++;
			if (passed < (a+b) && current_b_rank <= b) {
				passed++;
				cout << "Yes";
			} else {
				cout << "No";
			}
		} else {
			cout << "No";
		}
		
		cout << endl;
	}
  return 0;
}

Measured memory_bytes: 896
import java.util.*;
public class Main {

    public static void main(String[] args) {
        Scanner scan=new Scanner(System.in);

        int n=scan.nextInt();
        int a[]=new int[n];
        int max=0,min=1000;
        for(int i=0;i<n;i++){
            a[i]=scan.nextInt();
            if(a[i]>max)
                max=a[i];
            if(a[i]<min)
                min=a[i];
        }
        System.out.println(max-min);

    }
}

Measured memory_bytes: 21588
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
int main(int argc, char const *argv[]) {
    int n;
    cin >> n;
    vector<int> h(n);
    REP(i,n) cin >> h[i];
    ll dp[n+10];
    REP(i,n+10) dp[i] = INF;
    dp[0] = 0;
    dp[1] = abs(h[1]-h[0]);
    for (int i = 2; i < n; ++i) dp[i] = min(dp[i-1] + abs(h[i]-h[i-1]), dp[i-2] + abs(h[i]-h[i-2]));
    cout << dp[n-1] << std::endl;
    //REP(i,n) cout << i << " = " << dp[i] << std::endl;
    return 0;
}

Measured memory_bytes: 1408
import sys
import numpy as np
from collections import defaultdict



#input = sys.stdin.readline

def main():
    N, K = map(int,input().split())
    A = list(map(int,input().split()))
    A = [0] +A  #transporter
    visited = [0] * (N+1)
    town = 1
    cycle = 0
    for i in range(1,K+1):
        town = A[town]
        if visited[town] ==0:
            visited[town] = i
        else:
            cycle = i - visited[town]
            place = (K - visited[town]) % cycle + visited[town]
            for j in range(N+1):
                if visited[j] == place:
                    print(j)
                    exit()
    print(town)




if __name__ == "__main__":
    main()

Measured memory_bytes: 51036
/**
 * @copyright (c) 2020 Daisuke Hashimoto
 */

#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
using Pair = pair<int32_t, int32_t>;

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

  int64_t N, K;
  cin >> N >> K;
  int64_t result;
  if (N <= 0) {
    result = N;
  } else {
    const int64_t p = N % K;
    result = min(p, K - p);
  }
  cout << result << endl;

  return 0;
}


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

int main()
{
  int n;
  cin>>n;
  string s;
  cin>>s;
  for(int i=0;i<s.size();i++)
    s[i]=char((int(s[i])-65+n)%26+65);
  cout<<s<<endl;
  return 0;
}
	

Measured memory_bytes: 256
import Data.Char
import Data.List

main = interact $ unlines . map (show' . sum . map read' . words) . tail . lines
 where
  read' [] = 0
  read' (x:xs)
   | isDigit x = digitToInt x * alphaToInt (head xs) + read' (tail xs)
   | otherwise = alphaToInt x + read' xs

  show' = concat . insertUnit . normalize . show

  alphaToInt c = case c of {'m'->1000; 'c'->100; 'x'->10; 'i'->1}
  normalize = reverse . take 4 . (++ "000") . reverse
  insertUnit = map simplify . transpose . (: ["mcxi"])
   where simplify [n,c] = if n=='0' then [] else (if n=='1' then [c] else [n,c])

Measured memory_bytes: 4512
#pragma region
#include <bits/stdc++.h>
using namespace std;
inline void ci(void){
  return;
}
template <typename First, typename... Rest>
void ci(First& first, Rest&... rest){
  cin >> first;
  ci(rest...);
  return;
}
inline void co(void){
  cout << "\n";
  return;
}
template <typename First, typename... Rest>
void co(First first, Rest... rest){
  cout << first << " ";
  co(rest...);
  return;
}
#define ll long long
#define ld long double
#define st string
#define dl double
#define wh while
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define tp tuple
#define ft first
#define sc second
#define ve vector
#define tos to_string
#define len length
#define rt return 0
#define repi(i, m, n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i, n) repi(i, 0, n)
#define sz(v) ((int)(v).size()) 
#define ea(i, n) for(auto&& i: n)
#define so(n) sort(n.begin(), n.end())
#define sp(n) cout << fixed << setprecision(n)
#pragma endregion
// abs 絶対値, rtsq ルート, pow(a, n) aのn乗, int 2*10^9

int main() {
  int N, M, ac = 0, wa = 0;
  ci(N, M);
  map<int, pair<int, bool>> A;
  rep(i, M){
    int p;
    st S;
    ci(p, S);
    if(A.count(p) && S == "WA" && A[p].sc == false){
      A[p].ft++;
    }
    else if(A.count(p) && S == "AC"){
      A[p].sc = true;
    }
    else if(A.count(p) == false && S == "AC"){
      A[p] = mp(0, true);
    }
    else if(A.count(p) == false && S == "WA"){
      A[p] = mp(1, false);
    }
  }
  ea(i, A){
    if(i.sc.sc == true){
      wa += i.sc.ft;
      ac++;
    }
  }
  co(ac,wa);
}

Measured memory_bytes: 6528
#![allow(clippy::needless_range_loop)]
#![allow(unused_macros)]
#![allow(dead_code)]

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        #[allow(unused_mut)]
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

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

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

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

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

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

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

fn set_bits(i: u32) -> u32 {
    let i = i - ((i >> 1) & 0x55555555);
    let i = (i & 0x33333333) + ((i >> 2) & 0x33333333);
    (((i + (i >> 4)) & 0x0F0F0F0F) * 0x01010101) >> 24
}

fn main() {
    input! {
        n: usize,
        x: chars
    }
    let set = x.iter().filter(|x| **x == '1').count();
    let exp_2_mod_hi: Vec<usize> = (0..n)
        .scan(1, |state, _| {
            let current = *state;
            *state = *state * 2 % (set + 1);
            Some(current)
        })
        .collect();
    let exp_2_mod_low: Vec<usize> = if set > 1 {
        (0..n)
            .scan(1, |state, _| {
                let current = *state;
                *state = *state * 2 % (set - 1);
                Some(current)
            })
            .collect()
    } else {
        vec![]
    };
    let x_mod_hi = x.iter().rev().zip(&exp_2_mod_hi).fold(0, |acc, (x, y)| {
        (acc + y * (*x == '1') as usize) % (set + 1)
    });
    let x_mod_low = x.iter().rev().zip(&exp_2_mod_low).fold(0, |acc, (x, y)| {
        (acc + y * (*x == '1') as usize) % (set - 1)
    });
    for (c, key) in x.iter().zip((0..n).rev()) {
        let mut r = if *c == '1' {
            if set == 1 {
                println!("0");
                continue;
            }
            (x_mod_low + (set - 1) - exp_2_mod_low[key]) % (set - 1)
        } else {
            (x_mod_hi + exp_2_mod_hi[key]) % (set + 1)
        } as u32;
        let mut cnt = 1;
        while r > 0 {
            r = r % set_bits(r);
            cnt += 1;
        }
        println!("{}", cnt);
    }
}


Measured memory_bytes: 6388
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] ball = new int[n];
        int[] count = new int[n];
        for (int i = 0; i < n; i++) {
            ball[i] = sc.nextInt();
            count[ball[i] - 1] ++;
        }

        long sum = 0;
        for (int j = 0; j < n; j++) {
            long t = count[j];
            if(t > 1){
                sum += t * (t - 1) / 2;
            }
        }

        for (int i = 0; i < n; i++) {
            long t = count[ball[i] - 1];
            long r = sum - t + 1;

            System.out.println(r);
        }
    }
}

Measured memory_bytes: 102016
#include <iostream>

using namespace std;

int main() {
  string s;
  cin >> s;
  int l, r;
  for (int i = 0;; i++) {
    if (s[i] == 'A') {
      l = i;
      break;
    }
  }
  for (int i = s.size() - 1;; i--) {
    if (s[i] == 'Z') {
      r = i;
      break;
    }
  }
  cout << r - l + 1 << endl;
  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin>>N;
  vector<int> S(N);
  for(int i=0;i<N;i++){
    cin>>S.at(i);
  }
  sort(S.begin(),S.end());
  cout<<S.at(S.size()-1)-S.at(0)<<endl;
}

Measured memory_bytes: 256
N = int(input())
K = int(input())

ans = None
for i in range(2 ** N):
    tmp = 1
    for j in range(N):
        if ((i >> j) &1):
            tmp += K
        else:
            tmp *= 2
    if ans == None:
        ans = tmp
    else:
        ans = min(ans, tmp)

print (ans)



Measured memory_bytes: 3060
#define _CRT_SECURE_NO_WARNINGS 1
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <queue>
#include <sstream>
#include <climits>
#include <cmath>
#include <functional>
#include <map>
#include <stack>
using namespace std;
#define M_PI 3.141592
#define FOR(i,n) for(int i=0;i<(int)n;i++)
#define FORI(i,k,n) for(int i=k;i<(int)n;i++)
#define toRad 2.0*M_PI/360.0
#define inin(x) int x;cin>>x;
#define all(x) x.begin(),x.end()
#define debug(x) cout<<#x<<" "<<x<<endl;
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define EPS 1e-12
#define pri_max 60000
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };

/*
bool memo[pri_max] = {};
vector<int> pri;
void calc()
{
	for (int i = 2; i < pri_max; i++)
	{
		if (memo[i] == false)
		{
			pri.push_back(i);
			for (int l = i; l < pri_max; l += i)
			{
				memo[l] = true;
			}
		}
	}
}*/

int main()
{
	string s;
	while (cin >> s)
	{
		FOR(i, s.size())
		{
			if (s[i] == '@')
			{
				FOR(l, s[i + 1] - '0')
				{
					cout << s[i + 2];
				}
				i += 2;
			}
			else
			{
				cout << s[i];
			}
		}
		cout << endl;
	}
}

Measured memory_bytes: 1172
//subsetSumが間違っているのかと思って簡単なのに書き直したが、
//test1WA.cppと同じテストケースでWA
//mainやbool f()周辺を間違えているのだろうか

#include <bits/stdc++.h>

#define MAX_S 8000

using namespace std;

bool subsetSum(vector<int>::iterator a, int n, int s, int m)
{
    if (s == 0) {
        return true;
    }
    bool *reachable = new bool[MAX_S+1]();
    reachable[0] = true;
    for (int i = 0; i < n; i++) {
        for (int j = MAX_S; j >= 0; j--) {
            if (j >= a[i]) {
                reachable[j] |= reachable[j-a[i]];
            }
        }
    }
    return reachable[s];
}

bool f(vector<int>::iterator a, int n, int x)
{
    int m = 0;
    for (int i = 0; i < n; i++) {
        m += a[i];
    }
    if (m < x || (m-x) % 2 == 1) {
        return false;
    }
    return subsetSum(a, n, (m-x) / 2, MAX_S / 64);
}

int main(void)
{
    string s;
    int x, y;

    cin >> s;
    cin >> x >> y;
    //cout << "s: " << s << ", size: " << s.size() << endl;

    vector<int> dxs;
    vector<int> dys;

    auto it = s.begin();
    while (*it == 'F') {
        it++;
        x--;
    }
    //cout << "skipped " << it - s.begin() << " leading F's" << endl;
    int direction = 1; // 1: parallel to x axis, -1: parallel to y axis
    int distance = 0;
    for (; it <= s.end(); it++) {
        if (it == s.end() || *it == 'T') {
            if (direction == 1) {
                dxs.push_back(distance);
            } else if (direction == -1) {
                dys.push_back(distance);
            }
            direction *= -1;
            distance = 0;
        } else if (*it == 'F') {
            distance++;
        }
    }

    /*
    cout << "dxs:" << endl;
    for (auto it = dxs.begin(); it < dxs.end(); it++) {
        cout << *it << endl;
    }

    cout << "dys:" << endl;
    for (auto it = dys.begin(); it < dys.end(); it++) {
        cout << *it << endl;
    }
    */

    if (f(dxs.begin(), dxs.size(), x) && f(dys.begin(), dys.size(), y)) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>

using namespace std;

typedef pair<long long int, long long int> P;

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

int main(){
	
	long long int K, A, B;
	cin >> K >> A >> B;
	
	if(A > K + 1){
		cout << K + 1 << endl;
		return 0;
	}
	
	if(B - A < 2){
		cout << K + 1 << endl;
		return 0;
	}
	
	K -= A - 1;
	int rem = 0;
	if(K % 2){
		rem = 1;
	}
	K /= 2;
	
	cout << A + (B - A) * K + rem << endl;
	
	return 0;
}


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

using namespace std;
void F(bool x){cout << (x?"first":"second")<<endl;exit(0);}
int a[123456];
int main()
{
    int n,mx1,mx2,mx3;
    cin >> n ;
    a[0]=0;
    for (int i=1;i<=n;i++)
    {
        cin >> a[i];
    }
    sort(a,a+n+1,greater<int>());
    int t=0;
    for (int i=1;i<=n;i++)
    {
        if((a[i-1]-a[i])&1)
        {
            t^=n-i+1;
        }
    }
    F(t);
    return 0;
}

Measured memory_bytes: 640
"use strict";
var GET=(function(){function f(s){return new g(s);}function g(s){this._s=s.trim().split("\n");this._y=0;}g.prototype.a=function(f){var s=this._s, y=this._y, r;if(typeof s[y]==="string")s[y]=s[y].split(" ").reverse();r=s[y].pop();if(!s[y].length)this._y++;return f?r:+r;};g.prototype.l=function(f){var s=this._s[this._y++].split(" ");return f?s:s.map(a=>+a);};g.prototype.m=function(n,f){var r=this._s.slice(this._y,this._y+=n).map(a=>a.split(" "));return f?r:r.map(a=>a.map(a=>+a));};g.prototype.r=function(n,f){var r=this._s.slice(this._y,this._y+=n);return f?r:r.map(a=>+a);};return f;})();
var o=GET(require("fs").readFileSync("/dev/stdin","utf8"));
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill(0).map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill(0).map(x=>"+r+")";return eval(r);}
function gcd(a,b){return b?gcd(b,a%b):a;}

console.log(main());
function main(){
  var n = o.a();
  var m = o.a();
  var a = o.l();
  var g = a[0];
  var t = f(a[0]);
  for(var i = 1; i < n; i++){
    var t2 = f(a[i]);
    if(t !== t2)return 0;
    g = a[i]/gcd(g,a[i])*g;
    if(g > m*2)return 0;
  }
  return (m+g/2)/g|0;
}

function f(x){
  var r = 0;
  while(x%2 === 0)r++, x >>= 1;
  return r;
}

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

int N, mod = 1000000007;
int dp[109][256];
bool s[256];

bool hantei(string S) {
	if (S.substr(0, 3) == "012" || S.substr(1, 3) == "012") return true;
	for (int i = 0; i < 3; i++) {
		swap(S[i], S[i + 1]);
		if (S.substr(0, 3) == "012" || S.substr(1, 3) == "012") return true;
		swap(S[i], S[i + 1]);
	}
	return false;
}

void init() {
	for (int i = 0; i < 256; i++) {
		string V = "";
		for (int j = 0; j < 4; j++) V += ('0' + ((i / (1 << (2 * j))) % 4));
		if (hantei(V) == true) s[i] = true;
	}
}

int main() {
	cin >> N; init();
	if (N == 3) {
		cout << "61" << endl;
		return 0;
	}

	for (int i = 0; i < 256; i++) {
		if (s[i] == false) dp[4][i] = 1;
	}
	for (int i = 4; i < N; i++) {
		for (int j = 0; j < 256; j++) {
			for (int k = 0; k < 4; k++) {
				int r = ((j % 64) * 4) + k; if (s[r] == true) continue;
				dp[i + 1][r] += dp[i][j];
				dp[i + 1][r] %= mod;
			}
		}
	}
	
	int sum = 0;
	for (int i = 0; i < 256; i++) {
		sum += dp[N][i];
		sum %= mod;
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 3656
using System;
using static System.Console;

namespace AtCoder172
{
    class Program
    {
        static void Main(string[] args)
        {
            SolveA();
        }

        static void SolveA()
        {
            var a = int.Parse(ReadLine());
            WriteLine(a + a * a + a * a * a);
        }
    }
}

Measured memory_bytes: 27376
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii = pair<int,int>;
using pli = pair<ll,int>;
using pll = pair<ll,ll>;
using vpii = vector<pii>;
using vpli = vector<pli>;
using vpll = vector<pll>;

#define rep(i, n) for(int i=0;i<(int)n;i++)
#define rep2(i, s, n) for(int i=(s);i<(int)n;i++)
int INF=1e9+7;

int main() {
  int N;
  cin >> N;
  int k=0;
  for(int i=1;i*(i-1)<=2*N;i++) {
    if(i*(i-1)==2*N) k=i;
  }
  if(!k) cout << "No" << endl;
  else {
    cout << "Yes" << endl;
    cout << k << endl;
    vvi a(k,vi(k-1));
    rep(i,k-1) a[0][i]=i+1;
    rep2(i,1,k) {
      rep(j,i) a[i][j]=a[j][i-1];
      rep2(j,i,k-1) a[i][j]=a[i-1][k-2]+j-i+1;
    }
    rep(i,k) {
      cout << k-1 << ' ';
      rep(j,k-1) {
        cout << a[i][j] << ' ';
      }
      cout << endl;
    }
  }
}

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

typedef long long ll;
typedef pair<ll, ll> P;


#define rep(i,n) for(ll (i)=0; (i)<(ll)(n); (i)++)
#define frep(i,m,n) for(ll (i)=(m); (i)<=(ll)(n); (i)++)
#define rrep(i,n) for(ll (i)=(n)-1; (i)>-1; (i)--)
#define frrep(i,m,n) for(ll (i)=(n); (i)>(ll)(m); (i)--)
#define ALL(x) (x).begin(), (x).end()

const ll INF = 100100100100100100;
const ll MOD = 1000000007;

// get abs
ll my_abs(ll a);
// a^n
ll a_n(ll a, ll n);
// get gcd
ll my_gcd(ll a, ll b);
// a^(-1) % MOD 
ll inv(ll a);
// (a+b+c)%MOD
ll madd(ll a, ll b, ll c);
// (a-b)%MOD
ll msub(ll a, ll b);
// (a*b*c)%MOD
ll mtime(ll a, ll b, ll c);


int main() {
    ll n;
    cin >> n;
    map<ll, ll> a, b;
    rep(i, n) {
        ll v; cin >> v;
        if((i%2) == 0) {
            if(a.count(v)) a[v]++;
            else a[v] = 1;
        }
        else {
            if(b.count(v)) b[v]++;
            else b[v] = 1;
        }
    }
    vector<P> odd, even; // 個数、数
    for(auto p: a) {
        odd.push_back(make_pair(p.second, p.first));
    }
    for(auto p: b) {
        even.push_back(make_pair(p.second, p.first));
    }
    sort(ALL(odd), greater<P>());
    sort(ALL(even), greater<P>());
    if(odd[0].second != even[0].second) {
        cout << n-odd[0].first-even[0].first << endl;
    }
    else {
        if(odd.size() == 1 && even.size() == 1) {
            cout << n/2 << endl;
        }
        else if(odd.size() == 1) {
            cout << n-odd[0].first-even[1].first << endl;
        }
        else if(even.size() == 1) {
            cout << n-odd[1].first-even[0].first << endl;
        }
        else {
            ll o, e;
            o = n-odd[0].first-even[1].first;
            e = n-odd[1].first-even[0].first;            
            cout << min(o, e) << endl;
        }
    }
    return 0;
}

ll my_abs(ll a) {
    if(a >= 0) return a;
    else return -1 *a;
}

ll a_n(ll a, ll n) { 
    if(n == 0) return 1;
    
    ll ret = a, count = 1;
    while(count * 2 < n) {
        ret *= ret;
        count *= 2;
    }
    if(count == n) return ret;
    else return (ret * a_n(a, n-count));
}

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

ll inv(ll a) {
    return a_n(a, MOD-2);
}

ll madd(ll a, ll b, ll c) {
    ll ret = (a+b) % MOD;
    return (ret+c) % MOD;
}

ll msub(ll a, ll b) {
    if(a < b) return (a-b+MOD) % MOD;
    else return (a-b) % MOD;
}

ll mtime(ll a, ll b, ll c) {
    ll ret = (a*b) % MOD;
    return (ret*c) % MOD;
}


Measured memory_bytes: 8824
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
using namespace std;

int main()
{
        int N;
        cin >> N;
        long long int a[100010] = {0};
        for(int i = 0; i < N; i++) cin >> a[i];

        long long int res = 0;
        for(int i = 0; i < N; i++)
        {
                res = res ^ a[i];
        }

        if(res == 0) cout << "Yes" << endl;
        else cout << "No" << endl;
        return 0;
}

Measured memory_bytes: 1024
import java.io.BufferedReader
import java.io.InputStream
import java.io.InputStreamReader
import java.io.PrintWriter
import java.lang.Exception
import java.util.*

fun PrintWriter.solve(sc: FastScanner) {
    val a = sc.nextInt()
    val b = sc.nextInt()
    val c = sc.nextInt()
    println(if (a * b * c == 5 * 5 * 7) "YES" else "NO")
}

fun main() {
    val writer = PrintWriter(System.out, false)
    writer.solve(FastScanner(System.`in`))
    writer.flush()
}

class FastScanner(s: InputStream) {
    private var st = StringTokenizer("")
    private val br = BufferedReader(InputStreamReader(s))

    fun next(): String {
        while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())

        return st.nextToken()
    }

    fun nextInt() = next().toInt()
    fun nextLong() = next().toLong()
    fun nextLine() = br.readLine()
    fun nextDouble() = next().toDouble()
    fun ready() = br.ready()
}


Measured memory_bytes: 34288
/*
	http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0003
	Is it a Right Triangle?
*/

#include <stdio.h>
int main(void)
{
	int a,b,c;
	int n,i;
	scanf("%d",&n);

	for (i = 0; i < n && i < 1000; i++)
	{
		scanf("%d %d %d", &a, &b, &c);

		if (a*a + b*b == c*c || b*b + c*c == a*a || c*c + a*a == b*b)
		{
			printf("YES\n");
		}else{
			printf("NO\n");
		}

	}

	return 0;
}

Measured memory_bytes: 580
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define mp make_pair
#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define REP(i, s, n) for(int i = s; i < n; i++)
#define rRep(i, n) for(int i = n - 1; i >= 0; i--)
#define pii pair<int, int>
#define vii vector<pair<int, int>>
#define vi vector<int>
#define all(x) (x).begin(), (x).end()
#define endl "\n"

const int MAXN = 1e5 + 10;
int n, mat[MAXN][3], dp[MAXN][3];

int32_t main() {
    FAST
    cin >> n;
    memset(dp, -1, sizeof(dp));
    REP(i, 0, n)
        cin >> mat[i][0] >> mat[i][1] >> mat[i][2];

    dp[0][0] = mat[0][0], dp[0][1] = mat[0][1], dp[0][2] = mat[0][2];
    REP(i, 1, n) {
        dp[i][0] = mat[i][0] + max(dp[i - 1][1], dp[i - 1][2]);
        dp[i][1] = mat[i][1] + max(dp[i - 1][0], dp[i - 1][2]);
        dp[i][2] = mat[i][2] + max(dp[i - 1][0], dp[i - 1][1]);
    }

    cout << max({dp[n - 1][0], dp[n - 1][1], dp[n - 1][2]}) << endl;
}

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

int main()
{
  int N, Sum=0, Sum2=0, Sum3=0;
  cin >> N;
  vector<int> X(N);
  rep(i, N){
    cin >> X.at(i);
    Sum+=X.at(i);
  }
  rep(i, N) Sum2+=(X.at(i)-(Sum/N))*(X.at(i)-(Sum/N));
  rep(i, N) Sum3+=(X.at(i)-(Sum/N)-1)*(X.at(i)-(Sum/N)-1);
  cout << min(Sum2, Sum3) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fr(x) scanf("%d", &x)
using namespace std;

int n, c[512], s[512], f[512];

signed main(){
	fr(n);
	for(int i=1; i<n; ++i) {
		fr(c[i]);
		fr(s[i]);
		fr(f[i]);
	}
	for(int i=1; i<=n; ++i) {
		int ans = 0;
		for(int j=i; j<n; ++j) {
			if(ans < s[j]) ans = s[j];
			while(ans % f[j]) ++ans;
			ans += c[j];
		}
		printf("%d\n", ans);
	}
	return 0;
}

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

int main() {
  int N;
  cin >> N;
  int fx = 0;
  int n = N;
  for(int i = 0; i < 8; i++){
    int X = n % 10;
    fx += X;
    n = n / 10;
    if(n == 0)
      break;
  }
  if(N % fx == 0)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <algorithm>
#include <random>
#include <chrono>
#include <iomanip>
#define lint unsigned long long int
#define FOR(x, to) for(int x=0; x<(int)(to); x++)
#define DUMP(ar) for(auto itd=begin(ar); itd != end(ar); itd++) cout << "["s << itd - begin(ar) << "]:"s << *itd << endl
#define DUMPL(ar) for(auto itd=begin(ar); itd != end(ar); itd++) { cout << *itd; if(end(ar)-itd > 1) cout << ' '; } cout << endl
#define COUT(x) cout << (x) << endl
#define VCIN(ar) for(auto &vcin: (ar)) cin >> vcin
#define ALL(ar) ar.begin(), ar.end()
#define LOOPD(i) cout << "ループ["s << i << "]回目---------------"s << endl
using namespace std;
// lint:64ビット 10^19

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

    int n;
    cin >> n;
    vector<string> s(n);
    vector<int> t(n);
    for(int i=0; i<n; i++){
        cin >> s[i] >> t[i];
    }
    string x;
    cin >> x;

    int sum=0;
    bool flag = false;
    for(int i=0; i<n; i++){
        if(flag){
            sum += t[i];
        }else{
            if(s[i] == x){
                flag = true;
            }
        }
    }

    COUT(sum);

    return 0;
}

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

int main() {
  int N, F;
  cin >> N;
  F = 0;
  string S;
  for(int i = 0; i < N; i++){
  	cin >> S;
    if(S == "Y"){
    	F = 1;
      	break;
    }
  }
  if(F == 0){
  	cout << "Three" << endl;
  }else{
  	cout << "Four" << endl;
  }
}


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

long long C(int n, int k) {
    if(k == 0 || k == n) {
        return 1;
    }
    long long res = 1;
    if(k > n-k) k = n-k;
    for(int i = 0; i < k; i++) {
        res *= (n-i);
        res /= (i+1);
    }
    return res;
}

int main() {
    int n, m;
    cin >> n >> m;
    long long sum = 0;
    if(n < 2) {
        sum += 0;
    } else {
        sum += C(n, 2);
    }
    if(m < 2) {
        sum += 0;
    } else {
        sum += C(m, 2);
    }
    cout << sum << endl;

}

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

public class Main {
	
	static class Dice {
		
		private int[] sides;
		private int top;
		private int north;
		private int east;
		private int south;
		private int west;
		private int bottom;
		
		private static Dice getDice(String line) {
			Dice dice = new Dice();
			dice.top = 0;
			dice.north = 4;
			dice.east = 2;
			dice.south = 1;
			dice.west = 3;
			dice.bottom = 5;
			String[] sides = line.split(" ");
			dice.sides = new int[sides.length];
			for (int i = 0; i < sides.length; i++) {
				dice.sides[i] = Integer.parseInt(sides[i]);
			}
			return dice;
		}
		
		private static int roll(Dice dice, String line) {
			int top = dice.top;
			int north = dice.north;
			int east = dice.east;
			int south = dice.south;
			int west = dice.west;
			int bottom = dice.bottom;
			int tmp;
			
			char[] operations = line.toCharArray();
			for (char operation : operations) {
				switch (operation) {
				case 'N':
					tmp = south;
					south = bottom;
					bottom = north;
					north = top;
					top = tmp;
					break;
				case 'E':
					tmp = west;
					west = bottom;
					bottom = east;
					east = top;
					top = tmp;
					break;
				case 'S':
					tmp = north;
					north = bottom;
					bottom = south;
					south = top;
					top = tmp;
					break;
				case 'W':
					tmp = east;
					east = bottom;
					bottom = west;
					west = top;
					top = tmp;
					break;
				}
			}
			dice.top = top;
			dice.north = north;
			dice.east = east;
			dice.south = south;
			dice.west = west;
			dice.bottom = bottom;
			return dice.sides[top];
		}
	}

	public static void main(String[] args) {
		try {
			BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
			String line = input.readLine();
			String roll = input.readLine();
			
			Dice dice = Dice.getDice(line);
			System.out.println(dice.roll(dice, roll));
			
			input.close();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}

Measured memory_bytes: 17100
def counter(x):
    if x == 0:
        return 0
    return counter(x >> 1) + (x & 1)


N = int(input())
A = [0 for i in range(20)]
x = [[0 for i in range(20)] for j in range(20)]
y = [[0 for i in range(20)] for j in range(20)]

for i in range(1, N + 1):
    A[i] = int(input())
    for j in range(1, A[i] + 1):
        x[i][j], y[i][j] = list(map(int, input().split()))

# 2^N 通りをbit全探索
# kが正直者 = 2進数表記のk-1桁目が1 (1 <= k <= N)
ans = 0
for bits in range(1, 1 << N):
    ok = True
    for i in range(1, N + 1):
        # 不親切な人の証言は無視
        if ((bits >> (i - 1)) & 1) == 0:
            continue
        for j in range(1, A[i] + 1):
            # x_ij が正直者であることが偽であれば False
            if ((bits >> (x[i][j] - 1)) & 1) != y[i][j]:
                ok = False
    if ok:
        ans = max(ans, counter(bits))

print(ans)


Measured memory_bytes: 3064
import sys

# お約束
INF = float("inf")
MOD = int(1e9 + 7)
def int1(n):
    return int(n) - 1
def parse(args, *params):
    return tuple(p(v) for p, v in zip(params, next(args).split()))
def debug(*v):
    if __debug__:
        print(*v, file=sys.stderr)

# エントリーポイント
def main(args):
    N, K = parse(args, int, int)
    A = tuple(map(int, next(args).split()))

    MAX_DIG = 45
    bind, mask = True, 0
    for dig in reversed(range(MAX_DIG)):
        count = [0, 0]
        for a in A:
            count[(a & 1 << dig) != 0] += 1
        if bind:
            if count[1] < count[0]:
                if K & (1 << dig):
                    mask += 1 << dig
            else:
                if K & (1 << dig):
                    bind = False
        else:
            if count[1] < count[0]:
                mask += 1 << dig
    debug(mask)
    res = 0
    for a in A:
        res += a ^ mask
    print(res)

if __name__ == '__main__':
    main(iter(sys.stdin.read().split("\n")))


Measured memory_bytes: 15788
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,0,n+1)
#define int long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
const int MOD=1e9+7;
const int INF=1e18;
 
signed main(){
    int N,M;cin>>N>>M;
    int ans=100*N+1800*M;
    ans*=pow(2,M);
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define __ ios_base::sync_with_stdio(0);cin.tie(0);
#define fi first
#define se second
#define pb push_back
#define all(x) x.begin(),x.end()
#define forn(i,a,n) for(int i=a; i < n; i++)
typedef long long int lli;
typedef long double Double;
typedef pair<int,int> pii;
typedef vector<lli> vi;
typedef vector<vi> vvi;
#define MAXN 3005
int main(){__
	int a,b;
	cin >> a >> b;
	cout << a* b << endl;
	return 0;
}


Measured memory_bytes: 3636
import core.bitop;
import std.algorithm;
import std.ascii;
import std.bigint;
import std.conv;
import std.functional;
import std.format;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.random;
import std.typecons;

alias sread = () => readln.chomp();
alias Point2 = Tuple!(long, "y", long, "x");

T lread(T = long)()
{
    return readln.chomp.to!T();
}

T[] aryread(T = long)()
{
    return readln.split.to!(T[])();
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}

void minAssign(T, U = T)(ref T dst, U src)
{
    dst = cast(T) min(dst, src);
}

void maxAssign(T, U = T)(ref T dst, U src)
{
    dst = cast(T) max(dst, src);
}

enum MOD = (10 ^^ 9) + 7;

void main()
{
    long N = lread();
    auto A = aryread();
    long[] ans;
    ans.reserve(N);
    foreach_reverse (i; 0 .. N)
        if ((i ^ (ulong.max * (N & 1))) & 1)
        {
            ans ~= A[i];
        }
    foreach (i; 0 .. N)
        if (~(i ^ (ulong.max * (N & 1))) & 1)
        {
            ans ~= A[i];
        }
    // writeln(ans);
    write(ans[0]);
    foreach(a;ans[1..$])
    write(" ",a);
    writeln();
}


Measured memory_bytes: 13424
# E.Knapsack2 → numpy spped up
import numpy as np
N,W = map(int,input().split())
w,v = [],[]
for _ in range(N):
    w_,v_ = map(int,input().split())
    w.append(w_)
    v.append(v_)
    
Vmax = max(v)*N
INF = 10**9
            
dp = np.ones((N+1,Vmax+1),dtype=np.int64)*INF
dp[0][0]=0

for i in range(N):
    tmp = np.ones(Vmax+1,dtype=int)*INF
    tmp[v[i]:] = dp[i][:-v[i]] + w[i]
    dp[i+1] = np.minimum(dp[i],tmp)

ans = 0   
for i in range(Vmax,-1,-1):
    if dp[N][i] <= W:
        ans = i
        break
print(ans)


Measured memory_bytes: 107444
#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet};
#[allow(unused_imports)]
use std::io::*;
#[allow(unused_imports)]
use std::str::*;

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 $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")
    };
}

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let cin = stdin();
    let cin = cin.lock();
    let s: String = cin
        .bytes() // Bytes
        .map(|c| c.expect("failed reading char") as char)
        .skip_while(|c| c.is_whitespace()) // c が whitespace である限り skip
        .take_while(|c| !c.is_whitespace()) // c が whitespace でない限り要素を返す
        .collect();
    s.parse().ok().expect("failed parsing")
}

fn main() {
    input! {n:usize,a:usize,b:usize}
    println! {"{}", min(a*n,b)}
}


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

int main()
{
  string strN, Data;
  int N, K, I;
  cin >> N >> K;
  cin.ignore();
  getline(cin, Data);
  I = N;
  bool flag;

  while (true)
  {
    strN = to_string(I);
    for (int i = 0; i < strN.size(); i++)
    {
      flag = false;
      if (Data.find(strN.at(i)) != string::npos)
        break;
      else
        flag = true;
    }
    if (flag)
    {
      cout << strN << endl;
      return 0;
    }
    I++;
  }
  return 0;
}


Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var s string
	fmt.Scan(&s)

	ans := 0
	n := len(s)
	for i := 0; i < n/2; i++ {
		if s[i] != s[n-i-1] {
			ans++
		}
	}
	fmt.Println(ans)
}


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



int main() {
    int n;
    cin >> n;
    
    vector<int> a(n);
    rep(i,n) {
        cin >> a[i];
    }
    
    int cnt = 0, num = 1;
    rep(i,n) {
        if(a[i] == num) {
            num++;
        }
        else {
            cnt++;
        }
    }
    
    if(num == 1)
        cout << -1 << endl;
    else
        cout << cnt << endl;
    
    
    return 0;
}


Measured memory_bytes: 4052
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
const ll mod=1000000007;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int h,w,n;cin >> h >> w >> n;
	vector<pii> xy(n);
	map<pii,int> m;
	rep(i,n){
		cin >> xy.at(i).first >> xy.at(i).second;
		m[mp(xy.at(i).first,xy.at(i).second)]++;
	}
	vector<int> a(h+1,1);
	int j=1;
	for(int i=2;i<=h;++i){
		if(m[mp(i,j+1)]==0){
			j++;
		}
		a.at(i)=j;
	}
	sort(xy.begin(),xy.end());
	int ans=h;
	rep(i,n){
		if(a[xy.at(i).first-1]>=xy.at(i).second){
			ans=xy.at(i).first-1;
			break;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 24960
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <cstring>
#include <cstdlib>
using namespace std;

#define REP(i,n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> pint;
template <class T> inline void chmax(T &a, const T b) { a = max(a, b); }
template <class T> inline void chmin(T &a, const T b) { a = min(a, b); }
template <class T> void pp(T v, int n) { REP(i,n) cout<<v[i]<< ' '; cout << endl; }

void inline TorF(bool tf, const string &trueMessage, const string &falseMessage) { 
  cout << (tf ? trueMessage : falseMessage) << endl;
}
void inline YESNO(bool tf) { TorF(tf, "YES", "NO"); }
void inline YesNo(bool tf) { TorF(tf, "Yes", "No"); }

int main() {
  int N; cin>>N;
  ll ans = 0;
  vector<int> d(N); REP(i,N) cin>> d[i];
  REP(i,N) REP(j,i) {
    if(j <i) ans += d[i]*d[j];
  }
  //  cout << "Answer=";
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <string>
#include <iostream>
#include <algorithm>

using namespace std;
typedef long long ll;
ll n,m,i,j,k,a,b,c;
int main(){
	scanf("%lld",&n);
	printf("%lld",n*n);
	return 0;
}


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

using namespace std;
using ll = long long;

#define REP(i, n) for (ll i = 0; i < n; i++)
#define INF 9223372036854775807
#define all(x) (x).begin(), (x).end()

ll ts = 1000000007;

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

  ll a, b;
  cin >> a >> b;
  cout << 6 - a - b << "\n";
}

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

using namespace std;

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

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

    vector<int> dp(n,INT_MAX);

    dp[0] = 0;

    for(int i=0;i<n;i++){
        for(int j=i+1; j<i+1+k;j++){
            if(j<n)
                dp[j] = min(dp[j],dp[i] + abs(a[i] -a[j]));
        }
    }

    cout << dp[n-1] << endl;
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);
    String a = sc.next();
    String b = sc.next();

    if (a.length() > b.length()) {
      System.out.println("GREATER");
      return;
    } else if (a.length() < b.length()) {
      System.out.println("LESS");
      return;
    } else {
      int len = a.length();
      for (int i = 0; i < len; i++) {
        if (a.charAt(i) > b.charAt(i)) {
          System.out.println("GREATER");
          return;
        } else if (a.charAt(i) < b.charAt(i)) {
          System.out.println("LESS");
          return;
        }
      }
    }

    System.out.println("EQUAL");

  }
}

Measured memory_bytes: 35544