akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <numeric>
#include <cstdio>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
using namespace std;
#define MOD 1000000007
#define endl "\n" 
#define rep(i,n) for(int i = 0; i < (n); ++i)
typedef long long ll;


int main(void) {
    cin.tie(0);
    ios::sync_with_stdio(false);
  
    int n, k ; cin >> n >> k;
    double ans = 0;
    for(int i = 1; i <= n; ++i) {
        double tmp = 1.0/n;
        int num = i;
        while(num < k) {
            num *= 2;
            tmp /= 2;
        }
        ans += tmp;
    }

    printf("%.15f\n", ans);

    return 0;
}


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

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair< ll, ll > Pi;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
const ll INF = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}
#define all(x) x.begin(), x.end()
#define mp make_pair
bool compare(Pi a, Pi b) {
    if(a.second != b.second){
        return a.second < b.second;
        
    }else{
        return a.first < b.first;
    }
}


bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}
const vector<ll> dx{1,0,-1,0};
const vector<ll> dy{0,1,0,-1};


int main() {
    ll N,M;
    cin >>N>>M;
    vector<Pi>AB(M);
    rep(i,M){
        ll a,b;
        cin>>a>>b;
        AB[i]=mp(a,b);
    }

    sort(all(AB),compare);
    ll ans = 0;

    ll now=0;
    rep(i,M){
        if(AB[i].first >= now){
            ans++;
            now=AB[i].second;
        }

    }
    cout << ans << endl;


    return 0;
    

}

Measured memory_bytes: 4820
#include <iostream>
#include <string>
#include <vector>
using namespace std;

// http://www.prefield.com/algorithm/misc/dice.html
enum FACE { TOP, BOTTOM, FRONT, BACK, LEFT, RIGHT };
class dice {
public:
  dice() {
    id[TOP] = 1; id[FRONT] = 2; id[LEFT] = 3;
    id[RIGHT] = 4; id[BACK] = 5; id[BOTTOM] = 6;
  }
  int& operator[] (FACE f) { return id[f]; }
  const int& operator[] (FACE f) const { return id[f]; }
  bool operator==(const dice &b) const {
    const dice &a = *this;
    return a[TOP] == b[TOP] && a[BOTTOM] == b[BOTTOM] &&
           a[FRONT] == b[FRONT] && a[BACK] == b[BACK] &&
           a[LEFT] == b[LEFT] && a[RIGHT] == b[RIGHT];
  }
  void roll_x() { roll(TOP, BACK, BOTTOM, FRONT); }
  void roll_x2() { roll(TOP, FRONT, BOTTOM, BACK); }
  void roll_y() { roll(TOP, LEFT, BOTTOM, RIGHT); }
  void roll_y2() { roll(TOP, RIGHT, BOTTOM, LEFT); }
  void roll_z() { roll(FRONT, RIGHT, BACK, LEFT); }
  void roll_z2() { roll(FRONT, LEFT, BACK, RIGHT); }
  vector<dice> all_rolls() {
    vector<dice> ret;
    for (int k = 0; k < 6; (k&1?roll_y():roll_x()),++k)
      for (int i = 0; i < 4; roll_z(), ++i)
        ret.push_back(*this);
    return ret;
  }
  bool equivalent_to(const dice& di) {
    for (int k = 0; k < 6; (k&1?roll_y():roll_x()),++k)
      for (int i = 0; i < 4; roll_z(), ++i)
        if (*this == di) return true;
    return false;
  }
private:
  void roll(FACE a, FACE b, FACE c, FACE d) {
    int tmp = id[a];
    id[a] = id[b]; id[b] = id[c];
    id[c] = id[d]; id[d] = tmp;
  }
  int id[6];
};

int main(){
	int n;
	string s;
	for(;cin>>n,n;){
		dice di;
		for(;n--;){
			cin>>s;
			if(s[0]=='n')di.roll_x();
			if(s[0]=='e')di.roll_y();
			if(s[0]=='w')di.roll_y2();
			if(s[0]=='s')di.roll_x2();
		}
		cout<<di[TOP]<<endl;
	}
}

Measured memory_bytes: 1200
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace _001_FindingMissingCards
{
    /*
     */

    class Program
    {
        static void Main()
        {
            string line = Console.ReadLine();
            int num = Convert.ToInt32(line);
            int [,,] room = new int[4,3,10];
            for (int i = 0; i < num; i++)
            {
                string line_info = Console.ReadLine();
                string[] info = line_info.Split(' ');
                int b = Convert.ToInt32(info[0]);
                int f = Convert.ToInt32(info[1]);
                int r = Convert.ToInt32(info[2]);
                int v = Convert.ToInt32(info[3]);
                room[b - 1, f - 1, r - 1] += v;
            }
            for (int i = 0; i < 4; i++)
            {
                for (int j = 0; j < 3; j++)
                {
                    for (int k = 0; k < 10; k++)
                    {
                        Console.Write(" {0}", room[i, j, k]);
                    }
                    Console.WriteLine();
                }
                if (i < 3)
                {
                    Console.WriteLine("####################");
                }
            }
        }
    }
}

Measured memory_bytes: 9248
#include<bits/stdc++.h>
#define FOR(i,a,b)for(int i=(a),_b=(b);i<=_b;i++)
#define FORN(i,b,a)for(int i=(b);_a=(a);i>=_a;i--)
#define REP(i,n)for(int i=0,_n=n;i<n;i++)
#define ll long long
#define pii pair<int,int>
#define re return
#define vi vector<int>
#define pb push_back
#define si set<int>
#define in insert
#define fl float
#define db double
#define ld long double
#define X first
#define Y second
#define st string
#define ull unsigned long long
#define mod 1000000007
#define INF 1000000007
#define x1 XZVJDFADSPFOE
#define y1 GASDIJSLDAEJF
#define x2 DFDAJKVOHKWIW
#define y2 PSFSAODSXVNMQ
using namespace std;
inline void read(int &x)
{
	short negative=1;
    x=0;
    char c=getchar();
    while(c<'0' || c>'9')
    {
		if(c=='-')
			negative=-1;
		c=getchar();
	}
    while(c>='0' && c<='9')
        x=(x<<3)+(x<<1)+(c^48),c=getchar();
    x*=negative;
}
int main()
{
	string s;
	cin>>s;
	int q;
	cin>>q;
	int sum=0;
	bool flag=0;
	bool flag1=0;
	string front="";
	string end="";
	while(q--)
	{
		int a;
		cin>>a;
		if(a==1){
		sum++;
		if(flag1==1){flag=1-flag;} }
		else{
			flag1=1;
			cin>>a;
			char c;
			cin>>c;
			if((a==2&&flag==0)||(a==1&&flag==1))
				end+=c;
			else
				front+=c;
		}
	}
	//cout<<front<<endl<<end<<endl;
	if(sum%2==1)reverse(s.begin(),s.end());
	if(flag==0)
		{
		reverse(front.begin(),front.end());
		s=front+s+end;
	}
	else{
		reverse(end.begin(),end.end());
		s=end+s+front;
	}
	cout<<s<<endl;
	return 0;
}



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

int main(){
  int N,count=0;
  cin>>N;
  for(int i=1; i<=N; i++){
    if(1<=i&&i<=9){
      count++;
    }
    else if(100<=i&&i<=999){
      count++;
    }
    else if(10000<=i&&i<=99999){
      count++;
    }
  }
  cout<<count<<endl;
}

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

int main() {
  int x,y;
  cin >> x >> y;
  if((x+y)%2==0){
    cout << (x+y)/2 << endl;
  }
  if((x+y)%2==1){
    cout << (x+y)/2 +1 << endl;
  }
}

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

int main ()
{
	char a[110], b[110];
	int ketaa = 0, ketab = 0, itchi = 0;
	cin >> a;
  	cin >> b;
	for (int i = 0; a[i] != '\0'; i++) ketaa++;
	for (int i = 0; b[i] != '\0'; i++) ketab++;
	if (ketaa > ketab) cout << "GREATER";
	else if (ketaa < ketab) cout << "LESS";
	else {
	    for (int i = 0; i < ketaa; i++) {
	        if (a[i] > b[i]) {
	            cout << "GREATER";
	            break;
	        }
	        else if (a[i] < b[i]) {
	            cout << "LESS";
	            break;
	        }
	    }
	    for (int i = 0; i < ketaa; i++) {
	        if (a[i] == b[i]) itchi++;
	    if (ketaa == itchi) cout << "EQUAL";
	    }
	}
    return 0;
}

Measured memory_bytes: 256
n = gets.to_i
s = gets.chomp.split("")
arr = Array.new
a = s.count("E")
arr << a
for i in 0..n-1 do
    if s[i] == "E"
        a = a - 1
        arr << a
else
        a = a + 1
        arr << a
    end
end

puts arr.min

Measured memory_bytes: 29828
package main

import (
	"fmt"
)

func main() {
	var n, a, b int64
	const M = 1000000007

	fmt.Scan(&n)
	fmt.Scan(&a)
	fmt.Scan(&b)

	answer := modpow(2, n, M) - 1

	ca, cb := int64(1), int64(1)
	for i := int64(0); i < a; i++ {
		ca = ca * (n - i) % M * modinv(1 + i, M) % M
	}
	for i := int64(0); i < b; i++ {
		cb = cb * (n - i) % M * modinv(1 + i, M) % M
	}
	answer = (answer - ca - cb + 2 * M) % M
	fmt.Println(answer)
}

func modpow(a int64, n int64, m int64) int64 {
	if n == 0 {
		return 1
	}
	tmp := modpow(a, n / 2, m)
	if n % 2 == 0 {
		return tmp * tmp % m
	}
	return tmp * tmp % m * a % m
}

func modinv(a int64, m int64) int64 {
	return modpow(a, m - 2, m)
}


Measured memory_bytes: 512
import java.util.Scanner;

public class Main {
    public static void main(String args[]){
        Scanner scanner = new Scanner(System.in);
        String s = scanner.next();
        int c1 = -1;
        int count = 1;
        for (int i = 0;i < s.length();++i){
            char c = s.charAt(i);
            if(c1 == -1){
                c1 = c;
            }
            else if(c1 == c){
                ++count;
                if(count >= 3){
                    System.out.println("Yes");
                    return;
                }
            }
            else{
                count = 1;
                c1 = c;
            }
        }
        System.out.println("No");

    }
}

Measured memory_bytes: 22996
#include <bits/stdc++.h>
 
using namespace std;
 
int main(){
    int n;
    cin >> n;
    long long int max = 10000000000;
    long long int sum = 0;
    long long int a[n];
    for(int i=0 ;i<n;i++){
        cin >> a[i];
    }
    sort(a, a + n, greater<>());
    int p = n;
    sum = a[0];
    n--;
    for(int i=1; i<p;i++){
        long long int x = a[i];
        if(n==1)
            break;
        if(n>2){
            sum = sum + 2 * x;
            n-=2;
        }else{
            sum = sum + x;
            break;
        }
    }
    cout << sum;
    return 0; 
}

Measured memory_bytes: 5172
package main

import (
	"fmt"
)

func main() {
	var n int64
	fmt.Scan(&n)

	var sqn int
	for sqn = 1; int64(sqn)*int64(sqn) < n; sqn++ {
	}

	isnotPrime := make([]bool, sqn+1)
	ans := 0

OUTER:
	for i := 2; i <= sqn; i++ {
		if isnotPrime[i] {
			continue OUTER
		}
		for j := 2; i*j <= sqn; j++ {
			isnotPrime[i*j] = true
		}
		mul := int64(i)
		for {
			if n%mul == 0 {
				ans++
				n /= mul
				mul *= int64(i)
			} else {
				break
			}
		}
	}
	if n != 1 && n > int64(sqn) {
		fmt.Println(ans + 1)
		return
	}
	fmt.Println(ans)
	return
}


Measured memory_bytes: 2772
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define F first
#define S second
#define PB push_back
#define REP(i,a,b) for (int i = a ; i <= b ; i++)
#define REPI(i,a,b) for (int i = a ; i >= b ; i--)
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

const int OO = 1e9+7;
const int MOD = 1e9+7;
const int N = 100+7;
const int maxW = 1e5+7;

ll dp[N][maxW];
ll w[N],v[N];
int n;
ll W;

int main()
{
    //ios::sync_with_stdio(0);
    //cin.tie(0);cout.tie(0);
    //freopen("teleport.in","r",stdin);
    //freopen("teleport.out","w",stdout);

    scanf("%d %lld",&n,&W);
    REP(i,0,n-1) scanf("%lld %lld",&w[i],&v[i]);

    REP(j,w[0],W) dp[0][j] = v[0];

    // dp[i][j] = max value for max weght j and prefix i

    REP(i,1,n-1)
    {
        REP(j,0,W)
        {
            dp[i][j] = dp[i-1][j];
            //cerr << i << ' ' << j << ' ' << dp[i-1][j] << endl;
            if (j-w[i] >= 0) dp[i][j] = max(dp[i][j],dp[i-1][j-w[i]]+v[i]);
        }
    }

    printf("%lld\n",dp[n-1][W]);

    return 0;
}


Measured memory_bytes: 80128
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Volume0016
{
    class Program
    {
        static double _xCoordinate = 0;
        static double _yCoordinate = 0;
        static void Main(string[] args)
        {
            double rotationAngle = 90;
            string str = "";
            while ((str = Console.ReadLine()) != "0,0")
            {
                double[] dataSet = str.Split(',').Select(double.Parse).ToArray();
                double distance = dataSet[0];
               
                Coordinate.Coodination(ref _xCoordinate, ref _yCoordinate, distance, rotationAngle);
                rotationAngle -= dataSet[1];
            }
            Console.WriteLine((int) _xCoordinate + "\n" + (int) _yCoordinate);
        }
    }
    class Coordinate
    {
        internal static void Coodination(ref double x, ref double y, double distance, double rotationAngle)
        {
            x += distance * Math.Cos(rotationAngle * Math.PI / 180);
            y += distance * Math.Sin(rotationAngle * Math.PI / 180);
        }
    }
}



Measured memory_bytes: 16332
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;

int main() {
	int N; cin >> N;
	char S[10010]; cin >> S;

	for (int i = 0; i < strlen(S); ++i) {
		if (S[i] + N > 90) S[i] = N - (91 - S[i]) + 65;
		else S[i] += N;
	}

	printf("%s\n", S);
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys

YES = "Yes"  # type: str
NO = "No"  # type: str


def solve(K: int, X: int):
    print(YES if 500*K>=X else NO)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    K = int(next(tokens))  # type: int
    X = int(next(tokens))  # type: int
    solve(K, X)

if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#!/usr/bin/env python
from collections import deque, defaultdict
from itertools import combinations, combinations_with_replacement
import bisect
from math import factorial, sqrt, log, ceil, floor


def main():
    #N, M = map(int, input().split())
    #N, K = map(int, input().split())

    a = int(input())
    s = input()

    if a >= 3200:
        print(s)
    else:
        print("red")


if __name__ == '__main__':
    main()


Measured memory_bytes: 3316
n,x=map(int,input().split())
if(n>=x):
  print(0)
else:
  hoge=list(map(int,input().split()))
  hoge.sort()
  huga=[]
  for i in range(len(hoge)-1):
    huga.append(hoge[i+1]-hoge[i])
  huga.sort()
  ans=0
  for i in range(x-n):
    ans+=huga[i]
  print(ans)

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

int main() {
	int a,b,c;
	cin>>a>>b>>c;
	int anses[3]={10*a+b+c,10*b+a+c,10*c+a+b};
	int ans=0;
	for(int i=0;i<3;++i){
		ans=max(ans,anses[i]);
		
	}
	cout<<ans<<endl;
	// your code goes here
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define MOD 1000000007
#define print(A,n) for(ll i=0;i<n;++i)cout<<A[i]<<' ';cout<<endl;
#define take(A,n) for(ll i=0;i<n;++i)cin>>A[i];
//    for(auto& it : m)
void fastio(){ios_base::sync_with_stdio(false);cin.tie(NULL);}
//  priority_queue<ll int> pq;
//  priority_queue <ll int, vector<ll int>, greater<ll int> > pq;
//  vector<ll int> v;
//  vector< pair<ll int,ll int> > v;
//  set<ll int>::iterator it=s.begin();
//  unordered_map<  pair<ll int,ll int>, ll int> mp;

 

ll int power(ll int x, ll int y, ll int p)  
{  
    ll int res = 1;     // Initialize result  
  
    x = x % p; // Update x if it is more than or  
                // equal to p 
   
    if (x == 0) return 0; // In case x is divisible by p; 
  
    while (y > 0)  
    {  
        // If y is odd, multiply x with result  
        if (y & 1)  
            res = (res*x) % p;  
  
        // y must be even now  
        y = y>>1; // y = y/2  
        x = (x*x) % p;  
    }  
    return res;  
}  
 
int main()
{
  fastio();

 
ll int T;
T=1;
while(T--)
{
int n,m,i;cin>>n>>m;
vector<int>graph[n+1];int x,y;

int ans[n+1]={INT_MIN},vis[n+1]={0};
for(i=0;i<=n;i++)
ans[i]=INT_MIN;
ans[0]=0;
for(i=0;i<m;i++)
{
    cin>>x>>y;
    graph[x].push_back(y);
    graph[y].push_back(x);
}
queue<int> q;
q.push(1);
vis[1]=1;
ans[1]=0;
int cnt=0;
while(!q.empty())
{cnt++;
    int tt=q.size();
    while(tt--)
    {
        auto tp=q.front();
        for(i=0;i<graph[tp].size();i++)
        {
            //cout<<tp<<" "<<graph[tp][i]<<endl;
            
            if(!vis[graph[tp][i]])
            {
                q.push(graph[tp][i]);
                
                    vis[graph[tp][i]]=vis[tp]+1;
                    ans[graph[tp][i]]=tp;
                    
                
            }
        }
        q.pop();
    }
}

for(i=2;i<=n;i++)
if(ans[i]==INT_MIN)
{
    cout<<"No"<<endl;
    return 0;
}
cout<<"Yes"<<endl;
for(i=2;i<=n;i++)
cout<<ans[i]<<endl;
}
    return 0;
}


Measured memory_bytes: 10936
k = gets.chomp.to_i
ans = 0
kari = 0
1.step(k) do |a|
  1.step(k) do |b|
    1.step(k) do |c|
      kari = a.gcd(b)
      kari = kari.gcd(c)
      ans += kari
    end
  end
end

puts ans

Measured memory_bytes: 14400
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
from bisect import bisect_left,bisect_right 
import sys,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]
        
    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())
    
    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

n,m = inpl()
uf = UnionFind(n)
ed = [inpl() for _ in range(m)]
res = [n*(n-1)//2]
for i in range(1,m)[::-1]:
    a,b = ed[i]
    a,b = a-1, b-1
    if uf.same(a,b):
        res.append(res[-1])
        continue
    res.append(res[-1] - uf.size(a)*uf.size(b))
    uf.union(a,b)
print(*res[::-1])

Measured memory_bytes: 104704
#include <iostream>
#include <vector>
#include <map>
#include <list>
#include <queue>
#include <algorithm>
#include <cassert>
#include <string>
#include <climits>
#include <numeric>

#define all(x) begin(x),end(x)

using namespace std;
using ll = long long;

int main()
{
	int n; cin >> n;
	vector<int> h(n);
	int ans = 1;
	for (int i = 0; i < n; ++i)
		cin >> h[i];
	bool flag = true;
	for (int i = 1; i < n; ++i) {
		for (int j = 0; j < i; ++j) {
			if (h[i] < h[j])
				flag = false;
		}
		if (flag)
			ans++;
		flag = true;
	}
	cout << ans << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define ls (o<<1)
#define rs (o<<1|1)
#define pb push_back
const double PI= acos(-1.0);
const int M = 1e5+7;
/*
int head[M],cnt=1;
void init(){cnt=1,memset(head,0,sizeof(head));}
struct EDGE{int to,nxt,w;}ee[M*2];
void add(int x,int y,int w){ee[++cnt].nxt=head[x],ee[cnt].w=w,ee[cnt].to=y,head[x]=cnt;}
*/
char s[10][10];
int main()
{
	ios::sync_with_stdio(false);
  	cin.tie(0);
  	int h,w,k;
  	cin>>h>>w>>k;
  	for(int i=0;i<h;i++)cin>>s[i];
  	int ans=0;
  	for(int i=0;i<(1<<h);i++)
  	for(int j=0;j<(1<<w);j++)
  	{
  		int tp=0;
  		for(int a=0;a<h;a++)
  		for(int b=0;b<w;b++)
  		{
  			if(i>>a&1)continue;
  			if(j>>b&1)continue;
  			if(s[a][b]=='#')tp++;
		}
	//	cout<<i<<"  "<<j<<" "<<tp<<endl;
		if(tp==k)ans++;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
struct Fast {
    Fast() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} fast;

long long mod = 1000000007;

long long div(long long a, long long b, long long c) { return b / c - (a - 1) / c; }

void print_binary(long long a) {
    for (int i = 31; i >= 0; i--) {
        cout << (a >> i & 1);
    }
    cout << endl;
}
long long modpow(long long m, long long n) {
    if (n == 0) return 1;
    if (n % 2 == 0) {
        long long t = modpow(m, n / 2);
        return t * t;
    } else {
        return modpow(m, n - 1) * m;
    }
}
void yes() {
    cout << "Yes" << endl;
    exit(0);
}
void no() {
    cout << "No" << endl;
    exit(0);
}
#define REP(i, n) for (long long i = 0; i < (n); i++)
vector<int> h, memo;

// int dp(int n) {
//     if (memo[n] != -1) {
//         return memo[n];
//     }
//     if (n == 0) {
//         return 0;
//     }
//     if (n == 1) {
//         return abs(h[1] - h[0]);
//     }
//     memo[n] = min(dp(n - 1) + abs(h[n] - h[n - 1]), dp(n - 2) + abs(h[n] - h[n - 2]));
//     return min(dp(n - 1) + abs(h[n] - h[n - 1]), dp(n - 2) + abs(h[n] - h[n - 2]));
// }
signed main() {
    long long n, k;
    cin >> n >> k;
    map<int, int> cnt;
    REP(i, k) {
        int d;
        cin >> d;
        REP(i, d) {
            int a;
            cin >> a;
            cnt[a]++;
        }
    }
    int ans = 0;
    REP(i, n) {
        if (cnt[i + 1] == 0) {
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
#define int long long 
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
const int N=200005;
#define inf 1e18+8
const int mod=1e9+7;
#define pii pair<int, int>
#define vi vector<int>
#define sz(x) (int)x.size()
#define set multiset
#define all(x) begin(x), end(x)
#define vpii vector<pair<int,int> > 
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
int A[N],B[N],C[N],D[N];
string s,t,str="";
int len1,len2;
int dp[3001][3001];
//vector <char> str;
int rec(int s1,int t1)
{
    if (dp[s1][t1]!=-1) return dp[s1][t1];
    if(s1==len1 || t1==len2) return 0;
    if(s[s1]==t[t1])
    {
      //  cout<<s[s1];
        //str+=s[s1];
        return dp[s1][t1]=1+rec(s1+1,t1+1);
    }
    return dp[s1][t1]=max(rec(s1+1,t1),rec(s1,t1+1));
}
signed main()
{
    cin>> s>>t;
    for(int i=0;i<3001;i++)
    {
        for(int j=0;j<3001;j++)
        {
            dp[i][j]=-1;
        }
    }
    len1=s.size();
    len2=t.size();
    int y=rec(0,0);
    //cout<<str;
    int i=0,j=0;
    while(i<len1 && j<len2)
    {
        if(s[i]==t[j])
        {
            str+=s[i];
            i++;j++;
        }
        else if (dp[i+1][j]>dp[i][j+1])
        {
            i++;
        }
        else 
        {
            j++;
        }
    }
    cout<<str;
    
 
 
}
 

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

int main(){
	int ans = 0;
	int n;
	cin >> n;
	string s;
	cin >> s;
	int temp = 0;
	rep(i,n){
		if(s[i] == 'D') temp--;
		if(s[i] == 'I') temp++;
		ans = max(ans, temp);
	}
	cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
/*
ID: Nipun Paul
LANG: C++
PROB: God knows
*/

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

int main()
{
	int a, b, c[20][20] = {}, sum1 = 0;
	double sum = 0;
		cin >> a >> b;
	for (int i = 0; i < a; i++)
	{
		for (int j = 0; j < b; j++)
		{
			cin >> c[i][j];
		}
	}
	for (int i = 0; i < a; i++)
	{
		for (int k = i+1; k < a; k++)
		{
			for (int j = 0; j < b; j++)
			{
				sum = sum + pow((c[i][j] - c[k][j]), 2);
			}
			sum = sqrt(sum);
			if ((double)sum - (int)sum ==0)
			{
				sum1++;
			}
			sum = 0;
		}

	}
	cout << sum1 << endl;
	return 0;
}


Measured memory_bytes: 256
use proconio::marker::Chars;
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        n: usize,
        s: Chars,
    }

    let r = s.iter().filter(|c| **c == 'R').count();
    let g = s.iter().filter(|c| **c == 'G').count();
    let b = s.iter().filter(|c| **c == 'B').count();

    let mut ans = r * g * b;

    for i in 0..n {
        for j in i + 1..n {
            let k = 2 * j - i;
            if k < n {
                if s[i] != s[j] && s[i] != s[k] && s[j] != s[k] {
                    ans -= 1;
                }
            }
        }
    }

    println!("{}", ans);
}


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

public class Main
{
    static int N;
    static List<Integer> nlist;
    static int[] dp;

    public static void main(String[] args)
    {
        Scanner sc = new Scanner(System.in);
        N = sc.nextInt();
        nlist = new ArrayList<>();

        //使える数のリストを作り、ソート
        int n9 = 1, n6 = 1;
        while (n9 * 9 <= N)
        {
            n9 *= 9;
            nlist.add(n9);
        }
        while (n6 * 6 <= N)
        {
            n6 *= 6;
            nlist.add(n6);
        }
        nlist.add(1);
        Collections.sort(nlist);

        //dp
        dp = new int[N + 1];
        for (int i = 0; i < N; i++)
        {
            for (int li = 0; li < nlist.size(); li++)
            {
                int v = nlist.get(li);
                if (i + v > N) break;

                if (dp[i + v] == 0) dp[i + v] = dp[i] + 1;
                else dp[i + v] = Math.min(dp[i + v], dp[i] + 1);
            }
        }
        System.out.println(dp[N]);
    }
}



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

int main(int argc, char const *argv[])
{
    int a, b;
    cin >> a >> b;
    double c = 1. * a / b;

    cout << a / b << ' ' << a % b << ' ';
    printf("%.5f\n", c);
    cout << endl;
    
    return 0;
}



Measured memory_bytes: 3244
package main

import "fmt"

func main() {
	var s string
	fmt.Scan(&s)

	n := len(s)
	cnt := n

	for i := 0; i < n && rune(s[i]) != 'A'; i++ {
		cnt--
	}
	for i := n - 1; i >= 0 && rune(s[i]) != 'Z'; i-- {
		cnt--
	}

	fmt.Println(cnt)
}


Measured memory_bytes: 1920
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define MOD 1000000007
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;

typedef pair<int, int> P;
typedef pair<long long, long long> LLP;

int main() {

    string S;
    long long K;
    cin >> S >> K;

    long long i = 0;
    while (i < K && i < S.length()) {
        if (S[i] != '1') {
            cout << S[i] << endl;
            return 0;
        }
        i++;
    }

    cout << '1' << endl;
    
    return 0;
}

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

int main(){
  int H, W, N;cin>>H>>W>>N;
  int r,c;cin>>r>>c;
  string S,T;cin>>S>>T;

  bool ans=true;

  int left_out_lim=0, right_out_lim=W+1;
  int upper_out_lim=0, lower_out_lim=H+1;

  if(S[N-1]=='L') left_out_lim++;
  if(S[N-1]=='R') right_out_lim--;

  for (int i=N-2;i>=0;--i){
    if(T[i]=='R') left_out_lim=max(left_out_lim-1, 0);
    if(T[i]=='L') right_out_lim=min(right_out_lim+1, W+1);

    if(S[i]=='L') left_out_lim++;
    if(S[i]=='R') right_out_lim--; 
    if (left_out_lim>=right_out_lim-1) ans=false;
  }

  if (S[N-1]=='U') upper_out_lim++;
  if(S[N-1]=='D') lower_out_lim--;

  for (int i=N-2;i>=0;--i){
    if(T[i]=='D') upper_out_lim=max(upper_out_lim-1,0);
    if(T[i]=='U') lower_out_lim=min(lower_out_lim+1,H+1);

    if(S[i]=='U') upper_out_lim++;
    if(S[i]=='D') lower_out_lim--;
    if(upper_out_lim>=lower_out_lim-1) ans=false;
  }

  if(left_out_lim>=c|| right_out_lim<=c) ans=false;
  if(upper_out_lim>=r|| lower_out_lim<=r) ans=false;

  if(ans) cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}

Measured memory_bytes: 776
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<memory.h>

using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
  ll n;
  cin >> n;
  ll a[n];
  rep(i,n)cin >> a[i];
  ll sum=0;
  rep(i,n)sum+=a[i];
  ll ans=abs(2*a[0]-sum);
  ll temp=a[0];
  for(int i=1;i<n-1;i++){
    temp+=a[i];
    ans=min(ans,abs(2*temp-sum));
  }
  cout << ans << endl;
return 0;}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define ll long long
#define REP(i, n) for (ll (i) = 0; (i) < (n); (i)++)
#define REPI(i, a, b) for (ll (i) = (a); (i) < (b); (i)++)
#define P pair<ll, ll>
#define VI vector<ll>
#define int long long
using namespace std;

signed main() {
  int N;
  cin >> N;
  int ans = 0;
  REP (i, N) {
    int a;
    cin >> a;
    ans += (a - 1);
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
const input = require('fs').readFileSync('/dev/stdin', 'utf8').split(/\n/);
let x = input[1].split(' ').map(Number);
let y = input[2].split(' ').map(Number);
let p1 = 0;
let p2 = 0;
let p3 = 0;
let inf = 0;
for (let i = 0; i < x.length; i++) {
    p1 += Math.abs(x[i]-y[i]);
    p2 += Math.pow(Math.abs(x[i]-y[i]), 2);
    p3 += Math.pow(Math.abs(x[i]-y[i]), 3);
    if (inf < Math.abs(x[i]-y[i])) {
    inf = Math.abs(x[i]-y[i]);
    }
}
p2 = Math.sqrt(p2);
p3 = Math.cbrt(p3);
console.log(p1.toFixed(6));
console.log(p2.toFixed(6));
console.log(p3.toFixed(6));
console.log(inf.toFixed(6));


Measured memory_bytes: 15368
n = int(input())

num_cnt = [ [0]*9  for _ in range(9)]
for i in range(n):
    num = i+1
    num_s = str(num)
    top = int(num_s[0]) -1
    last = int(num_s[-1]) -1
    if top == -1 or last == -1:
        continue
    num_cnt[top][last] += 1

ans = 0
for x in range(0,9):
    for y in range(0,9):
        ans += num_cnt[x][y] * num_cnt[y][x]
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max() / 32 * 15 + 208;

int main() {
    int n, m;
    while(cin >> n >> m, n|m){
        vector<int> v(n+1);
        for (int i = 0; i < n; ++i) {
            int x;
            scanf("%d", &x);
            v[i+1] = v[i]+x;
        }
        map<int, int> w;
        for (int i = 0; i <= n; ++i) {
            for (int j = i+1; j <= n; ++j) {
                w[v[j]-v[i]]++;
            }
        }
        v.resize(m+1);
        int ans = 0;
        for (int i = 0; i < m; ++i) {
            int x;
            scanf("%d", &x);
            v[i+1] = v[i]+x;
        }
        for (int i = 0; i <= m; ++i) {
            for (int j = i+1; j <= m; ++j) {
                ans += w[v[j]-v[i]];
            }
        }
        cout << ans << "\n";
    }
    return 0;
}


Measured memory_bytes: 20976
using System;
using System.Collections.Generic;
using System.Linq;

namespace test
{
    class MainClass
    {
        public static void Main(string[] args)
        {

            //問題155

            int n = int.Parse(Console.ReadLine());

            string[] line = Console.ReadLine().Split(' ');

            List<int> a = new List<int>();

            for (int i = 0; i < n; i++)
            {
                if (int.Parse(line[i]) % 2 == 0)
                {
                    if (int.Parse(line[i]) % 3 == 0 || int.Parse(line[i]) % 5 == 0)
                    {
                        
                    }
                    else
                    {
                        Console.WriteLine("DENIED");
                        return;
                    }

                          
                }
            }

            Console.WriteLine("APPROVED");
        }

    }





    
}


Measured memory_bytes: 27788
import Data.List
import qualified Data.ByteString.Char8 as C
import Data.Maybe
main = do
  n <- read <$> getLine
  as <- map (fst . fromJust . C.readInt) . C.words <$> C.getLine
  print $ sum $ take (2*n) $ zipWith (*) (cycle [0,1]) (reverse $ sort as)

Measured memory_bytes: 51580
#include <iostream>
#include <vector>
#define inc 1
#define dec -1
#define init 0
 
 
using  namespace std;
 
int main() {
 
    int N;
    cin >> N;
    vector<long long> A(N);
    for (int i = 0; i <N ; ++i) cin >> A[i];
 
    int c = 0;
    long long pa = A[0];
    int j = init;
    int pj = init;
    for (int k = 1; k <N ; ++k) {
        if(pa < A[k]){
            j = inc;
 
        }else if(pa > A[k]){
            j = dec;
        }else{
            pj = j;
            pa = A[k];
            continue;
        }
 
 
        if (j != pj && pj != init){
            c++;
            j = init;
        }
        pa = A[k];
        pj = j;
 
 
    }
 
    cout << ++c;
    return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;
class Main{


	static char[][] map;

	static long[][] c;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);			//文字の入力
		int n = sc.nextInt();
		int d = sc.nextInt();

	
		int ans = 0;
		if(n % (2*d+1) == 0){
			ans = n/(2*d+1);
		}else{
			ans = n/(2*d+1) + 1; 

		}
		System.out.println(ans);



	}
	


	static int gcd(int a,int b){				//最大公約数を返す
		if(b == 0){
			return a;
		}else{
			return gcd(b, a%b);
		}
	}
	static long gcd(long a,long b){
		if(b == 0){
			return a;
		}else{
			return gcd(b, a%b);
		}
	}



	static long lcm (long a, long b) {
		long g = gcd(a,b);
		return a/g*b;
	}




}



class Pair implements Comparable{
	int from;
	int end;
	@Override
	public int compareTo(Object other) {
		Pair otherpair = (Pair)other;

		return   end- otherpair.end;
	}








}






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

using namespace std;

int main() {

    int hp,n,t,s;

    s=0;

    cin>>hp>>n;

    for(int i=0; i<n; i++){

    cin>>t;

      s+=t;

    }

  if(s<hp){cout<<"No";}

  else cout<<"Yes";

  }



Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <iomanip>
#include <iostream>
#include <vector>    
#include <cstdlib>
#include <set>
#include <map>
#include <queue>
#define fast_io()                \
    ios::sync_with_stdio(false); \
    std::cin.tie(0);
#define mod 998244353
typedef long long ll;
typedef long double ld;
using namespace std;

int main()
{
    fast_io();
    string s;
    cin >> s;
    if(s[0]=='7'||s[1]=='7'||s[2]=='7')
        cout << "Yes";
    else
        cout<<"No";

    return 0;
}

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

using ll =  long long;
using pint =  pair<int,int>;
using vint = vector<int>;
using vvint = vector<vint>;
using vpint = vector<pint>;

#define repi(i,start,end) for(int (i)=(start),TemPNuM=(int)(end);(i)<TemPNuM;++(i))
#define rep(i,end) repi((i),0,(end))
#define rfor(x,v) for(auto& (x) : (v))
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define fsort(v,lambda) sort(all((v)),(lambda))
#define vin(v) rep(i,(v).size())cin >> (v)[i];
#define vpin(v) rep(i,(v).size())cin>>v[i].first>>v[i].second
#define int long long
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; }
void put_double(double obj){printf("%.12f\n",obj);};
//lambda: [](int x, int y){return x<y;}

signed main(void){
    int n;cin>>n;
    vint a(n);vin(a);
    vint s(n+1,0);
    rfor(x,a)s[x]++;
    int sum=0;
    repi(i,1,n+1){
        int cnt=s[i];
        sum+=cnt*(cnt-1)/2;
    }
    rep(i,n){
        cout << sum-(s[a[i]]-1) << endl;
    }

    return 0;
}


Measured memory_bytes: 4096
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

/**
 * http://abc042.contest.atcoder.jp/tasks/abc042_b
 * @author Cummin
 */
public class Main {

    public static void main(String[] args) {
        int N, L ;
         // データの読み込み
        Scanner sc = new Scanner(System.in);
        N = sc.nextInt();
        L = sc.nextInt();
        
        List<String> array = new ArrayList<String>();
        for (int i=0 ; i<N; i++) {
            String s ;
            s = sc.next();
            array.add(s) ;
        }
        Collections.sort(array);
        for (String string : array) {
            System.out.printf("%s",string);
        }
    }
}


Measured memory_bytes: 11536
#include<iostream>
#include<vector>
#include<queue>
#include<cstring>
using namespace std;
typedef struct node{
	int cap,to,rev;
}node;
vector<node> path[210];
const int N=101,S=205,T=206;
const int INF=1<<30;
int lev[210];
queue<int> q1;

void add_edge(int a,int b,int n){
	node na;
	na.cap=n,na.to=b,na.rev=path[b].size();
	path[a].push_back(na);
	na.cap=0,na.to=a,na.rev=path[a].size()-1;
	path[b].push_back(na);
}

void add_edge_2(int a,int b){
	node na;
	na.cap=1,na.to=b,na.rev=path[b].size();
	path[a].push_back(na);
	na.cap=1,na.to=a,na.rev=path[a].size()-1;
	path[b].push_back(na);
}

void bfs(){
	int a,b,c;
	int i;
	memset(lev,-1,sizeof(lev));
	q1.push(S);
	lev[S]=0;
	while(!q1.empty()){
		a=q1.front(),q1.pop();
		for(i=0;i<path[a].size();i++){
			if(path[a][i].cap>0 && lev[path[a][i].to]==-1){
				lev[path[a][i].to]=lev[a]+1;
				q1.push(path[a][i].to);
			}
		}
	}
}

int dfs(int s,int t,int f){
	if(s==t)return f;
	node na;
	int d;
	for(int i=0;i<path[s].size();i++){
		na=path[s][i];
		if(na.cap>0 && lev[s]<lev[na.to]){
			d=dfs(na.to,t,min(na.cap,f));
			if(d>0){
				path[s][i].cap-=d;
				path[na.to][na.rev].cap+=d;
				return d;
			}
		}
	}
	return 0;
}

int main(){
	int h,w;
	int i,j,k;
	int a,b,c;
	int s=0;
	int place[2][2];
	char ca[105];
	cin>>h>>w;
	for(i=0;i<h;i++){
		cin>>ca;
		for(j=0;j<w;j++){
			if(ca[j]=='S')add_edge(S,i,INF),add_edge(S,N+j,INF),place[0][0]=i,place[0][1]=j;
			if(ca[j]=='T')add_edge(i,T,INF),add_edge(N+j,T,INF),place[1][0]=i,place[1][1]=j;
			if(ca[j]=='o')add_edge_2(i,N+j);
		}
	}
	if(place[0][0]==place[1][0] || place[0][1]==place[1][1]){
		cout<<-1<<endl;
		return 0;
	}
	while(1){
		bfs();
		if(lev[T]==-1)break;
		while((a=dfs(S,T,INF))>0){
			s+=a;
		}
	}
	cout<<s<<endl;
	return 0;
}


Measured memory_bytes: 512
# 最大公約数
def gcd(a, b):
    while b != 0:
        a, b = b, a % b
    return a
# 最小公倍数
def lcm(a, b):
    return a * b // gcd(a, b)

N = int(input())
ans = 1
for i in range(N):
    t = int(input())
    ans = lcm(ans,t)
print(ans)

Measured memory_bytes: 3060
#数字同士のすき間の個数分、二択（+ or −）が存在し、それらを全探索したい
n = input()
op_cnt = len(n) - 1 #隙間の個数
for i in range(2**op_cnt):
    op = ["-"]*op_cnt #あらかじめ["-","-","-"] というリストを作っておく
    for j in range(op_cnt):
        if((i>>j)&1):
            op[op_cnt -1 -j] = "+" 
    #print(op)
    formula = ""
    for p_n,p_o in zip(n, op+[""]):
        formula += (p_n + p_o)
    if eval(formula) == 7:
        print(formula + "=7")
        break

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define inf (ll)1e9
#define mod (ll)(1e9+7)
#define d(x) cerr<<#x<<"="<<x<<endl;
#define p(x) cout<<(x)<<endl
#define ps(x) cout<<(x);
#define pfix(d,x) cout << fixed << setprecision(d) << x << endl;
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define minel(v) *min_element(all(v))
#define minind(v) distance((v).begin(), min_element(all(v)))
#define maxel(v) *max_element(all(v))
#define maxind(v) distance((v).begin(), max_element(all(v)))
#define fi first
#define se second
ll a,b,c,d,n,m,x,y,z,k,h,w,sum,mi,ma,ans,s,t,l,r,res,tmp,itr,p,q;
bool flag;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
int dx8[8]={1,1,0,-1,-1,-1,0,1},dy8[8]={0,1,1,1,0,-1,-1,-1};
char cha;
string st;
typedef map<int, int> imap;
typedef pair<ll, ll> P;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<pair<ll,ll> > VP;


int main(){
    cin>>n;
    VL v(n);
    rep(i,n)cin>>v[i];
    rep(i,n){
        if(v[i]<0)sum++;
        else if(v[i]==0)flag=1;
    }
    mi=inf;
    rep(i,n)mi=min(mi,abs(v[i]));
    ans=0;
    rep(i,n){
        if(v[i]<0)ans-=v[i];
        else if(v[i]>0)ans+=v[i];
    }
    if(flag||sum%2==0)p(ans);
    else p(ans-2*mi);
    return 0;
}


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

#define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define I insert
#define endl '\n'
#define all(x) x.begin(), x.end()

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
using vvll = vector< vector<ll> >;
using vll = vector<ll> ;
using vb = vector<bool> ;
using pll = pair<ll, ll> ;

const ll maxs = 1e6+5;
const ll lmaxs = 20;
ll mod = 1e9+7;
ll oo = 1e18;


void pre(){



}
 

void solve(){
    
    int N,D,A;
    cin >> N >> D >> A;
    map<int,int> mp;
    set<int> s;
    for(int i=0;i<N;i++){
        int x,h;
        cin >> x >> h;
        int cnt = (h+A-1)/A;
        mp[x] = cnt;
        s.I(x);
        s.I(x + 2*D +1);
    }
    map<int,int> m;
    long long ans=0;
    long long now=0;
    for(auto it : s){
        if(m.count(it)){
            now -= m[it];
        }
        if(mp.count(it)){
            int tmp = max(0ll,mp[it]-now);
            ans += tmp;
            now += tmp;
            m[it + 2*D + 1] = tmp;
        }
    }
    cout << ans;

}

int main(){
    // #ifndef ONLINE_JUDGE
    // freopen("input00.txt","r",stdin);
    // #endif
    IOS;
    pre();
    ll T = 1;
    //cin>>T;
    while(T--){
        solve();   
    }
    return 0;
}

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

using namespace std;
const int maxn = 1e5+10;

int n, m; 
vector<int> graph[maxn];
int dp[maxn];

int rek(int pos) {
	int &ret = dp[pos];
	if (ret != -1) return ret;
	
	ret = 0;
	for (int i = 0; i < graph[pos].size(); i++) {
		int tren = graph[pos][i];
		ret = max(ret, rek(tren) + 1);
	}
	return ret;
}

int main() {
	memset(dp, -1, sizeof dp);
	scanf("%d%d", &n, &m);
	for (int i = 0; i < m; i++) {
		int a, b;
		scanf("%d%d", &a, &b);
		graph[b].push_back(a); 
	}
	
	int maxi = 0;
	for (int i = 1; i <= n; i++) 
		maxi = max(maxi, rek(i));
	
	//for (int i = 1; i <= n; i++) printf("%d ", rek(i)); printf("\n");
	printf("%d", maxi);
	return 0;
}


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

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

        return pow(mod - 2);
    }
    mint &operator/=(const mint a)
    {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const
    {
        mint res(*this);
        return res /= a;
    }
};
struct Sieve
{
    int n;
    vector<int> f, primes;
    Sieve(int n = 1) : n(n), f(n + 1)
    {
        f[0] = f[1] = -1;
        for (ll i = 2; i <= n;i++){
            if(f[i])
                continue;
            primes.push_back(i);
            f[i] = i;
            for (ll j = i*i; j <= n;j+=i){
                if(!f[j]) f[j] = i;
            }
        }
    }
    bool isPrime(int x){
        return f[x] == x;
    }
    vector<int> factorList(int x) {
        vector<int> res;
        while(x!=1){
            res.push_back(f[x]);
            x /= f[x];
        }
        return res;
    }
    vector<pair<int,int>> factor(int x){
        vector<int> fl = factorList(x);
        if(fl.size() == 0)
            return {};
        vector<pair<int, int>> res(1,pair<int,int>(fl[0],0));
        for(int p:fl){
            if(res.back().first == p) {
                res.back().second++;
            }else {
                res.emplace_back(p, 1);
            }
        }
        return res;
    }
};
int main()
{
    Sieve sieve(1e6);
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];

    map<int, int> mp;
    rep(i,n){
        auto f = sieve.factor(a[i]);
        for (auto p:f){
            mp[p.first] = max(mp[p.first], p.second);
        }
    }
    mint lcm = 1;
    for(auto p:mp){
        rep(i,p.second){
            lcm *= p.first;
        }
    }
    mint ans;
    rep(i,n){
        mint b = lcm / a[i];
        ans += b;
    }
    cout << ans.x << endl;
    return 0;
}

Measured memory_bytes: 4984
#include <iostream>
#include <bits/stdc++.h>
 
using namespace std;
 
 
int main() {
     
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); 
    
    int a,b,c;
    scanf("%d%d%d",&a,&b,&c);
    if((b-a)==(c-b))
        printf("YES");
  
    else
       printf("NO");
 
    
	return 0;
}

Measured memory_bytes: 256
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列
using namespace std;

typedef long long ll;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000 //10^12
#define MOD 10000007 //10^9+7
#define MAXR 100000 //10^5:最大のrange(素数列挙などで使用)

int main(void){
    string s;
    cin >> s;
    int a[26] = {0};
    REP(i, s.size()) a[s[i]-'a']++;
    REP(i, 26) {
        if(a[i] > 1) {
            cout << "no" << endl;
            return 0;
        }
    }
    cout << "yes" << endl;
    return 0;
}

Measured memory_bytes: 256