akhauriyash/Code-Regression huggingface dataset:
// template version 1.12
using namespace std;
#include <iostream>
#include <bits/stdc++.h>

// varibable settings
#define infile "../test/sample-1.in"
#define int long long //{{{
const int INF=1e18;
const int MOD=1e9+7; //}}}

// define basic macro {{{
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) rrepi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)((b)-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define each(i,a) for (auto&& i : a)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
#define ub upper_bound
#define lb lower_bound
#define posl(A, x) (lower_bound(all(A), x)-A.begin())
#define posu(A, x) (upper_bound(all(A),x)-A.begin())
template<class T> inline void chmax(T &a, const T &b) { if((a) < (b)) (a) = (b); }
template<class T> inline void chmin(T &a, const T &b) { if((a) > (b)) (a) = (b); }

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> iii;

template<typename T> using PQ = priority_queue<T, vector<T>, greater<T>>;
struct Fast { Fast(){ std::cin.tie(0); ios::sync_with_stdio(false); } } fast;

#if defined(PCM) || defined(LOCAL)
  #include "lib/dump.hpp"
#else
  #define dump(...) 42
  #define dump_1d(...) 42
  #define dump_2d(...) 42
#endif
//}}}

// 隣接リストで使う辺を表す型
struct Edge {
  int to, cost;  // 辺の接続先頂点, 辺の重み
  Edge(int to, int cost) : to(to), cost(cost) {}  // コンストラクタ
};

typedef vector<vector<Edge> > AdjList;  // 隣接リストの型
AdjList graph;  // グラフの辺を格納した構造体
                // graph[v][i]は頂点vから出るi番目の辺Edge

vector<int> dist; // 最短距離

int solve(){
  int a,b,c,k,ans;cin>>a>>b>>c>>k;
  //string s,ans;
  ans=a-b;
  if(k%2==1)ans*=-1;
  
  cout << ans << endl;
  
  return 0;
}

signed main() { //{{{
#ifdef INPUT_FROM_FILE
  std::ifstream in(infile);
  std::cin.rdbuf(in.rdbuf());
#endif
  solve();
  return 0;
} //}}}


Measured memory_bytes: 3636
import math
n = int(raw_input())
count = 0
for i in range(101,n+1,2):
	cuenta = 0
	for j in range(1,int(math.floor(i**0.5)+1),2):
		if i == j ** 2:
			cuenta += 1
		elif i % j == 0:
			cuenta += 2

	if cuenta == 8:
		count += 1

print count

Measured memory_bytes: 2568
#include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;
int N, Z, W, Card[2005], result;

int abs(int num)
{
    return num > 0 ? num : -num;
}

int main()
{
    scanf("%d %d %d", &N, &Z, &W);
    for(int i = 0; i < N; i++)
    {
        scanf("%d", &Card[i]);
    }
    result = abs(Card[N - 1] - W);
    if(N > 1)
    {
        result = max(result, abs(Card[N - 1] - Card[N - 2]));
    }
    printf("%d", result);
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long lli;
lli n,m;
vector<pair<lli,lli> > lr;
template<class T>
class sg_tree : public vector<T>{
private:
    lli n;
    T default_value;
    T _query(lli a,lli b,lli k,lli l,lli r){
        if(r <= a || b <= l) return default_value;
        if(a <= l && r <= b) return (*this)[k];
        else {
            T vl = _query(a,b,k*2+1,l,(l+r)/2);
            T vr = _query(a,b,k*2+2,(l+r)/2,r);
            return func(vl,vr);
        }
    }
public:
    sg_tree():vector<T>(){

    }
    sg_tree(lli n,T d = 0):vector<T>(n*4,d){
		this->n = 1;
        while(n > this->n) this->n <<= 1;
        this->default_value = d;
    }
    void update(lli i,lli x){
        i += n - 1;
        (*this)[i] = x;
        while(i > 0){
            i = (i - 1) / 2;
            (*this)[i] = func((*this)[i * 2 + 1],(*this)[i * 2 + 2]);
        }

    }
    T query(lli a,lli b){
        b++;
        return _query(a,b,0,0,n);
    }
    T func(T a,T b){
        return a + b;
    }
};
sg_tree<lli> sgp;
sg_tree<lli> sgm;
int main(int argc, char const *argv[]) {
    cin >> n >> m;
    lr = vector<pair<lli,lli> > (n);
    sgp = sg_tree<lli>(m+1);
    sgm = sg_tree<lli>(m+1);
    for(lli i = 0;i < n;i++){
        cin >> lr[i].first >> lr[i].second;
    }
    sort(lr.begin(),lr.end(),
    [](const pair<lli,lli>& a,const pair<lli,lli>& b)
    {return (a.second-a.first) < (b.second-b.first);});
    auto itr = lr.begin();
    for(lli i = 1;i <= m;i++){
        lli ans = 0;
        while(itr->second - itr->first + 1 < i && itr != lr.end()){
            sgp.update(itr->first,sgp.query(itr->first,itr->first)+1);
            sgm.update(itr->second,sgm.query(itr->second,itr->second)+1);
            itr++;
        }
        ans = lr.end() - itr;
        for(lli j = i;j <= m;j+=i){
            ans += sgp.query(0,j) - sgm.query(0,j-1);
        }
        cout << ans << endl;

    }
    return 0;
}


Measured memory_bytes: 11904
#include<bits/stdc++.h>
#include<string>
#define ll long long
#define lld long double
#define llu unsigned long long int
#define pb push_back
#define mp make_pair
#define fir first
#define sec second
#define gll(a,n) for(ll i=0;i<n;i++) cin>>a[i];
#define mod 1000000007
#define mod1 998244353
#define pi 3.1415926535897
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen("B-small-attempt0.in", "r", stdin);freopen("output.txt", "w", stdout);
    //std::cout << std::setprecision(9);
    //std::cout << std::fixed;
    ll n,i;
    cin>>n;
    ll a[n],b[n];
    gll(a,n);
    b[0]=0;
    ll sum=0,val=a[0];
    for(i=1;i<n;i++)
    {
        b[i]=a[i-1]-b[i-1];
        //cout<<b[i]<<" ";
        sum+=b[i];
        val+=a[i];
    }
    val/=2;
    val-=sum;
    for(i=0;i<n;i++)
    {
        ll x=val;
        if(i%2==1)
            x*=-1;
        cout<<2*(b[i]+x)<<" ";
    }
}


Measured memory_bytes: 2944
#include <iostream>
//#include <iomanip>
//#include <string>
//#include <vector>
//#include <algorithm>
//#include <utility>
//#include <set>
//#include <map>
//#include <queue>
//#include <deque>
//#include <bitset>
//#include <math.h>
using namespace std ;
using ll = long long ;
//using ld = long double ;
//using vll = vector<ll> ;
//using vvll = vector<vll> ;
//using vc = vector<char> ;
//using vvc = vector<vc> ;
//using vb = vector<bool> ;
//using vvb = vector<vb> ;
//using pll = pair<ll,ll> ;
//#define all(v) v.begin(),v.end()
//ll mod = 1000000007 ;
//long double pie = acos(-1) ;
//ll INF = 1000000000000 ;

//void yorn(bool a){if(a) cout << "Yes" << endl ; else cout << "No" << endl ;}
//void YorN(bool a){if(a) cout << "YES" << endl ; else cout << "NO" << endl ;}
ll mygcd(long long a,long long b){if(b==0) return a ; return mygcd(b,a%b) ;}
//ll mylcm(long long a,long long b){return a/gcd(a,b)*b ;}
//ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;}
//void mysort(vector<long long> &a){sort(a.begin(),a.end()) ;}
//void myrev(vector<long long> &a){reverse(a.begin(),a.end()) ;}
//void fix_cout(){cout << fixed << setprecision(20) ;}

int main(){
	ll k ; cin >> k ;
	ll ans = 0 ;
	for(int a=1;a<=k;a++){
		for(int b=1;b<=k;b++){
			for(int c=1;c<=k;c++){
				ans += mygcd(mygcd(a,b),c) ;
			}
		}
	}
	cout << ans << endl ;
}


Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
#include <set>
#include <iomanip>
#include <stdio.h>
#include <sstream>
#include <string>
#include <bits/stdc++.h>
using namespace std;
int main(void){
  int n;
  cin>>n;
  vector<int> x(n);
  int low=100;
  int high=0;
  for (int i = 0; i < n; i++)
  {
    cin>>x.at(i);
    low=min(low,x.at(i));
    high=max(high,x.at(i));
  }
  
  long long int ans=99999999999999999;
  for(int i=low; i<=high; i++){
    long long int pre=0;
    for(int j=0; j<n; j++){
      pre+=pow(i-x.at(j),2);
    }
    ans=min(ans,pre);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <queue>
#include <algorithm>
using namespace std;
#define INF (int)(1e9)

int N;
const int MAX_N = 100010;

int dist[MAX_N];
bool chk[MAX_N];

struct state{
    int d,v;
    bool operator<(const state& r)const{
        return d > r.d;
    }
};
priority_queue<state> Q;

void go(int u,int c){
    if(dist[u] > c){
        dist[u] = c;
        Q.push(state{dist[u], u});
    }
}

int main(){
    scanf("%d",&N);
    for(int i=0;i<N;i++){
        dist[i] = INF;
    }
    dist[1] = 1;

    Q.push(state{dist[1], 1});
    int v,d;
    while(!Q.empty()){
        state here = Q.top();
        Q.pop();
        v = here.v;
        d = here.d;
        if(chk[v])continue;
        chk[v] = 1;
        
        go((v+1)%N, d+1);
        go((v*10)%N, d);
    }
    printf("%d\n",dist[0]);
    return 0;
}
    


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

typedef long long ll;
typedef long double ld;

const int MOD = 1000000007;

int add(int a, int b){
    return (a+b)%MOD;
}

int dp[100005];
int dpp[100005];

int main(){
    ios_base::sync_with_stdio(false);
    cout.precision(10);
    cout<<fixed;

    int n, k;
    cin >> n >> k;
    dpp[0] = dp[0] = 1;
    for(int i=1; i<=n; i++){
        int x;
        cin >> x;
        int tren = 0;
        for(int j=0; j<=k; j++){
            tren = add(tren, dpp[j]);
            if(j-x > 0){
                tren = add(tren, MOD - dpp[j-x-1]);
            }
            dp[j] = tren;
        }
        for(int j=0; j<=k; j++){
            dpp[j] = dp[j];
        }
    }
    cout << dp[k];
    return 0;
}


Measured memory_bytes: 1024
n = int(input())
A = []
xy = []
max = 0
for i in range(n):
  a = int(input())
  A.append(a)
  xy.append([list(map(int,input().split())) for i in range(a)])
for i in range(2**n):
    ls = [0]*n
    check = 0
    for j in range(len(ls)):
        if (i >> j) & 1:
            ls[j] = 1
    for p in range(len(xy)):
      for t in xy[p]:
        if t[1] == 1 and ls[p] == 1:
          if ls[t[0]-1] != 1:
            check = 1
            break
        elif t[1] == 0 and ls[p] == 1:
          if ls[t[0]-1] != 0:
            check = 1
            break
    if check == 0:
      if ls.count(1) > max:
        max = ls.count(1)
print(max)


Measured memory_bytes: 3064
#include<stdio.h>
int main(void)
{
	int i,j;
	int n;
	int maxv=-1000000001,minv;
	
	scanf("%d",&n);
	int A[n];
	for (i=0;i<n;i++){
		scanf("%d",&A[i]);
	}
	minv=A[0];
	
	for (i=1;i<n;i++){
		if (maxv<A[i]-minv){
			maxv=A[i]-minv;
		}
		if (minv>A[i]){
			minv=A[i];
		}
	}
	
	printf("%d\n",maxv);
	
	return 0;
}

Measured memory_bytes: 1376
my $l;
$l->{'a'} = 'b';
$l->{'b'} = 'c';
$l->{'c'} = 'd';
$l->{'d'} = 'e';
$l->{'e'} = 'f';
$l->{'f'} = 'g';
$l->{'g'} = 'h';
$l->{'h'} = 'i';
$l->{'i'} = 'j';
$l->{'j'} = 'k';
$l->{'k'} = 'l';
$l->{'l'} = 'm';
$l->{'m'} = 'n';
$l->{'n'} = 'o';
$l->{'o'} = 'p';
$l->{'p'} = 'q';
$l->{'q'} = 'r';
$l->{'r'} = 's';
$l->{'s'} = 't';
$l->{'t'} = 'u';
$l->{'u'} = 'v';
$l->{'v'} = 'w';
$l->{'w'} = 'x';
$l->{'x'} = 'y';
$l->{'y'} = 'z';
$l->{'z'} = '';

my $w = glob <>;
print $l->{$w};

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

int main()
{
	int N, S;
	cin >> N >> S;
	vector<int> a(N);
	for (int i = 0; i < N; i++) {
		cin >> a[i];
	}
	int l = 0, r = 0, sum = 0, res = N + 1;
	while (r <= N) {
		if (sum >= S) {
			res = min(res, r - l);
			sum -= a[l++];
		}
		else {
			sum += a[r++];
		}
	}
	cout << (res == N + 1 ? 0 : res) << endl;
	return 0;
}

Measured memory_bytes: 3140
from collections import deque

N,M=map(int,input().split())

graph=[[False]*N for i in range(N)]
visited=[False]*N
a=[0]*M
b=[0]*M

for i in range(M):
    a[i],b[i]=map(int,input().split())
    a[i]-=1
    b[i]-=1
    graph[a[i]][b[i]]=True
    graph[b[i]][a[i]]=True

ans=0
for i in range(M):
    graph[a[i]][b[i]]=False
    graph[b[i]][a[i]]=False
    for j in range(N):
        visited[j]=False
    d=deque([0])
    while d:
        temp=d.popleft()
        visited[temp]=True
        for j in range(N):
            if graph[temp][j]==True and visited[j]==False:
                d.append(j)

    bridge = False
    for j in range(N):
        if visited[j] == False:
            bridge = True
            break
    if bridge == True:
        ans += 1
    graph[a[i]][b[i]] = True
    graph[b[i]][a[i]] = True

print(ans)

Measured memory_bytes: 3316
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <functional>
#include <ctime>
#include <cmath>
#include <limits>
#include <numeric>
#include <type_traits>
#include <iomanip>
#include <float.h>
#include <math.h>
using namespace std;
using ll = long long;
unsigned euclidean_gcd(unsigned a, unsigned b) {
    if (a < b) return euclidean_gcd(b, a);
    unsigned r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

ll ll_gcd(ll a, ll b) {
    if (a < b) return ll_gcd(b, a);
    ll r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

class UnionFind {
public:
    vector <ll> par;
    vector <ll> siz;
    UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    ll root(ll x) {
        while (par[x] != x) {
            x = par[x] = par[par[x]];
        }
        return x;
    }
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) {
        return root(x) == root(y);
    }

    ll size(ll x) {
        return siz[root(x)];
    }
};

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}

int main() {
    ll d;
    cin >> d;
    vector<ll> z(26);
    for (int i = 0; i < 26; i++) {
        cin >> z[i];
    }
    vector<vector<ll>> x(d, vector<ll>(26));
    for (int i = 0; i < d; i++) {
        for (int j = 0; j < 26; j++) {
            cin >> x[i][j];
        }
    }
    vector<ll> ans(d,1);
    for (int i = 0; i < 14; i++) {
        vector<bool> flag(26, false);
        for (int j = 0; j < 26; j++) {
            ll mx = 0;
            ll atai = 0;
            for (int k = 0; k < 26; k++) {
                if (flag[k] == false) {
                    mx = max(x[i * 26 + j][k], mx);
                    if (mx == x[i * 26 + j][k])atai = k;
                }
            }
            flag[atai] = true;
            ans[i * 26 + j] = atai + 1;
        }
    }
    ll mix = 0;
    ll ataii = 0;
    for (int k = 0; k < 26; k++) {
        mix = max(x[364][k], mix);
        if (mix == x[364][k])ataii = k;
    }
    ans[364] = ataii+1;
    for (int i = 0; i < d; i++) {
        cout << ans[i] << endl;
    }
}

Measured memory_bytes: 3720
package main

import "fmt"

func main() {
	var (
		a int
		b int
		c int
		d int
	)
	fmt.Scan(&a)
	fmt.Scan(&b)
	fmt.Scan(&c)
	fmt.Scan(&d)
	if a*b > c*d {
		fmt.Println(a * b)
	} else {
		fmt.Println(c * d)
	}
}

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

using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef pair<ll, ll> pair_t;
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define REP(i,n)  FOR(i,0,n)
/***** define constant start *******/
const ll MOD = 1000000007;
const double PI = 3.1415926535897932;
const ll INF = 1<<29;
/****** define constant end ********/

/****** define variable start ******/
double n;
/******* define variable end *******/
ll solve(){
	cin >> n;
	cout << (ll)ceil(n / 2.0) << endl;
    return 0;
}
int main(){
    //clock_t start = clock();
    cout << std::fixed << std::setprecision(10);
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll end_solve = solve();
    /*
    clock_t end = clock();
    const double time = static_cast<double>(end - start) / CLOCKS_PER_SEC * 1000.0;
    printf("time %lf[ms]\n", time);
    */
    
    return (int)end_solve;
}


Measured memory_bytes: 256
#include <cstdio>
#include <unordered_map>
#include <algorithm>
#include <map>
#include <vector>
using namespace std;
const int N = 1e2 + 1;
const int M  = 1e5 + 1;
long long f[N][M];
int n, m;
struct node{
    int w, v;
}a[N];
int main()
{
    scanf("%d %d", &n, &m);
    for (int i = 1; i <= n ;  i ++)
        scanf("%d %d", &a[i].w, &a[i].v);
    for (int i = 0; i < n; i ++) {
        for (int j = 0; j <= m ; j ++)
            f[i + 1][j] = f[i][j];
        for (int j = m - a[i + 1].w; j >= 0; j--)
            f[i + 1][j + a[i + 1].w] = max(f[i + 1][j + a[i + 1].w], f[i][j] + a[i + 1].v);
    }
    long long ans = 0;
    for (int i = 0; i <= m ;  i ++)
        ans = max(ans, f[n][i]);
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 78336
#include<bits/stdc++.h>
using namespace std;
int f[1000];
main(){
    string s;
    cin >> s;
    if(s.size() < 26){
        for (int i = 0;  i < s.size(); i++){
            f[s[i]] = 1;
        }
        cout <<s;
        for (char i = 'a'; i <= 'z'; i++)
        if(f[i] == 0) {cout <<  i << endl; return 0;}
    }
    vector<string > ans;
    string t =  "";
    for (int i = 0; i < s.size() ; i++){
        for (char j = s[i] + 1; j <= 'z'; j++)
        if(f[j] == 0) {ans.push_back(t+j); break;}
        f[s[i]] = 1;
        t+=s[i];
    }
    if(ans.size() == 0) cout << -1 << endl;
    else cout << ans.back() << endl;
}

//


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

public class Main{
  public static void main(String[] args){
    try {
      Scanner sc = new Scanner(System.in);
      int c, a, b;

      c=Integer.parseInt(sc.next());
      a=Integer.parseInt(sc.next());
      b=Integer.parseInt(sc.next());
      System.out.println(c*a/2);
                
      }catch (Exception e) {
      System.out.println("out");
    }
  }
}


Measured memory_bytes: 23124
#include<unordered_set>
#include<set>
#include<deque>
#include<queue>
#include<map>

#include<string>
#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
#include<functional>
using namespace std;
typedef long long int llint;
#define pub push_back
#define mp make_pair
#define fir first
#define sec second
#define res resize
#define mt make_tuple
const int big=((int)1<<30);
int n,i,j,q,w,gen;
string ans="Second";
vector<int> siz;
vector<vector<int>> nod;
int make_tree(int per,int ter){
	//oya[ter]=per;
	siz[ter]=1;
	auto itr=find(nod[ter].begin(),nod[ter].end(),per);
	if(itr!=nod[ter].end()){ nod[ter].erase(itr); }
	for(auto it=nod[ter].begin();it!=nod[ter].end();it++){siz[ter]+=make_tree(ter,*it); }
	return siz[ter];
}
int main(void){
	
	cin>>n;
	if(n%2==1){ cout<<"First"<<endl;return 0; }
	siz.resize(n);
	nod.resize(n);
	for(i=1;i<n;i++){
		cin>>q>>w;q--;w--;
		nod[q].pub(w);
		nod[w].pub(q);
	}
	make_tree(-1,0);
	if(nod[0].size()==1){ nod[nod[0][0]].pub(0);siz[nod[0][0]]++;nod[0].clear();siz[0]=1; }
	for(i=0;i<n;i++){
		gen=0;
		for(j=0;j<nod[i].size();j++){
			if(siz[nod[i][j]]%2==1){gen++;}
			if(gen>=2){ 
				cout<<"First"<<endl;return 0; 
			}
		}
	}
	cout<<"Second"<<endl;
	return 0;
}


Measured memory_bytes: 6272
/**
 *    Coded by : lucky_21
 *               --------Lokesh Singh
**/

#include<bits/stdc++.h>
using namespace std;

#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template<class T> using oset=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

#define     F           first
#define     S           second
#define     pb          push_back
#define     lb          lower_bound
#define     ub          upper_bound
#define     pii         pair<int,int>
#define     all(x)      x.begin(),x.end()
#define     fix         fixed<<setprecision(10)
#define     rep(i,a,b)  for(int i=int(a);i<=int(b);i++)
#define     repb(i,b,a) for(int i=int(b);i>=int(a);i--)
#define     FastIO      ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)

typedef double db;
typedef long long ll;

const int N=2e5+5;
const int mod=1e9+7;

signed main(){
    FastIO;
    int a,b,c;
    cin>>a>>b>>c;
    cout<<(a+b-1)/b*c;
    return 0;
}


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

int main(){
  int N,M;
  cin >> N >> M;
  vector<int> D(N,1);
  vector<bool> R(N);
  R.at(0)=true;
  int x,y;
  while(cin >> x >> y){
    D.at(x-1)--;
    D.at(y-1)++;
    if(R.at(x-1)) R.at(y-1)=true;
    if(D.at(x-1)==0) R.at(x-1)=false;
  }
  int ans=0;
  for(int i=0;i<N;++i){
    if(R.at(i)) ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <climits> 
int main(){
    long N;
    std::cin >> N;
    std::vector<long> A;
    std::vector<long> B;
    for(long i=0; i<N; i++){
        long temp1,temp2;
        std::cin >> temp1 >> temp2;
        A.push_back(temp1);
        B.push_back(temp2);
    }

    std::sort(A.begin(),A.end());
    std::sort(B.begin(),B.end());
    if(N%2==1){
        std::cout << B[N/2]-A[N/2]+1 << std::endl;
    }else{
        std::cout << (B[N/2]+B[N/2-1])-(A[N/2]+A[N/2-1]) +1 << std::endl;
    }
    return 0;
}

Measured memory_bytes: 6648
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REV(c) reverse(ALL(c))
#define sz(v) (int)v.size()
#define endl '\n'
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
template<class T> inline void printv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << (i == n - 1 ? endl : ' ');}
template<class T> inline void printvv(vector<vector<T>>& v) {for (auto u : v) printv(u);}
template<class T> inline void printlnv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << endl;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
 
void solve();
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

ll pow_mod(ll n, ll p, ll mod) {
    if (p == 0) {
        return 1;
    } else if (p % 2 == 1) {
        return pow_mod(n, p - 1, mod) * n % mod;
    } else {
        ll s = pow_mod(n, p / 2, mod);
        return s * s % mod;
    }
}

void solve() {
    ll n, k;
    cin >> n >> k;
    ll ans = 0;
    map<ll, ll> memo;
    for (ll i = k; i >= 1; i--) {
        ll c = pow_mod(k / i, n, MOD);
        ll x = 2;
        while (i * x <= k) {
            c -= memo[i * x];
            if (c < 0) c += MOD;
            x++;
        }
        memo[i] = c;
        ans += i * c % MOD;
        ans %= MOD;
    }
    cout << ans << endl;
}



Measured memory_bytes: 9916
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N=55;
int n,v,d,m[N],num[N],a[N],x,fa[N],f[N*N*N],Max,cnt[N],size[N],rk[N],ne[N],fi[N],tot,zz[N];
void jb(int x,int y){
	ne[++tot]=fi[x];
	fi[x]=tot;
	zz[tot]=y;
}
void dfs(int x){
	size[x]=1;
	num[x]=m[x];
	for (int i=fi[x];i;i=ne[i])dfs(zz[i]),size[x]+=size[zz[i]],num[x]+=num[zz[i]];
}
int cmp(int x,int y){
	return num[x]*size[y]<num[y]*size[x];
}
signed main(){
	scanf("%lld%lld%lld",&n,&v,&d);
	scanf("%lld",&m[1]);
	for (int i=2;i<=n;i++)scanf("%lld%lld",&m[i],&x),a[i]=min(n,d),jb(x,i);
	dfs(1);
	a[1]=n;
	for (int i=1;i<=n;i++)Max+=size[i]*a[i];
	for (int i=1;i<=Max+1;i++)f[i]=1e18;
	for (int i=1;i<=n;i++)
		for (int j=Max;j;j--){
			for (int k=1;k<=a[i]&&size[i]*k<=j;k++)f[j]=min(f[j],num[i]*k+f[j-k*size[i]]);
			f[j]=min(f[j],f[j+1]);
		}
	for (int i=1;i<=n;i++)rk[i]=i;
	sort(rk+1,rk+n+1,cmp);
	for (int i=2;i<=n;i++)cnt[i]=d-a[i];
	cnt[1]=1e18;
	int now=1,val=-1,ans=0,Ans=0;
	for (int i=Max;i>=0;i--){
		if (f[i]>v)continue;
		if (val==-1)val=v-f[i];
		else val+=f[i+1]-f[i];
		while (1){
			while (!cnt[rk[now]])now++;
			int c=min(cnt[rk[now]],val/num[rk[now]]);
			if (!c)break;
			cnt[rk[now]]-=c;ans+=c*size[rk[now]];
			val-=num[rk[now]]*c;
			if (!cnt[rk[now]])now++;
		}
		Ans=max(Ans,i+ans);
	}
	printf("%lld\n",Ans);
}


Measured memory_bytes: 768
S = raw_input()
S = int(S)
if S/3600 > 0:
    h = S/3600
else: h = 0
if (S % 3600) / 60 > 0:
    m = (S % 3600) / 60
else: m = 0
if (S % 3600) % 60 > 0:
    s = (S % 3600) % 60
else: s = 0
h= str(h)
m= str(m)
s= str(s)
#print h,m,s
print h + ':' + m + ':' + s

Measured memory_bytes: 6368
n,m = map(int,input().split())
box = [0] + [1 for _ in range(n)]
red = [0] + [1] + [0 for _ in range(n-1)]
for i in range(m):
    x,y=map(int,input().split())
    if red[x] == 1:
        red[y] = 1
    box[x] -= 1
    box[y] += 1
    if box[x] == 0:
        red[x] = 0
print(sum(red))

Measured memory_bytes: 5408
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define repp(i, m, n) for(int i = m; i < n; i++)
#define reps(i, n) for(int i = 1; i <= n; i++)
const int    INF = 100000000;
const double EPS = 1e-10;
const int    MOD = 1000000007;
using namespace std;
typedef long long ll;
typedef pair<int, int> pai;
typedef pair<ll,ll> pal;



int main()
{
	int n, a[100010], b[100010];
	cin >> n;
	reps(i, n) cin >> a[i];
	b[0]=1;
	int ans=-1, muri=0;
	reps(j, n)
	{
		b[j]=a[b[j-1]];
		if(b[j]==2)
		{
			ans=j;
			break;
		}
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1024
/*input
999999999
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define pb push_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define YY cout<<"YES\n"
#define NN cout<<"NO\n"
#define yy cout<<"Yes\n"
#define nn cout<<"No\n"
#ifdef leowang
#define debug(...) do{\
	fprintf(stderr,"%s - %d : (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
	_DO(__VA_ARGS__);\
}while(0)
template<typename I> void _DO(I&&x){cerr<<x<<endl;}
template<typename I,typename...T> void _DO(I&&x,T&&...tail){cerr<<x<<", ";_DO(tail...);}
#else
#define debug(...)
#endif
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
	out<<'('<<P.F<<','<<P.S<<')';
	return out;
}

//}}}
const ll maxn=300005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const double PI=acos(-1);
//const ll p=880301;
//const ll P=31;

ll mypow(ll a,ll b){
	ll res=1LL;
	while(b){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		
		b>>=1;
	}
	return res;
}
int a[10];
vector<int> v;
int main()
{
	IOS;
	
	for(int len=3;len<=9;len++){
		REP(i,mypow(3,len)){
			int tmp=i;
			int cur=0;
			bool tt[3]={0};
			REP(t,len){
				if(tmp%3==0) cur=cur*10+3,tt[0]=1;
				else if(tmp%3==1) cur=cur*10+5,tt[1]=1;
				else cur=cur*10+7,tt[2]=1;
				tmp/=3;
			}
			if(tt[0]&&tt[1]&&tt[2]) v.pb(cur);
		}
	}
	sort(ALL(v));
	//REP(i,20) cout<<v[i]<<" \n"[i==19];
	int n;
	cin>>n;
	n++;
	cout<<GET_POS(v,n)<<'\n';

	return 0;
}


Measured memory_bytes: 512
#include<iostream>
#include<string>
using namespace std;
int main() {
  string s1, s2;
  int N;
  cin >> N;
  cin >> s1 >> s2;

  for(int i=0; i<N; i++) {
    cout << s1[i] << s2[i];
  }
  cout << endl;
}

Measured memory_bytes: 256
lst = list(input())
lst_ki = []
lst_gu = []

for i in range(len(lst)):
    if i%2==1:
        lst_gu+=lst[i]
    else:
        lst_ki+=lst[i]

ki = ["R","U","D"]
gu = ["L","U","D"]

for i in range(len(lst_gu)):
    if lst_gu[i] not in gu:
        print("No")
        exit()
for i in range(len(lst_ki)):
    if lst_ki[i] not in ki:
        print("No")
        exit()
print("Yes")


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

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

int main()
{
    char inp[111];
    scanf("%s", inp);

    bool ok = true;
    for (int i = 0; i < strlen(inp); i++) {
        if (i % 2 == 0 && inp[i] == 'L')
            ok = false;
        else if (i % 2 == 1 && inp[i] == 'R')
            ok = false;
    }

    printf("%s\n", ok ? "Yes" : "No");

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;



int main(){
	int N,M; cin >> N >> M;
	vector<int> num(N,1);
	vector<bool> red(N,false);
	red[0] = true;
	rep(i,M){
		int x,y; cin >> x >> y;
		x--; y--;
		if(red[x] && num[x] > 1){
			red[x] = true;
			red[y] = true;
			num[x]--;
			num[y]++;
		}
		else if(red[x] && num[x] == 1){
			red[x] = false;
			red[y] = true;
			num[x]--;
			num[y]++;
		}
		else{
			num[x]--;
			num[y]++;
		}
	}
	int ans = 0;
	rep(i,N){
		if(red[i]) ans++;
	}
	cout << ans << endl;

}



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

int main() {
  int h, w; cin >> h >> w;
  set<pair<int, int>> S, T;
  rep(i, w) S.emplace(i, 0), T.emplace(0, i);

  rep(k, h) {
    int a, b; cin >> a >> b; --a;
    auto l = S.lower_bound({a, -1});
    auto r = S.lower_bound({b, -1});

    int x = w;
    while (l != r) {
      auto [i, j] = *l;
      x = min(x, j-i+b);
      l = S.erase(l);
      T.erase({j, i});
    }
    if (x < w && b < w) S.emplace(b, x), T.emplace(x, b);

    int ans = -1;
    if (!T.empty()) ans = k+1 + T.begin()->first;
    cout << ans << '\n';
  }
}


Measured memory_bytes: 22352
#include <bits/stdc++.h>
using namespace std;
#define fastcin {\
    cin.tie(0);\
    ios::sync_with_stdio(false);\
}
#define rep(i, a, b) for(int i = a; i < b; i++)
#define print(x) cout << x << "\n"
const int inf = 1e9+7;

int main() {
    fastcin;
    int a, b;
    cin >> a >> b;
    string ans = "x";
    if(a*b==15) ans = "*";
    else if(a+b==15) ans = "+";
    cout << ans << endl;
}

Measured memory_bytes: 892
S = input()
T = input()
q = int(input())

SA = []
SB = []
cnt_a = 0
cnt_b = 0
for s in S:
    if s == "A":
        cnt_a += 1
    else:
        cnt_b += 1
    SA.append(cnt_a)
    SB.append(cnt_b)

TA = []
TB = []
cnt_a = 0
cnt_b = 0
for t in T:
    if t == "A":
        cnt_a += 1
    else:
        cnt_b += 1
    TA.append(cnt_a)
    TB.append(cnt_b)


def check(a, b, c, d):
    sa = SA[b-1]
    sb = SB[b-1]
    if a >= 2:
        sa -= SA[a - 2]
        sb -= SB[a - 2]
    ta = TA[d-1]
    tb = TB[d-1]
    if c >= 2:
        ta -= TA[c-2]
        tb -= TB[c-2]
    """
    print(sa, sb)
    print(ta, tb)
    """

    sb += 2 * sa
    sb %= 3

    tb += 2 * ta
    tb %= 3

    return sb == tb


for i in range(q):
    a, b, c, d = map(int, input().split())
    if check(a, b, c, d):
        print("YES")
    else:
        print("NO")


Measured memory_bytes: 13080
/*
これを入れて実行
g++ code.cpp
./a.out
 */

#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <tuple>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef long double ld;

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

const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;

bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}

int gcd(int a, int b){
	if (b == 0)return a;
	return gcd(b, a % b);
}

//-----------------------ここから-----------


int main(void){
	int a, b;
	cin >> a >> b;
	
	int ans = a - 1;
	for(int i = 1; i <= b; i++){
		if(a == i){
			ans++;
		}
	}

	cout << ans << endl;
}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

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

	public void run() {
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		long k=sc.nextLong();
		long a[] = new long[100000+1];
		for(int i=0; i<n; i++) {
			int v=sc.nextInt();
			long w=sc.nextLong();
			a[v]+=w;
		}
		long cnt=0;
		int ans=-1;
		for(int i=0; i<=100000; i++) {
			cnt+=a[i];
			if(cnt>=k) {
				ans=i;
				break;
			}
		}
		System.out.println(ans);
		sc.close();
	}
}




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

signed main() {
  int N;
  cin >> N;
  vector<pair<pair<string, int>, int>> x;

  for (int i = 0; i < N; i++) {
    string s;
    int p;
    cin >> s >> p;
    x.push_back({{s, -p}, i + 1});
  }

  sort(x.begin(), x.end());

  for (auto a : x) {
    cout << a.second << endl;
  }

  return 0;
}


Measured memory_bytes: 256
N = int(input())
T,A = map(int,input().split())
H = list(map(int,input().split()))

y = 1000

for i in range(N):
    x = A - (T - H[i] * 0.006)
    if y > abs(x):
        y = abs(x)
        result = i+1

print(result)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
  
int main(void){
    int n;
    cin >> n;
    
    string s[100];
    for (int i=0; i<n; i++) {
        cin >> s[i];
        //cout << s[i] << endl;
        for (int j=0; j<i; j++) {//重複チェック
            if (s[j] == s[i]) {
                cout << "No";
                return 0;
            }
        }
        if (i>=1) { //しりとりチェック
            //cout << s[i-1] << " " << s[i-1][s[i-1].length()-1] << endl;
            if (s[i-1][s[i-1].length()-1] != s[i][0]) {
                cout << "No";
                return 0;
            } 
        }
    }
    cout << "Yes";
    return 0;
}

Measured memory_bytes: 256
M = 10**9+7
def ext(x)
  rec = Array.new(10**5+1,1)
  s = 1
  for i in 1..x
    rec[i] = (rec[i-1]*i)%M
  end
  return rec[x]
end

n,m = gets.strip.split.map(&:to_i)
if (n-m).abs >= 2
  puts 0
  exit
end
if (n-m).abs == 1
  puts (ext(n)*ext(m))%M
  exit
end
if n == m
  puts (2*ext(n)*ext(m))%M
  exit
end

Measured memory_bytes: 15856
//85DTG
//07082020
#include<bits/stdc++.h>
using namespace std;
#define bolt ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define F first
#define S second
#define pb push_back
#define endl "\n"
#define lb lower_bound
#define ub upper_bound
#define vi vector <int>
typedef long long ll;
typedef long double ld;
const ld pi=3.1415926535897932384626433;
const ll mod = 998244353;
const ll inf = 1e18;
int main ()
{
   bolt;
   ll k;
   cin>>k;
   ll c=7%k;
   for( ll i =1 ;i<1000001;i++)
   {
      if (c==0)
         return cout<<i, 0;
      c=((c*10)+7)%k;
      
   }
   cout<<-1;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
char grid[5001][5001];
long long mod=1e9+7;
int soln(int n,int m){
    int dp[n][m];memset(dp,0,sizeof(dp));
    dp[n-1][m-1]=1;
    for(int i=n-1;i>=0;i--){
        for(int j=m-1;j>=0;j--){
            if(i==n-1&&j==m-1)continue;
            else if(grid[i][j]=='#')dp[i][j]=0;
            else dp[i][j]=(((n-1-i>0)?dp[i+1][j]:0)+((m-1-j>0)?dp[i][j+1]:0))%mod;
        }
    }
    return dp[0][0];
}
int main() {
    int n,m;cin>>n>>m;
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            cin>>grid[i][j];
        }
    }
    cout<<soln(n,m);
}


Measured memory_bytes: 12344
a = list(map(int, input().split()))
num = int(input())
k = 0
for i in range(num):    #num回２倍を繰り返す。でなければNoをprint
  if a[0] == max(a) or a[1] == max(a):   #リストaの中のmaxよりも青が小さいならば青を二倍する
    a[2] = a[2] * 2
    k += 1
  elif a[1] == min(a) and k < num:
    a[1] = a[1] * 2
    k += 1 
  else:
    pass

if a[0] < a[1] and a[1] < a[2]:
  print("Yes")
else:
  print("No")


Measured memory_bytes: 9184
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1e9
#define PI 3.14159265359
#define MOD 1000000007
#define ALL(v) v.begin(),v.end()
#define ALLR(v) v.rbegin(),v.rend()
typedef long long ll;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//isPrime
//modpow modinv
//getDigit
int main() {
  cout << fixed << setprecision(10);
  string s;
  cin >> s;
  if(s.at(1)==s.at(2)){
    if(s.at(0)==s.at(1)||s.at(1)==s.at(3)){
      cout << "Yes" << endl;
      return 0; 
    }
  }
  cout << "No" << endl;
}


Measured memory_bytes: 256
import numpy as np

N, M=map(int, input().split())
A=np.sort(np.array(list(map(int, input().split()))))
P=np.array([int(np.log2(A[i])) for i in range(N)])

maxp=P[-1]
while M>0:
  temp=np.sum(P==maxp)
  if temp<=M:
    P[-temp:]=P[-temp:]-1
    A[-temp:]=A[-temp:]//2
    M-=temp
  else:
    A=np.sort(A)
    A[-M:]=A[-M:]//2
    M=0
    
  if np.sum(A)==0:
    break
  maxp-=1
    
print(np.sum(A))

Measured memory_bytes: 23100
X, N = map(int, input().split())
P = list(map(int, input().split()))
PS = set(P)

ans = None
d = float('inf')
for i in range(-100, 200):
    if i in PS:
        continue
    a = abs(X-i)
    if a < d:
        ans = i
        d = a

print(ans)

Measured memory_bytes: 61880
import java.util.Scanner;

public class Main {
	// 2-100
	public static String check(int x, int y) {
		
		return "";
	}
	public static void main(String args[]) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int count = 0;
		int vit = 0;
		while (n-- != 0) {
			int x = in.nextInt();
			int y = in.nextInt();
			
			if (x == y) {
				count++;
			}else {
				count=0;
			}
			if (count==3) {
				vit = 1;
			}
		}
		if (vit == 1) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}

	}

}

Measured memory_bytes: 27304
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N, *A = map(int, read().split())

    neg = total = 0
    min_abs = INF
    for a in A:
        if a < 0:
            neg += 1
        total += abs(a)
        if min_abs > abs(a):
            min_abs = abs(a)

    if neg % 2 == 1:
        total -= 2 * min_abs

    print(total)
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 20064
#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < n; i++)
#define ALL(a) a.begin(), a.end()
#define MOD 1000000007
using namespace std;
typedef long long ll;

ll gcd(ll a, ll b) {
    if (a < b) swap(a, b);
    ll r = a % b;
    while (r != 0) {
        a = b;
        b = r;
        r = a % b;
    }
    return b;
}

ll lcm(ll a, ll b) {
    return a / gcd(a, b) * b;
}

int main() {
    int N, M; cin >> N >> M;
    vector<int> A(N);
    REP(i, 0, N) {
        cin >> A[i];
        A[i] /= 2;
    }

    while (A[0] % 2 == 0) {
        REP(i, 0, N) {
            if (A[i] % 2 != 0) {
                cout << 0 << endl;
                return 0;
            }
            A[i] /= 2;
        }
        M /= 2;
    }

    REP(i, 0, N) {
        if (A[i] % 2 == 0) {
            cout << 0 << endl;
            return 0;
        }
    }

    ll l = A[0];
    REP(i, 1, N) l = lcm(l, A[i]);

    cout << (M / l + 1) / 2 << endl;
    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define rep(i,a,...) for(int i = (a)*(strlen(#__VA_ARGS__)!=0);i<(int)(strlen(#__VA_ARGS__)?__VA_ARGS__:(a));++i)
#define per(i,a,...) for(int i = (strlen(#__VA_ARGS__)?__VA_ARGS__:(a))-1;i>=(int)(strlen(#__VA_ARGS__)?(a):0);--i)
#define foreach(i, n) for(auto &i:(n))
#define pii pair<int, int>
#define pll pair<long long, long long>
#define all(x) (x).begin(), (x).end()
#define bit(x) (1ll << (x))
#define lambda(RES_TYPE, ...) (function<RES_TYPE(__VA_ARGS__)>)[&](__VA_ARGS__) -> RES_TYPE
#define method(FUNC_NAME, RES_TYPE, ...) function<RES_TYPE(__VA_ARGS__)> FUNC_NAME = lambda(RES_TYPE, __VA_ARGS__)
using ll = long long;
//const ll MOD = (ll)1e9+7;
const ll MOD = 998244353;
const int INF = (ll)1e9+7;
const ll INFLL = (ll)1e18;
using namespace std;
template<class t>
using vvector = vector<vector<t>>;
template<class t>
using vvvector = vector<vector<vector<t>>>;
template<class t>
using priority_queuer = priority_queue<t, vector<t>, greater<t>>;
template<class t, class u> bool chmax(t &a, u b){if(a<b){a=b;return true;}return false;}
template<class t, class u> bool chmin(t &a, u b){if(a>b){a=b;return true;}return false;}
#ifdef DEBUG
#define debug(x) cout<<"LINE "<<__LINE__<<": "<<#x<<" = "<<x<<endl;
#else
#define debug(x) (void)0
#endif

namespace templates{
  ll modpow(ll x, ll b){
    ll res = 1;
    while(b){
      if(b&1)res = res * x % MOD;
      x = x * x % MOD;
      b>>=1;
    }
    return res;
  }

  ll modinv(ll x){
    return modpow(x, MOD-2);
  }

  bool was_output = false;
  template<class t>
  void output(t a){
    if(was_output)cout << " ";
    cout << a;
    was_output = true;
  }
  void outendl(){
    was_output = false;
    cout << endl;
  }
  ll in(){
    ll res;
    scanf("%lld", &res);
    return res;
  }

  template<class t>
  istream& operator>>(istream&is, vector<t>&x){
    for(auto &i:x)is >> i;
    return is;
  }

  template<class t, class u>
  istream& operator>>(istream&is, pair<t, u>&x){
    is >> x.first >> x.second;
    return is;
  }

  template<class t>
  void in(t&x){
    cin >> x;
  }

  template<class t>
  t in(){
    t res; cin >> res; return res;
  }

  template<class t>
  void out(t x){
    cout << x;
  }

  template<class t>
  vector<t> sorted(vector<t> line,function<bool(t,t)> comp=[](t a,t b){return a<b;}){
    sort(line.begin(),line.end(),comp);
    return line;
  }

  template<class t>
  vector<t> reversed(vector<t> line){
    reverse(line.begin(),line.end());
    return line;
  }
}

using namespace templates;

int main(){
  int n = in();
  vector<int> line(n);
  foreach(i,line)i=in();
  line.erase(unique(all(line)),line.end());
  foreach(i,line){
    output(i);
  }
  outendl();
}



Measured memory_bytes: 3524
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <unordered_set>

using namespace std;
#define INF 99999
#define _GLIBCXX_DEBUG
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define fi first
#define se second
typedef vector<int> vint;
typedef pair<int,int> pint;
typedef vector<pint> vpint;
using namespace std;

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

    int N;
    cin >> N;

    vint p(N);
    REP(i, N) cin >> p[i];

    int count = 0;
    bool swapFlag = false;
    REP(i, N){
        if(i+1 == p[i]){
            if(swapFlag) {
                count++;
                swapFlag = false;
            } else {
                swapFlag = true;
            }
        } else{
            if(swapFlag) {
                count++;
                swapFlag = false;
            }
        }
    }
    if(swapFlag) {
        count++;
        swapFlag = false;
    }
    cout << count;

}

Measured memory_bytes: 640
/** Bismillahir Rahmanir Rahim **/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define Fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define print(x) cout << "x " << x;

int main()
{
    int n;
    cin >> n;
    string s;
    cin >> s;
    int cnt = 0;
    for (int i = 0; i < s.size()-2; i++) {
        if (s[i] == 'A' and s[i + 1] == 'B' and s[i + 2] == 'C') cnt++;
    }
    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <queue>
#include <vector>
#include <algorithm>
#include <cmath>
#include <chrono>

using namespace std;

int main(int argc, const char * argv[]) {
    
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    string s, t; cin >> s >> t;
    vector<vector<int>> dp(s.size() + 1, vector<int>(t.size() + 1, 0));
    
    for (int i = 1; i <= s.size(); i++) dp[i][0] = i;
    for (int i = 1; i <= t.size(); i++) dp[0][i] = i;
    
    for (int i = 0; i < s.size(); i++) {
        for (int j = 0; j < t.size(); j++) {
            if (s.at(i) == t.at(j)) dp[i + 1][j + 1] = dp[i][j];
            else dp[i + 1][j + 1] = min(min(dp[i + 1][j], dp[i][j + 1]), dp[i][j]) + 1;
        }
    }
    
    cout << dp[s.size()][t.size()] << endl;
    
    return 0;
}



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

using namespace std;

int main()
{
    string s;
    cin >> s;
    int ans = 0;
    for (int i = 0; i < s.length(); i++)
    {
        if (s[i] == '+')
        {
            ans++;
        }
        else
        {
            ans--;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
L=input()
MOD=(10**9)+7
dpmiman=[0 for _ in range(100005)]
dp=[0 for _ in range(100005)]

dp[0]=1
for i in range(len(L)):
  #a+b=0
  if L[i]=='0':
    dp[i+1]=dp[i]
    dpmiman[i+1]=dpmiman[i]
  else:
    dpmiman[i+1]=dp[i]+dpmiman[i]
  #a+b=1
  if L[i]=='0':
    dpmiman[i+1]+=dpmiman[i]*2
  else:
    dp[i+1]+=dp[i]*2
    dpmiman[i+1]+=dpmiman[i]*2
  dp[i+1]%=MOD
  dpmiman[i+1]%=MOD
print((dp[len(L)]+dpmiman[len(L)])%MOD)

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

using namespace std;

const int N=1e6+3;

#define pb push_back
#define all(x) (x).begin(),(x).end()
typedef long long ll;

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

const int inf=1e9;

int n,m,a[N],b[N],k,q,u,v,x,y,tc,c,l,r,ans,sz[N];

char s[N];

pair<int,int> p[N];

int main(){
	ll n;
	scanf("%lld",&n);
	ll ans=1e18;
	for(int i=1;(ll)i*i<=n;i++)
		if (n%i == 0)
			ans=min(ans,i+(n/i)-2);
	printf("%lld\n",ans);
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<algorithm>
#include<math.h>
#include<numeric>
#include<iomanip>
#include<deque>
#include<tuple>
#include<queue>
#include<map>
#include<cstdint>
#include<unordered_map>
#include<boost/multiprecision/cpp_int.hpp>


#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define vi vector<int>
#define all(x) (x).begin(),(x).end()
#define Endl endl
#define F first
#define S second

namespace mp = boost::multiprecision;

using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;


int main() {
	int n, m;
	cin >> n >> m;
	ll ans=0;
	if (n == 1 && m == 1) {
		ans = 1;
	}
	else if (n == 1 or m==1) {
		ans = max(n,m)-2;
	}
	else {
		ans = (ll)(n - 2)*(m - 2);
	}
	cout << ans << endl;

	
}



Measured memory_bytes: 256