akhauriyash/Code-Regression huggingface dataset:
// ਅਗਮਜੋਤ ਸਿੰਘ
// AGAMJOT SINGH

#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

// a_gamer

int power(int x, unsigned int y, int p) { 
    int res = 1;      // Initialize result 
  
    x = x % p;  // Update x if it is more than or  
                // equal to p 
  
    while (y > 0) 
    { 
        // If y is odd, multiply x with result 
        if (y & 1) 
            res = (res*x) % p; 
  
        // y must be even now 
        y = y>>1; // y = y/2 
        x = (x*x) % p;   
    } 
    return res; 
} 
  
int max(int a, int b){
    if (a > b)
        return a;
    else
        return b;
}
int maxSubArraySum(vector<int> &v){
    int size = v.size();
    int max_so_far = 0, max_ending_here = 0;
    int a[size];
    for (int i = 0; i < size; i++)
    {
        a[i] = v[i];
    }
    for (int i = 0; i < size; i++)
    {
        max_ending_here = max_ending_here + a[i];
        if (max_ending_here < 0)
            max_ending_here = 0;
        else if (max_so_far < max_ending_here)
            max_so_far = max_ending_here;
    }
    return max_so_far;
}
int NcR(int n, int r) { 
   
    long long p = 1, k = 1;  
    if (n - r < r) 
        r = n - r;  
    if (r != 0) {   
        while (r) { 
            p *= n; 
            k *= r;  
            long long m = __gcd(p, k);  
            p /= m; 
            k /= m;  
            n--; 
            r--; 
        }  
    }  
    else
        p = 1;  
    return p; 
}

signed main(){ 
    fastio;
    int n, k;
    cin >> n >> k;
    int arr[n];
    for(int i=0;i<n;i++){
        cin >> arr[i];
    }
    int dp[n];
    for(int i=0;i<n;i++){
        if(i == 0){
            dp[i] = 0;
        }
        else{
            // loop of k
            int temp = k , idx = i - 1 , mn = INT64_MAX;
            while(temp-- && idx>=0){
                mn =  min(abs(arr[idx] - arr[i]) + dp[idx], mn);
                idx--;
            }
            dp[i] = mn;
        }
    }
    cout << dp[n-1] << endl;
}

Measured memory_bytes: 1792
/**
    __author__ : srv_twry
**/

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

typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vll;
typedef pair<ll,ll> lll;

const ll MOD = 1000000007;
const ll INF = 1e9+5;
const double eps = 1e-7;
const double PI = acos(-1.0);

#define FOR(i,a,b) for(long long i = (long long)(a); i < (long long)(b); i++)
#define RFOR(i,a,b) for(long long i = (long long)(a); i >= (long long)(b); i--)
#define ull unsigned long long
#define deb(x )     cerr << #x << " = "<< x << endl;
#define endl    "\n"
#define coud(a,d) cout << fixed << showpoint << setprecision(d) << a;
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define fill(x, y) memset(x, y, sizeof(y))
#define all(x) (x).begin(), (x).end()

inline void debug_vi(vi a) {FOR(i, 0, a.size()) cout<<a[i]<<" ";}
inline void debug_vll(vll a) {FOR(i, 0, a.size()) cout<<a[i]<<" ";}

bool ge(const ll& a, const ll& b) { return a >= b; }
bool le(const ll& a, const ll& b) { return a <= b; }
bool eq(const ll& a, const ll& b) { return a == b; }
bool gt(const ll& a, const ll& b) { return a > b; }
bool lt(const ll& a, const ll& b) { return a < b; }
int sgn(const ll& x) { return le(x, 0) ? eq(x, 0) ? 0 : -1 : 1; }
/*----------------------------------------------------------------------*/

const int N = 1e5+5;
ll pos[N], p;

int main(){
    std::ios::sync_with_stdio(false);cin.tie(NULL); cout.tie(NULL);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
	int n; cin>>n;
	FOR(i, 0, n) {
		cin>>p; p--;
		pos[p] = i;
	}
	multiset<ll> ms; ms.insert(-1); ms.insert(-1); ms.insert(n); ms.insert(n);
	ll res = 0;

	// iterate in decreasing value.
	RFOR(i, n-1, 0) {
		ms.insert(pos[i]);
		auto itr = ms.find(pos[i]);
		ll s1,s2,b1,b2;
		--itr; s1 = *itr; // larger value to the left.
		--itr; s2 = *itr; // larger value to the left of the larger value.
		++itr; ++itr; ++itr;
		b1 = *itr; // larger value to the right.
		++itr; b2 = *itr;

		ll tmp = 1LL * (s1 - s2) * (b1 - pos[i]);
		tmp += 1LL * (b2 - b1) * (pos[i] - s1);

		res += tmp * (i + 1);
	}
	cout<<res;
    return 0;
}

Measured memory_bytes: 5760
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>

using namespace std;
typedef long long ll;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, f, n) for (ll i = (f); i < (n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define repv(v) for (auto it = (v).begin(); it != (v).end(); it++)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define INIT    \
    cin.tie(0); \
    ios::sync_with_stdio(false);

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

ll const INF = 1LL << 60;
ll const MOD = 1000000007;

ll const MAX_V = 100005;

struct edge {
    ll to, cost;
};
vector<edge> G[MAX_V];

int main() {
    INIT;

    ll N, M;
    cin >> N >> M;

    for (ll i = 0; i < M; i++) {
        // sからtへの辺を張る
        ll s, t;
        cin >> s >> t;
        s--;
        t--;
        edge et = {t, 1};
        G[s].push_back(et);

        // 無向グラフの場合はさらにtにsへの辺を張る
        edge es = {s, 1};
        G[t].push_back(es);
    }

    // 探索
    vector<ll> prev_v(N, -1);
    queue<ll> que;

    prev_v[0] = -1;
    que.push(0);

    while (!que.empty()) {
        int v = que.front();
        que.pop();

        for (auto nv : G[v]) {
            if (nv.to == v) continue;

            if (prev_v[nv.to] != -1) continue;
            prev_v[nv.to] = v;
            que.push(nv.to);
        }
    }

    bool flg = true;
    rep(i, N) {
        if (prev_v[i] == -1) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    reps(i, 1, N) { cout << prev_v[i] + 1 << endl; }

    // rep(i, N) { cout << i << ": " << prev_v[i] << endl; }

    return 0;
}

Measured memory_bytes: 16864
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    boolean judgeA = false;
    boolean judgeB = false;
    boolean judgeC = false;
    for (int i = 0; i < s.length(); i++) {
      if (s.charAt(i) == 'a') {
        judgeA = true;
      }else if (s.charAt(i) == 'b') {
        judgeB = true;
      }else if (s.charAt(i) == 'c') {
        judgeC = true;
      }
    }
    System.out.println(judgeA && judgeB && judgeC ? "Yes" : "No");
  }

}


Measured memory_bytes: 23380
import java.util.Scanner;

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

    int cou = 0;
    for(int i=0; i<2; i++) {
	   if(ss[i]=='9') {
		   cou++;
	   }
    }
    if(cou==0) {
    System.out.println("No");
    }else{
        System.out.println("Yes");
    }
}
}

Measured memory_bytes: 35732
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n); i > 0; i++)

using ll=long long;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  int a=0, b=0;
  rep(x,s.size()){
    if(s[x]=='0') a++;
    if(s[x]=='1') b++;
  }
  cout << min(b,a) *2 << endl;
}


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

int const N=4e2+5, M=1e5+5, /*OO = 0x3f3f3f3f,*/ MOD=1e9+7;
long long const OO = 0x3f3f3f3f3f3f3f3f;
int n;
long long arr[N];

long long mem[N][N];
long long solve(int s, int e)
{
    if(s==e)
        return 0;
    if(mem[s][e]!=-1)
        return mem[s][e];
    long long ret=OO;
    for(int i=s; i<e; i++)
        ret=min(ret,solve(s,i)+solve(i+1,e)+arr[e]-arr[s-1]);
    return mem[s][e]=ret;
}


int main()
{
//    freopen("input.txt","rt",stdin);
//    freopen("output.txt","wt",stdout);
    scanf("%d",&n);

    for(int i=1; i<=n; i++)
    {
        scanf("%lld",arr+i);
        arr[i]+=arr[i-1];
    }
    memset(mem, -1, sizeof mem);
    printf("%lld\n",solve(1,n));


}


Measured memory_bytes: 1536
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  int a[n];
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  for(int i=0;;i++){
    for(int j=0;j<n;j++){
      if(a[j]%2!=0){
        cout<<i;
        return 0;
      }else a[j]/=2;
    }
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<queue>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

typedef long long ll;
const ll INF = 1e17;



int main() {

	int N;
	cin >> N;

	string s[110000];

	string t;

	for (int i = 1; i <= N; i++) {
		cin >> s[i];

		for (int k = 1; k < 10; k++) {
			for (int j = k - 1; j >= 0; j--) {
				if (s[i][j] < s[i][j+1]) { swap(s[i][j], s[i][j+1]); }
			}
		}

		

	}

	sort(s+1, s + N+1);

	ll ans = 0;

	ll conseq = 0;
	for (int i = 1; i < N; i++) {

		
		if (s[i+1] == s[i]) {

			conseq++;
			ans += conseq;
		}

		else { conseq = 0; }
	}

	cout << ans;
	

	system("PAUSE");


}


Measured memory_bytes: 7552
import sys

K = int(input())
s = [1,2,3,4,5,6,7,8,9,10,11,12,21,22,23,32,33,34,43,44,45,54,55,56,65,66,67,76,77,78,87,88,89,98,99]

if K <= 35:
  print(s[K-1])
  sys.exit()

heads = ["10","11","12","21","22","23","32","33","34","43","44","45","54","55","56","65","66","67","76","77","78","87","88","89","98","99"]
s = len(heads)
dic={0:[0,1],1:[0,1,2],2:[1,2,3],3:[2,3,4],4:[3,4,5],
     5:[4,5,6],6:[5,6,7],7:[6,7,8],8:[7,8,9],9:[8,9]}


i = 0
K = K-10
while True:
  lenHeads = len(heads)
  if lenHeads-1 >= K:
      print(int(heads[K]))
      sys.exit()
  now = heads[i]
  tail = now[-1]
  values = dic[int(tail)]
  for v in values:
      newHead = "".join([now,str(v)])
      heads.append(newHead)
  i+=1

Measured memory_bytes: 10156
#include <bits/stdc++.h>
using namespace std;
typedef int64_t ll;
using P   = pair<ll, ll>;
using mat = vector<vector<ll>>;

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

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

ll mod(ll a) {
    if (a > 0) return a % MOD;
    if (a % MOD == 0) return 0;
    ll x = -a / MOD + 1;
    a += x * MOD;
    return a % MOD;
}

template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
    fill((T *)array, (T *)(array + N), val);
}
// int dx[4]    = {1, 0, -1, 0};
// int dy[4]    = {0, 1, 0, -1};
// ll pas[5001][5002];

ll dp[403][403] = {};
ll a[402], s[403] = {};

ll rec(int i, int j) {
    if (~dp[i][j]) return dp[i][j];
    ll &tmp = dp[i][j];
    if (i == j) return tmp = 0;
    tmp = INF;
    for (int k = i; k < j; ++k) { tmp = min(tmp, rec(i, k) + rec(k + 1, j)); }
    tmp += s[j] - s[i - 1];
    return tmp;
}

signed main() {
    IOS();
    ll n;
    cin >> n;
    Fill(dp, -1);
    s[0] = 0;
    for (int i = 1; i <= n; ++i) {
        cin >> a[i];
        s[i] = s[i - 1] + a[i];
    }
    ll ans = rec(1, n);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1536
#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 <cstdalign>
#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

using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; i++)
#define out(ans) cout << ans << endl;

int main()
{
  ll a, b;
  cin >> a >> b;
  if((a+b)%2==0){
    out((a + b) / 2);
  }
  else cout << "IMPOSSIBLE" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
typedef int64_t Int;

int main(){
    Int N, A, B, C, D;
    cin >> N >> A >> B >> C >> D;

    rep(i,N-1){ // 
        Int L = C*(N-1-i) - D*i;
        Int R = D*(N-1-i) - C*i;

        if(L <= B-A && B-A <= R){
            cout << "YES" << endl; return 0;
        }
    }

    cout << "NO" << endl;
}


Measured memory_bytes: 256
"""解説から
1.  A, B, Cの総和をabcとする。
2.  可能な操作は2種類あるが、abcの増加は必ず2になる
3.  2の前提からabcの偶奇を変更することはできない
4.  A, B, Cそれぞれに操作を加えて、A==B==Cとなった時、それぞれの値をXとする
5.  A, B, Cのいずれの値も減少させることはできないので、max(A, B, C)<=Xとなる
6.  abcの総和を3Xにできるとき、そのXが最終的なA, B, Cの値となる
7.  3と6の前提から、Xとabcの偶奇は一致している必要がある
8.  XとX+1の偶奇は異なるので、Xで無理ならX+1が最終的なA, B, Cの値となる
9.  A, B, Cのいずれかに増加させる値の総和は3X-abcで求めることができる
10. 2と9の前提から操作回数は(3X-abc)//2で求めることができる
"""
ABC = tuple(map(int, input().split()))
abc = sum(ABC)  # 1
X = max(ABC)  #4, 5
if X % 2 != abc % 2:  # 7
    X += 1  # 8
ans = (3 * X - abc) // 2  # 10
print(ans)


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

#define int long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define dbg(x) cerr << #x << ": " << x << endl;
#define dbg2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define dbg3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define dbgB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const double PI = 3.14159265358979323846;

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 T>
void print1(T begin, T end) {
  while (begin != end) {
    cout << (*begin) << " ";
    *begin++;
  }
  cout << endl;
}

template<typename T>
void print2(T Array, int height, int width) {
  for (int i = 0; i < height; i++) {
    for (int j = 0; j < width; j++) {
      cout << " " << Array[i][j];
    }
    cout << endl;
  }
}

// ------------------------------------------------------------------------------------------

signed main() {
  vec<int> v(4);
  rep (i, 4) {
    cin >> v[i];
  }
  sort(all(v));
  if (v[0] == 1 && v[1] == 4 && v[2] == 7 && v[3] == 9) {
    puts("YES");
  } else {
    puts("NO");
  }

  return 0;
}

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


int main() {
  int n;
  cin >> n;
  int i = n/111;
  if (n%111 != 0) ++i;
  cout << i*111 <<endl;
  return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;

using System.IO;

class _Class
{
	void _Do()
  {
		//
		var Na = _int();

		var N_人=Na[0];
		var T_秒 = Na[1];

		var t_押す = _int();
		int sum = 0;
		for (int i = N_人 - 1; i >= 0; i--)
		{
			if (i == N_人 - 1)
				sum += (T_秒);
			else
			{
				var a = (t_押す[i + 1] - t_押す[i]);
				sum += Math.Min(T_秒,a);
			}
		}
		Console.WriteLine(sum);
	}

	static void Main(string[] args)
  {
    new _Class()._Do();
  }

#region

  string _string()
  {
    return Console.ReadLine();
  }

	//
	string[] _strings()
  {
    return Console.ReadLine().Split();
  }

  int[] _int(int n)
  {
    var x = new int[n];
    for (var i = 0; i < n; i++)
    {
      x[i] = int.Parse(Console.ReadLine());
    }
    return x;
  }

	//
	int[] _int()
  {
    var ss = Console.ReadLine().Split();

    var x = new int[ss.Length];
    for (var i = 0; i < ss.Length; i++)
      x[i] = int.Parse(ss[i]);

    return x;
  }

	long[] _long()
	{
		var ss = Console.ReadLine().Split();

		var x = new long[ss.Length];
		for (var i = 0; i < ss.Length; i++)
			x[i] = long.Parse(ss[i]);

		return x;
	}
#endregion

}


Measured memory_bytes: 28256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const ll INF = LLONG_MAX;

int main()
{
    string a[] = {"dream", "dreamer", "erase", "eraser"};
    string s;
    cin >> s;
    for (int i = 0; i < 4; i++)
        reverse(a[i].begin(), a[i].end());
    int i = 0;
    reverse(s.begin(), s.end());
    while (i < s.length())
    {
        int tmp = i;
        for (int j = 0; j < 4; j++)
        {
            if (s.compare(i, a[j].length(), a[j], 0, a[j].length()) == 0)
            {
                i += a[j].length();
                break;
            }
        }
        if (tmp == i)
        {
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
}


Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <string.h>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <stdio.h>
#include <vector>
#define int long long
#define endre getchar();getchar();return 0
#define moder 1000000007
#define inf 1000000000000000000
#define rep(i,n) for(int i=0;i<n;i++)
#define P pair<int,int>
#define all(v) v.begin(),v.end()
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;

class segment_tree {
	int dat[1000005];
	int whi;
public:
	segment_tree(int &x,int y) {
		whi = y;
		if (whi != 0 && whi != 1 && whi != 2)exit(0);
		int s = x;
		x = 1;
		while (1) {
			x *= 2;
			if (s <= x)break;
		}
		if (!whi) {
			rep(i, x * 2 - 1)dat[i] = ((int)(1) << 31) - 1;
		}
		else if (whi == 1) {
			rep(i, x * 2 - 1)dat[i] = -(((int)(1) << 31) - 1);
		}
	}
	void update(int k, int a, int x) {
		k += x;
		if (whi != 2)dat[k] = a;
		else dat[k] += a;
		while (k > 0) {
			k = (k - 1) / 2;
			if (!whi)dat[k] = min(dat[k * 2 + 1], dat[k * 2 + 2]);
			else if (whi == 1)dat[k] = max(dat[k * 2 + 1], dat[k * 2 + 2]);
			else dat[k] = dat[k * 2 + 1] + dat[k * 2 + 2];
		}
	}
	int query(int a, int b, int x, int l, int r) {
		if (r < a || b < l) {
			if (!whi)return inf;
			else if (whi == 1)return -inf;
			else return 0;
		}
		if (a <= l && b >= r)return dat[x];
		int vl = query(a, b, x * 2 + 1, l, (l + r) / 2);
		int vr = query(a, b, x * 2 + 2, (l + r) / 2 + 1, r);
		if (!whi)return min(vl, vr);
		else if (whi == 1)return max(vl, vr);
		else return vl + vr;
	}
};
signed main() {
	int n, q;
	cin >> n >> q;
	static segment_tree segtree(n, 2);
	rep(i, q) {
		int a, b, c;
		cin >> a >> b >> c;
		if (a) {
			b--; c--;
			cout << segtree.query(b, c, (int)0, (int)0, n - 1) << endl;
		}
		else {
			b--;
			segtree.update(b, c, n - 1);
		}
	}
	endre;
}


Measured memory_bytes: 4708
h, w = map(int, input().split())
v = []
for i in range(h):
    v.append(input())

ans = [[-1 for i in range(w)] for j in range(h)]

for i in range(h):
    for j in range(w):
        if v[i][j] == '#':
            continue
        cnt = 0
        for dy in range(-1, 2):
            for dx in range(-1, 2):
                if dy == 0 and dx == 0:
                    continue
                ny = i + dy
                nx = j + dx
                if ny < 0 or ny >= h or nx < 0 or nx >= w:
                    continue
                if v[ny][nx]=='#':
                    cnt+=1
        ans[i][j] = cnt

for i in range(h):
    for j in range(w):
        if j==w-1:
            if ans[i][j]==-1:
                print('#')
            else:
                print(ans[i][j])
        else:
            if ans[i][j]==-1:
                print('#',end="")
            else:
                print(ans[i][j],end="")


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

typedef long long LL;
int main()
{
    LL a, b, top, top2, ans=0;
    bool flag = false;
    scanf("%lld%lld",&a,&b);
    if(a == b)
        return 0*puts("1");
    for(LL i=60; i>=0; --i)
    {
        if(b>>i&1 && !(a>>i&1))
        {
            top = i;
            break;
        }
        if(a>>i&1) a ^= 1LL<<i;
    }
    for(LL i=top-1; i>=0; --i)
    {
        if(b>>i&1)
        {
            flag = true;
            top2 = i;
            ans += (1LL<<i+1)-1;
            break;
        }
    }
    ans += ((1LL<<top)-a)<<1;
    if(flag && a <= (1LL<<top2+1)-1) ans -= (1LL<<top2+1)-a;
    printf("%lld\n",ans+(top!=0));
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <cctype>
#include <cmath>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <list>
#include <stdio.h>
#include <string.h>
#include <cstdlib>
#include <math.h>
#include <bitset>
#include <iterator>
#define INF 2000000000
using namespace std;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
#define ll long long
#define PL pair<long long, long long>
#define P pair<int,int>
#define mk make_pair
#define en endl
#define WHITE 0
#define BLACK 2
#define GRAY 1
#define RE return 0
#define int ll

#define MAX 10005

signed main(){
  set<int> set;
  int n;
  int a[MAX];
  cin>>n;
  for(int i=1; i<=10000; i++){
    set.insert(i);
  }
  for(int i=0; i<n; i++) {
    cin>>a[i];
    set.erase(a[i]);
  }
  
  int ans=0;
  for(int i=1; i<n; i++){
    if(a[i]==a[i-1]){
      a[i]=*set.begin();
      set.erase(*set.begin());
      ans++;
    }
  }
  
  cout<<ans<<en;
  
  RE;
}


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

int main(void){
    int n;
    cin >> n;
    vector<int> p(n);
    rep(i,n) cin >> p[i];
    int cnt = 0;
    for(int i = 1; i < n-1; i++) {
        if (min({p[i-1], p[i], p[i+1]}) != p[i] &&
            max({p[i-1], p[i], p[i+1]}) != p[i]) cnt++;
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 256
# @author 

import sys

class BProductMax:
    def solve(self, tc=0):
        a, b, c, d = [int(_) for _ in input().split()]
        ans = max(b * d, a * c, a * d, b * c)
        print(ans)


solver = BProductMax()
input = sys.stdin.readline

solver.solve()


Measured memory_bytes: 61688
#include <bits/stdc++.h>
//#include <atcoder/all>
#define rep(i, n) for (int i=0; i < (n); i++)
using namespace std;
//using namespace atcoder;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> P;
const int INF = 1 << 30;
const ll LINF = 1LL << 61;
const int NIL = -1;
const int MAX = 10000;
const int MOD = 1000000007;
const double pi = 3.141592653589;

int main() {
    int n;
    cin >> n;
    int s = 0;
    int n_ = n;
    while(n_!=0){
        s += n_ % 10;
        n_ /= 10;
    }
    if (n % s == 0) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3540
n=int(input())
a=[i for i in input().split()]

b=[]
c=[]
if n%2==0:
    for i in range(n):
        if i%2==0:
            b.append(a[i])
        else:
            c.append(a[i])
else:
    for i in range(n):
        if i%2==0:
            c.append(a[i])
        else:
            b.append(a[i])
c=c[::-1]
print(" ".join(c)+" "+" ".join(b))

Measured memory_bytes: 27664
#include<cstdio>
using namespace std;
char s1[10001],s2[10001];
int main()
{
	int n;
	scanf("%s%s",s1,s2);
	if(s1[0]==s2[2]&&s1[1]==s2[1]&&s1[2]==s2[0])
	{
		printf("YES\n");
		return 0;
	}
	printf("NO\n");
	return 0;
}

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

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int k = in.nextInt();
		int q = in.nextInt();

		int[] point = new int[n + 1]; // i番目の選手のポイント
		boolean[] result = new boolean[n + 1];
		Arrays.fill(point, -q+k);

		for ( int i = 1; i <= q; i++ ) {
			int num = in.nextInt();
			point[num]++;
			if ( point[num] > 0 ) result[num] = true;
		}

		for ( int i = 1; i <= n; i++ ) {
			if ( point[i] > 0 ) System.out.println("Yes");
			else System.out.println("No");

		}
		
//		for ( int i = 1; i <= n; i++ ) {
//			System.out.println(point[i]);
//		}

		in.close();
	}
}

Measured memory_bytes: 55704
#include<string>
#include<string.h>
#include<map>
#include<set>
#include<vector>
#include<stdio.h>
#include<math.h>
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;
int a,b,sum,c,t;
int main()
{
  cin>>a>>b;
  t=b;
  for(;;t/=10)
  {
    sum++;
    if(t==0)break;
  }
  for(int i=1;i<sum;i++)a=a*10;
  c=a+b;
  for(int i=1;i<=c;i++)
  {
     int ans=i*i;
     if(c==ans)
     {
       cout<<"Yes";
       system("pause");
       return 0;
     }
  } 
  cout<<"No";
  system("pause");
  return 0;
}

Measured memory_bytes: 504
"use strict"
function main(arg) {
    arg = arg.trim().split("\n")
    arg.shift()
    let data = arg.map(e => {
        var row = e.split(" ").map(Number)
        return [row[0]-row[1], row[1]+row[0]]
    }).sort((a, b) => {
        return a[1] - b[1]
    })
    let sum = 0;
    let P = Number.MIN_SAFE_INTEGER;
    for (var i=0; i<data.length; i++) {
        if (P <= data[i][0]) {
            sum++
            P = data[i][1]
        }
    }
    console.log(sum)
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 54384
import java.util.Scanner;

public class Main { 
	 // 必要があればインスタンス変数を宣言する 
	 // 一つ以上のメソッドを定義すること 
	 
		public void vote (int [][]sn,int [] ol){
			for(int i=0;i<ol.length;i++){
				for(int j=0;j<sn.length;j++){
					if(ol[i]>=sn[j][0]) {
						sn[j][1]++;
						break;
					}
				}
			}
		}
		
		public int max(int [][] sn){
			int max=sn[0][1];
			int maxn=1;
			for(int i=0;i<sn.length;i++){
				if(max<sn[i][1]){
					max=sn[i][1];
					maxn=i+1;
				}
			}
			return maxn;
		}
		
	 void doIt( ) { 
	 // これまでは main メソッドで処理していた内容を書く 
	 // クラス内で定義した一つ以上のメソッドを呼び出すこと 
		 Scanner sc=new Scanner(System.in);
			int i;
			int s=sc.nextInt();
			int o=sc.nextInt();
			
			int [][]sn = new int [s][2];
			int []ol = new int [o];

			for(i=0;i<s;i++){
				int m=sc.nextInt();
				sn[i][0]=m;
				sn[i][1]=0;
				
			}
			
			for(i=0;i<o;i++){
				int e=sc.nextInt();
				ol[i]=e;
				
			} 
			
			vote(sn,ol);
			
			
			System.out.printf("%d\n",max(sn));
	 } 
	 public static void main(String [ ] args) { 
		 new Main( ) . doIt( ); 
		 } 
	 } 

Measured memory_bytes: 23528
N = int(input())
A = [int(i) for i in input().split()]

""" 広義 """

cnt = 1
flag = 0 # 0:未定、1:増加、-1:減少
for i,a in enumerate(A):
    if i == 0:
        prev = a
        continue

    if flag == 0:
        if prev == a: pass
        elif prev > a: flag = -1
        else: flag = 1
    elif flag > 0:
        if prev <= a: pass
        else:
            cnt += 1
            flag = 0
    else:
        if prev >= a: pass
        else:
            cnt += 1
            flag = 0
    prev = a

print(cnt)

Measured memory_bytes: 14252
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <map>

using namespace std;

int n,W,Ans;
int w[110],v[110],len[5];
int a[5][110],pre[5][110];

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

inline int calc(int a,int b,int c){
  return min((W-a*w[1]-b*(w[1]+1)-c*(w[1]+2))/(w[1]+3),len[3]);
}

int main(){
  scanf("%d%d",&n,&W);
  for(int i=1;i<=n;i++) scanf("%d%d",&w[i],&v[i]);
  for(int i=1;i<=n;i++) a[w[i]-w[1]][++len[w[i]-w[1]]]=v[i];
  for(int i=0;i<4;i++) sort(a[i]+1,a[i]+1+len[i],cmp);
  for(int i=0;i<4;i++)
    for(int j=1;j<=len[i];j++) pre[i][j]=pre[i][j-1]+a[i][j];
  for(int A=0;A<=len[0];A++)
    for(int B=0;B<=len[1];B++)
      for(int C=0;C<=len[2];C++)
	if(1ll*A*w[1]+1ll*B*(w[1]+1)+1ll*C*(w[1]+2)<=W)
	  Ans=max(Ans,pre[0][A]+pre[1][B]+pre[2][C]+pre[3][calc(A,B,C)]);
  printf("%d\n",Ans);
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>

using namespace std;

int main() {
    int i, n, K;
    vector<int> ABC;
    for (i=0;i<3;i++) {
        int tmp;
        cin >> tmp;
        ABC.push_back(tmp);
    }
    cin >> K;
    sort(ABC.begin(), ABC.end());
    for (n=0;n<K;n++) {
        ABC[2] = ABC[2]*2;
    }
    cout << accumulate(ABC.begin(), ABC.end(),0) << endl;
    return 0;
}

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

ll N, M;
bool E[700][700];
bool used[700];
ll color[700];

bool dfs(ll v, ll x) {
  if(used[v]) return color[v] == x;
  used[v] = true;
  color[v] = x;

  bool ok = true;
  REP(u, 0, N) if(E[u][v]) {
    ok = dfs(u, -x) && ok;
  }
  return ok;
}

int main(void) {
  cin >> N >> M;
  REP(i, 0, N) REP(j, 0, N) E[i][j] = false;
  REP(i, 0, M) {
    ll u, v; cin >> u >> v; u--; v--;
    E[u][v] = true;
    E[v][u] = true;
  }

  REP(i, 0, N) REP(j, 0, N) if(i != j) E[i][j] = !E[i][j];

  ll cnt = 0;
  REP(i, 0, N) REP(j, i + 1, N) if(E[i][j]) cnt++;

  REP(i, 0, N) used[i] = false;
  bool ok = true;
  ll k = 1;
  REP(i, 0, N) if(!used[i]) ok = dfs(i, k++) && ok;

  if(!ok) {
    cout << -1 << endl;
    return 0;
  }

  map<ll, pll> mp;
  REP(i, 0, N) {
    ll c = color[i];
    if(c > 0) mp[c].first++;
    else mp[-c].second++;
  }

  vector<pll> vec;
  for(auto p : mp) vec.push_back(p.second);

  vector<vector<bool>> dp(vec.size() + 1, vector<bool>(N + 1));
  dp[0][0] = true;
  REP(i, 0, vec.size()) REP(j, 0, N) if(dp[i][j]) {
    if(j + vec[i].first <= N) dp[i + 1][j + vec[i].first] = true;
    if(j + vec[i].second <= N) dp[i + 1][j + vec[i].second] = true;
  }

  ll ans = 1LL << 50;
  REP(i, 0, N + 1) if(dp[vec.size()][i]) {
    ll s = i, t = N - i;
    ans = min(ans, M - s * t + cnt);
  }
  cout << ans << endl;
}

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

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP0(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REP1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)

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

const int INTINF = int(1e9) + 1;
const LL LLINF   = LL(1e18) + 1;
#define pow10(n) int(1e##n + n)

// インデックスで管理するものと思う
struct UnionFind
{
    std::vector<int> rank, p, cnt;

    UnionFind(){};
    UnionFind(int size)
    {
        init(size);
    }

    void init(int size)
    {
        rank.resize(size, 0);
        p.resize(size, 0);
        cnt.resize(size, 0);
        for (int i = 0; i < size; i++) makeSet(i);
    }

    void makeSet(int x)
    {
        p[x]    = x;
        rank[x] = 0;
        cnt[x]  = 1;
    }

    bool same(int x, int y)
    {
        return findSet(x) == findSet(y);
    }

    void unite(int x, int y)
    {
        if (same(x, y))
            return;
        link(findSet(x), findSet(y));
    }

    void link(int x, int y)
    {
        if (rank[x] > rank[y])
        {
            p[y] = x;
            cnt[x] += cnt[y];
        }
        else
        {
            p[x] = y;
            cnt[y] += cnt[x];
            rank[y] += (rank[x] == rank[y]);
        }
    }

    int findSet(int x)
    {
        if (x != p[x])
        {
            p[x] = findSet(p[x]);
        }
        return p[x];
    }

    int setSize(int x)
    {
        return cnt[findSet(x)];
    }
};
vector<int> friends[pow10(5)];
vector<int> blocks[pow10(5)];
UnionFind ds;

void solve()
{
    int N, M, K;
    cin >> N >> M >> K;
    ds.init(N + 1);

    REP0 (i, M)
    {
        int A, B;
        cin >> A >> B;
        ds.unite(A, B);
        friends[A].push_back(B);
        friends[B].push_back(A);
    }

    REP0 (i, K)
    {
        int C, D;
        cin >> C >> D;
        blocks[C].push_back(D);
        blocks[D].push_back(C);
    }

    REP1 (i, N)
    {
        int ans = ds.setSize(i) - 1;
        for (auto blk : blocks[i]) ans -= ds.same(i, blk);

        ans -= friends[i].size();
        std::cout << ans;
        if (i != N)
            std::cout << " ";
    }
    std::cout << endl;
}

int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(10);
    solve();
    return 0;
}


Measured memory_bytes: 13048
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <iomanip>
#include <cmath>
#include <vector>
#include <set>
#include <algorithm>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
using namespace boost::multiprecision;
const unsigned long long INF = 1000000000000000000;

int main()
{
    int N;
    cin >> N;
    vector<unsigned long long> A(N);
    for (int i = 0; i < N; i++)
    {
        cin >> A[i];
        if(A[i] == 0){
            cout << 0 << endl;
            return 0;
        }
    }
    cpp_int sum = 1;
    for (int i = 0; i < N; i++)
    {
        sum *= A[i];
        if(sum > INF){
            cout << -1 << endl;
            return 0;
        }
    }

    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 4048
fn main() {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    let v : Vec<i32> = s.trim().split_whitespace().map(|e| e.parse().ok().unwrap()).collect();
    let x = v[0] + v[1];
    let y = v[2] + v[3];
    if x > y {
        println!("Left");
    }
    else if x == y {
        println!("Balanced");
    }
    else {
        println!("Right");
    }
}


Measured memory_bytes: 4352
from collections import deque
K = int(input())
q = deque([i for i in range(1, 10)])

# print(q)
for i in range(K):
    x = q.popleft()
    if x % 10 != 0:
        q.append(10*x+x % 10-1)
    q.append(10*x+x % 10)
    if x % 10 != 9:
        q.append(10*x+x % 10+1)

print(x)


Measured memory_bytes: 74780
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
using namespace std;
#define rep(i,a,b) for(int64_t i=(a); i<(b); ++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int64_t i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define INF 10000000000000
#define MOD 1000000007LL
#define RANGE(a,b,c) (a).begin()+(b),(a).begin()+(c) // [b,c) イテレータ
using PII = pair<int64_t, int64_t>;
using VI = vector<int64_t>;
using VVI = vector<VI>;
using VS = vector<string>;
using VP = vector<PII>;
using i64 = int64_t;
// input vector
template<typename T>
void invec(vector<T> &A){for(T& a : A) cin >> a;}


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

int K, X; cin >> K >> X;

if (500 * K >= X) cout << "Yes\n";
else cout << "No\n";

}
// 書いて考える．場合分け
// 境界，出力文字列 チェック．行末にスペース入れない．
// 可読性優先．高速化次点．
// まずは全探索，次にDP
// 制限を見る．境界に注意．求めたい量の変域．動かせる量．
// 偶奇，逆から，ソート，出現回数，出現位置，DP， 余事象，包除
// データ構造． 問題の特徴量．単調性，二分探索
// 存在判定：構成方法，入力の特徴
// gcd, lcm ,素因数分解．
// 例外を十分に含む一般化．想像力の限界
// 小さい系から例示
// 代数的処理．前処理によるクエリ高速化．
// 始めは過剰に例示・場合分けしてもいい．各場合を確実に対処．
// 自明な例から処理，除外．
// 小数のときは，精度の設定する．doubel 変数に数値を入力するときは 123. とする．
// テストケース作成は数表あり
// 実行エラー：vector添え字超え．0割り．



Measured memory_bytes: 256
#include	<iostream>

using namespace std;

int		S[100'000];

bool	Search(int match, int l, int r)
{
	if (l > r)
	{
		return false;
	}

	int		m = (l + r) / 2;
	if (match == S[m])
	{
		return true;
	}

	if (match < S[m])
	{
		return Search(match, l, m - 1);
	}
	else
	{
		return Search(match, m + 1, r);
	}
}

int main()
{
	int		n;
	cin >> n;
	for (int i = 0; i < n; ++i)
	{
		cin >> S[i];
	}

	int		cnt = 0;
	int		q;
	cin >> q;
	for (int i = 0; i < q; ++i)
	{
		int		temp;

		cin >> temp;
		if (Search(temp, 0, n - 1))
		{
			++cnt;
		}
	}

	cout << cnt << endl;

	return 0;
}

Measured memory_bytes: 3380
import java.util.*;
import java.io.*;
public class Main {
    public static void main(String[] args) throws IOException{
    	// Solution sol = new Solution();
    	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    	StringTokenizer st = new StringTokenizer(br.readLine());
    	int N = Integer.parseInt(st.nextToken());
    	double k = (double)N/3;
    	System.out.println(Math.pow(k,3));

    }
}

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

int main() {

    int r;
    cin >> r;

    cout << 3 * r * r << endl;

    return 0;
}

Measured memory_bytes: 3600
# coding: utf-8
 
import sys
import math
from collections import Counter
import itertools
import fractions
#import numpy as np
#from functools import reduce
 
# 入力を整数に変換して受け取る
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
# 入力全てを整数に変換したものの配列を受け取る
def LI(): return list(map(int, sys.stdin.readline().split()))
# 入力全てを整数に変換して1引いたものの配列を受け取る
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SR(): return sys.stdin.readline().rstrip()
 
ascii_lowercase = 'abcdefghijklmnopqrstuvwxyz'
ascii_uppercase = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
ascii_uppercase2 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ'
 
# リストを改行区切りで出力する
p2D = lambda x: print(*x, sep="\n")
p2E = lambda x: print(''.join(x))
p2S = lambda x: print(*x, sep=" ")
 
# ###########################################
n=II()
A=LI()
 
ans = 1

if 0 in A:
    print(0)
    exit()

for a in A:
    ans *= a
    if ans > 1000000000000000000:
        print(-1)
        exit()
 
if ans > 1000000000000000000:
    print(-1)
else:
    print(ans)

Measured memory_bytes: 23992
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        
        int n = Integer.parseInt(sc.next());
        Card[] a = new Card[n];
        for(int i = 0; i < n; i++){
            a[i] = new Card(sc.next().charAt(0), Integer.parseInt(sc.next()));
        }
        Card[] a2 = a.clone();
        
        quicksort(a, 0, n-1);
        mergeSort(a2, 0, n);
        boolean stable = true;
        for(int i = 0; i < n; i++){
            if(a[i].suit != a2[i].suit){
                stable = false;
                break;
            }
        }
        
        if(stable){
            System.out.println("Stable");
        }else{
            System.out.println("Not stable");
        }
        StringBuilder sb = new StringBuilder();
        for(int i = 0; i < n; i++){
            sb.append(a[i].suit).append(" ").append(a[i].value).append(System.lineSeparator());
        }
        System.out.print(sb);
    }
    
    static void quicksort(Card[] a, int p, int r){
        
        if(p < r){
            int q = partition(a, p, r);
            quicksort(a, p, q-1);
            quicksort(a, q+1, r);
        }
    }
    
    static int partition(Card[] a, int p, int r){
        
        int x = a[r].value;
        int i = p-1;
        for(int j = p; j < r; j++){
            if(a[j].value <= x){
                i++;
                Card k = a[i];
                a[i] = a[j];
                a[j] = k;
            }
        }
        Card k = a[i+1];
        a[i+1] = a[r];
        a[r] = k;
        return i+1;
    }
    
    static void merge(Card[] a, int left, int mid, int right){
        
        int n1 = mid - left;
        int n2 = right - mid;
        Card[] l = new Card[n1 +1];
        Card[] r = new Card[n2 +1];
        for(int i = 0; i < n1; i++){
            l[i] = a[left +i];
        }
        for(int i = 0; i < n2; i++){
            r[i] = a[mid +i];
        }
        l[n1] = new Card('M', Integer.MAX_VALUE);
        r[n2] = new Card('M', Integer.MAX_VALUE);
        int i = 0;
        int j = 0;
        for(int k = left; k < right; k++){
            if(l[i].value <= r[j].value){
                a[k] = l[i];
                i++;
            }else{
                a[k] = r[j];
                j++;
            }
        }
    }
    
    static void mergeSort(Card[] a, int left, int right){
        
        if(left+1 < right){
            int mid = (left + right)/2;
            mergeSort(a, left, mid);
            mergeSort(a, mid, right);
            merge(a, left, mid, right);
        }
    }
    
    static class Card {
        char suit;
        int value;

        public Card(char suit, int value) {
            this.suit = suit;
            this.value = value;
        }
    }
}


Measured memory_bytes: 76504
#include<stdio.h>
main(){
	int n,m;
	int MAX_N = 100;
	int MAX_M = 100;
	int a[MAX_N][MAX_M];
	int b[MAX_M];
	int c[MAX_N];
	int i,j;

	scanf("%d %d",&n,&m);
	for(i=0;i<n;i++){
		for(j=0;j<m;j++){
			scanf("%d",&a[i][j]);
		}
	}
	for(i=0;i<m;i++){
		scanf("%d",&b[i]);
	}

	for(i=0;i<n;i++){
		c[i] = 0;
	}

	for(i=0;i<n;i++){
		for(j=0;j<m;j++){
			c[i] = c[i] + a[i][j] * b[j];
		}
	}

	for(i=0;i<n;i++){
		printf("%d\n",c[i]);
	}
	return 0;
}

Measured memory_bytes: 1064
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;cin>>n;
  int k;cin>>k;
  vector<int>a(n,0);
  int tmp;
  for(int i=0;i<n;i++){
    cin>>tmp;
    a.at(tmp-1)++;
  }
  tmp=0;
  vector<int>b;
  for(int i=0;i<n;i++){
    if(a.at(i)!=0){
      tmp++;
      b.push_back(a.at(i));
    }
  }
  tmp-=k;
  sort(b.begin(),b.end());
  int ans=0;
  for(int i=0;i<tmp;i++){
    ans+=b.at(i);
  }
  cout <<ans<<endl;
}

Measured memory_bytes: 4912
#include "bits/stdc++.h"
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
	ll x; // typedef long long ll;
	mint(ll x = 0) :x((x%mod + mod) % mod) {}
	mint operator-() const { return mint(-x); }
	mint& operator+=(const mint a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint a) {
		if ((x += mod - a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this; }
	mint operator+(const mint a) const { return mint(*this) += a; }
	mint operator-(const mint a) const { return mint(*this) -= a; }
	mint operator*(const mint a) const { return mint(*this) *= a; }
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	// for prime mod
	mint inv() const { return pow(mod - 2); }
	mint& operator/=(const mint a) { return *this *= a.inv(); }
	mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x; }
ostream& operator<<(ostream& os, const mint& a) { return os << a.x; }
// combination mod prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&feature=youtu.be&t=1619
struct combination {
	vector<mint> fact, ifact;
	combination(int n) :fact(n + 1), ifact(n + 1) {
		assert(n < mod);
		fact[0] = 1;
		for (int i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i;
		ifact[n] = fact[n].inv();
		for (int i = n; i >= 1; --i) ifact[i - 1] = ifact[i] * i;
	}
	mint operator()(int n, int k) {
		if (k < 0 || k > n) return 0;
		return fact[n] * ifact[k] * ifact[n - k];
	}
}c(200005);


//m^n
mint f(int m, int n) {
	if (0 == n) {
		return 1;
	}
	mint x = f(m, n / 2);
	x *= x;
	if (1 == n % 2) {
		x *= (mint)m;
	}
	return x;
}
// nCa
mint choose(int n, int a) {
	mint x = 1;
	mint y = 1;
	for (int m = 0; m < a; ++m) {
		x *= (mint)(n - m);
		y *= (mint)(a - m);
	}
	return x / y;
}
// nPk
mint nPk(int n, int a) {
	mint ret = choose(n, a);
	for (int n = 1; n <= a; ++n) {
		ret *= n;
	}
	return ret;
}


int main() {
	int N, M;
	cin >> N >> M;
	vector<long long>X(N);
	vector<long long>Y(M);
	for (int i = 0; i < N; ++i) {
		cin >> X[i];
	}	
	for (int i = 0; i < M; ++i) {
		cin >> Y[i];
	}
	mint x = 0;
	mint xsum = 0;
	mint y = 0;
	mint ysum = 0;
	for (int i = 0; i < N; ++i) {
		x += (mint)(X[i]*i)-xsum;
		xsum += (mint)X[i];
	}	
	for (int i = 0; i < M; ++i) {
		y += (mint)(Y[i]*i) - ysum;
		ysum += (mint)Y[i];
	}
	cout << x*y<<endl;
	return 0;
}

Measured memory_bytes: 7996
/* package whatever; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
public class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		Scanner sc=new Scanner(System.in);
		int a=sc.nextInt();
		int b=sc.nextInt();
		int t=sc.nextInt();
		double d=t+0.5;
	     double q=d/a;
	     int r=(int)q;
	     System.out.println(r*b);
		
	}
}

Measured memory_bytes: 23124
#include <stdio.h>

int main(void) {
	int card[10];
	int i, j;
	int c[3];
	int sum;
	int count;
	while (scanf("%d %d %d", &c[0], &c[1], &c[2]) != EOF) {
		memset(card, 0, sizeof(card));
		for (i = 0; i < 3; i++)
			card[c[i]-1]++;
		sum = c[0] + c[1];
		count = 0;
		for (i = 20 - sum - 1; i >= 0; i--) {
			if (!card[i])
				count++;
		}
		if ((double)count / 7.0 * 100 >= 50)
			printf("YES\n");
		else
			printf("NO\n");
	}
	return 0;
}

Measured memory_bytes: 580
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
# define mod 1000000007
# define INF (1 << 29)
# define MAX_N 1000010
/* ちゃんと考えてわかって実装 */

int c[10][1005];

int main(void){
    int h, w, k;
    cin >> h >> w >> k;
    vector<string> S;
    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){
            string s; cin >> s;
            S.push_back(s);
        }
    }

    int ans = INF;
    for(int bit=0; bit<(1<<(h-1)); bit++){
        int tmp_ans = 0;
        vector<int> id(h); // 各行のグループ番号
        int g = 0;
        for(int i=0; i<h; i++){
            id[i] = g;
            if(bit>>i & 1) g++;
        }
        tmp_ans += g;
        g++;

        for(int i=0; i<h; i++){
            for(int j=0; j<w; j++){
                c[i][j] = 0;
            }
        }
        for(int i=0; i<h; i++){
            for(int j=0; j<w; j++){
                c[id[i]][j] += (S[i][j] - '0');
            }
        }

        vector<int> now(g); // 各グループの1の数を数える

        // 各列について、数えるための(mainの中で使える)関数
        auto add = [&](int j){
            for(int i=0; i<g; i++){
                now[i] += c[i][j];
            }
            for(int i=0; i<g; i++){
                if(now[i] > k) return false;
            }
            return true;
        };

        for(int j=0; j<w; j++){
            if(!add(j)){
                tmp_ans++;
                // now を 0 で初期化し直す。
                now = vector<int>(g);
                // 今いる行を復活させるけど、その行単体でアウトならbreak
                if(!add(j)){
                    tmp_ans = INF;
                    break;
                }
            }
        }
        ans = min(ans, tmp_ans);
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 512
#include<stdio.h>
#include<iostream>
#include<math.h>
#include<string>
#include<vector>
#include<map>
#include<queue>
#include<cmath>
using namespace std;
using ll = long long int;
const double PI=3.14159265358979323846264;
typedef pair<int,int> P;

int main(void){
    double R;
    cin >> R;
    cout << R*2*PI << endl;
}

Measured memory_bytes: 3812