akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {
    static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        int n = Integer.parseInt(sc.nextLine());
        int n0 = Integer.parseInt(sc.nextLine());
        int n1 = Integer.parseInt(sc.nextLine());

        int max = n1 - n0;
        int min = Math.min(n0, n1);

        for(int i = 2; i < n; i++){
            int a = Integer.parseInt(sc.nextLine());
            max = Math.max(max, a - min);
            min = Math.min(min, a);
        }
        System.out.println(max);
    }
}


Measured memory_bytes: 167912
#include <bits/stdc++.h>
using namespace std;
    vector<vector<int>>g;
    vector<int> matched;
    vector<bool> visited;
    void add_edge(int u,int v){
        g[u].push_back(v);
        g[v].push_back(u);
    }

bool argument(int u){
    for(auto&& v:g[u]){
        visited[u]=true;
        int w=matched[v];
        if(w==-1 || !visited[w] && argument(w)){
            matched[v]=u;matched[u]=v;
            return true;
        }
    }
    return false;
}

int main(){
    int n;cin>>n;
    vector<int>x(2*n),y(2*n);
    for(int i=0;i<2*n;i++)cin >>x[i] >>y[i];
    g.resize(2*n);
    for(int i=0;i<n;i++){
        for(int j=n;j<2*n;j++){
            if(x[i]<x[j] && y[i]<y[j])add_edge(i,j);
        }
    }

    matched.resize(2*n,-1);
    int ans=0;
    for(int u=0;u<2*n;u++){
        if(matched[u]==-1){
        visited.assign(2*n,false);
        if(argument(u))ans++;
    }
    }
    // for(auto&& u:g ){for(auto&& w:u ){cout<<w<<" ";}cout<<endl;}
    // for(auto&& w:matched)cout<<w<<" ";
    // cout<<endl;
    cout<<ans<<endl;

    
}

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

int main() {
int d;
cin >> d;
vector<int> c(26);
rep(i,26) cin >> c.at(i);
vector<vector<int>> s(d,vector<int>(26));
rep(i,d)rep(j,26) cin >> s.at(i).at(j);

rep(i,d) cout << 3 << endl;
 }


Measured memory_bytes: 3692
import           Control.Monad
import           Control.Applicative
import           Data.List
import qualified Data.Vector                   as V

getBysplit = map read . words <$> getLine

main :: IO ()
main = do
  [n, a, b, c] <- getBysplit :: IO [Int]
  l            <- replicateM n readLn :: IO [Int]
  let vec = V.fromList l
  print $ dfs vec (a, b, c) (n - 1) (0, 0, 0)


dfs :: V.Vector Int -> (Int, Int, Int) -> Int -> (Int, Int, Int) -> Int
dfs vec (a1, b1, c1) cur (a, b, c) = if cur == -1
  then if minimum [a, b, c] > 0
    then abs (a - a1) + abs (b - b1) + abs (c - c1) - 30
    else 10000000000000
  else
    let ret0 = dfs vec (a1, b1, c1) (cur - 1) (a, b, c)
        ret1 = dfs vec (a1, b1, c1) (cur - 1) ((a + vec V.! cur), b, c) + 10
        ret2 = dfs vec (a1, b1, c1) (cur - 1) (a, (b + vec V.! cur), c) + 10
        ret3 = dfs vec (a1, b1, c1) (cur - 1) (a, b, (c + vec V.! cur)) + 10
    in  minimum [ret0, ret1, ret2, ret3]


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

int N;

int main(void){
    
    cin >> N;
    ll p = 1;
    for(int i = 1; i <= N; ++i){
        p *= i;
        p %= MOD;
    }
    cout << p << endl;
    
    return 0;
}


Measured memory_bytes: 256
s  = input()
a = s[:int(len(s)/2)]
b = s[:-int(len(s)/2 + 1)]
flag = 0
if s == s[::-1]:
    if a == a[::-1]:
        if b == b[::-1]:
            flag = 1

if flag:
    print('Yes')
else:
    print('No')

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

int n, a,b;
vector<int> graph[100005];
long long DP[100005][2],ans;

long long dp(int id, int color, int par){
	
	if(graph[id].size()==1 && par!=-1) return 1;
	if(DP[id][color]!=-1) return DP[id][color];
	long long res =1;
	for(int i =0;i<graph[id].size();i++){
		int nex = graph[id][i];
		if(nex == par) continue;
		if(color == 0)res *= (dp(nex,0,id) + dp(nex,1,id))%MOD;
		else res *= dp(nex,color^1,id);
		res %=MOD;
	}
//	printf(">> %d %d = %lld\n",id, color,res);
	return DP[id][color] = res;
}


int main(){
	scanf("%d",&n);
	memset(DP,-1,sizeof DP);
	for(int i = 0;i<n-1;i++){
		scanf("%d%d",&a,&b);
		graph[a].push_back(b);
		graph[b].push_back(a);
	}
	ans = dp(1,0,-1) + dp(1,1,-1);
	ans %= MOD;
	printf("%lld\n",ans);
	return 0;
}

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

using namespace std;

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

int const MAX = 200011;

typedef long long ll;

class Union_Find {
public:
  int par[MAX], rank[MAX], size[MAX], gnum;
    
  Union_Find(int N) {
    gnum = N;
    for (int i = 0; i < N; i++) {
      par[i] = i;
      rank[i] = 0;
      size[i] = 1;
    }
  }

  int find(int x)
  {
    if (par[x] == x) {
      return x;
    }
    return par[x] = find(par[x]);
  }

  void unite(int x, int y)
  {
    x = find(x);
    y = find(y);
    if (x == y) return;
        
    if (rank[x] < rank[y]) {
      par[x] = y;
      size[y] += size[x];
    } else {
      par[y] = x;
      size[x] += size[y];
      if (rank[x] == rank[y]) {
	rank[x]++;
      }
    }
    gnum--;
  }

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

  int getSize(int x)
  {
    return size[find(x)];
  }

  int groups()
  {
    return gnum;
  }
};

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

  vector<tuple<ll, int, int>> vs;

  rep(i, N) {
    int a, b; ll c; cin >> a >> b >> c;
    vs.emplace_back(c, a, b);
  }

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

  ll sum = 0;
  
  rep(i, vs.size()) {
    ll c; int a, b; tie(c, a, b) = vs[i];
    if(!uf.same(a, b)) {
      sum += (ll)uf.getSize(a) * uf.getSize(b) * c;
      uf.unite(a, b);
    }
  }
  
  cout << sum << endl;
  
  return 0;
}

Measured memory_bytes: 9344
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr long long INFL = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



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

    int N,M;
    cin >> N >> M;

    int ans=0;
    ans=(N-M)*100+M*1900;
    rep(i,M){
        ans*=2;
    }
    cout << ans << endl;



}


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

using namespace std;
 
int main() {

    while (true)
    {
        string shuffled;
        cin >> shuffled;

        if (shuffled == "-")
            break;

        int sf_times;
        cin >> sf_times;

        int breads;
        for (int i = 0; i < sf_times; i++)
        {
            cin >> breads;
            shuffled = shuffled.substr(breads, shuffled.size() - 1)
                       + shuffled.substr(0, breads);

            // FOR DEBUG
            // cout << shuffled << "\n" << endl;
        }
        cout << shuffled << endl;
    }
    return 0;
}


Measured memory_bytes: 3160
#include <bits/stdc++.h>
#define pb push_back
typedef long long ll;
using namespace std;
ll n,m,q;
const ll inf = 1e12;
vector<ll> s, t;
int main()
{
        cin >> n >> m >> q;
        s.pb(-inf);
        for(ll i=1;i<=n;i++) {
                ll x;
                cin >> x;
                s.pb(x);
        }
        s.pb(inf);
        t.pb(-inf);
        for(ll i=1;i<=m;i++) {
                ll x;
                cin >> x;
                t.pb(x);
        }
        t.pb(inf);
        vector<ll> sr = s;
        vector<ll> tr = t;
        reverse(sr.begin(), sr.end());
        reverse(tr.begin(), tr.end());
        for(ll i=0;i<sr.size();i++) sr[i] = -1 * sr[i];
        for(ll i=0;i<tr.size();i++) tr[i] = -1 * tr[i];
        while(q--) {

                ll x;
                cin >> x;
                ll ans = inf;
                ll A = *lower_bound(s.begin(), s.end(), x);
                ll B = *lower_bound(t.begin(), t.end(), x);
                ll C = *lower_bound(sr.begin(), sr.end(), -x);
                ll D = *lower_bound(tr.begin(), tr.end(), -x);
                C *= -1;
                D *= -1;
                ans = max(A,B) - x;
                ans = min(ans , x - min(C,D));
                ans = min(ans, 2*(B - x) + (x - C));
                ans = min(ans ,2*(x - C) + (B - x));
                ans = min(ans , 2*(A-x) + (x-D));
                ans = min(ans , 2*(x - D) + (A - x));
                cout << ans << "\n";
        }
        return 0;
}


Measured memory_bytes: 4596
#include <iostream>

using namespace std;
using ll = long long;
using ld = long double;

int main() {
  int N, P, A;
  cin >> N >> P;
  bool cond = false;
  ll ans{1};
  while (cin >> A) {
    cond |= A % 2;
    ans *= 2;
  }
  if (cond) ans /= 2;
  else if (P) ans = 0;

  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
static const long long MOD = 1000000000+7;
static const double PI = 3.141592653589793;

long long modpow(long long x, long long n, long long mod = 0) {
  if (mod == 0) {
    long long res=1;
    while (n > 0) {
      if (n%2 == 1) {
        res = ( res*x );
      }
      x = (x*x);
      n /= 2;
    }
    return res;
  }

  long long res=1;
  while (n > 0) {
    if (n%2 == 1) {
      res = ( res*x ) % mod;
    }
    x = (x*x) % mod;
    n /= 2;
  }
  return res;
}

long long modinverse(long long x, long long mod) {
  // mod must be prime number.
  return modpow(x, mod-2, mod);
}

// メモリ不足に注意！
vector<long long> vecmodfact(2,1);
long long modfact(long long n, long long mod) {
  std::size_t n_size_t = n;
  if (vecmodfact.size()-1 >= n_size_t) return vecmodfact.at(n);
  std::size_t i=vecmodfact.size();
  vecmodfact.resize(n+1);
  for (; i<=vecmodfact.size()-1; i++) {
    vecmodfact.at(i) = vecmodfact.at(i-1)*i % mod;
  }
  return vecmodfact.at(n);
}

long long modcomb(long long m, long long n, long long mod){
  if (m < n || n < 0) return 0;
  if (n == 0 || n == m) return 1;
  long long ans = modfact(m,mod) * modinverse(modfact(n,mod), mod) % mod;
  ans = ans * modinverse(modfact(m-n,mod), mod) % mod;
  return ans;
}

map<int, int> prime_factors(long long n) {
  map<int, int> res;
  if (n <= 1) return res;
  for (int i=2; i*i<=n; i++) {
    while (n%i==0) {
      ++res[i];
      n /= i;
    }
  }
  if (n != 1) ++res[n];
  return res;
}

int main() {
  int x,n;
  cin >> x >> n;
  vector<int> p(n);
  for (int i=0; i<n; ++i) {
    cin >> p.at(i);
  }

  auto isExist = [&](int num){
    for (auto i=0; i<p.size(); ++i) {
      if (num == p.at(i)) return true;
    }
    return false;
  };

  int ans=200;
  for (int i=-200; i< 200; ++i) {
    if (isExist(i)) continue;
    if (abs(x-ans) == abs(x-i) ) {
      ans = min(ans,i);
    }
    if (abs(x-ans) > abs(x-i) ) {
      ans = i;
    }
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3636
#include<iostream>
#include<cstring>
#define MaxSize 100
using namespace std;

typedef struct Node* Gmap;
struct Node{
	int N;
	int E;
	int arc[MaxSize][MaxSize];
	char data[MaxSize];
};

Gmap Create(Gmap map,int N,int E,char ch[]){//建图 
	map->N=N;
	map->E=E;
	for(int i=1;i<=N;i++)
		map->data[i]=ch[i];
	for(int i=1;i<=N;i++)
		for(int j=1;j<=N;j++)
			map->arc[i][j]=0;
	return map;
}

void CreatEdge(Gmap &map,int E1,int E2){
	map->arc[E1][E2]=1;
	map->arc[E2][E1]=1;
} 

int cnt=0;
int visited[MaxSize]={0};
void DFS(Gmap map,int v,int k){
	if(k==map->N){
		cnt++;
	}
		
	//cout<<map->data[v]<<" ";
	visited[v]=1;
	for(int j=1;j<=map->N;j++){
		if(!visited[j] && map->arc[v][j]){
			visited[j]=1;
			DFS(map,j,k+1);
			visited[j]=0;
		}
	}
}

char ch[10]={'0','1','2','3','4','5','6','7','8'};
int main(){
	int N,E,E1,E2;
	cin>>N>>E;
	Gmap map=new Node;
	map=Create(map,N,E,ch);
	
	for(int i=0;i<E;i++){
		cin>>E1>>E2;
		CreatEdge(map,E1,E2);
	}

	DFS(map,1,1);
	cout<<cnt<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <cstring>

#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
typedef long long ll;

static const int dy[4] = {0,1,0,-1};
static const int dx[4] = {1,0,-1,0};

using namespace std;

int main(){

    int n, m;
    int l[100005] = {};
    int r[100005] = {};

    cin >> n >> m;

    for(int i = 0; i < m; i++){
        cin >> l[i] >> r[i];
        l[i]--;
        r[i]--;
    }

    int lmax = 0;
    int rmin = 100000;
    for(int i = 0; i < m; i++){
        lmax = max(lmax, l[i]);
        rmin = min(rmin, r[i]);
    }
    cout << max(rmin - lmax + 1, 0) << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>

using namespace std;

int main(){
    string S;
    cin>>S;
    if(S.at(2)==S.at(3) && S.at(4)==S.at(5)){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
}

Measured memory_bytes: 256
using System;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            string s = Console.ReadLine();
            string t = Console.ReadLine();

            string result = t.StartsWith(s) ? "Yes" : "No";
            Console.WriteLine(result);

            Console.Out.Flush();
        }
    }
}


Measured memory_bytes: 26176
import sys
readline = sys.stdin.readline
from collections import Counter
MOD = 2019

def main():
    S = list(map(int, list(readline().rstrip())))
    N = len(S)
    T = [0] * (N+1)
    e = 1
    for i in range(N-1, -1, -1):
        T[i] = (T[i+1] + int(S[i]) * e) % MOD
        e = e * 10 % MOD
    
    c = Counter(T)
    ans = 0
    for k, v in c.items():
        ans += (v * (v-1)) // 2
    print(ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 17912
// inputに入力データ全体が入る
function Main(input) {
    // 1行目がinput[0], 2行目がinput[1], …に入る
    var N = input.split(' ')[0]
    var K = input.split(' ')[1]
    console.log(N >= (K - 1) * 2 + 1 ? 'YES' : 'NO');
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 21064
import java.util.Scanner;
public class Main {
	static int N;
	static String s;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		N=sc.nextInt();
		s=N==25?"Christmas":N==24?"Christmas Eve":N==23?"Christmas Eve Eve":"Christmas Eve Eve Eve";
		System.out.println(s);
	}
}


Measured memory_bytes: 22608
#include <bits/stdc++.h>
#include <stdlib.h>
#include <string>
#include <iostream>
#include <algorithm>
#include <map>
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<int, int> P;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()

int main(){
  int N; cin >>N;
  ll b_a = 0;
  ll a_b = 0;
  ll a[N];
  ll b[N];
  rep(i, N) cin >> a[i];
  rep(i, N) cin >> b[i];
  rep(i, N){
    if (a[i] >= b[i]) a_b += (a[i]-b[i]);
    else b_a += (b[i]-a[i])/2;
  }
  if (b_a >= a_b) cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

int main() {
  int a,b,c;
  cin >> a >> b >> c;
  if((a == b and b != c) or (a == c and c != b) or (b == c and c!= a)){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
c1, c2, c3 = map(int, input().split())
c4, c5, c6 = map(int, input().split())
c7, c8, c9 = map(int, input().split())
if c1 - c2 == c4 - c5 == c7 - c8 and c3 - c2 == c6 - c5 == c9 - c8:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3064
//  507.cpp
//  2012/12/14.

#if 1

#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iostream>
#include <cctype>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <complex>
#include <fstream>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T> T RoundOff(T a){ return int(a+.5-(a<0)); }
template<class T, class C> void chmax(T& a, C b){ if(a < b) a = b; }
template<class T, class C> void chmin(T& a, C b){ if(b < a) a = b; }
template<class T, class C> pair<T, C> mp(T a, C b){ return make_pair(a, b); }

int pat[32] = {0};
void rec(int left, int prev, int idx)
{
	if(left == 0)
	{
		for(int i = 0; 0 < pat[i]; i++) cout << pat[i] << (0 == pat[i+1] ? "\n" : " ");
	}
	
	for(int next = min(prev, left); 0 < next; next--)
	{
		pat[idx] = next;
		rec(left - next, next, idx+1);
		pat[idx] = 0;
	}
}

int main()
{
    for(int n; cin >> n; rec(n, n, 0));
}

#endif

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

template <typename T,typename E>
struct SegmentTree{
  typedef function<T(T,T)> F;
  typedef function<T(T,E)> G;
  typedef function<T(E,E)> H;
  typedef function<E(E,Int)> P;
  Int n;
  F f;
  G g;
  H h;
  T d1;
  E d0;
  P p;
  vector<T> dat;
  vector<E> laz;
  SegmentTree(){};
  SegmentTree(Int n_,F f,G g,H h,T d1,E d0,
	      vector<T> v=vector<T>(),P p=[](E a,Int b){++b;return a;}):
    f(f),g(g),h(h),d1(d1),d0(d0),p(p){
    init(n_);
    if(n_==(Int)v.size()) build(n_,v);
  }
  void init(Int n_){
    n=1;
    while(n<n_) n*=2;
    dat.clear();
    dat.resize(2*n-1,d1);
    laz.clear();
    laz.resize(2*n-1,d0);
  }
  void build(Int n_, vector<T> v){
    for(Int i=0;i<n_;i++) dat[i+n-1]=v[i];
    for(Int i=n-2;i>=0;i--)
      dat[i]=f(dat[i*2+1],dat[i*2+2]);
  }
  void update(Int a,Int b,E x,Int k,Int l,Int r){
    if(r<=a||b<=l) return;
    if(a<=l&&r<=b){
      laz[k]=h(laz[k],x);
      return;
    }
    update(a,b,x,k*2+1,l,(l+r)/2);
    update(a,b,x,k*2+2,(l+r)/2,r);
    dat[k]=f(g(dat[k*2+1],p(laz[k*2+1],(r-l)>>1)),
	     g(dat[k*2+2],p(laz[k*2+2],(r-l)>>1)));
  }
  void update(Int a,Int b,E x){
    update(a,b,x,0,0,n);
  }
  T query(Int a,Int b,Int k,Int l,Int r){
    if(r<=a||b<=l) return d1;
    if(a<=l&&r<=b) return g(dat[k],p(laz[k],r-l));
    T vl=query(a,b,k*2+1,l,(l+r)/2);
    T vr=query(a,b,k*2+2,(l+r)/2,r);
    return g(f(vl,vr),p(laz[k],min(r,b)-max(l,a)));
  }
  T query(Int a,Int b){
    return query(a,b,0,0,n);
  }
};

//INSERT ABOVE HERE
signed main(){
  Int n,q;
  cin>>n>>q;
  SegmentTree<Int, Int>::F f=[](Int a,Int b){return min(a,b);};
  SegmentTree<Int, Int>::G g=[](Int a,Int b){return a+b;};
  const Int INF = 1e15;
  vector<Int> v(n,0);
  SegmentTree<Int, Int> seg(n,f,g,g,INF,0,v);
  for(Int i=0;i<q;i++){
    Int a,s,t,x;
    cin>>a>>s>>t;
    t++;
    if(a) cout<<seg.query(s,t)<<endl;
    if(!a){
      cin>>x;
      seg.update(s,t,x);
    }
  }
  return 0;
}



Measured memory_bytes: 9264
#include<iostream>
#include<vector>
#include<iomanip>
using namespace std;
vector<vector<int> >G;
vector<vector<int> >prefix;
vector<vector<int> >suffix;
vector<int>pre;
vector<int>fin;
vector<bool>vis;
long long mod;
void dfs(int rt,int p)
{
    if(G[rt].size()==0)
    {
        pre[rt]=1;
        return;
    }
    prefix[rt].resize(G[rt].size());
    suffix[rt].resize(G[rt].size());
    long long prod=1ll;
    for(int i=0;i<G[rt].size();i++)
    {
        int chd=G[rt][i];
        if(chd!=p)
        {
            prefix[rt][i]=prod;
            dfs(chd,rt);
            prod=(prod*(1ll+(long long)pre[chd]))%mod;
        }
    }
    pre[rt]=prod;
    prod=1ll;
    for(int i=G[rt].size()-1;i>=0;i--)
    {
        int chd=G[rt][i];
        if(chd!=p)
        {
            suffix[rt][i]=prod;
            prod=(prod*(1ll+(long long)pre[chd]))%mod;
        }
    }
}
void dfs1(int rt,int val)
{
    vis[rt]=true;
    fin[rt]=(pre[rt]*(1ll+val))%mod;
    for(int i=0;i<G[rt].size();i++)
    {
        int chd=G[rt][i];
        if(!vis[chd])
        {
            dfs1(chd,(((prefix[rt][i]*(long long)suffix[rt][i])%mod)*(1ll+val))%mod);
        }
    }
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n,i;
    cin>>n>>mod;
    G.resize(n+1);
    vis.resize(n+1);
    pre.resize(n+1);
    fin.resize(n+1);
    prefix.resize(n+1);
    suffix.resize(n+1);
    for(i=0;i<n-1;i++)
    {
        int x,y;
        cin>>x>>y;
        G[x].push_back(y);
        G[y].push_back(x);
    }
    dfs(1,0);
    dfs1(1,0);
    for(i=1;i<=n;i++) cout<<fin[i]<<endl;
    G.clear();
    vis.clear();
    pre.clear();
    fin.clear();
    prefix.clear();
    suffix.clear();
}


Measured memory_bytes: 23808
#define DEBUG 0
#include <bits/stdc++.h>
#define all(v) (v).begin(), (v).end()
#define pb push_back
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template<class T>using numr=std::numeric_limits<T>;
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; }
const int INF = 1e9;
const ll LLINF = 1e16;
const int MOD = 1000000007;
const int MOD2 = 998244353;
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(nullptr);
    std::ios::sync_with_stdio(false);
    int x,y,z;
    cin >> x >> y >> z;
    cout << z << " " << x << " " << y<< endl;

}


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

int main() {
    int N;
    cin >> N;
    int X[N];
    for(int i=0;i<N;i++){
        cin >> X[i];
    }
    int P=1000000;
    for(int i=0;i<100;i++){
        int sum=0;
        for(int j=0;j<N;j++){
            sum=sum+pow((i-X[j]),2);
        }
        if(sum<P){
            P=sum;
        }
    }
    cout << P << endl;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
h, w = map(int, input().split())
c = [[] for _ in range(10)]
cnt = [0] * 10
for i in range(10):
    c[i] = list(map(int, input().split()))
a = [[] for _ in range(h)]
for i in range(h):
    a[i] = list(map(int, input().split()))
    for j in range(10):
        cnt[j] += a[i].count(j)
visit = [0] * 10
val = [c[i][1] for i in range(10)]
visit[1] = 1
pos = 1
while sum(visit) < 10:
    tmp = 10 ** 5  # INF
    for i in range(10):
        if not visit[i]:
            val[i] = min(val[i], val[pos] + c[i][pos])
            if tmp > val[i]:
                # pos = i#ここを更新したらあかんやん。。。
                next_pos = i
                tmp = val[i]
    pos = next_pos
    visit[pos] = 1
ans = 0
# print(val)
for i in range(10):
    ans += val[i] * cnt[i]
print(ans)


Measured memory_bytes: 3444
N = int(input())
s = input()

b_cnt, w_cnt = [0], [0]
for si in s:
    if si==".":
        b_cnt.append(b_cnt[-1])
        w_cnt.append(w_cnt[-1]+1)
    else:
        b_cnt.append(b_cnt[-1]+1)
        w_cnt.append(w_cnt[-1])

b_cnt = b_cnt[1:]
w_cnt = w_cnt[1:]
# print(b_cnt)
# print(w_cnt)
w = s.count(".")
b = s.count("#")
ans = float('inf')
ans = min(w, b)
for i in range(N):
    cond = b_cnt[i] + w - w_cnt[i]
    ans = min(ans, cond)

print(ans)


Measured memory_bytes: 14380
#include <bits/stdc++.h>
using namespace std;
struct Fast {
    Fast() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} fast;

void yes() {
    cout << "Yes" << endl;
    exit(0);
}
void no() {
    cout << "No" << endl;
    exit(0);
}
#define REP(i, n) for (long long i = 0; i < (n); i++)

int main() {
    long long n, k;
    cin >> n >> k;
    if (n - (n / k) * k < abs(n - (n / k + 1) * k)) {
        cout << n - (n / k) * k << endl;
    } else {
        cout << abs(n - (n / k + 1) * k) << endl;
        ;
    }
}

Measured memory_bytes: 256
// clang-format off
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}
// clang-format on

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

    vector<pair<int, int>> v;

    int s = 1;
    for (int i = m; i > 0; i -= 2) {
        v.pb({s, s + i});
        ++s;
    }

    s = m + 2;
    for (int i = m - 1; i > 0; i -= 2) {
        v.pb({s, s + i});
        ++s;
    }

    for (auto& p : v) cout << p.fi << " " << p.se << "\n";
    return 0;
}


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

int main() {
    int n, m;
    cin >> n >> m;
    int correct = 0, penalty = 0;
    bool isAC[n+1] = {};
    int cnt[n+1] = {};
    for (int i = 0; i < m; i++) {
        int p;
        string s;
        cin >> p >> s;
        if (isAC[p]) continue;
        if (s == "WA") {
            cnt[p]++;
        }
        else {
            correct++;
            isAC[p] = 1;
            penalty += cnt[p];
        }
    }

    cout << correct << " " << penalty << endl;
    return 0;
}

Measured memory_bytes: 768
N = int(input())
A = list(map(int, input().split()))
A.sort()
M = A[-1]
a = M // 2
for i in range(N-1):
  if A[i] <= a and A[i+1] >= a:
    if (M-A[i])*A[i] >= (M-A[i+1])*A[i+1]:
      ans = [M, A[i]]
    else:
      ans = [M, A[i+1]]
ans = [str(b) for b in ans]
ans = ' '.join(ans)
print(ans)
      

Measured memory_bytes: 14052
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstring>
#include <iterator>
#include <bitset>
#include <unordered_set>
#include <unordered_map>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <utility>
#include <memory>
#include <functional>
#include <deque>
#include <cctype>
#include <ctime>
#include <numeric>
#include <list>
#include <iomanip>

#if __cplusplus >= 201103L
#include <array>
#include <tuple>
#include <initializer_list>
#include <forward_list>

#define cauto const auto&
#else

#endif

using namespace std;


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

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

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

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

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define F first
#define S second
#define mkp make_pair
#define RALL(v) (v).rbegin(),(v).rend()
#define DEBUG
#ifdef DEBUG
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#else
#define dump(x) 
#define debug(x) 
#endif

#define MOD 1000000007LL
#define EPS 1e-8
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)

void mainmain(){
	ll H, W;
	cin>>H>>W;
	ll ans = INFL;
	reep(i,1,H+1){
		ll a = i*W;
		ll h = H-i;
		ll b;
		// cout<<h<<" "<<W<<" "<<a<<endl;
		if(h%2==0||W%2==0){
			b = abs(a - h*W/2);
		}
		else{
			// 5*3 2 3 1 2
			b = min(max(abs(a-(h/2)*W),abs(a-(h/2+1)*W)), max(abs(a-(W/2+1)*h),abs(a-(W/2)*h)));
		}
		mins(ans, b);
	}
	swap(H,W);
	reep(i,1,H+1){
		ll a = i*W;
		ll h = H-i;
		ll b;
		if(h%2==0||W%2==0){
			b = h*W/2;
		}
		else{
			// 5*3 2 3 1 2
			b = min(abs((h/2)*(W/2+1)-(h/2+1)*(W/2)), abs((h/2+1)*(W/2+1)-(h/2)*(W/2)));
		}
		mins(ans, abs(a-b));
	}
	cout<<ans<<endl;
}


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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	 int n,m,xc,yc;
	 int x[1000]={0},y[1000]={0};
	 cin>>n>>m>>xc>>yc;
	 for(int i=0;i<n;i++)
	 cin>>x[i];
	 for(int i=0;i<m;i++)
	 cin>>y[i];
	 int flag=0;
	 for(int i=xc+1;i<=yc;i++)
	 {  flag=0;
	 	for(int j=0;j<n;j++)
	     {
	     	if(i>x[j])continue;
	     	else 
			 {flag=1;
			 	break;
			 }
		 }
		 if(flag)continue;
	 for(int j=0;j<m;j++)
	 {
	 	if(i<=y[j])continue;
	     	else 
			 {flag=1;
			 	break;
			 }
	 }
	 if(!flag)break;
	 }
	 if(!flag)
	 {
	 	cout<<"No War"<<endl;
	 }
	 else
	 {
	 	 cout<<"War"<<endl;
	 }
 } 

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

int W[100000];
int n, k;

int check(long long P) {
	int i = 0;
	for (int j = 0; j < k; j++) {
		int s = 0;
		while (s + W[i] <= P) {
			s += W[i];
			i++;
			if (i == n)
				return n;
		}
	}
	return i;
}

int main() {
	cin >> n >> k;
	for (int i = 0; i < n; i++)
		cin >> W[i];
	long long left = 0;
	long long right = 100000 * 10000;
	long long mid;
	while (left + 1 < right) {
		mid = (left + right) / 2;
		int v = check(mid);
		if (v >= n) {
			right = mid;
		} else {
			left = mid;
		}
	}
	cout << right << endl;
	return 0;
}



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

int const md = 998244353, N = 100000;
int x[N];

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

int main(){
	int n;
	scanf("%d", &n);
	f(i, 0, n)scanf("%d", x + i);
	sort(x, x + n);
	int an = x[0];
	f(i, 1, n)an = (ll)an * gcd(i, x[i]) % md;
	printf("%d\n", an);
}

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

typedef pair<int,int> P;
#define ll long long
#define ld long double
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define sz(x) ((int)(x).size())
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(x) (x).begin(),(x).end()

const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

bool isprime(int num)
{
    for(int i = 2; i*i <=num; i++)
    {
        if(num%i==0)
        {
            return false;
        }
    }
    return true;
}
int main()
{
    int n;cin >> n;
    vector<int> a(n);
    int counter = 0;
    int kouho = 6;
    while(counter < n)
    {
        if(isprime(kouho))
        {
            a[counter] = kouho;
            counter++;
        }
        kouho += 5;
        
    }
    rep(i,n)
    {
        cout << a[i] << " ";
    }
    cout  << endl;
}

Measured memory_bytes: 3512
<?php
 
$arr = array();
fscanf(STDIN, "%d %d", $W, $H);
$ans = 0;
 
$WW = $W + 1;
$HH = $H + 1;
 
for ($i = 0; $i < $W; $i++) {
	$key = "W_" . strval($i);
	fscanf(STDIN, "%d", $arr[$key]);
}
 
for ($i = 0; $i < $H; $i++) {
	$key = "H_" . strval($i);
	fscanf(STDIN, "%d", $arr[$key]);
}
asort($arr);
foreach ($arr as $key => $val) {
	$WH = $key[0];
	if ($WH == "W") {
		$kazu = $HH;
		$WW--;
	} else {
		$kazu = $WW;
		$HH--;
	}
	$ans += $val * $kazu;
}
echo $ans . PHP_EOL;

Measured memory_bytes: 21240
#include<bits/stdc++.h>
using namespace std;
#define ll long long
typedef pair<ll,ll> P;
typedef pair<ll,P> PP;
const ll MOD = 1e9+7;

int main(){
  string s;
  cin>>s;
  ll f=0;
  ll ans=0;
  ll cnt=0;
  for(ll i=0;i<s.size();i++){
    if(s[i]=='B')f=1;
    if(f==0&&s[i]=='W')cnt++;
    if(f&&s[i]=='W'){
	 ans+=i-cnt;
	 cnt++;
    }
  }
  cout<<ans<<endl;
  return 0;
}


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

using namespace std;

int main() {
	string s;
	cin >> s;
	if (s.length() == 2) {
		if (s[0] == s[1]) cout << "1 2" << endl;
		else cout << "-1 -1" << endl;
		return 0;
	}
	else {
		for (int i = 0; i + 2 < s.length(); ++i) {
			if (s[i] == s[i + 1]
				|| s[i] == s[i + 2]
				|| s[i + 1] == s[i + 2]) {
				cout << i + 1 << " " << i + 3 << endl;
				return 0;
			}
		}
		cout << -1 << " " << -1 << endl;
		return 0;
	}
}

Measured memory_bytes: 512
#include<iostream>
using namespace std;
int n,m=0,a[30],b[30],c[30];
int main()
{
	cin>>n;
	for(int i=0;i<n;i++)
		cin>>a[i];
	for(int i=0;i<n;i++)	
		cin>>b[i];
	for(int i=0;i<n-1;i++)	
		cin>>c[i];	
	for(int i=0;i<n;i++)
	{
		if(a[i+1]==a[i]+1)
			m+=c[a[i]-1];
		m+=b[a[i]-1];	
	}	
	cout<<m<<endl;
} 

Measured memory_bytes: 256
tri = {} # 1: normal, chokkaku, eikaku donkaku
for i in range(4) :
    tri[i + 1] = 0
    
while(True) :
    l = sorted(map(int, input().split()), reverse=True)
    a, b, c = l[0], l[1], l[2]
    
    if a >= b + c :
        break
    else :
        if b ** 2 + c ** 2 == a ** 2:
            tri[1] += 1
        elif b ** 2 + c ** 2 > a ** 2:
            tri[2] += 1
        else :
            tri[3] += 1
            
print(sum(tri.values()), tri[1], tri[2], tri[3])


Measured memory_bytes: 5604
import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int[] length = new int[3];

        for(int i = 0; i < n; i++){
            for(int j = 0; j < 3; j++){
                length[j] = sc.nextInt();
            }

            Arrays.sort(length);

            if(length[0]*length[0] + length[1]*length[1] == length[2]*length[2]){
                System.out.println("YES");
            }else{
                System.out.println("NO");
            }
        }

    }
}

Measured memory_bytes: 23396
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
template<typename T> bool chmax(T &a,T b){if(a<b){a=b;return true;}return false;}
template<typename T> bool chmin(T &a,T b){if(a>b){a=b;return true;}return false;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef tuple<ll,ll,ll> tlll;
typedef tuple<int,int,int> tiii;
const ll mod=1e9+7;
const int inf=1<<30;

int main(){
  string s; cin >> s;
  if(s=="ABC"){
    cout << "ARC" << endl;
  }
  else{
    cout << "ABC" << endl;
  }
  
}

Measured memory_bytes: 3596
#include <iostream>
#include <string>
#include <queue>
#include <algorithm>
using namespace std;

int main(){
  int n, q, t;
  string name;
  queue<pair<string, int> > Q;

  cin >> n >> q;
  for (int i = 0; i < n; i++) {
    cin >> name >> t;
    Q.push(make_pair(name, t));
  }

  pair<string, int> u;
  int elaps = 0;
 
  while (!Q.empty()) {
    u = Q.front(); Q.pop();
    if (u.second > q) {
      elaps += q;
      u.second -= q;
      Q.push(u);
    } else {
      elaps += u.second;
      cout << u.first << ' ' << elaps << endl;
    }
  }
}



Measured memory_bytes: 6336
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int K = sc.nextInt();
		String S = sc.next();
		if (S.length() <= K) {
			System.out.println(S);
		} else {
			System.out.println(S.substring(0, K) +"...");
		}
	}
}

Measured memory_bytes: 38652
h, w = map(int, input().split())
c = [list(map(int, input().split())) for _ in range(10)]
a = [list(map(int, input().split())) for _ in range(h)]

def warshall_floyd(d, n):
    # 経由する頂点
    for k in range(n):
        # 始点
        for i in range(n):
            # 終点
            for j in range(n):
                # 始点 - 終点よりも経由点を通った方が良いのであれば更新
                d[i][j] = min(d[i][j], d[i][k] + d[k][j])
    return d
dist = warshall_floyd(c,10)
ans = 0
for i in range(h):
    for j in range(w):
        if a[i][j] == -1:
            continue
        ans += dist[a[i][j]][1]
print(ans)

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

bool dfs(int num, int val1, int val2, vector<int> &v){
  if(val1 > val2){
    int x = val1;
    val1 = val2;
    val2 = x;
  }
  if(num == 10)
    return true;

  if(val2 < v[num]){
    val2 = v[num];
    return dfs(num + 1, val1, val2, v);
  }else if(val1 < v[num]){
    val1 = v[num];
    return dfs(num + 1, val1, val2, v);
  }else {
    return false;
  }
}

int main(){
  int N;
  cin >> N;
  vector<int> v(10);
  vector<int> out(N, 0);
  for(int i=0;i<N;i++){
    for(int j=0;j<10;j++)
      cin >> v[j];
    if(dfs(0, 0, 0, v)){
      out[i] = 1;
    }
  }

  for(int i=0;i<N;i++)
    if(out[i] == 1)
      cout << "YES" << endl;
    else 
      cout << "NO" << endl;

  return 0;
}

Measured memory_bytes: 1184
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using P = pair<lint, lint>;

int main() {
    lint n, k;
    cin >> n >> k;

    vector<P> dt(n);
    for(int i=0; i<n; i++) cin >> dt[i].second >> dt[i].first;
    sort(dt.rbegin(), dt.rend());

    lint sum = 0;
    map<lint, lint> inside, all;
    priority_queue<P, vector<P>, greater<P>> pq;
    for(int i=0; i<n; i++) {
        lint d = dt[i].first, t = dt[i].second;
        if(i<k) {
            sum += d;
            pq.push(dt[i]);
            inside[t]++;
        }
        all[t]++;
    }
    lint kind = inside.size();
    lint ans = sum + kind * kind;
    
    for(int i=k; i<n; i++) {
        // 1. 取り除く
        while(!pq.empty()) {
            lint d, t;
            tie(d, t) = pq.top(); pq.pop();
            if(inside[t] == 1) continue;
            inside[t]--;
            sum -= d;
            break;
        }
        if(pq.empty()) break;

        // 2. 追加する
        lint d = dt[i].first, t = dt[i].second;
        pq.push(dt[i]);
        inside[t]++;
        sum += d;
        kind = inside.size();

        ans = max(ans, sum + kind * kind);
    }
    cout << ans << endl;
}

Measured memory_bytes: 12020
#include<iostream>
#include<cmath>
#include <vector>
using namespace std;

int main(){

  int N = 0;
  cin >> N;

  string S = "";
  cin >> S;

  string alp = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

  for (int i = 0; i < S.size(); i++) {
    for (int j = 0; j < 26; j++) {
      if (S[i] == alp[j]) {
        int position = (j + N) % 26;
        cout << alp[position];
      }
    }
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    //cout << "notstartred";
    int n;
    //cout << "start\n";
    cin >> n;
    int a[n];
    int cnt[3];
    memset(cnt, 0, sizeof(cnt));
    for(int i = 0; i < n; i++){
        cin >> a[i];
        cnt[a[i] - 1] ++;
    }
    //cout << "seg\n";
    double dp[310][310][310];
    memset(dp, 0, sizeof(dp));
    for(int k = 0; k <= n; k ++){
        for(int j = 0; j + k <= n; j++){
            for(int i = 0; i + j + k <= n; i++){
                if( i + j + k == 0) continue;
                double wait = 1.0 * n/(i + j + k);
                double p1 = 1.0 * i/(i + j + k);
                double p2 = 1.0 * j/(i + j + k);
                double p3 = 1.0 * k/(i + j + k);
                if(i)
                    dp[i][j][k] += p1 * dp[i - 1][j][k];
                if(j)
                    dp[i][j][k] += p2 * dp[i + 1][j - 1][k];
                if(k)
                    dp[i][j][k] += p3 * dp[i][j + 1][k - 1];
                dp[i][j][k] += wait;
            }
        }
    }
    cout << setprecision(10);
    cout << dp[cnt[0]][cnt[1]][cnt[2]] << "\n";
    return 0;
}

Measured memory_bytes: 232960
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n, p[], num[], ans = 0, j = 0;
		
		n = sc.nextInt();
		p = new int[n];
		num = new int[n];
		
		for(int i = 0; i < n; ++i) {
			p[i] = sc.nextInt();
			if(p[i] == i + 1)num[j++] = i;
		}
		sc.close();
		
		if(j != 0) {
			for(int i = 0; i < j; ++i) {
				int tmp = num[i];
				if(tmp < n - 1 && p[tmp + 1] == tmp + 2)
					++i;
				ans++;
			}
		}
		System.out.println(ans);
	}

}


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

class Program {

    private static int Main() {
        while( true ) {
            var input = Console.ReadLine();
            var sum = input.Select( _ => int.Parse( _.ToString() ) ).Sum();

            if( sum != 0 ) {
                Console.WriteLine( sum );
            } else {
                break;
            }
        }


        return 0;
    }

}

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

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

	vector<int> d(n);
	for (int i = 0; i < n; i++) {
		cin >> d.at(i);
	}
	
	sort ( d.begin(), d.end());
	d.erase(unique(d.begin(), d.end()), d.end());

	cout << d.size();
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef  long long int ll;
string int2string(int x){
        stringstream ss;
        ss << x;
        string tmp;
        ss >> tmp;
        return tmp;
    }
int string2int(string s){
    stringstream ss;
    ss << s;
    int x;
    ss >> x;
    return x;
}
long long power(long long a, long long b) {
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}
long long bigpow(long long a, long long b, long long m) {
    a %= m;
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}
ll gcd(ll a,ll b)
{
    if(b==0)
    return a;
    else return gcd(b,a%b);
}
ll lcm(ll a,ll b)
{
    ll r= a/gcd(a,b)*b;
    return r;
}
//***********************CODE*****************
void dfs(vector<vector<int> >&g,vector<vector<char> >&ans,int p,int i,vector<bool>&vis)
{
	ans[p][i]='Y';
	for(int j=0;j<g[i].size();j++)
	{
		if(!vis[g[i][j]])
		{
			vis[g[i][j]]=1;
			dfs(g,ans,p,g[i][j],vis);
			vis[g[i][j]]=0;
		}
	}
}
int main(){
    
cin.tie(NULL);
cout.tie(NULL);
ios_base::sync_with_stdio(false);

	ll n,k;
	cin>>n>>k;
	ll a[n];
	for(int i=0;i<n;i++)cin>>a[i];
	ll prev=a[0];
	int x=0;
	for(int i=k;i<n;i++)
	{
		//cout<<prev<<" "<<a[i]<<"\n";
		if(prev>=a[i])
		{
			cout<<"No\n";
		}
		else
		{
			cout<<"Yes\n";
		}
		prev=a[++x];
	}
    return 0;
}



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

int main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	if(a+b > c+d){
		cout << "Left" << endl;
	}else if(a+b == c+d){
		cout << "Balanced" << endl;
	}else{
		cout << "Right" << endl;
	}
}



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

#define ll long long

using namespace std;

bool isNear(ll x, ll y, ll d)
{
  ll d1 = x*x + y*y;
  d = d * d;
  if (d1 <= d) return true;
  return false;
}

int main()
{
  int n; ll d, a, b;
  cin>>n>>d;
  int ans = 0;
  for (int i=0; i<n; i++)
  {
    cin>>a>>b;
    if (isNear(a,b,d)) ans++;
  }
  cout << ans << '\n';
  return 0;
}

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

using namespace std;
#define _USE_MATH_DEFINES_
#define ll long long
#define ld long double
#define Accepted 0
#define pb push_back
#define mp make_pair
#define sz(x) (int)(x.size())
#define every(x) x.begin(),x.end()
#define F first
#define S second
#define lb lower_bound
#define ub upper_bound
#define For(i,x,y)  for (ll i = x; i <= y; i ++) 
#define FOr(i,x,y)  for (ll i = x; i >= y; i --)
#define SpeedForce ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
// ROAD to...                                                                                                                                                                                                                Red

inline void Input_Output () {
	//freopen(".in", "r", stdin);
   //freopen(".out", "w", stdout);
}

const double eps = 0.000001;
const ld pi = acos(-1);
const int maxn = 1e7 + 9;
const int mod = 1e9 + 7;
const ll MOD = 1e18 + 9;
const ll INF = 1e18 + 123;
const int inf = 2e9 + 11;
const int mxn = 1e6 + 9;
const int N = 6e5 + 123;                                          
const int M = 22;
const int pri = 997;
const int Magic = 2101;

const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};
 
int n, m, k;
int cur = 1;
int c[N];
int a[N];
set < vector < int > > var;
void gen (int p = 1) {
	if (p == n) {
		//cout << "variant:\n";
		vector < int > v;
		for (int i = 0; i < n; i++) {
			set < int > q;
			for (int j = 0; j < n; j++) if (i != j) {
				q.insert(c[j]);
			}
			v.pb(sz(q));

		}
		sort(every(v));
		var.insert(v);

	//	cout << '\n';
		return;
	}
	c[p] = cur;
	gen(p+1);
	c[p] = ++cur;
	gen(p+1);
	--cur;
}

inline void fail() {
	cout << "No\n";
	exit(0);
	
}

inline void good() {
	cout << "Yes\n";
	exit(0);
	
}

int main () {
	SpeedForce;
	cin >> n;
	/*c[0] = 1;
	gen();

	cout << "correct:\n";
	for (auto it : var) {
		for (auto vv : it)
			cout << vv << ' ';
		cout << '\n';	
	}                    //*/
	//exit(0);
	for (int i = 1; i <= n; i ++) {
		cin >> a[i];
	}	
	sort(a + 1, a + n + 1);
	if (a[n] - a[1] > 1) {
		fail();
	}
	if (a[n] == a[1] && a[1] < n - 1 && a[1] > n / 2) {
		fail();
	}
	if (a[n] == a[1]) {
		good();
	}
	int ptr = 1;
	while(a[ptr + 1] == a[1]) ++ptr;

	if (ptr > a[1]) fail();

	if (a[1] - (n - 2 - a[1]) > ptr) fail();
	good();

   	return Accepted;
}

// B...a

Measured memory_bytes: 640
#include <stdio.h>
#include <limits.h>

int main(){
  long long int A[100][100]={0},B[100][100]={0},C[100][100]={0};
  int n,m,l,i,j,k;
  scanf("%d %d %d",&n,&m,&l);
  for(i=0;i<n;i++){
    for(j=0;j<m;j++){
      scanf("%d",&A[i][j]);
    }
  }
  for(i=0;i<m;i++){
    for(j=0;j<l;j++){
      scanf("%d",&B[i][j]);
    }
  }
  for(i=0;i<n;i++){
    for(j=0;j<l;j++){
      for(k=0;k<m;k++){
	C[i][j] += A[i][k] * B[k][j];
      }
      printf("%lld",C[i][j]);
      if(j!=l-1)printf(" ");
    }
    puts("");
  }
  return 0;
}

Measured memory_bytes: 860
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<queue>
#include<string>
#include<vector>
#include<float.h>
#include<math.h>
#include<map>
#include<iomanip>
#include<numeric>
using  ll = long long;
using namespace std;
const ll M = 1000000007;

int main(){
  ll a, b; cin >> a >> b;
  int count = 0;
  string ans;
  if(a <= 0 && 0 <= b) ans = "Zero";
  else if(a == 0 || b == 0) ans = "Zero";
  else if(a > 0 && b > 0){
    ans = "Positive";
  }
  else if(a < 0 && b < 0){
    for(int i = a; i <= b; i++){
      count++;
    } if(count % 2 == 0){
      ans = "Positive";
    } else {
      ans = "Negative";
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 256