akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define cases long long test;cin>>test;while(test--)
#define f_io ios::sync_with_stdio(false); cin.tie(0)
#define foi(a,n) for(long long i=a;i<n;i++)
#define foj(a,n) for(long long j=a;j<n;j++)
#define fok(a,n) for(long long k=a;k<n;k++)
#define ll long long
#define MOD 1000000007
#define INF 1000000000
using namespace std;

int main()
{
    f_io;
    ll n;
    cin >> n;
    if(n)
        cout << "0";
    else
    {
        cout << "1";
    }
    
    return 0;
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;

const int N = 15e4;
vector<vector<int>> g(N);
map<int, ld> dp[N];
int n;
ld dfs(int i, int p, int f = 0) {
  if(dp[i].count(p)) return dp[i][p];
  int cnt = 0;
  ld res = 0;
  if(f || p == -1) {
    for(int j : g[i]) if(j != p) {
      cnt++;
      res += dfs(j, i, f);
    }
  } else {
    cnt = g[i].size() - 1;
    res = (dfs(i, -1, f) - 1.0) * g[i].size() - dfs(p, i, f);
  }
  if(cnt) res /= cnt, res += 1.0;
  return dp[i][p] = res;
}
int main() {
  std::ios::sync_with_stdio(false), std::cin.tie(0);
  cin >> n;
  for(int i = 0; i < n - 1; i++) {
    int a, b; cin >> a >> b; a--; b--;
    g[a].emplace_back(b);
    g[b].emplace_back(a);
  }
  dfs(0, -1, 1);
  cout << fixed << setprecision(8);
  for(int i = 0; i < n; i++) cout << dfs(i, -1) << "\n";
  return 0;
}


Measured memory_bytes: 61696
#include <stdio.h>

typedef long long int ll;
constexpr int kMod = int(1E9 + 7), kN = int(2E5 + 10);

ll a[kN], s[kN];

int main() {
	int n;
	ll ans = 0;
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) scanf("%lld", &a[i]);
	s[n] = a[n];
	for (int i = n - 1; i >= 1; i--) s[i] = (s[i + 1] + a[i]) % kMod;
	for (int i = 1; i < n; i++) ans += a[i] * s[i + 1] % kMod;
	printf("%lld\n", ans % kMod);
}


Measured memory_bytes: 4860
#include <bits/stdc++.h>
#define PB push_back
#define MP make_pair
using namespace std;
template<typename T>
inline T read(T&x){
	x=0;int f=0;char ch=getchar();
	while (ch<'0'||ch>'9') f|=(ch=='-'),ch=getchar();
	while (ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
	return x=f?-x:x;
}
/*const int N=10000+10;
int n;
int main(){
	cin>>n;
	puts(n<=999?"ABC":"ABD");
	return 0;
}*/
/*const int N=1000+10;
int i,a,b,posa,posb,sum[N];
int get(int x){
	for (int i=1;i<=999;i++){
		if (x==sum[i]) return i;
		if (x>sum[i-1]&&x<sum[i]) return i;
	}
}
int main(){
	cin>>a>>b;
	for (i=1;i<=1000;i++){
		sum[i]=sum[i-1]+i;
		if (i<=20) cout<<sum[i]<<endl;
	}
	posa=get(a);
	posb=get(b);
	cout<<(posb-posa+1)<<endl;
	return 0;
}*/
const int N=100000+10;
int dp[N];
int i,n,V,num[]={1,6,36,216,1296,7776,46656,9,81,729,6561,59049};
int main(){
	memset(dp,0x3f3f3f3f,sizeof(dp));
	dp[0]=0;
	for (i=0;i<12;i++){
		for (V=num[i];V<=100000;V++)if(dp[V-num[i]]!=0x3f3f3f3f){
			dp[V]=min(dp[V],dp[V-num[i]]+1);
		}
	}
	cin>>n;
	printf("%d\n",dp[n]);
	return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<cmath>
#define LL long long 
using namespace std;
int main()
{
	LL x, k, d, ans, cnt;
	cin>>x>>k>>d;
	if(x < 0)	x = -x;
	cnt = x / d;
	if(k <= cnt)
	{
		cout<< x - d * k <<endl;
		return 0;
	}
	k -= cnt;
	ans = x % d;
	if(k % 2)
		cout<< d - ans<<endl;
	else
		cout<< ans <<endl;
	return 0;
}

Measured memory_bytes: 3612
//khodaya khodet komak kon
#include <bits/stdc++.h>

#define F first
#define S second
#define pb push_back
#define all(x) x.begin(), x.end()
#pragma GCC optimise ("ofast")
#pragma GCC optimise("unroll-loops")

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

const int N = 200000 + 10;
const ll MOD = 1000000000 + 7;
const ll INF = 1000000000000000000;
const ll LOG = 25;

int A, B, M, a[N], b[N], aa[N], bb[N], c[N];

int32_t main(){
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> A >> B >> M;
	int mn = 1000000000;
	for (int i = 1; i <= A; i++){
		cin >> a[i];
		mn = min(a[i], mn);
	}
	int mn2 = 1000000000;
	for( int i = 1; i <= B; i++){
		cin >> b[i];
		mn2 = min(mn2, b[i]);
	}
	int ans = mn + mn2;
	for (int i = 1; i <= M; i++){
		cin >> aa[i] >> bb[i] >> c[i];
		ans = min(ans, a[aa[i]] + b[bb[i]] - c[i]);
	}

	cout << ans;








	return 0;
}


Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
#define rep(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
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; }
using ll = long long;
const ll MOD = 1e9+7; ll LLINF = 1LL << 60; int INF = INT_MAX;

//

int main(){
    int n,k,R,S,P;
    cin>>n>>k>>R>>S>>P;
    string t; cin>>t;
    vector<int> score(t.size(),0);
    rep(i,0,t.size()){
        if(t[i]=='r') score[i]=P;
        if(t[i]=='s') score[i]=R;
        if(t[i]=='p') score[i]=S;
    }
    for(int i=k; i<t.size(); i++){
        if(t[i]==t[i-k]){
            t[i]='o';
            score[i]=0;
        }
    }
    ll sum=0;
    rep(i,0,t.size()){
        sum+=score[i];
    }
    cout<<sum<<endl;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
using intl = long long;
using itnl = long long;//typo用
using itn = int;//typo用
using ld = long double;
using namespace std;
#define rep(i, n) for(intl i = 0; i < (intl)(n); i++)
#define rrep(i, n) for(intl i = (intl)(n) - 1; i >= 0; i--)
#define repi(i, a, b) for(intl i = (intl)(a); i < (intl)(b); i++)
#define rrepi(i, a, b) for(intl i = (intl)(a) - 1; i >= (intl)(b); i--)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,1,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define alength(a) (sizeof(a) / sizeof(a[0]))
#define debug(x) cout << #x << ":" << x << endl
#define rdebug(i,x) rep(i, alength(x))cout << #x << "[" << i << "]:" << x[i] << endl//1次元配列の出力
#define rrdebug(i, j, x) rep(i, alength(x))rep(j, alength(x[i]))cout << #x << "[" << i << "][" << j << "]:" << x[i][j] << endl//二次元配列の出力
#define pb push_back
#define mp make_pair
#define pii pair<intl,intl>
const intl INF = 1e9;
const intl MOD = 1e9+7;
const ld EPS = 1.0e-14;//-9
const ld PI = acos(-1);
void fp(bool f){cout << (f ? "Yes" : "No") << endl;}
void fp(bool f, string s, string t){cout << (f ? s : t) << endl;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) {a = b; return true;} return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) {a = b; return true;} return false; }
intl gcd(intl a, intl b){ if(!b)return a; return gcd(b, a % b); }
intl lcm(intl a,intl b){ return a / gcd(a, b) * b; }
intl kai(intl k){//k!を求める関数,
    intl a = 1;
    for(int i = 2; i <= k; i++){
        a *= i;
    }
    return a;
}
intl digit10(intl a){//aを10進数で表したときの桁数を求める関数
    intl b = 0;
    do{
        a /= 10;
        b++;
    }while(a);
    return b;
}

//--------------入力受け取る場所----------------------------------------------------

string s,t;

void input_var(){
    cin >> s;
}
//-------------------------------------------------------------------------------


signed main(){
    cout << fixed << setprecision(10);
    input_var();
    rep(i,s.length()){
        if(s[i] == '?')cout << 'D';
        else cout << s[i];
    }
    return 0;
}

Measured memory_bytes: 3728
import heapq

n,m=map(int, input().split())
a=list(map(int, input().split()))
for i in range(n):
    a[i]=-a[i]
heapq.heapify(a)

for i in range(m):
    x=-(-heapq.heappop(a)//2)
    heapq.heappush(a,x)

for i in range(n):
    a[i]=-a[i]

print(sum(a))
    
    

    


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

int main(){
    int N,A,B,C,D;
    cin >> N >> A >> B >> C >> D;
    string S;
    cin >> S;

    if(B<C){
        for (int i = A-1; i < max(C-1,D-1); i++)
        {
            if(S[i]=='#' && S[i+1]=='#'){
                    cout << "No" << endl;
                    return 0;
            }
        }
    }

    else if(B>C){
        for (int i = A-1; i < C-1; i++)
        {
            if(S[i]=='#' && S[i+1]=='#'){
                    cout << "No" << endl;
                    return 0;
            }
        }
        for (int i = B-1; i < D-1; i++)
        {
            if(S[i]=='#' && S[i+1]=='#'){
                    cout << "No" << endl;
                    return 0;
            }
        }
    }


    if(C>D){
        for (int i = B-2; i < D-1; i++)
        {
            if(S[i] == '.' && S[i+1] == '.' && S[i+2] == '.'){
                cout << "Yes" << endl;
                return 0;
            }
        }
            cout << "No" << endl;
            return 0;
    }

    cout << "Yes" << endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main() {
  int A,B,C;
  cin>>A>>B>>C;
  if(A+B+C<22){
    cout<<"win"<<endl;
  }
  else if(A+B+C>21){
    cout<<"bust"<<endl;
  }
}


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

using namespace std;
typedef long long ll;
#define loop(i,a,b) for(ll i=(a); i<ll(b); i++)
#define rep(i,b) loop(i,0,b)

typedef vector<int> vi;

int solve(string const& s){
    vi v(10);
    rep(i, 10) v[i] = s[i] - '0';
    while (v.size() != 1){
        vi w(v.size() - 1);
        rep(i, w.size()){
            w[i] = v[i] + v[i + 1];
            w[i] %= 10;
        }
        swap(v, w);
    }
    return v.front();
}

int main(){
    string s;
    while (cin >> s){
        cout << solve(s) << endl;
    }
}

Measured memory_bytes: 1184
#include<bits/stdc++.h>
using namespace std;
long long arr[4];
int main()
{
    long long a,b,c,d;
    cin>>a>>b>>c>>d;
    arr[0]=a*c;
    arr[1]=a*d;
    arr[2]=b*c;
    arr[3]=b*d;
    sort(arr,arr+4);
    cout<<arr[3]<<endl;




    return 0;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
using pii=pair<int,int>;
using ll=long long;
using pll=pair<ll,ll>;

#define fi first
#define se second
#define pb push_back
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define MOD 1000000007

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

int main() {
	int N;
	cin >> N;
	vector<ll> A(N);
	rep(i,N) cin >> A[i];
	sort(A.begin(),A.end());
	ll sum = 0;
	ll cnt = 0;
	rep(i,N) {
		if(sum * 2 >= A[i]) {
			cnt++;
		}
		else {
			cnt = 1;
		}
		sum += A[i];
	}
	cout << cnt << endl;

  return 0;
}


Measured memory_bytes: 1024
# coding: utf-8
W=[]
end=""
for i in range(int(input())):
    w=input()
    if w in W:
        print("No")
        exit()
    else:
        if 0 < i and end != w[0]:
            print("No")
            exit()
        end=w[-1::]
        W.append(w)
else:
    print("Yes")


Measured memory_bytes: 3060
// finish date: 2019/2/9

#include <bits/stdc++.h>

using namespace std;

#define FOR(i, a, b) for(int (i)=a;(i)<(b);(i)++)
#define rep(i, n)  FOR(i,0,n)
//#define input(name)
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<double> vd;
typedef vector<vector<double>> vvd;
typedef vector<vector<vector<double>>> vvvd;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, pair<int, int>> plii;
const int bigmod = 1000000007;
const int INF = 1050000000;
const long long INFll = 100000000000000000;


int main() {
    string S, T;
    int A, B;
    string U;
    cin >> S >> T >> A >> B >> U;
    if (S == U) {
        cout << A - 1 << " " << B << endl;
    } else {
        cout << A << " " << B - 1 << endl;
    }


    return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*; 
import java.text.*;
//Solution Credits: Taranpreet Singh
public class Main{
    //SOLUTION BEGIN
    void solve(int TC) throws Exception{
        int k = ni();
        pn((k/2)*((k+1)/2));
    }
    //SOLUTION ENDS
    long mod = (int)1e9+7, IINF = (long)1e18;
    final int MAX = (int)1e5+1, INF = (int)1e9, root = 3;
    DecimalFormat df = new DecimalFormat("0.00000000");
    double PI = 3.141592653589793238462643383279502884197169399375105820974944, eps = 1e-8;
    static boolean multipleTC = false, memory = true;
    FastReader in;PrintWriter out;
    void run() throws Exception{
        in = new FastReader();
        out = new PrintWriter(System.out);
        int T = (multipleTC)?ni():1;
        //Solution Credits: Taranpreet Singh
        for(int i = 1; i<= T; i++)solve(i);
        out.flush();
        out.close();
    }
    public static void main(String[] args) throws Exception{
        if(memory)new Thread(null, new Runnable() {public void run(){try{new Main().run();}catch(Exception e){e.printStackTrace();}}}, "1", 1 << 28).start();
        else new Main().run();
    }
    long gcd(long a, long b){return (b==0)?a:gcd(b,a%b);}
    int gcd(int a, int b){return (b==0)?a:gcd(b,a%b);}
    int bit(long n){return (n==0)?0:(1+bit(n&(n-1)));}
    void p(Object o){out.print(o);}
    void pn(Object o){out.println(o);}
    void pni(Object o){out.println(o);out.flush();}
    String n(){return in.next();}
    String nln(){return in.nextLine();}
    int ni(){return Integer.parseInt(in.next());}
    long nl(){return Long.parseLong(in.next());}
    double nd(){return Double.parseDouble(in.next());}

    class FastReader{
        BufferedReader br;
        StringTokenizer st;
        public FastReader(){
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        public FastReader(String s) throws Exception{
            br = new BufferedReader(new FileReader(s));
        }

        String next(){
            while (st == null || !st.hasMoreElements()){
                try{
                    st = new StringTokenizer(br.readLine());
                }catch (IOException  e){
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        String nextLine(){
            String str = "";
            try{    
                str = br.readLine();
            }catch (IOException e){
                e.printStackTrace();
            }   
            return str;
        }
    }
}

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

int main() {
    
    int n, i;
    double c=0;
    cin >> n;
    for(i=1; i<=n; i++){
        if(i%2!=0){
            ++c;
        }
    }
    cout << fixed << setprecision(10) << c/n << endl;
    
    
    
    
    
	return 0;
}

Measured memory_bytes: 3744
# -*- coding: utf-8 -*-

import sys, re
from collections import deque, defaultdict, Counter
from math import sqrt, hypot, factorial, pi, sin, cos, radians, log10
if sys.version_info.minor >= 5: from math import gcd
else: from fractions import gcd 
from heapq import heappop, heappush, heapify, heappushpop
from bisect import bisect_left, bisect_right
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul, xor
from copy import copy, deepcopy
from functools import reduce, partial
from fractions import Fraction
from string import ascii_lowercase, ascii_uppercase, digits
from datetime import date

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def round(x): return int((x*2+1) // 2)
def fermat(x, y, MOD): return x * pow(y, MOD-2, MOD) % MOD
def lcm(x, y): return (x * y) // gcd(x, y)
def lcm_list(nums): return reduce(lcm, nums, 1)
def gcd_list(nums): return reduce(gcd, nums, nums[0])
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

A,B=MAP()
A-=1
A2=[0]*50
B2=[0]*50

C=[0]*50
for i in range(1,50):
    T=2**i
    acnt=bcnt=0
    A2[i]+=A//T*(T//2)
    A2[i]+=max(A%T-(T//2-1), 0)
    B2[i]+=B//T*(T//2)
    B2[i]+=max(B%T-(T//2-1), 0)
    if (B2[i]-A2[i])%2==1:
        C[i]=1
ans=0
for i in range(1,50):
    if C[i]:
        ans+=2**(i-1)
print(ans)


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

int main() {
  int a, b, c, d; cin >> a >> b >> c >> d;
  if (abs(a - b) <= d && abs(b - c) <= d) cout << "Yes" << endl;
  else if (abs(a-c) <= d)                 cout << "Yes" << endl;
  else                                    cout << "No" << endl;
}


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

int main() {
  int N, min, cnt;
  cin >> N;
  cnt = 1;
  vector<int> num(N);
  cin >> num.at(0);
  min = num.at(0);
  for (int i = 1; i < N; i++) {
    cin >> num.at(i);
    if (num.at(i) < min) {
      cnt++;
      min = num.at(i);
    }
  }
  cout << cnt;
}

Measured memory_bytes: 1024
// B - ISU

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// const int INF = 2147483647;
// const ll INF = 9223372036854775807;
// const ll MOD = 1e9 + 7;

int main() {
	int X, Y, Z;
	cin >> X >> Y >> Z;

	int ans = 0;
	int need = Z;
	while (1) {
		need += Y + Z;
		if (need > X) break;
		ans++;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include<list>
#include <algorithm>
#include <string>
#include <math.h>
#include<map>
#include <utility>

#include<queue>
using namespace std;
#define REP(i,k,n) for(int i=k;i<n;i++)
 
#define INF (1e10)
typedef long long unsigned int ll;
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))
#define MOD 1000000007

template<typename T>
int vector_finder(std::vector<T> vec, T number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}

template<typename T>
T gcd(T a,T b){
	if(b>0){
		return gcd(b, a % b);
	}else{
		return a;
	}
}

template<typename T>
T lcm(T a,T b){
	T g = gcd(a, b);
	return a * b / g;
}

void clear( std::queue<pair<int,int> > &q )
{
   std::queue<pair<int,int> > empty;
   std::swap( q, empty );
}
bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}
template<typename T>
std::vector<T> enum_div(T n)//nの約数を列挙
{
	std::vector<T> ret;
	for(T i=1 ; i*i<=n ; ++i)
	{
		if(n%i == 0)
		{
			ret.push_back(i);
			if(i!=1 && i*i!=n)
			{
				ret.push_back(n/i);
			}
		}
	}
	return ret;
}

int N,M;


int main()
{
  cin>>N;

  ll a[N];
  REP(i,0,N){
    cin >> a[i];
  }
  sort(a,a+N);

  ll sum[N];
  sum[0]=a[0];
  REP(i,1,N){
    sum[i]=sum[i-1]+a[i];
  }
  int ans=1;

  for(int i=N-2;i>=0;i--){
    if(2*sum[i]>=a[i+1]){
      ans++;
    }else{
      break;
    }
  }

  cout<<ans<<endl;

  return 0;
}

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

#define rep(i,s,n) for (int i = (int)s; i < (int)n; i++)
#define ll long long
#define pb push_back
#define All(x) x.begin(), x.end()
#define Range(x, i, j) x.begin() + i, x.begin() + j
#define lbidx(x, y) lower_bound(x.begin(), x.end(), y) - x.begin()
#define ubidx(x, y) upper_bound(x.begin(), x.end(), y) - x.begin()
#define BiSearchRangeNum(x, y, z) lower_bound(x.begin(), x.end(), z) - lower_bound(x.begin(), x.end(), y)turn idx;
#define deg_to_rad(deg) ((((double)deg)/((double)360)*2*M_PI))
#define rad_to_deg(rad) ((((double)rad)/(double)2/M_PI)*(double)360)

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

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

int main() {
  string S, T;
  cin >> S >> T;
  int ans = 0;
  rep(i, 0, S.size()) {
    char s = S[i];
    char t = T[i];
    if (s == t) {
      ans += 1;
    }
  }

  cout << ans << endl;
};


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

const int inf = 1e9;
int G[1000][1000];
int D[1000][1000];
int main() {
  int n, m;
  cin >> n >> m;
  rep(i, n) {
    rep(j, n) {
      G[i][j] = D[i][j] = inf;
    }
  }
  
  rep(z, m) {
    int a, b;
    cin >> a >> b;
    --a; --b;
    G[a][b] = D[a][b] = 1;
  }
  
  rep(k, n) rep(i, n) rep(j, n)
    D[i][j] = min(D[i][j], D[i][k] + D[k][j]);
  
  int l = inf;
  int s = 0;
  rep(i, n) {
    if (D[i][i] < l) {
      l = D[i][i];
      s = i;
    }
  }
  
  if (l == inf) {
    cout << -1 << endl; 
  } else {
    cout << l << endl;
    int c = s;
    int k = l;
    while (true) {
      --k;
      cout << c + 1 << endl;
      int nxt = -1;
      rep(i, n) {
        if (c == i) continue;
        if (G[c][i] == inf) continue;
        if (D[i][s] == k) {
          nxt = i;
          break;
        }
      }
      if (nxt == -1) break;
      c = nxt;
    }
  }
}



Measured memory_bytes: 8064
#pragma GCC optimize("O3")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;

template <class T> inline T chmax(T &a, const T b) {return a = (a < b) ? b : a;}
template <class T> inline T chmin(T &a, const T b) {return a = (a > b) ? b : a;}

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;

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

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

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

    int a, b, c, d; cin>>a>>b>>c>>d;
    
    int cnt = 0;
    while(a > 0 && c > 0){
        if(cnt % 2 == 0) c -= b;
        else a -= d;
        cnt++;
    }

    if(a <= 0) cout << "No" << endl;
    else cout << "Yes" << endl;

    return 0;
}


Measured memory_bytes: 3608
#pragma target("avx")
#pragma optimize("O3")
#include<bits/stdc++.h>
using ll = int_fast64_t;
using P = std::pair<ll,ll>;
using PP = std::pair<ll,P>;
using V = std::vector<ll>;
template<typename T> using pq = std::priority_queue<T>;
template<typename T> using rpq = std::priority_queue<T, std::vector<T>, std::greater<T>>;

#define REP(i,b,e) for(ll i=b; i<e; i++)
#define ALL(vec) vec.begin(),vec.end()
#define PRINT(vec) printf("[ ");for(auto &i:vec)printf("%ld ",i);puts("]");
#define SCAN(vec) for(auto &i:vec)scanf("%ld",&i)
#define fi first
#define se second

const int MOD = 1e9+7;
const ll INF = 1e18;
int dx[] = {0, 1, 0, -1, 1, 1, -1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

int main(){
        ll x = 0;
        char c;
        while((c=getchar())!='\n'){
                x += (c-'0');
                x %= 9;
        }
        if(x==0) puts("Yes");
        else puts("No");
        return 0;
}


Measured memory_bytes: 3560
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<string>
#include<cstring>
#include<algorithm>
#include<sstream>
#include<complex>
#include<functional>
#include<vector>
#include<map>
#include<queue>
#include<deque>
#include<stack>
#include<set>

using namespace std;
#define endl '\n'
#define pb push_back
#define fst first
#define scd second
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define REP(i,n) for(int i = 0;i < (n);i++)
#define FOR(i,a,b) for(int i = (a);i <= (b);i++)
#define YES(n) cout << ((n) ? "YES" : "NO" ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No" ) << endl

constexpr int MOD = 1000000007;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vector<int>> vii;
typedef vector<ll> vl;

template <class T = int> T in() { T x; cin >> x; return (x); }
template <class T = int> void out(T x) { cout << (x) << endl; }

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

// value

void solve() {
	
	int N, K;
	cin >> N >> K;
	vl a(N);
	for (int i = 0; i < N; i++) {
		cin >> a[i];
	}

	vl part;
	for (int i = 0; i < N; i++) {
		ll sum = 0;
		for (int j = i; j < N; j++) {
			sum += a[j];
			part.pb(sum);
		}
	}

	ll ans = 0;
	for (int i = 62; i >= 0; i--) {
		ll cnt = 0;
		for (int j = 0; j < part.size(); j++) {
			if ((part[j] & (ans + (1LL << i))) == (ans + (1LL << i))) {
				cnt++;
			}
		}
		if (cnt >= K) ans += 1LL << i;
	}
	
	cout << ans << endl;

	return;

}

int main() {

	cin.tie(0);
	ios::sync_with_stdio(false);

	solve();

	return 0;

}

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

int main(){
    int a, b, i, j, counter=0;

    cin >> a >> b;
    for(i=a;i <= b;i++){
        string current = to_string(i);
        for(j=0;j < current.length() / 2 ;j++){
            if(current[j] != current[current.length() - j - 1]) break;
        }
        if(j != 0 && j == current.length() / 2) counter++;
    }
    cout << counter << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
//赤と緑でsort
int main(){
  ll X,Y,A,B,C; cin>>X>>Y>>A>>B>>C;
  vector<ll> R(A,0), G(B,0);
  for(int i=0; i<A; i++){
    ll p; cin>>p; R[i]=p;
  }
  for(int i=0; i<B; i++){
    ll q; cin>>q; G[i]=q;
  }  
  priority_queue<ll> pq;
  for(int i=0; i<C; i++){
    ll r; cin>>r; pq.push(r);
  }
  sort(R.begin(),R.end(),greater<ll>());
  sort(G.begin(),G.end(),greater<ll>());
  for(int i=0; i<X; i++)
    pq.push(R[i]);
  for(int i=0; i<Y; i++)
    pq.push(G[i]);
  ll fin=X+Y, ans=0;
  for(int i=0; i<fin; i++){
    ans+=pq.top();
    pq.pop();
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 8048
n = input()
t = []
a = []
c_t = 1
c_a = 1
for i in xrange(n):
    p,q = map(int, raw_input().split())
    t.append(p)
    a.append(q)

for i in xrange(n):
    if t[i] >= c_t and a[i] >= c_a:
        c_t = t[i]
        c_a = a[i]
    else:
        m = max(-(-c_t/t[i]), -(-c_a/a[i]))
        c_t = t[i]*m
        c_a = a[i]*m

print c_t+c_a



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

int main() {
  int s; cin >>s;
  int i = 1;
  ll buf = s;
  set<ll> n; n.insert(s);
  while(n.size() == i){
    i++;
    if (buf%2==0) buf /= 2;
    else buf = 3*buf+1;
    n.insert(buf);
  }
  int ans = i;
  cout <<ans;
  cout <<endl;
}


Measured memory_bytes: 256
import java.util.*;
class Main{
  public static void main(String[] args){
    Scanner scan=new Scanner(System.in);
    int N=scan.nextInt();
    scan.nextLine();
    String[] W=new String[N];
    for(int i=0;i<N;i++){
      W[i]=scan.nextLine();
    }
    
    for(int i=0;i<N-1;i++){
      for(int j=i+1;j<N;j++){
        if(W[i].equals(W[j])){
          System.out.println("No");
          System.exit(0);
        }
      }
    }
      for(int i=0;i<N-1;i++){
        int j=i+1;
        String A=W[i].substring(W[i].length()-1);
        String B=W[j].substring(0,1);
        if(!A.equals(B)){
          System.out.println("No");
          System.exit(0);
        }
      }
      System.out.println("Yes");
    }
  }


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

int main() {
  int N,ans=0,flag=0;
  cin >> N;
  long int a[N];
  for(int i=0; i<N; i++){
    cin >> a[i];
  }
  while(flag==0){
    for(int i=0; i<N; i++){
	  if(a[i]%2 != 0){
        flag=1;
 	    cout << ans << endl;
        break;
	  }
	  a[i] /= 2;
	}
  ans++;
  }
}


Measured memory_bytes: 256
N = int(input())

t_pre = 1
a_pre = 1
for i in range(N):
    t, a = map(int, input().split())
    if t_pre<=t and a_pre<=a:
        t_pre = t
        a_pre = a
    else:
        n = max((t_pre+t-1)//t,(a_pre+a-1)//a)        
        t_pre = n*t
        a_pre = n*a
print(t_pre+a_pre)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
long long int m1k=0,m5k=0,m10k=0;

int main()
{
    long long int i=0,j=0,k=0,n,m,sum=0;
    cin>>n>>m;
    int flag=0;
    for(i=0; i<=n; i++)
    {
        for(j=0; j<=n; j++)
        {
            for(k=0; k<=n; k++)
            {
                sum=k*10000+j*5000+i*1000;
                if(sum>m||i+j+k>n)
                    break;
                if(m==sum&&n==i+j+k)
                {
                    flag=1;
                    break;
                }
            }
            if(flag==1)
                break;
        }
        if(flag==1)
            break;
    }
    if(flag==1)
        cout<<k<<" "<<j<<" "<<i;
    else
        cout<<-1<<" "<<-1<<" "<<-1;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <random>
#include <unordered_map>
#include <unordered_set>

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
#define rep(i,n) for(ll i = 0;i < (ll)n;i++)
#define ALL(x) (x).begin(),(x).end()
#define MOD 1000000007



int main(){
  
  ll n,K;
  cin >> n >> K;
  vector<ll> s(n+1,0);
  map<ll,ll> r;
  r[0] = 1;
  ll res = 0;
  rep(i,n){
    if(i-K+1 >= 0)r[s[i-K+1]]--;
    ll x;cin >> x;
    s[i+1] = (s[i]+x-1)%K;
    res += r[s[i+1]];
    r[s[i+1]]++;
  }
  cout << res << "\n";
  

  return 0;
}

Measured memory_bytes: 17224
import itertools
import sys
import math
import numpy as np
from collections import deque
from itertools import combinations
from functools import reduce
from functools import lru_cache
sys.setrecursionlimit(10**9)

def main():
    N = int(input())
    A = list(map(int,input().split()))
    A_sorted = sorted(A)
    count = [0] * (N+1)

    pre = A_sorted[0]
    count[pre] = 1
    for i in range(1,N):
        if pre == A_sorted[i]:
            count[pre] += 1
        else:
            pre = A_sorted[i]
            count[pre] = 1

    sum = 0
    for i in range(len(count)):
        sum += count[i] * (count[i]-1) // 2

    for a in A:
        minus = count[a] * (count[a]-1) // 2
        plus = (count[a]-1) * (count[a]-2) // 2
        print(sum + plus - minus)




if __name__ == "__main__":
  main()


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

using namespace std;

struct Team {
    int id, point, rank;

    bool operator<(const Team& right) const {
        return point > right.point;
    }
} team[100];

int main() {
    int id, point, n = 0;
    while (1) {
        scanf("%d,%d", &id, &point);
        if (id == 0) {
            break;
        }
        team[id - 1].id = id;
        team[id - 1].point = point;
        n++;
    }
    sort(team, team + n);
    team[0].rank = 1;
    for (int i = 1, rank = 1; i < n; i++) {
        if (team[i].point == team[i - 1].point) {
            team[i].rank = rank;
        }
        else {
            team[i].rank = ++rank;
        }
    }
    while (cin >> id) {
        for (int i = 0; i < n; i++) {
            if (team[i].id == id) {
                cout << team[i].rank << endl;
                break;
            }
        }
    }

    return 0;
}

Measured memory_bytes: 1264
s=[0 for _ in range(26)]
t=[0 for _ in range(26)]
S=input()
T=input()

for i in range(len(S)):
  s[ord(S[i])-ord('a')]+=1
  t[ord(T[i])-ord('a')]+=1

s.sort()
t.sort()
print('Yes' if s==t else 'No')

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
void pn(){
    puts("No");
}
void py(){
    puts("Yes");
}
const int M=1e3+3;
char s[M];
int main(){
    double n;
    scanf("%lf",&n);
    printf("%.7f",n*n*n/27.0);

    return 0;
}


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

const int Maxn = 300010;
int sum_e[Maxn], sum_w[Maxn];

int main(){
    int n;
    string s;
    cin >> n >> s;
    for (int i = 0; i < n; i++){
        sum_e[i + 1] = sum_e[i] + (int)(s[i] == 'E');
        sum_w[i + 1] = sum_w[i] + (int)(s[i] == 'W');
    }

    int ans = Maxn;
    for (int i = 0; i < n; i++){
        int cnt = sum_w[i] + sum_e[n] - sum_e[i + 1];
        ans = min(ans, cnt);
    }

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

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

int main(){
  int n;
  int i,j,k;
  cin >> n;
  vector<int> bou(n);
  int ans=0;
  rep(i,n) cin >> bou[i];
  sort(bou.begin() ,bou.end() );
  for(i=0;i<n-2;i++){
  	for(j=i+1;j<n-1;j++){
    	for(k=j+1;k<n;k++){
        	if(bou[k]<bou[i]+bou[j]){
            	ans ++;
            }
        }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<string>
#define mod 1000000007
using ll = long long;
using namespace std; 

int main(){
    string s,t; 
    cin >> s >> t;
    ll ans=0;
    for (int i=0;i<s.size();i++){
        char q=s[i];
        char w=t[i];
        if (q!=w) ans++;
    }
    cout << ans << "\n";
}



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

int main() {
	int N,A,B;
	vector<int> P;
	cin >> N >> A >> B;
	for (int n(0); n < N; ++n) {
		int p;
		cin >> p;
		P.push_back(p);
	}
	int counter(0),counter2(0),counter3(0);
	for (int i(0); i < P.size(); ++i) {
		if (P[i] <= A) {
			++counter;
			P.erase(P.begin()+i);
			--i;
			continue;
		}
		if (A+1 <= P[i] && P[i] <= B) {
			++counter2;
			P.erase(P.begin()+i);
			--i;
			continue;
		}
		if (B+1 <= P[i]) {
			++counter3;
			P.erase(P.begin()+i);
			--i;
			continue;
		}
	}
	cout << min(min(counter,counter2),counter3);
	return 0;
}

Measured memory_bytes: 256
import copy

class Card:
    def __init__(self, str):
        self.mark = str[0]
        self.number = int(str[1:])
        
    def __str__(self):
        return self.mark + str(self.number)
        
n = int(input())
card_list = [Card(c) for c in input().split()]

# Bubble Sort
def bubble_sort(a):
    a = copy.copy(a)
    n = len(a)
    for i in range(n):
        for j in range(0, n-i-1):
            if a[j].number > a[j+1].number:
                a[j], a[j+1] = a[j+1], a[j]
    return a

sorted_card_list1 = bubble_sort(card_list)
print(" ".join([str(c) for c in sorted_card_list1]))
print("Stable")

# Selection Sort
def selection_sort(a):
    a = copy.copy(a)
    n = len(a)
    for i in range(n):
        min_index = i
        for j in range(i+1, n):
            if a[j].number < a[min_index].number:
                min_index = j
        if i != min_index:
            a[i], a[min_index] = a[min_index], a[i]
    return a

sorted_card_list2 = selection_sort(card_list)
is_stable = sorted_card_list1 == sorted_card_list2
print(" ".join([str(c) for c in sorted_card_list2]))
print("Stable" if is_stable else "Not stable")



Measured memory_bytes: 6348
#include<bits/stdc++.h>
using namespace std;
using Int = long long;

template<typename T> 
map<T, Int> factorize(T x){
  map<T, Int> res;
  for(Int i=2;i*i<=x;i++){
    while(x%i==0){
      x/=i;
      res[i]++;
    }
  }
  if(x!=1) res[x]++;
  return res;
}

//INSERT ABOVE HERE
Int cop[2020][2020];
signed main(){
  Int n;
  cin>>n;
  vector<Int> a(n);
  for(Int i=0;i<n;i++) cin>>a[i];
  sort(a.begin(),a.end());

  vector<Int> ans(n);

  memset(cop,0,sizeof(cop));
  
  for(Int i=0;i<n;i++)
    for(Int j=0;j<n;j++)
      cop[i][j]=__gcd(a[i],a[j])>1;

  Int m=0;
  map<Int, Int> r;

  vector<vector<Int> > G(n*100);
  for(Int i=0;i<n;i++){
    auto x=factorize(a[i]);
    for(auto p:x){
      if(!r.count(p.first)) r[p.first]=m++;
      G[i].emplace_back(n+r[p.first]);
      G[n+r[p.first]].emplace_back(i);
    }
  }
  
  vector<Int> used(n+m,0),post(n,0);
  for(Int t=0;t<n;t++){
    vector<Int> cs(n+m,-1);
    Int color=0;
    for(Int i=0;i<n+m;i++){
      if(used[i]||~cs[i]) continue;
      queue<Int> q;
      cs[i]=color;
      q.emplace(i);
      while(!q.empty()){
	Int v=q.front();q.pop();
	for(Int u:G[v]){
	  if(used[u]||~cs[u]) continue;
	  cs[u]=color;
	  q.emplace(u);
	}
      }
      color++;
    }
    
    Int idx=-1;
    for(Int i=0;i<n;i++){
      if(used[i]||post[i]) continue;
      idx=i;
      break;
    }
    
    used[idx]=1;
    ans[t]=idx;
    
    for(Int i=0;i<n;i++){
      if(cs[idx]!=cs[i]) continue;
      if(cop[idx][i]) post[i]=0;
      else if(a[idx]<a[i]) post[i]=1;
    }
  }


  vector<Int> b(n);
  for(Int i=0;i<n;i++) b[i]=a[ans[i]];
  
  vector<vector<Int> > H(n);
  for(Int i=0;i<n;i++)
    for(Int j=i+1;j<n;j++)
      if(__gcd(b[i],b[j])>1) H[i].emplace_back(j);

  vector<Int> indeg(n);
  for(Int i=0;i<n;i++)
    for(Int j:H[i]) indeg[j]++;
  
  using P = pair<Int, Int>;
  priority_queue<P> pq;
  for(Int i=0;i<n;i++)
    if(!indeg[i]) pq.emplace(b[i],i);

  vector<Int> c;
  while(!pq.empty()){
    P p=pq.top();pq.pop();
    c.emplace_back(p.first);
    for(Int u:H[p.second]){
      indeg[u]--;
      if(!indeg[u]) pq.emplace(b[u],u);
    }
  }
  
  assert((Int)c.size()==n);
  for(Int i=0;i<n;i++){
    if(i) cout<<" ";
    cout<<c[i];
  }
  cout<<endl;
  return 0;
}


Measured memory_bytes: 50816
#include <iostream>
#include <functional>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
using namespace std;

int main(void) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	long long N, tmp;
	long long ans = 0;
	cin >> N;
	vector<long long> A, B;
	for (int i = 0; i < N + 1; i++){
		cin >> tmp;
		A.push_back(tmp);
	}
	for (int i = 0; i < N; i++) {
		cin >> tmp;
		B.push_back(tmp);
	}

	for (int i = 0; i < N; i++)	{
		if (A[i] >= 0) {
			ans += min(A[i], B[i]);
			B[i] -= min(A[i], B[i]);
		}
		if (A[i + 1] >= 0) {
			ans += min(A[i + 1], B[i]);
			A[i + 1] -= min(A[i + 1], B[i]);
		}
	}
	cout << ans << endl;

	return 0;
}


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

int main()
{
int a=0,b=0,c=0,d=0;
scanf("%d %d %d",&a,&b,&c);
for(a=a;a<=b;a++)
{
if(c%a==0){
d=d+1;
}
}
printf("%d\n",d);
return 0;
}


Measured memory_bytes: 3220
#include <stdio.h>
#include <stdlib.h>

int main()
{
   int a,i;
 //  char sz[4];
   scanf("%d",&a);
   //for(i=0;i<4;i++)
   //{
   //    if(sz[i]=='+')
   //     a++;
    //   if(sz[i]=='-')
     //   a--;
   //}
   //printf("%d\n",a);
   int k=0;
   int x=a;
   while(a>=1)
   {
       k=k+a%10;
       a=a/10;
   }
   if(x%k==0)
    printf("Yes");
   else
   printf("No");
    return 0;
}


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

using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define ll long long int
#define INF 1000000007
// cin.eof() 入力個数の問題
int main() {
    int n;
    cin>>n;
    ll a[n],b[n];
    rep(i,n){
      cin>>a[i]>>b[i];
    }
    ll count=0;
    for (int i = n-1; i >=0; i--)
    {
      ll N=count+a[i];
      if(b[i]==1) continue;
      if(N==0){
        continue;
      }
      if(N<=b[i]){
        count+=b[i]-N;
      }else
      {if(N%b[i]==0) continue;
        count+=b[i]-(N%b[i]);
      }
     // cout<<count<<endl;
    }
    cout<<count<<endl;
    return 0;
}


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

using namespace std;

using ll = long long;

int main()
{
	int N = 0;
	cin >> N;

	std::vector<ll> A(N);

	for (auto& a : A)cin >> a;

	ll Max = 0;
	ll MinA = 10000000000;

	bool Is0 = false;
	bool Odd = false;

	for (auto& a : A)
	{
		ll n = std::abs(a);

		Max += n;

		if (MinA > n)MinA = n;

		if (a < 0)
		{
			Odd = !Odd;
		}
		else if (a == 0)
		{
			Is0 = true;
		}
	}

	if (!Is0&&Odd)
	{
		Max -= MinA * 2;
	}

	cout << Max;

	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;


int main() {
  ll n,k;
  cin >> n >> k;
  vector<ll> h(n);
  rep(i,n) cin >> h[i];
  sort(all(h));
  reverse(all(h));
  ll ans=0;
  for (int i=k;i<n;i++) ans+=h[i];
  cout << ans << endl;
}


Measured memory_bytes: 1792
DBG = !true

n = gets.to_i
a = Array.new(n)
b = Array.new(n)
st = []
for i in 0...n
  a1, b1 = gets.split.map{|x| x.to_i}
  a[i] = a1
  b[i] = b1
  st << [a1, i, 0]
  st << [b1, i, 1]
end

st.sort_by!{|x| x[0]}

cnts = Array.new(n, 0)
bothFound = false
aFound = false
bFound = false
halfsum = 0
for i in 0...n
  halfsum += st[i][0]
  suf = st[i][1]
  cnts[suf] += 1
  bothFound = true if cnts[suf] > 1
  aFound = true if st[i][2]>0
  bFound = true if st[i][2]==0
end

print halfsum, "\n" if DBG

if bothFound || !aFound || !bFound
  print "found case\n" if DBG
  print halfsum
  exit
end

h0last  = st[n-1]
h1first = st[n]

if h0last[1] != h1first[1]
  print "no found case 1\n" if DBG
  print (halfsum + h1first[0] - h0last[0])
  exit
end

h0last2  = st[n-2]
h1first2 = st[n+1]

d = [(h1first[0] - h0last2[0]).abs, (h1first2[0] - h0last[0]).abs].min
print (halfsum + d)


Measured memory_bytes: 24568
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  int K = N;
  int mod = 0;
  while(N != 0){
    mod += N % 10;
    N /= 10;
  }
  if(K % mod == 0) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<stdio.h>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<string>
#include<algorithm>
#include<functional>
#include<math.h>
#include<unordered_set>
using namespace std;

const int MAX = 200000;

int main() {
	int N;
	int X[MAX];
	int s[MAX];

	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> X[i];
		s[i] = X[i];
	}

	sort(s, s + N);

	int mid = N / 2;

	for (int i = 0; i < N; i++) {
		if (X[i] < s[mid])cout << s[mid] << endl;
		else cout << s[mid - 1] << endl;
	}


	

	return 0;
}

Measured memory_bytes: 3712
#pragma gcc optimize("Ofast")
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort(ALL(V)) //小さい方からソート
#define REV(V) reverse(ALL(V)) //リバース
#define RSORT(V) SORT(V);REV(V) //大きい方からソート
#define NPN(V) next_permutation(ALL(V)) //順列
#define pb(n) push_back(n)
#define endl '\n'
#define Endl '\n'
#define DUMP(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define yes(n) cout << ((n) ? "yes" : "no"  ) << endl
#define Yay(n) cout << ((n) ? "Yay!": ":(") << endl
#define RAPID cin.tie(0);ios::sync_with_stdio(false)
#define VSUM(V) accumulate(ALL(V), 0)
#define MID(a,b,c) (a) < (b) && (b) < (c)
#define MIDe(a,b,c) (a) <= (b) && (b) <= (c)
#define IN(n) cin >> n
#define IN2(a,b) cin >> a >> b
#define IN3(a,b,c) cin >> a >> b >> c 
#define IN4(a,b,c,d) cin >> a >> b >> c >> d
#define VIN(V) for(int i = 0; i < (V).size(); i++) {cin >> (V).at(i);}
#define OUT(n) cout << n << endl
#define VOUT(V) REP(i, (V).size()) {cout << (V)[i] << endl;}
#define VOUT2(V) REP(i, (V).size()) {cout << (V)[i] << " ";} cout<<endl;

// 型マクロ定義
#define int long long
#define P pair<ll,ll>
#define Vi vector<ll>
#define VVi vector<vector<ll>>
#define Vd vector<double>
#define Vb vector<bool>
#define Vs vector<string>
#define Vc vector<char>
#define M map<ll,ll>
#define S set<ll>
#define PQ priority_queue<ll>
#define PQG priority_queue<ll,V,greater<ll>
//

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

const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);

int gcd(int a,int b){return b != 0 ? gcd(b, a % b) : a;} //最大公約数
int lcm(int a, int b){return a * b / gcd(a, b);}
string toStrUp(string str){char diff = 'A'-'a';REP(i,str.size()) str[i] += diff;return str;}
string gCh(string str, int key){return str.substr(key,1);}

signed main() {
  RAPID;
  // デフォルト変数定義
  int n=0,m=0,a=0,b=0,c=0,d=0,x=0,y=0,z=0;
  string s="",t="";
  //

  // ここから
  IN(s);
  REP(i,s.size()){
    if(s[i]=='2') x++;
  }
  OUT(x);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
    long long int n;
    cin >> n;
    vector<long long int> a(n);
    for(long long int i=0;i<n;i++) {
        cin>>a[i];
    }
    sort(a.begin(),a.end());
    if(n%2==0) {
        long long int k = n/2;
        vector<long long int> temp;
        for(long long int i=n-1,j=0;i>=0 && j<k;i--,j++) {
            temp.push_back(a[i]);
        }

        long long int sum=0;
        sum+=temp[0];
        for(long long int i=1;i<temp.size();i++) {
            sum+=2*temp[i];
        }
        cout<<sum<<'\n';
        return 0;
    }
    else {
        long long int k = (n/2)+1;
        vector<long long int> temp;
        for(long long int i=n-1,j=0;i>=0 && j<k;i--,j++) {
            temp.push_back(a[i]);
        }
        long long int sum=0;
        sum+=temp[0];
        for(long long int i=1;i<temp.size()-1;i++) {
            sum+=2*temp[i];
        }
        sum+=temp[temp.size()-1];
        cout<<sum<<'\n';
        return 0;
    }
}

Measured memory_bytes: 5880
s = input()
q = int(input())
qs = [input().split() for i in range(q)]
n = False
left= right = ""
for operation in qs:
    if operation[0] == '1':
        n = not n
    if operation[0] == '2':
        t , f, c = operation
        f = int(f)
        if n:
            f = 1 if f != 1 else 2
        if f == 1:
            left=c+left
        elif f == 2:
            right+=c
s = left+s+right
print(s[::-1] if n else s)

Measured memory_bytes: 40680