akhauriyash/Code-Regression huggingface dataset:
// #include <bits/stdc++.h>
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <tuple>
#include <map>
#include <math.h>
#include <algorithm> // std::sort, std::min, std::next_permutation, std::lower_bound
#include <iomanip> // std::setprecision
#include <cmath> // std::ceil
#include <numeric> // std::gcd, std::lcm
#include <limits> // std::numeric_limits<long int>::max()
#include <unordered_map>
#include <map>
#include <cmath> // std::atan2

using namespace std;
typedef long long ll;
#define INF 1999999999
#define MODA 1000000007 
#define rep(i,n) for (long long i = 0; i < (n); ++i)

int main() {
  ll H, W;
  cin >> H >> W;
  vector<string> S(H);
  rep(i,H) cin >> S[i];

  vector<vector<ll> > latcount(H);
  rep(i, H) latcount[i].resize(W, 0);
  rep(i, H) {
    ll left = -1;
    rep(j, W + 1) {
      if (j == W || S[i][j] == '#') {
        if (left != -1) {
          for (int k = left; k < j; ++k) {
            latcount[i][k] = j - left;
            // cerr << latcount[i][k] << endl;
          }
          left = -1;
        }
      }
      else if(S[i][j] == '.') {
        if (left == -1) left = j;
        // cerr << i <<" "<< j <<" "<< left << endl;
      }
    }
  }  

  vector<vector<ll> > loncount(H);
  rep(i, H) loncount[i].resize(W, 0);
  rep(j, W) {
    ll up = -1;
    rep(i, H + 1) {
      if ( i == H || S[i][j] == '#') {
        if (up != -1) {
          for (int k = up; k < i; ++k) {
            loncount[k][j] = i - up;
          }
          up = -1;
        }
      }
      else if(S[i][j] == '.') {
        if (up == -1) up = i;
      }
    }
  }  

  ll maxcount = 0;
  rep(i, H) {
    rep(j, W) {
      maxcount = max(maxcount, latcount[i][j] + loncount[i][j] - 1);
    }
  }
  cout << maxcount << endl;
  return 0;
}


Measured memory_bytes: 68992
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner((System.in));
		int a = sc.nextInt();
		int b = sc.nextInt();
		String s = sc.next(), ans = "Yes";

		for (int i = 0; i < s.length(); i++) {
			if (i == (a)) {
				if (!s.substring(i, i + 1).equals("-")) {
					ans = "No";
					break;
				}
			} else {
				if (!s.substring(i, i + 1).matches("1|2|3|4|5|6|7|8|9|0")) {
					ans = "No";
					break;
				}
			}
		}
		System.out.println(ans);

		sc.close();
	}
}

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

int main(){

    int k,a,b;
    bool isAble = false;
    cin >> k >> a >> b;
    for (int i = a; i <= b;++i){
        if(i%k==0){
            isAble = true;
            break;
        }
    }
    if(isAble){
        cout << "OK" << endl;
    }
    else{
        cout << "NG" << endl;
    }
    return 0;
}



Measured memory_bytes: 3636
#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>;

vector<vector<int>> g;
vector<int> it;
int k = 0;

int f(int x){
	it.at(x) = k;
	rep(i, g.at(x).size()){
		if(it.at(g.at(x).at(i)) != -1) continue;
		f(g.at(x).at(i));
	}
	return 0;
}

int main(){
	int n, m;
	cin >> n >> m;
	vector<int> p(n);
	g = vector<vector<int>>(n, vector<int>(0));
	it = vector<int>(n);
	rep(i, n){
		cin >> p.at(i);
		it.at(i) = -1;
	}
	rep(i, m){
		int a, b;
		cin >> a >> b;
		a--; b--;
		g.at(a).push_back(b);
		g.at(b).push_back(a);
	}
	rep(i, n){
		if(it.at(i) == -1){
			f(i);
			k++;
		}
	}
	int ans = 0;
	rep(i, n){
		if(it.at(p.at(i)-1) == it.at(i)) ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 9472
import sys
input = sys.stdin.readline

n=10**5
sievebd=n//2
sieve=[True]*sievebd
limit=int(n**.5)//2
sieve[0]=0
for i in range(limit):
    if sieve[i]:
        for j in range(2*i*(i+1),sievebd,2*i+1):
            sieve[j]=False
for i in range((sievebd-1)//2,0,-1):
    if not sieve[i]:sieve[2*i]=False
for i in range(3,sievebd,2):sieve[i]=False
for i in range(1,sievebd):sieve[i]+=sieve[i-1]
q=int(input())
l=[list(map(int,input().split())) for _ in [0]*q]
for i in range(q):
    print(sieve[(l[i][1]-1)//2]-sieve[max(0,(l[i][0]-1)//2-1)])

Measured memory_bytes: 29688
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr int Inf = 1000000000;
constexpr ll INF= 9 * 1e18;
constexpr ll MOD = 1000000007;
const double PI = 3.1415926535897;
typedef pair<int,int> P;

template<typename T>
T Pow(T a,T b) {
    T ret = 1;
    for(int i = 0;i < b;i++) {
        ret *= a;
    }
    return ret;
}

int main() {
    int N;
    cin >> N;
    vector<int> vec(N);
    for(int i = 0;i < N - 1;i++) {
        int A;
        cin >> A;
        A--;
        vec.at(A)++;
    }
    for(int i = 0;i < N;i++) {
        cout << vec.at(i) << endl;
    }
}

Measured memory_bytes: 3988
#include <stdio.h>
#include <limits.h>

struct node_t {
	int n;
	int e[100][2];
};
typedef struct node_t Node;

int input(Node node[100]) {
	int n, i, j, k;

	scanf("%d", &n);
	for (i = 0; i < n; i++) {
		scanf("%d %d", &j, &k);
		for (j = 0; j < k; j++) {
			scanf("%d %d", &node[i].e[j][0], &node[i].e[j][1]);
		}
		node[i].n = k;
	}
	return n;
}

int main(void) {
	int num;
	int weight[100];
	char V[100];
	int v, cost, vn, index, i;
	Node E[100];

	num = input(E);

	V[0] = weight[0] = 0;
	for (i = 1; i < num; i++) {
		weight[i] = INT_MAX;
		V[i] = 1;
	}
	vn = num - 1;
	index = 0;

	while (vn--) {
		for (i = 0; i < E[index].n; i++) {
			v = E[index].e[i][0];
			if (!V[v])
				continue;
			cost = E[index].e[i][1] + weight[index];
			weight[v] = weight[v] < cost ? weight[v] : cost;
		}
		v = INT_MAX;
		for (i = 0; i < num; i++) {
			if (!V[i])
				continue;
			if (v > weight[i]) {
				v = weight[i];
				index = i;
			}
		}
		V[index] = 0;
	}

	for (i = 0; i < num; i++) {
		printf("%d %d\n", i, weight[i]);
	}
	return 0;
}

Measured memory_bytes: 676
#include<stdio.h>

int main()
{
  int i,j,a,b,r,p,q,x,n,A[100000];

  scanf("%d",&n);

  for(i = 0;i < n;i++)
    scanf("%d",&A[i]);

  r = n - 1;
  p = 0;
  
  x = A[r];
  i = p - 1;

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

  q = i + 1;

  for(i = 0;i < n - 1;i++)
    {
      if(i == q)
	{
	  printf("[");
	  printf("%d",A[i]);
	}
      if(i == q) printf("] ");
      else printf("%d ",A[i]);
    }
  printf("%d",A[n - 1]);
  printf("\n");
  
  return 0;
}
  



Measured memory_bytes: 2168
#include<bits/stdc++.h>
using namespace std;
char n;
int a,b;
int main(){
	cin>>a>>b;
	for(int i=1;i<=a;i++){
		cin>>n;
		if(n<'0'||n>'9'){
			cout<<"No"<<endl;
			return 0;
		}
	}
	cin>>n;
	if(n!='-'){
		cout<<"No"<<endl;
		return 0;
	}
	for(int i=1;i<=b+1;i++){
		cin>>n;
		if(n<'0'||n>'9'){
			cout<<"No"<<endl;
			return 0;
		}
	}
	cout<<"Yes"<<endl;
	return 0;
}

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

a = [int(i) for i in input().split()]

result = True
for check in a:
  if (check%2 == 0):
    if (check%3 == 0 ) or (check%5 == 0):
      pass
    else:
      result = False
      break
      
if (result):
  print("APPROVED")  
else:
  print("DENIED")

Measured memory_bytes: 9056
#include<bits/stdc++.h>
using namespace std;
void solve(){
    int n, k, cnt=0;
    cin >> n >> k;
    while(n != 0){
        cnt++;
        n = n/k;
        //cout << n << endl;
    }
    cout << cnt << endl;
}

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

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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
using P = pair<ll,ll>;
using ld=long double;

int main(){
    int a,b,c,d;cin >>a>>b>>c>>d;
    if((a+b)>(c+d))puts("Left");
    else if((a+b)==(c+d))puts("Balanced");
    else puts("Right");
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
  int ar[100009],i,j,n;
  cin>>n;
  for(i=1; i<=n; i++)
  {
    cin>>ar[i];
  }
  
  if(n==1)
  {
    cout<<"Yes"<<endl;
  }
  else
  {
    if(ar[1]==ar[2]) 
    {
      ar[1]--;
      ar[2]--;
    }
    if(ar[1]>ar[2])
    {
      ar[1]--;
    }
   /* if(ar[1]<ar[2])
    {
      ar[2]--;
    }*/

    int flag=0;
    for(i=1; i<n; i++)
    {
      if(ar[i+1]>ar[i])
      {
        ar[i+1]--;
      }
      else if(ar[i+1]<ar[i])
      {
        flag=1;
        break;
      }

    }
    if(flag) cout<<"No"<<endl;
    else cout<<"Yes"<<endl;
    /*for(i=1; i<=n; i++)
      cout<<ar[i]<<" ";*/
  }
  return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using P = pair<int, int>;

int main() {
  int n, m, Q;
  cin >> n >> m >> Q;
  vector<vector<int>> g(n, vector<int>(n));
  for(int i=0;i<m;i++) {
    int l, r;
    cin >> l >> r;
    l--;r--;
    g[l][r]++;
  }
  vector<vector<int>> sum(n, vector<int>(n));
  for(int i=0;i<n;i++) {
    for(int j=0;j<n;j++) {
      if(j == 0) sum[i][j] = g[i][j];
      else sum[i][j] = sum[i][j-1] + g[i][j];
    }
  }
  for(int i=0;i<Q;i++) {
    int p, q;
    cin >> p >> q;
    p--;q--;
    int ans = 0;
    for(int j=p;j<=q;j++) {
      ans += sum[j][q];
      if(p != 0) ans -= sum[j][p-1];
    }
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 2944
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
using loop = int;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(loop (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(loop (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(loop (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(loop (i)=(n);(i)>=(a);--(i))
#define each(i, a) for(auto &i : a)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x) ((y) < 0 || h <= (y) || (x) < 0 || w <= (x))
#define line cout << "------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
#define stop system("pause") //comment out this on AOJ.
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
constexpr ld eps = 1e-10;
constexpr ld pi = 3.1415926535897932;
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; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }

int main() {
    init();

    string s; cin >> s;
    int n = s.length();
    int a, z;
    FOR(i, 0, n)if (s[i] == 'A') {
        a = i;
        break;
    }
    rFOR(i, 0, n)if (s[i] == 'Z') {
        z = i;
        break;
    }
    cout << z - a + 1 << "\n";
}

Measured memory_bytes: 720
#include <iostream>
#include <cstring>
#include <map>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <set>
#include <vector>
#include <queue>
#include <list>
#include <numeric>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <math.h>
#include <stack>
#include <climits>
#include <bitset>

using namespace std;
typedef long long ll;

//最小公倍数
ll gcd(ll x, ll y) {
  ll tmp = 0;
  if (x < y){
    tmp=x;
    x=y;
    y=tmp;
  }
  while (y > 0) {
    ll r = x % y;
    x = y;
    y = r;
  }
  return x;
}

//最大公倍数
ll lcm(ll x,ll y){
  return x/gcd(x,y)*y;
}

//階乗
ll kaijo(ll k){
    ll sum = 1;
    for (ll i = 1; i <= k; ++i)
    {
        sum *= i;
        sum%=1000000000+7;
    }
    return sum;
}

//for(int i = ; i < ; i++){}

int main(){
  int n;
  cin>>n;
  int a[n];
  int b[n];
  for(int i = 0; i < n; i++){
    cin>>a[i];
    b[i]=0;
  }
  
  int counter=0;

  for(int i = 0; i < n; i++){
    int k = n-i;
    int sum = 0;
    int t = k;
    while(t <= n){
      sum+=b[t-1];
      t+=k;
    }
    
    if(sum % 2 != a[k-1]){
        b[k-1]=1;
        counter++;
      }
      else{
        b[k-1]=0;
      }
  }
  cout<<counter<<endl;
  for(int i = 0; i < n; i++){
    if(b[i]==1){
      cout<<i+1<<" ";
    }
  }
  return 0;
}

  



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

int main() {
  int A,B,C,X;
  cin >> A >> B >> C >> X;
  int ans=0;
  for(int a=0;a<=A;++a){
    for(int b=0;b<=B;++b){
      for(int c=0;c<=C;++c){
        int total = 500*a + 100*b + 50*c;
        if(total == X) ++ans;
      }
    }
  }
  cout << ans << endl;

}


Measured memory_bytes: 256
def solve(l):
  a,b,c = 0,0,0
  for i in range(m):
    a += l[i][0]
    b += l[i][1]
    c += l[i][2]
  return abs(a) + abs(b) + abs(c)

n,m = map(int,input().split())
lis = [list(map(int,input().split())) for i in range(n)]
ans = 0

lis.sort(key = lambda x:x[0]+x[1]+x[2])
ans = max(ans,solve(lis))

lis.sort(key = lambda x:x[0]+x[1]-x[2])
ans = max(ans,solve(lis))

lis.sort(key = lambda x:x[0]-x[1]+x[2])
ans = max(ans,solve(lis))

lis.sort(key = lambda x:x[0]-x[1]-x[2])
ans = max(ans,solve(lis))

lis.sort(key = lambda x:-x[0]+x[1]+x[2])
ans = max(ans,solve(lis))

lis.sort(key = lambda x:-x[0]+x[1]-x[2])
ans = max(ans,solve(lis))

lis.sort(key = lambda x:-x[0]-x[1]+x[2])
ans = max(ans,solve(lis))

lis.sort(key = lambda x:-x[0]-x[1]-x[2])
ans = max(ans,solve(lis))

print(ans)

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

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

class P{
public:
	int id,bought,price,walk;

	P(int _id,int _bought,int _price,int _walk){
		id = _id;
		bought = _bought;
		price = _price;
		walk = _walk;
	}

	bool operator<(const P &p)const{
		if(price == p.price) return walk > p.walk;
		return price > p.price;
	}
};

int t[12][12],market[12][16];
bool closed[12][33000];
vector<string> name[12];
vector<int> price[12];

int main(void){
	ios_base::sync_with_stdio(0);
	int n;

	while(cin>>n,n){
		rep(i,n){
			int k; cin>>k;
			name[i] = vector<string>(k);
			price[i] = vector<int>(k);
			rep(j,k) cin>>name[i][j]>>price[i][j];
		}

		int q; cin>>q;
		string list[q];
		rep(i,q) cin>>list[i];

		memset(t,0,sizeof(t));
		int m;
		cin>>m;
		rep(i,m){
			int a,b,cost;
			cin>>a>>b>>cost;
			t[a][b] = t[b][a] = cost;
		}

		memset(market,-1,sizeof(market));
		rep(i,n){
			rep(j,name[i].size()){
				rep(k,q){
					if(list[k] == name[i][j]){
						market[i][k] = price[i][j];
					}
				}
			}
		}

		priority_queue<P> open;
		memset(closed,0,sizeof(closed));
		open.push(P(0,0,0,0));
		P ans(0,0,0,0);

		while(!open.empty()){
			P p = open.top(); open.pop();
			if(closed[p.id][p.bought]) continue;
			closed[p.id][p.bought] = true;

			if(p.id == 0 && p.bought == (1<<q)-1){
				ans = p;
				break;
			}

			for(int i=0;i<=n;i++){
				if(t[p.id][i] > 0){
					open.push(P(i,p.bought,p.price,p.walk+t[p.id][i]));
				}
			}

			if(p.id > 0){
				int idx = p.id - 1;
				for(int i=0;i<q;i++){
					if(market[idx][i] > 0){
						open.push(P(p.id,p.bought|(1<<i),p.price+market[idx][i],p.walk));
					}
				}
			}
		}

		if(ans.bought == 0)
			cout<<"impossible\n";
		else
			cout<<ans.price<<" "<<ans.walk<<endl;
	}

	return 0;
}

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

int main(){
  int A, B, C;
  cin >> A >> B >> C;
  int min=200;
  if(abs(A-B)+abs(B-C)<min) min=abs(A-B)+abs(B-C);
  if(abs(A-C)+abs(C-B)<min) min=abs(A-C)+abs(C-B);
  if(abs(B-A)+abs(A-C)<min) min=abs(B-A)+abs(A-C);
  if(abs(B-C)+abs(C-A)<min) min=abs(B-C)+abs(C-A);
  if(abs(C-A)+abs(A-B)<min) min=abs(C-A)+abs(A-B);
  if(abs(C-B)+abs(B-A)<min) min=abs(C-B)+abs(B-A);
  cout << min << endl;
  return 0;
}


Measured memory_bytes: 256
/*
    handle - pruvi007
    questionName - 
    Contest - 
    Topic - 
    Platform - 
*/
#include<bits/stdc++.h>
using namespace std;
#define ll          long long int
#define fast         ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define INF          1e18
#define MOD          1000000007
#define Vi           vector<ll> 
#define Vs           vector<string>
#define VI           vector<vector<ll> >
#define PII          pair<ll,ll> 
#define PSI          pair<string,ll>
#define PB           push_back


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

int main()
{
    fast;
    int n;
    cin >> n;
    string s;
    cin >> s;
    int l=0,r=n-1;
    for(int i=0;i<n;i++)
    {
        if(s[i]=='W')
        {
            l = i;
            break;
        }
    }
    for(int i=n-1;i>=0;i--)
    {
        if(s[i]=='R')
        {
            r = i;
            break;
        }
    }
    int swap = 0;
    while(l<r)
    {
        if(s[l] == 'W' and s[r]=='R')
        {
            int temp = s[r];
            s[r] = s[l];
            s[l] = temp;
            l++;
            r--;
            swap++;
        }
        else if(s[l]=='W' and s[r]=='W')
        {
            r--;
        }
        else if(s[l]=='R' and s[r]=='R')
            l++;
        else if(s[l]=='R' and s[r]=='W')
        {
            l++;
            r--;
        }
    }
    // cout << s << '\n';
    cout << swap << '\n';
}

Measured memory_bytes: 3708
#include<stdio.h>

int main(){
  int pos1[2],pos2[2];
  int pos3[2],pos4[2];
  int vec12[2],vec23[2];

  scanf("%d %d %d %d", &pos1[0],&pos1[1],&pos2[0],&pos2[1]);

  vec12[0] = pos2[0] - pos1[0];
  vec12[1] = pos2[1] - pos1[1];

  vec23[0] = (-1) * vec12[1];
  vec23[1] = vec12[0];

  pos3[0] = pos2[0] + vec23[0];
  pos3[1] = pos2[1] + vec23[1];

  pos4[0] = pos1[0] + vec23[0];
  pos4[1] = pos1[1] + vec23[1];

  printf("%d %d %d %d\n", pos3[0], pos3[1], pos4[0], pos4[1]);

  return 0;
}


Measured memory_bytes: 128
# -*- coding: utf-8 -*-
"""
Created on Tue Sep 22 16:34:00 2020

@author: liang
"""

N = int(input())
A = [0]+[int(x) for x in input().split()]+[0]
ans = 0
for i in range(N+1):
    ans += abs(A[i+1] - A[i])

for i in range(1,N+1):
    tmp = ans
    if A[i-1] <= A[i] <= A[i+1]:
        print(tmp)
    elif A[i-1] >= A[i] >= A[i+1]:
        print(tmp)
    else:
        tmp -= min(abs(A[i] - A[i-1]),abs(A[i+1] - A[i]))*2
        print(tmp)

Measured memory_bytes: 19756
using System;

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

        
        string[] words = Console.ReadLine().Split(' ');
        int K = int.Parse(words[0]);
        int R = int.Parse(words[1]);
        if(K >= 10)
        {
            Console.WriteLine(R);
        }
        else
        {
            R += (100 * (10 - K));
            Console.WriteLine(R);
        }



    }
}

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

int main() {
  ll N, A=1, B;
  cin >> N;
  for (int64_t i = 2; i*i <= N; i++) {
    if (N%i==0) A = i;
  }
  B = N/A;
  cout << A+B-2 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef set<int> si;
typedef set<ll> sl;
typedef pair<int,int> pii;
#define rep(i,a,b) for(int i=(a); i<(b); ++i)
#define per(i,a,b) for(int i=(b)-1; i>=(a); --i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define F first
#define S second

int main(void) {
	ios_base::sync_with_stdio(false); cin.tie(0);
	//freopen("in.txt", "r", stdin);
	int A, B;
	cin >> A >> B;
	cout << (A+B)%24 << '\n';
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
#define bit(n) (1LL << (n))
#define len(x) ((ll)(x).size())
#define debug(var) cout << "[" << #var << "]\n" << var << endl
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;
const double EPS = 1e-9;

template <typename T>
ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  for (int i = 0; i < len; ++i) {
    s << v[i];
    if (i < len - 1)
      s << ' ';
  }
  return s;
}

template <typename T>
ostream& operator<<(ostream& s, const vector<vector<T>>& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) {
    s << vv[i];
    if (i != len - 1)
      s << '\n';
  }
  return s;
}

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

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

__attribute__((constructor)) void initial() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}

signed main() {
  int H, W;
  cin >> H >> W;
  vector<vector<string>> S(H, vector<string>(W));
  rep(i, H) {
    rep(j, W) {
      cin >> S[i][j];
    }
  }

  rep(i, H) {
    rep(j, W) {
      if (S[i][j] == "snuke") {
        cout << (char)('A' + j) << (i + 1) << endl;
        return 0;
      }
    }
  }
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
using ll = long long;

vector<vector<int>> g;
vector<int> color;

bool is_bipartite(int u) {
    for (int v: g[u]) {
        if (color[v] != -1) {
            if (color[v] == color[u]) return false;
        } else {
            color[v] = color[u] ^ 1;
            if (!is_bipartite(v)) return false;
        }
    }
    return true;
}

int main() {
    int V, E; cin >> V >> E;
    g.resize(V);
    for (int i = 0; i < E; i++) {
        int a, b; cin >> a >> b; a--; b--;
        g[a].emplace_back(b);
        g[b].emplace_back(a);
    }
    color.assign(V, -1);
    color[0] = 0;
    ll ans = 0;
    if (!is_bipartite(0)) {
        ans = 1LL * V * (V - 1) / 2;
    } else {
        for (int i = 0; i < V; i++) ans += color[i];
        ans *= V - ans;
    }
    ans -= E;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6400
X, N = map(int, input().split())
p = set(map(int, (input().split())))
i = 1
while True:
    j = ((i%2)*2-1) * (i//2)
    # print(j)
    if X+j not in p:
        ans = X+j
        break
    i += 1
print(ans)


Measured memory_bytes: 9104
N,C,K = map(int, input().split())
T = []
for i in range(N):
    T.append(int(input()))
T.sort()

cnt = 0
tmp = []
for i in T:
    if tmp != [] and (min(tmp) + K < i or len(tmp) == C):
        cnt += 1
        tmp = [i]
    else:
        tmp.append(i)

if tmp != []:
    cnt += 1
print(cnt)


Measured memory_bytes: 7384
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
using namespace std;

#define ll long long
#define pb push_back

int main() {
	
	string S;
	int Cplace=-1,capitalnum=0;
	cin>>S;
	for(int i=0;i<S.size();i++){
		if('A'<=S[i]&&S[i]<='Z')capitalnum++;
		if(S[i]=='C')Cplace=i;
	}
	if(capitalnum==2&&S[0]=='A'&&2<=Cplace&&Cplace<=S.size()-2)cout<<"AC"<<endl;
	else cout<<"WA"<<endl;

	return 0;
}


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

using namespace std;

int main()
{
    int str[3];
    int i,ci=0;
    for(i=0;i<3;i++)
    {
        cin>>str[i];
        getchar();
    }
    int flag=0;
    while(1)
    {
        sort(str,str+3);
        if(str[1]==str[2])
        {
            if((str[1]-str[0])%2==0)
            {
                 ci=ci+(str[1]-str[0])/2;
                 flag=1;
                 break;
            }
            else
            {
                ci=ci+(str[1]-str[0]+1)/2+1;
                flag=1;
                break;
            }
            if(flag==1)break;
        }
        else
        {
            str[0]++;
            str[1]++;
            ci++;
        }
    }
    cout<<ci<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using i64 = __int128_t;
using vi = vector<i64>;
using vvi = vector<vi>;
constexpr i64 MOD = 1e9 + 7;

i64 fact[101010];
i64 factinv[101010];

i64 modpow(i64 a, i64 n, i64 mod) {
    if (n == 0) return 1;
    if (n % 2 == 0) {
        i64 t = modpow(a, n / 2, mod);
        return t * t % mod;
    }
    return a * modpow(a, n - 1, mod) % mod;
}

void build() {
    fact[0] = 1;
    for (int i = 1; i < 101010; i++) {
        fact[i] = fact[i - 1] * i % MOD;
    }
    factinv[101010 - 1] = modpow(fact[101010 - 1], MOD - 2, MOD);
    for (int i = 101010 - 2; i >= 0; i--) {
        factinv[i] = factinv[i + 1] * (i + 1) % MOD;
    }
    assert(factinv[0] == 1 && factinv[1] == 1);
}

vi as;
vi sum;

int main() {
    build();
    int n;
    cin >> n;
    as = vi(n);
    sum = vi(n + 1);
    int a;
    for (int i = 0; i < n; i++) {
        cin >> a;
        as[i] = a;
        sum[i + 1] = sum[i] + as[i];
    }

    i64 ans = fact[n] * sum[n] % MOD;
    for (int i = 1; i < n; i++) {
        ans += fact[n] * factinv[i + 1] % MOD * fact[i] % MOD * ((sum[i] - sum[0]) + (sum[n] - sum[n - i])) % MOD;
        ans %= MOD;
    }

    i64 tmp = 0;
    for (int i = 1; i < n - 1; i++) {
        i64 cur = sum[n - i] - sum[i];
        ans += 2 * (tmp + cur) * fact[n] % MOD * factinv[i + 2] % MOD * fact[i] % MOD;
        ans %= MOD;
        tmp += cur;
    }

    cout << int64_t(ans) << endl;
}


Measured memory_bytes: 6528
#include<bits/stdc++.h>
/*#include<iostream>
#include<stdio.h>
#include<ctype.h>
#include<string.h>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<climits>*/
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define rep1(i,a,b) for(int i=a;i<=(b);++i)
#define per(i,a,b) for(int i=a;i>(b);--i)
#define per1(i,a,b) for(int i=a;i>=(b);--i)
#define LL long long
#define inf 0x7f7f7f7f
#define N 35
using namespace std;

int main()
{
	int a=1,b=1;
	while(a<10&&b<10)
	{
		printf("%dx%d=%d\n",a,b,a*b);
		b++;
		if(b>9)
		{
			a++;
			b=1;
		}
	}
}



Measured memory_bytes: 3024
#include <iostream> 
#include <vector>

using namespace std;

int main(int argc, char *argv[]) {
	int N;
	cin >> N;

	vector<int> a(N);
	for (int i = 0; i < N; i++) cin >> a[i];

	long ans_pos = 0;
	long sum = 0;
	for (int i = 0; i < N; i++) {
		sum += a[i];
		if (i % 2 == 1 && sum >= 0) {
			ans_pos += sum + 1;
			sum = -1;
		} else if (i % 2 == 0 && sum <= 0) {
			ans_pos += -sum + 1;
			sum = 1;
		}
	}

	long ans_neg = 0;
	sum = 0;
	for (int i = 0; i < N; i++) {
		sum += a[i];
		if (i % 2 == 0 && sum >= 0) {
			ans_neg += sum + 1;
			sum = -1;
		} else if (i % 2 == 1 && sum <= 0) {
			ans_neg += -sum + 1;
			sum = 1;
		}
	}

	cout << min(ans_pos, ans_neg) << endl;
	return 0;
}

Measured memory_bytes: 768
n, a, b, c = [int(x) for x in input().split()]
l_list = [int(input()) for _ in range(n)]

s_list = [a, b, c]

ans = 10000
for i in range(4 ** n):
    mp = 0
    temp_l_list = [0, 0, 0]
    
    for j in range(n):
        temp = (i >> (2 * j)) & 3
        if temp == 3:
            continue

        if temp_l_list[temp] != 0:
            mp += 10
        temp_l_list[temp] += l_list[j]

    for s, temp_l in zip(s_list, temp_l_list):
        if temp_l == 0:
            break
        mp += abs(s - temp_l)
    else:
        if ans > mp:
            ans = mp
print(ans)

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

int main() {
  long N;
  cin>>N;
  vector<long> a(N);
  for(int i=0;i<N;i++){
    cin>>a[i];
    }
  long ans=0;
  long M=a[0];
for(int i=1;i<N;i++){
  if(a[i]<a[i-1]){
    ans+=a[i-1]-a[i];
    M+=a[i-1];
    a[i]=a[i-1];
  }
  if(a[i]<a[i-1]){
    M=a[i];
  }
}
cout<<ans<<endl;
}


Measured memory_bytes: 4772
n,l=map(int,input().split())
ll=[]
lll=[]
mi=False
for i in range(1,n+1):
    ll.append(l+i-1)
    lll.append(abs(l+i-1))
    if (l+i-1)<0:
        mi=True
if 0 in ll:
    print(sum(ll))
elif mi:
    print(sum(ll)+min(lll))
else:
    print(sum(ll)-min(ll))


Measured memory_bytes: 38256
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,n,s) for(int i = s; i < (n); ++i)
#define rsrep(i,n,s) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<x<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define out_ary(...) { for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vstr> vvstr;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;

int main() {
    string o, e;
    cin >> o >> e;
    string ans = "";
    rep(i, o.length()) {
        ans += o[i];
        if (i >= e.length()) break;
        ans += e[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<cstdlib>
#include<cmath>
#include<string>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
ll xcnt[100005]={0},ycnt[100005]={0};
ll sx[100005]={0},sy[100005]={0};
vector<ll> node[100005];
bool used[100005];
int main(){
  ll n;
  cin>>n;
  vector<P> zp;
  zp.push_back(P(0,0));
  for(ll i=1;i<=n;i++){
    ll x,y;
    cin>>x>>y;
    zp.push_back(P(x,y));
    xcnt[x]++;
    ycnt[y]++;
    if(sx[x]==0){
      sx[x]=i;
    }
    else{
      node[sx[x]].push_back(i);
      node[i].push_back(sx[x]);
      sx[x]=i;
    }
    if(sy[y]==0){
      sy[y]=i;
    }
    else{
      node[sy[y]].push_back(i);
      node[i].push_back(sy[y]);
      sy[y]=i;
    }
  }
  for(ll i=0;i<=n;i++) used[i]=false;
  ll ans=0;
  for(ll i=1;i<=n;i++){
    if(used[i]) continue;
    vector<bool> xu(100005,false),yu(100005,false);
    ll xc=0,yc=0;
    queue<ll> que;
    que.push(i);
    ll nm=0;
    used[i]=true;
    while(!que.empty()){
      ll pos=que.front();
      que.pop();
      nm++;
    //  cout<<pos<<" ";
      ll x=zp[pos].first,y=zp[pos].second;
      if(!xu[x]){
        xu[x]=true;
        xc++;
      }
      if(!yu[y]){
        yu[y]=true;
        yc++;
      }
      for(ll j=0;j<node[pos].size();j++){
        ll to=node[pos][j];
        if(!used[to]){
          used[to]=true;
          que.push(to);
        }
      }
    }
    //cout<<endl;
    ans+=xc*yc-nm;
  //  cout<<xc<<" "<<yc<<" "<<nm<<" "<<i<<endl;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 10864
package main

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

func main() {
	sc.Split(bufio.ScanWords)
	n := nextInt()
	s, t := make([]string, n), make([]int, n)
	for i := 0; i < n; i++ {
		s[i], t[i] = next(), nextInt()
	}
	x := next()

	ans := 0
	sleep := false
	for i := 0; i < n; i++ {
		if s[i] == x {
			sleep = true
			continue
		}
		if sleep {
			ans += t[i]
		}
	}
	puts(ans)
	wt.Flush()
}

var (
	sc  = bufio.NewScanner(os.Stdin)
	rdr = bufio.NewReaderSize(os.Stdin, 1000000)
	wt  = bufio.NewWriter(os.Stdout)
)

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

func nextInt() int {
	i, _ := strconv.Atoi(next())
	return i
}

func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(next(), 64)
	return f
}

func nextInts(n int) []int {
	slice := make([]int, n)
	for i := 0; i < n; i++ {
		slice[i] = nextInt()
	}
	return slice
}

func nextFloat64s(n int) []float64 {
	slice := make([]float64, n)
	for i := 0; i < n; i++ {
		slice[i] = nextFloat64()
	}
	return slice
}

func nextMega() string {
	buf := make([]byte, 0, 1000000)
	for {
		l, p, _ := rdr.ReadLine()
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}

func putf(format string, a ...interface{}) {
	fmt.Fprintf(wt, format, a...)
}

func puts(a ...interface{}) {
	fmt.Fprintln(wt, a...)
}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
int main(void){
    int n[28];
    bool m[30];
    for(int i=0;i<30;++i){
        m[i]=false;
    }
    for(int i=0;i<28;++i){
        std::cin>>n[i];
    }
    for(int i=0;i<28;++i){
        m[n[i]-1]=true;
    }
    for(int i=0;i<30;++i){
        if(m[i]==false){
            std::cout<<i+1<<std::endl;
        }
    }
    return 0;
}

Measured memory_bytes: 3096
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define rush() int T;scanf("%d",&T);while(T--)
#define mm(a,b) memset(a,b,sizeof(a))
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define sc(a) scanf("%d",&a)
#define sc2(a,b) scanf("%d%d",&a,&b)
#define pf(a) printf("%d\n",a)
#define pf2(a,b) printf("%d %d\n",a,b)
#define p_f(a) printf("%d ",a)
#define fi first
#define se second
#define db double
#define ll long long
using namespace std;
const int inf=0x3f3f3f3f;
const ll INF=0x3f3f3f3f3f3f3f3f;
const db eps=1e-9;

int main()
{
    int a,b;
	cin>>a>>b;
	a=a*500;
	if(a>=b)puts("Yes");
	else puts("No");
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<map>

using namespace std;

int main(){
	
	cin.tie(0); ios_base::sync_with_stdio(0);
	map<int,int> mm;
	int n;
	cin>>n;
	int a[n];
	long long res = 0;
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	for(int i=n-1;i>=0;i--){
		res += mm[-i-a[i]];
		mm[a[i]-i]++;
	}
	cout<<res<<endl;
	
	return 0;
}

Measured memory_bytes: 20824
N = int(input())
S = input()
T = [0]*3

for i in range(N):
    if S[i] == "R":
        T[0] += 1
    elif S[i] == "G":
        T[1] += 1
    else:
        T[2] += 1
ans = T[0]*T[1]*T[2]
t = N // 2

for i in range(t):
    i = i+1
    j = 0
    while j + 2*i < N:
        if S[j] != S[j + i] and S[j] != S[j + 2*i] and S[j+i] != S[j + 2*i]:
            ans -= 1
        j += 1

print(ans)

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

int main() {
	int a, b, c;
	int K;
	cin >> a >> b >> c;
	cin >> K;

	int ma = max({ a,b,c });

	//cout << ma << endl;

	int sum;
	if (ma == a)sum = b + c;
	else if (ma == b) sum = a + c;
	else sum = a + b;
	//cout << sum << endl;

	for (int i = 0; i < K; i++)ma *= 2;
	cout << sum + ma << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long
#define ll long long
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
int gcd(int a,int b){return b ? gcd(b,a%b) : a;}
int lcm(int a,int b){return a/gcd(a,b)*b;}

main() {
    int N,x; cin >> N >> x; ll ans=0; int A[N]; rep(i,N) cin >> A[i];
    rep(i,N-1){
        if(A[i]>x){ans+=A[i]-x; A[i]=x;}
        if(A[i+1]>x){ans+=A[i+1]-x; A[i+1]=x;}
        if(A[i]+A[i+1]>x){
            if(A[i]!=x){
                ans+=(A[i+1]+A[i]-x);
                A[i+1]=x-A[i];
            }
            else{
                ans+=A[i+1];
                A[i+1]=0;
            } 
        } 
    }
    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<math.h>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
ll gcd(ll a, ll b) {
	return b ? gcd(b, a % b) : a;
}
ll inf = 1000000000;
ll a[2000005];
ll b[2000005] = {};
ll sum[2000005] = {};
ll choice(ll x) {
	ll ans = (x *( x - 1)) / 2;
	return ans;
}
int main() {
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		b[a[i]]++;	
	}
	ll goukei = 0;
	for (int i = 0; i < n; i++) {
		if (sum[a[i]] == 0) {
			sum[a[i]] = choice(b[a[i]]);
			goukei += sum[a[i]];
		}
	}
	ll ans;
	for (int i = 0; i < n; i++) {
		ans = goukei - sum[a[i]] + choice(b[a[i]] - 1);
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 11392
#include <bits/stdc++.h>
#define pb push_back
#define s(a, x, y) sort(a.begin()+x, a.begin()+y);
#define mp make_pair
#define F first
#define S second
#define ll long long
using namespace std;
ll n, a, q, b, c, S, x[100002];
int main() {
	cin>>n;
	for(int i=0; i<n; i++) {
	    cin>>a;
	    S+=a;
	    x[a]++;
	}
	cin>>q;
	for(int i=0; i<q; i++){
	    cin>>b>>c;
	    S-=x[b]*b;
	    S+=x[b]*c;
	    x[c]+=x[b];
	    x[b]=0;
	    cout<<S<<endl;
	}
	return 0;
}

Measured memory_bytes: 4404
#include <algorithm>
#include <bitset>
#include <boost/rational.hpp>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (int64_t)(n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

int main() {
  int H, W, A, B;
  cin >> H >> W >> A >> B;

  rep(i, H) {
    rep(j, W) { cout << ((i < B) == (j < A) ? 1 : 0); }
    cout << "\n";
  }

  return 0;
}

Measured memory_bytes: 1280
#include <iostream>

using namespace std;

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

  for (int c = 1; 4 > c; c++) {
    if (0 != ((a * b * c) % 2)) {
      cout << "Yes" << endl;
      return 0;
    }
  }

  cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.*;
import static java.lang.Math.*;
import java.math.BigInteger;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int n = sc.nextInt();
		int[] a = new int[n];
		long sum = 0;
		for(int i = 0; i < n; i++){
		    a[i] = sc.nextInt();
		    sum += a[i];
		}
		// 計算
		long result = 0;
		Arrays.sort(a);
		//System.out.println(Arrays.toString(a));
		for(int i = 0; i < n - 1; i = i+2){
		    if(a[i] >= 0){
		        break;
		    }else if(a[i+1] <= 0){
		        sum = sum - 2*a[i] - 2*a[i+1];
		    }else{
		        if(a[i] + a[i+1] < 0){
		            sum = sum - 2*a[i] - 2*a[i+1];
		        }
		    }
		}
		result = sum;
		// 出力
        System.out.println(result);
	}
}

Measured memory_bytes: 50392
#include <iostream>

using namespace std;

int main() {
  int N;
  int t[100001];
  int x[100001];
  int y[100001];
  t[0] = 0;
  x[0] = 0;
  y[0] = 0;
  cin >> N;
  for (int i = 1; i <= N ; i++) {
    cin >> t[i] >> x[i] >> y[i];
  }

  bool is_ok = true;
  //cout << "-------------" << endl;
  for (int i = 0; i <= N - 1; i++) {
    int z = abs(x[i+1] - x[i]) + abs(y[i+1] - y[i]);
    int t_diff = t[i+1] - t[i];
    //cout << "z:" << z << ",t_diff:" << t_diff << endl;
    if (t_diff >= z) {
      if (t_diff % 2 == 0 && z % 2 == 0) {
        //cout << "even" << endl;
        is_ok = true;
      } else if (t_diff % 2 != 0 && z % 2 != 0) {
        //cout << "odd" << endl;
        is_ok = true;
      } else {
        cout << "No" << endl;
        is_ok = false;
        break;
      }
    } else {
      cout << "No" << endl;
      is_ok = false;
      break;
    }
  }
  if (is_ok) {
    cout << "Yes" << endl;
  }
}


Measured memory_bytes: 1408
n,m = map(int,input().split())
ab = [] 
for _ in range (m):
    a,b = map(int,input().split())
    ab.append(a)
    ab.append(b)
for i in range(1,n+1):
    s = ab.count(i)
    if s == 0:
        print(0)
    else:
        print(s)

Measured memory_bytes: 3060
N, T = map(int, input().split())
t = list(map(int, input().split()))

ans = 0
end = -1
start = -1
for x in t:
    if end < x:
        ans += (end - start)
        start = x
        end = x + T
    else:
        end = x + T

ans += (end - start)

print(ans)


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

const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++) {
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

long long COM(int n, int k) {
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll solve() {
  COMinit();
  ll H, W, A, B;
  cin >> H >> W >> A >> B;
  ll ans = 0;
  ll h = H - A;
  ll w = W - B;
  rep(i, 0, h) {
    ans = (ans + COM(i + B - 1, B - 1) * COM(H - i - 2 + w, w - 1)) % MOD;
  }
  return ans;
}

int main() {
  cout << solve() << endl;
  return 0;
}


Measured memory_bytes: 12288
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

vector<int> Eratosthenes(ll n) {
  vector<int> res(n + 1, 1);
  res[0] = res[1] = 0;
  for (ll i = 2; i * i <= n; i++)
    if (res[i]) {
      for (ll j = 2; i * j <= n; j++) res[i * j] = 0;
    }
  return res;
}

int main() {
  ll n;
  cin >> n;
  vector<int> a = Eratosthenes(1e6);
  FOR(i, n, 1e6) {
    if (a[i]) {
      cout << i << endl;
      return 0;
    }
  }
}

Measured memory_bytes: 4096
# coding=utf-8
from math import floor, ceil, sqrt, factorial, log, gcd
from itertools import accumulate, permutations, combinations, product, combinations_with_replacement
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque
from heapq import heappop, heappush, heappushpop, heapify
import copy
import sys
INF = float('inf')
mod = 10**9+7
sys.setrecursionlimit(10 ** 6)


def lcm(a, b): return a * b / gcd(a, b)

# 1 2 3
# a, b, c = LI()


def LI(): return list(map(int, sys.stdin.buffer.readline().split()))

# a = I()


def I(): return int(sys.stdin.buffer.readline())

# abc def
# a, b = LS()


def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()

# a = S()


def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')

# 2
# 1
# 2
# [1, 2]


def IR(n): return [I() for i in range(n)]

# 2
# 1 2 3
# 4 5 6
# [[1,2,3], [4,5,6]]


def LIR(n): return [LI() for i in range(n)]

# 2
# abc
# def
# [abc, def]


def SR(n): return [S() for i in range(n)]

# 2
# abc def
# ghi jkl
# [[abc,def], [ghi,jkl]]


def LSR(n): return [LS() for i in range(n)]

# 2
# abcd
# efgh
# [[a,b,c,d], [e,f,g,h]]


def SRL(n): return [list(S()) for i in range(n)]


n, k = LI()
# n = [int(x) for x in str(n)]
d = set(LI())
notd = list(set(range(10)) - d)
q = deque()
q.appendleft(0)
cnt = 0
ans = []
num = []

# while q:
#     now = q.popleft()
#     cnt += 1
#     if cnt > len(n):
#         ans.append(int("".join(list(map(str, num)))))
#         num = []
#         cnt = 0

#         continue
#     for x in notd:
#         if now in notd:
#             continue
#         num.append(x)
#         q.appendleft(x)

# print(min([x for x in ans if x >= n]))
limit = 11*n
while n < limit:
    flg = 1
    for x in list(str(n)):
        if int(x) in d:
            flg = 0
            break
    if flg:
        print(n)
        break
    n += 1


Measured memory_bytes: 74628
#include<bits/stdc++.h>
 
#define rep(i,n) for(int i = 0;i < n;++i)
#define all(v) v.begin(),v.end()
using namespace std;
using ll = long long;
typedef pair<int,int> P;
 
const int INF = 1001001001;

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

    int k,a,b,f=0;
    cin >> k >> a >> b;
    for(int i = a;i <= b;++i){
        if(i % k == 0){
            f = 1;
        }
    }
    if(f == 0) cout << "NG" << endl;
    else cout << "OK" << endl;


    cout << endl;
    return 0;
}

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

int main(){
    int N,Q;
    long long K;
    cin >> N >> K >> Q;
    vector<long long> vec(N,K-Q);
    for(int i=0;i<Q;i++){
        int ans;
        cin >> ans;
        vec[ans-1]++;
    }
    for(int i=0;i<N;i++){
        if(vec[i]>0){
            cout <<"Yes" << endl;
        }
        else{
            cout << "No" <<endl;
        }
    }
}


Measured memory_bytes: 1408
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int data[100];
int sp=0;

void push(int x){
    data[sp++] = x;
}

int pop(){
    return data[--sp];
}

void stack_plus(){
    push( pop() + pop() );
}

void stack_minus(){
    int x = pop();
    push( pop() - x );
}

void stack_load(){
    push( pop() * pop() );
}

int main(){
    char ch[100];
    int x;
    while(scanf("%s",ch) != EOF){
        if(ch[0] == '+'){
            stack_plus();
        }else if(ch[0] == '-'){
            stack_minus();
        }else if(ch[0] == '*'){
            stack_load();
        }else{
            x = atoi(ch);
            push(x);
        }
        //printf("%d\n",data[0]);
    }
    printf("%d\n",data[0]);
    return 0;
}



Measured memory_bytes: 2044
n, m, c = map(int, input().split())
b = list(map(int, input().split()))
ans = 0
count = 0
for i in range(n):
    a = list(map(int, input().split()))
    for j in range(m):
        ans += a[j] * b[j]
    ans += c
    if ans > 0:
        count += 1
    ans = 0

print(count)


Measured memory_bytes: 3060
#include<stdio.h>

int H, W, N, K;
int ans_map[50][50];

void check2h(int h, int w, int num) {
	int p;
	int c = 0;
	
	if(num == 2) {
		ans_map[h][w] = 1;
		ans_map[h][w+1] = 1;
		return;
	}
	
	printf("? %d %d %d %d\n", h, w, h, w);
	fflush(stdout);
	scanf("%d", &p);
	ans_map[h][w] = p;
	c += p;
	if(c == num) return;
	
	ans_map[h][w+1] = 1;
}

void check10h(int h, int w, int num) {
	int i;
	int p;
	int c = 0;
	
	for(i=0;i<5;i++) {
		printf("? %d %d %d %d\n", h, w+i*2, h, w+i*2+1);
		fflush(stdout);
		scanf("%d", &p);
		if(p > 0) {
			c += p;
			check2h(h, w+i*2, p);
			if(c == num) return;
		}
	}
}

int main() {
	int i, j;
	int p;
	int c = 0;
	long ans = 0;
	long pow = 1;
	
	scanf("%d %d %d %d", &H, &W, &N, &K);
	
	for(i=0;i<50;i++) {
		for(j=0;j<5;j++) {
			if(c == N) break;
			printf("? %d %d %d %d\n", i, j*10, i, j*10+9);
			fflush(stdout);
			scanf("%d", &p);
			if(p > 0) {
				c += p;
				check10h(i, j*10, p);
			}
		}
	}
	
	for(i=0;i<H;i++) {
		for(j=0;j<W;j++) {
			if(ans_map[i][j]) ans += pow;
			pow *= 2;
			ans %= K;
			pow %= K;
		}
	}
	
	printf("! %ld\n", ans);
	
	return 0;
}

Measured memory_bytes: 596
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int top, S[1000];

void push(int x) {
	S[++top] = x;
}

int pop() {
	top--;
	return S[top+1];
}

int main(void) {
	int a, b;
	top = 0;
	char s[100];
	int count = 0;
	
	while ( scanf("%s", s) != EOF ) {
		if (s[0] == '+') {
			a = pop();
			b = pop();
			push(a + b);
		} else if (s[0] == '-') {
			b = pop();
			a = pop();
			push(a - b);
		} else if (s[0] == '*') {
			a = pop();
			b = pop();
			push(a * b);
		}else {
			push(atoi(s));
		}
		if (getchar() == '\n') break;
	}
	printf("%d\n", pop());

	return 0;
}

Measured memory_bytes: 548
value=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
K=int(input())
print(value[K-1])

Measured memory_bytes: 9092