akhauriyash/Code-Regression huggingface dataset:
def main():
	N,Q=map(int,input().split())
	S=input()
	A=[0]*N
	# 累積和
	for i in range(1,N):
		A[i]=S[i-1:i+1]=="AC"
		A[i]=A[i]+A[i-1]
	# [l:r)区間の総和を求める
	for i in range(Q):
		l,r=map(int,input().split())
		print(A[r-1]-A[l-1])
if __name__=='__main__':
	main()

Measured memory_bytes: 7748
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define Int int32_t
#define all(c) c.begin(), c.end()
#define FAST ios_base::sync_with_stdio(false) , cin.tie(NULL);
#define pii pair< int , int >
#define pb push_back
#define F first
#define S second
#define endl "\n"
#define bitcnt(n) __builtin_popcountll(n)
#define setpre(n) cout << fixed << setprecision(n)
#define tr(c) for(auto x : c )cout << x << " ";
#define ol(c, s, e) for(int pos=s; pos<e ; pos++) cout << c[pos] << " ";
#define PI acos(-1LL)

#ifndef CF
string to_string(const string& s){
    return '"' + s + '"';
}
string to_string(const char* s) {
    return to_string((string) s);
}
string to_string(bool b) {
    return (b ? "true" : "false");
}
template <typename A, typename B>
string to_string(pair<A, B> p) {
    return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename T>
string to_string(vector<T> v){
    bool first = true;
    string res = "{";
    for(const auto& x: v){
        if(!first) res+=", ";
        first = false;
        res+=to_string(x);
    }
    res+="}";
    return res;
}
void bug() { cerr << endl; }
template<typename Head, typename... Tail>
void bug(Head H, Tail... T) {
    cerr << " " << to_string(H);
    bug(T...);
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", bug(__VA_ARGS__);
#endif

const int M = 1000000007;
const int N = 2e6 + 5;
const long long INF = 1e18 + 37;

void solve() {
    int n;
    cin >> n;
    vector<int> ans(10005, 0);
    for(int i=1; i<=105; i++){
        for(int j=1;j<=105;j++){
            for(int k=1; k<=105; k++){
                if(i*i+j*j+k*k+i*j+j*k+k*i < 10005){
                    ans[i*i+j*j+k*k+i*j+j*k+k*i]++;
                }
            }
        }
    }
    for(int i=1; i<=n; i++){
        cout << ans[i] << endl;
    }
}

signed main(){
    FAST
    int tc = 1;
//    TODO : check for tc
//    cin >> tc;
    for (int t = 1; t <= tc; t++) {
        solve();
    }
}


Measured memory_bytes: 3696
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
 
#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
 
using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PI;
const ll mod = 1e9 + 7;
 

 
int main(void){
	int N;
	cin>>N;
	vector<ll> a(N*3);
	for(int i=0;i<N*3;i++)cin>>a[i];
	sort(a.begin(),a.end());
	//for(int i=0;i<N*3;i++)cout<<a[i];
	ll ans=0;
	for(int i=0;i<N;i++){
		ans+=a[N*3-i*2-2];
	}	
	cout<<ans<<endl;
}

Measured memory_bytes: 2560
#include <iostream>
#include <math.h>
#include <numeric>
#include <vector>
#include <map>
#include <algorithm>
#include <queue>
#include <tuple>
#include <functional>

#define PI 3.14159265359
#define INF 1e9
#define LINF 1e18
#define irep(i,n) for(int  i = 0; i < n; i++)
#define irep2(i,a,n) for(int i = a; i < n; i++)
#define lrep(i,n) for(long long  i = 0; i < n; i++)
#define lrep2(i,a,n) for(long long i = a; i < n; i++)
#define in(a) cin >> a
#define out(a) cout << a << endl
typedef long long ll;

typedef std::vector<int> v_int;
typedef std::vector<std::vector<int> > v2_int;
typedef std::vector<ll> v_ll;
typedef std::vector<std::vector<ll> > v2_ll;

using namespace std;

int main() 
{
    ll n, ans = 0;
    cin >> n;
    queue<ll> a;
    
    irep(i, n) {
        ll tmp;
        cin >> tmp; 
        a.push(tmp);
    }
    
    while(!a.empty()) {
        for(int i = 0; i < a.size(); i++) {
            ll num = a.front(); a.pop();
            if(num%2 == 1) {
                cout << ans;
                return 0;
            } else {
                a.push(num/2);    
            }
        }
        ans ++;
    }

    cout << ans;
    
    return 0;
}
    



Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <map>
//#include <set>
//#include <list>
//#include <cmath>
//#include <ctime>
//#include <deque>
//#include <queue>
//#include <stack>
//#include <string>
//#include <bitset>
//#include <cstdio>
//#include <limits>
//#include <vector>
//#include <climits>
//#include <cstring>
//#include <cstdlib>
//#include <fstream>
//#include <numeric>
//#include <sstream>
//#include <iomanip>
//#include <iostream>
//#include <algorithm>
//#include <unordered_map>

using namespace std;

#define file freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
#define PI 3.141592653589793238462643383279502884
#define MAX 1000100
#define mod 1000000007
#define EPS 1E-9
#define int long long
#define endl "\n"

int fix(int cur, int m)
{
    return ((cur%m) + m) % m;
}

int fast_power(int x, int y,int m)
{
    if (y == 0)
        return 1;
    int temp = fast_power(x, y / 2, m) ;
    temp = (temp*temp)% m;
    if (y % 2 != 0)
        temp = (temp*x)% m;
    return temp;

}


int32_t main()
{
    //freopen("D:/Important Files/Cocktail/SOLVE/TestLib/testcases/input/input11.txt", "r", stdin);
    //freopen("D:/Important Files/Cocktail/SOLVE/TestLib/testcases/output/output11.txt", "w", stdout);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.tie(0);

    int n;
    cin >> n;
    set<int>st;
    for(int i=0;i<n;i++)
    {
        int x;
        cin >> x;
        st.insert(x);
    }
    if(st.size()==n)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;




    return 0;
}


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

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

        private static int Solve(int K, int[] A)
        {
            var dic = new Dictionary<int, int>();
            foreach (int a in A)
            {
                if (!dic.ContainsKey(a)) { dic[a] = 0; }
                ++dic[a];
            }
            var values = dic.Values.OrderBy(value => value);
            var N = values.Count();
            return (N > K) ? values.Take(N - K).Sum() : 0;
        }

        static void Main(string[] args)
        {
            int[] values1 = ReadInts();
            int K = values1[1];
            int[] A = ReadInts();
            Console.WriteLine(Solve(K, A));
        }
    }
}


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

int main () {
  int N;
  string s;
  cin >> N >> s;
  
  int count = 0;
  for (int i = 1; i < N; i++) {
    if (s[i-1] != s[i]) {
      count ++;
    }
  }
  cout << count+1 << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)

int H,W;

vector<vector<int>> fie;

int main(){
  cin >> H >> W;
  fie.resize(H,vector<int>(W,0));
  rep(i,0,H - 1){
    string s;
    cin >> s;
    rep(j,0,W - 1){
      fie[i][j] = s[j] == '#';
    }
  }
  using P = pair<int,int>;
  rep(i,0,H - 1) rep(j,0,W - 1){
    if(fie[i][j]){
      queue<P> que;
      que.emplace(i,j);
      fie[i][j] = 0;

      int cou = 0;

      int dx[] = {1,-1,0,0};
      int dy[] = {0,0,1,-1};
      while(!que.empty()){
        int x = que.front().first;
        int y = que.front().second;
        que.pop();
        cou++;
        rep(c,0,3){
          int nx = x + dx[c];
          int ny = y + dy[c];
          if(0 <= nx && nx < H && 0 <= ny && ny < W){
            if(fie[nx][ny]){
              que.emplace(nx,ny);
              fie[nx][ny] = 0;
            }
          }
        }
      }

      if(cou <= 1){
        cout << "No" << endl;
        return 0;
      }
    }
  }

  cout << "Yes" << endl;
}


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

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

using ll = long long int;
const ll MOD = 1e9 + 7;

int main() {
  std::string N_str;
  int K;
  std::cin >> N_str >> K;

  std::vector<int> N(N_str.size());
  rep(i, N_str.size()) {
    N[i] = N_str[i] - '0';
  }


  int n = N.size();
  std::vector<std::vector<std::vector<int>>> dp(2,
    std::vector<std::vector<int>>(n + 1,
      std::vector<int>(K + 1))
  );
  dp[0][0][0] = 1;

  rep(i, n) {
    rep(j, K + 1) {
      rep(k, 2) {
        rep(d, 10) {
          int ni = i + 1, nj = j, nk = k;
          if(d != 0) ++nj;
          if(nj > K) continue;
          if(k == 0) {
            if(d > N[i]) continue;
            if(d < N[i]) nk = 1;
          }
          dp[nk][ni][nj] += dp[k][i][j];
        }
      }
    }
  }

  std::cout << dp[0][n][K] + dp[1][n][K] << '\n';
}


Measured memory_bytes: 256
import java.util.*;

public class Main {          
    
  public static void main(String[] args) {
   
     Scanner sc = new Scanner(System.in);          
    
     int MAX = 100002;
     
     int a[] = new int[MAX];
             
     int N = sc.nextInt();
     
     for(int i = 0;i < N;i++){
         int l = sc.nextInt();
         int r = sc.nextInt();
         a[l]++;
         a[r+1]--;         
     }
    
     for(int i = 0;i < MAX - 1;i++){
         a[i+1] += a[i];
     }
     
     int ans = 0;
     
     for(int i = 1;i < MAX - 1;i++){
         if(a[i] > 0){
             ans++;
         }
     }
     
     System.out.println(ans);
     
  }                            
}

Measured memory_bytes: 25584
import java.util.*;

public class Main{
	public static void main(String[] args){  
  		Scanner sc = new Scanner(System.in);
      
      	int N = sc.nextInt();
      	int Y = sc.nextInt();
      
      	int res10000 = -1;
      	int res5000 = -1;
      	int res1000 = -1;
  
  		for(int a=0; a<=N; a++){
	  		for(int b=0; a+b<=N; b++){
         	 	int c=N-(a+b);
              	int total = 10000*a + 5000*b + 1000*c;
              	if (total == Y){
                  	res10000 = a;
                  	res5000 = b;
                  	res1000 = c;
                }
    	    }  
        }
  	System.out.print(res10000);
  	System.out.print(" ");
  	System.out.print(res5000);
  	System.out.print(" ");
  	System.out.println(res1000);

    }
}

Measured memory_bytes: 21972
import sys

mx = 0

mn = 124
mx = 0
for i in range(5):
    tmp = int(sys.stdin.readline())
    mn = min(mn, tmp)
    mx = max(mx, tmp)

if (mx-mn) > int(sys.stdin.readline()):
    print(':(')
else:
    print('Yay!')


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define dbug(x) cout<<#x<<"="<<x<<endl
using namespace std;
template <typename T> void read(T &t) {
	t=0; char ch=getchar(); int f=1;
	while ('0'>ch||ch>'9') { if (ch=='-') f=-1; ch=getchar(); }
	do {(t*=10)+=ch-'0';ch=getchar();} while ('0'<=ch&&ch<='9'); t*=f;
}
int n;
int main() {
	//freopen("1.txt","r",stdin);
	read(n);
	printf("%d\n",n*n*n);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int maxn=1e6+5;
vector<ll> V;
int pre[maxn];
int main() {
    char buff[3];cin>>buff;
    if(*buff>='A'&&*buff<='Z') puts("A");
    else puts("a");
    return 0;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ld long double
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define all(x) x.begin(),x.end()
#define LOL cout<<'\n';
#define MOD 1000000007
#define sz(x) ((int)x.size())
#define INF LONG_LONG_MAX
#define NINF LONG_LONG_MIN

void solve(){
  int a[5];
  for(int i=0 ; i<5 ; i++) cin>>a[i];
  int f=0;
  for(int i=0 ; i<5 ; i++){
    if(a[i]==0) {f=i;break;}
  }
  cout<<f+1;LOL
}

signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
  solve();
  return 0;
}

Measured memory_bytes: 3532
#include <iostream>


using namespace std;

int A, B;
int X, Y, I;

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

    X = A + B;
    Y = A - B;
    I = A * B;
    if ((X > Y)&&(X > I))
    {
        cout << X << endl;
    }
    else if (Y > I)
    {
    cout << Y << endl;
    }
    else
    {
    cout << I << endl;
    }
}


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

int main()
{
    int a,b,c,d;
    while(~scanf("%d%d%d%d",&a,&b,&c,&d))
    {
        int sum =0;
        if(a>=b)
        {
            sum+=b;
        }
        else
        {
            sum += a;
        }
        if(c>=d)
        {
            sum += d;
        }
        else
        {
            sum +=c;
        }
        printf("%d\n",sum);
    }



}


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
int main(void){
  int X1,X2,X3,Y1,Y2,Y3;
  unsigned long long int S,sa;
  scanf("%llu",&S);
  X1=0;Y1=0;
  X2=(int)sqrt(S)+1;
  Y3=(int)sqrt(S)+1;
  sa=X2*Y3-S;
  X3=sa;
  Y2=1;
  if(S==1000000000000000000){
    X2=1000000000,Y3=1000000000,X3=0,Y2=0;
  }
  printf("%d %d %d %d %d %d",X1,Y1,X2,Y2,X3,Y3);
  return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<utility>
#include<algorithm>
#include<cstdio>
#include<iomanip>
#include<queue>
#include<stack>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)

using namespace std;

const ll inf = 1LL << 60;

template<class T> inline void chmin(T& a, T b) {
    if (a > b) {
        a = b;
    }
}
template<class T> inline void chmax(T& a, T b) {
    if (a < b) {
        a = b;
    }
}

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

    ll N, M;
    cin >> N >> M;
    vector<tuple<ll, ll, ll>> edges(M);
    Rep (i, M) {
        ll a, b, c;
        cin >> a >> b >> c;
        a--; b--;
        edges[i] =make_tuple(a, b, -c);
    }

    vector<ll> dist(N, inf);
    dist[0] = 0;
    Rep (i, N-1) {
        for (auto e : edges) {
            ll from = get<0>(e);
            ll to = get<1>(e);
            ll cost = get<2>(e);

            if (dist[from] != inf) chmin(dist[to], dist[from] + cost);
        }
    }

    Rep (i, N) {
        for (auto e : edges) {
            ll from = get<0>(e);
            ll to = get<1>(e);
            ll cost = get<2>(e);

            if (dist[to] > dist[from] + cost && dist[to] != inf) {
                dist[to] = -inf;
            }
        }
    }

    if (dist[N-1] == -inf) {
        cout << "inf" << endl;
        return 0;
    } else {
        cout << -dist[N-1] << endl;
    }
}

Measured memory_bytes: 384
//#pragma once
#include <stdio.h>
#include <string>
#include <iostream>
#include <queue>
#include <algorithm>
#include <sstream>
#include <vector>
#include <math.h>
#include <set>
#include <numeric>

using namespace std;

typedef pair<long long, long long> pl;

long long N, M, k, a, b, c, d, e, H, W, X;
long long A[200000] = {};
long long B[365][365] = {};
bool f;
bool ff;
string S[100005];
set <long long>sll;
pl buf;
vector <long long>vl;

struct ST
{
	long long total;
	long long aki;
	long long itta;
};

vector <ST> vst;
ST st;

int main() {

	cin >> N;
	d = 0;
	a = 0;
	b = 0;
	M = 0;

	for (int i = 0; i<N; i++) {
		cin >> S[i];
		f = false;
		ff = false;
		for (int j = 0; j < S[i].size(); j++) {


			if (S[i][j] == 'B' && f) {
				d++;
			}

			if (S[i][j] == 'B' && j == 0) {
				b++;
				ff = true;
			}

			if (S[i][j] == 'A') {
				f = true;
				if (j == S[i].size() - 1) {
					a++;
					if (ff == true) {
						M++;
					}
				}
			}
			else {
				f = false;

			}



		}

	}



	c = min(a, b);
	if (M == a && M == b && M!=0) {
		c--;
	}

	c = min(c, N - 1);

	cout << c + d << endl;

	return 0;
}


Measured memory_bytes: 1536
import qualified Data.Vector.Unboxed as U
import qualified Data.Vector.Unboxed.Mutable as UM
import qualified Data.Vector as V
import qualified Data.ByteString.Char8 as C
import Debug.Trace
import Data.List
import Control.Monad
import Data.Ord
import Data.Maybe
import qualified Data.Set as S

r :: Int -> IO (U.Vector Int)
r n = U.unfoldrN n (C.readInt . C.dropWhile (==' ')) <$> C.getLine

r' :: IO [Int]
r'  =   unfoldr    (C.readInt . C.dropWhile (==' ')) <$> C.getLine


main :: IO ()
main = do
    n <- readLn
    ss <- replicateM n getLine
    print $ S.size $ S.fromList ss



Measured memory_bytes: 169520
#include<cstdio>

const int MAX_N = 100000;
int s[MAX_N];

int main() {
	int n;
	scanf("%d", &n);
	for(int i=0;i<n;i++) {
		scanf("%d", &s[i]);
	}
	long long max_score = 0;
	for(int ab=1;ab<=(n-2)/2;ab++) {
		int max_i = (n-2) / ab - 1;
		if((n-1) % ab == 0) {
			int tmp = ((n-1) / ab - 1) / 2;
			if(tmp < max_i) max_i = tmp;
		}
		long long score = 0;
		for(int i=1;i<=max_i;i++) {
			score += s[ab*i] + s[n-1-ab*i];
			if(score > max_score) max_score = score;
		}
	}
	printf("%lld\n", max_score);
	return 0;
}


Measured memory_bytes: 512
#[allow(unused_imports)]
use std::cmp::{max, min};
use std::io::{stdin, stdout, BufWriter, Write};

#[derive(Default)]
struct Scanner {
    buffer: Vec<String>,
}

impl Scanner {
    fn next<T: std::str::FromStr>(&mut self) -> T {
        loop {
            if let Some(token) = self.buffer.pop() {
                return token.parse().ok().expect("Failed parse");
            }
            let mut input = String::new();
            stdin().read_line(&mut input).expect("Failed read");
            self.buffer = input.split_whitespace().rev().map(String::from).collect();
        }
    }
}

fn main() {
    let mut scan = Scanner::default();
    let out = &mut BufWriter::new(stdout());

    let mut x = Vec::<i32>::new();
    for _ in 0..3 {
        x.push(scan.next());
    }
    x.sort();
    writeln!(out, "{} {} {}", x[0], x[1], x[2]).ok();
}



Measured memory_bytes: 5036
def read():
    return int(input())

def reads():
    return list(map(int, input().split()))

k,a,b=reads()
k2 = 0
if (b-a)/2 <= 1:
    print(1+k)
else:
    k2 = k-a+1
    if k2 >= 2:
        print(int(a + (b-a)*(k2-k2%2)//2 + k2%2))
    else:
        print(1 + k)

Measured memory_bytes: 3060
s = input()

if "N" in s and "S" not in s:
    print("No")
elif "S" in s and "N" not in s:
    print("No")
elif "E" in s and "W" not in s:
    print("No")
elif "W" in s and "E" not in s:
    print("No")
else:
    print("Yes")


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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;

int main() {
    //cout.precision(10);
    ll N, K;
    cin >> N >> K;
    vector<ll> T[100050];
    for(int i = 1; i <= N; i++) {
        ll t, d;
        cin >> t >> d;
        T[t].push_back(d);
    }
    vector<ll> maximum;
    priority_queue<ll> que;
    for(int i = 1; i <= N; i++) {
        sort(T[i].begin(), T[i].end(), greater<ll>());
        if(T[i].empty()) continue;
        maximum.push_back(T[i][0]);
        for(int j = 1; j < T[i].size(); j++) {
            que.push(T[i][j]);
        }
    }
    sort(maximum.begin(), maximum.end(), greater<ll>());
    ll now = 0;
    ll var = maximum.size();
    ll ans = 0;
    ll max_sum = 0;
    for(int i = 0; i < maximum.size(); i++) {
        max_sum += maximum[i];
    }
    for(int i = 0; i < K - var; i++) {
        ll NEW = que.top();
        que.pop();
        now += NEW;
    }
    while(var > K) {
        var--;
        ll VAL = maximum.back();
        max_sum -= VAL;
        maximum.pop_back();
        que.push(VAL);
        //VAL = que.top();
        //que.pop();
        //now += VAL;
    }
    while(var > 0) {
        ans = max(ans, var * var + now + max_sum);
        //cout << var << " " << var *var << " " <<  now << " " <<  max_sum << endl;
        ll VAL = maximum.back();
        que.push(maximum.back());
        maximum.pop_back();
        max_sum -= VAL;
        now += que.top();
        que.pop();
        var--;
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;

int dp[1010][1010];

int main(void) {
    int q;
    string x, y;
    cin >> q;

    while (cin >> x >> y) {
        memset(dp, 0, sizeof dp);

        int xs = x.size(), ys = y.size();
        for (int i = 1; i <= xs; i++)
            for (int j = 1; j <= ys; j++) {
                if (x[i - 1] == y[j - 1]) dp[i][j] = dp[i - 1][j - 1] + 1;
                else dp[i][j] = max(dp[i - 1][j], max(dp[i][j - 1], dp[i - 1][j - 1]));
            }
            
        cout << dp[xs][ys] << endl;
    }

    return 0;
}


Measured memory_bytes: 7140
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c,d; cin>>a>>b>>c>>d;
  if(abs(a-c)<=d) cout<<"Yes"<<endl;
  else if(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, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()

int main() {
    int n;
    cin >> n; 
    cout << n*(n+1)/2 << endl;
}

Measured memory_bytes: 3520
#include <cstdio>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <iostream>
#include <queue>
#include <stack>
#include <sstream>
#include <cctype>
using namespace std;

#define PQ priority_queue
#define P pair<int,int>
#define CLA(array) memset(array,0,sizeof array)
#define CLINF(array) memset(array,0x3f,sizeof array)
#define CLF(array) memset(array,-1,sizeof array)
#define DB(a) cout << "DEBUG " << a << endl;
typedef long long LL;
typedef unsigned long long ULL;
const int MAXN = 200000 + 50;
const LL INF = 0x3f3f3f3f3f3f3f3f;
LL k;
LL a[55];

int main(){
    //ios_base::sync_with_stdio(false);
	while(~scanf("%lld", &k)){
		CLA(a);
		LL tmp = k/50;
		LL tp = k%50;
		for(int i = 0; i < 50; i++){
			a[i] += tmp;
		}
		for(int i = 0; i < 50; i++){
			if(i < 50 - tp){
				a[i] += 50 - tp - 1;
			}
			else{
				a[i] += 100 - tp;
			}
		}		
		printf("50\n");
		for(int i = 0; i < 50; i ++){
			printf("%lld", a[i]);
			if(i != 49) printf(" ");
			else printf("\n");
		}
	}
    return 0;
}


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

int gcd(int a,int b)
{
    return b?gcd(b,a%b):a;
}

int main() {
    int k;
    cin>>k;
    long long sum=0;
    for(int i=1; i<=k; i++) {
        for(int j=1; j<=k; j++) {
            for(int m=1; m<=k; m++) {
                int t=gcd(i,j);
                sum+=gcd(t,m);
            }
        }
    }
    cout<<sum<<endl;
}



Measured memory_bytes: 3596
object Main extends App {
    val in = io.Source.stdin.getLines.map(_.split(" ").map(_.toInt)).toSeq.init
    for (Array(h, m, s) <- in) {
        val x = 7200-h*3600-m*60-s
        println("%02d:%02d:%02d".format(x/3600, x/60%60, x%60))
        println("%02d:%02d:%02d".format(x/1200, x/20%60, x*3%60))
    }
}

Measured memory_bytes: 44660
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <iomanip>
#include <string>


#define rep(i,n) for(int i = 0;i < n;i++)
#define Rep(i,m,M) for(int i = m;i < M;i++)
#define print(var) cout<<#var" = "<<var<<endl;

typedef long long ll;

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<char> vchar;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;


int main()
{
	int a, b, c, d;
	cin >> a >> b;
	cin >> c >> d;
	bool T = (a != c);
	cout << T;
}


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

#define ll long long int
#define VI vector<int>
#define lf(i,a,b) for(int i=a;i<=b;i++)

int main()
{   ll n,m;cin>>n>>m;
    if(n>m)
        swap(n,m);
    ll ans;
    if(n==1)
    {   if(m==1)
            ans=1;
        else
        {   ans=m-2;
        }
    }   
    else
    {   ans=n*m;
        ans=ans-((m-1)*2+(n-1)*2);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3644
using System;

class Test
{
    static void Main()
    {
        string ss;

        while ((ss = Console.ReadLine()) != "-")
        {
            string shuffle = ss;
            int m = int.Parse(Console.ReadLine());
            for (int i = 0; i < m; i++)
            {
                int h = int.Parse(Console.ReadLine());
                shuffle = shuffle.Substring(h) + shuffle.Remove(h);
            }
            Console.WriteLine(shuffle);
        }
    }
}


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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef long long ll;

const int MOD = 1000000007;

int main() {
    ll N;
    cin >> N;
    ll n = N;
    ll s = 0;
    while (n > 0) {
        s += n % 10;
        n /= 10;
    }

    string ans = "Yes";
    if (N % s != 0) ans = "No";
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mk make_pair
#define fs first
#define sc second
using namespace std;
typedef long long ll;
typedef long double ld;
ll a[100010];
const ll d=63;
ll basis[63]; // basis[i] keeps the mask of the vector whose f value is i

ll sz; // Current size of the basis

void insertVector(ll mask) {
	for (ll i = 0; i < d; i++) {
		if ((mask & 1ll << i) == 0) continue; // continue if i != f(mask)

		if (!basis[i]) { // If there is no basis vector with the i'th bit set, then insert this vector into the basis
			basis[i] = mask;
			++sz;
			
			return;
		}

		mask ^= basis[i]; // Otherwise subtract the basis vector from this vector
	}
}
bool insertVector1(ll mask) {
	for (ll i = 0; i < d; i++) {
		if ((mask & 1ll << i) == 0) continue; // continue if i != f(mask)
		if (!basis[i]) { // If there is no basis vector with the i'th bit set, then insert this vector into the basis			
			return 1;
		}
		mask ^= basis[i]; // Otherwise subtract the basis vector from this vector
	}
	return 0;
}
char s[222];
int main(){
    ll n, t;
    cin>>t;
    while(t--){
        ll ans=0;
        scanf("%lld",&n);
        for(ll i=0; i<n; ++i){
            scanf("%lld",a+i);
        }
        reverse(a, a+n);
        scanf("%s",s);
        reverse(s, s+n);
        bool l=1;
        for(ll i=0; i<63; ++i){
        	basis[i]=0;
        }
        sz=0;
        for(ll i=0; i<n; ++i){
        	if(s[i]=='1'){
        		if(insertVector1(a[i])){
        			l=0;
        			break;
        		}
        	}
        	else{
        		insertVector(a[i]);
        	}
        }
        if(l){
        	printf("0\n");
        }
        else{
        	printf("1\n");
        }
    }
  return 0;
}




Measured memory_bytes: 3648
#include <iostream>
using namespace std;
int main(){
  int a=1,n,k,ans;
  cin>>n>>k;
  
  for(int i=0;i<n;i++){
    if(a*2<=a+k){
       a=a*2;
    }
    else{
      a=a+k;
    }
  }
  
  cout<<a<<endl;
}

Measured memory_bytes: 384
/*
Author: Sanskar Agarwal
Nick: sanskaragarwal
Birla Institute Of Technology, Mesra
*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define endl "\n"
#define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define F(i,a,b) for(ll i = (ll)(a); i <= (ll)(b); i++)
#define RF(i,a,b) for(ll i = (ll)(a); i >= (ll)(b); i--)
#define INF 100009
#define mod 1000000007
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define ff first
#define ss second
#define test while(t--)solve();

int n;
double dp[3000][3000];

double headCount(int i, int head, double arr[])
{
	if (i >= n)
	{
		if (head >= (n + 1) / 2)
			return 1;
		else
			return 0;
	}
	if (n - i + head < (n + 1) / 2)
		return dp[i][head] = 0;
	if (dp[i][head] != -1)
		return dp[i][head];

	double a = arr[i] * headCount(i + 1, head + 1, arr);
	double b = (1 - arr[i]) * headCount(i + 1, head, arr);
	return dp[i][head] =  a + b;
}

void solve()
{
	cin >> n;
	for (int i = 0; i < n; ++i)
	{
		for (int j = 0; j < n; ++j)
			dp[i][j] = -1;
	}
	double arr[n];
	for (int i = 0; i < n; ++i)
		cin >> arr[i];
	cout << setprecision(20) << fixed << headCount(0, 0, arr) << endl;
}

int main()
{
	//fast
	int t;
	// cin >> t;
	t = 1;
	test
	return 0;
}

Measured memory_bytes: 70784
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vll = vector<long long>;
using vp = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
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;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    ll h, w;
    cin >> h >> w;
    ll a, b, c;
    ll ans = 5e18;
    rep(_, 2) {
        for (ll i = 1; i <= h/2; ++i) {
            a = w * i;
            ll s = (h - i) * w;
            if (s % 2 == 0) {
                b = c = s/2;
            } else {
                if (h - i < w) {
                    b = (h - i) * (w / 2);
                    c = (h - i) * ((w + 1) / 2);
                } else {
                    b = w * ((h-i) / 2);
                    c = w * ((h-i+1)/ 2);
                }
            }
            chmin(ans, max({a, b, c}) - min({a, b, c}));
        }
        swap(h, w);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
//#include <intrin.h>

#define fore(i,a,b) for(int i = a; i < (b); i++)
#define fr(i,a,b) for(int i = a - 1; i >= b; i--)
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define N 300005
#define inf 2000000000
#define EPS 1e-7
#define MOD (ll)1e15
#define __builtin_popcount(x) __popcnt(x)

using namespace std;

typedef long long ll;
typedef pair<double, double> pr;
typedef pair<pair<int, int>, int> tup;

double find_r(double x, double y, vector<pr> &p)
{
	double l = 0, r = 1000;
	while (abs(r - l) > 1e-7) {
		double m = (l + r) / 2;

		bool ok = 1;
		fore(i, 0, p.size())
		{
			if ((x - p[i].first) * (x - p[i].first) + (y - p[i].second) * (y - p[i].second) - m * m > 0)
				ok = 0;
		}

		if (ok)
			r = m;
		else
			l = m;
	}

	return r;
}

double find_x(double y, vector<pr> &p)
{
	double l = 0, r = 1000;
	while (r - l > EPS) {
		double m1 = l + (r - l) / 3,
			m2 = r - (r - l) / 3;
		if (find_r(m1, y, p) > find_r(m2, y, p))
			l = m1;
		else
			r = m2;
	}
	return r;
}

inline void solve()
{
	int n;
	cin >> n;
	vector<pr> v(n);
	fore(i, 0, n)
		cin >> v[i].first >> v[i].second;

	double l = 0, r = 1000;
	while (r - l > EPS) {
		double m1 = l + (r - l) / 3,
			m2 = r - (r - l) / 3;
		if (find_r(find_x(m1, v), m1, v) > find_r(find_x(m2, v), m2, v))
			l = m1;
		else
			r = m2;
	}


	cout << fixed << setprecision(6) << find_r(find_x(r, v), r, v);
}

int main()
{
	fast;
#if defined(_DEBUG)
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	solve();
}

Measured memory_bytes: 256
N, M, K = map(int, input().split())
for i in range(N + 1):
    for j in range(M + 1):
        black = i * (M - j) + (N - i) * j
        # white = i * j + (N - i) * (M - j)
        if black == K:
            print("Yes")
            exit()
print("No")


Measured memory_bytes: 2940
#include <iostream>
#include <vector>
#include <algorithm>
#include <climits>
#include <cmath>
using namespace std;

#define vi vector<int>
#define vii vector<vector<int>>
#define ll long long int
const int mod = 1e9 + 7;
void testcase()
{
    ll n;
    cin >> n;
    ll ar[n + 1];
    // ll t[n + 1] = {0};
    ll sum = 0;
    for (ll i = 1; i <= n; i++)
    {
        cin >> ar[i];
        // t[i] = (ar[i] % mod + t[i - 1] % mod) % mod;
        sum = (sum % mod + ar[i] % mod) % mod;
    }
    ll ans = 0;
    for (ll i = 1; i <= n; i++)
    {
        // cout << t[n - i] << " ";
        sum = (sum % mod - ar[i] % mod) % mod;
        if(sum < 0){
            sum += mod;
        }
        ans = (ans % mod + (ar[i] % mod * sum % mod) % mod) % mod;
    }
    cout << ans << "\n";
}

int main()
{
    ios_base ::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    testcase();
    return 0;
}


Measured memory_bytes: 5208
#include <cstdlib>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef long long LL;

int main() {
  LL A, B, C, K; cin >> A >> B >> C >> K;
  if (A >= K) {
    cout << K << endl;
    return 0;
  }

  K -= A;
  if (B >= K) {
    cout << A << endl;
    return 0;
  }

  K -= B;
  cout << A - K << endl;
}


Measured memory_bytes: 3624
#include <iostream>
#include <stack>
#include <queue>
#include <vector>
#include <algorithm>
#include <string>
#include <iomanip>
#include <functional>
#include <map>



using namespace std;

int main(void) {

	int a[15][15];
	int n, m,x;
	cin >> n >> m >> x;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j <= m; j++) {
			cin >> a[i][j];
		}
	}

	int skill[15] = {};
	bool flag =  true;
	int min = -1;
	int cost = 0;
	for (int bit = 0; bit < (1 << 12); ++bit) {
		for (int i = 0; i < n; ++i) {
			if (bit & (1 << i)) { 
				cost += a[i][0];
				for (int j = 1; j <= m; j++) {
					skill[j] += a[i][j];
				}
			}
		}
		for (int i = 1; i <= m; i++) {
			if (skill[i] < x) flag = false;
			skill[i] = 0;
		} 
		if (flag && (cost < min || min == -1)) min = cost;
		cost = 0;
		flag = true;


	}


	cout << min << endl;




	return 0;
}

Measured memory_bytes: 3596
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    int n;
    cin >> n;
    vector<ll> v(n);
    for (auto &&i : v) scanf("%lld", &i);
    vector<ll> A(n+1), B(n+1);
    for (int i = 0; i < n; ++i) {
        A[i+1] = A[i] + v[i];
    }
    for (int j = n-1; j >= 0; --j) {
        B[j] = B[j+1] + v[j];
    }
    ll ans = INF<ll>;
    for (int i = 1; i < n; ++i) {
        ans = min(ans, abs(A[i]-B[i]));
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0;i < (n);i++)
using namespace std;
using ll = long long;
const ll INF = 1LL << 60;

int main(){
	int h,w;
	cin >> h >> w;
	vector<vector<char>> grid(h,vector<char>(w));
	int cnt_black = 0;
	rep(i,h) rep(j,w){
		cin >> grid[i][j];
		if(grid[i][j] == '#') cnt_black++;
	}
	
	vector<int> dy = {0,1,0,-1};
	vector<int> dx = {1,0,-1,0};
	vector<vector<ll>> d(h,vector<ll>(w,INF));
	queue<pair<int,int>> q;
	q.push(make_pair(0,0));
	while(!q.empty()){
		int y = q.front().first, x = q.front().second;
		rep(i,4){
			int ny = y+dy[i], nx = x+dx[i];
			if(y == h-1 && x == w-1)
				break;
			if(ny < 0 || ny > h-1 || nx < 0 || nx > w-1)
				continue;
			if(grid[ny][nx] == '.' && d[ny][nx] == INF){
				d[ny][nx] = d[y][x]+1;
				q.push(make_pair(ny,nx));
			}
		}
		q.pop();
	}

	if(d[h-1][w-1] == INF){
		cout << -1 << endl;
		return 0;
	}
	int ans = h*w - cnt_black - (d[h-1][w-1]+1);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.math.BigInteger;
import java.util.*;

public class Main {
	
	public static void main(String[] args) throws IOException {
		
		BufferedReader br = 
			new BufferedReader(new InputStreamReader(System.in));
		
		System.out.println(br.readLine().toUpperCase());
	}
	
}

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

const long MOD = 1000000007;

long mypow(int m, int n) {
    if (n == 1) return m;
    long d = mypow(m, n / 2);
    if (n % 2 == 0) {
        return d % MOD * d % MOD;
    } else {
        return d % MOD * d % MOD * m % MOD;
    }
}

int main() {
    int m, n;
    cin >> m >> n;
    cout << mypow(m, n) << endl;
}

Measured memory_bytes: 3096
import java.io.*;

class Main{
    public static void main(String[] args) throws IOException{
        
        double r;
        double men, shu;
        
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String str = br.readLine();
        
        r = Double.parseDouble(str);
        
        men = r * r * Math.PI;
        shu = 2 * r * Math.PI;
        
        System.out.printf("%1.6f %1.6f", men, shu);
    }
}

Measured memory_bytes: 24552
def dfs(cur, a, b, c):
    """
    深さがNだったら使用MPを評価
    N本の竹を使うときに必要な合成回数はN-1のため，最後に-1*10*3(?)
    1本も竹を使用していなかったら棄却→MPを無限に使うこととしている
    """
    if cur == N:
        return abs(a - A) + abs(b - B) + abs(c - C) - 30 if min(a, b, c) > 0 else 10 ** 9

    """ 
    cur番目の竹に対して
        ret0:ABCどれにも使わない
        ret1:Aに使う（合成:MP+10）
        ret2:Bに使う（合成:MP+10）
        ret3:Cに使う（合成:MP+10）
    """
    ret0 = dfs(cur + 1, a, b, c)
    ret1 = dfs(cur + 1, a + banboos[cur], b, c) + 10
    ret2 = dfs(cur + 1, a, b + banboos[cur], c) + 10
    ret3 = dfs(cur + 1, a, b, c + banboos[cur]) + 10
    return min(ret0, ret1, ret2, ret3)


# input
N, A, B, C = map(int, input().split())
banboos = [int(input()) for i in range(N)]

print(dfs(0, 0, 0, 0))

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <climits>
//#include "h.h"
using namespace std;

#define ll long long
#define pint pair<int, int>
#define pll pair<ll, ll>
#define pb push_back
#define mp make_pair
#define pm(first, second) pb(mp(first, second))
#define SPACE " "
#define fpf first.first
#define fps first.second
#define spf second.first
#define sps second.second

#define all(X) (X).begin(), (X).end()

int main(){

	while(true){
		int x, y, s;
		cin >> x >> y >> s;
		if(x == 0 && y == 0 && s == 0)break;

		int ans = 0;
		for(int i = 1; i <= s; i ++){
			for(int j = 1; i * (100 + x) / 100 + j * (100 + x) / 100 <= s; j ++){
				if(i * (100 + x) / 100 + j * (100 + x) / 100 == s){
					ans = max(ans, i * (100 + y) / 100 + j * (100 + y) / 100);
				}
			}
		}
		cout << ans << endl;
	}

	return 0;
}


Measured memory_bytes: 2996
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define mod 1000000007
#define pb push_back
#define inf 1000000000000000000
#define ff first
#define ss second
void checkpoint1()
{
	/******think more code less******/
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	/*#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif*/
}
vector< ll > all(10000001);
int main()
{
	checkpoint1();
	for(ll i=1;i<10000001;i++)
	{
		for(ll j=i;j<10000001;j+=i)
		{
			if(i==1)
				all[j]=1;
			else
				all[j]+=1;
		}
	}
	for(ll i=2;i<10000001;i++){
		all[i]=all[i-1]+(i*all[i]);
	}
	ll n;
	cin>>n;
	cout<<all[n];
	return 0;
}

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

int main() {
  int a,b;
  cin >> a >> b;
  int d=1;
  while ( d<=b ) {
    d*=10;
  }
  a=a*d+b;
  for ( int i=1; i<1000; i++ ) {
  	if ( i*i==a ){
	  puts("Yes");
	  return 0;
  	}
  }
  puts("No");
  return 0;
}


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

int main() {
    int n{}, m{};
    std::cin >> n >> m;
    std::vector<int> dp(n + 1);
    for (int i = 0; i < m; i++) {
        int a{};
        std::cin >> a;
        dp[a] = -1;
    }
    dp[0] = 1;
    for (int i = 0; i < n; i++) {
        if (dp[i] == -1) continue;
        for (int j = 1; j <=2; j++) {
            if (i + j > n) break;
            if (dp[i + j] == -1) continue;
            dp[i + j] += dp[i];
            if (dp[i + j] > 1000000007) dp[i + j] -= 1000000007;
        }
    }
    std::cout << dp.back() << std::endl;
    return 0;
}

Measured memory_bytes: 3788
<?php
fscanf(STDIN,'%d%d%d%d',$A,$B,$C,$D);
$left=$A+$B;
$right=$C+$D;
if($left==$right){
  echo 'Balanced';
}elseif($left>$right){
  echo 'Left';
}else{
  echo 'Right';
}



 ?>


Measured memory_bytes: 3576
n = int(input())
a = list(map(int, input().split()))
c = [0] * 9
for i in a:
    if i < 3200:
        c[i // 400] += 1
    else:
        c[8] += 1
ans = 0
for i in range(8):
    if c[i] != 0:
        ans += 1
if ans == 0:
    print(1, c[8])
else:
    print(ans, ans + c[8])

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

int main(){
  int chara[26]={0};
  string str;
  string S;
  while(cin>>S){
    str+=S;
  }
  for(int i=0;i<(int)str.size();i++){
    int c=int(tolower(str[i])-'a');
    if(0 <= c && c<26)
      chara[c]++;
  }
  for(int i=0;i<26;i++)
    cout<<char('a'+i)<<" : "<<chara[i]<<endl;
  return 0;
}

Measured memory_bytes: 1196
#define _CRT_SECURE_NO_WARNINGS
#include <algorithm>
#include<cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include<iostream>
#include<list>
#include<queue>
#include<set>
#include<string>
#include <vector>

#define ll long long
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define FORR(i,a,b) for(int i=(a);i>=(b);--i)
#define REPR(i,n)   FORR(i,n,0)

using namespace std;

int main(){
	ll N, b, c;
	vector<ll>A;
	scanf("%lld", &N);
	FOR(i, 1, N + 1){
		scanf(" %lld", &c);
		A.push_back(c - i);
	}
	sort(A.begin(), A.end());
	b = A.at((N + 1) / 2 - 1);
	ll ans = 0;
	FOR(i, 0, N){
		ans += abs(A.at(i) - b);
	}
	printf("%lld\n", ans);

	return 0;
}

Measured memory_bytes: 2420
//AnkitCode99 here....
#include<bits/stdc++.h>
#define endl "\n"
typedef long long int ll;
#define MOD 1000000007
#define mp make_pair
#define pll pair<ll,ll>
#define pb push_back
//max xor btw range of two numbers..
#define max_XOR(a,b) (1 << int(log2(a ^ b) + 1)) - 1
#define vl vector<ll>
#define inf ll(1e18)
#define all(v) v.begin(),v.end()
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define rep(i,a,b) for(long long int i=a;i<b;i++)
#define nrep(i,a,b) for(long long int i=a;i>=b;i--)
#define ceil(a,b) a/b+((a%b ==0 )?0:1)
using namespace std;

const ll sz=100005;
const ll szz=1000006;

int main()
{
	fast;
    
	ll x,y,a,b,c;
	cin>>x>>y>>a>>b>>c;
	
	vector<pll> v;
	rep(i,0,a)
	{
		ll ele;
		cin>>ele;
		v.pb({ele,1});
	}
	rep(i,0,b)
	{
		ll ele;
		cin>>ele;
		v.pb({ele,2});
	}
	rep(i,0,c)
	{
		ll ele;
		cin>>ele;
		v.pb({ele,3});
	}

	sort(all(v));
	reverse(all(v));
	ll extra=0,ans=0;
	for(auto aut:v)
	{
		if(extra== (x+y))
			break;
		if(aut.second==1)
		{
			if(x>0)
			{
				ans+=aut.first;
				x--;
			}
		}
		else if(aut.second==2)
		{
			if(y>0)
			{
				ans+=aut.first;
				y--;
			}
		}
		else
		{
			ans+=aut.first;
			extra++;
		}
	}
	cout<<ans<<endl;
}
//Goodbye...


Measured memory_bytes: 10476
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <functional>
#include <vector>
#include <queue>
#include <map>
#include <stack>
#include <string>

using namespace std;

typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)

ll const INF = 1000000000000000000;
int const I_MAX = 2147483647;
ll const MOD = 1e9 + 7;
int const POW_MAX = 1e5;

ll po[POW_MAX + 2];

ll mod_pow(ll x, ll n) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * x % MOD;
    x = x * x % MOD;
    n >>= 1;
  }
  return res;
}

ll mod_inv (ll x) {
  return mod_pow(x, MOD - 2) % MOD;
}

ll comb(int n, int r) {
  return (((po[n] * mod_inv(po[r])) % MOD) * mod_inv(po[n - r])) % MOD;
}

int N;
int h[101];

int main() {
  scanf("%d", &N);
  rep(i, N) {
    scanf("%d", &h[i]);
  }

  int count = 0;
  rep(i, 101) {
    int flg = 0;
    rep(j, N) {
      if (h[j]) {
        h[j]--;
        if (!flg) {
          flg++;
        }
      } else {
        if (flg) {
          flg--;
          count++;
        }
      }
    }
    if (flg) count++;
  }
  printf("%d\n", count);
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <functional>
using namespace std;

#define Rep(b, e, i) for(int i = b; i <= e; i++)
#define Repr(e, b, i) for(int i = e; i >= b; i--)
#define rep(n, i) Rep(0, n-1, i)
#define repr(n, i) Repr(n-1, 0, i)
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define uniq(x) (x).erase(unique(all(x)),(x).end())

typedef long long ll;
typedef pair<ll, ll> llP;
typedef pair<int, int> intP;
typedef std::priority_queue<int> IntPrioQueue; //Z->A
typedef std::priority_queue<int, std::vector<int>, std::greater<int> > IntReversePrioQueue; //A->Z

const int MAX = 200000;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const int MOD = 1000000007;

int ns[9];

void solve(void){
    int T;
    cin >> T;
    rep(T, i) {
        rep(9, i) scanf("%d", &ns[i]);
        char c;
        rep(9, i) {
            cin >> c;
            ns[i] += (c-'A')*10;
        }
        sort(ns, ns+9);
        bool can = false;
        do {
            bool t = true;
            rep(3, i) {
                t = t && ((ns[3*i] == ns[3*i+1] && ns[3*i] == ns[3*i+2]) || (ns[3*i] == ns[3*i+1]+1 && ns[3*i] == ns[3*i+2]+2));
            }
            can = can || t;
        } while(next_permutation(ns, ns+9));
        cout << (can?"1":"0") << endl;
    }
}

int main(void){
  solve();
  return 0;
}



Measured memory_bytes: 3224
#include<stdio.h>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <iterator>
#include <list>
#include <map>     
#include <numeric>
#include <utility>
#include <queue>
#include <set>
#include <sstream>
#include <iomanip>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define ll long long
#define ld long double
#define rep(a,t) for(int a=0;a<t;++a) 
#define forever while(true)
#define Sort(a) sort(a.begin(),a.end())
#define Reverse(a) reverse(a.begin(),a.end())
#define pb push_back
#define int_maxvalue numeric_limits<int>::max()
ll mod = 1e9 + 7;
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	ll Sqrt = (ll)sqrt(n);
	cout << n << ":";
	bool flag = false;
	for (ll i = 2; i <= Sqrt; i++) {

		while (n%i == 0) {
			flag = true;
			cout << " " << i;
			n /= i;
		}
	}
	if (n!=1) { cout << " " << n; }
	cout << endl;
	return 0;
}


Measured memory_bytes: 3176
# -*- coding: utf-8 -*-
import sys
input = sys.stdin.readline

from math import sqrt
n = int(input())
d = [list(map(int,input().split())) for i in range(n)]

#町iと町jの距離を計算
distance_nest_list = []
for i in d:
    distance_list = []
    for j in d:
        distance_list.append(sqrt((i[0] - j[0])**2 + (i[1] - j[1])**2))
    distance_nest_list.append(distance_list)

distance_nest_list_sum_witho_ii = 0
for i,v in enumerate(distance_nest_list):
    for i2,v2 in enumerate(v):
        if i!=i2:
            distance_nest_list_sum_witho_ii+=v2

ans = distance_nest_list_sum_witho_ii/n
print(ans)

Measured memory_bytes: 3064