akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Diagnostics;
class Program
{
    public static Scanner cin;
    static void Main()
    {
        cin = new Scanner();
        
        int[] nk = cin.arrayInt(2);
        int n = nk[0];
        int k = nk[1];
        string s = ReadLine();
        List<int> renzoku = new List<int>();
        int count = 0;
        int now = 1;
        if (s[0] == "0"[0]) {
            renzoku.Add(0);
            now = 0;
        }
        for (int a = 0; a < n; a++)
        {
            if (now == int.Parse(s[a].ToString())) count++;
            else
            {
                now ^= 1;
                renzoku.Add(count);
                count = 0;
                count++;
            }
            
        }
        renzoku.Add(count);
        if (s[s.Length-1] == "0"[0])
        {
            renzoku.Add(0);
        }
        //累積和
        var sum = new int[renzoku.Count+1];
        for(int a = 0; a < renzoku.Count; a++)
        {
            sum[a + 1] = renzoku[a] + sum[a];
        }
        int max = 0;
        for(int a = 0; a < renzoku.Count; a+=2)
        {
            int left = a;
            int right = Math.Min(a + k * 2 + 1, renzoku.Count);

            max = Math.Max(max,sum[right]-sum[left]);
        }

        WriteLine(max);
        Console.ReadLine();

    }
}





class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string input()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return input();
        i = 0;
        return s[i++];
    }

    public int inputInt()
    {
        return int.Parse(input());
    }
    public int[] arrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = inputInt() + add;
        }
        return Array;
    }

    public long inputLong()
    {
        return long.Parse(input());
    }

    public long[] arrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = inputLong() + add;
        }
        return Array;
    }

    public double inputDouble()
    {
        return double.Parse(input());
    }


    public double[] arrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = inputDouble() + add;
        }
        return Array;
    }
}

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

#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

int main() {
    int64_t n, m;
    cin >> n >> m;

    unordered_map<int64_t, int64_t> nums;
    ++nums[0];
    int64_t ans = 0, s = 0;
    for (auto _ : irange(0L, n)) {
        int64_t a;
        cin >> a;
        s += a;
        ans += nums[s % m]++;
    }

    cout << ans << endl;
}

Measured memory_bytes: 3596
import itertools
import math
H,W,A,B=map(int,raw_input().split())

mod=10**9+7


FACT={}
FACT_INVERSE={}

n=1
for i in range(H+W-1):
	if i==0: n=1
	else: n=(n*i)%mod
	FACT[i]=n

#print FACT

def C(n,r):
	return (FACT[n]*pow(FACT[r],10**9+5 ,mod)*pow(FACT[n-r],10**9+5 ,mod)) %mod


p=0
for i in range(B,W):
	p+=C(H-A-1+i,i)*C(A-1+W-i-1,W-i-1)
	p=p%mod


print p




Measured memory_bytes: 31672
using System;
using System.Collections.Generic;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(' ');
            var a = int.Parse(input[0]);
            var b = int.Parse(input[1]);
            var c = int.Parse(input[2]);

            var manzoku = a * c;
            if (b > manzoku)
            {
                Console.WriteLine(c);
            }
            else
            {
                Console.WriteLine(b / a);
            }
        }
    }
}


Measured memory_bytes: 13140
import java.util.*;
public class Main{
    public static void main(String[] args){
	new Main().run();
    }
    Scanner sc = new Scanner(System.in);

    int n, a, b, c, d;
    Team[] team;
    int[] re;

    void run(){
	while(sc.hasNext()){
	    n = sc.nextInt();
	    re = new int[n];
	    team = new Team[n];
	    for(int i=0; i<n; i++)
		team[i] = new Team(i+1);

	    for(int i=0; i<(n*(n-1))/2; i++){
		a = sc.nextInt()-1;
		b = sc.nextInt()-1;
		c = sc.nextInt();
		d = sc.nextInt();

		if(c>d){
		    team[a].result(3);
		    team[b].result(0);
		}
		else if(c==d){
		    team[a].result(1);
		    team[b].result(1);
		}
		else{
		    team[a].result(0);
		    team[b].result(3);
		}
	    }

	    Arrays.sort(team, new Comparator<Team>(){
		    public int compare(Team a, Team b){
			int x1 = a.getPoint();
			int x2 = b.getPoint();
			return x2-x1;
		    }
		}
		);

	    int prev = -1;
	    int rank = 1;
	    int tmp = 0;
	    for(int i=0; i<n; i++){
		int num = team[i].getNumber()-1;
		int p = team[i].getPoint();
		//System.out.println((num+1)+" "+p);
		if(prev==-1)
		    re[num] = rank;
		else if(p==prev){
		    re[num] = rank;
		    tmp++;
		}
		else{
		    rank += (tmp+1);
		    re[num] = rank;
		    tmp = 0;
		}
		prev = p;
	    }

	    for(int i=0; i<n; i++)
		System.out.println(re[i]);
	}
    }

    class Team{
	int number, point;
	Team(int n){
	    number = n;
	    point = 0;
	}
	void result(int p){ point += p; }
	int getPoint(){ return point; }
	int getNumber(){ return number; }
    }
}

Measured memory_bytes: 42292
#include <bits/stdc++.h>
using namespace std;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rp(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define p_queue(v) priority_queue<v, vector<v>, greater<v> >
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////

void solve(){
    char ch;
    cin >> ch;
    int c=ch-'a';
    if(0<=c&&c<=25) print('a');
    else print('A');
    return;
}
int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(30);
    solve();
    return 0;
}

Measured memory_bytes: 3644
#include<iostream>
#include<algorithm>

using namespace std;

int main(){

    while(1){
        int R0, W0, C, R;
        cin>> R0>> W0>> C>> R;
        if(!(R0||W0||C||R)) break;
        for(int x=0; ; x++){
            double noud=1.*(R0+x*R)/W0;
            if(noud>=C){
                cout<< x<< endl;
                break;
            }
        }
    }

    return 0;
}

Measured memory_bytes: 3108
while True:
    n = int(input())
    if n == 0:
        break
    total = [0] * (n + 1)
    for i in range(n):
        a = [int(i) for i in input().split()]
        a.append(sum(a))
        for j in range(n + 1):
            print("%5d" % (a[j]), end = "")
            total[j] += a[j]
        print()
    for i in range(n + 1):
        print("%5d" % (total[i]), end = "")
    print()

Measured memory_bytes: 7660
#include<iostream>

   using namespace std;

  int main(void)
  {
	  int n, a, b;
	  cin >> n;
	  if (n == 1)
	  {
		  cout << "Hello World";
	  }
	  if (n == 2)
	  {
		  cin >> a >> b;
		  cout << a + b;
	  }
	  return 0;
  }

Measured memory_bytes: 256
def read_input():
    s = input()
    t = input()

    return s, t


# 長さn、tを含むパターンを形成
def make_pattern(n, t):
    m = len(t)

    patterns = []
    for i in range(n - m + 1):
        patterns.append(['?'] * i + t + ['?'] * (n - i - m))

    return patterns

# aとbの要素ごとの比較
# ?と*はいずれともマッチする
def check_match(a, b):
    def convert(x, y):
        if x == '?' and y == '?':
            return 'a'
        if x == y:
            return x
        if x == '?':
            return y
        if y == '?':
            return x
        return None

    result = []
    for i in range(len(a)):
        result.append(convert(a[i], b[i]))

    return result

def submit():
    s, t = read_input()

    s = [c for c in s]
    t = [c for c in t]

    patterns = make_pattern(len(s), t)

    candidates = [check_match(s, p) for p in patterns]
    candidates = [''.join(c) for c in candidates if None not in c]
    candidates.sort()

    if candidates:
        print(candidates[0])
    else:
        print('UNRESTORABLE')

if __name__ == '__main__':
    submit()

Measured memory_bytes: 3064
package main

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

func main() {
	C := readstr()
	fmt.Println(string(C[0] + 1))
}

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.sql.SQLOutput;
import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int count[] = new int[26];
        while(scan.hasNext()) {
            String s;
            s = scan.nextLine();
            s = s.toLowerCase();
            for (int i = 0; i < s.length(); i++) {
                int d = s.charAt(i) - 'a';
                if (d >= 0 && d < 26) {
                    count[d]++;
                }
            }
            
        }
        for (int i = 0; i < 26; i++) {
            System.out.println((char) (i + 'a') + " : " + count[i]);
        }
    }
}



Measured memory_bytes: 26368
#include <bits/stdc++.h>
#define ROOP(i, N) for(int i=0; i++; i<N)
#define RVROOP(i, N) for(int i=N; i--; i>=0)
#define ALL(v) v.begin(), v.end()
const int INF = 1e9;
const int MAX = 10000;
const int MOD = 1000000007;
using namespace std;
typedef long long ll;

/*DP使ったほうがよくない？？WOWWOW*/
ll dp[100005][13];

int main(){
    string S; cin>>S;
    int N=S.size();
    dp[0][0]=1;
    for(int i=0; i<N; i++){
        int c;
        if(S.at(i)=='?'){
            c=-1;
        }
        else{
            c=S.at(i)-'0';
        }
        for(int j=0; j<10; j++){
            if(c!=-1 && c!=j){
                continue;
            }
            for(int k=0; k<13; k++){
                dp[i+1][(k*10+j)%13]+=dp[i][k];
            }
        }
        for(int j=0; j<13; j++){
            dp[i+1][j]%=MOD;
        }
    }
    cout<<dp[N][5]<<endl;
    return 0;
}

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

int main(){

    int a,b,c;
    int i;
    cin >> a;
    i = 1;
    cin >> b;
    if(a != b){
        i++;
    }
    cin >> c;
    if((a!=c)&&(b!=c)){
        i++;
    }

    cout << i << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
    public static void inorder(Node root){
        if(root == null)
            return;
        if(root.left != null)
            inorder(root.left);
        System.out.print(" " + root.key);
        if(root.right != null)
            inorder(root.right);
    }
    public static void preorder(Node root){
        if(root == null)
            return;
        System.out.print(" " + root.key);
        if(root.left != null)
            preorder(root.left);
        if(root.right != null)
            preorder(root.right);
    }
    public static void insert(Tree T, Node k){
        Node y = new Node(0);
        Node x = T.root;
        while(x != null){
            y = x;
            if(k.key < x.key)
                x = x.left;
            else
                x = x.right;
        }
        k.parent = y;
        if(y == null)
            T.root = k;
        else if(k.key < y.key)
            y.left = k;
        else
            y.right = k;
    }
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int m = sc.nextInt();
        String nul = sc.next();
        Node first = new Node(sc.nextInt());
        Tree T = new Tree(first);
        for(int i = 1 ; i < m ; i++){
            String order = sc.next();
            if(order.equals("print")){
                inorder(T.root);
                System.out.println();
                preorder(T.root);
                System.out.println();
            }
            else{
                int v = sc.nextInt();
                insert(T,new Node(v));
            }
        }
    }
}
class Tree{
    Node root = null;
    Tree(Node root){
        this.root = root;
    }
}
class Node{
    int key;
    Node parent;
    Node left = null;
    Node right = null;
    Node(int key){
        this.key = key;
    }
}


Measured memory_bytes: 203504
#include <stdio.h>

int n,A[20];

int search(int i,int m){
  if(m==0) return 1;
  if(i>=n)return 0;
  int res=search(i+1,m)||search(i+1,m-A[i]);
    return res;
}

int main(){
  int q,i,m;

  scanf("%d",&n);
  for(i=0;i<n;i++)  scanf("%d",&A[i]);
  scanf("%d",&q);

  for(i=0;i<q;i++) {
       scanf("%d",&m);
       if(search(0,m))printf("yes\n");
       else printf("no\n");
  }
  return 0;
}







Measured memory_bytes: 2108
//15 Puzzle
#include <iostream>
#include <string>
#include <queue>
#include <map>

using namespace std;

static const int N = 4;
static const int N2 = 16;
static const int LIMIT = 100;
static const char dir[4] = {'u', 'l', 'd', 'r'};
static const int dx[4] = {0, -1, 0, 1};
static const int dy[4] = {1, 0, -1, 0};

int MDT[N2][N2];
int path[LIMIT];

struct Puzzle {
    int f[N2];
    int space;
    int MD;
};

int getAllMD(Puzzle p) {
    int sum = 0;
    for(int i = 0; i < N2; i++) {
        if(p.f[i] == N2) continue;
        sum += MDT[i][p.f[i] - 1];
    }
    return sum;
}

bool dfs(Puzzle p, int limit, int depth, int prev) {
    if(p.MD == 0) return true;
    if(depth + p.MD > limit) return false;

    int sx = p.space % N;
    int sy = p.space / N;
    Puzzle q;

    for(int r = 0; r < 4; r++) {
        if(max(prev, r) - min(prev, r) == 2) continue;
        int tx = sx + dx[r];
        int ty = sy + dy[r];
        if(tx < 0 || ty < 0 || tx >= N || ty >= N) continue;
        q = p;
        q.space = tx + N * ty;
        swap(q.f[q.space], q.f[p.space]);
        q.MD -= MDT[q.space][p.f[q.space] - 1];
        q.MD += MDT[p.space][p.f[q.space] - 1];
        if(dfs(q, limit, depth + 1, r)) {
            path[depth] = r;
            return true;
        }
    }
    return false;
}

string iterative_deepening(Puzzle in) {
    in.MD = getAllMD(in);
    for(int limit = in.MD; limit <= LIMIT; limit++) {
        if(dfs(in, limit, 0, -100)) {
            string ans = "";
            for(int i = 0; i < limit; i++) ans += dir[path[i]];
            return ans;
        }
    }
    return "unsolvable";
}

int main() {
    for(int i = 0; i < N2; i++) {
        for(int j = 0; j < N2; j++) {
            MDT[i][j] = abs(i / N - j / N) + abs(i % N - j % N);
        }
    }

    Puzzle in;
    for(int i = 0; i < N2; i++) {
        cin >> in.f[i];
        if(in.f[i] == 0) {
            in.f[i] = N2;
            in.space = i;
        }
    }

    cout << iterative_deepening(in).size() << endl;
}


Measured memory_bytes: 3212
package main

import (
	"fmt"
)

func main() {
	var s, t string
	fmt.Scanf("%s", &s)
	fmt.Scanf("%s", &t)

  	min := len(t)
  for i := 0; i <= len(s)-len(t); i++ {
      	unmuch := 0
    	for j := 0; j < len(t); j++ {
            if s[i+j:i+j+1] != t[j:j+1] {
            	unmuch++
            }
        }
        if min > unmuch {
          	min = unmuch
        }
	}
	ans := min
	fmt.Printf("%d\n", ans)
}


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

// using ll = long long;
#define int long long

#define LOG(variable) cout << #variable":\t" << (variable) << endl
#define LOGCON(i, container) for(int (i) = 0; (i) < (container).size(); ++(i)) cout << (i) << ":\t" << (container)[(i)] << endl
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPS(i, r, n) for (int i = (r); i < (n); ++i)
#define REPR(i, n) for(int i = (n); i >= 0; --i) // from n to 0
#define REPRS(i, r, n) for(int i = (n); i >= (r); --i) // from n to r
#define REPOBJ(itr, obj) for(auto itr = (obj).begin(); itr != (obj).end() ; ++itr)
#define REPROBJ(itr, obj) for(auto itr = (obj).rbegin(), e = (obj).rend(); itr != e; ++itr)
#define COUTB(x) cout << (x) << "\n"
#define COUTS(x) cout << (x) << " "
#define PB push_back
#define SORT(obj) sort((obj).begin(), (obj).end())
#define SORTR(obj) sort((obj).begin(), (obj).end(), greater<>())
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define PI (acos(-1))
/***** MAIN *****/
signed main() {
  int sx, sy, tx, ty;
  cin >> sx >> sy >> tx >> ty;
  int dx = tx - sx;
  int dy = ty - sy;

  if(dx && dy) {
    REP(i,dx) cout << "R";
    REP(i,dy) cout << "U";
    REP(i,dx) cout << "L";
    REP(i,dy) cout << "D";
    cout << "D";
    REP(i,dx+1) cout << "R";
    REP(i,dy+1) cout << "U";
    cout << "L";
    cout << "U";
    REP(i,dx+1) cout << "L";
    REP(i,dy+1) cout << "D";
    cout << "R";
  } else if(dx) {
    REP(i,dx) cout << "R";
    cout << "U";
    REP(i,dx) cout << "L";
    cout << "D";
    cout << "D";
    REP(i,dx) cout << "R";
    cout << "U";
    cout << "R";
    cout << "UU";
    REP(i,dx+2) cout << "L";
    cout << "DD";
    cout << "R";
  } else {
    REP(i,dy) cout << "U";
    cout << "L";
    REP(i,dy) cout << "D";
    cout << "R";
    cout << "R";
    REP(i,dy) cout << "U";
    cout << "L";
    cout << "U";
    cout << "LL";
    REP(i,dy+2) cout << "D";
    cout << "RR";
    cout << "U";
  }
  
  cout << "\n";
  return 0;
}
/***** MAIN *****/


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define sc(x) scanf("%d",&x)
#define sc2(x,y) scanf("%d%d",&x, &y)
#define sc3(x,y,z) scanf("%d%d%d",&x, &y, &z)
#define pr(a) printf("%d\n",a)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define ll long long
#define F first
#define S second
#define inf INT_MAX
const int N = 1e5 + 5;
int n, m, x, y, k, ans;
int a[15], sum;
int main(){	
	string s;
	cin >> n;
	cin >> s;
	int cur = 0;
	for (int i = 0; i < n; i++){
		if (s[i] == 'I')++cur;
		else --cur;
		ans = max(ans, cur);
	}
	
	pr(ans);
	return 0;
}









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

int main()
{
    int n, a;
    cin >> n >> a;
    cout << n*n-a << "\n";
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <vector>

int main(int argc, char** argv) {
  int N; std::cin >> N;
  std::string S; std::cin >> S;
  std::string T; std::cin >> T;
  std::vector<char> new_string;
  for (auto i = 0;i < N;++i) {
    new_string.push_back(S[i]);
    new_string.push_back(T[i]);
  }
  for (const auto& e : new_string) {
    std::cout << e;
  }
  std::cout << '\n';
}


Measured memory_bytes: 256
def findSumOfDigits(n):
    sum = 0
    while n > 0:
        sum += n % 10
        n //= 10
    return int(sum)

N,a,b = map(int,input().split())
c = 0
total =0
for i in range(N+1):
    c = findSumOfDigits(i)
    if a <= c <= b:
        # print(i)
        # print(c)
        total += i
        # print(total)
print(total)

Measured memory_bytes: 9120
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr long long INFL = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



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

    int N;
    cin >>N;
    cout << "ABC" << N << endl;



}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
int a,b;
char op;
while(1){
cin >> a >> op >> b;
if(op=='?')break;
if(op=='+') cout << a+b <<endl;
else if(op=='-') cout << a-b <<endl;
else if(op=='*') cout << a*b <<endl;
else if(op=='/') cout << a/b <<endl;
}
return 0;
}


Measured memory_bytes: 3092
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back

using namespace std;
long long arr[105],n,sum,cap[105][105],maxflow,pre[105];

queue <pair<long long, long long> > q;
vector<long long> adj[105];
const long long inf = 1e18;
long long bfs(){
	while(!q.empty())q.pop();
	pre[0]=-2;
	q.push({0ll,inf});
	while(!q.empty()){
		long long cur  = q.front().fi;
		long long flow = q.front().se;
		q.pop();
		for(auto v: adj[cur]){
			// cout<<v<<' '<<cur<<' '<<cap[cur][v]<<endl;
			if(pre[v]==-1&&cap[cur][v]>0){
				pre[v]=cur;
				long long newflow = min(flow,cap[cur][v]);
				if(v==n+1)return newflow;
				q.push({v,newflow});
			}
		}
	}
	return 0;
}
int main(){
	cin>>n;
	for(long long i =1;i<=n;i++){
		cin>>arr[i];
		
		if(arr[i]>=0){
			adj[i].pb(n+1);
			adj[n+1].pb(i);
			cap[i][n+1]+=arr[i];
			sum+=arr[i];
		}
		if(arr[i]<0){
			adj[i].pb(0);
			adj[0].pb(i);
			cap[0][i]-=arr[i];
		}
		for(int j =2*i;j<=n;j+=i){
			adj[i].pb(j);
			adj[j].pb(i);
			cap[i][j]= inf;
		}
	}
	while(1){
		memset(pre,-1,sizeof(pre));
		long long add =bfs();
		if(add==0)break;
		maxflow+=add;
		long long cur = n+1;
		while(cur!=0){
			long long prev = pre[cur];
			cap[prev][cur]-=add;
			cap[cur][prev]+=add;
			cur=prev;
		}
	}
	// cout<<maxflow<<endl;
	cout<<sum-maxflow<<endl;

}

Measured memory_bytes: 3740
n = int(input())
a = list(map(int,input().split()))
an = max(a)
mi = -1
ms = 10**10
an2 = an/2
for i in a:
    if ms > abs(i-an2) and not an == i:
        mi = i
        ms = abs(i-an2)

print(an,mi)


Measured memory_bytes: 14428
#include <bits/stdc++.h>
using namespace std;
#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(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }
#define bit(k) (1LL<<(k))
typedef long long ll;

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

const int INF = 1e9;
const ll INFLL = 1e18;
const ll MOD = 1e9+7;
const double PI = acos(-1.0);

const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

/*------------------------------------/
for library*/

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

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

    int N,M;cin>>N>>M;
    cout<<((N==M)?"Yes":"No")<<endl;
}

Measured memory_bytes: 256
/**
 * File    : C.cpp
 * Author  : Kazune Takahashi
 * Created : 12/9/2018, 10:32:26 PM
 * Powered by Visual Studio Code
 */

#include <iostream>
#include <iomanip>   // << fixed << setprecision(xxx)
#include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ;
#include <vector>
#include <string> // to_string(nnn) // substr(m, n) // stoi(nnn)
#include <complex>
#include <tuple>
#include <queue>
#include <stack>
#include <map> // if (M.find(key) != M.end()) { }
#include <set>
#include <functional>
#include <random> // auto rd = bind(uniform_int_distribution<int>(0, 9), mt19937(19920725));
#include <chrono> // std::chrono::system_clock::time_point start_time, end_time;
// start = std::chrono::system_clock::now();
// double elapsed = std::chrono::duration_cast<std::chrono::milliseconds>(end_time-start_time).count();
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;

#define DEBUG 0 // change 0 -> 1 if we need debug.

typedef long long ll;

// const int dx[4] = {1, 0, -1, 0};
// const int dy[4] = {0, 1, 0, -1};

const int C = 5000;
// const ll M = 1000000007;

int N, A;
int x[50];

ll DP[60][10000];

int main()
{
  cin >> N >> A;
  for (auto i = 0; i < N; i++)
  {
    cin >> x[i];
    x[i] -= A;
  }
  fill(&DP[0][0], &DP[0][0] + 60 * 10000, 0);
  DP[0][C] = 1;
  for (auto i = 0; i < N; i++)
  {
    for (auto j = 0; j < 10000; j++)
    {
      if (DP[i][j] == 0)
      {
        continue;
      }
      DP[i + 1][j] += DP[i][j];
      DP[i + 1][j + x[i]] += DP[i][j];
    }
  }
  cout << DP[N][C] - 1 << endl;
}

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

using namespace std;

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

    int n;
    cin >> n;
    cout << ((n + 999) / 1000) * 1000 - n;

    return 0;
}


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

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

const int INF = 1e9;
const int mod = 1e9+7;

int a[26],b[26];

int main()
{
    string s,t;
    cin >> s >> t;
    for(int i = 0; i < s.length(); i++){
        a[s[i]-'a']++;
        b[t[i]-'a']++;
    }

    sort(a,a+26);
    sort(b,b+26);
    
    for(int i = 0; i < 26; i++){
        if(a[i] != b[i]){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

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

using namespace std;

int main()
{
    int N;
    cin >> N;
    string S[N];
    map<string, int> count;
    for (int i = 0; i < N; i++)
    {
        cin >> S[i];
        count[S[i]]++;
    }
    int max = 0;
    for (auto const &entry : count)
    {
        if (entry.second > max)
        {
            max = entry.second;
        }
    }
    for (auto const &entry : count)
    {
        if (entry.second == max)
        {
            cout << entry.first << endl;
        }
    }
}

Measured memory_bytes: 26752
#include <bits/stdc++.h>
using namespace std;
#define REP(i, a, b) for (int i = (a), _end_ = (b); i < _end_; ++i)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define X first
#define Y second
#define mp make_pair
#define eb emplace_back
#define SZ(x) (int((x).size()))
#define ALL(x) (x).begin(), (x).end()

template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }

typedef long long LL;
typedef long double LD;
typedef pair<int, int> pii;
typedef unsigned long long uLL;

template <typename T> inline void Read(T &x) {
    char c = getchar();
    bool f = false;
    for (x = 0; !isdigit(c); c = getchar()) {
        if (c == '-') {
            f = true;
        }
    }
    for (; isdigit(c); c = getchar()) {
        x = x * 10 + c - '0';
    }
    if (f) {
        x = -x;
    }
}

const int MAX_N = 1e5 +5;
const double eps = 1e-8;
const double PI = acos(-1.0);
const int INF = 0x3f3f3f3f;
const int MOD = 1e9 + 7;

int h, w, k;
LL dp[105][10];

int main() {
#ifdef ANONYM
    freopen("in", "r", stdin);
    freopen("out", "w", stdout);
#endif

    Read(h), Read(w), Read(k);
    dp[0][0] = 1;

    for (int i=1; i<=h; i++) {
        for (int p=0; p<w; p++) {
            for (int j=0; j<(1<<(w-1)); j++) {
                bool f = false;
                int q = p;
                for (int l=0; l<w-1; l++) {
                    if (((j>>l)&1) && ((j>>(l+1))&1)) f = true;
                }
                if (f) continue;

                if ((j>>p) & 1) {
                    q = p + 1;
                } else if (p>0 && ((j>>(p-1))&1)) {
                    q = p - 1;
                }

                dp[i][q] = (dp[i][q] + dp[i-1][p]) % MOD;
            }
        }
    }

    printf("%lld\n", dp[h][k-1]);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cmath>
#include <vector>
#include <numeric>

using namespace std;

template<class T>
using vc = vector<T>;

using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;

int main() {
    cout << setprecision(20) << fixed;

    int n;
    cin >> n;

    auto ans = vvvi(4, vvi(3, vi(10)));

    for (auto i = std::size_t(0); i < n; ++i) {
        int b, f, r, v;
        cin >> b >> f >> r >> v;
        ans[b-1][f-1][r-1] += v;
    }

    for (auto b = std::size_t(0); b < 4; ++b) {
        for (auto f = std::size_t(0); f < 3; ++f) {
            for (auto r = std::size_t(0); r < 10; ++r) {
                cout << " " << ans[b][f][r];
            }
            cout << "\n";
        }
        if (b != 3) {
            for (auto i = std::size_t(0); i < 20; ++i) {
                cout << "#";
            }
            cout << "\n";
        }
    }
    return 0;
}



Measured memory_bytes: 3148
package main

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

func readSlice(n int, sc *bufio.Scanner) []int {
	a := make([]int, n)
	for i := range a {
		sc.Scan()
		a[i], _ = strconv.Atoi(sc.Text())
	}
	return a
}

func abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

func search(a []int, f func(int) bool) int {
	ok := len(a)
	ng := -1
	for abs(ok-ng) > 1 {
		mid := (ok + ng) / 2
		if f(mid) {
			ok = mid
		} else {
			ng = mid
		}
	}
	return ok
}

func lowerbound(a []int, x int) int {
	return search(a, func(i int) bool { return a[i] >= x })
}

func upperbound(a []int, x int) int {
	return search(a, func(i int) bool { return a[i] > x })
}

func main() {
	n := 0
	fmt.Scan(&n)
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	a := readSlice(n, sc)
	b := readSlice(n, sc)
	c := readSlice(n, sc)

	sort.Ints(a)
	sort.Ints(c)
	ans := int64(0)
	for _, e := range b {
		ans += int64(lowerbound(a, e)) * int64(n-upperbound(c, e))
	}
	fmt.Println(ans)
}


Measured memory_bytes: 6016
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"

using namespace std;

const long long int MOD = 1000000007;

long long int N, M, K, H, W, L, R;


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

	cin >> N >> M;
	vector<int>a(N + 1);
	vector<int>b(N + 1);
	vector<vector<int>>edge(N + 1);
	string s;
	cin >> s;
	vector<int>can(N + 1, 1);
	can[0] = 0;
	for (int i = 0; i < M; i++) {
		cin >> L >> R;
		edge[L].push_back(R);
		edge[R].push_back(L);
		if (s[L - 1] == 'B')b[R]++;
		else a[R]++;
		if (s[R - 1] == 'B')b[L]++;
		else a[L]++;
	}
	queue<int>Q;
	for (int i = 1; i <= N; i++) {
		if (a[i] && b[i])continue;
		Q.push(i);
		can[i] = false;
	}
	while (!Q.empty()) {
		int cn = Q.front();
		Q.pop();
		for (auto i : edge[cn]) {
			if (!can[i])continue;
			if (s[cn-1] == 'B') {
				b[i]--;
			}
			else {
				a[i]--;
			}
			if (a[i] && b[i])continue;
			Q.push(i);
			can[i] = 0;
		}
	}
	int ans = 0;
	for (auto i : can)ans += i;
	if (ans)cout << "Yes\n";
	else cout << "No\n";
	return 0;
}


Measured memory_bytes: 12880
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
typedef vector<ll> vel;
typedef vector<str> ves;
#define REP(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
#define rep(i, b) REP(i, 0, b)
const ll mod = 1000000007;
const double pi = 3.14159265358979;

int main() {
    ll N;
    cin >> N;
    if(N/100 == N%10) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())

template<typename T>
T mod(T a, T b){
    return (a + b) % b;
}

template<typename T>
T gcd(T a, T b){
    if (b == 0) return a;
    return gcd(b, a % b);
}

ll lcm(ll a, ll b){
    return a * b / gcd(a,b);
}

// n を素因数分解
map<ll, ll> factor(ll n){
    map<ll, ll> mp;
    for (ll i = 2; i*i <= n; i++) {
        while (n % i == 0) {
            mp[i]++;
            n /= i;
        }
    }

    if (n > 1) {
        mp[n]++;
    }

    return mp;
}

// 文字列に "hoge" が含まれているか
// string str = "hogepiyo";
// if (str.find("hoge") != string::npos) {
//     cout << "文字列が含まれています" << endl;
// }

// char to string
// char c = 'a';
// string str = {c};

void solve(){
    int N, M;
    cin >> N >> M;

    vi K(M+1,0);
    for (int i = 0; i < N; i++) {
        int k;
        cin >> k;
        for (int i = 0; i < k; i++) {
            int A;
            cin >> A;
            K[A]++;
        }
    }

    int ans = 0;
    for (int i = 1; i <= M; i++) {
        if (K[i] == N) {
            ans++;
        }
    }

    cout << ans << endl;

    return;
}

int main(int argc, char const* argv[])
{
    solve();
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef unsigned long long int ulli;
const lli INF = 1e9 + 100;
const lli INF64 = (1LL << 61) + 100;
const lli MOD = 1e9 + 7;
const lli MH1 = 1599614977, MH2 = 2034417103, MH3 = 1090250123, MH4 = 2024491871; 
const int N = 1e5 + 10;
int dp[N];
int nums[N];
lli bpow(lli baseee, lli exponenttt) {
	if(exponenttt < 0) return 0;
	lli res = 1;
	baseee %= MOD;
	while (exponenttt > 0) {
		if ((exponenttt & 1) == 1) res = (res*baseee) % MOD;
		baseee = (baseee*baseee) % MOD;
		exponenttt >>= 1;
	}
	return res;
}
lli multInverse(lli a) {//if_mod_is_prime
	return bpow(a, MOD - 2);
}
lli divm(lli a, lli b) {//if_mod_is_prime
	return (a * multInverse(b)) % MOD;
}
lli multm(lli a, lli b) {
	return (a * b) % MOD;
}
lli subm(lli a, lli b) {
	a += MOD;
	lli r = a - b;
	if(r >= MOD) return r - MOD;
	return r;
}
lli addm(lli a, lli b) {
	lli r = a + b;
	if(r >= MOD) return r - MOD;
	return r;
}
signed main() {
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	//	freopen("input.txt", "r", stdin);
	//	freopen("output.txt", "w", stdout);
	int n, k;
	cin >> n >> k;
	for(int i = 1; i <= n; i++) cin >> nums[i];
	dp[1] = 0;
	dp[2] = abs(nums[1] - nums[2]);
	for(int i = 3; i <= n; i++) {
		dp[i] = 1e9 + 10;
		for(int j = i-1; j >= max(1, i - k); j--)
			dp[i] = min(dp[i], dp[j] + abs(nums[i] - nums[j]));
	}
	cout << dp[n] << "\n";
	
	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int n,t,x,y;
int main(){
    cin>>n;
    while(n--){
        cin>>t;
        cin>>x>>y;
        if(x+y<=t&&(t-x-y)%2==0) continue;
        cout<<"No"<<endl;
        exit(0);
    }
    cout<<"Yes"<<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>;
using vv = vector<vector<ll> >;
template <class _t> inline bool chmax (_t& a,_t b){if(a<b){a=b;return true;}return false;} template <class _t> inline bool chmin (_t& a,_t b){if(a>b){a=b;return true;}return false;}

const int INF = 2147483647;
const long long inf = 1ll << 60;
const long long mod = 1000000007;

int dx[4] = {1,0,-1,0};
int dy[4] = {0,-1,0,1};
int main(){
    int n; cin >> n;
    int ans = 0;
    for(int i=1;i<=n;i++){
        int a;cin >> a;
        if(i%2==0) continue;
        if(a%2==1) ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3620
#include <iostream>
#include <algorithm>

#define SIZE 200000

using namespace std;

int main() {
    long long int A,B,i,j,k,M,K,Q;
    long X,N,Y,Z,r;

  //  long long int A[100][100];

cin >> K;

A = 7 % K;
r=1;
while ((r<=K) && (A !=0)) {
  B = (10*A + 7) % K;
  A = B;
  r++;
}

if (A == 0)
  cout << r << endl;
else
  cout << "-1" << endl;
  return 0;

}


Measured memory_bytes: 3628
s=str(input())
t=str(input())
count=0
for i in range(len(s)):
	for j in range(len(t)):
		if s[i] < t[j]:
			count+=1
if set(s) == set(t):
	if len(s) < len(t):
		count+=1
print('Yes' if count !=0 else 'No')

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

int main() {
  int K,N;
  cin>>K>>N;
  vector<int> a(2*N);
  for(int i=0;i<N;i++) {
    cin>>a[i];
    a[i+N]=a[i]+K;
  }
  int ans=K;
  for(int i=0;i<N;i++)
    ans=min(ans,a[i+N-1]-a[i]);
  cout<<ans<<endl;
}
    


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

using namespace std;

typedef long long ll;

const int N = 1e8;
const int INF = 1e9;
const int MOD = 998244353;



int main() {
    string s;
    cin >> s;
    int n = s.size();
    bool av = 0;
    int ans = 0;
    for (int i = 0; i < n; i++) {
        ans += (s[i] == 'p' ? 0 : 1);
        if (!av)
            ans--;
        av = 1 - av;
    }
    cout << ans;
}

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <stack>
#include <math.h>
#include <algorithm>
#include <cstdlib>
#include <ctime>
#include <vector>

using namespace std;






int main()
{
	long long d;
	while (cin >> d) {
		long long sum = 0;
		for (long long i = 1; i <= (600 / d - 1); i++) {
			sum += i*i*d*d*d;
		}
		cout << sum << endl;
	}
	
	

}

Measured memory_bytes: 1156
#include<iostream>
using namespace std;
int main()
{	
  	int a,b,c,x;
 	cin >> a;
  	cin >> b;
  	cin >> c;
  	cin >> x;
 	int n,i,j,k;
 	n = 0;
 	
 	for (i = 0;i <= a;i = i + 1){
      for (j = 0;j <= b; j = j + 1){
        for (k = 0;k <= c; k = k + 1){
          if (500 * i + 100 * j + 50 * k == x){
            n = n + 1;
          }
        }
      }
    }
  
    cout << (n) << endl;
    return 0;
}


Measured memory_bytes: 256
N=int(input())
X=list(map(int,input().split()))
X.sort(key=int)
P=0
out=0
for i in X:
    P+=i
P=round(P/N)

def cost(x,p):
    return (x-p)*(x-p)
for i in X:
    out+=cost(i,P)

print(out)

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

#include <iostream>
#include <algorithm>

#include <bitset>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <stack>
#include <queue>
#include <deque>
#include <cstring>
#include <string>
#include <utility>
#include <array>
#include <complex>
#include <valarray>

#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <chrono>
#include <random>
#include <numeric>


using namespace std;
#define int long long

typedef long long ll;
typedef unsigned long long ull;
//typedef unsigned __int128 HASH;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll,int> plli;
typedef pair<double, int> pdbi;
typedef pair<int,pii> pipii;
typedef pair<ll,pll> plpll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<pii> vpii;
typedef vector<vector<int>> mat;

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n);i>0;i--)
#define rrep2(i,a,b) for (int i=(a);i>b;i--)
#define pb push_back
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()

const ll hmod1 = 999999937;
const ll hmod2 = 1000000000 + 9;
const int INF = 1<<30;
const double EPS = 1e-12;
const ll mod = 1000000000 + 7;
const int dx4[4] = {1, 0, -1, 0};
const int dy4[4] = {0, 1, 0, -1};
const int dx8[8] = {1, 1, 1, 0, 0, -1, -1, -1};
const int dy8[8] = {0, 1, -1, 1, -1, 0, 1, -1};
const double pi = 3.141592653589793;

#define addm(X, Y) (X) = ((X) + ((Y) % mod) + mod) % mod
#define inside(y, x, h, w) (0 <= (y) && (y) < (h) && 0 <= (x) && (x) < (w)) ? true : false

int n, k;
int cnt[100000 + 5];

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n >> k;
    rep(i, n) {
        int a, b;
        cin >> a >> b;
        cnt[a] += b;
    }
    int total = 0;
    rep(i, 100000 + 5) {
        total += cnt[i];
        if (total >= k) {
            cout << i << endl;
            break;
        }
    }
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <iomanip>
 
using namespace std;
 
typedef long long LL;
typedef long double LD;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
typedef pair<LD, LD> PLDLD;
typedef vector<int> VI;
typedef vector<LL> VLL;
typedef vector<char> VB;
 
#define FOR(i,a,b) for(int i=(a);i<(int)(b);++i)
#define REP(i,n) FOR(i,0,n)
#define CLR(a) memset((a), 0 ,sizeof(a))
#define ALL(a) a.begin(),a.end()
 
const LD eps=1e-10;
const long long INFLL=(LL)(1e9)*(LL)(1e9);
const int INF=1e9;
 
template<class T>
void chmin(T& a, const T b)
{
	if(a>b)
		a=b;
}
template<class T>
void chmax(T& a, const T b)
{
	if(a<b)
		a=b;
}
 
const LL pow(const LL p, const LL q)
{
	LL t=1;
	for(int i=0;i<q;i++)
		t*=p;
	return t;
}

template <typename T>
struct has_iter
{
	private:
		template <typename U>
		static constexpr true_type check(typename U::iterator*);
		template <typename U>
		static constexpr false_type check(...);

	public:
		static constexpr bool value = decltype(check<T>(nullptr))::value;
};


template<typename T, typename U = typename T::iterator>
void print(const T& container)
{
		auto&& first=begin(container), last=end(container);
		auto&& back=prev(last);
		for(auto e=first; e!=last; e=next(e))
			cout<<*e<<" \n"[e==back];
}


extern void* enabler;
template<typename Head, typename enable_if<!has_iter<Head>::value>::type*& = enabler>
void print(const Head& head)
{
	cout<<head<<endl;
}

template<> void print<string>(const string& container)
{
	cout<<container<<endl;
}

template<typename Head, typename... Tail>
void print(const Head& head, const Tail&... tail)
{
	cout<<head<<" ";
	print(tail...);
}

void io_speedup()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
}

template<typename T>
istream& operator >> (istream& is, vector<T>& vec)
{
	for(T& x: vec) is >> x;
	return is;
}


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

template<typename T>
vector<T> read(int n)
{
	vector<T> t(n);
	cin>>t;
	return t;
}

template<typename T>
T read()
{
	T t;
	cin>>t;
	return t;
}


template<unsigned int N> struct IsPrime {
	static const int size=(N>>5) + 1;
	unsigned int is_prime[size];
	constexpr IsPrime() : is_prime() {
		is_prime[0]=0x3;
		for(unsigned int i=2;i<N;i++)
		{
			if((is_prime[i>>5] & (1u<<(i&0x1f))) > 0)  continue;
			for(int j=i+i;j<N;j+=i)
				is_prime[j>>5]|=(1u<<(j&0x1f));
		}
	}
	constexpr bool operator[] (const int p) const
	{
		return (is_prime[p>>5] & (1u<<(p&0x1f))) == 0;
	}
};

template<int N> struct LikelyPrime {
	unsigned short sum[N+1];
	constexpr LikelyPrime(const IsPrime<N> pr) : sum() {
		for(int i=3;i<N;i++)
			sum[i+1]=sum[i]+(unsigned short)((pr[i] && pr[(i+1)/2])?1:0 );
	}
};

	constexpr IsPrime<100001> pr;
	constexpr LikelyPrime<100001> s(pr);
int main()
{
	io_speedup();
	int q;cin>>q;
	REP(i,q)
	{
		int l,r;
		cin>>l>>r;
		cout<<s.sum[r+1]-s.sum[l]<<endl;
		//print(s.sum[r+1]-s.sum[l]);
	}
}


Measured memory_bytes: 640
import java.util.*;
public class Main{
public static void main(String[]args){
  Scanner sc=new Scanner(System.in);
  Map<String,Integer>map=new HashMap<String,Integer>();
  int n=sc.nextInt();
  for(int i=0;i<n;i++){
  	String po=sc.next();
    map.put(po,(map.containsKey(po))?map.get(po)+1:1);
  }
  int m=sc.nextInt();
  for(int i=0;i<m;i++){
  	String po=sc.next();
    map.put(po,(map.containsKey(po))?map.get(po)-1:-1);
  }
  int ans=0;
  for(String key:map.keySet()){
      
      ans=Math.max(ans,map.get(key));
  }
  System.out.println(ans);
  

}

}

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

int main(){
    int N,M;
    cin >> N;
    int T[N];
    for(int i=0; i<N; i++){
        cin >> T[i];
    }
    cin >> M;
    int P[M], X[M];
    for(int i=0; i<M; i++){
        cin >> P[i] >> X[i];
    }

    int total = 0;
    for(int i=0; i<N; i++){
        total += T[i];
    }
    const int INITIAL_TOTAL_TIME = total;

    for(int i=0; i<M; i++){
        cout << (INITIAL_TOTAL_TIME - T[P[i]-1] + X[i]) << '\n';
    }



}



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

// 基本テンプレート
#pragma region MACRO
#define P(x) cout << (x) << endl
#define p(x) cout << (x)
#define PED cout << "\n"
#define rep(i,n) for(int i=0; i<(int)n; ++i)
#define REP(i,x,n) for(int i=x; i<(int)n; ++i)
#define repi(i,n) for(int i=0; i<=(int)n; ++i)
#define REPI(i,x,n) for(int i=x; i<=(int)n; ++i)
#define ILP while(true)
#define FOR(i,c) for(__typeof((c).begin())!=(c).begin(); i!=(c).end(); ++i)
#define ALL(c) (c).begin(), (c).end()
#define mp make_pair
#pragma endregion

// 型
#pragma region TYPE_DEF
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<string, string> pss;
typedef pair<string, int> psi;
typedef pair<int, string> pis;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long double> vld;
typedef vector<long> vl;
typedef vector<long long> vll;
typedef vector<string> vs;
#pragma endregion

// Effective std
#pragma region ESTD
template<typename C, typename T> int count(C& c, T t) { return count(ALL(c), t); }
template<typename C, typename F> int count_if(C& c, F f) { return count_if(ALL(c), f); }
template<typename C, typename T> void erase(C& c, T t) { remove(ALL(c), t), c.end(); }
template<typename C> void remove(vector<C>& c, unsigned int index) { c.erase(c.begin()+index); }
template<typename C, typename T, typename U> void replace(C& c, T t, U u) { replace(ALL(c), t, u); }
template<typename C, typename F, typename U> void replace_if(C& c, F f, U u) { (ALL(c), f, u); }
template<typename C> void reverse(C& c) { reverse(ALL(c)); }
template<typename C> void sort(C& c) { sort(ALL(c)); }
template<typename C, typename Pred> void sort(C& c, Pred p) { sort(ALL(c), p); }
#pragma endregion

// 定数
#pragma region CONST_VAL
constexpr int PI = (2*acos(0.0));
constexpr int EPS = (1e-9);
constexpr int MOD = (int)(1e9+7);
constexpr int INF = 100000000;
#pragma endregion


int main()
{
    int x;
    cin >> x;
    if(x<1200) P("ABC");
    else P("ARC");
    return 0;
}



Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var N, M, C int
	fmt.Scan(&N, &M, &C)

	Bs := make([]int, M)
	nums := make([][]int, N)

	for i := 0; i <= N; i++ {
		var ns []int
		for j := 0; j < M; j++ {
			if i == 0 {
				fmt.Scan(&Bs[j])
			} else {
				var num int
				fmt.Scan(&num)
				ns = append(ns, num)
			}
		}
		if i != 0 {
			nums[i-1] = ns
		}

	}

	var count int
	for i := 0; i < N; i++ {
		var sum int
		for j := 0; j < M; j++ {
			array := nums[i]
			sum += Bs[j] * array[j]
		}

		if sum + C > 0 {
			count++
		}
	}

	fmt.Println(count)
}


Measured memory_bytes: 512
import sys
from itertools import accumulate

def main():
    input = sys.stdin.readline
    N, M = map(int, input().split())
    acc = [0] * (N+1)
    for _ in range(M):
        left, right = map(int, input().split())
        acc[left-1] += 1
        acc[right] -= 1

    cnt = 0
    for a in accumulate(acc):
        if a == M:
            cnt += 1

    return cnt


if __name__ == '__main__':
    print(main())

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

#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)

int N;
vector<int> A;

int main()
{
    cin >> N;
    A.resize(N);
    long long int ans = 0;
    REP(i, N)
    {
        int tmp;
        cin >> tmp;
        ans += (tmp - 1);
    }
    cout << ans << endl;

}


Measured memory_bytes: 256