akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int M = sc.nextInt();
    String tmp;
    String grid[][] = new String[N][M];
    for(int i=0;i<N;i++){
      
        tmp=sc.next();
      for(int j=0;j<M;j++){
        grid[i][j]=tmp.substring(j,j+1);
      }
    }
    
    //まず全行削る
    for(int i=0;i<N;i++){
      if(isVanish(grid,"gyo",i,N,M)){
        for(int j=0;j<M;j++){
        grid[i][j]="G";
        }
      }
    }
    //全列削る
    for(int i=0;i<M;i++){
      if(isVanish(grid,"retsu",i,N,M)){
        for(int j=0;j<N;j++){
        grid[j][i]="G";
        }
      }
    }
    boolean isNotG = false;
    for(int i=0;i<N;i++){
      isNotG = false;
      for(int j=0;j<M;j++){
        if(grid[i][j].equals("G")){
        System.out.print("");
        }else{        
        System.out.print(grid[i][j]);
          isNotG=true;
        }
      }
      if(isNotG){
      System.out.println("");
      }
      
    } 
  }
  //与えられた数字とグリッドに対して、num番目の行or列が全部白or灰だったらtrueを返すメソッド
  public static boolean isVanish(String grid[][],String type,int num,int N ,int M){
    if(type.equals("gyo")){
      for(int i=0;i<M;i++){
        if(grid[num][i].equals("#")){
          return false;
        }
      }
    }else{
      for(int i=0;i<N;i++){
        if(grid[i][num].equals("#")){
          return false;
        }
      }
    } 
    return true;
  }
}

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

int main(){
    int H,W,K,ans=0;
    cin >> H >> W >> K;
    vector <vector<char>> c(H,vector<char>(W));
    for(int i=0; i<H; i++){
        for(int j=0; j<W; j++){
            cin >> c.at(i).at(j);
        }
    }
    for (int bith = 0; bith < (1<<H); bith++){
        for (int bitw = 0; bitw < (1<<W); bitw++){
            int judge=0;
            for (int i = 0; i < H; i++){
                for (int j = 0; j < W; j++){
                    if((bith>>i) & 1 && (bitw>>j) & 1 && c[i][j] == '#') judge++;
                }                
            }
            if(judge==K) ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3600
from itertools import accumulate
from collections import Counter
import math

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

n,m=map(int,input().split())
s=list(map(lambda x:x%m,list(accumulate(list(map(int,input().split()))))))
s.append(0)
#print(s)
d=Counter(s)
#print(d)
ans=0
for i in d:
    if d[i]>=2:
        ans+=combinations_count(d[i],2)
print(ans)

Measured memory_bytes: 14484
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define debug(x) cerr << #x << " " << x << '\n'
using namespace std;
using ll = long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
const int INF = 0x3f3f3f3f, N = 2e5 + 5;
const ll LINF = 1e18 + 5;

int main()
{
 	ios::sync_with_stdio(false);
 	cin.tie(0);
 	string s, t;
 	cin >> s >> t;
 	cout << t+s;
	return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashMap;

public class Main {

	public static void main(String[] args) throws IOException {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = br.readLine();

		HashMap<String, Integer> hs = new HashMap<String, Integer>();

		int maxOccured = 0;
		int maxLen = 0;
		String maxOccuredWord = "";
		String maxLenWord = "";

		for (String word : line.split(" +")) {
			if (!hs.containsKey(word)) {
				hs.put(word, 1);
			} else {
				hs.put(word, hs.get(word) + 1);
			}
			int v = hs.get(word);
			// 発生回数と単語を確認して更新
			if (maxOccured < v) {
				maxOccured = v;
				maxOccuredWord = word;
			}
			// 文字数と単語を確認して更新
			// 文字数確認済みの単語は確認しない
			if (v == 1 && maxLen < word.length()) {
				maxLen = word.length();
				maxLenWord = word;
			}
		}
		System.out.println(maxOccuredWord + " " + maxLenWord);
	}
}

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

int main(){
    int n;
    cin>>n;
    int* a=new int[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    cout<<a[n-1];
    for(int j=n-2;j>=0;j--){
        cout<<" "<<a[j];
    }
    cout<<endl;
    delete[] a;
    return 0;
}


Measured memory_bytes: 3104
#n = int(input())
a,b,c,x,y = map(int,input().split())
#a_L = list(map(int,input().split()))
price = float("inf")
for i in range(10**7):
    price = min(price,i*2*c + max(0,x-i)*a +  max(0,y-i)*b)

print(price)


Measured memory_bytes: 41196
#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define vi vector<int>
#define pii pair<int, int>
#define vii vector<pii>
#define mii map<int, int>
#define msi map<string, int>
#define pb push_back
#define mp make_pair
#define coutp cout<<fixed<<setprecision
#define FOR(n) for(int i=0;i<n;i++)
#define M 1000000007
#define imin INT_MIN
#define imax INT_MAX
#define SIEVE 100000

int n,m,k,a,b,mx=imin,mn=imax,mxi,mni;
double x,y;
string s,s1,s2;
vector<bool> prime(SIEVE+1,1);
vi primes;

void precomputation();
void solve();
void solvecase();
void sieve();
int pow(int, unsigned int, int);
bool miillerTest(int, int);
bool isPrime(int, int);


int32_t main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	clock_t start_time = clock();
	precomputation();
	solve();
	clock_t end_time = clock();
  	double elapsed_secs = double(end_time - start_time) / CLOCKS_PER_SEC;
	cerr<<elapsed_secs<<"\n";
	return 0;

}

void solvecase(){
    cin>>s1>>s2;
    for(int i=0;i<s1.size();i++)
    {
        if(s1[i]!=s2[i])n++;
    }
    cout<<n;
}

void solve(){
	int T=1;
	//cin>>T;
	for(int i=1;i<=T;i++)
	{
		//cout<<"Case #"<<i<<":"<<" ";
		solvecase();
		cout<<"\n";
	}
}

void precomputation(){
}

void sieve(){
	prime[0]=0;
	prime[1]=0;
	for(int i=2;i<=SIEVE;i++){
		if(prime[i]){
			primes.pb(i);
			for(int j=i+i;j<=SIEVE;j+=i){
				prime[j]=0;
			}
		}
	}
	sort(primes.begin(),primes.end());
}

int pow(int X, unsigned int Y, int P)
{
	int res = 1;
	X = X % P;
	while (Y > 0)
	{
		if (Y & 1)
			res = (res*X) % P;
		Y = Y>>1;
		X = (X*X) % P;
	}
	return res;
}

bool miillerTest(int D, int N)
{
	int A = 2 + rand() % (N - 4);
	int X = pow(A, D, N);
	if (X == 1 || X == N-1)
	return true;
	while (D != N-1)
	{
		X = (X * X) % N;
		D *= 2;
		if (X == 1)	 return false;
		if (X == N-1) return true;
	}
	return false;
}

bool isPrime(int N, int K)
{
	if (N <= 1 || N == 4) return false;
	if (N <= 3) return true;
	int D = N - 1;
	while (D % 2 == 0)
		D /= 2;
	for (int i = 0; i < K; i++)
		if (!miillerTest(D, N))
			return false;
	return true;
}


Measured memory_bytes: 3968
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        PrintWriter out = new PrintWriter(System.out);
        InputStreamScanner in = new InputStreamScanner(System.in);
        new Main().solve(in, out);
        out.flush();
    }

    private void solve(InputStreamScanner in, PrintWriter out) {
        int a = in.nextInt();
        int b = in.nextInt();
        int c = in.nextInt();
        int x = in.nextInt();

        int r = 0;
        for (int i = 0; i <= a; i++) {
            for (int j = 0; j <= b; j++) {
                int t = x - (i * 500 + j * 100);
                if (t >= 0 && t % 50 == 0 && t <= 50 * c) {
                    r++;
                }
            }
        }
        out.println(r);
    }

    static class InputStreamScanner {

        private InputStream in;

        private byte[] buf = new byte[1024];
        private int len = 0;
        private int off = 0;

        InputStreamScanner(InputStream in)	{
            this.in = in;
        }

        String next() {
            StringBuilder sb = new StringBuilder();
            for (int b = skip(); !isSpace(b);){
                sb.appendCodePoint(b);
                b = read();
            }
            return sb.toString();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        char nextChar() {
            return (char)skip();
        }

        int skip() {
            for (int b; (b = read()) != -1;) {
                if (!isSpace(b)) {
                    return b;
                }
            }
            return -1;
        }

        private boolean isSpace(int c) {
            return c < 33 || c > 126;
        }

        private int read() {
            if (len == -1) {
                throw new InputMismatchException("End of Input");
            }
            if (off >= len){
                off = 0;
                try {
                    len = in.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException(e.getMessage());
                }
                if (len <= 0) {
                    return -1;
                }
            }
            return buf[off++];
        }
    }
}

Measured memory_bytes: 22484
#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define WHATIS(x) cout << #x << " is " << x << endl;
#define ERROR(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x

using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<II, ll> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cout << *it << " = " << a << endl;
    err(++it, args...);
}

const ll MODBASE = 1000000007LL;
const int MAXN = 310;
const int MAXM = 35;
const int MAXK = 510;
const int MAXQ = 200010;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    int n, m, x, y;
    cin >> n >> m >> x >> y;
    cout << fixed << setprecision(9) << (ld) n * m / 2 << ' ';
    if (x == n / 2 && n % 2 == 0 && y == m / 2 && m % 2 == 0) cout << 1;
    else cout << 0;
    return 0;
}

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

int main() {
	string a, b;
	cin >> a >> b;

	int al = a.size(), bl = b.size();

	if (al == bl) {
		int d = 0;

		for (int i = 0; i < al; i++) {
			if (a[i] != b[i]) {
				if (a[i] > b[i])d = 1;
				else d = 2;

				break;
			}
		}

		if (!d)cout << "EQUAL" << endl;
		else if (d == 1)cout << "GREATER" << endl;
		else cout << "LESS" << endl;

	}

	else if (al < bl)cout << "LESS" << endl;
	else cout << "GREATER" << endl;

	return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const long double PI  = acos(-1.0L);
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef pair<double,double> PDD;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
#define chmax(a,b) a = (((a)<(b))?(b):(a))
#define chmin(a,b) a = (((a)>(b))?(b):(a))

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}


signed main(){
	int n,k,c; cin>>n>>k>>c;
	string s; cin>>s;
	int f[k],b[k];
	int fwd=0, bwd=n-1, cnt=0;
	while(cnt<k){
		if(s[fwd]=='o') f[cnt]=fwd+1, cerr<<fwd+1<<' ', fwd+=c, cnt++;
		fwd++;
	}
	cerr<<endl;
	cnt=0;
	while(cnt<k){
		if(s[bwd]=='o') b[k-cnt-1]=bwd+1, cerr<<bwd+1<<' ', bwd-=c, cnt++;
		bwd--;
	}
	cerr<<endl;
	rep(i,k)if(f[i]==b[i]) cout<<f[i]<<endl;

	return 0;
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(a) (a).begin(), (a).end()
#define pb push_back
#define ppb pop_back
#define INF 1e18
typedef long long ll;
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return true;
    }
    return false;
}

using namespace std;
int main()
{
    ll n, ans, f = 1, x = 5;
    cin >> n;
    if (n <= 1 || n % 2)
    {
        cout << 0;
        return 0;
    }
    while (1)
    {
        ll ret = x * 2;
        if (ret > n)
            break;
        ans += f * (n / ret);
        x *= 5;
    }
    cout << ans;
    return 0;
}

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

const int inf = 1e9;
const ll linf = 1e18;

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

    int n, k; cin >> n >> k;
    int r, s, p; cin >> r >> s >> p;
    string t; cin >> t;

    map<char, int> mp = {
        {'r', p}, {'s', r}, {'p', s}
    };

    int ans = 0;
    vector<vector<char>> hand(k);
    for (int i = 0; i < n; i++) {
        int mod = i % k;
        if (!hand[mod].empty() && hand[mod].back() == t[i]) {
            hand[mod].push_back('o');
        } else {
            hand[mod].push_back(t[i]);
            ans += mp[t[i]];
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 5200
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace TOPSIC
{
    class Program
    {
        static void Main(string[] args)
        {
          int N = int.Parse(Console.ReadLine());
            //入力値をスペース区切りで配列に格納
            string[] inputStr = Console.ReadLine().Split(' ');
            //入力値の個数
            int inputCount = inputStr.Length;
            //入力値をintにした配列
            int[] X = new int[inputStr.Length];

            //入力値をintに変換
            for (int i = 0; i < inputCount; i++)
            {
                X[i] = int.Parse(inputStr[i]);
            }

            double final = 999999999999999999;
            double ans;

            for (int i = 1; i <= 100; i++)
            {
                ans = 0;

                for (int n = 0; n < N; n++)
                {
                    ans += Math.Pow(X[n] - i, 2);
                }

                if (ans < final)
                {
                    final = ans;
                }
            }

            Console.WriteLine(final);
        }
    }
}


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

int main(){
  int n;
  cin >> n;
  int num;
  int tmp=n;
  for(int i=9;i>=0;i--){
    int c=1;
    for(int j=0;j<i;j++){
      c*=10;
    }
    int d=tmp/c;
    num+=d;
    tmp-=d*c;
  }
  if(n%num==0){
    cout << "Yes" << endl;
  }else cout << "No" << endl;
  return 0;
}


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

int main() {
  int N, W;
  cin >> N >> W;
  vector<long> DP(W + 1);
  for (int i = 0, w, v; i < N && cin >> w >> v; i++)
    for (int j = W; j >= w; j--) DP.at(j) = max(DP.at(j), DP.at(j - w) + v);
  cout << DP.at(W) << "\n"; 
}

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

int main()
{
    int N;
    string S, T;

    cin >> N;
    cin >> S >> T;

    string ans;

    for (int i = 0; i < N; i++)
    {
        ans += S[i];
        ans += T[i];
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader
import java.io.InputStreamReader
import java.io.PrintWriter
import kotlin.math.max

val br = BufferedReader(InputStreamReader(System.`in`))
val out = PrintWriter(System.out)

fun main() {
    br.use { out.use {
        solve()
        out.flush()
    } }
}

fun solve() {
    val (n, x, m) = readLongList()

    // 何個目の項からループするのかを求める
    val indexMap = mutableMapOf<Long, Int>()
    var cur = x
    var curIndex = 0
    while (indexMap.containsKey(cur) == false) {
        indexMap[cur] = curIndex
        curIndex++
        cur = cur * cur % m
    }
    val loopFromIndex = indexMap[cur]!!
    
    // ループする前の合計、1ループの合計、1ループの項数
    val sumBeforeLoop = indexMap.filter { it.value < loopFromIndex }.keys.sum()
    val sumOneLoop = indexMap.filter { it.value >= loopFromIndex }.keys.sum()
    val oneLoopSize = indexMap.count() - loopFromIndex

    // ループ開始後のn、ループする数、ループ終了後のn
    val nAfterStartLoop = max(0, n - loopFromIndex)
    val loopCount = nAfterStartLoop / oneLoopSize
    val nAfterEndLoop = nAfterStartLoop % oneLoopSize

    var ans = if (n <= loopFromIndex) 0 else sumBeforeLoop + loopCount * sumOneLoop

    var pre = if (n <= loopFromIndex) x else cur
    val simulateCount = if (n <= loopFromIndex) n.toInt() else nAfterEndLoop.toInt()
    repeat(simulateCount) {
        ans += pre
        pre = pre * pre % m
    }

    out.println(ans)
    return
}

fun readInteger() = Integer.parseInt(br.readLine())
fun readLong() = java.lang.Long.parseLong(br.readLine())
fun readStringList() = br.readLine()!!.split(' ')
fun readIntegerList() = readStringList().map(Integer::parseInt)
fun readLongList() = readStringList().map(java.lang.Long::parseLong)
fun readDoubleList() = readStringList().map(java.lang.Double::parseDouble)


Measured memory_bytes: 47712
n,a,b=map(int,input().split())

def sq(a, b, mod):  # aのb乗を剰余
    if b == 0:
        return 1
    elif b % 2 == 0:
        return sq(a, b // 2, mod)**2 % mod
    else:
        return sq(a, b - 1, mod) * a % mod
  
def egcd(a, b):
    if a == 0:
        return b, 0, 1
    else:
        g, y, x = egcd(b % a, a)
        return g, x - (b // a) * y, y

def modinv(a, m):
    g, x, y = egcd(a, m)
    if g != 1:
        raise Exception('modular inverse does not exist')
    else:
        return x % m
      
mod=10**9+7    
tot=sq(2,n,mod)
prev=1
for i in range(1,min(n+1,2*10**5+1)):
  v=(prev * (n+1-i) % mod * modinv(i, mod) % mod)
  prev=v
  if i==a or i==b:
    tot-=v
    
print((tot-1)%mod)

Measured memory_bytes: 3064
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <vector>
#include <numeric>
#include <algorithm>
#include <iostream>
#include <string>
#include <cstring>
#include <sstream>
#include <functional>
#include <queue>
#include <deque>
#include <stack>
#include <cassert>
#include <bitset>

using namespace std;

using int64 = long long;

/////////////////////
// Code starts here//
/////////////////////


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

    int N;
    cin >> N;
    int64 S = 0;
    for (int i = 1; i <= N; i++) {
        if ((i % 3) && (i % 5)) {
            S += i;
        }
    }
    cout << S << "\n";

    return 0;
}


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

a = [0 for i in range(n)]

count = 0

for i in range(n):
  if (i+1)%3 == 0 or (i+1)%5 == 0:
    continue
  else:
    a[i] = (i+1)
    count += (i+1)

print(count)

Measured memory_bytes: 33672
#pragma GCC optimize("Ofast")
#include<cstdio>
#include<cstdlib>
#include<string>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
#include <cmath>
#include <limits>
#include <iostream>
#include <map>
#include<set>
using namespace std;
#define INF 1LL<<62
#define MAX 100000
#define MOD 1000000007
typedef long long ll;
typedef pair<int,int> P;
typedef pair<pair<int,int>,int> p;
#define bit(n,k) ((n>>k)&1) /*nのk bit目*/
#define rad_to_deg(rad) (((rad)/2/M_PI)*360)
struct edge{ll to,cost,val;};
template<class T,class U>bool chmin(T&a,const U&b){if(a<=b)return false;a=b;return true;}
template<class T,class U>bool chmax(T&a,const U&b){if(a>=b)return false;a=b;return true;}
//__builtin_popcount(S);
//C.erase(unique(C.begin(),C.end()),C.end());
//#define int ll

int dp[5100];
ll dp2[25100000];

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

    int N;
    cin>>N;
    int a[3],b[3];
    for(int i=0;i<3;i++) cin>>a[i];
    for(int i=0;i<3;i++) cin>>b[i];

    dp[0]=0;
    for(int i=1;i<=N;i++){
        dp[i]=i;
        for(int j=0;j<3;j++){
            if(i-a[j]>=0) chmax(dp[i],dp[i-a[j]]+b[j]);
        }
    }
    dp2[0]=0;
    for(int i=1;i<=dp[N];i++){
        dp2[i]=i;
        for(int j=0;j<3;j++){
            if(i-b[j]>=0) chmax(dp2[i],dp2[i-b[j]]+a[j]);
        }
    }
    cout<<dp2[dp[N]]<<endl;
}


Measured memory_bytes: 195584
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

using namespace std;

typedef long long ll;

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

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

int main(void) {
    string S;
    cin >> S;
    const int slen = (int) S.size();

    int cnt = 0;
    for (int i = 0; i < slen / 2; i++) {
        if (S[i] != S[slen - 1 - i]) {
            cnt++;
        }
    }
    cout << cnt << endl;

    return 0;
}


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

int main() {
	int n;
  	cin>>n;
    float k;
  	priority_queue<float,vector<float>,greater<float>> a;
  	for(int i=0;i<n;i++) {
          cin>>k;
          a.push(k);
    }
    while(a.size()!=1) {
        float x=a.top();
        a.pop();
        float y=a.top();
        a.pop();
        float z = (x+y)/2;
        a.push(z);
    }
    cout<<a.top()<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for(int i=0;i<(n);++i)
#define per(i, n) for(int i=(n)-1;i>=0;--i)
#define repa(i, n) for(int i=1;i<(n);++i)
#define foreach(i, n) for(auto &i:(n))
#define pii pair<int, int>
#define pll pair<long long, long long>
#define all(x) (x).begin(), (x).end()
#define bit(x) (1ll << (x))
using ll = long long;
//const ll MOD = (ll)1e9+7;
const ll MOD = 998244353;
const int INF = (ll)1e9+7;
const ll INFLL = (ll)1e18;
using namespace std;
template<class t>
using vvector = vector<vector<t>>;
template<class t>
using vvvector = vector<vector<vector<t>>>;
template<class t>
using priority_queuer = priority_queue<t, vector<t>, greater<t>>;
template<class t, class u> bool chmax(t &a, u b){if(a<b){a=b;return true;}return false;}
template<class t, class u> bool chmin(t &a, u b){if(a>b){a=b;return true;}return false;}
#ifdef DEBUG
#define OUTPUT(x) (output(x), output("\n"))
#else
#define OUTPUT(x) (void)0
#endif

ll modpow(ll x, ll b){
    ll res = 1;
    while(b){
        if(b&1)res = res * x % MOD;
        x = x * x % MOD;
        b>>=1;
    }
    return res;
}

ll modinv(ll x){
    return modpow(x, MOD-2);
}

bool was_output = false;
template<class t>
void output(t a){
    if(was_output)cout << " ";
    cout << a;
    was_output = true;
}
void outendl(){
    was_output = false;
    cout << endl;
}
ll in(){
    ll res;
    scanf("%lld", &res);
    return res;
}

template<class t>
istream& operator>>(istream& is, vector<t> &x){
    for(auto &i:x)is >> i;
    return is;
}

template<class t, class u>
istream& operator>>(istream& is, pair<t, u> x){
    is >> x.first >> x.second;
    return is;
}



int main(){
    ll k = in();
    ll q = in();
    vector<ll> d(k);
    cin >> d;
    rep(query, q){
        ll n = in();
        ll x = in();
        ll m = in();
        --n;
        ll sum = x % m;
        vector<ll> df = [](vector<ll> line, ll mod){foreach(i, line)i %= mod;return line;}(d, m);
        ll ans = n;
        rep(i, k){
            ll time = (n-1) / k + ((n-1) % k >= i);
            sum += time * df[i];
            if(df[i]==0)ans -= time;
        }
        cout << ans - sum / m << endl;
    }
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define LOCAL
#pragma region Macros
typedef long long ll;
#define ALL(x) (x).begin(),(x).end()
const long long MOD=1e9+7;
// const long long MOD=998244353;
const int INF=1e9;
const long long IINF=1e18;
const int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
const char dir[4]={'D','R','U','L'};

template<typename T>
istream &operator>>(istream &is,vector<T> &v){
    for (T &x:v) is >> x;
    return is;
}
template<typename T>
ostream &operator<<(ostream &os,const vector<T> &v){
    for (int i=0;i<v.size();++i){
        os << v[i] << (i+1==v.size()?"": " ");
    }
    return os;
}
template<typename T,typename U>
ostream &operator<<(ostream &os,const pair<T,U> &p){
    cout << '(' << p.first << ',' << p.second << ')';
    return os;
}
template<typename T,typename U>
ostream &operator<<(ostream &os,const map<T,U> &m){
    os << '{';
    for (auto itr=m.begin();itr!=m.end();++itr){
        os << '(' << itr->first << ',' << itr->second << ')';
        if (++itr!=m.end()) os << ',';
        --itr;
    }
    os << '}';
    return os;
}
template<typename T>
ostream &operator<<(ostream &os,const set<T> &s){
    os << '{';
    for (auto itr=s.begin();itr!=s.end();++itr){
        os << *itr;
        if (++itr!=s.end()) os << ',';
        --itr;
    }
    os << '}';
    return os;
}

void debug_out(){cerr << '\n';}
template<class Head,class... Tail>
void debug_out(Head&& head,Tail&&... tail){
    cerr << head;
    if (sizeof...(Tail)>0) cerr << ", ";
    debug_out(move(tail)...);
}
#ifdef LOCAL
#define debug(...) cerr << " ";\
cerr << #__VA_ARGS__ << " :[" << __LINE__ << ":" << __FUNCTION__ << "]" << '\n';\
cerr << " ";\
debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

template<typename T> T gcd(T x,T y){return y!=0?gcd(y,x%y):x;}
template<typename T> T lcm(T x,T y){return x/gcd(x,y)*y;}

template<class T1,class T2> inline bool chmin(T1 &a,T2 b){
    if (a>b){a=b; return true;} return false;
}
template<class T1,class T2> inline bool chmax(T1 &a,T2 b){
    if (a<b){a=b; return true;} return false;
}
#pragma endregion

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    vector<int> A(N);
    for (int i=0;i<N;++i) cin >> A[i];
    vector<vector<int>> G(N);
    for (int i=0;i<N-1;++i){
        int a,b; cin >> a >> b; --a,--b;
        G[a].emplace_back(b);
        G[b].emplace_back(a);
    }
    auto dfs=[&](auto self,int v,int p)->int{
        --A[v];
        int res=0;
        for (int u:G[v]){
            if (u==p||A[v]<A[u]) continue;
            res|=self(self,u,v)^1;
        }
        ++A[v];
        return res;
    };
    vector<int> ans;
    for (int i=0;i<N;++i){
        if (dfs(dfs,i,-1)){
            ans.emplace_back(i+1);
        }
    }
    for (int i=0;i<ans.size();++i) cout << ans[i] << (i+1==ans.size()?'\n':' ');
}

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


typedef long long ll;
typedef vector<long long> VLL;
typedef vector<pair<int,int>> VP;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#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 FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define ALL(a)  a.begin(),a.end()
#define RALL(a) a.begin(),a.end(),greater<int>()
#define ROT(a) a.begin(),a.begin()+1,a.end()
#define RROT(a) a.begin(),a.end()-1,a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
#define sz(a) a.size()
const ll MOD = 1e9+7;
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
//cout << 'H' << endl;
/*--------------------------------------------*/

bool flag = false;
string s;

void dfs(int st){
  string t;
  if(sz(s) - st < 10){
    t = s.substr(st,sz(s)-st); 
    if(t == "dream" || t == "dreamer" || t == "erase" || t == "eraser"){
      flag = true;
      return;
    }
  }
  if(s.substr(st,5) == "dream"){
    dfs(st+5);
  }
  if(s.substr(st,7) == "dreamer"){
    dfs(st+7);
  }
  
  if(s.substr(st,5) == "erase"){
    dfs(st+5);
  }
  if(s.substr(st,6) == "eraser"){
    dfs(st+6);
  } 
}

int main(){
  //cout.precision(10);
  cin.tie(0);
  ios::sync_with_stdio(false);

  cin >> s;
  
  dfs(0);
  
  if(flag) cout << "YES" << endl;
  else cout << "NO" << endl;
}

  
  


Measured memory_bytes: 3280
#include <cassert>

#include <iostream>
#include <algorithm>
#include <deque>
#include <string>

using namespace std;

#define DEBUG(x) cerr << #x << " = " << x << endl

int main() {
  ios::sync_with_stdio(false);

  int n; cin >> n;
  deque<int> l;
  while(n--) {
    string s;
    cin >> s;
    if(s == "insert") {
      int x;
      cin >> x;
      l.push_front(x);
    }
    else if(s == "delete") {
      int x;
      cin >> x;
      auto it = find(l.begin(), l.end(), x);
      if(it != l.end()) {
        l.erase(it);
      }
    }
    else if(s == "deleteFirst") {
      l.pop_front();
    }
    else if(s == "deleteLast") {
      l.pop_back();
    }
    else {
      assert(false);
    }
  }

  int k = 0;
  for(int item : l) {
    cout << item << " \n"[k++ == l.size() - 1];
  }
}

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

#define ll long long int

using namespace std;

int main() {
    string s;
    cin >> s;
    ll m = 0;
    ll cur = 0;
    for (auto c : s) {
        if (c == 'R') {
            ++cur;
            if (m < cur) m = cur;
        } else {
            cur = 0;
        }
    }
    cout << m << endl;      
}


Measured memory_bytes: 3588
/**Bismillahir Rahmanir Rahim.**/
#include<bits/stdc++.h>
#include<stdlib.h>
#include<iostream>
#include<vector>
#include<math.h>
#include<cstring>
#include<cstdio>
using namespace std;
typedef long long int            ll;
typedef long double              ld;
#define Faster  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pi                 acos(-1);
#define test        int t; cin>>t; while(t--)
//scanf("%[^\n]%*c", str);
//sort(s,s+n,greater<int>());
//cin.getline(array,size);
int main()
{
    int n,i;
    cin>>n;
    for(i=1;;i++)
    {
        int s=i*1000;
        if(s>=n)
        {
            cout<<s-n<<endl;
            break;
        }
    }
}


Measured memory_bytes: 3460
#include<iostream>
#include<algorithm>
#include<string>
#include<numeric>
#include<vector>
using namespace std;
 
int main(){

    int n;
    string s;

    cin >> n;
    cin >> s;

    int Wleft = 0;
    int Eright = 0;

    for(int i = 0; i < n; i++){
        if(s[i] == 'E') Eright ++;
    }

    int min = 9999999;
    for(int i = 0; i < n; i++){
        if(s[i] == 'E') Eright --;

        if(Eright + Wleft < min) min = Eright + Wleft;

        if(s[i] == 'W') Wleft ++;

    }

    cout << min << endl;

}

Measured memory_bytes: 900
#include<iostream>
using namespace std;
typedef unsigned long long ll;
ll sum[4000],x;
int main(){
	sum[0]=100;
	for(int i=1;;i++){
		sum[i] = sum[i-1]*1.01;
		//cout<<i<<"=="<<sum[i]<<endl;
		if(sum[i]>=1e18) break;
	}
	cin>>x;
	for(int i=1;i<=3760;i++){
		if(sum[i]>=x){
			cout<<i<<endl;
			break;
		} 
	} 
} 

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

int main(){
  ld W,H,x,y; cin>>W>>H>>x>>y;
  bool flag; ld r,r1,r2;
  r = W*H/2;
  if(W==x*2 && H==y*2){flag = true;}
  else{flag = false;}
  printf("%.12Lf %d",r,flag);
}

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

inline int min(int a, int b)
{
	return (a < b) ? a : b;
}

int main()
{
	int A, B, C, K;
	scanf("%d%d%d%d", &A, &B, &C, &K);

	int ans = 0;
	int usea = min(A, K);
	K -= usea;
	int useb = min(B, K);
	K -= useb;
	int usec = K;

	printf("%d\n", usea - usec);

	return 0;
}


Measured memory_bytes: 1732
#include <iostream>
#include <cmath>
#include <math.h>
// #include <numbers> // C++20
#include <bits/stdc++.h>

int main()
{
  int A, B, H, M;
  std::cin >> A >> B >> H >> M;

  // float pi = std::numbers::pi<float>;
  double pi = M_PI;
  double theta_h = pi / 2 - 2 * pi * double(H) / 12 - 2 * pi / 12 * double(M) / 60;
  double theta_m = pi / 2 - 2 * pi * double(M) / 60;

  double d = sqrt(
      std::pow((double)(A * std::cos(theta_h) - B * std::cos(theta_m)), 2) +
      std::pow((double)(A * std::sin(theta_h) - B * std::sin(theta_m)), 2));

  std::cout << std::fixed << std::setprecision(11)  << d << std::endl;

  return 0;
}


Measured memory_bytes: 4068
//(・ω・)
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, atoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <iomanip> //setprecision
#include <limits>
#include <sstream> //istringstream
using namespace std;

int main(){
  int n;
  long long sum=0;
  cin >> n;
  for(int i=1; i<=n; i++){
     if(i%3!=0 && i%5!=0) sum+=i;
  }
  cout << sum << endl;
}

Measured memory_bytes: 3164
#include<bits/stdc++.h>
#define LL long long
#define Max 100005
#define Mod 1e9+7
const LL mod=1e9+7;
const LL inf=0x3f3f3f3f;
using namespace std;
LL a[Max],b[Max];
bool cmp(LL a,LL b)
{
	return a>b;
}
int main()
{
	LL sa,sb,n;
	sa=sb=0;
	scanf("%d",&n);
	for(int i=0;i<n;i++)
		scanf("%lld",&a[i]),sa+=a[i];
	for(int i=0;i<n;i++)
		scanf("%lld",&b[i]),sb+=b[i];
	if(sa<sb)
	{
		printf("%d\n",-1);
		return 0;
	}
	LL sum=0,c[Max],j=0,ans=0;
	for(int i=0;i<n;i++)
	{
		if(a[i]<b[i])
		{
			sum+=b[i]-a[i],ans++;
		}
		else
			c[j++]=a[i]-b[i];
	}
	sort(c,c+j,cmp);
	for(int i=0;i<j;i++)
	{
		if(sum<=0)
			break;
		sum-=c[i];
		ans++;
	}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 2432
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int[] B = new int[N-1];
    for (int i = 0; i < N-1; i++) {
      B[i] = sc.nextInt();
    }
    
    int ans = B[N-2];
    for (int i = N-3; i >=0; i--) {
      ans += Math.min(B[i], B[i+1]);
    }
    ans += B[0];
    
    System.out.println(ans);
  }
}

Measured memory_bytes: 23764
#include<bits/stdc++.h>
using namespace std;
int main(){
    char s[52][52];
    for(int i=0;i<52;i++){
        for(int j=0;j<52;j++){
            s[i][j]='.';
        }
    }
    int h,w;
    cin>>h>>w;
    for(int i=1;i<=h;i++){
        for(int j=1;j<=w;j++){
            cin>>s[i][j];
        }
    }
    bool ans=true;
    for(int i=1;i<=h;i++){
        for(int j=1;j<=w;j++){
            if(s[i][j]=='#'){
                bool flag=false;
                if(s[i-1][j]=='#'||s[i+1][j]=='#'||s[i][j-1]=='#'||s[i][j+1]=='#')flag=true;
                if(!flag)ans=false;
            }
        }
    }
    if(ans)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Top3{
	int fst=0;
	int snd=0;
	int thd=0;
}

public class Main{
	public static void main(String args[]){
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		int mnt[]=new int[10];
		for(int i=0;i<10;i++){
			String s;
			try {
				s = br.readLine();
				mnt[i]=Integer.parseInt(s);
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
		
		Top3 m = new Top3();
		
		for(int i=0;i<10;i++){
			if(mnt[i]>m.fst){
				m.thd = m.snd;
				m.snd = m.fst;
				m.fst = mnt[i];
			}else if(mnt[i]>m.snd){
				m.thd = m.snd;
				m.snd = mnt[i];
			}else if(mnt[i]>m.thd){
				m.thd = mnt[i];
			}
		}
		System.out.println(m.fst);
		System.out.println(m.snd);
		System.out.println(m.thd);
	}
}

Measured memory_bytes: 16868
//#pragma GCC target("avx2")
//#pragma GCC optimization("O3")
//#pragma GCC optimization("unroll-loops")
//assert(q==w) если q!=w --> runtime error
#include <bits/stdc++.h>

#define pb push_back
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define ub upper_bound
#define lb lower_bound
#define bit __builtin_popcount
#define memset(x) memset(x,0,sizeof(x))

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<vector<int>> matrix;

inline void boost(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}

const ll maxn=2e5+123;
const ll inf=1e9+123;
const ll linf=1e18+123;
const ll mod=1e9+7;
const double eps=1e-9;
const double pi=acos(-1);
int dx[8]={0,1,-1,0,1,-1,1,-1};
int dy[8]={1,0,0,-1,1,1,-1,-1};

int main(){
    boost();
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    int n;
    cin>>n;
    for(double i=1;i<=n;i++){
        if(int(i*1.08)==n){
            cout<<i;
            return 0;
        }
    }
    cout<<":(";
    exit(0);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ft first
#define sc second
#define pt(sth) cout << sth << "\n"
#define chmax(a, b) {if(a<b) a=b;}
#define chmin(a, b) {if(a>b) a=b;}
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
static const ll INF=1e18;
static const ll MAX=101010;
static const ll MOD=1e9+7;


int main(void) {
  ll N, K;
  cin >> N >> K;
  ll R, S, P;
  cin >> R >> S >> P;
  string T;
  cin >> T;
  ll i, j;
  ll score[]={R, S, P};
  
  
  for(i=0; i<N; i++) {
    if(T[i]=='r') T[i]='0';
    if(T[i]=='s') T[i]='1';
    if(T[i]=='p') T[i]='2';
  }
  
  ll ans=0;
  for(i=0; i<K; i++) {
    ll w=0;
    for(j=i; j<N; j+=K) {
      ll f=(j>=K && T[j-K]==T[j]);
      if(f) {
        if(w) {
          w=0;
        }else {
          ans+=score[(T[j]-'0'-1+3)%3];
          w=1;
        }
      }else {
        ans+=score[(T[j]-'0'-1+3)%3];
        w=1;
      }
    }
  }
  
  pt(ans);
  
  
}


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

long long int a[10004]={0}, b[10004]={0};

int main(){
    int n;
    cin >> n;
    for(int i=0;i<n;++i)cin >> a[i];
    for(int i=0;i<n;++i)cin >> b[i];
    long long int x = 0, y = 0;
    for(int i=0;i<n;++i){
        if(a[i] > b[i])y += a[i] - b[i];
        else if(a[i] < b[i]){
            x += (b[i] - a[i] + 1) / 2;
            y += (b[i] - a[i]) % 2;
        }
    }

    cout << (x-y >= 0 ? "Yes" : "No") << endl;

    return 0;
}


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

int main() {
    int n;
    cin >> n;
    int a[n];
    for (int i = 0; i < n; i++) cin >> a[i];
    int ans = 0;
    bool can = true;
    while(true) {
        for (int i = 0; i < n; i++) {
            if(a[i] % 2 != 0) can = false;
            a[i] /= 2;
        }
        if(!can) break;
        ans++;
    }
    cout << ans << endl;

    return 0;
}


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

int main(void){
    int H, W;
    cin >> H >> W;

    vector<string> a(H);
    for(int i=0; i<H; i++){
        cin >> a.at(i);
    }


    for(int i=0; i<W+2; i++) cout << '#';
    cout << endl;

    for(int i=0; i<H; i++){
        cout << '#' << a.at(i) << '#' << endl;
    }

    for(int i=0; i<W+2; i++) cout << '#';
    cout << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define ll long long
#define INF 999999999
using namespace std;
int main() {
  ll A,X;
  A = 100;
  std::cin >> X;
  for (ll i = 1; i < INF; i++) {
    A *= 1.01;
    if (A >= X) {
      std::cout << i << '\n';
      break;
    }
  }
}


Measured memory_bytes: 3644
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()

void QSort(int data1[],int data2[],int left,int right);
void Swap(int x[ ], int i, int j);
int main(void);

void QSort(int data1[],int data2[],int left,int right){
    int i, j;
    int pivot;

    i = left;                      /* ソートする配列の一番小さい要素の添字 */
    j = right;                     /* ソートする配列の一番大きい要素の添字 */

    pivot = data2[(left + right) / 2]; /* 基準値を配列の中央付近にとる */

    while (1) {                    /* 無限ループ */

        while (data2[i] < pivot)       /* pivot より大きい値が */
            i++;                   /* 出るまで i を増加させる */

        while (pivot < data2[j])       /* pivot より小さい値が */
            j--;                   /*  出るまで j を減少させる */
        if (i >= j)                /* i >= j なら */
            break;                 /* 無限ループから抜ける */

        Swap(data2, i, j);
        Swap(data1, i, j);             /* x[i] と x[j]を交換 */
        i++;                       /* 次のデータ */
        j--;
    }
 
    if (left < i - 1)              /* 基準値の左に 2 以上要素があれば */
        QSort(data1, data2, left, i - 1);     /* 左の配列を Q ソートする */
    if (j + 1 <  right)            /* 基準値の右に 2 以上要素があれば */
        QSort(data1, data2, j + 1, right);    /* 右の配列を Q ソートする */

}

void Swap(int x[ ], int i, int j)
{
    int temp;

    temp = x[i];
    x[i] = x[j];
    x[j] = temp;
}

int main(void){
	int N;
    cin >> N;
    int A[N],B[N];
    ll sum = 0;
    string ans = "Yes";

    rep(i,N){
        cin >> A[i] >> B[i];
    }

    QSort(A,B,0,N-1);

    rep(i,N){
        sum = sum + A[i];
        if(sum > B[i]){
            ans = "No";
            break;
        }
    }

   /*  rep(i,N){
        cout << A[i] << " " << B[i] << endl;
    } */
    
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1792
#include <stdio.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <queue>
#include <cstring>

using namespace std;

#define rep(i,x) for(int i=0;i<x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define FIND(x, target) find(x.begin(),x.end(),target)
#define pb(x) push_back(x)
#define output(x) cout<<x<<endl
#define ERASE(x, n) x.erase(x.begin(), x.begin()+n)
// #define int long long
#define P pair<int, int>
typedef long long ll;

const long long int MOD = 1e9+7;
const int INF = -1;
ll dp[100005][13];

signed main(void) {
	int K, X;
	cin >> K >> X;
	
	int min = X-K+1;
	int max = X+K-1;

	for (int i=min; i<=max; i++) {
		cout << i << " ";
	}

	cout << endl;

	return 0;
}


Measured memory_bytes: 256
package main

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

const (
	initialBufSize = 10000
	maxBufSize     = 100000000
)

var sc *bufio.Scanner = func() *bufio.Scanner {
	sc := bufio.NewScanner(os.Stdin)
	buf := make([]byte, initialBufSize)
	sc.Buffer(buf, maxBufSize)
	return sc
}()

// var sc = bufio.NewScanner(os.Stdin)
// var buff []byte
//
// func init() {
// 	sc.Split(bufio.ScanWords)
// 	sc.Buffer(buff, 100000000)
// 	log.SetFlags(log.Lshortfile)
// }

func main() {
	input := nextString()
	remSumArray := make([]int, 2019)
	remSumArray[0] = 1
	var num int
	digit := 1
	for i := len(input) - 1; i >= 0; i-- {
		num += int(input[i]-48) * digit
		digit *= 10
		digit %= 2019
		remSumArray[num%2019]++
	}
	var result int
	for _, num := range remSumArray {
		result += num * (num - 1) / 2
	}
	fmt.Println(result)
}

func nextString() (s string) {
	sc.Scan()
	return sc.Text()
}

func nextFloat64() float64 {
	sc.Scan()
	f, err := strconv.ParseFloat(sc.Text(), 64)
	if err != nil {
		panic(err)
	}
	return f
}

func nextInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func nextInts(n int) (r []int) {
	r = make([]int, n)
	for i := 0; i < n; i++ {
		r[i] = nextInt()
	}
	return r
}

var dy = []int{0, 1, 0, -1}
var dx = []int{1, 0, -1, 0}
var MAX = math.MaxInt32

func pow(a, b int) int {
	return int(math.Pow(float64(a), float64(b)))
}

func lcm(a, b int) int {
	return a * b / gcd(a, b)
}
func gcd(a, b int) int {
	if a < b {
		a, b = b, a
	}
	for b != 0 {
		a, b = b, a%b
	}
	return a
}
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 {
	if p[i].a == p[j].a {
		return p[i].b < p[j].b
	}
	return p[i].a < p[j].a
}


Measured memory_bytes: 2584
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.math,
    std.functional, std.numeric, std.range, std.stdio, std.string, std.random,
    std.typecons, std.container, std.format;

// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] lreads(T = long)(long n){return generate(()=>readln.chomp.to!T()).take(n).array();}
T[] aryread(T = long)(){return readln.split.to!(T[])();}
void scan(TList...)(ref TList Args){auto line = readln.split();
foreach (i, T; TList){T val = line[i].to!(T);Args[i] = val;}}
alias sread = () => readln.chomp();enum MOD = 10 ^^ 9 + 7;
alias PQueue(T, alias less = "a<b") = BinaryHeap!(Array!T, less);
// dfmt on

void main()
{
    long A, B;
    scan(A, B);
    writeln((A < 10 && B < 10) ? A * B : -1);
}


Measured memory_bytes: 256
import scala.io.StdIn
object Main extends App {
  val x = StdIn.readLine().toInt
  
  var b = 1
  var p = 2
  var max = 1
  while(scala.math.pow(b+1, p)  <= x){
    b += 1
    while(scala.math.pow(b, p+1) <= x){
      p += 1
    }
    max = scala.math.max(max, scala.math.pow(b, p).toInt)
    p = 2
  }
  
  println(max)
}


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

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    int min_a = *min_element(a.begin(), a.end());
    int max_a = *max_element(a.begin(), a.end());
    int itr_max;
    int itr_min;
    for (int i = 0; i < n; i++) {
        if (a[i] == max_a) itr_max = i;
        if (a[i] == min_a) itr_min = i;
    }
    if (min_a >= 0) {
        cout << n - 1 << endl;
        for (int i = 2; i <= n; i++) cout << i - 1 << " " << i << endl;
    }
    else if (max_a <= 0) {
        cout << n - 1 << endl;
        for (int i = n; i > 1; i--) cout << i << " " << i - 1 << endl;
    }
    else if (abs(max_a) >= abs(min_a)) {
        cout << 2*n - 2 << endl;
        for (int i = 0; i < n; i++) {
            if (itr_max != i) cout << itr_max + 1 << " " << i + 1 << endl;
        }
        for (int i = 2; i <= n; i++) cout << i - 1 << " " << i << endl;
    }
    else {
        cout << 2*n - 2 << endl;
        for (int i = 0; i < n; i++) {
            if (itr_min != i) cout << itr_min + 1 << " " << i + 1 << endl;
        }
        for (int i = n; i > 1; i--) cout << i << " " << i - 1 << endl;
    }
}


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

using namespace std;

int main()
{
    int A,B;
    cin>>A>>B;


    if((A + B) %2 == 0)
    {
        cout<<(A+B)/2<<endl;
    }
    else
    {
        cout<<"IMPOSSIBLE"<<endl;
    }
}

Measured memory_bytes: 256