akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int i = (int)(n); i >= 0; i--)
#define all(v) v.begin(),v.end()
typedef long long ll;

int main(){
    string S;
    cin >> S;
    ll len = S.size();
    ll cnt_white = 0;
    rep(i,len){
        if (S[i] == 'W') cnt_white++;
    }
    ll ans = 0;
    ll ans_sub = 0;
    for (ll i = 0; i < cnt_white; i++){
        ans_sub += i;
    }
    rep(i,len){
        if (S[i] == 'W') ans += i;
    }
    cout << ans - ans_sub << endl;
}


Measured memory_bytes: 640
#include <iostream>
#include <map>
#include <vector>
#include <queue>
#include <functional>
#include <algorithm>
#include <cmath>
#include <string>
#define mp make_pair
#define pb push_back

using namespace std;

int main() 
{
	map<string, int> ma;
	int n, m;
	cin >> n;
	for (int i = 0; i<n; ++i) {
		string s;
		cin >> s;
		ma[s]++;
	}
	cin >> m;
	for (int i = 0; i<m; ++i) {
		string s;
		cin >> s;
		ma[s]--;
	}
	int res = 0;
	for (auto it = ma.begin(); it != ma.end(); ++it) {
		res = max(res, it->second);
	}
	printf("%d\n", res);
	return 0;
}

Measured memory_bytes: 256
def main():
	N = int(input())
	arr = list(map(int, input().split()))
	ans = arr[0]
	if arr.count(0) > 0:
		print(0)
		return
	for i in range(1, N):
		ans *= arr[i]
		if ans > 1000000000000000000:
			print(-1)
			return
	print(ans)


if __name__ == '__main__':
	main()

Measured memory_bytes: 21652
'''     ##     ##  #######  # #  ######
        ##     ##  ##   ##  ###    ##
        ##     ##  ##    #  # #    ##
        #########  #######  # #    ##    '''

import sys
import math
# sys.setrecursionlimit(10**6)

def get_ints(): return map(int, input().strip().split())
def get_list(): return list(get_ints())

def printspx(*args): return print(*args, end="")
def printsp(*args): return print(*args, end=" ")
def printchk(*args): return print(*args, end=" \ ")

MODPRIME = int(1e9+7); BABYMODPR = 998244353;

ONLINE_JUDGE = 1
if not ONLINE_JUDGE:
    sys.stdin = open("input.txt","r")  # <<<  Comment this line  >>> #
    sys.stdout = open("output.txt","w")  # <<<  Comment this line  >>> #
    sys.stderr = open("output.txt","w")  # <<<  Comment this line  >>> #

# for _testcases_ in range(int(input())):
n = int(input())
li = get_list()
flagli= [True]*n
d = {}
li.sort()
se = set(li)
for i in range(n):
    try:
        d[li[i]].append(i)
    except:
        d[li[i]] = [i]

for i in range(n):
    j = li[i]
    if flagli[i]:
        while j <= li[-1]:
            if j in d:
                for val in d[j]:
                    if val != i:
                        flagli[val] = False
            j += li[i]
for k, v in d.items():
    if len(v) > 1:
        for i in v:
            flagli[i] = False

# print(flagli)
ans = 0
for i in flagli:
    if i:ans+=1
print(ans)

'''
>>> COMMENT THE STDIN!! CHANGE ONLINE JUDGE !!
THE LOGIC AND APPROACH IS BY ME @luctivud ( UDIT GUPTA )
SOME PARTS OF THE CODE HAS BEEN TAKEN FROM WEBSITES LIKE::
(I Own the code if no link is provided here or I may have missed mentioning it)
DO NOT PLAGIARISE.
TESTCASES:
>>> COMMENT THE STDIN!! CHANGE ONLINE JUDGE !!
'''

Measured memory_bytes: 130244
#include <iostream>

int main(){
int W, H, x, y, r;
int left, right, top, under;

std::cin >> W >> H >> x >> y >> r;
left = x - r;
right = x + r;
top = y + r;
under = y - r;
if(left >= 0 && right <= W && top <= H && under >= 0){
std::cout << "Yes" << std::endl;
}
else{
std::cout << "No" << std::endl;
}
}

Measured memory_bytes: 3092
let o = 1 lsl 35
let rec pow_int a n = if n <= 0 then 1 else a * pow_int a (n-1)
let () = Scanf.scanf "%d" @@ fun n ->
  let rec loop x s i =
    if x = 0 then s
    else if (x + o) mod (1 lsl (i+1)) > 0 then
      loop (x - pow_int (-2) i) ("1" ^ s) (i+1)
    else
      loop x ("0" ^ s) (i+1)
  in
  (if n = 0 then "0" else loop n "" 0) |> print_endline

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
const int D = 110;
const int N = 2000000;
int to[D][N];
int main() {
  int n;
  ll k;
  cin>>n>>k;
  for(int i=1; i<=n; i++){
    cin>>to[0][i];
  }
  rep(i,D-1){
    for(int j=1; j<=n; j++){
      to[i+1][j] = to[i][to[i][j]];
    }
  }
  int now_town = 1;
  int tmp = -1;
  do{
    tmp++;
    if(k%2==1){
      now_town=to[tmp][now_town];
    }
    k /= 2;
  }while(k!=0);
  cout<<now_town<<endl;
}

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

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

//#define int long long
//signed main(){
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin >> n;
    cout << n*800-(n/15)*200 << "\n";

    return 0;
}

Measured memory_bytes: 3636
#include<cstdio>
#include<utility>
#include<algorithm>

using namespace std;

typedef pair<int, int> P;

long long a[100100];
int N;

void input(){
	scanf("%d", &N);
	for(int i = 0; i < N; ++i){
		scanf("%lld", a + i);
	}
}

int req[100100];
bool must[100100];

int calc(int x){
	long long tmp = 1;
	for(int i = 0; i < x; ++i){
		if(tmp >= x) return i;
		tmp *= 2;
	}
	return -1;
}

int solve(){
	for(int i = 0; i < N; ++i){
		req[i] = calc(a[i]);
		int tmp = a[i] & (a[i] - 1);
		if(tmp == 0) must[i] = false;
		else must[i] = true;
	}
	int cur = 0;
	int ans = 0;
	for(int i = 0; i < N; ++i){
		if(cur < req[i]){
			ans += (req[i] - cur);
			cur = req[i];
		}else if(cur == req[i]){
			if(must[i]){
				cur = req[i] - 1;
			}
		}else{
			if(must[i]){
				cur = req[i] - 1;
			}else{
				cur = req[i];
			}
		}
	}
	return ans;
}
	
/*
int field[40][100100];

int calc(int x){
	long long tmp = 1;
	for(int i = 0; i < x; ++i){
		if(tmp >= x){
			return i;
		}
		tmp *= 2;
	}
	return -1;
}

int calcL(int *a){
	int ans = 0;
	int st = 0;
	for(int i = 0; i < N; ++i){
		if(a[i] == 0){
			if(st == 2){
				ans++;
			}
			st = 0;
		}else if(a[i] == 1){
			// nothing
		}else{
			st = 2;
		}
	}
	if(st == 2) ans++;
	return ans;
}

int solve(){
	for(int i = 0; i < N; ++i){
		int l1 = calc(a[i]);
		int l2 = a[i] - 1;
		for(int j = 0; j <= l1; ++j){
			field[j][i] = 2;
		}
		for(int j = l1 + 1; j <= min(l2, 35); ++j){
			field[j][i] = 1;
		}
		for(int j = l2 + 1; j < 40; ++j){
			field[j][i] = 0;
		}
	}
	int ans = 0;
	for(int i = 1; i < 40; ++i){
		int tmp = calcL(field[i]);
		ans += tmp;
	}
	return ans;
}
*/
int main(){
	input();
	int ans = solve();
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 1408
#include<iostream>
#include<cstring>
using namespace std;
const int A = 1e6;
int coont[A+1];
bool valid[A+1];
int main()
{
	memset(coont,0,sizeof coont);
	memset(valid,true,sizeof valid);

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

	for(int k = 1; k <= A; k++)
		if(coont[k])
		{
			for(int m = 2*k; m <= A; m += k)
				valid[m] = false;
			if(coont[k] > 1)
				valid[k] = false;
		}
		

	int ans = 0;
	for(int k = 1; k <= A; k++)
		if(valid[k])
			ans += coont[k];
	cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 8072
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector< vector<int> > VVI;
typedef vector< vector<int> > VVL;
typedef pair<int,int> PII;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define pb push_back
#define mp make_pair

int main(){
  string S;
  cin>>S;
  int F=0;
  rep(i,S.size()){
    if(i) if(S[i-1]==S[i]){
      cout<<i<<" "<<i+1<<endl;
      return 0;
    }
  }
  rep(i,S.size()){
    if(i>1) if(S[i-2]==S[i]){
      cout<<i-1<<" "<<i+1<<endl;
      return 0;
    }
  }
  cout<<-1<<" "<<-1<<endl;
}

Measured memory_bytes: 512
/**
 *  Author: Wasi Ur Rahman
 *  FROM RMSTU
**/
#include<bits/stdc++.h>
#define  fast           ios::sync_with_stdio(false);cin.tie(0)
using namespace std;
#define  min3(a,b,c) min(a,min(b,c))
#define pi acos(-1.0)
int arr[101];
int main()
{
    fast;
     double t;
     scanf("%lf",&t);
     printf("%.20f\n",pi*2.0*t);
     return 0;
}



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

using namespace std;

int main() {
    int N;
    cin >> N;
    vector<int> left, right;
    vector<int> lr(N);
    for (int i = 0; i < N; i++) cin >> lr[i];
    for (int t : lr) {
        int a;
        cin >> a;
        if (t == 0)
            right.push_back(a);
        else
            left.push_back(a);
    }
    if (min(right.size(), left.size()) == 0)
    {
        cout << 0 << endl;
        return 0;
    }
    sort(right.begin(), right.end());
    sort(left.begin(), left.end());
    cout << right[0] + left[0] << endl;
    return 0;
}


Measured memory_bytes: 3140
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <string>
#include <utility>
#include <map>
using namespace std;
#define rep(i,n) for(int i=1;i<=(int)(n);i++)
#define Rep(i,n) for(int i=0;i<=(int)(n-1);i++)
typedef long long ll;
int dx[]={-1,0,1,0};
int dy[]={0,-1,0,1};
int inf=2020000000;

int N,A,B;

int main() {
	cin>>N>>A>>B;
	if((B-A)%2==0) cout<<"Alice"<<endl;
	else cout<<"Borys"<<endl;
	

	
	return 0;
}


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

int main() {
    int n;cin>>n;
    int a[4];
    rep(i,4)a[i]=0;
    string tmp;
    rep(i,n){
        cin>>tmp;
        if(tmp=="AC")++a[0];
        if(tmp=="WA")++a[1];
        if(tmp=="TLE")++a[2];
        if(tmp=="RE")++a[3];
    }
    
    cout<<"AC x "<<a[0]<<endl;
    cout<<"WA x "<<a[1]<<endl;
    cout<<"TLE x "<<a[2]<<endl;
    cout<<"RE x "<<a[3]<<endl;
    return 0;
}


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

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

using namespace std;

using ll = long long int;

const int MOD_NUM = 1e9 + 7;

int main() {
    // Input
    int N;
    vector<string> S;

    cin >> N;
    S = vector<string>(N);
    rep(i, N) cin >> S[i];

    // Process
    vector<int> cnt(4, 0);

    for (string s : S) {
        if (s == "AC")
            cnt[0]++;
        else if (s == "WA")
            cnt[1]++;
        else if (s == "TLE")
            cnt[2]++;
        else
            cnt[3]++;
    }

    // Output
    cout << "AC x " << cnt[0] << endl;
    cout << "WA x " << cnt[1] << endl;
    cout << "TLE x " << cnt[2] << endl;
    cout << "RE x " << cnt[3] << endl;

    return 0;
}


Measured memory_bytes: 6356
// author::devendra parihar
#include<bits/stdc++.h>
#define ll long long int

using namespace std;


int main(){
		string s;
		cin>>s;
		bool f=false;
		for(int i=0;i<s.size()-1;i++){
			for(int j=i+1;j<s.size();j++)
			if(s[i]!=s[j]){
				f=true;
			}
		}
		if(f==true) cout<<"Yes";
		else cout<<"No";
		return 0;
}			

Measured memory_bytes: 256
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;
import std.ascii;


void main()
{
  writeln(700 + readln.chomp.to!(char[]).count!(x=>x=='o') * 100);
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;
int main(void){
    // Here your code !

int n,a[100];
int b=0;
for(int i=0;i<100;i++){
    a[i]=0;
}

while(cin>>n){
a[n]++;
}

for(int i=0;i<100;i++){
   b=max(b,a[i]);
}
for(int i=0;i<100;i++){
if(b==a[i]) cout<<i<<endl;
}



}

Measured memory_bytes: 1160
#include <cstdint>
#include <iostream>
#include <map>
#include <string>

using namespace std;

int main() {
  int64_t N, A;
  cin >> N;

  map<int64_t, bool> checker;
  string result = "YES";
  for (size_t n = 0; n < N; ++n) {
    cin >> A;
    if (checker.count(A)) {
      result = "NO";
      break;
    }
    checker[A] = true;
  }
  cout << result << endl;
  
  return 0;
}


Measured memory_bytes: 12800
let rec solve acc s l r =
  if r <= l then Some acc
  else if s.[l] = s.[r] then solve acc s (l + 1) (r - 1)
  else if s.[l] = 'x' then solve (1 + acc) s (l + 1) r
  else if s.[r] = 'x' then solve (1 + acc) s l (r - 1)
  else None
let solve s = solve 0 s 0 (String.length s - 1)

let () =
  let s = read_line () in
  solve s
  |> (function None -> -1 | Some x -> x)
  |> Printf.printf "%d\n"


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
template<typename T1, typename T2>
inline bool cmx (T1& a, T2 b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
int main() {
	cin.tie(0); cin.sync_with_stdio(false);
	int n;
	cin >> n;
	vector<long long> s(n);
	for (int i = 0; i < n; i++) {
		cin >> s[i];
	}
	long long ret = 0;
	for (int C = 1; C < n; C++) {
		long long tmp = 0;
		set<int> ckd;
		for (int i = 0; i <= n - 3; i += C) {
			if (ckd.count(i)) break;
			int A = n - 1 - i;
			int B = A - C;
			if (A <= C) break;
			if (A <= B) break;
			if (i == n - 1 - i) break;
			ckd.insert(i);
			ckd.insert(n - 1 - i);
			tmp += s[i] + s[n - 1 - i];
			cmx(ret, tmp);
		}
	}
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 7424
#include<bits/stdc++.h>
using namespace std;
using i64 = int64_t;
void chmin(i64& a,const i64& b){if(a>b)a=b;}
main(){
  i64 n,w;
  cin>>n>>w;
  vector<i64>weight(n),value(n);
  for(int i=0;i<n;++i)cin>>weight[i]>>value[i];
  
  vector<vector<i64> > dp(110,vector<i64>(1010*110,(1LL<<50)));
  dp[0][0]=0;
  for(int i=0;i<n;++i){
    for(int j=0;j<1010*110;++j){
      if(j>=value[i])
        chmin(dp[i+1][j],dp[i][j-value[i]]+weight[i]);
      chmin(dp[i+1][j],dp[i][j]);
    }
  }
  i64 ans=0;
  for(int i=0;i<1010*110;++i){
    if(dp[n][i]<=w)ans=i;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 96640
import sys
sys.setrecursionlimit(10**9)

def mi(): return map(int,input().split())
def ii(): return int(input())
def isp(): return input().split()
def deb(text): print("-------\n{}\n-------".format(text))

INF=10**20
def main():
    N=ii()
    A=list(mi())

    mx = 0
    ans = 0
    for i in range(N):
        if mx > A[i]:
            ans += mx - A[i]
            A[i] = mx
        
        mx = max(mx,A[i])

    print(ans)

        
        






if __name__ == "__main__":
    main()

Measured memory_bytes: 94112
def write(H, W):
    for i in range(H):
        tmp = []
        for j in range(W):
            if i%2==0:
                if j%2==0:
                    tmp.append('#')
                elif j%2==1:
                    tmp.append('.')
            elif i%2==1:
                if j%2==0:
                    tmp.append('.')
                elif j%2==1:
                    tmp.append('#')
        print(*tmp, sep='')
            
            

while True:
    H, W = map(int, input().split())
    if H==0 and W==0:
        break
    write(H, W)
    print('')


Measured memory_bytes: 7048
object Main extends App {
  @scala.annotation.tailrec
  def loop(chars: List[Char], a: Int, b: Int, result: Vector[String]): Vector[String] = chars match {
    case List() => result
    case x::xs => x match {
      case 'a' if 0 < a =>
        loop(xs, a - 1, b, result :+ "Yes")
      case 'a' if 0 < b =>
        loop(xs, 0, b - 1, result :+ "Yes")
      case 'b' if 0 < b =>
        loop(xs, a, b - 1, result :+ "Yes")
      case _ =>
        loop(xs, a, b, result :+ "No")
    }
  }
  val sc = new java.util.Scanner(System.in)
  val _, a, b = sc.nextInt()
  val s = sc.next().toCharArray.toList
  loop(s, a, b, Vector.empty).foreach(println)
}

Measured memory_bytes: 51968
function Main(input){
  input = input.split('\n').map(num => Number(num));
  var a = input[0];
  var b = input[1];
  var h = input[2];

    var area = ((a + b) * h) / 2;


  console.log(area);


}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 9420
#include <algorithm>
#include <cstring>
#include <cstdio>
struct point
{
	int x, y; 
	inline bool operator <(const point &a) const
	{
		return x < a.x; 
	}
} arr[300005], st1[300005], st2[300005]; 
int mx[1200005], lazy[1200005]; 
void modify(int u, int l, int r, int L, int R, int x)
{
	if (L <= l && r <= R)
	{
		mx[u] += x; 
		lazy[u] += x; 
		return; 
	}
	int m = l + r >> 1; 
	if (L <= m)
		modify(u << 1, l, m, L, R, x); 
	if (m < R)
		modify(u << 1 | 1, m + 1, r, L, R, x); 
	mx[u] = std::max(mx[u << 1], mx[u << 1 | 1]) + lazy[u]; 
}
int work(int w, int h, int n)
{
	memset(mx, -0x3f, sizeof(mx)); 
	memset(lazy, 0, sizeof(lazy)); 
	std::sort(arr, arr + n); 
	int tp1 = 0, tp2 = 0, ans = 0; 
	for (int i = 0; i < n - 1; i++)
	{
		int &tp = arr[i].y <= h / 2 ? tp1 : tp2, nxt = i - 1; 
		auto *st = arr[i].y <= h / 2 ? st1 : st2;
		while (tp && ((st[tp - 1].y < arr[i].y) ^ (arr[i].y > h / 2)))
		{
			modify(1, 0, n - 1, st[tp - 1].x, nxt, (st[tp - 1].y - arr[i].y) * (arr[i].y <= h / 2 ? 1 : -1)); 
			nxt = st[--tp].x - 1; 
		}
		if (nxt != i - 1)
			st[tp++] = {nxt + 1, arr[i].y}; 
		st1[tp1++] = {i, 0}; 
		st2[tp2++] = {i, h}; 
		modify(1, 0, n - 1, i, i, h - arr[i].x - mx[0]); 
		ans = std::max(ans, mx[1] + arr[i + 1].x); 
	}
	return ans; 
}
int main()
{
	// freopen("ARC063-F.in", "r", stdin); 
	int w, h, n; 
	scanf("%d%d%d", &w, &h, &n); 
	for (int i = 0; i < n; i++)
		scanf("%d%d", &arr[i].x, &arr[i].y); 
	arr[n++] = {0, 0}; 
	arr[n++] = {w, h}; 
	int ans = work(w, h, n); 
	for (int i = 0; i < n; i++)
		std::swap(arr[i].x, arr[i].y); 
	ans = std::max(ans, work(h, w, n)); 
	printf("%d\n", ans << 1);
	return 0; 
}


Measured memory_bytes: 16640
sx, sy, tx, ty = map(int, input().split())

if sy == ty:
    #  +---+
    #  |   |
    # -s---t-
    #  |   |
    #  +---+
    # l = 4
    l = tx - sx
    print("U" + "R"*l + "D" + "L"*l + "D" + "R" *
          l + "U" + "RDDL" + "L" * l + "LUUR")
elif sx == tx:
    l = ty - sy
    print("L" + "U"*l + "R" + "D"*l + "R" + "U" *
          l + "L" + "URRD" + "D" * l + "DLLU")
else:
    lx = tx - sx
    ly = ty - sy
    print("R"*lx + "U"*ly + "L"*lx + "D"*ly + "DR" + "R" *
          lx + "U" * ly + "UL" + "UL" + "L"*lx + "D"*ly + "DR")

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

namespace AOJ
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            for (int i = 0; i < n; i++)
            {
                string str = Console.ReadLine();
                string[] val = str.Split(' ');
                int[] arr = new int[3];
                arr[0] = int.Parse(val[0]) * int.Parse(val[0]);
                arr[1] = int.Parse(val[1]) * int.Parse(val[1]);
                arr[2] = int.Parse(val[2]) * int.Parse(val[2]);
                Array.Sort(arr);
                if (arr[0] + arr[1] == arr[2])
                {
                    Console.WriteLine("YES");
                }
                else
                {
                    Console.WriteLine("NO");
                }
            }
        }
    }
}

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

using namespace std;
using ll = long long;

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define debug(x) cout << #x << ": " << x << endl;

bool ok(int node, vector<bool> used, vector<int> G[]) {
    bool flg = true;
    for (auto to : G[node]) {
        if (used[to])continue;
        flg = false;
    }
    return flg;
}

int main() {
    int N, M;
    cin >> N >> M;
    vector<int> G[100010];
    for (int i = 0; i < M; i++) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        G[a].emplace_back(b);
        G[b].emplace_back(a);
    }

    deque<int> dq;
    vector<bool> used(N, false);
    dq.push_back(0);
    used[0] = true;
    for(auto to : G[0]){
        if(used[to])continue;
        dq.push_back(to);
        used[to]=true;
        break;
    }

    while ((!ok(dq.front(), used, G))) {
        for (auto to : G[dq.front()]) {
            if (used[to])continue;
            dq.push_front(to);
            used[to] = true;
            break;
        }
    }
    while((!ok(dq.back(), used, G))){
        for (auto to : G[dq.back()]) {
            if (used[to])continue;
            dq.push_back(to);
            used[to] = true;
            break;
        }
    }

    cout << dq.size() << endl;
    for (auto i = dq.begin(); i != dq.end(); i++) {
        if (i == dq.begin())cout << *i + 1;
        else cout << " " << *i + 1;
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 6784
#include <bits/stdc++.h>
using namespace std;
long long n,t,ans,a[200005],danh;
int main()
{
 cin>>n;
 danh=0;
 cin>>a[1];
 if(a[1]!=0) danh=-1;
 for(int i=2;i<=n;i++)
   {
   	cin>>a[i];
   	if(a[i]-a[i-1]>=2) danh=-1;
   	  else 
   	  {
   	  	 if(a[i]<=a[i-1]) ans+=a[i];
   	  	   else ans++;
	 }
   }
  if(danh==0) cout<<ans;
    else cout<<-1;
}

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

//マクロ
#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,s,e) for(int i=(int)(s); i<(int)(e); ++i)
#define RFOR(i,s,e) for(int i=(int)(e)-1; i>=(int)(s); --i)

#define All(a) (a).begin(),(a).end()

//定数
#define INF 1e9
#define MOD (int)(1e9+7)

typedef long long ll;
typedef unsigned long long ull;
using namespace std;

//とりあえず書いておく変数
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };

//今回の変数

//使用する関数

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

	int len = s.size();
	int ans = 0;
	bool f = false;
	REP(i, len) {
		if (f) {
			if (s[i] == s[i - 1]) {
				if (i == len - 1)break;
				i++;
				f = false;
			}
		}
		else {
			f = true;
		}
		ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 1152
//ABC154 C

#include <bits/stdc++.h>
using namespace std;

int N,K;
int p[200000];
double Ep[1001];

int main() {
  cin >> N >> K;

  for(int i=0;i<N;i++){
    scanf("%d",&p[i]);
  }

  double max_Ep = 0;
  for(int i=0;i<K;i++){
    max_Ep += (p[i]-1)*0.5+1;
  }
  double tmp_A,tmp_B;
  double tmp_Ep = max_Ep;
  for(int i=K;i<N;i++){
    tmp_A = (p[i-K]-1)*0.5+1;
    tmp_B = (p[i]-1)*0.5+1;
    tmp_Ep = tmp_Ep - tmp_A + tmp_B;
    max_Ep = max(max_Ep,tmp_Ep);
  }

  printf("%lf\n",max_Ep);
}


Measured memory_bytes: 1024
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>
#include <deque>
#include <numeric>

using namespace std;

#define mod 1000000007

int main()
{
	long long int n, a, b;
	cin >> n >> a >> b;
	long long int ans = (n / (a + b)) * a;
	ans += min((n % (a + b)), a);
	cout << ans << endl;
}

Measured memory_bytes: 384
o=input()
e=input()
O=len(o)
E=len(e)
a=[]
if O==E:
    for i in range(O):
        a.append(o[i]+e[i])
    b=''.join(a)
    print(b)
else:
    for i in range(E):
        a.append(o[i]+e[i])
    a.append(o[O-1])
    b=''.join(a)
    print(b)

Measured memory_bytes: 9060
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.*;

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

    static class Task {
        static int[][] D = {
        		{1, 1, 1},
        		{-1, 1, 1},
        		{1, -1, 1},
        		{1, 1, -1},
        		{1, -1, -1},
        		{-1, 1, -1},
        		{-1, -1, 1},
        		{-1, -1, -1},
        };
        
        int N, M;
        long[][] cake;
        long ans = 0;
        
        void solve(InputReader in, PrintWriter out) {
        	N = in.nextInt();
        	M = in.nextInt();
        	
        	cake = new long[N][3];
        	for (int i = 0; i < N; ++i) {
        		cake[i][0] = in.nextLong();
        		cake[i][1] = in.nextLong();
        		cake[i][2] = in.nextLong();
        	}
        	
        	for (int[] d : D) {
        		Arrays.sort(cake, (a, b) -> 
        			Long.signum(
        					(b[0]*d[0] + b[1]*d[1] + b[2]*d[2]) - 
        					(a[0]*d[0] + a[1]*d[1] + a[2]*d[2]))
        		);
        		long cur = 0;
        		for (int i = 0; i < M; ++i) {
        			cur += cake[i][0]*d[0] + cake[i][1]*d[1] + cake[i][2]*d[2];
        		}
        		ans = Math.max(cur, ans);
        	}
        	
        	out.println(ans);
        }
    }

    static class InputReader {
        BufferedReader reader;
        StringTokenizer tokenizer;

        InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream));
            tokenizer = null;
        }

        String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

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

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

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


Measured memory_bytes: 28628
def isX(xy1,xy2):
    ax,ay,bx,by = xy1; cx,cy,dx,dy = xy2
    tc=(ax-bx)*(cy-ay)+(ay-by)*(ax-cx)
    td=(ax-bx)*(dy-ay)+(ay-by)*(ax-dx)
    return tc*td < 0
    
def ip(xy1,xy2):
    ax,ay,bx,by = xy1; cx,cy,dx,dy = xy2
    dn = ((by-ay)*(dx-cx)-(bx-ax)*(dy-cy))*1.0
    x = ((cy*dx-cx*dy)*(bx-ax)-(ay*bx-ax*by)*(dx-cx))/dn
    y = ((cy*dx-cx*dy)*(by-ay)-(ay*bx-ax*by)*(dy-cy))/dn
    return x,y

while 1:
    xy1 = map(int,raw_input().split())
    if xy1.count(0) == 4: break
    xy2 = map(int,raw_input().split())
    xy3 = map(int,raw_input().split())
    if isX(xy1,xy2) and isX(xy2,xy3) and isX(xy3,xy1):
        x1,y1 = ip(xy1,xy2); x2,y2 = ip(xy2,xy3); x3,y3 = ip(xy3,xy1)
        S = abs(x1*(y2-y3)+x2*(y3-y1)+x3*(y1-y2))/2.0
        if   S >= 1900000: print "dai-kichi"
        elif S >= 1000000: print "chu-kichi"
        elif S >= 100000 : print "kichi"
        elif S > 0       : print "syo-kichi"
        else             : print "kyo"
    else:
        print "kyo"

Measured memory_bytes: 4324
#include <iostream>

//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <tuple>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s)
{
    int v;
    istringstream sin(s);
    sin >> v;
    return v;
}
template <class T>
inline string toString(T x)
{
    ostringstream sout;
    sout << x;
    return sout.str();
}

//math
//-------------------------------------------
template <class T>
inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort((c).begin(), (c).end())

//repetition
//------------------------------------------
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0, sizeof(a))

//debug
// #define dump(x) cerr << #x << " = " << (x) << endl;
// #define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
//                       << " " << __FILE__ << endl;

int main()
{
    int n;
    cin >> n;
    cout << (n * n * n) << endl;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
     
int main() {
  int N;
  int64_t K;
  cin >> N >> K;
  
  vector<int> inp(N + 1);
  
  for(int i = 1 ; i <= N ; i++){
    cin >> inp.at(i);
  }
  
  vector<int> map(N + 1);
  vector<bool> flag(N + 1,false);
  map.at(0) = 1;
  
  int now = 1;
  
  int loop_result = -1;
  
  for(int i = 1 ; i <= N ; i++){
    if(flag.at(now)){
      //ループ
      loop_result = i;
      break;
    }
    flag.at(now) = true;
    
    map.at(i) = inp.at(now);
    now = inp.at(now);
  }
  
  if(loop_result == -1){
    //ループがなかった場合
    if( K >= N ){
      K %= N;
    }
    
    int result = map.at(K);
    cout << result << endl;
  }else{
    //ループがあった場合
    
    int loop_start = 0;
    
    for(int i = 1; i <= N ; i++){
      if(map.at(i) == inp.at(now)){
        loop_start = i;
        break;
      }
    }
    
    
    if(loop_result > K){
      int result = map.at(K);
      cout << result << endl;
    }else{
      K -= loop_start;
      K %= (loop_result - loop_start);
      int result = map.at(K + loop_start);
      cout << result << endl;
    }
  }
      
}

Measured memory_bytes: 4820
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;
typedef long long int ll;
/*
vector<vector<long long>> comb(int n,int r){
    vector<vector<long long>> v(n+1,vector<long long>(n+1,0));
    for(int i=0;i<v.size();i++){
        v[i][0] = 1;
        v[i][i] = 1;
    }
    for(int j=1;j<v.size();j++){
        for(int k=1;k<j;k++){
            v[j][k] = (v[j-1][k-1] + v[j-1][k]);
        }
    }
    return v;
}
*/
int main(){
    int n;
    vector<string> s;
    //input
    cin>>n;
    for(int i=0;i<n;i++){
        string t;
        cin>>t;
        s.push_back(t);
    }


    for(int i=0;i<n;i++){
        sort(s[i].begin(),s[i].end());
    }
    sort(s.begin(),s.end());
    long long int ct =0;

    map<string,int> m;
    for(int i=0;i<n;i++){
        auto itr = m.find(s[i]);
        if(itr != m.end()){
            ct+=m[s[i]];
            m[s[i]] = m[s[i]]+1;
        }else{
            m[s[i]]=1;
        }
    }
    cout << ct <<endl;
}
/*
    for(int i=0;i<n;i++){
        cout << s[i] << endl;
    }
    */
    /*
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            if(s[i]==s[j]){
                ct++;
            }
        }
    }*/
    /*
    int i=0,j=1;
    while(i<n && j<n){
        while(s[i]==s[j++]);
        for(int k=1;k<j-i;k++){
            ct++;
        }
        i=j++;
    }
    */
    /*
    int start=0,end=1;
    vector<vector<long long>> v;
    while(end < n){
        bool flag=false;
        while(end < n && s[start] == s[end]){
            end++;
            flag = true;
        }
        if(flag){
//            cout << "start:"<<start<< " end:"<<end<<endl;
            v = comb(end-start,2);
            ct += v[end-start][2];
//            cout << v[end-start][2] << endl;
        }
        start = end;
        end++;
    }
    */



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

public class Main {

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		ArrayList array = new ArrayList();
		int b = 0;
		int c = 0;
		int sum = 0;
		for (int i = 0; i < a; i++) {
			b = sc.nextInt();
			c = sc.nextInt();
			array.add(c-b+1);
		}
		for(int j =0;j<array.size();j++){
			sum += (int)array.get(j);
		}
		System.out.println(sum);
	}
}

Measured memory_bytes: 26224
#include<stdio.h>
long long MIN(long long a,long long b){return a<b?a:b;}
long long MAX(long long a,long long b){return a<b?b:a;}
int main(){
  long long n,m,t,a[100010],b[100010],c[100010],i;
  scanf("%lld %lld %lld",&n,&t,&m);
  for(i=0;i<n;i++)scanf("%lld %lld",&a[i],&b[i]);
  if(b[0]==2)c[0]=a[0]-t;
  for(i=1;i<n;i++){
    if(b[i]==1)continue;
    if(b[i-1]==1)c[i]=MAX(a[i]-t,(a[i-1]+a[i])/2);
    else         c[i]=MAX(a[i]-t,c[i-1]);
  }
  if(b[n-1]==1)c[n-1]=a[n-1]+t;
  for(i=n-2;i>-1;i--){
    if(b[i]==2)continue;
    if(b[i+1]==2)c[i]=MIN(a[i]+t,(a[i+1]+a[i])/2);
    else         c[i]=MIN(a[i]+t,c[i+1]);
  }
  while(m--){
    scanf("%lld",&i);
    printf("%lld\n",c[i-1]);
  }
  return 0;
}

Measured memory_bytes: 2940
#import<bits/stdc++.h>
#define endl '\n'
using namespace std;
typedef long long LL;
LL i,j,k,m,n,a[100005];
string s;
main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin>>s;
	n=s.size();
	for(;s[i];i++)
	{
		if(s[i]^s[n-i-1])
		{
			cout<<"No";
			return 0;
		}
	}
	n/=2;
	for(i=0;i<n;i++)
	{
		if(s[i]^s[n-i-1]||s[n+i+1]^s[n+n-i])
		{
			cout<<"No";
			return 0;
		}
	}
	cout<<"Yes";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
//#define f(i,a,n) for(ll i=a;i<n;i++)
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll isPrime(int n) 
{ 
    // Corner cases 
    if (n <= 1) 
        return 1; 
    if (n <= 3) 
        return 2; 

    // This is checked so that we can skip 
    // middle five numbers in below loop 
    if (n % 2 == 0 || n % 3 == 0) 
        return 1; 

    for (int i = 5; i * i <= n; i = i + 6) 
        if (n % i == 0 || n % (i + 2) == 0) 
            return 1; 

    return 2; 
} 

ll fact(ll n){ll res = 1;for (ll i = 2; i <= n; i++)res = res * i,res%=1000000007; 
    return res; } 
 
 int gcd(int a, int b) 
{ 
    if (b == 0) 
        return a; 
    return gcd(b, a % b); 
} 
  
 
ll findlcm(ll arr[], int n) 
{ 
   
    ll ans = arr[0]; 
  
    
    for (int i = 1; i < n; i++) 
        ans = (((arr[i] * ans)) / 
                (gcd(arr[i], ans))); 
  
    return ans; 
} 
 
 
int main() 
{
    fast;
    ll t=1;
    //cin>>t;
    while(t--)
    {
        string s;
        cin>>s;
        ll a=s.size();
        for(ll i=0;i<a;i++)
        {
            if(i%2==0)
            {
                cout<<s[i];
            }
        }

    }
    return 0;
}


Measured memory_bytes: 3680
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define each(a,b) for(auto (a): (b))
#define all(v) (v).begin(),(v).end()
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define spair(p) cout<<#p<<": "<<p.fi<<" "<<p.se<<endl
#define svec(v) cout<<#v<<":";rep(kbrni,v.size())cout<<" "<<v[kbrni];cout<<endl
#define sset(s) cout<<#s<<":";each(kbrni,s)cout<<" "<<kbrni;cout<<endl
#define smap(m) cout<<#m<<":";each(kbrni,m)cout<<" {"<<kbrni.first<<":"<<kbrni.second<<"}";cout<<endl

using namespace std;

typedef pair<int,int>P;

const int MAX_N = 13;

double dp[(1 << MAX_N)];
double gu[(1 << MAX_N)],ch[(1 << MAX_N)],pa[(1 << MAX_N)];
bool ok[(1 << MAX_N)];

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    n--;
    int a;
    cin >> a;
    vector<int> vec(n);
    vector<double> r(n),p(n),s(n);
    rep(i,n){
        int x,y,z;
        cin >> vec[i] >> x >> y >> z;
        r[i] = x / 100.0,p[i] = y / 100.0,s[i] = z/100.0;
    }
    rep(i,(1<<n)){
        int mx = a;
        rep(j,n){
            if(i & (1 << j)){
                mx = max(mx,vec[j]);
            }
        }
        if(mx == a){
            ok[i] = true;
        }
    }
    rep(i,(1<<n)){
        double res1 = 1.0,res2 = 1.0,res3 = 1.0;
        rep(j,n){
            if(i & (1 << j)){
                res1 *= r[j],res2 *= p[j],res3 *= s[j];
            }
        }
        gu[i] = res1,ch[i] = res3,pa[i] = res2;
    }
    dp[0] = 1.0;
    for(int i=1;i<(1<<n);i++){
        double g=0,c=0,p=0;
        for(int j=i;j>=0;j=(j-1)&i){
            if(j != i){
                g += gu[j]*ch[i^j]*dp[j];
                c += ch[j]*pa[i^j]*dp[j];
                p += pa[j]*gu[i^j]*dp[j];
            }
            if(j == 0){
                break;
            }
        }
        if(ok[i]){
            double mg=0,mc=0,mp=0;
            for(int j=i;j>=0;j=(j-1)&i){
                if(j != i){
                    mg += gu[j]*pa[i^j];
                    mc += ch[j]*gu[i^j];
                    mp += pa[j]*ch[i^j];
                }
                if(j == 0){
                    break;
                }
            }
            for(int j=i;j>=0;j=(j-1)&i){
                if(j != i){
                    mg += gu[j]*ch[i^j];
                    mc += ch[j]*pa[i^j];
                    mp += pa[j]*gu[i^j];
                }
                if(j == 0){
                    break;
                }
            }
            g += 1-mg,c += 1-mc,p += 1-mp;
        }
        dp[i] = max(g,max(c,p));
    }
    printf("%.12lf\n",dp[(1 << n)-1]);
    return 0;
}



Measured memory_bytes: 3504
from collections import Counter
N, M = map(int,input().split())
A = list(map(int,input().split()))
B = [A[0] % M]
for i in range(N-1):
    B.append((B[-1]+A[i+1])%M)
count = Counter(B)
count[0] += 1
ans = 0
for i in count.values():
    ans += i * (i - 1) // 2
print(ans)

Measured memory_bytes: 16556
using System;

namespace AtCoderABC130B
{
    class Program
    {
        static void Main(string[] args)
        {
            int ans = 1;

            string[] s = Console.ReadLine().Split(' ');

            int N = int.Parse(s[0]);
            int X = int.Parse(s[1]);

            s = Console.ReadLine().Split(' ');

            int D = 0;

            for (int i = 0; i < N; i++)
            {
                D += int.Parse(s[i]);

                if (D > X)
                    break;

                ans++;
            }

            Console.WriteLine(ans.ToString());
        }
    }
}


Measured memory_bytes: 11092
#include<bits/stdc++.h>
//#define int long long
#define loop(i, a, b) for(int i = a; i < b; i++)
#define rep(i, a) loop(i, 0, a)
#define all(a) (a).begin(),(a).end()
using namespace std;
const int MOD = 1e9 + 7, INF = 1e9;
using vi = vector <int>;
using vvi = vector <vi>;
//g++ -std==c++14

int main(){
	int n;
	cin >> n;
	vi l(2 * n);
	rep(i, 2 * n)cin >> l[i];
	sort(all(l));
	int cnt = 0;
	for(int i = 0; i < 2 * n; i += 2)
		cnt += min(l[i] , l[i + 1]);
	cout << cnt << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)

int main()
{
    int N, K, C;
    cin >> N >> K >> C;
    string S;
    cin >> S;

    vector<int> v1, v2;
    int prv = -N - C;
    REP(i, N) if (S[i] == 'o' and i > prv + C) v1.push_back(i), prv = i;
    prv = N + C + 2;
    IREP(i, N) if (S[i] == 'o' and i < prv - C) v2.push_back(i), prv = i;
    reverse(v2.begin(), v2.end());
    if (v1.size() > K ) {
        puts("");
        return 0;
    }
    REP(i, v1.size()) if (v1[i] == v2[i]) printf("%d\n", v1[i] + 1);
}


Measured memory_bytes: 3448
#include<stdio.h>
int degree(int x){
  int i,count;
  count=0;
  for(i=1;i<100000;i=i*10){
    if(x%i==x) break;
    count++;
  }
  return count;
}

int tasizann(int x,int y){
  int i,ten,count;
  count = 0;
  ten=1;
  for(i=y;i>1;i--){
    ten=ten*10;
  }
  for(i=ten;i>0;i=i/10){
    count=count + (x/i);
    x=x%i;
  }
  return count;
  
}

int main(){
  int  A,B,N,a,b,sum1,sum2,i,k;
  scanf("%d",&N);
  b=100000;
  A=N-1;
  B=1;
  while(A>=B){
    sum1=tasizann(A,degree(A));
    sum2=tasizann(B,degree(B));
    a=sum1+sum2;
    if(b>a) b=a;
    A--;
    B++;
    }
  printf("%d",b);

  return 0;
}

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

int main() {
  int n;cin>>n;
  map<string,int> mp;
  rep(i,n){
    string s;cin>>s;
    mp[s]++;
  }
  for(string s:{"AC","WA","TLE","RE"}){
    cout<<s<<" x "<<mp[s]<<endl;
  }
}

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

int main() {
    int n, s;
    cin >> n;
    int sum = 0, a = 101;
    for (int i = 0; i < n; i++) {
        cin >> s;
        sum += s;
        if (s%10 != 0) a = min (a, s);
    }
    if (sum%10 != 0) cout << sum << endl;
    else if (a == 101) cout << 0 << endl;
    else cout << sum-a << endl;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
//#define int long long
#define fo(a,b) for(int a=0;a<b;a++)
#define Sort(a) sort(a.begin(),a.end())
#define rev(a) reverse(a.begin(),a.end())
#define fi first
#define se second
#define co(a) cout<<a<<endl
#define sz size()
#define bgn begin()
#define en end()
#define pb(a) push_back(a)
#define pop pop_back
#define V vector
#define P pair
#define V2(a,b,c) V<V<int>> a(b,V<int>(c))
#define V2a(a,b,c,d) V<V<int>> a(b,V<int>(c,d))
#define incin(a) int a; cin>>a
//#define min min<int>
//#define max max<int>
template<class T>
 void cou(vector<vector<T>> a){
  int b=a.size();
  int c=a[0].size();
  fo(i,b){
    fo(j,c){
      cout<<a[i][j];
      if(j==c-1)
        cout<<endl;
      else
        cout<<' ';
    }
  }
}
/*template<>
 void cou(vector<vector<char>> a){
  int b=a.size();
  int c=a[0].size();
  fo(i,b){
    fo(j,c){
      cout<<a[i][j];
      if(j==c-1)
        cout<<endl;
      else
        cout<<' ';
    }
  }
}*/
 int wari(int a,int b) {
   if(a%b==0)
     return a/b;
   else
     return a/b+1;
 }
 int keta(int a){
  double b=a;
  b=log10(b);
  int c=b;
  return c+1;
 }
 int souwa(int a){
  return a*(a+1)/2;
 }
 int lcm(int a,int b){
  int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return d*e/f;
    }
  int gcm(int a,int b){
      int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return f;
  }
 bool prime(int a){
   if(a<2)
     return false;
   else if(a==2)
     return true;
   else if(a%2==0)
     return false;
   double b=sqrt(a);
    for(int i=3;i<=b;i+=2){
      if(a%i==0){
        return false;
      }
    }
   return true;
 }
struct Union{
  vector<int> par;
  Union(int n){
	par= vector<int>(n, -1);
  }
  int find(int x){
    if(par[x]<0)
      return x;
    else
      return par[x]=find(par[x]);
  }
  bool same(int a,int b){
    return find(a)==find(b);
  }
  int Size(int a){
    return -par[find(a)];
  }
  void unite(int a,int b){
    a=find(a);
    b=find(b);
    if(a==b)
      return;
    if(Size(b)>Size(a))
      swap<int>(a,b);
    par[a]+=par[b];
    par[b]=a;
  }
};
int ketas(int a){
  string b=to_string(a);
  int c=0;
  fo(i,keta(a)){
    c+=b[i]-'0';
  }
  return c;
}
/*struct aa{
	vector<int> gt;
  aa(int n){
	gt= vector<int>(n, 1);
  }
	void c(V<int> d,int b){
	if(d[b]==0){
		gt[d[b]-1]++;
		gt[gt.sz-1]++;
	}
	else{
		gt[d[b]-1]++;
		c(d,d[d[b]]-1);
	}
}
void cok(int a){
	cout<<gt[a-1]<<endl;
	fo(i,a-1)
	cout<<gt[i]<<endl;
}
};
*/
signed main(){
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	if(abs(a-c)<=d||(abs(a-b)<=d&&abs(b-c)<=d))
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define erep(i,a,n) for(int i = a;i<=n;i++)
typedef long long ll;
#define int long long
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstring vector<string>
#define vdouble vector<double>
#define vll vector<ll>:
#define vbool vector<bool>
#define INF 1101010101010101010
#define MOD 1000000007
#define P pair<int,int>
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }

signed main(){
  int a,s,d,f,g;
  cin >> a >> s >> d >> f >> g;
  if(a == 0) cout << 1 << endl;
  if(s == 0) cout << 2 << endl;
  if(d == 0) cout << 3 << endl;
  if(f == 0) cout << 4 << endl;
  if(g == 0) cout << 5 << endl;
}

Measured memory_bytes: 3580
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1000000007;

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//my functions
int roundup(int a,int b) {return ((a + (b - 1)) / b);}
int roundoff(int a,int b) {return ((a + (b / 2)) / b);}


int main(int argc, char const* argv[])
{
	int n,k;
	cin >> n >> k;
	//array<int,100000> a;
	//int min;
	//for (int i = 0; i < n; i++) {
	//	cin >> a[i];
	//	if (a[i] == 1) {
	//		min = i;
	//	}
	//}
	n -= k;
	cout << roundup(n,k-1) + 1 << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout <<(#x)<<" is "<<(x)<<endl
#define debug cout <<"hi"<<endl
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
const int MOD=1e9+7;
const int INF32=1<<30;
const ll INF64=1LL<<60;

int main(){
  string s; cin >>s;
  cout <<s[0]<<s[1]<<s[2];
return 0;}

Measured memory_bytes: 3624
import java.util.*;
import java.io.*;

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

    for(int i = 0; i < n; i++)  d[i] = scan.nextInt();

    Arrays.sort(d);
    for(int i = 1 ; i < n; i++){
      if(d[i-1] != d[i])
        cnt++;
    }

    System.out.println(cnt);
  }
}


Measured memory_bytes: 23252
#include <iostream>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <limits>
#include <numeric>
#include <algorithm>
#include <functional>

#include <set>

using namespace std;

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

	string S;
	cin >> S;

	set<char> check;

	for (int i = 0; i < S.size(); i++)
	{
		check.insert(S[i]);
	}

	if (check.size() == 2)
	{
		cout << "Yes";
	}
	else
	{
		cout << "No";
	}

	return 0;
}


Measured memory_bytes: 3624