akhauriyash/Code-Regression huggingface dataset:
//解答見てやり直し
//ほぼあってたのに～～～～～～～～～～～
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,N) for (int i = 0; i < N; i++)

ll x, y, z, k;
vector<ll> a, b, c;

int main() {
    cin >> x >> y >> z >> k;
    a.resize(x); b.resize(y); c.resize(z);
    rep(i,x) scanf("%Ld", &a[i]);
    rep(i,y) scanf("%Ld", &b[i]);
    rep(i,z) scanf("%Ld", &c[i]);

    sort(a.begin(), a.end(), greater<ll>());
    sort(b.begin(), b.end(), greater<ll>());
    sort(c.begin(), c.end(), greater<ll>());

    vector<ll> xysum;
    rep(i,x)rep(j,y) xysum.push_back(a[i]+b[j]);
    sort(xysum.begin(), xysum.end(), greater<ll>());
    

    vector<ll> xyzsum;
    rep(i,min(k,x*y))rep(j,min(k,z)) xyzsum.push_back(xysum[i]+c[j]);
    sort(xyzsum.begin(), xyzsum.end(), greater<ll>());
    rep(i,min(k,x*y*z)) cout << xyzsum[i] << endl;

    return 0;
}

Measured memory_bytes: 42984
input = require("fs").readFileSync("/dev/stdin", "utf8").split("\n")
abcd = input[0]
target = 7
ans = ""
dfs = (str, rest)=>{
  if(rest.length === 0){
    if(eval(str) === target){
      ans = str;
    }
  }else{
    dfs(str+"+"+rest[0], rest.substr(1));
    dfs(str+"-"+rest[0], rest.substr(1));
  }
};
dfs(abcd[0], abcd.substr(1));
console.log(ans+"="+target);

Measured memory_bytes: 16076
#include <cstdio>
#include <cmath>
using namespace std;

int main() {
    int x;
    scanf("%d", &x);

    int result = 1;
    for (int b = 2; b <= 31; b++) {
        for (int p = 2; pow(b, p) <= x; p++) {
            if (pow(b, p) > result) { result = pow(b, p); }
        }
    }
    printf("%d\n", result);
}

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

struct Node{
  int key;
  struct Node *right;
  struct Node *left;
  struct Node *parent;
};

struct Node *root;
struct Node *NIL;


struct Node *find(struct Node *u, int k){
  while (u != NIL && k != u->key){
    if(k < u->key) u = u->left;
    else u = u->right;
  }
  return u;
}

void insert(int k){

  struct Node *y = NIL;
  struct Node *x = root;
  struct Node *z;

  z = (struct Node *)malloc(sizeof(struct Node));

  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x != NIL){
    y = x;
    if(z->key < x-> key) x = x->left;
    else x = x->right;
  }
  z->parent = y;
  if(y == NIL) root = z;
  else{
    if(z->key < y->key) y->left = z;
    else y -> right = z;
  }
}

void inorder(struct Node *u){
  if(u == NIL) return;
  inorder(u->left);
  printf(" %d", u->key);
 
  inorder(u->right);
}

void preorder(struct Node *u){
  if(u == NIL) return;
  printf(" %d", u->key);
  preorder(u->left);
  preorder(u->right);
}

int main(){

  int n;
  int i,j;
  int x;
  
int count=0;
int cnt[10];
int tmp=0;

  struct Node *t;
  char *com;
  char *comin = "insert";
  char *compr = "print";

  com = (char*)malloc(7*sizeof(char));  

  scanf("%d", &n);

  for(i=0; i<n; i++){
    scanf("%s", com);
    if(com[0] == 'f'){
      scanf("%d", &x);
      t = find(root, x);
      if(t != NIL){
	printf("yes\n");
      }
      else{
	printf("no\n");
      }
    }
      else if(strncmp(com,comin,6)==0){
	scanf("%d",&x);
	insert(x);
      }
      else if(strncmp(com,compr,5)==0){

	inorder(root);
	printf("\n");
	preorder(root);
	printf("\n");
      }
    }

    return 0;
  }



Measured memory_bytes: 20516
using System;
class _0007
{
    public static void Main()
    {
        double money = 100000;
        int n = int.Parse(Console.ReadLine());
        for (int i = 0; i < n; i++)
        {
            money += money * 0.05;
            money = Math.Ceiling(money / 1000.0) * 1000.0;
        }
        Console.WriteLine(money);
    }
}

Measured memory_bytes: 5608
#include <iostream>
#include <algorithm>
#include <math.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define REP(i, k, n) for (int i = k; i <= n; ++i)
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    char str[10];
    
    cin >> str;
    
    if(str[0] == 'A' && str[2] == 'B'){
        cout << "Yes" << "\n";
    }else if(str[0] == 'B' && str[2] == 'A'){
        cout << "Yes" << "\n";
    }else if(str[0] == 'A' && str[2] == 'A' && str[1] == 'B'){
        cout << "Yes" << "\n";
    }else if(str[0] == 'B' && str[2] == 'B' && str[1]=='A'){
        cout << "Yes" << "\n";
    }else{
        cout << "No" << "\n";
    }

    return 0;
}

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

struct Point {
  int x,y;
  bool operator < (const Point& p) const {
    if( y != p.y ) return y < p.y;
    return x > p.x;
  }
};
ostream& operator << (ostream& os,const Point& p) {
  os << p.x <<" "<< p.y;
}

int score[100001];
int t[1000000];
int time_[1000000];
int main(){
  priority_queue<Point> Q;
  priority_queue<Point> T;
  int N,R,L;
  int d,x;
  int a=1,b=0;

  cin >>N>>R>>L;


  for(int i=0;i<R;i++){
    cin >>d>>t[i]>>x;    
    score[d]+=x;
    Q.push((Point){d,score[d]});  
    while(!Q.empty() && score[Q.top().x] != Q.top().y){
      Q.pop();
    }
    time_[a]+=t[i]-b; 
    T.push((Point){a,time_[a]});
    while( Q.empty() );
    a=Q.top().x;
    b=t[i];
    time_[a]+=t[i]-b;
    
  }
  
  while( !Q.empty() && score[Q.top().x] != Q.top().y){
    Q.pop();
  }
  time_[a]+=L-b;
  if( !Q.empty() ) a=Q.top().x;
  else a = 1;
  b=L;
  T.push((Point){a,time_[a]});
 
  cout <<T.top().x<<endl;

  while( !T.empty() ){
    //cout <<T.top()<<endl;
    T.pop();
  }
  return 0;
}



    

	    


    

Measured memory_bytes: 22960
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    string s;
    cin>>s;
    bool sx=false,sy=false;
    if((s[0]=='0'&&s[1]<='9'&&s[1]>'0')||(s[0]=='1'&&s[1]<='2'))
    sx=true;
    if((s[2]=='0'&&s[3]<='9'&&s[3]>'0')||(s[2]=='1'&&s[3]<='2'))
    sy=true;
    if(sx&&sy)
    cout<<"AMBIGUOUS";
    else if(sx&&!sy)
    cout<<"MMYY";
    else if(!sx&&sy)
    cout<<"YYMM";
    else
    cout<<"NA";
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

Node treeMinimum(Node x){

  return 0;
}

Node treeMaximum(Node x){

  return 0;
}

Node treeSearch(Node u, int k){
  if((u==NIL)||(k==u->key)){
    return u;
} 
  if(k < u->key){
    return treeSearch(u->left,k);
}
  else {
    return treeSearch(u->right,k);
}
}

Node treeSuccessor(Node x){

  return 0;
}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y



}
void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;
  while(x!=NIL){
    y=x;
    if((z->key) < (x->key)){
      x=(x->left);
    }
    else{
      x=(x->right);
    }
  }
  (z->parent) = y;

  if(y==NIL){
    root=z;
  }
  else if((z->key) < (y->key)){
    (y->left) = z;
  }
  else{
    (y->right) = z;
  }
}

void inorder(Node u){
  if(u != NIL){
    inorder(u->left);
    printf(" %d",(u->key));
    inorder(u->right);
  }
}
void preorder(Node u){
  if(u==NIL) return;
  printf(" %d",(u->key));
  preorder(u->left);
  preorder(u->right);
}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }

  return 0;
}



Measured memory_bytes: 20476
use std::io::Read;
use std::collections::VecDeque;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

    println!("{}", answer);
}

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let n: usize = iterator.next().unwrap().parse().unwrap();
    let mut graph: Vec<Vec<usize>> = vec![Vec::new(); n];
    for _ in 0..(n - 1) {
        let ai: usize = iterator.next().unwrap().parse().unwrap();
        let bi: usize = iterator.next().unwrap().parse().unwrap();
        graph[ai - 1].push(bi - 1);
        graph[bi - 1].push(ai - 1);
    }
    let mut c: Vec<usize> = (0..n).map(|_| iterator.next().unwrap().parse().unwrap()).collect();
    c.sort();
    c.reverse();

    let mut m: usize = 0;
    for i in 1..n {
        m += c[i];
    }

    let mut i: usize = 0;
    let mut d: Vec<usize> = vec![0; n];
    let mut q: VecDeque<usize> = VecDeque::new();
    q.push_back(0);
    d[0] = c[i];
    i += 1;
    while let Some(u) = q.pop_front() {
        for &v in &graph[u] {
            if d[v] != 0 {
                continue;
            }
            d[v] = c[i];
            i += 1;
            q.push_back(v);
        }
    }

    let mut result = String::new();
    result.push_str(&format!("{}\n", m));
    for i in 0..n {
        result.push_str(&format!("{} ", d[i]));
    }
    result.trim().to_string()
}


Measured memory_bytes: 3120
import sys
input = sys.stdin.buffer.readline
N, M, L = map(int, input().split())
d = [[float("inf")] * (N + 1) for _ in range(N + 1)]
for _ in range(M):
  u, v, c = map(int, input().split())
  d[u][v] = c
  d[v][u] = c
Q = int(input())
for k in range(1, N + 1):
  for i in range(1, N + 1):
    for j in range(1, N + 1):
      if d[i][j] > d[i][k] + d[k][j]:
        d[i][j] = d[i][k] + d[k][j]

nd = [[float("inf")] * (N + 1) for _ in range(N + 1)]

for i in range(1, N + 1):
  for j in range(1, N + 1):
    if d[i][j] <= L:
      nd[i][j] = 1
for k in range(1, N + 1):
  for i in range(1, N + 1):
    for j in range(1, N + 1):
      if nd[i][j] > nd[i][k] + nd[k][j]:
        nd[i][j] = nd[i][k] + nd[k][j]

for _ in range(Q):
  s, t = map(int, input().split())
  if nd[s][t] == float("inf"):
    print(-1)
  else:
    print(nd[s][t] - 1)

Measured memory_bytes: 73436
#include<iostream>
#include<algorithm>
using namespace std;
#define INF ( 1 << 30 )
int dp[2][2][5001],data[9999];
int main(){
  int n;
  cin >> n;
  fill_n(**dp,2*2*5001,INF);
  dp[0][0][0] = 0;
  for(int i = 1 ; i < n ; i++ ){
    cin >> data[i];
  }
  for(int i = 0 ; i < n ; i++ ){
    for(int j = 0 ; j <= n / 2 ; j++ ){
      //dp[index+1][next(A)][Acost+1] = min(NoCut:dp[index][A][cost],Cut:dp[index][B][Acost] + data[index]);
      dp[(i+1)&1][0][j+1] = min(dp[i&1][0][j],dp[i&1][1][j]+data[i]);
      //dp[index+1][next(B)][Acost] = min(NoCut:dp[index][B][Acost],Cut:dp[index][B][Acost] + data[index]);
      dp[(i+1)&1][1][j] = min(dp[i&1][1][j],dp[i&1][0][j]+data[i]);
    }
    dp[(i+1)&1][0][0] = INF;
  }
  cout << min(dp[(n/2)%2][0][n/2],dp[(n/2)%2][1][n/2]) << endl;
}

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

int main()
{
    int n,l;
    cin>>n>>l;
    string s[100];
    for(int i=0; i<n; i++)
    {
        cin>>s[i];
    }
    sort(s,s+n);
    for(int i=0; i<n; i++)
    {
        cout<<s[i];

    }
    cout<<"\n";




}





Measured memory_bytes: 256
<?php
fscanf(STDIN, "%s", $s);
fscanf(STDIN, "%d", $k);
$cc = count_chars($s, 1);
$z = 0;
foreach ($cc as $c => $n) {
	$cx[chr($c)] = 1;
	$z += $n;
	if ($z >= 5) break;
}
for ($i = 0; $i < strlen($s); $i++) {
	if (!isset($cx[$s[$i]])) continue;
	$st = $s[$i];
	$ss[$st] = 1;
	for ($j = $i + 1; $j < $i + 5; $j++) {
		if (!isset($s[$j])) break;
		$st .= $s[$j];
		$ss[$st] = 1;
	}
}
$a = array_keys($ss);
sort($a);
echo $a[$k-1];

Measured memory_bytes: 4604
package main

import (
	"fmt"
	"math"
)

func main() {
	var (
		cnt, cntS float64
		X         string
	)
	fmt.Scan(&X)

	for _, v := range X {
		switch v {
		case 'S':
			cntS++
		case 'T':
			if cntS == 0 {
				cnt++
			}
			cntS = math.Max(0, cntS-1)
		}
	}
	fmt.Println(int(cnt + cntS))
}


Measured memory_bytes: 1920
#include <bits/stdc++.h>
#define FOR(i, a, n) for(ll i = (ll)a; i < (ll)n; i++)
#define rep(i, n) FOR(i, 0, n)
#define ALL(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;

constexpr int Mod = 998244353;
constexpr int mod = 1e9 + 7;
constexpr ll inf = 1LL << 60;

template <typename T> constexpr bool chmax(T &a, const T &b) {
    if(a >= b) return false;
    a = b;
    return true;
}
template <typename T> constexpr bool chmin(T &a, const T &b) {
    if(a <= b) return false;
    a = b;
    return true;
}

/*-------------------------------------------*/

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

    int N;
    cin >> N;
    vector<ll> X(N), Y(N);
    vector<ll> a(N), b(N);
    bool odd = false, even = false;
    rep(i, N) {
        cin >> X[i] >> Y[i];
        (X[i] + Y[i] & 1 ? odd : even) = true;
        if(even) Y[i]--; //奇数の場合に帰着 最後に1,Uすればよい
        a[i] = X[i] + Y[i];
        b[i] = X[i] - Y[i];
    }
    if(odd && even) {
        cout << -1 << endl;
        return 0;
    }
    cout << 31 + even << endl;
    for(int i = 30; i >= 0; i--)
        cout << (1 << i) << " ";
    if(even) cout << 1;
    cout << endl;

    string s = "LDUR";
    rep(i, N) {
        string ans;
        ll nowa = 0, nowb = 0;
        for(int j = 30; j >= 0; j--) {
            int A, B;
            nowa += ((A = (nowa < a[i])) ? 1 : -1) << j;
            nowb += ((B = (nowb < b[i])) ? 1 : -1) << j;
            ans.push_back(s[2 * A + B]);
        }
        cout << ans;
        if(even) cout << "U";
        cout << endl;
    }

    return 0;
}

Measured memory_bytes: 512
import java.lang.reflect.Array;
import java.util.Arrays;
import java.util.OptionalInt;
import java.util.Scanner;
import java.util.ArrayList;
import java.util.Collections;
import java.util.stream.Collectors;

public class Main {

    static long gcd(long p, long q) {
        if(q == 0) return p;
        return gcd(q, p % q);
    }

    static boolean isPrime(long n) {
        //if(n == 1) return false;
        long limit = (long)Math.sqrt(n);
        for(long i = 2; i <= limit; i++) {
            if(n % i == 0) return false;
        }

        return true;
    }

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

    public static void main(String[] args) {
        int cnt = 0;
        long A = sc.nextLong(), B = sc.nextLong();
        long gcd = gcd(A, B);
        long limit = (long)Math.sqrt(gcd);
        for(long i = 1; i <= limit; i++) {
            if(gcd % i > 0) continue;

            if(isPrime(i)) {
                cnt += 1;
            }
            if(i * i == gcd) continue;

            if(isPrime(gcd / i)) {
                cnt += 1;
            }
        }

        System.out.print(cnt);
    }
}
//[B@25618e91
//[B@326de728
//

Measured memory_bytes: 35676
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stack>
#include <iomanip>

using namespace std;

struct Map {
    int left = 0;
    int right = 0;
    int up = 0;
    int down = 0;
};

int main() {
    int h, w;
    cin >> h >> w;
    
    vector<string> map(h);
    for(int i = 0; i < h; i++) {
        cin >> map[i];
    }
    
    vector<vector<Map>> v = vector<vector<Map>>(h, vector<Map>(w));
    // left
    for(int i = 0; i < h; i++) {
        int left = -1;
        for(int j = 0; j < w; j++) {
            if(map[i][j] == '#') {
                left = -1;
            }
            else {
                left++;
                v[i][j].left = left;
            }
        }
    }
    
    // right
    for(int i = 0; i < h; i++) {
        int right = -1;
        for(int j = w - 1; j >= 0; j--) {
            if(map[i][j] == '#') {
                right = -1;
            }
            else {
                right++;
                v[i][j].right = right;
            }
        }
    }
    
    // up
    for(int i = 0; i < w; i++) {
        int up = -1;
        for(int j = 0; j < h; j++) {
            if(map[j][i] == '#') {
                up = -1;
            }
            else {
                up++;
                v[j][i].up = up;
            }
        }
    }
    
    // down
    for(int i = 0; i < w; i++) {
        int down = -1;
        for(int j = h - 1; j >= 0; j--) {
            if(map[j][i] == '#') {
                down = -1;
            }
            else {
                down++;
                v[j][i].down = down;
            }
        }
    }
    
    int ans = 0;
    int index_i = 0;
    int index_j = 0;
    for(int i = 0; i < h; i++) {
        for(int j = 0; j < w; j++) {
            ans = max(ans, v[i][j].up + v[i][j].down + v[i][j].left + v[i][j].right);
        }
    }
    
    cout << ans + 1 << endl;
    
    return 0;
}


Measured memory_bytes: 66944
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0;i < (int)(n);i++)
using ll = long long;
const ll MOD=1000000007;
//const ll MOD=998244353;
const long long INF = 1LL << 60;
const double pi=acos(-1.0);
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, -1, 1};

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



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

  ll N; cin>>N;
  string S1,S2; cin>>S1>>S2;
  
  ll ans=1;
  if(S1[0]==S2[0]){
    ans*=3;
    for(int i=1;i<N;i++){
      if(S1[i]==S2[i]&&S1[i-1]==S2[i-1]) ans=ans*2%MOD;
      if(S1[i]!=S2[i]){
        if(S1[i-1]==S2[i-1]) ans=ans*2%MOD;
        else ans=ans*3%MOD;
        i++;
      }
    }
  }
  else{
    ans*=6;
    for(int i=2;i<N;i++){
      if(S1[i]==S2[i]&&S1[i-1]==S2[i-1]) ans=ans*2%MOD;
      if(S1[i]!=S2[i]){
        if(S1[i-1]==S2[i-1]) ans=ans*2%MOD;
        else ans=ans*3%MOD;
        i++;
      }
    }
  }
  
  cout<<ans<<'\n';
  
  return 0;
}

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

#define PB          push_back
#define PF          push_front
#define MP          make_pair
#define FI          first
#define SE          second
#define SIZE( A )   int( ( A ).size( ) )
#define ALL( A )    ( A ).begin( ), ( A ).end( )
#define ALLR( A )   ( A ).rbegin( ), ( A ).rend( )

using namespace std;

typedef long long           ll;
typedef unsigned long long  ull;
typedef long double         lf;
typedef pair< int, int >    pii;
typedef pair< ll, ll >      pll;
typedef vector< bool >      vb;
typedef vector< lf >        vd;
typedef vector< ll >        vll;
typedef vector< int >       vi;
typedef vector< pii >       vpii;

const int MAXN = int( 2e5 );
const int MOD  = int( 360 );
const int oo   = INT_MAX;

int n, k;
ll arr[ MAXN ];
ll acc_l[ MAXN ], acc_r[ MAXN ], acc[ MAXN ];

int main( ) {

  #ifdef LOCAL
    freopen( "input", "r", stdin );
    //freopen( "output", "w", stdout );
  #else
    //freopen( "input", "r", stdin );
    //freopen( "output", "w", stdout );
    ios_base::sync_with_stdio( 0 );
    cin.tie( 0 );
  #endif

  while( cin >> n >> k ) {
    acc[ 0 ] = 0;
    for( int i = 1; i <= n; ++i ) {
      cin >> arr[ i ];
      acc[ i ] = acc[ i-1 ]+arr[ i ];
    }
    acc_l[ 0 ] = 0;
    for( int i = 1; i <= n; ++i ) {
      acc_l[ i ] = acc_l[ i-1 ] + ( arr[ i ] > 0 ? arr[ i ] : 0 );
    }
    acc_r[ n+1 ] = 0;
    for( int i = n; i > 0; --i ) {
      acc_r[ i ] = acc_r[ i+1 ] + ( arr[ i ] > 0 ? arr[ i ] : 0 );
    }
    ll ans = 0;
    for( int i = 1; i+k-1 <= n; ++i ) {
      ll cur = acc_l[ i-1 ]+acc_r[ i+k ];
      ll val = acc[ i+k-1 ]-acc[ i-1 ];
      if( val > 0 ) {
        cur += val;
      }
      ans = max( ans, cur );
    }
    cout << ans << '\n';
  }

  return 0;
}

Measured memory_bytes: 5632
//-----------------------------------------------------------
// すぐ使える
//-----------------------------------------------------------
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        
		// 1行、2つ(複数)数字
		String[] ss0 = br.readLine().trim().split(" ", 0);
		int a = Integer.parseInt(ss0[0]);
		int b = Integer.parseInt(ss0[1]);

		a += b;
		if (a >= 24) { a -= 24; }

        System.out.println(a);
        return;
    }

}

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



Measured memory_bytes: 21076
#include"bits/stdc++.h"
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
const long long mod = 1000000007;
const long long inf = 1ll << 61;
typedef pair<int, int> P;

signed main() {
	string s; cin >> s;
	sort(s.begin(), s.end());
	if (s[0] == s[1] && s[2] == s[3] && s[0] != s[2])puts("Yes");
	else puts("No");
}

Measured memory_bytes: 256
import math


def main():
    n = int(input())
    # a, b = map(int, input().split())
    h = list(map(int, input().split()))
    # s = input()
    # h = [int(input()) for _ in rane(n)]

    count = 1
    maxi = h[0]
    for i in range(1, n):
        if h[i] >= h[i-1] and h[i] >= maxi:
            count += 1
            maxi = h[i]
    print(count)


if __name__ == '__main__':
    main()


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

int main() {
	string S; cin >> S;
	for (unsigned int i = 0; i < S.size() - 1; i++) {
		if (S.at(i) == 'A' && S.at(i + 1) == 'C') {
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
using namespace std;
static const int INFTY = 10001;
int N;
int p[5], t[5];
int dp[101];

void solve() {

    for (int i = 0; i <= N; i++) dp[i] = INFTY;
    int minv = INFTY;
    dp[0] = 0;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < 4; j++) {
            if (i + t[j] > N) minv = min(minv, dp[i]+p[j]);
            else dp[i + t[j]] = min(dp[i+t[j]], dp[i] + p[j]);
        }
    }
    printf("%d\n", min(minv, dp[N]));
}

int main()
{
    scanf("%d", &N);
    for (int i = 0; i < 4; i++) scanf("%d", &p[i]);
    for (int i = 0; i < 4; i++) scanf("%d", &t[i]);
    solve();
    return 0;
}


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

public class Main{

	public static void main(String... args){
		Scanner scan = new Scanner(System.in);

		// input
		int num = scan.nextInt();
		
		// check
		long power = 1;
		for(int i = 1; i <= num; i++){
			power *= i;
			if(power > 1000000007){
				power %= 1000000007;
			}
		}
		
		// answer
		System.out.println(power % 1000000007);
		
	}
}

Measured memory_bytes: 23508
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(int)(a); (i)<(int)(b); ++(i))
#define rFor(i, a, b) for(int (i)=(int)(a)-1; (i)>=(int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;
template<class T> bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T> bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}
template<class T> T div_floor(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>=0 ? a/b : (a+1)/b-1;
}
template<class T> T div_ceil(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>0 ? (a-1)/b+1 : a/b;
}

constexpr lint mod = 1000000007;
constexpr lint INF = mod * mod;
constexpr int MAX = 100010;

int main(){
    int n;
    scanf("%d", &n);
    int nxt[20][n];
    rep(i, n){
        int p;
        scanf("%d", &p);
        nxt[0][i] = i + p;
    }
    For(k, 1, 20)rep(i, n) nxt[k][i] = nxt[k-1][nxt[k-1][i]];

    int d[n];
    fill(d, d+n, mod);
    queue<int> que;
    d[0] = 0;
    que.push(0);
    while(!que.empty()){
        int v = que.front();
        que.pop();
        For(i, 1, 7){
            if(v + i >= n-1){
                printf("%d\n", d[v] + 1);
                return 0;
            }
            int nv = nxt[19][v + i];
            if(nxt[0][nv] != nv) continue;
            if(nv == n-1){
                printf("%d\n", d[v] + 1);
                return 0;
            }
            if(chmin(d[nv], d[v] + 1)) que.push(nv);
        }
    }
}


Measured memory_bytes: 11420
#include <bits/stdc++.h>
using namespace std;
void solve() {
        int n;
        cin >> n;
        vector <int> v;
        for(int i=0;i<n;i++) {
                int x;
                cin >> x;
                v.push_back(x);
        }
        int sum = 0;
        for(int i=0;i<n;i++) {
                for(int j=i+1;j<n;j++) {
                        sum += v[i]*v[j];
                }
        }
        cout << sum << '\n';
        return ;
}
int main() {
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        cout.tie(NULL);
        solve();
        return 0;
}


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

using namespace std;

int n,m,x,f[100000],a[300];

int main(){
	scanf("%d%d",&n,&m); ++m;
	for (int i=1;i<=n;++i)
		scanf("%d",a+i);
	for (int i=1,lst=0;i<m;++i){
		int mn=0; a[0]=1000;
		for (int j=1;j<=n;++j)
			if (j^lst) if (a[j]<a[mn]) mn=j;
		++a[mn];
		f[i]=mn;
		lst=mn;
	}
	for (int i=1;i<=n;++i) if (a[i]<m){puts("-1"); return 0;}
	printf("%d\n",(n-1)*m+1);
	for (int i=1;i<=m;++i){
		for (int j=1;j<=n;++j) if (j!=f[i-1]&&j!=f[i]) printf("%d ",j);
		if (i<m) printf("%d ",f[i]);
	}
	
	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 all(a) a.begin(),a.end()
typedef long long ll;

int main(void){
    int n;
    cin>>n;
    vector<ll> a(n);
    vector<bool> del(n);
    ll sum[2] = {};
    rep(i,n){
        cin>>a[i];
        if(a[i]>0) sum[i%2] += a[i];
        else del[i] = true;
    }

    ll Sum = max(sum[0],sum[1]);
    if(Sum == 0LL){
        int pos = max_element(all(a)) - a.begin();
        del[pos] = false;
        Sum = a[pos];
    }else{
        rep(i,n) if(sum[i%2] < sum[(i+1)%2]){
            del[i] = true;
        }
    }

    vector<int> pos;
 
    int r = n-1;
    while(del[r]) pos.push_back(r--);

    int l = 0;
    while(del[l]) pos.push_back(0), l++;

    for(l+=2; l<=r; l+=2){
        pos.push_back(del[l] ? 2 : 1);
    }
 
    cout<<Sum<<endl<<pos.size()<<endl;
    for(int i : pos){
        cout<<i+1<<endl;
    }
    return 0;
}

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

#define int long long int
#define rep(a,b,c) for(int a=b;a<c;a++)
#define repm(a,b,c) for(int a=(b-1);a>=c;a--)
#define pb push_back
#define str string
#define sf(a) scanfs("%d",&a)
#define pb push_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) (v).begin(), (v).end()

using namespace std;

const int INF = 1e18 + 9;
const int Mod = 1e9 + 7;
inline int replac(str s){double ans=0;rep(i,0,s.length()){ans+=(s[i]-'0')*pow(10,s.length()-i-1);}return (int)ans;}
inline string numstr(int m){str s="";while(m>0){char c;int a=m/10;if(a>0)a=m%(a*10);else a=m;c=(char)('0'+a);s+=c;m/=10;}str st="";for(int i=s.size()-1;i>=0;i--){st+=s[i];}return st;}
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector<pii> vii;
int a[2000][2000];
 queue<pii> p1;
 queue<pii> p2;
signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int w,h;
    cin >> h >> w;
    memset(a,0,sizeof(a));
    rep(i,0,h){
        rep(j,0,w){
            char c;
            cin >> c;
            if(c=='.'){
                p1.push(mp(j,i));
            }else{
                //cout << c-'0' << endl;
                a[i][j]=c-'0';
            }
        }
    }
    int dx[8]={0,1,0,-1,1,-1,-1,1};
    int dy[8]={1,0,-1,0,1,-1,1,-1};
    int ans=0;
    while(!p1.empty()){
        //if(p1.empty())break;
        ans++;
        while(!p1.empty()){
            pii pa = p1.front();p1.pop();
            rep(i,0,8){
                int x=dx[i]+pa.first;
                int y=dy[i]+pa.second;
                if(x<0||y<0||x>=w||y>=h)continue;
                ///a[y][x]--;
                //cout << a[y][x];
                if(a[y][x]==1){
                   // cout << y << x << endl;
                    p2.push(mp(x,y));
                }
                if(a[y][x]>0)a[y][x]--;
            }
        }
        if(p2.empty())break;
        ans++;
        while(!p2.empty()){
            pii pa = p2.front();p2.pop();
            rep(i,0,8){
                int x=dx[i]+pa.first;
                int y=dy[i]+pa.second;
                if(x<0||y<0||x>=w||y>=h)continue;
                if(a[y][x]==1){
                    p1.push(mp(x,y));
                  //  cout << y << x << endl;
                }
                if(a[y][x]>0)a[y][x]--;
            }
        }
    }
    cout << ans-1 << endl;
    return 0;
}

Measured memory_bytes: 34496
#include <cstdio>

int gcd( int m, int n )
{
	if ( ( 0 == m ) || ( 0 == n ) )
		return 0;
	
	while( m != n )
	{
		if ( m > n ) m = m - n;
		else         n = n - m;
	}
	return m;
}

int lcm( int m, int n )
{
	if ( ( 0 == m ) || ( 0 == n ) )
		return 0;
	
	return ((m / gcd(m, n)) * n); 
}

int main()
{
	int a,b;
	while(scanf("%d %d",&a,&b) != EOF)
	{
		int kari1,kari2;
		kari1=gcd(a,b);
		kari2=lcm(a,b);
		printf("%d %d\n",kari1,kari2);
	}
	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
typedef long long ll;
const ll MOD = 1e9+7;
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REP(i,num,n) for(int i=num, i##_len=(n); i<i##_len; ++i)
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<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};
#define print(x) (cout << (x) << endl)
#define pb push_back
#define mp make_pair
#define sz(x) int(x.size())
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class itr> void cins(itr first, itr last){ for(auto i = first; i != last; i++){ cin >> (*i); } }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++) ans += to_string(*i) + " "; if(!ans.empty()) ans.pop_back(); cout << ans << endl; }
#define fs first
#define sc second


const int INF = 1e9;
const ll LLINF = 1e16;

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}
 
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
 
template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}
 
template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
  for(auto &e:u) fill_v<T>(e,v...);
}
 
template<typename T>
T gcd(T a,T b){return b?gcd(b,a%b):a;}

template<typename T>
T ngcd(vector<T> a){
    T res;
    res = a[0];
    for(int i = 1; i < a.size() && res != 1; i++) {
        res = gcd(a[i], res);
    }
    return res;
}
 
template<typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

template<typename T>
T nlcm(vector<T> numbers) {
    T res;
    res = numbers[0];
    for (int i = 1; i < numbers.size(); i++) {
        res = lcm(res, numbers[i]);
    }
    return res;
}


// 素数判定
template<typename T>
bool isPrime(T x){
    T i;
    if(x < 2)return 0;
    else if(x == 2) return 1;
    if(x%2 == 0) return 0;
    for(i = 3; i*i <= x; i += 2) if(x%i == 0) return 0;
    return 1;
}

// 桁和
template<typename T>
T digsum(T n) {
    T res = 0;
    while(n > 0) {
        res += n%10;
        n /= 10;
    }
    return res;
}

// 回文判定
bool kai (string s) {
    string t{s};
    reverse(begin(t), end(t));
    return s == t;
};

// 指定した文字cが文字列に何文字入ってるか
ll stringcount(string s, char c) {
    return count(s.cbegin(), s.cend(), c);
}



// 割り算の切り上げ処理
template<typename T>
T rp(T a, T b) {
  return (a + b - 1) / b;
}


using pint = pair<int, int>;
using pll = pair<ll, ll>;



int main(void)
{
    cout.tie(0);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    int n;
    cin >> n;
    vector<int> l(n);
    rep(i, n) cin >> l[i];
    sort(rall(l));
    int sum = 0;
    REP(i,1,n) sum += l[i];
    Yes(l[0] < sum);

}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <vector>
#include <set>
#include <bitset>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using lint = long long;
using namespace std;

const int MOD = 1000000007;

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

    lint res = N * (N-1) / 2;
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
num = int(input())

# if num % 2 == 0:
#     half = num / 2
# else:
#     half = int(num  + 1) / 2

half = int(num / 2)

count = 0

for i in range(1, half + 1):
    a = i
    b = num - i
#     print(a,b)
    if a != b:
        count += 1
    
print(count)

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

typedef long long ll;
typedef vector<int> vi;

const double PI=acos(-1.0);

int N,R;
void input()
{
    cin>>N>>R;
}

void solve()
{
    if(N>=10) cout<<R<<endl;
    else cout<<R+100*(10-N)<<endl;
}

int main()
{
    cin.tie();
    ios::sync_with_stdio(false);
    input();
    solve();
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()
#ifdef _DEBUG_
	#define debug(...) printf(__VA_ARGS__)
#else
	#define debug(...) (void)0
	#define endl '\n'
#endif
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;

struct Trie {
	Trie *nxt[26]={};
	Trie *lst;
	Trie **to_me;
	int sum=0;
	bool is_S=0;
	Trie(Trie *lst_=NULL, Trie **to_me_=NULL): lst(lst_), to_me(to_me_) {}
};

const int MAXN=100050;
const int MAXL=400100;
string S[MAXN];
Trie *str[MAXN];
Trie *que[MAXL];
int ql=0, qr=0;

int main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	int N;
	cin >> N;
	for(int i=0;i<N;i++) cin >> S[i];
	Trie *root=new Trie(NULL, &root);
	for(int i=0;i<N;i++) {
		Trie *p=root;
		const string &W=S[i];
		for(int j=0;j<SZ(W);j++) {
			if(!p->nxt[W[j]-'a']) p->nxt[W[j]-'a']=new Trie(p, &(p->nxt[W[j]-'a']));
			p=p->nxt[W[j]-'a'];
		}
		str[i]=p;
		p->is_S=1;
	}
	que[qr++]=root;
	while(ql<qr) {
		Trie *p=que[ql++];
		int out_d=0;
		for(int i=0;i<26;i++) if(p->nxt[i]) out_d++;
		if(out_d==1 && !p->is_S) {
			Trie *out=NULL;
			for(int i=0;i<26;i++)
				if(p->nxt[i]) {
					out=p->nxt[i];
					break;
				}
			*(p->to_me) = out;
			out->lst = p->lst;
			out->to_me=p->to_me;
			p->lst=NULL;
			que[qr++]=out;
		}
		else {
			for(int i=0;i<26;i++)
				if(p->nxt[i])
					que[qr++]=p->nxt[i];
		}
	}
	for(int i=0;i<N;i++) {
		S[i].clear();
		auto ton=str[i]->to_me;
		for(auto p=str[i]->lst; p ; p=p->lst) {
			S[i].PB(ton-(p->nxt) + 'a');
			debug("i=%d [%ld]\n",i,ton-(p->nxt));
			ton = p->to_me;
		}
	}
	for(int i=qr-1;i>=0;i--)
		if(que[i]->lst) {
			que[i]->sum=(que[i]->is_S ? 1:0);
			for(int j=0;j<26;j++)
				if(que[i]->nxt[j])
					que[i]->sum += que[i]->nxt[j]->sum;
		}
	// S is stored in reverse order!
	for(int i=0;i<N;i++) debug("(%s)\n",S[i].c_str());
	int Q;
	cin >> Q;
	while(Q--) {
		int K;
		string P;
		cin >> K >> P;
		K--;
		int ans=1;
		auto p=root;
		debug("!\n");
		for(int i=SZ(S[K])-1;i>=0;i--) {
			debug("i=%d\n",i);
			if(p->is_S) ans++;
			for(int j=0;P[j]!=S[K][i];j++)
				if(p->nxt[P[j]-'a'])
					ans+=p->nxt[P[j]-'a']->sum;
			debug("hi\n");
			p=p->nxt[S[K][i]-'a'];
		}
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 98816
import java.util.Scanner;
import java.math.BigDecimal;

class Main{
public static void main(String[] args){
Scanner sc=new Scanner(System.in);
int w=sc.nextInt();
int a=100000;
for(int i=0;i<w;i++){
a+=a/20;
BigDecimal x=new BigDecimal(a);
x=x.setScale(-3,BigDecimal.ROUND_UP);
a=x.intValue();
}
System.out.println(a);
}
}

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

using namespace std;
typedef long long ll;


const int MOD=1e9+7;
ll mod(ll x){
    return (x%MOD + MOD)%MOD;
}
ll mul(ll a , ll b){
    return mod(mod(a)*mod(b));
}

void solve(){
    int n,k;
    cin>>n>>k;
    vector<ll>pos;
    vector<ll>neg;
    for(int i=0;i<n;i++){
        int x;
        cin>>x;
        if(x>0)
            pos.push_back(x);
        else
            neg.push_back(x);
    }

    ll ans=1;
    if(pos.size()>0){
        if(k%2==1){
            sort(pos.begin(),pos.end());
            ///after sort : 5 6 7 8 9 10  
            ans=mul(ans,pos.back());///ODD HOLE LARGEST ELEMENT always INCLUDED : 10 
            pos.pop_back();
            --k;
        }
        ///NOW K IS EVEN 
        ///***REST or "vector ok" IS same for both odd & even ************
        vector<ll>ok;
        sort(pos.begin(),pos.end(),greater<>());///BORO THEKE SOTO ////10 9 8 7 6 5 
        sort(neg.begin(),neg.end());////ascending: -4 -3 -2 -1; 

        for(int i=0;i+1<(int)pos.size();i+=2)
            ok.push_back(pos[i]*pos[i+1]);

        for(int i=0;i+1<(int)neg.size();i+=2)
            ok.push_back(neg[i]*neg[i+1]);

        if((int)pos.size()%2 && (int)neg.size()%2){
            ok.push_back(pos.back()*neg.back());
            /***
            ////10 9 8 7 6  
            ///-16 -5 -4 -3 -2 
             so (10 9) = 90; (8 7 ) = 56; 
                (-16 5) = 80; (-4 -3) = 12; 
            ///both are odd ; so 2tar back() or last element MULTIPLY HOBE: (6 -2) = -12
            So OK: [90 80 56 12 -12]
            */ 

        }

        sort(ok.begin(),ok.end(),greater<>());

        for(int i=0;i<(k/2);i++)
            ans=mul(ans,ok[i]);
        cout<<ans;
    }
    else{
        ///all numbers are negative 
        sort(neg.begin(),neg.end());///[-5 -4 -3 -2 -1 ]
        if((k%2)==1){
            reverse(neg.begin(),neg.end());
            ///odd hole: [-1 -2 -3 -4 -5]; (-1*-2*-3 = -6) ans; k = 3 
        }
        ///even hole: [-5 -4 -3 -2 -1]; (-5*-4*-3*-2 = 120 ans); k= 4
        for(int i=0;i<k;i++){
            ans=mul(ans,neg[i]);
        }
        cout<<ans;
    }
}
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    
    solve();

    return 0;
}


Measured memory_bytes: 6552
// dfmt off
T lread(T=long)(){return readln.chomp.to!T;}T[] lreads(T=long)(long n){return iota(n).map!((_)=>lread!T).array;}
T[] aryread(T=long)(){return readln.split.to!(T[]);}void arywrite(T)(T a){a.map!text.join(' ').writeln;}
void scan(L...)(ref L A){auto l=readln.split;foreach(i,T;L){A[i]=l[i].to!T;}}alias sread=()=>readln.chomp();
void dprint(L...)(lazy L A){debug{auto l=new string[](L.length);static foreach(i,a;A)l[i]=a.text;arywrite(l);}}
static immutable MOD=10^^9+7;alias PQueue(T,alias l="b<a")=BinaryHeap!(Array!T,l);import std;
// dfmt on

void main()
{
    long N = lread();
    long[string] D;
    foreach (_; 0 .. N)
    {
        auto S = sread();
        D[S] = D.get(S, 0) + 1;
    }
    writefln("AC x %s", D.get("AC", 0));
    writefln("WA x %s", D.get("WA", 0));
    writefln("TLE x %s", D.get("TLE", 0));
    writefln("RE x %s", D.get("RE", 0));
}


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

inline int read()
{
    char ch=getchar();
    int x=0,f=1;
    while(ch<'0'||ch>'9'){if(ch=='-') f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9') x=x*10+(ch^48),ch=getchar();
    return x*f;
}

int n,tree[26][500005];

int lowbit(int x)
{
	return x&(-x);
} 
 
void add(int x,int k,int tr)
{
	while(x<=n)
	{
		tree[tr][x]+=k;
		x+=lowbit(x);
	}
}

int sum(int x,int tr)
{
	int ans=0;
	while(x>0)
	{
		ans+=tree[tr][x];
		x-=lowbit(x);
	}
	return ans;
}

signed main()
{
 	ios::sync_with_stdio(false);
	cin.tie(0);
 	
	cin>>n;
	string s;
	cin>>s;
	for(int i=0;i<n;i++)
	{
		add(i+1,1,s[i]-'a');
	}
	int t;
	cin>>t;
	int x,y,z;
	char c;
	while(t--)
	{
		cin>>x;
		if(x==1)
		{
			cin>>y>>c;
			add(y,-1,s[y-1]-'a');
			add(y,1,c-'a');
			s[y-1]=c;
		}
		else if(x==2)
		{
			cin>>y>>z;
			int ans=0;
			for(int i=0;i<26;i++)
			{
				if(sum(z,i)>sum(y-1,i))
				{
					ans++;
				}
			}
			cout<<ans<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 51740
class UnionFind:
    def __init__(self, n):
        self.parent = list(range(n)) #親ノード
        self.size = [1]*n #グループの要素数
 
    def root(self, x): #root(x): xの根ノードを返す．
        while self.parent[x] != x:
            self.parent[x] = self.parent[self.parent[x]]
            x = self.parent[x]
        return x 
 
    def merge(self, x, y): #merge(x,y): xのいる組とyのいる組をまとめる
        x, y = self.root(x), self.root(y)
        if x == y: return False
        if self.size[x] < self.size[y]: x,y=y,x #xの要素数が大きいように
        self.size[x] += self.size[y] #xの要素数を更新
        self.parent[y] = x #yをxにつなぐ
        return True
 
    def issame(self, x, y): #same(x,y): xとyが同じ組ならTrue
        return self.root(x) == self.root(y)
        
    def getsize(self,x): #size(x): xのいるグループの要素数を返す
        return self.size[self.root(x)]

# coding: utf-8
# Your code here!
import sys
readline = sys.stdin.readline
read = sys.stdin.read

n,m = map(int,readline().split())

UF = UnionFind(n)

ans = n-1
for i in range(m):
    a,b = map(int,readline().split())
    if UF.merge(a-1,b-1):
        ans -= 1

print(ans)





Measured memory_bytes: 13628
n = int(input())
h = list(map(int, input().split()))

dp = [10**18] * (10**5+10)
dp[0] = 0

for i in range(n):
  if i+1 < n:
    dp[i+1] = min(dp[i+1], dp[i] + abs(h[i+1] - h[i]))
  if i+2 < n:
    dp[i+2] = dp[i] + abs(h[i+2] - h[i])

print(dp[n-1])

Measured memory_bytes: 52208
#include<bits/stdc++.h>
#define M 1000000007
#define pi ld(acos(-1.0))
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define Rep(i,n) for(int i=1;i<(int)(n);i++)
#define repp(i,a,b)  for(int i=a;i<=(int)(b);i++)
#define Repp(i,a,b)  for(int i=a;i>=(int)(b);i--)
#define cs ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define fi first
#define se second
#define ii pair<ll,ll>
#define bye(x) {cout<<x;return 0;}
typedef long long ll;
typedef long double ld;
using namespace std;

int main() {
    cs
    string s;cin>>s;
    char c=s.back();
    if(c=='2'||c=='4'||c=='5'||c=='7'||c=='9') cout<<"hon";
    else if(c=='3') cout<<"bon";
    else cout<<"pon";

}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  // 入力
  int N ;
  cin >> N;
  vector<pair<string,int>> v(N,pair<string,int>("",0));
  vector<pair<string,int>> w(N,pair<string,int>("",0));
  for(int i =0;i<N;i++){
   cin >> get<0>(v.at(i)) >>get<1>(v.at(i));
    w.at(i).first = get<0>(v.at(i));
    w.at(i).second =100 - get<1>(v.at(i));
  }
  sort(w.begin(),w.end());
  for(int i = 0;i<N;i++){
   w.at(i).second = 100 - w.at(i).second; 
  }
  for(pair<string,int> x:w ){
   for(int i= 0;i<N;i++){
      if ((get<0>(v.at(i))==x.first)&&(get<1>(v.at(i)) == x.second )){
      cout<< i+1 << endl; 
     }
   }
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iterator>
#include <iomanip>
#include <cmath>
#include <vector>
#include <numeric>
#include <cstdio>
#include <bitset>
#include <map>
#include <string>
// #include <cctype>


using namespace std;

void get_value(string pattern, int next[]);


int main()
{

    //method 1 failure
    // string text, word, temp;

    // cin >> word;

    // while (getline(cin, temp) && temp != "END_OF_TEXT")
    //     text += ' ' + temp;

    // // cout << text << endl;


    // int next[10];
    // get_value(word, next);

    // // copy(next, next+10, ostream_iterator<int>(cout, " "));


    // int i = 0, j = 0, sum = 0;
    // while (text[i] != '\0')
    // {
    //     if (j == -1 || tolower(text[i]) == word[j])
    //     {
    //         i++;
    //         j++;
    //     }
    //     else
    //         j = next[j];

    //     if (j != -1 && word[j] == '\0')
    //     {
    //         sum++;
    //         j = 0;
    //     }
    // }

    // cout << sum << endl;


    //method 2

    string word, text;

    cin >> word;

    int sum = 0;
    while (cin >> text && text != "END_OF_TEXT")
    {
        int i = 0;
        while (word[i] == tolower(text[i]))
            i++;
        
        if (i > word.size())
            sum++;
    }

    cout << sum << endl;
}



void get_value(string pattern, int next[])
{
    int i = 0, j = -1;
    next[0] = -1;

    while (pattern[i] != '\0')
        if (j == -1 || pattern[i] == pattern[j])
        {
            i++;
            j++;
            if (pattern[i] != pattern[j])
                next[i] = j;
            else 
                next[i] = next[j];
        }
        else
            j = next[j];
}


Measured memory_bytes: 3164
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ll long long
#define lld long double
#define ALL(x) x.begin(), x.end()
#ifdef DEBUG
#define line() cerr << "[" << __LINE__ << "] ";
#define dump(i) cerr << #i ": " << i << " ";
#define dumpl(i) cerr << #i ": " << i << endl;
#else
#define line(i)
#define dump(i)
#define dumpl(i)
#endif
using namespace std;
const ll INF = (1ll << 60);
const int IINF = (1 << 30);

vector<int> dijkstra(map<int, vector<int>> &g, int n, int s)
{
    priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> pque;
    map<int, bool> used;
    pque.push({0, s});
    vector<int> ret(n, IINF);
    while (!pque.empty())
    {
        int cost = pque.top().first;
        int cur = pque.top().second;
        pque.pop();
        if (used[cur])
        {
            continue;
        }
        used[cur] = true;
        ret[cur] = cost;
        for (auto x : g[cur])
        {
            if (used[x] == false)
                pque.push({cost + 1, x});
        }
    }
    return ret;
}

int main(int argc, char const *argv[])
{
    int n, m;
    cin >> n >> m;
    map<int, vector<int>> g;
    rep(i, m)
    {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        g[a].push_back(b);
        //g[b].push_back(a);
    }
    int s, t;
    cin >> s >> t;
    s--;
    t--;
    if (m == 0)
    {
        cout << -1 << endl;
        return 0;
    }
    map<int, vector<int>> h;
    rep(i, n)
    {
        for (auto x : g[i])
        {
            h[3 * i + 0].push_back(3 * x + 1);
            h[3 * i + 1].push_back(3 * x + 2);
            h[3 * i + 2].push_back(3 * x + 0);
        }
    }
    cerr << "ok" << endl;
    auto dist = dijkstra(h, 3 * n, 3 * s);
    if (dist[3 * t] == IINF)
    {
        cout << -1 << endl;
    }
    else
    {
        cout << dist[3 * t] / 3 << endl;
    }

    return 0;
}


Measured memory_bytes: 59264
#define _CRT_SECURE_NO_WARNINGS

#include<stdio.h>

int main(void)
{
	int a, b;

	char op;

	while (1) {
		scanf("%d ", &a);  op = getchar(); scanf("%d", &b);

		if (op == '+')
			printf("%d\n", a + b);
		else if (op == '-')
			printf("%d\n", a - b);
		else if (op == '*')
			printf("%d\n", a*b);
		else if (op == '/')
			printf("%d\n", a / b);
		else if (op == '?')
			break;
	}
	return 0;
}


Measured memory_bytes: 2724