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

//long long
using ll = long long;

// pair<int, int>
using PII = pair<int, int>;

//最大値、mod
const int MOD = 1000000007;
const int INF = 1000000000;
const long long LINF = 1e18;

//出力系
#define print(x) cout << x << endl
#define prints(x) cout << fixed << setprecision(10) << x << endl
#define printc(x) cout << setw(2) << setfill('0') << x << endl;
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
 
// begin() end()
#define all(x) (x).begin(),(x).end()

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

//最大公約数 
unsigned gcd(unsigned a, unsigned b) {
  if(a < b) return gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

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

// a = max(a, b), a = min(a, b)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

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

int main(){
    int N, K;
    cin >> N >> K;
    vector<int>A(N);
    int ma = -1;
    int g;
    REP(i, N) {
        cin >> A.at(i);
        chmax(ma, A.at(i));
        if(i == 0) g = A.at(i);
        else g = gcd(g, A.at(i));
    }
    if(K > ma){
        print("IMPOSSIBLE");
        return 0;
    }
    if(K % g == 0){
        print("POSSIBLE");
        return 0;
    }

    print("IMPOSSIBLE");
    return 0;

}

Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<sstream>
using namespace std;
 
class Stack{
private:
  int sp;
  int S[100];
public:
  Stack(){
    sp=0;
  }
  bool isFull(){
    return (sp==100);
  }
  bool isEmpty(){
    return (sp==0);
  }
  void push(int d){
    if(isFull()){
      return;
    }
    S[sp++] = d;
  }
  void pop(){
    if(isEmpty()){
      return;
    }
    sp--;
  }
  int top(){
    if(isEmpty()){
      return -1;
    }
    return S[sp-1];
  }
};
 
int main(){
  Stack s;
  string expr;
  getline(cin, expr);
 
  istringstream is(expr);
 
  while(!is.eof()){
    string op;
    is >> op;
 
    int tmp1,tmp2;
 
    switch(op[0]){
      case'+':
        tmp1 = s.top();
        s.pop();
        tmp2 = s.top();
        s.pop();
        s.push(tmp2+tmp1);
        break;
      case'-':
        tmp1 = s.top();
        s.pop();
        tmp2 = s.top();
        s.pop();
        s.push(tmp2-tmp1);
        break;
      case'*':
        tmp1 = s.top();
        s.pop();
        tmp2 = s.top();
        s.pop();
        s.push(tmp2*tmp1);
        break;
      default:
        istringstream is2(op);
        is2 >> tmp1;
        s.push(tmp1);
        break;
    }
  }
  cout << s.top() << endl;
 
  return 0;
}


Measured memory_bytes: 3200
#include <bits/stdc++.h>
using namespace std;
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return 1;
    }
    return 0;
}
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define LLINF (1e18)
#define PI (acos(-1))
#define MOD (1000000007)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------

struct WeightedUnionFind
{
    vector<int> par;
    vector<int> rank;
    vector<int> diff_weight;

    WeightedUnionFind(int n = 1, int s = 0)
    {
        init(n, s);
    }

    //初期化
    void init(int n = 1, int s = 0)
    {
        par.resize(n);
        rank.resize(n);
        diff_weight.resize(n);
        for (int i = 0; i < n; i++)
        {
            par[i] = i;
            rank[i] = 0;
            diff_weight[i] = s;
        }
    }

    // xの親を再帰処理により求める
    int root(int x)
    {
        if (par[x] == x)
        {
            return x;
        }
        else
        {
            int r = root(par[x]);
            diff_weight[x] += diff_weight[par[x]]; //累積和
            return par[x] = r;
        }
    }

    // ノードxの重み
    int weight(int x)
    {
        root(x);
        return diff_weight[x];
    }

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

    // weight(y)-weight(x)
    int diff(int x, int y)
    {
        return weight(y) - weight(x);
    }

    // weight(y)-weight(x) = wになるようにmergeする
    bool merge(int x, int y, int w)
    {
        w += weight(x);
        w -= weight(y);
        x = root(x);
        y = root(y);
        // すでに繋がっていればfalseを返す
        if (x == y)
        {
            return false;
        }
        // rank[x] >= rank[y]になるようにする
        if (rank[x] < rank[y])
        {
            swap(x, y);
            w = -w;
        }
        // yをxの下にmerge
        if (rank[x] == rank[y])
        {
            rank[x]++;
        }
        par[y] = x;
        // xがyの親になるので、差分をdiff_weightに記録
        diff_weight[y] = w;
        return true;
    }
};

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    WeightedUnionFind wuf(n);
    bool flg = true;
    for (int i = 0; i < m; i++)
    {
        int l, r, d;
        cin >> l >> r >> d;
        l--;
        r--;
        if (wuf.issame(l, r))
        {
            int diff = wuf.diff(l, r);
            if (diff != d)
            {
                flg = false;
            }
        }
        else
        {
            wuf.merge(l, r, d);
        }
    }
    cout << (flg ? "Yes" : "No") << endl;
}

Measured memory_bytes: 1408
//#define _GLIBCXX_DEBUG

#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const int INF= 1e9+5;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll> >vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const ll MOD=1000000007LL;
int main(){
  ll n;
  cin>>n;
  vl a(n);
  map<ll,ll>M;
  rep(i,n)cin>>a[i];
  rep(i,n)M[a[i]]++;
  ll count=0;
  for(auto p:M){
    //cout<<p.first<<p.second<<endl;
    if(p.second%2!=0)count++;
  }
  cout<<count<<endl;
}
  

Measured memory_bytes: 7296
/**
*
* Author: Mouhanad
* Lang: GNU C++14
*
**/
#include<bits/stdc++.h>
using namespace std;

#define F first
#define S second
#define ii pair < int , int >
#define LS pair < ll , string >
typedef long long ll;
const int inf = 1<<30;
const int N =100100;
int n , a[N] , k ;

int main ( ){
  scanf("%d %d",&n ,&k);
  for  (int i = 0 ; i < n ;  i++ ) scanf("%d",a+i);
  int  mn = inf ;
  for ( int i = 0 ; i < n; i++ ){
     int st = a[i], ed = -1 ;
     if ( i+k-1 >= n ) break ;
     ed = a[i+k-1];
     int dst = ed-st ;
     dst += min ( abs(ed) , abs(st));
    mn = min ( mn , dst);
  }
  printf("%d",mn);
return 0 ;
}


Measured memory_bytes: 640
N, K = map(int,input().split())
a = []
b = []
for i in range(N) :
    p, q = map(int,input().split())
    a.append(p)
    b.append(q)

c = [0 for _ in range(10**5+1)]

for i in range(N) :
    c[a[i]] += b[i]

temp = 0
for i in range(10**5+1) :
    temp += c[i]
    if temp >= K :
        print(i)
        break


Measured memory_bytes: 13812
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
using namespace std;

int main (){
  int k, x;
  cin >> k >> x;
  if (k * 500 >= x) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    static ArrayList<ArrayList<Integer>> edge;
    static long[] dist_0;
    static long[] dist_N;
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        dist_0 = new long[N];
        dist_N = new long[N];
        Arrays.fill(dist_0, -1);
        Arrays.fill(dist_N, -1);
        edge = new ArrayList<ArrayList<Integer>>();
        for (int i=0;i<N;i++) {
            ArrayList<Integer> add = new ArrayList<Integer>();
            edge.add(add);
        }
        for (int i=0;i<N-1;i++) {
            int a = Integer.parseInt(sc.next())-1;
            int b = Integer.parseInt(sc.next())-1;
            edge.get(a).add(b);
            edge.get(b).add(a);
        }

        dfs(0, dist_0, 0);
        dfs(N-1, dist_N, 0);
        int Fennec = 0;
        int snuke = 0;
        for (int i=0;i<N;i++) {
            if (dist_0[i]<=dist_N[i]) {
                Fennec++;
            } else {
                snuke++;
            }
        }

        if (Fennec>snuke) {
            System.out.println("Fennec");
        } else {
            System.out.println("Snuke");
        }
    }

    static void dfs(int s, long[] dist, int depth) {
        dist[s]=depth;
        for (Integer i :  edge.get(s)) {
            if (dist[i]!=-1) continue;
            dfs(i, dist, depth+1);
        }
    }
}

Measured memory_bytes: 91128
using System;
using static System.Console;
using System.Collections.Generic;
using System.Collections;

namespace Grobal
{
	class Program
	{
		static void Main(string[] args)
		{
			string o = ReadLine();
			string e = ReadLine();
			string s = "";

			for(int i = 0;i < o.Length * 2;i++)
			{
				try
				{
					s += o[i];
					s += e[i];
				}
				catch
				{
					break;
				}
			}
			WriteLine(s);
		}
    }
}


Measured memory_bytes: 11092
#include<string>
#include<iostream>
#include<cctype>
using namespace std;

int main(){
  int a = 0; //a??????????????????????????????
  string str1, str2;
  cin >> str2;

  while (1) {
    cin >> str1;
    if (str1 == "END_OF_TEXT") break;
    for (int i = 0; i < str1.size(); i++) str1[i] = tolower(str1[i]);
    if (str1 == str2) a++;

  }

  cout << a << endl;

return 0;
}

Measured memory_bytes: 3176
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();

		//解いたことがあるかカウンター
		int[] ac = new int[N];
		//ACしたならばWAを数えてもよい退避場所
		int[] wa = new int[N];

		//答えカウンター
		int ok = 0;
		int ng = 0;

		for (int i = 0; i < M; i++) {
			//問題番号は配列のキーにあたる
			int indx = sc.nextInt();
			String acWa = sc.next();

			if (acWa.equals("AC")) {
				if (ac[indx - 1] == 1) {

				} else {
					ok++;
					ac[indx - 1] = 1;
				}
			} else {
				if (ac[indx - 1] == 1) {

				} else {
					wa[indx - 1]++;
				}
			}
		}
		//ACしたならばWAを数えてもよい
		for (int i = 0; i < N; i++) {
			if (ac[i] == 1) {
				ng = ng + wa[i];
			} else {
			}
		}

		System.out.println(ok + " " + ng);
	}
}


Measured memory_bytes: 63824
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);

    String s = sc.next();
    int ans = 0;
    int index = 0;
    String lstr = "";

    while (index < s.length()) {
      String rstr = "";
      while (index < s.length()) {
        rstr += s.charAt(index);
        index++;
        if (!lstr.equals(rstr)) {
          break;
        }
      }
      if (!lstr.equals(rstr)) {
        ans++;
      }
      lstr = rstr;
    }

    System.out.println(ans);

  }
}

Measured memory_bytes: 53412
#include <iostream>

using namespace std;

int main()
{
    int N;
    cin >> N;
    for (int i = 0; i <= (int)(N / 4); i++)
    {
        for (int j = 0; j <= (int)(N / 7); j++)
        {
            if ((i * 4 + j * 7) == N)
            {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000

int cnt[100];
int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    int ans = 0;
    if (N <= 9) {
        cout << N << endl;
        return 0;
    }
    REP(i, 1, 9) {
        REP(j, 1, 9) {
            stringstream ss;
            ss << i;
            ss << j;
            string R = ss.str();
            int num = atoll(R.c_str());
            if (i == j) cnt[num]++;
            REP(a, 0, 9) {
                REP(b, 0, 9) {
                    REP(c, 0, 9) {
                        REP(d, 0, 9) {
                            stringstream s;
                            s << i;
                            s << a;
                            s << b;
                            s << c;
                            s << d;
                            s << j;
                            string T = s.str();
                            if(atoll(T.c_str()) <=N)cnt[num]++;
                        }
                        stringstream s;
                        s << i;
                        s << a;
                        s << b;
                        s << c;
                        s << j;
                        string T = s.str();
                        if(atoll(T.c_str()) <=N)cnt[num]++;
                    }          
                    stringstream s;
                    s << i;
                    s << a;
                    s << b;
                    s << j;
                    string T = s.str();
                     if(atoll(T.c_str()) <=N)cnt[num]++;
                }
                stringstream s;
                s << i;
                s << a;
                s << j;
                string T = s.str();
                 if(atoll(T.c_str()) <=N)cnt[num]++;
            }
            stringstream s;
            s << i;
            s << j;
            string T = s.str();
            if(atoll(T.c_str()) <=N)cnt[num]++;
            //cout << i << j << " " << cnt << endl;
        }
    }
    REP(i, 1, 9) {
        REP(j, 1, 9) {
            stringstream s1;
            stringstream s2;
            s1 << i << j;
            s2 << j << i;
            ans += cnt[atoll(s1.str().c_str())] * cnt[atoll(s2.str().c_str())];
        }
    }
    cout << ans << endl;

    return 0;
}


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

using namespace std;

#define REP(i,n) for(int (i)=(0);(i)<(n);++i)
#define ll long long
#define INF 1000000000

int dp[100010];

int main()
{
	int n,a;
	cin >> n;

	int high[n+1];

	REP(i,n){
		cin >> a;
		high[i] = a;
	}

	dp[0]=0; dp[1]=abs(high[1]-high[0]);

	for(int i=2;i<n;++i){
		dp[i] = min(dp[i-2]+abs(high[i]-high[i-2]),dp[i-1]+abs(high[i]-high[i-1]));
	}

	cout << dp[n-1] << endl;

	return 0;
}

Measured memory_bytes: 1024
#include <cstdio>
#include <iostream>
#include <queue>
#include <string>
#include <algorithm>
#include <vector>
#include <utility>

using namespace std;
int main(){
    long int n,m;
    cin >> n >>m;
    priority_queue<int,vector<int>,greater<int>> a;
    vector<long long unsigned int> ret;
    int ai,i;
    for(i=0;i<m;i++){
        cin>>ai;
        a.push(ai);
    }
    int danger;
       if(!a.empty()){
   //     cout<<"ok"<<endl;
            danger=a.top();
 //       cout<<"ok"<<endl;
            a.pop();
        }else{
            danger=-1;
        }      

    for(i=0;i<n+1;i++){
 //       cout<<"ok"<<i<<endl;
        if(i==danger){
            ret.push_back(0);
       if(!a.empty()){
   //     cout<<"ok"<<endl;
            danger=a.top();
 //       cout<<"ok"<<endl;
            a.pop();
        }else{
            danger=-1;
        }      

        }else{
            if(i==0){
                ret.push_back(1);
            }else if(i==1){
                ret.push_back(1);
            }else{
                ret.push_back((ret[i-1]+ret[i-2])%1000000007);
            }
        }
    }

    cout<< (ret[n]%1000000007)<<endl;
    return 0;
}

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

int main(){
	
	long long int n , id , price , num, cnt;
	while(cin >> n , n!=0){
		vector<long long int> p(4001,0);
		vector<int> a;
		while(n--){
			cin>>id>>price>>num;
			if(find(a.begin(),a.end(),id)==a.end()) a.push_back(id);
			p[id]+=price*num;
			}
		cnt=0;	
		for(int i=0;i<a.size();i++){
			if(p[a[i]]>=1000000){
				cout << a[i] << endl; 
				cnt++;
			} 
		}
		if (cnt==0) cout << "NA" << endl;
	}
	return 0;
}

Measured memory_bytes: 1256
W,H,x,y = map(int,input().split())

center_x,center_y = W/2 , H/2

s = W*H / 2

if (center_x == x and center_y == y) or (center_y == x and center_x == y):
    print("{} {}".format(s,1))
else:
    print("{} {}".format(s,0))

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

long long int distance(long long int , long long int);
int main()
{
	long long int n, d, k, count=0 ;
	cin>>n>>d;
	long long int x[n], y[n];
	for(int i=0; i<n; i++)
	{
		cin>>x[i]>>y[i];
		k=distance(x[i], y[i]);
		if(k<=(d*d))
		{
			count++;
		}
	}
	cout<<count;
	return 0;
}
long long int distance(long long int x, long long int y)
{
	long long int result;
	result=((x*x)+(y*y));
	return result;
}


Measured memory_bytes: 6744
#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>
using namespace std;

int h[300010], w[300010];

int main() {
	int H, W, M;
	cin >> H >> W >> M;
	vector<pair<int, int>> hcnt(H), wcnt(W), m(M);
	for(int i=0; i<H; ++i) hcnt[i]=make_pair(0, i);
	for(int i=0; i<W; ++i) wcnt[i]=make_pair(0, i);
	for(int i=0; i<M; ++i){
	    cin >> h[i] >> w[i];
	    --h[i], --w[i];
	    m[i]=make_pair(h[i], w[i]);
	    ++hcnt[h[i]].first;
	    ++wcnt[w[i]].first;
	}
	sort(hcnt.begin(), hcnt.end(), greater<>());
	sort(wcnt.begin(), wcnt.end(), greater<>());
	sort(m.begin(), m.end());
	int ha=1, wa=1;
	while(ha!=H){
	    if(hcnt[ha-1].first>hcnt[ha].first) break;
	    ++ha;
	}
	while(wa!=W){
	    if(wcnt[wa-1].first>wcnt[wa].first) break;
	    ++wa;
	}
	if(M/ha<wa){
	    cout << hcnt[0].first+wcnt[0].first << endl;
	    return 0;
	}
	for(int i=0; i<ha; ++i){
	    for(int j=0; j<wa; ++j){
	        if(!binary_search(m.begin(), m.end(), make_pair(hcnt[i].second, wcnt[j].second))){
	            cout << hcnt[0].first+wcnt[0].first << endl;
	            return 0;
	        }
	    }
	}
	cout << hcnt[0].first+wcnt[0].first-1 << endl;
	return 0;
}


Measured memory_bytes: 12740
N = int(input())
S = list(str(input()))

ans = 0
for j in range(1, N-1):
    left_S = S[0:j]
    right_S = S[j+1:N]
    temp_left = [0, 0, 0]
    temp_right = [0, 0, 0]
    for i in range(len(left_S)):
        if left_S[i] == 'G':
            temp_left[0] += 1
        elif left_S[i] == 'B':
            temp_left[1] += 1
        else:
            temp_left[2] += 1
    for i in range(len(right_S)):        
        if right_S[i] == 'G':
            temp_right[0] += 1
        elif right_S[i] == 'B':
            temp_right[1] += 1
        else:
            temp_right[2] += 1
    if S[j] == 'G':
        ans += temp_left[1] * temp_right[2]
        ans += temp_left[2] * temp_right[1]
    elif S[j] == 'B':
        ans += temp_left[0] * temp_right[2]
        ans += temp_left[2] * temp_right[0]
    else:
        ans += temp_left[0] * temp_right[1]
        ans += temp_left[1] * temp_right[0]

for j in range(1, N-1):
    for i in range(1, min(len(S[0:j+1]), len(S[j:N]))):
        if S[j-i] != S[j] and S[j] != S[j+i] and S[j-i] != S[j+i]:
            ans -= 1
print(ans)

Measured memory_bytes: 75192
#include <iostream>
using namespace std;
#include <bits/stdc++.h>
#define speed  ios_base::sync_with_stdio(0);cin.tie(0) ; cout.tie(0);   
#define ll long long
#define pb push_back
#define endl "\n"
#define ff first
#define ss second
#define mod 1000000007
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppl;
typedef map<ll, ll> mpll;
typedef map<vector<ll>, ll> mpvl;
int main()
{
  speed;
  ll t;
 

 t=1;
  while(t--)
  {  
    ll n,k;
    cin>>n>>k;
    ll arr[n];
    for(ll i=0;i<n;i++)
    {
      cin>>arr[i];
    }
    
    map<ll,ll>mp;
    vector<ll>v;
    ll i=0;
    mp[1]++;
    v.pb(1);
    while(true)
    {
       v.pb(arr[i]);
      
      if(mp[arr[i]]!=0)
      {  
        break;
      }
      mp[arr[i]]++;
      i=arr[i]-1;
      

    }
    
    auto it=v.end();
    it--;
    ll ff=(*it);
    ll tk,st;
    vector<ll>cy;
    for(ll i=0;i<v.size();i++)
    {
      if(v[i]==ff)
      {
        tk=(v.size()-1)-i;
        st=i;
        break;
      }
    }
    if(k<=st)
    {
      cout<<v[k];
      return 0;
    }

   
    for(ll i=st;i<v.size()-1;i++)
    {
      cy.pb(v[i]);
    }
    
    ll md=(k-st)%(tk);
   
    if(md==0)
    cout<<cy[0]<<endl;
    else
    {
      cout<<cy[md]<<endl;
    }
    







    
  



    
  }
}

Measured memory_bytes: 19072
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = (int)(a); i <= (int)(n); ++i)
#define rrep(i, a, n) for (int i = (int)(a); i >= (int)(n); --i)
#define debug(x) cerr << #x << " = " << x << "\n"
#define debugv(x) \
  rep(f, 0, (x.size() - 1)) cerr << x[f] << (f == (x.size() - 1) ? "\n" : " ")
#define debug2(x, y)                       \
  cerr << "(" << #x << "," << #y << ") = " \
       << "(" << x << "," << y << ")\n"
#define all(x) x.begin(), x.end()
#define int long long
using namespace std;
typedef pair<int, int> pii;
typedef vector<int> vi;
const int MX = 1e5 + 5, INF = 5 << 28, MOD = 1e9 + 7;

int N, M;
string S;
vi va, vb;

void input() {
  cin >> N;
  va.resize(N);
  rep(i, 0, N - 1) { cin >> va[i]; };
  ;
}
int dp[MX][2];  // dp[i][j]:
                // va[0]~va[i]まで，jはひっくり返したかどうかのフラグでの最大値
void solve() {
  // 各iはたかだか1回
  int asum = 0;
  for (auto x : va) {
    asum += x;
  }

  dp[0][0] = 0;
  dp[0][1] = -INF;
  rep(i, 0, N - 1) {
    dp[i + 1][0] = max(dp[i][0] + va[i], dp[i][1] - va[i]);
    dp[i + 1][1] = max(dp[i][0] - va[i], dp[i][1] + va[i]);
  }
  cout << dp[N][0] << endl;

  ;
  ;
}
signed main() {
  input();
  solve();
  return 0;
}

Measured memory_bytes: 2560
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>
#include <cstring>
#include <cassert>


using namespace std;
#define SZ(x) (int)(x.size())
#define REP(i, n) for(int i=0;i<n;++i)
#define FOR(i, a, b) for(int i=a;i<b;++i)
#define RREP(i, n) for(int i=n-1;i>=0;--i)
#define RFOR(i, a, b) for(int i=b-1;i>=a;--i)

#define all(x) begin(x),end(x)
#define dump(x) cerr<<#x<<" = "<<(x)<<endl
#define debug(x) cerr<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<< endl;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<int, int>;
const double eps = 1e-8;
const ll MOD = 1000000007;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;

template<class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}


template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> p) {
    os << p.first << ":" << p.second;
    return os;
}

template<class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
    os << "[";
    REP(i, SZ(v)) {
        if (i) os << ", ";
        os << v[i];
    }
    return os << "]";
}

template<class T1, class T2>
ostream &operator<<(ostream &os, const map<T1, T2> &mp) {
    os << "[";
    for (auto it = mp.begin(); it != mp.end(); ++it) {
        if (it != mp.begin()) {
            os << ", ";
        }
        os << *it;
    }
    return os << "]";
}

// edit

void solve() {
    int N, X, T;
    cin >> N >> X >> T;

    int cnt = (N + X - 1) / X;
    int ans = cnt * T;

    cout << ans << endl;

}


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
//    std::ifstream in("input.txt");
//    std::cin.rdbuf(in.rdbuf());

    solve();


    return 0;
}


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

int main()
{
	long long x;
	cin >> x;

	long long times = x / 11;
	long long a = x % 11;

	long long add = 0;
	if (a){
		add = 1;
		if (a > 6){
			add = 2;
		}
	}
	cout << times*2+add;


	return 0;
}

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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);--i)
#define RREP(i,n) RFOR(i,n,0)

const double EPS = 1e-9;
const double PI  = acos(-1.0);
const int INT_INF = 2147483647;
const long long LL_INF = 1LL<<60;
const long long MOD = 1000000007;

#define CLR(a) memset((a), 0 ,sizeof(a))

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

template<typename T>
struct SegmentTree {
	typedef function<T(T,T)> F;
    typedef function<T(T,T)> G;
    int n;
    F f;
    G g;
    T d1, d0;

    vector<T> val;

    SegmentTree(vector<T> a, F f_, G g_, T d1_, T d0_):
        f(f_), g(g_), d1(d1_), d0(d0_){
            int sz = a.size();
            n = 1;

            while (n < sz) n <<= 1;
            val.resize(2 * n - 1, d1);
            for (int i = 0; i < sz; i++) val[i + n - 1] = a[i];
            for (int i = n - 2; i >= 0; i--) val[i] = f(val[i * 2 + 1], val[i * 2 + 2]);
        }
    
        SegmentTree() {}

        void update(int pos, T v) {
            int k = pos + n - 1;
            val[k] = g(val[k], v);
            while (k > 0) {
                k = (k - 1) / 2;
                val[k] = f(val[k * 2 + 1], val[k * 2 + 2]);
            }
        }

        T get(int pos) {
            int k = pos + n - 1;
            return val[k];
        }

        T query(int a, int b, int k = 0, int l = 0, int r = -1) {
            if (r < 0) r = n;
            if (r <= a || b <= l) return d1;
            if (a <= l && r <= b) return val[k];
            T lv = query(a, b, k * 2 + 1, l, (l + r) / 2);
            T rv = query(a, b, k * 2 + 2, (l + r) / 2, r);
            return f(lv, rv);
        }
};

int main(void){
    int n,q; cin >> n >> q;
    VI a(n,0);
    auto f = [](int a, int b){return a+b;};
    auto g = [](int a, int b){return a+b;};
    SegmentTree<int> st(a, f, g, 0, 0);
    REP(i,q){
        int c,x,y; cin >> c >> x >> y;
        if(c == 0){
            x--;
            st.update(x, y);
        }
        else{
            x--; y--;
            cout << st.query(x, y+1) << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 4748
# coding: utf-8
# Your code here!
import math

def main():
    number_of_digit = int(input())
    
    result = 0
    for first in range(1,number_of_digit+1):
        for second in range(1,number_of_digit+1):
            first_gcd = math.gcd(first,second)
            if first_gcd == 1:
                result += number_of_digit
            else:
                for third in range(1,number_of_digit+1):
                    second_gcd = math.gcd(first_gcd,third)
                    result += second_gcd
    print(result)
            
if __name__ == "__main__":
    main()

Measured memory_bytes: 9136
import java.util.*;
import java.util.Arrays;
public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long[] a = new long[n];
        for(int i = 0; i < n; i++){
            a[i] = sc.nextLong();
        }
        long[] b = new long[n];
        for(int i = 0; i < n; i++){
            b[i] = a[i] - (i+1);
        }
        Arrays.sort(b);
        long B = b[n/2];
        long ans = 0;
        for(int i = 0; i < n; i++){
            ans += Math.abs(B - b[i]);
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 85264
#include <stdio.h>

int main()
{
  int N,K,h,ans=0;
  scanf("%d %d",&N,&K);
  for (int i=0; i<N; i++) {
    scanf("%d",&h);
	if (h>=K) ans++;
  }
  printf("%d\n",ans);
  return 0;
}

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

using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using ll = long long int;
using vll = vector<ll>; using vvll = vector<vll>; using vvvll = vector<vvll>;
using vd = vector<double>; using vvd = vector<vd>; using vvvd = vector<vvd>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using cdouble = complex<double>;

const double eps = 1e-7;
#define Loop(i, n) for(int i = 0; i < int(n); i++)
#define Loopll(i, n) for(ll i = 0; i < ll(n); i++)
#define Loop1(i, n) for(int i = 1; i <= int(n); i++)
#define Loopll1(i, n) for(ll i = 1; i <= ll(n); i++)
#define Loopr(i, n) for(int i = int(n) - 1; i >= 0; i--)
#define Looprll(i, n) for(ll i = ll(n) - 1; i >= 0; i--)
#define Loopr1(i, n) for(int i = int(n); i >= 1; i--)
#define Looprll1(i, n) for(ll i = ll(n); i >= 1; i--)
#define Foreach(buf, container) for(auto buf : container)
#define Loopdiag(i, j, h, w, sum) for(int i = ((sum) >= (h) ? (h) - 1 : (sum)), j = (sum) - i; i >= 0 && j < (w); i--, j++)
#define Loopdiagr(i, j, h, w, sum) for(int j = ((sum) >= (w) ? (w) - 1 : (sum)), i = (sum) - j; j >= 0 && i < (h); j--, i++)
#define Loopdiagsym(i, j, h, w, gap) for (int i = ((gap) >= 0 ? (gap) : 0), j = i - (gap); i < (h) && j < (w); i++, j++)
#define Loopdiagsymr(i, j, h, w, gap) for (int i = ((gap) > (h) - (w) - 1 ? (h) - 1 : (w) - 1 + (gap)), j = i - (gap); i >= 0 && j >= 0; i--, j--)
#define Loopitr(itr, container) for(auto itr = container.begin(); itr != container.end(); itr++)
#define printv(vector) Loop(ex_i, vector.size()) { cout << vector[ex_i] << " "; } cout << endl;
#define printmx(matrix) Loop(ex_i, matrix.size()) { Loop(ex_j, matrix[ex_i].size()) { cout << matrix[ex_i][ex_j] << " "; } cout << endl; }
#define quickio() ios::sync_with_stdio(false); cin.tie(0);
#define bitmanip(m,val) static_cast<bitset<(int)m>>(val)
#define Comp(type_t) bool operator<(const type_t &another) const
#define fst first
#define snd second
#define INF INFINITY
bool feq(double x, double y) { return abs(x - y) <= eps; }
bool inrange(ll x, ll t) { return x >= 0 && x < t; }
bool inrange(vll xs, ll t) { Foreach(x, xs) if (!(x >= 0 && x < t)) return false; return true; }
int ceillog2(ll x) { int ret = 0;	x--; while (x > 0) { ret++; x >>= 1; } return ret; }
ll rndf(double x) { return (ll)(x + (x >= 0 ? 0.5 : -0.5)); }
ll floorsqrt(ll x) { ll m = (ll)sqrt((double)x); return m + (m * m <= x ? 0 : -1); }
ll ceilsqrt(ll x) { ll m = (ll)sqrt((double)x); return m + (x <= m * m ? 0 : 1); }
ll rnddiv(ll a, ll b) { return (a / b + (a % b * 2 >= b ? 1 : 0)); }
ll ceildiv(ll a, ll b) { return (a / b + (a % b == 0 ? 0 : 1)); }
ll gcd(ll m, ll n) { if (n == 0) return m; else return gcd(n, m % n); }
ll lcm(ll m, ll n) { return m * n / gcd(m, n); }

/*******************************************************/

int main() {
	ll r; cin >> r;
	cout << 3 * r * r << endl;
}

Measured memory_bytes: 256
#define _DEBUG
#include "bits/stdc++.h"
#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0,a1,a2,a3,a4,x,...) x
#define debug_1(x1) cout<<#x1<<": "<<x1<<endl
#define debug_2(x1,x2) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<endl
#define debug_3(x1,x2,x3) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<endl
#define debug_4(x1,x2,x3,x4) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<", "#x4<<": "<<x4<<endl
#define debug_5(x1,x2,x3,x4,x5) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<", "#x4<<": "<<x4<<", "#x5<<": "<<x5<<endl
#ifdef _DEBUG
#define debug(...) CHOOSE((__VA_ARGS__,debug_5,debug_4,debug_3,debug_2,debug_1,~))(__VA_ARGS__)
#else
#define debug(...)
#endif
#define rep(index,num) for(int index=0;index<(int)num;index++)
#define rep1(index,num) for(int index=1;index<=(int)num;index++)
#define brep(index,num) for(int index=(int)num-1;index>=0;index--)
#define brep1(index,num) for(int index=(int)num;index>0;index--)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef long long ll;
typedef long double ld;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=(ll)1e+18+1;
int INF=1e+9+1;
bool dp[1000002];
int cnt[1000002];
int main(){
	int N;
	int A[200001];
    vint As;
	int ans=0;
	scan(N);
	rep(i,N){
		scan(A[i]);
		cnt[A[i]]++;
	}
    rep(i,1000001) if(cnt[i]>0) As.push_back(i);
    sort(ALL(As));
    fill(dp,dp+1000001,1);
	for(auto a:As){
        if(dp[a]==1&&cnt[a]==1) ans++;
        for(int k=1;a*k<=1000000;k++){
            dp[a*k]=0;
        }
	}
	prin(ans);
	return 0;
}


Measured memory_bytes: 9576
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll ans;
int main() {
    int N, M; cin >> N >> M;
    priority_queue<int> Q;
    for(int i = 0; i < N; i++) {
        int X; cin >> X;
        Q.push(X);
    }

    for(int i = 0; i < M; i++) {
        int T = Q.top();
        Q.pop();
        T /= 2;
        Q.push(T);
    }

    for(int i = 0; i < N; i++) {
        ans += Q.top();
        Q.pop();
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 892
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/*
 * AtCoder Beginner Contest 103 C "Modulo Summation"
 *   https://abc103.contest.atcoder.jp/tasks/abc103_c/
 */
public class Main {

	public static void main(String[] args) {

		InputScanner in = new InputScanner(System.in);
		PrintWriter out = new PrintWriter(System.out);

		int N = in.nextInt();
		long[] a = in.nextLongArray(N);

		long ans = 0;
		for (int i = 0; i < a.length; i++) {
			ans += a[i] - 1;
		}

		out.println(ans);

		in.close();
		out.close();
	}

	/*
	 * extends java.util.Scanner
	 */
	static class InputScanner {

		Scanner scanner;

		public InputScanner(InputStream inputStream) {
			this.scanner = new Scanner(inputStream);
		}

		public int nextInt() {
			return scanner.nextInt();
		}

		public long nextLong() {
			return scanner.nextLong();
		}

		public double nextDouble() {
			return scanner.nextDouble();
		}
		public String next() {
			return scanner.next();
		}

		public int[] nextIntArray(int n) {
			int[] ret = new int[n];
			for (int i = 0; i < n; i++) {
				ret[i] = scanner.nextInt();
			}
			return ret;
		}

		public int[][] nextIntArray(int h, int w) {
			int[][] ret = new int[h][w];
			for (int i = 0; i < h; i++) {
				for (int j = 0; j < w; j++) {
					ret[i][j] = scanner.nextInt();
				}
			}
			return ret;
		}

		public long[] nextLongArray(int n) {
			long[] ret = new long[n];
			for (int i = 0; i < n; i++) {
				ret[i] = scanner.nextLong();
			}
			return ret;
		}

		public long[][] nextlongArray(int h, int w) {
			long[][] ret = new long[h][w];
			for (int i = 0; i < h; i++) {
				for (int j = 0; j < w; j++) {
					ret[i][j] = scanner.nextLong();
				}
			}
			return ret;
		}

		public double[] nextDoubleArray(int n) {
			double[] ret = new double[n];
			for (int i = 0; i < n; i++) {
				ret[i] = scanner.nextDouble();
			}
			return ret;
		}

		public double[][] nextDoubleArray(int h, int w) {
			double[][] ret = new double[h][w];
			for (int i = 0; i < h; i++) {
				for (int j = 0; j < w; j++) {
					ret[i][j] = scanner.nextLong();
				}
			}
			return ret;
		}

		public String[] nextStringArray(int n) {
			String[] ret = new String[n];
			for (int i = 0; i < n; i++) {
				ret[i] = scanner.next();
			}
			return ret;
		}

		public String[] nextStringArray(String split) {
			String[] ret = scanner.next().split(split);
			return ret;
		}

		public String[][] nextStringArray(int h, int w) {
			String[][] ret = new String[h][w];
			for (int i = 0; i < h; i++) {
				for (int j = 0; j < w; j++) {
					ret[i][j] = scanner.next();
				}
			}
			return ret;
		}

		public String[][] nextStringArray(int h, String split) {
			String[][] ret = new String[h][];
			for (int i = 0; i < h; i++) {
				ret[i] = scanner.next().split(split);
			}
			return ret;
		}

		public void close() {
			scanner.close();
		}

	}

}


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

int main(){
	int N;
	cin >> N;
	vector<int> A;
	int mina = 1e9+5;
	rep(i,N){ 
		int a;
		cin >> a;
		if (a < mina) mina = a; 
		A.push_back(a);
	}

	while (A.size() > 1) {
		vector<int> v;
		int tmp = mina;
		for (int a : A) {
			a %= mina;
			if (a > 0) {
				tmp = min(tmp, a);
				v.push_back(a);
			}
		}
		v.push_back(mina);
		mina = tmp;
		A = v;
	}

	cout << mina << endl;

	return 0;
}


Measured memory_bytes: 4188
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
ll arr[200001];
ll msa[200002];
vector<ll>ans;
ll sum=0;
int main(){
int n,k; 
cin>>n>>k;

for(int i=1;i<=n;++i){
    cin>>arr[i];
}
for(int i=1;i<=k;++i){
    sum+=arr[i];
}
for(int i=1;i<=n-k;++i){
    if(arr[i]<arr[i+k]) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

    return 0;
}

Measured memory_bytes: 5192
using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;
using System.Numerics;

namespace sumitomo2019
{
    class Program
    {
        static void Main(string[] args)
        {
            //Console.SetIn(new StreamReader("input.txt"));
            solve_sumitomo2019B();
        }

        public static void solve_sumitomo2019B()
        {
            int n = Convert.ToInt32(Console.ReadLine());
            double div = n / 1.08;
            if (Math.Floor(Math.Ceiling(div) * 1.08) == n) 
            {
                Console.WriteLine(Math.Ceiling(div));
            }
            else
            {
                Console.WriteLine(":(");
            }
        }

        public static void solve_sumitomo2019A()
        {
            int[] md1 = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
            int[] md2 = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);

            Console.WriteLine(md2[0] != md1[0] ? 1 : 0);
        }
    }
}


Measured memory_bytes: 13268
#include <stdio.h>
int main(){
	int n;
	scanf("%d",&n);
	if(n==1)		printf("1\n");
	else if(n%2==0)	printf("0.5\n");
	else{
		double all = n;
		double odd = n/2+1;
		printf("%.7f\n",odd/all);
	}
	return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);

        long n = scan.nextInt();
        long a = scan.nextInt();
        long b = scan.nextInt();
        

        long total = 0;
        total = pow(2, n) - 1;
        total = (total + 1000000007 - comb(n, a)) % 1000000007;
        total = (total + 1000000007 - comb(n, b)) % 1000000007;
        System.out.println(total);
    }

    static long comb(long n, long k) {
        long numerator = nume(n, k);
        long denominator = fac(k);
        return (numerator * pow(denominator, 1000000007 - 2)) % 1000000007;
    }

    static long nume(long n, long k) {
        // k--;
        long result = 1;
        while(k > 0) {
            result = result * n % 1000000007;
            k--;
            n--;
        }
        return result;
    }

    static long fac(long k) {
        long result = 1;
        while(k > 0) {
            result = result * k % 1000000007;
            k--;
        }
        return result;
    }

    static long pow(long n, long p) {
        long result = 1;
        long weight = n;
        while(p > 0) {
            if ((p & 1) == 1) {
                result *= weight;
                result %= 1000000007;
            }
            weight = weight * weight % 1000000007;
            p >>= 1;
        }
        return result;
    }
}

Measured memory_bytes: 21844
from math import sqrt

N,D=map(int,input().split())
XY=[]
for _ in range(N):
  XY.append(list(map(int,input().split())))
ans=0
for i in range(N):
  if sqrt(XY[i][0]**2+XY[i][1]**2)<=D:
    ans+=1
print(ans)


Measured memory_bytes: 45360
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <set>
#include <cmath>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)

using namespace std;
typedef long long int lli;

int main(){
	int H,W,N;
	cin>>H>>W>>N;
	int a[10001];
	rep1(i,N)cin>>a[i];
	queue<int> q;
	rep1(i,N)rep1(j,a[i])q.push(i);
	int c[100][100];
	if(H%2==0){
		rep(i,H/2){
			rep(j,W){c[2*i][j]=q.front();q.pop();}
			rep(j,W){c[2*i+1][W-j-1]=q.front();q.pop();}
		}
	}
	else{
		rep(i,H/2){
			rep(j,W){c[2*i][j]=q.front();q.pop();}
			rep(j,W){c[2*i+1][W-j-1]=q.front();q.pop();}
		}
		rep(j,W){c[H-1][j]=q.front();q.pop();}
	}
	rep(i,H){
	rep(j,W)cout<<c[i][j]<<" ";
		cout<<endl;
	}
}

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

int main()
{
	int LorR[26] = { 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0 };
	string s;
	while (cin >> s, s != "#")
	{
		int ans = 0;
		for (int i = 1; i < s.size(); i++)
		{
			int now = s[i] - 'a';
			int before = s[i - 1] - 'a';
			if (LorR[now] != LorR[before]) ans++;
		}
		cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 1184
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-2;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;

#include<cstring>
struct edge { int to, cap, rev; };
vector<edge> G[100000];
bool used[100000];
void add_edge(int from, int to, int cap) {
	G[from].push_back(edge{ to, cap, (int)G[to].size() });
	G[to].push_back(edge{ from, 0, (int)G[from].size() - 1 });
}
int dfs(int v, int t, int f) {
	if (v == t)return f;
	used[v] = true;
	for (int i = 0; i < (int)G[v].size(); i++) {
		edge &e = G[v][i];
		if (!used[e.to] && e.cap > 0) {
			int d = dfs(e.to, t, min(f, e.cap));
			if (d > 0) {
				e.cap -= d;
				G[e.to][e.rev].cap += d;
				return d;
			}
		}
	}
	return 0;
}
int max_flow(int s, int t) {
	int flow = 0;
	for (;;) {
		memset(used, 0, sizeof(used));
		int f = dfs(s, t, mod);
		if (f == 0)return flow;
		flow += f;
	}
}
vector<P> v[2];
int main() {
	int n, a, b; cin >> n >> a >> b;
	int cnt = 0;
	rep(i, n) {
		int x, y; cin >> x >> y;
		int z = abs(x - y);
		if (z <= a || (b <= z && z <= 2 * a))cnt++;
		else {
			if (x-y>0) {
				v[0].push_back({ x,y });
			}
			else {
				v[1].push_back({ x,y });
			}
		}
	}
	int m = v[0].size(); int len = v[1].size();
	int sta = m + len, goa = m + len + 1;
	rep(i, m)add_edge(sta, i, 1);
	rep(i, len)add_edge(i + m, goa, 1);
	rep(i, m) {
		rep(j, len) {
			int z = v[0][i].first - v[0][i].second + v[1][j].first - v[1][j].second;
			z = abs(z);
			if (z <= a || (b <= z && z <= 2 * a)) {
				add_edge(i, m + j,1);
			}
		}
	}
	int ans = cnt + max_flow(sta,goa);
	cout << ans << endl;
	//stop
	return 0;
}


Measured memory_bytes: 6732
N = int(input())
X = list(map(int, input().split()))
 
def calc_power(p):
  P = list(map(lambda x: (x-p)**2, X))
  return sum(P)
 
power = []
_min = min(X)
_max = max(X)

if _min != _max:
  for p in range(_min, _max):
    power.append(calc_power(p))
  print(min(power))
  
else:
  power = calc_power(_min)
  print(power)

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

using namespace std;
using ll = long long;
using vl = vector<ll>;
using pll = pair<ll, ll>;

#define rep(i, n) for (ll i = 0, xxx_rep_end = (n); i < xxx_rep_end; ++i)
#define all(x) (x).begin(), (x).end()

template <class T1, class T2>
inline bool chmax(T1 &a, const T2 &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T1, class T2>
inline bool chmin(T1 &a, const T2 &b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

constexpr ll INF = 0x3f3f3f3f3f3f3f3fLL;
constexpr ll mod = 1000000007;

int main() {
    ll X;
    cin >> X;
    ll yokin = 100;
    ll ans = 0;
    while (true) {
        ll y = yokin / 100;
        yokin += y;
        ++ans;
        if (yokin >= X) {
            break;
        }
    }
    cout << ans << endl;
}

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

using namespace std;

int main()
{
  int N; cin >> N;
  vector<int> l(N), r(N);
  for (int i = 0; i < N; ++i) {
    cin >> l[i] >> r[i];
  }

  int ans = 0;
  for (int i = 0; i < N; ++i) {
    ans += r[i] - l[i] + 1;
  }

  cout << ans;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
	int A1, A2, A3, Ai;
	
	scanf("%d %d %d", &A1, &A2, &A3);
	Ai = A1 + A2 + A3;
	
	if (Ai>=22){
		printf("bust\n");
	}
	else 
		printf("win\n");
	return 0;
}


Measured memory_bytes: 1644
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

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

    ll a, b, c;
    cin >> a >> b >> c;
    if (a + b + c >= 22) cout << "bust" << endl;
    else cout << "win" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>

using namespace std;

typedef long long ll;

const int N=55;

int n,p,sum;
int a[N];
ll f[105*N];
ll ans;

int main(){
	scanf("%d%d",&n,&p);
	for (int i=1;i<=n;++i){
		scanf("%d",&a[i]);
		sum+=a[i];
	}
	f[0]=1;
	for (int i=1;i<=n;++i){
		for (int j=sum-a[i];j>=0;--j)
			f[j+a[i]]+=f[j];
	//	for (int j=0;j<=sum;++j) printf("%d ",f[j]);puts("");
	}
	for (int j=0;j<=sum;++j)
		if (j%2==p) ans+=f[j];
	printf("%lld\n",ans);
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <sstream>
using namespace std;
pair<int,long long>p[100006];
int main() {
    string s;
    cin>>s;
    int ans=1000;
    for(int i=0;i<s.size()-2;i++)
    {
        string g="";
        g=s.substr(i,3);
        stringstream a(g);
        int b=0;
        a >> b;
        ans=min(ans,abs(753-b));
    }
    cout<<ans;
    return 0;
}

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

class Main {

	void solve () {

		int p = in.nextInt(), q = in.nextInt(), r = in.nextInt();
		int[] ar = {p+q, p+r, q+r};
		Arrays.sort(ar);
		out.println(ar[0]);
		
	}

	public static PrintWriter out = new PrintWriter(System.out);
	public static Scanner in = new Scanner(System.in);
	public static void main(String[] args) {
		new Main().solve();
		out.flush();
	}

}

Measured memory_bytes: 23764