akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

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

    long long ans = 0;
    for ( int b = k+1; b <= n; b++ ) {
        ans += max(0, b-k) * (n / b);
        ans += max(0, n%b-k+1);
        if ( k == 0 ) ans--;    /* 0 の分を引く */
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3528
#include<bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n ; i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define whole(f, x, ...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x) // decltypeで型取得、引数があればva_argsのところに入れる
using namespace std;
typedef long long ll; // long longをllでかけるようにした
const int INF = 1e9;

int main(void){
    while(true){
        int n; cin >> n;
        if(n == 0) return 0;
        else{
            vector<pair<int, int>> P(n);
            REP(i, n) cin >> P[i].first >> P[i].second;
            int m; cin >> m;
            vector<pair<char, int>> Go(m);
            REP(i, m) cin >> Go[i].first >> Go[i].second;
            pair<int, int> now = make_pair(10, 10);
            vector<bool> Get(n, false);
            REP(i, m){
                REP(j, Go[i].second){
                    if(Go[i].first == 'N') now.second++;
                    else if(Go[i].first == 'S') now.second--;
                    else if(Go[i].first == 'E') now.first++;
                    else if(Go[i].first == 'W') now.first--;
                    REP(p, n){
                        if(P[p] == now) Get[p] = true;
                    }
                }
            }
            bool ok = true;
            REP(i, n) if(Get[i] == false) ok = false;
            cout << (ok ? "Yes" : "No") << endl;
        }       
    }
}


Measured memory_bytes: 3072
'use strict'

const INF = 900719925474099;
function mapint(temp){
    return temp.split(' ').map((v)=>parseInt(v));
}

function Main(input){
    let temp = input.trim();
    let a = mapint(temp);

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


Measured memory_bytes: 21192
def main():
    N, M = map(int, input().split())
    A = list(map(int, input().split()))
    # import numpy as np

    # A = np.array(A)
    su = sum(A)
    a = sorted(A, reverse=True)

    tmp = su/M * 0.25

    if a[M-1] < tmp:
        print('No')
    else:
        print('Yes')


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
using ld = long double;
template<typename T> using V = vector<T>;
template<typename T> using VV = vector<vector<T>>;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
#define rep(i,a,n) for(ll i=a;i<(ll)(n);++i)
#define repr(i,a,n) for(ll i=n-1;(ll)a<=i;--i)
#define ENDL '\n'
typedef pair<int,int> Pi;
typedef pair<ll,ll> PL;
constexpr ll mod = 1000000007;
constexpr ll INF = 1000000099;
constexpr ll LINF = (ll)(1e18 +99);
const vector<ll> dx={-1,1,0,0},dy={0,0,-1,1};
template<typename T,typename U> inline bool chmin(T& t, const U& u){if(t>u){t=u;return 1;}return 0;}
template<typename T,typename U> inline bool chmax(T& t, const U& u){if(t<u){t=u;return 1;}return 0;}
template<typename T> inline T gcd(T a,T b){return b?gcd(b,a%b):a;}
template<typename T,typename Y> inline T mpow(T a, Y n) {
  T res = 1;
  for(;n;n>>=1) {
    if (n & 1) res = res * a;
    a = a * a;
  }
  return res;
}



signed main(){
  cin.tie(0);ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(20);
  ll x;cin>>x;

  V<ll> v(5000);
  rep(i,0,5000){
    v[i]=i*i*i*i*i;
    //cerr<<v[i]<<ENDL;
  }

  rep(i,0,5000){
    rep(j,i,5000){
      if(v[j]+v[i]==x){
        cout<<j<<" "<<-i<<ENDL;
        return 0;
      }else if(v[j]-v[i]==x){
        cout<<j<<" "<<i<<ENDL;
        return 0;
      }

    }
  }
  assert(false);
}
//! ( . _ . ) ! 
//CHECK overflow,vector_size,what to output?

Measured memory_bytes: 3696
#include <stdio.h>
#include <math.h>

int main(void){
	while(1){
	int i;
	double n, n2[1001] = {}, m, x[1001] = {}, y;
		y = 0;
		m = 0;
		scanf("%lf", &n);
		if(n == 0)break;
		for(i = 0; i < n; i++){
			scanf("%lf", &n2[i]);
			m += n2[i];
		}
		m /= n;
		for(i = 0; i < n; i++){
			x[i] += n2[i] - m;
			y += x[i] * x[i];
		}
		y /= n;
		printf("%lf\n", sqrt(y));
	}
	return 0;
}

Measured memory_bytes: 664
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
//#include <algorithm>
//#include <vector>
 
int main(int argc, char* argv[])
{
    long r;
    scanf("%ld", &r);

    if(r<1200) {
        printf("ABC\n");
    }
    else if(r<2800) {
        printf("ARC\n");
    }
    else {
        printf("AGC\n");
    }

    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define fastio() ios_base::sync_with_stdio(false);
using namespace std;
typedef long long ll;
typedef long double ld;


int main(){
	int n;
	string s, t;
	cin >> n >> s >> t;
	string ans = "";
	for(int i = 0; i<n; i++){
		ans.push_back(s[i]);
		ans.push_back(t[i]);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
using Int = long long;
const char newl = '\n';

//INSERT ABOVE HERE
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(0);
  int s,w;
  cin>>s>>w;
  if(s<=w) cout<<"unsafe"<<newl;
  else cout<<"safe"<<newl;
  return 0;
}


Measured memory_bytes: 3660
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            //[summary]A - Shiritori
            var lines = ReadLines<string>(1).ToList();

            if (IsShiritori(lines[0]))
            {
                Console.WriteLine("YES");
            }
            else
            {
                Console.WriteLine("NO");
            }            
        }

        static bool IsShiritori(List<string> line)
        {
            string s = "";

            foreach(var word in line)
            {
                if (s != "")
                {
                    if (!word.StartsWith(s))
                    {
                        return false;
                    }
                }

                s = word.Substring(word.Length - 1, 1);                
            }

            return true;
        }
                               
        static IEnumerable<List<T>> ReadLines<T>(int count = 0, char separator = ' ')
        {
            //[summary]コンソールの値を読み込んで、List<T>のコレクションを返却

            //読み込む行数が未指定のときは、1行目の値を"count"とみなす
            if (count == 0)
            {
                string line = Console.ReadLine().TrimEnd();
                count = int.Parse(line);
            }

            for (int i = 0; i < count; i++)
            {
                //コンソールを1行読み込み
                string line = Console.ReadLine().TrimEnd();

                //char型のときは1文字ずつに分割
                if (typeof(T) == typeof(char))
                {
                    var list = line.ToCharArray().ToList();
                    yield return (List<T>)(object)list;
                }
                else
                {
                    //読み込んだ値を"separator"で区切る
                    var list = line.Split(separator).ToList();

                    //int型のときは数値に変換
                    if (typeof(T) == typeof(int))
                    {
                        var numbers = list.ConvertAll(int.Parse);
                        yield return (List<T>)(object)numbers;
                    }
                    else if (typeof(T) == typeof(long))
                    {
                        var numbers = list.ConvertAll(long.Parse);
                        yield return (List<T>)(object)numbers;
                    }
                    else
                    {
                        yield return (List<T>)(object)list;
                    }
                }
            }
        }
    }
}


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

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    
    //good luck kittu!
    int n, m, index;
    char character;
    cin>>n>>m;
    string s = "";
    for(int i = 0; i<n; i++) s.push_back('x');

    bool ok = 1;
    while(m--){
        cin>>index>>character;
        index--;
        if(s[index]!='x' && s[index]!=character) ok = 0;
        else if(n!=1 && index==0 && character=='0') ok = 0;
        else s[index] = character;
        //cout<<s<<"\n";
    }

    if(n!=1 && s[0]=='x') s[0] = '1';
    else if(n==1 && s[0]=='x') s[0] = '0';
    for(int i = 0; i<n; i++) if(s[i]=='x') s[i] = '0';

    if(ok) cout<<s<<"\n";
    else cout<<"-1\n";
    return 0;
}

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

struct activity
{
  int A, B, C;
};

int solve(vector<activity> v, int n)
{
  int dp[n + 1][3];
  dp[1][0] = v[1].A;
  dp[1][1] = v[1].B;
  dp[1][2] = v[1].C;
  for (int i = 2; i <= n; i++)
  {
    dp[i][0] = v[i].A + max(dp[i - 1][1], dp[i - 1][2]);
    dp[i][1] = v[i].B + max(dp[i - 1][0], dp[i - 1][2]);
    dp[i][2] = v[i].C + max(dp[i - 1][0], dp[i - 1][1]);
  }

  return max(dp[n][0], max(dp[n][1], dp[n][2]));
}

int main()
{
  int n, k;
  cin >> n;
  vector<activity> v(n + 1);
  for (int i = 1; i <= n; i++)
  {
    cin >> v[i].A;
    cin >> v[i].B;
    cin >> v[i].C;
  }
  cout << solve(v, n);
  return 0;
}

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

using namespace std;
using ll=long long;

void solve() {
    int M, n;
    cin >> M >> n;
    vector<int> a(n);
    for (auto& x: a) {
        cin >> x;
    }
    ll res = 0;
    for (int _ = 0; _ < 2; _++) {
        vector<ll> sum(n+1);
        for (int i = 1; i <= n; i++) {
            sum[i] = sum[i-1] + a[i-1];
        }
        for (int i = 1; i <= n; i++) {
            int x = i >> 1;
            int l = n - x;
            ll tmp = 0;
            if (i & 1) {
                tmp += (x*1ll*M - (sum[n] - sum[l])) * 2; // L
                tmp += (sum[l] - sum[l-x-1]) * 2 - a[l-1]; // R
            } else {
                tmp += (x*1ll*M - (sum[n] - sum[l])) * 2 - (M - a[l]); //L
                tmp += (sum[l] - sum[l-x]) * 2; // R
            }
            res = max(res, tmp);
        }

        reverse(a.begin(), a.end());
        for (auto& x: a) {
            x = M - x;
        }
    }
    cout << res;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    cout << endl;
}


Measured memory_bytes: 2660
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define u unsigned
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define mod 1000000007
#define f(i,n) for(int i=0;i<n;i++)
#define f1(i,n) for(int i=1;i<n;i++)
#define in(i,arr) for(auto &i:arr)cin>>i;
#define out(i,arr) for(auto &i:arr)cout<<i<<" "
#define all(x) (x).begin(), (x).end()   // sort(all(v)) instead sort(v.begin(),v.end())
#define vpii vector<pair<int,int>>
#define vpll vector<pair<ll,ll>>
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define eb empalce_back
ll powe(ll base, ll to)
{   ll ans=1;
    while(to>0) {
        if (to & 1)
            ans *= base, to--;
        else base *= base, to /= 2;
    }
    return ans;
}
ll gcd(ll a,ll b){return (b==0)?a:gcd(b,a%b);}
bool prime(ll n){if(n==1)return 0;for(ll i=2;i*i<=n;i++)if(n%i==0)return 0;return 1;}
bool check(vi v,int n)
{
    if(v.size()<2)return false;
    for(int i=0;i<v.size();i++)
    {
        if((v[i]+v[i+1]+1)==n)return true;
    }
    return false;
}


int main() {
    fast;
    int t = 1;
    //cin >> t;
    while (t--) {
       ll a,b,c,d;
       cin>>a>>b>>c>>d;
       cout<<max({a*c,a*d,b*c,b*d});
    }

}


Measured memory_bytes: 3660
package main

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

// https://atcoder.jp/contests/abc121/tasks/abc121_b
func main() {
	sc := bufio.NewScanner(os.Stdin)

	var N, M, C int
	var err error
	if sc.Scan() {
		in := splitWithSpace(sc.Text())
		N, err = strconv.Atoi(in[0])
		if err != nil {
			panic(err)
		}
		M, err = strconv.Atoi(in[1])
		if err != nil {
			panic(err)
		}
		C, err = strconv.Atoi(in[2])
		if err != nil {
			panic(err)
		}
	}
	var b []int
	if sc.Scan() {
		in := splitWithSpace(sc.Text())
		for i := 0; i < M; i++ {
			bElm, err := strconv.Atoi(in[i])
			if err != nil {
				panic(err)
			}
			b = append(b, bElm)
		}
	}

	numRightAns := 0
	for i := 0; i < N; i++ {
		ans := 0
		if !sc.Scan() {
			panic("cannot scan")
		}
		in := splitWithSpace(sc.Text())
		for j := 0; j < M; j++ {
			ai, err := strconv.Atoi(in[j])
			if err != nil {
				panic(err)
			}
			ans += ai * b[j]
		}
		ans += C

		if ans > 0 {
			numRightAns++
		}
	}

	fmt.Println(numRightAns)
}

func splitWithSpace(str string) []string {
	return strings.Split(str, " ")
}

Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<list>
#include<cmath>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int n;
int a[200000];
bool e = true;
int main(){
	cin >> n;
	rep(i, n) {
		cin >> a[i];
		if (a[i] % 2)e = false;
	}
	if (e)puts("second");
	else puts("first");
	return 0;
}

Measured memory_bytes: 640
import math
K = int(input())
ans = 0
for i in range(1, K+1):
    for j in range(1, i+1):
        for k in range(1, j+1):
            gcd = math.gcd(i, math.gcd(j, k))
            if i == j == k:
                ans += gcd
            elif i != j and j != k:
                ans += 6 * gcd
            else:
                ans += 3 * gcd
print(ans)

Measured memory_bytes: 9080
N=int(input())
A=list(map(int, input().split()))
Acum=[0]*(N+1)
for i in range(0,N):
    Acum[i+1]=Acum[i]+A[i]
ans=0
for i in range(N-1):
    ans+=A[i]*(Acum[N]-Acum[i+1])
print(ans%(10**9+7))

Measured memory_bytes: 31656
#include<stdio.h>
long long d[1000010]={};
long long m,b[1000010]={};
int main(){
  int n,i,a[300010];
  scanf("%d",&n);
  while(n--){
    scanf("%lld",&m);
    b[m]++;
  }
  for(i=1;i<1000005;i++)d[i]+=b[i]*i+d[i-1];
  scanf("%d",&n);
  for(i=0;i<n;i++)scanf("%d",&a[i]);
  for(i=0;i<n;i++){
    scanf("%lld",&m);
    printf("%s\n",d[a[i]]<m?"No":"Yes");
  }
  return 0;
}

Measured memory_bytes: 17380
#include <iostream>
#include <string>

using namespace std;

int main() {

    string n;
    cin >> n;

    uint64_t sum = 0;
    for(int i = 0; i < n.length(); i++) sum += n[i] - '0';

    if(sum % 9) cout << "No" << endl;
    else cout << "Yes" << endl;

    return 0;
}

Measured memory_bytes: 3480
function Main(input) {
  input = input.split("\n");
  var h = parseInt(input[0].split(" ")[0]);
  var w = parseInt(input[0].split(" ")[1]);
  s = new Array(h);
  d = new Array(h);
  var b = 0;
  for(i=0;i<h;i++){
    tmp = new Array(w);
    dsub = new Array(w);
    for(j=0;j<w;j++){
      tmp[j]=input[i+1].substr(j,1);
      dsub[j]=h*w;
      if(i==0&&j==0){
        dsub[j]=0;
      }
    }
    if(input[i+1].match(/#/g)){
    b+=(input[i+1].match(/#/g)).length;
    }
    s[i]=tmp;
    d[i]=dsub;
  }

  function dist(i,j,d,c,a){
    cueue = new Array(0);
    cueue.push([i,j,d,c,a]);
    d[i][j]=0;
    while(cueue.length!=0){
      if(cueue[0][0]-1>=0&&d[cueue[0][0]-1][cueue[0][1]]==a&&c[cueue[0][0]-1][cueue[0][1]]=="."){
        d[cueue[0][0]-1][cueue[0][1]]=d[cueue[0][0]][cueue[0][1]]+1;
        cueue.push([cueue[0][0]-1,cueue[0][1],cueue[0][2],cueue[0][3],cueue[0][4]]);
      }
      if(cueue[0][0]+1<=h-1&&d[cueue[0][0]+1][cueue[0][1]]==a&&c[cueue[0][0]+1][cueue[0][1]]=="."){
        d[cueue[0][0]+1][cueue[0][1]]=d[cueue[0][0]][cueue[0][1]]+1;
        cueue.push([cueue[0][0]+1,cueue[0][1],cueue[0][2],cueue[0][3],cueue[0][4]]);
      }
      if(cueue[0][1]-1>=0&&d[cueue[0][0]][cueue[0][1]-1]==a&&c[cueue[0][0]][cueue[0][1]-1]=="."){
        d[cueue[0][0]][cueue[0][1]-1]=d[cueue[0][0]][cueue[0][1]]+1;
        cueue.push([cueue[0][0],cueue[0][1]-1,cueue[0][2],cueue[0][3],cueue[0][4]]);
      }
      if(cueue[0][1]+1<=w-1&&d[cueue[0][0]][cueue[0][1]+1]==a&&c[cueue[0][0]][cueue[0][1]+1]=="."){
        d[cueue[0][0]][cueue[0][1]+1]=d[cueue[0][0]][cueue[0][1]]+1;
        cueue.push([cueue[0][0],cueue[0][1]+1,cueue[0][2],cueue[0][3],cueue[0][4]]);
      }
      cueue.shift();
    }
    return d;
  }
  d=dist(0,0,d,s,h*w);
  var ans=0;
  if(d[h-1][w-1]==h*w){
    ans = -1;
  }else{
    ans=h*w-b-d[h-1][w-1]-1;
  }
  console.log('%s', ans);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 21064
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<set>
#include<unordered_set>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
using namespace std;
#define DEBUG(x) cout<<#x<<"="<<x<<endl
#define DEBUG2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<endl
typedef long long ll;
// #define LOCAL
const int MAXN=2e5+10;
const ll MOD=10;
ll _gcd(ll a,ll b){if(b==0)return a;return _gcd(b,a%b);}
ll gcd(ll a,ll b){a=abs(a),b=abs(b);if(a<b)swap(a,b);return _gcd(a,b);}
ll qpow(ll a,ll n){ll rt=1;while(n){if(n&1)rt=(rt*a)%MOD;a=a*a%MOD;n>>=1;}return rt;}
ll factor[MAXN];
void cal_factor(){factor[0]=1;for(int u=1;u<MAXN;u++){factor[u]=(factor[u-1]*u)%MOD;}}
ll C(ll n,ll k){return factor[n]*qpow(factor[n-k],MOD-2)%MOD*qpow(factor[k],MOD-2)%MOD;}
int N;
int A[MAXN];
bool cmp(int a,int b)
{
    return a>b;
}
void solve()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>N;
    for(int u=0;u<N;u++)cin>>A[u+1];
    sort(A+1,A+1+N,cmp);
    ll ans=A[1];
    for(int u=2;u<=N;u++){
        if(u*2-1<=N)ans+=A[u];
        if(u*2<=N)ans+=A[u];
    }
    cout<<ans;
}
int main()
{
#ifdef LOCAL
    freopen("in.txt","r",stdin);
#endif
    solve();
}

Measured memory_bytes: 4432
import sys
def main():
    input = sys.stdin.readline
    N,T=map(int, input().split())
    *A,=map(int, input().split())
    R=[]
    mn=(A[0],set([0]))
    for i in range(1,N):
        if A[i] > mn[0]:
            R.append((A[i] - mn[0], mn[1]))
        elif mn[0] == A[i]:
            mn[1].add(i)
        else:
            mn = (A[i],set([i]))
    R.sort(reverse=True, key=lambda x:x[0])
    ans = 0
    mx = R[0][0]
    tmp1 = set()
    cnt = 0
    for r in R:
        if r[0] != mx: break
        cnt += 1
        tmp1 |= r[1]
    print(min(cnt, len(tmp1)))

if __name__ == '__main__':
    main()

Measured memory_bytes: 73836
//
//  main.cpp
//  CompetitiveProgramming
//
//  Created by 小林竜也 on 2019/02/22.
//  Copyright © 2019 小林竜也. All rights reserved.
//

#include <iostream>
#include <stack>
#include <cstdio>
#include <queue>
#include <vector>
using namespace std;

int main(int argc, const char * argv[]) {
    int A,B,C;
    cin>>A>>B>>C;
    if(B/A>=C){
        cout<<C;
    }else{
        cout<<B/A;
    }
    
}


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()
#define int long long
#define _GLIBCXX_DEBUG


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

  rep(i, s.size()) {
    if(s[i] != 'a' && 'z' - s[i] + 1 <= K) {
      K -= 'z' - s[i] + 1;
      s[i] = 'a';
    }
    if(K == 0) {
      cout << s << endl;
      return 0;
    }
  }
  
  if(K > 25) K %= 26;
  
  s[s.size()-1] += K;
  cout << s << endl;


}

Measured memory_bytes: 512
using System;
using System.Diagnostics;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        int[] v = Console.ReadLine().Split().Select(i => int.Parse(i)).ToArray();


        Dictionary<int, int> o = new Dictionary<int, int>();
        Dictionary<int, int> e = new Dictionary<int, int>();

        // インデックス0から始まるので、インデックスが偶数のものは奇数番目にある
        for (int i = 0; i < n; i++)
        {
            if (i % 2 == 1)
            {
                // 偶数の場合
                if (e.ContainsKey(v[i]))
                {
                    e[v[i]]++;
                }
                else
                {
                    e.Add(v[i], 1);
                }
            }
            else
            {
                // 奇数の場合
                if (o.ContainsKey(v[i]))
                {
                    o[v[i]]++;
                }
                else
                {
                    o.Add(v[i], 1);
                }
            }
        }

        // 出てくる個数でソート
        var o_sorted = o.OrderByDescending(i => i.Value);
        var e_sorted = e.OrderByDescending(i => i.Value);

        // 奇数偶数に分割した結果、要素が1コしか無い場合があるのでElementAtOrDefault
        var o_1st = o_sorted.First();
        var o_2nd = o_sorted.ElementAtOrDefault(1);
        var e_1st = e_sorted.First();
        var e_2nd = e_sorted.ElementAtOrDefault(1);

        // 偶奇で最頻値が同じかどうかで場合分け
        if (e_1st.Key != o_1st.Key)
        {
            Console.WriteLine(n - e_1st.Value - o_1st.Value);
        }
        else
        {
            // 最頻値が同じ場合、片方は二番目に多い数で書き換え。少ないほうが答え。
            Console.WriteLine(Math.Min(n - o_1st.Value - e_2nd.Value, n - e_1st.Value - o_2nd.Value));
        }
    }
}

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

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

int main()
{
    int L;
    cin >> L;
    double d = L / 3.0;
    cout << fixed << setprecision(12) <<  pow(d, 3.0) << endl;
}

Measured memory_bytes: 384
// finish date: 2018/01/21
#include <iostream>
#include <cmath>
#include <vector>
#include <bitset>
#include <algorithm>
#include <stack>
#include <map>
#include <climits>

using namespace std;

#define FOR(i, a, b) for(int (i)=a;(i)<(b);(i)++)
#define rep(i, n)  FOR(i,0,n)
#define ll long long
#define bigmod 1000000007
#define INF 500000000


int main() {
    string S;
    cin>>S;
    cout<<S.front()<< S.length()-2 <<S.back()<<endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
typedef pair<int, int> P;
ll Mod = 1000000007;
int main() {
  int X,Y;
  cin >> X >> Y;
  int ans = 0;
  if (X == 3) {
    ans += 100000;
  } else if (X == 2) {
    ans += 200000;
  } else if (X == 1) {
    ans += 300000;
  }
  if (Y == 3) {
    ans += 100000;
  } else if (Y == 2) {
    ans += 200000;
  } else if (Y == 1) {
    ans += 300000;
  }
  if (X == 1 && Y == 1) {
    ans += 400000;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3588
//#pragma GCC optimize ("O3")
//#pragma GCC target ("avx")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

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


	string S;
	cin >> S;

	if (S[0] == '7' || S[1] == '7' || S[2] == '7') co("Yes");
	else co("No");


	Would you please return 0;
}


Measured memory_bytes: 3648
#include <iostream>
#include <vector>
#include <list>
#include <set>
#include <queue>
#include <map>
#include <algorithm>
#include <functional>
#include <string>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>
using namespace std;
 
#define REP(i,p,n) for(ll i=p;i<ll(n);++i)
#define rep(i,n) REP(i,0,n)
 
using ll = long long int;
using pll = pair<ll, ll>;
 
const ll mod = static_cast<ll>(1e9) + 7;
 
ll N;
string S;
 
void solve(ll n, ll p)
{
    if (n == N)
    {
        cout << S << endl;
        return;
    }
 
    rep (i, p + 1)
    {
        S[n] = 'a' + i;

        const ll pp = p + (i == p ? 1 : 0);
        solve(n + 1, pp);
    }
}
 
 
int main()
{
    cin >> N;
    rep (i, N) { S += 'a'; }
 
    solve(0, 0);
 
    return 0;
}


Measured memory_bytes: 1536
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <iostream>

using namespace std;

int main()
{
    int long long N;
    int long long power = 1;
    cin >> N;
    for(int i = 0;i<N;i++){
        power=power*(i+1)% 1000000007;
    }
    cout << power << endl;
    return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>

using namespace std;

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

static const double eps = 10e-6;

int main(){
	int n;
	while(~scanf("%d",&n)){
		printf("3C%02d\n",n%39 == 0 ? 39 : n%39);
	}
}

Measured memory_bytes: 0
#include<iostream>
#include<vector>
#include<map>
#include<cmath>
using namespace std;
long long int a[55];
vector<pair<int,int> > v1;
int main(){
	int n;
	int i,j,k;
	int t[2]={0,0};
	cin>>n;
	for(i=0;i<n;i++){
		cin>>a[i];
		if(a[t[0]]>a[i])t[0]=i;
		if(a[t[1]]<a[i])t[1]=i;
	}
	if(abs(a[t[0]])<abs(a[t[1]])){
		for(i=1;i<n;i++){
			if(a[i-1]<=a[i])continue;
			while(a[i-1]>a[i]){
				a[i]+=a[t[1]];
				v1.push_back(make_pair(t[1]+1,i+1));
			}
			if(a[i]>a[t[1]])t[1]=i;
		}
	}else{
		for(i=n-2;i>=0;i--){
			if(a[i+1]>=a[i])continue;
			while(a[i+1]<a[i]){
				a[i]+=a[t[0]];
				v1.push_back(make_pair(t[0]+1,i+1));
			}
			if(a[i]<a[t[0]])t[0]=i;
		}
	}
	cout<<v1.size()<<endl;
	for(i=0;i<v1.size();i++){
		cout<<v1[i].first<<" "<<v1[i].second<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define LL long long

void solve() {
	int L;
	cin>>L;
	cout<<L+pow(L,2)+pow(L,3)<<"\n";
}

int main()
{
    //freopen("in.txt","r",stdin);
    //int tc;cin>>tc;
    //while(tc--)
	solve();
    return 0; 
}

Measured memory_bytes: 4164
/*
　　こんにちは。あたしはｶｳｶﾞｰﾙ。
　　RedcoderになるためAtCoderを巡る旅をしてます。

　　　 　＿_
　　　 ヽ|＿_|ノ　　　　ﾓｫ
　　　　||‘‐‘||ﾚ　　_)_, ―‐ 、
　　　　/(Ｙ (ヽ＿ /・ ヽ　　   ￣ヽ
　　　　∠ ＿ ゝ　 ｀^ヽ ﾉ.::::_(ノヽ
　　　　 _/ヽ　 　　  /ヽ￣￣￣/ヽ
*/

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define dump(x) cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl

#define rep(i, n) REP(i, 0, n)                  // 0, 1, ..., n-1
#define REP(i, x, n) for(int i = x; i < n; i++) // x, x + 1, ..., n-1
#define FOREACH(x, a) for(auto &(x) : (a))

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()

#define COUT(x) cout << (x) << endl

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

const ll INF = 1e10;

ll N, A, B;
vector<ll> h;

bool f(ll K) {
    ll tmp = 0;
    rep(i, N) {
        ll rem = h[i] - B * K;
        if(rem > 0) tmp += (rem + (A - B - 1)) / (A - B);
    }
    return (tmp <= K);
}

ll binary_search() {
    ll ng = -1;
    ll ok = INF;
    while(abs(ok - ng) > 1) {
        ll mid = (ok + ng) / 2;
        if(f(mid))
            ok = mid;
        else
            ng = mid;
    }
    return ok;
}

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

    cin >> N >> A >> B;
    h.resize(N);
    rep(i, N) cin >> h[i];
    cout << binary_search() << endl;
}


Measured memory_bytes: 1024
#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif
#include<bits/stdc++.h>
using namespace std;
#define rep(i,s,t) for(ll i = (ll)(s); i < (ll)(t); i++)
#define rrep(i,s,t) for(ll i = (ll)(s-1);(ll)(t) <= i; i--)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
constexpr ll INF = numeric_limits<ll>::max()/4;
constexpr ll n_max = 2e5+10;
#define int ll

template <typename A, typename B>
string to_string(pair<A, B> p);
string to_string(const string &s) {return '"' + s + '"';}
string to_string(const char *c) {return to_string((string) c);}
string to_string(bool b) {return (b ? "true" : "false");}
template <size_t N>
string to_string(bitset<N> v){
    string res = "";
    for(size_t i = 0; i < N; i++) res += static_cast<char>('0' + v[i]);
    return res;
}
template <typename A>
string to_string(A v) {
    bool first = true;
    string res = "{";
    for(const auto &x : v) {
        if(!first) res += ", ";
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}
template <typename A, typename B>
string to_string(pair<A, B> p){return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";}

void debug_out() {cerr << endl;}
template<typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H);
    debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

template<class T>
bool chmax(T &a, T b){if(a < b){a = b; return true;} return false;}
template<class T>
bool chmin(T &a, T b){if(a > b){a = b; return true;} return false;}

void print() {
    cout << endl;
}

template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
    cout << head;
    if (sizeof...(tail) != 0) cout << " ";
    print(forward<Tail>(tail)...);
}

template <class T>
void print(vector<T> &vec) {
    for (auto& a : vec) {
        cout << a;
        if (&a != &vec.back()) cout << "\n";
    }
    cout << endl;
}

template <class T>
void print(vector<vector<T>> &df) {
    for (auto& vec : df) {
        print(vec);
    }
}

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll n; cin >> n;
    vector<ll> cnt(n+1);
    for(int x = 1; x * x <= n; x++){
        for(int y = 1; y * y <= n; y++){
            for(int z = 1; z * z <= n; z++){
                ll temp = ((x + y + z) * (x + y + z) + (x*x)+(y*y) + (z*z)) / 2;
                if(temp <= n)cnt[temp]++;
            }
        }
    }

    rep(i,1,n+1)cout << cnt[i] << "\n";
}

Measured memory_bytes: 3632
//package com.company;

import java.io.*;
import java.math.BigInteger;
import java.util.*;

public class Main {
    public static class Task {


        public void solve(Scanner sc, PrintWriter pw) throws IOException {
            int n = sc.nextInt();
            int m = sc.nextInt();
            int[][] keys = new int[m][2];
            for (int i = 0; i < m; i++) {
                keys[i][0] = sc.nextInt();
                int k = sc.nextInt();
                for (int j = 0; j < k; j++) {
                    keys[i][1] += 1 << (sc.nextInt() - 1);
                }
            }
            int[] dp = new int[1 << n];
            Arrays.fill(dp, Integer.MAX_VALUE / 2);
            dp[0] = 0;
            int[] nextDp = new int[1 << n];
            for (int i = 0; i < m; i++) {
                System.arraycopy(dp, 0, nextDp, 0, dp.length);
                for (int j = 0; j < 1 << n; j++) {
                    nextDp[j | keys[i][1]] = Math.min(nextDp[j | keys[i][1]], dp[j] + keys[i][0]);
                }
                dp = nextDp;
            }
            pw.println(dp[(1 << n) - 1] >= Integer.MAX_VALUE / 2 ? -1 : dp[(1 << n) - 1]);
        }
    }

    static long TIME_START, TIME_END;

    public static void main(String[] args) throws IOException {
        Scanner sc = new Scanner(System.in);
//        Scanner sc = new Scanner(new FileInputStream("input"));
        PrintWriter pw = new PrintWriter(new BufferedOutputStream(System.out));
//        PrintWriter pw = new PrintWriter(new FileOutputStream("output"));

        Runtime runtime = Runtime.getRuntime();
        long usedMemoryBefore = runtime.totalMemory() - runtime.freeMemory();
        TIME_START = System.currentTimeMillis();
        Task t = new Task();
        t.solve(sc, pw);
        TIME_END = System.currentTimeMillis();
        long usedMemoryAfter = runtime.totalMemory() - runtime.freeMemory();
        pw.close();
        System.err.println("Memory increased: " + (usedMemoryAfter - usedMemoryBefore) / 1000000);
        System.err.println("Time used: " + (TIME_END - TIME_START) + ".");
    }

    static class Scanner {
        StringTokenizer st;
        BufferedReader br;

        public Scanner(InputStream s) {
            br = new BufferedReader(new InputStreamReader(s));
        }

        public Scanner(FileReader s) throws FileNotFoundException {
            br = new BufferedReader(s);
        }

        public String next() throws IOException {
            while (st == null || !st.hasMoreTokens())
                st = new StringTokenizer(br.readLine());
            return st.nextToken();
        }

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

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

        public String nextLine() throws IOException {
            return br.readLine();
        }

        public double nextDouble() throws IOException {
            return Double.parseDouble(next());
        }

        public boolean ready() throws IOException {
            return br.ready();
        }
    }
}


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

const int M = 105, N = 105, INF = 1E9 + 7;

int m, n, dst[M][N];
char s[M][N];
bool chk[M][N];
deque<pair<int, int>> de;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> m >> n;
    for (int i = 1; i <= m; i++) {
        cin >> (s[i] + 1);
    }
    s[0][1] = s[m + 1][n] = '.';
    for (int i = 0; i <= m + 1; i++) {
        for (int j = 0; j <= n + 1; j++) {
            dst[i][j] = INF;
        }
    }
    for (de.push_back({0, 1}), dst[0][1] = 0; !de.empty(); ) {
        int u = de.front().first, v = de.front().second;
        de.pop_front();
        if (chk[u][v]) {
            continue;
        }
        chk[u][v] = true;
        if (s[u + 1][v] != '\0') {
            dst[u + 1][v] = min(dst[u + 1][v], dst[u][v] + (s[u + 1][v] != s[u][v]));
            if (s[u + 1][v] == s[u][v]) {
                de.push_front({u + 1, v});
            } else {
                de.push_back({u + 1, v});
            }
        }
        if (s[u][v + 1] != '\0') {
            dst[u][v + 1] = min(dst[u][v + 1], dst[u][v] + (s[u][v + 1] != s[u][v]));
            if (s[u][v + 1] == s[u][v]) {
                de.push_front({u, v + 1});
            } else {
                de.push_back({u, v + 1});
            }
        }
    }
    cout << dst[m + 1][n] / 2;
}


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

using namespace std;

const int N=2010;

int n,m,q;
int a[N][N],b[N][N],c[N][N];
char s[N][N];

int main(){
	scanf("%d%d%d",&n,&m,&q);
	for(int i=1;i<=n;i++)
		scanf("%s",s[i]+1);
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
			a[i][j]=a[i-1][j]+a[i][j-1]-a[i-1][j-1]+(s[i][j]=='1');
	for(int i=1;i<=n;i++)
		for(int j=2;j<=m;j++)
			b[i][j]=b[i-1][j]+b[i][j-1]-b[i-1][j-1]+(s[i][j]=='1' && s[i][j-1]=='1');
	for(int i=2;i<=n;i++)
		for(int j=1;j<=m;j++)
			c[i][j]=c[i-1][j]+c[i][j-1]-c[i-1][j-1]+(s[i][j]=='1' && s[i-1][j]=='1');
	while(q--){
		int a1,b1,a2,b2;
		scanf("%d%d%d%d",&a1,&b1,&a2,&b2);
		int A=a[a2][b2]-a[a2][b1-1]-a[a1-1][b2]+a[a1-1][b1-1];
		int B=b[a2][b2]-b[a2][b1]-b[a1-1][b2]+b[a1-1][b1];
		int C=c[a2][b2]-c[a2][b1-1]-c[a1][b2]+c[a1][b1-1];
		printf("%d\n",A-B-C);
	}
	return 0;
}

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

using namespace std;
typedef pair<int, int> P;
// input


int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	
    int num, ans = 0;
    cin >> num;
    vector<int> diff(num);
    rep(i,num) cin >> diff[i];
    sort(diff.begin(),diff.end());

    cout << diff[num/2]- diff[(num/2)-1] << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define loop(i, a, b) for (int i = a; i < (int)(b); i++)
 
const int MAX = 1 << 29;
int N;
vector<vector<int>> load(100001);
 
struct SearchResult {
    int stepsToN;
    int centerCityIdx;
};
 
 
SearchResult calcStepsToN(int last, int curr, int steps) {
    if (curr == N) {
        return {steps, 0};
    }
    SearchResult m = {MAX, 0};
    for (int a : load[curr]) {
        if (a == last) continue;
        SearchResult d = calcStepsToN(curr, a, steps + 1);
        if (d.stepsToN < m.stepsToN) {
            m = d;
        }
    }
    if (m.stepsToN == MAX) {
        return m;
    }
    if (m.stepsToN / 2 + 1 == steps) {
        m.centerCityIdx = curr;
    }
    return m;
}
int countCitys(int last, int curr, int centerCity) {
    if (curr == N) {
        return 0;
    }
    if (curr == centerCity) {
        return 0;
    }
    int count = 1;
    for (int a : load[curr]) {
        if (a == last) continue;
        int c = countCitys(curr, a, centerCity);
        count += c;
    }
    return count;
}
 
int main() {
    cin >> N;
    rep(i, N - 1) {
        int a, b;
        cin >> a >> b;
        load[a].push_back(b);
        load[b].push_back(a);
    }
    SearchResult r = calcStepsToN(-1, 1, 0);
    int count = countCitys(-1, 1, r.centerCityIdx);
    if (count > N / 2) {
        cout << "Fennec" << endl;
    } else {
        cout << "Snuke" << endl;
    }
    return 0;
}

Measured memory_bytes: 13568
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

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

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

int main() {
  int t;
  cin >> t;
  REP(i, t) {
    int n;
    cin >> n;
    int h[n];
    REP(j, n) cin >> h[j];
    int up = 0, down = 0;
    REP(i, n - 1) {
      if (h[i] < h[i + 1]) {
        up = max(up, h[i + 1] - h[i]);
      } else if (h[i] > h[i + 1]) {
        down = max(down, h[i] - h[i + 1]);
      }
    }
    cout << up << " " << down << endl;
  }
  return 0;
}


Measured memory_bytes: 3076
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <set>

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,j) FOR(i,0,j)
#define mp std::make_pair

const int INF = 1 << 24;
const int dx[8] = {0, 0, 1, -1, 1, 1, -1, -1}, dy[8] = {1, -1, 0, 0, 1, -1, 1, -1};

typedef unsigned long long ull;
typedef std::pair<int,int> P;

std::string toNegaDecimal(int n){
    std::string res = "";
    while(n){
        int q = n / (-10), r = n % (-10);
        while(r < 0){
            q += 1;
            r += 10;
        }
        n = q;
        res = static_cast<char>(r+'0') + res;
    }
    return res;
}

int main(){
    int n;
    while(std::cin >> n, n){
        std::cout << toNegaDecimal(n) << std::endl;
    }
}

Measured memory_bytes: 1200
import sys
import os
if sys.platform=="darwin":
	base = os.path.dirname(os.path.abspath(__file__))
	name = os.path.normpath(os.path.join(base, '../Documents/input.txt'))
	#print(name)
	sys.stdin = open(name)

n = int(input())
l = list(map(int,input().split()))

l = sorted(l)
#print(l)
#print( l[::2] )
print( sum(l[::2]) )


Measured memory_bytes: 38256
program redistribution
  implicit none
  integer(8), parameter :: modu = 1000000007
  integer :: s
  integer(8) :: m(3, 3) = 0
  read(*,*) s
  if (s < 3) then
    write(*,'(i0)') 0
    stop
  end if
  m(1, 1) = 1
  m(2, 1) = 1
  m(3, 2) = 1
  m(1, 3) = 1
  m = modmatpow(m, s - 3)
  write(*,'(i0)') m(1, 1)
contains
  function modmatmul(x, y) result(res)
    integer(8), intent(in) :: x(:, :), y(:, :)
    integer(8) :: tmp, res(size(x, 1), size(y, 2))
    integer :: i, j, k
    do j = 1, size(y, 2)
      do i = 1, size(x, 1)
        res(i, j) = 0
      end do
      do k = 1, size(x, 2)
        tmp = y(k, j)
        do i = 1, size(x, 1)
          res(i, j) = mod(res(i, j) + x(i, k) * tmp, modu)
        end do
      end do
    end do
  end
  function modmatpow(x, n) result(res)
    integer(8), intent(in) :: x(:, :)
    integer, intent(in) :: n
    integer(8) :: res(size(x, 1), size(x, 2)), tmp(size(x, 1), size(x, 2))
    integer :: m, i
    res = 0
    do i = 1, size(x, 1)
      res(i, i) = 1
    end do
    tmp = x
    m = n
    do while (m > 0)
      if (btest(m, 0)) res = modmatmul(res, tmp)
      tmp = modmatmul(tmp, tmp)
      m = rshift(m, 1)
    end do
  end
end program redistribution

Measured memory_bytes: 2884
#include <stdio.h>
int main(void)
{
  char str[100];
  char std[100];
  int a = 0;
  int n;
  
    scanf("%s",str);
    scanf("%s",std);
  
  for(n=0;str[n] != '\0' && std[n] != '\0'; n++){
   if(str[n] == std[n]){
     a++;
   }else continue;
  };
    
  printf("%d",a);
  
    return 0;
  }

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

int main() {
  int K;
  cin >> K;
  
  string t = "1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51,";

  int sum = 0;
  for (int i = 0; i < t.size(); i++) {
    if (t.at(i) == ',') {
       sum += 1;
       if (sum == K) {
         if(K == 1) {
           cout << 1 << endl;
           break;
         }
         if(t.at(i-2) == ' ') {
           cout << t.at(i-1) << endl;
         }
         else {
           cout<< t.at(i-2) << t.at(i-1) << endl;
         }  
       }
    }
  }
  
     
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using  namespace std;
#define ll long long int
int main()
{
   string s;
   cin>>s;
  ll a=0,b=0;
  for(ll i=0;i<3;i++)
  {
      if(s[i]=='A')
        a++;
      if(s[i]=='B')
        b++;

  }
  if(a>0&&b>0)
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<bitset>
#include<stack>
#include<memory>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
#define endl "\n"
using namespace std;
using ll = long long;
using P = pair<int,int>;
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const string YES = "";
const string NO = "";

int color[9];

int main() {
    int n; cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    rep(i,n){
        if(a[i] >= 3200){
            color[8]++;
        }
        else{
            color[a[i]/400]++;
        }
    }
    int _min = 0;
    rep(i,8){
        if(color[i]>0) _min++; 
    }
    _min = max(_min, 1);
    int _max = min(_min + color[8] ,n);
    cout << _min << " " << _max << endl;
}

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

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { each (i, v) is >> i; return is; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  lli n, m;
  while (cin >> n >> m) {
    if (n == 1 && m == 1) {
      cout << 1 << endl;
    } else if (min(n, m) == 1) {
      cout << max(n, m) - 2 << endl;
    } else {
      cout << (n - 2) * (m - 2) << endl;
    }
  }
  
  return 0;
}

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

int main() {
	char* S = new char[1001];
	char* T = new char[1001];
	cin >> S;
	cin >> T;

	int lS = 0;
	int lT = 0;
	char* p = S;
	while(*p != '\0'){
		lS++;
		p++;
	}
	p = T;
	while(*p != '\0'){
		lT++;
		p++;
	}

	p = S;
	int mn = 1000;
	for(int i = 0; i <= lS - lT; i++){
		int c = 0;
		char* r = p;
		char* q = T;
		for(int j = 0; j < lT; j++){
			if(*r != *q) c++;
			r++;
			q++;
		}
		mn = (c < mn ? c : mn);
		p++;
	}

	cout << mn << endl;
	return(0);
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s,s1;
    cin>>s;
    cin>>s1;
    int l=s1.length();
    s1.erase(s1.begin()+l-1);
    if(s==s1)
    cout<<"Yes"<<endl;
    else
    cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 3592
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.UncheckedIOException;
import java.util.StringTokenizer;

class Main{
	public static void main(String[] args) {
		SC sc=new SC(System.in);
		int H=sc.nextInt();
		int W=sc.nextInt();
		int[][] twn=new int[H][W];
		int sum=0;
		for(int i=0; i<H; i++) {
			for(int j=0; j<W; j++) {
				twn[i][j]=sc.nextInt();
			}
		}
		int max=1000000007;
		int[][] road=new int[H][W];
		for(int i=0; i<H; i++) {
			for(int j=0; j<W; j++) {
				int tmp=0;
				for(int k=0; k<H; k++) {
					for(int l=0; l<W; l++) {
						tmp+=Math.min(Math.abs(i-k),Math.abs(l-j))*twn[k][l];
					}
				}
				max=Math.min(max, tmp);
			}
		}
		pl(max);
	}
	public static void pl(Object o) {
		System.out.println(o);
	}
	public static void pl() {
		System.out.println();
	}
	public static void p(Object o) {
		System.out.print(o);
	}
	static class SC {
		private BufferedReader reader = null;
		private StringTokenizer tokenizer = null;
		public SC(InputStream in) {
			reader = new BufferedReader(new InputStreamReader(in));
		}
		public String next() {
			if (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new UncheckedIOException(e);
				}
			}
			return tokenizer.nextToken();
		}
		public int nextInt() {
			return Integer.parseInt(next());
		}
		public long nextLong() {
			return Long.parseLong(next());
		}
		public double nextDouble() {
			return Double.parseDouble(next());
		}
		public String nextLine() {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new UncheckedIOException(e);
			}
		}
	}
}


Measured memory_bytes: 25324
#include<stdio.h>
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<algorithm>
#include<string>
#include<math.h>
using namespace std;
 
int main(){
    int K,X;

    cin >> K >> X;

    int b = max(-1000000,X - (K -1 ));
    int e = min(1000000,X + (K - 1));

    while(b <= e){
        cout << b << ' ';
        b++;
    }

    cout << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <numeric>
using namespace std;
int main() {
	int n; cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++)cin >> a[i];
	cout << accumulate(a.begin(), a.end(), 0) - n << endl;
}

Measured memory_bytes: 256