akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <functional>
#include <map>
#include <iomanip>
#include <math.h> 
#include <stack>
#include <queue>
#include <bitset>
#include <cstdlib>
#include <tuple>

using namespace std;

int minn = 9999999;

int func6(int n, int cnt);

//tuple <int, int > func9(int n, int cnt) {
int func9(int n, int cnt) {
	
	if (n < 6) {
		cnt += n;
		minn = min(minn, cnt);
	//	cout << "cnt->"<< cnt << endl;
		return 0;
	}

	if (n >= 9) {
		int i;
		for (i = 1; pow(9,i) <= n; i++) {
			//cnt++;
		}
		i--;
		cnt++;
		n -= pow(9, i);
	}
	else {
		return 0;
	}

	func9(n, cnt);
	func6(n, cnt);
	//return forward_as_tuple( n, cnt);
	return 0;
}


//tuple <int, int >  func6(int n, int cnt ) {
int func6(int n, int cnt) {

	if (n < 6) {
		cnt += n;
		minn = min(minn, cnt);
		//cout << "cnt->" << cnt << endl;
		return 0;
	}

	if (n >= 6) {
		int i;
		for (i = 1; pow(6,i) <= n; i++) {
			//cnt++;
		}
		i--;
		cnt++;
		n -= pow(6, i);
	}
	else {
		return 0;
	}


	func9(n, cnt);
	func6(n, cnt);

	//return forward_as_tuple(n, cnt);
	return 0;
}


//tuple<int, int> func(int n, int cnt) {
int func(int n, int cnt){

//	tie(n, cnt) = func9(n, cnt);
//	tie(n, cnt) = func6(n, cnt);

	func9(n, cnt);
	func6(n, cnt);

	/*
	 if (n < 6) {
		 for (int i = n; i == 0; i--) {
			 cnt++;
		 }
		 cout << "cnt->" << cnt << endl;
	 }
	 else {
		 func(n, cnt);
	 }
	 */

	 //return forward_as_tuple(n, cnt);
	 return 0;
}


int main() {
	int i, j, k;
	int n, cnt = 0;

	cin >> n;




//	tie(n, cnt) = func(n, cnt);
	func(n, 0);

	
	//cout << "n->" << n << " cnt->" << cnt << endl;



	cout << minn << endl;




	getchar();
	getchar();
	return 0;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val N = nextInt()
    val A = listOfInt()
    val B = listOfInt()
    var ans = 0L
    for (i in 0 until 29) {
        val mA = IntArray(N)
        val mB = IntArray(N)
        val mask = (1 shl i + 1) - 1
        for (j in 0 until N) {
            mA[j] = A[j] and mask
            mB[j] = B[j] and mask
        }
        mB.sort()
        var count = 0L
        val T = 1 shl i
        for (j in 0 until N) {
            val n1 = LowerBound(mB,     T - mA[j])
            val n2 = LowerBound(mB, 2 * T - mA[j])
            val n3 = LowerBound(mB, 3 * T - mA[j])
            count += (n2 - n1) + (N - n3)
        }
        ans = ans or ((count and 1) shl i)
    }
    println(ans)
}
fun LowerBound(arr: IntArray, v: Int): Int {
    var left = 0
    var right = arr.size - 1
    while (left <= right) {
        val center = (left + right) ushr 1
        if (v > arr[center]) left = center + 1
        else right = center - 1
    }
    return left
}

fun next() = readLine()!!
fun nextInt() = next().toInt()
fun listOfString() = next().split(" ")
fun listOfInt(d: Int = 0) = listOfString().map { it.toInt() + d }
fun listOfLong(d: Long = 0) = listOfString().map { it.toLong() + d }



Measured memory_bytes: 130068
if __name__ == "__main__":
    import sys
    N = int(sys.stdin.readline().strip())
    L = list(map(int, sys.stdin.readline().split()))
    L.sort(reverse=True)
    pairs = [(L[i], L[i+1]) for i in range(0, len(L), 2)]
    print(sum(map(min, pairs)))

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int n,m,p,x;
int a[110],b[110],ans;
int main()
{
	ios::sync_with_stdio(false);
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
	}
	cin>>m;
	while(m--)
	{
		ans=0;
		cin>>p>>x;
		for(int i=1;i<=n;i++)
		{
			if(i==p)ans+=x;
			else ans+=a[i];
		}
		cout<<ans<<endl;
	}
}

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

using namespace std;

int main(){
	vector<int> a;
	int x;
	for(int i = 0 ; i < 3;i++){
		cin >> x;
		a.push_back(x);
	}
	sort(a.begin(),a.end());
	cout << a[0];
	for(int i = 1 ; i < 3;i++)
		cout << " " << a[i];
	cout << "\n";
}




Measured memory_bytes: 3152
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }
#define dump(x) cerr<<#x<<": "<<x<<endl;
#define bit(k) (1LL<<(k))
typedef long long ll;
typedef pair<int, int> i_i;
typedef pair<ll, ll> l_l;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;
template< typename T1, typename T2 >
ostream &operator<<(ostream &os, const pair< T1, T2 >& p) {
  os << "{" <<p.first << ", " << p.second << "}";
  return os;
}
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; }

const int INF = (ll)1e9;
const ll INFLL = (ll)1e18+1;
const ll MOD = (ll)1e9+7;
const double PI = acos(-1.0);
/*
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const string dir = "DRUL";
*/

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    int N;
    cin >> N;
    vector<ll> A(N);
    vector<ll> cnt(1000100,0);
    vector<bool> ok(1000100, true);
    rep(i, N){
        cin >> A[i];
        cnt[A[i]]++;
    }
    sort(all(A));
    int ans = 0;
    rep(i,N){
        if(cnt[A[i]] == 1 && ok[A[i]])ans++;
        if(!ok[A[i]])continue;
        for(int j = A[i]; j <= 1000000;j += A[i]){
            ok[j] = false;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 12936
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 30;
const int MOD = 1e9 + 7;

const int N = 5e5 + 10;
char s[N];

int main() {
  int n;
  scanf("%d", &n);
  scanf("%s", s);
  vector<ii> a;
  for (int i = 0, j; i < n; i = j) {
    for (j = i + 1; j < n && s[i] == s[j]; ++j);
    a.push_back({s[i] - '0', j - i});
  }
  n = a.size();
  int ret = 0;
  int i = 0;
  if (a[0].first == 0) ++i;
  for (int j; i < n; i = j) {
    vector<int> b;
    b.push_back(a[i].second);
    for (j = i + 2; j < n && a[j - 1].second == 1; j += 2) {
      b.push_back(a[j].second);
    }
    int m = b.size();
    if (m == 1) continue;
    vector<vector<int>> dp(m, vector<int>(3));
    dp[m - 1][0] = dp[m - 1][1] = dp[m - 1][2] = 0;
    dp[m - 2][0] = max(b[m - 2], b[m - 1]);
    dp[m - 2][1] = b[m - 2] == 1 ? 0 : max(b[m - 2] - 1, b[m - 1]);
    dp[m - 2][2] = b[m - 1];
    for (int k = m - 3; k >= 0; --k) {
      dp[k][0] = dp[k + 1][0];
      dp[k][0] = max(dp[k][0], b[k] + dp[k + 1][1]);
      if (b[k + 1] > 1) dp[k][0] = max(dp[k][0], max(b[k], b[k + 1] - 1) + dp[k + 1][2]);
      dp[k][0] = max(dp[k][0], max(b[k], b[k + 1]) + dp[k + 2][0]);
      dp[k][1] = dp[k + 1][0];
      if (b[k] == 1) {
        dp[k][1] = max(dp[k][1], dp[k + 1][0]);
      } else {
        dp[k][1] = max(dp[k][1], b[k] - 1 + dp[k + 1][1]);
        if (b[k + 1] > 1) dp[k][1] = max(dp[k][1], max(b[k] - 1, b[k + 1] - 1) + dp[k + 1][2]);
        dp[k][1] = max(dp[k][1], max(b[k] - 1, b[k + 1]) + dp[k + 2][0]);
      }
      dp[k][2] = dp[k + 1][0];
      dp[k][2] = max(dp[k][2], 1 + dp[k + 1][1]);
      if (b[k + 1] > 1) dp[k][2] = max(dp[k][2], b[k + 1] - 1 + dp[k + 1][2]);
      dp[k][2] = max(dp[k][2], b[k + 1] + dp[k + 2][0]);
    }
    ret += dp[0][0];
  }
  printf("%d\n", ret);
  return 0;
}


Measured memory_bytes: 3060
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))

int main(){
	ll a,b;
	scanf("%lld%lld",&a,&b);
	puts(a<=8&&b<=8?"Yay!":":(");
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define INF 1000000000
#define pi 3.14159265358979323846264338327950L
#define FOR(i,a,b) for(int i=a;i<=b;i++)

ll A,B;

ll f(ll x)
{
    ll ans=floor((A*x)/B)-(A*floor(x/B));
    return ans;
}

int main()
{
    //freopen("contest.txt","r",stdin);
    //freopen("contest.txt","w",stdout);
    IOS
    ll N;
    cin>>A>>B>>N;
    ll sum_1=0,sum_2=0;

    cout<<f(min(B-1,N))<<endl;

    return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define N 100005
int n,k,s;
int main()
{
	scanf("%d %d %d",&n,&k,&s);
	for(int i=1;i<=k;++i) printf("%d ",s);
	for(int i=k+1;i<=n;++i)
		if(s==1e9) printf("%d ",s-1);else printf("%d ",s+1);
	return 0;
}

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

int main() {
    char c;
    cin >> c;
    
    if(c=='a'||c=='e'||c=='i'||c=='o'||c=='u'){
        cout << "vowel" << endl;    
        }
        else cout << "consonant" <<endl;
        
    return 0;
}

Measured memory_bytes: 256
# coding=utf-8

###
### for atcorder program
###

import sys
import math
import array

# math class
class mymath:
    ### pi
    pi = 3.14159265358979323846264338

    ### Prime Number
    def pnum_eratosthenes(self, n):
        ptable = [0 for i in range(n+1)]
        plist = []

        for i in range(2, n+1):
            if ptable[i]==0:
                plist.append(i)
                for j in range(i+i, n+1, i):
                    ptable[j] = 1
        return plist

    ### GCD
    def gcd(self, a, b):
        if b == 0:
            return a
        return self.gcd(b, a%b)

    ### LCM
    def lcm(self, a, b):
        return (a*b)//self.gcd(a,b)

    ### Mat Multiplication
    def mul(self, A, B):
        ans = []
        for a in A:
            c = 0
            for j, row in enumerate(a):
                c += row*B[j]
            ans.append(c)
        return ans

mymath = mymath()

### output class
class output:
    ### list
    def list(self, l):
        l = list(l)
        #print(" ", end="")
        for i, num in enumerate(l):
            print(num, end="")
            if i != len(l)-1:
                print(" ", end="")
        print()

output = output()

### input sample
#i = input()
#N = int(input())
#A, B, C = [x for x in input().split()]
#N, K = [int(x) for x in input().split()]
#inlist = [int(w) for w in input().split()]

#R = float(input())
#A.append(list(map(int,input().split())))

#for line in sys.stdin.readlines():
#    x, y = [int(temp) for temp in line.split()]

### output sample
#print("{0} {1} {2:.5f}".format(A//B, A%B, A/B))
#print("{0:.6f} {1:.6f}".format(R*R*math.pi,R*2*math.pi))
#print(" {}".format(i), end="")

def main():
    
    N = int(input())
    P = None
    A = []
    P = [int(w) for w in input().split()]

    for i in range(N-2):
        if P[i] < P[i+1] < P[i+2]:
            A.append(P[i+1])
        elif P[i] > P[i+1] > P[i+2]:
            A.append(P[i+1])

    print(len(A))

if __name__ == '__main__':
    main()



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

using namespace std;

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define BW(a,x,b) ((a)<=(x)&&(x)<=(b))
#define ALL(v) (v).begin(), (v).end()
#define LENGTHOF(x) (sizeof(x) / sizeof(*(x)))
#define AFILL(a, b) fill((int*)a, (int*)(a + LENGTHOF(a)), b)
#define SQ(x) ((x)*(x))
#define Mod(x, mod) (((x)+(mod)%(mod))
#define MP make_pair
#define PB push_back
#define Fi first
#define Se second
#define INF (1<<29)
#define EPS 1e-10
#define MOD 1000000007

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

int st[1024];

int main()
{
  int N, m;

  cin >> N >> m;
  rep(i, m){
    int c, d; cin >> c >> d;
    st[c]++;
    st[d]--;
  }
  rep(i, N) st[i+1] += st[i];
  int res = 0;
  rep(i, N+1)
    if(st[i+1]) res += 3;
    else res += 1;
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 1168
#include <bits/stdc++.h>
#define ll long long
#define endl "\n"
#define pb push_back
#define ms(v,x) memset(v,x,sizeof(v))
#define ff first
#define ss second
#define td(v) v.begin(),v.end()
#define rep(i,a,n) for (int i=(a);i<(n);i++)
#define pii pair<int,int>
#define pll pair<ll,ll>
using namespace std;
void solve(){
	int n,m;
	cin >> n >> m;
	int val = 2*m+1;
	for(int i=0;i<m/2;i++){
		cout << i+1 << " "<< val/2 - i << endl;
	}
	int cnt = 1;
	for(int i=m/2;i<m;i++){
		cout << val/2 + cnt << " " << val - (cnt-1) << endl;
		cnt++;
	}
}
int main(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);  
    int t=1,l=1;
   	//cin >> t;
    while(t--){
    	solve();
    }    
}

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

using namespace std;

typedef vector<int> VI;
#define PB push_back
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define IN(v) int v;cin>>v;
#define OUT(v) cout<<v<<endl


int main() {
  IN(N);

  VI min_v(N+1), max_v(N+1), A;
  min_v[0] = 1000000001;
  max_v[N] = 0;
  REP(i, N) {
    IN(a);
    A.PB(a);
    min_v[i+1] = min(min_v[i], a);
  }
  for (int i = N - 1; i >= 0; --i) {
    max_v[i] = max(max_v[i+1], A[i]);
  }
  int res = -1000000001;
  REP(i, N-1) {
    res = max(res, max_v[i+1] - min_v[i+1]);
  }
  OUT(res);


  return 0;
}



Measured memory_bytes: 5404
/**************************************************************************
Coded by: Saba Karimi(_VINTAGE)
Institution: AIT PUNE
***************************************************************************/
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back 
#define all(a) a.begin(),a.end()
#define lb lower_bound
#define ub upper_bound
#define pii pair<int,int>
#define ld long double
#define int long long int 
#define F first 
#define S second
/**************************************************************************/
bool isprime(int n)
{
    if(n==1)
        return 1;
    if(n==2)
        return 1;
    if(n%2==0)
        return 0;
    for(int i=3;i*i<=n;i+=2)
        if(n%i==0)
            return 0;
    return 1;
}
signed main()
{
    fast;
    int a,b;
    cin>>a>>b;
    if(a>b)
        swap(a,b);
    set<int> ans;
    for(int i=1;i<=sqrt(a);i++)
    {
        if(a%i==0)
        {
            if(b%i==0)
                ans.insert(i);
            int x = a/i;
            int y = b/i;
            if(b%x == 0)
                ans.insert(x);
            if(a%y==0)
                ans.insert(y);
        }
    }
    int cnt = 0;
    for(auto it:ans)
        if(isprime(it))
            cnt++;
    cout<<cnt;
}

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

import sys

#def xcheck(n):
#	
#    m = int(n**.5)
#    return 1 if abs(m*m - n) < 1e-6 else 0
#	if(1):
#		#兵法数なら
#		return 1
#	return 0

n = int(input())
tmpinput = input().split()
a = list(map(lambda a: int(a), tmpinput))

check = []
for i in range(0,30):
	check.append(0)

for i in range(0,n):
	j=a[i]
	k=0
	while(j!=0):
		tmp = j%2
		check[k]+=tmp
		j = j//2
		k+=1

flg = 0;
for i in range(0,30):
	flg += check[i]%2


#print(check)
#print(a)
#print(flg)

if(flg == 0):
	print("Yes")
else:
	print("No")



Measured memory_bytes: 14212
#include<stdio.h>
#include<string.h>
int main()
{
	int a[10000]={0};
	int n,m;
	while(~scanf("%d%d",&n,&m))
	{
		int sum=1;
		memset(a,0,sizeof a);
		a[0]=0;
		for(int i=1;i<=n;i++)
		{
			int k;
			scanf("%d",&k);
			a[i]=a[i-1];
			a[i]+=k;
			if(a[i]<=m)
			sum++;
		}
		printf("%d\n",sum);
	}
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int n,i;
  scanf("%d",&n);
  double x[n+1],sum=0;
  char u[n+1][4];
  for(i=0;i<n;i++){
    scanf("%lf",&x[i]);
    scanf("%s",u[i]);
    if(u[i][0]=='B')
      sum+=380000*x[i];
    else
      sum+=x[i];
  }
  printf("%lf\n",sum);
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int
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;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const ll MOD = 1000000007;
const double EPS = 1e-9;
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;



int main(void) {
    
    int a,b,c;
    cin>>a>>b>>c;
    if(a>b)swap(a,b);
    if(b>c)swap(b,c);
    if(a>b)swap(a,b);
    if(a==5&&b==5&&c==7)fin("YES");
    else fin("NO");
}


Measured memory_bytes: 256
import numpy as np

N = int(input())
a = np.array([int(x) for x in input().split(" ")], np.int64)
sum = 0
pow = 0
while any(a):
    one = np.count_nonzero(a & 1)
    sum += one * (N - one) * 2 ** pow
    sum %= (10 ** 9 + 7)
    pow += 1
    a >>= 1
print(sum)

Measured memory_bytes: 48872
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define loop(i, a, n) for(int i = (a); i < (n); i++)
#ifdef _DEBUG
#define dd(x) cout << #x << " : " << x << endl
#else
#define dd(x)
#endif
using namespace std;
using ll = int64_t;

const ll mod = 1e9+7;
struct mint
{
    ll x;
    mint(ll x=0) : x((x%mod+mod)%mod){}
    mint operator-() const {return mint(-x);}
    mint& operator+=(const mint a){
        if((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a){
        if((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a){
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const { return mint(*this) += a;}
    mint operator-(const mint a) const { return mint(*this) -= a;}
    mint operator*(const mint a) const { return mint(*this) *= a;}
    mint pow(ll t) const {
        if(!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if(t&1) a *= *this;
        return a;
    }

    ll val(){ return x; }

    // for prime mod
    mint inv() const { return pow(mod-2);}
    mint& operator/=(const mint a) { return *this *= a.inv();}
    mint operator/(const mint a) const { return mint(*this) /= a;}

    friend istream& operator>>(istream& is, mint& a) { return is >> a.x;}
    friend ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
};

struct Func {
    const ll mod;
    vector<ll> fact, ifact;
    ll mod_pow(ll x, ll n, const ll mod){
        ll ans = 1;
        while(n){
            if(n & 1) ans = ans*x%mod;
            x = x*x%mod;
            n >>= 1;
        }
        return ans;
    }
    Func(ll n, ll mod) : fact(n+1), ifact(n+1), mod(mod) {
        fact[0] = 1;
        for(ll i = 1; i <= n; i++) fact[i] = fact[i-1] * i % mod;
        ifact[n] = mod_pow(fact[n], mod-2, mod);
        for(ll i = n; i >= 1; i--) ifact[i-1] = ifact[i] * i % mod;
    }
    ll comb(ll n, ll k) {
        if (k < 0 || k > n) return 0;
        return fact[n]*ifact[k]%mod*ifact[n-k]%mod;
    }
    ll perm(ll n, ll k) {
        if (k < 0 || k > n) return 0;
        return fact[n]*ifact[n-k]%mod;
    }
};

int main(){
    int k; string s; cin >> k >> s;
    int n = s.size();

    Func f = Func(n+k, mod);
    mint p25 = 25;
    mint p26 = 26;
    mint ans = 0;
    for(int i = 0; i <= k; i++) {
        mint tmp = f.comb(n+k-i-1, n-1);
        tmp *= p26.pow(i);
        tmp *= p25.pow(k-i);
        ans += tmp;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 35640
#include<bits/stdc++.h>
#define int long long
using namespace std;
main()
{
	//freopen("input.txt","rt",stdin);
	int m,k;
	cin>>m>>k;
	int p = pow(2,m)-1;
	//cout<<p<<endl;
	if(m == 0)
	{
		if(k==0)
		{
			cout<<"0 0 "<<endl;
		}
		else
		cout<<"-1"<<endl;
	}
	else if(m==1)
	{
		if(k==0)
		{
			for(int i=0;i<=p;i++)
			{
				cout<<i<<" "<<i<<" ";
			}
			cout<<endl;
		}
		else
		{
			cout<<"-1"<<endl;
		}
	}
	else if(k>=0 && k <= p)
	{
		if(k == 0)
		{
			for(int i=0;i<=p;i++)
			{
				cout<<i<<" "<<i<<" ";
			}
			cout<<endl;
		}
		else
		{
			int s = 0;
			for(int i=0;i<=p;i++)
			{
				if(i != k)
				{
					s ^= i;
					//cout<<i<<endl;
			    }
			}
			s ^= k;
			if(s==0)
			{
				cout<<"0 "<<k<<" 0 ";
				for(int i=1;i<=p;i++)
				{
					if(i != k)
					{
					cout<<i<<" ";
				    }
				}
				cout<<k<<" ";
				for(int i=p;i>=1;i--)
				{
					if(i != k)
					cout<<i<<" ";
				}
			}
			else
			{
				cout<<"-1"<<endl;
			}
		}
	}
	else
	{
		cout<<"-1"<<endl;
	}
	
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
//BEGIN CUT HERE
struct Dinic{
  const int INF=1<<28;
  
  struct edge {
    int to,cap,rev;
    edge(){}
    edge(int to,int cap,int rev):to(to),cap(cap),rev(rev){}
  };

  int n;
  vector<vector<edge> > G;
  vector<map<int,int> > M;
  vector<int> level,iter;

  Dinic(){}
  Dinic(int sz):n(sz),G(n),M(n),level(n),iter(n){}
  
  void add_edge(int from,int to,int cap){
    M[from][to]=G[from].size();
    M[to][from]=G[to].size();
    G[from].push_back(edge(to,cap,G[to].size()));
    // undirected
    //G[to].push_back(edge(from,cap,G[from].size()-1));
    // directed
    G[to].push_back(edge(from,0,G[from].size()-1));
  }
  
  void bfs(int s){
    fill(level.begin(),level.end(),-1);
    queue<int> que;
    level[s]=0;
    que.push(s);
    while(!que.empty()){
      int v=que.front();que.pop();
      for(int i=0;i<(int)G[v].size();i++){
	edge &e = G[v][i];
	if(e.cap>0&&level[e.to]<0){
	  level[e.to]=level[v]+1;
	  que.push(e.to);
	}
      }
    }
  }
  
  int dfs(int v,int t,int f){
    if(v==t) return f;
    for(int &i=iter[v];i<(int)G[v].size();i++){
      edge &e=G[v][i];
      if(e.cap>0&&level[v]<level[e.to]){
	int d = dfs(e.to,t,min(f,e.cap));
	if(d>0){
	  e.cap-=d;
	  G[e.to][e.rev].cap+=d;
	  return d;
	}
      }
    }
    return 0;
  }
  
  int flow(int s,int t,int lim){
    int fl=0;
    for(;;){
      bfs(s);
      if(level[t]<0||lim==0) return fl;
      fill(iter.begin(),iter.end(),0);
      int f;
      while((f=dfs(s,t,lim))>0){
	fl+=f;
	lim-=f;
      }
    }
  }

  int flow(int s,int t){
    return flow(s,t,INF);
  }

  //cap==1 only
  bool back_edge(int s,int t,int from, int to){
    for(int i=0;i<(int)G[from].size();i++) {
      edge& e=G[from][i];
      if(e.to==to) {
	if(e.cap==0&&flow(from,to,1)==0) {
	  flow(from,s,1);
	  flow(t,to,1);
	  return 1;
	}
      }
    }
    return 0;
  }
};
//END CUT HERE

signed main(){
  int V,E;
  cin>>V>>E;
  Dinic dinic(V);
  for(int i=0;i<E;i++){
    int u,v,c;
    cin>>u>>v>>c;
    dinic.add_edge(u,v,c);
  }
  cout<<dinic.flow(0,V-1)<<endl;
  return 0;
}

/*
  verified on 2017/10/29
  http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=GRL_6_A&lang=jp
*/

Measured memory_bytes: 3248
###############################################################################

from sys import stdout
from bisect import bisect_left as binl
from copy import copy, deepcopy
from collections import defaultdict


mod = 1


def intin():
    input_tuple = input().split()
    if len(input_tuple) <= 1:
        return int(input_tuple[0])
    return tuple(map(int, input_tuple))


def intina():
    return [int(i) for i in input().split()]


def intinl(count):
    return [intin() for _ in range(count)]


def modadd(x, y):
    global mod
    return (x + y) % mod


def modmlt(x, y):
    global mod
    return (x * y) % mod


def lcm(x, y):
    while y != 0:
        z = x % y
        x = y
        y = z
    return x


def combination(x, y):
    assert(x >= y)

    if y > x // 2:
        y = x - y

    ret = 1

    for i in range(0, y):
        j = x - i
        i = i + 1

        ret = ret * j
        ret = ret // i

    return ret


def get_divisors(x):
    retlist = []
    for i in range(1, int(x**0.5) + 3):
        if x % i == 0:
            retlist.append(i)
            retlist.append(x // i)
    return retlist


def get_factors(x):
    retlist = []
    for i in range(2, int(x**0.5) + 3):
        while x % i == 0:
            retlist.append(i)
            x = x // i
    retlist.append(x)
    return retlist


def make_linklist(xylist):
    linklist = {}
    for a, b in xylist:
        linklist.setdefault(a, [])
        linklist.setdefault(b, [])
        linklist[a].append(b)
        linklist[b].append(a)
    return linklist


def calc_longest_distance(linklist, v=1):
    distance_list = {}
    distance_count = 0
    distance = 0
    vlist_previous = []
    vlist = [v]
    nodecount = len(linklist)

    while distance_count < nodecount:
        vlist_next = []
        for v in vlist:
            distance_list[v] = distance
            distance_count += 1
            vlist_next.extend(linklist[v])
        distance += 1
        vlist_to_del = vlist_previous
        vlist_previous = vlist
        vlist = list(set(vlist_next) - set(vlist_to_del))

    max_distance = -1
    max_v = None
    for v, distance in distance_list.items():
        if distance > max_distance:
            max_distance = distance
            max_v = v

    return (max_distance, max_v)


def calc_tree_diameter(linklist, v=1):
    _, u = calc_longest_distance(linklist, v)
    distance, _ = calc_longest_distance(linklist, u)
    return distance


###############################################################################


def main():
    n = intin()
    alist = intina()
    alist = [a - (i + 1) for i, a in enumerate(alist)]

    alist.sort()
    b = alist[n // 2]

    ans = 0
    for a in alist:
        ans += abs(a - b)
    print(ans)




if __name__ == '__main__':
    main()


Measured memory_bytes: 27096
import java.util.*;
import java.io.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;
import static java.lang.Math.*;

public class Main {

	int INF = 1 << 28;
	//long INF = 1L << 62;
	double EPS = 1e-10;
	int h, w;
	boolean[][] map;
	
	void run() {
		Scanner sc = new Scanner(System.in);
		for (;;) {
			w = sc.nextInt(); h = sc.nextInt();
			if ((w|h) == 0) break;
			
			map = new boolean[h+2][w+2];
			for (boolean[] a: map) fill(a, true);
			V s = new V(sc.nextInt(), sc.nextInt(), sc.nextInt(), sc.nextInt(), 0);
			
			for (int y=1;y<=h;y++) for (int x=1;x<=w;x++) 
				map[y][x] = sc.next().charAt(0) == '1';
			
			System.out.println(bfs(s));
		}
	}
	
	int[] dx = {-1,0,1,0};
	int[] dy = {0,-1,0,1};
	String bfs(V s) {
		boolean[][][][] mem = new boolean[w+2][h+2][w+2][h+2];
		mem[s.x1][s.y1][s.x2][s.y2] = true;
		LinkedList<V> q = new LinkedList<V>();
		q.add(s);
		
		for (;! q.isEmpty();) {
			V c = q.removeFirst();
			if ( c.is_meet() ) return "" + c.c;
			
			for (int i=0;i<4;i++) {
				int nx1 = c.x1 + dx[i], ny1 = c.y1 + dy[i];
				int nx2 = c.x2 - dx[i], ny2 = c.y2 - dy[i];
				if (map[ny1][nx1]) {
					nx1 = c.x1; ny1 = c.y1;
				}
				if (map[ny2][nx2]) {
					nx2 = c.x2; ny2 = c.y2;
				}
				
				if (! mem[nx1][ny1][nx2][ny2]) {
					mem[nx1][ny1][nx2][ny2] = true;
					q.addLast(new V(nx1, ny1, nx2, ny2, c.c + 1));
				}
			}
		}
		
		return "NA";
	}
	
	class V {
		int x1, y1, x2, y2, c;
		V(int x1, int y1, int x2, int y2, int c) {
			this.x1 = x1;
			this.x2 = x2;
			this.y1 = y1;
			this.y2 = y2;
			this.c = c;
		}
		
		boolean is_meet() {
			return x1 == x2 && y1 == y2;
		}
	}

	void debug(Object... os) {
		System.err.println(Arrays.deepToString(os));
	}

	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 157676
#pragma GCC optimize("Ofast")
#include <cstdio>
#include <cstdlib>
#include <string>
#include <algorithm>
#include <iostream>
#include <queue>
#include <vector>
#include <bitset>
#include <cmath>
#include <limits>
#include <iostream>
#include <map>
#include <set>
#include <tuple>
#include <iomanip>
#include <functional>

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<int,ll> pil;
typedef pair<ll,int> pli;
typedef pair<ll,ll> pll;

template<class T,class U>constexpr bool chmin(T&a,const U b){if(a<=b)return false;a=b;return true;}
template<class T,class U>constexpr bool chmax(T&a,const U b){if(a>=b)return false;a=b;return true;}
#define bit(n,k) ( (n>>k)&1 )

//デバッグ
template<class T>
void Vout(vector<T> &V){
    cout<<"\nstart\n";
    const int sz=V.size();
    for(int i=0;i<sz;i++){
        cout<<i<<" "<<V[i]<<'\n';
    }
    cout<<"end\n"<<endl;
}

template<class T>
void VPout(vector<T> &V){
    cout<<"\nstart\n";
    const int sz=V.size();
    for(int i=0;i<sz;i++){
        cout<<i<<" "<<V[i].first<<" "<<V[i].second<<'\n';
    }
    cout<<"end\n"<<endl;
}


//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++


constexpr int MAX=1<<30;
constexpr ll INF=1LL<<62;
constexpr int MOD=1e9+7;
int dx[]={1,-1,0,0},dy[]={0,0,-1,1};

//__builtin_popcount(S);
//#define int ll
//vector<vector<int>> data(3, vector<int>(4));
//vector.resize(a,vector<int>(b,-1));
//vector<vector<vector<要素の型>>> 変数名(要素数1, vector<vector<要素の型>>(要素数2, vector<要素の型>(要素数3, 初期値)));

ll dp[1100000][3];
//1hakoeteru

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr); 
    cout<<fixed<<setprecision(10);
    for(int i=0;i<1100000;i++){
        for(int j=0;j<3;j++){
            dp[i][j]=INF;
        }
    }
    string S;
    cin>>S;
    int sz=(int)S.size();
    dp[0][1]=2;
    dp[0][0]=0;
    for(int i=0;i<sz;i++){
        int x=S[i]-'0';
        for(int j=0;j<3;j++){
            if(dp[i][j]==INF) continue;
           if(j==1){
               chmin(dp[i+1][1],dp[i][j]+10-x-1);
               chmin(dp[i+1][0],dp[i][j]+x);
               chmin(dp[i+1][1],dp[i][j]+x+2);
           }else if(j==0){
               chmin(dp[i+1][0],dp[i][j]+x);
               if(x!=9) chmin(dp[i+1][1],dp[i][j]+x+2);
           }
        }
    }
    cout<<min(dp[sz][0],min(dp[sz][2],dp[sz][1]) )<<endl;
}

Measured memory_bytes: 27804
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE BinaryLiterals #-}
{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE NumDecimals #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-}

import Control.Applicative
import Control.Arrow
import Control.Monad
import Control.Monad.ST

import Data.Char
import Data.List
import Data.Maybe

import qualified Data.ByteString.Char8 as B

import Data.Array.ST.Safe
import Data.STRef

import Debug.Trace
import Text.Printf

readInt = readLn :: IO Int
readInts = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine
readNInts = readInt >>= flip replicateM readInt

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

main = do
	[ a, b, c ] <- readInts
	print $ min c $ b `div` a

Measured memory_bytes: 380
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <unordered_map>
#include <cmath>
#include <utility> // pair make_pair
#include <algorithm>
#include <functional>
#include <iomanip>
#include <climits> // LLONG_MAX, LLONG_MIN, INT_MIN, INT_MAX
#include <assert.h>

#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,63,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define ll long long
#define int ll
#define INF INT_MAX/10
#define MOD 1000000007

using namespace std;
using Pi = pair<int, int>;
using Graph = vector<vector<int> >;
using WeightGraph = vector<vector<Pi> >;

int Input[100100];

signed main() {
  int N; cin >> N;
  int m = INF;
  int it = -1;
  int cnt = 0;
  int sum = 0;
  
  for (int i = 0; i < N; i++) {
    int a; cin >> a;
    if (a < 0) {
      cnt++;
    }
    if ( abs(a) < m ) {
      m = abs(a);
      it = i;
    }
    // cout << sum << endl;
    sum += abs(a);
  }

  if (cnt % 2 == 0) {
    cout << sum << endl;
  } else if (m == 0) {
    cout << sum << endl;
  } else {
    // cout << m << endl;
    // cout << sum << endl;
    cout << sum - 2*m << endl;
  }
}




Measured memory_bytes: 256
import math
a, b, x = map(int, input().split())
if x > a**2*b/2:
    print(math.degrees(math.atan((a**2*b-x)/(a**3*0.5)))) # 水多い
else:
    print(90-math.degrees(math.atan((x)/(a*b**2*0.5)))) # 水少ない


Measured memory_bytes: 2940
//Keep working hard :)
#include<bits/stdc++.h>
using namespace std;

#define IOS ios::sync_with_stdio(false); cin.tie(nullptr); cout.precision(10); cout << fixed;
#define long long long

int main()
{
	IOS;
	#ifdef LOCAL
	freopen("input.txt","rt",stdin);
	freopen("output.txt","wt",stdout);
	#endif

	int a,b,c;
	cin >> a >> b >> c;
	int tra = min(c,a-b);
	c -= tra;
	cout << c <<endl;

	return 0;
}


Measured memory_bytes: 256
/**
   Solution by Abil
**/
# include <bits/stdc++.h>

# define fr first
# define sc second
# define pb push_back
# define mk make_pair
# define sz(s) s.size()
# define all(s) s.begin(),s.end()
# define int long long

using namespace std;

const long long N = (1e6 + 10);
const long long mod = (1e9 + 7);
const long long inf = (1e9 + 7);


main()
{
     string s;
     cin >> s;
     int ans = 0,cnt = 0;
     for(int i = s.size() - 1; i >= 0; i--){
      if(s[i] == 'W'){
        cnt++;
      }
      else{
        ans = ans + cnt;
      }
     }
     cout << ans;
}


Measured memory_bytes: 640
object MainKt {
  @JvmStatic fun main(args:Array<String>) {
    val (H,W) = readLine()!!.split(" ").map(String::toInt)
    val pixel=Array(H) {
      readLine()!!
    }
      (1..(W+2)).map {"#"}.forEach(::print).let { println("")}
      (1..H).map{"#"+pixel[it-1]+"#"}.forEach(::println)
      (1..(W+2)).map {"#"}.forEach(::print).let { println("")}
  }

}

Measured memory_bytes: 37744
#include<bits/stdc++.h>
#define IO std :: ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long
#define double long double
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int,int>
#define vii vector<pii>
#define nl '\n'
#define yy "YES\n"
#define nn "NO\n"
#define mp map
#define ump unordered_map
#define ve vector
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define f first
#define s second
#define mod 1000000007

using namespace std;

signed main()
{
        IO;
        int n;
        cin >> n;
        vector <double> dp(n+1);
        dp[0] = 1;
        for(int i=1; i<=n ;i++){
            double ph;
            cin >> ph;
            for(int j=i; j>=0; j--){
                dp[j] = (1 - ph) * dp[j] + (j == 0 ? 0 : dp[j-1]*ph);
            }
        }
        double ans = 0;
        for(int i=0; i<=n; i++){
            if(i > n - i)
                ans += dp[i];
        }
        //for(int i : dp)
          //  cout << i << ' ';
        cout<< setprecision(15) << ans;
}
/*
3
0.30 0.60 0.80
*/





Measured memory_bytes: 384
#include <iostream>

using namespace std;

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

int main(){

   int n, m, l;

   cin >> n >> m >> l;

   int a[n][m], b[m][l];
   long long int c[n][l];

   rep(i, n){
      rep(j, m){
         cin >> a[i][j];
      }
   }

   rep(i, m){
      rep(j, l){
         cin >> b[i][j];
      }
   }

   rep(i, n){
      rep(j, l){
         c[i][j] = 0;
         rep(k, m){
            c[i][j] += a[i][k] * b[k][j];
         }
      }
   }

   rep(i, n){
      rep(j, l){
         if(j){
            cout << " ";
         }
         cout << c[i][j];
      }
      cout << endl;
   }

   return 0;
}


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

t = []

for i in range(N):
    a = int(input())
    t_append = []
    for j in range(a):
        x, y = map(int, input().split())
        t_append.append((x, y))
    t.append(t_append)

ans = 0

for i in range(1 << N):
    ok = 1
    for j in range(N):
        if 1 << j & i:
            for a_t in t[j]:
                if 1 << (a_t[0]-1) & i:
                    if a_t[1] != 1:
                        ok = 0
                        break
                else:
                    if a_t[1] != 0:
                        ok = 0
                        break
        if ok == 0:
            break
    if ok:
        if ans < sum(list(map(int, list(bin(i)[2:])))):
            ans = sum(list(map(int, list(bin(i)[2:]))))

print(ans)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define fr first
#define sc second
#define pb push_back
#define maxheap priority_queue<int>
#define minheap priority_queue<int, vector<int>, greater<int> >
const int INF = 1e9+7;
const int MAXN = 5e5 + 200;
const  long double eps = 1e-16;
const long double pi = acos(-1.0);
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

int n, m;
int a[MAXN], b[MAXN];
string s;
int ans1, ans2;
void solve(){
    cin >> n >> m;
    for (int i = 1; i <= m; i++){
        int x;
        cin >> x >> s;
        //cout << x << " " << s << endl;
        if (s == "AC"){
            if (a[x] == 0){
                a[x]++;
                ans1++;
                if (b[x] != 0)
                    ans2 += b[x];
            }

        }
        else{
            if (a[x] == 0){
                b[x]++;
            }
        }
    }
    cout << ans1 << " " << ans2 << endl;
}

int main() {
ios::sync_with_stdio(NULL), cin.tie(0), cout.tie(0);
cout.setf(ios::fixed), cout.precision(10);
 //freopen("input.in", "r", stdin);
// freopen("output.out", "w", stdout);
 int step;
 step = 1;
  for (int i = 1; i <= step; i++){
         solve();
    }
}


Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string>
#include <cctype>
#include <stack>
#include <queue>
#include <vector>
#include <cstdlib>

using namespace std;

int main(void){

	int  a, b, c,count = 0;
	
	cin >> a >> b >> c;

	for (int i = a; i <= b; i++) {
		if (c %i == 0)
			count++;
	}

	cout << count << endl;

	return 0;
}

Measured memory_bytes: 3076
a,b = [int(i) for i in input().split()]
 
l = [int(i) for i in input().split()]
ans = 0
for i in range(1,a):
    if l[i] - l[i -1] > b:
        ans += b
    else:
        ans += l[i] - l[i-1]
        
ans += b
 
print(ans)

Measured memory_bytes: 25200
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define bug cout<<"AIkahne aise"<<endl
ll A[5000001],sign[5000001];
vector<ll>v;
vector<pair<ll,ll> >v2;
/*void sieve()
{
    for(ll i=3; i<=2000; i+=2)
    {
        for(ll j=i*i; j<=4000000; j+=i)
            A[j]=1;
    }
    v.push_back(2);
    for(ll i=3; i<=4000000; i+=2)
        if(A[i]==0)
            v.push_back(i);
}*/
int main()
{
ll n,sum=0,zero=0,cnt=0;
cin>>n;
for(int i=1;i<=n;i++)
{
    cin>>A[i];
    sum+=abs(A[i]);
    if(A[i]<0)
        cnt++;
        if(A[i]==0)
            zero++;
}

//cout<<sign[n]<<endl;
if(cnt%2==0)
{
    cout<<sum<<endl;
}
else if(cnt%2==1&&zero>0)
{
    cout<<sum<<endl;
}
else
{
    cnt=0;
    ll ans=999999999999999999;
    for(int i=1;i<=n;i++)
    {
                ans=min(ans,abs(A[i]));
    }
    cout<<sum-2*ans<<endl;
}
return 0;
}


Measured memory_bytes: 2304
#include <algorithm>
#include <iostream>
#include <numeric>
#include <set>
#include <string>
#include <vector>

using namespace std;
using LLONG = long long;

vector<vector<int>> ComputeGroups(const string &str, const int N)
{
    vector<vector<int>> groups;
    vector<int> group;
    for (int i = 0; i < N; ++i)
    {
        if (str[i] == '#')
        {
            if (!group.empty())
            {
                groups.push_back(group);
                group.clear();
            }
        }
        else
        {
            group.push_back(i);
        }
    }
    if (!group.empty()) groups.push_back(group);
    return groups;
}

int main()
{
    int H, W;
    cin >> H >> W;
    vector<string> rows(H);
    vector<string> columns(W);
    vector<int> scores(H * W, 0);
    for (int r = 0; r < H; ++r)
    {
        cin >> rows[r];
        for (int c = 0; c < W; ++c)
        {
            columns[c] += rows[r][c];
        }
    }
    for (int r = 0; r < H; ++r)
    {
        const auto groups = ComputeGroups(rows[r], W);
        for (const auto &group : groups)
        {
            for (const int member : group)
            {
                scores[r * W + member] += static_cast<int>(group.size());
            }
        }
    }
    for (int c = 0; c < W; ++c)
    {
        const auto groups = ComputeGroups(columns[c], H);
        for (const auto &group : groups)
        {
            for (const int member : group)
            {
                scores[member * W + c] += static_cast<int>(group.size());
            }
        }
    }
    cout << *max_element(scores.begin(), scores.end()) - 1 << endl;
}


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

int main()
{
    long n,k,i,j,l,r,j1,zero,sum,count;
    cin>>n>>k;
    long a[n],a1[n],b[n+1];
    zero=0;
    sum=0;
    for (i = 0; i < n; i++) cin>>a[i];
    for (i = 0; i < k; i++)
    {
        for (j = 0; j < n; j++) b[j]=0;
        count=0;
        for (j = 0; j < n; j++)
        {
            l=max(zero,j-a[j]);
            r=min(n-1,j+a[j]);
            b[l]++;
            b[r+1]--;
        }
        for (j = 0; j < n; j++) a[j]=0;
        for (j = 0; j < n; j++) 
        {
            count+=b[j];
            a[j]+=count;
            sum+=a[j];
        }
        if (sum==n*n) break;
        else sum=0;
    }
    for (i = 0; i < n; i++) cout<<a[i]<<" ";
    cout<<endl;
}

Measured memory_bytes: 6732
A, B, C = [int(a) for a in input().split()]

count = 0

while 1:
    if A%2==0 and B%2==0 and C%2==0:
        if A==B and B==C:
            print(-1)
            exit()
        A_tmp = B//2 + C//2
        B_tmp = A//2 + C//2
        C_tmp = A//2 + B//2
        A, B, C = A_tmp, B_tmp, C_tmp
        count += 1
    else:
        break
print(count)

Measured memory_bytes: 9052
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;
typedef struct _data {
	int x;
	int y;
} data;

int  main()
{
	int n;
	cin >> n;
	int w[n];
	int ite[n];
	int sum = 0;
	rep(i,n)
	{
		cin >> w[i];
		sum += w[i];
	}
	// rep(i, n)
	// {
	// 	ite[i] = w[i];
	// }
	int ans = sum;
	ite[0] = w[0];
	for (int i = 1; i < n - 1; i++)
	{
		ite[i] = ite[i-1] + w[i];
		ans = min(abs(ite[i] - (sum - ite[i])), ans);
		// cout << ite[i] << endl;
	}
	cout << ans;
	return (0);
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 1000000007
#define INF 1LL<<30
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()

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

    ll ans=0;
    ll a[n+1];
    vector<ll> b(n+1,0);
    vector<ll> c(n+1,0);

    rep(i,n+1) a[i]=i;
    rep(i,n+1){
        if(i>0) b[i]=(b[i-1]+a[i]);

    }
    for(int i=n;i>=0;i--){
        if(i==n) c[i]=a[i];
        else c[i]=(c[i+1]+a[i]);
    }
    reverse(all(c));
    
    for(int i=k;i<=n+1;i++){
        ans=(ans+c[i-1]-b[i-1]+1)%MOD;
    }

    cout<<ans<<endl;
}


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

// in-short-use macros

#define ll long long int
#define ld long double
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define mod 1000000007

//container-use 

typedef vector< ll > vl;
typedef vector< vl > vvl;
typedef pair< ll,ll > pll;
typedef vector<pair<ll,ll > > vpl;
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(typeof((c).begin() i = (c).begin(); i != (c).end(); i++)
#define present(c,x) ((c).find(x) != (c).end())
#define rep(i,a,b) for (int i = a; i <= b; i++)

//main function here

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
    int a;
    cin>>a;
    bool ans=false;

    for(int i=1;i<=9;i++){
        if(a%i==0 && a/i<=9)
            ans=true;
    }
    if(ans)
        cout<<"Yes\n";
    else
        cout<<"No\n";
  return 0;
 }

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

using namespace std;

const int N=1e6+10;
vector<int> G[N];
int order[N];
int low[N];
int p[N];
int ans[N];
int child=0;
int cnt=0;

void add(int s,int t)
{
    G[s].push_back(t);
    G[t].push_back(s);
}

void dfs(int v)
{
    order[v]=low[v]=++cnt;
    for(int i=0;i<G[v].size();i++)
    {
        int u=G[v][i];
        if(!order[u])
        {
            if(v==0) child++;
            p[u]=v;
            dfs(u);
            low[v]=min(low[v],low[u]);
            if(low[u]>=order[v]) ans[v]=true;
        }else if(p[v]!=u)
        {
            low[v]=min(low[v],order[u]);
        }
    }
}

int main()
{
    int v,e;
    cin>>v>>e;

    for(int i=0;i<e;i++){
        int s,t;
        cin>>s>>t;
        add(s,t);
    }

    dfs(0);
    if(child<=1)    ans[0]=false;


    for(int i=0;i<v;i++) if(ans[i]) cout<<i<<endl;

    return 0;
}



Measured memory_bytes: 27768
#include<iostream>
using namespace std;
int main(){
	int n;
	cin>>n;
	int A[n];
	for(int i=0; i<n; i++)
		cin>>A[i];
	int q;
	cin>>q;
	while(q--){
		int b,e,t;
		cin>>b>>e>>t;
		for(int i=0; i<e-b; i++){
			swap(A[b+i], A[t+i]);
		}
	}
	for(int i=0; i<n-1; i++)
		cout<<A[i]<<" ";
	cout<<A[n-1]<<endl;
	return 0;
}


Measured memory_bytes: 3096
using System;
using System.Collections.Generic;

namespace ABC177_A {
    public class Program {
        public static void Main(string[] args) {
            var inputArr = parseInputStrForList();

            if(inputArr[0] <= inputArr[1] * inputArr[2]) {
                Console.WriteLine("Yes");
            } else {
                Console.WriteLine("No");
            }

            return;

            int ans = 0;
            Console.WriteLine(ans);
        }

        private static List<int> parseInputStrForList() {
            var input = Console.ReadLine().Split();
            var list = new List<int>();
            for(int index = 0; index < input.Length; index++) {
                list.Add(int.Parse(input[index]));
            }

            return list;
        }
    }
}

Measured memory_bytes: 27640