akhauriyash/Code-Regression huggingface dataset:
#include <sys/time.h>

#include <iostream>
#include <iomanip>
#include <algorithm>
#include <utility>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <utility>
#include <cctype>


#include <boost/multiprecision/cpp_int.hpp>

using namespace std;

using ll = long long;
using P = pair<double, double>;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mkp(a, b) make_pair(a, b)
ll mod = 1000000007LL;

namespace mp = boost::multiprecision;
using BigInt = mp::cpp_int;


int main() {
	ll x, k ,d;
	cin >> x >> k >> d;

	x = abs(x);

	ll count = x / d;

	if (k <= count) {
		cout << x - d * k << endl;
		return 0;
	}

	x = x - d * count;
	k -= count;

	if (k % 2 == 0) {
		cout << x << endl;
		return 0;
	}

	cout << abs(x - d) << endl;

	return 0;
}


Measured memory_bytes: 3224
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int num = scan.nextInt();
        String str = scan.next();
        String alpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
        String result = "";

        for (int i = 0; i < str.length(); i++) {
            char c = str.charAt(i);
            int wantGet = (alpha.indexOf(c) + num) % 26;
            String[] alphaList = alpha.split("");
            result += alphaList[wantGet];
        }

        System.out.println(result);
    }
}

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

using i64=int64_t;

#define rep(i,x,y) for(i64 i=i64(x),i##_max_for_repmacro=i64(y); i<i##_max_for_repmacro; ++i)
#define debug(x) #x << "=" << (x)
 
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif
 
const int inf=1.01e9;
const i64 inf64=4.01e18;
const double eps=1e-9;
 
template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
        os << v << ",";
    }
    os << "]";
    return os;
}

void solve(){
    const i64 mod = 1'000'000'007;
    i64 N,Q;
    cin >> N >> Q;
    
    vector<i64> A(N);
    rep(i,0,N){
        cin >> A[i];
    }

    vector<i64> X(Q),Y(Q);
    rep(i,0,Q){
        cin >> X[i] >> Y[i];
        --X[i];
        --Y[i];
    }

    const i64 size=3000;
    static i64 pow2[size+1];
    pow2[0]=1;
    rep(i,1,size+1){
        pow2[i]=pow2[i-1]*2%mod;
    }
    static i64 dp[size][size];
    static i64 last[size][size];
    fill_n((i64*)dp,size*size,0);
    fill_n((i64*)last,size*size,-1);
    rep(i,0,N) {
        rep(j, 0, N) {
            if (A[j] <= A[i]) continue;
            ++dp[j][i];
        }
    }

    rep(j,0,Q){
        i64 x=X[j],y=Y[j];

        auto evaluate=[&](i64 k,i64 l){
            if(last[k][l]<j){
                dp[k][l]*=pow2[j-last[k][l]-1];
                dp[k][l]%=mod;
            }
            last[k][l]=j;
        };

        vector<i64> xk(N),kx(N),yk(N),ky(N);
        rep(k,0,N){
            evaluate(x,k);
            xk[k]=dp[x][k];

            evaluate(k,x);
            kx[k]=dp[k][x];

            evaluate(y,k);
            yk[k]=dp[y][k];

            evaluate(k,y);
            ky[k]=dp[k][y];
        }
        rep(k,0,N){
            if(k==x) continue;
            dp[x][k]+=yk[k];
            dp[x][k]%=mod;

            dp[k][x]+=ky[k];
            dp[k][x]%=mod;
        }

        rep(k,0,N){
            if(k==y) continue;
            dp[y][k]+=xk[k];
            dp[y][k]%=mod;

            dp[k][y]+=kx[k];
            dp[k][y]%=mod;
        }

        dp[y][x]+=xk[y];
        dp[y][x]%=mod;

        dp[x][y]+=yk[x];
        dp[x][y]%=mod;
    }

    i64 ans = 0;
    rep(j,0,N){
        rep(k,j+1,N){
            dp[j][k]*=pow2[Q-last[j][k]-1];
            dp[j][k]%=mod;
            ans+=dp[j][k];
            ans%=mod;
        }
    }

    cout << ans << endl;
}

int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}


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

int main() {
    int a,b;
    cin>>a>>b;
    if(a>b) printf("a > b\n");
    if(a<b) printf("a < b\n");
    if(a==b) printf("a == b\n");
    
    return 0;
    
   
}



Measured memory_bytes: 3080
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <iomanip> // 文字幅の指定 setw(int), 詰めたい文字の指定 setfill(char)
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define p(x) cout << (x) << endl
#define FOR(i,r,n) for(ll i=(ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n); i>=r; i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) REP(i,0,n)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define pb push_back

// 定義する？→左揃えで0埋め
// cout << setfill('0') << left << setw(4) << 12; // "0012"
// http://marycore.jp/prog/cpp/padding-left-right-zero/

const int inf = (int)1e9;
const ll INF = (ll)1e18;

// vectorの中身をcout << vs;で表示
template <class T>
ostream &operator<<(ostream &o, const vector<T> &v)
{
    o << "{";
    for (int i = 0; i < (int)v.size(); i++) o << (i > 0 ? ", " : "") << v[i];
    o << "}";
    return o;
}

ll gcd (ll a, ll b) {
	while (b > 0) {
		ll t = a % b;
		a = b, b = t;
	}
	return a;
}

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

bool is_prime (ll n) {
		if (n < 2) return false;
		else if (n == 2) return true;
		else if (n % 2) return false;
		
		double sqrtn = sqrt(n);
		for (ll i = 3; i < sqrtn; i += 2) {
			if (n % i == 0) return false; 
		}
		return true;
}

ll ctoi(char c) {
	return (ll)(c - 48);
}

ll n, k, cnt=0, ans=0;
string s,t;

// ==================== template ============================

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

	signed int a, b; cin >> a >> b;
	cout << max(a+b, max(a-b, a*b)) << endl;

}



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

using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()
#define int long long
#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second
#define mod 1000000007
#define INF 10e10
template <typename T>

void print(T x)
{
	std::cout << x << " ";
}
template <typename T>

void println(T x)
{
	std::cout << x << "\n";
}

signed main(void) {
	int n;
	cin >> n;
	int ans = 1;
	vector<int>a(n);
	rep(i, n) {
		cin >> a[i];
		if (a[i] == 0) {
			print(0);
			return 0;
		}
	}
	rep(i, n) {
		if (a[i]>(int)1e18/ans) {
			print(-1);
			return 0;
		}
		ans *= a[i];
	}
	print(ans);
}

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

namespace AtCoder
{
    class Program
    {
        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }

        static int Solve(int N, int[] A)
        {
            int sum = 0;
            int cnt = 1;
            for (int i = 1; i < N; ++i)
            {
                if (A[i - 1] == A[i])
                {
                    ++cnt;
                }
                else
                {
                    sum += cnt / 2;
                    cnt = 1;
                }
            }
            return sum + cnt / 2;
        }
        static void Main(string[] args)
        {
            int N = ReadInt();
            int[] A = ReadInts();
            Console.WriteLine(Solve(N, A));
        }
    }
}


Measured memory_bytes: 11220
#include <iostream>
#include <vector>
#include <stdlib.h>
#include <algorithm>
using namespace std;

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

	sort(arr, arr + n);

	int i = 0;
	while(i < n && sum % 10 == 0){
		if((sum - arr[i]) % 10){
			sum -= arr[i];
		}
		i++;
	}
	if(i == n){
		cout << 0;
		return 0;
	}
	cout << sum;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <vector>
#include <utility>
#include <algorithm>
#include <string>
#include <queue>
#include <stack>
#include <tuple>
#include <set>
#include <map>
#include <functional>
#include <cmath>
#include <cstring>
using namespace std;
#define sci(n) scanf("%lld", &(n))
#define scd(n) scanf("%Ld", &(n))
typedef long long LL;
typedef long double LD;
typedef pair<LL, LL> pll;

int main(void)
{
	LL a, b, c, _c;
	LL eat = 0;
	LL ans = 0;
	cin >> a >> b >> c;
	_c = c;
	if (c >= a + b) {
		ans += (a + 2*b) + (c-(a+b)>0?1:0);
	}
	else {ans += c + b;
		
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int n, m;
vector<vector<int> > a;
vector<pair<int, int> > s;

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

bool solve(int k, int y, int x, int rest)
{
    if(rest < 0)
        return false;

    if(rest == 0){
        if(k == m)
            return true;
        y = s[k].first;
        x = s[k].second;
        rest = -a[y][x];
        ++ k;
    }

    for(int i=0; i<4; ++i){
        int y2 = y + dy[i];
        int x2 = x + dx[i];
        if(y2 < 0 || y2 >= n || x2 < 0 || x2 >= n)
            continue;
        if(a[y2][x2] > 0){
            a[y2][x2] *= -1;
            if(solve(k, y2, x2, rest + a[y2][x2]))
                return true;
            a[y2][x2] *= -1;
        }
    }

    return false;
}

int main()
{
    for(;;){
        cin >> n;
        if(n == 0)
            return 0;

        a.assign(n, vector<int>(n));
        s.clear();
        m = 0;
        int sum = 0;
        for(int i=0; i<n; ++i){
            for(int j=0; j<n; ++j){
                cin >> a[i][j];
                sum += a[i][j];
                if(a[i][j] < 0){
                    s.push_back(make_pair(i, j));
                    ++ m;
                }
            }
        }

        if(sum != 0){
            cout << "NO" << endl;
            continue;
        }

        if(solve(0, -1, -1, 0))
            cout << "YES" << endl;
        else
            cout << "NO" << endl;
    }
}

Measured memory_bytes: 908
package main

import (
	"fmt"
)

func main() {
	var s string

	fmt.Scan(&s)

	var ans string
	for _, char := range s {
		if char == '0' {
			ans += string('0')
		} else if char == '1' {
			ans += string('1')
		} else if char == 'B' && len(ans) > 0 {
			tmp := []rune(ans)
			ans = string(tmp[:(len(tmp) - 1)])
		}
	}

	fmt.Println(ans)

}


Measured memory_bytes: 512
(let* ((n (read))
       (d (read))
       (x (read))
       (an (loop :for q :from 1 :upto n collect(read))))
  (mapcar (lambda (k) (loop :for w :from 1 :upto d :by k do(setq x (1+ x)))) an)
  (princ x))

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

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


Measured memory_bytes: 3540
object Main extends App {

  import scala.io.StdIn._

  val s = readLine.trim.toArray.map{_.asDigit}.toList
  println(
    calPattern(s)
  )
  def calPattern(chars: List[Int], count: Int = 4): Int = {
    if (count == 1){
      if (chars.isValidAsIpSegment) 1
      else 0
    }else {
      List(1, 2, 3).filter(l ⇒ chars.length >= l && chars.take(l).isValidAsIpSegment).map(l ⇒ calPattern(chars.drop(l), count - 1)).sum
    }
  }
  implicit class Ex(val list: List[Int]){
    def isValidAsIpSegment: Boolean = {
      list.nonEmpty && ((list.head == 0 && list.length == 1) || (list.head != 0 && list.toInt <= 255))
    }
    def toInt: Int = list.foldLeft(0){case (a, b) ⇒ a * 10 + b}
  }
  implicit class Extenion[T](val value :T){
    def also(func: T ⇒ Unit): T = {
      func(value)
      value
    }
    def let[R](func: T ⇒ R): R = func(value)
  }
}


Measured memory_bytes: 44428
#include <iostream>
using namespace std;
int main(void)
{
  int N; cin>>N;
  int ans = 0;
  for(int i=0;i<N;i++){
    int l,r; cin>>l>>r;
    ans+=(r-l+1);
  }
  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 256
import math
from collections import defaultdict
def larger_nibeki(i):
    return 2 ** len(format(i, 'b'))
N = int(input())
A = sorted(map(int, input().split()), reverse=True)
C = defaultdict(int)
for a in A:
    C[a] += 1
ans = 0
for a in A:
    if C[a] == 0:
        continue
    C[a] -= 1
    partner = larger_nibeki(a) - a
    if C[partner] > 0:
        ans += 1
        C[partner] -= 1
print(ans)

Measured memory_bytes: 55920
import java.util.Scanner;

public class Main {

    public static void main(String[] args){

        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int c = sc.nextInt();
        int[][] d = new int[c][c];
        int[][] b = new int[n][n];
        int[][] f = new int[3][c];

        for(int i=0; i<c; i++) {
            for(int j=0; j<c; j++) {
                d[i][j] = sc.nextInt();
            }
        }
        for(int i=0; i<n; i++) {
            for(int j=0; j<n; j++) {
                b[i][j] = sc.nextInt() - 1;
                f[(i+j)%3][b[i][j]]++;
            }
        }

        long res = Long.MAX_VALUE;
        for(int i=0; i<c; i++) {
            for(int j=0; j<c; j++) {
                if(i==j) continue;
                for(int k=0; k<c; k++) {
                    if(j==k || i==k) continue;
                    long score = 0;
                    for(int m=0; m<c; m++) {
                        score += d[m][i] * f[0][m];
                        score += d[m][j] * f[1][m];
                        score += d[m][k] * f[2][m];
                    }
                    res = Math.min(res, score);
                }
            }
        }


        System.out.println(res);
    }

}


Measured memory_bytes: 87360
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
  ll n,s=0;
  cin >> n;
  for(ll i = 1; i <= n; ++i)
  {
      if(i % 3 == 0 || i % 5 == 0)
      {
          continue;
      }
      else 
      {
          s += i;
      }
  }
  cout << s;
}


Measured memory_bytes: 3624
const H,W=map(x->parse(Int,x),split(readline()))
const S=String[]
for i=1:H
	push!(S,chomp(readline()))
end
function calc(sx,sy)
	ret=ones(Int,H,W)*1919810
	ret[sx,sy]=0
	Q=Pair{Int,Int}[sx=>sy]
	while !isempty(Q)
		x,y=shift!(Q)
		for (tx,ty)=[x-1=>y,x+1=>y,x=>y-1,x=>y+1]
			if 1<=tx<=H&&1<=ty<=W&&S[tx][ty]!='#'&&ret[x,y]+1<ret[tx,ty]
				ret[tx,ty]=ret[x,y]+1
				push!(Q,tx=>ty)
			end
		end
	end
	ret
end
function main()
	ans=0
	for i=1:H,j=1:W
		if S[i][j]=='#'
			continue
		end
		d=calc(i,j)
		for I=1:H,J=1:W
			if ans<d[I,J]<1919810
				ans=d[I,J]
			end
		end
	end
	println(ans)
end
main()


Measured memory_bytes: 152588
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>
#define rep(i,n) for(int i=0; i<(n); ++i)
#define outl(x) cout<< (x) << '\n'
using namespace std;
using pii = pair<int,int>;

struct card
{
    char c;
    int n;
    bool operator < (const card &r) const { return n < r.n; }
    bool operator > (const card &r) const { return n > r.n; }
    bool operator != (const card &r) const { return c!=r.c || n!=r.n; }
};

istream& operator >> (istream &is, card &c)
{
    is >> c.c >> c.n;
    return is;
}

ostream& operator << (ostream &os, card &c)
{
    os << c.c << c.n;
    return os;
}

void bubble(card a[], int n)
{
    bool f = true;
    for (int i=0; f; ++i) {
        f = false;
        for (int j=n-1; j > i; --j) {
            if (a[j-1] > a[j]) {
                swap(a[j-1], a[j]);
                f = true;
            }
        }
    }
    return;
}

void selection(card a[], int n)
{
    rep(i, n-1) {
        card *pt = min_element(a+i, a+n);
        if (a+i != pt) {
            swap(a[i], *pt);
        }
    }
    return ;
}

bool same(const card a[], const card b[], int n)
{
    rep(i, n) {
        if (a[i] != b[i]) return false;
    }
    return (true);
}

void print(card a[], int n)
{
    rep(i, n) {
        cout << a[i] << (i+1 < n ? ' ' : '\n');
    }
}

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

   int n;
   card a[38];
   card b[38];

   cin >> n;
   rep(i, n) {
       cin >> a[i];
       b[i] = a[i];
   }

   bubble(a, n);
   selection(b, n);

   print(a,n);
   outl("Stable");

   print(b, n);
   outl(same(a,b,n)? "Stable" : "Not stable");

}




Measured memory_bytes: 3188
import java.util.*;
public class Main {

	public void doIt(){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		while(!(n == 0 && k == 0)){
			int [] list = new int[n];
			list[0] = sc.nextInt();
			for(int i=1; i < n; i++){
				list[i] = list[i-1] + sc.nextInt();
			}
			int max = list[k-1];
			for(int i=1; i + k - 1 < n; i++){
				int result = list[i+k-1] - list[i-1];
				if(result > max){
					max = result;
				}
			}
			System.out.println(max);

			n = sc.nextInt();
			k = sc.nextInt();
		}
	}
	public static void main(String[] args) {
		Main obj = new Main();
		obj.doIt();

	}

}

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

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

using namespace std;

int n;
vector<pair<int,int>> G[100000];

bool vis[100000];
int d[100000];

bool dfs(int u){
	vis[u]=true;
	for(auto e:G[u]){
		int v=e.first,c=e.second;
		if(vis[v]){
			if(d[u]+c!=d[v]) return false;
		}
		else{
			d[v]=d[u]+c;
			if(!dfs(v)) return false;
		}
	}
	return true;
}

int main(){
	int m; scanf("%d%d",&n,&m);
	rep(i,m){
		int u,v,d; scanf("%d%d%d",&u,&v,&d); u--; v--;
		G[u].emplace_back(v,d);
		G[v].emplace_back(u,-d);
	}

	rep(u,n) if(!vis[u] && !dfs(u)) { puts("No"); return 0; }
	puts("Yes");

	return 0;
}


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

#define debug(x) cerr << #x << ": " << x << endl
#define debugArray(x, n)                                                       \
    for(long long hoge = 0; (hoge) < (n); ++(hoge))                            \
    cerr << #x << "[" << hoge << "]: " << x[hoge] << endl
using namespace std;

using ll = long long;
using ull = unsigned long long;
const ll INF = LLONG_MAX / 2;
const ll MOD = 1e9 + 7;

int N;
int l[10];
ll dfs(int a, int b, int c, int S) {
    ll ret = abs(a) + abs(b) + abs(c);
    for(int i = a > 0 ? 0 : N; i <= N; i++) {
        if(!((S >> i) & 1) || i == N) {
            int T = S;
            int A = a;
            if(i < N) {
                T |= (1 << i);
                A -= l[i];
            }
            for(int j = b > 0 ? 0 : N; j <= N; j++)
                if((!((T >> j) & 1)) || j == N) {
                    int U = T;
                    int B = b;
                    if(j < N) {
                        U |= (1 << j);
                        B -= l[j];
                    }
                    for(int k = c > 0 ? 0 : N; k <= N; k++)
                        if((!((U >> k) & 1)) || k == N) {
                            int V = U;
                            int C = c;
                            if(k < N) {
                                V |= (1 << k);
                                C -= l[k];
                            }
                            if(V != S)
                                ret = min(ret, dfs(A, B, C, V) + (i != N) * 10
                                                   + (j != N) * 10
                                                   + (k != N) * 10);
                        }
                }
        }
    }
    return ret;
}

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cin >> N;
    int A, B, C;
    cin >> A >> B >> C;
    for(int i = 0; i < N; i++)
        cin >> l[i];
    ll ans = INF;
    for(int i = 0; i < N; i++) {
        int T = (1 << i);
        for(int j = 0; j < N; j++)
            if(!((T >> j) & 1)) {
                int U = T | (1 << j);
                for(int k = 0; k < N; k++) {
                    if(!((U >> k) & 1)) {
                        int V = U | (1 << k);
                        ans = min(ans, dfs(A - l[i], B - l[j], C - l[k], V));
                    }
                }
            }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String arg[]) {

		Scanner sc = new Scanner(System.in);

		double W = sc.nextInt();
		double H = sc.nextInt();

		double x = sc.nextInt();
		double y = sc.nextInt();

		if (x * 2 == W && y * 2 == H) {
			System.out.println((W * H) / 2 + " " + 1);
		} else {
			System.out.print((W * H) / 2 + " " + 0);
		}
	}
}

Measured memory_bytes: 23764
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007
const ll INF=1e18;
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<endl;}
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 (a > b){ a = b; return 1; } return 0; }



int main(int argc, char const *argv[]) {
  int n, m;
  cin >> n >> m;
  ll ans = 0;
  priority_queue<ll> pq;
  rep(i, n) {
    ll a;cin >> a;
    pq.push(a);
  }
  rep(i,m){
    ll x=pq.top();
    pq.pop();
    pq.push(x / 2);
  }

  while(!pq.empty()){
    ans += pq.top();
    pq.pop();
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1400
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <algorithm>
#include <set>
#include <map>
#include <cassert>
#include <cstdio>
#include <cstdlib>

using namespace std;

#define INF 0x7fffffff

unsigned long d[201][201];

int main(int argc,char** argv) {
	int n,m,r,s[8];
	for(int i = 0;i < 201;i++)for(int j = 0;j < 201;j++)d[i][j] = INF;
	cin >> n >> m >> r;
	for(int i = 0;i < r;i++) {
		cin >> s[i];
		s[i]--;
	}
	for(int i = 0;i < m;i++) {
		int a,b,c;
		cin >> a >> b >> c;
		a--;
		b--;
		d[a][b] = c;
		d[b][a] = c;
	}
	for(int i = 0;i < n;i++)
		for(int j = 0;j < n;j++)
			for(int k = 0;k < n;k++)
				d[j][k] = min(d[j][k],d[j][i] + d[i][k]);
	sort(s,s+r);
	unsigned long res = INF;
	do {
		unsigned long dt = 0;
		for(int i = 1;i < r;i++) {
			dt += d[s[i]][s[i-1]];
		}
		res = min(res,dt);
	}while(next_permutation(s,s+r));
	cout << res << endl;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef complex< double > Point;
typedef vector< Point > Polygon;
namespace std{
    bool operator < ( Point a, Point b){
        return real(a) != real(b) ? real(a) < real(b) : imag(a) < imag(b);
    }
};
const double INF = 1e12;
const double EPS = 1e-8;
Point NextPoint(){
    Point P;
    cin>>P.real()>>P.imag();
    return P;
}
struct Line : Polygon{
    Line(){};
    Line(Point p, Point q){push_back(p);push_back(q);}
};
 
struct Circle{
    Point p;
    double r;
    Circle();
    Circle(Point a, double s){p = a,r = s;}
};
double cross(Point p, Point q){
    return imag(conj(p)*q);
}
double dot(Point p,Point q){
    return real(conj(p)*q);
}
int ccw(Point a,Point b,Point c){
    b -= a,c -= a;
    if(cross(b,c) > 0)return 1;
    if(cross(b,c) < 0)return -1;
    if(dot(b,c) < 0 )return 2;
    if(norm(b) < norm(c))return -2;
    return 0;
}
Point projection(Line l,Point p){
    double t = dot(p - l[0],l[0]-l[1]) / norm(l[0]-l[1]);
    return l[0] + t * (l[0]-l[1]);
}
bool intersectSP(Line s,Point p){
    return abs(s[0]-p)+abs(s[1]-p)-abs(s[1]-s[0]) < EPS;
}
double distanceSP(Line s,Point p){
    const Point r = projection(s,p);
    if(intersectSP(s,r))return abs(r-p);
    return min(abs(s[0] - p),abs(s[1] - p));
}
int main(){
    int r,n;
    while(cin>>r>>n,r){
        int sc[50] = {};
        for(int i = 0;i < n;i++){
            int l,r,h;
            cin>>l>>r>>h;
            l+=21,r+=21;
            for(int j = l;j < r;j++){
                sc[j] = max(sc[j],h);
            }
        }
        Polygon G;
        G.push_back(Point(-100,0));
        G.push_back(Point(0,0));
        for(int i = 0;i < 45;i++){
             
            if(i != 0){
                if(sc[i] != sc[i-1])
                    G.push_back(Point(i,sc[i]));
                 
                G.push_back(Point(i+1,sc[i]));
            }
        }
        G.push_back(Point(100,0));
 
        for(int i = 0;i < G.size();i++){
            //cout<<G[i].real()<<" "<<G[i].imag()<<endl;
        }
 
        double low = -r,high = 25;
        int D = 50;
        //cout<<sc[20]<<endl;
        while(D--){
            double mid = (low+high)/2;
            Circle C = Circle(Point(21,mid),r-EPS);
            double mi = INF;
            for(int i = 0;i < G.size()-1;i++){
                double dist = distanceSP(Line(G[i],G[i+1]),C.p);
                mi = min(mi,dist);
            }
            //cout<<mid<<" "<<mi<<" "<<mid+r<<endl;
            if(mi < r - EPS)high = mid;
            else if(sc[21] < mid+r)high = mid;
            else low = mid;
        }
        printf("%.4lf\n",low+r);
    }
}

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

using namespace std;
 
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl;
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}
typedef long long ll;
// #define int ll
 
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(int)(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const long double pi = 3.1415926535897932384626433832795028841971L;
#define Sp(p) cout<<setprecision(25)<< fixed<<p<<endl;
// int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
// int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
// vi dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};
// vi dx2 = { 1,1,0,-1,-1,-1,0,1 }, dy2 = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
// const ll MOD = 1000000007;
const ll MOD = 998244353;
// #define mp make_pair
//#define endl '\n'


signed main() {
    fio();
    
    int n;
    cin >> n;
    vector<bool> is_prime(n + 1, true);
    is_prime[0] = is_prime[1] = false;
    vl num(n + 1);
    num[1] = 1;
    vi primes(n + 1, -1);
    for (int i = 2; i <= n; i++) {
        if (is_prime[i]) {
            num[i] = 2;
            for (int j = 2; i * j <= n; j++) {
                is_prime[i * j] = false;
                primes[i * j] = i;
            }
        }
        else {
            int mo = i / primes[i];
            int cnt = 0;
            int mm = mo;
            while (mm % primes[i] == 0) {
                cnt++;
                mm /= primes[i];
            }
            num[i] = num[mo] / (cnt + 1) * (cnt + 2);
        }
    }

    ll ans = 0;
    rep1 (i, n) {
        ans += num[i] * i;
    }
    cout << ans << endl;
}


Measured memory_bytes: 121712
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		
		if(n % 2 ==0 && n % n == 0) System.out.println(n);
		else System.out.println(n * 2);

		scan.close();
	}
}


Measured memory_bytes: 23124
n,m=map(int,input().split())
s=[]
for i in range(n):
  t=input()
  if '#' in t:
    s.append(t)
s2=[list(x) for x in zip(*s)]
s3=[]
for i in range(m):
  if '#' in s2[i]:
    s3.append(s2[i])
s4=[list(x) for x in zip(*s3)]
for i in s4:
  print("".join(map(str,i)))


Measured memory_bytes: 3188
n,c = map(int,input().split())
l = [[0,0] for _ in range(n)]
dp1 = [0 for _ in range(n)]
dp2 = [0 for _ in range(n)]
mx1 = [0 for _ in range(n)]
mx2 = [0 for _ in range(n)]
for i in range(n):
    l[i] = list(map(int, input().split()))


dp1[0] = l[0][1] - l[0][0]
dp2[0] = l[-1][1] - c + l[-1][0]
tmp = dp1[0]
tmp2 = dp2[0]
mx1[0] = dp1[0]
mx2[0] = dp2[0]
for i in range(1,n):
    dp1[i] = dp1[i-1] + l[i][1] - l[i][0] + l[i-1][0]
    dp2[i] = dp2[i-1] + l[-i-1][1] - l[-i][0] + l[-i-1][0]
    if tmp < dp1[i]:
        mx1[i] = dp1[i]
        tmp = dp1[i]
    else :
        mx1[i] = tmp
    if tmp2 < dp2[i]:
        mx2[i] = dp2[i]
        tmp2 = dp2[i]
    else :
        mx2[i] = tmp2

ans = max(max(dp1),max(dp2))

tmp = [0 for _ in range(n-1)]
tmp2 = [0 for _ in range(n-1)]
for i in range(n-1):
    tmp[i] = dp1[i] + mx2[-i-2] - l[i][0]
    if ans < tmp[i]:
        ans = tmp[i]

for i in range(n-1):
    tmp2[i] = dp2[i] + mx1[-i-2] - (c - l[-i-1][0])
    if ans < tmp2[i]:
        ans = tmp2[i]

if ans > 0:
    print(ans)
else:
    print(0)


Measured memory_bytes: 46060
import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner in = new Scanner(System.in);
		while(true){
			int n = in.nextInt();
			if(n==0) break;
			Lines[] line = new Lines[n+1];
			Queue<Integer> ans = new LinkedList<Integer>();
			for(int i=0; i<=n; i++){
				int m = in.nextInt();
				Pos[] p = new Pos[m];
				for(int j=0; j<m; j++){
					p[j] = new Pos(in.nextInt(), in.nextInt());
				}
				line[i] = new Lines(p);
				if(i==0) continue;
				if(line[0].equals(line[i])) ans.add(i);
			}
			for(int i: ans) System.out.println(i);
			System.out.println("+++++");
		}
	}
	
}

class Lines{
	String[] str;
	public Lines(Pos[] pos){
		str = new String[2];
		for(int i=0; i<2; i++){
			str[i] = ""+pos[0].dist(pos[1]);
			for(int j=1; j<pos.length-1; j++){
				str[i]+= (ccw(pos[j-1], pos[j], pos[j+1])==-1?'a':'b')+"";
				str[i]+= pos[j].dist(pos[j+1])+"";
			}
			if(i==1)break;
			Pos[] tmp = new Pos[pos.length];
			for(int j=0; j<pos.length; j++)
				tmp[j] = pos[pos.length-1-j];
			pos = tmp;
		}
	}
	
	@Override
	public boolean equals(Object obj) {
		Lines o = (Lines)obj;
		if(o.str[0].equals(str[0]) || o.str[0].equals(str[1]))
			return true;
		return false;
	}
	
	public static int ccw(Pos a, Pos b, Pos c){
		int dx1 = b.x-a.x;
		int dy1 = b.y-a.y;
		int dx2 = c.x-a.x;
		int dy2 = c.y-a.y;
		return Integer.signum(dx1*dy2-dx2*dy1);
	}
}

class Pos{
	int x, y;
	public Pos(int x, int y){
		this.x = x;
		this.y = y;
	}
	
	public int dist(Pos p){
		return (x-p.x)*(x-p.x) + (y-p.y)*(y-p.y);
	}
}

Measured memory_bytes: 30388
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <limits.h>
#include <string.h>


int main(void)
{
	int h,w,d,l[200000],r[200000];
	int q;
	int a;
	int i,j,k;
	int x[100000],y[100000],ke[100000];
	scanf("%d%d%d",&h,&w,&d);
	for(i=1;i<=h;i++)for(j=1;j<=w;j++){
		scanf("%d",&a);
		x[a]=i;
		y[a]=j;
	}
	scanf("%d",&q);
	for(i=1;i<=q;i++){scanf("%d%d",&l[i],&r[i]);ke[i]=0;}
	for(i=d+1;i<=h*w;i++){ke[i]=ke[i-d]+(int)(fabs(x[i]-x[i-d])+fabs(y[i]-y[i-d]));}
	for(i=1;i<=q;i++){printf("%d\n",ke[r[i]]-ke[l[i]]);}
		
	
	return 0;
}


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

#define fr(i,n) for(int i = 0; i<n; i++)
#define sz(v) (int)(v.size())
#define prin(a) cout << #a << " = " << a << endl
#define all(v) (v).begin(),(v).end()

typedef long long ll;

const int N = 1e5+10;
ll v[N];

int main(){
	int n; cin >> n;
	
	ll ans = 1;
	
	fr(i,n) scanf("%lld", v+i);
	
	fr(i,n){
		if(v[i]==0){
			cout << 0 << endl;
			return 0;
		}
	}
	
	ll maxv = round(1e18l);
	fr(i,n){
		if(ans>maxv/v[i]){
			cout << -1 << endl;
			return 0;
		}
		ans *=v[i];
	}
	
	if(ans>maxv){
		cout << -1 << endl;
	} else{
		cout << ans << endl;
	}
}

Measured memory_bytes: 4540
#include <iostream>

using namespace std;

int main(){
  int N, i, max=0, index=-1, flag=0, sum=0;
  cin >> N;
  int L[N];
  for(i=0; i<N; i++){
    cin >> L[i];
    if(max<L[i]){
      max = L[i];
      index = i;
    }
  }
  for(i=0; i<N; i++){
    if(index != i){
      sum += L[i];
    }
  }
  if(sum > L[index]) flag=1;
  if(flag==0) cout << "No\n";
  else cout << "Yes\n";
  return 0;
}


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

const double PI = 3.14159265358979323846;
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
//typedef pair<ll, ll> P;
typedef pair<double, ll> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

std::istream &operator>>(std::istream &in, set<int> &o) {
    ll a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);

//const ll mod = 1e10;
typedef priority_queue<string, vector<string>, greater<string> > PQ_ASK;

int dfs(int i, int k, vector<int> &parents, vector<vector<int>> &edges, vector<bool> &change) {
    int child_depth = 0;
    for (int to : edges[i]) {
        int now = dfs(to, k, parents, edges, change);
        cmax(child_depth, now);
    }
    int depth = child_depth + 1;
    if (depth == k && parents[i] != 0) {
        parents[i] = 0;
        change[i] = true;
        return 0;
    }
    return depth;
}

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

    vector<vector<int>> edges(n);
    vector<bool> change(n, false);

    vector<int> parents(n);
    rep(i, n) {
        int a;
        cin >> a;
        a--;

        if (i == 0) {
            if (a != 0) {
                change[0] = true;
            }
            continue;
        }

        edges[a].push_back(i);
        parents[i] = a;
    }

    vector<int> ds(n);

    dfs(0, k, parents, edges, change);

    int ans = count(change.begin(), change.end(), true);
    cout << ans << endl;

}


Measured memory_bytes: 15872
import java.util.Scanner;

//Scene in a Picture
public class Main{

	public static void dump(int[][][] p, int m){
		for(int k=0;k<4;k++){
			for(int i=0;i<m;i++){
				for(int j=0;j<m;j++){
					System.out.print(p[i][j][k] + " ");
				}
				System.out.println();
			}
			System.out.println();
		}
	}

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(true){
			int n = sc.nextInt();
			int m = sc.nextInt();
			if(n==0&&m==0)break;
			int[][] map = new int[n][n];
			for(int i=0;i<n;i++)for(int j=0;j<n;j++)map[i][j]=sc.nextInt();
			int[][][] p = new int[m][m][4];
			for(int i=0;i<m;i++)for(int j=0;j<m;j++)p[i][j][0]=sc.nextInt();
			for(int k=1;k<4;k++){
				for(int i=0;i<m;i++)for(int j=0;j<m;j++)p[i][j][k]=p[j][m-1-i][k-1];
			}



			boolean f = false;
			for(int i=0;i<n-m+1;i++){
				if(f)break;
				for(int j=0;j<n-m+1;j++){
					if(f)break;
					for(int k=0;k<4;k++){
						boolean match = true;
						int ti = -1;
						int tj = -1;
						for(int di=0;di<m;di++){
							for(int dj=0;dj<m;dj++){
								if(p[di][dj][k]==-1)continue;
								else if(ti==-1){
									ti = di;
									tj = dj;
								}
								if(p[di][dj][k]!=map[i+di][j+dj]){
									match = false;
									break;
								}
							}
						}
						if(match){
							f = true;
							System.out.println((j+tj+1) + " " + (i+ti+1));
							break;
						}
					}
				}
			}
			if(!f)System.out.println("NA");
		}
	}
}

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

long long arr[100001];

int main()
{
    int n,j;
    int count=0,gc=0;
    long long a;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>a;
        arr[i]=a;

    }
    sort(arr,arr+n);
    for(int i=0;i<n;i++)
    {
        for(j=i;1;j++)
        {
            if(arr[i]!=arr[j])
                break;
            count++;
        }
        if(count%2!=0)
            gc++;
        count=0;
        i=j-1;
    }
    cout<<gc<<endl;
}

Measured memory_bytes: 1024
n = input()
a = sorted(map(int, input().split()), reverse=True)

i = 1
result = a[0]
flag = False
if a[-1] == 0:
    result = 0
else:
    for i in range(len(a)-1):
        result = result * a[i+1]
        if result > 10 ** 18:
            flag = True
            break

if flag:
    print(-1)
else:
    print(result)


Measured memory_bytes: 21704
#include<stdio.h>
#include<string.h>
char ha[1<<21],k[256];
int main(int argc,char *argv[]){
  int i,flg;
  int val,s,t;
  char c;
  k['T'] = 1;
  k['G'] = 2;
  k['C'] = 3;
  k['A'] = 4;
  
  scanf("%d", &val);
  getchar();
  for(i=0;i<val;i++){
    s = 0;
    t = 1;
    flg = ( c = getchar() ) == 'i';
    while ( ( c = getchar() ) != ' ' );
    while ( ( c = k[getchar()] ) != 0 ) {
      s += c * t;
      t *= 4;
    }
    if (flg) ha[s] = 1; else puts( ha[s] ? "yes" : "no" );
  }
  return 0;
}



Measured memory_bytes: 3076
from collections import Counter

N = int(input())
A_array = list(map(int, input().split()))
Ai_dict = Counter(A_array)


def calc_comb(dct):
    num = 0
    for k,v in dct.items():
        num += v*(v-1)/2
    return int(num)


res_dict = dict([])
TotalComb = calc_comb(Ai_dict)

for n in A_array:
    if not n in res_dict.keys():
        res_dict[n] = TotalComb - Ai_dict[n]+1
    print(res_dict[n])


Measured memory_bytes: 35224
import java.util.Scanner;

public class Main {

		public static void main(String[] args) {
		// TODO Auto-generated method stub
		try (Scanner sc = new Scanner(System.in)) {
			int RATE, DICREASE, ans = 0;
			RATE = sc.nextInt();
			DICREASE = sc.nextInt();
			ans = sc.nextInt();
			
			for (int i = 1; i <= 10; i++) {
				ans = RATE*ans - DICREASE;
				System.out.println(ans);
			}
			
		} catch (Exception e) {
			// TODO: handle exception
		}
	}

}


Measured memory_bytes: 21844
s = input()
for i in range(len(s) // 5):
    if s[-5:] == "dream" or s[-5:] == "erase":
        s = s[:-5]
    elif s[-6:] == "eraser":
        s = s[:-6]
    elif s[-7:] == "dreamer":
        s = s[:-7]
ans = "YES" if s == "" else "NO"
print(ans)

Measured memory_bytes: 3188
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
inline int my_getchar_unlocked(){
  static char buf[1048576];
  static int s = 1048576;
  static int e = 1048576;
  if(s == e && e == 1048576){
    e = fread_unlocked(buf, 1, 1048576, stdin);
    s = 0;
  }
  if(s == e){
    return EOF;
  }
  return buf[s++];
}
inline void rd(int &x){
  int k;
  int m=0;
  x=0;
  for(;;){
    k = my_getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = my_getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
struct MY_WRITER{
  char buf[1048576];
  int s;
  int e;
  MY_WRITER(){
    s = 0;
    e = 1048576;
  }
  ~MY_WRITER(){
    if(s){
      fwrite_unlocked(buf, 1, s, stdout);
    }
  }
}
;
MY_WRITER MY_WRITER_VAR;
void my_putchar_unlocked(int a){
  if(MY_WRITER_VAR.s == MY_WRITER_VAR.e){
    fwrite_unlocked(MY_WRITER_VAR.buf, 1, MY_WRITER_VAR.s, stdout);
    MY_WRITER_VAR.s = 0;
  }
  MY_WRITER_VAR.buf[MY_WRITER_VAR.s++] = a;
}
inline void wt_L(char a){
  my_putchar_unlocked(a);
}
inline void wt_L(int x){
  int s=0;
  int m=0;
  char f[10];
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    my_putchar_unlocked('-');
  }
  while(s--){
    my_putchar_unlocked(f[s]+'0');
  }
}
int K;
int arr[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
int main(){
  rd(K);K += (-1);
  wt_L(arr[K]);
  wt_L('\n');
  return 0;
}
// cLay varsion 20200314-1

// --- original code ---
// int K, arr[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
// {
//   rd(K--);
//   wt(arr[K]);
// }


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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin >> n;
    switch (n%10) {
        case 2:
        case 4:
        case 5:
        case 7:
        case 9:
            cout << "hon" << endl;
            return 0;
        case 0:
        case 1:
        case 6:
        case 8:
            cout << "pon" << endl;
            return 0;
        case 3:
            cout << "bon" << endl;
    }
    return 0;
}

Measured memory_bytes: 3656
#include<stdio.h>

int main (){

   int n;
   scanf("%d",&n);

  int i,j,k,l,m,b,f,r,v;
 int d1[3][10],d2[3][10],d3[3][10],d4[3][10];
 for(j=0;j<3;j++){
   for(k=0;k<10;k++){
     d1[j][k]=0;
     d2[j][k]=0;
     d3[j][k]=0;
     d4[j][k]=0;

   }
 }//numbers sets                                                                

  for(i=0;i<n;i++){
    scanf("%d %d %d %d",&b,&f,&r,&v);
  if(b==1){
    d1[f-1][r-1]+=v;
    }
  if(b==2){
    d2[f-1][r-1]+=v;
  }
  if(b==3){
    d3[f-1][r-1]+=v;
  }
  if(b==4){
      d4[f-1][r-1]+=v;
    }
    }
for(j=0;j<3;j++){
    for(k=0;k<10;k++){
      printf(" %d",d1[j][k]);
    }
    printf("\n");
  }

  printf("####################\n");
  for(j=0;j<3;j++){
    for(k=0;k<10;k++){
      printf(" %d",d2[j][k]);
    }
    printf("\n");
  }
  printf("####################\n");
  for(j=0;j<3;j++){
    for(k=0;k<10;k++){
      printf(" %d",d3[j][k]);
    }
    printf("\n");
  }
  printf("####################\n");
  for(j=0;j<3;j++){
    for(k=0;k<10;k++){
      printf(" %d",d4[j][k]);
    }
    printf("\n");
  }
  return 0;
}

Measured memory_bytes: 612
import java.util.Arrays;
import java.util.Scanner;
import java.util.stream.IntStream;

/**
 * 解説どおりに作成したソースコード
 */
public class Main {

	private static final long MOD = 1_000_000_007L;

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int n = scanner.nextInt();
			int[] a = new int[n + 1];
			IntStream.range(0, n + 1).forEach(i -> a[i] = scanner.nextInt());
			// 各数字が配列aでのindexを格納する配列
			int[] indexes = new int[n + 1];
			Arrays.fill(indexes, -1);
			int tempL = 0, tempR = 0;
			for (int i = 0; i < n + 1; i++) {
				if (indexes[a[i]] >= 0) {
					tempL = indexes[a[i]] + 1;
					tempR = i + 1;
					break;
				}
				indexes[a[i]] = i;
			}
			final int l = tempL, r = tempR;
			// 階乗の配列
			long[] frac = new long[n + 2];
			frac[0] = 1;
			IntStream.range(1, frac.length).forEach(i -> frac[i] = frac[i - 1] * i % MOD);
			// 階乗^-1の配列
			long[] reverseFrac = new long[n + 2];
			reverseFrac[n + 1] = powMod(frac[n + 1], MOD - 2);
			IntStream.range(1, reverseFrac.length).map(i -> reverseFrac.length - i - 1)
					.forEach(i -> reverseFrac[i] = reverseFrac[i + 1] * (i + 1) % MOD);
			// n+1_C_k − l+n−r_C_k−1 を計算
			IntStream.rangeClosed(1, n + 1)
					.mapToLong(k -> calcMod(frac[n + 1] * reverseFrac[k] % MOD * reverseFrac[n + 1 - k] % MOD
							- ((l + n - r - k + 1 >= 0)
									? frac[l + n - r] * reverseFrac[k - 1] % MOD * reverseFrac[l + n - r - k + 1] % MOD
									: 0L)))
					.forEach(System.out::println);
		}
	}

	/**
	 * @param n
	 * @param m
	 * @return n^m mod MOD
	 */
	private static long powMod(long n, long m) {
		long result = 1L;
		while (m > 0) {
			if (1 == (m & 1)) {
				result = result * n % MOD;
			}
			n = n * n % MOD;
			m >>= 1;
		}
		return result;
	}

	/**
	 * @param l 入力数字
	 * @return l mod MOD
	 */
	private static long calcMod(long l) {
		l %= MOD;
		if (l < 0) {
			l += MOD;
		}
		return l;
	}
}


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

int main() {
  string S;
  long K;
  cin >> S >> K;

  string T = S + ' ';
  int t = 0;
  for (int i = 0, cnt = 1; i + 1 < T.size(); i++) {
    if (T.at(i) != T.at(i + 1)) t += cnt / 2, cnt = 1;
    else cnt++;
    if (cnt == S.size()) return cout << cnt * K / 2 << "\n", 0;
  }

  string R = S + S + ' ';
  int r = 0;
  for (int i = 0, cnt = 1; i + 1 < R.size(); i++) {
    if (R.at(i) != R.at(i + 1)) r += cnt / 2, cnt = 1;
    else cnt++;
  }

  cout << ((K == 1) ? t : t + (r - t) * (K - 1)) << "\n";
}

Measured memory_bytes: 256
//============================================================================
// Name        : AOJ.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
using namespace std;
int P[100001];
long long A[100001],B[100001],C[100001];
int D[100001];

int main() {
	int N,M;
	long long R=0;
	cin>>N>>M;
	for(int i=1;i<M+1;i++)cin>>P[i];

	for(int i=1;i<N;i++)cin>>A[i]>>B[i]>>C[i];

	for(int i=1;i<M;i++){
		if(P[i]<P[i+1]){
			for(int j=P[i];j<P[i+1];j++)D[j]+=1;
		}else{
			for(int j=P[i+1];j<P[i];j++)D[j]+=1;
		}
	}

	for(int j=1;j<N;j++)R+=min(D[j]*B[j]+C[j],D[j]*A[j]);
	cout<<R<<endl;
	return 0;
}

Measured memory_bytes: 6200
N ,Q = map(int, input().split())
S = list(input())
ans = [0]*N
jdg = S[0]
cnt = 0
for i in range(1,N):
    if jdg == "A" and S[i] == "C":
        cnt += 1
        ans[i] = cnt
        jdg = S[i]
    else:
        jdg = S[i]
        ans[i] = cnt

for i in range(Q):
    l, r = map(int, input().split())
    print(ans[r-1]-ans[l-1])

Measured memory_bytes: 54520
/***
*	???????????????
*	???????¨??????????????????§?????????????°????minj???????????????????????????????????????????????´???????????¢?????´????????????
****/

#include <iostream>
#include <vector>
using namespace std;


int main(void)		//???????????¢??°
{
	int n;
	cin >> n;
	
	vector <int> str;
	str.resize(n);
	
	for(int i =0; i < n ;  i++){	//????????\???
		cin >> str[i] ;
	}
	int cnter =0;
//-----------------------------------??\???????????????
	for( int i=0 ; i <= ( n-1 ) ; i++ ){
		int minj = i;
		int p = 0;
		for(int j = i ; j<= ( n-1 ); j++ ){
			
			if( str[j] < str[minj]){	//???????????????????????§????°??????????????´?minj????±???????
				minj = j;
				p++;
			}
		}
		if(p!=0){
			int temp   = str[i];		//str[j]??¨str[minj]?????????????´??????????
			str[i]     = str[minj];
			str[minj]  = temp;
			cnter ++;
		}else{
			//???????????????????????´???
		}
	}
//----------------------------------	???????????????
	for(int i =0; i<n ; i++){
		cout << str[i] ;
		if(i != (n-1)){
			cout << " ";
		}
	}
	cout << endl;
	
	cout << cnter << endl;
	
	return 0;
}

Measured memory_bytes: 1200