akhauriyash/Code-Regression huggingface dataset:
#include <cmath>
#include <iostream>
#include <functional>
#include <string>
#include <sstream>
#include <vector>
#include <algorithm>
#include <stdio.h>
using namespace std;


int main(){    
  int r,d,x[11];
  cin >> r >> d >> x[0];

  for(int i=0;i<11;i++){
    x[i+1] = r*x[i] - d;
  }
  
  for(int i=1;i<11;i++){
  cout << x[i] << endl;
  }
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>

using namespace std;

int X,K,Q,maxn[100001],minn[100001],r[1000001],f[1000001],t,a,ans;

int main(){
	scanf("%d%d",&X,&K);maxn[0]=X;for(int i=1;i<=K;++i)scanf("%d",r+i);
	for(int i=1;i<=K;++i){
		int t=r[i]-r[i-1];maxn[i]=maxn[i-1],minn[i]=minn[i-1];
		if(i&1)minn[i]=max(minn[i],min(maxn[i],t-f[i-1])),f[i]=max(minn[i-1]+f[i-1]-t,0)-minn[i];
		else maxn[i]=min(maxn[i],max(minn[i],X-t-f[i-1])),f[i]=min(maxn[i-1]+f[i-1]+t,X)-maxn[i];
	}
	scanf("%d",&Q);
	for(int i=1;i<=Q;++i){
		scanf("%d%d",&t,&a);
		int j=upper_bound(r+1,r+K+1,t)-r-1,p=t-r[j];
		a=max(minn[j],a),a=min(maxn[j],a);
		ans=a+f[j];
		if(j&1)ans=min(X,ans+p);else ans=max(0,ans-p);
		printf("%d\n",ans);
	}
}

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

int main() {
  int N = 0;
  cin >> N;
  
  int pi[N];
  int max = 0;
  for (int i = 0; i < N; i++) {
  	int p = 0;
    cin >> p;
    if (max < p) {
      max = p;
    }
    pi[i] = p;
  }
  
  int sum = 0;
  bool f = true;
  for (int p: pi) {
    if (p == max && f) {
      sum += p / 2;
      f = false;
    } else {
      sum += p;
    }
  }
  
  cout << sum << endl;
  
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main{
	public static void main(String[] ag) {
		Scanner sc=new Scanner(System.in);
		int N=sc.nextInt();
		int M=sc.nextInt();

		int[] machi=new int[N+1];
		for(int i=0; i<N+1; i++) {
			machi[i]=0;
		}

		int mae=0,ato=0;
		for(int i=0; i<M; i++) {
			mae=sc.nextInt();
			ato=sc.nextInt();
			machi[mae]++;
			machi[ato]++;
		}

		for(int i=1; i<=N; i++) {
			System.out.println(machi[i]);
		}
	}
}

Measured memory_bytes: 21844
def mapt(fn, *args):
    return tuple(map(fn, *args))
    

# def sum_num_is_x(n, x):
#     seen = set()
#     for a in range(1, n+1):
#         for b in range(1, n+1):
#             for c in range(1, n+1):
#                 if a != b and a != c and b != c:
#                     if a + b + c == x:
#                         k = tuple(sorted([a,b,c]))
#                         seen.add(k)
#     return len(seen)

from itertools import combinations


def sum_num_is_x(n, x):
    return len([row for row in combinations(range(1, n+1), 3) if sum(row)==x])

def Input():
    while True:
        n, x = mapt(int, input().split(" "))
        if n == x == 0: break
        print(sum_num_is_x(n, x))

Input()



Measured memory_bytes: 5744
#include<iostream>
#include<string>
#include<algorithm>
#include<bits/stdc++.h>
#include<math.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rep1(i,n) for(int i = 1; i < (n); i++)

int main(){
    string s, t, u;
    int a, b;
    cin >> s >> t >> a >> b >> u;
    if(s==u){
        a--;
    } else if(t==u) {
        b--;
    }
    cout << a << " " << b << endl;
}

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

#define debug(x) cout <<"DEBUG"<<" "<< #x << ":" << x << '\n'
#define rep(i,n) for(int_fast32_t i = 0; i < ((int_fast32_t)(n)); i++)   // 0-indexed up
#define rep1(i,n) for(int_fast32_t i = 1; i <= ((int_fast32_t)(n)); i++) // 1-indexed up
#define rrep(i,n) for(int_fast32_t i = ((int_fast32_t)(n)-1); i >= 0; i--)  // 0-indexed down
#define rrep1(i,n) for(int_fast32_t i = ((int_fast32_t)(n)); i >= 1; i--)   // 1-indexed down
#define all(x) (x).begin(),(x).end()

using namespace std;

template<typename T>
using vec = vector<T>;
using i32 = int_fast32_t;
using i64 = int_fast64_t;
using u32 = uint_fast32_t;
using u64 = uint_fast64_t;
using ll = long long;
using ld = long double;
using vi = vec<int_fast32_t>;
using vl = vec<int_fast64_t>;
using vld = vec<ld>;
using vii = vec<vi>;
using PII = pair<int_fast32_t, int_fast32_t>;

template<class T>
using maxheap = std::priority_queue<T>;
template<class T>
using minheap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

template<class T,class U> inline bool chmax(T &a, const U &b){if(a<b){a=b;return 1;}return 0;}
template<class T,class U> inline bool chmin(T &a, const U &b){if(a>b){a=b;return 1;}return 0;}

const ld Pi = std::acos(-1.0L);
constexpr ll infll = (1LL<<62)-1;
constexpr int inf = (1<<30)-1;
const int mod = 1000000007;
// const int mod = 998244353;


/*FUNCs=================================================*/


/*MAIN==================================================*/
signed main(){
    double START_TIME = clock();
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
//    cout << fixed << setprecision(15);

    i32 n, p; cin >> n >> p;
    string s; cin >> s;

    vi mod_s(n+1);
    i32 mod_pow10 = 1;
    rep(i,n) {
        mod_s[i+1] = mod_s[i] + (i32)(s[n-1-i]-'0') * mod_pow10;
        mod_pow10 *= 10;
        mod_pow10 %= p;
    }

    i64 ans = 0;
    if(p == 2) {
        rep(i,n) {
            if(i32(s[n-1-i]-'0') % 2 == 0) {
                ans += n-i;
            }
        }
    }
    else if(p == 5) {
        rep(i,n) {
            if(i32(s[n-1-i]-'0') == 0 || i32(s[n-1-i]-'0') == 5) {
                ans += n-i;
            }
        }
    }
    else {
        map<i32, i32> mp;
        for(auto val : mod_s) {
            mp[val%p]++;
        }
        for(auto pr : mp) {
            ans += pr.second * (pr.second-1) / 2;
        }
    }
    cout << ans << '\n';

//     printf("ElapsedTime: %5.3f ms\n",1000*((clock()-START_TIME)/CLOCKS_PER_SEC));
}


Measured memory_bytes: 5480
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
using ll = long long;
using ld = long double;
#define endl "\n"
//#define int long long
#define ALL(x) begin(x),end(x)
#define _CRT_SECURE_NO_WARNINGS
#define rep(i, n) for (int i = 0; i < n; i++)
#define _GLIBCXX_DEBUG
const int MOD = 1e9 + 7;
const int INF = 1e18 + 9;
constexpr long double pi = 3.141592653589793238462643383279;
int fact(int i) {
    if (i == 0) return 1;
    return ((fact(i - 1)) * i) % MOD;
}
int gcd(int a, int b) {
    if (b == 0) return a;
    return gcd(b, a % b);
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
int keta(int n) {
    if (n == 0) return 1;
    int count = 0;
    while (n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
int ketasum(int n) {
    int sum = 0;
    while (n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
char toSmall(char c) { // 大文字を小文字へ
    return (c + 0x20);
}
char toLarge(char c) { // 小文字を大文字へ
    return (c - 0x20);
}
float myPower(int a, int n) { // aのn乗の計算
    float x = 1;
    while (n > 0) { // 全てのbitが捨てられるまで
        if (n & 1) { // 一番右のbitが１のとき
            x *= a;
        }
        a *= a;
        n >>= 1; // bit全体を右に1つシフトして一番右を捨てる
    }
    return x;
}
bool is_prime(const unsigned n) {
    switch (n) {
    case 0: // fall-through
    case 1: return false;
    case 2: // fall-through
    case 3: return true;
    } // n > 3 が保証された
    if (n % 2 == 0 || n % 3 == 0) return false;
    // n は 2 と 3 のいずれの倍数でもないことが保証された
    // これより n は (6の倍数)-1 か (6の倍数)+1 である
    // 6の倍数前後の数を使って試し割りをする
    for (unsigned i = 5; i * i <= n; i += 6) {
        if (n % i == 0) return false; // (6の倍数)-1
        if (n % (i + 2) == 0) return false; // (6の倍数)+1
    }
    return true;
}

/*signed*/int main(void) {   
    int n;
    cin >> n;
    vector<pair<int, int>> p(n);
    rep(i, n) {
        int a, b;
        cin >> a >> b;
        p[i] = make_pair(a, b);
    }
    sort(p.rbegin(), p.rend());
    cout << p[0].first + p[0].second << endl;
    return 0;
}

Measured memory_bytes: 3996
inf = 10 ** 18

a = []
b = []
c = []
n, ma, mb = map(int, input().split())

for _ in range(n):
    a_, b_, c_ = map(int, input().split())
    a.append(a_)
    b.append(b_)
    c.append(c_)

abmax = 10
p = n * abmax
dp = [[[inf for _ in range(p + 1)] for _ in range(p + 1)]
      for _ in range(n + 1)]
dp[0][0][0] = 0

for i in range(n):
    for j in range(p + 1):
        for k in range(p + 1):
            if dp[i][j][k] == inf:
                continue
            dp[i + 1][j][k] = min(dp[i+1][j][k], dp[i][j][k])
            dp[i + 1][j + a[i]][k + b[i]
                                ] = min(dp[i + 1][j + a[i]][k + b[i]], dp[i][j][k] + c[i])

ans = inf
for j in range(p)[1::]:
    for k in range(p)[1::]:
        if j * mb == k * ma:
            ans = min(ans, dp[n][j][k])

if ans == inf:
    ans = -1
print(ans)


Measured memory_bytes: 59984
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> P;
typedef vector<vector<int>> Matrix;
static const int INF = 2000000000;



int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  sort(ALL(a));
  int ans = 0;
  int tmp = a[0];
  int c = 1;
  for (int i = 1; i < n; i++){
    if (a[i] == tmp) c++;
    else {
      if (c%2) ans++;
      c = 1;
      tmp = a[i];
    }
  }
  if (c%2) ans++;
  cout << ans << endl;
}

Measured memory_bytes: 768
import java.util.Scanner;

class Main{
  public static double[][] solEq(double[][] a){
    int n = a.length, m = a[0].length;
    for (int ipv = 0; ipv < n; ipv++) {
      double max = 0.0;
      int row = 0;
      for(int i = ipv; i < n; i++) {
        if(Math.abs(a[i][ipv]) > max) {
          max = a[i][ipv];
          row = i;
        }
      }
      if(max == 0.0) {
        break;
      }
      if(ipv != row) {
        for(int j = 0; j < m; j++) {
          double temp = a[ipv][j];
          a[ipv][j] = a[row][j];
          a[row][j] = temp;
        }
      }
      
      double inv_pv = 1.0/a[ipv][ipv];
      for (int j = 0; j < m; j++) {
        a[ipv][j] *= inv_pv;
      }
      
      for (int i = 0; i < n; i++) {
        if (i != ipv) {
          double temp = a[i][ipv];
          for (int j = 0; j < m; j++) {
            a[i][j] -= temp*a[ipv][j];
          }
        }
      }
    }
    return a;
  }

  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    while(sc.hasNext()) {
      double [][] point = new double[4][2];
      for (int i = 0; i < 4; i++) {
        for (int j = 0; j < 2; j++) {
          point[i][j] = sc.nextDouble();
        }
      }
      double[][] mat = {{point[1][0]-point[0][0],point[2][0]-point[0][0],point[3][0]-point[0][0]}
                       ,{point[1][1]-point[0][1],point[2][1]-point[0][1],point[3][1]-point[0][1]}};
      mat = solEq(mat);
      if(mat[0][2] > 0 && mat[1][2] > 0 && mat[0][2]+mat[1][2] <= 1 ) {
        System.out.println("YES");
      }
      else {
        System.out.println("NO");
      }
    }
  }
}

Measured memory_bytes: 12000
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <bitset>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
#include <functional>
#include <cassert>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
#define ALL(v) v.begin(),v.end()
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; }
#define DEBUG_VLL(vec) REP(sz, vec.size()) std::cerr<<vec[sz]<<(sz==vec.size()-1?'\n':' ');

const long long MOD = 1000000007;
const long long HIGHINF = (long long)1e18;
const int INF = (int)1e9;

ll n, q, t;
vll s;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    s.resize(n);
    for (ll i = 0; i < n; i++) cin >> s[i];
    cin >> q;
    ll ans = 0;
    for (int i = 0; i < q; i++) {
        cin >> t;
        ll low = 0, high = n;
        while (low < high) {
            ll mid = (low + high) >> 1;
            if (s[mid] < t) low = mid + 1;
            else high = mid;
        }
        if (low < n && s[low] == t) ans++;
    }
    cout << ans << '\n';
    return 0;
}



Measured memory_bytes: 3500
package main

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

const (
	initialBufSize = 100000
	maxBufSize     = 10000000
)

var (
	sc = bufio.NewScanner(os.Stdin)
	wt = bufio.NewWriter(os.Stdout)
)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	i, _ := strconv.Atoi(next())
	return i
}

func puts(a ...interface{}) {
	fmt.Fprintln(wt, a...)
}

func min(nums ...int) int {
	ret := nums[0]
	for _, v := range nums {
		if v < ret {
			ret = v
		}
	}
	return ret
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, initialBufSize), maxBufSize)
	defer wt.Flush()

	const inf = 1 << 60

	n, m := nextInt(), nextInt()

	cost, prev, use := make([][]int, n), make([][]int, n), make([][]bool, n)
	for i := 0; i < n; i++ {
		cost[i], prev[i], use[i] = make([]int, n), make([]int, n), make([]bool, n)
		for j := 0; j < n; j++ {
			cost[i][j], prev[i][j] = inf, i
		}
	}
	for i := 0; i < m; i++ {
		a, b, c := nextInt()-1, nextInt()-1, nextInt()
		cost[a][b], cost[b][a] = c, c
	}

	// ワーシャルフロイド
	for k := 0; k < n; k++ {
		for i := 0; i < n; i++ {
			for j := 0; j < n; j++ {
				if cost[i][k]+cost[k][j] < cost[i][j] {
					cost[i][j] = cost[i][k] + cost[k][j]
					prev[i][j] = prev[k][j]
				}
			}
		}
	}

	for start := 0; start < n; start++ {
		for goal := start + 1; goal < n; goal++ {
			for cur := goal; cur != start; cur = prev[start][cur] {
				use[prev[start][cur]][cur], use[cur][prev[start][cur]] = true, true
			}
		}
	}

	useCnt := 0
	for i := range use {
		for j := range use[i] {
			if use[i][j] {
				useCnt++
			}
		}
	}

	puts(m - useCnt/2)
}


Measured memory_bytes: 896
#include<bits/stdc++.h>
using namespace std;
int main()
{
   long long h,x,p;
    cin>>h;
    if(h<2)
        cout<<"1"<<endl;
    else
    {
       for(long long i=1; ;i=i*2)
       {
         if(i==h||i*2>h)
          {
              x=i*2-1;
              cout<<x<<endl;
              return 0;
          }

       }

    }

}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    void run() {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        String mid = "";
        if (s.length() >= 2) {
            mid = s.substring(1, s.length() - 1);
        }
        int q = sc.nextInt();
        StringBuffer sbHead = new StringBuffer(1000000);
        sbHead.append(s.charAt(0));
        StringBuffer sbLast = new StringBuffer(1000000);
        if (s.length() != 1) {
            sbLast.append(s.charAt(s.length() - 1));
        }
//        debug(sbHead, sbLast);
        boolean isHead = true;
        for (int i = 0; i < q; i++) {
//            debug(sbHead, sbLast);
            int t = sc.nextInt();
            if (t == 1) {
                isHead = !isHead;
                continue;
            }
            int f = sc.nextInt();
            char c = sc.next().charAt(0);
            if ((f == 1 && isHead) || (f == 2 && !isHead)) {
                sbHead.append(c);
            } else {
                sbLast.append(c);
            }
        }


        StringBuffer ans = sbHead.reverse().append(mid).append(sbLast);
        if (isHead) {
            System.out.println(ans.toString());
        } else {
            System.out.println(ans.reverse().toString());
        }
    }

    void debug(Object... os) {
        System.err.println(Arrays.deepToString(os));
    }

    public static void main(String[] args) {
        new Main().run();
    }
}


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

#define ll long long
#define ld long double
#define F first
#define S second

#define ONLINE_JUDGE 1

using namespace std;

const int mod = 1e9+7;
const int MAX = 200020;

vector<ll> fact(MAX),ifac(MAX);
vector<ll> invs(MAX);
vector<vector<int> > g(MAX);
vector<ll> dp(MAX);
vector<ll> sz(MAX);

ll pwr(ll a, ll n){
	if(n==0) return 1;
	if(n==1) return a%mod;
	ll q = pwr(a,n >> 1);
	q = 1ll * q * q % mod;
	if(n&1) q = 1ll * q * a % mod;
	return q;
}

ll inv(ll n){
	return pwr(n,mod-2);
}

void init(){
	fact[0] = 1,invs[1] = 1,ifac[0] = 1;
	for(int i = 1; i < MAX; i++)
		fact[i] = 1ll * fact[i-1] * i % mod;
	for(int i = 2; i < MAX; i++)
		invs[i] = -invs[mod%i] * 1ll * (mod / i) % mod;
	for(int i = 1; i < MAX; i++)
		ifac[i] = 1ll * ifac[i-1] * invs[i] % mod;
}

void dfs1(int v, int p = -1){
	dp[v] = 1;
	sz[v] = 1;
	for(int u : g[v]){
		if(u==p) continue;
		dfs1(u,v);
		sz[v]+=sz[u];
		dp[v] = (1ll * dp[v] * dp[u] % mod) * ifac[sz[u]] % mod;
	}
	dp[v] = 1ll * dp[v] * fact[sz[v] - 1] % mod;
}

void dfs2(int v,int p = -1){
	for(int u : g[v]){
		if(u==p) continue;
		ll tmp = (dp[v] * fact[sz[u]] % mod)  % mod;
		tmp = fact[sz[1] - sz[u] - 1] *  tmp % mod;
		ll tmp_n = ifac[sz[u] - 1] %mod;
		dp[u] = tmp_n * tmp % mod;
		dp[u] = dp[u] * ifac[sz[1] - sz[u]] % mod;
		dfs2(u,v);
	}
}

void solve(){
	int n;
	cin >> n;
	for(int i = 1; i < n; i++){
		int u,v; cin >> u >> v;
		g[u].push_back(v);
		g[v].push_back(u);
	}
	dfs1(1);
//	cout << dp[1] + mod << "\n";
	dfs2(1);
	for(int i = 1; i <= n; i++){
		cout << (dp[i] + mod)%mod << "\n";
	}
}
int main(){
	#ifndef ONLINE_JUDGE	
		freopen("in.txt","r",stdin);
		freopen("out.txt","w",stdout);
	#endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL),cout.tie(NULL);		
	int t = 1;
	//cin >> t;
	init();
	while(t--)
		solve();
	return 0;
}

Measured memory_bytes: 21748
#include <iostream>
using namespace std;
#include <cstdio>
#include <cmath>
#include <cstring>
#include <string>
#include <algorithm>
#include <functional> //sort(A,A.end(),greater<int>());降順ソート
#include <queue>
#include <stack>
#include <vector>

#define INF 10 << 10

int main() {
	string str;
	cin >> str;
	int cnt = 0;
	for (int i = 0; i < str.size() - 1; ++i) {
		if (str[i] != str[i + 1]) { cnt++; }
	}
	cout << cnt << endl;
}


Measured memory_bytes: 512
N,X = map(int, input().split())
S = list(map(int,input().split()))

S.sort(reverse=True)
mod = 10**9+7
dp = [ [0] * (10**5+1) for _ in range(N+1)]
dp[0][X] = 1
for i in range(N):
    for j in range(0,10**5+1):
        dp[i+1][j] += dp[i][j] * (N-1-i) % mod
        dp[i+1][j% S[i]] += dp[i][j] 

        dp[i+1][j] %= mod
        dp[i+1][j%S[i]] %= mod
ans = 0
for j in range(0,10**5+1):
    ans = (ans + dp[N][j] * j % mod ) % mod

print(ans)

Measured memory_bytes: 193672
#include <iostream>
#include <vector>
#include <list>
#include <algorithm>
#include <string>
#include <sstream>
#include <stack>
#include <iomanip>
#include <numeric>
#include <queue>
#include <climits>
#include <set>
#include <complex>
#include <cmath>
#include <cstring>
#include <map>
using namespace std;
using ll = long long;
#define MOD 1000000007
#define INF 1LL << 59
int main()
{
    //std::ios::sync_with_stdio(false);
    //std::cin.tie(0);
    //cout << fixed << setprecision(7);
    string s;
    while (cin >> s)
    {
        char c = 'd';
        if (s[0] == 'o' && s[1] == 'o' && s[2] == 'o')
            c = 'o';
        if (s[3] == 'o' && s[4] == 'o' && s[5] == 'o')
            c = 'o';
        if (s[6] == 'o' && s[7] == 'o' && s[8] == 'o')
            c = 'o';
        if (s[0] == 'o' && s[3] == 'o' && s[6] == 'o')
            c = 'o';
        if (s[1] == 'o' && s[4] == 'o' && s[7] == 'o')
            c = 'o';
        if (s[2] == 'o' && s[5] == 'o' && s[8] == 'o')
            c = 'o';
        if (s[0] == 'o' && s[4] == 'o' && s[8] == 'o')
            c = 'o';
        if (s[2] == 'o' && s[4] == 'o' && s[6] == 'o')
            c = 'o';

        if (s[0] == 'x' && s[1] == 'x' && s[2] == 'x')
            c = 'x';
        if (s[3] == 'x' && s[4] == 'x' && s[5] == 'x')
            c = 'x';
        if (s[6] == 'x' && s[7] == 'x' && s[8] == 'x')
            c = 'x';
        if (s[0] == 'x' && s[3] == 'x' && s[6] == 'x')
            c = 'x';
        if (s[1] == 'x' && s[4] == 'x' && s[7] == 'x')
            c = 'x';
        if (s[2] == 'x' && s[5] == 'x' && s[8] == 'x')
            c = 'x';
        if (s[0] == 'x' && s[4] == 'x' && s[8] == 'x')
            c = 'x';
        if (s[2] == 'x' && s[4] == 'x' && s[6] == 'x')
            c = 'x';

        cout << c << endl;
    }
    return 0;
}


Measured memory_bytes: 3056
#include<iostream>
#include<vector>
#include<map>
using namespace std;

int main(){
	string a,b,c;
	cin>>a>>b>>c;
	
	if(a[a.size()-1]==b[0]&&b[b.size()-1]==c[0]){
		cout << "YES"<<endl;
	}else{
		cout <<"NO"<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define all(x) (x).begin(), (x).end()
using ll = long long;
using namespace std;
template <typename T> using vec = std::vector<T>;

int main() {
    ll N, W;
    cin >> N >> W;

    vec<ll> w(N), v(N);
    rep(i, N) cin >> w[i] >> v[i];

    vec<vec<ll>> dp(N + 1, vec<ll>(W + 1, 0));
    dp[0][0] = 0;
    for (ll i = 1; i <= N; ++i) {
        for (ll x = 0; x <= W; ++x) {
            dp[i][x] = max({dp[i][x], dp[i - 1][x]});
            if (x > 0) dp[i][x] = max({dp[i][x], dp[i][x - 1]});
            if (x + w[i - 1] <= W) {
                dp[i][x + w[i - 1]] =
                    max({dp[i][x + w[i - 1]], dp[i - 1][x] + v[i - 1]});
            }
        }
    }

    cout << dp[N][W] << endl;
}


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

int main () {
  int n, x, t;
  cin >> n >> x >> t;
  if (n % x) {
    cout << ( n / x + 1 ) * t << endl;  
  }
  else {
    cout << ( n / x ) * t << endl;
  }
  return 0;
}

Measured memory_bytes: 3620
import java.io.BufferedReader
import java.io.InputStream
import java.io.InputStreamReader
import java.io.PrintWriter
import java.lang.StringBuilder
import java.util.*

fun PrintWriter.solve(sc: FastScanner) {
    val n = sc.nextInt()
    val a = mutableListOf(0)
    for (i in 0 until n) {
        a.add(sc.nextInt())
    }
    a.add(0)
    val d = Array(n + 1) { 0 }
    for (i in 0 until n + 1) {
        d[i] = Math.abs(a[i + 1] - a[i])
    }
    var sum = d.sum()
    for (i in 0 until n) {
        println(sum - d[i] - d[i + 1] + Math.abs(a[i] - a[i + 2]))
    }
}

fun main(args: Array<String>) {
    val writer = PrintWriter(System.out, false)
    writer.solve(FastScanner(System.`in`))
    writer.flush()
}

class FastScanner(s: InputStream) {
    private var st = StringTokenizer("")
    private val br = BufferedReader(InputStreamReader(s))

    fun next(): String {
        while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())

        return st.nextToken()
    }

    fun nextInt() = next().toInt()
    fun nextLong() = next().toLong()
    fun nextLine() = br.readLine()
    fun nextDouble() = next().toDouble()
    fun ready() = br.ready()
}


Measured memory_bytes: 46224
#include <iostream>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <math.h>
#include <cmath>
#include <deque>
#include <queue>
using namespace std;

typedef long long ll;

int main(){
    
    int N;
    cin >> N;
    int x[N], y[N];
    for(int i = 0; i < N; i++)
        cin >> x[i] >> y[i];
    
    double a = 1;
    for(int i = N-1; i >= 1; i--){
        a *= i;
    }
    double ans = 0;
    for(int i = 0; i < N; i++){
        for(int j = i+1; j < N; j++){
            double dis = sqrt(pow(x[i]-x[j], 2) + pow(y[i]-y[j], 2));
            ans += 2*a*dis;
        }
    }

    printf("%f", ans/(N*a));
}



Measured memory_bytes: 256
import math
def p(x):
    if x==2:
        return True
    
    if x==1 or x%2==0:
        return False
    
    i=3
    while i <=math.sqrt(x):
        if x%i==0:
            return False
        i=i+2
    return True
    
c=0
n=int(input())
for i in range(n):
    x=int(input())
    if p(x)==True:
        c+=1
print(c)


Measured memory_bytes: 5672
#include<bits/stdc++.h>
#include<vector>
#include<cmath>
#include<algorithm>
using namespace std;
int main(){
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);

    int n,k;
    cin>>n>>k;

    vector<int> h(n+1);
    for(int i=1;i<=n;i++){
        cin>>h[i];
    }

    vector<int> c(n+1);
    c[1]=0;
    c[2]=abs(h[1]-h[2]);

    for(int i=3;i<=n;i++){
        int m;
        if(i<=k){
            m=i-1;
        }

        else{
            m=k;
        }

        int min=c[i-1]+abs(h[i]-h[i-1]);
        for(int j=2;j<=m;j++){
            if(min>(c[i-j]+abs(h[i]-h[i-j]))){
                min=c[i-j]+abs(h[i]-h[i-j]);
            }
        }

        c[i]=min;
    }

    cout<<c[n]<<"\n";
    return 0;
}

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

a = input().split()

a = [int(x) for x in a]

count = 0

for i in range(0, n):
    minj = i
    for j in range(i, n):
        if a[j] < a[minj]:
            minj = j
   
    if i != minj:
        tmp = a[i]
        a[i] = a[minj]
        a[minj] = tmp
        count += 1

for i,x in enumerate(a):
    if i != len(a)-1:
        print(x, end=" ")
    else:
        print(x, end="")
print()
print(count)



Measured memory_bytes: 5616
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<fstream>
#include<cstring>
#include<string>
#include<cmath>
using namespace std;
string s;
char fz,fz1;
int sum;
int main()
{
	cin>>s;
	 fz=s[0];
	 int len=s.size();
	 fz1=s[len-1];
	
	for(int i=1;i<s.size()-1;i++) sum++;
	
	cout<<fz<<sum<<fz1;
	
	
	
	return 0;
}

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

#define fs first
#define sc second
#define pb emplace_back
#define mp make_pair
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

signed main() {
  string s;
  cin >> s;

  string a[16] = {"AKIHABARA", "AKIHABAR", "AKIHABRA", "AKIHABR", "AKIHBARA", "AKIHBAR", "AKIHBRA", "AKIHBR",
                  "KIHABARA",  "KIHABAR",  "KIHABRA",  "KIHABR",  "KIHBARA",  "KIHBAR",  "KIHBRA",  "KIHBR"};
  for (int i = 0; i < 16; ++i) {
    if (s == a[i]) {
      cout << "YES" << endl;
      return 0;
    }
  }
  cout << "NO" << endl;
}


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

int comUp(const void *a, const void *b){
    return *(int *)a - *(int *)b;
}

int main(void){
    int n;
    scanf("%d",&n);
    int a[n];
    for(int i = 0; i < n; i++){scanf("%d",&a[i]); a[i] -= (i + 1);}
    
    qsort(a, n, sizeof(int), comUp);

    int median = a[n/2];
    long long int ans = 0;
    for(int i = 0; i < n; i++){
        ans += (long long int)abs(a[i] - median);
    }
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
#define mod   998,244,353
#define ps(x, y) fixed<<setprecision(y)<<x
#define w(t) int t; cin>>t;while(t--)
int power (int b , int a) {
	int ans = 1;
	a = a % mod;
	while (b != 0) {
		if (b & 1)
		{ans = (ans * a) % mod;}
		b >>= 1; //b/2
		a = a * a;
		a %= mod;

	}
	return ans;
}

int32_t main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);


	int n ;
	cin >> n;
	set<string>s;
	while (n--) {
		string str;
		cin >> str;

		s.insert(str);

	}
	cout << s.size() << "\n";




	return 0;



}





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

#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define LL long long
#define pii pair <int,int>
#define fi first
#define se second
#define pb push_back
#define mpr make_pair

using namespace std;

const LL MOD=1e9+7;

LL n,d,x,y,ans=0;

int main()
{
	cin>>n>>d;
	rep(i,n)
	{
		cin>>x>>y;
		if(x*x+y*y<=d*d) ans++;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3636
#define	_USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cfloat>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <string>
#include <set>
#include <complex>
#include <utility>
#include <numeric>
#define  rep(i,n) for(int i=0;i<(n);i++)
#define  REP(i,a,n) for(int i=a;i<(n);i++)
#define  rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define  VI	vector<int>
#define	 VS vector<string>
#define  all(a) (a).begin(),(a).end()
#define  debug(x) cout<<#x<<": "<<x<<endl
using namespace std;
typedef pair<int,int> P;
typedef long long ll;

const int INF=1000000;
char field[101][101];
int d[21][21];
int N,M;
int sx,sy;
int gx,gy;
int w,h;
int ans;

int dx[4]={0,0,-1,1};
int dy[4]={-1,1,0,0};
const int MAX_V=100;
const int MAX_N=100;
char o[3]={'+','-','*'};
bool f;



void solve(int n,int x, int y){
	if(n>=ans)
		return ;
	
	for(int i=0;i<4;i++){
		int nx=x,ny=y;
		nx+=dx[i];ny+=dy[i];
		if(nx<0||nx>=w)	continue;
		if(ny<0||ny>=h)	continue;
		if(d[ny][nx]==1)
			continue;
		while(1){
			if(d[ny][nx]==3){
				ans = n;
				return;
			}
			
			nx+=dx[i];ny+=dy[i];
			if(ny<0||ny>=h) break;
				if(nx<0||nx>=w) break;
			
			if(d[ny][nx]==1){
				d[ny][nx]=0;
				solve(n+1,nx-dx[i],ny-dy[i]);
				d[ny][nx]=1;
				break;
			}
			
		}
	}	
}
int main(){
	
	
	
	while(cin>>w>>h,w||h){
		int a,b;
		for(int i=0;i<h;i++){
			for(int j=0;j<w;j++){
		cin>>d[i][j];
		if(d[i][j]==2){
			a=j;
			b=i;
		}
		}
	}
		ans = 11;
		solve(1,a,b);
		if(ans>10)
			ans=-1;
		cout<<ans<<endl;
	}

	
}

Measured memory_bytes: 1160
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
using namespace std;
#define pb push_back;
#define sz(v) ((int)(v).size())
#define ll long long;
int main()
{
    int x,i,j,c,max=0;
    cin >>x;    
    for(i=1;i<=1000;i++)
    {
        for(j=2;j<=10;j++)
        {
            c=pow(i,j);
            if(c>x)
            {
                break;
            }
            if(c>=max)
            {
                max=c;
            }
        }
    }
    cout <<max<<endl;
    //system("pause");
    return 0;
}
    

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

int main() {
	string a, b, sum;
	int x, y, z;
	double A;


	cin >> a >> b;

	sum = a + b;
	x = stoi(sum);
	y = sqrt(x) * 10;
	z = y % 10;

	if(z == 0) cout << "Yes";
	else cout << "No";

	return 0;
}


Measured memory_bytes: 256
function Main(input) {
	var tmp = input.split(" ");
    var a = parseInt(tmp[0],10);
    var b = parseInt(tmp[1],10);
    var c = parseInt(tmp[2],10);

    

    console.log(c+" "+a+" "+b);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
// 🐋💭
import Foundation

func main() {
    var n = Int(readLine()!)!
    //_____________________________ここまで入力
    var ans = String()
    var surplus = 0
    while n > 0 {
        n -= 1
        surplus = n % 26
        ans += String(UnicodeScalar(Int("a".unicodeScalars.first!.value) + surplus)!)
        n /= 26
    }
    print(String(ans.reversed()))
}
main()






Measured memory_bytes: 13172
import sys
readline = sys.stdin.readline
write = sys.stdout.write

err = -2 * (10**9) + 1

class Node:
    def __init__(self, k, l, r, p):
        self.key = k
        self.left = l
        self.right = r
        self.parent = p

def maxHeapify(A, i):
    l = 2*i #index of left child
    r = 2*i + 1 #right child
    H = len(A)-1 #heap size, A[0] is not used therefore -1
    largest = 0
    if l <= H and A[i].key < A[l].key:
        largest = l
    else:
        largest = i
    if r <= H and A[largest].key < A[r].key:
        largest = r

    if largest != i:
        temp = A[i]
        A[i] = A[largest]
        A[largest] = temp
        maxHeapify(A, largest)

def buildmaxHeap(A):
    H = len(A)-1
    s = int(H/2)
    for i in range(s, 0, -1):
        maxHeapify(A, i)

n = int(input())
keys = list(map(int, readline().split()))

Heap = [Node(err, None, None, None) for i in range(n+1)]
for i in range(1, n+1):
    Heap[i].key = keys[i-1]
    if 2*i  < n+1:
        Heap[i].left = Heap[2*i]
    if 2*i + 1 < n+1:
        Heap[i].right = Heap[2*i + 1]
    if i > 1:
        Heap[i].parent = Heap[int(i/2)]
buildmaxHeap(Heap)
for i in range(1, n+1):
    write(" " + str(Heap[i].key))
write("\n")


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

typedef long long ll;
typedef pair<int,int> P;

#define p_ary(ary,a,b) do { cout << "["; for (int count = (a);count < (b);++count) cout << ary[count] << ((b)-1 == count ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

template<typename T1,typename T2>ostream& operator<<(ostream& os,const pair<T1,T2>& a) {os << "(" << a.first << ", " << a.second << ")";return os;}

const char newl = '\n';

int main() {
    int d;
    cin >> d;
    int c[370],s[370][370];
    for (int i = 0;i < d;++i) cin >> c[i];
    for (int i = 0;i < d;++i) for (int j = 0;j < d;++j) cin >> s[i][j];
    for (int i = 0;i < d;++i) cout << 1 << newl;
}

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

using namespace std;

#define SZ(v) ((int)(v).size())
#define ALL(v) (v).begin(),(v).end()
#define one first
#define two second
typedef long long ll;
typedef pair<int, int> pi;
const int INF = 0x3f2f1f0f;
const ll LINF = 1ll * INF * INF;

const int MAX_N = 1e3 + 10;

int N; ll Nr[MAX_N];
vector<int> Ans; int Now;
void op(int x) {
	if(x == 0 || x == Now-1) Now++;
	Now -= 2;
	Ans.push_back(x+1);
}
int main() {
	cin >> N; Now = N;
	ll mx[2] = {0, 0};
	for(int i=0; i<N; i++) scanf("%lld", &Nr[i]), mx[i%2] += max(Nr[i], 0ll);
	if(mx[0] == 0 and mx[1] == 0) {
		int ix = 0; for(int i=0; i<N; i++) if(Nr[ix] < Nr[i]) ix = i;
		for(int i=0; i<ix; i++) op(0);
		for(int i=ix+1; i<N; i++) op(Now-1);
		printf("%lld\n", Nr[ix]);
	}else{
		int k = (mx[1] > mx[0]);
		int l=INF, r=-1;
		for(int i=k; i<N; i+=2) if(Nr[i] > 0) l = min(l, i), r = max(r, i);
		for(int i=0; i<l; i++) op(0);
		for(int i=r+1; i<N; i++) op(Now-1);
		for(int i=r; i>=l; i-=2) if(Nr[i] <= 0) op(i-l);
		while(Now >= 3) op(1);
		printf("%lld\n", mx[k]);
	}
	printf("%d\n", SZ(Ans));
	for(int x : Ans) printf("%d\n", x);
	return 0;
}


Measured memory_bytes: 256
// In the name of god
#include <bits/stdc++.h>
#pragma GCC optimze("02")
#define F first
#define S second
#define pb push_back
#define p push
using namespace std;
using ll = long long;
const ll maxn=5e5+5,inf = 1e18+18;
ll n,k,a[maxn],l,r,mid,sum;
int main(){
	ios::sync_with_stdio(false) , cin.tie(0 ) ,cout.tie(0);
	cin>>n>>k;
	for(int i=0;i<n;i++)cin>>a[i];
	r=1e9+1;
	while(l!=r-1){
		mid=(l+r)/2;
		sum=0;
		for(int i=0;i<n;i++)sum+=(((a[i]+mid-1)/mid)-1);
		if(sum>k)l=mid;
		else r=mid;
	}
	cout<<r<<endl;
}


Measured memory_bytes: 5212
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mem(x,val) memset(x,val,sizeof(x))
#define F(i,n) for(ll i=0;i<n;i++)
#define pb push_back
#define endl '\n'
#define mod 1000000007
#define crap ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
ll n,a[100005],dp[100005];
ll func(ll ind)
{
	if(ind==n-1)
		return 0;
	if(ind>=n)
		return INT_MAX;
	if(dp[ind]!=-1)
		return dp[ind];
	
	ll small1=abs(a[ind]-a[ind+1])+func(ind+1);
	ll small2=INT_MAX;
	
	small2=abs(a[ind]-a[ind+2])+func(ind+2);
	return dp[ind]=min(small2,small1);
}
signed main(){
    crap;
 		memset(dp,-1,sizeof(dp));
        cin>>n;
        for(ll int i=0;i<n;i++)
             cin>>a[i];
         cout<<func(0);
         return 0;
     }

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

using namespace std;
typedef long long ll;

int main(){
    int r, g, b, n;
    cin >> r >> g >> b >> n;
    int ans = 0;
    for (int i = 0; i <= n; i+=r)
    {
        for (int j = 0; j <= n-i; j+=g)
        {
            if((n-i-j)%b==0){
                ans++;
            }
        }
        
    }
    cout << ans<< endl;
    
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <cmath>
#include <algorithm>
#include <cctype>
using namespace std;

int main() {
    int n, x, l[100];
    cin >> n >> x;
    for (int i = 0; i < n; i++) {
        cin >> l[i];
    }
    int d=0,j=1;
    while (j <= n + 1) {
        d += l[j - 1];
        if (d > x) break;
        j++;
    }
    cout << j << endl;
}

Measured memory_bytes: 256
//go:generate echo "https://atcoder.jp/contests/dp/tasks/dp_c"
package main

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

type scanner struct{ *bufio.Scanner }

func newScanner(r io.Reader) *scanner {
	s := bufio.NewScanner(r)
	s.Split(bufio.ScanWords)
	s.Buffer(nil, 100000000)
	return &scanner{s}
}

func (s *scanner) Int() int {
	s.Scan()
	n, _ := strconv.Atoi(s.Text())
	return n
}

func (s *scanner) IntSlice(l int) []int {
	if l == 0 {
		return []int{}
	}
	sl := make([]int, l, l)
	for i := range sl {
		sl[i] = s.Int()
	}
	return sl
}

func (s *scanner) IntSlice2(l, n int) []int {
	if l == 0 {
		return []int{}
	}
	sl := make([]int, l, l)
	for i := 0; i < n; i++ {
		sl[i] = s.Int()
	}
	return sl
}

func solve(n int, u [][]int) int {
	t := make([][]int, n+1, n+1)
	for i := range t {
		t[i] = make([]int, 3, 3)
	}
	t[0] = u[0]
	for d := 0; d < n; d++ {
		for sel := 0; sel <= 2; sel++ {
			for k := range u[d] {
				if k == sel {
					continue
				}
				if v := t[d][sel] + u[d+1][k]; t[d+1][k] < v {
					t[d+1][k] = v
				}
			}
		}
	}
	max := math.MinInt64
	for _, v := range t[n-1] {
		if max < v {
			max = v
		}
	}
	return max
}

func main() {
	scan := newScanner(os.Stdin)
	n := scan.Int()
	u := make([][]int, n+1, n+1)
	for i := 0; i <= n; i++ {
		u[i] = []int{scan.Int(), scan.Int(), scan.Int()}
	}
	fmt.Println(solve(n, u))
}


Measured memory_bytes: 13728
#include <stdio.h>
int main()
{
int p, h, w, x, y;



	while(1){
		scanf("%d %d", &h, &w);
		if( h >= 300 && w >= 300){
			break;
		}else if(h == 0 && w == 0){
			break;
			
		
		}else{
			for( x = 0; x < h; x++ ){
				for( y = 0; y < w; y++){
					printf("#");
				}
				printf("\n");
			}
			printf("\n");
			
		}
	}
	
	

	scanf("%d", &p);
	return 0;

}

Measured memory_bytes: 572
/*																													   
 Templatka c++ Kacper Fis																							   																											   //
*/																													  
																								   
#include <bits/stdc++.h>																							   
																													   
using namespace std; 																								   
																													   
const int INF = 1000000001;																						   
const float PI = 3.14;																								   
typedef long long LL;																								   
																													   
typedef vector<int> vi;																								   
typedef list<int> li;																								   
typedef queue<int> qi; 																								   
typedef pair<int,int> ii; 																							   
typedef map<string,int> msi; //np msi['nazwa'] = 'liczba'															   
typedef vector<ii> vii; //vector par<int>, do tworzenia tablicy dla grafów wagowych #dijkstra #Bellman_Ford			   
typedef priority_queue< ii, vector<ii>, greater<ii> > pq; //kolejka priorytetowa vectorów par(top()=min) #dijkstra	   
																													   																				   
vector<ii>::iterator iter;																							   
																													   																				   
#define print_list(x) for(it = (x).begin(); it != (x).end(); it++) {cout << *it << " ";}							   
#define print_vector(x) for(it2 = (x).begin(); it2 != (x).end(); it2++) {cout << *it2 << " ";}						   
#define search_list(x) for(it = (x).begin(); it != (x).end(); it++)													   
#define search_vector(x) for(it2 = (x).begin(); it2 != (x).end(); it2++);											   
#define pb(x) push_back(x) 																							   
#define pf(x) push_front(x)																							   
#define mp(x, y) make_pair(x, y)                                                                                       
///////////////////////////////////////////////GLOBAL DEFINITIONS////////////////////////////////////////////////////////



///////////////////////////////////////////////////FUNCTIONS/////////////////////////////////////////////////////////////


/////////////////////////////////////////////////////MAIN////////////////////////////////////////////////////////////////
int main(int argc, char* argv[])																					 
{ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);                  												       
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	
	int a, b;
	cin >> a >> b;
	if((a == 1 && b == 2) || ((a == 2) && b == 1)){
		cout << "3" << endl;
	}
	else if((a == 2 && b == 3) || ((a == 3) && (b == 2))){
		cout << "1" << endl;
	}
	else cout << "2" << endl;
	
	
	
	
	
	
	
	
	
	
	
	
	
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <iomanip>
#include <random>
#include <cassert>
#include <cstring>
using namespace std;

#define GET_ARG(a,b,c,F,...) F
#define REP3(i,s,e) for (i = s; i <= e; i++)
#define REP2(i,n) REP3 (i,0,(int)(n)-1)
#define REP(...) GET_ARG (__VA_ARGS__,REP3,REP2) (__VA_ARGS__)
#define RREP3(i,s,e) for (i = s; i >= e; i--)
#define RREP2(i,n) RREP3 (i,(int)(n)-1,0)
#define RREP(...) GET_ARG (__VA_ARGS__,RREP3,RREP2) (__VA_ARGS__)
#define DEBUG(x) cerr << #x ": " << x << endl

const int INF = 1e9;

int dp[500001][3];

int main(void) {
    int i, n;
    string s;
    cin >> n >> s;

    // 0: any, 1: 10, 2: .0..1...1
    REP (i,0,n) dp[i][0] = dp[i][1] = -INF;
    dp[0][0] = 0;
    REP (i,n) {
        dp[i][0] = max(dp[i][0],dp[i][1]);
        dp[i+1][0] = max(dp[i+1][0],dp[i][0]);
        if (s[i] == '1') {
            dp[i+1][1] = max(dp[i+1][1],dp[i][1] + 1);
            dp[i+1][2] = max(dp[i][0],dp[i][2]) + 1;
        }
        if (i == n-1) break;
        if (s[i] == '1' && s[i+1] == '0')
            dp[i+2][1] = dp[i][0];
        else if (s[i] == '0' && s[i+1] == '1')
            dp[i+2][0] = dp[i][2];
    }
    cout << max(dp[n][0],dp[n][1]) << endl;
    return 0;
}

Measured memory_bytes: 6788
import java.util.*;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int ans = 0;
		String s = sc.next();
		for(int i = 0; i < s.length(); i++) {
			if(s.charAt(i) == '+') {
				ans += 1;
			} else {
				ans -= 1;
			}
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 21716
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <numeric>
#include <cmath>
#include <iomanip> //cout << fixed << setprecision(15) << << endl;
#include <cassert>
//#include "atcoder/all"

using namespace std;
//using namespace atcoder;

typedef long long ll;

#define pb push_back
#define rep(i, n) for(int i=0;i<(n);i++)
#define REP(i, n) for(int i=1;i<=(n);i++)
#define P pair<int,int>

int mx8[] = {0, 0, 1, -1, -1, 1, -1, 1};
int my8[] = {-1, 1, 0, 0, -1, -1, 1, 1};
int mx4[] = {1, -1, 0, 0};
int my4[] = {0, 0, -1, 1};

const int MOD = 1000000007;

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

    ll n; cin >> n;
    ll ans = 0;
    ll N = n;
    for(ll i = 2; i*i<=n; ++i)
    {
        int k = 0;
        while(N%i==0)
        {
            N /= i;
            k++;
        }
        ans += floor((-1 + sqrt(1+8*k)) / 2);
    }
    if(N > 1) ans += 1;
    cout << ans << endl;
}

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

int main() {
    int N, X, Y;
    cin >> N >> X >> Y;

    Graph G(N);
    rep(i, N - 1) {
        G[i].push_back(i+1);
        G[i+1].push_back(i);
    }
    G[X-1].push_back(Y-1);
    G[Y-1].push_back(X-1);

    vector<int> ans(N, 0);
    for (int i = 0; i < N; i++) {
        vector<int> dist(N, -1);
        queue<int> que;
        
        dist[i] = 0;
        que.push(i);
        
        while (!que.empty()) {
            int v = que.front();
            que.pop();
            
            for (int nv : G[v]) {
                if (dist[nv] != -1) continue;
                dist[nv] = dist[v] + 1;
                que.push(nv);
            }
        }
        for (int j = 0; j < N; j++) {
            ans[dist[j]]++;
        }
    }
    for (int i = 1; i < N; i++) {
        cout << ans[i]/2 << endl;
    }

    return 0;
}


Measured memory_bytes: 3748
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdint.h> // int64_t

#define max(a,b) ((a) > (b) ? (a) : (b))
#define min(a,b) ((a) > (b) ? (b) : (a))

int get_int(void) {
  int num;
  scanf("%d", &num);
  return num;
}

// <arr[0]> <arr[1]> .. <arr[size-1]>
int fget_array(int *arr, int size) {
    int i;
    for(i = 0; i < size; i++) {
        scanf("%d", &arr[i]);
    }
    return 0;
}


// hashmap
#define HASH_SIZE 65536

struct list {
    int64_t num;
    int val;
    struct list *next;
};

struct list *create_htable(void) {
    static struct list htable[HASH_SIZE];
    int i;
    for(i = 0; i < HASH_SIZE; i++) {
        htable[i].next = &htable[i];
    }
    return htable;
}

int get_key(int64_t num) {
    return num & (HASH_SIZE-1);
}

struct list* find(struct list *htable, int64_t num) {
    struct list *head = &htable[get_key(num)];
    struct list *elem;
    for(elem = head->next; elem != head; elem = elem->next) {
        if(elem->num == num) {
            return elem;
        }
    }
    return NULL;
}

int find_val(struct list *htable, int64_t num) {
    struct list *elem = find(htable, num);
    return (elem) ? elem->val : 0;
}

void add_elem(struct list *htable, int64_t num) {
    struct list *elem = find(htable, num);
    if(elem) {
        elem->val++;
        return;
    }
    elem = malloc(sizeof(struct list));
    struct list *head = &htable[get_key(num)];
    elem->next = head->next;
    elem->num = num;
    elem->val = 1;
    head->next = elem;
}

void put_elem(struct list *htable, int64_t num) {
    struct list *elem = find(htable, num);
    if(!elem) return;
    if(elem->val) elem->val--;
    return;
}


#define NUM_MAX 200000

int main(void) {
    int num = get_int();
    static int arr[NUM_MAX];
    fget_array(arr, num);
    struct list *htable = create_htable();
    int64_t sum = 0;
    int i;
    for(i = 0; i < num; i++) {
        sum += arr[i];
        add_elem(htable, sum);
    }

    int64_t offset = 0;
    int64_t ans = find_val(htable, 0);
    for(i = 0; i < num-1; i++) {
        offset += arr[i];
        put_elem(htable, offset);
        ans += find_val(htable, offset);
    }
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 8704