akhauriyash/Code-Regression huggingface dataset:
n, m = map(int, input().split())
ls = [int(input()) for _ in range(m)]

dp = [0] * (n + 1)
dp[0] = 1

ls.append(0)

if ls[0] == 1:
	dp[1] = 0
	del ls[0]
else:
	dp[1] = 1

for i in range(2, n + 1):
	if i == ls[0]:
		dp[i] == 0
		del ls[0]
	else:
		dp[i] = dp[i - 1] + dp[i - 2]

print(dp[n] % 1000000007)

Measured memory_bytes: 460020
// inputに入力データ全体が入る
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
	input = input.split("\n");
	tmp = input[0].split(" ");
	//文字列から10進数に変換するときはparseIntを使います
	var N = parseInt(tmp[0], 10);
	var A = [];
	var counter = 0;
	var button = 1;
	for (var i = 0; i < N; i++) {
		A[i] = parseInt(input[i + 1], 10);
	}

	while (button !==2) {
		button = A[button-1];
		counter += 1;
		if (counter > Math.pow(10,6)) {
			break;
		}
	}

	if (button === 2) {
		console.log(counter);
	}else {
		console.log('-1');
	}
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 27220
#include <bits/stdc++.h> 
using namespace std;
int main(){
	int A[3];
	cin>>A[0]>>A[1]>>A[2];
	sort(A,A+3);
	if((A[0]^A[1]^1)&1) cout<<A[2]-(A[1]+A[0]>>1);
	else cout<<((A[2]<<1)-A[1]-A[0]+1>>1)+1;
	return 0;
}





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

using namespace std;

#define forn(a, e) for (int a = 0; a < (int)(e); a++)
#define forr(a, s, e) for (int a = s; a < (int)(e); a++)
#define fore(e, a) for (auto& e : a)

#ifdef LOCAL
#define logv(a) {cerr << #a << " = "; fore(e, a) {cerr << e << " ";} cerr << "\n";}
#define logvp(a) {cerr << #a << " = "; fore(e, a) {cerr << "(" << e.first << ", " << e.second << ") ";} cerr << "\n";}
#define logvv(a) {cerr << #a << " = \n"; fore(r, a) { fore(e, r) {cerr << e << " ";} cerr << "\n";} }
#define logvf(a, field) {cerr << #a"."#field << " = \n"; fore(e, a) { cerr << e.field << " ";} cerr << "\n"; }
#define logvff(a, f1, f2) {cerr << #a".{"#f1 << ", "#f2 << "} = \n"; fore(e, a) { cerr << "(" << e.f1 <<", " << e.f2 << ") ";} cerr << "\n"; }
#define logs(a) cerr << #a << " = " << (a) << "\n";
#define logss(a, b) cerr << #a << " = " << (a) << ", " << #b << " = " << (b) << "\n";
#define logp(a) cerr << #a << " = " << "(" << a.first << ", " << a.second << ")" << "\n";
#define cond(pred, stmt) if (pred) { stmt }
#else
#define logv(a)
#define logvp(a)
#define logvv(a)
#define logvf(a, field)
#define logvff(a, f1, f2)
#define logs(a)
#define logss(a, b)
#define logp(a)
#define cond(pred, stmt)
#endif

using i64 = long long;
using iip = pair<i64, i64>;
using ivec = vector<int>;
using llvec = vector<i64>;
using svec = vector<string>;
template<typename T> using vec = vector<T>;

template<typename T, typename Dim>
auto make_vec(T value, Dim dim) { return vector<T>(dim, value); }
template<typename T, typename Dim1, typename... Dim>
auto make_vec(T value, Dim1 dim1, Dim... dims) { return make_vec(make_vec(value, dims...), dim1); }

template<typename T>
bool uax(T& v, const T& newv) { if (v < newv) { v = newv; return true; } else return false; }
template<typename T>
bool uin(T& v, const T& newv) { if (v > newv) { v = newv; return true; } else return false; }

template<typename T>
istream& operator>>(istream& is, vector<T>& c) { for (auto& e : c) is >> e; return is; }

template<typename ...T>
istream& read(T&... args) { return (cin >> ... >> args); }

static mt19937 rande(123123);
template<typename T>
T rand_int(T from, T to) { uniform_int_distribution<T> distr(from, to); return distr(rande); }

const i64 M = 1e9 + 7;
const int INF = 1e9 + 1;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n, m;
    while (read(n, m)) {
        ivec a(n);
        read(a);

        priority_queue<int> q;
        fore(ai, a) {
            q.push(ai);
        }

        forn(i, m) {
            int nn = q.top(); q.pop();
            q.push(nn / 2);
        }

        i64 ans = 0;
        while (!q.empty()) {
            ans += q.top(); 
            q.pop();            
        }
        cout << ans << endl;
    }
}


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

        int main() {
          ll N;
          cin>> N; 
          vector<ll> x(N), y(N), h(N);
          for(int i=0; i<N; i++){
              cin>> x.at(i) >> y.at(i) >> h.at(i); 
          }
          
          
          ll Cx;
          ll Cy; 
          ll H;
          
          for(ll i=0; i<101; i++){
               for(ll j=0; j<101; j++){
                   
                   bool flag = true; 
                   ll candidate =0; 
                   ll ind=0; 
                   
                   while( h.at(ind) == 0 ){
                        ind++; 
                   } 
                   
                   candidate = abs(x.at(ind)-i) + abs(y.at(ind)-j) + h.at(ind); 
                   
                   if(candidate <= 0 ) flag=false; 
                   
                   for(int k=0; k<N; k++){
                       ll a = candidate - abs(x.at(k)-i) - abs(y.at(k)-j) ; 
                       if (a<0) a = 0; 
                       if( h.at(k) != a  ) flag=false; 
                   }
                   
                    if(flag){
                        Cx = i;
                        Cy = j; 
                        H = candidate; 
                    }                     
                   
               }
               
  
          }
          
          cout<< Cx <<" "<<Cy <<" "<<H;

        }

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin >> n;
    n = n % 1000;
    if (n == 0)
        cout << 0 << endl;
    else
    {
        cout << 1000 - n << endl;
    }

    return 0;
}

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

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

  bool f = false;
  for (int i = 0; i <= n; ++i) {
    for (int j = 0; j <= m; ++j) {
      if (i * j + (n - i) * (m - j) == k) f = true;
    }
  }

  cout << (f ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<=(end);i++)
#define REP(i, n) FOR(i,1,n)
#define IFOR(i, begin, end) for(int i=(end);i>=(begin);i--)
#define IREP(i, n) IFOR(i,1,n)
#define SORT(a) sort(a.begin(), a.end())
#define REVERSE(a) reverse(a.begin(), a.end())

#define ll long long
using namespace std;

bool is_prime(int k)
{
    for(int j=2;j*j<=k;j++){
        if(k%j==0) {
            return false;
        }
    }
    return true;
}

int main()
{
	stringstream ss;
    // 入力
    int N;
    cin>>N;
    int L[N+1];
    int maxL=-1;
    int Lsum=0;
    FOR(i,1,N){
    	cin>>L[i];
    	Lsum+=L[i];
    	if(maxL<L[i]) maxL=L[i];
    }
    Lsum-=maxL;
    if(Lsum>maxL) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n,T;
	cin >> n>>T;
	vector<int> c(n);
  	vector<int> t(n);
  	bool tle=true;
  	for(int i = 0; i< n;i++){
      cin >> c[i] >> t[i];
      if(t[i] <= T)
        tle=false;
    }
  if(tle){
	cout <<"TLE"<<endl;
   	return 0;
  }
  int cost=100000;
  for(int i=0;i<n;i++){
   if(t[i]>T)
     continue;
    if(cost> c[i])
    	cost = c[i];
  }
  cout <<cost << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <fstream>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <limits.h>
#include <math.h>
#include <functional>
#include <bitset>
#include <iomanip>

#define repeat(i,n) for (long long i = 0; (i) < (n); ++ (i))
#define debug(x) cerr << #x << ": " << x << '\n'
#define debugArray(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i] << '\n'
#define debugArrayP(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i].first<< " " << x[i].second << '\n'

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef vector<int> vint;
typedef vector<ll> vll;
const ll INF = INT_MAX;
const ll MOD = 1e9+7;


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int A,B,C;cin>>A>>B>>C;
  cout<<(A+B>=C?"Yes":"No")<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mkp make_pair
#define con continue
#define pb push_back
#define pob pop_back
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef map<ll,ll>::iterator itll;
int main()
{
	string s;
	cin>>s;
	bool pod ;
	pod = (s[0] == 'P'?1:0);
	ll sz= s.size();
	for(int i=0;i<sz;i++)
	{
		if(s[i] == '?')
		s[i] = 'D';
	}
	
	cout<<s<<endl;
	return 0;
 } 

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

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

  int max = 0;

  for(int i=1;i<s.size()/2;i++) {
    string str = s.substr(0, i);
    string secondStr = s.substr(i, i);

    if(str == secondStr) {
      max = i;
    }
  }

  cout << max * 2 << endl;

  
}

Measured memory_bytes: 256
/*author: hyperion_1724
  date: 
*/

//Optional FAST

//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,fma,abm,mmx,avx,avx2,tune=native")

//Required Libraries

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

//Required namespaces

using namespace std;
using namespace __gnu_pbds;

//Required defines

#define endl '\n'

#define READ(X) cin>>X;
#define READV(X) long long X; cin>>X;
#define READAR(A,N) long long A[N]; for(long long i=0;i<N;i++) {cin>>A[i];}
#define rz(A,N) A.resize(N);
#define sz(X) (long long)(X.size())
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define trav(x,A) for(auto &x:A)
#define FORI(a,b,c) for(long long a=b;a<c;a++)
#define FORD(a,b,c) for(long long a=b;a>c;a--)

//Required typedefs

typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef tree<long long,null_type,greater<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set1;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
typedef vector<int> veci;
typedef vector<long long> vecl;

//Required Constants

const long long inf=(long long)1e18;
const long long MOD=(long long)(1e9+7);
const long long INIT=(long long)(1e6+1);

//Required Functions

ll power(ll x,ll y) 
{ 
    if (y == 0) 
        return 1; 
    ll p = power(x, y/2) % MOD; 
    p = (p * p) % MOD; 
  
    return (y%2 == 0)? p : (x * p) % MOD; 
}
ll modInverse(ll a) 
{ 
   return power(a,MOD-2); 
   
}

//Work

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

    READV(N);
    ll A[61]={0};
    FORI(i,0,N)
    {
        READV(x);
        FORI(j,0,61)
        {
            if (x%2==1)
            {
                A[j]++;
            }
            x=x/2;
        }
    }
    ll ans=0;
    FORI(i,0,61)
    {
        ll z=((N-A[i])*A[i])%MOD;
        z=(z*power(2,i))%MOD;
        ans=(ans+z)%MOD;
    }
    cout<<ans<<endl;

    return 0;
}

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

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; }

#define rep(i,cc,n) for(int i=cc;i<n;++i)
#define lrep(i,cc,n) for(long long i=cc;i<n;++i)
#define sqrep(i,cc,n) for(long long i=cc;i*i<=n;++i)
#define rrep(i,cc,n) for(long i=cc;i>n;--i)
#define pii pair<int, int>
#define pll pair<long long, long long>
 
using ll = long long;

const vector<int> dx = {1, 0, -1, 0};
const vector<int> dy = {0, 1, 0, -1};
const double PI = 3.1415926535;
const ll inf = 1001001001;
const ll e9  = 1000000000;
const ll mod = 1000000007;

int n, m;
vector<vector<int>> graph;

void bfs(){
   vector<int>dist(n, -1);
   vector<int>seen(n, -1);
   queue<int>que;
   que.push(0);
   dist[0]=0;
   while(!que.empty()){
      int p = que.front();
      que.pop();
      for(auto next:graph[p]){
         if(dist[next]!=-1)continue;
         dist[next] = dist[p]+1;
         seen[next] = p;
         que.push(next);
      }
   }
   bool flag = true;
   rep(i, 1, n){
      if(seen[i]==-1)flag = false;
   }
   if(flag){
      cout << "Yes" << endl; 
      rep(i, 1, n)cout << seen[i]+1 << endl;
   }else cout << "No" << endl; 
}
int main(){
   cin >> n >> m;
   graph.assign(n, vector<int>());
   rep(i, 0, m){
      int a, b;
      cin >> a >> b;
      a--,b--;
      graph[a].push_back(b);
      graph[b].push_back(a);
   }
   bfs();
}

Measured memory_bytes: 10560
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] sa = br.readLine().split(" ");
		int n = Integer.parseInt(sa[0]);
		sa = br.readLine().split(" ");
		Map<Integer, Integer> map = new HashMap<>();
		for (int i = 0; i < n; i++) {
			addCntMap(map, Integer.parseInt(sa[i]));
		}
		br.close();

		List<Integer> list = new ArrayList<>(map.size());
		for (Integer o : map.values()) {
			list.add(o);
		}
		Collections.sort(list);

		Integer[] sum = list.toArray(new Integer[0]);
		int len = sum.length;
		for (int i = 1; i < len; i++) {
			sum[i] += sum[i - 1];
		}
		PrintWriter pw = new PrintWriter(System.out);
		int ans = n;
		int x = len - 1;
		for (int i = 1; i <= n; i++) {
			if (i > len) {
				pw.println(0);
				continue;
			}
			for ( ; ans >= 0; ans--) {
				for ( ; x > 0; x--) {
					if (list.get(x) <= ans) {
						break;
					}
				}
				int val = sum[x];
				val += (len - 1 - x) * ans;
				if (val >= i * ans) {
					pw.println(ans);
					break;
				}
			}
		}
		pw.flush();
	}

	static void addCntMap(Map<Integer, Integer> map, Integer key) {
		if (map.containsKey(key)) {
			map.put(key, map.get(key) + 1);
		} else {
			map.put(key, 1);
		}
	}
}


Measured memory_bytes: 83680
def myAnswer(N:int,K:int) -> int:
   ans = 0
   for n in range(1,N+1):
      sub = K - n
      counter = 0
      total = n
      if(total >= K):
         ans += 1/N
         continue
      while True:
         total *= 2
         counter += 1
         if(total >= K):
            break
      ans += 1/N * (1/2)**counter
   return ans

def modelAnswer():
   return
def main():
   N,K = map(int,input().split())
   print(myAnswer(N,K))
if __name__ == '__main__':
   main()

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,-1,sizeof(x))
const int INF = 1e9 + 1;
const ll MOD = 1e9 + 7;
const double PI = 3.141592653589793;

int main(){
  int a, b, c, d, e;
  char s;
  cin >> s;
  if(isupper(s)) cout << 'A' <<endl;
  else cout << 'a'<<endl;
}

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

using namespace std;

int main(){
	string s;
	cin >> s;
	long long x,i=0,sum=0;
	x= s.size();
	int ar[x];
	while(i != x){
		ar[i]=s[i]-'0';
		sum += ar[i];
		i++;
	}
	if(sum%9 == 0){
		cout << "Yes" << endl;
	}
	else{
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 4464
s = input()
t = input()
max_count = 0

for i in range(len(s) - len(t) + 1):
    count = 0
    for j in range(len(t)):
        if s[j + i] == t[j]:
            count += 1
            
    if count > max_count :
        max_count = count
        
print(len(t) - max_count)

Measured memory_bytes: 9056
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;

class Program
{

    public static void Main( )
    {
        int N = int.Parse( Console.ReadLine( ) );
        var sortedResult = new Dictionary<string, int>( );
        for ( int i = 0; i < N; i++ )
        {
            var sorted = string.Concat( Console.ReadLine( ).OrderBy(c=>c) );
            if ( !sortedResult.ContainsKey( sorted ) ) sortedResult[ sorted ] = 0;
            sortedResult[ sorted ] += 1;
        }

        long ans = 0;
        foreach ( var item in sortedResult )
        {
            if ( item.Value < 2 ) continue;
            ans += Combination( item.Value, 2 );
        }

        Console.WriteLine(ans);
    }

    public static long Combination( int n, int m )
    {
        long numerator = 1;
        for ( int i = n; i > n - m; i-- ) numerator *= i;
        long denominator = 1;
        for ( int i = m; i >= 1; i-- ) denominator *= i;
        return numerator / denominator;
    }

}

Measured memory_bytes: 55992
N,K = map(int, input().split())
es = [[] for _ in range(N)]

for _ in range(N-1):
    a,b = map(int, input().split())
    es[a-1].append(b-1)
    es[b-1].append(a-1)


MOD = 10**9+7
 
MAXN = K+5
fac = [1,1] + [0]*MAXN
finv = [1,1] + [0]*MAXN
inv = [0,1] + [0]*MAXN
for i in range(2,MAXN+2):
    fac[i] = fac[i-1] * i % MOD
    inv[i] = -inv[MOD%i] * (MOD // i) % MOD
    finv[i] = finv[i-1] * inv[i] % MOD
 
def nPr(n,r):
    if n < r:
        return 0
    return fac[n] * finv[n-r]

ans = 1

checked = [False] * N
q = []
# 探索開始ノードの取りうる色K個と、そこに繋がるノードの色の取り方
ans *= K * nPr(K-1, len(es[0]))

checked[0] = True
for nxt in es[0]:
    q.append(nxt)
    checked[nxt] = True

while q:
    curr = q.pop()
    ans *= nPr(K-2, len(es[curr]) - 1)
    ans %= MOD
    for nxt in es[curr]:
        if not checked[nxt]:
            q.append(nxt)
            checked[nxt] = True
print(ans % MOD)

Measured memory_bytes: 72480
// C - Sum of product of pairs
#include <bits/stdc++.h>
using namespace std;

int main(){
	int N; cin>>N;
	int MOD = (1e9) + 7;
	int64_t ans = 0, b = 0;
	for(int i=0; i<N; ++i){
		int a; cin>>a;
		ans += a * b % MOD;
		b += a;
		b %= MOD;
	}
	cout<< (ans + MOD) % MOD <<endl;
}


Measured memory_bytes: 3576
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <math.h>

using namespace std;

int m, n;

int main () {
    cin >> n >> m;
    if ( (n + m ) % 2 == 0 ) {
        cout << (n + m) / 2;
    }
    else {
        cout <<"IMPOSSIBLE ";
    }
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int ans = 0;
        int a = sc.nextInt();
        int b = sc.nextInt();
        if ((b-2+a)%(a-1) == 0) {
            ans = (b - 2 + a) / (a - 1) - 1;
        } else {
            ans = (b - 2 + a) / (a - 1);
        }
        System.out.println(ans);

    }
}

Measured memory_bytes: 21844
def f():
    n = int(input())
    s = input()
    leftMemo = [None]*10
    rightMemo = [None]*10
    for i in range(10):
        char = str(i)
        for j in range(n):
            if s[j] == char:
                leftMemo[i] = j
                break
        for k in range(n-1,-1,-1):
            if s[k] == char:
                rightMemo[i] = k
                break
    ans = 0
    for leftNum in range(10):
        if leftMemo[leftNum] is None:
            continue
        start = leftMemo[leftNum]+1
        for rightNum in range(10):
            if rightMemo[rightNum] is None:
                continue
            end = rightMemo[rightNum]
            ans += len(set(s[start:end]))
    print(ans)


f()

Measured memory_bytes: 3188
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
using namespace std;

struct XY{
  int x;
  int y;
};

int main(){
  int N,M;
  cin >> N >> M;
  XY student[N],checkPoint[M];
  for(int i = 0; i < N; i++) cin >> student[i].x >> student[i].y;
  for(int i = 0; i < M; i++) cin >> checkPoint[i].x >> checkPoint[i].y ;
  int ans,diff,output;
  for(int i = 0; i < N; i++){
    ans = (int)1e9;
    for(int j = 0; j < M; j++){
      diff = abs(student[i].x - checkPoint[j].x) + abs(student[i].y - checkPoint[j].y);
      if(ans > diff){
        output = j + 1;
        ans = diff;
      }
    }
    cout << output << endl;
  }

  return 0;
}


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

using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;

#define repi(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,a) repi(i,0,a)
#define rrep(i,a) for(ll i=a-1;i>=0;i--)

//debug
#define debug(arr) cerr<<#arr<<"(l"<<__LINE__<<") : ";for(auto x:arr)cerr<<x<<" ";cerr<<endl;

int main(){
  ll N; cin >> N;
  ll A[N];
  rep(i, N) cin >> A[i];

  ll sumall = 0;
  ll odd[N/2+1] = {};
  ll even[N/2] = {};
  rep(i, N) sumall += A[i];
  sumall /= 2;
  odd[0] = A[0];
  even[0] = A[1];
  rep(i, N/2) odd[i+1] = odd[i] + A[(i+1)*2];
  rep(i, N/2-1) even[i+1] = even[i] + A[(i+1)*2+1];

  ll ans[N];
  rep(i, N){
    if(i == 0) ans[i] = (sumall - even[N/2-1]) * 2;
    else if(i == 1) ans[i] = (sumall - odd[N/2] + odd[0]) * 2;
    else if(i % 2) ans[i] = (sumall - even[i/2-1] - odd[N/2] + odd[i/2]) * 2;
    else ans[i] = (sumall - odd[i/2-1] - even[N/2-1] + even[i/2-1]) * 2;
  }
  rep(i, N) cout << ans[i] << (i == N-1 ? '\n' : ' ');
  return 0;
}


Measured memory_bytes: 3712
N = int(input())
a = list(map(int, input().split()))
a_set = set(a)
if len(a_set) == 1:
    if a_set == {0}:
        print('Yes')
    else:
        print('No')
elif len(a_set) == 2:
    a_set = list(a_set)
    a0 = a.count(a_set[0])
    a1 = a.count(a_set[1])
    if N % 3 == 0 and a1 == 2 * a0 and a_set[0] == 0:
        print('Yes')
    else:
        print('No')
elif len(a_set) == 3:
    a_set = list(a_set)
    flag = 0
    if a.count(a_set[0]) == a.count(a_set[1]) and a.count(a_set[0]) == a.count(a_set[2]):
        flag = 1
    if N % 3 == 0 and flag == 1 and a_set[0] ^ a_set[1] == a_set[2]:
        print('Yes')
    else:
        print('No')
else:
    print('No')


Measured memory_bytes: 14212
import scala.io.Source.stdin

object Main {
  def find(s:Double,i:Int,l:IndexedSeq[Double],d:Double):Int =
    if( s >= d ) i else find(s+l(i),i+1,l,d)

  def main(args:Array[String]) = {
    for(l<-stdin.getLines.map(s=>s.split(",").map(_.toDouble))) {
      val sum = l.take(10).sum
      val d = sum*l(10)/(l(10)+l(11))
      println(find(0D,0,l,d))
    }
  }
}

Measured memory_bytes: 44032
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n =sc.nextInt();
        Map<String, Integer> m = new HashMap<>();

        for (int i = 0; i < n; i++) {
            String s = sc.next();
            int c = m.getOrDefault(s, 0);
            m.put(s, c+1);
        }

        int M = sc.nextInt();
        int max = 0;
        for (int i = 0; i < M; i++) {
            String s = sc.next();
            int c = m.getOrDefault(s, 0);
            m.put(s, c-1);
        }

        for (int i : m.values()) {
            if (i > max) max = i;
        }
        System.out.println(max);
    }
}

Measured memory_bytes: 22100
#include <iostream>
#include <cmath>

using namespace std;

void solve()
{
	double x, h;
	while(cin >> x >> h, x || h)
	{
		double Sum = x * x;
		double Height = sqrt(h * h + (x / 2) * (x / 2));
		Sum += Height * x * 2;
		printf("%.6f\n", Sum);
	}
}

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

Measured memory_bytes: 0
import java.util.*;
public class Main {
	public static void main(String[] args){
      	
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long cnt =0;
		for (long i = 1; i < N+1; i++) {
			if (i%3==0||i%5==0) {
				
			}else{
				cnt += i;
			}
		}
		System.out.println(cnt);
		sc.close();
    }	
		
}

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

class Main {

	public static void main(String[] args) throws IOException{
		BufferedReader br =new BufferedReader(new InputStreamReader(System.in));
		String s=br.readLine();
		if(s.equals("ABC"))
		{
			System.out.println("ARC");
		}
		else
		{
			System.out.println("ABC");
		}

	}

}

Measured memory_bytes: 32372
# include <bits/stdc++.h>
# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>0; --i)
# define range_for(i, b, e) for(int i=(b), i##_len=(e); i<=i##_len; ++i)
# define ALL(x) (x).begin(), (x).end()
# define RALL(x) (x).rbegin(), (x).rend()
# define pb push_back
# define len(x) ((int)(x).size())
# define optimize_cin() cin.tie(0); ios::sync_with_stdio(false)
# define debug(x) std::cerr<<#x<<": "<<(x)<<endl;
# define LINT_MAX (LONG_LONG_MAX)
# define cauto const auto
using namespace std;
using lint = long long;
template <class Type> inline constexpr bool InRange(const Type& x, const Type& i, const Type& a) { return (i <= x) && (x <= a); }
template<class Integer>bool chmax(Integer &a, const Integer &b) { if (a<b) { a=b; return 1; } return 0; }
template<class Integer>bool chmin(Integer &a, const Integer &b) { if (b<a) { a=b; return 1; } return 0; }
template<class Integer>bool IsOdd(Integer &n) { return n & 1; }
template<class Integer>bool IsEven(Integer &n) { return !(n & 1); }
int ctoi(const char c) { return ('0' <= c && c <= '9') ? (c - '0') : -1; }
string YesNo(bool b) { return b ? "Yes" : "No"; }
string YESNO(bool b) { return b ? "YES" : "NO"; }
string yesno(bool b) { return b ? "yes" : "no"; }
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 << " "; } cout << endl; }
template <class T> void Print(vector<vector<T>> &df) { for (auto& vec : df) { Print(vec); } }

// 整数の桁数を返す ( log(N) )
template <class Integer> Integer GetDigit(Integer n) {
    if (n == 0) return 1;
    Integer d = 0;
    while (n) {
        n /= 10;
        d++;
    }
    return d;
}

// 素数かどうかを返す ( O(sqrt(N)) )
template <class Integer>
constexpr bool IsPrime(const Integer n) noexcept {
    if (n < 4) return n == 2 || n == 3;
    if (n % 2 == 0 || n % 3 == 0 || (n % 6 != 1 && n % 6 != 5)) return false;
    for (Integer i = 5; i * i <= n; i += 6) if (n % i == 0 || n % (i + 2) == 0) return false;
    return true;
}


int main()
{
    string S; cin >> S;
    string Sw = S;
    string Sb = S;

    map<char, char> rev;
    rev['0'] = '1';
    rev['1'] = '0';

    int cntw = 0;
    if (Sw[0] == '1')
    {
        Sw[0] = '0';
        cntw++;
    }
    range_for (i, 1, len(S)-1)
    {
        if (Sw[i-1] == Sw[i])
        {
            Sw[i] = rev[Sw[i-1]];
            cntw++;
        }
    }

    int cntb = 0;
    if (Sb[0] == '0')
    {
        Sb[0] = '1';
        cntb++;
    }
    range_for (i, 1, len(S)-1)
    {
        if (Sb[i-1] == Sb[i])
        {
            Sb[i] = rev[Sb[i-1]];
            cntb++;
        }
    }

    Print(min(cntw, cntb));

    return 0;
}



Measured memory_bytes: 512
def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7 #出力の制限
N = 10**6
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )



x, y = map(int, input().split())

if (2*y-x)%3 == 0 and (2*x-y)%3 == 0:
    m = (2*y-x)//3
    n = (2*x-y)//3

    if n >= 0 or m >= 0:
        print( str(int(cmb(n+m,n, mod) % (10e9+7)) ))
    else:
        print(0)
else:
    print(0)


Measured memory_bytes: 122232
import java.util.Scanner;
import java.util.Random;
import java.io.PrintWriter;


public class Main{
    public static Random rand = new Random();
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
        long start = System.currentTimeMillis();
        int D = Integer.parseInt(sc.next());
        int[] C = new int[26];
        int[] L = new int[26];
        for (int i = 0; i < 26; i++){
            C[i] = Integer.parseInt(sc.next());
            L[i] = 0;
        }
        int[][] S = new int[D][26];
        for (int i = 0; i < D; i++){
            for (int j = 0; j < 26; j++){
                S[i][j] = Integer.parseInt(sc.next());
            }
        }
        int[] Ans = new int[D];
        for (int i = 0; i < D; i++){
            Ans[i] = (i % 26) + 1;
        }
        int maxPoint = calcPoint(Ans, S, C, L);
        

        while (System.currentTimeMillis() - start < 1850){
            change(Ans, S, C, L, D, maxPoint);
        }

        for (int i = 0; i < D; i++){
            out.print(Ans[i]);
            out.print("\n");
        }

        //template
        sc.close();
        out.flush();
    }

    public static int calcPoint(int[] Ans, int[][] S, int[] C, int[] L){
        int point = 0;
        for (int i = 0; i < 26; i++){
            L[i] = 0;
        }
        for (int i = 0; i < Ans.length; i++){
            point += S[i][Ans[i] - 1];
            L[Ans[i] - 1] = i + 1;
            for (int j = 0; j < 26; j++){
                point -= C[j] * (i + 1 - L[j]);
            }
        }
        return point;
    }

    public static void change(int[] Ans, int[][] S, int[] C, int[] L, int D, int maxPoint){
        int ci = rand.nextInt(D);
        int before = Ans[ci];
        Ans[ci] = rand.nextInt(26) + 1;
        int newPoint = calcPoint(Ans, S, C, L);
        if (newPoint < maxPoint){
            Ans[ci] = before;
        }
        else{
            maxPoint = newPoint;
        }
    }
}

Measured memory_bytes: 42168
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long ll;

int main(){
    long long a,b;
    while(cin>>a>>b)
    if(abs(a-b)<=1)cout<<"Brown"<<endl;
    else cout<<"Alice"<<endl;
	return 0;
}


Measured memory_bytes: 3632
/*author: hyperion_1724
  date: 
*/

//Optional FAST

//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,fma,abm,mmx,avx,avx2,tune=native")

//Required Libraries

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

//Required namespaces

using namespace std;
using namespace __gnu_pbds;

//Required defines

#define endl '\n'

#define READ(X) cin>>X;
#define READV(X) long long X; cin>>X;
#define READAR(A,N) long long A[N]; for(long long i=0;i<N;i++) {cin>>A[i];}
#define rz(A,N) A.resize(N);
#define sz(X) (long long)(X.size())
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define trav(x,A) for(auto &x:A)
#define FORI(a,b,c) for(long long a=b;a<c;a++)
#define FORD(a,b,c) for(long long a=b;a>c;a--)

//Required typedefs

typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef tree<long long,null_type,greater<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set1;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
typedef vector<int> veci;
typedef vector<long long> vecl;

//Required Constants

const long long inf=(long long)1e18;
const long long MOD=(long long)(1e9+7);
const long long INIT=(long long)(1e6+1);

//Required Functions

ll power(ll x,ll y) 
{ 
    if (y == 0) 
        return 1; 
    ll p = power(x, y/2) % MOD; 
    p = (p * p) % MOD; 
  
    return (y%2 == 0)? p : (x * p) % MOD; 
}
ll modInverse(ll a) 
{ 
   return power(a,MOD-2); 
   
}

//Work

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

    READV(M1);
    READV(D1);
    READV(M2);
    READV(D2);
    if(M1+1==M2 ||(M1==12 && M2==1))
    {
        cout<<1<<endl;
    }
    else
    {
        cout<<0<<endl;
    }
    

    return 0;
}

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

int main() {
  string s;
  cin >> s;
  int sum = 0;
  int pre_tile = s[0] - '0';
  for (int i = 1; i < s.size(); i++) {
    int cur_tile = s[i] - '0';
    if (cur_tile == pre_tile) {
      sum++;
      pre_tile = (cur_tile == 0 ? 1 : 0);
    } else {
      pre_tile = cur_tile;
    }
  }
  cout << sum << endl;
  return 0;
}


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

using namespace std;
int b[100005];
int main()
{
	int n,i,s,a[100005];
	do
	{
		cin >> n;
		if(n!=0)
		{
		s=0;
		for(i=0; i<n; i++)
		{
			cin >> a[i];
			b[a[i]]++;
			s+=a[i];
		}
		s=s/n;
		for(i=1; i<=100000; i++)
			b[i]+=b[i-1];
		cout << b[s] << endl;
		for(i=0; i<=100000; i++)
			b[i]=0;
		}
	}while(n!=0);
}



Measured memory_bytes: 3532
import java.util.Scanner;

class Work {
	String name;
	int time;
	
	Work(String n,int t){
		name=n;  time=t;
	}
	
}

class Queue {
	int head;
	int tail;
	Work[] a;
	
	/*コンストラクタ*/
	Queue(int n){
		head=0; tail=-1; a=new Work[n];
	}
	
	void enqueue(Work x,int n){
		tail=(tail+1)%n;
		a[tail]=x;
	}
	
	Work dequeue(int n){
		Work temp=a[head];
		head=(head+1)%n;
		return temp;
	}
	
	void decrease(int t){
		a[head].time-=t;
	}
	
	int getTime(){
		return a[head].time;
	}
	
	String getName(){
		return a[head].name;
	}
	
}

class Main {
	
	static void solve(Queue Q,int n,int q,int sum){
		int time=0;
		Work temp;
		
		while(time != sum){
			if(Q.getTime() == q){
				time+=q;
				System.out.println(Q.getName() + " " + time);
				temp=Q.dequeue(n);
			}
			else if(Q.getTime() < q){
				time+=Q.getTime();
				System.out.println(Q.getName() + " " + time);
				temp=Q.dequeue(n);
			}
			else {
				time+=q;
				Q.decrease(q);
				temp=Q.dequeue(n);
				Q.enqueue(temp,n);
			}
		}
		
		return;
	}
		
	
	
	public static void main(String[] args){
		Scanner scan=new Scanner(System.in);
		
		int n=scan.nextInt();
		int q=scan.nextInt();
		int sum=0;
		Queue Q=new Queue(n);
		
		for(int i=0;i<n;i++){
			Work temp=new Work(scan.next(),scan.nextInt());
			Q.enqueue(temp,n);
			sum+=temp.time;
		}
		
		solve(Q,n,q,sum);
		
	}
}


Measured memory_bytes: 73076
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <bitset>
#include <climits>

using namespace std;
#define all(container)     (container).begin(), container.end()
#define rall(container)    (container).rbegin(), container.rend()
#define sz(container)      (int) (container).size()
#define pb                 push_back
#define eb                 emplace_back
#define fi                 first
#define sc                 second

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#ifdef LOCAL_DEFINE
	#include "DEBUG.hpp"
#else
	#define eprint(...) 0
#endif
template<class T> bool smin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool smax(T &a, T b) { return a < b ? (a = b, true) : false; }

const int N = 2;
char line[N];

int main(void)
{
	scanf("%s", line);
	if (line[0] >= 'a' && line[0] <= 'z')
		puts("a");
	else
		puts("A");
	return 0;
}

Measured memory_bytes: 3672
#include<bits/stdc++.h>
using namespace std;
int main(){
  int x,y,z;
  cin>>x>>y>>z;
  int ans=0;
  x-=z;
  if(x>=0){
    while(1){
      x-=y;
      x-=z;
      if(x<0)break;
      ans++;
    }
  }
  cout<<ans<<endl;
  return(0);
}


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

int main(int argc, char *argv[]) {
  ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);

  int n;cin>>n;
  ll sum=0;
  std::vector<int> v(n);
  for(int i=0;i<n;i++){
    cin>>v[i];
    sum += v[i];
  }
  int m;cin>>m;
  for(int i=0;i<m;i++){
    int p,x;cin>>p>>x;p--;
    cout<<sum+(x-v[p])<<endl;
  }

  return 0;
}


Measured memory_bytes: 256
n,m = map(int, input().split())
cs = list(map(int, input().split()))
dp = [10**9]*(n+1)
dp[0] = 0
for i in range(n+1):
    for c in cs:
        if i+c < n+1:
            dp[i+c] = min(dp[i+c], dp[i]+1)
print(dp[n])


Measured memory_bytes: 7252
#include<iostream>
#include<sstream>
#include<vector>
#include<iterator>
#include<map>
#include<algorithm>
using namespace std;

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

    vector<int> P(N);
    for (int i = 0; i < N; i++)
        cin >> P[i];

    vector<int> Q(N);
    for (int i = 0; i < N; i++)
        cin >> Q[i];

    string p;
    for (int i = 0; i < N; i++)
        p += P[i] + '0';

    string q;
    for (int i = 0; i < N; i++)
        q += Q[i] + '0';

    string str(N, '0');
    for (int i = 0; i < N; i++)
        str[i] += i + 1;

    map<string, int> mp;
    do {
        mp[str];
    } while (next_permutation(str.begin(), str.end()));

    int i = 1;
    for (auto it = mp.begin(); it != mp.end(); it++, i++)
        it->second = i;

    int a = mp[p];
    int b = mp[q];

    cout << abs(a - b) << endl;

    return 0;
}


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


/* エイリアス */
#define ll long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vpi vector<pii>
#define vpll vector<pll>
#define endl '\n'

#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define em emplace
#define mp make_pair


/* 関数マクロ */
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rep2(i, n, m) for (ll i = n; i <= m; ++i)
#define rep3(i, n, m) for (ll i = n; i >= m; --i)
#define all(v) v.begin(), v.end()
#define si(v) int(v.size())
#define UNIQUE(v) sort(all(v)), v.erase(unique(all(v)),v.end())


/* 定数 */
const ll mod = 1e9 + 7;
const ll infll = (1LL << 62) - 1;
const ll inf = (1LL << 30) - 1;


/* その他 */
template<class S, class T> inline bool chmax(S &a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class S, class T> inline bool chmin(S &a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T> using pq = priority_queue<T>;
template<class T> using pqg = priority_queue<T, vector<T>, greater<T>>;


signed main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cout << fixed << setprecision(15);

  ll a, b; cin >> a >> b;
  cout << a / __gcd(a, b) * b << endl;
}


Measured memory_bytes: 3592
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() { 
  ios::sync_with_stdio(false); cin.tie(0);
  long long s;
  cin >> s;
  cout << "0 0 1000000000 1 ";
  const int k = 1000000000;
  long long y3 = (s + k - 1) / k;
  long long x3 = y3 * k - s;
  cout << x3 << " " << y3 << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define il inline
#define ll long long
const int N=2e5+5;

int n,s[2],o,v[N]; ll ans; struct node{int v,id,o;}d[N];

il bool cmp(node x,node y){return x.v<y.v;}

int main()
{
	scanf("%d",&n); int i;
	for (i=1; i<=n; i++)
		scanf("%d%d",&d[i+i-1].v,&d[i+i].v),
		d[i+i-1].id=d[i+i].id=i,d[i+i].o=1;
	std::sort(d+1,d+n+n+1,cmp);
	
	for (i=1; i<=n; i++) ans+=(ll)d[i].v,s[d[i].o]++,o|=++v[d[i].id]>1;
	if (o||s[0]==n||s[1]==n) return printf("%lld",ans),0;
	ans+=(ll)d[n+1].v-d[n].v,s[d[n].o]--,s[d[n+1].o]++;
	if (d[n].id!=d[n+1].id||s[0]==n||s[1]==n) return printf("%lld",ans),0;
	printf("%lld",ans+(ll)std::min(d[n+2].v-d[n+1].v,d[n].v-d[n-1].v));
	
	return 0;
}

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

#define int long long
#define fi first
#define se second
#define otp(n) cout << n;
#define ct(n) cout << n << endl;
#define cts(n) cout << n << " ";
#define cte cout << endl;
#define ctv(v) rep(i,(v).size()) ct(v[i])
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define repo(i,o,n) for(int i=o;i<n;i++)
#define repm(i,n) for(int i=n-1;i>=0;i--)
#define repv(i,v) for(int i=0;i<(v).size();i++)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sperase(v,n) (v).erase(remove(all(v), n), (v).end());
#define vdelete(v) (v).erase(unique(all(v)), (v).end());
#define pb(n) push_back(n);

int a,b,c,ans;

main() {
    cin >> a >> b >> c;
    ans += min(a+b,c)+b;
    if(a+b < c) ans++;
    ct(ans)
}


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

#define pi pair<int,int>
#define mp(x,y) make_pair(x,y)
#define fi first
#define se second
#define pl pair<long long,long long>
#define pb push_back
#define vi vector<int>
#define ll long long

const int MAXN=200005,mod=1e9+7;
int w[(1<<26)+5];
char t[MAXN];

int main ()
{
    int a,b,c,d,e,f,k,q,m,res;

    scanf("%s", t);
    m=1<<26;

    for (a=1; a<m; a++)
        w[a]=1000000;

    w[0]=0;
    b=0;
    res=0;

    for (a=0; t[a]; a++)
    {
        c=(1<<(t[a]-'a'));
        b^=c;
        d=w[b]+1;

        for (c=0; c<26; c++)
        {
            e=b^(1<<c);
            d=min(d,w[e]+1);
        }

        res=d;
        w[b]=min(w[b],res);
    }

    printf("%d", res);

    return 0;
}


Measured memory_bytes: 262528
#include <stdio.h>
int main(){
  int i ,j ,n ,tmp=0 ,total=0;
  while( scanf( "%d" ,&n ) ){
    if( n == 0 ){
      break;
    }
    
    int mas[n+1][n+1];
    
    for( i=0 ; i<n ; i++ ){
      for( j=0 ; j<n ; j++ ){
	scanf( "%d" ,&mas[i][j] );
	tmp += mas[i][j];
      }
      mas[i][n] = tmp;
      total += tmp;
      tmp = 0;
    }
    
    for( i=0 ; i<n ; i++ ){
      for( j=0 ; j<n ; j++ ){
	tmp += mas[j][i];
      }
      mas[n][i] = tmp;
      tmp = 0;
    }
    
    mas[n][n] = total;
    
    for( i=0 ; i<n+1 ; i++ ){
      for( j=0 ; j<n+1 ; j++ ){
	printf( "%5d" ,mas[i][j] );
      }
      printf( "\n" );
    }
    total = 0;
  }
  return 0;
}

Measured memory_bytes: 616
# include <bits/stdc++.h>
using namespace std;
const int N = 200005;
int n, a[N], f[N];
int main() {
	// freopen("B.in", "r", stdin);
	scanf("%d", &n);
	for (int i = 1; i <= n; i ++)
		scanf("%d", a + i);
	for (int i = 1; i <= n; i ++)
		f[a[i]] = f[a[i] - 1] + 1;
	printf("%d\n", n - * max_element(f + 1, f + n + 1));
	return 0;
}

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

#define debug(x) cout <<"DEBUG"<<" "<< #x << ":" << x << '\n'

// n回繰り返し
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順
#define rep1(i,n) for(int i = 1; i <= ((int)(n)); i++) // 1-indexed昇順
#define rrep(i,n) for(int i = ((int)(n)-1); i >= 0; i--)  // 0-indexed降順
#define rrep1(i,n) for(int i = ((int)(n)); i >= 1; i--)   // 1-indexed降順
#define all(x) (x).begin(),(x).end()

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vii;  // 2次元配列
typedef vector<ll> vll;
typedef vector<double> vd;
typedef pair<int, int> PII;

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

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

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


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


/*MAIN==================================================*/
signed main(){
    int _StartTime_ = clock();
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化
    // cout << fixed << setprecision(15);

    int n; cin >> n;
    vll a(n); rep(i,n) cin >> a[i];

    vll csum(n+1); rep(i,n) csum[i+1] += csum[i] + a[i];

    ll ans = infll;
    for(int i = 1; i < n; ++i) {
        chmin(ans, abs((csum[i]-csum[0]) - (csum[n] - csum[i])));
//        debug(abs((csum[i]-csum[0]) - (csum[n] - csum[i])));
    }
    cout << ans << '\n';

    // printf("ExecutionTime: %d /ms\n",1000*(int)((clock()-_StartTime_)/CLOCKS_PER_SEC));
}

Measured memory_bytes: 3328
package main

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

var isProduct = false

func dfs(i, j int) int {
	if j == 0 {
		return 0
	}

	return i * j
}

func main() {
	nextReader = newScanner()

	n, x, y := nextInt()+1, nextInt(), nextInt()

	dic := make(map[int]int, n)

	for i := 1; i < n; i++ {
		for j := i + 1; j < n; j++ {
			d := mins(
				abs(j-i),
				abs(x-i)+abs(y-j)+1,
				abs(y-i)+abs(x-j)+1,
			)

			// fmt.Println(i, j, d)

			dic[d]++
		}
	}

	for i := 1; i < n-1; i++ {
		fmt.Println(dic[i])
	}

}

/* --------------------------------------------------------------------------
 *  std.io
 * ------------------------------------------------------------------------- */
var nextReader func() string

func newScanner() func() string {
	r := bufio.NewScanner(os.Stdin)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)
	return func() string {
		r.Scan()
		return r.Text()
	}
}
func nextString() string {
	return nextReader()
}
func nextInt64() int64 {
	v, _ := strconv.ParseInt(nextReader(), 10, 64)
	return v
}
func nextInt() int {
	v, _ := strconv.Atoi(nextReader())
	return v
}
func nextInts(n int) []int {
	r := make([]int, n)
	for i := 0; i < n; i++ {
		r[i] = nextInt()
	}
	return r
}
func nextInt64s(n int) []int64 {
	r := make([]int64, n)
	for i := 0; i < n; i++ {
		r[i] = nextInt64()
	}
	return r
}
func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(nextReader(), 64)
	return f
}

func max(a, b int) int {
	if a > b {
		return a
	} else {
		return b
	}
}

func min(a, b int) int {
	if a < b {
		return a
	} else {
		return b
	}
}

func mins(t ...int) int {
	if len(t) == 0 {
		return 0
	}

	min := t[0]
	for i := 1; i < len(t); i++ {
		if min > t[i] {
			min = t[i]
		}
	}
	return min
}

func abs(a int) int {
	if a >= 0 {
		return a
	} else {
		return 0 - a
	}
}


Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
using ll  = long long;
using vl  = vector<ll>;
using vi  = vector<int>;
#define _GLIBCXX_DEBUG
#define IO_STREAM cin.tie(0);ios::sync_with_stdio(false)
#define all(x) x.begin(),x.end()
#define rep(i,sta,end) for(ll i=sta;i<end;++i)
#define lcm(a,b) (a)/__gcd((a),(b))*(b)
#define pb push_back
#define INF 1000000000000000LL
const ll MOD = 1000000007;
const double PI = acos(-1);
//|| stoll to_string
//#define DBG(a,b,c,d) //cout<<a<<" "<<b<<" "<<c<<" "<<d<<" "<<endl

signed main(){
	IO_STREAM;
	ll A,B;
	string s,b;
	cin>>A>>s;
	rep(i,0,s.size()){
		if(s[i]!='.'){
			b.pb(s[i]);
		}
	}
	B=stoll(b);
	ll ans;
	ans=A*B/100;
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3616
using System;
class Program
{
    static void Main(string[] args)
    {
        int n = int.Parse(Console.ReadLine());
        string[] input = Console.ReadLine().Split(' ');
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
        {
            a[i] = int.Parse(input[i]);
        }

        int count = 0;

        for (int i = 0; i < n; i++)
        {
            if ((i + 1) % 2 == 1 && a[i] % 2 == 1)
            {
                count++;
            }
        }
        Console.WriteLine(count);
    }
}


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

int main (){
  int n, k;
  string s;
  cin >> n >> k;
  cin >> s;
  char x = s.at(k - 1);
  if (x == 'A') {
    x = 'a';
  }
  else if (x == 'B') {
    x = 'b';
  }
  else {
    x = 'c';
  }
  s.at(k - 1) = x;
  cout << s << endl;
}
  


Measured memory_bytes: 256
#include <bits/stdc++.h>
 using namespace std;
 
 int main()
 {
     int a,b,c,d;
     long long s1,s2;
 
     cin >> a >> b >> c >> d;
 
     s1 = a * b;
     s2 = c * d;
 
     if (s1 < s2)
         s1 = s2;
 
     printf("%lld\n",s1);
 
     return 0;
 }


Measured memory_bytes: 256