akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<iomanip>
#include<climits>
#include<vector>
#include<list>
#include<functional>
#include<algorithm>
#include<string>
#include<cmath>
#include<complex>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<tuple>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

class SegmentTree {
	int n;
	vector<int> node;
	const int INIT = 0;
	int f(int x, int y) {return x + y;}
public:
	SegmentTree(const vector<int> &v) {
		n = 1;
		while (n < v.size()) n *= 2;
		node.resize(2 * n - 1, INIT);
		REP(i, v.size()) node[i + n - 1] = v[i];
		for (int i = n - 2;i >= 0;--i) node[i] = f(node[2 * i + 1], node[2 * i + 2]);
	}

	void update(int i, int x) {
		i += n - 1;
		node[i] += x;
		while (i > 0) {
			i = (i - 1) / 2;
			node[i] = f(node[2 * i + 1], node[2 * i + 2]);
		}
	}

	int get(int a, int b, int k = 0, int l = 0, int r = -1) {
		if (r < 0) r = n;
		if (b <= l || r <= a) return INIT;
		if (a <= l && r <= b) return node[k];
		return f(get(a, b, 2 * k + 1, l, (l + r) / 2), get(a, b, 2 * k + 2, (l + r) / 2, r));
	}

	void print() {
		int step = 0;
		int end = 1;
		REP(i, 2 * n - 1) {
			++step;
			cout << node[i] << " ";
			if (step == end) {
				step = 0;
				end *= 2;
				cout << endl;
			}
		}
	}
};

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

	int n, q;
	cin >> n >> q;
	SegmentTree seg = SegmentTree(vector<int>(n));

	REP(i, q) {
		int com, x, y;
		cin >> com >> x >> y;
		if (com == 0) {
			seg.update(x - 1, y);
		}
		else {
			cout << seg.get(x - 1, y) << endl;
		}
	}
	//seg.print();
	
	return 0;
}


Measured memory_bytes: 4056
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <string>
#define SS(i) scanf("%s",i)
#define SC(i) scanf("%d",&i)
#define SCC(i,j) scanf("%d%d",&i,&j)
#define SCCC(i,j,z) scanf("%d%d%d",&i,&j,&z)
#define PR(i) printf("%d\n",i)
#define LL long long
#define FF(i,a,b) for(int i=a;i<=b;++i)
#define RR(i,a,b) for(int i=a;i>=b;--i)
#define CL(i,x) memset(i,x,sizeof(i))
#define IN freopen("in.txt","r",stdin)
#define OUT  freopen("out.txt","w",stdout)
#define PB(i) push_back(i)
#define min(x,y) ((x>y)?(y):(x))
#define max(x,y) ((x<y)?(y):(x))
#define abs(i) (i<0?(-i):i)
#define lson x,m,rt<<1
#define rson m+1,y,rt<<1|1
using namespace std;
const int N=200000+10;

vector<int>g[10];

int ans;
int vis[10];
int n, m;

void dfs(int u)
{
    int ok = 1;
    FF(i, 1, n) if(vis[i]==0){
        ok = 0;
        break;
    }
    if(ok){
        ans += 1; return;
    }
    int sz = g[u].size();
    FF(i, 0, sz-1)
    {
        int v = g[u][i];
        if(!vis[v]){
            vis[v] = 1;
            dfs(v);
            vis[v] = 0;
        }
    }
}
int main()
{
#ifndef ONLINE_JUDGE
   
#endif


    SCC(n, m);
    FF(i, 1, m)
    {
        int x, y; SCC(x, y);
        g[x].PB(y); g[y].PB(x);
    }
    ans = 0;
    vis[1] = 1;
    dfs(1);
    PR(ans);
    return 0;
}


Measured memory_bytes: 256
class Node{
  constructor(id, parent, children) {
    this.id = id;
    this.parent = parent;
    this.children = children;
  }

  get type() {
    if (this.parent === null) return 'root';
    if (this.children.length === 0) return 'leaf';
    return 'internal node';
  }

  get depth() {
    const getDepth = (node, i) => {
      return node.parent === null ? i : getDepth(node.parent, i + 1);
    };
    return getDepth(this, 0);
  }

  toString() {
    return `node ${this.id}: parent = ${this.parent !== null ? this.parent.id : -1}, depth = ${this.depth}, ${this.type}, [${this.children.map(n => n.id).join(', ')}]`;
  }
};

class Tree {
  static get Node() {
    return Node;
  }

  constructor(n) {
    this.nodes = [];
    for (let i = 0; i < n; i++) this.nodes[i] = new Tree.Node(i, null, []);
  }

  add(id, childrenIds) {
    let node = this.find(id);
    childrenIds.forEach((cid) => {
      let c = this.find(cid);
      c.parent = node;
      c.id = cid;
      node.children.push(c);
    })
  }

  find(id) { return this.nodes[id]; }

  print() { console.log(this.nodes.sort((a, b) => a.id - b.id).map(n => n.toString()).join('\n')); }
}

(function main(){
  const lines = require('fs').readFileSync('/dev/stdin', 'utf8').trim().split('\n');
  const n = Number(lines.shift());
  let tree = new Tree(n);
  let id, k, childrenIds;
  lines.map(l => l.split(' ')).forEach(function(line) {
    id = Number(line.shift());
    k = Number(line.shift());
    childrenIds = line.map(Number);
    tree.add(id, childrenIds);
  });
  tree.print();
})();



Measured memory_bytes: 158288
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,i;
    cin>>n;

    int a[n];
    int sum=0,avg;
    for(i=0;i<n;i++)
    {
        cin>>a[i];
        sum+=a[i];
    }
    avg=(sum)/n;
    int avg1=(sum+n-1)/n;
    long long ans=0,ans1=0;
    for(i=0;i<n;i++){
        ans+=(avg-a[i])*(avg-a[i]);
        ans1+=(avg1-a[i])*(avg1-a[i]);
    }
    cout<<min(ans,ans1)<<endl;
    return 0;
}


Measured memory_bytes: 3604
#include "bits/stdc++.h"

using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
	REP(i, v.size()) { if (i)os << " "; os << v[i]; }return os;
}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
	REP(i, v.size()) { if (i)os << endl; os << v[i]; }return os;
}

const ll INF = 1LL << 60;

int main() {
	ll n;
	vector<ll> v;
	ll alice = 0;
	ll bob = 0;

	cin >> n;

	REP(i, n) {
		ll a;
		cin >> a;
		v.push_back(a);
	}

	sort(v.begin(), v.end(), greater<ll>());

	REP(i, n) {
		if (i % 2 == 0) {
			alice += v[i];
		}
		else {
			bob += v[i];
		}
	}

	cout << alice - bob << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h> 
#include<iostream>
using namespace std; 
int minimumCostT(int arr[],int n)
{
	int dp[n+1];
	dp[0] = 0;
	
	dp[1] =abs(arr[0]-arr[1]);
	
	for(int i=2;i<n;i++)
	{
		dp[i] = min(dp[i-1]+abs(arr[i] - arr[i-1]),dp[i-2]+abs(arr[i] - arr[i-2]));
	}
	return dp[n-1];
}

int main()
{
  	int n;
	cin>>n;
	int arr[n];
	
	for(int i=0;i<n;i++)
	{
		cin>>arr[i];
	}
	cout<<minimumCostT(arr,n)<<endl;
}

Measured memory_bytes: 1024
INF = 10 ** 20

n, m = map(int, input().split())
dist = []
weth = []
for _ in range(n):
  dist.append(int(input()))
for _ in range(m):
  weth.append(int(input()))

dp = [INF] * (n + 1)
dp[0] = 0
for i in range(m):
  for j in range(n, 0, -1):
    dp[j] = min(dp[j], dp[j - 1] + dist[j - 1] * weth[i])
print(dp[n])


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

namespace ProblemD
{
    class Program
    {
        static void Main(string[] args)
        {
            var read= Console.ReadLine().Split(' ').Select(x_ => int.Parse(x_)).ToArray();
            var a = (double)read[0];
            var b = (double)read[1];
            var x = (double)read[2];

            double ret;
            var c = 2 * x / b / a;
            if (c <= a)
            {
                ret = GetDegree(Math.Atan(b / c));
                Console.WriteLine(ret);
            }
            else
            {
                var d = (2 * x - a * a * b) / (a * a);
                Console.WriteLine(GetDegree(Math.Atan((b - d) / a)));
            }
        }

        static double GetDegree(double radian)
        {
            return radian * 180 / Math.PI;
        }
    }
}


Measured memory_bytes: 13268
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <set>
#include <iomanip>
#include <stack>
#include <fstream>
#include <cstdint>
#include <cmath>
#include <algorithm>
#include <utility>
#include <numeric>
#include <functional>

using namespace std;

constexpr int INF = 1000000000;/* 1e+9a */
constexpr int MODULO = 1000000007;

typedef int64_t ll;


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N, M;
    while(cin >> N >> M)
    {
        if(N == 0) break;
        vector<ll> P;
        P.push_back(0);
        for (int i = 0; i < N; ++i) {
            ll tmp;
            std::cin >> tmp;
            P.push_back(tmp);
        }
        vector<ll> P2;
        for (int i = 0; i < P.size(); ++i) {
            for (int j = i; j < P.size(); ++j) {
                P2.push_back(P[i] + P[j]);
            }
        }
        sort(P2.begin(), P2.end());
        ll maxim = 0;
        for (int i = 0; i < P2.size(); ++i) {
            auto val12 = P2[i];
            auto gval = M - val12;
            if(gval >= 0){
                auto good = upper_bound(P2.begin(), P2.end(), gval);
                maxim = max(maxim, val12 + *(good-1));
            }
            else break;
        }
        cout << maxim << '\n';
    }
}



Measured memory_bytes: 10744
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector<int> vec(N);
  
  for (int i = 0; i < N; i++) cin >> vec.at(i);
  
  sort(vec.begin(), vec.end());
  
  int num = 1;
  
  for (int i = 0; i < N - 1; i++) {
     if (vec.at(i) == vec.at(i + 1)) continue;
    
     num++;
  }
  
  cout << num << endl;
}

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

int main()
{
  int a[3];

  for(int i = 0; i < 3; i++){
    cin >> a[i];
  }

  sort(a, a + 3);

  cout << a[0] << " " << a[1] << " " << a[2] << endl;

  return 0;

}

Measured memory_bytes: 3152
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <climits>
using namespace std;
int main(){
    int a,b,c;
    cin>>a>>b>>c;
    int min;

    min=abs(a-b)+abs(b-c);
    if(min>abs(b-a)+abs(a-c))min=abs(b-a)+abs(a-c);
    if(min>abs(b-c)+abs(c-a))min=abs(b-c)+abs(c-a);
    // if(min>abs(c-b)+abs(b-a))
    // if(min>abs(c-a)+abs(a-b))
    cout<<min<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <stdio.h>
#include <math.h>
#include <cmath>
using namespace std;
#define vsort(vec) sort(vec.begin(), vec.end())
#define vreverse(vec) reverse(vec.begin(), vec.end())
using ll =long long;
using ull =unsigned long long;
const ll INF =1001001001;
const double PI = 3.14159265358979323846;
//10億7。　　　100000007

//最大公約数
ll gcd(ll a, ll b){
   if (a%b==0){
       return(b);
   }else{
       return(gcd(b,a%b));
   }
}
//最小公倍数
ll lcm(ll a, ll b){
   return a*b/gcd(a,b);
}


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

int a,b,c;
  cin>>a>>b>>c;
  
  cout<<a+b+c-max(a,max(b,c))<<endl;
      
}



Measured memory_bytes: 3556
from collections import deque
from functools import lru_cache

H, W = map(int, input().split())
S = [input() for _ in range(H)]

minDist = [[10**10] * W for _ in range(H)]
que = deque([(0, 0, 0 if S[0][0] == '.' else 1, S[0][0] == '.')])

while que:
    h, w, dist, isWhite = que.popleft()

    if minDist[h][w] <= dist:
        continue
    minDist[h][w] = dist

    if h + 1 < H:
        isNextWhite = S[h + 1][w] == '.'
        if isWhite and not isNextWhite:
            que.append((h + 1, w, dist + 1, isNextWhite))
        else:
            que.appendleft((h + 1, w, dist, isNextWhite))
    if w + 1 < W:
        isNextWhite = S[h][w + 1] == '.'
        if isWhite and not isNextWhite:
            que.append((h, w + 1, dist + 1, isNextWhite))
        else:
            que.appendleft((h, w + 1, dist, isNextWhite))

ans = minDist[H - 1][W - 1]
print(ans)


Measured memory_bytes: 3684
N,*A = $<.read.split.map &:to_i
t,B = 0,Array.new(N,0)
N.times {|i;j|
  a = A[i]
  B[j] += 1  if N > j=i+a
  t += B[j]  if 0 <= j=i-a
}
p t

Measured memory_bytes: 30708
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)

using namespace std;

int main()
{
    int n;
    while(cin >> n && n)
    {
        int ans = 0;

        REP(i,1,1001) {
            if(i > n) break;
            int res = i;
            
            REP(j,i+1,1001) {
                res += j;

                if(res > n) break;
                if(res == n) {
                    ans++;
                    break;
                }
            }
        }

        cout << ans << endl;
    }

    return 0;
}

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

void Max(int &a,int x){
  a=max(a,x);
}

string s;
int mem[305][305][305];
int rec(int l,int r,int k){

  if( mem[l][r][k] != -1 )return mem[l][r][k];
  
  if(l==r)return 1;
  if(l>r)return 0;
  
  int res=0;
  
  if(s[l]==s[r]){
    Max(res,rec(l+1,r-1,k)+2);
  }

  Max(res,rec(l+1,r,k));
  Max(res,rec(l,r-1,k));
  if(k>0){
    Max(res,rec(l+1,r-1,k-1)+2);
  }

  
  return mem[l][r][k]=res;
}

int main(){
  memset( mem, -1, sizeof(mem) );
  cin>>s;
  int k;
  cin>>k;

  cout<< rec(0, s.size()-1 , k) <<endl;
  return 0;
}


Measured memory_bytes: 111104
#include "bits/stdc++.h"
using namespace std;
typedef long long int lint;
typedef pair<lint, lint> plint;
typedef pair<double long, double long> pld;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for(lint i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(lint i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
template<typename T1, typename T2> pair<T1, T2> operator+(const pair<T1, T2>& l, const pair<T1, T2>& r) { return make_pair(l.first + r.first, l.second + r.second); }
template<typename T1, typename T2> pair<T1, T2> operator-(const pair<T1, T2>& l, const pair<T1, T2>& r) { return make_pair(l.first - r.first, l.second - r.second); }
const lint MOD = 1e9 + 7, INF = 1e18;

lint N;
char char_map[500][500];

bool check(lint k) {
	REP(i, N) {
		REP(j, N) {
			if (char_map[i][(j + k)%N] != char_map[j][(i + k)%N]) return false;
		}
	}
	return true;
}

int main() {
	cin.tie(0); ios_base::sync_with_stdio(false);
	cin >> N;
	REP(i, N) {
		REP(j, N) {
			cin >> char_map[i][j];
		}
	}
	lint cnt = 0;
	REP(i, N) {
		if (check(i)) cnt++;
	}
	cout << cnt * N << endl;
}


Measured memory_bytes: 3804
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <vector>
#include <complex>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <iterator>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <regex>
#include <limits>
#include <time.h>
#include <cstdint>
using namespace std;
using pii  = pair<int,int>;
using ll=long long;
using ld=long double;
#define pb push_back
#define mp make_pair
#define sc second
#define fr first
#define stpr setprecision
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define rep(i,n) for(ll i=0;i<(n);++i)
#define Rep(i,a,b) for(ll i=(a);i<(b);++i)
#define rrep(i,n) for(ll i=n-1;i>=0;i--)
#define rRep(i,a,b) for(ll i=a;i>=b;i--)
#define crep(i) for(char i='a';i<='z';++i)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define ALL(x) (x).begin(),(x).end()
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define endl '\n'
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
ll gcd(ll a,ll b){return (b == 0 ? a : gcd(b, a%b));}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
constexpr ll MOD=1000000007;
constexpr ll INF=1000000011;
constexpr ll MOD2=998244353;
constexpr ll LINF = 1001002003004005006ll;
constexpr ld EPS=10e-8;
template <class T, class U> inline bool chmax(T& lhs, const U& rhs) { if (lhs < rhs) { lhs = rhs; return 1; } return 0; }
template <class T, class U> inline bool chmin(T& lhs, const U& rhs) { if (lhs > rhs) { lhs = rhs; return 1; } return 0; }
template<typename T> istream& operator>>(istream& is,vector<T>& v){for(auto&& x:v)is >> x;return is;}
template<typename T,typename U> istream& operator>>(istream& is, pair<T,U>& p){ is >> p.first; is >> p.second; return is;}
template<typename T,typename U> ostream& operator>>(ostream& os, const pair<T,U>& p){ os << p.first << ' ' << p.second; return os;}
template<class T> ostream& operator<<(ostream& os, vector<T>& v){
  for(auto i=begin(v); i != end(v); ++i){
    if(i !=begin(v)) os << ' ';
    os << *i;
  }
  return os;
}

ll A[5];

int main(){
  ll N,M;
  cin >> N >> M;
  if(M==0){
    cout << (N==1 ? 0 : pow(10,N-1))  <<endl;
    return 0;
  }
  rep(i,5){
    A[i]=INF;
  }
  rep(i,M){
    ll X,K;
    cin >> X >> K;
    X--;
    if(A[X]==INF){
      A[X]=K;
    }
    else if(A[X]!=K){
      cout<< -1 << endl;
      return 0;
    }
  }
  if(A[0]==0 && N==1){
    cout << 0 << endl;
    return 0;
  }
  if(A[0]==0 && N!=1){
    cout << -1 << endl;
    return 0;
  }
  rep(i,N){
    cout << (A[i]!=INF ? A[i] : (i==0 ? 1 :0));
  }
  cout << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

typedef long long ll;
typedef uint64_t ull;
typedef pair<int, int> P;
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)

vector<ll> divisor(ll x){
    vector<ll> res;
    for(ll i = 1; i * i <= x; ++i){
        if(x % i == 0){
            res.emplace_back(i);
            if(i * i != x)  res.emplace_back(x / i);
        }
    }
    sort(res.begin(), res.end());
    return res;
}

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

    ll n;
    cin >> n;
    ll ans = 0;
    vector<ll> div = divisor(n);
    for(ll x : div){
        if(x == 1)  continue;
        ll foo = n;
        while(foo % x == 0) foo /= x;
        if(foo % x == 1)    ++ans;
    }
    vector<ll> div2 = divisor(n - 1);
    ans += div2.size() - 1;
    cout << ans << endl;
}

Measured memory_bytes: 3736
#include<bits/stdc++.h>
using namespace std;
using ll=int_fast64_t;
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)

int main(){
    istream& in(cin);
    ostream& out(cout);
    double a,b,x,h,pi=3.1415926535;
    in>>a>>b>>x;
    h=x/(a*a*b);
    if(h<0.5){
        h*=2*a;
        printf("%.12lf\n",atan2(b,h)/pi*180);
    }
    else{
        h=1-h;
        h*=2*b;
        printf("%.12lf\n",atan2(h,a)/pi*180);
    }
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

class Main {

    private static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        String str = sc.next();
        long k = sc.nextLong();

        for (int i = 0; i < str.length(); i++) {
            if (i == k-1) {
                System.out.println(str.charAt(i));
                return;
            }
            if (str.charAt(i) != '1') {
                System.out.println(str.charAt(i));
                return;
            }
        }
    }
}

Measured memory_bytes: 23764
using System;

namespace C___Slimes
{
    class Program
    {
        static void Main (string[] args)
        {
            var n = int.Parse (Console.ReadLine ());
            var s = Console.ReadLine ();
            var ans = 1;
            for (var i = 1; i < n; i++)
            {
                if (s[i] != s[i - 1])
                {
                    ans++;
                }
            }
            Console.WriteLine (ans);
        }
    }
}

Measured memory_bytes: 13140
#include <stdio.h>
#define min(a, b) ((a)>(b) ? (b) : (a))

int main(){
  long q, h, s, d, n;
  scanf("%ld %ld %ld %ld %ld", &q, &h, &s, &d, &n);
  long ans = 0;
  if(n == 1){
    ans = min(q*4, min(h*2, s));
  }else{
    long per2 = min(q*8, min(h*4, min(s*2, d)));
    ans = per2 * (n/2);
    if(n % 2)
      ans = ans + min(q*4, min(h*2, s));
  }
  printf("%ld\n", ans);
  return 0;
}


Measured memory_bytes: 128
#pragma gcc optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,r,n) for(ll i=(ll)(r);i<(ll)(n);++i)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
#define pb(n) push_back(n)
#define endl '\n'
#define P(x)  cout << #x << " = " << (x) << endl
#define IN(n) cin >> n
#define IN2(a,b) cin >> a >> b
#define IN3(a,b,c) cin >> a >> b >> c
#define VIN(V) for(int i = 0; i < (V).size(); i++) {cin >> (V).at(i);}
#define OUT(n) cout << n << endl
#define VOUT(V) REP(i, (V).size()) {cout << (V)[i] << endl;}
#define VOUT2(V) REP(i, (V).size()) {cout << (V)[i] << " ";} cout<<endl;
typedef long long int ll;
typedef vector<ll> vi;
typedef vector<pair<ll, ll> > vp;
typedef vector<string> vs;
typedef vector<char> vc;
typedef list<ll> lst;
typedef pair<ll, ll> P;
const long long INF = numeric_limits<ll>::max();
const long long MOD = 1000000007;
const long double PI = 3.1415926;
template <class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <class T> T &chmax(T &a, const T &b) { return a = max(a, b); }
ll n, m, k, ans, sum, count = 0; string s; char c;

int main(){
  cin.tie(0);ios::sync_with_stdio(false);
  ll r;
  IN(r);
  if (r < 1200) {
    OUT("ABC");
  } else if (r < 2800){
    OUT("ARC");
  } else {
    OUT("AGC");
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <deque>
#include <set>
#include <cmath>
#include <bits/stdc++.h>
#include <limits>

#define MOD 1000000007

using namespace std;

int main(void){
    // Your code here!
    long long x, t;
    
    cin >> x >> t;
    
    cout << max(x - t, (long long)0) << endl;
    
    return 0;
}

Measured memory_bytes: 256
use proconio::input;

#[allow(unused_imports)]
use proconio::marker::{Bytes, Chars, Usize1};
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::ops::*;

#[derive(Clone, Debug, Default)]
struct Struct;

//#[proconio::fastout]
fn main() {
    input! {
        n:usize,
        mut v:[(i64,i64);n],
    }
    let mut vl:Vec<i64> = v.iter().map(|x| x.0).collect();
    let mut vh:Vec<i64> = v.iter().map(|x| x.1).collect();
    vl.sort_unstable();
    vh.sort_unstable_by_key(|x|-x);

    /*
       Nが奇数の時 p=(N-1)/2
         中央値の最小値は vl[p] 最大値は vh[p]

       Nが偶数の時 p1=N/2-1 p1=N/2
         中央値の最小値は (vl[p1]+vl[p2])/2 最大値は (vh[p1]+vh[p2])/2
    */
    let ans;
    if n % 2 == 1 {
        let p = (n-1)/2;
        ans = vh[p]-vl[p]+1;
    } else {
        let p1 = n/2-1;
        let p2 = n/2;
        ans = (vh[p1]+vh[p2]) - (vl[p1]+vl[p2]) + 1;
    }
    println!("{}",ans);

}


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

namespace ConsoleApp14
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int a = Convert.ToInt32(input[0]);
            int b = Convert.ToInt32(input[1]);

            Console.WriteLine(a - b + 1);
            Console.Read();
        }
    }
}


Measured memory_bytes: 27332
using System;
using System.Linq;

namespace ITP1_2_B_Range
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine( Console.ReadLine().Split( ' ' ).Select( n => new { num = int.Parse( n ), isBigger = true } )
                .Aggregate( (acc, c) => new { num = c.num, isBigger = acc.isBigger && ( acc.num < c.num ) } ).isBigger ? "Yes" : "No" );
        }
    }
}

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

//template
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(a);i>(b);i--)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll;
const int inf = 0x3fffffff; const ll INF = 0x1fffffffffffffff; const double eps=1e-12;
string to_str(ll x){string res; while(x)res+=('0'+(x%10)),x/=10; reverse(ALL(res)); return res;}
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; }
//template end

int mx=200010;
bool prime[200010];

int main(){
    int n; scanf("%d",&n);
    rep(i,2,mx)prime[i]=1;
    rep(i,2,mx)if(prime[i]){
        int idx=2*i;
        while(idx<=mx){
            prime[idx]=0;
            idx+=i;
        }
    }
    rep(i,n,mx)if(prime[i]){
        printf("%d\n",i);
        return 0;
    }
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <time.h>
#include <random>
#include <string>
#include <cassert>
#include <vector>
#include <ostream>
#include <istream>
#include <stack>
#include <deque>
#include <queue>
#include <functional>
#include <chrono>

using namespace std;

#define int long long
#define pb push_back
#define all(a) (a).begin(), (a).end()
#define pii pair<int, int>
#define ld long double

ostream& operator << (ostream &a, const vector<int> &b) {
    for (auto k : b) cout << k << " ";
    return a;
}

#ifdef LOCAL
    #define dbg(x) cout << #x << " : " << (x) << "\n";
    const int INF = 1e18;
    // const int mod = 2600000069;
    // const int p = 10;
    // const ld PI = 3.1415926535;
#else
    #define dbg(x)
    const int INF = 1e18;
    // const int mod = 2600000069;
    // const int p = 179;
    // const ld PI = 3.1415926535;
#endif

// #pragma GCC optimize("Ofast,no-stack-protector")
//#pragma GCC target("sse,sse2,sse3,sse3,sse4")
// #pragma GCC optimize("unroll-loops")
// #pragma GCC optimize("fast-math")
// #pragma GCC target("avx2")
//#pragma GCC optimize("section-anchors")
//#pragma GCC optimize("profile-values,profile-reorder-functions,tracer")
//#pragma GCC optimize("vpt")
//#pragma GCC optimize("rename-registers")
//#pragma GCC optimize("move-loop-invariants")
//#pragma GCC optimize("unswitch-loops")
//#pragma GCC optimize("function-sections")
//#pragma GCC optimize("data-sections")`  

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    for (int i = 0; i < k; i++) {
        int m;
        cin >> m;
        for (int j = 0; j < m; j++) {
            int x;
            cin >> x;
            x--;
            a[x] = 1;
        }
    }
    int ans = 0;
    for (auto k : a) {
        if (!k) ans++;
    }
    cout << ans;
}
/*

*/  


Measured memory_bytes: 3652
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <bitset>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
#include <functional>
#include <cassert>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define ALL(v) v.begin(),v.end()
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; }
#define DEBUG_VLL(vec) for(int sz=0;sz<int(vec.size());sz++) std::cerr<<vec[sz]<<(sz==vec.size()-1?'\n':' ');

const long long MOD = 1000000007;
const long long HIGHINF = (long long)1e18;
const int INF = (int)1e9;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    V< V<int> > a(n, V<int>(n));
    for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) cin >> a[i][j];
    vll cost(1 << n, 0);
    for (int i = 0; i < (1 << n); i++) {
        for (int r1 = 0; r1 < n; r1++) {
            for (int r2 = r1 + 1; r2 < n; r2++) {
                if ((i >> r1 & 1) && (i >> r2 & 1)) cost[i] += a[r1][r2];
            }
        }
    }

    vll dp(1 << n, 0);
    for (int state = 0; state < (1 << n); state++) {
        dp[state] = cost[state];
        for (int subs = state; subs > 0; subs = (subs - 1) & state) {
            chmax(dp[state], dp[subs] + dp[state ^ subs]);
        }
    }
    cout << dp.back() << '\n';
    return 0;
}


Measured memory_bytes: 4236
W, H, N = [int(i) for i in input().split()]
Map = [ [1 for _ in range(H)] for _ in range(W) ]
for _ in range(N):
    x, y, a = [int(i) for i in input().split()]
    if a == 1:
        for i in range(x):
            for j in range(H):
                Map[i][j] = 0
    elif a == 2:
        for i in range(x, W):
            for j in range(H):
                Map[i][j] = 0
    elif a == 3:
        for i in range(W):
            for j in range(y):
                Map[i][j] = 0
    elif a == 4:
        for i in range(W):
            for j in range(y, H):
                Map[i][j] = 0
#for y in range(H, 0, -1):
#   for x in range(W):
#       print(Map[x][y-1], end="")
#   print()
print(sum([sum(i) for i in Map]))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
//cervello|Phoenix
using namespace std;
#define ll long long int
#define eb emplace_back
#define mk make_pair
#define all(x) x.begin(),x.end()
#define mod 1000000007

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  string s; cin>>s;
  cout<<s.substr(0,3)<<"\n";
  return 0;
}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
#define ll long long int
#define pii pair<int,int>
#define mod 1000000007
#define eps 0.000000001
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
#define sz(x) ((int)x.size())
#define ln(x) ((int)x.length())
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define FASTIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define dbg(x) cout<<#x<<": "<<x<<endl;
const double PI = acos(-1.0);
using namespace std;

void cp()
{
    int x, y, a, b, c;
    cin >> x >> y >> a >> b >> c;
    vector<int> p(a), q(b), r(c);
    for(int &d : p)
        cin >> d;
    for(int &d : q)
        cin >> d;
    for(int &d : r)
        cin >> d;
    ll total = 0;
    sort(allr(p));
    sort(allr(q));
    sort(allr(r));
    set<int> s(all(r));
    int i = 0, j = 0, k = 0, count = 0, cx=0, cy=0;
    vector<int> v;
    
    for(int i=0;i<x;i++)
    	v.pb(p[i]);
    for(int i=0;i<y;i++)
    	v.pb(q[i]);
    for(int i=0;i<c;i++)
    	v.pb(r[i]);
    sort(allr(v));
    for(int i=0;i<x+y;i++)
    	total += v[i];
    cout << total;
}

int main()
{
    FASTIO;
    int t;
    t = 1;
    // cin >> t;
    while(t--)
    {
        cp();
    }
    return 0;
}

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

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int a, b;
    cin >> a >> b;

    if(a<=5){
        cout << 0 << endl;
        return 0;
    }
    if(a<=12){
        cout << b/2 << endl;
        return 0;
    }
    cout << b << endl;
}

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

ll GCD(ll a, ll b) {
	return (b > 0) ? GCD(b, a % b) : a;
}

ll LCM(ll a, ll b) {
	return a / GCD(a, b) * b;
}

int main() {
	int n, x;
	cin >> n >> x;
	vector<int> X;
	X.push_back(x);
	rep(i, n) {
		cin >> x;
		X.push_back(x);
	}
	sort(X.begin(), X.end());
	vector<ll> d(n);
	rep(i, n) {
		d[i] = X[i + 1] - X[i];
	}

	ll ans = d[0];
	rep(i, n - 1) ans = GCD(ans, d[i + 1]);
	cout << ans << endl;
}

Measured memory_bytes: 1528
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <functional>

using namespace std;

#define fst first
#define scd second
#define PB push_back
#define MP make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define omajinai ios::sync_with_stdio(false);cin.tie(0)
#define rep(i,x) for(int i=0;i<(int)(x);++i)
#define rep1(i,x) for(int i=1;i<=(int)(x);++i)
#define rrep(i,x) for(int i=(int)x-1;i>=0;--i)
#define rrep1(i,x) for(int i=(int)x;i>=1;--i)

using ll=long long;
using ld=long double;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int, int>;
using vpii=vector<pii>;

template<class T,class U>ostream&operator<<(ostream&os,const pair<T,U>p){os<<"("<<p.fst<<", "<<p.scd<<")";return os;}
template<class T>ostream&operator<<(ostream&os,const vector<T>v){rep(i,v.size()){if(i)os<<", ";os<<v[i];}return os;}
template<typename T>T&max(T&a,T&b){if(a>=b)return a;return b;}
template<typename T>T&min(T&a,T&b){if(a < b)return a;return b;}
template<typename T>bool chmax(T&a,T b){if(a < b){a=b;return true;}return false;}
template<typename T>bool chmin(T&a,T b){if(a > b){a=b;return true;}return false;}

constexpr int inf = 1e9;
constexpr ll linf = 3e18;
constexpr double eps = 1e-9;

signed main()
{
    int x,a,b;cin>>x>>a>>b;
    cout << (abs(a-x)<abs(b-x)?"A":"B")<<endl;
}


Measured memory_bytes: 764
#include<iostream>
using namespace std;
int D,N;
 
int main() {
	cin >> D >>N;
        if (N == 100)N=101;
	if (D == 0)cout << N;
	if (D == 1)cout << 100 * N;
	if (D == 2)cout << 10000 * N;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#define int long long
#define ll getchar();getchar();return 0;
	using namespace std;
	signed main() {
		string o, l;
		cin >> o >> l;
		for (int i = 0; i < l.size(); i++) {
			cout << o[i] << l[i];
		}
		if (o.size() > l.size())cout << o[o.size() - 1] << endl;
		ll
}

Measured memory_bytes: 256
/*

Parallelism(https://onlinejudge.u-aizu.ac.jp/problems/0021)
前

*/
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <cmath>
#include <complex>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cassert>
#include <iomanip>
using namespace std;

#define Rep(b, e, i) for(int i = b; i <= e; i++)
#define Repr(e, b, i) for(int i = e; i >= b; i--)
#define rep(n, i) Rep(0, n-1, i)
#define repr(n, i) Repr(n-1, 0, i)
#define all(v) (v).begin(), (v).end()
#define pb(v) push_back(v)
#define uniq(v) (v).erase(unique(all(v)),(v).end())
#define bitcnt(x) __builtin_popcount(x)
#define fst first
#define snd second
#define Pqaz(T) priority_queue<T,vector<T>,greater<T>>
#define Pqza(T) priority_queue<T>
#define put(x) cout << x;
#define putsp(x) cout << x << ' ';
#define putln(x) cout << x << endl;
#define ENJYU std::ios::sync_with_stdio(false);std::cin.tie(0);

typedef long long ll;
typedef pair<ll, ll> llP;
typedef pair<int, int> intP;
typedef complex<double> comp;
typedef vector <int> vec;
typedef vector <ll> vecll;
typedef vector <double> vecd;
typedef vector <vec> mat;
typedef vector <vecll> matll;
typedef vector <vecd> matd;

//vector の中身を出力
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

const int MAX = 200000;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const ll INFL = 1e18;
const int MOD = 1000000007;

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

//********************************template END****************************************//

//外積を計算する関数
double gaiseki(comp a, comp b)
{
	return (conj(a)*b).imag();
}

void solve(void){

	double xs[4], ys[4];

	while(cin >> xs[0] >> ys[0])
	{

		rep(3, i)
		{
			cin >> xs[i+1] >> ys[i+1];
		}

		vector <comp> ps(4);
		rep(4, i)
		{
			ps[i] = comp(xs[i], ys[i]);
		}

		int cnt = 0, on = 0;

		rep(3, i)
		{
			if (gaiseki(ps[i]-ps[3], ps[(i+1)%3]-ps[3]) > 0)
			{
				cnt++;
			}
			else if (gaiseki(ps[i]-ps[3], ps[(i+1)%3]-ps[3]) < 0)
			{
				cnt--;
			}
			else
			{
				//辺上にあるかのフラグ
				on = 1;
			}

			//cout << cnt << endl;

		}

		cout << ((abs(cnt) != 3 || on) ? "NO" : "YES") << endl;

	}

}

int main(void){
	solve();
	//cout << "yui(*-v・)yui" << endl;
	return 0;
}



Measured memory_bytes: 3084
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

int32_t main()
{
	IOS;
	int a, b;
	cin >> a >> b;
	int ans = 0;
	int cur = 1;
	while(cur < b)
	{
		ans++;
		cur += (a - 1);
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define int ll
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a) (a).begin(),(a).end()
#define pb emplace_back
#define INF (1e9+1)

signed main(){
    int n;
    cin>>n;
    
    vector<int> v(n);
    rep(i,n)cin>>v[i];
    
    vector<int> im(n+1);
    for(int i=1;i<=n;i++)im[i] = v[i-1];
    
    for(int i=1;i<=n;i++)im[i] += im[i-1];
    
    
    map<int,int> mp;
    rep(i,im.size()){
        mp[im[i]]++;
    }
    
    int ans = 0;
    for(auto elm:mp){
        int n = elm.second;
        ans += n*(n-1)/2;
    }
    
    cout<<ans<<endl;
}


Measured memory_bytes: 15872
'''
Accepted    　:No
difficult   　: 
ペナルティ　  　:5分
実際の回答時間  :分
WAの回数　     :回
合計時間　　  　:分
'''
import collections
def myAnswer(N:int,V:list) -> int:
   odd = []
   even = []
   if len(set(V)) == 1:
      return N//2

   for n,v in enumerate(V):
      even.append(v) if n % 2 == 0 else odd.append(v)
   
   oddCounter = collections.Counter(odd)
   evenCounter = collections.Counter(even)
   oddCounter = sorted(oddCounter.items(),key=lambda x:x[1])
   evenCounter = sorted(evenCounter.items(),key=lambda x:x[1])
   oddMAX = oddCounter[-1][0]
   evenMAX = evenCounter[-1][0]
   if oddMAX == evenMAX:
      evenLen = len(evenCounter)
      oddLen = len(oddCounter)
      if evenLen >= 2 and oddLen >= 2:
         if evenCounter[-2][1] > oddCounter[-2][1]:
            evenMAX = evenCounter[-2][0]
         else:
            oddMAX = oddCounter[-2][0]
      elif evenLen >= 2:
         evenMAX = evenCounter[-2][0]
      else:
         oddMAX = oddCounter[-2][0]

   
   total = 0
   for n,v in enumerate(V):
      if n % 2 == 1:
         if oddMAX != v:
            total += 1
      else:
         if evenMAX != v:
            total += 1
   return total
def modelAnswer():
   return
def main():
   N = int(input())
   V = list(map(int,input().split()))
   print(myAnswer(N,V))


if __name__ == '__main__':
   main()


Measured memory_bytes: 27880
import heapq

n, m = map(int, input().split())
l = [[] for _ in range(m)]
 
for i in range(n):
    a, b = map(int, input().split())
    if a <= m:
        l[a - 1].append(b)

a = []
ans = 0

for k in range(m - 1, -1, -1):
    i = m - k - 1
    for j in l[i]:
        heapq.heappush(a, (-1) * j)
    if a:
        ans += heapq.heappop(a) * (-1)
        
print(ans)


Measured memory_bytes: 72736
import sys
import collections
from collections import Counter
# from collections import deque
# from collections import defaultdict
import itertools
# from itertools import accumulate
# from itertools import permutations
# from itertools import combinations
# from itertools import takewhile
from itertools import compress
# import functools
# from functools import reduce
import math
# from math import gcd
# from math import inf
# from math import ceil
# from math import floor
# from math import log10
# from math import log2
# from math import log
from math import factorial

# import re

N, K = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]

S = set()
for i in range(N):
    for j in range(i, N):
        b = A[i:j + 1]
        S.add(sum(b))

S = list(S)

ans = 0
for i in range(39, -1, -1):
    A = [s & (1 << i) for s in S]
    newS = list(compress(S, A))
    if len(newS) >= K:
        ans += (1 << i)
        S = newS

print(ans)


Measured memory_bytes: 120536
#include<bits/stdc++.h>
#define mod 1000000007

using namespace std;

using ll = long long;

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

 	string s;
 	cin >> s;

 	bool flag = 0;
 	for(ll i=0;i<3;i++){
 		if(s[i] == '7'){
 			flag = 1;
 			break;
 		}
 	}  

 	if(flag == 1){
 		cout << "Yes\n";
 	}
 	else{
 		cout << "No\n";
 	}
 	
	return 0;
}

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

int main() {
	int n,k;cin>>n>>k;
	int a[n];
	int min=0;
    for(int i=0;i<n;i++){
    	cin>>a[i];
    	if(a[i]==1){
    		min=i;
    	}
    }
    int ans=0;
//    if(min!=0)ans+=(min-1)/(k-1)+1;
//    if(min!=n-1)ans+=(n-min-1-1)/(k-1)+1;
//    int re=min;
//    while(re>0){
//    	re-=k-1;
//    	ans++;
//    }
//    re=n-min-1;
//    while(re>0){
//    	re-=k-1;
//    	ans++;
//    }
    ans=(n-1-1)/(k-1)+1;
    cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 640
using System;

public class Program
{
    public void Solve()
    {
        var sc = new Scanner();
        int N = sc.NextInt();
        string S = sc.Next();

        int cnt = 1;

        for (int i = 1; i < N; i++)
        {
            if (S[i] != S[i - 1])
            {
                cnt++;
            }
        }
        Console.WriteLine(cnt);
    }

    public static void Main(string[] args)
    {
        new Program().Solve();
    }
}

class Scanner
{
    public Scanner()
    {
        _pos = 0;
        _line = new string[0];
    }

    const char Separator = ' ';
    private int _pos;
    private string[] _line;

    #region スペース区切りで取得

    public string Next()
    {
        if (_pos >= _line.Length)
        {
            _line = Console.ReadLine().Split(Separator);
            _pos = 0;
        }

        return _line[_pos++];
    }

    public int NextInt()
    {
        return int.Parse(Next());
    }

    public long NextLong()
    {
        return long.Parse(Next());
    }

    public double NextDouble()
    {
        return double.Parse(Next());
    }

    #endregion

    #region 型変換

    private int[] ToIntArray(string[] array)
    {
        var result = new int[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = int.Parse(array[i]);
        }

        return result;
    }

    private long[] ToLongArray(string[] array)
    {
        var result = new long[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = long.Parse(array[i]);
        }

        return result;
    }

    private double[] ToDoubleArray(string[] array)
    {
        var result = new double[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = double.Parse(array[i]);
        }

        return result;
    }

    #endregion

    #region 配列取得

    public string[] Array()
    {
        if (_pos >= _line.Length)
            _line = Console.ReadLine().Split(Separator);

        _pos = _line.Length;
        return _line;
    }

    public int[] IntArray()
    {
        return ToIntArray(Array());
    }

    public long[] LongArray()
    {
        return ToLongArray(Array());
    }

    public double[] DoubleArray()
    {
        return ToDoubleArray(Array());
    }

    #endregion
}

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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF INT_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()

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

  int n,m;
  cin>>n>>m;
  vector<int>c(m);
  for(int i=0;i<m;i++)cin>>c[i];

  vector<vector<int>>dp(m+1,vector<int>(n+1,INF-100));
  dp[0][0]=0;
  for(int i=1;i<=m;i++){
    for(int j=0;j<=n;j++){
      dp[i][j]=dp[i-1][j];
      if(j-c[i-1]>=0)dp[i][j]=min({dp[i][j],dp[i-1][j-c[i-1]]+1,dp[i][j-c[i-1]]+1});
    }
  }

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



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

#include <ext/pb_ds/assoc_container.hpp> //required
#include <ext/pb_ds/tree_policy.hpp> //required

using namespace __gnu_pbds; 
using namespace std;

template <typename T> using ordered_set =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; 
// find_by_order(k)  returns iterator to kth element starting from 0;
// order_of_key(k) returns count of elements strictly smaller than k;
typedef long long  ll;
typedef vector<ll> VL;
typedef vector<int> VI;
typedef pair<ll,ll> PLL;
typedef pair<int,int> PII;
#define pb push_back

#define F first
#define S second
#define SZ(a) int((a).size())
#define ALL(a) a.begin(),a.end()
#define fr(i,x,y) for(int i=x;i<y;i++)
#define frr(i,x,y) for(int i=x-1;i>=y;i--)
#define inf 1e18+1
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const int mod=998244353;
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll power(ll a,ll b){ll ans=1;while(b!=0){if(b&1){ans*=a;}a=a*a;b>>=1;}return ans;}
ll powerm(ll a,ll b){ll ans=1;while(b!=0){if(b&1){ans*=a;ans%=mod;}a=a*a;a%=mod;b>>=1;}return ans%mod;}
VL dx={1,0,-1,0};
VL dy={0,1,0,-1};
// string to integer stoi()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();

void solve()
{
    ll n,k;
    cin>>n>>k;
    vector<PLL> arr(k);
    fr(i,0,k)
        cin>>arr[i].F>>arr[i].S;
    VL dp(n+2,0);
    dp[1]=1;
    dp[2]=-1;
    fr(i,1,n+1)
    {
        dp[i]+=dp[i-1];
        fr(j,0,k)
        {
            ll x=min(n+1,i+arr[j].F);
            ll y=min(n+1,i+arr[j].S+1);
            dp[x]+=dp[i];
            dp[x]%=mod;
            dp[y]-=dp[i];
            dp[y]+=mod;
            dp[y]%=mod;
        }
        dp[i]%=mod;
    }
    cout<<dp[n]<<endl;
    return;
}
int main()
{
    IOS;
    ll t=1,pp;
    //cin>>t;
    pp=t;
    while(t--)
    {
        //cout<<"Case #"<<pp-t<<": ";
        solve();
    }
    return 0;
}
/* stuff you should look for
        * int overflow, array bounds
        * special cases (n=1?)
        * do smth instead of nothing and stay organized
        * WRITE STUFF DOWN
*/
/*
recursion - matrix exponential

*/
// BITMASK:
// 1)When some constrall is of the order of 15-20, think of bitmask DP.
// 2)When some constrall is around 40, try out meet in the middle
// 3) See Strings,palindromes,prefix,suffix etc -> KMP,Z algorithm

Measured memory_bytes: 4772
/**********************************
	author:  mariogzsl
**********************************/

#include <bits/stdc++.h>

#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,b,a) for(int i=b-1;i>=a;i--)
#define f first
#define s second
#define puts(x) cout<<x<<endl
using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
int gcd(int a, int b){return (b==0)?a:gcd(b,a%b);}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int A, B;
	cin>>A>>B;
	int ans = A+A-1;
	ans=max(max(ans, A+B), B+B-1);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256