akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace Competitive
{
    internal class Solution
    {
        public int N;

        public void Run()
        {
            N = Input.ReadInt();
            Console.WriteLine(N <= 999 ? "ABC" : "ABD");

        }
    }

    // libs ----------
    

    // common ----------

    internal static class Input
    {
        public static string ReadString()
        {
            string line = Console.ReadLine();
            return line;
        }

        public static int ReadInt()
        {
            string line = Console.ReadLine();
            return int.Parse(line);
        }

        public static int[] ReadIntArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(int.Parse).ToArray();            
        }

        public static long ReadLong()
        {
            string line = Console.ReadLine();
            return long.Parse(line);
        }

        public static long[] ReadLongArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(long.Parse).ToArray();
        }

        public static double[] ReadDoubleArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(double.Parse).ToArray();
        }
    }
    
    internal class Program
    {
        public static void Main(string[] args)
        {
            var s = new Solution();
            s.Run();
        }
    }
}

Measured memory_bytes: 13140
import java.util.Scanner;

class Main {

	public static void main(String[] args) {
		try (Scanner sc = new Scanner (System.in)){
			double x1 = sc.nextDouble();
			double y1 = sc.nextDouble();
			double x2 = sc.nextDouble();
			double y2 = sc.nextDouble();
			
			double x = x1-x2;
			double y = y1-y2;

			double ans = Math.sqrt(Math.pow(x, 2) + Math.pow(y, 2) );

			System.out.println(ans);
		}
	}

}



Measured memory_bytes: 28124
#include<iostream>
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<<"Right"<<endl;
	else
	cout<<"Balanced"<<endl;
} 

Measured memory_bytes: 256
#include<stdio.h>
#define MAXWI 100000
 
int gP,gSum,gMaxW;
int gw[MAXWI+1];
int gn,gk;
 
 
void carryPackage( int maxPackage )
{
    int i;
    int tmpk;
    int package;
      
    if( gMaxW <= maxPackage ) {
        tmpk=gk;
        package=i=0;
        while( i < gn ) {
            package+=gw[i];
            if( maxPackage <= package ) {
                if( maxPackage < package ) {
                    i--;
                }
                tmpk--;
                if( maxPackage*tmpk < gn-i ) { break; }
                if( tmpk == 0 ) { break; }
                package=0;     
            }
            i++;
        }
        if( 1<=tmpk || (0==tmpk && i == (gn-1)) ) {
            gP=maxPackage;
        } else {
        	if( gMaxW < maxPackage ) {
        		gMaxW=maxPackage;
        	}
        }
    }
    
    return;
}
 
int main( void ) 
{
    int i,j;
    int end;
    int maxPackage;
         
    scanf( "%d%d", &gn, &gk );

    end=gn/gk;
    maxPackage=gMaxW=gSum=0;
   for( i=0; i<end; i++ ) {
        scanf( "%d", &gw[i] );
        maxPackage+=gw[i];
        gSum+=gw[i];
		if( gMaxW < gw[i] ) {
        	gMaxW=gw[i];
    	}
    }   
    for( i=end; i<gn; i++ ) {
        scanf( "%d", &gw[i] );
        gSum+=gw[i];
		if( gMaxW < gw[i] ) {
        	gMaxW=gw[i];
    	}
    }
 
    if( 1 == gk ) {
        gP=gSum;    
    } else if( gk < gn ) {
	    gP=gSum;
	  	i=0;
	  	j=end;
        if( gMaxW < gSum/gk ) { gMaxW=gSum/gk; }
        while( i < gn ) {
            while( end < gn ) {
                maxPackage+=gw[end];
                if(  maxPackage < gP ) {
                    carryPackage( maxPackage );
                } else {
                    break;
                }
                j++;
                end=i+j;
            }
            maxPackage-=gw[end];
            maxPackage-=gw[end-1];            
	        maxPackage-=gw[i];
           	end--;
            j-=2;
            i++;
            if( end <= i  ) {
                maxPackage=0;
                end=i;
                j=0;
            }
        }
    } else {
    	gP=gMaxW;
    }
    printf( "%d\n", gP );
 
    return 0;
}

Measured memory_bytes: 984
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
int main() {
    string S;
    cin >> S;
    int ans = 0;
    if(S.find("RRR") != -1){
        cout << 3 << endl;
    }else if(S.find("RR") != -1){
        cout << 2 << endl;
    }else if(S.find("R") != -1){
        cout << 1 << endl;
    }else{
        cout << 0 << endl;
    }
}

Measured memory_bytes: 3624
#include<iostream>
#include<iomanip>
#include<math.h>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<string>
#include<bitset>
#include<random>
#include<time.h>
#define INF 1000000000ll
#define MOD 1000000007ll
#define EPS 1e-10
#define REP(i,m) for(long long i=0; i<(ll)m; i++)
#define FOR(i,n,m) for(long long i=n; i<(ll)m; i++)
#define DUMP(a) for(long long dump=0; dump<(ll)a.size(); dump++) { cout<<a[dump]; if(dump!=(ll)a.size()-1) cout<<" "; else cout<<endl; }
#define ALL(v) v.begin(),v.end()
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef long double ld;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll a,b;
	cin>>a>>b;
	vector<vector<char>> ans1(50,vector<char>(100));
	vector<vector<char>> ans2(50,vector<char>(100));
	REP(i,50) {
		REP(j,100) {
			ans1[i][j]='.';
			ans2[i][j]='#';
		}
	}
	a--;
	b--;
	for(ll i=1; i<49; i+=2) {
		for(ll j=1; j<99; j+=2) {
			if(b>0) {
				ans1[i][j]='#';
				b--;
			}
			if(a>0) {
				ans2[i][j]='.';
				a--;
			}
		}
	}
	cout<<100<<" "<<100<<endl;
	REP(i,50) {
		REP(j,100) {
			cout<<ans1[i][j];
			if(j==99) cout<<endl;
		}
	}
	REP(i,50) {
		REP(j,100) {
			cout<<ans2[i][j];
			if(j==99) cout<<endl;
		}
	}
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"bytes"
	"fmt"
	"log"
	"os"
	"sort"
	"strconv"
	"strings"
)

type st struct {
	no, order int
}

type sts []st

func (f sts) Len() int {
	return len(f)
}

func (f sts) Less(i, j int) bool {
	return f[i].order < f[j].order
}

func (f sts) Swap(i, j int) {
	f[i], f[j] = f[j], f[i]
}

func main() {
	scanner := makeWordScanner()
	n := eGetInt(scanner)
	a := make([]st, n)
	for i := 0; i < n; i++ {
		a[i].no = i + 1
		a[i].order = eGetInt(scanner)
	}
	sort.Sort(sts(a))
	var buf bytes.Buffer
	sep := ""
	for _, e := range a {
		buf.WriteString(fmt.Sprintf("%s%d", sep, e.no))
		sep = " "
	}
	fmt.Println(buf.String())
}

////////////////////////////////////////////////////////////////////////////////
// ライブラリ
////////////////////////////////////////////////////////////////////////////////
func makeScanner(maxByte int) *bufio.Scanner {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Buffer(make([]uint8, 0, 8192), maxByte)
	return scanner
}
func makeWordScanner() *bufio.Scanner {
	scanner := makeScanner(8192)
	scanner.Split(bufio.ScanWords)
	return scanner
}
func eGetLine(r *bufio.Scanner) string {
	if r.Scan() {
		return r.Text()
	}
	err := r.Err()
	if err != nil {
		log.Fatal(err)
	}
	// EOF
	return ""
}
func eGetInt(r *bufio.Scanner) int {
	line := eGetLine(r)
	return eAtoi(line)
}
func eGetInt64(r *bufio.Scanner) int64 {
	line := eGetLine(r)
	return eAtoInt64(line)
}
func eGetFields(r *bufio.Scanner) []string {
	line := eGetLine(r)
	return strings.Fields(line)
}
func eGetInts(r *bufio.Scanner) []int {
	fields := eGetFields(r)
	ints := make([]int, len(fields))
	for i := 0; i < len(ints); i++ {
		ints[i] = eAtoi(fields[i])
	}
	return ints
}
func eGetInt64s(r *bufio.Scanner) []int64 {
	fields := eGetFields(r)
	ints := make([]int64, len(fields))
	for i := 0; i < len(ints); i++ {
		ints[i] = eAtoInt64(fields[i])
	}
	return ints
}
func eGetChars(r *bufio.Scanner) []string {
	line := eGetLine(r)
	return strings.Split(line, "")
}
func eAtoi(s string) int {
	n, err := strconv.Atoi(s)
	if err != nil {
		log.Fatal(err)
	}
	return n
}
func eAtoInt64(s string) int64 {
	n, err := strconv.ParseInt(s, 10, 64)
	if err != nil {
		log.Fatal(err)
	}
	return n
}


Measured memory_bytes: 6528
#include <bits/stdc++.h>
using namespace std;
struct test {
string T;
int n;

};
int main(){
    test test_cases[4];
    test_cases[0].T = "AC", test_cases[1].T = "WA", test_cases[2].T = "TLE", test_cases[3].T = "RE" ;
    test_cases[0].n = 0, test_cases[1].n = 0, test_cases[2].n = 0, test_cases[3].n = 0;
    int m;
    cin>>m;
    string s;
    for(int i = 0; i < m; i++){
        cin>>s;
        for(int j = 0; j < 4; j++){
            if(s == test_cases[j].T){
                test_cases[j].n++;
            }
        }
    }
    for(int i = 0; i < 4; i++){
        cout<<test_cases[i].T<<" x "<<test_cases[i].n<<endl;
    }
    return 0;
}



Measured memory_bytes: 3616
#include <vector>
#include <iostream>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <numeric>
using namespace std;

int main(){
    int a=0;
    string s;
    cin >> s;
    s.erase(s.end()-1);
    while(1){    
        if(s.length()%2==0){
            a=0;
            for(int i=0;i<s.length()/2;i++){
                if(s[i]==s[i+s.length()/2]){
                    a++;
                    if(a==s.length()/2){
                        cout << a*2;
                        return  0;
                    }
                    continue;
                }else{
                    break;
                }
            }
            s.erase(s.end()-1);
            s.erase(s.end()-1);
        }else{
            s.erase(s.end()-1);
        }
    }
}

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

a = 0
w = 0
t = 0
r = 0

for i in range(n):
    b = input()
    if b == "AC":
        a += 1
    if b == "WA":
        w += 1
    if b == "TLE":
        t += 1
    if b == "RE":
        r += 1
print("AC x", a)
print("WA x", w)
print("TLE x", t)
print("RE x", r)

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

int main(){
  int n, d, ans; cin >> n >> d;
  int s = n / (2*d+1);
  int a = n % (2*d+1);
  if (a!=0){
    ans = s+1;
  }else{
    ans = s;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
/*
 * 2641.cc: Magic Bullet
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 50;

/* typedef */

typedef long long ll;

template <typename T>
struct Pt3d {
  T x, y, z;

  Pt3d() {}
  Pt3d(T _x, T _y, T _z) : x(_x), y(_y), z(_z) {}
  Pt3d(const Pt3d& pt) : x(pt.x), y(pt.y), z(pt.z) {}

  Pt3d<T> operator+(const Pt3d pt) const {
    return Pt3d<T>(x + pt.x, y + pt.y, z + pt.z);
  }
  Pt3d<T> operator-() const {
    return Pt3d<T>(-x, -y, -z);
  }
  Pt3d<T> operator-(const Pt3d pt) const {
    return Pt3d<T>(x - pt.x, y - pt.y, z - pt.z);
  }
  T dot(Pt3d v) const { return x * v.x + y * v.y + z * v.z; }
  Pt3d<T> cross(Pt3d v) const {
    return Pt3d<T>(y * v.z - z * v.y, z * v.x - x * v.z, x * v.y - y * v.x);
  }
  T d2() { return x * x + y * y + z * z; }
  double d() { return sqrt(d2()); }

  void print(string format) {
    printf(("(" + format + ", " + format + ", " + format + ")").c_str(),
           x, y, z);
  }
  void print() { print("%.6lf"); }
};

typedef Pt3d<double> pt3d;

/* global variables */

pt3d cps[MAX_N];
double rs[MAX_N];
ll ls[MAX_N];

/* subroutines */

double dist_p_seg(pt3d &s0, pt3d &s1, pt3d &p) {
  pt3d v = s1 - s0, p0 = p - s0, p1 = p - s1;
  double d0 = v.dot(p0), d1 = v.dot(p1);

  if (d0 <= 0.0) return p0.d();
  if (d1 >= 0.0) return p1.d();
  return sqrt(p0.d2() - d0 * d0 / v.d2());
}

/* main */

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

  for (int i = 0; i < n; i++)
    cin >> cps[i].x >> cps[i].y >> cps[i].z >> rs[i] >> ls[i];

  while (qn--) {
    pt3d sp, gp;
    cin >> sp.x >> sp.y >> sp.z >> gp.x >> gp.y >> gp.z;

    ll sum = 0;
    for (int i = 0; i < n; i++) {
      double d = dist_p_seg(sp, gp, cps[i]);
      if (d <= rs[i]) sum += ls[i];
      if (false) {
	sp.print(); putchar('-'); gp.print(); printf(" : "); cps[i].print();
	printf(" = %lf\n", d);
      }
    }
    printf("%lld\n", sum);
  }
  return 0;
}

Measured memory_bytes: 1220
import collections

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

b = int(input())
c = collections.Counter(prime_factorize(b))
ans = 0

for i in (c.keys()) :
    for j in range (50) :
        if j*(j+1)/2 <= c[i] < (j+1)*(j+2)/2 :
            ans += j

print(ans)

Measured memory_bytes: 9472
#include<cstdio>
#include<algorithm>
using namespace std;
#define MN 100
char s[MN+5][MN+5];
short R[MN+5][MN+5],C[MN+5][MN+5],f[MN+5][MN+5][MN+5][MN+5],ans;
void rw(short&a,short b){if(b>a)a=b;}
int qr(int x,int l,int r){return l<=r?R[x][r]-R[x][l-1]:0;}
int qc(int x,int l,int r){return l<=r?C[r][x]-C[l-1][x]:0;}
int main()
{
	int n,m,i,j,x,y,a,b,c,d;
	scanf("%d%d",&n,&m);
	for(i=1;i<=n;++i)
	{
		scanf("%s",s[i]+1);
		for(j=1;j<=m;++j)
		{
			if(s[i][j]=='E')x=i,y=j;
			R[i][j]=R[i][j-1]+(s[i][j]=='o');
			C[i][j]=C[i-1][j]+(s[i][j]=='o');
		}
	}
	for(a=0;x-a;++a)for(b=0;x+b<=n;++b)for(c=0;y-c;++c)for(d=0;y+d<=m;++d)
	{
		if(x-a-1)rw(f[a+1][b][c][d],f[a][b][c][d]+(x-a-1>b)*qr(x-a-1,max(y-c,d+1),min(y+d,m-c)));
		if(x+b+1<=n)rw(f[a][b+1][c][d],f[a][b][c][d]+(x+b+1<n-a+1)*qr(x+b+1,max(y-c,d+1),min(y+d,m-c)));
		if(y-c-1)rw(f[a][b][c+1][d],f[a][b][c][d]+(y-c-1>d)*qc(y-c-1,max(x-a,b+1),min(x+b,n-a)));
		if(y+d+1<=m)rw(f[a][b][c][d+1],f[a][b][c][d]+(y+d+1<m-c+1)*qc(y+d+1,max(x-a,b+1),min(x+b,n-a)));
		rw(ans,f[a][b][c][d]);
	}
	printf("%d",ans);
}

Measured memory_bytes: 205056
#include <iostream>
using namespace std;
int main(void){
    int a,b,c;
    
    cin>>a>>b>>c;
    if(a>b && a>c)cout<<b+c<<endl;
    if(b>a && b>c)cout<<a+c<<endl;
    if(c>a && c>b)cout<<a+b<<endl;
    if(a==b && b==c)cout<<a+b<<endl;
    return 0;
}

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

// エイリアス
using  ll = long signed long;
using ull = long unsigned long;
using  ld = long double;
using   P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;

// 汎用マクロ
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOREACH(i,q) for (auto &i : q)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
#define SZ(x) ((int)(x).size())
template <class T>inline bool chmin(T &a, const T b) {if (a > b) { a = b; return true;} return false;}
template <class T>inline bool chmax(T &a, const T b) {if (a < b) { a = b; return true;} return false;}
template <class T>inline void line_out(const vector<T> vec) {int n = SZ(vec); rep(i, n) { cout << vec[i]; if(i < n-1) cout << " ";}cout << endl;}
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 28;
const ll INF64 = 1ll << 55;
const int mod = 1000000007;
//const int mod = 998244353;
struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }
 
  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};


int main()
{
  string s, t;
  cin >> s >> t;
  int n = s.size(), m = t.size();
  int ans = INF;
  rep(i, n-m+1) {
    string ss = s.substr(i, m);
    int c = 0;
    rep(j, m) if(ss[j] != t[j]) ++c;
    chmin(ans, c);
  }
  cout << ans << endl;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
int main() {
  std::cin.tie(0); std::cin.sync_with_stdio(false);
  int n, m; std::cin >> n >> m;
  struct work {int deadline, value;};
  std::vector<work> w(n);
  for (auto& x : w)
  {
    int a, b; std::cin >> a >> b;
    x.deadline = m - a;
    x.value    = b;
  }
  std::sort(w.begin(), w.end(), [](auto x, auto y){
    return x.deadline < y.deadline;
  });
  int ret = 0;
  auto que = std::priority_queue<int>{};
  for (int day = m; day >= 0; day--) {
    while (!w.empty())
    {
      auto x = w.back();
      if (x.deadline < day) break;
      w.pop_back();
      que.push(x.value);
    }
    if (!que.empty())
    {
      ret += que.top(); que.pop();
    }
  }
  std::cout << ret << std::endl;
  return 0;
}

Measured memory_bytes: 1660
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <unordered_set>
#include <iostream>
#include <fstream>
#include <chrono>

using namespace std;

const int DIV = 998244353;

void execute(int test, istream &in) {
    int n, d;
    in >> n >> d;
    int cnt = 0;
    int64_t s = (int64_t)d * d;
    for (int i = 0; i < n; i++) {
        int64_t x, y;
        in >> x >> y;
        int64_t cur = x * x + y * y;
        if (cur <= s)
            cnt++;
    }
    printf("%d\n", cnt);
}

int main(int argc, char* argv[])
{
#ifdef VLAD_LOCAL
    //FILE *f = fopen("in.txt", "r");
    ifstream f("in.txt");
    auto start = std::chrono::steady_clock::now();
#else
    //FILE *f = stdin;
    istream &f = cin;
#endif
    int tests = 1;
    //f >> tests;
    for (int test = 0; test < tests; test++) {
        execute(test, f);
    }
#ifdef VLAD_LOCAL
    auto end = std::chrono::steady_clock::now();
    double seconds = (double)std::chrono::duration_cast<std::chrono::milliseconds>(end - start).count() / 1000;
    printf("%.3lf seconds\n", seconds);
#endif
    return 0;
}


Measured memory_bytes: 3748
package main

import (
	"bufio"
	"fmt"
	"log"
	"os"
	"strconv"
)

func main() {
	log.SetFlags(log.Lshortfile)
	N := nextInt()
	out := bufio.NewWriter(os.Stdout)
	fmt.Fprintf(out, "%d\n", (N+1)*N/2)
	out.Flush()
}
func Max(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r < a[i] {
			r = a[i]
		}
	}
	return r
}
func Min(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r > a[i] {
			r = a[i]
		}
	}
	return r
}
func Sum(a []int) (r int) {
	for i := range a {
		r += a[i]
	}
	return r
}
func Abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

type Pair struct {
	a, b int
}

type Pairs []Pair

func (p Pairs) Len() int {
	return len(p)
}
func (p Pairs) Swap(i, j int) {
	p[i], p[j] = p[j], p[i]
}

func (p Pairs) Less(i, j int) bool {
	return p[i].b < p[j].b
}

var nextReader func() string

func init() {
	nextReader = NewScanner()
}

func NewScanner() func() string {
	r := bufio.NewScanner(os.Stdin)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)
	return func() string {
		r.Scan()
		return r.Text()
	}
}
func nextString() string {
	return nextReader()
}
func nextInt64() int64 {
	v, _ := strconv.ParseInt(nextReader(), 10, 64)
	return v
}
func nextInt() int {
	v, _ := strconv.Atoi(nextReader())
	return v
}
func nextInts(n int) []int {
	r := make([]int, n)
	for i := 0; i < n; i++ {
		r[i] = nextInt()
	}
	return r
}
func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(nextReader(), 64)
	return f
}


Measured memory_bytes: 640
#include <stdio.h>
#include <string.h>
#include <ctype.h>
//prototype
int main(void);

int main(void){

  char word[11];
  char sentence[101];
  char eot[12] = "END_OF_TEXT";
  char judge_str[101];
  int s_len;
  int j = 0;
  int count = 0;

  scanf("%s", &word);

  while (1) {
    scanf("%s", sentence);

    //exit condition
    if(strcmp(sentence, eot) == 0){
      break;
    }

    s_len = strlen(sentence);

    //assign to judge_str 
    for (int i = 0; i < s_len; i++) {
      if (sentence[i] >= 'a' && sentence[i] <= 'z' || sentence[i] >= 'A' && sentence[i] <= 'Z') {
        judge_str[j] = tolower(sentence[i]);
        j++;
      }
    }

    //terminal char
    judge_str[j] = '\0';

    //Count the same Word
    if(strcmp(judge_str, word) == 0){
      count++;
    }

    j = 0;  //initialize j
  }

  printf("%d\n", count);

  return 0;
}



Measured memory_bytes: 2032
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    String S = sc.next();
    int count = 0;
    long r = 0;
    long g = 0;
    long b = 0;
    for(int i =0; i < N; i++){
        char tmp = S.charAt(i);
        if(tmp=='R'){r++;};
        if(tmp=='G'){g++;};
        if(tmp=='B'){b++;};
    }
    long ans = r*g*b;
    for(int i = 0; i < N -2; i++){
      for(int j = i+1; j < N -1; j++){
        int k = 2*j-i;
        if(k<N){
        if(S.charAt(i)!=S.charAt(j)&S.charAt(j)!=S.charAt(k)&S.charAt(k)!=S.charAt(i)){
          ans--;
        }
      }
      }
    }
    System.out.println(ans);
  }

  
}




Measured memory_bytes: 37456
using System;
using System.Linq;
using System.Collections.Generic;

class Program {
  static void Main() {
    var s = Console.ReadLine();
    var d = new Stack<int>();
    var p = new Stack<KeyValuePair<int, int>>();
    int a = 0;
    for (int i = 0; i < s.Length; i++) {
      if (s[i] == '\\') {
        d.Push(i);
      } else if (s[i] == '/' && d.Count > 0) {
        int b = d.Pop();
        int t = i - b;
        a += t;
        while (p.Count > 0 && b < p.Peek().Key) {
          t += p.Pop().Value;
        }
        p.Push(new KeyValuePair<int, int>(b, t));
      }
    }
    Console.WriteLine(a);
    Console.Write(p.Count);
    foreach (var item in p.Select(x => x.Value).Reverse().Select(x => x.ToString()).ToArray()) {
      Console.Write(" " + item);
    }
    Console.WriteLine();
  }
}


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

const double pi=3.14159265358979323846;

int main(){
    double A,B,H,M;
    cin>>A>>B>>H>>M;
    
    double a=H*pi/6.0+M*pi/360.0;
    double b=M*pi/30.0;
    
    double dist=sqrt(pow(A,2)+pow(B,2)-2*A*B*cos(a-b));
    
    cout<<fixed<<setprecision(15)<<dist<<endl;
}


Measured memory_bytes: 4224
#include <iostream>
#include <string>
#include <cmath>
#include <unordered_map>

size_t A[200000];
int main(void) {
  int n;

  std::cin >> n; /* 1 to 3*10^5 */

  //int* A = new int[n];
  for (size_t i = 0; i < n; i++) {
    std::cin >> A[i];
  }

  size_t count = 0;

  size_t lsum = 0;
  size_t rsum = 0;
  size_t offset = 0;
  for (size_t i = 0; i < n; ++i) {
    size_t lcount = 0;
    for (size_t j = i + offset; j < n; ++j) {
      size_t l = lsum ^ A[j];
      size_t r = rsum + A[j];
      if (l == r) {
        lcount++;
        lsum = l;
        rsum = r;
        continue;
      }
      break;
    }
    count += lcount + offset;
    if (lcount + offset > 1) {
      offset = lcount + offset - 1;
    } else {
      offset = 0;
    }
    lsum ^= A[i];
    rsum -= A[i];
  }

  std::cout << count << std::endl;;

  return 0;
}

Measured memory_bytes: 1792
x,n = map(int, input().split())
P = list(map(int, input().split()))
if n == 0:
    print(x)
    exit()

A = [i for i in range(max(P)+2) if i not in P]
X = abs(x-A[0])
ans = A[0]
for a in A[1:]:
    if abs(x-a) < X: 
        X = abs(x-a)
        ans = a
print(ans)

Measured memory_bytes: 9200
import heapq
from collections import deque
from enum import Enum
import sys
import math
from _heapq import heappush, heappop

BIG_NUM = 2000000000
MOD = 1000000007
EPS = 0.000000001


V,E = map(int,input().split())
can_visit = [[None] * V for _ in range(V)]

for i in range(V):
    for k in range(V):
        can_visit[i][k] = (i == k)

for _ in range(E):
    FROM,TO = map(int,input().split())
    can_visit[FROM][TO] = True

#ワーシャルフロイド
for mid in range(V):
    for start in range(V):
        if can_visit[start][mid] == False:
            continue
        for goal in range(V):
            if can_visit[mid][goal] == False:
                continue
            can_visit[start][goal] = True


for FROM in range(V-1):
    for TO in range(FROM+1,V):
        if can_visit[FROM][TO] == True and can_visit[TO][FROM] == True:
            print("1")
            sys.exit()

print("0")




Measured memory_bytes: 6468
#include <bits/stdc++.h>
#define rep(i, n) for (long long i = 0, max_i = (n); i < max_i; i++)
#define repi(i, a, b) for (long long i = (a), max_i = (b); i < max_i; i++)
using namespace std;
typedef long long ll;

int main() {
  int N; cin >> N;
  vector<int> v(N);
  int ans = 0;
  rep(i,N) {
    int p; cin >> p;
    v.at(i) = p;
    ans += p;
  }
  sort(v.rbegin(), v.rend());
  cout << ans - v.at(0)/2 << endl;
  return 0;
}


Measured memory_bytes: 256
N = int(input())
a = list(map(int, input().split()))


m = max(a)
for i in range(100):
    if 2**i>m:
        n = i
        break


mat = []
for j in a:
    b=[1 if j >> i &1 else 0 for i in reversed(range(n))] 
    mat.append(b)


for i in range(n):
    f = [part[i] for part in mat]
    if sum(f)%2==0:
        ans = f
#         print(ans)
    else:
        ans = [1 if j==0 else 0 for j in f]
#         print(ans)
    for j in range(len(ans)):
        mat[j][i] = ans[j]
res = []
for m in mat:
    ans = 0
    for i in range(len(m)):
        ans += 2**i*m[-i-1]
    
    res.append(ans)
print(" ".join(map(str,res)))

Measured memory_bytes: 252600
#include<iostream>
using namespace std;
int head,tail,n;
struct task
{
	char name[100];
	int time;
}t,Q[1000000];
void enqueue(task x)
{
	Q[tail]=x;
	tail++;
}
task dequeue()
{
	task x=Q[head];
	head++;
	return x;
}
int main()
{
	int q;
	cin>>n>>q;
	for(int i=1;i<=n;i++)
		cin>>Q[i].name>>Q[i].time;
	head=1;
	tail=n+1;
	int sum=0;
	while(head!=tail)
	{
		t=dequeue();
		if(t.time>q)
		{
			sum+=q;
			t.time-=q;
			enqueue(t);
		}
		else
		{
			sum+=t.time;
			cout<<t.name<<' '<<sum<<endl;
		}
	}
	return 0;
}


Measured memory_bytes: 22332
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vll = vector<long long>;
using vp = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
template<class T> inline bool chmax(T &a, T b) { if (a<b) {a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a, T b) { if (b<a) {a=b; return 1;} return 0;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n, m;
    cin >> n;
    map<string, int> s, t;
    rep(i, n) {
        string x;
        cin >> x;
        s[x]++;
    }
    cin >> m;
    rep(i, m) {
        string x;
        cin >> x;
        t[x]++;
    }
    int mx = 0;
    for (auto&& p : s) {
        int now = 0;
        now += p.se;
        now -= t[p.fi];
        chmax(mx, now);
    }
    cout << mx << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N = 100010;
const long long Inf = 1e13;
int n, k;
long long f[N], h[N];
int main()
{
    scanf("%d%d", &n, &k);
    for (int i = 1; i <= n; i++)
    {
        scanf("%lld", &h[i]);
        f[i] = Inf;
    }
    f[1] = 0ll;
    for (int i = 2; i <= n; i++)
    {
        for (int j = 1; j <= min(i - 1, k); j++)
        {
            f[i] = min(f[i], f[i - j] + abs(h[i] - h[i - j]));
        }
    }
    printf("%lld\n", f[n]);
    return 0;
}

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

using namespace std;

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

  int n, a;
  cin >> n;
  vector<int> A(n);
  for (int i = 0; i < n; ++i) {
    cin >> a; 
    a--;
    A[i] = a;
  }
  int i = 0;
  int res = 0;
  vector<bool> seen(n, false);
  while (i != 1 && !seen[i]) {
    seen[i] = true;
    i = A[i];
    ++res;
  }
  cout << (i == 1 ? res : -1) << endl;

  return 0;
}



Measured memory_bytes: 640
/*
これを入れて実行
g++ code.cpp
./a.out
 */

#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <tuple>
#include <iomanip>

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

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

const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;

bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}

ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}

ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}

ll nCm(ll n, ll m){
    if(m == 0 || m == n){
        return 1;
    } else if(m == 1){
        return n;
    }
    return (nCm(n - 1, m) + nCm(n - 1, m - 1));
}

//-----------------------ここから-----------


int main(void){
    string s;
    cin >> s;
    for(int i = s.size() - 3; i >= 0; i -= 2){
        if(s.substr(0, i / 2 + 1) == s.substr(i / 2 + 1, i / 2 + 1)){
            cout << i + 1 << endl;
            return 0;
        }
    }
}

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

int main()
{
    int a , b;

    cin >> a >> b;

    if (a > b)
    {
        cout << "a > b" << endl;
    }
    else if (a < b)
    {
        cout << "a < b" << endl;
    }
    else
    {
        cout << "a == b" << endl;
    }

    return 0;
}



Measured memory_bytes: 3116
#include <cstdio>
#include <iostream>
#include <set>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

int main(int argc, char const *argv[]) {
  int n;
  cin >> n;
  vector<int> p(n);
  for (int i = 0; i < n; i++) cin >> p[i];
  int res = 0;
  sort(p.begin(), p.end());
  res = p[p.size() / 2] - p[(p.size() / 2) - 1];
  cout << res;
  return 0;
}


Measured memory_bytes: 768
X = int(input())
if X <= 599:
    print(8)
elif 600 <= X <= 799:
    print(7)
elif 800 <= X <= 999:
    print(6)
elif 1000 <= X <= 1199:
    print(5)
elif 1200 <= X <= 1399:
    print(4)
elif 1400 <= X <= 1599:
    print(3)
elif 1600 <= X <= 1799:
    print(2)
else:
    print(1)

Measured memory_bytes: 9176
#include "bits/stdc++.h"
using namespace std;
using ll=long long;
#define print(n) cout<<n<<endl
#define rep(i,a,n) for(int i=a;i<n;i++)
#define ALL(s) s.begin(),s.end()
#define P pair<ll,ll>
#define vl vector<ll>
#define vi vector<int>
#define vvl vector<vector<ll>>
#define vvi vector<vector<int>>
const int M=100111;
const int inf=1000000007;
const long long INF=1e18;
int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};
int ddx[8]={1,-1,0,0,1,-1,-1,1},ddy[8]={0,0,1,-1,1,-1,1,-1};


int main() {
	int n,ans=0,a;
	cin>>n;
	rep(i,0,n)cin>>a,ans^=a;
	ans==0?print("Yes"):print("No");
}             

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb(x) push_back(x)
#define PI pair<int,int>
#define PL pair<long int,long int>
#define PLL pair<ll,ll>
#define Tcase int t;cin>>t;while(t--)   
int main(){
int n;cin>>n;
  int a[n-1],flag[n+1];
  for(int i=0;i<=n;i++)flag[i]=0;
  for(int i=0;i<n-1;i++){cin>>a[i];flag[a[i]]++;}
  for(int i=1;i<=n;i++)cout<<flag[i]<<"\n";
  
return 0;
}

Measured memory_bytes: 5188
#include <bits/stdc++.h>
using namespace std;
#define NIL -1
#define N_MAX 25

struct Node {
    long parent;
    long left;
    long right;
};

struct Node T[N_MAX];

void preParse(long id) {
    if (id == NIL) {
        return;
    }
    cout << " " << id;
    preParse(T[id].left);
    preParse(T[id].right);
}

void inParse(long id) {
    if (id == NIL) {
        return;
    }
    inParse(T[id].left);
    cout << " " << id;
    inParse(T[id].right);
}

void postParse(long id) {
    if (id == NIL) {
        return;
    }
    postParse(T[id].left);
    postParse(T[id].right);
    cout << " " << id;
}

int main() {
    long n;
    cin >> n;
    
    // initialize Tree
    for (long i = 0; i < n; i++) {
        T[i].parent = NIL;
        T[i].left = NIL;
        T[i].right = NIL;
    }
    
    long id, l, r;
    for (long i = 0; i < n; i++) {
        cin >> id >> l >> r;
        T[id].left = l;
        T[id].right = r;
        T[T[id].left].parent = id;
        T[T[id].right].parent = id;
    }
    
    long id_root;
    for (long i = 0; i < n; i++) {
        if (T[i].parent == NIL) {
            id_root = i;
            break;
        }
    }
    
    cout << "Preorder" << endl;
    preParse(id_root);
    cout << endl;
    
    cout << "Inorder" << endl;
    inParse(id_root);
    cout << endl;
    
    cout << "Postorder" << endl;
    postParse(id_root);
    cout << endl;
}


Measured memory_bytes: 3080
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
int N;
cin>>N;
int A[N];
int left[N];
int right[N];
cin>>A[0];
left[0]=A[0];
for(int i=1;i<N;i++)
{
    cin>>A[i];
    left[i]=left[i-1]+A[i];
}
right[N-1]=A[N-1];
for(int j=N-2;j>=0;j--)
{
    right[j]=right[j+1]+A[j];
}
int M=INT_MAX;
for(int i=0;i<N-1;i++)
{
    M=min(M,abs(left[i]-right[i+1]));
}
cout<<M;
    return 0;
    
}

Measured memory_bytes: 256
while True:
    a,op,b=input().split()
    a=int(a)
    b=int(b)
    if op=='+':
        print(f"{a+b}")
    elif op=='-':
        print(f"{a-b}")
    elif op=='*':
        print(f"{a*b}")
    elif op=='/':
        print(f"{a//b}")
    elif op=='?':
        break



Measured memory_bytes: 5600
#include <iostream>
#include <iomanip>
#include <random>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <numeric>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <sstream>
#include <bitset>
#include <cassert>
#include <fstream>
#include <queue>

#define len(X) ((int)(X).size())

#ifdef __LOCAL
	#define DBG(X) cout << #X << "=" << (X) << '\n';
	#define SAY(X) cout << (X) << '\n';
#else
	#define DBG(X)
	#define SAY(X)
#endif
 
using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld  = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

const int INT_INF = (int)(2e9);
const ll  LL_INF  = (ll)(2e18);

const int NIL = -1;
static mt19937 _g(time(nullptr));

inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T> inline T sign(T x) { return T(x > 0) - T(x < 0); }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for(auto el: v) cout << el << " "; return os; }
template<typename T> inline T fetch() { T ret; cin >> ret; return ret; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for(auto& elem: ret) cin >> elem; return ret; }

void solve() {
	map<string, int> m;
	m["SUN"] = 0;
	m["MON"] = 1;
	m["TUE"] = 2;
	m["WED"] = 3;
	m["THU"] = 4;
	m["FRI"] = 5;
	m["SAT"] = 6;
	
	auto day = fetch<string>();
	cout << 7 - m[day] << '\n';
}

int main() {
	fast_io();
	solve();

	return 0;

}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <string>
#include <algorithm>
#include <iostream>
#include <string>
#include <map>
#include <set>
#include <functional>
#include <iostream>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

ll x;

int main(void){
	scanf("%lld",&x);
	ll res=x/11LL;
	x-=res*11LL;
	res*=2LL;
	if(x>=7){
		printf("%lld\n",res+2LL);
	}else if(x>0){
		printf("%lld\n",res+1LL);
	}else{
		printf("%lld\n",res);
	}
	return 0;
}


Measured memory_bytes: 256
#include<algorithm>
#include<complex>
#include<ctype.h>
#include<iomanip>
#include<iostream>
#include<map>
#include<math.h>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<stdio.h>
#include<string>
#include<string>
#include<vector>

using namespace std;
typedef long long ll;

#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("YES")
#define p_no() p("NO")

template < typename T >
void vprint(T &V){
	for(auto v : V){
    	cout << v << " ";
	}
	cout << endl;
}

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

const ll mod = 1e9 + 7;
const ll inf = 1e18;

string dp[10010];

ll cost[10] = {8, 2, 5, 5, 4, 5, 6, 3, 7, 6};

string max_string(string a, string b){
    if(a.size() > b.size()){
        return a;
    }
    else if(a.size() < b.size()){
        return b;
    }
    // 同じ長さ
    else{
        if(a[0] > b[0]){
            return a;
        }else{
            return b;
        }
    }
}

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

    // input
    ll N, M;
    cin >> N >> M;

    vector<ll> A(M);
    FOR(i, 0, M){
        cin >> A.at(i);
    }
    sort(ALL(A));
    
    dp[0] = "";
    dp[1] = "";
    FOR(i, 2, 10010){
        dp[i] = "";
        for(ll a : A){
            ll c = cost[a];
            if(i>=c){
                // コストピッタリ
                if(i==c){
                    dp[i] = max_string(dp[i], to_string(a));                    
                }else{
                    if(dp[i-c]==""){
                        //
                    }else{
                        dp[i] = max_string(dp[i], to_string(a) + dp[i-c]);
                    }
                }
            }
        }
    }

    p(dp[N]);
    
    return 0;
}

Measured memory_bytes: 32512
#include <bits/stdc++.h>
#define ll long long
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end))) // rep(i, 1, 5) --> {1,2,3,4} // rep(i, 5, 1) --> {4,3,2,1} // rep(it, end(v), begin(v)) --> *it

using namespace std;

int main()
{
    string sa, sb, sc;
    cin >> sa >> sb >> sc;
    int ia = 0, ib = 0, ic = 0;
    char curr = sa[0];
    while (true)
    {
        if (ia == sa.size() && curr == 'a')
            return cout << "A", 0;
        if (ib == sb.size() && curr == 'b')
            return cout << "B", 0;
        if (ic == sc.size() && curr == 'c')
            return cout << "C", 0;
        if (curr == 'a')
        {
            curr = sa[ia];
            ia++;
        }
        else if (curr == 'b')
        {
            curr = sb[ib];
            ib++;
        }
        else if (curr == 'c')
        {
            curr = sc[ic];
            ic++;
        }
    }
    return 0;
}

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

#define fi first
#define se second
#define FO(x, n) for (int x = 0; x < n; ++x)
#define FOR(x, a, b) for (int x = a; x < b; ++x)
#define RFO(x, n) for (int x = n - 1; x >= 0; --x)
#define RFOR(x, a, b) for (int x = b - 1; x >= a; --x)
#define FOR_ITER(x, a) for(auto x = a.begin(); x != a.end(); ++x)



using namespace std;
typedef unsigned char byte;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef pair<string, string> pss;
typedef pair<ll, ll> pll;
inline bool feq(const double& a, const double& b) { return fabs(a - b) < 1e-10; }

using namespace std;


int main(){
//    int n, l;
//    cin >> n >> k;
//    vector<bool> dislike(10, false);
//
//    FOR(i, 0, k) {
//        int t;
//        cin >> t;
//        dislike[t] = true;
//    }




int n;
cin >> n;
vector<int> t(n);
 int sum = 0;
 FO(i, n) {
    cin >> t.at(i);
    sum += t.at(i);
 }

 int m;
 cin >> m;

 FO(i, m) {
    int a, b;
    cin >>a>>b;
    cout << sum -t.at(a - 1) + b<< endl;
 }

    return 0;
}


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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);   
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    ll ans = -1e18;
    ans = max(ans, a*c);
    ans = max(ans, a*d);
    ans = max(ans, b*d);
    ans = max(ans, b*c);
    cout << ans << endl;
}

Measured memory_bytes: 3660
package main

import (
	"fmt"
)

func main() {
	var n string
	fmt.Scan(&n)
	a := len(n)
	ans := n[a-1 : a]

	if ans == "2" || ans == "4" || ans == "5" || ans == "7" || ans == "9" {
		fmt.Println("hon")
	} else if ans == "0" || ans == "1" || ans == "6" || ans == "8" {
		fmt.Println("pon")
	} else if ans == "3" {
		fmt.Println("bon")
	}
}


Measured memory_bytes: 1752
#include <bits/stdc++.h>
#define FOR(v, a, b) for(int v = (a); v < (b); ++v)
#define FORE(v, a, b) for(int v = (a); v <= (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define REV(v, a, b) for(int v = (a); v >= (b); --v)
#define ALL(x) (x).begin(), (x).end()
#define ITR(it, c) for(auto it = (c).begin(); it != (c).end(); ++it)
#define RITR(it, c) for(auto it = (c).rbegin(); it != (c).rend(); ++it)
#define EXIST(c,x) ((c).find(x) != (c).end())
#define LLI long long int
#define fst first
#define snd second
#ifdef DEBUG
#include <boost/core/demangle.hpp>
#define dump(x) cerr << "L" << __LINE__ << ": in " << __PRETTY_FUNCTION__ << " \e[32;1m" << boost::core::demangle(typeid(x).name()) << "\e[37m" << " " << (#x) << " = " << (x) << "\e[m" << endl;
#else
#define dump(x)
#endif
using namespace std;
template <typename T> using V = vector<T>;
template <typename T, typename U> using P = pair<T,U>;
template <typename I> void join(ostream &ost, I s, I t, string d=" "){for(auto i=s; i!=t; ++i){if(i!=s)ost<<d; ost<<*i;}ost<<endl;}
template <typename T> istream& operator>>(istream &is, vector<T> &v){for(auto &a : v) is >> a; return is;}
template <typename T, typename U> istream& operator>>(istream &is, pair<T,U> &p){is >> p.first >> p.second; return is;}

template <typename T> ostream& operator<<(ostream &os, vector<T> &v){os << "{";ITR(i,v){if(i!=v.begin())os << ","; os << *i;}os << "}"; return os;}
template <typename T, typename U> ostream& operator<<(ostream& os, pair<T,U> &p){os << "(" << p.first << "," << p.second << ")"; return os;}

template <typename T> T& chmin(T &a, const T &b){return a = min(a,b);}
template <typename T> T& chmax(T &a, const T &b){return a = max(a,b);}

double dp[3100][3100];

int main(){

  int N; cin >> N;
  vector<double> p(N); cin >> p;

  dp[0][0] = 1;

  REP(i,N){
    REPE(j,N){
      if(j==0) dp[i+1][j] = dp[i][j]*(1-p[i]);
      else dp[i+1][j] = dp[i][j]*(1-p[i]) + dp[i][j-1]*p[i];
    }
  }

  double ans = 0;
  FORE(i,N/2+1,N) ans += dp[N][i];

  printf("%.012f\n", ans);
  
  return 0;
}


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

const ll mod=1000000007;

int main() {
  int count=0;
 string s,t;
  cin >> s >> t;
  r(i,s.size()){
    if(s[i]!=t[i])count++;
  }
  cout<<count<<endl;
}

Measured memory_bytes: 3852
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin>>s;
    int i,j,k;
    int c=0;
    int maxn=0;
    int rn=0;
    i=0;
    while(i<s.size())
    {
        if(s[i]=='R')
        {
            rn++;
        }
        else if(s[i]=='S')
        {
            if(rn>maxn)
            {
                maxn=rn;
                rn=0;
            }

        }
        i++;

    }
    if(rn>maxn)
            {
                maxn=rn;
                rn=0;
            }
    cout<<maxn<<endl;
}


Measured memory_bytes: 3620
#include<iostream>

int daikei(int a, int b, int h) {
    return (a + b) * h / 2;
}

int main () {
    int a;
    int b;
    int h;
    std::cin >> a >> b >> h;
    std::cout << daikei(a, b, h) << std::endl;
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define ll long long
#define rep2(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) rep2(i,0,n)

using namespace std;


main(){
    int n,a[110000];
    cin>>n;
    int count=0;
    int b[110000]={};
    rep(i,n){
        cin>>a[i];
        if(a[i]>n) count++;
        else (b[a[i]]++);
    }
    rep(i,n+1){
        if(b[i]>=i) count+=(b[i]-i);
        else count+=b[i]; 
    }

    cout<<count;

    return 0;
}

Measured memory_bytes: 1152
#include<stdio.h>
int main()
{
    long long int a,x,b,d,c;
    int count=0;
    scanf("%lld%lld%lld",&a,&b,&x);
    c=b/x-a/x;
    if(a%x==0)
        count++;
    printf("%lld",c+count);
    return 0;
    }


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define LL long long
const int maxn = 111;
const LL mod = 1e9+7;
int n;
LL ans;
char s[2][maxn];
vector<int> v;
int main () {
    scanf ("%d", &n);
    for (int i = 0; i < 2; i++) {
        scanf ("%s", s);
    }
    int p = 0;
    while (p < n) {
        if (p!=n-1&&s[0][p+1] == s[0][p]) {
            p += 2;
            v.push_back (2);
        }
        else {
            p += 1;
            v.push_back (1);
        }
    }
    if (v[0] == 1) {
        ans = 3;
    }
    else {
        ans = 6;
    }
    for (int i = 1; i < v.size(); i++) {
        //printf ("%d", v[i]);
        if (v[i-1] == 1 && v[i] == 1) {
            ans *= 2;
        }
        else if (v[i-1] == 1 && v[i] == 2) {
            ans *= 2;
        }
        else if (v[i-1] == 2 && v[i] == 1) {
            ;
        }
        else {
            ans *= 3;
        }
    }
    printf ("%lld\n", ans%mod);
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
    public static void main(String[] args) {
        int num = new Scanner(System.in).nextInt();
        
        int hh = (int)(num / 3600); num -= hh * 3600;
        int mm = (int)(num / 60); num -= mm * 60;
        int ss = num;
        
        System.out.println(hh + ":" + mm + ":" + ss);
    }
}


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

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

		int sum = 0;

		if (d == 0) {
			sum = n;
		} else {
			sum = (n - d) * 2;
		}
		System.out.println(BigDecimal.valueOf((double) (m - 1) * sum / n / n).toPlainString());

		sc.close();
	}

}


Measured memory_bytes: 21844
n, y = map(int, input().split())

for i in range(n + 1):
  for j in range(n - i + 1):
    if y == 10000 * i + 5000 * j + 1000 * (n - i - j):
      print(i, j, n - i - j)
      exit()

print("-1 -1 -1")


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

using namespace std;
 
int main() {
  int N, con=0;
  int P[55];
  cin >> N;
  P[0]=0;
  for(int i=1; i<=N; ++i){
    cin >> P[i];
  }
  for(int i=1; i<=N; ++i){
    if(P[i]!=i) con +=1;
  }
  if(con <= 2) cout << "YES" << endl;
  else cout << "NO" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
map<ll, ll> mp;
int main(void){
    ll N, K;
    cin >> N >> K;
    vector<ll> A(N);
    vector<ll> A_sum(N+1);
    for (int i = 0; i < N; i++)
        cin >> A[i];

    A_sum[0] = 0;
    for (int i  = 1; i < N+1; i++)
        A_sum[i] += (A_sum[i-1] + A[i-1] - 1) % K;
    
    ll ans = 0;
    for (ll i = 1; i < N+1; i++) {
        mp[A_sum[i-1]]++;
        if (i-K >= 0)
            mp[A_sum[i-K]]--;
        //cout << i << " " << mp[A_sum[i]] << endl;
        ans += mp[A_sum[i]];
    }
    cout << ans << endl;
}

Measured memory_bytes: 15872