akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;



public class Main {


	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long ans = 0;
		int n = sc.nextInt();
		long[][] count = new long[10][10];
		for (int i=1;i<=n;i++) {
			int j=i;
			while(j>=10) {
				j/=10;
			}
			count[j][i%10]++;
		}
		for (int i=1;i<=9;i++) {
			for (int j=1;j<=9;j++) {
				ans += (count[i][j]*count[j][i]);
			}
		}
		System.out.println(ans);
	}
}





Measured memory_bytes: 21972
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstring>
#include<stack>
#include<queue>
using namespace std;

#define read(x) scanf("%d",&x)
#define readl(x) scanf("%lld",&x)
#define ll long long 
#define ull unsigned long long
#define MOD 998244353 
#define inf 2147483647

int n,m,x;
int c[20],a[20][20];
int ans,now,f;
int rt[20];

int main()
{
	read(n),read(m),read(x);
	ans=inf;
	for(int i=1;i<=n;i++)
	{
		read(c[i]);
		for(int j=1;j<=m;j++)
		{
			read(a[i][j]);
		}	
	}
	for(int i=0;i<=(1<<n)-1;i++)
	{
		memset(rt,0,sizeof(rt));
		now=0;
		f=0;
		for(int j=0;j<=n-1;j++)
		{
			if(i&(1<<j))
			{
				now+=c[j+1];
				for(int k=1;k<=m;k++) rt[k]+=a[j+1][k];
			}
		}
		for(int j=1;j<=m;j++) if(rt[j]<x) f=1;
		if(!f) ans=min(ans,now); 
	}
	if(ans>2e9) printf("-1\n");
	else printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 3828
N=int(input())
mod=10**9+7
t=0
a,b,c=1,1,1
for i in range(N):
    a*=10
    b*=9
    c*=8
    if i%10==0:
        a%=mod
        b%=mod
        c%=mod
ans=(a+c-(2*b))%mod
print(ans)

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

typedef long long int ll;
typedef unsigned long long int ull;
#define rep(i,n) for(ll i=0;i<(n);i++)

using namespace std;



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

    ll n = s.size();

    vector<char> v;
    vector<int> w(n, 0);

    ll ix = 0;
    rep(i, n){
        if(s[i] != 'x'){
            v.push_back(s[i]);
            ix++;
        }
        else w[ix]++;
    }

    ix++;

    ll m = v.size();
    rep(i, m/2){
        if(v[i] != v[m-i-1]){
            cout << -1 << endl;
            return 0;
        }
    }

    ll sum = 0;
    rep(i, ix/2){
        sum += abs(w[i] - w[ix-i-1]);
    }

    cout << sum << endl;



    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define D(x) cerr << #x << " = " << (x) << ", "
template <typename T> ostream& operator<<(ostream& _o_, const vector<T>& _v_){ \
 if(!_v_.empty()){_o_<<'[';copy(_v_.begin(),_v_.end(),ostream_iterator<T>(_o_,", "));_o_<<"\b\b]";}return _o_;}
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
typedef unsigned int uint;
typedef unsigned long ul;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef unsigned char uchar;
struct secure_hash {
 static uint64_t splitmix64(uint64_t x) {
  x += 0x9e3779b97f4a7c15; x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9; x = (x ^ (x >> 27)) * 0x94d049bb133111eb; return x ^ (x >> 31); }
 size_t operator()(uint64_t x) const {
  static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count(); return splitmix64(x + FIXED_RANDOM); } };
template<typename T> using V = vector<T>;
template<typename T, typename U> using umap = unordered_map<T,U,secure_hash>;
template<typename T> using uset = unordered_set<T,secure_hash>;
template<typename T> using min_heap = priority_queue<T, vector<T>, greater<T>>;
template<typename T> using max_heap = priority_queue<T>;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n, k;
    cin >> n >> k;
    V<int> a(n);
    rep(i,0,n) cin >> a[i];
    V<bool> win(k+1);
    win[0] = false;
    rep(i,1,k+1) {
        win[i] = false;
        for (int x : a) {
            if (x > i) break;
            if (not win[i-x]) {
                win[i] = true;
                break;
            }
        }
    }
    cout << (win[k] ? "First" : "Second") << endl;
}


Measured memory_bytes: 256
n, m = list(map(int, input().split()))
s = []
c = []
for _ in range(m):
    s_i, c_i = list(input().split())
    s.append(int(s_i))
    c.append(c_i)
for i in range(10 ** n):
    num = str(i)
    if len(num) == n and all([num[s[j] - 1] == c[j] for j in range(m)]):
        print(num)
        exit()
print(-1)

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

using namespace std;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int M, D;
  cin >> M >> D;
  int count = 0;
  for (int m = 1; m <= M; m ++) {
    for (int d = 1; d <= D; d ++) {
      int d1 = d % 10;
      int d10 = d / 10;
      if (d1 >= 2 && d10 >= 2 && d1 * d10 == m) {
        count += 1;
      }
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <assert.h>
#include <vector>

#include <cmath>
#include <algorithm>
#include <string>
#include <set>
#include <climits>

#define N 4
#define N2 16

using namespace std;

// const int N = 4;
// const int N2 = 16;

static const int dx[4] = {0, -1, 0, 1};
static const int dy[4] = {1, 0, -1, 0};
static const char dir[4] = {'r', 'u', 'l', 'd'}; 


struct Node
{
	int puzzle[N2];
	int space;
	int md;
};

class Npuzzle
{
private:
	Node s_node;
	Node cur_n;
	int limit;
	int md[N2][N2];
	// vector<int> path;
	int ans;
public:
	Npuzzle() {
		s_node = Node();
		int in[N2];
		for (int i = 0; i < N2; ++i)
		{
			int tmp;
			cin >> tmp;
			if(tmp == 0) {
				tmp = N2;
				s_node.space = i;
			}
			s_node.puzzle[i] = tmp;
		}
		set_md();
		s_node.md = get_md_sum(s_node.puzzle);
	}

	int get_md_sum(int *puzzle) {
		int sum = 0;
		for (int i = 0; i < N2; ++i)
		{
			if(puzzle[i] == N2) continue;
			sum += md[i][puzzle[i]-1];
		}
		return sum;
	}

	void set_md() {
		for (int i = 0; i < N2; ++i)
		{
			for (int j = 0; j < N2; ++j)
			{
				md[i][j] = abs(i / N - j / N) + abs(i % N - j % N);
			}
		}
	}

	bool dfs(int depth, int pre) {
		if(cur_n.md == 0 ) {
			ans = depth;
			return true;
		}
		if(depth + cur_n.md > limit) return false;
		int s_x = cur_n.space / N;
		int s_y = cur_n.space % N;
		for (int i = 0; i < 4; ++i)
		{
			Node tmp = cur_n;
			int new_x = s_x + dx[i];
			int new_y = s_y + dy[i];
			if(new_x < 0  || new_y < 0 || new_x >= N || new_y >= N) continue; 
			if(max(pre, i) - min(pre, i) == 2) continue;

			//incremental manhattan distance
			cur_n.md -= md[new_x * N + new_y][cur_n.puzzle[new_x * N + new_y] - 1];
			cur_n.md += md[s_x * N + s_y][cur_n.puzzle[new_x * N + new_y] - 1];

			swap(cur_n.puzzle[new_x * N + new_y], cur_n.puzzle[s_x * N + s_y]);
			cur_n.space = new_x * N + new_y;
			// assert(get_md_sum(new_n.puzzle) == new_n.md);
			// return dfs(new_n, depth+1, i);
			if(dfs(depth + 1, i)){
				// path[depth] = i;
				return true;
			}
			cur_n = tmp;
		}
		return false;
	}

	void ida_star() {
		for (limit = s_node.md; limit < 1000; ++limit)
		{
			// path.resize(limit);
			cur_n = s_node;
			if(dfs(0, -10)) {
				cout << limit << endl;
				// string str = "";
				// for (int i = 0; i < limit; ++i)
				// {
				// 	str += dir[path[i]];
				// }
				// cout << str << endl;
				return;
			}
		}
	}

	void exec() {
		ida_star();
	}
};


int main() {
	Npuzzle np = Npuzzle();
	np.exec(); 
}

Measured memory_bytes: 3116
d, g = map(int, input().split())
p = [0] * d
c = [0] * d
for i in range(d):
    p[i], c[i] = map(int, input().split())
ans = []
def greedy(count,comp,diff):
    ret = -1
    for i in range(d-1,-1,-1):
        if not(i in comp):
            if (p[i]-1)*(i+1)*100 >= diff:
                ret = count + diff//((i+1)*100) + (diff % ((i+1)*100) != 0)
                break
    return ret

def search(i,score,count,comp):
    if i == d:
        if score >= g:
            ans.append(count)
            return
        res = greedy(count,comp,g - score)
        if res != -1:
            ans.append(res)
    else:
        search(i+1,score,count,comp)
        comp.append(i)
        search(i+1,score+p[i]*(i+1)*100+c[i],count+p[i],comp)
search(0,0,0,[])
print(min(ans))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<long long> vll;
typedef vector<pair<int,int>> vp;
typedef pair<int,int> pii;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,n) for(int i=1;i<=(int)(n);i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define ALL(a)  a.begin(),a.end()
#define RALL(a) a.begin(),a.end(),greater<int>()
#define ROT(a) a.begin(),a.begin()+1,a.end()
#define RROT(a) a.begin(),a.end()-1,a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
#define sz(a) a.size()
const ll MOD = 1e9+7;
const int MAX = 10000000;
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
//cout << 'H' << endl;
//next_permutation(ALL(p));
//typedef priority_queue<int> pque;//これは大きい順
//typedef priority_queue<int, vector<int>, greater<int>> pque;//これは小さい順
//factorizeは、素因数分解用の関数

int main(){
	int a,b;
	cin >> a >> b;
	if((a+b)%2 == 0){
		cout << (a+b)/2 << endl;
	}else{
		cout << "IMPOSSIBLE" << endl;
	}

  return 0;
}


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

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
#define FOR(i, a, b) for(int i = 0; i < (a); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define fst first
#define snd second
#define pf push_front
#define pb push_back
#define eb emplace_back
#define all(obj) (obj).begin(), (obj).end()
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
//#define int long long int
const int MOD = 1000000007;
const ll LINF = (ll)1e18 - 1;
const int INF = 1e9 - 1;
const double EPS = 0.000000001;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

signed main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  int n = s.size();
  VI a(n, 0);
  int rc = 0;
  rep(i, n){
    if(s[i] == 'R') rc++;
    else{
      a[i] += rc / 2;
      a[i-1] += rc - (rc / 2);
      rc = 0;
    }
  }
  int lc = 0;
  for(int i = n-1; i >= 0; --i){
    if(s[i] == 'L') lc++;
    else{
      a[i] += lc / 2;
      a[i+1] += lc - (lc / 2);
      lc = 0;
    }
  }
  rep(i, n) cout << a[i] << " ";
  cout << endl;
  return 0;
}


Measured memory_bytes: 1104
n, t = list(map(int, input().split()))

INITIAL_MIN_COST = 10000
min_cost = INITIAL_MIN_COST

for i in range(n):
    cost, time = list(map(int, input().split()))
    if time > t:
        continue
    if min_cost > cost:
        min_cost = cost

if min_cost == INITIAL_MIN_COST:
    print('TLE')
else:
    print(min_cost)


Measured memory_bytes: 2940
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <utility>
#include <algorithm>
#include <unordered_map>
#include <math.h>
#include <cctype>
using namespace std;
#define _USE_MATH_DEFINES

int gcd(int a, int b) {
	if (a < b)
		return gcd(b, a);
	else {
		if (b == 0)
			return a;
		else
			return gcd(b, a%b);
	}
}
int main() {
	int a, b;
	cin >> a >> b;
	cout << gcd(a, b)<<endl;
}

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

int main()
{
	cin.sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(10);
	int a,b,c;
	cin >> a >> b >> c;
	if(c - a + b > 0)
		cout << c- a + b;
	else
		cout << 0;
	
	return 0;
 } 

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

string s;

void solve() {
    if (s.at(2) == s.at(3) && s.at(4) == s.at(5)) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

int main() {
    cin >> s;
    solve();
}

Measured memory_bytes: 256
uses math;
const fi='kstones.inp';
      fo='kstones.out';
      maxn=100;
var n,k,mmin:int32;
    a:array[1..maxn] of int32;
    f:array[0..100000] of boolean;
//=============================
procedure nhap;
var i:int32;
begin
   readln(n,k);
   mmin:=maxlongint;
   for i:=1 to n do
   begin read(a[i]); mmin:=min(mmin,a[i]); end;
end;
//=============================
procedure xuli;
var i,j:int32;
    ok:boolean;
begin
   fillchar(f,sizeof(f),false);
   for i:=mmin to k do
   begin
    ok:=false;
    for j:=1 to n do
    if i>=a[j] then
    if not f[i-a[j]] then
     begin
        ok:=true; break;
     end;
    f[i]:=ok;
   end;
   if f[k] then write('First') else write('Second');
end;
//=============================
begin
//   assign(input,fi); reset(input);
//   assign(output,fo); rewrite(output);
   nhap;
   xuli;
//   close(input); close(output);
end.


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main() {
  
int n , l , r , k ;
cin >> n ;
  int g = 0 ;
  for ( int i = 0 ; i < n ; i++ ){ 
    cin >> l >> r ;
   k = r - l + 1 ;
   g = k + g ;
  }    
cout << g << endl;   
       
}


Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod = 1e9 + 7;
int n;
ll qpow(ll x, ll n)
{
	ll res = 1;
	while(n)
	{
		if(n & 1) res = res * x % mod;
		x = x * x % mod;
		n >>= 1;
	}
	return res;
}
int main()
{
    std::ios::sync_with_stdio(false);
    cin >> n;
    if(n == 1) cout << 0 << endl;
    else 
    {
    	ll a0 = qpow(9, n), a9 = qpow(9, n), a09 = qpow(8, n), tmp = qpow(10, n);
    	cout << (tmp - a0 - a9 + 2 * mod + a09) % mod << endl;
	}
	return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stdlib.h>
#include <map>
#include <cmath>
#define MOD_P 1000000007
#define MOD_Q 998244353
#define PI 3.14159265358979
#define ll long long
using namespace std;


int main()
{
	int n;
	cin >> n;
	vector<int> mins(n);
	vector<int> maxs(n);

	for (int i = 0; i < n; i++) {
		cin >> mins[i] >> maxs[i];
	}

	sort(mins.begin(), mins.end());
	sort(maxs.begin(), maxs.end());

	if (n % 2) {
		printf("%d", maxs[(n - 1) / 2] - mins[(n - 1) / 2] + 1);
	} else {
		printf("%d", maxs[n / 2] + maxs[n / 2 - 1] - mins[n / 2] - mins[n / 2 - 1] + 1);
	}

	/*for (int v : mins) {
		printf("%d ", v);
	}
	printf("\n");
	for (int v : maxs) {
		printf("%d ", v);
	}
	printf("\n");*/

	return 0;
}



Measured memory_bytes: 4788
#include <iostream>
#include <stdlib.h>
#include <time.h>
#include <stdio.h>

using namespace std;

int main() {

    int plane[6],planeup,planebef,n,i,j,random,box;

    for(i=0;i<6;i++){
        cin >> plane[i];
    }

    cin >> n;
    for(j=0;j<n;j++){
        cin >> planeup >> planebef;

        while(1){
            if(planeup == plane[0] && planebef == plane[1]){
                cout << plane[2] << endl;
                break;
            }
            random = rand() % 4 + 1;

             if(random == 1){
                 box=plane[0];
                 plane[0]=plane[4];
                 plane[4]=plane[5];
                 plane[5]=plane[1];
                 plane[1]=box;
             }
             else if(random == 2){
                 box=plane[0];
                 plane[0]=plane[1];
                 plane[1]=plane[5];
                 plane[5]=plane[4];
                 plane[4]=box;
             }
             else if(random == 3){
                 box=plane[0];
                 plane[0]=plane[2];
                 plane[2]=plane[5];
                 plane[5]=plane[3];
                 plane[3]=box;
             }
             else if(random == 4){
                 box=plane[0];
                 plane[0]=plane[3];
                 plane[3]=plane[5];
                 plane[5]=plane[2];
                 plane[2]=box;
             }
        }
        
    }
    return 0;
}

Measured memory_bytes: 1164
#include<iostream>
#include<iomanip>
#include<queue>
#include<string>
#include<stack>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<cassert>
#include<ctime>
#include<algorithm>
#include<utility>
#include<map>
#include<set>
#include<vector>
#include<functional>

using namespace std;

#ifdef DEBUG
#define dprintf      printf
#define dout(x)      cout<<#x" = "<<(x)<<endl
#define darray(x,n)  {int i;rep(i,n)cout<<#x"["<<i<<"] = "<<*((x)+i)<<endl;}
#define dloop(i,s,g) for(int (i)=(s);(i)<(g);(i)++)
#define drep(i,n)    for(int (i)=0;(i)<(n);(i)++)
#define dstop()      scanf("%*c")
#else
#define dprintf      (1)?0:printf
#define dout(x)
#define darray(x,n)
#define dloop(i,s,g) if(int i=0){}else
#define drep(i,n)    if(int i=0){}else
#define dstop()      scanf("")
#endif

#define F    first
#define S    second
#define pb   push_back
#define mp   make_pair

#define loop(i,s,g) for((i)=(s);(i)<(g);(i)++)
#define rep(i,n)    for((i)=0;(i)<(n);(i)++)
#define all(x)      (x.begin(),x.end())
#define in(T,...) T __VA_ARGS__; impl(__VA_ARGS__);
#define array(T,id,n) T id[n]; rep(i,n)cin>>id[i];

//#define int long long;
#ifndef int
#define INF (0x7fffffff)
#else
#define INF (0x7fffffffffffffff)
#endif

typedef  long long           ll;
typedef  unsigned            ui;
typedef  unsigned long long  ull;
typedef  pair<int,int>       i_i;
typedef  pair<ll,int>        ll_i;
typedef  pair<ll,ll>         ll_ll;
typedef  pair<double,int>    d_i;
typedef  pair<double,double> d_d;

void impl(){};
template <typename T,typename... TS >
void impl(T &head,TS &... tail)
{
  cin>>head;
  impl(tail ...);
}

signed main(void)
{
  in(int,n);
  int i;
  int a[112345]={};
  int b[112345]={};
  rep(i,n)
    cin>>a[i];

  int max=0;
  int min=INF;
  rep(i,n)
    {
      b[a[i]]++;
      if(a[i]>max)max=a[i];
      if(a[i]<min)min=a[i];
    }
  int ans=1;
  int sum;
  for(i=min;i<max+2;i++)
    {
      sum=b[i]+b[i+1]+b[i+2];
      if(ans<sum)ans=sum;
    }
  
  cout<<ans<<endl;
  return 0;
}


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

#include <iostream>


#define MOD 1000000007

typedef unsigned long long ull;
typedef long long ll;

using namespace std;
auto f=[]()
{
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
};

int main()
{
	f();
	ll n,a,b;cin>>n>>a>>b;
	ll tot=(a+b);

	//ll q=(n/tot);
	//ll m=(n%tot);

	cout<<((n/(a+b)*a)+min(a,n%(a+b)))<<'\n';
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main () {
	int N,D,X;
	cin >> N >> D >> X;
	int count = X;
    D--;
	for (int i = 0; i < N; ++i)
	{
		int tmp;
		cin >> tmp;
		count += D / tmp + 1;


	}
	cout << count << endl;
}

Measured memory_bytes: 256
from bisect import bisect_left
import sys
input = sys.stdin.readline


def main():
    N, K = map(int, input().split())
    XY = [list(map(int, input().split())) for _ in range(N)]

    Xs = []
    Ys = []
    for x, y in XY:
        Xs.append(x)
        Ys.append(y)
    Xs.sort()
    Ys.sort()
    points = [[0 for _ in range(N)] for _ in range(N)]

    for x, y in XY:
        ix = bisect_left(Xs, x)
        iy = bisect_left(Ys, y)
        points[ix][iy] += 1

    sumpoints = [[0 for _ in range(N+1)] for _ in range(N+1)]

    for ix in range(1, N+1):
        s = 0
        for iy in range(1, N+1):
            if ix == 1:
                sumpoints[ix][iy] = points[ix-1][iy-1]
            if points[ix-1][iy-1] == 1:
                s = 1
            sumpoints[ix][iy] = sumpoints[ix-1][iy] + s

    ans = int(8E18)
    for lx in range(N-1):
        for rx in range(lx+1, N):
            for ly in range(N-1):
                for ry in range(ly+1, N):
                    if sumpoints[rx+1][ry+1] - sumpoints[rx+1][ly] - sumpoints[lx][ry+1] + sumpoints[lx][ly] >= K:
                        s = (Xs[rx]-Xs[lx])*(Ys[ry]-Ys[ly])
                        ans = min(ans, s)
    print(ans)

if __name__ == "__main__":
    main()

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

int main(){
string S, T;
cin >> S >> T;
int ans = 0; 
for (int i = 0; i < 3; i++) {
    if (S.at(i) == T.at(i)) {
        ans++;
    }
}
cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <limits.h>
#include <math.h>
#include <assert.h>
typedef int64_t ll;
typedef uint64_t ull;
int acs(const void *a, const void *b){return *(int*)a - *(int*)b;} /* 1,2,3,4.. */
int des(const void *a, const void *b){return *(int*)b - *(int*)a;} /* 8,7,6,5.. */
#define min(a,b) (a < b ? a: b)
#define max(a,b) (a > b ? a: b)

#define MAXN (200001)
#define MOD (1000000007)

int main(void)
{
    ll n;
    scanf("%ld",&n);

    for(int i=1;i<=9;i++)for(int j=1;j<=9;j++)
    {
        if(n==i*j)
        {
            printf("Yes\n");
            return 0;
        }
    }
    printf("No\n");
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using vb=vector<bool>;
using vvb=vector<vb>;
using vc=vector<char>;
using vvc=vector<vc>;
using pii = pair<int,int>;
using pil = pair<int,ll>;
using pli = pair<ll,int>;
using pll = pair<ll,ll>;
using tiii = tuple<int,int,int>;
using vpii = vector<pii>;
using vpil = vector<pil>;
using vpli = vector<pli>;
using vpll = vector<pll>;

#define rep(i, n) for(int i=0;i<(int)n;i++)
#define rep2(i, s, n) for(int i=(s);i<(int)n;i++)
int INF=1e9+7;

int main() {
  ll N,X;
  int M;
  cin >> N >> X >> M;
  
  vl check(M);
  ll ans=0;
  ll l=0,r=0;
  for(ll i=1;i<N+1;i++) {
    if(check[X]) {
      l=check[X];
      r=i;
      break;
    }
    else {
      check[X]=i;
      ans+=X;
      (X*=X)%=M;
    }
  }
  if(l==0) cout << ans << endl;
  else {
    ll K=(N-l+1)/(r-l),R=(N-l+1)%(r-l);
    ll A=0,B=0;
    for(ll i=0;i<r-l;i++) {
      A+=X;
      if(i==R-1) B=A;
      (X*=X)%=M;
    }
    cout << ans+A*(K-1)+B << endl;
  }
}

Measured memory_bytes: 4048
#include <iostream>

using namespace std;

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

    for(int i = 100; i <= 999; i++){
        int A = N / 100;
        int B = N/10;
        B = B % 10;
        int C = N % 10;

        if(A == B && B == C){
            ans = N;
            break;
        }

        N++;
    }

    cout << ans;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(){
    while (1) {
        int x,y,i;
        scanf("%d",&y);
        if (y==0) {
            return 0;
        }
        for (i=0; i<9; i++) {
            scanf("%d",&x);
            y-=x;
        }
        printf("%d\n",y);
    }
}

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

int main() {
  int N ,K;
  cin >> N >> K;
  int ans =1;

  for(int i =0;i <N ;i++){
    if(ans <K){
      ans *= 2;
    }

    else{
      ans +=K;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
a = [list(map(int,input().split())) for _ in range(3)]
n = int(input())
hit = [[0,0,0] for i in range(3)]
for i in range(n):
  b = int(input())
  for ii in range(3):
    for jj in range(3):
      if b == a[ii][jj]:
        hit[ii][jj] = 1
bingo=False
for i in range(3):
  f = True
  for j in range(3):
    if hit[i][j] == 1:
      continue
    else:
      f = False
  bingo = f
  if bingo:
    break
if not bingo:
  for j in range(3):
    f = True
    for i in range(3):
      if hit[i][j] == 1:
        continue
      else:
        f = False
    bingo = f
    if bingo:
      break
if not bingo:
  if hit[0][0] == 1 and hit[1][1] == 1 and hit[2][2] == 1:
    bingo = True
  elif hit[2][0] == 1 and hit[1][1] == 1 and hit[0][2] == 1:
    bingo = True
print('Yes' if bingo else 'No')

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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) for(i64 i = 1; i <= n; ++i)
#define RREP(i, n) for(i64 i = n - 1; i >= 0 ; --i)
#define RREPS(i, n) for(i64 i = n; i >= 1; --i)

#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define pb push_back
#define mp make_pair
#define F first
#define S second

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

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }

template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }


struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;


#define N 5
i64 k;
i64 X[N];

int main() {
    REP(i, N) cin >> X[i];
    cin >> k;

    REP(i, N - 1) {
        for (i64 j = i + 1; j < N; j++) {
            if (X[j] - X[i] > k) {
                cout << ":(" << endl;
                return 0;
            }
        }
    }
    cout << "Yay!" << endl;

    return 0;
}

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

int main(){
  string s,t;
  cin >> s >> t;
  for(auto x:s){
    for(auto y:t){
      if(x<y){
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  sort(s.begin(),s.end());
  sort(t.begin(),t.end());
  if(s<t){
    cout << "Yes" << endl;
    return 0;
  }
  cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
using System;
class aoj
{
    static void Main()
    {
        string []a = new string[50];
        int i = 0;
        while (true)
        {
            string b = Console.ReadLine();
            if (String.IsNullOrEmpty(b)) break;
            double v = double.Parse(b);
            double t = v / 9.8;
            double y = 4.9 * Math.Pow(t, 2);
            double n = (y + 5) / 5;
            n = Math.Ceiling(n);
            a[i++] = n.ToString();
        }
        for(int j = 0; j < i; j++)
        {
            Console.WriteLine(a[j]);
        }
    }
}

Measured memory_bytes: 9188
my $s = <STDIN>;
my($H,$W,$K) = split (/ /,$s);
my @data;
for(my $i=0; $i<$H;$i++){
  $s = <STDIN>;
  my @dat = split(//,$s);
  for(my $j=0; $j<$W;$j++){
    $data[$i][$j] = $dat[$j];
  }
}
my @list;
$list[0][0] = 0;
for(my $i=0; $i<($H-1);$i++){
  my @newlist;
  for(my $j=0;$j<=$#list;$j++){
    my @new   = @{$list[$j]};
    my @new2 = @new;
    push (@new, $new[-1]);
    push (@new2, $new[-1]+1 );
    push (@newlist,\@new);
    push (@newlist,\@new2);
  }
  @list = @newlist;
}
my $mincut = $H+$W;
for(my $k=0; $k<=$#list;$k++){
  if ($mincut < $list[$k][-1]){last};
  my $cut =0;
  my @gcount;
  my $nextflag=0;
  for(my $j=0; $j<$W;$j++){
    my @rowcount ;
    my $cutflag =0;
    for(my $i=0; $i<$H;$i++){
        if($data[$i][$j]){
            $rowcount[$list[$k][$i]]++;
        }
    }
    for(my $m=0;$m<=$#rowcount;$m++){
        if($K < $rowcount[$m] ){
            $nextflag =1;
            last;
        }
        if($K<($rowcount[$m]+$gcount[$m]) ){
            $cutflag =1;
        }
    }
    if($nextflag){last;}
    if($cutflag){
        @gcount = @rowcount;
        $cut++;
    }else{
        for(my $m=0;$m<=$#rowcount;$m++){
          $gcount[$m] = $gcount[$m] + $rowcount[$m];
        }
    }
  }
  if($nextflag){ next;}
  $cut = $cut + $list[$k][-1];
  if( $cut < $mincut){
    $mincut = $cut;
  }
}
print "$mincut\n";


Measured memory_bytes: 1664
#include <bits/stdc++.h>
#define rep(i,m,n) for(int i=m; i<n; i++)
#define co(n) cout << n << endl
using namespace std;
int main(){
  char s='A', k;
  int h, w;
  cin >> h >> w;
  string a[h][w];
  rep(i,0,h){
    rep(j,0,w) cin >> a[i][j];
  }
  
  rep(i,0,h){
    rep(j,0,w){
      if(a[i][j]=="snuke"){
        k=s+j;
        cout << k << i+1 << endl;
      }
    }
  }
  
  
  return 0;
}


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

B = list(map(int, input().split()))
B.append(10**5+1)
B.insert(0, 10**5+1)


max_sum = 0

for i in range(1, N):
    max_sum += min(B[i], B[i-1])

max_sum += B[-2]

print(max_sum)



Measured memory_bytes: 38256
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <set>
#include <iterator>
#include <math.h>
#include <bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
#define pb push_back
#define dd double
#include <algorithm>
#include <cmath>
using namespace std;
int main()
{
	ll N,M,D;
	cin>>N>>M>>D;

	ll a,b,c;

	a=(ll)(abs(N)/D);
	ll present,next;
	if(a>=M)
	{
		// no chances of flipping;
		if(N>0)
		{
			N=N-M*D;
		}
		else
		{
			N=N+M*D;
		}
		cout<<abs(N)<<"\n";
	}
	else
	{
		if(N>0)
		{
			b=N-a*D;
			c=b-D;
		}
		else
		{
			b=N+a*D;
			c=b+D;
		}
		M=M-a;
			present=b;
			next=c;
		if(abs(b)>abs(c))
		{
			M--;
			present=c;
			next=b;
		}
		if(M%2==0)
		{
			cout<<abs(present);
		}
		else
		{
			cout<<abs(next);
		}
	}
	return 0;
}

Measured memory_bytes: 3632
#include<iostream>
#include<algorithm>
#include<cstdio>
using namespace std;
const int maxn=200005;
struct bag{
    int x,y;
}p[maxn];
bool operator < (bag a,bag b){
    if(a.x==b.x)return a.y<b.y;
    return a.x<b.x;
}
int n,Rmax,Rmin,Bmax,Bmin;
int main(){
    long long ans=1e18;
    scanf("%d",&n);
    if(n==1){
        cout<<0<<endl;return 0;
    }
    for(int i=0;i<n;i++){
        scanf("%d%d",&p[i].x,&p[i].y);
        if(p[i].x>p[i].y){
            int k=p[i].x;
            p[i].x=p[i].y;
            p[i].y=k;
        }
    }
    sort(p,p+n);
    int Max=p[0].y,Min=p[0].x,_max=0,_min=0;
    for(int i=1;i<n;i++){
        if(p[i].x<=Min&&p[i].y>=Max){
            Min=p[i].x;Max=p[i].y;
            _max=i;_min=i;
        }
        else if(p[i].x<Min){
            Min=p[i].x;
            _min=i;
        }else if(p[i].y>Max){
            Max=p[i].y;
            _max=i;
        }
    }
    Rmax=Max;Bmin=Min;
    Rmin=p[_min].y;Bmax=p[_max].x;
    for(int i=0;i<n;i++){
        Rmin=min(Rmin,p[i].y);
        Bmax=max(Bmax,p[i].x);
    }
    ans=(long long)(Rmax-Rmin)*(Bmax-Bmin);
    if(_max!=_min){
        Bmax=Max;Bmin=Min;
        Rmax=max(p[n-1].x,p[0].y);
        int premin=p[0].y;
        Rmin=min(p[0].y,p[1].x);
        //sort(p,p+n);
        long long ans0=Rmax-Rmin;
        for(int i=1;i<n-1;i++){
            Rmax=max(p[i].y,Rmax);
            Rmin=min(min(premin,p[i].y),p[i+1].x);
            premin=min(premin,p[i].y);
            if(Rmax-Rmin<ans0)ans0=Rmax-Rmin;
        }
        ans0*=Bmax-Bmin;
        ans=min(ans,ans0);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1792
s = input()
N = len(s)
ls = [0] + [i for i in range(1,N) if (s[i-1]=='L' and s[i] == 'R')]
ls.append(N)
ls2 = [(ls[i],ls[i+1]) for i in range(len(ls)-1)]
ls3 = [i for i in range(1,N) if (s[i-1]=='R' and s[i] == 'L')]
res = ['0']*N
for i,tp in enumerate(ls2):
    res[ls3[i]] = str((tp[1]-ls3[i]-1)//2+(ls3[i]-tp[0])//2+1)
    res[ls3[i]-1] = str((tp[1]-ls3[i])//2+(ls3[i]-tp[0]-1)//2+1)
print(' '.join(res))


Measured memory_bytes: 17476
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <numeric>
#include <chrono>
#include <bitset>
#include <tuple>
#include <queue>
#include <cstring>
#include <cassert>
using namespace std;

const int N = 12 + 10, mod = 1e9 + 7;

int n, m, x;
int arr[N][N];
int c[N];
int cur[N];
int ans = (1 << 30);

void brute(int i, int cost) {
    if(i == n) {
        bool ok = 1;
        for(int j = 0; j < m; j++) ok &= (cur[j] >= x);
        if(!ok) return;
        ans = min(ans, cost);
        return;
    }
    brute(i + 1, cost);
    for(int j = 0; j < m; j++) cur[j] += arr[i][j];
    brute(i + 1, cost + c[i]);
    for(int j = 0; j < m; j++) cur[j] -= arr[i][j];
}

int main() {
    // ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int tc = 1; 
    // scanf("%d", &tc);
    for(int cn = 1; cn <= tc; cn++) {
        scanf("%d%d%d", &n, &m, &x);
        for(int i = 0; i < n; i++) {
            scanf("%d", &c[i]);
            for(int j = 0; j < m; j++) scanf("%d", &arr[i][j]);
        }
        brute(0, 0);
        if(ans == (1 << 30)) ans = -1;
        printf("%d\n", ans);
    }  
    return 0;
}

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

int main() {
  long a,b;
  cin >> a >> b;
  long gcd=0;
  for(long i=1;i<=min(a,b);i++){
    if(a%i==0 && b%i==0) gcd=i;
  }
  cout << a*b/gcd; 
}


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

using namespace std;

int main ()
{
	int n, k, ans = 0;
	scanf ("%d%d", &n, &k);
	for (int i = 1; i <= n; ++i)
	{
		int tmp;
		scanf ("%d", &tmp);
		ans += tmp >= k;
	}
	printf ("%d\n", ans);
	return 0;
}

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

#define dump(...) cout<<"# "<<#__VA_ARGS__<<'='<<(__VA_ARGS__)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define all(c) begin(c),end(c)
#define mp make_pair
#define mt make_tuple

using uint=unsigned;
using ll=long long;
using ull=unsigned long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using vd=vector<double>;
using vvd=vector<vd>;
using vs=vector<string>;

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

template<typename Tuple>
void print_tuple(ostream&,const Tuple&){}
template<typename Car,typename... Cdr,typename Tuple>
void print_tuple(ostream& os,const Tuple& t){
	print_tuple<Cdr...>(os,t);
	os<<(sizeof...(Cdr)?",":"")<<get<sizeof...(Cdr)>(t);
}
template<typename... Args>
ostream& operator<<(ostream& os,const tuple<Args...>& t){
	print_tuple<Args...>(os<<'(',t);
	return os<<')';
}

template<typename Ch,typename Tr,typename C>
basic_ostream<Ch,Tr>& operator<<(basic_ostream<Ch,Tr>& os,const C& c){
	os<<'[';
	for(auto i=begin(c);i!=end(c);++i)
		os<<(i==begin(c)?"":" ")<<*i;
	return os<<']';
}

constexpr int INF=1e9;
constexpr int MOD=1e9+7;
constexpr double EPS=1e-9;

int solve_small(int n,int c,vi as,vi bs)
{
	rep(i,n) assert(as[i]==bs[i]);

	vvi xs(n,vi(c+1));  // xs[i][j]=x_iのj乗
	rep(i,n){
		xs[i][0]=1;
		rep(j,c) xs[i][j+1]=ll(xs[i][j])*as[i]%MOD;
	}

	vvi dp(n+1,vi(c+1));  // dp[i][j]: [0,i)までにj個使う
	dp[0][0]=1;
	rep(i,n) rep(j,c+1) rep(k,j+1)
		dp[i+1][j]=(dp[i+1][j]+(ll)dp[i][j-k]*xs[i][k])%MOD;

	return dp[n][c];
}

int solve(int n,int c,vi as,vi bs)
{
	vvi pow(401,vi(401));  // pow[i][j]: pow(i,j)
	rep(i,pow.size()){
		pow[i][0]=1;
		repi(j,1,pow[i].size())
			pow[i][j]=(ll)pow[i][j-1]*i%MOD;
	}

	vvi xs(n,vi(c+1));
	rep(i,n)
		rep(j,c+1)
			repi(x,as[i],bs[i]+1)
				(xs[i][j]+=pow[x][j])%=MOD;

	vvi dp(n+1,vi(c+1));
	dp[0][0]=1;
	rep(i,n) rep(j,c+1) rep(k,j+1)
		dp[i+1][j]=(dp[i+1][j]+(ll)dp[i][j-k]*xs[i][k])%MOD;

	return dp[n][c];
}

int main()
{
	for(int n,c;cin>>n>>c && n|c;){
		vi as(n),bs(n);
		rep(i,n) cin>>as[i];
		rep(i,n) cin>>bs[i];
		cout<<solve(n,c,as,bs)<<endl;
	}
}


Measured memory_bytes: 2176
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define debug(x) cout << #x << ": " << x << endl
#define repn(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, a) for(int i = 0; i < (int)(a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define endl '\n'

int gcd(int a, int b){ return ((b == 0) ? a : gcd(b, a % b)); }

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	int a, b, c;
	cin >> a >> b >> c;
	cout << (a * b) / 2 << endl;
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;

using ll = long long;

int main(){
    ll A, B, X;
    cin >> A >> B >> X;
    for (auto && i: irange(0LL, B+1)){
        if (A + i == X){
            cout << "YES";
            return 0;
        }
    }
    cout << "NO";

  return 0;
}

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

int main(){
	int n;
	int m;
	int h[500];
	int r[500];
	int dp[500];
	for(;;){
		cin >> n;
		if(n==0) break;
		for(int i=0; i<n; i++){
			cin >> h[i] >> r[i];
		}
		cin >> m;
		for(int i=0; i<m; i++){
			cin >> h[i+n] >> r[i+n];
		}

		for(int i=(n+m)-1; i>=0; i--){
			for(int j=0; j<i; j++){
				if(h[j]>h[j+1]){
					int tmp = h[j];
					h[j] = h[j+1];
					h[j+1] = tmp;

					tmp = r[j];
					r[j] = r[j+1];
					r[j+1] = tmp;
				}
			}
		}

//		for(int i=0; i<(n+m); i++){
//			cout << h[i] << " " << r[i] << endl;
//		}

		for(int i=0; i<(n+m); i++){
			dp[i] = 1;
		}

		for(int i=0; i<(n+m); i++){
			for(int j=0; j<i; j++){
				if(r[j]<r[i] && h[j]<h[i]){
					if(dp[i]<dp[j]+1){
						dp[i] = dp[j]+1;
					}
				}
			}
		}

		int mx = 0;
		for(int i=0; i<(n+m); i++){
			if(mx<dp[i]) mx = dp[i];
		}
		cout << mx << endl;

	}

}

Measured memory_bytes: 1164
#include <iostream>
#include <algorithm>
#include <vector>
#include <tuple>
#include <set>
#define pb push_back
using namespace std;
typedef tuple<int,int,int> T;
int a,b,c;
set<int> st;

int main(){
  int n,q;
  cin >> n >> q;
  int s[n],t[n],x[n],d[q];
  for(int i=0;i<n;i++) cin >> s[i] >> t[i] >> x[i];
  for(int i=0;i<q;i++) cin >> d[i];
  vector<T> event(0);
  for(int i=0;i<n;i++){
    event.pb(T(s[i]-x[i],1,x[i]));
    event.pb(T(t[i]-x[i],0,x[i]));
  }
  sort(event.begin(),event.end());
  int k=0;
  for(int i=0;i<2*n;i++){
    tie(a,b,c)=event[i];
    while(a>d[k]&&k<q){
      if(st.empty()) cout << -1 << endl;
      else cout << *st.begin() << endl;
      k++;
    }
    if(b) st.insert(c);
    else st.erase(c);
  }
  for(int i=k;i<q;i++) cout << -1 << endl;
}

Measured memory_bytes: 19692
package main

import (
	"fmt"
)

func main() {
	var s,t string
	fmt.Scan(&s,&t)
	
	if s == t[:len(t)-1] && len(t) == len(s) + 1 {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}

Measured memory_bytes: 1752
import numpy as np

N = int(input())
A = np.array(list(map(int, input().split())))

A2 = np.abs(A)
x = A2.min()
s = A2.sum()
A3 = A < 0
if sum(A3) % 2 == 0:
    print(s)
else:
    print(s-2*x)



Measured memory_bytes: 23380
s=list(input())

l=0
r=len(s)-1

ans=0
while r-l>0:
  if s[l]==s[r]:
    l+=1
    r-=1
  else:
    if s[l]=="x":
      l+=1
      ans+=1
    elif s[r]=="x":
      r-=1
      ans+=1
    else:
      print(-1)
      exit()
      
print(ans)

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

using namespace std;
using ll = long long;

#define REP(i, n) for (ll i = 0; i < n; i++)
#define INF 9223372036854775807
#define all(x) (x).begin(), (x).end()

ll ts = 1000000007;

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

  ll a, b, c;
  cin >> a >> b >> c;

  bool can = false;
  for (int i = 1; i <= b; i++) {
    if (a * i % b == c) can = true;
  }

  cout << (can ? "YES" : "NO") << "\n";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
typedef pair<ll,ll> P;
typedef pair<ll,P> PP;
const ll MOD = 1e9+7;

int main(){
  ll n,k;
  cin>>n>>k;
  ll a[1111];
  ll sum=0;
  ll suma[1111];
  for(int i=0;i<n;i++){
	cin>>a[i];
	sum+=a[i];
	suma[i]=sum;
  }
  vector<ll> v;
  for(int i=0;i<n;i++){
	for(int j=i;j<n;j++){
	  ll t=suma[j];
	  if(i)t-=suma[i-1];
	  v.push_back(t);
	}
  }
  // for(int i=0;i<v.size();i++)cout<<v[i]<<endl;
  vector<ll> ans;
  for(int i=60;i>=0;i--){
	vector<ll> tmp;
	ll cnt=0;
	for(int j=0;j<v.size();j++){
	  if(v[j]>>i&1){
		cnt++;
		tmp.push_back(v[j]);
	  }
	}
	if(cnt<k)continue;
	v=tmp;
	ans.push_back(i);
  }
  ll an=0;
  for(int i=0;i<ans.size();i++){
	an+=1LL<<ans[i];
  }
  cout<<an<<endl;

  //  for(int i=0;i<v.size();i++)cout<<v[i]<<endl;
  
  return 0;
}


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

int main() {
  int n;
  while (cin >> n) {
    if (n == 0) {
      break;
    }
    vector<int> dp(n + 3);
    dp.at(n) = 1;
    for (int i = n - 1; i >= 0; i--) {
      dp.at(i) = dp.at(i + 1) + dp.at(i + 2) + dp.at(i + 3);
    }
    int total = dp.at(0);
    int day = 0;
    while (total > 0) {
      total -= 10;
      day++;
    }
    int year = (day + 365 - 1) / 365;
    cout << year << endl;
  }

  return 0;
}


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

using namespace std;
using ll = long long;
using edge = struct {int to; ll cost;};

#define mod 1000000007
#define REP(i, n) for (int i = 0; i < n; i++)
#define INF (1 << 29)


//long C(long n, long r);
//long long gcd(long long a, long long b);
//long long lcm(long long a, long long b);


void solve()
{
    ll n, h;
    cin >> n >> h;
    ll A = 1ll;
    priority_queue<ll> B;
    REP(i, n) {
        ll a, b;
        cin >> a >> b;
        A = max(A, a);
        B.push(b);
    }
    ll damage = 0ll;
    ll ans = 0ll;
    for(int i = 0; i < n; i++){
        if(B.top() > A){
            damage += B.top();
            ans++;
        }
        B.pop();
        if(damage >= h) {
            cout << ans << "\n";
            return;
        }
    }
    ans += (ll)ceil((double)(h - damage) / A);
    cout << ans << "\n";
}

int main()
{
    solve();
    return 0;
}

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

int calcExp(const long x) {
	int exp = 0;
	long tmp = x;
	while(tmp % 2 == 0) {
		exp += 1;
		tmp = tmp / 2;
	}
	return exp;
}

int main() {
	string buf;
	int n;
	int min_exp = 100;
	cin >> n;
	while (getline(cin, buf, ' ')) {
		long x = stol(buf);
		int tmp_exp = calcExp(x);
		if (tmp_exp < min_exp) min_exp = tmp_exp;
	}
	cout << min_exp << endl;
	return 0;
}

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

int main(void){
    long long n,sq,i;
    vector<long long> ans;
    cin>>n;
    sq=sqrt(n);
    for(i=1;i<=sq;i++){
        if(n%i==0){
            ans.push_back(i+n/i);
        }
    }
    cout<<*min_element(ans.begin(),ans.end())-2<<endl;
}

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

using namespace std;

#define INF (1 << 30)
#define EPS 1e-10
#define MOD 1000000007

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

using ll = long long;

template<class T> void chmax(T& a, T b){ a>b?:a=b; }
template<class T> void chmin(T& a, T b){ a<b?:a=b; }

int main() {
    int n, k, d, a, b[101] = { 0 };
    cin >> n >> k;
    while (k--) {
        cin >> d;
        for (int i = 0; i < d; ++i) {
            cin >> a;
            b[a] = 1;
        }
    }
    int cnt = 0;
    for (int i = 1; i <= n; ++i) {
        if (b[i] == 0)
            cnt++;
    }
    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 3636
///Bismillahir Rahmanir Rahim
#include "bits/stdc++.h"

#define                           ll                          long long
#define                           int                         ll
#define                           fi                          first
#define                           si                          second
#define                           mp                          make_pair
#define                           pb                          push_back
#define                           pi                          pair<ll,ll>
#define                           clr(x)                      memset(x,0,sizeof(x));
#define                           f(i,l,r)                    for(int i=l;i<=r;i++)
#define                           rf(i,r,l)                   for(int i=r;i>=l;i--)
#define                           done(i)                     cout<<"done = "<<i<<endl;
#define                           show(x,y)                   cout<<x<<" : ";for(auto z:y)cout<<z<<" ";cout<<endl;
#define                           fast                        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

using namespace std;

const ll inf=1e18;
const int mod=1e9+7;
const int M=100005;
int x,y,z,k,tmp;
vector<int>a,b,c,yo,ses;
bool chk(int val)
{
    int cur=0,cnt=0;
    for(auto p:yo)
    {
        int nw=val-p;
        while(c[cur]<nw && cur<z-1)
        {
            cur++;
        }
        if(c[cur]>=nw)
        {
           cnt+=(z-cur);
        }
    }
    if(cnt>=k)return true;
    else return false;
}
void work(int val)
{
    int cur=0;
    for(auto p:yo)
    {
         int nw=val-p;
        while(c[cur]<nw && cur<z-1)
        {
            cur++;
        }
        if(c[cur]>=nw)
        {
           for(int i=cur;i<z;i++)
           {
              ses.pb(p+c[i]);
           }
        }
    }
    int sz=ses.size();
    int baki=k-sz;
    while(baki--)
    {
        ses.pb(val-1);
    }
}
 main()

{
    fast
    cin>>x>>y>>z>>k;
    f(i,1,x)
    {
        cin>>tmp;a.pb(tmp);
    }
    f(i,1,y)
    {
        cin>>tmp;b.pb(tmp);
    }
    f(i,1,z)
    {
        cin>>tmp;c.pb(tmp);
    }
    sort(a.begin(),a.end());
    sort(b.begin(),b.end());
    sort(c.begin(),c.end());
    f(i,0,x-1)
    {
        f(j,0,y-1)
        {
            yo.pb(a[i]+b[j]);
        }
    }
    sort(yo.rbegin(),yo.rend());
    int lo=0,hi=30000000000;
    while(hi>lo)
    {
        int mid=(lo+hi+1)>>1;
        if(chk(mid))
        {
            lo=mid;
        }
        else
        {
            hi=mid-1;
        }
    }
    work(lo+1);
    sort(ses.rbegin(),ses.rend());
    for(auto x:ses)
    {
        cout<<x<<"\n";
    }
    return 0;

}





































Measured memory_bytes: 11640
#include <bits/stdc++.h>
#define int long long
#define ld long double
#define endl "\n"
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb(x) push_back(x)
#define mp(a,b) make_pair(a,b)
#define ms(v,x) memset(v,x,sizeof(v))
#define all(v) v.begin(),v.end()
#define ff first
#define ss second
#define rep(i,l,r) for(int i = (int)l;i<(int)r;i++)
#define td(v) v.begin(),v.end()
#define sz(v) (int)v.size()
//#define M   1000000007 // 1e9 + 7
#define MAXN 200100
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
inline int mod(int n, int m){ int ret = n%m; if(ret < 0) ret += m; return ret; }
int gcd(int a, int b){return (b == 0 ? a : gcd(b, a%b));}
int exp(int a,int b,int m){
    
    if(b==0) return 1;
    if(b==1) return mod(a,m);
    int k = mod(exp(a,b/2,m),m);
    if(b&1){
        return mod(a*mod(k*k,m),m);
    }
    else return mod(k*k,m);
}

int32_t main(){
    fastio;
    int k,x;
    cin>>k>>x;
    if(k*500LL >=x)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
  
  

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;;
#define ll long long
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define INF 1<<30
#define LINF 1LL<<62
#define all(x) (x).begin(), (x).end()
#define mp make_pair
#define pb push_back
const int MOD = 1000000007;
 
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n;cin >> n;
  double ans = 0.0;
  REP(i,n){
      double x;
      string u; 
      cin >> x >> u;
      if(u=="JPY"){
          ans += x;
      }else{
          ans += x * 380000.0;
      }
  }
  printf("%.6lf\n", ans);

}



Measured memory_bytes: 256