akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<cstring>
#include<map>
#include<algorithm>
using namespace std;
typedef long long ll;
const int INF=0x3f3f3f3f;
const int maxn=1e6+10;
struct node{
	int index,num;
};
node q[200010];
bool cmp(node a,node b)
{
	return a.num<b.num;
}
int main()
{
	int n,k;
	while(~scanf("%d%d",&n,&k))
	{
		map<int,int> m;
		int cnt=0,type=0;
		for(int i=0;i<n;i++) 
		{
			int a;
			scanf("%d",&a);
			if(m.find(a)==m.end())
			type++;
			m[a]++;
		}
		map<int,int>::iterator it;
		for(it=m.begin();it!=m.end();it++)
		{
			q[cnt].index=it->first;
			q[cnt].num=it->second;
			cnt++;
		}
		if(type<=k)
		{
			printf("0\n");
		}
		else
		{
			sort(q,q+cnt,cmp);
			int ans=0;
			int temp=type-k;
			for(int i=0;i<temp;i++)
			{
				ans+=q[i].num;
			}
			printf("%d\n",ans);
		}
	}
	return 0;
}

Measured memory_bytes: 11136
import java.util.*;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		int K = sc.nextInt();
		sc.close();
		int[] Array = {A,B,C};
		Arrays.sort(Array);
		for(int i = 0;i < K;i++) {
			Array[2] *= 2;
		}
		System.out.println(Array[0] + Array[1] + Array[2]);	
	}

}


Measured memory_bytes: 23124
#include<iostream>
#include<string>

using namespace std;

int main(){
	string str;
	int ans = 0;

	while (cin >> str){
		int i = 0;
		int n = str.size();
		int a = 1;
		while (i * 2 < n){
			if (str[i] != str[n - i - 1]){
				a = 0;
				break;
			}
			i++;
		}
		if (a)
			ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1180
import math
N,M,C=map(int,input().split())
B=list(map(int,input().split()))
A=[]
for i in range(N):
    A.append(list(map(int,input().split())))
ans=0
for j in range(N):
    judge=C
    for i in range(M):
        judge+=A[j][i]*B[i]
    if judge>0:
        ans+=1
print(ans)


Measured memory_bytes: 3060
//#pragma GCC target("avx2")
#pragma GCC optimize("O3")
//#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

template <typename T>
void print(T x) {
    cout << x << "\n";
}

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REVFOR(i, m, n) for (int i = (n - 1); i >= (m); --i)
#define REP(i, n) FOR(i, 0, n)
#define REVREP(i, n) REVFOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

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

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

void SOE(ll N, vi & p) {
    int m = int(floor(sqrt(N))) + 1;
    int s[m];
    REP(i ,m) s[i] = i;

    FOR (i, 2, m) {
        if (s[i] != i) continue;

        p.pb(i);

        for (int j = i+i; j <= m; j += i) {
            s[j] = i;
        }
    }
}

void solve(int n, vll& a) {
    ll g = a[0];
    REP(i, n) g = __gcd(g, a[i]);

    vector<int> prime;
    SOE(1e6, prime);

    map<int, int> m;

    bool f = true;
    REP(i, n) {
        for(auto &e: prime) {
            if (a[i] % e != 0) continue;

            if (m[e] > 0) f = false;

            int cnt = 0;
            while(a[i] % e == 0) {
                a[i] /= e;
                cnt++;
            }

            m[e] += cnt;
        }

        if (a[i] > 1) {
            if (m[a[i]] > 0) f = false;
            m[a[i]] += 1;
        }
    }

    if (f) {
        print("pairwise coprime");
    } else {
        if (g == 1) {
            print("setwise coprime");
        }
        else print("not coprime");
    }
}

int tle(int n, vll &a) {
    ll g = a[0];
    REP(i, n) g = __gcd(g, a[i]);

    bool f = true;
    REP(i, n) FOR(j, i + 1, n) {
        f &= __gcd(a[i], a[j]) == 1;
//        debug(a[i], a[j], __gcd(a[i], a[j]))
    }

    if (f) {
        return  1;
    } else {
        if (g == 1) return 2;
        return 3;
    }
}

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


    int n;
    cin >> n;

    vll a(n); REP(i, n) cin >> a[i];

    solve(n, a);
}


Measured memory_bytes: 14720
#include <bits/stdc++.h>
#define exrep(i, a, b) for(long long i = a; i <= b; i++)
#define rep(i,n)for(long long i=0;i<(n);i++)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
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 ll MOD=1e9+7;
const ll INF=1e18;
const int MAX=110000;
const double pi=acos(-1);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

ll gcd(ll x, ll y){
  if(x%y==0)return y;
  return gcd(y,x%y);
}
ll lcm(ll x,ll y){
  return x/gcd(x,y)*y;
}
ll f(ll a){
  if(a%4==0)return a;
  if(a%4==1)return 1;
  if(a%4==2)return a+1;
  if(a%4==3)return 0;
}
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);  
  
  ll a,b;
  cin >> a >> b;
  ll ans=f(a-1)^f(b);
  cout << ans << endl;
}

Measured memory_bytes: 256
import sys

def input():
    return sys.stdin.readline().strip()

def main():
    N,K = map(int,input().split())
    A = sorted(list(map(int,input().split())))
    left = 0
    right = A[-1]

    while right - left > 1:
        cnt = 0
        middle = (left + right) // 2
        for i in A:
            cnt += (i - 1) // middle
        if cnt <= K:
            right = middle
        else:
            left = middle
    print(right)


if __name__ == "__main__":
    main()

Measured memory_bytes: 30924
#include <bits/stdc++.h>
using namespace std;
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; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
*/

int main(){
    string s; cin >> s;
    int tmp1 = 0, tmp2 = 0;

    for(int i=0; i<s.size(); i++){
        if(i%2 == 0 && s[i] == '1') tmp1++;
        if(i%2 == 1 && s[i] == '0') tmp1++;

        if(i%2 == 0 && s[i] == '0') tmp2++;
        if(i%2 == 1 && s[i] == '1') tmp2++;
    }

    cout << min(tmp1, tmp2) << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
#define SORT(c) sort((c).begin(),(c).end())
#define dbug(x) cout<<#x<<"="<<x<<endl
#define m0(x) memset(x,0,sizeof(x))
#define rep(i, n) for(ll i = 0; i < n; i++)
#define reprs(i, m, n) for(ll i = n; i >= m; i--)
#define reps(i, m, n) for(ll i = m; i < n; i++)
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<ll, ll> pl;

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

const int MOD = 1000000007;

int main(){

  ll N,K;
  cin >>N>>K;

//  ll dp[K+1][N+1];
  vector<ll> fs;

  fs.emplace_back(0);

  for(ll i=1;i<=sqrt(N);i++){
    fs.emplace_back(i);
  }

  ll size=fs.size()-1;

  for(ll i=size;i>=1;i--){
    ll x=N/i;
    if(x==size) continue;
    fs.emplace_back(x);
  }

  ll size2=fs.size();
  ll dp[K+1][size2];
  ll temp=0;

  reps(i,1,K+1){
    reprs(j,1,size2-1){
      if(i==1){
        dp[i][j]=1;
      }
      else if(j==size2-1){
        dp[i][j]=dp[i-1][1];
      }
      else {
        dp[i][j]=(dp[i][j+1]+dp[i-1][size2-j]*(fs[size2-j]-fs[size2-j-1]))%MOD;
      }
    }
  }

  ll ans=0;

  reps(j,1,size2){
    ans=(ans+dp[K][j]*(fs[j]-fs[j-1]))%MOD;
  }
  cout << ans <<endl;
  return 0;
}


Measured memory_bytes: 50296
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, a, b) for (ll i = (a); i < (b); i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((int)(x).size())
#define PRINT(V) for (auto v:(V)) {cerr << v << " ";} cerr << endl
#define dump(x) cerr << #x << " : " << (x) << endl
#define dump2(x, y) cerr << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")" << endl
inline ll GCD(ll a, ll b){return b ? GCD(b, a % b) : a;}
#define int ll
/* END OF TEMPLATE */

ll l, a, b, MOD;

ll cdf(ll x){
    if(x < a) return 0;
    if(x >= a+(l-1)*b) return l;
    return (x-a)/b+1;
}

// https://atcoder.jp/contests/abc129/submissions/5854082
ll mod_pow(ll x, ll p, ll M = MOD) {
  ll a = 1;
  while (p) {
    if (p % 2)
      a = a*x%M;
    x = x*x%M;
    p /= 2;
  }
  return a;
}

ll mod_inverse(ll a, ll M = MOD) {
  return mod_pow(a, M - 2, M);
}


int keta(ll x) {
  int cnt = 0;
  while (x > 0) {
    cnt++;
    x /= 10;
  }
  return cnt;
}

ll value(ll idx) {
  return a + b * idx;
}

typedef vector<ll> vec;
typedef vector<vec> mat;

mat mul(mat &A, mat &B) {
	mat C(A.size(), vec(B[0].size()));
	for (int i = 0; i < A.size(); i++) {
		for (int k = 0; k < B.size(); k++) {
			for (int j = 0; j < B[0].size(); j++) {
				C[i][j] = C[i][j] + A[i][k] * B[k][j] % MOD;
                C[i][j] %= MOD;
			}
		}
	}
	return C;
}

vec mul(mat &A, vec &B) {
	vec C(A.size());
	for (int i = 0; i < A.size(); i++) {
		for (int j = 0; j < B.size(); j++) {
			C[i] += A[i][j] * B[j] % MOD;
            C[i] %= MOD;
		}
	}
	return C;
}

mat pow(mat A, ll n) {
	mat B(A.size(), vec(A.size()));
	for (int i = 0; i < A.size(); i++) {
		B[i][i] = 1;
	}
	while (n > 0) {
		if (n & 1)B = mul(B, A);
		A = mul(A, A);
		n >>= 1;
	}
	return B;
}
// ------------------------------------------

signed main(){
    cin.tie(0); ios::sync_with_stdio(false);
    cin >> l >> a >> b >> MOD;
    vll cd(19, 0);
    ll d_ = 1;
    ll d__ = 1;
    repr(i, 1, 19){
        d_ *= 10;
        cd[i] = cdf(d_-1) - cdf(d__-1);
        d__ *= 10;
    }
    vec v{0, a, 1};
    ll d = 1;
    repr(i, 1, 19){
        d *= 10;
        d %= MOD;
        mat mt{{d%MOD, 1, 0}, {0, 1, b}, {0, 0, 1}};
        mt = pow(mt, cd[i]);
        v = mul(mt, v);
    }
    cout << v[0] << endl;
    return 0;
}

Measured memory_bytes: 256
N,W=map(int,input().split())
DP=[[0 for j in range(W+10)] for i in range(N+10)]
v=[0]*(N+1)
w=[0]*(N+1)
for i in range(1,N+1):
    v[i],w[i]=map(int,input().split())
for i in range(1,N+1):
    for j in range(1,W+1):
        if j-w[i]<0:
            DP[i][j]=DP[i-1][j]
        else:
            if v[i]+DP[i-1][j-w[i]]>DP[i-1][j]:
                DP[i][j]=v[i]+DP[i-1][j-w[i]]
            else:
                DP[i][j]=DP[i-1][j]
print(DP[N][W])


Measured memory_bytes: 26688
def ABC072C(d,i):
    if i not in d:
        d[i]=1
    else:
        d[i]+=1
    return d


n=int(input())
a=map(int,input().split())
d=dict()
for i in a:
    d=ABC072C(d,i-1)
    d=ABC072C(d,i)
    d=ABC072C(d,i+1)
print(max(d.values()))

Measured memory_bytes: 22036
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

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

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

      String[] lines = br.readLine().split(" ");
      int a = Integer.parseInt(lines[0]);
      int b = Integer.parseInt(lines[1]);

      String ans = "No";
      if((a & 1) == 1 && (b & 1) == 1)
        ans = "Yes";

      System.out.println(ans);
    }
    catch(IOException e) {
      System.err.println(e);
    }
  }
}

Measured memory_bytes: 20564
import sys
import bisect
from collections import deque

fastinput = sys.stdin.readline
N = int(fastinput())
A = [int(fastinput()) for j in range(N)]
surface = deque([A[0]])#常に小さい順にソートされている
surfMax = A[0]
surfMin = A[0]
color = 1
for n,a in enumerate(A):
    if n==0:continue

    if color == 1:
        c = surface[0]
        if a>c:
            surface[0] = a
            surfMax = a
            surfMin = a
        if a==c:
            surface.appendleft(a)
            color += 1
        if a<c:
            surface.appendleft(a)
            color += 1
            surfMin = a

    else:    
        if a<=surfMin:
            color += 1
            surface.appendleft(a)
            surfMin = a
        elif a>surfMax:
            surface[color-1] = a
            surfMax = a
        else:
            pos = bisect.bisect_left(surface,a) -1 #a未満の最大の整数
            surface[pos] = a
            if pos==0:
                surfMin = a
            if pos == color-1:
                surfMax = a
print(color)


Measured memory_bytes: 46940
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> mp;
ll inf =  1e9;


int main(){
    while( 1 ){
	string s;
	cin>>s;
	if( s=="#")break;
	vector< vector<int> > t;
	vector<int> a;
	for(int i=0;i<s.size();i++){
	    if( s[i]=='b' )
	    {
		a.push_back(1);
	    }else if( s[i] == '/' ){
		t.push_back( a );
		a.clear();
	    }else{
		int j = s[i]-'0';
		for(int k = 0;k<j;k++)a.push_back(0);
	    }
	}
	t.push_back( a );
	int x,y,z,w;
	cin>>x>>y>>z>>w;
	swap( t[x-1][y-1] , t[z-1][w-1] );
	for(int i=0;i<t.size();i++){
	    int cnt = 0;
	    for(int j=0;j<t[i].size();j++){
		if( t[i][j] == 1 ){
		    if( cnt )cout<<cnt,cnt=0;
		    cout<<'b';
		}else{
		    cnt++;
		}
	    }
	    if(cnt)cout<<cnt,cnt=0;
	    if(i!=t.size()-1)cout<<'/';
	}
	cout<<endl;
    }
    return 0;
}



Measured memory_bytes: 3188
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastReader in = new FastReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        BOneClue solver = new BOneClue();
        solver.solve(1, in, out);
        out.close();
    }

    static class BOneClue {
        public void solve(int testNumber, FastReader s, PrintWriter out) {
            int k = s.nextInt();
            int x = s.nextInt();

            for (int i = x - k + 1; i < x + k; i++) {
                out.print(i + " ");
            }
        }

    }

    static class FastReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private FastReader.SpaceCharFilter filter;

        public FastReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1) {
                throw new InputMismatchException();
            }
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0) {
                    return -1;
                }
            }
            return buf[curChar++];
        }

        public int nextInt() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9') {
                    throw new InputMismatchException();
                }
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public boolean isSpaceChar(int c) {
            if (filter != null) {
                return filter.isSpaceChar(c);
            }
            return isWhitespace(c);
        }

        public static boolean isWhitespace(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}



Measured memory_bytes: 22868
N, P = map(int,input().split())

def factorize(n):
  factor = []
  b, e = 2, 0
  while b * b <= n:
    if n % b == 0:
      while n % b == 0:
        n //= b
        e += 1
      factor.append((b, e))
    b, e = b + 1, 0
  if n != 1:
    factor.append((n, 1))
  return factor

ans = 1
for b, e in factorize(P):
  ans *= pow(b, (e//N))
print(ans)

Measured memory_bytes: 3064
n = int(input())
ll = []
for i in range(n):
  x, l = map(int, input().split())
  ll.append([x-l, x+l])
ll = sorted(ll, key=lambda x: x[1])

ans = 0
tmp = -10**9

for s, t in ll:
  if s >= tmp:
    ans += 1
    tmp = t

print(ans)

Measured memory_bytes: 22104
#include <bits/stdc++.h>
using namespace std;
#ifdef _IS_LOCAL //
#define dout cout
#define debug() if(true)
#else
#define dout if(false) cout
#define debug() if(false)
#endif//
#define next asdnext
#define prev asdprev
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define vrep(i, v) for(auto &i : v)
#define all(x) (x).begin(),(x).end()
#define vout(v) for(auto &i:v){cout<<i<<" ";}cout<<"\n"; //配列出力
#define vin(v) for(auto &i:v)cin>>i; //配列入力
#define vec(v,n) vector<int> v(n,0);
typedef long long ll;
typedef unsigned long long ull;

void Main() {
	int r;
	cin>>r;
	cout<<(3*r*r)<<endl;
}

int main() {
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << std::fixed << std::setprecision(15);
	Main();
	return 0;
}


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

int main(){
    string S, T;
    cin >> S;
    cin >> T;

    for(int i=S.size()-1; i>=T.size()-1; i--){
        bool flag = true;
        for(int j=T.size()-1; j>-1; j--){
            if(S[i+j-T.size()+1] == T[j] || S[i+j-T.size()+1] == '?') continue;
            else{
                flag = false;
                break;
            }
        }
        if(flag){
            S.replace(i-T.size()+1, T.size(), T);
            for(int j=0; j<S.size(); j++){
                if(S[j] == '?') S[j] = 'a';
            }
            cout << S << endl;
            return 0;
        }
    }

    cout << "UNRESTORABLE" << endl;
    return 0;
}


Measured memory_bytes: 256
n, a, b = map(int, input().split())
x = tuple(map(int, input().split()))

# o <-tel-> o --walk-- 0 -- walk-- o <=tel-> ...
# 左から順にa,b最小コストを選択
print(sum(min((after - prev) * a, b) for prev, after in zip(x, x[1:])))

# http://xxxasdfghjk999.hatenablog.jp/entry/2018/07/29/214705
# 最小全域木だとTLEする
# 徒歩区間を連結できるので、貪欲に決まる


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

using namespace std;

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

  int n, t;
  cin >> n>>t;
  vector<int> a(n);
  for (auto& e : a) {
    cin >> e;
  }
  int max_diff = 0;
  int min_cost = INT_MAX;
  int cnt = 0;
  for (int i = 0; i < n; ++i) {
    min_cost = min(min_cost, a[i]);
    int diff = a[i] - min_cost;
    if (max_diff < diff) {
      cnt = 1;
      max_diff = diff;
    } else if (diff == max_diff){
      ++cnt;
    }
  }
  cout << cnt << "\n";
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define REP(i, n) for(decltype(n) i = 0; i < n; i++)
#define REPvec(itr, mp) for(auto itr = mp.begin();itr != mp.end(); itr ++)
#define readvec(vec) for(auto& e: vec){cin >> e;}
#define all(x) x.begin(), x.end()
#define MOD 1000000007//1e9+7
using namespace std;
typedef long long int ll;
typedef vector<int >    vecint;
typedef vector<ll >      vecll;
typedef vector<double >   vecd;
typedef vector<string > vecstr;
typedef vector<char >  vecchar;
typedef vector<bool >  vecbool;
typedef vector<vector<bool> >  vec2bool;
typedef vector<vector<int> >    vec2int;
typedef vector<vector<double> >   vec2d;
////////////////////////////////////////////////
void init()
{
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}
////////////////////////////////////////////////
int main()
{
  int n, m; cin >> n >> m;
  vecll a(n,0), b(n,0), c(n,0);
  REP(i,n){
    cin >> a[i] >> b[i] >> c[i];
  }
  ll sign [2] = {-1,+1};
  ll ans = 0;
  for(auto& sa: sign){
    for(auto& sb: sign){
      for(auto& sc: sign){
        vecll v(n,0);
        REP(i,n)v[i] = sa*a[i] + sb*b[i] + sc*c[i];
        sort(all(v), greater<ll>());
        ll tmp = 0;
        REP(i,m){
          tmp += v[i];
        }
        ans = max(tmp, ans);
      }
    }
  }
  cout << ans << endl;
}



Measured memory_bytes: 256
// clang-format off
#include <bits/stdc++.h>

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (int i = 0; i < int(n); i++)
#define forn1(i,n) for (int i = 1; i <= int(n); i++)
#define popcnt __builtin_popcount
#define ffs __builtin_ffs
#define ctz __builtin_ctz
#define clz __builtin_clz
#define all(a) (a).begin(), (a).end()
 
using namespace std;

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
using pil = pair<int,ll>;
using pll = pair<ll,ll>;
template <typename T> using vec = vector<T>;
using vi = vec<int>;
using vl = vec<ll>;
template <typename T> using que = queue<T>;
template <typename T> using deq = deque<T>;

template <typename T> T id(T b) {return b;};
template <typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template <typename T> void chmin(T &x, T y) {if (x > y) x = y;}
template <typename S, typename K> bool contains(S &s, K k) { return s.find(k) != s.end(); }
void fastio() { ios_base::sync_with_stdio(false); cin.tie(nullptr); }
constexpr ll TEN(int n) { if (n == 0) return 1LL; else return 10LL*TEN(n-1); }
// clang-format on

const int MAX_N = 200000;
int n;
int a[MAX_N], b[MAX_N];

int main() {
    fastio();

    cin >> n;
    forn(i, n) cin >> a[i] >> b[i];

    sort(a, a + n);
    sort(b, b + n);

    int meda, medb;
    if (n % 2 == 0) {
        meda = a[n / 2] + a[n / 2 - 1];
        medb = b[n / 2] + b[n / 2 - 1];
    } else {
        meda = a[n / 2];
        medb = b[n / 2];
    }

    //cout << medb << " " << meda << endl;

    int ans = medb - meda + 1;

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 5180
#include <iostream>
#include <string>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
#define ref goto refrain
int main(){
	int n;
	refrain:
	double ave=0;
	cin>>n;
	if(n==0) return 0;
	double a[n];
	for(int i=0;i<n;i++){
		cin>>a[i];
		ave+=a[i];
	}
	ave=ave/n;
	double stdev=0;
	for(int i=0;i<n;i++){
		a[i]=a[i]-ave;
		stdev+=a[i]*a[i];
	}
	stdev/=n;
	printf("%lf\n",sqrt(stdev));
	ref;
}

Measured memory_bytes: 1256
function Main( input ){

    input = input.split( '\n' )
    
    var n = Number( input[0] )
    var str = []
    
    for( var i=1; i<n+1; i++ ){
        str.push( [].slice.call( input[i] ).sort() )
    }
    
    var output = ''
    var base = str.shift()
    
    function arr( base, str ){
        if( str.length === 0 ) return base
        
        var s = str.shift()
        
        var out = []
        for( var i=0; i<base.length; i++ ){
            for( var j=0; j<s.length; j++ ){
                if( base[i] === s[j] ){
                    out.push( base[i] )
                    s.splice( j, 1 )
                    break
                }
            }
        }
        
        return arr( out, str )
    }
    
    var result = arr( base, str )
    
    if( result.length === 0 ) console.log()
    else console.log( result.join( '' ) )
    
}

Main( require( 'fs' ).readFileSync( '/dev/stdin', 'utf8' ) )

Measured memory_bytes: 21192
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define endl "\n"
#define sz(x) (int)(x).size()
#define _USE_MATH_DEFINES
using namespace std;
typedef long long int lli;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    
    string s;
    cin >> s;
    if (s == "ABC")
      cout << "ARC";
    else
      cout << "ABC";
    return 0;
}

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

int main(){
    int n;
    cin >> n;
    int i=n%10;
    if (i==0 || i==1 || i==6 || i==8){
        cout << "pon" << endl;
    }
    else if (i==2 || i==4 || i==5 || i==7 || i==9){
        cout << "hon" << endl;
    }
    else if (i==3){
        cout << "bon" << endl;
    }
    return 0;
}

Measured memory_bytes: 3624
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
    Scanner scanner = new Scanner(System.in);
    int a = scanner.nextInt();
    int b = scanner.nextInt();
    if(a > b){
      System.out.println("a > b");
    }
    else if(a < b){
      System.out.println("a < b");
    }
    else{
      System.out.println("a == b");
    }
    }
  }

Measured memory_bytes: 26264
#include <array>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
using namespace std;


typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
	v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
	stringstream ss;
	ss << f;
	ss >> t;
}


#define REP(i,n) for(int i=0;i<int(n);++i)
#define ALL(v) (v).begin(),(v).end()
#define RALL(v) (v).rbegin(),(v).rend()
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define PB push


#define MOD 1000000007LL
#define EPS 1e-10

int main()
{
    const int inf = 100000000;

    int n, m;
    cin >> n >> m;

    int a[1000], b[1000], c[1000], dist[100][100];

    REP(i, m)
    {
        cin >> a[i] >> b[i] >> c[i];
        --a[i]; --b[i];
    }

    REP(i, n)
    {
        REP(j, n)
        {
            if (i == j)
            {
                dist[i][j] = 0;
            }
            else
            {
                dist[i][j] = inf;
            }
        }
    }

    REP(i, m)
    {
        dist[a[i]][b[i]] = c[i];
        dist[b[i]][a[i]] = c[i];
    }

    REP(k, n) REP(i, n) REP(j, n)
    {
        dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
    }

    int ans = 0;
    REP(i, m)
    {
        if (c[i] > dist[a[i]][b[i]]) ++ans;
    }

    cout << ans << endl;

    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);
		int n = sc.nextInt();
		int h[] = new int[n+1];
		for (int i = 1; i <= n; i++) {
			h[i] = sc.nextInt();
		}
h[0]=0;
int ans=0;
for (int i =0; i <= n-1; i++) {
if(h[i]<h[i+1]){
ans+=h[i+1]-h[i];
}
}
System.out.println(ans);
	}
}

Measured memory_bytes: 21972
N, W = list(map(int, input().split()))
Bs = []
for i in range(N):
    Bs.append(tuple(map(int, input().split())))

dp = [[0 for _ in range(W + 1)] for _ in range(N + 1)]
for i in range(N - 1, -1, -1):
    for j in range(W + 1):
        dp[i][j] = max(dp[i + 1][j], (dp[i + 1][j - Bs[i][0]] + Bs[i][1]) if j >= Bs[i][0] else 0)

print(dp[0][W])

Measured memory_bytes: 171656
#include<bits/stdc++.h>
using namespace std;
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define P pair<int,int>
#define PP pair<P,int>
#define fi first
#define se second
#define INF 1e9
#define MOD 1000000007
#define REP(i,n) for(int i=0;i<n;i++)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
int main(){
    int n;
    cin>>n;
    string a,b;
    cin>>a>>b;
    int ans=sz(a)+sz(b);
    for(int i=1;i<=min(sz(a),sz(b));i++){
        if(a.substr(sz(a)-i,i)==b.substr(0,i)){
            ans=min(ans,sz(a)+sz(b)-i);
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
const long long MOD = 998244353;

template< typename T >
T mod_pow(T x, T n, const T &p) {
  T ret = 1;
  while(n > 0) {
    if(n & 1) (ret *= x) %= p;
    (x *= x) %= p;
    n >>= 1;
  }
  return ret;
}


void solve(long long N, long long S, std::vector<long long> A){
    ll dp[N+1][S+5] ={};
    dp[0][0] = 1;
    // ll sum[S+5] = {};
    for(int i=0;i<N;i++){
        // cerr <<"i="<<i <<endl;
        for(int j=0;j<=S;j++){
            // cerr <<"j="<< j<<"val= " << dp[i][j] << endl;
            dp[i+1][j] += (dp[i][j]*2);
            dp[i+1][j] %= MOD;
          
            if(A[i]+j>S){
                continue;
            }
            dp[i+1][j+A[i]] += dp[i][j];
            dp[i+1][j+A[i]] %= MOD; 
        }
        
    }
    cout << dp[N][S] %MOD << 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 N;
    scanf("%lld",&N);
    long long S;
    scanf("%lld",&S);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    solve(N, S, std::move(A));
    return 0;
}


Measured memory_bytes: 74160
#pragma optimization_level 3
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx")

#include<bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);cout<<fixed;cout<<setprecision(10);
#define randomINIT mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define ll long long
#define gcj cout<<"Case #"<<tc<<": "
#define ld long double
#define pll pair<ll,ll>
#define vll vector<pll>
#define vl vector<ll>
#define f first
#define s second
#define pb push_back
#define MAP map<ll,ll>
#define MAPs map<ll,sl>
#define MAPv map<ll,vl>
#define mset1(x,val,n) foo(i,0,n+5) x[i]=val;
#define mset2(x,val,n,m) foo(i,0,n+5) foo(j,0,n+5) x[i][j]=val;
#define mod 1000000007
#define foo(i,a,b) for(ll i=(a);i<=(b);i++)
#define rep(i,a,b) for(ll i=(a);i>=(b);i--)
#define FOR(i,v) for(auto &(i):(v))
#define OUTv(v) for(auto &i:(v)) cout<<i<<" ";
#define deb1(a) cout<<a<<"\n";
#define deb2(a,b) cout<<a<<" "<<b<<"\n";
#define deb3(a,b,c) cout<<a<<" "<<b<<" "<<c<<"\n";
#define deb4(a,b,c,d) cout<<a<<" "<<b<<" "<<c<<" "<<d<<"\n";
#define sl set<ll>
#define sll set<pll>
#define ub upper_bound
#define lb lower_bound
using namespace std;

const ll   INF = 0x7f7f7f7f7f7f7f7f;
const ll NINF = -INF;
const ll MAXN  = 1e+6 + 8;

int dx8[] = {0, 1, 1, 1, 0, -1, -1, -1}, dy8[] = {1, 1, 0, -1, -1, -1, 0, 1};
int dx4[] = {0, 1, 0, -1}, dy4[] = {1, 0, -1, 0};

struct custom_hash {
	static uint64_t splitmix64(uint64_t x) {
		// http://xorshift.di.unimi.it/splitmix64.c
		x += 0x9e3779b97f4a7c15;
		x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
		x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
		return x ^ (x >> 31);
	}
	size_t operator()(uint64_t x) const {
		static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
		return splitmix64(x + FIXED_RANDOM);
	}
};

#define UMAP unordered_map<ll,ll,custom_hash>

ll t = 1; randomINIT;
//<<-----Declare Variable Here------->>//
ll k, d, dp[10000][2][100];

//<<-----Implement Functions Here---->>//
ll solve(string &S, ll index, bool smaller, ll rem) {
	if (index == S.size()) {
		if (rem == 0) return 1;
		else return 0;
	}
	if (dp[index][smaller][rem] != -1) return dp[index][smaller][rem];
	ll limit = 9, cnt = 0;
	if (smaller) limit = S[index] - '0';
	foo(i, 0, limit) {
		bool ns;
		if (i < S[index] - '0') ns = 0;
		else ns = smaller;
		cnt = (cnt % mod + (solve(S, index + 1, ns, (rem  + i) % d)) % mod) % mod;
	}
	return dp[index][smaller][rem] = cnt;
}

//<<-----Start of Main--------------->>//
void MAIN(ll tc) {
	// cin >> k >> d;
	string A, B;
	cin >> A >> d;
	// cout << A.size();
	B = to_string(0);
	memset(dp, -1, sizeof(dp));
	ll a1 = solve(B, 0, 1, 0);
	memset(dp, -1, sizeof(dp));
	ll a2 = solve(A, 0, 1, 0);

	cout << (a2 - a1 + mod) % mod << "\n";

}

int main() {
	fastio;
	// cin>>t;
	foo(i, 1, t) {
		MAIN(i);
	}

// #ifndef ONLINE_JUDGE
// 	cout << "\nTime Elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " sec\n";
// #endif
}

Measured memory_bytes: 16640
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;

public class Class1
{
    static void Main(string[] args)
    {
        int N = int.Parse(Console.ReadLine());

        string[] inV = Console.ReadLine().Split(' ');
        int[] V = new int[N];
        for(int i = 0;i < N;i++) { V[i] = int.Parse(inV[i]); }


        string[] inC = Console.ReadLine().Split(' ');
        int[] C = new int[N];
        for (int i = 0; i < N; i++) { C[i] = int.Parse(inC[i]); }

        int result = 0;

        for(int i = 0;i < N;i++)
        {
            if (V[i] > C[i]) result += V[i] - C[i];
        }

        Console.WriteLine(result);
    }
}


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

int main() {
  int A[100005];
  int n, k;
  cin >> n >> k;
  for (int i = 0; i < n; ++i)
    cin >> A[i];
  map<int, int> cts;
  int values_in_window = 0;
  int m = 100005;
  for (int f = 0, b = 0; f < n; ++f) {
    if (!cts[A[f]] and A[f] <= k)
      ++values_in_window;
    cts[A[f]] += 1;
    while (A[b] > k or cts[A[b]] > 1)
      cts[A[b++]]--;
    if (values_in_window >= k)
      m = min(m, f - b + 1);
  }
  cout << (m > 1e5 ? 0 : m) << endl;
}



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

int main(){
  string st;
  cin>>st;
  int n=st.size();
  ll dp[100050][13], mod=1e9+7;
  if(st[0]!='?')
    dp[0][st[0]-'0']=1;
  else{
    rep(i,10)
      dp[0][i]=1;
  }
  int c;
  for(int i=1; i<n; i++){
    if(st[i]!='?') c=st[i]-'0';
    else c=-1;
    
    for(int j=0; j<10; j++){
      if(c!=-1&& c!=j) continue;
      for(int k=0; k<13; k++){
        dp[i][(k*10+j)%13]+=dp[i-1][k];
      }
    }
   for(int j=0; j<13; j++)
     dp[i][j]%=mod;
  }
  cout<<dp[n-1][5]<<endl;
    
    
  
    
}

Measured memory_bytes: 10624
x, y = map(int, input().split())
res = 99999999999999
# そのまま
c = y - x
if c >= 0:
    res = min(res, c)

# 最初に1かい押す
c = y - (-x)
if c >= 0:
    res = min(res, c + 1)

# 最後に1かい押す
c = (-y) - (x)
if c >= 0:
    res = min(res, c + 1)

# 2回押す
c = (-y) - (-x)
if c >= 0:
    res = min(res, c + 2)

print(res)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define pf push_front

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
double pi = 3.141592653589793;
ll mod = 1000000007;
ll INF = 1000000001;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;



int main(){
   int n, r;
   cin >> n >> r;
   if(n>=10){
	   cout << r << endl;
   }else{
	   cout << r + 100 * (10 - n) << endl;
   }
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>

using namespace std;

int main(void)
{
	int price[1000], amount[1000];
	int count = 0;
	int psum = 0;
	double asum = 0;
	double pave, aave;
	int ave;
	for(int i = 0; i < 1000; i++){
		scanf("%d,%d", &price[i], &amount[i]);
		if(price[i] == 0 && amount[i] == 0)
		break;
		count++;
		psum += price[i] * amount[i];
		asum += amount[i];
	}
	aave = asum/count;
	ave = aave;
	
	if(aave - ave >= 0.5)
	ave += 1;
	cout << psum << endl;
	cout << ave << endl;
	
	return 0;
}

Measured memory_bytes: 1208
from bisect import bisect_left, bisect_right

n=int(input())
l=[int(x) for x in input().rstrip().split()]
l.sort()
ans=0
# print(l)
for i in range(n):
  for j in range(i+1,n):
    ans+=bisect_left(l,l[i]+l[j])-j-1
print(ans)

Measured memory_bytes: 3188
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<queue>
#include<vector>
#include<ctime>
#include<map>
#include<bitset>
#include<set>
#define LL long long
#define mp(x,y) make_pair(x,y)
#define pll pair<long long,long long>
#define pii pair<int,int>
using namespace std;
inline int read()
{
	int f=1,x=0;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
int stack[20];
inline void write(LL x)
{
	if(x<0){putchar('-');x=-x;}
    if(!x){putchar('0');return;}
    int top=0;
    while(x)stack[++top]=x%10,x/=10;
    while(top)putchar(stack[top--]+'0');
}
inline void pr1(int x){write(x);putchar(' ');}
inline void pr2(LL x){write(x);putchar('\n');}
char ch[105];
char temp[15];
bool check(int u1,int u2,int u3,int u4)
{
	int ln=0;
	for(int i=u1;i<=u2;i++)temp[++ln]=ch[i];
	for(int i=u3;i<=u4;i++)temp[++ln]=ch[i];
	if(temp[1]=='k'&&temp[2]=='e'&&temp[3]=='y'&&temp[4]=='e'&&temp[5]=='n'&&temp[6]=='c'&&temp[7]=='e')return true;
	return false;
}
int main()
{
	scanf("%s",ch+1);int len=strlen(ch+1);
	bool tf=true;
	if(len==7&&check(1,len,1,0))tf=false;
	for(int i=1;i<=len;i++)for(int j=i;j<=len;j++)if(len-(j-i+1)==7)
	{
		if(check(1,i-1,j+1,len))tf=false;
	}
	if(!tf)puts("YES");
	else puts("NO");
	return 0;
}


Measured memory_bytes: 128
import java.util.Scanner;
public class Main
{
  public static void main(String[]args)
  {
    Scanner input=new Scanner(System.in);
    int h=0,j=0;
    while(true)
    {int a=input.nextInt();
    int b=input.nextInt();
    if(a==0 && b==0)
      break;
   for(int p=1;p<=a;p++)
     {
       for(int i=1;i<=b;i++)
       {if( p>=2 && i>=2 && p<=a-1 && i<=b-1)
         System.out.print(".");
       else
         System.out.print("#");
       }
      System.out.println();}
       System.out.println();
     }
    }
     }


Measured memory_bytes: 32744
#include <bits/stdc++.h>
#define PI 3.14159265359
#define NIL (-1)
#define LL long long
using namespace std;
const int64_t MOD = 1e9 + 7;
const int INF = INT_MAX;

int main() {
	int N;
	cin >> N;

	vector<vector<int>> v(N, vector<int>(N, NIL));
	for (int i = 0; i < N; i++) {
		int A;
		cin >> A;
		for (int j = 0; j < A; j++) {
			int x, y;
			cin >> x >> y;
			x--;
			v[i][x] = y;
		}
	}

	//for (int i = 0; i < N; i++) {
	//	for (int j = 0; j < v[i].size(); j++) {
	//		if (j) cout << ' ';
	//		cout << v[i][j];
	//	}
	//	cout << endl;
	//}
	//cout << endl;

	int ans = 0;
	for (int bit = 0; bit < (1 << N); bit++) {
		vector<int> vec(N, 0);
		for (int i = 0; i < N; i++) {
			if (bit & (1 << i)) vec[i] = 1;
		}
		/*for (int i = 0; i < N; i++) cout << vec[i];
		cout << endl;*/

		bool b = 1;
		for (int i = 0; i < N; i++) {
			if (vec[i] == 0) continue;
			for (int j = 0; j < N; j++) {
				if (v[i][j] != NIL) {
					if (vec[j] != v[i][j]) {
						b = 0;
						break;
					}
				}
			}
			if (!b) break;
		}
		if (!b) continue;
		int n = count(vec.begin(), vec.end(), 1);
		ans = max(ans, n);
	}

	cout << ans << endl;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
#include <atcoder/all>

#include <cstdio>
using namespace std;
using namespace atcoder;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;

int main() {
  ll n, m;
  cin >> n >> m;
  ll cnt = 0;

  dsu d(n);

  for (int i =0; i<m; i++){
    ll a, b;
    cin >> a >> b;
    a--;
    b--;
    d.merge(a, b);
  }

  rep(i, n){
    if (d.leader(i) == i){
      // Leaderの個数が連結成分
      cnt++;
    }
  }
  int ans = cnt -1;
  // 連結成分の数-1
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3820
#include<iostream>
#include<algorithm>
using namespace std;
int main() {
    int N,min=999999999;
    cin >> N;
    int W[N];
    for (int i=0; i<N; i++) cin >> W[i];
    for (int i=1; i<N; i++) {
        int S1=0,S2=0,j=0;
        for (; j<i; j++) S1 += W[j];
        for (; j<N; j++) S2 += W[j];
        if (min > abs(S1 - S2)) min = abs(S1 - S2);
    }
    cout << min << endl;
    return 0;
}


Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func read() string {
	sc.Scan()
	var input = sc.Text()
	return input
}

func main() {
	input := strings.Split(read(), " ")
	k, _ := strconv.Atoi(input[1])
	arr := strings.Split(read(), " ")
	iarr := make([]int, 0)
	for _, a := range arr {
		i, _ := strconv.Atoi(a)
		iarr = append(iarr, i)
	}
	sort.Ints(iarr)
	sum := 0
	for _, i := range iarr[len(iarr)-1*k:] {
		sum += i
	}
	fmt.Println(sum)
}

Measured memory_bytes: 640
-- Try AtCoder
-- author: Leonardone @ NEETSDKASU

main = interact $ head . dropWhile null . zipWith ($) (map foldl1 $ zipWith (.) (map ((.) . ($ (`lookup` [(True, 0)]))) [((maybe "" (const "<")) .), ((maybe "=" (const ">")) .)]) [(<), (>)]) . repeat . words




Measured memory_bytes: 380
// https://twitter.com/kyopro_friends/status/1276873988010995712
// の通り実装。
// 「N以下のうちKの倍数になるもの」を考える！

#include <iostream>
using namespace std;
typedef long long ll;
#define REP(i,n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i,a,b) for(int i = (a); i < (int)(b); ++i)
#define ALL(c) (c).begin(), (c).end()
#define SIZE(v) ((int)v.size())

#define pb push_back
#define mp make_pair
#define mt make_tuple

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

    ll N;
    cin >> N;

    ll ans = 0;
    FOR(i, 1, N + 1) {
        FOR(j, 1, N + 1) {
            ll n = i * j;
            if (n <= N) ans += n;
            else break;
        }
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;

int main() {
    int rate, minus, mo2000;
    int mo[11];//2000 ~ 2010 mo[0]~mo[10]

    cin >> rate >> minus >> mo2000;
    mo[0] = mo2000;

    for(int i = 1; i < 11; i++)
    {
        mo[i] = rate * mo[i-1] - minus;
        cout << mo[i] << endl;
    }
    
    return 0;
}

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


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

// 最大公約数gcd
// 最小公倍数lcm=m*n/gcd
uint64_t gcd(uint64_t m, uint64_t n) {
  uint64_t temp;
  while (m % n != 0){
    temp = n;
    n = m % n;
    m = temp;
  }
  return n;
}

uint64_t lcm(uint64_t m, uint64_t n) {
  return (m*n)/gcd(m,n);
}

// vector<vector<uint64_t> > v(n+1, vector<uint64_t>(n+1, 0))
// v[n][k]に組み合わせ数が入る。
void comb(vector<vector <uint64_t> > &v){
  for(uint64_t i = 0;i <v.size(); i++){
    v[i][0]=1;
    v[i][i]=1;
  }
  for(uint64_t k = 1;k <v.size();k++){
    for(uint64_t j = 1;j<k;j++){
      v[k][j]=(v[k-1][j-1]+v[k-1][j]);
    }
  }
}

// 掛け算オーバーフロー判定
bool is_product_overflow(uint64_t a, uint64_t b) {

	uint64_t prod = a * b;
	
	return (prod / b != a);
}

//素因数分解
void primeFactorization(uint64_t a, list<uint64_t> &factors){ //素因数分解を出力するプログラム
  long i,sq;
  if(a%2==0){ //偶数の場合
    factors.push_back(2);
    primeFactorization(a/2,factors); //2で割った値で再帰
    return;
  }
  sq = sqrt(a);
  for(i=3;i<=sq;i+=2){ //3以上√a以下の奇数の場合
	if(a%i==0){
	  factors.push_back(i);
      primeFactorization(a/i,factors); //割れた値で再帰
      return;
	}
  }
  //偶数でも3以上√a以下の奇数の場合でも割り切れない場合
  if(a!=1){ //aが1でないなら、a自身は素数
    factors.push_back(a);
  }
}

// フェルマーの小定理
// mod. m での a の逆元 a^{-1} を計算する
int64_t modinv(int64_t a, int64_t m) {
    int64_t b = m, u = 1, v = 0;
    while (b) {
        int64_t t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

// 円周率
// M_PI

// #include <iomanip> // setprecisionを使用するのに必要
// cout << std::fixed << std::setprecision(15) << y << endl;

// 昇順
// priority_queue<int, vector<int>, greater<int> > queue;
signed main() {
  string s;
  cin >> s;
  
  if(s[2]==s[3]&&s[4]==s[5]) cout << "Yes" << endl;
  else cout << "No" << endl;
  
  return 0;
}



Measured memory_bytes: 3612
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<math.h>
using namespace std;
#define N (1000000000+7)
#define INF 1e16
typedef pair<int,int> P;
typedef long long ll;

int main(void){
    int n,ans=0;
    cin>>n;
    vector<int>p(n);
    for(int i=0;i<n;i++)cin>>p[i];
    for(int i=0;i<n-2;i++){
        int x=p[i+1];
        int a[3]={p[i],p[i+1],p[i+2]};
        sort(a,a+3);
        if(x==a[1])ans++;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
   cin.tie(0);
   ios::sync_with_stdio(false);
   string s;
   cin >> s;
   sort(s.begin(), s.end());
   for(int i = 0;i < s.length()-1;i++) {
       if(s[i]==s[i+1]) {
           cout << "no" << endl;
           return 0;
       }
   }
   cout << "yes" << endl;
}


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


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

  vector<int> count(n + 1, 0);


  string s;
  cin >> s;

  for(int i = 0; i < n ; i++){
    count[i + 1] = count[i] + (s.substr(i,2) == "AC"? 1 : 0);
  }
  for(int i = 0; i < q; i++){
    int l, r;
    cin >> l >> r;

    cout << count[r - 1] - count[l - 1] << endl;
  }
  
  //std::cout << "Hello World!\n";
}

Measured memory_bytes: 1408
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<vector>
#define inf 2147483647
#define mem0(a) memset(a,0,sizeof(a))
#define rep(i,a,b) for(int i=a;i<b;i++)
#define  rr read()
#define ll long long
#define pn putchar('\n')
#define ps putchar(' ')
#define repb(i,a,b) for(int i=a;i<=b;i++)
#define CloseIo   ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
using namespace std;
const int N=1e5+5;


int main()
{
 ll n;
 ll ans=1ll*inf*10000000;
 cin>>n;
 repb(i,1,sqrt(n))
 {
 	 if(n%i==0)
 	 {
 	 	 ans=min(ans,i+n/i-2);
	  }
 }
 cout<<ans;
}





Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using P = pair<int, int>;
const int M = 1000000007;

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    int sum = 0;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        sum += a[i];
    }
    sort(a.begin(), a.end());
    sum -= a.back() / 2;
    cout << sum << "\n";
    return 0;
}


Measured memory_bytes: 256