akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pl;
typedef vector<pl> vp;
#define fore(i,a,b) for(ll i=(a);i<=(b);++i)
#define rep(i,n) fore(i,0,(n)-1)
#define rfore(i,a,b) for(ll i=(b);i>=(a);--i)
#define rrep(i,n) rfore(i,0,(n)-1)
#define all(x) (x).begin(),(x).end()
const ll INF=1001001001;
const ll LINF=1001001001001001001;
const ll D4[]={0,1,0,-1,0};
const ll D8[]={0,1,1,0,-1,-1,1,-1,0};
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;}
template<class T>
ll sum(const T& a){return accumulate(all(a),0LL);}

void solve(){
    double a,b,c;cin>>a>>b>>c;
    c=c*2*M_PI/360;
    double s=a*b*sin(c)/2;
    double l=a+b+sqrt(a*a+b*b-2*a*b*cos(c));
    double h=b*sin(c);
    cout.precision(10);
    printf("%.7f\n",s);
    printf("%.7f\n",l);
    printf("%.7f\n",h);
}

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



Measured memory_bytes: 3548
#include <iostream>
#include <cmath>
using namespace std;
int main(void) {
	int n, m, p, q;
	q = 0;
	cin >> n;
	for (int i = 0; i < n; i++) {
		p = 0;
		cin >> m;
		if (m != 1) {
			for (int j = 2; j <= sqrt(m); j++) {
				if (m%j == 0) {
					p++;
				}
			}
			if (p == 0) {
				q++;
			}
		}
	}
	cout << q << endl;
	return 0;
}

Measured memory_bytes: 3080
import std.stdio, std.string, std.conv, std.range;
import std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, std.random, core.bitop;

void scan(T...)(ref T args) {
    auto line = readln.split;
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront;
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

bool chmin(T, U...)(ref T x, U args) {
    bool isChanged;
    foreach (arg; args) if (x > arg) {
        x = arg;
        isChanged = true;
    }
    return isChanged;
}

bool chmax(T, U...)(ref T x, U args) {
    bool isChanged;
    foreach (arg; args) if (x < arg) {
        x = arg;
        isChanged = true;
    }
    return isChanged;
}


enum inf = 1_001_001_001;
enum infl = 1_001_001_001_001_001_001L;

long[] factor(long N) {
    long[] res;
    for (long p = 2; p*p <= N; p++) {
        while (N % p == 0) {
            res ~= p;
            N /= p;
        }
    }
    if (N > 1) {
        res ~= N;
    }
    return res;
}

void main() {
    int n;
    scan(n);
    auto d = factor(n);
    writefln("%s: %(%s %)", n, d);
}



Measured memory_bytes: 2508
/* --- author: dxm --- */
#include<bits/stdc++.h>
using namespace std;

#define INF 1e9
#define Inf 1e18
#define rep(i,n) for(int (i)=0;(i)<n;i++)
#define REP(i,n) for(int (i)=1;(i)<=n;i++)
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define fst first
#define snd second
typedef long long ll;
inline void Fail(){printf("0");exit(0);}

const int maxn=100005;
int n;
char c[maxn];
 
int main(){
	scanf("%s",c);n=strlen(c);
	int a=c[0]==c[n-1],b=n%2==0;
	printf(a^b?"Second":"First");
	return 0;
}

/*
Input:
-----------------
Output:
*/

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

using namespace std;

typedef long long ll;

const ll M = 1e9 + 7;

const int N = 100100;

int cnt[N];

int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n, a;
    cin >> n;
    int e[3] = { 0, 1, 2 };
    for (int i = 0; i < n; ++i) {
        cin >> a;
        for (int j = 0; j < 3; ++j) {
            ++cnt[a + e[j]];
        }
    }
    int ans = 0;
    for (int i = 0; i < N; ++i) {
        ans = max(ans, cnt[i]);
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<iomanip>
#include<algorithm>
using namespace std;
#define inf 1<<29
int h,w;
int c[11][11];
int m[15][15];
int a[205][205];
int main()
{
     cin>>h>>w;
    int x,y,z;
    for(int i=0;i<10;i++)
         for(int j=0;j<10;j++)
              cin>>c[i][j];
              int n=10;
              memset(m,100000000,sizeof(m));
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<n;j++)
        {
            for(int k=0;k<n;k++)
            {
                if(c[j][k]>c[j][i]+c[i][k])
                    c[j][k]=c[j][i]+c[i][k];
            }
        }
    }
   int sum=0;
   for(int i=0;i<h;i++)
      for(int j=0;j<w;j++)
      {
          cin>>a[i][j];
          int t=a[i][j];
          if(a[i][j]==-1||a[i][j]==1) continue;
          sum+=c[t][1];
      }
    cout<<sum<<endl;
        return 0;
}


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


struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};

typedef struct node *Node;
Node root;

void insert(int );
void inorder(Node );
void preorder(Node );

int main(){
  int n,i;
  int k;
  char t[5];

  scanf("%d",&n);
  
  for(i=0 ; i<n ; i++){
    scanf("%s",t);
    if(t[0]== 'p'){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
    if(t[0]=='i'){
    scanf("%d",&k);
    insert(k);
    }
  }

  return 0;
}


void insert(int k){
  Node z;
  Node y = NULL;
  Node x = root;
  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NULL;
  z->right = NULL;

  while(x != NULL){
    y=x;
    if(z->key < x->key) x = x->left;
    else x = x->right;
  }
  z->parent = y;

  if(y == NULL)root = z;
  else if(z->key < y->key) y->left = z;
  else y->right = z;
}


void inorder(Node T){
  if(T != NULL){
    inorder(T->left);
    printf(" %d",T->key);
    inorder(T->right);
  }
}


void preorder(Node T){
  if(T != NULL){
    printf(" %d",T->key);
    preorder(T->left);
    preorder(T->right);
  }
}

Measured memory_bytes: 24040
// Ala be zekrellah tatmaenolgholoob ...
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define F first
#define S second
#define MP make_pair
const int maxn = 1e5+9;
const ll mod = 1e9+7;

map <pair<string,string>,int> mp;

int main () {
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	int n;
	string s;
	cin >> n >> s;
	for (int i = 0; i < (1 << n); i++) {
		string cur1, cur2;
		for (int t = 0; t < n; t++)
			if (i & (1 << t))
				cur1 += s[t];
			else
				cur2 += s[t];
		mp[MP(cur1, cur2)]++;
	}
	ll res = 0;
	for (int i = 0; i < (1 << n); i++) {
		string cur1, cur2;
		for (int t = 0; t < n; t++)
			if (i & (1 << t))
				cur1 += s[2 * n - t - 1];
			else
				cur2 += s[2 * n - t - 1];
		res += mp[MP(cur1, cur2)];
	}
	cout << res << "\n";
}



Measured memory_bytes: 91904
#include<map>
#include<bitset>
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<stack>
#define REP(i,x,y) for(ll i=x;i<=y;i++)
typedef long long ll;
using namespace std;

ll a[1000];
int main() {
	ll n, x;
	cin >> n >> x;
	REP(i, 1, n) {
		cin >> a[i];
	}
	sort(a + 1, a + 1 + n);
	ll cnt = 0;
	REP(i, 1, n-1) {
		if (x >= a[i]) {
			x -= a[i];
			cnt++;
		}
		else {
			break;
		}
	}
	if (x == a[n]) {
		cnt++;
	}
	cout << cnt << endl;
}

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

using namespace std;
typedef long long ll;

int N,M;
int d[5];

int main(){
    cin >> N >> M;
    for(int i=0;i<N;i++) d[i] = -1;
    for(int i=0;i<M;i++){
        int a,b;
        cin >> a >> b;
        if(d[a-1] != -1 && d[a-1] != b){
            cout << -1 << endl;
            return 0;
        }
        d[a-1] = b;
    }
    if(d[0] == 0 && N > 1){
        cout << -1 << endl;
        return 0;
    }
    for(int i=0;i<N;i++){
        if(d[i] == -1){
            if(i == N-1 || i != 0) cout << 0;
            else cout << 1;
        }else{
            cout << d[i];
        }
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <cmath>   
#include<cctype>
#include<string>
#include<set>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include <deque>
#include <typeinfo>
#include <utility> 

#define rep(i,m,n) for(int i = m;i < n;++i)
using namespace std;
using ll = long long;
using R = double;
const ll inf = 1LL << 50;
const ll MOD = 1e9 + 7;

struct edge { int to; int from; int cost; };
bool comp(const edge& e1, const edge& e2) {
	return e1.cost < e2.cost;
}


int V, E;


class UnionFind {
public:
	vector<int> r, p;

	UnionFind() {}
	UnionFind(int size) {
		r.resize(size, 0);
		p.resize(size, 0);
		rep(i, 0, size)makeSet(i);
	}

	void makeSet(int x) {
		p[x] = x;
		r[x] = 0;
	}

	bool same(int x, int y) {
		return findSet(x) == findSet(y);
	}

	void unite(int x, int y) {
		link(findSet(x), findSet(y));
	}

	void link(int x, int y) {
		if (r[x] > r[y]) {
			p[y] = x;
		}
		else {
			p[x] = y;
			if (x == y) {
				r[y]++;
			}
		}
	}


	int findSet(int x) {
		if (x == p[x]) {
			return x;
		}
		else {
			return p[x] = findSet(p[x]);
		}
	}
};



int kruskal(vector<edge>edges) {
	sort(edges.begin(), edges.end(),comp);
	UnionFind un = UnionFind(V);
	int res = 0;
	rep(i, 0, edges.size()) {
		edge e = edges[i];
		if (!un.same(e.from, e.to)) {
			un.unite(e.from, e.to);
			res += e.cost;
		}
	}
	return res;
}

int main() {
	cin >> V >> E;
	vector<edge>edges;
	rep(i, 0, E) {
		int s, t, w;
		cin >> s >> t >> w;
		edges.push_back({ s,t,w });
		edges.push_back({ t,s,w });
	}
	cout << kruskal(edges) << endl;
}


Measured memory_bytes: 7576
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define uniq(v) v.erase(unique(v.begin(),v.end()),v.end())
#define lb(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define ub(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
using Pair = pair<ll,pair<int,int>>;
#define pq priority_queue<Pair, vector<Pair>, greater<Pair>> 
const ll mod=1000000007;
//const ll mod=998244353;
const ld pi=acos(-1.0);
const ll INF = 1LL<<61;
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; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//  cout << fixed << setprecision (20);   小数点以下2０桁まで
//実行時間制約2秒では２×10^8回くらいまで計算できる



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

  int n,x,t;
  cin>>n>>x>>t;



  cout << t*((n+x-1)/x) << endl;

}

Measured memory_bytes: 3648
#include <stdio.h>

int main(void) {
    int n, m;
    scanf("%d%d", &n, &m);
    
    int a[m], total = 0;
    for(int i = 0; i < m; i++) {
        scanf("%d", &a[i]);
        total += a[i];
    }
    
    if(n < total) printf("-1");
    else printf("%d\n", n - total);
}


Measured memory_bytes: 1772
using System;
using System.IO;
using System.Net;
using System.Net.Sockets;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
using System.Text.RegularExpressions;
using static System.Math;
using MethodImplOptions = System.Runtime.CompilerServices.MethodImplOptions;
using MethodImplAttribute = System.Runtime.CompilerServices.MethodImplAttribute;

public static class P
{
    public static void Main()
    {
        int n = Reader.NextUInt;
        int last = 0;
        int cur = 0;
        int max = 0;
        for (int i = 0; i < n; i++)
        {
            var h = Reader.NextUInt;
            if (last >= h) max = Max(max, ++cur);
            else cur = 0;
            last = h;
        }
        Console.WriteLine(max);
    }
}

static class Reader
{
    const int BUF_SIZE = 1 << 12;
    static Stream Stream = Console.OpenStandardInput();
    static byte[] buffer = new byte[BUF_SIZE];
    static int ptr = 0;

    private static void Read() { Stream.Read(buffer, 0, BUF_SIZE); }

    private static byte Next { get { if (ptr >= buffer.Length) { Read(); ptr = 0; } return buffer[ptr++]; } }

    public static int NextUInt
    {
        get
        {
            int res = 0; byte next; do { next = Next; } while (next < 48);
            do { res = res * 10 + next - 48; next = Next; } while (48 <= next);
            return res;
        }
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pi acos(-1.0)
#define rf freopen("in.txt", "r", stdin);
#define ld long double
#define all(v) v.begin(),v.end()
#define push_back push_back
#define ff first
#define ss second
#define ln length()
#define rep(i,a, n) for(int i=a;i<=n;i++)
#define repp(i,a,b) for(int i=a;i<b;i++)
#define s(n) scanf("%d",&n);
#define sl(n) scanf("%lld",&n);
#define sld(n) scanf("%lf", &n);

using namespace std;

int main(){
    int n;
    ll X = 0, x = 0,ans = 1000000000000000000ll;
    s(n);
    vector <ll> a(n);
    for (int i = 0; i < n; i++) {
        sl(a[i]);
        X += a[i];
    }

    for (int i = 0; i < n; i++) {
        x += a[i];
        if (i + 1 < n) {
            ans = min(ans, abs(X-2*x));
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1792
import sys
from collections import defaultdict as dd
mod = pow(10, 9) + 7
mod2 = 998244353
inf = int(1e20)
def data(): return sys.stdin.readline().strip()
def out(*var, end="\n"): sys.stdout.write(" ".join(map(str, var))+end)
def l(): return list(sp())
def sl(): return list(ssp())
def sp(): return map(int, data().split())
def ssp(): return map(str, data().split())
def l1d(n, val=0): return [val for i in range(n)]
def l2d(n, m, val=0): return [l1d(n, val) for j in range(m)]


n = int(data())
arr = list(map(float, data().strip().split()))
dp = dd(lambda: dd(float))
dp[0][0] = 1
for i in range(1, n+1):
    dp[i][0] = dp[i-1][0] * (1.0 - arr[i-1])
answer = 0.0
for i in range(1, n+1):
    for j in range(1, n+1):
        dp[i][j] = arr[i-1] * dp[i-1][j-1] + (1.0 - arr[i-1]) * dp[i-1][j]
        if j >= n//2+1 and i == n:
            answer += dp[i][j]
out(answer)


Measured memory_bytes: 742792
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
  int D;
  cin>>D;
  D=365;
  vector<ll> c(26);
  vector<ll> d(26);
  ll sumc=0;
  vector<vector<ll>> s(D,vector<ll>(26));
  for(int i=0;i<26;i++){
    cin>>c.at(i);
    c.at(i)=0;
    sumc+=c.at(i);
  }
  for(int i=0;i<365;i++){
    for(int j=0;j<26;j++){
      s.at(i).at(j)=0;
      cin>>s.at(i).at(j);
    }
  }
  ll dp[400][30];
  for(int i=1;i<=D;i++){
    if(i==1){
      ll rock=0;
      for(int j=1;j<=26;j++){
        rock=max(rock,s.at(0).at(j-1)-(sumc-c.at(j-1)));
      }
      for(int j=1;j<=26;j++){
        if(s.at(0).at(j-1)-(sumc-c.at(j-1))==rock){d.at(j-1)=i;cout<<j<<endl;break;}
      }
      for(int j=1;j<=26;j++){
        dp[1][j]=s.at(0).at(j-1)-(sumc-c.at(j-1));
      }
    }
    else{
      for(int j=1;j<=26;j++){
        dp[i][j]=dp[i-1][j];
        for(int k=1;k<=26;k++){
          dp[i][j]-=(i-d.at(k-1))*c.at(k-1);
          if(d.at(k-1)+1==i){dp[i][j]+=c.at(k-1);}
        }
      }
      ll ans=0;
      for(int j=1;j<=26;j++){
        ans=max(ans,dp[i][j]);
      }
      for(int j=1;j<=26;j++){
        if(ans==dp[i][j]){d.at(j-1)=i;cout<<j<<endl;break;}
      }
    }
  }
}

Measured memory_bytes: 3808
#include <stdio.h>
#include <string.h>
#include <limits.h>

#define MAX_H 514
#define INF INT_MAX 

int main(){
  int H,i,a[MAX_H],j;
  for(i = 0 ; i < MAX_H ; i++){
    a[i] = INF;
  }
  scanf("%d",&H);
  for(i = 0 ; i < H ; i++){
    scanf("%d",&a[i]);
  }
  for(i = 0 ; i < H ; i++){
    printf("node %d: key = %d, ", i+1, a[i]);
    if(i != 0){
      j = (i & 1 ? i/2 : (i-1)/2);
      printf("parent key = %d, ", a[j]);
    }
    if(a[i*2+1] != INF){
      printf("left key = %d, ", a[i*2+1]);
    }
    if(a[i*2+2] != INF){
      printf("right key = %d, ", a[i*2+2]);
    }
    printf("\n");
  }
  return 0;
}

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

int main(void)
{
    int N;
    string S;
    cin >> N;
    cin >> S;
    int buf = N;
    for (int i = 1; i < buf; i++) {
        if (S[i] == S[i - 1]) {
            N--;
        }
    }
    cout << N << endl;
}



Measured memory_bytes: 512
import sys
bbn=1000000007
	
#+++++

		
def main():
	n = int(input())
	al=[]
	for i in range(n):
		b , c = map(int, input().split())
		al.append([b+c,b-c,b,c])
	al.sort()
	#pa(al)
	init=al[0]
	count=1
	for right,left,x,l in al[1:]:
		if left >= init[0]:
			count+=1
			init=[right,left,x,l]
	print(count)
		
	
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)

if __name__ == "__main__":
	if sys.platform =='ios':
		sys.stdin=open('inputFile.txt')
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

Measured memory_bytes: 28388
import sys

input_methods=['clipboard','file','key']
using_method=0
input_method=input_methods[using_method]

tin=lambda : map(int, input().split())
lin=lambda : list(tin())
mod=1000000007

#+++++

def main():
	#a = int(input())
	x, n = tin()
	#s = input()
	al = set(lin())
	mm=5000
	mv=-1000
	for i in range(-100,200):
		if abs(i-x) < mm and i not in al:
			mm = abs(i-x)
			mv = i
	print(mv)
	
	
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)
		
def input_clipboard():
	import clipboard
	input_text=clipboard.get()
	input_l=input_text.splitlines()
	for l in input_l:
		yield l

if __name__ == "__main__":
	if sys.platform =='ios':
		if input_method==input_methods[0]:
			ic=input_clipboard()
			input = lambda : ic.__next__()
		elif input_method==input_methods[1]:
			sys.stdin=open('inputFile.txt')
		else:
			pass
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

Measured memory_bytes: 62156
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<vector>
using namespace std;
const int N=305,mod=1000000007;
int n,m,l,r,xx,ans,f[2][3][N][N];
vector<int> v[N],x[N];
int main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++){
		scanf("%d%d%d",&l,&r,&xx);
		v[r].push_back(l);
		x[r].push_back(xx);
	}
	int sta=0;
	f[sta][0][0][0]=f[sta][1][0][0]=f[sta][2][0][0]=1;
	for(int i=1;i<=n;i++){
		sta^=1;
		if(i==n){
			for(int j=0;j<i;j++){
				for(int k=0;k<i;k++){
					if(j==k&&j!=0){
						f[sta][0][j][k]=0;
					}else{
						f[sta][0][j][k]=f[sta^1][0][j][k];
						f[sta][1][j][k]=f[sta^1][1][j][k];
						f[sta][2][j][k]=f[sta^1][2][j][k];
					}
				}
			}
			for(int j=0;j<(int)v[i].size();j++){
				l=v[i][j];
				xx=x[i][j];
				for(int j=0;j<i;j++){
					for(int k=0;k<i;k++){
						if((j>=l)+(k>=l)+1!=xx){
							f[sta][0][j][k]=f[sta][1][j][k]=f[sta][2][j][k]=0;
						}
					}
				}
			}
			break;
		}
		for(int j=0;j<i;j++){
			for(int k=0;k<i;k++){
				if(j==k&&j!=0){
					f[sta][0][j][k]=0;
				}else{
					f[sta][0][j][k]=f[sta^1][0][j][k];
					f[sta][1][j][k]=f[sta^1][1][j][k];
					f[sta][2][j][k]=f[sta^1][2][j][k];
				}
			}
		}
		for(int j=0;j<(int)v[i].size();j++){
			l=v[i][j];
			xx=x[i][j];
			for(int j=0;j<i;j++){
				for(int k=0;k<i;k++){
					if((j>=l)+(k>=l)+1!=xx){
						f[sta][0][j][k]=f[sta][1][j][k]=f[sta][2][j][k]=0;
						f[sta^1][0][j][k]=f[sta^1][1][j][k]=f[sta^1][2][j][k]=0;
					}
				}
			}
		}
		for(int j=0;j<i;j++){
			for(int k=0;k<i;k++){
				if(k!=j||j==0){
					f[sta][0][i][j]=(f[sta][0][i][j]+f[sta^1][1][k][j])%mod;
					f[sta][0][j][i]=(f[sta][0][j][i]+f[sta^1][2][j][k])%mod;
					f[sta][1][i][j]=(f[sta][1][i][j]+f[sta^1][0][k][j])%mod;
					f[sta][1][j][i]=(f[sta][1][j][i]+f[sta^1][2][j][k])%mod;
					f[sta][2][i][j]=(f[sta][2][i][j]+f[sta^1][0][k][j])%mod;
					f[sta][2][j][i]=(f[sta][2][j][i]+f[sta^1][1][j][k])%mod;
				}
			}
		}
	}
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			ans=(ans+f[sta][0][i][j])%mod;
			ans=(ans+f[sta][1][i][j])%mod;
			ans=(ans+f[sta][2][i][j])%mod;
		}
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 2432
n,m,c=map(int,input().split())
b=list(map(int,input().split()))
info=[]
for i in range(n):
    info.append(list(map(int,input().split())))

count=0
for i in range(n):
    score=0
    for j in range(m):
        score+=info[i][j]*b[j]
    if score+c>0:
        count+=1
print(count)

Measured memory_bytes: 3064
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }
    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        long N = scan.nextLong();
        long M = scan.nextLong();
        if (N == 1) {
            System.out.println(M);
            return;
        }
        List<Long> divisors = this.divisor(M);
        long answer = 1;
        for (long i : divisors) {
            if (M < i * N) {
                continue;
            }
            long x = M - i * (N - 1);
            if (x % i == 0 && x > 0) {
                answer = Math.max(answer, i);
            }
        }
        System.out.println(answer);
    }
    private List<Long> divisor(long M) {
        List<Long> list = new ArrayList<>();
        for (long i = 2; i * i <= M; i++) {
            if (M % i != 0) {
                continue;
            }
            list.add(i);
            long j = M / i;
            if (i != j) {
                list.add(j);
            }
        }
        return list;
    }
}


Measured memory_bytes: 25300
// #define _CRT_SECURE_NO_WARNINGS
// #define _USE_MATH_DEFINES	// M_PI=3.1415...
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <locale>
#include <cctype>
#include <sstream>
#include <iomanip>	// 20桁出力 cout << setprecision(20) << double;
#include <queue>
#include <bitset>	// bitset<8> bs1(131uL); // 10000011 bs1[0]は1 01stringからビット集合生成可
#include <numeric>
#include <random>
using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<LL> VL;
typedef vector<pair<LL, LL> > VP;
typedef vector<string> VS;
typedef map<int, int> MAPII;
typedef multimap<int, char, greater<int> > MuMAPIC;
typedef multimap<int, string, greater<int> > MuMIS;
typedef pair<int, int> P;
typedef pair<int, pair<P, P> > PP;

#define INF 999999999999999997;
#define MP make_pair
#define FAST_IO  cin.tie(0); ios::sync_with_stdio(false);
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORL(i,a,b) for(LL i=(a);i<(b);i++)
#define FOR_REV(i,a,b) for(int i=(a);i>=(b);i--)
#define foreach_it(type,it,c) for(type::iterator it=c.begin(),c_end=c.end();it!=c_end;++it)
#define FOR_ITR(d) for(auto itr=d.begin(),d_end=d.end();itr!=d_end;++itr)	// C++11
#define O(s) cout<<s<<endl;

#define DUMP_VVI(b) FOR(i,0,b.size()){FOR(j,0,b[i].size())printf("%d ",b[i][j]);puts("");}
#define D_OUT(str,value) if(dbgF){cout<<str<<" : "<<value<<endl;}

template<class T>T IN() { T d; cin >> d; return d; }

LL gcd(LL a, LL b) { return (b > 0) ? gcd(b, a%b) : a; } // 最大公約数（Greatest Common Divisor）
LL lcm(LL a, LL b) { return a / gcd(a, b) * b; } // 最小公倍数（Least Common Multiple）
bool uruu(LL Y) { return (((Y % 4 == 0 && Y % 100 != 0) || Y % 400 == 0) ? true : false); } // うるう年判定

int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };
int dxx[8] = { 0,1,1,1,0,-1,-1,-1 };
int dyy[8] = { 1,1,0,-1,-1,-1,0,1 };

// vector注意
// vec[i][j]の形に入力を入れるとき、vecは初期化してある必要がある.

// ------------------- include, typedef, define END. -------------------


int main() {
	FAST_IO;
	bool dbgF = true; // for D_OUT(str, value)  ... cout<< str <<" : "<< value <<endl;

	LL N, A, B;
	cin >> N >> A >> B;

	if (A > B) {
		O(0);
	}
	else if (N == 1 && A != B) {
		O(0);
	}
	else {
		LL centerNum = max(N - 2, (LL)1);
		LL ans = B*centerNum - A*centerNum;
		ans++;
		O(ans);
	}

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
const double PI=acos(-1);

const ll mod = 1000000007;

template<int MOD> class Fp {
    ll val;
public:
    constexpr Fp(ll v = 0) noexcept : val(v % MOD) {
        if(val < 0) val += MOD;
    }
    constexpr int getmod() { return MOD; }
    constexpr Fp operator- () const noexcept { return val ? MOD - val : 0; }
    constexpr Fp operator+ (const Fp& r) const noexcept { return Fp(*this) += r; }
    constexpr Fp operator- (const Fp& r) const noexcept { return Fp(*this) -= r; }
    constexpr Fp operator* (const Fp& r) const noexcept { return Fp(*this) *= r; }
    constexpr Fp operator/ (const Fp& r) const noexcept { return Fp(*this) /= r; }
    constexpr Fp& operator+= (const Fp& r) noexcept {
        val += r.val;
        if(val >= MOD) val -= MOD;
        return *this;
    }
    constexpr Fp& operator-= (const Fp& r) noexcept {
        val -= r.val;
        if(val < 0) val += MOD;
        return *this;
    }
    constexpr Fp& operator*= (const Fp& r) noexcept {
        (val *= r.val) %= MOD;
        return *this;
    }
    constexpr Fp& operator/= (const Fp& r) noexcept {
        ll a = r.val, b = MOD, u = 1, v = 0;
        while(b){
            ll t = a/b;
            a -= t*b; swap(a, b);
            u -= t*v; swap(u, v);
        }
        (val *= u) %= MOD;
        if(val < 0) val += MOD;
        return *this;
    }
    constexpr bool operator== (const Fp& r) const noexcept {
        return this->val == r.val;
    }
    constexpr bool operator!= (const Fp& r) const noexcept {
        return this->val != r.val;
    }
    constexpr bool operator> (const Fp& r) const noexcept {
        return this->val > r.val;
    }
    constexpr bool operator< (const Fp& r) const noexcept {
        return this->val < r.val;
    }
    friend constexpr ostream& operator<< (ostream &os, const Fp<MOD>& x){
        ll tmp = x.val;
        os << tmp;
        return os;
    }
    friend constexpr ostream& operator>> (istream &is, const Fp<MOD>& x){
        ll tmp;
        is >> tmp;
        x = Fp<MOD>(tmp);
        return is;
    }
    constexpr Fp<MOD> modpow(ll n) noexcept {
        if(n == 0) return 1;
        auto t = modpow(n>>1);
        t *= t;
        if(n & 1) t *= *this;
        return t;
    }
};
using mint = Fp<mod>;

int main(){
    ll n, m; cin >> n >> m;
    mint ans(1);
    rep(i, n) ans *= i+1;
    rep(i, m) ans *= i+1;
    if(n == m) ans *= 2;
    else if(abs(n - m) > 1) ans = 0;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef vector<vector<long long> > vvll;
typedef vector<pair<int, int> > vpii;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<ll, ll> pll;
#define INF 1000000000
#define MOD 1000000007
#define EPSILON 0.00001
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define p_q priority_queue

#define FOR(i, a, b) for (int i=(a); i<=(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define RFOR(i, a, b) for (int i=(a); i >= b; i--)

#define MN 200005
int n;
ll a[MN];
ll b[MN];
pair<ll, pair<int, bool> > nums[MN]; //false = a, true = b

pair<bool, bool> used[MN];

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

    cin >> n;
    F0R(i, n){
        cin >> a[i] >> b[i];
        nums[2*i] = mp(a[i], mp(i, false));
        nums[2*i+1] = mp(b[i], mp(i, true));
    }

    sort(nums, nums+2*n);
    ll sm1 = 0;
    F0R(i, n){
        sm1 += nums[i].f;
        if(nums[i].s.s){
            used[nums[i].s.f].s = true;
        } else{
            used[nums[i].s.f].f = true;
        }
    }
    //ll sm2 = sm1-nums[n].f+nums[n+1].f;

    ll fct = 0;

    F0R(i, n){
        if(used[i].f == used[i].s){
            cout << sm1 << "\n";
            return 0;
        }
        if(used[i].f) fct++;
    }
    /*if(fct == 1 || fct == n-1){
        cout << sm2 << "\n";
    } else{
        cout << sm1 << "\n";
    }*/
    //cout << fct << "\n";

    if(fct == 0 || fct == n){
        cout << sm1 << "\n";
    } else if((nums[n-1].s.f != nums[n].s.f) || (fct == 1 && !nums[n-1].s.f) || (fct==n-1&&nums[n-1].s.f)){
        cout << sm1-nums[n-1].f+nums[n].f << "\n";
    } else{
        ll o1 = nums[n].f-nums[n-2].f;
        ll o2 = nums[n+1].f-nums[n-1].f;
        cout << sm1+min(o1, o2) << "\n";
    }

    return 0;
}


Measured memory_bytes: 6272
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let k: i64 = buf.trim().parse().unwrap();
    let total = if k % 2 == 0 {
        (k / 2) * (k / 2)
    } else {
        (k / 2) * ((k + 1) / 2)
    };
    println!("{}", total);
}


Measured memory_bytes: 4352
def resolve():
    N = int(input())
    c = 0
    for i in range(1, 10):
        for j in range(1, 10):
            a = 0
            b = 0
            for n in range(1, N+1):
                s = str(n)
                if s[0] == str(i) and s[-1] == str(j):
                    a += 1
                if s[0] == str(j) and s[-1] == str(i):
                    b += 1
            c += a * b
    print(c)
resolve()

Measured memory_bytes: 43332
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
typedef  unsigned long long int ull;
typedef pair<ll,ll> P;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
//const ll mod=998244353;
const ll mod=1000000007;
//ios_base::sync_with_stdio(false);
//cin.tie(NULL);
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
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 (a>b) { a=b; return 1; } return 0; }
template<typename T>
map<T,ll> factorize(T x){
	map<T,ll> res;
	for(ll i=2;i*i<=x;i++){
		while(x%i==0){
			x/=i;
			res[i]++;
		}
	}
	if(x!=1) res[x]++;
	return res;
}
long long modpow(long long a, long long n) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a ;
        a = a * a;
        n >>= 1;
    }
    return res;
}
int main(){
ll n,p;
cin>>n>>p;
map<ll,ll> mp=factorize(p);
ll ans=1;
for(auto p:mp){
       if(p.se/n)ans*=modpow(p.fi,p.se/n);
}
cout<<ans<<endl;
}


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

using namespace std;

inline int gcd(int a, int b){
    int d_a = 0;
    while(!(a & 1)){ a >>= 1; ++d_a;}

    int d_b = 0;
    while(!(b & 1)){ b >>= 1; ++d_b;}

    while(a != b){
        if(a < b) swap(a, b);
        a -= b;
        do a >>= 1; while(!(a & 1));
    }

    return a << min(d_a, d_b);
}

int a, b;

int main(){
    while(cin >> a >> b){
        int c = gcd(a, b);
        cout << c << " " << (a / c) * b << endl;
    }
    return 0;
}

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

int main(){
  int n,m;
  cin >>n >>m;
  vector<int> a(m);
  int sum = 0;
  rep(i,m) {
    cin >>a[i];
    sum += a[i];
  }
  if(sum>n) cout << -1 << endl;
  else cout << n-sum << endl;
}


Measured memory_bytes: 3620
#include <stdio.h>

int main(){
	int N,a[200][3],ok,D[200],i,j,k;
	scanf("%d",&N);
	for(k=0;k<N;k++){
		for(i=0;i<3;i++){
			scanf("%d",&a[k][i]);
		}
	}
	for(i=0;i<N;i++){
		D[i]=0;
	}
	for(k=0;k<3;k++){
		for(i=0;i<N;i++){
			ok=0;
			for(j=0;j<N;j++){
				if(j==i){
					continue;
				}
				if(a[i][k]==a[j][k]){
					ok=1;
					break;
				}
			}
			if(ok==0){
				D[i]+=a[i][k];
			}
		}
	}
	for(i=0;i<N;i++){
		printf("%d\n",D[i]);
	}
	return 0;
}

Measured memory_bytes: 596
import sys
from scipy.sparse import csr_matrix
from scipy.sparse.csgraph import floyd_warshall
import numpy as np

N, M, L = map(int, sys.stdin.buffer.readline().split())
rest = np.array(sys.stdin.buffer.read().split(), np.int)
in_, out, weight = rest[0:3*M:3], rest[1:3*M:3], rest[2:3*M:3]

graph = csr_matrix((weight, (in_, out)), shape=(N+1, N+1))
graph = floyd_warshall(graph, directed=False)
graph = floyd_warshall(graph <= L, directed=False)
graph[np.isinf(graph)] = 0

S, T = rest[3*M+1::2], rest[3*M+2::2]
print('\n'.join(map(str, graph[S, T].astype(int) - 1)))


Measured memory_bytes: 32544
#include <bit>
#include <bitset>
#include <assert.h>
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <stdlib.h>
#include <queue>
#include <stack>


typedef long double ld;
typedef long long ll;

using namespace std;

int main() {
	int n, k;
	cin >> n >> k;
	vector<int> a;
	for (int i = 0; i < n; i++) {
		int t;
		cin >> t;
		a.push_back(t);
	}
	sort(a.begin(), a.end());
	int ret = 0;
	for (int i = 0; i < k; i++) {
		ret += a[i];
	}
	cout << ret << endl;
	return 0;
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
typedef long long ll;
#define fi first
#define se second
#define mem(a,b) memset(a,b,sizeof(a))
#define pb push_back
using namespace std;
const int maxn = 10005;
int x[4]={1,0,-1,0};
int y[4]={0,1,0,-1};
int h, w, n;
stack<int> s;
int a[maxn];
vector<int> v[maxn];
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> h >> w >> n;
    for(int i = 1; i <= n; i++){
        cin >> a[i];
    }
    for(int i = 1; i <= n; i++){
        while(a[i]--)s.push(i);
    }
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++)
        {
            v[i].pb(s.top());
            s.pop();
        }
    }
    for(int i = 0; i < h; i+=2){
        reverse(v[i].begin(), v[i].end());
    }
    for(int i = 0; i < h; i++){

        for(int j = 0; j < v[i].size() - 1; j++){
            cout << v[i][j] << " ";
        }
        cout << v[i][v[i].size()-1] << "\n";
    }
    return 0;
}



Measured memory_bytes: 640
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        a: u32,
        b: u32,
    }
    println!("{}",
        if a % 3 == 0 || b % 3 == 0
        || (a + b) % 3 == 0 {"Possible"}
        else {"Impossible"}
    );
}


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

#ifdef LOCAL
#include "/home/shahraaz/bin/debug.h"
#else
#define db(...)
#endif

using ll = long long;
#define f first
#define s second
#define pb push_back
#define all(v) v.begin(), v.end()

const int NAX = 2e5 + 5, MOD = 1000000007;

class Solution
{
private:
public:
    Solution() {}
    ~Solution() {}
    void solveCase()
    {
        int n, m, k;
        cin >> n >> m >> k;
        vector<ll> a(n), b(m);
        for (size_t i = 0; i < n; i++)
        {
            int x;
            cin >> x;
            if (i > 0)
                a[i] = a[i - 1];
            a[i] += x;
        }
        for (size_t i = 0; i < m; i++)
        {
            int x;
            cin >> x;
            if (i > 0)
                b[i] = b[i - 1];
            b[i] += x;
        }
        ll ret = 0;
        for (ll i = 0; i < n; ++i)
        {
            if (k < a[i])
                break;
            ll extra = k - a[i];
            ll it = upper_bound(all(b), extra) - b.begin();
            ret = max(ret, it + i + 1);
        }
        a.swap(b);
        swap(n, m);
        for (ll i = 0; i < n; ++i)
        {
            if (k < a[i])
                break;
            ll extra = k - a[i];
            ll it = upper_bound(all(b), extra) - b.begin();
            ret = max(ret, it + i + 1);
        }
        cout << ret << '\n';
    }
};

int32_t main()
{
#ifndef LOCAL
    ios_base::sync_with_stdio(0);
    cin.tie(0);
#endif
    int t = 1;
    // cin >> t;
    Solution mySolver;
    for (int i = 1; i <= t; ++i)
    {
        mySolver.solveCase();
#ifdef LOCAL
        cerr << "Case #" << i << ": Time " << chrono::duration<double>(chrono::steady_clock::now() - TimeStart).count() << " s.\n";
        TimeStart = chrono::steady_clock::now();
#endif
    }
    return 0;
}


Measured memory_bytes: 6356
#include <iostream>
#include <set>
#include <queue>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstring>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
#include <numeric>

using namespace std;
#define ALL(x)			(x).begin(),(x).end()
#define REP(i, n)		for (int (i) = 0 ; (i) < (ll)(n) ; ++(i))
#define REPN(i, m, n)	for (int (i) = m ; (i) < (ll)(n) ; ++(i))
#define INF				(int)2e9
#define MOD				(1000 * 1000 * 1000 + 7)
#define Ceil(x, n)		(((((x))+((n)-1))/n))		/* Nの倍数に切り上げ割り算 */
#define CeilN(x, n)		(((((x))+((n)-1))/n)*n)		/* Nの倍数に切り上げ */
#define FloorN(x, n)	((x)-(x)%(n))				/* Nの倍数に切り下げ */
#define IsOdd(x)		(((x)&0x01UL) == 0x01UL)			
#define IsEven(x)		(!IsOdd((x)))						
#define M_PI			3.14159265358979323846
typedef long long		ll;
typedef pair<ll, ll>	P;
typedef vector<ll>		VLL;
typedef vector<VLL>		VVLL;
typedef vector<VVLL>	VVVLL;

/*-----------------------------------------------------------------------------
　処理
 -----------------------------------------------------------------------------*/
/* 最大公約数 */
ll gcd(ll a, ll b) 
{
	if (b == 0) return a;
	return gcd(b, a % b);
}

/* 最小公倍数 */
ll lcm(ll a, ll b) 
{
	ll gcdRes = gcd(a, b);
	return (a * (b / gcdRes));
}

int main()
{
	int N, M;
	cin >> N >> M;
	VLL a(N);
	REP(i, N) cin >> a[i];
	
	ll yakusu = 1;
	REP(i, N) {
		yakusu = lcm(yakusu, a[i] / 2);
	}

	ll isEvenCnt = 0;
	REP(i, N) {
		if (IsEven(yakusu / (a[i] / 2))) {
			isEvenCnt++;
		}
	}

	ll ans = 0;
	if (isEvenCnt == 0 || isEvenCnt == N) {
		if (yakusu <= M) {
			ans = (M / yakusu - 1) / 2 + 1;
		}
	}

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


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#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 ll long long
using namespace std;
int main(){
  ll n;
  ll m = 1000000001, mc = 0, s = 0;
  bool zero = false;
  cin >> n;
  REP(i, n){
    ll a;
    cin >> a;
    ll absa = abs(a);
    if (m > absa) m = absa;
    s += absa;
    if (a < 0) mc++;
    if (a == 0) zero = true;
  }
  if (!zero && mc % 2 == 1) {
    cout << s - m * 2 << endl;
  } else {
    cout << s << endl;
  }
  return 0;
}


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

int main(){
	
	char a[105];
	cin>>a;
	
	int i=0;
	while(a[i]!=0){
		if((i+1)%2==1){
			if(a[i]=='R' || a[i]=='U' || a[i]=='D'){
				
			}else{
				//printf("%d",i);
				i=-1;
				break;
			}
		}else if((i+1)%2==0){
			if(a[i]=='L' || a[i]=='U' || a[i]=='D'){
				
			}else{
				//printf("%d",i);
				i=-1;
				break;
			}
		}
		//printf("%c\t",a[i]);
		i++;
	}
	if(i!=-1){
		printf("Yes");
	}else{
		printf("No");
	}
	
	
	return 0;
}









Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
#define pb push_back
#define all(x) x.begin(), x.begin()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define reps(i, m, n) for (int i = m; i <= n; ++i)
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;

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

  int n; cin >> n;
  string cardT, cardH;
  int pntT = 0, pntH = 0;

  rep(i, n) {

    cin >> cardT >> cardH;

    if( cardT > cardH ) pntT += 3;
    else if( cardT < cardH ) pntH += 3;
    else {
      pntT++;
      pntH++;
    }
  }

  cout << pntT << ' ' << pntH << endl;

  return 0;
}




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

object Main {
  def weightClass(weight: Double): String =
    if (weight > 91) "heavy"
    else if (weight > 81) "light heavy"
    else if (weight > 75) "middle"
    else if (weight > 69) "light middle"
    else if (weight > 64) "welter"
    else if (weight > 60) "light welter"
    else if (weight > 57) "light"
    else if (weight > 54) "feather"
    else if (weight > 51) "bantam"
    else if (weight > 48) "fly"
    else "light fly"

  def results(i: Iterator[String], result: Vector[String] = Vector()): Vector[String] =
    if (i.hasNext) results(i, result :+ weightClass(i.next.toDouble))
    else result

  def main(args: Array[String]): Unit = {
    results(stdin.getLines).foreach(println)
  }
}

Measured memory_bytes: 43484
n = int(input())
p = list(map(int,(input().split(' ')) ))
c = 0
for i in range(n-2):
    if (p[i] <= p[i+1] and p[i+1] < p[i+2]) or (p[i] > p[i+1] >= p[i+2]):
        c += 1
print(c)

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

int main() {
	int sx,sy,tx,ty; 
	cin >> sx >> sy >> tx >> ty;
	const int dx=tx-sx,dy=ty-sy;
	cout << string(dy,'U') << string(dx,'R');
	cout << string(dy,'D') << string(dx,'L');
	cout << 'L' << string(dy+1,'U') << string(dx+1,'R') << 'D';
	cout << 'R' << string(dy+1,'D') << string(dx+1,'L') << 'U';
	cout << endl; 
	return 0;
}


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

#define endl '\n'

void io(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout.precision(15);
}

int cnt[55][27] ;
int fcnt[27] ;
int main(int argc,char* argv[]) { 
    io() ;
    #ifndef ONLINE_JUDGE
     //   freopen("inp.txt", "r", stdin) ;
        // freopen("out.txt", "w", stdout);
    #endif
    int n ;
    cin >> n ;
    string str ;
    for(int i = 1 ; i <= n ; i++){
        cin >> str ;
        for(auto c:str){
            cnt[i][c - 'a']++ ;
        }
    }
    for(int i = 0 ; i < 26 ; i++){
        fcnt[i] = 100 ;
        for(int j = 1 ; j <= n ; j++){
            fcnt[i] = min(fcnt[i] , cnt[j][i]) ;
        }
    }
    for(int i = 0 ; i < 26 ; i++){
        while(fcnt[i]--){
            cout << (char)(i + 'a') ;
        }
    }
    cout << endl ;
    return 0 ; 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define mp make_pair
#define si(x) int(x.size())
const int mod=1000000007,MAX=505,INF=1<<30;

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    double a,b;cin>>a>>b;
    cout<<setprecision(25)<<(a*b)/(a+b)<<endl;
}



Measured memory_bytes: 3812
#include <bits/stdc++.h>
 
using namespace std;
 
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl;
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}
typedef long long ll;
#define int ll
 
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#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 rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(int)(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
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 (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const long double pi = 3.1415926535897932384626433832795028841971L;
#define Sp(p) cout<<setprecision(25)<< fixed<<p<<endl;
// int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
// int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
vi dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};
// vi dx2 = { 1,1,0,-1,-1,-1,0,1 }, dy2 = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
const ll MOD = 1000000007;
// const ll MOD = 998244353;
// #define mp make_pair
//#define endl '\n'



signed main() {
    fio();
    
    int h, w, m;
    cin >> h >> w >> m;

    vector<set<int>> y2x(h), x2y(w);
    rep (i, m) {
        int r, c;
        cin >> r >> c;
        r--; c--;
        y2x[r].insert(c);
        x2y[c].insert(r);
    }

    int max_y = 0, max_x = 0;
    rep (i, h) chmax(max_y, (int)y2x[i].size());
    rep (i, w) chmax(max_x, (int)x2y[i].size());

    vi ys, xs;
    rep (i, h) {
        if (y2x[i].size() == max_y) ys.push_back(i);
    }
    rep (i, w) {
        if (x2y[i].size() == max_x) xs.push_back(i);
    }

    for (int y: ys) {
        for (int x: xs) {
            if (y2x[y].count(x) == 0) {
                cout << max_y + max_x << endl;
                return 0;
            }
        }
    }
    cout << max_y + max_x - 1 << endl;
}

Measured memory_bytes: 67864
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <cassert>
#include <memory>
#include <stack>
#include <set>

#define MAX_SIZE 100000000
typedef unsigned long long ull;
using namespace std;

int main() {
  int n; cin >> n;
  int max_p = 0, sum = 0;
  vector<int> prices(n);
  for(auto&v : prices) {
    cin >> v;
    max_p = max(max_p, v);
  }

  bool already = false;
  for(auto v : prices) {
    if(v == max_p && !already) {
      sum += v / 2;
      already = true;
    } else {
      sum += v;
    }
  }
  cout << sum << endl;
}


Measured memory_bytes: 768
#include <iostream>
#include <iomanip>
#include <algorithm>
using namespace std;
#include <cstdio>
#include <tuple>
#include <string>
#include <vector> 
#include <set>
#include <string.h>
#include <map>
#include <cmath>
#include <deque>
using ll = long long;
using Graph = vector<vector<int>>;
#include <queue>
#include <stack>

//最大公約数
ll gcd(ll a,ll b){
    if(b == 0LL) return a;
    return gcd(b , a % b);
}

//最小公倍数
ll lcm(ll a,ll b){
    return a / gcd(a,b) * b;

}

int main(){
    
    ll q,h,s,d;
    cin >> q >> h >> s >> d;
    ll n;
    cin >> n;

    ll p = min(min(4 * q,2 * h),s);

    ll ans = min(d * (n/2) + (n % 2) * p,p * n);
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256