akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include<stdio.h>
using namespace std;
int main()
{
    int  a,b;
    while(cin>>a>>b)
    {
        int f[100005]={0},cc=0;
        int x=0,y=0,sum=a;
        cin>>x;
        for(int i=0;i<a-1;i++)
        {
            int t,c;
            scanf("%d",&t);
            c=t-x-1;
            x=t;
            f[cc++]=c;
        }
        sort(f,f+cc);
        for(int i=0;i<a-b;i++)
            sum+=f[i];
        cout<<sum<<endl;
    }
    return 0;
}






Measured memory_bytes: 3628
H, W= map(int, input().split())
A = [input() for i in range(H)]

v_list = []
reverse_list = [""]*W
h_list = []

for i in range(H):
    if "#" in A[i]:
        v_list.append(A[i])

for i in range(W):
    for j in range(len(v_list)):
        reverse_list[i] = reverse_list[i] + v_list[j][i]

for i in range(W):
    if "#" in reverse_list[i]:
        h_list.append(reverse_list[i])

result_list = [""]*(len(h_list[0]))

for i in range(len(h_list[0])):
    for j in range(len(h_list)):
        result_list[i] = result_list[i] + h_list[j][i]

for s in result_list:
    print(s)


Measured memory_bytes: 3064
import re

while 1:
    s=raw_input()
    if(s=='.'):
        break
    s = re.sub('[^][()]', '', s)
    while (1):
        tmp=s
        s = re.sub('\[\]', '', s)
        s = re.sub('\(\)', '', s)
        if (tmp==s):
            break
    if(not s):
        print 'yes'
    else:
        print 'no'

Measured memory_bytes: 4224
#include <stdio.h>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef vector<vector<int>> v2int;
typedef vector<vector<vector<int>>> v3int;
typedef vector<ll> vll;
typedef vector<vector<ll>> v2ll;
typedef vector<vector<vector<ll>>> v3ll;
typedef list<int> liint;
typedef pair<int, int> pint;
typedef vector<pair<int, int>> vpint;
typedef vector<pair<ll, ll>> vpll;
typedef vector<pair<ll, int>> vpll_int;
typedef vector<pair<int, ll>> vpint_ll;
typedef set<pair<int, int>> spint;
typedef set<pair<ll, int>> spll;
typedef unordered_map<int, unordered_set<int>> Graph;
const int INF = int(2e9);
const ll LINF = ll(2e9) * ll(2e9);
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b) { a > b ? : a = b; }
template<class T, class C> void chmin(T& a, C b) { a < b ? : a = b; }



int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int N;
    cin >> N;
    unordered_map<string, int> ans;
    rep(i, N) {
        string s;
        cin >> s;
        ans[s]++;
    }
    cout << "AC x " << ans["AC"] << endl;
    cout << "WA x " << ans["WA"] << endl;
    cout << "TLE x " << ans["TLE"] << endl;
    cout << "RE x " << ans["RE"] << endl;


    return 0;
}

Measured memory_bytes: 3656
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <stdlib.h>
#include <math.h>

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

typedef int long long ill;
typedef int long il;

using namespace std;

#define N 100
#define L 100
int n, l;

string ss;
void set();
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    cin >> n >> l;
    vector<string> s(n);
    REP(i, n)
    cin >> s[i];
    sort(s.begin(), s.end());
    REP(i, n)
    cout << s[i];
    cout << '\n';
    return 0;
}


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

class UnionFind {
public:
    UnionFind(int n) : par(n), rnk(n, 1) {
        rep(i, 0, n) par[i] = i;
    }

    int root(int a) {
        if (par[a] == a) return a;
        return par[a] = root(par[a]);
    }

    void unite(int a, int b) {
        a = root(a);
        b = root(b);
        if (a == b) return;
        if (rnk[a] > rnk[b]) swap(a, b);
        par[a] = b;
        rnk[b] += rnk[a];
    }

    bool same(int a, int b) {
        return root(a) == root(b);
    }

    int size(int a) {
        return rnk[a];
    }

private:
    vector<int> par, rnk;
};

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

    vector<int> friend_cnt(n, 0);
    UnionFind friends(n);
    rep(i, 0, m) {
        int a, b;
        cin >> a >> b;
        friends.unite(--a, --b);
        friend_cnt[a]++;
        friend_cnt[b]++;
    }

    vector<vector<int>> block_member(n);
    rep(i, 0, k) {
        int c, d;
        cin >> c >> d;
        --c, --d;
        block_member[c].push_back(d);
        block_member[d].push_back(c);
    }

    map<int, int> friends_root;
    rep(i, 0, n) {
        friends_root[i] = friends.root(i);
    }
    
    vector<int> friends_group(n, 0);
    for (auto e : friends_root) {
        friends_group[e.second]++;
    }

    vector<int> ans(n, 0);
    rep(i, 0, n) {
        ans[i] = friends_group[friends_root[i]] - 1 - friend_cnt[i];
        int block_cnt = 0;
        rep(j, 0, block_member[i].size()) {
            if (friends_root[i] == friends_root[block_member[i][j]]) block_cnt++;
        }
        ans[i] -= block_cnt;
    }

    rep(i, 0, n) cout << ans[i] << (i + 1 == n ? "\n" : " ");
    
    return 0;
}

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

// calculate |gcd|.
// if  ether num is 0, return 0
long long GCD(long long left, long long right) {
  if (left == 0 || right == 0) return 0;
  if (left < 0) left *= -1;
  if (right < 0) right *= -1;
  if (left < right) swap(left, right);
  long long nextnum, ansgcd = -1;
  while (ansgcd == -1) {
    nextnum = left % right;
    if (nextnum == 0) ansgcd = right;
    left = right;
    right = nextnum;
  }
  return ansgcd;
}

long long LCM(long long left, long long right) {
  return left / GCD(left, right) * right;
}

long long k;

int main() {
  cin >> k;

  cout << 360 / GCD(k, 360) << endl;
  return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#include <unordered_set>
using namespace std;
#define ll long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repeat(i,s,n) for(int (i)=s; (i)<(n); (i)++)
#define revrep(i,n) for(int (i)=(n)-1;i>=0; i--)

bool f[100][10];
ll p[100][11];
int n;

int A=0;

ll solve(int s, vector<bool>& b) {
  if(s==10) {
    rep(k,11) {
      if(k==10) return -1e9;
      if(b[k]) break;
    }
    A++;
    vector<int> c(n);
    rep(i,n) {
      rep(k,10) {
        if(b[k]&&f[i][k]) c[i]++;
      }
    }
    ll sum=0;
    rep(i,n) sum+=p[i][c[i]];
    if(sum==0) {
      //cout << "aaaa" << endl;
    }
    return sum;
  }
  b[s]=true;
  ll a = solve(s+1,b);
  b[s]=false;
  return max(a,solve(s+1,b));
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<setprecision(std::numeric_limits<float>::max_digits10);
  cin>>n;
  rep(i,n) {
    rep(j,10) {
      cin>>f[i][j];
    }
  }
  rep(i,n) {
    rep(j,11) cin>>p[i][j];
  }
  vector<bool> b(10);
  cout << solve(0,b) << endl;
//  cout << A << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define llu unsigned long long
#define ld long double
#define pb push_back
#define mp make_pair
#define MOD 1000000007
#define PI 3.14159265
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
#define deb(x) cerr << ">> " << #x << " : " << x << "\n"
#define endl '\n'
#define ff first
#define ss second
#define gcd(a, b) __gcd(a, b)
#define lcm(a, b) (a * b) / __gcd(a, b)
#define DESYNC ios::sync_with_stdio(0); cin.tie(0);
#define print(a) for(auto x : a) cout << x << " "; cout << endl;

using namespace std;

const ll inf = 1e18 + 42;

const ll M = 998244353;

ll power(ll x, ll y) {
	if (y == 0) return 1;
	if (y & 1) return (x * power(x, y - 1));
	ll t = power(x, y / 2);
	return (t * t);
}

const ll MAX = 2e5 + 5;

// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

void ahShitHereWeGoAgain()
{
	ll h1, m1, h2, m2, k;
	cin >> h1 >> m1 >> h2 >> m2 >> k;
	ll ans = 0;
	ll diff = (h2 - h1) * 60 + (m2 - m1);
	ans = diff - k;
	cout << ans << endl;
}

int main()
{
	DESYNC	
	ll t = 1;
	// cin >> t;
	while (t--)
		ahShitHereWeGoAgain();
	return 0;
}



Measured memory_bytes: 3648
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
int main(){
  int A,B,C,K,a;
  cin>>A>>B>>C>>K;
  a=max(A,max(B,C));
  for(int i=1;i<=K;i++) a*=2;
  cout<<min(A+B+a,min(A+C+a,B+C+a))<<endl;
}


Measured memory_bytes: 256
n = int(input())
r = [list(map(int,input().split())) for _ in range(n)]
b = [list(map(int,input().split())) for _ in range(n)]
b.sort()
r = sorted(r,key=lambda x:-x[1])
ans = 0
for i,b_ in enumerate(b):
    for j,r_ in enumerate(r):
        if b_[0]>r_[0] and b_[1]>r_[1]:
            ans+=1
            del r[j]
            break

print(ans)

Measured memory_bytes: 3188
//********************************************************************//
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define RANGE(i, n) for (int i = 0; i < n; ++i)
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define DFOR(i, a, b) for(int i = a; i > b; --i)
#define DEB(x) cout << #x << ": " << x << endl
#define ALL(v) v.begin(), v.end() 
#define SORT(v) sort(ALL(v))
#define DISPV(v) { for(auto x___: v) cout << x___ << " "; cout << endl; }
#define DISPM(m) { for(auto x____: m){ cout << x____.first << ": " << x____.second << endl; } };
#define DISPMV(m) { for(auto x_____: m){ cout << x_____.first << ": " ;DISPV(x_____.second);} };
using LL = long long;
using VI = vector <int>;
using VL = vector <long long>;
using VVI = vector<VI>;
using VVL = vector <VL>;
using MII = map<int, int>;
using MIVI = map<int, VI>;
using MLL = map<LL, LL>;
int READ_INT(){int temp;cin>>temp;return temp;}      // read an int
LL READ_LONG(){LL temp;cin>>temp;return temp;}      // read a long long

const int MOD = int(1e9) + 7;
const int INF = 1e9 + 5;
const double PI = acos(-1.0); //M_PI;
const double EPS = 1e-9;
//********************************************************************//

int rows, cols;    // rows, cols
char grid[1005][1005];
int dist[1005][1005], visited[1005][1005];

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

bool ok(int x, int y){
    return x >= 1 && x <= rows && y >= 1 && y <= cols && !visited[x][y];
}

void bfs(int x, int y){
    dist[x][y] = 0;
    visited[x][y] = 1;
    deque<pair<int, int>>q, cur;
    q.push_front({x, y});
    while(!q.empty()){
        int x1 = q.front().first, y1 = q.front().second;
        q.pop_front();
        for(int x2 = x1-2; x2 <= x1+2; ++x2){
            for(int y2 = y1-2; y2 <= y1+2; ++y2){
                if(ok(x2, y2) && grid[x2][y2] == '.'){
                    if(abs(x2 - x1) + abs(y2 - y1) == 1 && dist[x2][y2] > dist[x1][y1]){
                        dist[x2][y2] = dist[x1][y1];
                        q.push_front({x2, y2});
                    }
                    else if(abs(x2 - x1) + abs(y2 - y1) != 1 && dist[x2][y2] > 1+dist[x1][y1]){
                        dist[x2][y2] = 1+dist[x1][y1];
                        q.push_back({x2, y2});
                    }
                }
            }
        }
    }
}

int main(){
    ios::sync_with_stdio(false);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    int x1, y1, x2, y2;
    cin >> rows >> cols;
    cin >> x1 >> y1 >> x2 >> y2;
    RANGE(i,rows){
        RANGE(j,cols){
            cin >> grid[i+1][j+1];
            visited[i+1][j+1] = 0;
            dist[i+1][j+1] = INF;
        }
    }
    bfs(x1, y1);
    (dist[x2][y2] >= INF)? cout << -1 << endl: cout << dist[x2][y2] << endl;
    return 0;
}



/* complie flags
-Wall -Wextra -pedantic -std=c++11 -O2 -Wshadow -Wformat=2 -Wfloat-equal -Wconversion -Wlogical-op -Wshift-overflow=2 -Wduplicated-cond -Wcast-qual -Wcast-align -D_GLIBCXX_DEBUG -D_GLIBCXX_DEBUG_PEDANTIC -D_FORTIFY_SOURCE=2 -fsanitize=address -fsanitize=undefined -fno-sanitize-recover -fstack-protector
*/

Measured memory_bytes: 12448
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<cctype>
#include<cstring>
#define maxn 2007
#define SDOI2020 RP++ 
using namespace std;
int n,m,a[maxn],tot; 
inline int read()
{
	int x=0;
	int flag=0;
	char ch;
	ch=getchar();
	while(!isdigit(ch)) 
	{
		if(ch=='-') flag=1;
	ch=getchar();	
	}
	while(isdigit(ch))
	{
		x=(x<<3)+(x<<1)+ch-48;
		ch=getchar();
		}
		if(flag==1) x=-x;	
		return x;
}
inline int cmp(int x,int y)
{
	return x > y;
}

int main()
{
	n = read();
	m = read();
	for(register int i = 1;i <= n;i++)
	{
		a[i] = read();
		tot += a[i];
	} 
	sort(a + 1,a + n + 1,cmp);
	int cnt = 0;
	for(register int i = 1;i <= n;i++)
	{
		if(a[i] * 4 * m >= tot) cnt++;
		else break;
		if(cnt == m)
		{
			printf("Yes\n");
			return 0;
		}
	}
	printf("No\n");
	return 0;
} 

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

const long long MOD=1000000007;

int main() {
  int N,A,B,C,D;
  cin >> N >> A >> B >> C >> D;
  A--;
  B--;
  C--;
  D--;
  string S;
  cin >> S;
  int e=-1;
  if(A<B&&C<D||A>B&&C>D){
    e=1;
  }
  else{
  for(int i=B-1;i<min(C,D);i++){
    if(S.at(i)==S.at(i+1)&&S.at(i+1)==S.at(i+2)&&S.at(i)=='.')
      e=1;
  }
  }
  for(int i=A;i<max(C,D)-1;i++){
    if(S.at(i)==S.at(i+1)&&S.at(i)=='#')
      e=-1;
  }
  if(e==1){
    cout << "Yes" << endl;
  }
  else
    cout << "No" << endl;
}

Measured memory_bytes: 640
import math

A, B = map(int, input().split())

x = math.ceil(100 / 8 * A)
y = math.ceil(100 / 10 * B)

if x == y:
  print(x)
elif x > y:
  if math.floor(x*0.1) == B:
    print(x)
  else:
    print(-1)
else:
  if math.floor(y*0.08) == A:
    print(y)
  else:
    print(-1)

Measured memory_bytes: 80432
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repd(i,a,b) for (int i = (a); i < (b); i++)
#define INF LLONG_MAX
typedef long long ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main(void)
{
    ll N, ans=0;
    cin >> N;
	ll v[N][3];
	ll dp[N+1][3];
	rep(i, N) rep(j, 3) cin >> v[i][j];
	rep(i, N+1) rep(j, 3) dp[i][j] = 0;

	rep(i, N)
	{
		rep(j, 3)
		{
			rep(k, 3)
			{
				if(j==k) continue;
				chmax(dp[i+1][k], dp[i][j] + v[i][k]);
			}
		}
	}

    rep(i, 3) chmax(ans, dp[N][i]);
	cout << ans << endl;
}


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

int main(){
    int N,T;
    cin >> N >> T;
    int ans = 0;
    int a[N];
    
    for (int i=0;i<N;++i) cin >> a[i];

    for (int i=0;i<N-1;++i){
        ans += min(a[i+1]-a[i],T);
    }

    ans += T;

    cout << ans << endl;

}

Measured memory_bytes: 1024
class Dice:
    def __init__(self,label):
        self.W = label[3]
        self.S = label[1]
        self.E = label[2]
        self.N = label[4]
        self.u = label[0]
        self.l = label[5]
    def rotate(self,direction):
        if direction =='S':
            dummy = self.S
            self.S = self.u
            self.u = self.N
            self.N = self.l
            self.l = dummy
        elif direction == 'N':
            dummy = self.S
            self.S = self.l
            self.l = self.N
            self.N = self.u
            self.u = dummy
        elif direction == 'W':
            dummy = self.W
            self.W = self.u
            self.u = self.E
            self.E = self.l
            self.l = dummy
        else:
            dummy = self.W
            self.W = self.l
            self.l = self.E
            self.E = self.u
            self.u = dummy
    def rot(self):
            dummy = self.W
            self.W = self.S
            self.S = self.E
            self.E = self.N
            self.N = dummy

l = input().split()
D = Dice(l)
n = int(input())
for i in range(n):
    a,b = input().split()
    if a == D.u:
        c = 1
    elif a == D.N:
        D.rotate('S')
    elif a == D.W:
        D.rotate('E')
    elif a == D.E:
        D.rotate('W')
    elif a == D.S:
        D.rotate('N')
    else:
        D.rotate('S')
        D.rotate('S')
    for i in range(4):
        D.rot()
        if (D.S == b)+(D.S == str(b)):
            break
    print(D.E)
    D = Dice(l)
    


Measured memory_bytes: 5608
using System;
using System.Linq;

namespace MinPro_A
{
    class Program
    {
        static void Main(string[] args)
        {
            var NK = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var N = NK[0];
            var K = NK[1];

            Console.WriteLine((N + 1) / 2 >= K ? "YES" : "NO");
        }
    }
}


Measured memory_bytes: 13268
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; i++)
#define repr(i, n) for(int i=n; i>=0; i--)
#define reps(i, s, e) for(int i=s; i<e; i++)
#define inf 1e18
#define vsort(v) sort(v.begin(), v.end())
#define vsortr(v) sort(v.begin(), v.end(), greater<ll>())
#define sz(x) x.size()
#define ceil(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
using namespace std;
using ll = long long;
template<typename T> inline bool chmax(T &a, T b){ if(a<b){ a=b; return true; } return false; }
template<typename T> inline bool chmin(T &a, T b){ if(b<a){ a=b; return true; } return false; }
template<typename T> T gcd(T a, T b){ if(b==0) return a; return gcd(b, a%b); }
template<typename T> T lcm(T a, T b){ return a*b/gcd(a, b); }
template<typename T> T vdebug(vector<T> v){ for(auto vv : v){ cout << vv << " "; } cout << endl; }
template<typename T> T adebug(T arr[], int n){ rep(i, n){ cout << arr[i] << " "; } cout << endl; }
void ans(bool b){ if(b) cout << "Yes" << endl; else cout << "No" << endl; }
void ans2(bool b){ if(b) cout << "YES" << endl; else cout << "NO" << endl; }
int keta(ll num){ int k=0; while(num>0){ num/=10; k++; } return k; }
int dx[] = {1, -1, 0, 0, 1, -1, 1, -1};
int dy[] = {0, 0, 1, -1, 1, -1, -1, 1};


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

    vector<int> abc(3);
    cin >> abc[0] >> abc[1] >> abc[2];

    int oddcnt = 0;
    int oddarr[3];

    rep(i, 3){
        if(abc[i]%2 == 1){
            oddcnt++;
            oddarr[i] = 1;
        }else{
            oddarr[i] = 0;
        }
    }

    int res = 0;
    if(oddcnt == 2){
        rep(i, 3){
            if(oddarr[i] == 1) abc[i]++;
        }
        res++;
    }
    if(oddcnt == 1){
        rep(i, 3){
            if(oddarr[i] == 0) abc[i]++;
        }
        res++;
    }

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

    int diff1 = abc[2]-abc[0];
    int diff2 = abc[2]-abc[1];

    while(diff1 > 0){
        diff1 -= 2;
        res++;
    }
    while(diff2 > 0){
        diff2 -= 2;
        res++;
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 256
/*
 * written by Yaqi Zhang
 * University of Wisconsin-Madison
 * 2020
 */

#include<algorithm>
#include<cstring>
#include<climits>
#include<iostream>
#include<map>
#include<set>
#include<stdio.h>
#include<vector>

#define INF 0x3f3f3f3f
typedef long long ll;

using namespace std;


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    vector<pair<int, int>> coords(101, {-1, -1});
    for(int i = 0; i < 3; ++i) {
        for(int j = 0; j < 3; ++j) {
            int a;
            cin >> a;
            coords[a] = {i, j};
        }
    }
    map<pair<int, int>, int> counter;
    int n;
    cin >> n;
    bool bingo = false;
    for(int i = 0; i < n; ++i) {
        int b;
        cin >> b;
        int r, c;
        tie(r, c) = coords[b];
        // auto [r, c] = coords[b];
        if (r != -1) {
            if(++counter[{1, r}] == 3) bingo = true;
            if(++counter[{2, c}] == 3) bingo = true;
            if(++counter[{3, r + c}] == 3) bingo = true;
            if(++counter[{4, r - c}] == 3) bingo = true;
        }
    }
    cout << (bingo ? "Yes" : "No") << endl;
    return 0;
}



Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <tuple>
#include <stack>
#include <bitset>

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

const ll MAX_N = 100010;
//const ll MAX_M = 100010;
//const ll MOD_P = 1000000000 + 7;
const ll INF = 1000000000000;
ll A[MAX_N];

int main() {

  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  
  ll N; 
  cin >> N;

  ll neg_cnt = 0;
  ll min_abs = INF;
  for (int i = 0; i < N; i++) {
    cin >> A[i];
    if(A[i] < 0) neg_cnt++;
    min_abs = min(min_abs, abs(A[i]));
  }

  ll ans = 0;
  for (int i = 0; i < N; i++) ans += abs(A[i]);
  if(neg_cnt % 2 != 0) ans -= 2*min_abs;

  cout << ans << endl;

  return 0;
}


    


Measured memory_bytes: 3960
#!/usr/bin/python3
# -*- coding:utf-8 -*-

from math import floor

def main():
  n, m = map(int, input().split())
  divisors = []
  for i in list(range(1, floor(m**0.5)+1))[::-1]:
    if m%i == 0:
      divisors.insert(0, i)    
      if m//i != i:
        divisors.append(m//i)
  
  for divisor in divisors[::-1]:
    if m//divisor >= n:
      print(divisor)
      return
    
if __name__=='__main__':
  main()



Measured memory_bytes: 4468
void main()
{
    long[] a = rdRow;

    a.sort!"a < b";
    writeln(a.uniq.array.length == 2 ? "Yes" : "No");
}

enum long mod = 10^^9 + 7;
enum long inf = 1L << 60;

T rdElem(T = long)()
if (!is(T == struct))
{
    return readln.chomp.to!T;
}

alias rdStr = rdElem!string;
alias rdDchar = rdElem!(dchar[]);

T rdElem(T)()
if (is(T == struct))
{
    T result;
    string[] input = rdRow!string;
    assert(T.tupleof.length == input.length);
    foreach (i, ref x; result.tupleof)
    {
        x = input[i].to!(typeof(x));
    }
    return result;
}

T[] rdRow(T = long)()
{
    return readln.split.to!(T[]);
}

T[] rdCol(T = long)(long col)
{
    return iota(col).map!(x => rdElem!T).array;
}

T[][] rdMat(T = long)(long col)
{
    return iota(col).map!(x => rdRow!T).array;
}

void rdVals(T...)(ref T data)
{
    string[] input = rdRow!string;
    assert(data.length == input.length);
    foreach (i, ref x; data)
    {
        x = input[i].to!(typeof(x));
    }
}

void wrMat(T = long)(T[][] mat)
{
    foreach (row; mat)
    {
        foreach (j, compo; row)
        {
            compo.write;
            if (j == row.length - 1) writeln;
            else " ".write;
        }
    }
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.traits;
import std.container;
import std.functional;
import std.typecons;
import std.ascii;
import std.uni;

Measured memory_bytes: 256
let () = Scanf.scanf "%d\n" @@ fun m ->
  let dcs = Array.init m @@ fun _ ->
    Scanf.scanf "%d %d\n" @@ fun d c -> d, c in
  let digitsum, digit =
    Array.fold_left (fun (digitsum, digit) (d, c) ->
      digitsum + d * c, digit + c) (0, 0) dcs in
  Printf.printf "%d\n" @@ (digitsum - 1) / 9 + digit - 1



Measured memory_bytes: 9472
//29, 09, 2018, 09:01:21 Rafaelcs cpp
#include <bits/stdc++.h>
    
using namespace std;
typedef pair<int, int> pii;
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
    
const int N = int(3e5);
int a[N];
int cnt[N][2];
vector< pii > v1, v0;
int n;
    
bool equal(){
    int x = a[0];
    
    for(int i = 1 ; i < n ; i++){
        if(a[i] != x){
            return false;
        }
    }
    
    return true;
}
    
int main(){
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    
    scanf("%d", &n);
    
    for(int i = 0 ; i < n ; i++){
        scanf("%d", &a[i]);
    
        cnt[a[i]][i % 2]++;
    }
    
    if(equal()){
        printf("%d\n", n / 2);
        return 0;
    }
    
    for(int i = 1 ; i <= N - 100 ; i++){
        if(cnt[i][1]){
            v1.push_back({cnt[i][1], i});
        }
    
        if(cnt[i][0]){
            v0.push_back({cnt[i][0], i});
        }
    }
    
    sort(v0.begin(), v0.end(), greater< pii >());
    sort(v1.begin(), v1.end(), greater< pii >());
    
    int best = 1e9;
    
    for(int i = 0 ; i < min(int(v1.size()), 1000) ; i++){
        for(int j = 0 ; j < min(int(v0.size()), 1000) ; j++){
            if(v0[j].second != v1[i].second){
                best = min(best, n - v0[j].first - v1[i].first);
            }
        }
    }
    
    printf("%d\n", best);
    
    return 0;
}

Measured memory_bytes: 2428
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <iomanip>
using namespace std;
#define pb push_back
#define pf push_fron
#define INF 1000000000
typedef long long ll;


int main() {
	/*cin.tie(0);
	ios::sync_with_stdio(false);*/
	
	int x, a, b;
	cin >> x >> a >> b;
	int wallet = x - a;

	while (1) {
		if (wallet < b)break;
		wallet -= b;
	}

	cout << wallet << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mod 1000000007
using namespace std;
int main(){
    int H,W;
    cin >> H >> W;
    char G[H][W];
    long long dp[H+5][W+5];
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            cin >> G[i][j];
        }
    }

    for(int i=0;i<H+5;i++){
        for(int j=0;j<W+5;j++){
            dp[i][j] = 0;
        }
    }
    dp[0][0] = 1;

    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            if(G[i][j] != '#'){
                if(G[i+1][j] != '#') dp[i+1][j] = (dp[i+1][j] + dp[i][j]) % mod;
                if(G[i][j+1] != '#') dp[i][j+1] = (dp[i][j+1] + dp[i][j]) % mod;
            }
        }
    }
    cout << dp[H-1][W-1] << endl;
}

Measured memory_bytes: 9088
#include<iostream>
#include<cctype>
#include<cstdio>
#include<cstring>

int main(){
    char str[1001];
    
    while(1){
        scanf("%s",str);
        if(str[0]=='0')break;
        int num=0;
        int i;
        for(i=0; i< strlen(str); i++){
            num+=(str[i]-'0');
        }
        printf("%d\n",num);
    }
    return 0;
}


Measured memory_bytes: 3228
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000001;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

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

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

struct edge {
	ll ind;
	ll to;
	ll d;
};


///////////////////////////





int main() {

	ll x;
	cin >> x;

	ll ans = x / 11 *2;

	if (x % 11 > 0) { ans++; }
	if (x % 11 > 6) { ans++; }
	cout << ans;

	system("PAUSE");
}


Measured memory_bytes: 504
package main

import (
	"fmt"
)

func checkNum(i int) {
	n := i
	if n%3 == 0 {
		fmt.Printf(" %d", i)
		endCheckNum(i)
		return
	}
	includeThree(i, n)
}

func includeThree(i, n int) {
	if n%10 == 3 {
		fmt.Printf(" %d", i)
		endCheckNum(i)
		return
	}
	n /= 10
	if n != 0 {
		includeThree(i, n)
		return
	}
	endCheckNum(i)
}

func endCheckNum(i int) {
	i++
	if i <= num {
		checkNum(i)
		return
	}
	fmt.Println()
}

var num int

func main() {
	fmt.Scan(&num)

	checkNum(1)
}



Measured memory_bytes: 9212
fn main() {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    let v: Vec<i32> = s
        .trim()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect();
    let a = v[0];
    let b = v[1];
    if a == b {
        println!("Draw");
    } else if a == 1 {
        println!("Alice");
    } else if b == 1 {
        println!("Bob");
    } else if a > b {
        println!("Alice");
    } else {
        println!("Bob");
    }
}


Measured memory_bytes: 4352
use std::io;
use std::str::FromStr;
fn main() {
    let stdin = io::stdin();
    let mut s = String::new();
    stdin.read_line(&mut s).ok();
    let iter = s.trim().split_whitespace();
    let mut numbers = Vec::new();
    for arg in iter {
        numbers.push(u64::from_str(&arg).expect("e"));
    }
    let n : u64 = numbers[0];
    let k : u64 = numbers[1];
    if n % k == 0 {
        println!("0");
    } else {
        println!("1");
    }
}

Measured memory_bytes: 4352
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < (n); i++)

using namespace std;

void solve() {
  long A, B, C, D, E, F;
  cin >> A >> B >> C >> D >> E >> F;

  vector<long> suger(F+1, 0);
  suger[0] = 1;
  rep (i, F+1) {
    if (suger[i] == 0) continue;
    if (i + C < F+1) suger[i+C] = 1;
    if (i + D < F+1) suger[i+D] = 1;
  }

  vector<long> water(F+1, 0);
  water[0] = 1;
  rep (i, F+1) {
    if (water[i] == 0) continue;
    if (i + 100 * A < F+1) water[i+100*A] = 1;
    if (i + 100 * B < F+1) water[i+100*B] = 1;
  }

  vector<long> clean_water, clean_suger;
  rep (i, suger.size()) if (suger[i]) clean_suger.push_back(i);
  rep (i, water.size()) if (water[i]) clean_water.push_back(i);

  double ans = -1;
  long ans_w, ans_s;
  for (auto s: clean_suger) for (auto w: clean_water) {
    if (s + w > F) continue;
    if (s > w / 100 * E) continue;
    double tmp = 100;
    tmp *= s;
    tmp /= w + s;
    if (ans < tmp) {
      ans = tmp;
      ans_w = w;
      ans_s = s;
    }
  }

  cout << ans_w + ans_s << " " << ans_s << endl;
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  solve();
  return 0;
}


Measured memory_bytes: 384
S=gets.chomp
T=gets.chomp
donelist=[]
S.size.times{|i|
  if S[i]!=T[i] && !donelist.include?(S[i]) then
    for j in i+1...S.size do
      if (S[i]==S[j] && T[i]!=T[j])||(T[i]==T[j] && S[i]!=S[j]) then
        puts "No"
        exit
      end
    end
    donelist << S[i]
  end
}
puts "Yes"

Measured memory_bytes: 2632
#include<bits/stdc++.h>
#define rep(i, n) for(int (i)=0 ;i <(n); ++(i))
#define REP(i,m,n) for(int (i) = (m); (i) <= (n); ++(i))
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)? "YES":"NO")
typedef long long ll;
using namespace std;

int main() {
  int a,b;
  cin >> a >> b;
  if(a == 1 && b == 2) cout << 3 << endl;
  if(a == 1 && b == 3) cout << 2 << endl;
  if(a == 2 && b == 1) cout << 3 << endl;
  if(a == 2 && b == 3) cout << 1 << endl;
  if(a == 3 && b == 1) cout << 2 << endl;
  if(a == 3 && b == 2) cout << 1 << endl;
  return 0;
}

Measured memory_bytes: 256
import collections
import math
import operator as op
from functools import reduce

import numpy as np
import math


def main():
    a, b, x = list(map(int, input().split()))
    if x > a**2 * b / 2:
        angle_rad = math.atan(2 * (a**2 * b - x) / a**3)
    else:
        angle_rad = math.atan(a * (b**2) / (2 * x))
    angle = angle_rad * 180 / math.pi

    print(angle)


if __name__ == '__main__':
    main()


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

int A[3][3];
bool ok[3][3];

int main(){
  for (int i=0;i<3;++i){
    for (int j=0;j<3;++j){
      cin >> A[i][j];
    }
  }
  int n;
  cin >> n;
  for (int i=0;i<n;++i){
    int b;
    cin >> b;
    for (int j=0;j<3;++j){
      for (int k=0;k<3;++k){
        if(A[j][k] == b) ok[j][k] = true;
      }
    }
  }
  //ここまででマルバツの配列に変換できた
  
  bool bingo = false;
  for (int i=0;i<3;++i){
    int cnt = 0;
    for (int j=0;j<3;++j) if(ok[i][j]) cnt++;
    if (cnt >= 3) bingo = true;
  }
  for (int j=0;j<3;++j){
    int cnt = 0;
    for (int i=0;i<3;++i) if(ok[i][j]) cnt++;
    if (cnt >= 3) bingo = true;
  }
  //ここまでで縦横
  int cnt = 0;
  for (int i=0;i<3;++i){
    if(ok[i][i]) cnt++;
    if (cnt >= 3) bingo = true;
  }
  //ここまでで縦横斜め
  if (ok[0][2] && ok[1][1] && ok[2][0]) bingo = true;

  if (bingo) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int M = 1e5+10;
#define ll long long
#define F first
#define S second

ll l[M];
main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int n;cin>>n;
	l[0]=2;
	l[1]=1;
	for(int i=2;i<=n;i++)
		l[i]=l[i-1]+l[i-2];
	cout<<l[n];
}

Measured memory_bytes: 256
#include <iostream>

int DNum(int n)
{
    int ans = 0;
    for (int i = 1; i <= n; i++) {
        if (n%i==0) ans++;
    }

    return ans;
}

int main()
{
    int N;
    std::cin >> N;

    int ans = 0;
    for (int i = 1; i <=N; i+= 2) {
        if (DNum(i) == 8) ans++;
    }

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

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <utility>
#include <algorithm>
#include <sstream>
using namespace std;
typedef pair<int,int> P;

const int max_n=1000+10;
int h,w,n,sx,sy,dx[]={0,0,-1,1},dy[]={-1,1,0,0},d[max_n][max_n],ans;
char c[max_n][max_n];

void bfs(int x,int y,int m){
	if(m>n)return;
	queue<P> q;
	memset(d,0,sizeof(d));
	q.push(P(x,y));
	d[x][y]=1;
	while(!q.empty()){
		P p=q.front();
		q.pop();
		if(c[p.first][p.second]=='0'+m){
		    ans+=d[p.first][p.second]-1;
		    bfs(p.first,p.second,m+1);
		    return;
		}
		for(int i=0;i<4;i++){
			int tx=p.first+dx[i],ty=p.second+dy[i];
			if(tx>=0 && tx<h && ty>=0 && ty<w && c[tx][ty]!='X' && !d[tx][ty]){
				q.push(P(tx,ty));
				d[tx][ty]=d[p.first][p.second]+1;
			}
		}
	}
}

int main(){
    scanf("%d%d%d",&h,&w,&n);
    for(int i=0;i<h;i++)
        for(int j=0;j<w;j++){
            cin>>c[i][j];
            if(c[i][j]=='S'){sx=i;sy=j;}
        }
    bfs(sx,sy,1);
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 8092
#include<bits/stdc++.h>
/*
g++ -std=c++11 -Wall -g -fsanitize=undefined -D_GLIBCXX_DEBUG agc/agc024/a.cpp
*/
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define SZ(x) ((int)(x).size())
#define INF (1e16)
typedef long long ll;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);//おまじないでcin, cout早くする
    ll a, b, c, k;
    cin >> a >> b >> c >> k;

    if(k % 2 == 0){
        cout << a - b << "\n";
    }else{
        cout << b - a << "\n";
    }
    return 0;
}

Measured memory_bytes: 256
//              +-- -- --++-- +-In the name of ALLAH-+ --++-- -- --+              \\

#include <bits/stdc++.h>

#define F first
#define S second
#define _sz(x) (int)x.size()

using namespace std ;
using ll = long long ;
using ld = long double ;
using pii = pair <int , int> ;

int const L = 2e5 + 20 ;
int l , a[L] ;
ll dp[L][5] ;

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

	cin >> l ;

	for (int i = 0 ; i < l ; i ++) cin >> a[i] ;
	
	for (int i = 0 ; i < l ; i ++) {
		for (int j = 0 ; j < 5 ; j ++) {
			dp[i + 1][j] = dp[i][j] ;
			if (j) dp[i + 1][j] = min(dp[i + 1][j] , dp[i + 1][j - 1]) ;
		}
		for (int j = 0 ; j < 5 ; j ++) {
			if (!j || j == 4) dp[i + 1][j] += a[i] ;
			else if (j == 2) dp[i + 1][j] += !(a[i] & 1) ;
			else dp[i + 1][j] += (a[i] & 1) + 2 * !a[i] ;
		}
	}

	ll ans = dp[l][0] ;
	for (int i = 1 ; i < 5 ; i ++) ans = min(ans , dp[l][i]) ;

	cout << ans << '\n' ;
}


Measured memory_bytes: 8960
/*よくばりセット2019/07/13 */
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#define MOD 1000000007
typedef long long int ll;
void llswap(ll *x,ll *y){ll temp;temp=*x;*x=*y;*y=temp;}
void swap(int *x,int *y){int tmp;tmp=*x;*x=*y;*y=tmp;}
int max(int x,int y){return x>y?x:y;}
int min(int x,int y){return x>y?y:x;}
ll llmax(ll x,ll y){return x>y?x:y;}
ll llmin(ll x,ll y){return x>y?y:x;}
int asc(const void *a,const void *b){return *(int*)a-*(int*)b;}
int desc(const void *a,const void *b){return *(int*)b-*(int*)a;}

int main(){
    int e,y;
    
    scanf("%d %d",&e,&y);

    if(e==0){
        if(y<=1911){
            printf("M%d\n",y-1867);
        }else if(y<=1925){
            printf("T%d\n",y-1911);
        }else if(y<=1988){
            printf("S%d\n",y-1925);
        }else{
            printf("H%d\n",y-1988);
        }
    }else if(e==1){
        printf("%d\n",y+1867);
    }else if(e==2){
        printf("%d\n",y+1911);
    }else if(e==3){
        printf("%d\n",y+1925);
    }else{
        printf("%d\n",y+1988);
    }

    return 0;

}


Measured memory_bytes: 2108
/*
    問題をよく読もう！
    論理的に考えよう！
    サンプルを確認しよう!
    絶対に諦めるな！
    工夫をしろ！
    配列は少し多めにとっておく

    Twitterは終わるまでログアウト！
    （間違えて解法をツイートしてはいけないから）

*/
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <functional>
#include <cmath>
using namespace std;
#define rep(i, n) for(int i=0; i<n; ++i)
typedef long long ll;
//必要な宣言

void solve();
bool func(int, int);

int h, w;
char a[101][101];
int b[101][101] = {};
int c[101];

int main() {
  cin >> h >> w;
  rep(i, h) {rep(j, w) cin >> a[i][j]; }

  solve();

  return 0;
}

void solve() {

  rep(i, h) {
    if(func(0, i)) {
      c[i] = 1;
      rep(j, w) b[i][j] = 1;
    }
  }

  rep(i, w) {
    if(func(1, i)) {
      rep(j, h) b[j][i] = 1;
    }
  }

  rep(i, h) {
    rep(j, w) {
      if(!b[i][j]) cout << a[i][j];
    }
    if(!c[i]) cout << endl;
  }

}

bool func(int n, int m) {

  if(!n) {
    rep(j, w) {
      if(a[m][j]=='#') return false;
    }
    return true;
  }else {
    rep(j, h) {
      if(a[j][m]=='#') return false;
    }
    return true;
  }
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Comparator;
import java.util.StringTokenizer;
import java.util.TreeSet;

import javax.management.Query;

public class Main {

	public static void main(String[] args) throws IOException {
		Main mainObj = new Main();
		mainObj.solve();
	}

	public void solve() throws IOException {
		FastScanner fs = new FastScanner();
		int n = fs.nextInt();
		int k = fs.nextInt();
		
		int[] aArr = fs.nextIntArr(n);
		
		SegmentTree segTree = new SegmentTree(300_001, (a,b) -> Math.max(a,b), 0);
		
		for(int i = 0; i < n; i++) {
			
			int a = aArr[i];
			int left = Math.max(0, a-k);
			int right = Math.min(300_000, a+k);
			
			int maxLength = segTree.query(left, right+1, 0, 0, segTree.reafSize);
			segTree.update(a, maxLength+1);
		}
		
		
		System.out.println(segTree.query(0, 300_001, 0, 0, segTree.reafSize));
	}
	
	public class SegmentTree {
		int reafSize;
		int[] tree;
		TreeFunc treeFunc;
		int notInSectionValue;

		public SegmentTree(int size, TreeFunc treeFunc, int notInSectionValue) {
			reafSize = 1;
			while (reafSize < size) {
				reafSize *= 2;
			}
			tree = new int[reafSize * 2 - 1];
			this.treeFunc = treeFunc;
			this.notInSectionValue = notInSectionValue;
		}

		public void update(int pos, int val) {
			int pointer = reafSize + pos - 1;
			tree[pointer] = val;
			while (pointer > 0) {
				pointer = (pointer - 1) / 2;
				tree[pointer] = treeFunc.calc(tree[pointer * 2 + 1], tree[pointer * 2 + 2]);
			}
		}

		public int query(int a, int b, int k, int l, int r) {

			if (r < 0) {
				r = reafSize;
			}

			if (r <= a || b <= l) {
				return notInSectionValue;
			}
			if (a <= l && r <= b) {
				return tree[k];
			}

			return treeFunc.calc(query(a, b, k * 2 + 1, l, (l + r) / 2), query(a, b, k * 2 + 2, (l + r) / 2, r));
		}
	}

	@FunctionalInterface
	interface TreeFunc {
		public int calc(int left, int right);
	}


	public class FastScanner {

		BufferedReader reader;
		private StringTokenizer st;

		public FastScanner() {
			st = null;
			reader = new BufferedReader(new InputStreamReader(System.in));
		}

		public String next() throws IOException {
			if (st == null || !st.hasMoreElements()) {
				st = new StringTokenizer(reader.readLine());
			}
			return st.nextToken();
		}

		public String nextLine() throws IOException {
			st = null;
			String readLine = null;
			readLine = reader.readLine();
			return readLine;
		}

		public int nextInt() throws NumberFormatException, IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws NumberFormatException, IOException {
			return Long.parseLong(next());
		}

		public int[] nextIntArr(int n) throws NumberFormatException, IOException {
			int[] retArr = new int[n];
			for (int i = 0; i < n; i++) {
				retArr[i] = nextInt();
			}
			return retArr;
		}

		public long[] nextLongArr(int n) throws NumberFormatException, IOException {
			long[] retArr = new long[n];
			for (int i = 0; i < n; i++) {
				retArr[i] = nextLong();
			}
			return retArr;
		}

		public void close() throws IOException {
			reader.close();
		}
	}

}


Measured memory_bytes: 56732
#include <iostream>
#include <math.h>

int main() {
  long a, b, c;

  std::cin >> a >> b >> c;

  if(a < b && b < c) {
    std::cout << "Yes" << std::endl;
  }
  else  {
    std::cout << "No" << std::endl;
  }

  return 0;
}

Measured memory_bytes: 1156
#include <iostream>
#include <cstdio>
#include <cmath>

using namespace std;

typedef long long ll;
	
ll a,b,c;

int main()
{
	cin>>a>>b>>c;
	if(a+b>=c)
	{
		cout<<"No"<<endl;
		return 0;
	}
	ll cnt=4*a*b;
	ll ans=(c-a-b)*(c-a-b);
	if(cnt<ans)
		cout<<"Yes";
	else
		cout<<"No";
	return 0;
}

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

typedef long long ll;
//loop
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//STL
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))

//const
#define MOD 1000000007 //10^9+7:合同式の法

//acronym
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

void Main() {
    string a,b;
    cin >> a >> b;
    if (a == "H") {
        if (b == "H") {
            cout << "H" << endl;
        } else {
            cout << "D" << endl;
        }
    } else {
        if (b == "H") {
            cout << "D" << endl;
        } else {
            cout << "H" << endl;
        }
    }
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	Main();
	return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
#include<iomanip>
#include<tuple>
#include<cassert>
#include<set>
#include<atcoder/all>
using namespace std;
using namespace atcoder;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<LL,int> LP;
const int INF=1<<30;
const LL MAX=1e9+7;

void array_show(int *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%d%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(LL *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%lld%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(vector<int> &vec_s,int vec_n=-1,char middle=' '){
	if(vec_n==-1)vec_n=vec_s.size();
	for(int i=0;i<vec_n;i++)printf("%d%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}
void array_show(vector<LL> &vec_s,int vec_n=-1,char middle=' '){
	if(vec_n==-1)vec_n=vec_s.size();
	for(int i=0;i<vec_n;i++)printf("%lld%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}

using mint = modint998244353;
mint kai[110000];

int main(){
	int n,m;
	int i,j,k;
	int a,b,c;
	mint ma,mb;
	kai[0]=1;
	for(i=1;i<=1e5;i++){
		kai[i]=kai[i-1]*i;
	}
	cin>>n;
	map<int,int> m1;
	vector<int> v1,v2;	
	for(i=0;i<2*n;i++){
		cin>>a;
		m1[a]++;
	}
	typedef pair<int,vector<int>> Q;
	priority_queue<Q,vector<Q>,greater<Q>> q1;
	for(auto node:m1){
		a=node.second;
		v1.clear();
		v1.push_back(1);
		for(i=2;i<=a;i+=2){
			ma=kai[a]/(kai[a-i]*kai[i]);
			ma*=kai[i]/(mint(2).pow(i/2));
			ma/=kai[i/2];
			v1.push_back(ma.val());
		}
		q1.push(make_pair(v1.size(),v1));
	}
	while(q1.size()>1){
		v1=q1.top().second,q1.pop();
		v2=q1.top().second,q1.pop();
		v1=convolution(v1,v2);
		q1.push(make_pair(v1.size(),v1));
	}
	v1=q1.top().second;
	mb=0;
	for(i=0;i<v1.size() && i<=n;i++){
		ma=v1[i];
		ma*=kai[2*(n-i)]/(mint(2).pow(n-i)*kai[n-i]);
		if(i%2==0)mb+=ma;
		else mb-=ma;
	}
	cout<<mb.val()<<endl;
}

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

using namespace std;

int a[200005];

int main()
{
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  long long sum = 0;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    sum += a[i];
  }
  long long temp = 0, ans = (int)1e18;
  for (int i = 0; i < n - 1; ++i) {
    temp += a[i];
    ans = min(ans, abs(sum - temp - temp));
  }
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 1024
import collections

n=int(input())
v=list(map(int,input().split()))
v0=v[::2]
v1=v[1::2]

v0_c=collections.Counter(v0)
m0=v0_c.most_common()
v1_c=collections.Counter(v1)
m1=v1_c.most_common()
#print(m0)
#print(m1)

if len(m0)==1:
	mm0=[[m0[0][0],len(v0)-m0[0][1]], ["X",len(v0)]]
else:
  	mm0=[[m0[0][0],len(v0)-m0[0][1]], [m0[1][0],len(v0)-m0[1][1]]]
if len(m1)==1:
	mm1=[[m1[0][0],len(v1)-m1[0][1]], ["X",len(v1)]]
else:
  	mm1=[[m1[0][0],len(v1)-m1[0][1]], [m1[1][0],len(v1)-m1[1][1]]]

print(mm0[0][1]+mm1[0][1] if mm0[0][0]!=mm1[0][0] else min(mm0[0][1]+mm1[1][1],mm0[1][1]+mm1[0][1]))



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


int main() {
  int mod = 1000000007;
  ll n;
  cin >> n;
  ll ans = 0;
  ll num;
  cin >> num;
  
  rep(i, n-1) {
    ll a;
    cin >> a;
    ans += (num*a)%mod;
    ans %= mod;
    num += a;
    num %= mod;
  }
  
  cout << ans << endl;
}


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

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

int main() {
  int x, y; cin >> x >> y;
  cout << x + y - (GCD(x, y) - 1) << endl;
  return 0;
}


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

int main() {
	int n, w[100], i = 0;
	int min = 100, sum1 = 0, sum2 = 0, diff;
	
	cin >> n;
	for (i = 0; i < n; ++i)
		cin >> w[i];
	i = 0;
	for (int t = 1; t < n; ++t) {
		while (i < t)
			sum1 += w[i++];
		while (i < n)
			sum2 += w[i++];
		diff = (sum1 < sum2) ? sum2 - sum1 : sum1 - sum2;
		if (diff < min)
			min = diff;
		sum1 = 0;	sum2 = 0;	i = 0;
	}

	cout << min << endl;

	return 0;
}


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

int main() {
  string a, b, c;
  cin >> a >> b >> c;
  vector<char> s = {'a','b','c','d','e','f','g','h','i','j','k','l','m'
    ,'n','o','p','q','r','s','t','u','v','w','x','y','z'};
  vector<char> S = {'A','B','C','D','E','F','G','H','I','J','K','L','M'
    ,'N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
  
  for (int i = 0; i < s.size(); i++) {
  	if (a[0] == s[i]) {
    	a = S[i];
        break;
    }      
  }
  for (int i = 0; i < s.size(); i++) {
  	if (b[0] == s[i]) {
    	b = S[i];
        break;
    }
  }
    for (int i = 0; i < s.size(); i++) {
  	if (c[0] == s[i]) {
    	c = S[i];
        break;
    }
  }
  cout << a + b + c << endl;
}



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


using namespace std;

typedef long long ll;

const ll 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 main(void){
	int a, b, t;

	cin >> a >> b >> t;

	int ans = t / a * b;

	cout << ans << endl;
}


Measured memory_bytes: 256