akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
using namespace std;
int main(void){
    string s;
    getline(cin, s);    //1行読み込む
        //cout << s;
        for(int i = 0; i < s.size(); i++) {
            char c = s[i];
            if ('A' <= c && c <= 'Z') {
                //c = tolower(c);
                c = c + 32;
            }
            else if('a' <= c && c <= 'z') {
                c = c - 32;
            }
            cout << c;
    }
    cout << endl;
}


Measured memory_bytes: 3128
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define REPL(i,m,n) for(ll i=(ll)(m); i<(ll)(n); i++)
#define repl(i,n) REPL(i,0,n)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
#define MAX_N 100005
class UnionFind
{
public:
  int par[MAX_N];
  int depth[MAX_N];
  int nGroup[MAX_N];
  UnionFind(int n) {
    init(n);
  }
  void init(int n) {
    for(int i=0; i<n; i++) {
      par[i] = i;
      depth[i] = 0;
      nGroup[i] = 1;
    }
  }
  int root(int x) {
    if(par[x] == x) {
      return x;
    } else {
      return par[x] = root(par[x]);
    }
  }
  bool same(int x, int y) {
    return root(x) == root(y);
  }
  void unite(int x, int y) {
    x = root(x);
    y = root(y);
    if(x == y) return;
    if(depth[x] < depth[y]) {
      par[x] = y;
      nGroup[y] += nGroup[x];
      nGroup[x] = 0;
    } else {
      par[y] = x;
      nGroup[x] += nGroup[y];
      nGroup[y] = 0;
      if(depth[x] == depth[y])
        depth[x]++;
    }
  }
};
int main() {
  int N, M, K;
  cin >> N >> M >> K;
  UnionFind uf(N);
  vector<set<int> > F(N, set<int>());
  vector<int> A(M), B(M);
  rep(i, M) {
    cin >> A[i] >> B[i];
    A[i]--; B[i]--;
    uf.unite(A[i], B[i]);
    F[A[i]].insert(B[i]);
    F[B[i]].insert(A[i]);
  }
  vector<set<int> > NF(N, set<int>());
  vector<int> C(K), D(K);
  rep(i, K) {
    cin >> C[i] >> D[i];
    C[i]--; D[i]--;
    if(uf.same(C[i], D[i])) {
      NF[C[i]].insert(D[i]);
      NF[D[i]].insert(C[i]);
    }
  }
  rep(i, N) {
    cout << uf.nGroup[uf.root(i)] - (int)F[i].size() - (int)NF[i].size() - 1 << ' ';
  }
  cout << endl;
  return 0;
}


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

int main(){
  int N;
  cin >> N;
  vector<pair<int, int>> A(N, pair<int, int>(2, 0));
  for(int i = 0; i < N; i++){
    A.at(i).second = i + 1;
    cin >> A.at(i).first;
  }
  sort(A.begin(), A.end());
  for(int i = 0; i < N; i++){
    cout << A.at(i).second;
    if(i != N - 1){
      cout << " ";
    }
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 1664
package main

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

func main() {
	N := nextInt()
	M := nextInt()
	Q := nextInt()

	a := make([]int, Q)
	b := make([]int, Q)
	c := make([]int, Q)
	d := make([]int, Q)

	for i := 0; i < Q; i++ {
		a[i] = nextInt() - 1
		b[i] = nextInt() - 1
		c[i] = nextInt()
		d[i] = nextInt()
	}
	candidates := increasing(M, N)

	ans := 0

	for j := 0; j < len(candidates); j++ {
		A := candidates[j]
		// printarr(A)
		s := 0
		for i := 0; i < Q; i++ {
			if A[b[i]]-A[a[i]] == c[i] {
				s += d[i]
			}
		}
		ans = max(ans, s)
	}

	fmt.Println(ans)
}

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

// 1からnまでのm項からなる単調増加列
func increasing(n, m int) [][]int {
	return increasing1(0, 0, n, m, []int{})
}

//
func increasing1(n, m, N, M int, arr []int) [][]int {
	if n == N && m == M {
		ret := []int{}
		s := 0
		for i := 0; i < len(arr); i++ {
			if arr[i] == 1 {
				s++
			} else {
				ret = append(ret, s)
			}
		}
		return [][]int{ret}
	}
	ret := [][]int{}
	if n < N {
		arr1 := append([]int{}, arr...)
		arr1 = append(arr1, 1)
		ret = append(ret, increasing1(n+1, m, N, M, arr1)...)
	}
	if n != 0 && m < M {
		arr0 := append([]int{}, arr...)
		arr0 = append(arr0, 0)
		ret = append(ret, increasing1(n, m+1, N, M, arr0)...)
	}
	return ret
}

var stdin = initStdin()

func initStdin() *bufio.Scanner {
	bufsize := 1 * 1024 * 1024 // 1 MB
	var stdin = bufio.NewScanner(os.Stdin)
	stdin.Buffer(make([]byte, bufsize), bufsize)
	stdin.Split(bufio.ScanWords)
	return stdin
}

func nextString() string {
	stdin.Scan()
	return stdin.Text()
}

func nextBytes() []byte {
	stdin.Scan()
	return stdin.Bytes()
}

func nextInt() int {
	i, _ := strconv.Atoi(nextString())
	return i
}

func nextInt64() int64 {
	i, _ := strconv.ParseInt(nextString(), 10, 64)
	return i
}


Measured memory_bytes: 42476
#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstring>
#define rep(i, s, g) for (i = s; i <= g; i++)
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;

ll dp[3010][3010];

int main(void)
{
    int N;
    vector<int> a(3010);
    int i, j;
    int len;
    ll X = 0, Y = 0;

    cin >> N;

    a.resize(N);

    rep(i, 0, N - 1)
    {
        cin >> a[i];
    }

    memset(dp, 0, sizeof(dp));

    rep(len, 1, N)
    {
        rep(i, 0, N - len)
        {
            j = i + len;
            if ((N - len) % 2 == 0)
            {
                dp[i][j] = max(dp[i + 1][j] + a[i], dp[i][j - 1] + a[j - 1]);
            }
            else
            {
                dp[i][j] = min(dp[i + 1][j] - a[i], dp[i][j - 1] - a[j - 1]);
            }
        }
    }

    cout << dp[0][N] << endl;
}


Measured memory_bytes: 71040
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        n: usize,
        s: [String; n],
    }

    let c = ["AC", "WA", "TLE", "RE"];
    let mut ans = vec![0; 4];
    for i in 0..n {
        for j in 0..4 {
            if s[i] == c[j] {
                ans[j] += 1;
            }
        }
    }

    for i in 0..4 {
        println!("{} x {}", c[i], ans[i]);
    }
}


Measured memory_bytes: 7788
/* ex7_1
  kt125 */

#include<stdio.h>

//頂点を表す構造体
typedef struct point{
    int x_elem;
    int y_elem;
}point;

//p2を中心にp1を90°回転した点を返す関数
point shift_point(point p1, point p2){
    point p3;
    //p1からp2への方向ベクトルを反時計回り90°回転させて、p2に足してp3を求める
    p3.x_elem = p2.x_elem + (p2.y_elem - p1.y_elem);
    p3.y_elem = p2.y_elem + (p1.x_elem - p2.x_elem);
    return p3;
}

int main(void){
    point p1,p2,p3,p4; //各頂点
    scanf("%d %d %d %d", &p1.x_elem, &p1.y_elem, &p2.x_elem, &p2.y_elem);

    p4 = shift_point(p2, p1); //p1を中心にp2を90°回転
    p3 = shift_point(p1, p4); //p4を中心にp1を90°回転

    printf("%d %d %d %d\n", p3.x_elem, p3.y_elem, p4.x_elem, p4.y_elem);
    return 0;
}

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

int main() {
  int K;cin>>K;
  bool can=false;
  if(K%2==0) can=true;
  else if(K%5==0) can=true;
  if(can) cout<<-1<<endl;
  else{
    int L;
    if(K%7==0) L=9*K/7;
    else L=9*K;
    int A=1;
    int i=1;
    while(true){
      A=A*10;
      A=A%L;
      if(A==1) break;
      else if(i==1000000) break;
      i++;
    }
  if(i<1000000) cout<<i<<endl;
  else cout<<-1<<endl;
  }
}


Measured memory_bytes: 3588
#include <stdio.h>
#define MAX 255
int parent(int i){
  int u;
  u=i/2;
  return u;
}
int left(int i){
    int u;
    u=2*i;
  return u;
}
int right(int i){
    int u;
    u=2*i+1;
  return u;
}

int main(){
  int i,p,l,r,H,A[MAX];
    scanf("%d", &H);
  for(i=1;i<=H;i++)scanf("%d",&A[i]);
  for(i=1;i<=H;i++){
    printf("node %d:",i);
    printf(" key = %d,",A[i]);
    p=parent(i);
    if(i!=1)printf(" parent key = %d,",A[p]);
    l=left(i);
    r=right(i);
    if(l<=H)printf(" left key = %d,",A[l]);
    if(r<=H)printf(" right key = %d,",A[r]);
    printf(" \n");

  }

  return 0;
}




Measured memory_bytes: 2108
/**    epsileer 07 September 2019  23:05:42  **/    
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef long double LD;
typedef pair<LL,LL> PII;
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define TEST int t = 1; while(t--) solve()

void solve(){
    LL n, sum =0; cin>>n;
    vector<int> a(n), b(n), c(n-1);
    for(int i=0;i<n;i++){
        cin>>a[i];
        a[i]--;
    }
    for(int i=0;i<n;i++)
        cin>>b[i];
    for(int i=0;i<n-1;i++)
        cin>>c[i];
    for(int i=0;i<n;i++){
        sum += b[a[i]];
        if(i!=0 && a[i-1]+1 == a[i])
            sum += c[a[i-1]];
    }
    cout<<sum;
}

int main(){
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL); TEST;
return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
    static int h;
    public static void main (String[] args) {
	Scanner scan = new Scanner(System.in);
	h = Integer.parseInt(scan.nextLine()) + 1;
	int[] a = new int[h];
	String[] input = scan.nextLine().split(" ");
	for (int i = 1; i < h; i++) {
	    a[i] = Integer.parseInt(input[i-1]);
	}
        buildMaxHeap(a);
	for (int i = 1; i < h; i++) {
	    System.out.print(" " + a[i]);
	}
	System.out.println();
    }
    static void buildMaxHeap (int[] a) {
	for (int i = h / 2; i > 0; i--) {
	    maxHeapify(a, i);
	}
    }
    static void maxHeapify (int[] a, int i) {
	int leftId = i * 2;
	int rightId = i * 2 + 1;
	int largest = 0;
	if (leftId < h && a[leftId] > a[i]) {
	    largest = leftId;
	} else {
	    largest = i;
	}
	if (rightId < h && a[rightId] > a[largest]) {
	    largest = rightId;
	}
	if (largest != i) {
	    int tmp = a[i];
	    a[i] = a[largest];
	    a[largest] = tmp;
	    maxHeapify(a, largest);
	}
    }
}

Measured memory_bytes: 125972
#include <iostream>
#include <algorithm>
using namespace std;
int main(void){
    // Your code here!
    int A,B,C,D;
    scanf("%d%d%d%d",&A,&B,&C,&D);
    if(min(min(B-C,D-C),min(D-A,B-A))<=0){cout<<0<<endl;}
    else{cout<<min(min(B-C,D-C),min(D-A,B-A))<<endl;}
    return 0;
}


Measured memory_bytes: 256
import Foundation

#if swift(>=4.0)
extension String {
    func split(by separator: String) -> [String] {
        return self.components(separatedBy: separator)
    }
    func toArray() -> [String] {
        return self.map{String($0)}
    }
}
#else
extension String {
    func split(by separator: String) -> [String] {
        return self.componentsSeparatedByString(separator)
    }
    var count: Int {
        return self.characters.count
    }
    func toArray() -> [String] {
        return self.characters.map{String($0)}
    }
}
extension Array where Element: Comparable {
    func max() -> Element {
        return self.maxElement()!
    }
    func min() -> Element {
        return self.minElement()!
    }
    func sorted() -> Array {
        return self.sort()
    }
    func reversed() -> Array {
        return self.reverse()
    }
    mutating func sort() {
        self.sortInPlace()
    }
}
extension Array {
    init(repeating: Element, count: Int) {
        self.init(count: count, repeatedValue: repeating)
    }
}
func stride<T: Strideable>(from start: T, to end: T, by stride: T.Stride) -> StrideTo<T> {
    return start.stride(to: end, by: stride)
}
#endif
func readInt() -> Int? {
    return Int(readLine()!)
}
func readStringSplit(by separator: String) -> [String] {
    return readLine()!.split(by: separator)
}
func readIntSplit(by separator: String) -> [Int] {
    return readLine()!.split(by: separator).map{Int($0)!}
}

/*************** テストスペース ***************/

let input = readIntSplit(by: " ")
let (H, W) = (input[0], input[1])
var a = [[String]](repeating: [""], count: H)
for i in 0..<H {
    a[i] = readLine()!.toArray()
}

var row = [Bool](repeating: false, count: H)
var col = [Bool](repeating: false, count: W)
for i in 0..<H {
    for j in 0..<W {
        if a[i][j] == "#" {
            row[i] = true
            col[j] = true
        }
    }
}

for i in 0..<H {
    if row[i] {
        for j in 0..<W {
            if col[j] {
                print(a[i][j], terminator: "")
            }
        }
        print()
    }
}

Measured memory_bytes: 1792
#include <stdio.h>

int main(void){
	int a,b;

	scanf("%d%d",&a,&b);
	if(a<6){
		printf("0\n");
	}else if(a>=6&&a<=12){
		printf("%d\n",b/2);
	}else {
		printf("%d\n",b);
	}
}




Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n) for(int i = 0; i < n; ++i)
#define rep2(i,start,end) for(ll i = start; i < end; ++i)
#define dwn(i,n) for(int i = n; i >= 0; --i)
#define dwn2(i,start,end) for(ll i = start; i >= end; --i)
#define pll pair<ll,ll>
#define mk(x,y) make_pair(x,y)
#define pdl pair<double, ll>
const ll N = 4e5 + 200;
const ll INF = 0x3f3f3f;
const ll mode = 1e9 + 7;


int main(){
	ll n;
	cin>>n;
	vector<ll> v(n);
	ll sum = 0;
	ll now = 0;
	
	rep(i,n){
		cin>>v[i];
		if(i){
			if(v[i] <= v[i-1]){
				now++;
			}else{
				now = 0;
			}
			if(now > sum) sum = now;
		}
	}
	cout<<sum<<endl;

	return 0;
}








Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <string.h>
#define MAX_N 101
#define INF 10000000
using namespace std;
int d[MAX_N][MAX_N];
int n,k;

void warshall_floyd(int a,int b){
    for(int i = 0 ; i < n ; i++){
      for(int j = 0 ; j < n ; j++){
	d[j][i] = d[i][j] = min(d[i][j],d[i][a] + d[a][b] + d[b][j]);
      }
    }
}

int main(){

  while( cin >> n >> k ,n+k){

    n++;
    for(int i = 0 ; i < n ; i++ ){
      for(int j = 0 ; j < n ; j++ ){
	if(i == j)d[j][i] = 0;
	else d[j][i] = INF;
      }
    }
    for(int i= 0 ; i < k ; i++ ){
      int a,b,cost;
      cin >> a;
      if(a == 0){
	cin >> a >> b;
	if(d[a][b] < INF)cout << d[a][b] << endl;
	else cout << -1 <<endl;

      } else if(a == 1){

	cin >> a >> b >> cost;

	if(d[a][b] > cost){
	  d[a][b] = d[b][a] = cost;
	  warshall_floyd(a,b);
	}

      }
    }
  }
  return 0;
}

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

int main(){
	int n = 0;
  cin >> n;
  int an = 0;
  long long int b[n];
  long long int ans = 0;
  long long int min = 0;
  int num = 0;
  for(int i = 0;i < n;i++){
  	cin >> b[i];
      if(b[i] < 0){
      	b[i] *= -1;
        
      num++;
      }
    if(i == 0){
      min = b[i];
    }
    if(b[i] < min){
    	min = b[i];
      an = i;
    }
  }
  
  for(int i= 0;i < n;i++){
    	ans += b[i];
  }
  if(num %2 == 1){
  ans -= min*2;
  }
  cout << ans << endl;
}

Measured memory_bytes: 1024
#![allow(non_snake_case, unused)]
use std::cmp::*;
use std::collections::*;
use std::f64::consts::*;

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

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

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

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

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

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

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

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

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

fn main() {
    input! {
        s: chars,
    }
    for i in 0..s.len() {
        if i % 2 == 1 {
            if (s[i] == 'L') | (s[i] == 'U') | (s[i] == 'D') {
                continue;
            } else {
                return println!("No");
            }
        } else {
            if (s[i] == 'R') | (s[i] == 'U') | (s[i] == 'D') {
                continue;
            } else {
                return println!("No");
            }
        }
    }
    println!("Yes");
}


Measured memory_bytes: 4352
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define N 500001
  
struct Node {
  int key;
  struct Node *parent,*left,*right;
};
 
struct Node *NIL,*root;
 
void inorder(struct Node *);
void preorder(struct Node *);
void insert(int);
void search(struct Node *,int);
 
int main(){
 
  int i,j=0,n,m=0,x;
  static char command[N][10],judge[N];
 
 
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%s",command[i]);
    if(strcmp(command[i],"insert")==0){
      scanf("%d",&x);
      insert(x);
    }
    if(strcmp(command[i],"print")==0){
      while(j<m){
	if(judge[j]==1)
	  printf("yes\n");
	if(judge[j]==0)
	  printf("no\n");
	j++;
      }
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
    if(strcmp(command[i],"find")==0){
      scanf("%d",&x);
      search(root,x);
    }
  }
    return 0;
  }
 
     
void inorder(struct Node *x){
  if(x==NIL) return;
  inorder(x->left);
  printf(" %d",x->key);
  inorder(x->right);
}
 
 
 void preorder(struct Node *x){
   if(x==NIL) return;
   printf(" %d",x->key);
   preorder(x->left);
   preorder(x->right);
 }

 void search(struct Node *x,int k){
   if(x==NIL) {
     printf("no\n");
     return;
   }
   if(x->key==k) {
     printf("yes\n");
     return;
   }
   {
     if(k < x->key)
       search(x->left,k);
     else 
       search(x->right,k);
   }
 }
 
 
 
 void insert(int k){
 
  struct Node *y=NIL;
  struct Node *x=root;
  struct Node *z;
  z=malloc(sizeof(struct Node));
  z->key=k;
  z->left=NIL;
  z->right=NIL;
 
  while(x!=NIL){
    y=x;
    if(z->key < x->key)
      x=x->left;
    else
      x=x->right;
  }
  z->parent=y;
 
  if(y==NIL)
    root=z;
  else if(z->key < y->key)
    y->left=z;
  else y->right=z;
}

Measured memory_bytes: 24240
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  
  int N, harshad, x;

  cin >> N;
  x = N;
  
  for ( int i = 8; i >= 0; i-- ) { 
    int digit = 1;
    for (int j = 0; j < i; j++)
      digit *= 10;
    
    while ( x - digit >= 0 ) {
      harshad++;
      x -= digit;
    }        
  }
  
  if ( N % harshad == 0 )
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
    
}

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


void solve()
{
    ll n,a;
    cin>>n>>a;
    cout<<(n*n)-a<<endl;

}

int main()
{
    ios_base :: sync_with_stdio(false);
    ll t,i=1;
    //cin>>t;
   t=1;
    while(t--)
    {
        solve();
    }
}


Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10 ** 7)
rl = sys.stdin.readline
INF = 10 ** 18


def reachable_nodes(s, edges):
    cur = {s}
    reachable = set()
    while cur:
        reachable |= cur
        cur = set().union(*(edges[node] for node in cur)) - reachable
    return reachable


def bellman_ford(n, edges, s):
    dists = [INF] * n
    dists[s] = 0
    for cnt in range(n):
        for u, v, cost in edges:
            if dists[u] != INF and dists[u] + cost < dists[v]:
                if cnt == n - 1:
                    return -1
                dists[v] = dists[u] + cost
    return dists


def solve():
    N, M, P = map(int, rl().split())
    A, B, C = [0] * M, [0] * M, [0] * M
    to = [[] for _ in range(N)]
    reverse_to = [[] for _ in range(N)]
    for i in range(M):
        a, b, c = map(int, rl().split())
        a, b = a - 1, b - 1
        A[i], B[i], C[i] = a, b, P - c
        to[a].append(b)
        reverse_to[b].append(a)
    
    reachable = reachable_nodes(0, to) & reachable_nodes(N - 1, reverse_to)
    
    edge_dict = dict()
    for a, b, c in zip(A, B, C):
        if a in reachable and b in reachable:
            edge_dict[(a, b)] = min(c, edge_dict.get((a, b), 10 ** 6))
    edges = [(u, v, cost) for (u, v), cost in edge_dict.items()]
    
    dists = bellman_ford(N, edges, 0)
    if dists == -1:
        print(-1)
    else:
        print(max(0, -dists[-1]))


if __name__ == '__main__':
    solve()


Measured memory_bytes: 44272
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;
public static class P
{
    public static void Main()
    {

        Console.WriteLine(Console.ReadLine().Contains('7') ? "Yes" : "No");
    }
}

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

#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define mp make_pair
#define pb push_back
#define fs first
#define sc second
#define fr(i, a, b) for(int i = a ; i < b ; i++)
#define frr(i, a, b) for(int i = a ; i >= b ; i--)
#define tr(it, var) for(__typeof(var.begin()) it = var.begin(); it != var.end(); it++)
#define trr(rit, var) for(__typeof(var.rbegin()) rit = var.rbegin(); rit != var.rend(); rit++)
#define its(x) static_cast< ostringstream & >( ( ostringstream() << dec << x ) ).str() // int to string
#define boost ios_base::sync_with_stdio(false)
#define deb(x) cout << #x" = " << x << '\n'
#define has(cont, x) ((cont).find((x)) != (cont).end())
#define sz(x) ((int)(x).size())

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;



int main() {
//    freopen("input.in", "r", stdin);
	int n;
	scanf("%d", &n);
	ll res = 0;
	fr(i, 0, n) {
		int vie;
		scanf("%d", &vie);
		res += (vie-1);
	}
	cout << res << '\n';
	return 0;
}

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

int main() {
  vector<int> vec(3);
  rep(i, 3) cin >> vec.at(i);
  sort(vec.begin(), vec.end());
  if (vec.at(0) == vec.at(1)) cout << vec.at(2) << endl;
  else cout << vec.at(0) << endl;
}


Measured memory_bytes: 256
def solve():
    n,k=map(int,input().split())
    A=[0 for i in range(n)]
    for i in range(k):
        d=int(input())
        di=list(map(int,input().split()))
        for ele in di:
            A[ele-1]+=1
    count=0
    for i in range(n):
        if(A[i]==0):
            count+=1
    print(count)
solve()

Measured memory_bytes: 9176
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define chmax(x,y) x = max(x,y);
#define chmin(x,y) x = min(x,y);
const int di[] = {-1, 0, 1, 0};
const int dj[] = {0, -1, 0, 1};
const int INF = 1001001001;



int main() {
    int a, b;
    cin >> a >> b;
    cout << a-b+1 << endl;
    return 0;
}

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

vector<int> e[100005];
int dp[100005];

int dfs(int v) {
  if (dp[v] == 0) {
    dp[v] = 1;
    for (int u : e[v])
      dp[v] = max(dp[v], 1 + dfs(u));
  }
  return dp[v];
}

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

  int n, m;
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int u, v;
    cin >> u >> v;
    e[u].push_back(v);
  }
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    ans = max(ans, dfs(i));
  }
  cout << ans - 1 << '\n';

  return 0;
}

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

typedef long long int int64;
struct vertex {
	int estart;
	int k;
} v[100009];
struct edge {
	int enext;
	int to;
} e[200009];int en;
int a,b,c;
void dfs(int i)
{
	if(v[i].k == 0)
		++a;
	else
		++b;
	for(int j = v[i].estart;j != -1;j = e[j].enext) {
		int to = e[j].to;
		if(v[to].k == v[i].k) {
			c = 1;
			return;
		}
		if(v[to].k == -1) {
			v[to].k = 1 - v[i].k;
			dfs(to);
		}
		if(c == 1) return;
	}
}
int main()
{
	int n,m;
	scanf("%d%d",&n,&m);
	for(int i = 0;i < n;++i) {
		v[i].k = -1;
		v[i].estart = -1;
	}
	for(int i = 0;i < m;++i) {
		int a,b;
		scanf("%d%d",&a,&b);
		--a,--b;
		e[en].enext = v[a].estart;e[en].to = b;v[a].estart = en;++en;
		e[en].enext = v[b].estart;e[en].to = a;v[b].estart = en;++en;
	}
	v[0].k = 0;
	dfs(0);
	if(c == 1) {
		printf("%lld\n",1LL*n*(n-1)/2-m);
	} else {
		printf("%lld\n",1LL*a*b-m);
	}
}

Measured memory_bytes: 2816
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long n, m;
  cin >> n >> m;
  if(n>1&&m>1){
    cout << (n - 2) * (m - 2) << endl;
  }else{
    if(n==2||m==2){
      cout << 0 << endl;
    }else{
      if(n==1&&m==1){
        cout << 1 << endl;
      }
      else if(n==1){
        cout << m - 2 << endl;
      }else{
        cout << n - 2 << endl;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 3608
n = int(input())
s = input()

nowL = 0 # 今見てる左側の位置
nowR = n-1 # 今見てる右側の位置
ans = 0 # swapした回数

while(True):
    while(nowL < n-1):
        # 左側で、右に移動しながら次のWを探す
        if(s[nowL]=='W'):
            break
        else:
            nowL+=1
    while(nowR > 0):
        # 右側で、次のRを探す
        if(s[nowR]=='R'):
            break
        else:
            nowR-=1
    if(nowR <= nowL):
        #見てる位置がぶつかったら探索終了
        break
    
    nowL+=1
    nowR-=1
    ans+=1
    
    
print(ans)



Measured memory_bytes: 73256
#include <iostream>
#include <vector>

using namespace std;

int main(){
  int N, tmp;
  cin >> N;
  vector<int> perm;
  for (int i=0; i<N; i++){
    cin >> tmp;
    perm.push_back(tmp);
  }
  int res = 0;
  for (int i=1; i<N - 1; i++){
    if ((perm[i - 1] > perm[i] && perm[i + 1] < perm[i]) || 
        (perm[i - 1] < perm[i] && perm[i + 1] > perm[i])){
      res++;
    }
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;

char grade(int m, int f, int r)
{
    if (m == -1 || f == -1)
        return 'F';

    int x = m + f;

    if (x >= 80)
        return 'A';
    if (x >= 65)
        return 'B';
    if (x >= 50)
        return 'C';
    if (x < 30)
        return 'F';
    if (r >= 50)
        return 'C';

    return 'D';
}

int main()
{
    while (true) {
        int m, f, r;
        cin >> m >> f >> r;

        if (m == -1 && f == -1 && r == -1) {
            break;
        }

        cout << grade(m, f, r) << endl;
    }
}



Measured memory_bytes: 3100
#include<stdio.h>

int main(){
    long long int x;
    scanf("%lld",&x);
    
    long long int m=(x-1)/11;
    long long int n=(x+4)/11;
    if(m<n){
        printf("%lld\n",2*n);
    }else{
        printf("%lld\n",2*n+1);
    }
    return 0;
}

Measured memory_bytes: 1720
import java.util.Scanner;

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

    public Main() {
        Scanner sc = new Scanner(System.in);
        long a = Integer.parseInt(sc.next());
        long b = Integer.parseInt(sc.next());
        long r, x, tmp;

        x = a * b;
        if (a < b) {
            tmp = a;
            a = b;
            b = tmp;
        }

        r = a % b;
        while (r != 0) {
            a = b;
            b = r;
            r = a % b;
        }

        long lcm = x / b;
        System.out.println(lcm);
    }
}


Measured memory_bytes: 22996
import java.util.Scanner;
public class Main
{
  	public static void main(String[] args)
    {
     	Scanner sc = new Scanner(System.in);
      	int a = Integer.parseInt(sc.nextLine());
      	String[] word = sc.nextLine().split("");
      	long count[] = new long[3];
      	long discount = 0L;
      	for(int i = 0; i < a; i++)
        {
         	if(word[i].equals("R"))
            {
              	count[0]++;
            }else if(word[i].equals("G")){
              	count[1]++;
            }else{
              	count[2]++;
            }
        }
      
      	for(int i = 0; i < a - 2; i++)
        {
         	for(int j = 1; (i + 2 * j) < a; j++)
            {
             	if(!word[i].equals(word[i + j]) && !word[i].equals(word[i + j * 2]) && !word[i + j].equals(word[i + j * 2])){
                  	discount++;
                }
            }
        }
      
      	
      	
      
      
      	System.out.println(count[0] * count[1] * count[2] - discount);
    }
}

Measured memory_bytes: 37100
package main

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

var (
	scanner = bufio.NewScanner(os.Stdin)
	w       = bufio.NewWriter(os.Stdout)
)

func readInt() (read int) {
	scanner.Scan()
	read, err := strconv.Atoi(scanner.Text())
	if err != nil {
		panic(err)
	}
	return
}

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

func main() {
	scanner.Split(bufio.ScanWords)
	defer w.Flush()

	var n, m, k int
	var a, b []int

	n = readInt()
	m = readInt()
	k = readInt()

	a = make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = readInt()
	}

	var t int
	b = make([]int, m)
	for i := 0; i < m; i++ {
		b[i] = readInt()
		t += b[i]
	}

	ans := 0
	j := m
	for i := 0; i < n+1; i++ {
		for j > 0 && t > k {
			j--
			t -= b[j]
		}
		if t > k {
			break
		}
		ans = max(ans, j+i)
		if i == n {
			break
		}
		t += a[i]
	}
	fmt.Println(ans)
}


Measured memory_bytes: 7828
using System;

class Rectangle
{
    public static void Main()
    {
        while (true)
        {
            string[] s = Console.ReadLine().Split();

            int H = int.Parse(s[0]);
            int W = int.Parse(s[1]);

            if (H == 0 && W == 0)
            {
                break;
            }

            for (int i = 0; i < H; i++)
            {
                for(int j = 0;j< W; j++)
                {
                    if((i+j)%2 == 0)
                    {
                        Console.Write("#");
                    }
                    else
                    {
                        Console.Write(".");
                    }
                }
                Console.WriteLine();
            }
            Console.WriteLine();
        }
    }
}


Measured memory_bytes: 8904
#include<bits/stdc++.h>
using namespace std;
const int N = 1e5 + 11;
const int mod = 1e9 + 7;
int n, k;
int miu[N], g[N];
bool is_not[N];
int ksm(int base, int x){
    int ans = 1;
    while(x){
        if(x & 1)ans = 1LL * ans * base % mod;
        base = 1LL * base * base % mod;
        x >>= 1;
    }
    return ans;
}
int main(){
    miu[1] = 1;
    for(int i = 2;i <= 1e5; i++)miu[i] = 1;
    for(int i = 2;i <= 1e5; i++){
        if(is_not[i])continue;
        miu[i] = -1;
        for(int j = 2;j * i <= 1e5; j++){
            is_not[i*j] = 1;
            if(j % i == 0)miu[j*i] = 0;
            else miu[j*i] *= -1;
        }
    }
    cin>>n>>k;
    int ans = 0;
    for(int i = 1;i <= k; i++){
        g[i] = ksm(k / i, n);
    }
    for(int i = 1;i <= k; i++){
        for(int j = 1;j * i <= k; j++){
            (ans += (1LL * i * g[j*i] * miu[j] % mod + mod) % mod) %= mod;
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 4456
#include<stdio.h>
int main(void)
{
	int i,a,b,n[8],j;
	for(i=0;i<7;i++){
		a=0; b=0;
		scanf("%d %d",&a,&b);
		n[i]=a-b;
	}
	for(i=0;i<7;i++) printf("%d\n",n[i]);
	return 0;
}	

Measured memory_bytes: 2752
/// Bismillahir Rahmanir Rahim
/* Mohammad Morsalin
   Dept of ICE, NSTU
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ll long long
#define pb push_back
#define mp make_pair
#define endl "\n"
#define int long long
#define f0(n) for(int i=0;i<n;i++)
#define ms(x) memset(x,0,sizeof(x))
#define ms2d(x,m,n) memset(x, 0, sizeof(x[0][0]) * m * n)
#define uniq(vec) vec.resize(distance(vec.begin(),unique(vec.begin(),vec.end())))
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define pi pair<int,int>
#define tc(t) int t;cin>>t;while(t--)
#define bits(n) __builtin_popcount(n)
#define maxpq priority_queue<int>
#define minpq priority_queue<int, vector<int>, greater<int> >
#define ins insert
#define ALL(v) v.begin(),v.end()
#define highest(x) numeric_limits<x>::max()
#define lowest(x) numeric_limits<x>::min()
#define Inf INFINITY
#define minv(v) *min_element(v.begin(),v.end())
#define maxv(v) *max_element(v.begin(),v.end())
#define fi first
#define se second
#define PI acos(-1)
#define sz(a) (int)a.size();
#define IOS ios::sync_with_stdio(false);
using namespace std;
int gcd(int a, int b) { if (a == 0) return b; return gcd(b % a, a);}
typedef tree<pair<int, int>,null_type,less<pair<int, int>>,rb_tree_tag,tree_order_statistics_node_update> ordered_multiset;
int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1};
int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1};
int dx4[] = {0, 0, 1, -1};
int dy4[] = {1, -1, 0, 0};
const long long MOD = 1000000007;
double sq(double x) {return x*x;}
template<typename T>inline T Bigmod(T base, T power, T MOD){
    T ret=1;
    while(power)
    {
        if(power & 1)ret=(ret*base)%MOD;
        base=(base*base)%MOD;
        power>>=1;
    }
    return ret;
}

bool sortinrev(const pair<int,int> &a,
               const pair<int,int> &b)
{
       return (a.first > b.first);
}
signed main()
{
    IOS
    int x,y;
    while(cin>>x>>y){
        if(y%2!=0){
            cout << "No\n";
        }
        else{
            if(2*x<=y && y<=4*x){
                cout << "Yes\n";
            }
            else{
                cout << "No\n";
            }
        }
    }
    return 0;
}
///Alhamdulillah


Measured memory_bytes: 3640
#include <iostream>
#define MAX 999999

using namespace std;

bool is_prime[MAX];

void isprime(void){

  for( int i = 0 ; i < MAX ; i++ ) is_prime[i] = true;
  is_prime[0] = is_prime[1] = false;

  for( int i = 2 ; i*i < MAX ; i++ ){
    if( is_prime[i] ){
      for( int j = i+i ; j < MAX ; j += i ){
	is_prime[j] = false;	
      }
    }
  }
}

int main(void){

  isprime();

  int n;
  while( cin >> n ){
    if( n == 0 )break;
    int sum = 0;
    for( int i = 2 ; ; i++ ){
      if( is_prime[i] ){
	sum += i;
	n--;
      }
      if( n == 0 )break;
    }
    cout << sum << endl;
  }
  return 0;
}

Measured memory_bytes: 2136
#include <iostream>
#include <vector>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;

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


Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> int_pair;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
const char a='0';
 
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	string s;
	char sing[]={'-','+'};
	cin>>s;
	int ans;
	FOR(i,0,8){
		ans=s[0]-a;
		if(i&1)ans+=(s[1]-a);
		else ans-=(s[1]-a);
		if(i&2)ans+=(s[2]-a);
		else ans-=(s[2]-a);
		if(i&4)ans+=(s[3]-a);
		else ans-=(s[3]-a);
		if(ans==7){
			printf("%c%c%c%c%c%c%c=7\n",s[0],sing[i&1],s[1],sing[(i&2)/2],s[2],sing[(i&4)/4],s[3]);
			return 0;
		}
	}
	return 0;
}


Measured memory_bytes: 256
N = int(input())
P = list(map(float, input().split()))
P = [0] + P
dp = [[0] * (N+1) for _ in range(N+1)]
dp[0][0] = 1

for i in range(1, N+1):
    dp[i][0] = dp[i-1][0] * (1 - P[i])

for i in range(1, N+1):
    for j in range(1, i+1):
        dp[i][j] += dp[i-1][j-1] * P[i] + dp[i-1][j] * (1 - P[i]) 

ans = 0
if N % 2 == 0:
    start = N // 2
else:
    start = N // 2 + 1

for i in range(start, N+1):
    ans += dp[N][i]
    
print(ans)

Measured memory_bytes: 207264
n,m=map(int,input().split())
quant=[1]*(n+1)
prob=[0]*(n+1)
prob[1]=1
for i in range(m):
    x,y=map(int,input().split())
    quant[x]-=1
    quant[y]+=1
    if prob[x]>0:
        prob[y]+=1
    if quant[x]==0:
        prob[x]=0

cnt=0
for i in range(n+1):
    if prob[i]>0:
        cnt+=1
print(cnt)
        


Measured memory_bytes: 4596
/* ex5_3
   moka223711 */

#include <stdio.h>
#define ROW 101
#define COL 101

int main(void){
    int row, col, i, j, br[ROW] = {0}, bc[COL] = {0}, id = 0;
    char sq[ROW][COL];
    scanf("%d %d", &row, &col);
    for(i = 0; i < row; i++){
        for(j = 0; j < col; j++){
            scanf(" %c", &sq[i][j]);
            if(sq[i][j]=='#'){
                br[i] = 1;
                bc[j] = 1; }
        }
    }
    for(i = 0; i < row; i++){
        for(j = 0; j < col; j++){
            if(br[i] == 0){
                id = 0;
                continue; }
            if(bc[j] == 1){
                id = 1;
                printf("%c", sq[i][j]); }
        }
        if(id == 1)printf("\n");
    }
    return 0;
}


Measured memory_bytes: 128
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#define all(v) (v).begin(),(v).end()
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
constexpr ll INF = 1e18;

int main(void) {
    ll D, T, S;
    cin >> D >> T >> S;
    if (D <= T*S) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}



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

const int maxn=55;
char s[maxn][maxn];
int n,m;
int dir[4][2]={0,1,0,-1,1,0,-1,0};

bool valid(int x,int y)
{
    return x<n&&x>=0 &&y<m&&y>=0;
}
bool ok(int x,int y)
{
    for(int i=0;i<4;i++)
    {
        int dx=x+dir[i][0];
        int dy=y+dir[i][1];
        if(valid(dx,dy))
        {
            if(s[dx][dy]=='#') return true;
        }
    }
    return false;
}
int main()
{
   // int n,m;
    while(cin>>n>>m)
    {
        for(int i=0;i<n;i++)
            cin>>s[i];
        bool flag=true;
        for(int i=0;i<n;i++)
            for(int j=0;j<m;j++)
            {
                if(s[i][j]=='#' && !ok(i,j))
                {
                    flag=false;
                    break;
                }

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


Measured memory_bytes: 256
n, m = list(map(int, input().split()))
low = 0
high= n+1

for i in range(m):
  temp = list(map(int, input().split()))
  if temp[0] > low:
    low = temp[0]
  if temp[1] < high:
    high = temp[1]


if high-low >= 0:
  print(high-low+1)
else:
  print(0)

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

string s; 

void solve(bool ans[],int N){
    for(int i=1;i<N-1;i++){
        if(s[i]=='o'&&ans[i]==true){
            ans[i+1]=ans[i-1];
        }else if(s[i]=='x'&&ans[i]==true){
            ans[i+1]=1-ans[i-1];
        }else if(s[i]=='o'&&ans[i]==false){
            ans[i+1]=1-ans[i-1];
        }else{
            ans[i+1]=ans[i-1];
        }
    }
}

bool check(bool ans[],int N){
    if((ans[N-1]==true&&s[N-1]=='o')||(ans[N-1]==false&&s[N-1]=='x')){
        if(ans[N-2]!=ans[0]){
            return false;
        }
    }
    if((ans[N-1]==true&&s[N-1]=='x')||(ans[N-1]==false&&s[N-1]=='o')){
        if(ans[N-2]==ans[0]){
            return false;
        }
    }
    if((ans[0]==true&&s[0]=='o')||(ans[0]==false&&s[0]=='x')){
        if(ans[N-1]!=ans[1]){
            return false;
        }
    }
    if((ans[0]==true&&s[0]=='x')||(ans[0]==false&&s[0]=='o')){
        if(ans[N-1]==ans[1]){
            return false;
        }
    }
    return true;
}

int main(){
    int N; cin >> N;
    cin >> s;
    bool ans[N];
    for(int i=0;i<=1;i++){
        for(int j=0;j<=1;j++){
            ans[0]=i; ans[1]=j;
            solve(ans,N);
            if(check(ans,N)){
                for(int i=0;i<N;i++){
                    if(ans[i]==true) cout << 'S';
                    else cout << 'W';
                }
                return 0;
            }
        }
    }
    cout << -1 << endl;
    return 0;
}

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



int main() {
    int a, b;
    cin >> a >> b;
    ll ans = (ll)a*b/__gcd(a,b);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3612
n, k = map(int, input().split())
a = tuple(map(int, input().split()))

MAX_DIGIT = 50

bits = [0] * (MAX_DIGIT + 1)
# 1 << 40 > 10 ** 12 より、
# 1 << 0 の位から 1 << 40 の位までを考慮すればよい
# bits[j] : aの要素aaの二進表現で、1 << j の位のbitが立っている総数
# -> n - bits[j] : 立っていない総数


for j in range(MAX_DIGIT + 1):
    bits[j] = sum(1 for aa in a if (aa >> j) & 1)

dp = [[0] * 2 for _ in range(MAX_DIGIT + 1)]
# dp[j][smaller] :
# 1 << MAX_DIGIT の位から 1 << j の位まで決めたときの排他的論理和の和の最大値
# smaller : 0 == 未確定 / 1 == 確定

for j in reversed(range(MAX_DIGIT)):
    # 最上位の桁からxを決めていく
    if (k >> j) & 1:
        # k の 1 << j の位にbitが立っている場合
        dp[j][0] = dp[j + 1][0] + (n - bits[j]) * (1 << j)
        if dp[j + 1][1] == 0:
            dp[j][1] = dp[j + 1][0] + bits[j] * (1 << j)
        else:
            dp[j][1] = max(
                dp[j + 1][0] + bits[j] * (1 << j),
                dp[j + 1][1] + max(bits[j], n - bits[j]) * (1 << j)
            )

    else:
        # k の 1 << j の位にbitが立っていない場合
        dp[j][0] = dp[j + 1][0] + bits[j] * (1 << j)
        if dp[j + 1][1] == 0:
            dp[j][1] = 0
        else:
            dp[j][1] = dp[j + 1][1] + max(bits[j], n - bits[j]) * (1 << j)

print(max(
    dp[0][0],
    dp[0][1]
))

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

int main(){
    ll n;
    cin >> n;
    ll sum = 0;
    vector<ll> ans(n, 0);
    for(int x=1; x*x<=n; x++){
        for(int y=1; y*y<=n; y++){
            for(int z=1; z*z<=n; z++){
                sum = (x+y+z)*(x+y+z)-(x*y+y*z+z*x);
                if(sum > n) break;
                ans[sum-1]++;
            }
        }
    }
    rep(i, n){
        cout << ans[i] << endl;

    }
    return 0;
}

Measured memory_bytes: 3584
a,b,c,d,e=map(int,input().split())
a,b,c,d,e=int(a),int(b),int(c),int(d),int(e)
sum=a+b+c+d+e
if sum==14:
    print(1)
elif sum==13:
    print(2)
elif sum==12:
    print(3)
elif sum==11:
    print(4)
elif sum==10:
    print(5)


Measured memory_bytes: 9124
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define it ::iterator
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double ESP=1e-10;
using namespace std;
int main(){
  #define MAX 2000000
  bool sosu[MAX]={0};
  for(int i=4;i<MAX;i+=2)sosu[i]=true;
  for(int i=3;i<MAX;i+=2){
	if(sosu[i])continue;
	for(int j=i*3;j<MAX;j+=i*2)sosu[j]=true;
  }
  int n;
  while(cin>>n,n){
	int co=0;
	for(int i=n;i<MAX;i++){
	  if(!sosu[i])break;
	  co++;
	}
	for(int i=n;i>1;i--){
	  if(!sosu[i])break;
	  co++;
	}
	cout<<co<<endl;
  }
}

Measured memory_bytes: 3116
s = raw_input()
l = s.split(' ')
stk = []

for i in l:
  if i in ['+','-','*','/']:
    b = stk.pop()
    a = stk.pop()
    if i == '+':
      c = a+b
      stk.append(c)
    elif i == '-':
      c = a-b
      stk.append(c)
    elif i == '*':
      c = a * b
      stk.append(c)
    elif i == '/':
      c = a / b
      stk.append(c)
  else:
    stk.append(int(i))
print stk[0]

Measured memory_bytes: 6452
n=int(input())
count=0
lists=[]
for i in range(n):
    d1,d2=list(map(int,input().split()))
    lists.append([d1,d2])
for i in range(n-2):
    if lists[i][0]==lists[i][1] and lists[i+1][0]==lists[i+1][1] and lists[i+2][0]==lists[i+2][1]:
        print('Yes')
        break
    elif i==n-3:
        print('No')
        break
    else:
        continue


Measured memory_bytes: 9188
def main():
    N = int(input())
    A = [int(i) for i in input().split()]
    from itertools import accumulate
    S = [i for i in accumulate(A)]
    s = S.pop()
    B = [abs((i*2)-s) for i in S]
    print(min(B))


if __name__ == '__main__':
    main()


Measured memory_bytes: 88476
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 3e5 + 10;

int main() {
    string s,t,c;
    int cs, ct;
    cin >> s >> t >> cs >> ct;
    map<string, int> mp;
    mp[s] = cs;
    mp[t] = ct;
    cin >> c;
    mp[c]--;
    cout << mp[s] << " " << mp[t] << '\n';
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
int main() {
	int ans=0;
	for (int i = 0; i < 4; i++) {
		int x; cin >> x;
		ans += x;
	}
	cout << ans / 60 << endl<< ans % 60 << endl;
}


Measured memory_bytes: 3124
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <tuple>
#include <utility>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <iomanip>
#include <map>
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define SORT(v) sort((v).begin(), (v).end())
#define SORTR(v) sort((v).rbegin(), (v).rend())
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
	

int main(){

	int n;
	cin>>n;
	cout<<n*n*n<<endl;

    return 0;
}


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

#define int long long
#define fast_io(); ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define loop(i,a,b) for(int i=a;i<b;i++)
#define all(x) x.begin(),x.end()
#define pb push_back
#define ins insert
#define fi first
#define se second
#define _max max_element
#define _min min_element
#define tc(T) int T; cin>>T; while(T--)
#define q(q) int q; cin>>q; while(q--)
#define pi 3.1415926535897932384626433832
const int pinf=((int)9e18);
const int ninf=((int)-9e18);
const int mod=1000000007;

using namespace std;

int32_t main()
{
    fast_io();

    //FILE *fptr1=freopen("in.txt","r",stdin);
    //FILE *fptr2=freopen("out.txt","w",stdout);

    int n;
    cin>>n;

    int x;
    double s=0;
    loop(i,0,n)
    {
        cin>>x;

        s+=(1.0/x);
    }

    s=1.0/s;

    printf("%0.12f",s);

    return 0;
}


Measured memory_bytes: 3788