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

class Main {
	public static void main(String[] args) {
		// BufferedReader br = new BufferedReader(new
		// InputStreamReader(System.in));
		try {
		        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			String str = br.readLine();
			// n:???????????°???k:?????????????????°
			int n = Integer.parseInt(str.split(" ")[0]);
			int k = Integer.parseInt(str.split(" ")[1]);
			// ?????????????´?????????????
			int[] nimotu = new int[n];
			// ??¨????????????????????????????¨?????????????
			int totalWeight = 0;
			int maxweight = 0;
			// ??????????????????????´????????????????????????§??????????±???????
			for (int i = 0; i < n; i++) {
				nimotu[i] = Integer.parseInt(br.readLine());
				totalWeight += nimotu[i];
				if(nimotu[i] > maxweight){
					maxweight = nimotu[i];
				}
			}
			// ???????????????????±???????
			int aver = totalWeight / k;
			//?¨???????????±???????
			int settingVal= 0;
			// ??????????????????????????????????????????????????????????????????????????????????????????????????£??\
			if(maxweight < aver){
				settingVal = aver;
			}else{
				settingVal = maxweight;
			}
			int tracknum;
			while(settingVal <= totalWeight){
				int weight = 0;
				tracknum = 1;
				// ?¨????????????????????¶???????????????????????????????????????????
				for(int i = 0;i < n && tracknum <= k;) {
					// ????????????????????????????????°?????????
					if(weight + nimotu[i] <= settingVal){
						weight += nimotu[i];
						i++;
					//???????????????????????????????????????????????????????????????????????£?????????????????°?¬???????????????????
					} else {
						weight = 0;
						tracknum++;
					}
				}
				/* ???????????¶
				 * ?±???????????°??????????????????????aver?????????????????¨?????????????????????????????????aver????????????????????¨?????????????????°????¨??????????????¶???????????????????
				 * ??\????????????????????????????????????????????°????¶???????????????????????±???????????°????????????????????????§?????????
				 * 1.tracknum = k???????????????????????????????????°????¶???????????????¨
				 * 2.flg = true????????¨?????????????????????????????????????????¨
				*/
				if(tracknum <= k){
					System.out.println(settingVal);
					break;
				}
				// ?????????????????´?????????????????????????¬????
				settingVal++;
			}
		} catch (IOException e) {
			System.out.println("error");
		}
	}
}

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

int MCM(int molCol[], int matNum) {
	int DP_memory[100+1][100+1];

	//?????????????????????
	for (int i = 1; i <= matNum; i++)
		DP_memory[i][i] = 0;

	for (int l = 2; l <= matNum; l++) { //???????????¨????????????(i = 2??????2??????????????§????????????????°???????????±???????)
		for (int i = 1; i <= matNum - l + 1; i++) { //?????????????????§????°???????
			int j = i + l - 1; //??????????????§?????§??????
			DP_memory[i][j] = (1 << 30); //??????????????????????????§?????????(????°???????????±?????????????)
			for (int k = i; k < j; k++) //i??¨j????????§????????????????????????????????´???
				DP_memory[i][j] = DP_memory[i][j] < (DP_memory[i][k] + DP_memory[k + 1][j] + molCol[i - 1] * molCol[k] * molCol[j])
					? DP_memory[i][j] : (DP_memory[i][k] + DP_memory[k + 1][j] + molCol[i - 1] * molCol[k] * molCol[j]);
		}
	}

	return DP_memory[1][matNum];
}

int main() {
	int matNum;
	int molCol[200+1];
	cin >> matNum;
	for (int i = 1; i <= matNum; i++) {
		cin >> molCol[i - 1] >> molCol[i];
	}

	int answer = MCM(molCol, matNum);

	cout << answer << endl;
	return 0;
}

Measured memory_bytes: 3136
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
constexpr int MOD = 1000000000 + 7;
constexpr int INF = 2000000000;
using namespace std;

int main() {
	int a, b;
	cin >> a >> b;
	if (a <= 0 && 0 <= b)cout << "Zero" << endl;
	else if (a < 0 && (b-a) % 2 == 0)cout << "Negative" << endl;
	else cout << "Positive" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mt make_tuple
#define mp make_pair
#define pu push_back
#define INF 1000000001
#define MOD 1000000007
#define EPS 1e-6
#define ll long long int
#define ld long double
#define fi first
#define se second
#define all(v) v.begin(),v.end()
#define pr(v) { for(int i=0;i<v.size();i++) { v[i]==INF? cout<<"INF " : cout<<v[i]<<" "; } cout<<endl;}
#define t1(x)                cerr<<#x<<" : "<<x<<endl
#define t2(x, y)             cerr<<#x<<" : "<<x<<" "<<#y<<" : "<<y<<endl
#define t3(x, y, z)          cerr<<#x<<" : " <<x<<" "<<#y<<" : "<<y<<" "<<#z<<" : "<<z<<endl
#define t4(a,b,c,d)          cerr<<#a<<" : "<<a<<" "<<#b<<" : "<<b<<" "<<#c<<" : "<<c<<" "<<#d<<" : "<<d<<endl
#define t5(a,b,c,d,e)          cerr<<#a<<" : "<<a<<" "<<#b<<" : "<<b<<" "<<#c<<" : "<<c<<" "<<#d<<" : "<<d<<" "<<#e<<" : "<<e<<endl
#define t6(a,b,c,d,e,f)          cerr<<#a<<" : "<<a<<" "<<#b<<" : "<<b<<" "<<#c<<" : "<<c<<" "<<#d<<" : "<<d<<" "<<#e<<" : "<<e<<" "<<#f<<" : "<<f<<endl
#define GET_MACRO(_1,_2,_3,_4,_5,_6,NAME,...) NAME
#define t(...) GET_MACRO(__VA_ARGS__,t6,t5, t4, t3, t2, t1)(__VA_ARGS__)
#define _ cerr<<"here"<<endl;
#define __ {ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);}

using namespace std;
template<class A, class B> ostream& operator<<(ostream& out, const pair<A, B> &a){ return out<<"("<<a.first<<", "<<a.second<<")";}
template <int> ostream& operator<<(ostream& os, const vector<int>& v) { os << "["; for (int i = 0; i < v.size(); ++i) { if(v[i]!=INF) os << v[i]; else os << "INF";if (i != v.size() - 1) os << ", "; } os << "]\n"; return os; } 
template <typename T> ostream& operator<<(ostream& os, const vector<T>& v) { os << "["; for (int i = 0; i < v.size(); ++i) { os << v[i]; ;if (i != v.size() - 1) os << ", "; } os << "]\n"; return os; } 


int main()
{
  __;
  int n,m;
  cin >> n >> m;
  vector<string> v(n);
  for(int i=0;i<n;i++) cin >> v[i];

  vector<vector<int> > dp(n,vector<int>(m,INF));

  dp[0][0] = v[0][0] == '.' ? 0:1;

  for(int i=0;i<n;i++)
  {
    for(int j=0;j<m;j++)
    {
      if(i+j == 0) continue;
      if(i>0) 
      {
        char curr = v[i][j];
        char prev = v[i-1][j];
        if(curr == prev)
        {
          dp[i][j] = min(dp[i][j],dp[i-1][j]);
        }
        else if(curr == '.' && prev == '#')
        {
          dp[i][j] = min(dp[i][j],dp[i-1][j]);
        }
        else
        {
          dp[i][j] = min(dp[i][j],dp[i-1][j]+1);
        }
      }
      if(j>0)
      {
        char curr = v[i][j];
        char prev = v[i][j-1];
        if(curr == prev)
        {
          dp[i][j] = min(dp[i][j],dp[i][j-1]);
        }
        else if(curr == '.' && prev == '#')
        {
          dp[i][j] = min(dp[i][j],dp[i][j-1]);
        }
        else
        {
          dp[i][j] = min(dp[i][j],dp[i][j-1]+1);
        }
      }
    }
  }

  cout << dp[n-1][m-1] << endl;
  return 0;
}


Measured memory_bytes: 384
class Bit:
    def __init__(self, n):
        self.size = n
        self.tree = [0]*(n+1)

    def __iter__(self):
        psum = 0
        for i in range(self.size):
            csum = self.sum(i+1)
            yield csum - psum
            psum = csum
        raise StopIteration()

    def __str__(self):  # O(nlogn)
        return str(list(self))

    def sum(self, i):
        # [0, i) の要素の総和を返す
        s = 0
        while i>0:
            s += self.tree[i]
            i -= i & -i
        return s

    def add(self, i, x):
        i += 1
        while i <= self.size:
            self.tree[i] += x
            i += i & -i

    def __getitem__(self, key):
        return self.sum(key+1) - self.sum(key)

    def __setitem__(self, key, value):
        # 足し算と引き算にはaddを使うべき
        self.add(key, value - self[key])

mod = 10**9+7
N, K = map(int, input().split())
A = list(map(int, input().split()))
bit = Bit(max(A)+1)
ans = 0
for i, a in enumerate(A):
    ans += i - bit.sum(a+1)
    bit.add(a, 1)
ans *= K
from itertools import combinations
cnt = 0
for a, b in combinations(A, 2):
    if a!=b:
        cnt += 1
cnt *= K*(K-1)//2
ans += cnt
print(ans%mod)


Measured memory_bytes: 3188
// In the name of Allah the Lord of the Worlds.

#include<bits/stdc++.h>

using namespace std;

typedef long long ll;

const int MAX = 1e7+9;
int cnt[MAX], d[MAX];

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


    ll ans = 0 , n;
    cin >> n;
    for(int i=0;i<=n;i++)cnt[i]=1;
    for(ll i=2;i<=n;i++){
        if(d[i]==0){
            for(ll j=i;j<=n;j+=i){
                int counter = 1;
                ll temp = j;
                while(temp%i==0){
                    counter++;
                    temp/=i;
                }
                cnt[j]*=counter;
                d[j] = 1;
            }
        }
    }
    for(int i=1;i<=n;i++){
        ans+=(ll)i*cnt[i];
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 81780
import java.util.Scanner;

public class Main {

    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        while(true) {
        	int m = sc.nextInt();
        	int nmin = sc.nextInt();
        	int nmax = sc.nextInt();
        	if(m + nmin + nmax == 0) break;
        	int[] p = new int[m];
        	for(int i=0;i<m;i++) {
        		p[i] = sc.nextInt();
        	}
        	int pass = 0;
        	int g = 0;
        	for(int i=nmin;i<=nmax;i++) {
        		if(Math.abs(p[i-1] - p[i]) >= g) {
        			g = Math.abs(p[i-1] - p[i]);
        			pass = i;
        		}
        	}
        	System.out.println(pass);
         }
    }
}


Measured memory_bytes: 57584
N = int(input())
A = input()
A = A.split(" ")
A = list(map(int, A))
result = 1
for i in range(N):
  result = result*A[i]
  if result > 10**18:
    result = 10**18 + 1
if result == 10**18 + 1:
   result = -1
print(result)

Measured memory_bytes: 21792
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
using namespace std;

map<int, vector<int>> mp;
int se(int i){
    for(int j=0; j<mp[i].size(); ++j) mp[i][j]=se(mp[i][j]);
    sort(mp[i].begin(), mp[i].end(), greater<int>());
    int mx=0;
    for(int j=0; j<mp[i].size(); ++j) mx=max(mx, mp[i][j]+j+1);
    return mx;
}
int main() {
	int N, a; cin >> N;
	for(int i=2; i<=N; ++i){
	    cin >> a;
	    mp[a].push_back(i);
	}
	cout << se(1) << endl;
	return 0;
}


Measured memory_bytes: 20608
import java.util.*;
import java.lang.*;

public class Main{
    
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        
        String str = sc.next();
        int l = str.length();
        int n = sc.nextInt();
        
        for (int i = 0; i < n; i++) {
            String command = sc.next();
            int a = sc.nextInt();
            int b = sc.nextInt();
            char[] newstr = new char[l];
            
            if (command.equals("print")) {
                System.out.println(str.substring(a, b + 1));
            }
            if (command.equals("reverse")) {
                for (int j = 0; j < l; j++) {
                    if (j < a || j > b) {
                        newstr[j] = str.charAt(j);
                    } else {
                        newstr[j] = str.charAt(b - (j - a));
                    }
                }
                str = String.valueOf(newstr);
                //System.out.println("reverse: " + str);
            }
            if (command.equals("replace")) {
                String p = sc.next();
                for (int j = 0; j < l; j++) {
                    if (j < a || b < j) {
                        newstr[j] = str.charAt(j);
                    } else {
                        newstr[j] = p.charAt(j - a);
                    }
                }
                str = String.valueOf(newstr);
                //System.out.println("replace: " + str);
            }
        }

    }
}



Measured memory_bytes: 30228
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

n,m=map(int, input().split())
uf=UnionFind(n+1)
for _ in range(m):
    a,b=map(int, input().split())
    uf.union(a, b)
print(-1*min(uf.parents))

Measured memory_bytes: 14748
#include <iostream>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
const long long INF = 1e9 + 7;
using namespace std;
typedef long long ll;
map<int, int> mp;
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, m, l;
	cin >> n >> m >> l;
	ll a[100][100];
	ll b[100][100];
	ll c[100][100];
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			cin >> a[i][j];
		}
	}
	for (int i = 0; i < m; i++) {
		for (int j = 0; j < l; j++) {
			cin >> b[i][j];
		}
	}
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < l; j++) {
			ll o = 0;
			for (int k = 0; k < m; k++) {
				o += a[i][k] * b[k][j];
			}
			if (j == 0) cout << o;
			else cout << " " << o;
		}
		cout << endl;
	}
	return 0;
}


Measured memory_bytes: 3328
#include <stdio.h>
#define N 251

int heap[N];

int right(int id) {
    return (2 * id) + 1;
}

int left(int id) {
    return 2 * id;
}

int parent(int id) {
    return id / 2;
}

void printNode(int id, int n) {
    printf("node %d: ", id);
    printf("key = %d, ", heap[id]);
    if (id > 1) {
        printf("parent key = %d, ", heap[parent(id)]);
    }
    if (left(id) <= n) {
        printf("left key = %d, ", heap[left(id)]);
    }
    if (right(id) <= n) {
        printf("right key = %d, ", heap[right(id)]);
    }
    printf("\n");
}

int main() {
    int i;
    int n;

    scanf("%d", &n);

    for (i = 1; i <= n; i++) {
        scanf("%d", &heap[i]);
    }

    for (i = 1; i <= n; i++) {
        printNode(i, n);
    }

    return 0;
}


Measured memory_bytes: 2052
# 169A
# 値 A × B を整数として出力せよ。

# 1. 入力をプログラムで扱えるように受け取ること
a, b = map(int, input().split())
# print(a, b)

# 2. 受け取った入力値を使って、適切に処理(計算)すること
answer = a * b

# 3. 計算した結果を出力すること
print(answer)



Measured memory_bytes: 9144
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

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

            string x = a.Substring(0, 1);
            string y = b.Substring(0, 1);
            string z = c.Substring(0, 1);

            string j = x.ToUpper();
            string k = y.ToUpper();
            string l = z.ToUpper();

            Console.WriteLine(j + k + l);

            Console.Read();
        }
    }
}


Measured memory_bytes: 13140
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;
int fa[1010],tp[1010];
int son[1010][2];
int mi[1010],ma[1010];
int nn,now;
char s[1010];
void Build(int p,int tp1,int mi1,int ma1)
{
	tp[p]=tp1;
	mi[p]=mi1;
	ma[p]=ma1;
}
void update(int x)
{
	if(!x)
		return ;
	int mi1=mi[x],ma1=ma[x];
	if(tp[x]==0)
	{
		mi[x]=max(mi[son[x][0]],mi[son[x][1]]);
		ma[x]=max(ma[son[x][0]],ma[son[x][1]]);
	}
	else
	{
		mi[x]=min(mi[son[x][0]],mi[son[x][1]]);
		ma[x]=min(ma[son[x][0]],ma[son[x][1]]);
	}
	if(mi[x]!=mi1||ma[x]!=ma1)
		update(fa[x]);
}
int main()
{
	int T,l;
	scanf("%d",&T);
	fa[1]=0;
	while(T--)
	{
		scanf("%s",s+1);
		l=strlen(s+1);
		for(int i=1;i<=1000;i++)
		{
			mi[i]=0;
			ma[i]=99;
		}
		nn=0;
		now=++nn;
		for(int i=1;i<=l;i++)
		{
			if(s[i]>='0'&&s[i]<='9')
			{
				if(mi[now])
					mi[now]=ma[now]=mi[now]*10+s[i]-'0';
				else if(s[i]=='0')
					Build(now,2,0,0);
				else
					Build(now,2,s[i]-'0',(s[i]-'0')*10+9);
				update(fa[now]);
			}
			else if(s[i]=='^')
			{
				Build(now,0,0,99);
				son[now][0]=++nn;
				fa[nn]=now;
				son[now][1]=++nn;
				fa[nn]=now;
			}
			else if(s[i]=='_')
			{
				Build(now,1,0,99);
				son[now][0]=++nn;
				fa[nn]=now;
				son[now][1]=++nn;
				fa[nn]=now;
			}
			else if(s[i]=='(')
				now=son[now][0];
			else 
			{
				if(tp[now]==2)
				{
					ma[now]=mi[now];
					update(fa[now]);
				}
				if(s[i]==',')
					now=son[fa[now]][1];
				else if(s[i]==')')
					now=fa[now];
			}
			if(ma[1]==mi[1])
			{
				printf("%d %d\n",mi[1],i);
				break;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        long a = sc.nextLong();
        a--;
        long b = sc.nextLong();
        long c = sc.nextLong();
        long d = sc.nextLong();

        long total = b - a;

        long divD = b / d - a / d;
        long divC = b / c - a / c;

        long lcm = getLcm(c, d);
        long divL = b / lcm - a / lcm;

        System.out.println(total - (divD + divC - divL));

    }

    private static long getLcm(long n, long m) {

        long bn = n;
        long bm = m;

        while (n != m) {
            if (n < m) {
                n += bn;
            } else {
                m += bm;
            }
        }
        return n;
    }
}

Measured memory_bytes: 21972
#include<stdio.h>
int MIN(int a, int b){return a>b?b:a;}

typedef long long int ll;

int main(void){
    ll l,r;
    scanf("%lld%lld", &l,&r);

    int time;
    if(r-l > 2019){
        printf("0\n");
        return 0;
    }

    int ans = 2019;
    for(ll i=l; i<r; i++){
        for(ll j=i+1; j<=r; j++){
            //printf("i:%d j:%d\n", i,j);
            ans = MIN(ans, i*j%2019);
        }
    }

    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<stack>
#include<map>
#include<queue>
using namespace std;
int main() {
	int n, m;
	cin >> n >> m;
	if (abs(n - m) > 1)cout << 0 << endl;
	else {
		long long ans = 1;
		for (int i = 1; i <= n; i++) {
			ans *= i;
			ans %= 1000000007;
		}
		for (int i = 1; i <= m; i++) {
			ans *= i;
			ans %= 1000000007;
		}
		if ((n + m) % 2 == 0)ans *= 2;
		ans %= 1000000007;
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include <queue>
#include <utility>
#include <map>
#include <set>
#include <deque>
using namespace std;

string YorN(bool P) { if (P)return "YES"; else return "NO"; }

int main() {

    int R,G;
    cin >> R >> G;

    cout << R+2*(G-R) << endl;
    
    return 0;

}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
using namespace std;
int main(void) {
	char a[52], x[52] = {};
	int y[52], n;
	cin>>n;
	for (int i = 0; i < n; i++) {
		cin>>a[i]>>y[i];
		if (a[i] == 'S') {
			x[4 * y[i]-4] = 1;
		}
		else if (a[i] == 'H') {
			x[4 * y[i] - 1] = 1;
		}
		else if (a[i] == 'C') {
			x[4 * y[i] - 2] = 1;
		}
		else  {
			x[4 * y[i] - 3] = 1;
		}
	}
	for (int i = 1; i <= 13; i++) {
		if (x[4 * i-4] == 0)
			cout << 'S' << " " << i << endl;
	}
	for (int i = 1; i <= 13; i++) {
		if (x[4 * i - 1] == 0)
			cout << 'H' << " " << i << endl;
	}
	for (int i = 1; i <= 13; i++) {
		if (x[4 * i - 2] == 0)
			cout << 'C' << " " << i << endl;
	}
	for (int i = 1; i <= 13; i++) {
		if (x[4 * i - 3] == 0)
			cout << 'D' << " " << i << endl;
	}
    return 0;
}

    


Measured memory_bytes: 3104
#include <bits/stdc++.h>
using namespace std;
/* string board[50];
for (int i = 0; i < h; ++i) cin >> board[i]; board[i][j]とおける*/
const int dx[8] = {-1, -1, 0, 0, 1, 1, -1, 1};
const int dy[8] = {0, 1, -1, 1, -1, 0, -1, 1};

void solve(long long H, long long W, std::vector<std::string> S)
{
    for (int i = 0; i < H; i++) //y
    {
        for (int j = 0; j < W; j++) //x
        {

            if (S[i][j] == '#')
            {
                cout << S[i][j];
                continue;
            }

            int cnt = 0;
            for (int k = 0; k < 8; k++)
            {
                const int x = j + dx[k];
                const int y = i + dy[k];

                /*if (x < 0 || y < 0 || x >= W || y >= H)
                {
                    continue;
                }*/

                if (y < 0 || H <= y)
                    continue;
                if (x < 0 || W <= x)
                    continue;
                if (S[y][x] == '#')
                    cnt++;
            }

            cout << cnt;
        }
        cout << endl;
    }
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main()
{
    long long H;
    scanf("%lld", &H);
    long long W;
    scanf("%lld", &W);
    std::vector<std::string> S(H);
    for (int i = 0; i < H; i++)
    {
        std::cin >> S[i];
    }
    solve(H, W, std::move(S));
    return 0;
}


Measured memory_bytes: 256
def f(x):
  xor_cnt,r=divmod(x,2)
  if r==1:xor_cnt+=1
  res=0
  if x%2==1:
    if xor_cnt%2==0:
      res=0
    else:
      res=1
  else:
    if xor_cnt%2==0:
      res=0^x
    else:
      res=1^x
  return res  

a,b=map(int,input().split())
print(f(b)^f(a-1))

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

using namespace std;
const int N=1e6+100;
int arr[N];
int main()
{
    int n,a;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>arr[i ];
    }
    sort(arr,arr+n  );
    int cnt=0,p=1;
    for(int i=0;i<n;i++)
        {
            if(arr[i]==arr[i+1])
            {
                p++;
            }
            else
            {
                if(p%2!=0)
                cnt++;
                p=1;
            }
        }
        cout<<cnt<<endl;
    return 0;
}


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

using namespace std;

int a[100],x,cnt;

int main()
{
	cin >> x;
	for(;x;x=(x-a[cnt-1])/(-2))
	{
		a[cnt++]=x%(-2);
		if(a[cnt-1]<0) a[cnt-1]+=2;
		cerr << x << endl;
	}
	if(!cnt) puts("0");
	for(int i=cnt-1;i>=0;i--)
		printf("%d",a[i]); puts("");
		
	return 0;
}

Measured memory_bytes: 256
/*
    -ensure correct output format
    -ensure printing required output
    -reread the problem statement
  */

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll>pll;
typedef pair<ll,pair<ll,ll>>plll;
#define fastread() (ios_base:: sync_with_stdio(false),cin.tie(NULL));
#define vll(v) v.begin(),v.end()
#define all(x) x.rbegin(),x.rend()
#define min3(a, b, c)   min(a, min(b, c))
#define max3(a, b, c)   max(a, max(b, c))
#define F first
#define S second
#define in  freopen("input.txt", "r", stdin)
#define out  freopen("output.txt", "w", stdout)
#define minheap int,vector<int>,greater<int>
#define pb push_back
#define eb emplace_back
#define ischar(x)  (('a' <= x && x <= 'z') || ('A' <= x && x <= 'Z'))
#define isvowel(ch) ((ch=='a'||ch=='e'||ch=='i'||ch=='o'||ch=='u')||(ch=='A'|| ch=='E' || ch=='I'|| ch=='O'|| ch=='U'))
#define bug cout<<"BUG"<<endl;
const int Max = 1e5 + 10;
const int Mod = 1e9 + 7;
const double PI  =3.141592653589793238463;
bool compare(const pair<ll,ll> &a, const pair<ll,ll> &b)
{
       return (a.first > b.first);
}
ll lcm(ll a,ll b)
{
    if(a==0 || b==0)return 0;

    return a/__gcd(a,b)*b;
}

void input(ll ara[],ll n)
{
    for(ll i=0; i<n; i++)cin>>ara[i];
}


ll dp[2][Max+10];

vector<ll>v[Max+10];



ll call(ll ch,ll s,ll p)
{
        ll &ret=dp[ch][s];

        if(~ret)return ret;

        ret=1;


        for(auto x : v[s])
        {
            if(x!=p)
            {
                if(ch==0)
                ret=(ret*call(1,x,s))%Mod;

                else
                {
                  ret=(ret*(call(1,x,s)+call(0,x,s)))%Mod;
                }
            }
        }

        return (ret)%Mod;
}
int main()
{

   fastread();

   ll i,j,n,m,p,a,sum=0,k,t,b,c,d,cnt=0,q,l,r;

      bool flag=false;

      string str;


      memset(dp,-1,sizeof(dp));
       cin>>n;

       for(i=1; i<n; i++)
       {
           cin>>a>>b;


           v[a].eb(b);
           v[b].eb(a);
       }

       cout<<(call(0,1,1)+call(1,1,1))%Mod<<endl;









}



Measured memory_bytes: 18968
Input_list = sorted(list(map(int, input().split())))

A = Input_list[-1]
B = Input_list[1]
C = Input_list[0]
ans = 0
if (3*A-(A+B+C)) % 2 == 0:
    if (A - B) % 2 == 0:
        ans += (A - B) // 2 + (A - C) // 2
    else:
        ans += (A - B) // 2 + 1 + (A - (C+1)) // 2
    print(ans)
else:
    if (A - B) % 2 == 0:
        ans += (A+1 - (B+1)) // 2 + 1 + (A+1 - C) // 2
    else:
        ans += (A+1 - B) // 2 + 1 + (A+1 - (C+1)) // 2
    print(ans)

Measured memory_bytes: 38384
#include <iostream>
#include<vector>
#include<algorithm>

using namespace std;

int N;

vector<int> L;

int main(void) {
	cin >> N;
	int tmp;
	for (int i = 1; i <= 2*N; i++) {
		cin >> tmp; L.push_back(tmp);
	}

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

	int ans = 0;
	for (int i = 0; i < 2 * N; i += 2) {
		ans += L[i];
	}

	cout << ans << endl;

	//system("pause");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#include<cmath>
#include<string>
#define pb push_back
#define ll long long
#define ull unsigned long long
#define deb(x) cerr<<#x<<" "<<x<<"\n"
#define debi cerr<<"hey sparky\n"
#define x first
#define y second
#define fast ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define eps (double)1e-9
#define all(x) x.begin(),x.end()
#define int long long
using namespace std;
using namespace __gnu_pbds; 
typedef tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> pdbs;
 
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
//void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
 
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
 
// look for  all edge cases
//search for a pattern




signed main() {    
	ios::sync_with_stdio(0);
	cout.tie(0);
	cin.tie(0);
	
	int n;
	cin >> n;
	vector<int> v(n);
	for(int i =0 ; i < n; i++){
		cin >> v[i];
	}
	int ans =0;
	int now = v[0];
	for(int i =1 ; i< n; i++){
		if(v[i] > now){
			now = v[i];
		}
		else{
			ans += now - v[i];
		}
	}
	cout<<ans;
	 
	return 0;
}


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

int main(){
  int a=0,b=0,c=0;
  int counter[2]={0};

  while((scanf("%d,%d,%d",&a,&b,&c))!=EOF){
    
    if(a*a + b*b == c*c)
      counter[0]++;
    if(a == b)
      counter[1]++;
  }

  printf("%d\n%d\n",counter[0],counter[1]);

  return 0;

}  

  
    

Measured memory_bytes: 1188
n, k = map(int, input().split())
now = (n - 1) * (n - 2) // 2
if now < k:
    print(-1)
    exit()

print(n - 1 + now - k)
for i in range(2, n + 1):
    print(1, i)
v = 2
w = 3
while k < now:
    now -= 1
    print(v, w)
    w += 1
    if w == n + 1:
        v += 1
        w = v + 1


Measured memory_bytes: 74064
/* 
	بسم الله الرحمن الرحیم

	(; طلا یک جهانی
*/

#include <bits/stdc++.h>
using namespace std;

#define F first
#define S second
typedef pair<int, int> pii;

const int MAX_N = 50 + 5;
int n;
pii a[MAX_N];

void read_input() {
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> a[i].F >> a[i].S;
}

void solve() {
	multiset<pii> s;
	for (int i = 0; i < n; i++)
		for (int j = 0; j < n; j++)
			if (i != j) {
				int p = a[i].F - a[j].F;
				int q = a[i].S - a[j].S;
				s.insert({p, q});
			}
	int mx = 0;
	for (auto i: s) 
		mx = max(mx, (int) s.count(i));
	cout << n - mx;
}

int main() {
	ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	read_input();
	solve();
}


Measured memory_bytes: 384
#include<iostream>
#include<bits/stdc++.h>
#define pq priority_queue
using namespace std;
#define MZ 1000000007
long long num[200005];
long long w[200005];
long long n,l,t;
int main()
{
    long long gg=0,gl;
    long long cnt=0,ct,wtf;
    scanf("%lld%lld%lld",&n,&l,&t);
    for(int i=0;i<n;i++)
    {
        scanf("%lld%lld",num+i,w+i);
        num[i+n]=num[i]+l;
        w[i+n]=w[i];
    }
    for(int i=0;i<n;i++)
    {
        if(w[i]!=w[0])
            cnt++;
    }
    ct=t%l;
    gg=((t/l)*2*cnt)%n;
    if(w[0]==1)
    {
        for(int i=0;i<2*n;i++)
        {
            if(w[i]!=w[0] && ct*2>=num[i]-num[0])
                gg++;
        }
    }
    else
    {
        for(int i=0;i<2*n;i++)
        {
            if(w[i]!=w[0] && ct*2>=num[0]-num[i]+2*l)
                gg++;
        }
    }
    gg%=n;
    if(w[0]==2)
        gg=(n-gg)%n;
    for(int i=0;i<n;i++)
    {
        if(w[i]==1)
            num[i]=(num[i]+t)%l;
        else
            num[i]=((num[i]-t)%l+l)%l;
        if(num[i]<num[0])
            num[i]+=l;
        if(i && w[0]==1 && num[i]==num[0])
            num[i]+=l;
    }
    sort(num+1,num+n);
    for(int i=0;i<n;i++)
        printf("%lld\n",num[(n-gg+i)%n]%l);
    return 0;
}


Measured memory_bytes: 4352
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <cmath>
#include <iomanip>
#include <algorithm>
using namespace std;
using ll = long long;

ll lmax(ll a, ll b){
    if(a > b){
        return a;
    } else {
        return b;
    }
}

ll llceil(ll a, ll b){
    if(a % b == 0){
        return a / b;
    } else {
        return a / b + 1LL; 
    }
}

int main(){
    int n;
    cin >> n;
    int t[n];
    int a[n];
    for(int i = 0; i < n; i++){
        cin >> t[i] >> a[i];
    }
    ll x = 1LL;
    ll y = 1LL;
    for(int i = 0; i < n; i++){
        ll m = lmax(llceil(x, t[i]), llceil(y, a[i]));
        x = m*t[i];
        y = m*a[i];
    }
    cout << x + y << endl;
    return 0;
}


Measured memory_bytes: 256
import sys
import numpy as np

stdin = sys.stdin
def ns(): return stdin.readline().rstrip()
def ni(): return int(stdin.readline().rstrip())
def nm(): return map(int, stdin.readline().split())
def nl(): return list(map(int, stdin.readline().split()))


def main():
    n = ni()
    S = ns()
    E = np.cumsum([1 if s == 'E' else 0 for s in S][::-1])[::-1]
    W = np.cumsum([1 if s == 'W' else 0 for s in S])
    ans = E + W
    print(np.min(ans) - 1)


if __name__ == '__main__':
    main()


Measured memory_bytes: 36312
#include <bits/stdc++.h>
#define FOR(i, a, n) for(int (i) = (int)(a); (i) < (int)(n); ++(i))
#define FORe(i, a, n) for(int (i) = (int)(a); (i) <= (int)(n); ++(i))
#define rFOR(i, a, n) for(int (i) = (int)(n)-1; (i) >= (int)(a); --(i))
#define rFORe(i, a, n) for(int (i) = (int)(n); (i) >= (int)(a); --(i))
#define REP(i, n) FOR((i), 0, (n))
#define REPe(i, n) FORe((i), 1, (n))
#define REPo(i, n) FORe((i), 0, (n))
#define rREP(i, n) rFOR((i), 0, (n))
#define rREPe(i, n) rFORe((i), 1, (n))
#define rREPo(i, n) rFORe((i), 0, (n))
#define rep(i, n) FOR((i), 0, (n))
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define fi first
#define se second
#define dup(x, y) (((x)+(y)-1)/(y))
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
using ll = long long;
using P = pair<int,int>;
using T = tuple<int,int,int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vs = vector<string>;
using vp = vector<P>;
using vt = vector<T>;

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

const ll INF = 1e18;

int main() {
  int n;
  cin >> n;
  vi a(n);
  REP(i, n) cin >> a[i];
  v(vl) dp(200005, vl(4, -INF));
  int k = 1+n%2;
  dp[0][0] = 0;
  REP(i, n) {
    REPo(j, k) {
      ll now = dp[i][j];
      chmax(dp[i+1][j+1], now);
      if ((i+j)%2==0) now += a[i];
      chmax(dp[i+1][j], now);
    }
  }
  ll ans = dp[n][k];
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 18048
n = int(input())

ans = []
for i in range(1,n+1):
    for j in range(i+1,n+1):
        if j == n-i and n%2 == 1: pass
        elif j == n-i+1 and n%2 == 0: pass
        else:
            ans.append([i, j])

print(len(ans))
[print(ans[i][0], ans[i][1]) for i in range(len(ans))]

Measured memory_bytes: 4124
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>

using namespace std;

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

static const double EPS = 1e-8;
static const double PI = 3.141592653589;
static ll INF = 9999999;
int mod = 1000000007;

#define REP(i,n)	for(int i=0;i<(int)n;++i)
#define ALL(c)		(c).begin(),(c).end()
#define CLEAR(v)	memset(v,0,sizeof(v))
#define MP(a,b)		make_pair((a),(b))
#define ABS(a)		((a)>0?(a):-(a))
#define MIN(a,b)    (a) < (b) ? (a):(b)
#define MAX(a,b)    (a) > (b) ? (a):(b)
#define debug(x) cerr << #x << " = " << x << endl;
int dx[] = {1,-1,0,0,1,-1,1,-1};
int dy[] = {0,0,1,-1,-1,1,1,-1};

using namespace std;




int main() {
    int N , M;
    cin >> N >> M;
    int box[100005][2];
    REP(i, 100005){
        box[i][0] = 1;

    }
    box[0][1] = 1;

    REP(i, M){
        int a,b;
        cin >> a >>b;
        a--;
        b--;
        box[a][0]--;
        box[b][0]++;
        if(box[a][1] == 1)box[b][1] = 1;
        if(box[a][0] == 0)box[a][1] = 0;
    }
    int ans = 0;
    REP(i, N){
        if(box[i][1] == 1)ans++;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1152
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const int dx[4] = { 0, -1, 1, 0 };
const int dy[4] = { -1, 0, 0, 1 };
const int INF = 1e9 + 7;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}

template<class T1, class T2> void chmin(T1 &a, T2 b) { if (a>b)a = b; }

template<class T1, class T2> void chmax(T1 &a, T2 b) { if (a<b)a = b; }
template<class T>
void Add(T &a, const T &b, const T &mod = 1000000007) {
	int val = ((a % mod) + (b % mod)) % mod;
	if (val < 0) { val += mod; }
	a = val;
}
////////////////////////////////////////
int main() {
	int N; ll K;
	cin >> N >> K;
	vector<ll>A(N);
	for (int i = 0; i < N; ++i)cin >> A[i];
	//Aの各bitに1がいくつたっているかを数えておく
	int nBit = 41;
	vector<int>cnt(nBit, 0);
	for (int i = 0; i < N; ++i) {
		ll a = A[i];
		int j = 0;
		while (a > 0) {
			if (a % 2 == 1)cnt[j]++;
			a /= 2;
			j++;
		}
	}

	//k+1の２進数表記 Kbinを求める
	ll KK = K + 1;
	vector<int>Kbin(nBit, 0);
	for (int i = 0; i < nBit; ++i) {
		if (KK % 2 == 1)Kbin[i] = 1;
		KK /= 2;
	}
	ll ans = 0;
	for (int i = 0; i < nBit; ++i) {
		//X<K+1となる条件(2):Kbin[i]=1
		if (Kbin[i] == 0)continue;
		//XbinはXの二進数表記
		vector<int>Xbin(nBit, 0);
		//条件(2):Xのi ビット目は0
		Xbin[i] = 0;
		//条件(1):Xのiビット目より上位ではXとK+1は一致する
		for (int j = i + 1; j < nBit; ++j) {
			Xbin[j] = Kbin[j];
		}
		//i ビットより下位では
		//各Aのjビット目の1の数がNの半分以下のとき
		//Xのjビット目も1にする
		for (int j = 0; j < i; ++j) {
			if (cnt[j] < (N + 1) / 2) {
				Xbin[j] = 1;
			}
		}
		//求めたXの２進数表現からXを求める
		ll X = 0;
		for (int j = 0; j < nBit; ++j) {
			if (Xbin[j] == 1) {
				X += (ll)1 << j;
			}
		}
		//f(X)を計算する
		ll tmp = 0;
		for (int j = 0; j < N; ++j) {
			tmp += X ^ A[j];
		}
		ans = max(ans, tmp);
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
const double PI = 3.14159265358979323846;

int main() {
  int k;
  cin >> k;
  int cnt_even = 0;
  int cnt_odd = 0;
  
  for(int i = 1; i <= k; i++) {
    if(i % 2 == 0) cnt_even++;
    else cnt_odd++;
  }
  
  int ans = cnt_even * cnt_odd;
  
  cout << ans << endl;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
int main(){
    string s;cin>>s;
    long long d= 9000000;
    long long x;
    for(int i=0;i<s.length()-2;i++){
        x = ((int)s[i]-48)*100+((int)s[i+1]-48)*10+((int)s[i+2]-48);
        d = min(abs(x-753),d);
    }
    cout<<d<<endl;
}

Measured memory_bytes: 256
import numpy as np
from itertools import product

n, m, x = map(int, input().split())
ca = np.array([list(map(int, input().split())) for _ in range(n)], dtype="i8")

ans = 10 ** 20
for bit in product([0, 1], repeat=n):
    tmp = np.zeros(m + 1)
    for i, j in enumerate(bit):
        if j == 1:
            tmp += ca[i]
    f = 0
    for i in tmp[1:]:
        if i < x:
            f = 1
    if f == 0:
        ans = min(ans, tmp[0])

if ans == 10 ** 20:
    print(-1)
else:
    print(int(ans))

Measured memory_bytes: 27152
#include<iostream>
#include<string>
#include<ctype.h>
using namespace std;
int main(){
	string a;
	char cc;
	getline(cin,a); //一行丸ごとaに格納
	for(int i=0;i<a.size();i++){
		if(isalpha(a[i])!=0){ //isalpha() アルファベットなら！＝０
			cc=a[i];
			a[i]=tolower(a[i]); 
			if(cc==a[i])
				a[i]=toupper(a[i]);
		}
		cout<<a[i];
	}
	cout<<endl;
	return 0;
}



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

int main() {
  int N, fl = 0;
  string s, as;
  cin >> N >> s;
  for (int i = 0; i < N; i++) {
    as += '#';
    if (s[i] == '.') fl += 1;
  }
  int m = fl;
  for (int i = 0; i < N; i++) {
    as[i] = '.';
    if (s[i] == '.') fl -= 1;
    else fl += 1;
    m = min(m,fl);
  }
  cout << m << endl;
}

Measured memory_bytes: 776
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <cassert>
using namespace std;
typedef long long ll;
const int INF = 1<<30;
const ll MOD = 1e9+7;
const double EPS = 1e-9;

int decide(int n, int ai, vector<int> &b){
  int N = (int)b.size();
  int sum = 0;
  for(int i=2; i*n<=N; i++){
    sum += b[n*i-1];
  }
  return (sum%2)^ai;
}

int main(int argc, const char * argv[]) {
  int N; cin >> N;
  vector<int> a(N);
  for(int i=0; i<N; i++)
    cin >> a[i];
  
  vector<int> b(N, -1);
  int left;
  for(int d=2; d<=(N/2 + 1); d++){
    left = N/d + 1;
    while(b[left-1] == -1){
      b[left-1] = decide(left, a[left-1], b);
      left++;
    }
  }
  int M = 0;
  for(int i=1; i<N; i++){
    M += b[i];
  }
  assert(b[0] == -1);
  b[0] = (M%2) != a[0];
  
  cout << M + b[0] << endl;
  for(int i=0; i<N; i++){
    if(b[i] == 1) cout << i+1 << endl;
  }
  
  return 0;
}


Measured memory_bytes: 2432
#include <iostream>
#include <stdio.h>
#include <string>
#include <vector>

using namespace std;

int main() {

	int a, b, c, x;
	cin >> a >> b >> c >> x;

	int d = 0;

	for (int i = 0; i <= a; i++) {
		for (int j = 0; j <= b; j++) {
			for (int k = 0; k <= c; k++) {
				if (500 * i + 100 * j + 50 * k == x) {
					d++;
				}
			}
		}
	}

	cout << d << endl;

	return 0;

}


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

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    int a[n], b[n], c[n-1];

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

    int sum = b[a[0] - 1];
    for (int i = 1; i < n; ++i){
        sum += b[a[i] - 1];

        if(a[i] == a[i - 1] + 1) sum += c[a[i - 1] - 1];
    }
    cout << sum << endl;

}

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

int N, M;
vector<pair<int, int>> wars;

int main() {
    cin >> N >> M;
    wars.resize(M);
    for (int i = 0; i < M; i++) {
        int a, b;
        cin >> a >> b;
        wars.at(i) = make_pair(a, b);
    }

    sort(wars.begin(), wars.end(), [](auto const &lhs, auto const &rhs) {
        return lhs.second < rhs.second;
    });

// i番目とi+1番目をかける橋
    int right_bridge = 0;
    int res = 0;

    for (auto &e: wars) {
        if (right_bridge < e.first || right_bridge >= e.second) {
            res++;
            right_bridge = e.second - 1;
        }
    }

    cout << res << endl;
}

    

Measured memory_bytes: 1024
module ABC137

  ! <module>s to import
  use, intrinsic :: iso_fortran_env

  ! require all variables to be explicitly declared
  implicit none

  ! accessibility of <subroutine>s and <function>s in this <module>
  public :: task_B

  ! constants for this <module>
  integer(INT32), parameter, private :: val_coordinate_min_limit = -10000000_INT32
  integer(INT32), parameter, private :: val_coordinate_max_limit =  10000000_INT32

  ! contained <subroutine>s and <function>s are below
  contains

  subroutine task_B (val_width, val_coordinate)

    ! arguments for this <subroutine>
    integer(INT32), intent(in) :: val_width, val_coordinate

    ! variables for this <subroutine>
    integer(INT32) :: val_coordinate_min
    integer(INT32) :: val_coordinate_max

    ! support variables for this <subroutine>
    integer(INT32) :: itr

    ! STEP.01
    ! calculate the range of coordinate where the black stone was set
    val_coordinate_min = val_coordinate - (val_width - 1_INT32)
    val_coordinate_max = val_coordinate + (val_width - 1_INT32)

    ! STEP.02
    ! adjust the range
    val_coordinate_min = max(val_coordinate_min, val_coordinate_min_limit)
    val_coordinate_max = min(val_coordinate_max, val_coordinate_max_limit)

    ! STEP.03
    ! output the answer of this task
    write(unit=OUTPUT_UNIT, fmt='(I0)', advance='no') val_coordinate_min

    do itr = val_coordinate_min + 1_INT32, val_coordinate_max, 1_INT32
      write(unit=OUTPUT_UNIT, fmt='(1X,I0)', advance='no') itr
    end do

    write(unit=OUTPUT_UNIT, fmt='(A)', advance='yes') ""

    ! STEP.END
    return

  end subroutine task_B

end module ABC137


program main

  ! <module>s to import
  use, non_intrinsic :: ABC137

  ! require all variables to be explicitly declared
  implicit none

  ! variables for this <program>
  integer(INT32) :: K, X

  ! STEP.01
  ! read out the given data
  read(unit=INPUT_UNIT, fmt=*) K, X

  ! STEP.02
  ! calculate & output the answer of this task
  call task_B (K, X)

end program main

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
    int n,a[200000];
    int max1 = 0,max2 = 0,maxn1,maxn2;
    scanf("%d",&n);
    for (int i = 0; i < n; i++)
    {
        scanf("%d",&a[i]);
    }

    for (int i = 0; i < n; i++)
    {
        if (a[max1] < a[i])
        {
            max1 = i;
        }
    }
    maxn1 = a[max1];
    a[max1] = 0;
    for (int i = 0; i < n; i++)
    {
        if (a[max2] < a[i])
        {
            max2 = i;
        }
    }
    maxn2 = a[max2];
    
    for (int i = 0; i < n; i++)
    {
        printf("%d\n",i == max1 ? maxn2 : maxn1);
    }
    
}


Measured memory_bytes: 2304
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskX solver = new TaskX();
		solver.solve(1, in, out);
		out.close();
	}

	static int INF = 1 << 30;
	static int MOD = 1000000007;
	static int[] mh4 = { 0, -1, 1, 0 };
	static int[] mw4 = { -1, 0, 0, 1 };

	static class TaskX {
		public void solve(int testNumber, InputReader in, PrintWriter out) {

			int n = in.nextInt();
			long[] a = new long[n];
			long[] sa = new long[n];
			long sum = 0;
			for (int i = 0; i < n; i++) {
				long t = in.nextLong();
				a[i] = t;
				sum += t;
			}

			long m = 0;
			if (sum % ((long)n*(n+1)/2) == 0) {
				m = sum / ((long)n*(n+1)/2);
			} else {
				out.println("NO");
				return;
			}

			for (int i = 0; i < n; i++) {
				sa[i] = a[(i+1)%n] - a[i];
			}

			for (int i = 0; i < n; i++) {
				sa[i] -= m;
			}

			long k = 0;
			for (int i = 0; i < n; i++) {
				if (sa[i] <= 0 && sa[i] % n == 0) {
					k -= sa[i] / n;
				} else {
					out.println("NO");
					return;
				}
			}

			out.println(k == m ? "YES" : "NO");
		}
	}

	static class InputReader {
		BufferedReader in;
		StringTokenizer tok;

		public String nextString() {
			while (!tok.hasMoreTokens()) {
				try {
					tok = new StringTokenizer(in.readLine(), " ");
				} catch (IOException e) {
					throw new InputMismatchException();
				}
			}
			return tok.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(nextString());
		}

		public long nextLong() {
			return Long.parseLong(nextString());
		}

		public double nextDouble() {
			return Double.parseDouble(nextString());
		}

		public int[] nextIntArray(int n) {
			int[] res = new int[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextInt();
			}
			return res;
		}

		public long[] nextLongArray(int n) {
			long[] res = new long[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextLong();
			}
			return res;
		}

		public InputReader(InputStream inputStream) {
			in = new BufferedReader(new InputStreamReader(inputStream));
			tok = new StringTokenizer("");
		}

	}

}


Measured memory_bytes: 37960