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

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

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	string s,t; cin>>s>>t;
	sort(s.begin(), s.end());
	sort(t.rbegin(), t.rend());
	cout << (s<t ? "Yes" : "No") << endl;
	return 0;
}


Measured memory_bytes: 256
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <list>
#include <stack>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  (int)1000000007
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi  vector<int> 
#define   dbg(x)  cerr << #x << " = " << x << '\n'
#define   sz(x)  (int)x.size()
#define   all(a) (a.begin(),a.end())
#define   ff   first
#define   ss   second
#define   pii  pair<int,int> 
#define   lcm(a,b) (a*b)/__gcd(a,b) 
using namespace std;


int bigmod(int a, int p, int m){ 
    if (p == 0)  return 1 ; 
    if (p & 1){ 
        int p1 = a % m ;
        int p2 = bigmod( a, p-1, m ); 
        return  (p1 * p2) % m; 
    }
    int p1 = bigmod( a, p/2, m ); 
    return  (p1 * p1) % m; 
}


inline void solve(){
    vi bit(61,0),p(61,0);
    int n,sum=0LL; 
    cin>>n; 
    vi a(n);
    for (int i=0;i<n;i++) {
        cin >> a[i]; 
        for (int j=0;j<60;j++){
            if ((a[i]>>j)&1) bit[j]++;
        }
    }
    for (int i=0;i<60;i++) p[i] = bigmod(2,i,mod);
    for (int i=0;i<n;i++){
        for (int j=0;j<60;j++){
            if (((a[i]>>j)&1)){
                sum += (n-i-bit[j]) * p[j] ;  
                bit[j]--;
            }
            if ((((a[i]>>j)&1)==0) and (bit[j]>0)){
                sum += (bit[j]*p[j]);
            }
        }
        sum = sum%mod;
    }
    printf("%lld\n",sum);
}
// https://atcoder.jp/contests/abc147/tasks/abc147_d
signed main()
{
    int n=1; // cin>>n;
    while (n--) solve();
    return 0;
}


Measured memory_bytes: 5604
using System;

namespace AtCoderCs
{
    class Program
    {
        static void Main(string[] args)
        {

            var str = Console.ReadLine().Split(' ');

            if ((str[0] == str[1] || str[2] == str[1]) && str[0] != str[2] || str[0] == str[2] && str[1] != str[0])
                Console.WriteLine("Yes");
            else Console.WriteLine("No");


        }
    }
}


Measured memory_bytes: 13140
#include<stdio.h>
#include<math.h>

int main(void)
{
	double a,b,c,C;
	double S,L,h;
	
	scanf( "%lf %lf %lf", &a,&b,&C );
	
	h = b * sin( C * (M_PI / 180 ) );
	S = a*h/2;
	c =  a*a + b*b - 2*a*b*cos( C * (M_PI / 180 ));
	L = a+b+sqrt(c);
	printf( "%f\n", S );
	printf( "%f\n", L );
	printf( "%f\n", h );
	
	return 0;
}


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

using namespace std;

int main() {

	int n;
	cin >> n;
	vector<int> a(n, 0);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}

	int minj;
	int counter = 0;
	for (int i = 0; i < n ; i++) {
		minj = i;
		for (int j = i; j < n; j++) {
			if (a[j] < a[minj]) {
				minj = j;
			}
		}
		swap(a[i], a[minj]);
		if (minj != i) { counter++; }
	}

	for (int i = 0; i < n - 1; i++) {
		cout << a[i] << " ";
	}
	cout << a[n - 1] << endl;
	cout << counter << endl;
}


Measured memory_bytes: 3084
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int mem[3002][3005];
void setmem(string s,string t){
    for(int i=0;i<=s.length();i++){
        mem[i][0]=0;
    }
    for(int i=0;i<=t.length();i++){
        mem[0][i]=0;
    }
    for(int i=1;i<=s.length();i++){
        for(int j=1;j<=t.length();j++){
            if(s[i-1]==t[j-1]) mem[i][j]=1+mem[i-1][j-1];
            else mem[i][j]=max(mem[i-1][j],mem[i][j-1]);
        }
    }
}
void printPath(string s,string t){
    string ans="";
    int lenS=s.length();
    int lenT=t.length();
    while(lenS!=0&&lenT!=0){
        if(s[lenS-1]==t[lenT-1]){
            ans+=s[lenS-1];
            lenS-=1;
            lenT-=1;
        }else{
            if(mem[lenS-1][lenT]>=mem[lenS][lenT-1]){
                lenS-=1;
            }else{
                lenT-=1;
            }
        }
    }
    for(int i=ans.length()-1;i>=0;i--){
        cout<<ans[i];
    }
    
    //cout<<endl;
}
main(){
    string s,t;
    cin>>s>>t;
    memset(mem,0,sizeof(mem));
    setmem(s,t);
    printPath(s,t);
}

Measured memory_bytes: 38884
#include <stdio.h>
#define TEAM_MAX 10

int main() {
  int n;
  int i, j;
  int temp;
  struct team {
    char name;
    int win;
    int lose;
  } t[TEAM_MAX], ttemp;

  while(1) {
    for(i = 0; i < TEAM_MAX; i++) {
      t[i].win = 0;
      t[i].lose = 0;
    }
    scanf("%d", &n);
    if(n == 0) break;
    for(i = 0; i < n; i++) {
      scanf(" %c ", &t[i].name);
      for(j = 0; j < n-1; j++) {
	scanf("%d", &temp);
	switch(temp) {
	case 0:t[i].win++; break;
	case 1:t[i].lose++; break;
	}
      }
    }


    for(i = n-1; i > 0; i--) {
      for(j = 0; j < i; j++) {
	if(t[j+1].lose < t[j].lose) {
	  ttemp = t[j+1];
	  t[j+1] = t[j];
	  t[j] = ttemp;
	}
      }
    }
    for(i = n-1; i > 0; i--) {
      for(j = 0; j < i; j++) {
	if(t[j+1].win > t[j].win) {
	  ttemp = t[j+1];
	  t[j+1] = t[j];
	  t[j] = ttemp;
	}
      }
    }

    for(i = 0; i < n; i++) {
      printf("%c\n", t[i].name);
    }
  }
  return 0;
}

Measured memory_bytes: 0
//
//  main.c
//  A
//
//  Created by s1262004 on 2019/07/16.
//  Copyright © 2019 s1262004. All rights reserved.
//

#include <stdio.h>
int F[50];
int fibonacci(int);

int main(int argc, const char * argv[]) {
    int n;
    scanf("%d", &n);
    printf("%d\n", fibonacci(n));
    return 0;
}

int fibonacci(int n){
    if (n == 0 || n == 1) return F[n] = 1;
    if (F[n] != 0) return F[n];
    return F[n] = fibonacci(n - 2) + fibonacci(n - 1);
}



Measured memory_bytes: 2112
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()

typedef long long lint;

using namespace std;

int main(){
  int N;
  cin>>N;
  int p[N];
  REP(i,N){
    int k;
    cin>>k;
    k--;
    p[k]=i;
  }
  int A[N],B[N];
  int X=N+1;
  REP(i,N)A[i]=X*(i+1);
  REP(i,N)B[i]=X*(N-i)+p[i];
  REP(i,N)cout<<A[i]<<" ";
  cout<<endl;
  REP(i,N)cout<<B[i]<<" ";
  cout<<endl;
  return 0;
}


Measured memory_bytes: 896
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <vector>
#include <map>
#include <utility>
#include <cmath>
#include <queue>
#include <stack>

using namespace std;

#define mp make_pair
#define pb push_back
#define st first
#define nd second
#define MAX_XY 300 * 2 + 100

typedef long long ll;
typedef vector<ll> vl;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef pair<ll,ll> pll;

int sqr(int x) {
  return x * x;
}

int main() {
  int n;
  scanf("%d", &n);
  int a;
  bool stat = false;
  for(int i = 0; i < n; ++i) {
    scanf("%d", &a);
    if(a % 2 == 1) stat = true;
  }
  if(stat) printf("first\n");
  else printf("second\n");
  return 0;
}


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

#define ll long long
#define MOD 1000000007
#define vi vector<int>
#define vvi vector<vector<int> >
#define vii vector<pair<int, int> >


int main(int argc, char * argv[])
{
    std::ios_base::sync_with_stdio(false);    
    std::cin.tie(NULL);

    std::vector<int> v(5);
    for(int i = 0; i < 5; ++i) std::cin >> v[i];

    for(int i = 0; i < 5; ++i)
    {
	if(v[i] == 0)
	{
	    cout << i+1 << endl;
	    break;
	}
	
    }


    return 0;
}


Measured memory_bytes: 3600
#include <bits/stdc++.h>
#include <string>
#include <algorithm>
#include <string.h>
#include <ctype.h>
#include <math.h>
#include <float.h>
#include <iomanip>
#include <iostream>
using namespace std;

int main()
{

    int N,A,B;

    cin>>N;

    if(N==1){
        cout <<"Hello World"<<endl;
    }else{
        cin>>A>>B;
        cout<<A+B<<endl;
    }

    return 0;
}


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

#define MOD 1000000007
#define rep(i, n) for(ll i=0; i < (n); i++)
#define rrep(i, n) for(ll i=(n)-1; i >=0; i--)
#define ALL(v) v.begin(),v.end()
#define rALL(v) v.rbegin(),v.rend()
#define FOR(i, j, k) for(ll i=j;i<k;i++)
#define debug_print(var) cerr << #var << "=" << var <<endl;
#define DUMP(i, v)for(ll i=0;i<v.size();i++)cerr<<v[i]<<" "

using namespace std;
typedef long long int ll;
typedef vector<ll> llvec;
typedef vector<double> dvec;
typedef pair<ll, ll> P;
typedef long double ld;
struct edge{ll x, c;};

ll mod(ll a, ll mod){
  ll res = a%mod;
  if(res<0)res=res + mod;
  return res;
}

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

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

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

bool is_prime(ll n){
  ll i = 2;
  if(n==1)return false;
  if(n==2)return true;
  bool res = true;
  while(i*i <n){
    if(n%i==0){
      res = false;
    }
    i = i+1;
  }

  //if(i==1)res = false;
  if(n%i==0)res=false;
  return res;
}

struct UnionFind{
  ll N;
  llvec p;
  llvec cnt;
  UnionFind(ll n){
    N = n;
    p=llvec(N);
    cnt=llvec(N, 0);
    rep(i, N){
      p[i] = i;
      cnt[i] = 1;
    }
  }

  void con(ll a, ll b){
    P at = root(a);
    P bt = root(b);
    if(at.second!=bt.second){
      if(at.first>bt.first){
        swap(at, bt);
        swap(a, b);
      }
      p[at.second] = bt.second;
      cnt[bt.second]+=cnt[at.second];
      p[a]=bt.second;
    }
  }

  P root(ll a){
    ll atmp = a;
    ll c=0;
    while(atmp!=p[atmp]){
      atmp = p[atmp];
      c++;
    }
    p[a] = atmp;
    return {c, atmp};
  }

  bool is_con(ll a, ll b){
    P at=root(a);
    P bt=root(b);
    return at.second == bt.second;
  }
  
};

struct dijkstra{
  ll N;
  llvec d;
  vector<vector<edge>> e;
  dijkstra(ll n){
    N = n;
    //d = llvec(N, 1e18);
    e = vector<vector<edge>>(N);
  }

  void add_edge(ll from, ll to, ll cost){
    e[from].push_back({to, cost});
  }

  void run(ll start){
    priority_queue<P, vector<P>, greater<P>> que;
    que.push({0, start});
    d = llvec(N, 1e18);
    d[start]=0;
    while(!que.empty()){
      P q = que.top();que.pop();
      ll dc = q.first;
      ll x = q.second;
      if(dc>d[x]){
        continue;
      }else{
        for(auto ip: e[x]){
          if(d[ip.x]<=d[x]+ip.c){
            continue;
          }else{
            d[ip.x]= d[x]+ip.c;
            que.push({d[ip.x], ip.x});
          }
        }
      }
    }
  }  
};


/**************************************
** A main function starts from here  **
***************************************/
int main(){
  ll N;
  cin >> N;
  if(N%1000==0)cout << 0;
  else cout << 1000 - N%1000;
  return 0;
}


Measured memory_bytes: 3628
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

N = int(input())
P = [None] + [int(x) for x in input().split()]
p_to_i = [None] * (N+1)
for i,x in enumerate(P[1:],1):
    p_to_i[x] = i

# 大きい数から挿入していく
# 左隣にあるインデックスを取得できるようにしておく
# そのために、[1,i]内で書き込んだ数の個数を獲得できるBITを持つ

def BIT_add(i):
    while i <= N:
        tree[i] += 1
        i += i&(-i)

def BIT_sum(i):
    s = 0
    while i:
        s += tree[i]
        i -= i&(-i)
    return s

def BIT_search(x):
    # 二分探索。和がx以上となる最小のインデックス(>= 1)を返す
    i = 0
    s = 0
    step = 1<<(N.bit_length()-1)
    while step:
        if i+step <= N and s + tree[i+step] < x:
            i += step
            s += tree[i]
        step >>= 1
    return i+1

tree = [0] * (N+1)
answer = 0
for x in range(N,0,-1):
    c = p_to_i[x]
    L = BIT_sum(c) # 左にある既に書き込んだ数の個数
    BIT_add(c)
    R = N-x-L # 右にある既に書き込んだ数の個数
    a = BIT_search(L-1) if L >= 2 else 0
    b = BIT_search(L) if L >= 1 else 0
    d = BIT_search(L+2) if R >= 1 else N+1
    e = BIT_search(L+3) if R >= 2 else N+1
    coef = 0
    if b != 0:
        # [b,c]を含むようにする。(a,b) と(c,d)が自由
        coef += (b-a) * (d-c)
    if d != 0:
        # [c,d]を含むようにする。
        coef += (e-d) * (c-b)
    answer += x * coef
print(answer)





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

#define fastio 			ios::sync_with_stdio(0);	cin.tie(0); cout.tie(0);  cout<<fixed;  cout<<setprecision(12);
#define randomINT 		mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define	newl 			cout<<"\n"
#define DISP(as)		for(auto it : as) cout<<it<<" ";newl;
#define all(x)         	(x).begin(),(x).end()
#define mset(x,val)    	memset(x,val,sizeof(x))
#define newl           	cout<<"\n"
#define pb             	push_back
#define mp             	make_pair
#define f 				first
#define s 				second
#define dline          cerr<<"///REACHED///\n";
#define deb1(x)        cerr<<#x<<" = "<<x<<'\n';
#define deb2(x,y)      cerr<<'['<<#x<<','<<#y<<"] = "<<'['<<x<<','<<y<<']'<<'\n';
#define deb3(x,y,z)    cerr<<'['<<#x<<','<<#y<<','<<#z<<"] = "<<'['<<x<<','<<y<<','<<z<<']'<<'\n';

typedef long long 				ll;
typedef long double 			ld;
typedef vector<ll> 				vll;
typedef pair<ll , ll> 			pll;
typedef pair<ld, ld> 			pld;
typedef unordered_map<ll, ll> 	um;
typedef vector<pll> 			vpll;

const ll 	MAX5 	= 	1e+5 + 7;
const ll 	MAX7 	= 	1e+7 + 7;
const ll 	MAXN 	= 	MAX7;
const ll   	INF   	=  	0x7f7f7f7f7f7f7f7f;
const int  	INFi 	=  	0x7f7f7f7f;
const ll 	MOD		=  	1e+9 + 7;


// <------------- Declare Variables Here ------------> //

ll T = 1;
ll n, x, m, y, k;
string s, t;

// <------------- Implement Functions Here ----------> //


// <------------- Start of main() -------------------> //

void MAIN() {
	cin >> n;
	vll a(n);
	for(ll i=0;i<n;i++) cin>>a[i];
	ll max1 = 0,max2 = 0;
	for(ll i=0;i<n;i++) {
		if(max1 < a[i]) {
			max2 = max1;
			max1 = a[i];
		}
		else if(max2 < a[i]) {
			max2 = a[i];
		}
	}

	for(ll i=0;i<n;i++) {
		if(a[i] == max1) cout<<max2;
		else cout<<max1;
		newl;
	}
}

int main() {
	fastio; randomINT;
	//cin >> T;
	while (T--) {
		MAIN();
	}
	return 0;
}


Measured memory_bytes: 4708
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define mkt make_tuple
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define all(v) v.begin(),v.end()
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;
template<class T> void chmin(T &a,const T &b){if(a>b) a=b;}
template<class T> void chmax(T &a,const T &b){if(a<b) a=b;}

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

  int N;
  ll D;
  cin>>N>>D;
  vector<ll> X(N),Y(N);
  rep(i,N) cin>>X[i]>>Y[i];

  D*=D;
  int ans=0;
  for(int i=0;i<N;i++){
    ll dist=X[i]*X[i]+Y[i]*Y[i];
    if(dist<=D) ans++;
  }

  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 6360
#include <iostream>

int main()
{
  int W = 0 ;
  int H = 0 ;
  int x = 0 ;
  int y = 0 ;
  int r = 0 ;

  std::cin >> W >> H >> x >> y >> r ;

  bool bYes = true ;

  if ( x - r < 0 )
    bYes = false ;
  else if ( y - r < 0 )
    bYes = false ;
  else if ( x + r > W )
    bYes = false ;
  else if ( y + r > H )
    bYes = false ;

  if ( bYes )
    std::cout << "Yes" << std::endl ;
  else
    std::cout << "No" << std::endl ;

  return 0 ;
    
}

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

int main(){
  int n,m,ans=0;
  int s[1000];
  while(1){
    cin>>n>>m;
    ans=0;
    if(n==0 && m==0) break;
    for(int i=0;i<1000;i++) s[i]=0;
    for(int i=0;i<n;i++) cin>>s[i];
    for(int i=0;i<n;i++){
      for(int j=i+1;j<n;j++){
	if((s[i]+s[j])<=m){
	  ans=max(ans,s[i]+s[j]);
	}
      }
    }
    if(ans) cout<<ans<<endl;
    else cout<<"NONE"<<endl;
  }
  return 0;
}



Measured memory_bytes: 3012
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<stack>
#include<bitset>
#include<cstdlib>
#include<cmath>
#include<set>
#include<list>
#include<deque>
#include<map>
#include<queue>
using namespace std;
typedef long long ll;
const double PI = acos(-1.0);
const double eps = 1e-6;
const int INF = 0x3f3f3f3f;

const int MAXN = 1e5+10;
int n,k;
ll T[MAXN];

int check(ll P){
	int i =0;
	for(int j=0;j<k;j++){
		ll s=0;
		while(s+T[i]<=P){
			s+=T[i];
			i++;
			if(i==n)	return n;
		}
	}
	return i;
}

int solve(){
	ll left =0;
	ll right = MAXN*MAXN;
	ll mid;
	while(right-left>1){
		mid = (left+right)/2;
		int v = check(mid);
		if(v>=n)	right = mid;
		else left = mid;
	}
	return right;
}

int main(){
	scanf("%d %d",&n,&k);
	for(int i=0;i<n;i++){
		scanf("%lld",&T[i]);
	}
	ll ans = solve();
	printf("%lld\n",ans);

	return 0;
}




Measured memory_bytes: 3916
#include<bits/stdc++.h>
using namespace std;
#define ll long long
typedef pair<ll,ll> P;
#define M 1000000007
int main(){
  int n,k,c=0;
  cin>>n>>k;
  for(int i=1;i<=k;i++){
    int a=i/10,b=i%10;
    if(a>1&&b>1){
      for(int j=1;j<=n;j++){
        if(j==a*b)c++;
      }
    }
  }
  cout<<c;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
using namespace std;
using ll = long long;
int main(){
  string s,t;
  cin >> s;
  cin >> t;
  ll cnt = 0;
  for(ll i=0;i<s.size();i++){
    if(s[i]!=t[i]) cnt++;
  }
  cout << cnt;
}

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

#define rep(i,n) for(int i=0;i<n;i++)
#define srep(i,s,e) for(int i=s;i<=e;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define MAX (int)1e9 + 99
#define maxof(a,b,c) max(a,max(b,c))
#define minof(a,b,c) min(a,min(b,c))
#define vi vector<int>
#define vvi vector<vector<int>>
#define vb vector<bool>
#define ll long long
#define ull unsigned long long
#define vll vector<ll>
#define pa pair<int, int>
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define bitcnt(x) __builtin_popcount(x)
#define gcd(a,b) __gcd(a,b)
#define all(x) (x).begin(),(x).end()
#define ts(x) to_string(x)
#define rsort(a) sort(all(a)); reverse(all(a))
#define set0(x) memset(x, 0, sizeof(x))
const double pi = 3.14159265358979323846;
ll binpow(ll, ll);
ll mult(ll, ll);
ll add(ll , ll);
ll division(ll, ll);
ll nCr(ll, ll);
ll inv(ll);
void calc();
void maxi(int &a, int b) {if(a<b) a = b;}
void mini(int &a, int b) {if(a>b) a = b;}
template<class T> istream &operator>>(istream &is, vector<T> &v) { for (T &x : v) is >> x; return is;}
template<class T> ostream &operator<<(ostream &os, const vector<T> &v) {if (!v.empty()) {os << v.front();for (int i = 1; i < v.size(); ++i) os << ' ' << v[i];} return os;}
const int N=50010;
const int MOD = 1e9+7;
//ll fact[N];






void solve()
{
    int s;
    cin>>s;
    vll dp(2001, 1);
    dp[0] = dp[1] = dp[2] = 0;

    srep(i,4,s) {
        srep(j,3,i-3) {
            dp[i] = add(dp[i], dp[j]);
        }
    }


    cout<<dp[s];
}

int main()
{
    fastio;
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    int t=1;
    // cin>>t;
    
    rep(i,t)
    {
        solve();
        cout<<"\n";
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
    return 0;
}




ll add(ll a, ll b){
    a+=b;
    while(a>=MOD) a-=MOD;
    while(a<0) a+=MOD;
    return a;
}


Measured memory_bytes: 3848
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define deb(x) cout << #x << " = "<< x << "\n";

signed main() {
//	freopen("in.txt", "r",stdin);
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	
	string s, t;
	cin >> s >> t;
	
	int ans = 1002;
	int n = s.length(), m = t.length();
	
	for(int i = 0; i + m - 1 < n; i++) {
		int res = m;
		for(int j = 0; j < m; j++) {
			res -= (s[i + j] == t[j]);
		}
		ans = min(ans, res);
	}
	
	cout << ans;
	
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define RFOR(i,n1,n2) for(ll i=((ll)(n1)-1);i>=(ll)(n2);i--)
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
#define IOS cin.tie(0),ios::sync_with_stdio(false)
typedef long long ll;
typedef unsigned long long ull;
typedef std::pair<ll, ll> P;
template<typename T1, typename T2> inline bool chmin(T1& a, T2 b) { if (a > b) { a = b; return 1; }return 0; }
template<typename T1, typename T2> inline bool chmax(T1& a, T2 b) { if (a < b) { a = b; return 1; }return 0; }
template<class Type>struct is_vector : std::false_type {};
template<class ValueType, class Alloc>struct is_vector<std::vector<ValueType, Alloc>> : std::true_type {};
template <typename T> inline std::ostream& operator << (std::ostream& out, const std::vector<T>& v) {
	if (v.empty())return out;
	constexpr bool is_vector_v = is_vector<T>::value;
	if (is_vector_v)for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? "\n" : "");
	else for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? " " : "");
	return out;
}
inline void put() {}
template<class T> inline void put(const T& first) { std::cout << first << "\n"; }
template<class T, class... N> inline void put(const T& first, const N& ... rest) { std::cout << first << " "; put(rest...); }
inline void putn() {}
template<class T, class... N> inline void putn(const T& first, const N& ... rest) { std::cout << first << "\n"; putn(rest...); }

template<typename U>
int lis(vector<U> a, bool broad = true) {//broad=true:広義、false:狭義
	int rtn = 0;
	vector<int> lis;
	lis.push_back(a[0]);
	FOR(i, 1, a.size()) {
		if (broad) {
			if (lis.back() <= a[i]) {
				lis.push_back(a[i]);
			} else {
				auto itr = upper_bound(all(lis), a[i]) - lis.begin();
				lis[itr] = a[i];
			}
		} else {
			if (lis.back() < a[i]) {
				lis.push_back(a[i]);
			} else {
				auto itr = lower_bound(all(lis), a[i]) - lis.begin();
				lis[itr] = a[i];
			}
		}

	}
	rtn = lis.size();//LISの長さ
	return rtn;
}

int main() {
	IOS;
	int n;
	cin >> n;
	vector<int> a(n);
	REP(i, n) {
		cin >> a[i];
	}
	int res = 0;
	int tmp = INT_MAX;
	REP(i, n) {
		if (chmin(tmp, a[i])) {
			res++;
		}
	}
	put(res);
	
	return 0;
}


Measured memory_bytes: 1024
import sys
from heapq import heappush, heappop


N = int(input())
Px = []
Py = []
for k, s in enumerate(sys.stdin.readlines()):
    x, y = map(int, s.split())
    Px.append((x, k))
    Py.append((y, k))

edge = [[] for _ in range(N)]

Px.sort()
for i in range(N - 1):
    x0, k0 = Px[i]
    x1, k1 = Px[i + 1]
    d = abs(x0 - x1)
    edge[k0].append((k1, d))
    edge[k1].append((k0, d))

Py.sort()
for i in range(N - 1):
    y0, k0 = Py[i]
    y1, k1 = Py[i + 1]
    d = abs(y0 - y1)
    edge[k0].append((k1, d))
    edge[k1].append((k0, d))

q = []
used = set([0])
for np, nd in edge[0]:
    heappush(q, (nd, np))

cnt = 0
while len(used) < N:
    d, p = heappop(q)
    if p in used:
        continue
    else:
        cnt += d
        used.add(p)
        for np, nd in edge[p]:
            heappush(q, (nd, np))

print(cnt)


Measured memory_bytes: 122972
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#define MOD 1000000007
#define INF 1 << 30

using namespace std;
typedef long long ll;

int main(void) {
	int num, i, j, sum = 0;
	cin >> num;
	ll ans = num;
	vector<int> d(num);
	for (i = 0; i < num; i++)
		scanf("%d", &d[i]);
	for (i = 0, j = 0; i < num; i++) {
		if (sum + d[i] == (sum ^ d[i])) {
			sum += d[i];
			ans += i - j;
		}
		else {
			sum -= d[j++];
			i--;
		}
	}
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <map>
typedef long long LL;

int int_vector_find(std::vector<int> vec, int num) {
	auto itr = std::find(vec.begin(), vec.end(), num);
	int index = std::distance(vec.begin(), itr);

	if (index != vec.size()) {
		return 1;
	}
	else {
		return 0;
	}
}

int main() {
	int a, b, k;
	std::cin >> a >> b >> k;
	std::vector<int> vec;
	int hoge = 1;

	for (int i = 0; i < 100; ++i) {
		if (a%hoge == 0 && b%hoge == 0) {
			vec.push_back(hoge);
		}
		hoge++;
	}

	std::sort(vec.begin(), vec.end(),std::greater<int>());

	std::cout << vec[k-1] << std::endl;
	
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <sstream>
#include <vector>
#include <math.h>
#include <cstdlib>
#include <cctype>
#include <random>

using namespace std;

int main() {
    int r, D, x2;
    cin >> r >> D >> x2;

    for (int i=1; i<=10; i++) {
        x2 = r*x2 - D;
        cout << x2 << endl;
    }


    return 0;
}


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


int main()
{
	string s,t;
	cin >> s;

	for (int i = 0; i < s.size(); i++)
	{
		
		
			t += s[i];
		
		
		i++;
	}
	cout << t << endl;
}

Measured memory_bytes: 512
from collections import defaultdict
import sys
sys.setrecursionlimit(200000)
input = sys.stdin.readline


road_dict=defaultdict(list)

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

for _ in range(M):
    A,B=map(int,input().split())
    road_dict[A].append(B)
    road_dict[B].append(A)

result_dict=defaultdict(int)

next_list=[]
for i in road_dict[1]:
    if i not in result_dict:
        result_dict[i]=1
        next_list.append(i)

taisho_list=next_list[:]

while True:
    next_list=[]

    if len(taisho_list)==0:
        break

    for j in taisho_list:
        for k in road_dict[j]:
            if k not in result_dict:
                result_dict[k]=j
                next_list.append(k)
    taisho_list=next_list[:]


print('Yes')
for k in range(2,N+1):
    print(result_dict[k])

Measured memory_bytes: 47392
n,C,*H=map(int,open(0).read().split());
dp=[0];
P=[0];
for i in range(1,n):
    h=H[i]
    f=lambda I:dp[I]+H[I]*(H[I]-2*h)
    while len(P)>1 and f(P[0])>f(P[1]):P.pop(0)
    dp+=[f(P[0])+h**2+C]
    h=0
    while len(P)>1 and (H[P[-1]]-H[P[-2]])*(f(P[-1])-f(i))>(H[i]-H[P[-1]])*(f(P[-2])-f(P[-1])):P.pop()
    P+=[i]
print(dp[-1])

Measured memory_bytes: 27120
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define fi first
#define sc second
#define pb push_back
#define COUT(x) cout << (x) << "\n"
#define COUTF(x) cout << setprecision(15) << (x) << "\n"
#define ENDL cout << "\n"
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SZ(x) (ll) x.size()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#define MAX(x, y, z) max(x, max(y, z))
#define MIN(x, y, z) min(x, min(y, z))
#define ANS cout << ans << "\n"
#define RETURN(x)    \
  cout << x << "\n"; \
  return 0
clock_t CLOCK;
#define START_TIMER CLOCK = clock()
#define SHOW_TIMER cerr << "time: " << (ld)(clock() - CLOCK) / 1000000 << "\n"
#define init() \
  cin.tie(0);  \
  ios::sync_with_stdio(false)
#define LINE cerr << "[debug] line: " << __LINE__ << "\n";
#define debug(x) cerr << "[debug] " << #x << ": " << x << "\n";
#define debugV(v)                       \
  cerr << "[debugV] " << #v << ":";     \
  rep(i, v.size()) cerr << " " << v[i]; \
  cerr << "\n";
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using mll = map<ll, ll>;
using qll = queue<ll>;
using P = pair<ll, ll>;

constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr ld PI = 3.141592653589793238462643383279;
ll get_digit(ll x) {
  return to_string(x).size();
}

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

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

vector<P> factorize(ll n) {
  vector<P> result;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      result.pb({i, 0});
      while (n % i == 0) {
        n /= i;
        result.back().second++;
      }
    }
  }
  if (n != 1) {
    result.pb({n, 1});
  }
  return result;
}

vll divisor(ll n) {
  vll ret;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n) ret.push_back(n / i);
    }
  }
  SORT(ret);
  return (ret);
}

signed main() {
  init();
  ll N;
  cin >> N;

  vector<P> RED(N);
  vector<P> BLUE(N);
  rep(i, N) cin >> RED[i].first >> RED[i].second;
  rep(i, N) cin >> BLUE[i].first >> BLUE[i].second;
  SORT(BLUE);

  ll ans = 0;
  rep(i, N) {
    ll blue_x = BLUE[i].first;
    ll blue_y = BLUE[i].second;
    ll red_max_y = -1;
    ll red_max_index = INF;
    rep(j, RED.size()) {
      if (blue_x > RED[j].first && blue_y > RED[j].second &&
          RED[j].second > red_max_y) {
        red_max_y = RED[j].second;
        red_max_index = j;
      }
    }
    if (red_max_index != INF) {
      RED.erase(RED.begin() + red_max_index);
      ans++;
    }
  }
  ANS;

  return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
const int N = 1e3+7 , mz = 1e9+7;

int main(){
    int n;
    cin>>n;
    int a[N] = {0}, b[N] = {0}, c[N] = {0};
    for(int i = 1 ; i <= n ; i++)   cin>>a[i];
    for(int i = 1 ; i <= n ; i++)   cin>>b[i];
    for(int i = 2 ; i <= n ; i++)   cin>>c[i];
    int sum = 0;
    a[0] = -5;
    for(int i = 1 ; i <= n ; i++){
        if( a[i] - a[i-1] == 1 ){
            sum += c[a[i]];
        }
        sum += b[a[i]];
    }
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<math.h>
#include<queue>
#include<vector>
#include<climits>
#include<map>
#include<string>

using namespace std;
typedef long long ll;

ll x;

int main() {
	cin >> x;
	cout << x*x*x << endl;
	return 0;
}


Measured memory_bytes: 3108
#include<stdio.h>

int main(void){
    int a, b;
    int i, sum = 0;

    scanf("%d %d", &a, &b);

    for(i = 0;i < 2;i++){
        if(a > b){
            sum += a;
            a--;
        }
        else{
            sum += b;
            b--;
        }
    }
    printf("%d\n", sum);
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define N 111111
#define INF 10000000000
#define int long long
int dp[N+1],dp2[N+1],cost[N+1],cost2[N+1];
typedef pair<int,int> P;
int getcost(int x){
  if(x<=0) return 0;
  return cost2[x];
}
signed main(){
  int n;
  while(cin>>n,n){
    int hp[n];
    for(int i=0;i<n;i++) cin>>hp[i];
    int m;cin>>m;
    vector<P> single,all;
    bool f=0;
    for(int i=0;i<m;i++){
      string name,target;
      int mp,damage;
      cin>>name>>mp>>target>>damage;
      if(damage){
	if(target=="All") all.push_back(P(mp,damage));
	else single.push_back(P(mp,damage));
	f|=!mp;
      }
    }
    
    for(int i=0;i<=N;i++) cost[i]=cost2[i]=dp[i]=dp2[i]=INF;
    cost[0]=dp[0]=0;
    for(int i=0;i<=N;i++){
      if(cost[i]==INF) continue;
      //cout<<i<<":"<<cost[i]<<endl;
      for(int j=0;j<(int)single.size();j++){
	int u=single[j].first,v=single[j].second;
	//cout<<u<<":"<<v<<endl;
	if(i+v<N) cost[i+v]=min(cost[i+v],cost[i]+u);
	else cost[N]=min(cost[N],cost[i]+u);
      }
    }
    cost2[N]=cost[N];
    for(int i=N-1;i>=0;i--) cost2[i]=min(cost2[i+1],cost[i]);
    for(int i=0;i<N;i++){
      if(dp[i]==INF) continue;
      for(int j=0;j<(int)all.size();j++){
	int u=all[j].first,v=all[j].second;
	if(i+v<N) dp[i+v]=min(dp[i+v],dp[i]+u);
	else dp[N]=min(dp[N],dp[i]+u);
      }
    }
    dp2[N]=dp[N];
    for(int i=N-1;i>=0;i--) dp2[i]=min(dp2[i+1],dp[i]);
    int ans=INF;
    for(int i=0;i<N;i++){
      if(dp2[i]==INF) continue;
      int tmp=0;
      for(int j=0;j<n;j++) tmp+=getcost(hp[j]-i);
      //cout<<i<<";"<<dp2[i]<<":"<<tmp<<endl;
      ans=min(ans,dp2[i]+tmp);
    }
    cout<<!f*ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 6608
#include<bits/stdc++.h>
#define FL "a"
using namespace std;
typedef long long ll;
const int mod=1e9+7;
const int N=1e6+10;
inline ll read(){
  ll d=0,w=1;char ch=getchar();
  while(ch!='-'&&(ch<'0'||ch>'9'))ch=getchar();
  if(ch=='-')w=-1,ch=getchar();
  while(ch<='9'&&ch>='0')d=d*10+ch-48,ch=getchar();
  return d*w;
}
inline void file(){
  freopen(FL".in","r",stdin);
  freopen(FL".out","w",stdout);
}

inline void upd(int &a,int b){a+=b;if(a>=mod)a-=mod;}
inline void dec(int &a,int b){a-=b;if(a<0)a+=mod;}

inline int poww(int a,int b){
  int res=1;
  for(;b;b>>=1,a=1ll*a*a%mod)
    if(b&1)res=1ll*res*a%mod;
  return res;
}

int n,f[N],g[N],ans;

int main()
{
  n=read();f[0]=g[0]=1;
  for(int i=1;i<=n;i++){
    f[i]=f[i-1];
    if(i>=3)upd(f[i],g[i-3]);
    upd(g[i]=f[i],g[i-1]);
  }
  upd(ans,f[n]);
  for(int i=n-2;~i;i--)
    upd(ans,1ll*f[i]*(i+1)%mod);
  upd(ans,1ll*f[n-1]*(n-1)%mod);
  for(int i=n-2;~i;i--)
    upd(ans,1ll*f[i]*(n-1)%mod*(n-1)%mod);
  printf("%d\n",ans);
  return 0;
}


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

#define WA {puts("-1");return 0;}

#define MAXN 100010

int n;
char s[MAXN];
vector<int> edge[MAXN];

int main()
{
	scanf("%s",s+1);
	n=strlen(s+1);
	for(int i=1;i<=n;++i)s[i]-='0';
	for(int i=0;i<=n;++i)if(s[i]!=s[n-i])WA
	if(!s[1])WA
	int now=1,tot=1,size=1;
	for(int i=1;i<=n/2;++i)
	{
		if(s[i])
		{
			for(int j=size;j<i;++j)
			{
				edge[now].push_back(++tot);
			}
			edge[now].push_back(++tot);
			now=tot;
			size=tot;
		}
	}
	if(tot!=n)
	{
		for(int i=tot+1;i<=n;++i)edge[tot].push_back(i);
	}
	for(int i=1;i<=n;++i)
		for(auto j : edge[i])
			printf("%d %d\n",i,j);
}

Measured memory_bytes: 5756
import sys, math
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = 10**20
def I(): return int(input())
def F(): return float(input())
def S(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LS(): return input().split()

def resolve():
    A, B, H, M = LI()

    rad_M = 2*math.pi * M / 60
    rad_H = 2*math.pi * (60*H+M) / 720

    ans = (A**2+B**2-2*A*B*math.cos(rad_H-rad_M))**0.5

    print(ans)

if __name__ == '__main__':
    resolve()


Measured memory_bytes: 9464
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)

	a, b := nextInt(), nextInt()
	if 1 <= a && a <= 9 && 1 <= b && b <= 9 {
		fmt.Println(a*b)
	} else {
		fmt.Println(-1)
	}
}

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

int main(){
    int n; cin >> n;
    vector <int> A(n);
    for (int i=0; i<n; i++) cin >> A[i];
    int m; cin >> m;
    vector <int> B(n);
    for (int i=0; i<m; i++) cin >> B[i];
    
    int cnt=0;
    for (int i=0; i<m; i++){
        int searchValue=B[i];
        for (int k=0; k<n; k++){
            if (searchValue==A[k]){
                cnt++;
                break;
            }
        }
    }
    cout << cnt << endl;
}


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

int main(){
  ios::sync_with_stdio(0); cin.tie(0);
  int a, b, c, x, y, cost=0; cin >> a >> b >> c >> x >> y;
  if(a+b > 2*c){
    for(int i=0;i<min(x,y);i++) cost += 2*c;
    if(x > y && a < 2*c) cost += a*(x-y);
    else if(x < y && b < 2*c) cost += b*(y-x);
    else for(int i=0;i<abs(x-y);i++) cost += 2*c;
  }
  else cost = a*x + b*y;
  cout << cost << endl;
  return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	if(a+b>c+d)
	{
		cout<<"Left"<<endl;
		return 0;
	}
	else if(a+b<c+d)
	{
		cout<<"Right"<<endl;
		return 0;
	}
	else
	{
		cout<<"Balanced"<<endl;
		return 0;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
const ll mod=1000000007;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
// head
ll n,ans,res;

int main() {
	scanf("%lld",&n);
  ans += n/11;
  ans*=2;
  if(n%11<=6){
    ans += 1;
  }
  else{
    ans+=2;
  }
  if(n%11<=0){
    ans += -1;
  }
  printf("%lld",ans);
}

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

// #undef DEBUG  // Uncomment this line to forcefully disable debug print.
#if DEBUG
template <typename T>
void debug(T value) {
  std::cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  std::cerr << value << ", ";
  debug(args...);
}
#define dbg(...)                              \
  do {                                        \
    cerr << #__VA_ARGS__ << ": ";             \
    debug(__VA_ARGS__);                       \
    cerr << " (L" << __LINE__ << ")" << endl; \
  } while (0)
#else
#define dbg(...)
#endif

void read_from_cin() {}
template <typename T, typename... Ts>
void read_from_cin(T& value, Ts&... args) {
  std::cin >> value;
  read_from_cin(args...);
}
#define in(type, ...) \
  type __VA_ARGS__;   \
  read_from_cin(__VA_ARGS__);

template <typename T>
void write_to_cout(const T& value) {
  std::cout << value << std::endl;
}
template <typename T, typename... Ts>
void write_to_cout(const T& value, const Ts&... args) {
  std::cout << value << ' ';
  write_to_cout(args...);
}
#define out(...) write_to_cout(__VA_ARGS__);

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

using ll = long long;

using namespace std;

int main() {
  in(int, n);
  ll minus = 0, mini = numeric_limits<ll>::max(), sum = 0;
  rep(i, n) {
    in(ll, a);
    if (a < 0) {
      ++minus;
      a = -a;
    }
    sum += a;
    mini = min(mini, a);
  }
  if (minus % 2 == 1) {
    sum -= mini * 2;
  }
  out(sum);
}


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

#define FOR(i,a,n) for (int i = a; i < (int)n; ++i)
#define REP(i,n) FOR(i,0,n)
#define whole(f,x,...) ([&](decltype((x)) whole) { \
    return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)
template<typename T> bool chmin(T &a, const T &b) {if (a > b) { a = b; return true; }return false;}
template<typename T> bool chmax(T &a, const T &b) {if (a < b) { a = b; return true; }return false;}

using ll = int_fast64_t;

constexpr ll INF = (1e9);
constexpr ll MOD = (1e9+7);

char march[] = {'M', 'A', 'R', 'C', 'H'};

int main() {
  int n; cin >> n;
  vector<string> s(n); REP(i,n) cin >> s[i];
  vector<ll> cnt(5);
  REP(i,n) {
    REP(j,5) {
      if (s[i][0] == march[j]) cnt[j]++;
    }
  }
  ll ans = 0;
  REP(i,5) FOR(j, i+1, 5) FOR(k, j+1, 5) {
    ans += cnt[i]*cnt[j]*cnt[k];
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 6144
#include <bits/stdc++.h>
#include <string>
#include <vector>
#include <algorithm>
#include <iostream>
#include <set>
using namespace std;

int main(){
    int n,q;
    cin >> n >> q;
    string s;
    cin >> s;

    vector<int> l(q);
    vector<int> r(q);

    for(int i=0;i<q;i++){
        cin >> l[i] >> r[i];
    }

    int count=0;

    vector<int> Sums(n+1);

    
    Sums[0]=0;
    for(int i=1;i<n+1;i++){
        if(s[i-2]=='A' && s[i-1]=='C'){
            Sums[i] = Sums[i-1] + 1;
        }
        else{
            Sums[i] = Sums[i-1];
        }
    }

    for(int i=0;i<q;i++){
        cout << Sums[r[i]] - Sums[l[i]] << endl;
    }

    /*for(int i=0;i<q;i++){
        count = 0;
        for(int j=l[i];j<r[i];j++){
            if(s[j-1]=='A' && s[j]=='C'){
                count++;
            }
        }
        cout << count << endl;
    }*/

    /*for(int i=0;i<n+1;i++){
        cout << Sums[i];
    }*/

}

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

using namespace std;

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

    vector<pair<int, int> > vt(N);
    for (int i = 0; i < N; ++i) {
        int a, b;
        cin >> a >> b;
        vt.emplace_back(make_pair(a, b));
    }
    sort(vt.begin(), vt.end(), greater<>());

    cout << vt[0].first + vt[0].second << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stdlib.h>
#include <math.h>
#include <numeric>


int main() {
	int n;

	std::cin >> n;

	double ans = 0;

	for (size_t i = 0; i < n; i++)
	{
		double a;
		std::cin >> a;

		ans += 1.0 / a;
	}

	std::cout << std::fixed << 1 / ans << std::endl;

	return 0;
}

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

int main()
{
    double a,b,c,d,e,f;
    
    while(cin >> a >> b >> c >> d >> e >> f)
    {


    double A = a*e-b*d;
    double ans1, ans2;
    ans1 = (c*e - b*f)/A;
    ans2 = (-c*d + a*f)/A;
    if(ans1<0.0005 && ans1> -0.0005) ans1 = 0;
    if(ans2<0.0005 && ans2> -0.0005) ans2 = 0;

    printf("%1.3f %1.3f\n",ans1,ans2);
    }
    return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <cmath>
#include <numeric>
#include <iomanip>
#include <deque>
#include <tuple>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <sstream>
#include <stdexcept>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>

#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define FOR(i, a, done) for (int i = (a); i < (done); ++i)
#define all(a) (a).begin(), (a).end()
#define x first
#define y second
#define debug(a) cout << (a) << endl
namespace mp = boost::multiprecision;
using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;
template <class T>
bool chmax(T &a, const T &b)
{
	if (a < b)
	{
		a = b;
		return 1;
	}
	return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
	if (a > b)
	{
		a = b;
		return 1;
	}
	return 0;
}

ll M = 1000000007;

void solve()
{
	int n;
	cin>>n;
	vector<int>a(n);
	rep(i,n){
		cin>>a[i];
	}
	ll step=0;
	int now=a[0];
	FOR(i,1,n){
		if(now<a[i]){
			now=a[i];
		}else{
			step+=now-a[i];
		}
	}
	cout<<step<<endl;
}

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


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

#define MAX 2000000
#define INFTY (1<<30)

int H;

int left(int i) {
    return i * 2;
}

int right(int i) {
    return i * 2 + 1;
}

int parent(int i) {
    return i / 2;
}


void maxHeapify(vector<int> &A, int i) {
    int l = left(i);
    int r = right(i);

    int largest;

    if (l <= H && A.at(l) > A.at(i)) {
        largest = l;
    }
    else {
        largest = i;
    }

    if (r <= H && A.at(r) > A.at(largest)) {
        largest = r;
    }

    if (largest != i) {
        swap(A.at(i), A.at(largest));
        maxHeapify(A, largest);
    }
}

int extract(vector<int> &A) {
    int maxv;
    if ( H < 1 ) {
        return -INFTY;
    }
    maxv = A.at(1);
    A.at(1) = A.at(H);
    H--;
    maxHeapify(A, 1);
    return maxv;
}

void increaseKey(int i, int key, vector<int> &A) {
    if ( key < A.at(i)) {
        return;
    }

    A.at(i) = key;
    
    while ( i > 1 && A.at(parent(i)) < A.at(i)) { // iの親より大きい場合、親とiのkeyを入れ替える
        swap(A.at(i), A.at(i / 2));
        i = i / 2;
    }
}

void insert(int key, vector<int> &A)
{
    H++;
    A.at(H) = -INFTY;
    increaseKey(H, key, A);
}

int main() {
    string cmd;
    int key;
    vector<int> A(MAX+1);

    while (true)
    {
        cin >> cmd;

        if (cmd == "insert") {
            cin >> key;
            insert(key, A);
        }

        if (cmd == "extract") {
            cout << extract(A) << endl;
        }
        if (cmd == "end") {
            break;
        }
    }
}


Measured memory_bytes: 10576
n = int(input().rstrip())
a = list(map(int, input().rstrip().split()))
b = list(map(int, input().rstrip().split()))
c = list(map(int, input().rstrip().split()))

pre_ai = 20
sum = 0
for i in range(n):
	ai = a[i] - 1
	sum = sum + b[ai]
	if (pre_ai + 1) == ai:
		sum = sum + c[pre_ai]

	pre_ai = ai

print(sum)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
 
using namespace std;
 
typedef vector< int > vi;
typedef vector< vi > vvi;
typedef pair< int,int > ii;
#define ll	long long
#define sz(a) int((a).size())
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(typeof((c)).begin() i = (c).begin(); i != (c).end(); i++)
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define fastio	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define hell 1000000007
#define PI 3.141592653589793
 
int main() 
{	fastio;
	int testcases = 1;
	//cin>>testcases;
	while (testcases--) {
		string s;
		cin>>s;
		int l = sz(s);
		for (int i = 0; i < l; i++) {
			if (s[i] == '?') s[i] = 'D';
			
		}
		cout<<s;
		cout<<"\n";	
	}
    return 0; 
}


Measured memory_bytes: 3772
while line = gets
	n, x = line.split( " " ).map { | val | val.to_i }
	break if 0 == n && 0 == x

	cnt = 0
	for i in ( 1 .. n-2 )
		for j in ( i+1 .. n-1 )
			if	x < ( i+j )
				break
			end
			for k in ( j+1 .. n )
				s = ( i + j + k )
				if x == s
					cnt += 1
					break
				elsif	x < s
					break
				end
			end
		end
	end
	
	puts( cnt )
end

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
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 ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}
ll factorial(ll n) {
  if (n == 1) {
    return 1;
  }
  ll ans = factorial(n-1);
  return ans*n;
}
ll gcd(ll a, ll b) {
  if (a < b) {
    ll tmp = a;
    a = b;
    b = tmp;
  }
  ll r = a%b;
  while(r != 0) {
    a = b;
    b = r;
    r = a%b;
  }
  return b;
}
ll lcm(ll a, ll b) {
  return (a/gcd(a, b))*b;
}

int main() {
  ll n;
  cin >> n;
  vector <ll> v(n);
  rep(i, n) cin >> v.at(i);
  ll ans = 1LL;
  rep(i, n) ans = lcm(ans, v.at(i));
  cout << ans << endl;
}

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

// constexpr size_t MAX = 1e5;
// vector<size_t> friends[MAX];
// bool blocks[MAX][MAX];

struct UnionFind {
    vector<int> d;
    UnionFind(int n): d(n, -1) {}
    int root(int x) {
        if (d[x] < 0) return x;
        return d[x] = root(d[x]);
    }
    bool unite(int x, int y) {
        x = root(x); y = root(y);
        if(x==y) return false;
        if(d[x] > d[y]) swap(x, y);
        d[x] += d[y];
        d[y] = x;
        return true;
    }
    bool same(int x, int y) {return root(x) == root(y);}
    int size(int x) { return -d[root(x)]; }
};
int deg[100005];
vector<int> to[100005];


signed main()
{
    int N, M, K;
    cin >> N >> M >> K;
    UnionFind uf(N);
    rep(_, M) {
        int i, j;
        cin >> i >> j;
        i--; j--;
        deg[i]++; deg[j]++;
        uf.unite(i, j);
        // friends[i].push_back(j);
        // friends[j].push_back(i);
    }
    rep(_, K) {
        int i, j;
        cin >> i >> j;
        i--; j--;
        to[i].push_back(j);
        to[j].push_back(i);
    }
    rep(i, N) {
        int ans = uf.size(i) - 1 - deg[i];
        for(auto u : to[i]) {
            if(uf.same(i, u)) ans--;
        }
        printf("%d ", ans);
    }

    return 0;
}



Measured memory_bytes: 6784