akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll mod=1000000007;
const int MAX_N = 1000;         // n の最大値
 
int main() {
ll n;
cin>>n;
ll f=0;
ll counter=0;
ll a[n+2]={};
for(ll i=1; i<=n; i++){
cin>>a[i];}
for(ll i=1; i<=n; i++){
if(a[i]%2==0){
counter+=a[i]/2;
continue;}
else if(a[i+1]>0){
counter+=a[i]/2;
counter++;
a[i+1]--;}
else{
counter+=a[i]/2;}}
cout<<counter<<endl;}


Measured memory_bytes: 1024
# ABC143E - Travel by Car
# https://atcoder.jp/contests/abc143/submissions/8051337
import sys
import numpy as np

from scipy.sparse import csr_matrix
from scipy.sparse.csgraph import floyd_warshall


def main():
    # FW -> once more FW to edges <= L
    read = sys.stdin.buffer.read
    N, M, L, *X = map(int, read().split())
    ABC, ST = X[: 3 * M], X[3 * M + 1 :]
    A, B, C, S, T = ABC[::3], ABC[1::3], ABC[2::3], ST[::2], ST[1::2]

    G = csr_matrix((C, (A, B)), (N + 1, N + 1))
    dist = floyd_warshall(G, directed=0)  # naive distance

    # assume distance within L as 1 and compute the number of fueling
    modified_G = np.full((N + 1, N + 1), np.inf)
    np.fill_diagonal(modified_G, 0)
    modified_G[dist <= L] = 1
    modified_dist = floyd_warshall(modified_G, directed=0)
    modified_dist[modified_dist == np.inf] = 0
    modified_dist = (modified_dist).astype(int)

    ans = modified_dist[S, T] - 1
    print("\n".join(ans.astype(str)))


if __name__ == "__main__":
    main()

Measured memory_bytes: 45540
#include<bits/stdc++.h>
#define N 200100
using namespace std;
const int INF=1008610086;
const int MOD=1e9+7;
inline void read(int &a){
	int f=a=0;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-') f=1;ch=getchar();}
	while(ch<='9'&&ch>='0') a=a*10+ch-'0',ch=getchar();
	if(f) a=-a;
}
struct Node{
	int x,v,l,r;
}a[N];
inline bool cmpx(Node a,Node b){
	return a.x<b.x;
}
inline bool cmpv(Node a,Node b){
	return a.v<b.v;
}
int n,f[N];
int xds[N<<2];
inline int query(int l,int r,int k,int x,int y){
	if(l==x&&r==y) return xds[k];
	int mid=l+r>>1;
	if(y<mid+1) return query(l,mid,k<<1,x,y);
	else if(x>mid) return query(mid+1,r,k<<1|1,x,y);
	return (query(l,mid,k<<1,x,mid)+query(mid+1,r,k<<1|1,mid+1,y))%MOD;
}
inline void xg(int l,int r,int k,int x,int v){
	if(l==x&&r==x){
		xds[k]+=v;
		return;
	}
	int mid=l+r>>1;
	if(x<mid+1) xg(l,mid,k<<1,x,v);
	else xg(mid+1,r,k<<1|1,x,v);
	xds[k]=(xds[k<<1]+xds[k<<1|1])%MOD;
}
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		read(a[i].x);
		read(a[i].v);
	}
	sort(a+1,a+n+1,cmpv);
	for(int i=1;i<=n;i++) a[i].v=i;
	sort(a+1,a+n+1,cmpx);
	int ma=-INF,mi=INF;
	for(int i=1;i<=n;i++){
		ma=max(ma,a[i].v);
		a[i].r=ma;
	}
	for(int i=n;i;i--){
		mi=min(mi,a[i].v);
		a[i].l=mi;
	}
	int l=0;
	xg(1,n+2,1,1,1);
	a[0].l=1;
	a[n+1].l=a[n+1].r=n+1;
	for(int i=1;i<=n+1;i++){
		while(l<i&&a[i].l>a[l].r+1) l++;
		f[i]=query(1,n+2,1,l+1,i+1);
		xg(1,n+2,1,i+1,f[i]);
	}
	printf("%d\n",f[n+1]);
	return 0;
}

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

int main(int argc, const char * argv[]) {
    vector<int> v;
    int x;
    
    for (int i = 0; i < 3; i++) {
        cin >> x;
        v.push_back(x);
    }
    sort(v.begin(), v.end());
    cout << v[0] + v[1] << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<string>
#include<cstdio>
#define inf 1e16
#define N 100002
using namespace std;
typedef long long LL;
LL n,a[N],r_ans,ans;
int main()
{
	scanf("%lld",&n);
	for (int i = 1;i <= n; ++i)
		scanf("%lld",&a[i]);
	r_ans = inf;
	for (int o = 0;o < 2; ++o)
	{ 
		LL sum = 0; 
		ans = 0;
		bool x = o;
		for (int i = 1;i <= n; ++i)
		{
			x ^= 1;
			sum += a[i];
			if (!sum) 
			{
				++ans;
				if (x) sum = 1;
				else sum = -1;
			}
			else
			if (!(x == (sum > 0)))
			{ 
				if (x) ans += (1 - sum),sum = 1;
				else ans += (sum + 1),sum = -1;
			}
		}
			//if (x == (sum <= 0)) 
		r_ans = min(r_ans,ans);
	}
	cout<<r_ans;
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b) - 1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)

#define PB push_back
#define INF INT_MAX/3
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define CLR(a) memset(a,0,sizeof(a))

typedef long long int ll;

using namespace std;

int main(){
    while(true){
	string s,ss;
	cin >> s >> ss;
	if(s == "0") break;
	int hit = 0;
	int blow = 0;
	REP(i,s.size()){
	    REP(j,ss.size()){
		if(s[i] == ss[j]){
		    if(i == j) hit++;
		    else blow++;
		}
	    }
	}
	cout << hit << " " << blow<<endl;
    }
    return 0;
}

Measured memory_bytes: 1188
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    println(problem073a(n))
}

fun problem073a(n: Int): String {
    return when {
        n == 9 -> "Yes"
        n > 88 -> "Yes"
        n.toString().takeLast(1) == "9" -> "Yes"
        else -> "No"
    }
}

Measured memory_bytes: 29348
#include<bits/stdc++.h>
#define ll long long int
#define ld long double
#define inf LLONG_MAX>>2
#define MAX 1000000
#define mod 1000000007
#define pb push_back
#define f(i,a,n,x) for ((i)=(a);(i)<(n);(i)+=(x))
#define fd(i,a,n,x) for ((i)=(a);(i)>=(n);(i)-=(x))
#define fi first
#define se second
#define mk make_pair
#define pi pair
#define vt vector
#define ms multiset
#define is insert
using namespace std;
void read(vt<ll> &a,ll n){ll i,temp;f(i,0,n,1){cin>>temp;a.pb(temp);}}
ll fa[MAX];
ll power(ll p,ll q){
    ll res=1;
    p%=mod;
    while(q){
        if (q&1)
            res=(res*p)%mod;
        q>>=1;
        p=(p*p)%mod;
    }
    return res;
}
ll fact(ll n){
    if (n<=1)
        return fa[n]=1;
    if (fa[n])
        return fa[n];
    return fa[n]=(n*fact(n-1))%mod;
}
ll ncr(ll n,ll r){
    if (!r)
        return 1;
    return (((fact(n)*power(fact(n-r),mod-2))%mod)*power(fact(r),mod-2))%mod;
}
void solve(){
    ll n,i,j,k,count=0;
    vt<ll> a;
    cin>>n;
    read(a,n);
    f(i,0,n,1)
        f(j,i,n,1)
            f(k,j,n,1)
                if (a[i]!=a[j] && a[i]!=a[k] && a[j]!=a[k] &&
                    a[i]+a[j]>a[k] && a[i]+a[k]>a[j] && a[j]+a[k]>a[i])
                        count++;
    cout<<count<<endl;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll t=1;
    //cin>>t;
    while(t--)
        solve();
    return 0;
}

Measured memory_bytes: 3656
#include <stdio.h>

#define MAX 100

using namespace std;

int numbers[MAX];

void trace(int a[], int n)
{
    for (int i = 0; i < n; i++) {
        if (i > 0) printf(" ");
        printf("%d", a[i]);
    }
    printf("\n");
}
void insersionSort(int a[], int n)
{
    int i, j, pivot;
    for (int i = 1; i < n; i++) {
        pivot = a[i];
        j = i - 1;
        while ((a[j] > pivot) && (j >= 0)) {
            a[j + 1] = a[j];
            j--;
        }
        a[j + 1] = pivot;
        trace(a, n);
    }
}

int main()
{
    int n, i, j;
    scanf("%d", &n);
    for (i = 0; i < n; i++) {
        scanf("%d", &numbers[i]);
    }
    trace(numbers, n);
    insersionSort(numbers, n);

    return 0;
}

Measured memory_bytes: 2648
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5 + 10;
vector<int> adj[MAXN];
int n, a, t;

vector<int> bfs(int s){
	vector<int> d(n + 1, 1e9 + 1);
	d[s] = 0;
	queue<int> q;
	q.push(s);
	while (q.size()){
		int u = q.front();
		q.pop();
		for (int v : adj[u]){
			if (d[v] > 1e9){
				d[v] = d[u] + 1;
				q.push(v);
			}
		}
	}
	return d;
}

int main(){
	ios::sync_with_stdio(0);
	cout << setprecision(10) << fixed;
	cin >> n >> t >> a;
	for (int i = 0; i < n - 1; ++i){
		int u, v;
		cin >> u >> v;
		adj[u].push_back(v);
		adj[v].push_back(u);
	}
	vector<int> da = bfs(a);
	vector<int> dt = bfs(t);
	int ans = 0, prev = n + 1;
	for (int i = 1; i <= n; ++i){
		if (dt[i] < da[i]) ans = max(ans, da[i]);
	}
	cout << ans - 1;
	return 0;
}



Measured memory_bytes: 6656
/*hello guys！~*/ 
#include<bits/stdc++.h>
using  namespace std;
typedef long long ll;
int go(ll n)
{
	string str;
	while(n>0){
		int m=n%26;
		if(m==0) m=26;
		str+=(char)(m+96);
		n=(n-m)/26;
	}
	reverse(str.begin(),str.end());
	cout<<str<<endl;
	return 0;
}
int main()
{
	ll a;
	scanf("%lld",&a);
	if(a<=26)
	printf("%c",a+'a'-1);
	else 
	{
		go(a);
	}
	return 0;
} 

Measured memory_bytes: 3724
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }

typedef long long ll;

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; }

const int INF = 1e9;
const ll INFLL = 1e18;
const ll MOD = 1e9+7;
const double PI = acos(-1.0);

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

/*------------------------------------/
for library*/

/*------------------------------------*/

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    int N;
    string S;
    cin>>N>>S;
    set<string> set1pre,set2pre,set3;
    string y = "";
    y.push_back(S[0]);
    set1pre.insert(y);
    rep1(i,N){
        set<string> set1,set2;
        string xx = "";
        xx.push_back(S[i]);
        set1.insert(xx);
        for(auto x1:set1pre){
            set1.insert(x1);
            x1.push_back(S[i]);
            set2.insert(x1);
        }
        for(auto x2:set2pre){
            set2.insert(x2);
            x2.push_back(S[i]);
            set3.insert(x2);
        }
        swap(set1pre,set1);
        swap(set2pre,set2);
    }
    /*
    for(auto x:set1pre){
        cerr<<x<<endl;
    }
    cerr<<endl;
    for(auto x:set2pre){
        cerr<<x<<endl;
    }
    cerr<<endl;
    for(auto x:set3){
        cerr<<x<<endl;
    }
    cerr<<endl;
    */
    cout<<set3.size()<<endl;

}

Measured memory_bytes: 384
import sys
input = sys.stdin.buffer.readline
sys.setrecursionlimit(1000000000)

N, *XY = map(int,open(0).read().split())
MOD = 10**9 + 7

neighbor = [[] for _ in range(N)]
for x,y in zip(*[iter(XY)]*2):
    neighbor[x-1] += y-1,
    neighbor[y-1] += x-1,

memo = [[-1]*2 for _ in range(N)]

def dp(node, color, parent):
    if memo[node][color] != -1:
        return memo[node][color]
    output = 1
    for child in neighbor[node]:
        if child == parent:
            pass
        else:
            tmp = dp(child, 0, node)
            if color == 0:
                tmp += dp(child, 1, node)
            output *= tmp
            output %= MOD
    memo[node][color] = output
    return output

print((dp(0,0,-1) + dp(0,1,-1)) % MOD)

Measured memory_bytes: 260696
#include<iostream>
#include<vector>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#include<deque>
#include<map>
#include<bitset>
using namespace std;

typedef long long ll;
#define rep(i, n) for(int i = 0;i < (n);i++)
#define repr(i, n) for(int i = (n);i >= 0;i--)
#define repf(i, m, n) for(int i = (m);i < (n);i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1;} return 0;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1;} return 0;}
int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
//////////////////////////////////////////////////


int main() {
    double l; cin >> l;
    l /= 3.0;
    printf("%.7lf\n", l*l*l);
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#define MAX 100000
#define inf 1000000000

typedef struct {
  char suit;
  int value;
} Card;

Card L[MAX / 2],R[MAX / 2];

void merge(Card A[], int n, int left, int mid, int right) {
  int i,j,k,n1,n2;

  n1 = mid - left;
  n2 = right - mid;

  for(i = 0;i < n1;i++) L[i] = A[left + i];
  for(i = 0;i < n2;i++) R[i] = A[mid + i];
  L[n1].value = R[n2].value = inf;
  i = j = 0;
  for(k = left;k < right;k++) {
    if(L[i].value <= R[j].value) {
      A[k] = L[i++];
    }
    else {
      A[k] = R[j++];
    }
  }
}

void mergeSort(Card A[], int n, int left, int right) {
  int mid;

  if(left + 1 < right) {
    mid = (left + right) / 2;
    mergeSort(A,n,left,mid);
    mergeSort(A,n,mid,right);
    merge(A,n,left,mid,right);
  }
}

int partition(Card A[], int n, int p, int r) {
  int i,j;
  Card t,x;

  x = A[r];
  i = p - 1;
  for(j = p;j < r;j++) {
    if(A[j].value <= x.value) {
      i++;
      t = A[i];
      A[i] = A[j];
      A[j] = t;
    }
  }
  t = A[i + 1];
  A[i + 1] = A[r];
  A[r] = t;

  return i + 1;
}

void quickSort(Card A[], int n, int p, int r) {
  int q;

  if(p < r) {
    q = partition(A,n,p,r);
    quickSort(A,n,p,q - 1);
    quickSort(A,n,q + 1,r);
  }
}

int main() {
  int n,i,v,stable = 1;
  Card A[MAX],B[MAX];
  char S[10];
  
  scanf("%d",&n);

  for(i = 0;i < n;i++) {
    scanf("%s%d",S,&v);
    A[i].suit = B[i].suit = S[0];
    A[i].value = B[i].value = v;
  }

  mergeSort(A,n,0,n);
  quickSort(B,n,0,n - 1);
  for(i = 0;i < n;i++) {
    if(A[i].suit != B[i].suit) stable = 0;
  }

  if(stable == 1) printf("Stable\n");
  else printf("Not stable\n");
  for(i = 0;i < n;i++) {
    printf("%c %d\n",B[i].suit,B[i].value);
  }

  return 0;
}



Measured memory_bytes: 4124
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,ans;
  ans=0;
  cin>>a;
  if(100>a){
    ans=min(9,a);
  }
  else if(10000>a){
    ans=min(a-99,900);
    ans=ans+9;
  }
  else{
    ans=min(a-9999,90000);
    ans=ans+909;
  }
  cout<<ans;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
double n,a[100866];
double ans,sum;
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin >> a[i];
		sum += (1 / a[i]);
	}
	cout << (1 / sum) << endl;
	return 0;
}

Measured memory_bytes: 256
import scala.collection.mutable.ListBuffer
import scala.io.StdIn

object Main extends App {

  var temp = Array(-1, -1)
  val buff = new ListBuffer[(Int, Int)]
  while(temp(0) != 0 && temp(1) != 0){
    temp = StdIn.readLine().split(' ').map(_.toInt)
    buff += ((temp(0), temp(1)))
  }

  val even = "."
  val odd  = "#"
  
  val result = buff.dropRight(1).map { case (h, w) =>
    (0 until h).map { j =>
      if(j % 2 == 0){
        (0 until w).map(k => if(k%2==0) "#" else ".").mkString("")
      } else {
        (0 until w).map(k => if(k%2==0) "." else "#").mkString("")
      }
    }.mkString(f"%n")
  }
  println(result.mkString(f"%n%n"))
  println("")
}


Measured memory_bytes: 47036
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vl = vector<long>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvb = vector<vector<bool>>;
using vvc = vector<vector<char>>;
using pii = pair<int, int>;
using pll = pair<long, long>;
#define fix20 cout << fixed << setprecision(20);
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define MOD 1000000007
#define all(vec) vec.begin(), vec.end()

int main(){
    long h,w;
    cin >> h >> w;
    if(h == 1 || w == 1) cout << 1 << endl;
    else cout << (h*w+1)/2<< endl;
}

Measured memory_bytes: 256
#include <cstring>
#include <iostream>
#include <math.h>
#include <stdio.h>

#define arrayLength(array) (size_t)((sizeof array) / (sizeof array[0]))

int main() {
  int n = 0, m = 0, x = 0, y = 0, z = 0, a = 0, b = 0;

  char s[255];
  char t;

  //   scanf(" %d %d %d %d", &n, &m, &x, &y);
  scanf("%d %d", &n, &m);
  for (int i = 0; i < n; i++) {
    scanf(" %d", &a);
    if (a >= m)
      x += 1;
  }
  printf("%d", x);

  return 0;
}


Measured memory_bytes: 256
#include <iostream>

int main(void){
    int coinPerDay, coinBonus, coinNeeded;
    int day = 0;
    int nowMyCoin = 0;
    
    std::cin >> coinPerDay >> coinBonus >> coinNeeded;
    
    while(nowMyCoin < coinNeeded){
        nowMyCoin += coinPerDay;
        //if the day is 7th from start
        if((++day % 7) == 0){
            nowMyCoin += coinBonus;
        }
    }
    
    std::cout << day << std::endl;
}


Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, o, n) for (auto i = (o); (i) < (n); ++(i))
#define FOR1(i, n) FOR(i, 1, n+1)
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (auto i = (n)-1; (i) >= 0; --i)
#define REPI(itr, v) for (auto itr = v.begin(); itr != v.end(); ++itr)
#define REPIR(itr, v) for (auto itr = v.rbegin(); itr != v.rend(); ++itr)
#define fi first
#define se second
#define ll long long
#define int long long
#define V2(name, h, w) vector<vector<int> > name((h), vector<int>(w));
#define myCeil(dividend, divisor) ceil((double)(dividend) / (double)(divisor))
#define myFloor(dividend, divisor) floor((double)(dividend) / (double)(divisor))
#define calcDigits(num) floor(log10(num))+1

#define dl(line) cerr << "RUN: until " << (line) << "th line." << endl
#define dv(name, value) cerr << (name) << " is " << (value) << endl
#define da(v)  cerr << "["; REPI(itr, v){cerr << *itr << (itr != --v.end() ? ", " : "");} cerr << "]" << endl


signed main(){
  long long N;
  scanf("%lld",&N);
  std::vector<pair<int, int>> A(N);
  REP(x, N) {
    cin >> A.at(x).fi;
    A.at(x).se = x+1;
  }
  sort(A.begin(), A.end());
  REP(x, N) cout << A.at(x).se << ' ';
  cout << endl;
}


Measured memory_bytes: 2432
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static System.Console;
using static System.Math;

namespace ABC_prac
{
    class Program
    {
        static void Main(string[] args)
        {
            var cin = ReadInts();
            int k = cin[0];
            int s = cin[1];
            int ans = 0;
            for (int x = 0; x <= k; x++)
            {
                for (int y = 0; y <= k; y++)
                {
                    int z = s - x - y;
                    if (0<=z && z<=k)
                    {
                        ans++;
                    }

                }
            }
            WriteLine("{0}", ans);

            Read();
        }

        private static string Read() { return ReadLine(); }
        private static char[] ReadChars() { return Array.ConvertAll(Read().Split(), a => a[0]); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }

    }

}


Measured memory_bytes: 13268
#pragma GCC optimize(2)

#include "bits/stdc++.h"

using namespace std;

//#define _DEBUG
#define all(a) begin(a), end(a)
#define MOD 1000000007
#define PII pair<int, int>
#define complete_unique(a) a.erase(unique(begin(a), end(a)), end(a))
#define mst(x, a) memset(x, a, sizeof(x))
typedef vector<int> VI;
typedef long long ll;

ll quick_pow(ll a, ll b) {
    long long res = 1;
    while (b) {
        if (b & 1)
            res = a * res;
        a = a * a;
        b >>= 1;
    }
    return res;
}

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

bool is_prime(int n) {
    if (n == 0) return false;
    if (n == 1) return false;
    if (n == 2) return true;
    if (n % 2 == 0) return false;
    int j = sqrt(n);
    for (int i = 2; i <= j; ++i) {
        if (n % i == 0) return false;
    }
    return true;
}

ll reverse_num(ll n) {
    ll x = 0, t = n;
    while (t != 0) {
        x = x * 10 + t % 10;
        t /= 10;
    }
    return x;
}

const int N = 1005;
int mem[N][N];
vector<vector<int>> road;
int r;

int dfs(int row, int col) {
    if (mem[row][col] != -1) {
        return mem[row][col];
    }
    if (row == r) {
        return 0;
    }
    int res = max(dfs(row + 1, col), dfs(row + 1, col + 1)) + road[row][col];
    mem[row][col] = res;
    return res;
}

void solve() {
    ll k, x;
    cin >> k >>x ;
    if (k*500 >= x) {
        cout <<"Yes";
    } else {
        cout << "No";
    }
}

int main() {
#ifdef _DEBUG
    freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
#endif
    // 加速输入和输出
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int t = 1;
//    cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}



Measured memory_bytes: 3564
using System;
using System.Collections.Generic;
using System.Linq;
class Program{
	static List<int>[] li;
	static int[] s;
	static void Main(){
		Sc sc=new Sc();
		s=sc.Ia;
		li=new List<int>[s[0]+1];
		int[] h=new int[s[0]+1];
		h[0]=-1;
		int[] ans=new int[s[0]];
		for(int i = 1;i<=s[0];i++) {
			li[i]=new List<int>();
			ans[i-1]=-1;
		}
		for(int i = 0;i<s[0]+s[1]-1;i++) {
			int[] q=sc.Ia;
			li[q[0]].Add(q[1]);
			h[q[1]]++;
		}
		var pq=new Pq<Mo<int[]>>(s[0]+s[1]);
		for(int i = 1;i<=s[0];i++) {
			if(h[i]==0){
				ans[i-1]=0;
				for(int j=0;j<li[i].Count;j++){
					pq.Push(new Mo<int[]>(0,new int[]{li[i][j],i}));
				}
				break;
			}
		}
		while(pq.count>0){
			h[pq.Top().d[0]]--;
			if(h[pq.Top().d[0]]==0){
				ans[pq.Top().d[0]-1]=pq.Top().d[1];
				for(int j=0;j<li[pq.Top().d[0]].Count;j++){
					pq.Push(new Mo<int[]>(pq.Top().n+1,new int[]{li[pq.Top().d[0]][j],pq.Top().d[0]}));
				}
			}
			pq.Pop();
		}
		Console.WriteLine(String.Join("\n",ans));
	}
	static void Fu(int a,int b){
		for(int i=0;i<li[a].Count;i++) {
			
		}
	}
	static int ca(long[] a,long[] b){
		if(a[0]+b[0]<a[0]+b[0]){return 1;}
		else if(a[0]+b[0]>a[0]+b[0]){return -1;}
		else{return 0;}
	}
}
public class Mo<T>:IComparable{
	public int n;
	public T d;
	public Mo(int n,T d){this.n=n;this.d=d;}
	public int CompareTo(object obj){
		Mo<T> mymo=(Mo<T>)obj;
		if(mymo.n>this.n){return -1;}
		else if(mymo.n<this.n){return 1;}
		else{return 0;}
	}
}
public class Pq<T> where T:IComparable{
	private T[] he;
	public int count=0;
	public Pq(int max){he=new T[max];}
	public void Push(T x){
		int j=count;
		while(j!=0&&Compare(x,he[(j-1)/2])>0){he[j]=he[(j-1)/2];j=(j-1)/2;}
		he[j]=x;
		count++;
	}
	public void Pop(){
		count--;
		T r=he[count];
		int j=0;
		while(true){
			if(j*2+1<count){
				if(Compare(he[j*2+1],he[j*2+2])>0){j=j*2+1;}
				else{j=j*2+2;}
			}
			else if(j*2<count){j=j*2+1;}
			else{break;}
			if(Compare(he[j],r)<=0){j=(j-1)/2;break;}
			he[(j-1)/2]=he[j];
		}
		he[j]=r;
	}
	private int Compare(T x,T y){return y.CompareTo(x);}
	public int Count(){return count;}
	public T Top(){return he[0];}
}

class Sc{
	public int I{get{return int.Parse(Console.ReadLine());}}
	public long L{get{return long.Parse(Console.ReadLine());}}
	public double D{get{return double.Parse(Console.ReadLine());}}
	public string S{get{return Console.ReadLine();}}
	public int[] Ia{get{return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
}

Measured memory_bytes: 34916
/*input
10
5 3
5 7
8 9
1 9
9 10
8 4
7 4
6 10
7 2
*/

#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <climits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include <stdint.h>
 
using namespace std;
 
/*******  All Required define Pre-Processors and typedef Constants *******/
#define scd(t) scanf("%d",&t)
#define scld(t) scanf("%ld",&t)
#define sclld(t) scanf("%lld",&t)
#define scc(t) scanf("%c",&t)
#define scs(t) scanf("%s",t)
#define scf(t) scanf("%f",&t)
#define sclf(t) scanf("%lf",&t)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define FOREACH(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define tests int t; cin >> t; while(t--)
#define MP make_pair
#define PI acos(-1)
typedef pair<int, int> PII;
typedef pair<double, double> PDD;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef map<int,int> MPII;
typedef set<int> SETI;
typedef multiset<int> MSETI;
typedef long int int32;
typedef unsigned long int uint32;
typedef long long int int64;
typedef unsigned long long int  uint64;
#define godspeed ios_base::sync_with_stdio(false); cin.tie(NULL);

#define MOD(x) ((x)%(1000000007))

int main() {
	godspeed;
	int n;
	cin >> n;
	int64 u, v;
	int64 numComp = 0;
	for(int64 i = 1; i < n; i++) {
		numComp += i*(n-i+1); 
		cin >> u >> v;
		numComp -= min(u, v)*(n-max(u, v)+1); 
	}
	numComp += n;
	cout << numComp << endl;
}


/*
Let S be the set of the vertices numbered L through R. 
f(L,R) represents the number of connected components in 
the subgraph formed only from the vertex set S and the edges
whose endpoints both belong to S.

None of these connected components can have a cycle because 
G is a tree. Therefore all connected components are trees.
In a tree num V = num E + 1 so adding all connected comps
num V in all connected comps = num E in all connected comps + 
num connected comps

Therefore f(L, R) = (R-L+1) + num E whose u_i \in [L, R] and 
v_i \in [L, R]

Subtract this:
Each edge (L, R) is included L*(N-R+1) times where L<=R. 

Add this:
Each Vertex x is included X*(N-X+1) times.
*/

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

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

  cin >> a >> b >> c;

  if (a % 2 == 0 || b % 2 == 0 || c % 2 == 0)
    cout << 0;
  else
    cout << min(a * b, min(b * c, c * a));

  return 0;
}

Measured memory_bytes: 256
import math
N,D = map(int,input().split())
XY = [list(map(int,input().split())) for _ in range(N)]
cnt = 0
dis = 0
for i in range(N):
  dis = math.sqrt(XY[i][0]**2 + XY[i][1]**2)
  if dis <= D:
    cnt += 1
print(cnt)

Measured memory_bytes: 45460
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
using namespace std;
 
int main()
{
  int N, i, sum = 0;
  cin >> N;
  int V[N], C[N], S[N];
  for (int i = 0; i < N; i++)
    cin >> V[i];
  for (int i = 0; i < N; i++)
    cin >> C[i];
  for (int i = 0; i < N; i++)
    S[i] = V[i] - C[i];
  sort(S, S + N, greater<int>());
  i = 0;
  while (S[i] > 0 && i < N) {
    sum += S[i];
    i++;
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
x = int(input())
if 400 <= x <= 599:
    a = 8
elif x <= 799:
    a = 7
elif x <= 999:
    a = 6
elif x <= 1199:
    a = 5
elif x <= 1399:
    a = 4
elif x <= 1599:
    a = 3
elif x <= 1799:
    a = 2
else:
    a = 1
print(a)

Measured memory_bytes: 9176
/*
 * atcoder/abc089/b.cpp
 */

// C++ 14
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring> // memset
#include <cassert>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
void solve();
int main() { solve(); return 0; }

#define ld long double
void solve() {
  int n=3;
  vector<string> S(n);
  loop(i,0,n) cin >> S[i];
  loop(i,0,n) cout << (char)toupper(S[i][0]);
  cout << endl;
}


Measured memory_bytes: 3620
#include <cstdio>
#include <cmath>
#include <algorithm>
using namespace std;
#define EPS 1e-6

struct node{
  int x, y, len;
  double r;
  inline void cal_radius(double height){ r = sqrt(len * len - height * height); }
  inline void read(){ scanf("%d%d%d", &x, &y, &len); }
} nodes[20];

int n;

inline bool intersect(const node &a, const node &b){ return hypot(a.x - b.x, a.y - b.y) < a.r + b.r + EPS; }
inline double dist(const node &a, const node &b){ return hypot(a.x - b.x, a.y - b.y); }

inline bool check(double height){
  for(int i = 0; i < n; i++) nodes[i].cal_radius(height);
  
  for(int i = 0; i < n; i++)
  for(int j = i + 1; j < n; j++) 
    if(!intersect(nodes[i], nodes[j])) return false;
    
  double left[20], right[20];
  double maxx = 1000.0, mini = -1000.0, mid;
  
  for(int i = 0; i < n; i++) maxx = fmin(maxx, nodes[i].y + nodes[i].r);
  for(int i = 0; i < n; i++) mini = fmax(mini, nodes[i].y - nodes[i].r);
  
  while(maxx - mini > EPS){
    mid = (maxx + mini) * 0.5;
    
    for(int i = 0; i < n; i++){
      double half_chord = sqrt(nodes[i].r * nodes[i].r - (nodes[i].y - mid) * (nodes[i].y - mid));
      left[i] = nodes[i].x - half_chord;
      right[i] = nodes[i].x + half_chord;
    }
    
    bool up = false, down = false;
    for(int i = 0; i < n; i++)
    for(int j = i + 1; j < n; j++)
    if(fmax(left[i], left[j]) > fmin(right[i], right[j]) + EPS){
      double nxty = nodes[i].y + (nodes[j].y - nodes[i].y) * nodes[i].r / dist(nodes[i], nodes[j]);
      if(nxty > mid) up = true;
      else down = true;
    }
    
    if(up && down) return false;
    if(!up && !down) return true;
    if(up) mini = mid;
    if(down) maxx = mid;
  }
  return false;
}

int main(){
  while(scanf("%d", &n) == 1 && n){
    for(int i = 0; i < n; i++) nodes[i].read();
    
    double maxx = 1000.0, mini = 0.0, mid;
    for(int i = 0; i < n; i++) maxx = fmin(maxx, nodes[i].len);
    
    while(maxx - mini > EPS){
      double mid = (maxx + mini) * 0.5;
      
      if(check(mid)) mini = mid;
      else maxx = mid;
    }
    
    printf("%.7lf\n", maxx);
  }
  return 0;
}

Measured memory_bytes: 1084
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;


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

	int a, b, k, aa, bb, i;
	cin >> a >> b >> k;
	for (i = 0; i < k; i++) {
		if (i % 2 == 0) {
			b += a / 2;
			a /= 2;
		}
		else {
			a += b / 2;
			b /= 2;
		}
		//cout << a << " " << b << "\n";
	}
	cout << a << " " << b << "\n";
		
	return 0;
}


Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
}

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

func main() {
	a, err := strconv.Atoi(input())
	if err != nil {
		log.Fatalln(err)
	}
	b, err := strconv.Atoi(input())
	if err != nil {
		log.Fatalln(err)
	}

	fmt.Println(a * b)
}


Measured memory_bytes: 1816
import sys
stdin = sys.stdin

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
sa = lambda h: [list(map(int, stdin.readline().split())) for i in range(h)]

s = ni()

def f(x):
    if x % 2 == 0:
        return x/2
    else:
        return 3*x + 1

num = []
m = 1

while s not in num:
    num.append(s)
    s = f(s)
    m += 1

print(m)

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

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define ll long long
#define ii pair<int,int>
#define vi vector<int>
#define vll vector<ll>
#define vii vector<ii>

const int maxn = 1e5+10;
const int mod = 1e9+7;

using namespace std;

vll vx;

void precalc(){
	ll x=0,s=1;
	while(x<=1000000000000001LL){
		x+=(s*26LL);
		vx.pb(x);
		s*=26LL;
	}
}

void solve(){
	ll n;
	cin>>n;
	if(n<=26){
		cout<<char((n-1)+'a')<<endl;
		return;
	}
	auto it = lower_bound(all(vx),n)-vx.begin();
	string ans(it+1,'a'); int pos = it;
	ll aux = n-(vx[it-1]+1);
	while(aux){
		ll xd=(aux%26);
		ans[pos]+=xd;
		--pos;
		aux/=26;
	}
	cout<<ans<<endl;
}

int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	precalc();
	int t=1;
	//cin>>t;
	while(t--){
		solve();
	}
	return 0;
}

Measured memory_bytes: 3664
S=input()
N=len(S)
INF=10**9
#dp[i][j]: 下からi桁目まで見たときの枚数最小値(jは上への繰り上がりがあるか)
dp=[[INF for _ in range(2)] for __  in range(N+1)]
dp[0][0]=0
for i in range(N):
    n=int(S[N-1-i])
    ni=i+1
    for j in range(2):
        if n+j<=9:
            dp[ni][0]=min(dp[ni][0],dp[i][j]+n+j)
            dp[ni][1]=min(dp[ni][1],dp[i][j]+10-n-j)
        else:
            dp[ni][1]=min(dp[ni][1],dp[i][j])
print(min(dp[N][0],dp[N][1]+1))


Measured memory_bytes: 156068
# from collections import defaultdict
# n, m = map(int, input().split())
# nums = [int(i) for i in input().split()]
#
# num_freq = defaultdict(int)
#
# for _ in range(m):
#     b, c = map(int, input().split())
#     num_freq[c] += b
#
#
# new_list = []
# for num, freq in sorted(num_freq.items(), key=lambda x: -x[0]):
#     new_list += [num] * freq
#     if len(new_list) >= n:
#         break
# tmp = sorted(nums + new_list)[::-1]
# print(sum(tmp[:n]))

# ↑と同じ処理なのに↑のはREになる
n, m = map(int, input().split())
nums = list(map(int, input().split()))
exc = []

for i in range(m):
    exc.append(list(map(int, input().split())))
exc.sort(key=lambda x: x[1], reverse=True)
e = []
count = 0
for i in range(m):
    freq = exc[i][0]
    e += [exc[i][1]] * freq
    count += freq
    if count >= n:
        break
cards = sorted(nums + e, reverse=True)
print(sum(cards[:n]))


Measured memory_bytes: 37836
#include <bits/stdc++.h>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t1, f1;
    string c1;
    string s;
    cin >> s;
    int c;
    cin >> c;
    bool f = true;
    int count = 0;
    string start = "", final = "";
    while (c--)
    {
        cin >> t1;
        if (t1 == 1)
        {
            count++;
            swap(start, final);
        }
        else
        {
            cin >> f1 >> c1;
            if (f1 == 1)
                start.append(c1);
            else
                final.append(c1);
        }
    }

    if (count % 2 != 0)
    {
        reverse(final.begin(), final.end());
        s = final + s + start;
        reverse(s.begin(), s.end());
        cout << s;
    }
    else
    {
        reverse(start.begin(), start.end());
        s = start + s + final;
        cout << s;
    }

    return 0;
}


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

int sumh[601][601], sumw[601][601];

int main(){
    int H, W;
    cin >> H >> W;
    string S[300];
    for(int i=0; i<H; i++) cin >> S[i];

    bitset<601> S2[601];
    for(int i=0; i<H; i++){
        for(int j=0; j<W; j++){
            if(S[i][j] == '#') S2[i+j+1][i-j+W+1] = 1;
        }
    }

    for(int i=1; i<=600; i++){
        for(int j=1; j<=600; j++){
            sumh[i][j] = sumh[i-1][j] + S2[i][j];
            sumw[i][j] = sumw[i][j-1] + S2[i][j];
        }
    }

    int64_t ans = 0;
    for(int k=2; k<=600; k+=2){
        for(int i=1; i<=600; i++){
            for(int j=(i+W)%2; j<=600; j+=2){
                if(S2[i][j] == 0) continue;
                if(i+k <= 600 && S2[i+k][j]){
                    if(j-k >= 1)   ans += sumh[i+k-1][j-k] - sumh[i][j-k];
                    if(j+k <= 600) ans += sumh[i+k-1][j+k] - sumh[i][j+k];
                }
                if(j+k <= 600 && S2[i][j+k]){
                    if(i-k >= 1)   ans += sumw[i-k][j+k] - sumw[i-k][j-1];
                    if(i+k <= 600) ans += sumw[i+k][j+k] - sumw[i+k][j-1];
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3328
#include <algorithm>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <queue>
#include <stack>
#include <utility>
#include <vector>
using std::cin;
using std::cout;
using std::endl;

int main(void) {
  cout << std::fixed << std::setprecision(10);
  cin.tie(0);
  std::ios::sync_with_stdio(false);
  int n;
  std::string a, b, c;
  cin >> n >> a >> b >> c;
  int res = 0;
  for (int i = 0; i < n; i++) {
    if (a[i] == b[i] && b[i] == c[i]) {
      // nothing
    } else if (a[i] == b[i] || b[i] == c[i] || a[i] == c[i]) {
      res++;
    } else {
      res += 2;
    }
  }
  cout << res << endl;

  return 0;
}


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

int sum;
void ans(int n,int k,int s)
{
  s-=n;
  if(s==0 && k==1)sum++;
  if(s<=0 || k==0)return;
  for(int i=n-1;i>0;i--){
    ans(i,k-1,s);
  }
}

int main()
{
  int n,k,s;

  while(1){
    cin>>n>>k>>s;
    if(n==0&&k==0&&s==0)break;
    sum=0;
    for(int i=n;i>0;i--){
      ans(i,k,s);
    }
    cout<<sum<<endl;
  }
  return 0;
}

Measured memory_bytes: 1160
#include<iostream>
using namespace std;
int main(){
	char s[4];
	cin>>s;
	if(s[0]=='R'&&s[1]=='R'&&s[2]=='R')
	cout<<"3"<<endl;
	else if(s[0]=='R'&&s[1]=='R')
    cout<<"2"<<endl;
    else if(s[1]=='R'&&s[2]=='R')
    cout<<"2"<<endl;
    else if(s[0]=='R'||s[1]=='R'||s[2]=='R')
    cout<<"1"<<endl;
    else 
    cout<<"0"<<endl;
}

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

const int INF = 1001001001;
vector<int> to[100005];

int main() {
  ll a, b, n;
  cin >> a >> b >> n;
  
  if (b > n) cout << a * n / b << endl;
  else cout << a * (b-1) / b << endl;
  
  return 0;
}

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

const int MAX_M = 1000;
const int MAX_N = 1000;
const int MAX_K = 100000;
int jn[MAX_M][MAX_N] = {};
int on[MAX_M][MAX_N] = {};
int in[MAX_M][MAX_N] = {};

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int m, n;
	cin >> m >> n;
	
	int k;
	cin >> k;
	
	for(int i = 1; i <= m; ++i){
		for(int j = 1; j <= n; ++j){
			char c;
			cin >> c;
			
			jn[i][j] += jn[i - 1][j] + jn[i][j - 1] - jn[i - 1][j - 1];
			on[i][j] += on[i - 1][j] + on[i][j - 1] - on[i - 1][j - 1];
			in[i][j] += in[i - 1][j] + in[i][j - 1] - in[i - 1][j - 1];
			
			if(c == 'J') jn[i][j]++;
			if(c == 'O') on[i][j]++;
			if(c == 'I') in[i][j]++;
		}
	}
		
	for(int i = 0; i < k; ++i){
		int a, b, c, d;
		cin >> a >> b >> c >> d;
		int ansj = jn[c][d] - jn[c][b - 1] - jn[a - 1][d] + jn[a - 1][b - 1];
		int anso = on[c][d] - on[c][b - 1] - on[a - 1][d] + on[a - 1][b - 1];
		int ansi = in[c][d] - in[c][b - 1] - in[a - 1][d] + in[a - 1][b - 1];
		cout << ansj << " " << anso << " " << ansi << endl;
	}
	
	return 0;
}

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

int main(){
long long n,t,a,b,c,d;
cin>>a>>b>>c>>n;
long r=0;
d=min(a,n);
r=r+d;
n=n-d;
if(n==0){cout<<r<<endl;return 0;}
else{
    d=min(b,n);n=n-d;
        if(n==0){cout<<r<<endl;return 0;}
        else{
            d=min(c,n);
            r=r-d;
            cout<<r<<endl;return 0;
        }
}
return 0;
}


Measured memory_bytes: 3624
#include<iostream>
#include<vector>
#include<algorithm>
#include<climits>
#include<utility>
#include<set>
#include<cstdlib>
using namespace std;

long long int n;
vector<long long int>a;

int main(void){
  long long int i,t,ans=0,l;
  cin >> n;
  a=vector<long long int>(n);
  for(i=0;i<n;i++){
    cin >> a.at(i);
  }
  for(i=0;i<n;i++){
    if(a.at(i)<=0){
      if(a.at(i)!=0){
        l=a.at(i);
      }
      t++;
    }
  }
  if(t%2==0){
    for(i=0;i<n;i++){
      ans+=abs(a.at(i));
    }
  }else{
    for(i=0;i<n;i++){
      if(abs(l)>abs(a.at(i)))l=a.at(i);
    }
    for(i=0;i<n;i++){
      if(a.at(i)==l){
        if(0<=a.at(i)){
          a.at(i)*=(-1);
        }
        ans+=a.at(i);
      }else{
        ans+=abs(a.at(i));
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define SPEED ios_base::sync_with_stdio(false); cin.tie(NULL)
#define REP(i,a,b) for(int i=a,_b=b;i<=_b;i++)
#define rep(i,n) REP(i,0,n-1)
#define FORD(i,b,a) for(int i=b,_a=a;i>=_a;i--)
#define ford(i,n) FORD(i,n-1,0)
#define sqr(x) ((x)*(x))
#define ll long long
#define pi pair<int,int>
#define vi vector<int>
#define vpi vector<pi>
#define vll vector<ll>
#define fi first
#define se second
#define all(a) a.begin(),a.end()
#define add push_back
#define len(arr) arr.size()
#define print(x) cout<<(x)<<endl
using namespace std;


int main() {
	SPEED;
	//freopen("in.txt", "r", stdin);
	
	int n;
	cin >> n;
	string s;
	cin >> s;
	
	int res = -1;
	REP(i, 1, n - 1){
		int a[26] = {};
		int b[26] = {};
		int cnt = 0;
		rep(j, i) a[s[j] - 'a']++;
		REP(j, i, n - 1) b[s[j] - 'a']++;
		rep(i, 26) if(a[i] && b[i]) cnt++;
		res = max(res, cnt);
	}
	
	print(res);
	return 0;
}


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

int sdx[4] = {0, 1, 0, -1};
int sdy[4] = {-1, 0, 1, 0};

struct Edge{
  int src,dst,weight;
  Edge(int src,int dst,int weight) :
    src(src), dst(dst), weight(weight) { }
};
bool operator<(const Edge &e, const Edge &f) {
  return (e.weight != f.weight) ? e.weight>f.weight :
    (e.src != f.src) ? e.src<f.src : e.dst<f.src;
}

typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
const int INF = 0x7fffffff;
int w,h;
void dijkstra(const Graph &g, int s, vector<int> &dist, vector<int> &prev) {
  int n = g.size();
  dist.assign(n, INF);
  dist[s] = 0;
  prev.assign(n, -1);
  priority_queue<Edge> Q;

  for(Q.push(Edge(-2, s, 0)); !Q.empty(); ) {
    Edge e = Q.top();
    Q.pop();
    if(prev[e.dst] != -1) continue;
    prev[e.dst] = e.src;
    for(Edges::const_iterator it = g[e.dst].begin(); it != g[e.dst].end(); ++it) {
      if(dist[it->dst] > e.weight + it->weight) {
	dist[it->dst] = e.weight + it->weight;
	Q.push(Edge(it->src, it->dst, e.weight + it->weight));
      }
    }
  }
}

int main() {
  while(cin>>w>>h, w||h) {
    Graph g(w*h*4);
    int t,tk,nx,ny,inp;

    for(int i=0; i<h; ++i) {
      for(int j=0; j<w; ++j) {
	cin>>t;
	if(t==4) continue;
	for(int k=0; k<4; ++k) {
	  tk = (k+t)%4;
	  nx = j+sdx[tk], ny = i+sdy[tk];
	  if(nx >= 0 && (nx<w) && ny >= 0 && ny < h )
	    g[(i*w+j)*4+k].push_back( Edge((i*w+j)*4+k, (ny*w+nx)*4+tk, 0) );
	}
      }
    }

    int c[4];
    cin>>c[0]>>c[1]>>c[2]>>c[3];

    for(int i=0; i<h; ++i) {
      for(int j=0; j<w; ++j) {
	for(int t=0; t<4; ++t) {
	  for(int k=0; k<4; ++k) {
	    tk = (k+t)%4;
	    nx = j+sdx[tk],ny = i+sdy[tk];
	    if(nx >= 0 && nx < w && ny >= 0 && ny < h)
	       g[(i*w+j)*4+k].push_back( Edge((i*w+j)*4+k, (ny*w+nx)*4+tk, c[t]) );
	  }
	}
      }
    }

    vector<int> dist;
    vector<int> prev;
    dijkstra(g, 1, dist, prev);

    cout<<min( dist[dist.size()-2], dist[dist.size()-3] )<<endl;
  }
}

Measured memory_bytes: 1292
#include <iostream>
using namespace std;
using ll = long long;

int main()
{
    int n, x;
    while (cin >> n >> x)
    {
        if (n == 0 && x == 0)
            return 0;
        int a = 0;
        for (int i = 1; i <= n; i++)
        {
            for (int j = i + 1; j <= n; j++)
            {
                for (int k = j + 1; k <= n; k++)
                {
                    if (i + j + k == x)
                        a++;
                }
            }
        }
        cout << a << endl;
    }
}


Measured memory_bytes: 3104
/**akshaykumar99**/
 
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
template<typename T> using id_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update> ;
template<typename T> using id_setp = tree<pair<T,T>,null_type,less<pair<T,T>>,rb_tree_tag,tree_order_statistics_node_update> ;
 
#define f(i,x,n) for(i=x;i<n;i++)
#define fr(i,x,n) for(i=x;i>=n;i--)
#define pu push_back           
#define pp pop_back
#define F first
#define S second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define SP(x) fixed<<setprecision(x)
#define IOS() ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
 
const long long MOD=1e9+7;
const long double PI = acos(-1);
const long long INF=INT_MAX;
const long long LINF=LLONG_MAX;
const long long N=2e5+1;
 
typedef long long ll;
typedef long double ld;

int main()
{
    IOS();
    
   	ll n,m,i,j;
   	cin>>n>>m;
   	if(n==m)
   		cout<<"Yes\n";
   	else
   		cout<<"No\n";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <unordered_map>
typedef long long ll;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " \n"[i == n-1];}
#define printp(x,n) for(ll i = 0; i < n; i++){ cout << "(" << x[i].first << ", " << x[i].second << ") "; } cout << endl;
#define INF (1e18)
using namespace std;
const ll MOD = 1e9 + 7;
typedef pair<ll, ll> lpair;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    ll a[100010];
    cin >> N;
    rep(i,0,N) cin >> a[i];
    ll is_used[100010] = {};
    bool ok = true;
    rrep(bit,31,0){
        ll cnt = 0;
        rep(i,0,N){
            if((a[i]>>bit) & 1) cnt++;
        }
        if(cnt % 2 == 0) continue;
        // print(bit);
        bool flg = true;
        rep(i,0,N){
            if(a[i] % (1LL<<(bit+1)) == (1LL<<(bit)) && is_used[i] == 0){
                is_used[i] = 1;
                // print2(bit,i);
                a[i]--;
                flg = false;
                break;
            }
        }
        if(flg){
            ok = false;
        }
    }
    if(!ok){
        print(-1);
    }else{
        ll ans = 0;
        rep(i,0,N){
            if(is_used[i] == 1) ans++;
        }
        print(ans);
    }
    //010
    //011
    //100

    //001
    //010
    //011
    
}


Measured memory_bytes: 1792
#include <stdio.h>
#include <limits.h>
#define max_n 100

int n;
int AdjWeight[max_n][max_n];
int d[max_n];
int edge[max_n];
int parent[max_n];
int visited[max_n];

void relax(int, int);
void initialize(int);
void shortestPath(int);

int main(){
	int from, to;
	int i, j;
	scanf("%d", &n);
	
	for (i = 0; i < n; i++){
		scanf("%d %d", &from, &edge[i]);
		for (j = 0; j < edge[i]; j++){
			int tempWeight;
			scanf("%d %d", &to, &tempWeight);
			AdjWeight[from][to] = tempWeight;
		}
	}
	shortestPath(0);
	
	for (i = 0; i < n; i++){
		printf("%d %d\n", i, d[i]);
	}
	return 0;
}

void initialize(int from){
	int i;
	for (i = 0; i < n; i++){
		d[i] = INT_MAX;
		parent[i] = -1;
	}
	d[from] = 0;
}

void relax(int linkFrom, int linkTo){
	if(visited[linkTo] == 0 && d[linkTo] > d[linkFrom] + AdjWeight[linkFrom][linkTo]){
		d[linkTo] = d[linkFrom] + AdjWeight[linkFrom][linkTo];
		parent[linkTo] = linkFrom;
	}
}

int minWeight(){
	int i;
	int min = INT_MAX;
	int anchor = -1;
	
	for (i = 0; i < n; i++){
		if(visited[i] == 0 && d[i] < min){
			min = d[i];
			anchor = i;
		}
	}
	return anchor;
}

void shortestPath(int from){
	initialize(from);
	int j;
	
	while(1){
		int anchor = minWeight();
		if (anchor == -1) break;
		visited[anchor] = 1;
		
		for (j = 0; j < n; j++){
			if (AdjWeight[anchor][j] != 0) relax(anchor, j); //if (visited[j] != 1) 
		}
	}
}


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

using namespace std;

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

    for (int i = n; i <= 999; i++) {
        string s = to_string(n);
        if (s[0] == s[1] && s[1] == s[2]) {
            break;
        } else {
            n += 1;
        }
    }

    cout << n << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, P> P3;
typedef pair<P, P> PP;
constexpr ll MOD = ll(1e9 + 7);
constexpr int IINF = INT_MAX;
constexpr ll LLINF = LLONG_MAX;
constexpr int MAX_N = int(1e5) + 5;
constexpr double EPS = 1e-9;
constexpr int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i > 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define SORTR(v) sort((v).rbegin(), (v).rend())
#define ALL(v) (v).begin(), (v).end()

int main() {
    int h[10];
    for(int i=0;i<10;i++){
        cin >> h[i];
    }
    sort(h,h+10);
    for(int i=9;i>=7;i--){
        cout << h[i] << endl;
    }
    return 0;
}



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

int main() {
  int n;
  scanf("%d", &n);
  long long ans = 0, mn = 2e9;
  bool chain = false;
  for (int i = 0; i < n; ++i) {
    int a, b;
    scanf("%d %d", &a, &b);
    ans += b;
    if (a > b)
      mn = min(mn, 1LL * b), chain = true;
  }
  printf("%lld\n", (chain ? ans - mn : 0));
  return 0;
}

Measured memory_bytes: 256