akhauriyash/Code-Regression huggingface dataset:
import java.io.*;
import java.util.*;

public class Main {
    public static final long mod = (long)1e9+7;
    public static final long INF = Long.MAX_VALUE/4;
    public static final int inf = Integer.MAX_VALUE/4;

    static void solve(InputReader in, PrintWriter out){
        int n = in.ni(), m = in.ni(), Q = in.ni();
        long[][] map = new long[n][n];
        int l, r, p, q;
        for (int i = 0; i < m; i++) {
            l = in.ni()-1;
            r = in.ni()-1;
            map[l][r]++;
        }
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n-1; j++) {
                map[i][j+1] = map[i][j]+map[i][j+1];
            }
        }
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < Q; i++) {
            p = in.ni()-1;
            q = in.ni()-1;
            int ans = 0;
            for (int j = p; j <= q; j++) {
                ans += map[j][q];
            }
            sb.append(ans).append("\n");
        }
        out.print(sb);
    }

    public static void main(String[] args){
        InputReader in = new InputReader(System.in);
        PrintWriter out = new PrintWriter(System.out);
        solve(in, out);
        out.close();
    }
    public static class InputReader{
        private BufferedReader br;
        private StringTokenizer st;
        public InputReader(InputStream is){
            br = new BufferedReader(new InputStreamReader(is));
            st = null;
        }
        public String ns(){
            if(st == null || !st.hasMoreTokens()){
                try{
                    st = new StringTokenizer(br.readLine());
                }catch (Exception e){
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }
        public int ni(){
            return Integer.parseInt(ns());
        }
        public long nl(){
            return Long.parseLong(ns());
        }
        public Double nd(){
            return Double.parseDouble(ns());
        }
        public int[] ni(int n){
            int[] a = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = ni();
            }
            return a;
        }
        public long[] nl(int n){
            long[] a = new long[n];
            for (int i = 0; i < n; i++) {
                a[i] = nl();
            }
            return a;
        }
        public double[] nd(int n){
            double[] a = new double[n];
            for (int i = 0; i < n; i++) {
                a[i] = nd();
            }
            return a;
        }
    }
}

Measured memory_bytes: 62788
//
//  atcoder1.c
//  prg1
//
//  Created by k20043kk on 2020/07/25.
//

#include <stdio.h>
int main(){
    int x;
    scanf("%d",&x);
    if(x>=400&&x<=599){
        printf("8\n");
    }else if( 600<=x && 799>=x){
        printf("7\n");
    }else if( 800<=x && 999>=x){
        printf("6\n");
    }else if( 1000<=x && 1199>=x){
        printf("5\n");
    }else if( 1200<=x && 1399>=x){
        printf("4\n");
    }else if( 1400<=x && 1599>=x){
        printf("3\n");
    }else if( 1600<=x && 1799>=x){
        printf("2\n");
    }else if( 1800<=x && 1999>=x){
        printf("1\n");
    }






    return 0;
}


Measured memory_bytes: 1660
#include <iostream>
#include <algorithm>
using namespace std;
#define MAX_N 100000
 
int n;
int A[MAX_N];
 
int partition(int p, int r){
  int x = A[r];   //基準
  int i = p - 1;
  for(int j = p; j < r; j++){
    if(A[j] <= x){
      i++; swap(A[i], A[j]);
    }
  }
  swap(A[i+1], A[r]);
  return i + 1;
}
 
int main(void){
  cin >> n;
  for(int i = 0; i < n; i++) cin >> A[i];
  int x = partition(0, n - 1);
  for(int i = 0; i < n; i++){
    if(i) cout << " ";
    if(i == x) cout << "[";
    cout << A[i];
    if(i == x) cout << "]";
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 3396
package main

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

func main() {
	S := readstr()
	T := readstr()
	A := readint()
	B := readint()
	U := readstr()
	if S == U {
		A--
	}
	if T == U {
		B--
	}
	fmt.Println(A, B)
}

const (
	iobufsize = 1 * 1024 * 1024 // 1 MB
)

var stdinsc = func() *bufio.Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Buffer(make([]byte, iobufsize), iobufsize)
	sc.Split(bufio.ScanWords)
	return sc
}()

func readint() int {
	stdinsc.Scan()
	v, err := strconv.Atoi(stdinsc.Text())
	if err != nil {
		panic(err)
	}
	return v
}

func readstr() string {
	stdinsc.Scan()
	return stdinsc.Text()
}

func pow(x, y int) int {
	if y < 1 {
		return 1
	}
	return x * pow(x, y-1)
}

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}


Measured memory_bytes: 640
import java.util.Scanner;

public class Main { 
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int k = Integer.parseInt(sc.next());
        int x= Integer.parseInt(sc.next());
        sc.close();
        for(int i = x- k +1 ; i <= x+k-1;i++){
            System.out.print(i);
            System.out.print(" ");
        }
    }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
 
using namespace std;
 
#define lli long long int
#define REP(i,s,l) for(lli i=s;i<l;i++)
#define DEBUG 0
#define INF (1LL<<50)
#define MOD 1000000007

signed main(){

	lli a,b;
	cin>>a>>b;


	if((a+b)%2!=0)cout<<"IMPOSSIBLE"<<endl;
	else cout<<(a+b)/2<<endl;

	return 0;
}

Measured memory_bytes: 764
fn solve() {
    let s = std::io::stdin();
    let mut sc = Scanner { stdin: s.lock() };
    let s = sc.chars();
    let res1 = s.iter().enumerate().fold(0, |sum, (idx, &c)| {
        if idx % 2 == 0 {
            if c == '1' {
                return sum + 1;
            }
        } else {
            if c == '0' {
                return sum + 1;
            }
        }
        sum
    });
    let res2 = s.iter().enumerate().fold(0, |sum, (idx, &c)| {
        if idx % 2 == 0 {
            if c == '0' {
                return sum + 1;
            }
        } else {
            if c == '1' {
                return sum + 1;
            }
        }
        sum
    });
    println!("{}", std::cmp::min(res1, res2));
}

fn main() {
    std::thread::Builder::new()
        .stack_size(64 * 1024 * 1024) // 64MB
        .spawn(|| solve())
        .unwrap()
        .join()
        .unwrap();
}

//snippet from kenkoooo
pub struct Scanner<R> {
    stdin: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self.stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn read_line(&mut self) -> String {
        use std::io::Read;
        let buf = self.stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b'\n' || b == b'\r')
            .take_while(|&b| b != b'\n' && b != b'\r')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }

    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 8572
/**************
*	Shell Sort
*************/

#include <iostream>
#include <math.h>
#include <algorithm>
#include <vector>	//??£?¨?
using namespace std;

void insertionSort(vector<int>* A, int g, int* cnt  ){

	for(unsigned int i=g ; i<(A->size()); i++){
		int v = (*A)[i];
		int j = i-g;
		while(j>=0 && (*A)[j]>v){
			(*A)[j+g] = (*A)[j];
			j = j-g;
			(*cnt)++;
		}
		(*A)[j+g] =v;
	}
	return ;
}
//---------------------------------------------------------
void shellSort(vector<int>* A, vector<int>* G, int* cnt){
//	*cnt =0;
//	int m = A->size();
//	vector<int> G(1,m);
	for(unsigned int i=0; i<(G->size()); i++){
		insertionSort(A, (*G)[i], cnt);
	}

	return;
}
//--<<???????????¢??°>>-------------------------------------------------------
int main(){

	//??\???
	int n;
	cin >> n;
	vector<int> A;
	A.resize(n);
	for(unsigned int i=0; i< A.size(); i++){
		cin >> A[i];
	}

	//??????
// 	vector<int> G(1,1);
	vector<int> G;
// 	for(int i= n; i!=0; --i){
// 	    G.push_back(i) ;
// 	}
	vector<int> Temp;
	int sum = 0;
	while(sum < n){
		//sum += pow(3,i);
		sum *= 3;
		sum++;
	    Temp.push_back(sum);
	}
	for(int j=0; Temp[j]<=n; j++){
	    G.push_back(Temp[j]);
	}
	reverse(G.begin(), G.end());

	int cnt = 0;
	shellSort(&A, &G, &cnt);

	//??????
	cout << G.size() << endl;
	for(unsigned int i=0; i<(G.size()); i++){
		cout << G[i];
		if(i!=(G.size()-1)){
			 cout <<" " ;
		}
	}
	cout << endl;
	cout << cnt << endl;
	for(int i=0; i< n; i++){
		cout << A[i]<< endl;
	}

	return 0;
}
//-----------------------------------------------

Measured memory_bytes: 6784
(ns Atcoder.ARC061-A)

(def S (read-line))

(def len (count S))

(defn char2int [c]
  (- (int c) (int \0))
  )
(defn calc [i]
  (loop [j 1 now (char2int (nth S 0)) sum 0]
    (if (= len j)
      (+ sum now)
      (if (= (bit-and 1 (bit-shift-right i (dec j))) 1)
        (recur (inc j) (char2int (nth S j)) (+ sum now))
        (recur (inc j) (+ (* now 10) (char2int (nth S j))) sum)
        )
      )
    )
  )
(def ans (reduce + (for [i (range 0 (Math/pow 2 (dec len)))] (calc i))))
(println ans)

Measured memory_bytes: 83060
#include <algorithm>
#include <stdio.h>
#include <iostream>
using namespace std;

#define ONE 1
#define TWO 2
#define THREE 3
#define STO 4
#define FULL 5
#define FOUR 6

int main(void){
	int a[5];
	int hand;
	int cnt[3];
	int num;
	int temp;
	int i;

	while(scanf("%d,%d,%d,%d,%d", &a[0], &a[1], &a[2], &a[3], &a[4]) != EOF){
		hand = 0;
		num = 0;
		cnt[0] = 1;
		cnt[1] = 1;
		cnt[2] = 1;
		sort(a, a+5);
		temp = a[0];
		for(i=1; i<5; i++){
			if(temp == a[i]){
			   	cnt[num]++;
			}else{
				temp = a[i];
				if(cnt[num] == 1){
					cnt[num] = 1;
				}else{
					num++;
				}
			}
		}
		if(cnt[0] == 4 || cnt[1] == 4 || cnt[2] == 4){
			hand = FOUR;
			puts("four card");
		}else if(cnt[0] + cnt[1] + cnt[2] == 6){
			hand = FULL;
			puts("full house");
		}else if((a[0]+1 == a[1] && a[1]+1 == a[2] && a[2]+1 == a[3] && a[3]+1 == a[4]) ||
			   	(a[0] == 1 && a[1] == 10 && a[2] == 11 && a[3] == 12 && a[4] == 13)){
			hand = STO;
			puts("straight");
		}
		else if(cnt[0] == 3 || cnt[1] == 3 || cnt[2] == 3){
			hand = THREE;	//two pair
			puts("three card");
		}else if(cnt[0] + cnt[1] + cnt[2] == 5){
			hand = TWO;	//three pair
			puts("two pair");
		}else if(cnt[0] == 2 || cnt[1] == 2 || cnt[2] == 2){
			hand = ONE;
			puts("one pair");
		}else{
			puts("null");
		}
	}

	return 0;
}

Measured memory_bytes: 0
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.Deque;

public class Main {

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

  public void run() {

    try(BufferedReader in = new BufferedReader(new InputStreamReader(System.in))) {

      String[] lines = in.readLine().split(" ");
      int[] arr = new int[lines.length];
      int k=0;
      for (String s : lines) {
        arr[k++] = Integer.parseInt(s); 
      }
      Arrays.sort(arr);
      int step=0;
      if(arr[2] - arr[1] > 2) {
        for(; arr[1]+2 < arr[2]; step++) {
          arr[1] += 2;
        }
      }
      if(arr[1] - arr[0] > 2) {
        for(; arr[0]+2 < arr[1]; step++) {
          arr[0] += 2;
        }
      }

      Tuple3 t = new Tuple3(arr[0], arr[1], arr[2]);
      t.step = step;

      bfs(t);
    }
    catch(IOException e) {
      System.err.println(e);
    }
  }

  private void bfs(Tuple3 t) {
    Deque<Tuple3> que = new ArrayDeque<>();

    que.offer(t);

    Tuple3 cur;
    while(!que.isEmpty()) {
      cur = que.poll();

      if(cur.isEq()) {
        System.out.println(cur.step);
        return;
      }

      if(cur.e[0] < cur.e[1] && cur.e[0] < cur.e[2]) {
        que.offer(new Tuple3(cur.e[0]+2, cur.e[1], cur.e[2]));
        que.peekLast().step = cur.step + 1;
      } else if(cur.e[1] < cur.e[2]) {
        que.offer(new Tuple3(cur.e[0], cur.e[1]+2, cur.e[2]));
        que.peekLast().step = cur.step + 1;
      } else {
        que.offer(new Tuple3(cur.e[0], cur.e[1], cur.e[2]+2));
        que.peekLast().step = cur.step + 1;
      }

      if(cur.e[0] < cur.e[2] && cur.e[1] < cur.e[2]) {
        que.offer(new Tuple3(cur.e[0]+1, cur.e[1]+1, cur.e[2]));
        que.peekLast().step = cur.step + 1;
      } else if(cur.e[1] < cur.e[0] && cur.e[2] < cur.e[0]) {
        que.offer(new Tuple3(cur.e[0], cur.e[1]+1, cur.e[2]+1));
        que.peekLast().step = cur.step + 1;
      } else {
        que.offer(new Tuple3(cur.e[0]+1, cur.e[1], cur.e[2]+1));
        que.peekLast().step = cur.step + 1;
      }
      
    }
  }

  class Tuple3 {
    int[] e;
    int step;

    public Tuple3(int a, int b, int c) {
      e = new int[3];
      e[0] = a;
      e[1] = b;
      e[2] = c;
      step = 0;
    }

    public boolean isEq() {
      return (e[0] == e[1]) && (e[1] == e[2]);
    }
  }
}

Measured memory_bytes: 21076
#include <iostream>
#include <cstdio>
#include <map>
using namespace std;

int main(){
	map<string,int> mm;
	int d;
	char a[1000];
	char b[3];
	while(cin >> a){
		sscanf(a,"%d,%s",&d,&b);
		mm[b]++;
	}
	cout << mm["A"] << endl << mm["B"] << endl << mm["AB"] << endl << mm["O"] << endl;
}

Measured memory_bytes: 0
#EDPC P_Independent_Set
import sys
input = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 7)
 
N = int(input())
edge = [[] for _ in range(N + 1)]
mod = 10 ** 9 + 7
 
for _ in range(N - 1):
    a, b = map(int, input().split())
    edge[a].append(b)
    edge[b].append(a)

root = 1
 
black = [1] * (N + 1)
white = [1] * (N + 1)
under = [[] for _ in range(N+1)]
seen = [False] * (N + 1)

#節点iの子のリストを作成
node = [root]
while node:
    s = node.pop()
    seen[s] = True
    for t in edge[s]:
        if seen[t]:
            continue
        node.append(t)
        under[s].append(t)

def BW(s):
    if not under[s]: #葉なら白黒1色ずつ
        return
    for t in under[s]:
        BW(t)
        white[s] = (white[s] * (white[t] + black[t])) % mod
        black[s] = (black[s] * white[t]) % mod

BW(root)
ans = white[root]+black[root]
print(ans%mod)
    
 



Measured memory_bytes: 114004
#pragma region template
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vld = vector<ld>;
using vvld = vector<vld>;
using vvvld = vector<vvld>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
template <typename T>
using pqrev = priority_queue<T, vector<T>, greater<T>>;
#define rep(i, n) for (ll i = 0, i##_end = (n); i < i##_end; i++)
#define repb(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repr(i, a, b) for (ll i = (a), i##_end = (b); i < i##_end; i++)
#define reprb(i, a, b) for (ll i = (b)-1, i##_end = (a); i >= i##_end; i--)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
//*
constexpr ll MOD = 1e9 + 7;
/*/
constexpr ll MOD = 998244353;
//*/
constexpr ll INF = 1e+18;
constexpr ld EPS = 1e-12L;
constexpr ld PI = 3.14159265358979323846L;
constexpr ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
constexpr ll LCM(ll a, ll b) { return a / GCD(a, b) * b; }
template <typename S, typename T>
inline bool chmax(S &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename S, typename T>
inline bool chmin(S &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif
template <typename T>
bool print_(const T &a) {
  cout << a;
  return true;
}
template <typename T>
bool print_(const vector<T> &vec) {
  for (auto &a : vec) {
    cout << a;
    if (&a != &vec.back()) {
      cout << " ";
    }
  }
  return false;
}
template <typename T>
bool print_(const vector<vector<T>> &vv) {
  for (auto &v : vv) {
    for (auto &a : v) {
      cout << a;
      if (&a != &v.back()) {
        cout << " ";
      }
    }
    if (&v != &vv.back()) {
      cout << "\n";
    }
  }
  return false;
}
void print() { cout << "\n"; }
template <typename Head, typename... Tail>
void print(Head &&head, Tail &&... tail) {
  bool f = print_(head);
  if (sizeof...(tail) != 0) {
    cout << (f ? " " : "\n");
  }
  print(forward<Tail>(tail)...);
}
#pragma endregion

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  string s;
  cin >> s;
  rep(i, SZ(s)){
    s[i] = 'x';
  }
  print(s);
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#define rep(i, a, n) for(int i = a;i < n;i++)
#define repr(i, a, n) for(int i = a;i > n;i--)
using namespace std;


int n;
string s[100010];
vector<string> nm[5];


char judgeI(char c){
	if(c == 'M') return 'M';
	if(c == 'A') return 'A';
	if(c == 'R') return 'R';
	if(c == 'C') return 'C';
	if(c == 'H') return 'H';
	return 0;
}


long long int comb(){
	long long int cnt = 0;
	rep(i, 0, 5){
		rep(j, i+1, 5){
			rep(k, j+1, 5){
				cnt += nm[i].size() * nm[j].size() * nm[k].size();
			}
		}
	}
	return  cnt;
}


long long int solve(){
	rep(i, 0, n){
		switch(s[i].front()){
		case 'M' :
			nm[0].push_back(s[i]);
			break;
		case 'A' :
			nm[1].push_back(s[i]);
			break;
		case 'R' :
			nm[2].push_back(s[i]);
			break;
		case 'C' :
			nm[3].push_back(s[i]);
			break;
		case 'H' :
			nm[4].push_back(s[i]);
			break;
		default :
			;
		}
	}
	return comb();
}


int main(){
	cin >> n;
	rep(i, 0, n) cin >> s[i];

	cout << solve() << endl;

	return 0;
}

Measured memory_bytes: 11636
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#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 all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
//#define int ll
typedef ll Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
// #define mt make_tuple
//typedef tuple<pii,int,int> tp;
//typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-7;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int main(){
	int n;
	cin>>n;
	vi in(n+1,inf);
	rep(i,n)cin>>in[i];
	sort(all(in));
	ll sum=0;
	rep(i,n)sum+=in[i];
	int out=0;
	rep(i,n-1){
		sum-=in[n-i-1];
		if(sum*2<in[n-i-1]){
			out=in[n-i-1];
			break;
		}
	}
	int co=0;
	rep(i,n)if(in[i]>=out)co++;
	cout<<co<<endl;
}








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

#define rep(i,a,b) for(int i = (a); i <= (b); ++i)
#define per(i,a,b) for(int i = (b); i >= (a); --i)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())

typedef long long ll;
typedef long double ld;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef pair<PII,int> PIII;

const int N = 200005;
const int P = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LLINF = 0x3f3f3f3f3f3f3f3f;
const ld eps = 1e-20;
ll qmod(ll a,ll n,ll mod){ll ans=1;while(n){assert(ans>0);if(n&1ll)ans=ans*a%mod;n>>=1;a=a*a%mod;}return ans%mod;}

//head

//your code goes there

ll a[N];
ll sum[N];

map<ll,int> mmap;

int main()
{
        int n; cin >> n; sum[0] = 0;
        rep(i,1,n) scanf("%lld",&a[i]), sum[i] = sum[i-1] + a[i];
        rep(i,1,n) mmap[sum[i]]++;
//        rep(i,1,n) cout << sum[i] << ' '; cout << endl;
//        rep(i,1,n) cout << a[i] << ' '; cout << endl;
        ll ans = 0;
        for(auto x : mmap) ans += (ll)(x.se) * (ll)(x.se-1) / 2;
        cout << ans+mmap[0] << endl;
        return 0;
}


Measured memory_bytes: 15872
ans = 'No'
N, M = map(int, input().split())
Alist = list(map(int, input().split()))
s = sum(Alist)
selectnumber = s / (4*M)
count = 0
for i in Alist:
  if i >= selectnumber:
    count += 1
    if count >= M:
      ans = 'Yes'
      break

print(ans)

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

#define debug(x) cout <<"DEBUG"<<" "<< #x << ":" << x << '\n'

// n回繰り返し
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順
#define rep1(i,n) for(int i = 1; i <= ((int)(n)); i++) // 1-indexed昇順
#define rrep(i,n) for(int i = ((int)(n)-1); i >= 0; i--)  // 0-indexed降順
#define rrep1(i,n) for(int i = ((int)(n)); i >= 1; i--)   // 1-indexed降順
#define all(x) (x).begin(),(x).end()

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vii;  // 2次元配列
typedef vector<ll> vll;
typedef vector<double> vd;
typedef pair<int, int> PII;

template<typename T>
using vec = vector<T>;
template<class T>
using maxheap = std::priority_queue<T>;
template<class T>
using minheap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

template<class T,class U> inline bool chmax(T &a, const U &b){if(a<b){a=b;return 1;}return 0;}
template<class T,class U> inline bool chmin(T &a, const U &b){if(a>b){a=b;return 1;}return 0;}

const ld Pi = std::acos(-1.0L);
const ll infll = (1LL<<62)-1;
const int inf = (1<<30)-1;
const int mod = 1000000007;
// const int mod = 998244353;


/*FUNCs=================================================*/


/*MAIN==================================================*/
signed main(){
    int _StartTime_ = clock();
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化
    // cout << fixed << setprecision(15);

    int V, E; cin >> V >> E;
    vec<vll> graph(V, vll(V, infll));
    rep(i, V) graph[i][i] = 0;
    rep(_, E) {
        int s, t;
        ll d;
        cin >> s >> t >> d;
        graph[s][t] = d;
    }

    rep(k, V) rep(i, V) rep(j, V){
        if(graph[i][k] == infll || graph[k][j] == infll) continue;
        chmin(graph[i][j], graph[i][k] + graph[k][j]);
    }

    rep(i, V) if(graph[i][i] != 0) {
        cout << "NEGATIVE CYCLE" << '\n';
        return 0;
    }

    rep(i, V) rep(j,V) {
        if(graph[i][j] != infll) cout << graph[i][j] << (j==V-1 ? '\n' : ' ');
        else cout << "INF" << (j==V-1 ? '\n' : ' ');
    }

    // printf("ExecutionTime: %d /ms\n",1000*(int)((clock()-_StartTime_)/CLOCKS_PER_SEC));
}


Measured memory_bytes: 3308
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n,sum=0,min,k=0;	cin >> n;
int a[n];
for(int i=1;i<=n;i++){cin >> a[i]; sum+=a[i];}
min = sum+1;
for(int i=1;i<=n;i++)
{
  k+=a[i];
  if(abs(sum-2*k)<min)
    min = abs(sum-2*k);
}
cout << min;
}

Measured memory_bytes: 256
N = int(input())
XY = [tuple(map(int,input().split())) for i in range(N)]
import itertools
from math import hypot
sm = k = 0
for ptn in itertools.permutations(XY):
    k += 1
    for (x1,y1),(x2,y2) in zip(ptn,ptn[1:]):
        sm += hypot(x1-x2, y1-y2)
print(sm / k)

Measured memory_bytes: 3188
# import sys
# sys.setrecursionlimit(10 ** 6)
# import bisect
# from collections import deque
# from decorator import stop_watch
# 
# 
# @stop_watch
def solve(K):
    print('ACL' * K)


if __name__ == '__main__':
    # S = input()
    K = int(input())
    # N, M = map(int, input().split())
    # A = [int(i) for i in input().split()]
    # B = [int(i) for i in input().split()]
    # AB = [[int(i) for i in input().split()] for _ in range(N)]
    solve(K)

    # # test
    # from random import randint
    # from func import random_str
    # solve()


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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<vector<ll>> VV;
typedef vector<vector<int>> VVi;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
const ll INF=1e16+18;
const ll MAX=100005;
const ll MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
#define ALL(v) v.begin(), v.end()
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define REPM(i, mp) for (auto i = mp.begin(); i != mp.end(); ++i)
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbgmap(mp) cerr << #mp << ":"<<endl; for (auto i = mp.begin(); i != mp.end(); ++i) { cerr << i->first <<":"<<i->second << endl;}
#define dbgarr(n,m,arr) rep(i,n){rep(j,m){cerr<<arr[i][j]<<" ";}cerr<<endl;}
#define dbgdp(n,arr) rep(i,n){cerr<<arr[i]<<" ";}cerr<<endl;
#define sum(v) accumulate(ALL(v),0)
#define fi first
#define se second

template<typename T1, typename T2>
ostream &operator<<(ostream &s, const pair<T1, T2> &p) { return s<<"("<<p.first<<", "<<p.second<<")"; }

// vector
template<typename T>
ostream &operator<<(ostream &s, const vector<T> &v) {
    int len=v.size();
    for(int i=0; i<len; ++i) {
        s<<v[i];
        if(i<len-1) s<<"	";
    }
    return s;
}

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

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

    ll n;
    cin>>n;
    Vec a(n);
    Vec b(n);
    Vec x(n);

    rep(i,n){
        cin>>a[i]>>b[i];
        x[i] = a[i]+b[i];
    }

    sort(ALL(x));
    reverse(ALL(x));

    ll ans = 0;
    rep(i,n) ans-= b[i];

    rep(i,n){
        if(i%2==0){
            ans += x[i];
        }
    }


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


Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define ANS cout << ans << endl
#define all(a) a.begin(),a.end()
#define SORT(a) sort(all(a))
#define REVERSE(a) reverse(all(a))
#define int long long
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define VIin(a) for(int i=0; i<a.size(); i++) cin >> a[i]
#define OUT(a) cout << a << endl
typedef vector<int> VI;
typedef vector<VI> VVI;
const int MOD=1e9+7;
const long long INF = 1LL << 60;
/*最大公約数*/int gcd(int x, int y) { return y ? gcd(y,x%y) : x;}
/*最小公倍数*/int lcm(int a, int b) { int g = gcd(a, b); return a / g * b; }
/*素数判定*/int isPrime(int n){if(n<2){return 0;}for(int i=2; i*i<=n; i++){if(n%i==0){return 0;}}return 1;}
/*約数列挙*/vector<int> getDivisor(int n){vector<int> v; for(int i=1; i*i<=n; i++){if(n%i==0){v.push_back(i);if(i!=n/i){v.push_back(n/i);}}}sort(v.begin(),v.end()); return v;}
//----------------------------------------------
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    string s; cin >> s;
    if(s[5] == '1' || s[6] >= '5') OUT("TBD");
    else OUT("Heisei");

    return 0;
}

Measured memory_bytes: 256
import Control.Applicative
import Data.List

solve :: [Int] -> Int
solve xs | not $ all (\x -> mod x 2 == 0) xs = 0
         | group xs == [xs] = -10000000
         | l == 0 = 1 + (solve $ next xs)
         | l == 1 = 1
         | l == 2 = 1
         | l == 3 = 1 + (solve $ next xs)
            where l = length $ filter (\x -> mod x 4 == 0) xs

next :: [Int] -> [Int]
next [a,b,c] = [y+z,x+z,x+y]
                where [x,y,z] = map (\x -> div x 2) [a,b,c]

main = do
    xs <- map read .words <$> getLine
    let ans = if solve xs < 0 then "-1" else show $ solve xs
    putStrLn ans


Measured memory_bytes: 508
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  
  int x, y;
  x = 800 * N;
  y = (N / 15) * 200;
  
  cout << x - y << endl;
  
  
  return 0;  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1e9)
#define PI (acos(-1))
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl

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

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

template<class T> inline auto __lcm(T& a, T& b) 
{ return a * b / __gcd(a, b); }

template<typename T> void remove(std::vector<T>& vector, unsigned int index)
{ vector.erase(vector.begin() + index); }


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

vector<pair<ll, int>> factorization(ll n) {
  vector<pair<ll, int>> res;
  for (ll i = 2; i*i <= n; ++i) {
    if (n % i) continue;
    res.emplace_back(i, 0);
    while (n % i == 0) {
      n /= i;
      res.back().second++;
    }
  }
  if (n != 1) res.emplace_back(n, 1);
  return res;
}

vector<bool> sieve(vector<bool> IsPrime, ll n) {
  if (n+1 > IsPrime.size()) {
    IsPrime.resize(n+1, true);  // IsPrime に必要な要素数を確保
  }
  IsPrime[0] = false;
  IsPrime[1] = false;

  for (ll i = 2; i*i <= n; ++i) {
    if (IsPrime[i]) {
      for (ll j = 2; j*i <= n; ++j) {
        IsPrime[j*i] = false;
      }
    }
  }
  return IsPrime;
}


int main() {
  ll A, B;  cin >> A >> B;

  ll g = gcd(A, B);
  vector<pair<ll, int>> f = factorization(g);
  ll ans = f.size() + 1;
  print(ans);
  return 0;
}


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

#ifdef LOCAL
#include "dump.hpp"
#else
#define dump(...)
#define dumpv(...)
#endif

#define rep(i, n) for (int i = 0; i < (n); i++)
typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
const int MOD = 1e9 + 7;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;

#define mins(x, y) (x = min(x, y))
#define maxs(x, y) (x = max(x, y))

void solve() {
  int n;
  ll k;
  cin >> n >> k;
  vl a(n);
  rep(i, n) cin >> a[i];
  int m = 40;
  // while (!((k >> (m - 1)) & 1)) m--;
  dump(n, k, m, a);
  vi c(m);
  rep(i, m) rep(j, n) {
    int x = (int)((a[j] >> i) & 1);
    if (x) c[i]++;
  }
  dump(c);
  vvl dp(100005, vl(2, -1)); // [i][less]
  dp[0][0] = 0;
  rep(i, m) rep(less, 2) rep(d, 2) {
    int j = m - i - 1;
    int x = (int)((k >> j) & 1);
    int nless = less;
    if (less == 0 && x < d) continue;
    if (less == 0 && x > d) nless = 1;
    ll val;
    /*
    l, x, d
    0, 0, 0, c
    0, 0, 1, c <<==
    0, 1, 0, c
    0, 1, 1, n-c
    1, 0, 0, c
    1, 0, 1, n-c
    1, 1, 0, c
    1, 1, 1, n-c
    */
    if (d == 0) val = c[j] * (ll)(1ll << j);
    else val = (n - c[j]) * (ll)(1ll << j);
    // if (less == 0 && x == 0) val = c[j] * (ll)(1ll << j);
    // else if (d == 0) val = c[j] * (ll)(1ll << j);
    // else val = (n - c[j]) * (ll)(1ll << j);
    if (dp[i][less] >= 0) {
      maxs(dp[i + 1][nless], dp[i][less] + val);
      dump(i, j, d, x, less, nless, c[j], val, dp[i], dp[i+1]);
    }
  }
  // rep(i, m) {
  //   int j = m - i - 1;
  //   int x = (int)((k >> j) & 1);
  //   ll mask = 1ll << j;
  //   if (dp[i][1] >= 0) {
  //     //これは、すでに X < Kなる場合が存在する時
  //     //この時、この桁については1でも0でも構わない
  //     maxs(dp[i + 1][1], dp[i][1] + mask * max(c[j], n - c[j]));
  //   }
  //   if (dp[i][0] >= 0) {
  //     if (x == 0) {
  //       maxs(dp[i + 1][0], dp[i][0] + mask * c[j]);
  //     } else {
  //       maxs(dp[i + 1][1], dp[i][0] + mask * c[j]);
  //       maxs(dp[i + 1][0], dp[i][0] + mask * (n - c[j]));
  //     }
  //   }
  //   dump(i, j, x, dp[i], dp[i+1]);
  // }
  dump(dp[m][0], dp[m][1]);
  ll ans = max(dp[m][0], dp[m][1]);
  cout << ans << endl;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  // freopen("temp.1", "r", stdin);
  solve();
  return 0;
}

Measured memory_bytes: 6528
#include<iostream>
#include<set>
#include<vector>
#include<algorithm>
using namespace std;
int H,W,N;
int cntx[3<<17],cnty[3<<17];
main()
{
	cin>>H>>W>>N;
	set<pair<int,int> >b;
	int mxi=0,myi=0;
	for(int i=0;i<N;i++)
	{
		int x,y;cin>>x>>y;
		x--,y--;
		cntx[x]++;
		cnty[y]++;
		b.insert(make_pair(x,y));
		if(cntx[mxi]<cntx[x])mxi=x;
		if(cnty[myi]<cnty[y])myi=y;
	}
	int diff=-1;
	for(int j=0;j<W;j++)
	{
		if(b.find(make_pair(mxi,j))==b.end()&&cnty[j]==cnty[myi])diff=0;
	}
	for(int i=0;i<H;i++)
	{
		if(b.find(make_pair(i,myi))==b.end()&&cntx[i]==cntx[mxi])diff=0;
	}
	cout<<cntx[mxi]+cnty[myi]+diff<<endl;
}


Measured memory_bytes: 20036
from collections import Counter
 
input()
d = Counter(map(int, input().split()))
d = dict(sorted(d.items(), reverse=True))
ans = []
for i, j in d.items():
    if j >= 4:
        ans.append(i)
    if j >= 2:
        ans.append(i)
if len(ans) >= 2:
    print(ans[0] * ans[1])
else:
    print(0)

Measured memory_bytes: 34856
#include<bits/stdc++.h>
#define _ ios_base::sync_with_stdio(0);
#define REP(i,n) for(int i=0;i<(int)(n);i++)

using namespace std;
int ps[210];
int main(){ _;
  int m,nmin,nmax;
  while(cin>>m>>nmin>>nmax,(m|nmin|nmax)!=0){
    nmin--;nmax--;
    int p;
    REP(i,m)cin>>ps[i];
    int maxGap=0,maxGapIndex;
    for(int i=nmin;i<=nmax;i++){
      int gap=ps[i]-ps[i+1];
      if(gap>=maxGap){
	maxGap=gap;
	maxGapIndex=i;
      }
    }
    cout<<maxGapIndex+1<<endl;
  }
}

Measured memory_bytes: 3036
#include<bits/stdc++.h>
using namespace std;
#define INF 10000000

int prim(int v, vector<vector<pair<int, int> > > adjlist){

    priority_queue<pair<int, int> >  wait;    // first := 候補辺のコスト   second　:= 行先ノード
    vector<int> result(v, INF);               // 頂点iと木の間の最小コスト
    int ans = 0, size = 0;                    // 木のコスト　頂点数

    //初期条件
    result[0] = 0;
    wait.push(make_pair(0, 0));

    while(!wait.empty() && size < v){

        //候補辺のうち最小のものを取り出す
        int newpoint = wait.top().second;
        int newcost = -wait.top().first;
        wait.pop();

        if(result[newpoint] < newcost) continue;

        //出てきた頂点を木に追加
        ans += newcost;
        result[newpoint] = -INF;
        size++;

        // 新しい点から出ている辺をすべてなめる
        for(int i = 0; i < adjlist[newpoint].size(); i++){
            int nextpoint = adjlist[newpoint][i].second;
            int nextcost = adjlist[newpoint][i].first;
            //より木に近くなった頂点があれば,　そこへの枝をqueueに追加
            if(result[nextpoint] > nextcost){
                result[nextpoint] = nextcost;
                wait.push(make_pair(-nextcost, nextpoint));
            }
        }
    }

    return ans;
}


int main(){

    int V; cin >> V;     // V:= 頂点の数
    vector<vector<pair<int, int> > > adjlist(V);      //first := コスト　second := 行先

    //入力
    for(int i = 0; i < V; i++){
        for(int j = 0; j < V; j++){
            int a; cin >> a;
            if(a == -1) continue;
            else{
                adjlist[i].push_back(make_pair(a, j));
            }
        }  
    }

    int ans = prim(V, adjlist);

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


Measured memory_bytes: 3144
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define VV vector
#define pb push_back
#define bitc  __builtin_popcountl
#define m_p make_pair
#define inf 1000000000000000000ll
#define MAXN 1000001
#define eps 0.0000000001
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
string char_to_str(char c){string tem(1,c);return tem;}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template<class T>//usage rand<long long>()
T rand() {
    return uniform_int_distribution<T>()(rng);
}

// string to integer stuuu()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();

//////////////

#define S second
#define F first
#define int long long  
///////

long long modinverse(long long a, long long b)
{
    long long b0 = b, t, q;
    long long x0 = 0, x1 = 1;
    if (b == 1) return 1;
    while (a > 1) {
        q = a / b;
        t = b, b = a % b, a = t;
        t = x0, x0 = x1 - q * x0, x1 = t;
    }
    if (x1 < 0) x1 += b0;
    return x1;
}

signed main()
{
	fastio;
	#ifdef ANIKET_GOYAL
		freopen("inputf.in","r",stdin);
		freopen("outputf.in","w",stdout);
	#endif
	int mo=1000000007;
	int n,k,m;
	cin>>n>>m>>k;
	int fac[200001];
	int ifac[200001];
	fac[0]=1;
	ifac[0]=modinverse(fac[0],mo);
	for(int i=1;i<200001;++i)
	{
		fac[i]=(fac[i-1]*i)%mo;
		ifac[i]=modinverse(fac[i],mo);
	}
	int ans=0;
	for(int i=1;i<=n;++i)
	{
		for(int j=1;j<=m;++j)
		{
			ans+=((m-j)*(((i*(i-1))/2)%mo))%mo;
			ans%=mo;
			ans+=(m*((((n-i)*(n-i+1))/2)%mo))%mo;
			ans%=mo;
			ans+=((n-i)*(((j*(j-1))/2)%mo))%mo;
			ans%=mo;
			ans+=(n*((((m-j)*(m-j+1))/2)%mo))%mo;
			ans%=mo;
			ans+=(i*((((j)*(j-1))/2)%mo))%mo;
			ans%=mo;
			ans+=(j*((((i)*(i-1))/2)%mo))%mo;
			ans%=mo;	
			// cout<<ans<<" ";
		}
	}
	ans*=modinverse(2,mo);
	ans%=mo;
	int nu=n*m-2;
	int de=k-2;
	// cout<<((fac[nu]*((ifac[nu-de]*ifac[de])%mo))%mo)<<"\n";
	cout<<(ans*((fac[nu]*((ifac[nu-de]*ifac[de])%mo))%mo))%mo;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
int main(){
  int A,B,O=0,tth,th,t,o;
  cin >> A >> B;
  for(int i=A;i<=B;i++){
    o = i % 10;
    t =(i % 100) /10;
    th =(i % 10000) /1000;
    tth = i /10000;
    if(o == tth && t == th) O++;
  }
  cout << O << endl;
}
    
    
  

Measured memory_bytes: 256
(declaim (optimize (speed 0) (safety 3) (debug 3)))
#+sbcl (declaim (sb-ext:unmuffle-conditions sb-ext:compiler-note))
;;(declaim (optimize (speed 3) (safety 0) (debug 0)))

(format t "~:[No~;Yes~]" (loop for i fixnum = (read) then (floor i 10)
			      for r fixnum = (mod i 10)
			      while (/= i 0)
			      when (= r 7) do (return t)
			      finally (return nil)))


Measured memory_bytes: 23744
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <random>
#include <cmath>
#include <iomanip>
#include <climits>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>
#include <bitset>
#include <sstream>
#include <new>
#include <typeinfo>
#include <iterator>

typedef long long ll;
typedef unsigned long long ull;
constexpr ll mop = 1000000007;
constexpr ll mop2 = 998244353;

using namespace std;

signed main() {
	string s;
	cin >> s;
	cout << s.substr(0, 3) << endl;
}

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

#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define MIN(a) *min_element(all(a))
#define MAX(a) *max_element(all(a))
#define SUM(a, b) accumulate(all(a), b)
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define RREP(i, n) for(int (i)=(n)-1; (i)>=0; (i)--)
#define FOR(i, m, n) for(int (i)=(m); (i)<(n); i++)
#define FORR(i, m, n) for(int (i)=(n)-1; (i)>=(m); i--)
#define ios() cin.tie(0), ios::sync_with_stdio(false)
#define debug(x) cerr << #x << " = " << x << endl
//#define int long long

typedef long long ll;
typedef unsigned long long ull;
//ll const MOD = 998244353;
ll const MOD = 1e9+7;
ll const INF = 1e18;

template<typename T> int size(const T& a){return (int)a.size();}
template<typename T> T Div(T a, T b){return (a + b - 1) / b;}
template<typename T> bool chmin(T& a, const T& b){if(a > b){a = b; return true;} return false;}
template<typename T> bool chmax(T& a, const T& b){if(a < b){a = b; return true;} return false;}

//Graph in adjcency list (weighted)
class Graph{
public:
    int N;
    vector<vector<pair<int,ll>>> adjlist;
    vector<ll> depth;
    vector<int> color;

    Graph(int n) : N(n), adjlist(n), depth(n, 0), color(n, 0){}

    void setEdge(int a, int b, ll c){
        adjlist[a].push_back(make_pair(b, c));
    }

    void dfs(int p, int v, ll dep, ll len){
        static vector<bool> check(N, false);
        if(check[v]){
            return;
        }
        check[v] = true;
        if(p != -1){
            color[v] = (color[p] ^ len%2);
        }

        depth[v] = dep + len;

        for(auto i : adjlist[v]){
            if(i.first == p){
                continue;
            }
            dfs(v, i.first, dep+len, i.second);
        }
    }
};

signed main(){
    int n;
    cin >> n;
    Graph G(n);
    REP(i, n-1){
        int a, b;
        ll c;
        cin >> a >> b >> c;
        G.setEdge(a-1, b-1, c);
        G.setEdge(b-1, a-1, c);
    }
    G.dfs(-1, 0, 0, 0);
    for(auto i : G.color) cout << i << endl;
    return 0;
}


Measured memory_bytes: 10240
#include<stdio.h>
int main(){
	int a;
	scanf("%d",&a);
	if(400<=a&&a<=599)
		printf("8");
	else if(600<=a&&a<=799)
		printf("7"); 
	else if(800<=a&&a<=999)
		printf("6");
	else if(1000<=a&&a<=1199)
		printf("5");
	else if(1200<=a&&a<=1399)
		printf("4");
	else if(1400<=a&&a<=1599)
		printf("3");
	else if(1600<=a&&a<=1799)
		printf("2");
	else if(1800<=a&&a<=1999)
		printf("1");   
} 

Measured memory_bytes: 1664
extern crate core;

use std::io::{self, Read};

fn main() {
    let mut input = String::new();
    io::stdin().read_to_string(&mut input).unwrap();
    let output = run(input.trim().to_string());
    println!("{}", output);
}

fn run(input: String) -> String {
    let list = input
        .split("\n")
        .skip(1)
        .map(|x| {
            x.split_whitespace()
                .map(|x| x.parse::<i32>().unwrap())
                .collect::<Vec<_>>()
        })
        .collect::<Vec<_>>();

    let n = list[0].len();
    let mut max = 0;

    //何回目で下に行くか
    for i in 0..n {
        let c = list[0].iter().take(i + 1).sum::<i32>() + list[1].iter().skip(i).sum::<i32>();
        if c > max {
            max = c;
        }
    }
    max.to_string()
}

#[test]
fn test() {
    let tests = vec![
        (
            "5
3 2 2 4 1
1 2 2 2 1",
            "14",
        ),
        (
            "4
1 1 1 1
1 1 1 1",
            "5",
        ),
        (
            "7
3 3 4 5 4 5 3
5 3 4 4 2 3 2",
            "29",
        ),
        (
            "1
2
3",
            "5",
        ),
    ];
    for (i, (input, output)) in tests.into_iter().enumerate() {
        println!("test:{}", i);
        assert_eq!(run(input.to_string()), output.to_string());
    }
}


Measured memory_bytes: 4352
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#define r(i,n) for(int i=0; i<n; i++)
typedef long long ll;
using namespace std;

int main(void){
	long a, b, c, x, y;
	long sum=0;

	cin >> a >> b >> c >> x >> y;
	if(a+b>2*c){
		sum+= min(x,y)*2*c;
		if(x<y){
			sum+=(y-x)*b;
		}else{
			sum+=(x-y)*a;
		}

		if(c*max(x,y)*2<sum){
			cout << c*max(x,y)*2 << endl;
		}else{
			cout << sum << endl;
		}
		
	}else{
		cout << a*x+b*y << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using ll=long long;
using namespace std;
#define rep_i(i, n) for (int i = 0; i < (n); ++i)
#define rep_ll(i, n) for (long long i = 0; i < (n); ++i)
#define r_rep_i(i, start, end) for (int i = (start); i < (end); ++i)
#define r_rep_ll(i, start, end) for (long long i = (start); i < (end); ++i)
#define debug_vi(v) copy((v).begin(), (v).end(), ostream_iterator<int>(cout, " "));
#define debug_vll(v) copy((v).begin(), (v).end(), ostream_iterator<long long>(cout, " "));
#define debug_vd(v) copy((v).begin(), (v).end(), ostream_iterator<double>(cout, " "));
#define sort_v(v) sort((v).begin(), (v).end()); //昇順
#define d_sort_vi(v) sort((v).begin(), (v).end(), greater<int>()); //降
#define d_sort_vll(v) sort((v).begin(), (v).end(), greater<long long>()); //降
#define d_sort_vd(v) sort((v).begin(), (v).end(), greater<double>()); //昇順
#define say(t) cout << (t) << endl;
#define sum_vi(v) accumulate((v).begin(), (v).end(), 0);
#define sum_vll(v)accumulate((v).begin(), (v).end(), 0LL);

ll gcd(ll a, ll b) { return b?gcd(b, a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a, b)*b;}
const int IINF=(1<<30);
const ll LLINF = 1LL<<60;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(0);
  int n; cin >> n;
  
  for (int i = 1; i < 10000000; i++){
    if(i*(i+1)/2 >= n){
      cout << i << endl;
      return 0;
    }
  }
}

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

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

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef pair<int,int> P;
constexpr ll INF = (1LL << 55);

int main(){
  string s, t;
  cin >> s >> t;
  int n = sz(s);
  vector<set<int>> st(26);
  for (int i = 0; i < n; i++) {
    st[s[i] - 'a'].insert(i);
    st[s[i] - 'a'].insert(i + n);
  }
  ll res = 0;
  int m = sz(t);
  int id = 0;
  for (int i = 0; i < m; i++) {
    if (st[t[i] - 'a'].empty()) {
      cout << -1 << endl;
      return 0;
    }
    auto itr = *st[t[i] - 'a'].lower_bound(id) + 1;
    if (itr >= n) itr %= n, res += n;
    id = itr;
  }
  res += id;
  cout << res << endl;
  return 0;
} 

Measured memory_bytes: 9856
#include <bits/stdc++.h>
using namespace std;
int main(){
    string n;
    cin>>n;
  if(n[0]==n[1] && n[1]==n[2]||n[1]==n[2] && n[2]==n[3]){
    cout<<"Yes"<<endl;
  }
  else cout<<"No"<<endl; 
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;
struct People
{
	int l,r;
	bool operator<(const People &p)const
	{
		return r>p.r;
	}
}p[202020];
struct Node
{
	Node *lch,*rch;
	int l,r;
	int ma,lz;
}*rt;
void add(Node *x,int v)
{
	x->ma+=v;
	x->lz+=v;
}
void down(Node *x)
{
	if(x->lz)
	{
		add(x->lch,x->lz);
		add(x->rch,x->lz);
		x->lz=0;
	}
}
void update(Node *x)
{
	x->ma=max(x->lch->ma,x->rch->ma);
}
Node *Build(int l,int r)
{
	Node *ret=new Node;
	ret->l=l;
	ret->r=r;
	ret->lz=0;
	if(l==r)
	{
		ret->ma=-l;
		ret->lch=ret->rch=NULL;
		return ret;
	}
	int mid=(l+r)>>1;
	ret->lch=Build(l,mid);
	ret->rch=Build(mid+1,r);
	update(ret);
	return ret;
}
void modify(Node *x,int l,int r)
{
	if(l<=x->l&&r>=x->r)
	{
		add(x,1);
		return ;
	}
	down(x);
	int mid=(x->l+x->r)>>1;
	if(l<=mid)
		modify(x->lch,l,r);
	if(mid<r)
		modify(x->rch,l,r);
	update(x);
}
int main()
{
	int n,m,now=1,ans=0;
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)
		scanf("%d%d",&p[i].l,&p[i].r);
	sort(p+1,p+1+n);
	rt=Build(0,m);
	for(int i=m+1;i>=0;i--)
	{
		while(now<=n&&p[now].r==i)
		{
			modify(rt,p[now].l,m);
			now++;
		}
		ans=max(ans,rt->ma-m-1+i);
	}
	printf("%d",max(ans,n-m));
	return 0;
}

Measured memory_bytes: 20608