akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <string.h>

void addstr(char *str1, char *str2)
{
    char temp[1000];
    int max;
    int i;
    
    if (strlen(str1) > strlen(str2)){
        max = strlen(str1);
    }
    else {
        max = strlen(str2);
    }
    
    memset(temp, '\0', 1000);
    strcpy(&temp[max - strlen(str1) + 1], str1);
    i = 0;
    while (temp[i] == '\0'){
         temp[i] = '0';
         i++;
    }
    strcpy(str1, temp);
    
    memset(temp, '\0', 1000);
    strcpy(&temp[max - strlen(str2) + 1], str2);
    i = 0;
    while (temp[i] == '\0'){
         temp[i] = '0';
         i++;
    }
    strcpy(str2, temp);
    
    for (i = max; i >= 0; i--){
        str1[i] += str2[i] - '0';
        if (str1[i] > '9'){
            str1[i] -= 10;
            str1[i - 1] += 1;
        }
    }
    if (str1[0] == '0'){
        memset(temp, '\0', 1000);
        strcpy(temp, &str1[1]);
        memset(str1, '\0', 1000);
        strcpy(str1, temp);
    }
}

int main(void)
{
    char str[1000], str2[1000];
    int n;
    
    scanf("%d", &n);
    
    while (n-- != 0){

        scanf("%s", str);
        scanf("%s", str2);
        
        addstr(str, str2);
        
        if (strlen(str) < 81){
            printf("%s\n", str);
        }
        
        else {
            printf("overflow\n");
        }
    }
    
    return (0);
}

Measured memory_bytes: 596
using System;

namespace _0052
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                int ans = 0;
                int a = int.Parse(Console.ReadLine());
                if (a == 0) { break; }
                int kari = a / 5;
                while (!(kari < 1))
                {
                    ans += kari;
                    kari = kari / 5;
                }

                Console.WriteLine(ans);
            }
        }
    }
}

Measured memory_bytes: 9064
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define mkt make_tuple
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;
template<class T> void chmin(T &a,const T &b){if(a>b) a=b;}
template<class T> void chmax(T &a,const T &b){if(a<b) a=b;}

int N;
vector<string> ans;
map<string,int> mp;

void solve(int now,int pos,string &S){
  if(mp.count(S)) return;
  mp[S]=1;
  if(now==N){
    ans.push_back(S);
    return;
  }

  for(int i=0;i<now;i++){
    string T=S;
    T+=S[i];
    solve(now+1,pos,T);
  }
  string T=S;
  T+=char('a'+pos);
  solve(now+1,pos+1,T);
}

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

  cin>>N;
  string s="a";
  solve(1,1,s);

  rep(i,ans.size()) cout<<ans[i]<<endl;

  return 0;
}


Measured memory_bytes: 19828
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m+1;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;


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


int main(){
  int N;cin >> N;
  vector<int> c(N);REP(i,N)cin>>c[i];
  VSORT(c);
  int ans =0;
  ans = (c[N/2]-c[(N/2)-1]);
  cout << ans <<endl;
  
}


Measured memory_bytes: 640
#include <iostream>

int main() {
  unsigned int N;
  unsigned int K;

  std::cin >> N;
  std::cin >> K;

  unsigned int minpos = 0;
  for (; minpos<N; minpos++) {
    unsigned int a;
    std::cin >> a;
    if (a == 1) break;
  }

  unsigned int num_lower = minpos/(K-1);;
  if (minpos%(K-1)!=0) num_lower++;

  unsigned int done = num_lower*(K-1)+1;

  if (done >= N) {
    std::cout << num_lower << std::endl;
  } else {
    unsigned int rest = N-done;
    unsigned int num_higher = rest/(K-1);;
    if (rest%(K-1)!=0) num_higher++;
    std::cout << (num_lower+num_higher) << std::endl;
  }

  return 0;
}


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

using namespace std;

int main() {
	int n, m; cin >> n >> m;
	vector<bool> flag(n);
	vector<int> cnt(n);
	int ac = 0, wa = 0;
	for (int i = 0; i < m; ++i) {
		int p; cin >> p;
		--p;
		string s; cin >> s;
		if (flag[p]) continue;
		if (s == "WA") ++cnt[p];
		else {
			wa += cnt[p];
			++ac;flag[p] = true;
		}
	}
	cout << ac << " " << wa << endl;

	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h> 
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace std;
using namespace __gnu_pbds;  
#define ordered_set tree<ll, null_type , less<ll> , rb_tree_tag , tree_order_statistics_Node_update> 
#define ll long long
#define ull unsigned long long
#define pb push_back
#define inf 1e18
#define mk make_pair
#define ld long double
#define mod 1000000007
#define fi first
#define se second
#define fastIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define test ll t; cin>>t; while(t--)
#define setbits __builtin_popcount
#define endl '\n'
#define LOCAL
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i));}
sim, class b dor(pair < b, c > d) {
    ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
    *this << "[";
    for (auto it = d.b; it != d.e; ++it)
        *this << ", " + 2 * (it == d.b) << *it;
    ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
int main()
{
    fastIO;
    string str;
    cin>>str;
    ll val=0,val1=0;
    for(auto itr:str)
    {
        if(itr=='0')
        {
            val++;
        }
        else
        {
            val1++;
        }
    }
    ll ans=min(val,val1)*2;
    cout<<ans<<endl;
}

Measured memory_bytes: 3736
s = list(input())
ans = []
count_r = 0
count_l = 0
for i in range(len(s)):
  if s[i] == 'R':
    if i == 0:
      count_r += 1
      ans.append(0)
    elif s[i-1] == 'L':
      if (count_r + count_l) % 2 == 0:
        ans.pop()
        ans.append((count_r+count_l)//2)
        ans.append((count_r+count_l)//2)
        for _ in range(count_l-1):
          ans.append(0)
      else:
        ans.pop()
        k = (count_r+count_l)//2
        if count_r > k:
          a = (count_r-1)%2
          if a == 0:
            ans.append(k+1)
            ans.append(k)
            for _ in range(count_l-1):
              ans.append(0)
          else:
            ans.append(k)
            ans.append(k+1)
            for _ in range(count_l-1):
              ans.append(0)
        else:
          a = (count_l-1)%2
          if a == 0:
            ans.append(k)
            ans.append(k+1)
            for _ in range(count_l-1):
              ans.append(0)
          else:
            ans.append(k+1)
            ans.append(k)
            for _ in range(count_l-1):
              ans.append(0)
      count_r = 1
      count_l = 0
      ans.append(0)
    else:
      count_r += 1
      ans.append(0)
  elif s[i] == 'L':
    count_l += 1
if (count_r + count_l) % 2 == 0:
        ans.pop()
        ans.append((count_r+count_l)//2)
        ans.append((count_r+count_l)//2)
        for _ in range(count_l-1):
          ans.append(0)
else:
  ans.pop()
  k = (count_r+count_l)//2
  if count_r > k:
    a = (count_r-1)%2
    if a == 0:
      ans.append(k+1)
      ans.append(k)
      for _ in range(count_l-1):
        ans.append(0)
    else:
      ans.append(k)
      ans.append(k+1)
      for _ in range(count_l-1):
        ans.append(0)
  else:
      a = (count_l-1)%2
      if a == 0:
        ans.append(k)
        ans.append(k+1)
        for _ in range(count_l-1):
          ans.append(0)
      else:
        ans.append(k+1)
        ans.append(k)
        for _ in range(count_l-1):
          ans.append(0)
print(*ans)

Measured memory_bytes: 7268
use std::cmp;

#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

#[allow(dead_code)]
fn find_min(x: &[u64]) -> u64 {
    let mut min: u64 = x[0];
    let mut x_iter = x.iter();
    while let Some(i) = x_iter.next() {
        min = cmp::min(*i, min);
    }
    return min;
}

#[allow(dead_code)]
fn find_max(x: &[u64]) -> u64 {
    let mut max: u64 = x[0];
    let mut x_iter = x.iter();
    while let Some(i) = x_iter.next() {
        max = cmp::max(*i, max);
    }
    return max;
}

fn calc(v: &Vec<u64>) -> u64 {
    if v.len() == 1 {
        v[0]
    } else {
        let min: u64 = find_min(v);
        let vec: Vec<u64> = v.iter().map(|x| x - min).collect();
        let mut ans: u64 = min;

        let mut i: usize = 0;
        while i < vec.len() {
            let mut tmp: Vec<u64> = Vec::new();
            while i < vec.len() && vec[i] != 0 {
                tmp.push(vec[i]);
                i += 1;
            }
            i += 1;
            if tmp.len() > 0 {
                ans += calc(&tmp);
            }
        }
        ans
    }
}

fn main() {
    let _n: u64 = read();
    let h: Vec<u64> = read_vec();

    println!("{}", calc(&h));
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
#define MAX 1000000007
#define ll long long int
#define fo(i,n) for(int i=0;i<n;i++)
#define ull unsigned long long int
#define pb push_back
#define eb emplace_back
using namespace std;


int main(){

    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    // int t;
    // cin>>t;
    // while(t--){
    // }
    string s,t;
    cin>>s;
    cin>>t;
    int mx=1001;
    for(int i=0;i+t.length()-1<s.length();i++){
        int ct=0;
        for(int j=0;j<t.length();j++){
            if(t[j]!=s[i+j]){
                ct++;
            }
        }
        mx = min(mx,ct);
    }

    cout<<mx<<endl;
    return 0;
}

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


int main(void){
    string s;
    cin >> s;
    for(int i=0; i < s.size(); i++){
        if(s.at(i) == '1'){
            s.at(i) = '9';
        }else{
            s.at(i) = '1';
        }
    }
    cout << s << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
using vs = vector<string>;
using vll = vector<long long>;
using vpii = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvs = vector<vector<string>>;
using vvb = vector<vector<bool>>;
using pii = pair<int, int>;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define reps(i,n) for(int i = 1; i <= (int)(n); i++)
#define rrep(i,n) for(int i = (int)(n) - 1; i >= 0; i--)
#define rreps(i,n) for(int i = (int)(n); i > 0; i--)
#define FOR(i,a,b) for(int i = (int)(a); i <= (int)(b); i++)
#define RFOR(i,a,b) for(int i = (int)(a); i >= (int)(b); i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define call(x) (x).cbegin(), (x).cend()
#define MAX(x) *max_element(all(x))
#define MIN(x) *min_element(all(x))
template<class T> inline bool chmax(T &a, T b) {if (a<b) {a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a, T b) {if (b<a) {a=b; return 1;} return 0;}
const int INF = INT_MAX;
const int MOD = 1000000007;
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};

int main() {
    int N, M;
    cin >> N >> M;
    vb broken(N+1, false);
    rep(i, M) {
      int x;
      cin >> x;
      broken[x] = true;
    }
    vll dp(N+1);
    dp[0] = 1;
    if (broken[1]) {
      dp[1] = 0;
    } else {
      dp[1] = 1;
    }
    FOR(i, 2, N) {
      if (broken[i]) {
        dp[i] = 0;
      } else {
        dp[i] = dp[i-2] + dp[i-1];
        dp[i] %= MOD;
      }
    }
    cout << dp[N] << endl;
}

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

#define ll long long

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    int n,k,x;
    cin >> n;
    cin >> k;
    vector<int> a(n, 0);
    for(int i=0;i<k;i++){
        int j; cin >> j;
        while(j--){
            cin >> x, --x;
            a[x] = 1;
        }
    }
    int cnt=0;
    for(int i=0;i<n;i++){
        if(a[i]==0)++cnt;
    }
    cout << cnt;
    cout << '\n';
    return 0;
}

Measured memory_bytes: 3576
#include <cstdio>
#include <algorithm>
using namespace std;
const int MAXN=110000;
int h[MAXN], f[MAXN];
int main()
{
//	freopen("A.in", "r", stdin);
//	freopen("A.out", "w", stdout);
	int n;
	scanf("%d", &n);
	for (int i=1; i<=n; i++) scanf("%d", &h[i]);
	f[1]=0; f[2]=abs(h[2]-h[1]);
	for (int i=3; i<=n; i++)
		f[i]=min(f[i-1]+abs(h[i]-h[i-1]), f[i-2]+abs(h[i]-h[i-2]));
	printf("%d\n", f[n]);
	return 0;
}

Measured memory_bytes: 896
using System;
using System.Collections.Generic;
using System.Linq;
namespace AtCoderTemplate
{
    public class App
    {
        public static void Main(string[] args)=>Console.WriteLine("{2}",args=new string[1],args[0]="0",Console.ReadLine().ToCharArray().Select(c => "ACGT".Contains(c)).Select((b)=>args[0]=b?(int.Parse(args[0])+1).ToString():"0").Max(v=>int.Parse(v)));
    }
}

Measured memory_bytes: 13280
#include <iostream>
#include <map>
#include <set>
#include <algorithm>
#include <string>
using namespace std;

int main() {
	int m;
	cin >> m;
	for(int t = 0; t < m; t++) {
		string str;
		cin >> str;

		set<string> count;
		count.insert(str);
		for(int cut = 0; cut < str.size(); cut++) {
			string rev_a(str.begin(), str.begin() + cut);
			string rev_b(str.begin() + cut, str.end());

			string a = rev_a;
			string b = rev_b;

			reverse(rev_a.begin(), rev_a.end());
			reverse(rev_b.begin(), rev_b.end());

			count.insert(a + rev_b);
			count.insert(rev_a + b);
			count.insert(rev_a + rev_b);
			count.insert(b + a);
			count.insert(b + rev_a);
			count.insert(rev_b + a);
			count.insert(rev_b + rev_a);
		}

		cout << count.size() << endl;
	}
}

Measured memory_bytes: 1288
#include<bits/stdc++.h>
#define vll vector<ll>
#define vi vector<int>
#define vpll vector<pair<ll,ll>>
#define pii pair<int,int>
#define REP(i,a) for(int (i)=0; (i)<(a); (i)++)
#define RREP(i,a) for(int (i)=a-1; (i)>=(0); (i)--)
#define REP2(i,a,b) for(int (i)=(a); (i)<(b); (i)++)
#define MOD 1000000007
#define ALL(v) v.begin(), v.end()
#define m0(x) memset(x,0,sizeof(x))
typedef long long ll;

using namespace std;

int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int N,M=0;
  cin>>N;
  vi a(N+1),b(N+1),c;
  REP2(i,1,N+1){
    cin>>a[i];
  }
  int hanbun = (int)(N/2)+1;
  for(int i=N;i>=hanbun;i--){
    b[i]=a[i];
    if(b[i]==1){
      M++;
      c.push_back(i);
    }
  }
  int now,ball;
  for(int i=hanbun-1;i>=1;i--){
    now =2*i;
    ball=0;
    while(1){
      ball+=b[now];
      now += i;
      if(now>N)break;
    }
    if(ball%2==a[i]){
      b[i]=0;
    }
    else{
      b[i]=1;
      M++;
      c.push_back(i);
    }
  }
  cout<<M<<"\n";
  REP(i,M)cout<<c[i]<<" ";
  return 0;
}

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

int main() {
    long double a, b, c;
    cin >> a >> b >> c;
    long double left = a + b + 2 * sqrt(a * b);
    long double right = c;

    if(left < right) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.HashSet;
import java.util.InputMismatchException;
import java.util.Set;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskX solver = new TaskX();
		solver.solve(1, in, out);
		out.close();
	}

	static int INF = 1 << 30;
	static int modP = 1000000007;

	static class TaskX {
		public void solve(int testNumber, InputReader in, PrintWriter out) {

			char[] s = in.nextString().toCharArray();
			Set<Character> set = new HashSet<>();
			for (int i = 0; i < 3; i++) {
				set.add(s[i]);
			}

			if (set.size() == 3) {
				out.println("Yes");
			} else {
				out.println("No");
			}

		}
	}

	static class InputReader {
		BufferedReader in;
		StringTokenizer tok;

		public String nextString() {
			while (!tok.hasMoreTokens()) {
				try {
					tok = new StringTokenizer(in.readLine(), " ");
				} catch (IOException e) {
					throw new InputMismatchException();
				}
			}
			return tok.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(nextString());
		}

		public long nextLong() {
			return Long.parseLong(nextString());
		}

		public double nextDouble() {
			return Double.parseDouble(nextString());
		}

		public int[] nextIntArray(int n) {
			int[] res = new int[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextInt();
			}
			return res;
		}

		public long[] nextLongArray(int n) {
			long[] res = new long[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextLong();
			}
			return res;
		}

		public InputReader(InputStream inputStream) {
			in = new BufferedReader(new InputStreamReader(inputStream));
			tok = new StringTokenizer("");
		}

	}

}


Measured memory_bytes: 20820
<?php
while (true) {
    $line = trim(fgets(STDIN));
    list($H, $W) = explode(' ', $line);
    if ($W == 0 && $H == 0) {
        break;
    }
    $room = array();
    for ($i = 0; $i < $H; $i++) {
        $room[$i] = trim(fgets(STDIN));
    }
    $visited = array();
    for ($i = 0; $i < $H; $i++) {
        for ($j = 0; $j < $W; $j++) {
            $visited[$i][$j] = false;
        }
    }
    $x = 0; $y = 0;
    $isLoop = false;
    while (true) {
        $line = $room[$y];
        $dir = $line[$x];
        if ($dir == '.') {
            break;
        }
        $visited[$y][$x] = true;
        switch ($dir) {
            case '>':
                $x++;
                break;
            case '<':
                $x--;
                break;
            case 'v':
                $y++;
                break;
            case '^':
                $y--;
                break;
        }
        if ($visited[$y][$x]) {
            $isLoop = true;
            break;
        }
    }
    if ($isLoop) {
        echo "LOOP\n";
    } else {
        echo "$x $y\n"; 
    }
}

Measured memory_bytes: 16588
n = int(input())
alst = list(map(int, input().split()))
lst = [[0, [0, 0]] for _ in range(n)]

lst[0][0] = 1000
lst[0][1][0] = 1000 // alst[0]
lst[0][1][1] = 1000 % alst[0]
for i, num in enumerate(alst[1:], start = 1):
    m1 = lst[i - 1][1][1] + lst[i - 1][1][0] * num
    lst[i][0] = max(lst[i - 1][0], m1)
    lst[i][1][0] = lst[i][0] // num
    lst[i][1][1] = lst[i][0] % num
    
print(lst[-1][0])

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

int main(){ 
  int n, k;
  cin >> n >> k;
  cout << (n%k == 0 ? 0 : 1) << endl;
  return 0;
} 

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

int main(){
    string s;
    cin >> s;
    int n = s.size();
    for(int i = n-1; i; i--){
        string s1 = s.substr(0,i);
        int s1size = s1.size();
        string a = s1.substr(0,s1size/2-1);
        string b = s1.substr(s1size/2,s1size/2-1);
        if(a == b){
            cout << s1size - 1 << endl;
            return 0;
        }
    }
    return 0;
}



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

int main() {

	int n;
	cin >> n;

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

	sort(a.begin(), a.end());

	double mid = ((double)a[n-1])/2;

	double left_max = a[1];
	for(int i = 0;i<n-1;i++) {
		if (mid - a[i] < 0) {
			cout << a[n - 1] << " " << ((mid-left_max < a[i]-mid)? (int)left_max :a[i]) << endl;
			break;
		}
		left_max = a[i];
		if (i == n - 2) {
			cout << a[n - 1] << " " << (int)left_max << endl;
		}
	}
}

Measured memory_bytes: 640
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt(); sc.nextLine();
        String s = sc.nextLine();
        int count = 0;
        char prevC = 0;
        for (int i = 0; i < N; i++) {
            char c = s.charAt(i);
            if (c != prevC) {
                count++;
                prevC = c;
            }
        }
        System.out.println(count);
    }
}


Measured memory_bytes: 26300
n = gets.to_i
x = gets.chomp.chars
pc = x.count("1")

ur = []
lr = []
ut = 1
lt = -1
n.times do
  ut %= pc + 1
  ur.unshift(ut)
  ut <<= 1
  if pc - 1 > 0
    lt %= pc - 1
    lr.unshift(lt)
    lt <<= 1
  end
end

rl = x[0].to_i
ru = x[0].to_i
1.step(n - 1) do |i|
  t = x[i]
  if pc - 1 > 0
    rl <<= 1
    rl += t.to_i
    rl %= pc - 1
  end
  ru <<= 1
  ru += t.to_i
  ru %= pc + 1
end

n.times do |i|
  res = 1
  if x[i] == "0"
    t = (ur[i] + ru) % (pc + 1)
  elsif pc - 1 == 0
    puts "0"
    next
  else
    t = (lr[i] + rl) % (pc - 1)
  end
    
  while t > 0
    t %= ("%b" % [t]).count("1")
    res += 1
  end
  puts res
end

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

using namespace std;

typedef long long ll;
typedef long double ld;

const int INF = (int) 1e9 + 123;
const ll LINF = (ll) 1e18 + 123;
const ld EPS = (ld) 1e-12;
const ll MOD = (ll) 1e9 + 7;

#define sz(x) (int) (x).size()
#define mp(x, y) make_pair(x, y)
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define lb(s, t, x) (int) (lower_bound(s, t, x) - s)
#define ub(s, t, x) (int) (upper_bound(s, t, x) - s)
#define rep(i, f, t) for (auto i = f; i < t; i++)
#define per(i, f, t) for (auto i = f; i >= t; i--)

ll power(ll x, ll y, ll mod = MOD) {
    if (y == 0) {
        return 1;
    }
    if (y & 1) {
        return power(x, y - 1, mod) * x % mod;
    } else {
        ll tmp = power(x, y / 2, mod);
        return tmp * tmp % mod;
    }
}

void add(ll &x, ll y, ll mod = MOD) {
    x += y;
    if (x >= mod) x -= mod;
    if (x < 0) x += mod;
}

ll sum(ll x, ll y, ll mod = MOD) {
    add(x, y, mod);
    return x;
}

ll mult(ll x, ll y, ll mod = MOD) {
    return (x * y) % mod;
}

ll div(ll x, ll y, ll mod) {
    return x * power(y, mod - 2, mod);
}

template<typename A, typename B> bool mini(A &x, const B &y) {
    if (y < x) {
        x = y;
        return true;
    }
    return false;
}

template<typename A, typename B> bool maxi(A &x, const B &y) {
    if (y > x) {
        x = y;
        return true;
    }
    return false;
}

template<typename T> void read(T first, T last) {
    while (first != last) {
        cin >> *(first++);
    }
}

template<typename T> void print(T first, T last) {
    while (first != last) {
        cout << *(first++) << " ";
    }
    cout << "\n";
}

void run();

#define TASK ""

int main() {
#ifdef LOCAL
    if (strlen(TASK) > 0) {
        cerr << "Reminder: you are using file i/o, filename: " TASK "!" << endl << endl;
    }
#endif
#ifndef LOCAL
    if (strlen(TASK)) {
        freopen(TASK ".in", "r", stdin);
        freopen(TASK ".out", "w", stdout);
    }
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
#endif
    cout << fixed << setprecision(12);
    run();
    return 0;
}

// == SOLUTION == //

const int N = 501;

int n, p;
int a[N];
ll dp[N][2];

void run() {
    cin >> n >> p;
    read(a, a + n);
    dp[0][0] = 1;
    rep(i, 0, n) {
        rep(j, 0, 2) {
            dp[i + 1][j] += dp[i][j];
            dp[i + 1][(j + a[i]) % 2] += dp[i][j];
        }
    }
    cout << dp[n][p] << "\n";
}


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

typedef long long ll;

using namespace std;

int main() {
  int N;
  cin >> N;
  unordered_map<string, int> S;
  for (int i = 0; i < N; ++i) {
    string s;
    cin >> s;
    sort(s.begin(), s.end());
    ++S[s];
  }
  ll res = 0;
  for (auto &s : S) {
    res += (ll)s.second * (s.second - 1) / 2;
  }
  printf("%lld\n", res);
}

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

int main() {
  cout << "Christmas";
  int D; cin >> D;
  int dif = 25 - D;
  for (int i = 0; i < dif; i++) {
    cout << " Eve" << endl;
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 256
i,a[1<<17],b[1<<17];c;
main(s){
	for(;~(c=getchar_unlocked());)c>10?a[i]=a[i]*10+c-48:i++;
	for(b[i=s]=1;!b[s=a[s]]++&&s-2;i++);
	printf("%d",s-2?-1:i);
}

Measured memory_bytes: 896
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace Tasks
{
    public class B
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var S = Console.ReadLine();
            var answer = S.LastIndexOf('Z') - S.IndexOf('A') + 1;
            Console.WriteLine(answer);
        }
    }
}


Measured memory_bytes: 26692
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
int main(){
  int i,j,N,cnt=0;
  long long bpow[100002],com[100002],comb[100002],ans=0,plus;
  bpow[0]=1;
  for(i=1;i<100002;i++){
    bpow[i]=(bpow[i-1]*2)%mod;
  }
  com[0]=1;com[1]=2;
  comb[0]=1;comb[1]=3;
  for(i=2;i<100002;i++){
    com[i]=(com[i-1]*3)%mod;
    comb[i]=(comb[i-1]+com[i])%mod;
  }

  char L[100002];
  scanf("%s",L);
  N=strlen(L);
  
  for(i=0;i<N;i++){
    if(L[i]=='1'){
      plus=(comb[N-i-1]*bpow[cnt++])%mod;
      ans=(ans+plus)%mod;
    }
  }
  ans=(ans+bpow[cnt])%mod;
  printf("%lld\n",ans);
  return 0;
}

Measured memory_bytes: 2688
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Practice
{
    class Program
    {
        static void Main(string[] args)
        {
            Solve();
        }
        private const long MOD = 1000000007;
        
        static void Solve()
        {
            int x = ReadAndParseInt();
            int ans = 0;
            int pos = 0;
            for(int i=1;i<=x;++i)
            {
                pos += i;
                ans++;
                if( pos >= x)
                {
                    break;
                }
            }
            Console.WriteLine(ans);
        }
        #region よく使う便利関数
        private static bool isPrime(long x)
        {
            if (x == 2) { return true; }
            if (x < 2 || x % 2 == 0) { return false; }
            long i = 3;
            while (i * i <= x)
            {
                if (x % i == 0) { return false; }
                i = i + 2;
            }
            return true;
        }
        private static long lcm(long x, long y)
        {
            return x / gcd(x, y) * y;
        }
        private static long gcd(long x, long y)
        {
            return y > 0 ? gcd(y, x % y) : x;
        }
        private static long pow(long x, long n)
        {
            if (n == 0) { return 1; }
            long res = pow(x * x % MOD, n / 2);
            if (n % 2 == 1)
            {
                res = res * x % MOD;
            }
            return res;
        }
        private static int ReadAndParseInt()
        {
            return int.Parse(Console.ReadLine());
        }
        private static int[] ReadAndParseIntArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
        }
        private static long ReadAndParseLong()
        {
            return long.Parse(Console.ReadLine());
        }
        private static long[] ReadAndParseLongArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);
        }
        #endregion
    }
}

Measured memory_bytes: 13140
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <deque>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <utility>
#include <algorithm>
#include <numeric>
#include <typeinfo>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <ctime>

using namespace std;

#define dump(n) cout<<"# "<<#n<<"="<<(n)<<endl
#define debug(n) cout<<__FILE__<<","<<__LINE__<<": #"<<#n<<"="<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,n) repi(i,0,n)
#define iter(c) __typeof((c).begin())
#define foreach(i,c) for(iter(c) i=(c).begin();i!=(c).end();i++)
#define allof(c) (c).begin(),(c).end()
#define mp make_pair

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;

const int INFTY=1<<29;

int main()
{
	for(int n,m;cin>>n>>m,n|m;){
		vvi c(m,vi(m,INFTY));
		rep(i,m)
			c[i][i]=0;
		vvi t=c;
		
		rep(i,n){
			int src,dst,cost,time;
			cin>>src>>dst>>cost>>time;
			src--;dst--;
			c[src][dst]=c[dst][src]=cost;
			t[src][dst]=t[dst][src]=time;
		}
		
		rep(k,m) rep(i,m) rep(j,m){
			c[i][j]=min(c[i][j],c[i][k]+c[k][j]);
			t[i][j]=min(t[i][j],t[i][k]+t[k][j]);
		}
		
		int query;
		cin>>query;
		rep(i,query){
			int src,dst,which;
			cin>>src>>dst>>which;
			src--;dst--;
			if(which)
				cout<<t[src][dst]<<endl;
			else
				cout<<c[src][dst]<<endl;
		}
	}
	
	return 0;
}

Measured memory_bytes: 992
#include <bits/stdc++.h>
#define rep(var,cnt) for(int (var)=0; (var)<(int)(cnt); ++(var))
#define REP(var,init,cnt) for(int (var)=(init); (var)<(cnt); ++(var))
#define ran(var,vec) for(auto &(var):(vec))
#define all(v) (v).begin(),(v).end()
#define TF(flag) (flag)?1:0
using namespace std;

using ll = long long;
using ull = unsigned long long;
using pi = pair<int,int>;
using pl = pair<ll,ll>;
using ti = tuple<int,int,int>;
using tl = tuple<ll,ll,ll>;

template<typename T>
using vec = vector<T>;
template<typename T>
using mat = vector<vec<T>>;
template<typename T>
using cub = vector<mat<T>>;
template<typename T>
using val = valarray<T>;

template<typename T>
using pq = priority_queue<T>;
template<typename T>
using rpq = priority_queue<T,vec<T>,greater<T>>;

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

template<typename T1,typename T2>
istream &operator>>(istream &is, pair<T1,T2> &p){
  is>>p.first>>p.second;
  return is;
}

template<typename T>
ostream &operator<<(ostream &os, const vector<T> &v){
  cout<<"V{";
  for(int i=0; i<(int)v.size(); ++i){
    os<<v[i]<<(i+1!=v.size()?" ":"");
  }
  cout<<"}";
  return os;
}

template<typename T>
istream &operator>>(istream &is, vector<T> &v){
  for(T &in:v) is>>in;
  return is;
}

template<typename T>
ostream &operator<<(ostream &os, const valarray<T> &v){
  cout<<"V{";
  for(int i=0; i<(int)v.size(); ++i){
    os<<v[i]<<(i+1!=v.size()?" ":"");
  }
  cout<<"}";
  return os;
}

template<typename T>
istream &operator>>(istream &is, valarray<T> &v){
  for(T &in:v) is>>in;
  return is;
}

// Usual Template End ================================================

// Template End ======================================================

int main(void){
  int A,B; cin>>A>>B;
  cout<<(A+B)%24;
}














Measured memory_bytes: 256
/********************************************************************
 * Ejercicio: Vacation                                              *
 * Url: https://atcoder.jp/contests/dp/tasks/dp_c                   *
 * Lenguaje: c++                                                    *
 * Autor: Sebastian Vega                                            *
 * Fecha: 27-08-2020                                                *
 *******************************************************************/

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define forn(i, a, b) for (int i = a; i < b; ++i)
#define SZ(x) int(x.size())
#define pb push_back
#define F first
#define S second
void dbg_out() { cerr << endl; }
template <typename Head, typename... Tail>
void dbg_out(Head H, Tail... T) {
  cerr << ' ' << H;
  dbg_out(T...);
}

const int N = 1e5 + 1;
int n, a[N], b[N], c[N], dp[N][3];

int main() {
#ifdef LOCAL
  freopen("in.txt", "r", stdin);
// freopen("main.txt", "w", stdout);
#define dbg(...) cerr << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)
#else
  ios::sync_with_stdio(0);
  cin.tie(0);
#define endl '\n'
#define dbg(...) 18
#endif
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i] >> b[i] >> c[i];
  }
  for (int i = 0; i < n; i++) {
    if (i == 0) {
      dp[i][0] = a[i];
      dp[i][1] = b[i];
      dp[i][2] = c[i];
    } else {
      dp[i][0] = a[i] + max(dp[i - 1][1], dp[i - 1][2]);
      dp[i][1] = b[i] + max(dp[i - 1][0], dp[i - 1][2]);
      dp[i][2] = c[i] + max(dp[i - 1][0], dp[i - 1][1]);
    }
  }
  cout << *max_element(dp[n - 1], dp[n - 1] + 3) << endl;
  return 0;
}

Measured memory_bytes: 5980
use proconio::input;
use proconio::marker::{Chars, Usize1};
use std::iter::Iterator;
use std::collections::*;
use std::cmp::*;
use itertools::Itertools;

#[allow(unused_macros)]
macro_rules! max {
    ($x:expr) => {
      $x
    };
    ($x:expr, $($xs:tt)+) => {
      max($x,max!($($xs)+))
    };
  }
  
  #[allow(unused_macros)]
  macro_rules! min {
    ($x:expr) => {
      $x
    };
    ($x:expr, $($xs:tt)+) => {
      min($x,min!($($xs)+))
    };
  }

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn main() {
    input! {
    n: usize,
    }

  let mut map = HashMap::new();

  let mut cnt:u64 = 0;

  for _ in 0..n {
    input! {
      mut s: Chars,
      }

        s.sort();
        let str1 = s.into_iter().rev().collect::<String>();
        map.entry(str1).and_modify(|e| *e += 1_u64).or_insert(1_u64);
      }


      for (_, v) in &map {
        cnt += v * (v -1) /2
    }

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




Measured memory_bytes: 11624
#include "bits/stdc++.h"
using namespace std;

int main() {
	long long N, X[3][2], Y[3][2];
	vector<double> TIME;
	double ANS = 1000000000000000000.0;
	cin >> N;
	for (int i = 0; i < 3; i++) {
		X[i][0] = 1000000000;
		X[i][1] = -1000000000;
		Y[i][0] = 1000000000;
		Y[i][1] = -1000000000;
	}
	for (int i = 0; i < N; i++) {
		long long x, y;
		char C;
		cin >> x >> y >> C;
		if (C == 'R') {
			X[0][0] = min(X[0][0], x);
			X[0][1] = max(X[0][1], x);
			Y[2][0] = min(Y[2][0], y);
			Y[2][1] = max(Y[2][1], y);
		}
		if (C == 'L') {
			X[1][0] = min(X[1][0], x);
			X[1][1] = max(X[1][1], x);
			Y[2][0] = min(Y[2][0], y);
			Y[2][1] = max(Y[2][1], y);
		}
		if (C == 'U') {
			Y[0][0] = min(Y[0][0], y);
			Y[0][1] = max(Y[0][1], y);
			X[2][0] = min(X[2][0], x);
			X[2][1] = max(X[2][1], x);
		}
		if (C == 'D') {
			Y[1][0] = min(Y[1][0], y);
			Y[1][1] = max(Y[1][1], y);
			X[2][0] = min(X[2][0], x);
			X[2][1] = max(X[2][1], x);
		}
	}
	if (X[0][0] < X[1][0]) TIME.push_back((double)(X[1][0] - X[0][0]) / 2.0);
	if (X[0][0] < X[2][0]) TIME.push_back(X[2][0] - X[0][0]);
	if (X[2][0] < X[1][0]) TIME.push_back(X[1][0] - X[2][0]);
	if (X[0][1] < X[1][1]) TIME.push_back((double)(X[1][1] - X[0][1]) / 2.0);
	if (X[0][1] < X[2][1]) TIME.push_back(X[2][1] - X[0][1]);
	if (X[2][1] < X[1][1]) TIME.push_back(X[1][1] - X[2][1]);
	if (Y[0][0] < Y[1][0]) TIME.push_back((double)(Y[1][0] - Y[0][0]) / 2.0);
	if (Y[0][0] < Y[2][0]) TIME.push_back(Y[2][0] - Y[0][0]);
	if (Y[2][0] < Y[1][0]) TIME.push_back(Y[1][0] - Y[2][0]);
	if (Y[0][1] < Y[1][1]) TIME.push_back((double)(Y[1][1] - Y[0][1]) / 2.0);
	if (Y[0][1] < Y[2][1]) TIME.push_back(Y[2][1] - Y[0][1]);
	if (Y[2][1] < Y[1][1]) TIME.push_back(Y[1][1] - Y[2][1]);
	TIME.push_back(0.0);
	for (auto T : TIME) {
		double XMIN, XMAX, YMIN, YMAX;
		XMIN = min(min((double)X[0][0] + T, (double)X[1][0] - T), (double)X[2][0]);
		XMAX = max(max((double)X[0][1] + T, (double)X[1][1] - T), (double)X[2][1]);
		YMIN = min(min((double)Y[0][0] + T, (double)Y[1][0] - T), (double)Y[2][0]);
		YMAX = max(max((double)Y[0][1] + T, (double)Y[1][1] - T), (double)Y[2][1]);
		ANS = min(ANS, (XMAX - XMIN) * (YMAX - YMIN));
	}
	printf("%.12lf\n", ANS);
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val line = readLine()!!.toString()
    var valueMap = mutableMapOf<String, Int>()

    for (v in line) {
        if (!valueMap.containsKey(v.toString())) {
            valueMap[v.toString()] = 0
        }

        valueMap[v.toString()]?.let {
            valueMap[v.toString()] = it + 1
        }
    }

    if (valueMap.size != 2) {
        println("No")
        return
    }

    for ((k, v) in valueMap) {
        if (v != 2) {
            println("No")
            return
        }
    }

    println("Yes")
}

Measured memory_bytes: 33836
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)

typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, double> Pid;
typedef pair<double, int> Pdi;
const double PI = 3.1415926535897932;   // acos(-1)
const double EPS = 1e-15;
const int INF = 1001001001;
const ll mod = 1e+9 + 7;

#define chadd(x, y) x = (x + y) % mod

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

    int h, w;
    double n;
    cin >> h >> w >> n;

    cout << ceil(n / max(h, w)) << endl;
}

Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp::{Ordering};

#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};

#[allow(unused_imports)]
use std::io::{stdin, stdout, BufWriter, Write};

#[allow(unused_imports)]
use std::iter::FromIterator;

#[allow(unused_macros)]
macro_rules! min {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::min($x, min!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! max {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::max($x, max!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! get { 
    ([$t: ty]) => { 
        { 
            let mut line = String::new(); 
            stdin().read_line(&mut line).unwrap(); 
            line.split_whitespace().map(|t|t.parse::<$t>().unwrap()).collect::<Vec<_>>()
        }
    };
    ([$t: ty];$n: expr) => {
        (0..$n).map(|_|get!([$t])).collect::<Vec<_>>()
    };
    ($t: ty) => {
        {
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t: ty),*) => {
        { 
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ($(iter.next().unwrap().parse::<$t>().unwrap(),)*)
        }
    };
    ($t: ty; $n: expr) => {
        (0..$n).map(|_|get!($t)).collect::<Vec<_>>()
    };
    ($($t: ty),*; $n: expr) => {
        (0..$n).map(|_|get!($($t),*)).collect::<Vec<_>>()
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*).unwrap();
    }
}

const BIG_STACK_SIZE: bool = true;

#[allow(dead_code)]
fn main() {
    use std::thread;
    if BIG_STACK_SIZE {
        thread::Builder::new()
            .stack_size(32 * 1024 * 1024)
            .name("solve".into())
            .spawn(solve)
            .unwrap()
            .join()
            .unwrap();
    } else {
        solve();
    }
}

const INF: usize = 1_000_000_000_000_000;

fn dfs(l: usize, r: usize, sums: &Vec<usize>, dp: &mut Vec<Vec<usize>>) -> usize {
    if l+1 == r {
        return 0;
    }
    if dp[l][r] != INF {
        return dp[l][r];
    }
    let mut mn = std::usize::MAX;
    for i in (l+1)..r {
        let left = dfs(l,i,sums,dp);
        let right = dfs(i,r,sums,dp);
        mn = min!(mn, left+right);
    }
    mn += sums[r] - sums[l];
    dp[l][r] = min!(dp[l][r], mn);
    mn
}

fn solve() {
    let n = get!(usize);
    let a = get!([usize]);

    let mut sums = vec![0; n+1];
    for i in 0..n {
        sums[i+1] = sums[i] + a[i];
    }

    let res = dfs(0, n, &sums, &mut vec![vec![INF; n+1];n+1]);
    println!("{}", res);
}


Measured memory_bytes: 8572
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); ++i)
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;
}
using namespace std;
using ll = long long;
using P = pair<int, int>;
using Pl = pair<long long, long long>;
using veci = vector<int>;
using vecl = vector<long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long long>>;

int main() {
    int N;
    cin >> N;
    veci A(N);
    REP(i,N) cin >> A[i];
    veci ans(N);
    for(int i = N-1; i >= 0; --i) {
        int total = 0;
        for(int j = 2; j <= N/(i+1); j++) total += ans[(i+1)*j-1];
        if(total%2 == A[i]) ans[i] = 0;
        else ans[i] = 1;
    }
    veci b;
    for(int i = 0; i < N; i++) {
        if(ans[i]) b.push_back(i+1);
    }
    cout << b.size() << endl;
    if(b.size() > 0) {
    for(int i: b) cout << i << " ";
    cout << endl;
    }
}


Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <numeric>
#include <iomanip>
#include <tuple>

using namespace std;


int main(){
   string Atcoder,s,Contest;
   cin>>Atcoder>>s>>Contest;
   cout<<'A'<<s[0]<<'C'<<endl;
}

   


Measured memory_bytes: 256
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;


public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		String S = sc.next();
		sc.close();
		
		int ans = 0;
		for(int i = 1;i < S.length();++i) {
			Set<Character> sufSet = new HashSet<>();
			for(int j = 0;j < i;++j)
				sufSet.add(S.charAt(j));
			Set<Character> preSet = new HashSet<>();
			for(int j = i;j < S.length();++j)
				preSet.add(S.charAt(j));
			Set<Character> set = new HashSet<>(sufSet);
			set.retainAll(preSet);
			if(set.size() > ans)
				ans = set.size();
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 22228
#include <bits/stdc++.h>
typedef long long LL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

using namespace std;

int main(void)
{
  LL a,v,b,w,t;
  cin >> a >> v >> b >> w >> t;
  if(w*t+abs(b-a)>v*t) cout << "NO" << endl;
  else cout << "YES" << endl;
  return 0;
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
 
int main() 
{
	int a, b, c, x;
	scanf("%d %d %d %d", &a, &b, &c, &x);
	int cnt = 0;
	for(int i = 0; i <= min(a, x/500); i++) {
		for(int j = 0; j <= min(b, x/100); j++) {
			for(int k = 0; k <= min(c, x/50); k++) {
				if(500*i + 100*j + 50*k == x) {
					cnt++;
				}
			}
		}
	}
	printf("%d\n", cnt);
}

Measured memory_bytes: 256
import collections

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

def resolve():
    N = int(input())
    factor_list = prime_factorize(N)
    if len(factor_list) == 0:
        print(0)
        return
    factor_count = collections.Counter(factor_list)
    div_count = 0
    for factor, count in factor_count.items():
        e = 1
        while True:
            if count >= e:
                N = N // (factor**e)
                div_count += 1
                count -= e
                e += 1
            else:
                break
    print(div_count)

resolve()

Measured memory_bytes: 9492
#include <bits/stdc++.h>
#define ll long long
#define LL long long
#define db double
#define iosks std::ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
#define PI acos(-1)
ll mod=1e9+7;
char chs[200005];
int num[500];
int main()
{
    int n;
    cin >> n;
    scanf("%s",chs);
    for(int i=0;i<n;i++)
    {
        num[chs[i]]++;
    }
    int ans=0;
    for(int i=0;i<num['R'];i++)
    {
        if(chs[i]=='W')
            ans++;
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 3820
#include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;
int main(){
    long long int X,K,D;
    cin>>X>>K>>D;
    if(X<0ll)X*=-1ll;
    if(X/D>=K){
        cout<<X-K*D<<endl;
        return 0;
    }
    //printf("[%lld]\n",X);
    long long int karix=X;
    long long int kariK=K;
    X-=(X/D)*D;
    K-=karix/D;
    //printf("[%lld]\n",X);
    if(K%2ll==1ll)X-=D;
    //printf("[%lld]\n",X);
    if(X<0ll)X*=-1ll;
    cout<<X<<endl;
    return 0;
}


Measured memory_bytes: 3192