akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define N 200010
#define INFLL 0x3f3f3f3f3f3f3f3f
int n, m;
ll d, a[N];
struct Edge
{
	int u, v; ll w;
	Edge() {}
	Edge(int u, int v, ll w) : u(u), v(v), w(w) {}
	bool operator < (const Edge &other) const { return w < other.w; }
}edge[N * 30];

void add(int l, int r)
{
	if (l == r) return;
	int mid = (l + r) >> 1;
	ll Min = INFLL; int pos = -1; 
	for (int i = l; i <= mid; ++i) 
	{
		ll f = a[i] - d * i;
		if (f < Min)
		{
			Min = f;
			pos = i;
		}
	}
	for (int i = mid + 1; i <= r; ++i)
		edge[++m] = Edge(pos, i, a[pos] + a[i] + d * (i - pos));
	Min = INFLL; pos = -1;
	for (int i = mid + 1; i <= r; ++i)
	{
		ll f = a[i] + d * i;
		if (f < Min)
		{
			Min = f;
			pos = i;
		}
	}
	for (int i = l; i <= mid; ++i) 
		edge[++m] = Edge(pos, i, a[pos] + a[i] + d * (pos - i));
	add(l, mid);
	add(mid + 1, r);
}

int pre[N];
int find(int x) { return pre[x] == 0 ? x : pre[x] = find(pre[x]); }
ll Kruskal()
{
	memset(pre, 0, sizeof pre);
	sort(edge + 1, edge + 1 + m);
	int cnt = 1;
	ll res = 0;
	for (int i = 1; i <= m; ++i)
	{
		int u = edge[i].u, v = edge[i].v; ll w = edge[i].w;
		int fu = find(u), fv = find(v);
		if (fu == fv) continue;
		pre[fu] = fv;
		res += w;
		++cnt;
		if (cnt == n) return res;
	}
	return res;
}

int main()
{
	while (scanf("%d%lld", &n, &d) != EOF)
	{
		m = 0;
		for (int i = 1; i <= n; ++i) scanf("%lld", a + i);
		add(1, n);
		printf("%lld\n", Kruskal());
	}
	return 0;
}


Measured memory_bytes: 59648
A = list(map(int, input().split()))
A.sort()
g=0
k=0
cnt=0
for i in A:
    if i%2==0:
        g+=1
if g==0 or g==3:
    cnt=(2*A[2]-A[0]-A[1])/2
elif g==1:
    for i in range(3):
        if A[i]%2==1:
            A[i]+=1
    cnt=(2*A[2]-A[0]-A[1])/2+1
elif g==2:
    for i in range(3):
        if A[i]%2==0:
            A[i]+=1
    cnt=(2*A[2]-A[0]-A[1])/2+1
    
print(int(cnt))


Measured memory_bytes: 61700
#include <cstdio>
#include <cstring>
#include <map>
#include <algorithm>
#include <iostream>
#include <cmath>
//#define e 2.718

#define red   1
#define blue -1
#define ll long long

using namespace std;
struct node{
    int x;
    int y;
    int color;

};

bool cmp(node a,node b){
    return a.x<=b.x;
}

bool cmp2(int a,int b){
    return a>b;
}

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

    node list[2*n];
    for(int i=0;i<2*n;i++){
        if(i<n){
            cin>>list[i].x>>list[i].y;
            list[i].color = red;
        }else{
            cin>>list[i].x>>list[i].y;
            list[i].color = blue;
        }
    }


    sort(list,list+2*n,cmp);
    int res=0;
    int height[n];
    int pos=0;
    for(int i=0;i<n;i++){
        height[i]=-1;
    }

    for(int i=0;i<2*n;i++){
        if(list[i].color ==red){
            height[pos] = list[i].y;
            ++pos;
        }else{
            if(pos>0){
                sort(height,height+n,cmp2);
                for(int j=0;j<pos;j++){
                    if(height[j]<list[i].y){
                        ++res;
                        height[j]=-1;
                        --pos;
                        sort(height,height+n,cmp2);
                        break;
                    }
                }
            }
        }
    }
    cout<<res<<endl;
    return 0;

}

Measured memory_bytes: 256
#include <iomanip>
#include <utility>
#include <algorithm>
#include <type_traits>
#include <set>
#include <string>
#include <iostream>
#include <fstream>
#include <cassert>
#include <memory>
#include <unordered_set>
#include <unordered_map>
#include <set>
#include <queue>
#include <vector>
#include <array>
#include <chrono>
#include <random>
#include <forward_list>
#include <iomanip>
#include <functional>
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <sstream>

using namespace std;
#define MFOR(i,end) for(size_t i = 0, end_i = (end); i < end_i; ++ i)

struct my_int {
	int32_t v = -999999;
	my_int() {}
	my_int(int32_t u) :v(u) {}
	operator int32_t& () { return v; }
	operator const int32_t& ()const { return v; }
};
namespace std {
	template<>
	struct hash<my_int>
		: hash<int32_t>
	{};
}
//dp[i][j] = i+1ターン、j回以下パーを出したとき最大得点
//std::unordered_map<int32_t, my_int> dp[100000];
my_int dp[1000][1000];

int N;
char s[100009];

////dp[i][j] = i+1ターン、j回以下パーを出したとき最大得点
//constexpr int32_t f(int32_t i, int32_t j)
//{
//	if (i <= 0) {
//		return -1;
//	}
//	if (j <= 0) {
//		return f(i - 1, j) - 1;// +(s[i] == 'g' ? 1 : 0);
//	}
//	return std::max(f(i - 1, j - 1), f(i - 1, j) - 1);// +(s[i] == 'g' ? 1 : 0);
//}

int main()
{
	std::cin >> s;
	N = strlen(s);

	//for (size_t i = 0; i < N_MAX; i++) {
	//	dp[0][i] = -1;
	//}
	//for (size_t i = 1; i < N_MAX; i++) {
	//	dp[i][0] = dp[i - 1][0] - 1;
	//	for (size_t j = 1; j < N_MAX/2; ++j) {
	//		dp[i][j] = std::max(dp[i-1][j-1], dp[i - 1][j] - 1);
	//	}
	//}


	//std::cout << f(N - 1, N / 2) + std::count_if(s, s + N, [](char c) {return c == 'g'; }) << std::endl;
	std::cout << -(N-(N / 2)) + std::count_if(s, s + N, [](char c) {return c == 'g'; }) << std::endl;

	return 0;
}


Measured memory_bytes: 4224
#pragma GCC optimize("Ofast")
#include <cstdio>
#include <cstdlib>
#include <string>
#include <algorithm>
#include <iostream>
#include <queue>
#include <vector>
#include <bitset>
#include <cmath>
#include <limits>
#include <iostream>
#include <map>
#include <set>
#include <tuple>
#include <iomanip>
#include <functional>

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<int,ll> pil;
typedef pair<ll,int> pli;
typedef pair<ll,ll> pll;

template<class T,class U>constexpr bool chmin(T&a,const U b){if(a<=b)return false;a=b;return true;}
template<class T,class U>constexpr bool chmax(T&a,const U b){if(a>=b)return false;a=b;return true;}
#define bit(n,k) ( (n>>k)&1 )

//デバッグ
template<class T>
void Vout(vector<T> &V){
    cout<<"\nstart\n";
    const int sz=V.size();
    for(int i=0;i<sz;i++){
        cout<<i<<" "<<V[i]<<'\n';
    }
    cout<<"end\n"<<endl;
}

template<class T>
void VPout(vector<T> &V){
    cout<<"\nstart\n";
    const int sz=V.size();
    for(int i=0;i<sz;i++){
        cout<<i<<" "<<V[i].first<<" "<<V[i].second<<'\n';
    }
    cout<<"end\n"<<endl;
}


//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++


constexpr int MAX=1<<30;
constexpr ll INF=1LL<<62;
constexpr int MOD=1e9+7;
int dx[]={1,-1,0,0},dy[]={0,0,-1,1};

//__builtin_popcount(S);
//#define int ll
//vector<vector<int>> data(3, vector<int>(4));
//vector.resize(a,vector<int>(b,-1));
//vector<vector<vector<要素の型>>> 変数名(要素数1, vector<vector<要素の型>>(要素数2, vector<要素の型>(要素数3, 初期値)));




signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr); 
    cout<<fixed<<setprecision(10);

    int N;
    cin>>N;
    vector<int> A(N);
    for(int i=0;i<N;i++){
        int a;
        cin>>a;
        if(a%2==0 && (a%3!=0 && a%5!=0)){
            cout<<"DENIED"<<endl;
            return 0;
        }
    }
    cout<<"APPROVED"<<endl;
}

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

int main(){
	ll n; cin >> n;
	for(ll i = 1; i <= 3500; ++i){
		for(ll j = 1; j <= 3500; ++j){
			ll po = 4 * i * j - n * i - n * j;
			if(po > 0 && !(n * i * j % po)){
				cout << i << " " << j << " " << n * i * j / po << endl;
				return 0;
			}
		}
	}
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){

  int n = 0;
  int i = 0;
  int result = 0;
  int a[100];

  int max = 0;
  int min = 1000000000;

  //input
  scanf("%d",&n);

  for( i=0; i<n; i++ ){

    scanf("%d",&a[i]);

    if( max < a[i] )
      max = a[i];

    if( min > a[i] )
      min = a[i];
    
    
  }

  result = max - min;  
  
  //output
  printf("%d\n",result);
  
  return 0;
}


Measured memory_bytes: 128
B,M,S = 13,9,5
dx = [ 0, 0, 1, 0,-1, 1, 1,-1,-1, 0, 2, 0,-2]
dy = [ 0,-1, 0, 1, 0,-1, 1, 1,-1, 2, 0,-2, 0]
def isOnCloth(x,y):
    return 0<=x<10 and 0<=y<10
def soak(cloth,x,y,ink):
    for i in xrange(ink):
        cloth[y+dy[i]][x+dx[i]] -= 1
def drop(cloth,x,y,ink):
    for i in xrange(ink):
        cloth[y+dy[i]][x+dx[i]] += 1
def canSoak(cloth,x,y,ink):
    return all([isOnCloth(x+dx[i],y+dy[i]) and cloth[y+dy[i]][x+dx[i]]>0 for i in xrange(ink)])
def DFS(cloth,ink_set,cur):
    if len(ink_set)==0:
        return []
    for i in xrange(cur,100):
        if not cloth[i/10][i%10] == 0:
            break
        cur += 1
    for ink in set(ink_set):
        for i in xrange(ink):
            cx,cy = cur%10+dx[i],cur/10+dy[i]
            if isOnCloth(cx,cy) and cloth[cy][cx]>0:
                if canSoak(cloth,cx,cy,ink):
                    soak(cloth,cx,cy,ink)
                    ink_set.remove(ink)
                    result = DFS(cloth,ink_set,cur)
                    if not result == False:
                        result.append([cx,cy,ink])
                        return result
                    ink_set.append(ink)
                    drop(cloth,cx,cy,ink)
    return False
import itertools
n = input()
cloth = []
for u in xrange(10):
    cloth.append(map(int,raw_input().split(" ")))
su = sum([sum(cloth[i]) for i in xrange(10)])
ink_sets = [list(a) for a in itertools.combinations_with_replacement([0,13,9,5],n) if sum(a) == su]
for ink_set in ink_sets:
    pass
    result = DFS(cloth,ink_set,0)
    if not result == False:
        break
dic = {B:3,M:2,S:1}
for r in result:
    print "{} {} {}".format(r[0],r[1],dic[r[2]])

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

using namespace std;
typedef long long int LL;
typedef long long int ll;
typedef pair<long long int, long long int> pii;
typedef pair<double, double> pdd;

#define SORT(c) sort((c).begin(),(c).end())
#define BACKSORT(c) sort((c).begin(),(c).end(),std::greater<LL>())
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SP << " " <<

LL mod = 1000000007;

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

  LL H,W,N;
  cin >> H >> W >> N;
  LL sr, sc;
  cin >> sr >> sc;
  string S, T;
  cin >> S >> T;

  bool flag = false;

  {
    LL cnt = W - sc + 1;
    REP(i,N){
      if(S[i]=='R'){
        cnt--;
        if(cnt<=0){
          flag = true;
        }
      }
      if(T[i]=='L'){
        cnt++;
        cnt = min(cnt, W);
      }
    }
  }
  {
    LL cnt = sc;
    REP(i,N){
      if(S[i]=='L'){
        cnt--;
        if(cnt<=0){
          flag = true;
        }
      }
      if(T[i]=='R'){
        cnt++;
        cnt = min(cnt, W);
      }
    }
  }
  {
    LL cnt = H - sr + 1;
    REP(i,N){
      if(S[i]=='D'){
        cnt--;
        if(cnt<=0){
          flag = true;
        }
      }
      if(T[i]=='U'){
        cnt++;
        cnt = min(cnt, H);
      }
    }
  }
  {
    LL cnt = sr;
    REP(i,N){
      if(S[i]=='U'){
        cnt--;
        if(cnt<=0){
          flag = true;
        }
      }
      if(T[i]=='D'){
        cnt++;
        cnt = min(cnt, H);
      }
    }
  }

  if(flag){
    cout << "NO" << endl;
  }else{
    cout << "YES" << endl;
  }
}


Measured memory_bytes: 920
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    N = I()
    S = SS()
    K = I()

    ans = []
    S_k = S[K-1]
    for i in S:
        if i == S_k:
            ans.append(i)
        else:
            ans.append('*')

    print(''.join(ans))

if __name__ == '__main__':
    resolve()


Measured memory_bytes: 10032
//47行目から編集
#include <iostream>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <cassert>

#define REP(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define eb emplace_back
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<int> > vvi;
typedef vector<vector<ll> > vvl;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;

template<class T> bool chmin(T& a,T b);
template<class T> bool chmax(T& a,T b);
template<class T> void debugger(vector<T>& a);
template<class T> void debugger(vector<vector<T>>& a);
///////////////////////////////////////////////////////////

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    //cout << fixed << setprecision(20);
    ll n,a,b;cin >> n >> a >> b;
    ll m = n / (a+b);
    ll ans = m * a + min(a,n % (a+b));
    cout << ans << '\n';
    return 0;
}

///////////////////////////////////////////////////////////
template<class T> bool chmin(T& a,T b){
    if(a > b){a = b;return true;}else return false;
}
template<class T> bool chmax(T& a,T b){
    if(a < b){a = b;return true;}else return false;
}
template<class T> void debugger(vector<T>& a){
    cerr << "{";
    for(int i = 0;i < a.size();i++){
        if(i == 0)cerr << a[i];
        else cerr << "," << a[i];
    }
    cerr << "}" << '\n';
    return;
}
template<class T> void debugger(vector<vector<T>>& a){
    int n = a.size();
    int m = a[0].size();
    cerr << "__|";
    for(int i = 0;i < m;i++){
        cerr << setw(5) << i;
    }
    cerr << '\n';
    for(int i = 0;i < n;i++){
        cerr << setw(3) << i;
        for(int j = 0;j < m;j++){
            if(a[i][j] >= 100000)cout << setw(5) << "INF";
            else cerr << setw(5) << a[i][j];
        }
        cerr << '\n';
    }
}


Measured memory_bytes: 256
#define DEBUG 0
#include <bits/stdc++.h>
#define loop(n) for (lint ngtkana_is_a_genius = 0; ngtkana_is_a_genius < lint(n); ngtkana_is_a_genius++)
#define rep(i, begin, end) for (lint i = lint(begin); (i) < lint(end); i++)
#define all(v) v.begin(), v.end()
#define rand(l, r) std::uniform_int_distribution<>(l, r)(mt)
using lint = long long;
auto mt = std::mt19937_64(std::random_device{}());
auto cmn = [](auto&& a, auto b){ if (a > b) {a = b; return true;} return false; };
auto cmx = [](auto&& a, auto b){ if (a < b) {a = b; return true;} return false; };
void debug_impl() { std::cerr << std::endl; }
template <typename Head, typename... Tail>
void debug_impl(Head head, Tail... tail) { std::cerr << " " << head; debug_impl(tail...); }
#if DEBUG
#define debug(...)\
  do {\
    std::cerr << std::boolalpha << "[" << #__VA_ARGS__ << "]:";\
    debug_impl(__VA_ARGS__);\
    std::cerr << std::noboolalpha;\
  } while (false)
#else
#define debug(...) {}
#endif

template < typename Container, typename Value = typename Container::value_type, std::enable_if_t<!std::is_same< Container, std::string >::value, std::nullptr_t> = nullptr>
std::istream& operator>> (std::istream& is, Container& v)
  { for (auto & x : v) { is >> x; } return is; }

template < typename Container, typename Value = typename Container::value_type, std::enable_if_t<!std::is_same< Container, std::string >::value, std::nullptr_t> = nullptr >
std::ostream& operator<< (std::ostream& os, Container const& v) {
 os << "{";
  for (auto it = v.begin(); it != v.end(); it++)
    {os << (it != v.begin() ? "," : "") << *it;}
  return os << "}";
}

int main() {
  std::cin.tie(0); std::cin.sync_with_stdio(false);
  int n, k; std::cin >> n >> k;
  std::vector<int> a(n); std::cin>>a;
  int ans = std::numeric_limits<int>::max();
  rep(i,0,n-k+1) {
    int j = i + k - 1;
    debug(i,j);
    int x = a.at(i), y = a.at(j);
    bool negative = (x >= 0) ^ (y >= 0);
    debug(x,y,negative);
    if (x < 0) x = -x;
    if (y < 0) y = -y;
    if (x > y) std::swap(x, y);
    int now = negative ? 2*x+y : y;
    cmn(ans, now);
  }
  std::cout << ans << std::endl;
  return 0;
}

/*
つけるろうそくを全探索です。
左端、右端の座標の絶対値が x, y とすると、答えは min(2x+y, x+2y) です。
*/

Measured memory_bytes: 640
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
dish = [a,b,c,d,e]
last = 0
for index,d in enumerate(dish):
  if d % 10 != 0:
    d10 = ((d // 10)+1) *10
    if last <= d10 - d:
      last = d10 - d
    dish[index] = d10
print(sum(dish)-last)
      
    
    
  

Measured memory_bytes: 9176
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin>>n;
  int ans = 0, Max = 0;
  for(int i=0;i<n;i++){
    int xx;
    scanf("%d",&xx);
    Max = max(Max, xx);
    ans += xx;
  }
  cout<<ans - Max / 2<<endl;
  return 0;
}

Measured memory_bytes: 256
a, b, c, d = map(int, input().split())

aoki = 0
if a % d == 0:
    aoki = a // d
else:
    aoki = a // d + 1

takahashi = 0
if c % b == 0:
    takahashi = c // b
else:
    takahashi = c // b + 1

if takahashi <= aoki:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 61588
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;

const int inf = 99999999;
const ll linf = 999999999999999999;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.end(), v.begin());
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

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

int main(){
	int n;
	cin >> n;
	if(n < 1200)P("ABC");
	else P("ARC");

	return  0;
}

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

public class Main {

    public static void main(String args[]) {

        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        
        boolean[] isSafe = new boolean[N+1];
        Arrays.fill(isSafe, true);
        
        for (int i = 1; i < M+1; i++) {
            int tmp = sc.nextInt();
            isSafe[tmp] = false;
        }
         long[] dp = new long[N+1]; 
         Arrays.fill(dp, 0);
         dp[0] = 1;
         dp[1] = 1;
         if(!isSafe[1]) dp[1] = 0;
         for(int i=2; i<N+1; i++) {
             if(!isSafe[i]) continue;
             dp[i] = (dp[i-1]+dp[i-2])%1000000007;
         }
       System.out.println(dp[N]);
    }
}

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

#define ln '\n'
#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 FORR(i, a, b) for(int i = (a); i >= (int)(b); --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
typedef vector<P> VP;
typedef vector<PL> VPL;
typedef vector<string> VS;


const int MAX_DIGIT = 50;


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, k;
    cin >> n >> k;
    VI bit_cnt(MAX_DIGIT, 0);
    REP(i, n) {
        ll a;
        cin >> a;
        REP(j, MAX_DIGIT) {
            bit_cnt[j] += a % 2;
            a /= 2;
        }
    }

    VVL dp(MAX_DIGIT, VL(2, -1));  // [上からi桁目][is_smaller]
    dp[0][0] = 0;  // MAX_DIGIT - 1桁目 上から0桁目
    FOR(i, 1, MAX_DIGIT - 1) {
        ll mask = 1LL << (MAX_DIGIT - i - 1);
        ll cost0 = bit_cnt[MAX_DIGIT - i - 1] * mask;
        ll cost1 = (n - bit_cnt[MAX_DIGIT - i - 1]) * mask;
        
        dp[i][0] = dp[i - 1][0] + (k & mask ? cost1 : cost0);
        if(k & mask) dp[i][1] = dp[i - 1][0] + cost0;
        if(dp[i - 1][1] != -1) dp[i][1] = max(dp[i][1], dp[i - 1][1] + max(cost0, cost1));
    }

    cout << *max_element(ALL(dp[MAX_DIGIT - 1])) << ln;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int n = Integer.parseInt(sc.next());
        int[] l = new int[n];

        int max = 0;
      	int max_i = 0;

        for (int i = 0; i < n; i++) {
            int num = Integer.parseInt(sc.next());
            if (num > max) {
                max = num;
              	max_i = i;
            }
            l[i] = num;
        }
      
        int sum = 0;
        for (int i = 0; i < n; i++) {
          	if (i == max_i) {
            	continue;
            }
            sum += l[i];
        }
      
        if (max < sum) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long ll;

typedef long double ld;
typedef pair<ll,ll> pp;
typedef tree<pp,null_type,less<pp>,rb_tree_tag,tree_order_statistics_node_update> super_set;

#define x1 dfds
#define y1 dsfdsfe
#define pb push_back
#define forn(i,n) for(ll i = 1;i<=n;++i)
#define fi first
#define sc second
#define endl '\n'
#define po(x) (1ll<<x)
#define log sdfdsfdsf

const ll DIM = 2E5+7;
const ll MOD = 1e9+123;

const ll INF = 1E17;
const ld eps = 0.00000000000001;
const ld PI = 3.14159265358979323846;
int getInt(int a = 0, int b = INT_MAX){
    static mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    return uniform_int_distribution <int> (a, b)(rng);
}

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    ll x;
    cin>>x;
    cout<<1-x<<endl;
    return 0;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(x)(x).begin(), (x).end() // 昇順ソート
#define rall(v)(v).rbegin(), (v).rend() // 降順ソート
#define INF 1LL << 60
typedef long long int LL;
typedef long long int ll;
#define pll pair < ll, ll >
#define F first
#define S second
const int MOD = 1000000007;
template < class T > bool chmax(T & a,const T & b) { if (a < b) { a = b; return true; } return false; }
template < class T > bool chmin(T & a,const T & b) { if (a > b) { a = b; return true; } return false; }
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)

int main() {
    int X,Y;cin >> X >> Y;

    int tmp = X*2;
    if(Y / 2 <= tmp && tmp <= Y && Y % 2 == 0)cout << "Yes" << endl;
    else cout << "No" << endl;

}

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

int main(){
  int n, c, k;
  cin >> n >> c >> k;
  vector <int> t(n);
  for (int i = 0; i < n; i++){
    cin >> t.at(i);
  }
  sort(t.begin(), t.end());
  
  int ans = 1;
  int first = 0;
  for (int i = 1; i < n; i++){
    if (i - first + 1 > c || t.at(i) - t.at(first) > k){
      ans++;
      first = i;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 640
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

#define int         long long
#define ll          long long
#define pb          push_back
#define mp          make_pair
#define pii         pair<int,int>
#define vi          vector<int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (int)x.size()
#define hell        1000000007
#define endl        '\n'
#define rep(i,a,b)  for(int i=a;i<b;i++)
using namespace std;
int ans=0;
void solve(){
  int N,M;
  cin>>N>>M;
  vi x(N);
  rep(i,0,N)cin>>x[i];
  vector<int>dsu(N,-1);
  rep(i,0,M){
    int a,b;
    cin>>a>>b;
    while(dsu[a]>=0)a=dsu[a];
    while(dsu[b]>=0)b=dsu[b];
    if(a==b)continue;
    if(dsu[a]>dsu[b])swap(a,b);
    dsu[a]+=dsu[b];
    dsu[b]=a;
  }
  vector<priority_queue<int,vi,greater<int> > > leads(N);
  set<int> p;
  priority_queue<int,vi,greater<int>> pqq;
  rep(i,0,N){
    int a=i;
    while(dsu[a]>=0)a=dsu[a];
    leads[a].push(x[i]);
    p.insert(a);
  }
  if(sz(p)==1){
    cout<<0<<endl;
    return;
  }
  for(auto i:p){
    ans+=leads[i].top();
    leads[i].pop();
    while(!leads[i].empty()){
      pqq.push(leads[i].top());
      leads[i].pop();
    }
  }
  if(sz(pqq)<sz(p)-2){
    cout<<"Impossible"<<endl;
    return;
  }
  rep(i,0,sz(p)-2){
    ans+=pqq.top();
    pqq.pop();
  }
  cout<<ans<<endl;
}

signed main(){
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int t=1;
//  cin>>t;
  while(t--){
    solve();
  }
  return 0;
}

Measured memory_bytes: 12800
n, m = map(int, input().split())
broken = [0]*(n+1)
for i in range(m):
    a = int(input())
    broken[a] = 1
dp = [0]*(n+1)
dp[0] = 1
mod = 1000000007
for i in range(1, n+1):
    if broken[i]:
        continue
    dp[i] = (dp[i-1] + dp[i-2]) % mod
print(dp[n])


Measured memory_bytes: 13608
# coding: utf-8
# Your code here!
N = int(input())
S = input()

count = 0
r = S.count("R")
g = S.count("G")
b = S.count("B")

count = r*g*b
#print(count)
for i in range(N - 1):
    for j in range(i+1, N):
        k = 2 * j -i
        if k >= N:
            break
        if S[i] != S[j] and S[j] != S[k] and S[k] != S[i]:
            count -= 1

print(count)

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

using namespace std;

using ll = long long;
using ld = long double;

using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;
using vld = vector<ld>;
using vvld = vector<vld>;

typedef pair<ll, ll> P;

#define bit(n) (1LL << (n))

//#define int long long

#define all(v) v.begin(), v.end()

#define rep(i, n) for (ll i = 0; i < n; i++)
#define REP(i, n) for (ll i = 1; i < n; i++)

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define FORm(i, m) for (auto i = m.begin(); i != m.end(); i++)

template <class T>
inline void chmax(T& a, T b) {
  a = std::max(a, b);
}
template <class T>
inline void chmin(T& a, T b) {
  a = std::min(a, b);
}

#define mod (ll)(1e9 + 7)
// #define mod (998244353ll)

const long long INF = 1LL << 60;

struct UnionFind {
  vector<int> parent;
  vector<int> num_node;

  UnionFind(int N) : parent(N), num_node(N, 1) {
    for (int i = 0; i < N; i++) {
      parent[i] = i;
    }
  }

  // 根を求める
  int root(int x) {
    if (parent[x] == x) {
      return x;
    }

    // 経路圧縮
    parent[x] = root(parent[x]);
    return parent[x];
  }

  // 同一判定
  bool is_same(int x, int y) {
    return this->root(x) == this->root(y);
  }

  // 併合
  void unite(int x, int y) {
    x = this->root(x);
    y = this->root(y);

    // すでに一緒ならなにもしない
    if (x == y) {
      return;
    }
    parent[x] = y;
    num_node[y] += num_node[x];
  }

  // 同一グループのノード数
  int size(int x) {
    return num_node[root(x)];
  }
};

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

  ll n;
  cin >> n;

  vector<P> vx, vy;
  vector<P> vp;
  rep(i, n) {
    ll x, y;
    cin >> x >> y;
    vx.emplace_back(x, i);
    vy.emplace_back(y, i);
    vp.emplace_back(x, y);
  }

  sort(all(vx));
  sort(all(vy));

  UnionFind uf(n);
  rep(i, n - 1) {
    if (vx[i].first == vx[i + 1].first) {
      uf.unite(vx[i].second, vx[i + 1].second);
    }
    if (vy[i].first == vy[i + 1].first) {
      uf.unite(vy[i].second, vy[i + 1].second);
    }
  }

  map<ll, set<ll>> mx, my;
  rep(i, n) {
    mx[uf.root(i)].insert(vp[i].first);
    my[uf.root(i)].insert(vp[i].second);
  }

  ll ans = 0;
  for (auto&& xx : mx) {
    ll lx = xx.second.size();
    ll ly = my[xx.first].size();
    ans += lx * ly;
  }

  ans -= n;
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 13408
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<queue>
#include<cmath>

using namespace std;

long long comb(long long a, long long b, long long MOD){
    long long now=1;
    for(long long i=1;i<=a-b;i++){
        long long k = (a+1-i) % MOD;
        now = (now * k / i);
        now = now % MOD;
    }
    return now % MOD;
}



int main(){
    long long X, Y;
    long long MOD = 1000000007;
    cin >> X >> Y;
    if((X+Y) % 3 != 0){
        cout << 0;
        return 0;
    }
    long long border = (X+Y)/3;
    if(X < border || Y < border){
        cout << 0;
        return 0;
    }
    vector<long long> kai(border+1);
    vector<long long> inv(border+1);
    vector<long long> finv(border+1);
    kai[0]=1;kai[1]=1;
    finv[0]=1;finv[1]=1; 
    inv[1]=1;
    for(int i=2;i<=border;i++){
        kai[i] = kai[i-1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
        finv[i] = finv[i-1] * inv[i] % MOD;
    }
    cout << kai[border] * (finv[X-border] * finv[2*border-X] % MOD) % MOD << endl;
//    cout << comb(border, X-border, MOD) % MOD  << endl;

    return 0;
}


Measured memory_bytes: 15872
#!/usr/bin/env python3
import sys


def solve(N: int):
    if N % 2 == 0:
        return 0.5
    else:
        return ((N+1) // 2 )/ N


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    p=solve(N)
    print(p)

if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
S=input()
s=list(S)

if s[0]!='A':
    print('WA')
else:
    if s.count('C')!=1:
        print('WA')
    else:
        if s.index('C')<2 or s.index('C')>len(s)-2:
            print('WA')
        else:
            s.remove('A')
            s.remove('C')
            
            count=0
            for i in range(len(s)):
                if str.islower(s[i]):
                    count+=1
            if count==len(s):
                print('AC')
            else:
                print('WA')

Measured memory_bytes: 3064
n = int(input())
x = list(map(int,input().split()))
ans = 0
for i in range(min(x),max(x)):
    num = 0
    for j in range(len(x)):
        num += (i-x[j])**2
    if ans == 0:
        ans = num
    elif num < ans:
        ans = num
print(ans)

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

int main(void){
    ll n;
    cin >> n;

    ll a[n], b[n], c[n];
    rep(i, n){
        cin >> a[i] >> b[i] >> c[i];
    }

    ll dp[n][3];
    dp[0][0] = a[0];
    dp[0][1] = b[0];
    dp[0][2] = c[0];

    for(int i = 1; i < n; i++){
        dp[i][0] = max(dp[i-1][1], dp[i-1][2]) + a[i];
        dp[i][1] = max(dp[i-1][0], dp[i-1][2]) + b[i];
        dp[i][2] = max(dp[i-1][0], dp[i-1][1]) + c[i];
    }

    cout << max(dp[n-1][0], max(dp[n-1][1], dp[n-1][2])) << endl;
    return 0;
}


Measured memory_bytes: 4992
#include<iostream>
using namespace std;
int main()
{
    int r,d,x2;
    cin>>r>>d>>x2;
    int ar[11];
    ar[0]=x2;
    for(int i=1;i<11;++i)
    {
        ar[i]=r*ar[i-1]-d;
    }
    for(int i=1;i<11;++i)
    {
        cout<<ar[i]<<endl;
    }
    
}

Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! get {
    ([$t:ty] ; $n:expr) => {
        (0..$n)
        .map(|_| get!([$t])).collect::<Vec<_>>()
    };
    ($($t:ty),+ ; $n:expr) => {
        (0..$n).map(|_| get!($($t),+)).collect::<Vec<_>>()
    };
    ([$t:ty]) => {
        rl().split_whitespace()
        .map(|x| x.parse().unwrap())
        .collect::<Vec<$t>>()
    };
    ($t:ty) => {
        rl().parse::<$t>().unwrap()
    };
    ($($t:ty),*) => {
        {
            let line =rl();
            let mut iter = line.split_whitespace();
            ($(iter.next().unwrap().parse::<$t>().unwrap()),*)
        }
    };
}
fn rl() -> String {
    let mut line = String::new();
    std::io::stdin().read_line(&mut line).unwrap();
    line.trim().to_string()
}

fn main() {
    let _n = get!(usize);
    let v = get!([i64]);
    let mut sum = 0;
    for i in v.iter() {
        sum += *i;
    }
    let mut snuke = 0;
    let mut ans = 1 << 62;
    for i in 0..v.len() - 1 {
        snuke += v[i];
        let tmp = (snuke - (sum - snuke)).abs();
        //eprintln!("ans: {}, tmp: {}", ans, tmp);
        ans = std::cmp::min(ans, tmp);
    }
    println!("{}", ans);
}


Measured memory_bytes: 10492
import sys
from collections import deque

sys.setrecursionlimit(5 * 10**5)
input=sys.stdin.readline

N, Q = list(map(int, input().split()))

M = [[] for _ in range(N)]
for _ in range(N-1):
    a, b = list(map(int, input().split()))
    M[a-1].append(b-1)
    M[b-1].append(a-1)

ans = [0] * N
for _ in range(Q):
    p, x = list(map(int, input().split()))
    ans[p-1] += x

Q = deque([0])

while Q:
    current = Q.popleft()

    for i in M[current]:
        ans[i] += ans[current]
        M[i].remove(current)
        Q.append(i)

print(' '.join(map(str, ans)))


Measured memory_bytes: 72132
n=int(input())
a = list(map(int,input().split()))
t=0
while all((i%2==0 for i in a)):  #iはaの数を試行する

    a=[i/2 for i in a]  
    #iはaの数なので，それを/2して，aに格納する
    t += 1

print(t)

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main() {
  string s;
  int q;
  cin >> s;
  cin >> q;

  deque<char> d;
  for (char c : s) {
    d.push_back(c);
  }

  bool rev = false;
  int t, f;
  char c;
  for (int i = 0; i < q; i++) {
    cin >> t;
    if (t == 1) {
      rev = !rev;
    } else {
      cin >> f >> c;
      if (rev ^ (f == 1)) {
        d.push_front(c);
      } else {
        d.push_back(c);
      }
    }
  }

  if (rev) {
    while (d.size()) {
      cout << d.back();
      d.pop_back();
    }
  } else {
    while (d.size()) {
      cout << d.front();
      d.pop_front();
    }
  }
  cout << endl;
}


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

int main() {
    int A,B,K;
    cin >> K;
    scanf("%d%d", &A, &B);
    for (int i=A; i<=B; i++) {
        // printf("%d", i%K);
        if (i % K == 0) {
            printf("OK");
            return 0;
        }
    }
    printf("NG");
    return 0;
}

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

using namespace std;

#define N 300000
#define LL long long

int n,a[N],fa[N],c[N][2],par[N];
LL ans;

struct node{
	int x,c0,c1;
	node(int x=0,int c0=0,int c1=0):x(x),c0(c0),c1(c1){}
	bool operator < (const node p) const{
		LL t1=(LL)c1*p.c0,t2=(LL)c0*p.c1;
		return t1<t2||(t1==t2&&x<p.x);
	}
};
set<node> se;

int gfa(int x){return x==par[x]?x:par[x]=gfa(par[x]);}

int main(){
	scanf("%d",&n);
	for (int i=2;i<=n;++i) scanf("%d",&fa[i]);
	for (int i=1;i<=n;++i){scanf("%d",&a[i]); ++c[i][a[i]];}
	for (int i=1;i<=n;++i) par[i]=i;
	for (int i=2;i<=n;++i) se.insert(node(i,c[i][0],c[i][1]));
	for (int i=1;i<n;++i){
		int x=se.begin()->x,y=gfa(fa[x]);
		se.erase(node(x,c[x][0],c[x][1]));
		par[x]=par[y];
		ans+=(LL)c[y][1]*c[x][0];
		if (y!=1) se.erase(node(y,c[y][0],c[y][1]));
		c[y][0]+=c[x][0]; c[y][1]+=c[x][1];
		if (y!=1) se.insert(node(y,c[y][0],c[y][1]));
	}
	printf("%lld\n",ans);
	
	return 0;
}
			

Measured memory_bytes: 17408
#include <stdio.h>

int main()
{
  int H,W;
  while(1){
    scanf("%d %d",&H,&W);
    if(H == 0 && W == 0)break;
    else
      for(int i=1;i<=H;i++){
	for(int j=1;j<=W;j++){
	  if(i % 2 == 0 && j % 2 == 0){
	    printf("#");
	  }
	  else if(i % 2 == 0 && j % 2 != 0){
	    printf(".");
	  }
	  else if(i % 2 != 0 && j % 2 == 0){
	    printf(".");
	  }
	  else printf("#");
	}
	printf("\n");
      }
    printf("\n");
  }
  return 0;
}



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

int main(){
    int n;
    long long w;
    scanf("%d %lld", &n, &w);
    long long ws[105], vs[105];
    vector<long long> kn1(100005), kn2(100005);
    for(int i=1; i<=n; i++){
        scanf("%lld %lld", &ws[i], &vs[i]);
    }
    for(int i =0; i<100005; i++){
        kn2[i] = 0;
    }
    for(int i=1; i<=n; i++){
        for(int j =1; j<=w;j++){
            if(ws[i]<=j){
                kn1[j] = max(kn2[j], kn2[j-ws[i]]+vs[i]);
            }
            else{
                kn1[j] = kn2[j];
            }
        }
        kn2 = kn1 ;
    }
    printf("%lld\n", kn1[w]);
}

Measured memory_bytes: 1792
// Sqrt decomposition(平方分割)
// より一般的には bucket method(バケット法)
//
// n個の要素からなる列を、√n程度ごとのバケットにまとめて管理する手法。
// 区間に対する処理がO(√n)程度で行える。
//
// verifyした問題
// Range Minimum Query (RMQ)
// https://onlinejudge.u-aizu.ac.jp/problems/DSL_2_A

#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;
// #define int long long

constexpr int ceil(int a, int b) { return (a + b - 1) / b; }
class SqrtDecomposition
{
    const int UNIT{2147483647};                            // 単位元
    const int OPERATOR(int a, int b) { return min(a, b); } // 演算子
    int bucket_size;

private:
    vector<int> elements;
    vector<int> buckets;

public:
    SqrtDecomposition(int n)
    {
        bucket_size = floor(sqrt(n));
        const int bucket_num = ceil(n, bucket_size);
        elements.assign(bucket_num * bucket_size, UNIT);
        buckets.assign(bucket_num, UNIT);
    }
    void update(int pos, int val)
    {
        int bucket_pos = pos / bucket_size;
        elements[pos] = val;
        int accumulation = UNIT;
        for (int i = bucket_pos * bucket_size; i < (bucket_pos + 1) * bucket_size; i++)
            accumulation = OPERATOR(elements[i], accumulation);

        buckets[bucket_pos] = accumulation;
    }
    int query(int left, int right)
    {
        int accumulation = UNIT;
        for (int i = 0; i < buckets.size(); i++)
        {
            int bucket_left = i * bucket_size;
            int bucket_right = (i + 1) * bucket_size;

            if (bucket_right <= left || right <= bucket_left)
                continue;

            if (left <= bucket_left && bucket_right <= right)
                accumulation = OPERATOR(buckets[i], accumulation);
            else
                for (int j = max(left, bucket_left); j < min(right, bucket_right); j++)
                    accumulation = OPERATOR(elements[j], accumulation);
        }

        return accumulation;
    }
};

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

    int n, q;
    cin >> n >> q;
    SqrtDecomposition sq(n);

    for (int i = 0; i < q; i++)
    {
        int com, x, y;
        cin >> com >> x >> y;

        if (com == 0)
            sq.update(x, y);
        else
            cout << sq.query(x, y + 1) << "\n";
    }
}



Measured memory_bytes: 3328
def gcm(a,b):
    if a < b:
        a,b = b,a
    while True:
        if a % b == 0:
            return b
        else:
            a,b = b,a % b

A,B,C = map(int,input().split())
g = gcm(A,B)
if C % g == 0:
    print('YES')
else:
    print('NO')


Measured memory_bytes: 2940
#include "iostream"
using namespace std;

int main()
{
	int gyouretu[101][101];//101?
	
	int beku[101];
	
	int n, m;
	cin >> n >> m;
	

	int a ,b ;

	for (int i = 1; i <= n;i++){//行列のインプット
		for (int j = 1; j <= m; j++){
			cin >> a;
			gyouretu[i][j]=a;

		}
	}
	for (int i = 1; i <= m; i++){//行ベクトルのインプット
		cin >> b;
		beku[i]=b;
	}

	
	for (int i = 1; i <= n; i++){//行
		int c=0;
		for (int j = 1; j <= m; j++){//列
			
			c+=gyouretu[i][j] * beku[j];
			//ループ毎に０になってる？
		}
		cout << c << endl;
	}

	return 0;
}



Measured memory_bytes: 3120
#include<stdio.h>
int dp[1001][1001]={0},C[1001],D[1001];
int main(){
	int n,m,i,j;
	scanf("%d%d",&n,&m);
	for(i=0;i<n;i++)scanf("%d",&C[i]);
	for(i=0;i<m;i++)scanf("%d",&D[i]);
	for(i=0;i<n+1;i++){
		for(j=i;j<m+1;j++){
			if(dp[i][j]+C[i]*D[j]<dp[i+1][j+1]||dp[i+1][j+1]==0)dp[i+1][j+1]=dp[i][j]+C[i]*D[j];
			if(dp[i][j+1]>dp[i][j]||dp[i][j+1]==0)dp[i][j+1]=dp[i][j];
		}
	}
	printf("%d\n",dp[n][m]);
	return 0;
}



Measured memory_bytes: 4888
#include<stdio.h>
 
int main(void){
  char c[5];
  scanf("%s",c);
  int w=0;
  if(c[0]=='R'){
    w++;
  }
  if(c[1]=='R'){
    w += 2;
  }
  if(c[2]=='R'){
    w +=4;
  }
  if(w==0){
    printf("0\n");
  }else if(w==1 || w==2 || w==4 || w==5){
    printf("1\n");
  }else if(w==3 || w==6){
    printf("2\n");
  }else{
    printf("3\n");
  }
  return 0;
}

Measured memory_bytes: 1612
object Main extends App {

  val Array(a,b,c,d) = scala.io.StdIn.readLine().split(" ").map(_.toLong)

  def solve(): Long = {
    b - (a-1) - calcCount(b, c, d) + calcCount(a-1, c, d)
  }

  def calcLCM(x: Long, y: Long): Long = {
    (x * y) /  calcGCD(x, y)
  }

  def calcGCD(x: Long, y: Long): Long = {
    if(y == 0) x
    else calcGCD(y, x % y)
  }

  def calcCount(target: Long, x: Long, y: Long): Long = {
    val lcm = calcLCM(x, y)
    (target / x) + (target / y) - (target / lcm)
  }


  println(solve)

}

Measured memory_bytes: 25560
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

#define rep(i,k,n) for(int (i)=(k);(i)<(n);(i)++)
#define max(a,b) (a)>(b)?(a):(b)
#define min(a,b) (a)<(b)?(a):(b)
#define abs(a,b) (a)< 0 ?(a):-(a)
#define llong long long

int main(){
	int N,M; scanf("%d %d",&N,&M);
	int H[N];
	rep(i,0,N) scanf("%d",&H[i]);
	int flag[N];
	rep(i,0,N) flag[i]=1;
	rep(i,0,M){
		int A,B; scanf("%d %d",&A,&B);
		A--; B--;
		if( H[A] <= H[B] ) flag[A]=0;
		if( H[B] <= H[A] ) flag[B]=0;
	}
	int ans=0;
	rep(i,0,N) if( flag[i] ) ans++;
	printf("%d",ans);
	return 0;
}


Measured memory_bytes: 2476
#include<bits/stdc++.h>
#define MAXN 200005
#define INF 1000000000
#define MOD 1000000007
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int n,a[MAXN],b[MAXN];
int main()
{
	scanf("%d",&n);
	ll s=0;
	int res=INF;
	bool f=true;
	for(int i=1;i<=n;i++) 
	{
		scanf("%d%d",&a[i],&b[i]);
		if(a[i]!=b[i]) f=false;
		s+=a[i];
		if(a[i]>b[i]) res=min(res,b[i]);
	}
	if(f) puts("0"); else printf("%lld\n",s-res);
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
	int a,b;
	while(1){
		cin >> a >> b;
		if(a==0&&b==0)
			break;
		if(a>b)
			swap(a,b);
		cout << a << " " << b << endl;
	}
return 0;
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
#define ll long long

using namespace std;

int n,k;
int matW[2048][2048];


int sum(int x, int y)
{
    if(x<0 || y<0)
        return 0;
    return matW[x][y];
}

int dodaj(int x2, int y2)
{
    int x1=x2-k+1;
    int y1=y2-k+1;
    if(x2<0 || x1>=2*k)
        return 0;
    if(y2<0 || y1>=2*k)
        return 0;

    if(x2>=2*k)
        x2=2*k-1;
    if(y2>=2*k)
        y2=2*k-1;

    if(x1<0)
        x1=0;
    if(y1<0)
        y1=0;

    return sum(x2,y2)-sum(x2,y1-1)-sum(x1-1,y2)+sum(x1-1,y1-1);
}

int solve(int xc, int yc)
{
    int suma=0;
    suma+=dodaj(xc,yc);
    suma+=dodaj(xc+2*k,yc);
    suma+=dodaj(xc+k,yc+k);
    suma+=dodaj(xc,yc+2*k);
    suma+=dodaj(xc+2*k,yc+2*k);
    suma+=dodaj(xc-k,yc+k);
    //cout<<"*"<<suma<<"   "<<xc<<" "<<yc<<endl;
    return suma;
}

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

	cin>>n>>k;
	int x,y;
	char c;
	for(int i=0;i<n;i++)
    {
        cin>>x>>y>>c;
        x=x%(2*k);
        y=y%(2*k);
        if(c=='W') matW[x][y]++;
        else matW[x][(y+k)%(2*k)]++;
    }
    /*for(int i=0;i<2*k;i++)
    {
        for(int j=0;j<2*k;j++)
            cout<<matW[i][j]<<" ";
        cout<<endl;
    }*/

    for(int i=1;i<2*k;i++)
    {
        matW[i][0]+=matW[i-1][0];
        matW[0][i]+=matW[0][i-1];
    }
    for(int i=1;i<2*k;i++)
        for(int j=1;j<2*k;j++)
            matW[i][j]=matW[i][j]+matW[i-1][j]+matW[i][j-1]-matW[i-1][j-1];

    int sol=0;
    for(int xc=0;xc<2*k;xc++)
        for(int yc=0;yc<k;yc++)
            sol=max(sol,solve(xc,yc));

    cout<<sol;

    /*for(int i=0;i<2*k;i++)
    {
        for(int j=0;j<2*k;j++)
            cout<<matW[i][j]<<" ";
        cout<<endl;
    }*/

	return 0;
}


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

using namespace std;

#define range(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  range(i,0,n)

int main(void){
	double d;
	cin >> d;
	double ans=d;
	int df=d/1.0;
	if(df>=1) ans=max<double>(ans,df+1);
	ans=max<double>(ans,2*sqrt(d*d/2));
	cout.precision(15);
	cout << fixed << ans << endl;
	return 0;
}

Measured memory_bytes: 1284
//Author:- S_Aditya

#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
using namespace std;
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
#define ll long long 
#define scn(n) scanf("%d",&n)
#define lscn(n) scanf("%lld",&n)
#define lpri(n) printf("%lld",n)
#define pri(n) printf("%d",n)
#define pln() printf("\n")
#define priln(n) printf("%d\n",n)
#define lpriln(n) printf("%lld\n",n)
#define rep(i,init,n) for(int i=init;i<n;i++)
#define pb push_back     
#define mp make_pair
#define F first
#define S second
#define gcd __gcd
#define inf INT_MAX
#define ninf INT_MIN
const ll mod=1e9+7;         
const int N=1e5+4;

//dp[i][j] tells the no. of ways to distribute total of j candies among the first i boys
//according to the given constraints.

ll dp[104][N];

int main()                  
{
    int n,k;
    
    scn(n); scn(k);
    
    int a[n];
    
    rep(i,0,n)
    scn(a[i]);
    
    dp[0][0]=1;
    
    rep(i,0,n)
    {
      	if(i)
        rep(j,1,k+1)
        dp[i][j]=(dp[i][j]+dp[i][j-1])%mod;
        
        rep(used,0,k+1)
        {
            int l=used,r=used+min(k-used,a[i]);
            
            dp[i+1][l]=(dp[i+1][l]+dp[i][used])%mod;
            
            dp[i+1][r+1]=(dp[i+1][r+1]-dp[i][used]+mod)%mod;
        }
    }
  	
  	rep(j,1,k+1)
    dp[n][j]=(dp[n][j]+dp[n][j-1])%mod;
        
    
    cout<<dp[n][k];
} 


Measured memory_bytes: 81764