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

using namespace std;

const int maxn=25;

inline int read(){
	int x=0,f=1;
	char p=getchar();
	while(!isdigit(p)){
		if(p=='-') f=-1;
		p=getchar();
	}
	while(isdigit(p)) x=(x<<3)+(x<<1)+(p^48),p=getchar();
	return x*f;
}

#define pb() push_back()

int ans,f[maxn],n,vis[maxn];

vector<pair<int,int> > vec[maxn];

inline bool check(){
	for(int i=1;i<=n;i++){
		if(vis[i]==0){
			int flag=1;
			for(int j=0;j<vec[i].size();j++){
				int y=vec[i][j].first,z=vec[i][j].second;
				if(vis[y]!=z){
					flag=0;
					break;
				}
			}
			if(flag) return 0;
		}
		if(vis[i]==1){
			for(int j=0;j<vec[i].size();j++){
				int y=vec[i][j].first,z=vec[i][j].second;
				if(vis[y]!=z){
					return 0;
				}
			}
		}
	}
	return 1;
}

inline void dfs(int dep,int cnt){
	if(dep==n){
		if(check()) ans=max(ans,cnt);
		return;
	}
	vis[dep+1]=1;
	dfs(dep+1,cnt+1);
	vis[dep+1]=0;
	dfs(dep+1,cnt);
}

int main(){
	n=read();
	for(int i=1;i<=n;i++){
		int x=read();
		for(int j=1;j<=x;j++){
			int y=read(),z=read();
			vec[i].push_back(make_pair(y,z));
		}
	}
	dfs(0,0);
	cout<<ans<<endl;
	return 0;
}



















Measured memory_bytes: 256
import core.bitop;
import std.algorithm;
import std.ascii;
import std.bigint;
import std.conv;
import std.functional;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.random;
import std.typecons;
import std.container;

enum MAX = 1_000_100;
ulong MOD = 1_000_000_007;
ulong INF = 1_000_000_000_000;
alias sread = () => readln.chomp();
alias Pass = Tuple!(long, "x", long, "y");

void main()
{
    auto s = sread();
    long l = s.length / 2, cnt;
    foreach(i; iota(l))
    {
        if(s[i] != s[$ - i - 1])
            cnt++;
    }
    cnt.writeln();
}

T lread(T = long)()
{
    return readln.chomp.to!T();
}

T[] aryread(T = long)()
{
    return readln.split.to!(T[])();
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}


Measured memory_bytes: 256
n,k,c=map(int,input().split())
s=input()
l=[0]*n
pre=n+c+1
cnt=k
for i in range(n-1,-1,-1):
    if s[i]=="o" and -(i)+pre>c and cnt>0:
        pre=i
        l[i]=cnt
        cnt-=1
pre=-c-5
cnt=0
for i in range(n):
    if s[i]=="o" and i-pre>c and cnt<k:
        pre=i;cnt+=1
        if l[i]==cnt:print(i+1)


Measured memory_bytes: 12680
//int a = stoi(c); 文字列をintへ
//小文字から大文字
//transform(a.begin(), a.end(), a.begin(), ::toupper);
//途中の出力をそのまま残さない
//数値計算 個数以外はdouble
//map<キー,値> p は辞書。p[キー] = 値
//map 全探索
//auto begin = p.begin(), end = p.end();
//for (auto it = begin; it != end; it++) {}
//mapのキー：it->first mapのバリュー：it->second
//絶対値 abs()
//入力は空白で切れる
//大文字判定 isupper(文字) 小文字判定 islower(文字)
//do{}while(next_permutation(ALL(配列)))
//while(N)で回すとき、Nはコピーを作っておく
//小文字に対応する文字コード：S[i] - 'a'
//文字コード→小文字：(char)(数字+'a')
//グラフの距離:隣接行列で扱う
//等価なものに変換する思考
//bool型　初期値はTrue
//島渡りの問題：中間ノードに着目
//配列はvector<>を使う：意味わからないエラーがなくなる。
//背反な事象にちゃんとわける
//チェックリストはマップを使う
//数が大きい時の比較はstring型で行う
//全て0になったか調べたい->0になるたびにcntする
//またはかかつか
//例外処理は最初にする
#include <bits/stdc++.h>
#define rep(i,N) for(int i = 0; i < N;i++)
#define ALL(a) (a).begin(),(a).end()
#define ll long long int
using namespace std;

// K進数でのNの桁数
ll dig(ll N, ll K) {
	ll dig = 0;
	while (N) {
		dig++;
		N /= K;
	}
	return dig;
}
// a,bの最大公約数
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a%b);
}

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

//nC2の計算
ll C(ll N) {
	return N * (N - 1) / 2;
}

//円周率
const double PI = 3.14159265358979323846;
//割るやつ
const ll MOD = (pow(10, 9) + 7);

int main() {
	ll N, X; cin >> N >> X;
	vector<ll> x(N); rep(i, N)cin >> x[i];

	vector<ll> d(N);
	rep(i, N) d[i] = abs(X - x[i]);

	ll g;
	rep(i, N) {
		if (i == 0) g = d[i];
		else g = gcd(g, d[i]);
	}

	cout << g << endl;
}

Measured memory_bytes: 1792
using System;

namespace test
{
  class Program
  {
   	static void Main(string[] args)
   	{
     	string[] s = Console.ReadLine().Split(' ');
     	int apple = int.Parse(s[0]);
      	int applePiece = int.Parse(s[1]);
        Console.WriteLine((apple*3+applePiece)/2);
   	}
  }
}


Measured memory_bytes: 11092
#include <iostream>
#include <numeric>
#include <cmath>
#include <limits>
#include <stdio.h>
#include <iomanip>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
using ll = long long;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
ll Max(ll(a), ll(b), ll(c)) {
	return max(max(a, b), c);
}
ll Min(ll(a), ll(b), ll(c)) {
	return min(min(a, b), c);
}




int main() {

	ll N, K, S;
	cin >> N >> K >> S;
	if (S == 1e9) {
		rep(i, N) {
			if (i < K)cout << S << " ";
			else cout << 1 << " ";
		}
	}
	else if(S == 1) {
		rep(i, N) {
			if (i < K)cout << 1 << " ";
			else cout << 1000000000 << " ";
		} 

	}
	else {
		rep(i, N) {
			if (i < K)cout << S << " ";
			else cout << 1000000000 << " ";
		}
	}
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#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())

void yes(){
  cout << "Yes" << endl;
  exit(0);
}

void no(){
  cout << "No" << endl;
  exit(0);
}

int main(){
  string s; cin >> s;
  ll x,y; cin >> x >> y;

  // +8000平行移動
  // dp[0][j]: x=jへ到達可能か
  // dp[1][j]: y=jへ到達可能か
  ll MAX = 8000; // x,y座標の最大値
  ll A_MAX = 2*MAX+1; // dpテーブルのサイズ
  vector<vector<bool>> dp(2, vector<bool>(A_MAX,false));
  dp[0][MAX] = true; dp[1][MAX] = true;
 
  ll cnt = 0;
  ll xy = 0;
  ll pos = 0;
  bool f = false; //左へ行けるか
  while(pos<SZ(s)){
    if(s[pos]=='T'){
      f = true;
      cnt = 0;
      xy ^= 1;
      pos++;
      continue;
    }
    while(pos<SZ(s) && s[pos]=='F'){
      cnt++;
      pos++;
    }
    vector<ll> upd;
    REP(j,A_MAX) if(dp[xy][j]) upd.push_back(j);
    REP(i,SZ(upd)){
      dp[xy][upd[i]] = false;
    }
    REP(i,SZ(upd)){
      dp[xy][upd[i]+cnt] = true;
      if(f) dp[xy][upd[i]-cnt] = true;
    }
  }
  if(dp[0][x+MAX] && dp[1][y+MAX]) yes();
  else no();
}

Measured memory_bytes: 384
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <vector>
#include <set>

using namespace std;

struct Point {
	double x, y;
};

struct Segment {
	Point p1, p2; 
};

#define BOTTOM 0
#define LEFT  1
#define RIGHT 2
#define TOP 3

class EndPoint {
public:
	Point p;
	int seg, st; 
	EndPoint() {}
	EndPoint(Point p, int seg, int st) : p(p), seg(seg), st(st) {}

	bool operator < (const EndPoint & ep) const {
		if ( p.y == ep.p.y ) {
			return st < ep.st; 
		} else return p.y < ep.p.y;
	}
};

EndPoint EP[2 * 100000];

int manhattanIntersection(vector<Segment> S) {
	int n = S.size();

	for ( int i = 0, k = 0; i < n; i++ ) {
		if ( S[i].p1.y == S[i].p2.y ) {
			if ( S[i].p1.x > S[i].p2.x ) swap(S[i].p1, S[i].p2);
		} else if ( S[i].p1.y > S[i].p2.y ) swap(S[i].p1, S[i].p2);

		if ( S[i].p1.y == S[i].p2.y ) {
			EP[k++] = EndPoint(S[i].p1, i, LEFT);
			EP[k++] = EndPoint(S[i].p2, i, RIGHT);
		} else {
			EP[k++] = EndPoint(S[i].p1, i, BOTTOM);
			EP[k++] = EndPoint(S[i].p2, i, TOP);
		}
	}

	sort(EP, EP + (2 * n));
	
	set<int> BT;
	BT.insert(1000000001);
	int cnt = 0;

	for ( int i = 0; i < 2 * n; i++ ) {
		if ( EP[i].st == TOP ) {
			BT.erase(EP[i].p.x);
		} else if ( EP[i].st == BOTTOM) {
			BT.insert(EP[i].p.x);
		} else if( EP[i].st == LEFT ) {
			set<int>::iterator b = BT.lower_bound(S[EP[i].seg].p1.x);
			set<int>::iterator e = BT.upper_bound(S[EP[i].seg].p2.x);
			cnt += distance(b, e);
		}
	}

	return cnt;
}

int main()
{
	int n;
	vector<Segment> s;

	scanf("%d", &n);
	for ( int i = 0; i < n; i++ ) {
		Segment x;
		scanf("%lf %lf %lf %lf", &x.p1.x, &x.p1.y, &x.p2.x, &x.p2.y);
		s.push_back(x);
	}

	printf("%d\n", manhattanIntersection(s));
	
	return 0;
}



Measured memory_bytes: 16592
s = input()

def split_by_num(s, bits):
    i, j = 0, 0
    res = 0
    while j < len(bits):
        if bits[j] == "1":
            res += int(s[i:min(len(s), j+1)])
            j += 1
            i = j
        else:
            j += 1

    res +=  int(s[i:])
    return res


res = 0
for i in range(0, 1 << (len(s) - 1)):
    tar_bin = format(i, 'b')
    if len(tar_bin) != len(s) - 1:
        tar_bin = "0" * (len(s) - 1 - len(tar_bin)) + tar_bin
    
    res += split_by_num(s, tar_bin)
print(res)



Measured memory_bytes: 3064
#include <iostream>
using namespace std;
int main()
{
  long long n, a, b;
  int ans;
  cin >> n >> a >> b;

  if(n==1){
    if(a == b){
      cout << 1 << endl;
    } else {
      cout << 0 << endl;
    }
  } else {
    if(b >= a){
      cout << (b-a)*(n-2)+1 << endl;
    } else {
      cout << 0 << endl;
    }
  }

  return 0;
}

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

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

	double pi = acos(-1.0);

	double h = (H*60+M)/(12.0*60);
	// cout << h << endl;
	double m = M/60.0;
	h *= 2*pi;
	m *= 2*pi;

	double x1 = cos(h)*A, y1 = sin(h)*A;
	double x2 = cos(m)*B,  y2 = sin(m)*B;

	// cout << x1 << " " << y1 << endl;
	// cout << x2 << " " << y2 << endl;

	cout << fixed << setprecision(20);

	cout << hypot(x1-x2, y1-y2) << endl;
}

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

#define hell                         1000000007
#define lcm(a,b)                     (a*b)/__gcd(a,b)
#define ll                           long long
#define vll                          vector<ll>
#define vi                           vector<int>
#define pll                          vector< pair<ll,ll> >
#define pb                           push_back
#define mp                           make_pair
#define all(v)                       v.begin(),v.end()
#define lbnd                         lower_bound
#define ubnd                         upper_bound
#define bs                           binary_search
#define F                            first
#define S                            second
#define rep(i,a,b)                   for(i=a;i<b;i++)
#define parr(a,n)                    for(ll it=0;it<n;it++) cout<<a[it]<<" ";cout<<endl;
#define pcont(a)                     for(auto it:a) cout<<it<<" ";cout<<endl;
#define ret(x)                       return cout<<x,0;
#define endl                           '\n'

/*constants*/
#define MAXN                         100005
#define PI                           3.14159265358979323846

/*debug*/
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>void __f(const char* name, Arg1&& arg1){ std::cout << name << " : " << arg1 << '\n';}
    template <typename Arg1, typename... Args>void __f(const char* names, Arg1&& arg1, Args&&... args){const char* comma = strchr(names + 1, ','); std::cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);}
#else
#define trace(...)
#endif

using namespace std;


int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
	
	ll i,j,n,m,k,cnt=0,ans=0,t=1;
	string s;
	cin>>n>>s;
	rep(i,0,n){
		if(s[i]=='R') cnt++;
	}	
	if(cnt>n-cnt) ret("Yes")
		ret("No")
	
	return 0;
}

Measured memory_bytes: 256
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
			　　　　　　　　　　(¸.·´ (¸.·'* ☆
					*/

#include <iostream>
#include <vector>
#include <array>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <climits>
#include <tuple>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cmath>
#include <algorithm>
#include <memory>
#include <iomanip>
#include <type_traits>

#ifdef _MSC_VER
#include <intrin.h>
#define __builtin_popcount __popcnt
#endif
#define rep(i, n) for(Int (i) = 0; (i) < (n); ++(i))
#define all(n) std::begin(n), std::end(n)
#define rall(n) std::rbegin(n), std::rend(n)
#define debug(var) std::cout << #var << ": " << var << "\n"
using Int = int64_t;
constexpr Int INF = INT_MAX;
constexpr Int mod = 1e9 + 7;
using namespace std;


void init() {
	std::cin.tie(nullptr);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
}


void calc() {

	std::string S; std::cin >> S;
	rep(i, S.size()) {
		if (S[i] == '9')std::cout << '1';
		else std::cout << '9';
	}

}


int main() {

	init();
	calc();

	return 0;
}

Measured memory_bytes: 256
import java.io.IOException;
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {
		// TODO ?????????????????????????????????????????????
		// ?????°?????£?¨?
		int a, b;
		String str1, str2;
		ArrayList<String> st = new ArrayList<String>();

		// ???????????????
		Scanner scan = new Scanner(System.in);
		st.add(scan.next());
		st.add(scan.next());

		str1 = st.get(0);
		str2 = st.get(1);

		a = Integer.parseInt(str1);
		b = Integer.parseInt(str2);

		if (a < -1000 || b < -1000 || a > 1000 || b > 1000) { // a,b??§?????¶??????
			System.out.println("a,b?????????-1000~1000??§??\???.???????????????.");
			System.exit(0);
		}

		if (a > b) {
			System.out.println("a > b");
		}

		else if (a < b) {
			System.out.println("a < b");
		}

		else if (a == b) {
			System.out.println("a == b");
		}
	}

}

Measured memory_bytes: 26304
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <string>
#include <sstream>

using namespace std;


#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define INF 1<<30
#define mp make_pair
#define pb push_back



typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pair<int, int> > vp;

typedef long long ll;

int main(){
	int MAX = 64;
	//char buffer[sizeof(long) * 8 + 1];
	string n,buffer;
	char ans;
	ll mi = pow(10, 17);
	ll ma = pow(10, 18)-1;
	ll mid;
	string check,lcheck;
	rep(i, MAX){
		mid = (mi + ma) / 2;
		//_i64toa_s(mid, buffer, sizeof(long) * 8 + 1, 10);
		buffer = to_string(mid);
		string buff = buffer;
		check = buff.substr(0, 10);
		if (check == lcheck && check[9] == '0'){
			break;
		}
		lcheck = check;

		cout << "? " << buffer << endl;
		//cout << "@: " << i+1 << endl;
		cin >> ans;
		if (ans == 'Y'){
			ma = mid;
		} else if(ans=='N'){
			mi = mid;
		}
	}
	ll threshold = mid / pow(10, 8);
	//109 vs 1090 10901 : y y  1091 : y y 110 : y n
	//99 vs 990 9901:y y 991:y y 100: n : y
	//199 VS 1990 19901: y y 1991:y y 200: y n
	ll res = threshold;
	for (int i = 9; 0 < i; i--){
		threshold = 1 + threshold / 10;
		cout << "? " << threshold << endl;
		cin >> ans;
		//99999の時の処理
		if (threshold == pow(10, i)){
			if (ans == 'Y'){
				break;
			}
			if (ans == 'N'){
				res /= 10;
				break;
			}
		} else{
			if (ans == 'N'){
				break;
			}
		}
		res /= 10;
	}
	/*
	_i64toa_s(mid, buffer, sizeof(long) * 8 + 1, 10);
	stringstream s;
	s << buffer;
	string buff=s.str();
	string highest = "";
	string res;
	rep(i,buff.size()-8){
		highest += buff[i];
	}
	for (int i = highest.size() - 1;; i--){
		res = highest.substr(0, i);
		cout << "? " + res << endl;
		cin >> ans;
		if (ans == 'Y'){
			break;
		}
	}*/

	cout << "! ";
	cout << res << endl;

	return 0;
}


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

using namespace std;

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

    vector<int> A(N-1);
    vector<int> ans(N);
    for(int i = 0; i < N-1; i++){
        cin >> A[i];
    }

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

    for(int i = 0; i < N; i++){
        cout << ans[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 4840
//解説あり
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <string>
#include <stack>

#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 pb push_back
#define mp make_pair
#define bg begin()
#define en end()
#define all(v) (v).begin(), (v).end()
#define sz(v) (int) (v).size()


using namespace std;

typedef long long ll;

static const long long MOD = 1000000007;

int h, w, k, ans = 1000000000;
char s[15][1005];
int a[15][1005];

int main(void) {
  cin >> h >> w >> k;
  rep(i, 0, h) scanf("%s", s[i]);
  rep(i, 0, h) rep(j, 0, w) if (s[i][j] == '1') a[i][j+1] = 1;
  
  rep(i, 0, h) rep(j, 1, w+2) a[i][j] += a[i][j-1];
  
  for(int S=0; S<(1<<(h-1)); S++) {
    int c = 0, s = 0;
    rep(i, 1, w+2) {
      int sum = 0;
      rep(j, 0, h) {
        sum += a[j][i] - a[j][s];
        if (sum>k) {
          if (i==w+1) c = 1000000000;
          c++;
          sum = 0;
          s = i-1;
          break;
        }
        if ((S>>j) & 1) sum = 0;
      }
    }
    //for (int i=0; i<h-1; i++) if ((S>>i)&1) c++;
    c += __builtin_popcount(S);
    ans = min(ans, c);
  
  }
  
  
  cout << ans << "\n";

  return 0;
}


Measured memory_bytes: 256
using System;
        using System.Linq;
        using System.Collections.Generic;
        using static System.Math;

        public class Program
        {
            public static void Main(string[] args)
            {
            int[] gridInput = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            string[,] grid = new string[gridInput[0] + 1,gridInput[1] + 2];

            for (int i = 0; i < gridInput[0]; i++)
            {
                for (int j = 0; j < gridInput[1] + 2; j++)
                {
                    grid[i, j] = ".";
                }
            }

            for (int i = 1; i < gridInput[0] + 1; i++)
            {
                string input = Console.ReadLine();
                for (int j = 1; j < gridInput[1] + 1; j++)
                {
                    grid[i, j] = input.Substring(j - 1,1);
                }
            }

            bool check = true;
            for (int i = 1; i < gridInput[0]; i++)
            {
                for (int j = 1; j < gridInput[1]; j++)
                {
                    if (grid[i,j] == "#")
                    {
                        int count = 0;
                        if (grid[i + 1, j] == "." && grid[i, j + 1] == "."
                            && grid[i - 1, j] == "." && grid[i, j -1] == ".")
                        {
                            check = false;
                        }
                    }
                }
            }

            Console.WriteLine(check == true? "Yes":"No");
            }
        }

Measured memory_bytes: 13368
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main{
//	private int LinearSearch(int[] a1, int[] a2) {
//		
//	}
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		Set<Integer> set1 = new HashSet<>();
		for (int i = 0; i < n; ++i) 
			set1.add(scan.nextInt());
		int q = scan.nextInt();
		Set<Integer> set2 = new HashSet<>();
		for (int i = 0; i < q; ++i) 
			set2.add(scan.nextInt());
//		set1.retainAll(set2);//求共同元素
//		//返回值表示set1的内存发生改变，s两者可能没有公共元素，set1变成空集
//		System.out.println(set1.size());
		int sum = 0;
		for(int i : set1)
			for (int j : set2) {
				if(i == j)
					sum++;
			}
		System.out.println(sum);
				
	}

}



Measured memory_bytes: 40160
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int main(){
    ll n;
    map<ll,ll> mp;
    ll q,x,sum=0;
    cin>>n;
    for(ll i=1;i<=n;i++){
        scanf("%lld",&x);
        if(mp.find(x)==mp.end()){
            mp[x]=1;
        }
        else mp[x]++;
        sum+=x;
    }
    cin>>q;
    ll a,b;
    for(ll i=1;i<=q;i++){
        cin>>a>>b;
        if(mp.find(a)==mp.end()){
            printf("%lld\n",sum);
        }
        else{
            ll y=mp[a];
            mp.erase(a);
            mp[b]+=y;
            sum=sum-a*y+b*y;
            printf("%lld\n",sum);
        }
    }
    return 0;
}


Measured memory_bytes: 7592
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll,ll> P;
using VP = vector<P>; using VVP = vector<VP>;
using VI = vector<ll>; using VVI = vector<VI>; using VVVI = vector<VVI>;
const int inf=1e9+7;
const ll INF=1LL<<58;
const ll mod=1e9+7;

int main(){
  int i,j,k;
  int n,m;
  cin>>n>>m;
  VVI v(n);
  vector<P> ban;
  ban.pb(P(-1,-1));
  for(i=0;i<m;i++){
    int s,t;
    cin>>s>>t;
    s--;
    t--;
    v[s].pb(t);
    ban.pb(P(s,t));
  }
  
  double ans=INF;
  vector<double> d(n,0);
  for(i=0;i<1;i++){
    //vector<double> d(n,0);
    d[n-1]=0;
    ll f=0;
    for(j=n-2;j>=0;j--){
      ll ok=v[j].size();
      for(k=0;k<v[j].size();k++){
        if(ban[i].fi==j&&ban[i].se==v[j][k]){
          ok--;
        }
        if(ok==0) {
          f=1;
          break;
        }
      }
      if(f==1) break;
      for(k=0;k<v[j].size();k++){
        if(ban[i].fi==j&&ban[i].se==v[j][k]) continue;
        else {
          d[j]+=d[v[j][k]];
        }
      }
      d[j]/=ok;
      d[j]+=1;
    }
    if(f==1) continue;
    ans=min(ans,d[0]);
  }


  for(i=n-1;i>=0;i--){
    vector<double> dd;
    dd=d;
    if(v[i].size()==1) continue;
    double ma=0;
    ll ok=v[i].size();
    for(k=0;k<v[i].size();k++){
      ma=max(ma,dd[v[i][k]]);
    }
    dd[i]--;
    dd[i]*=ok;
    dd[i]-=ma;
    dd[i]/=(ok-1);
    dd[i]+=1;
    for(j=i-1;j>=0;j--){
      double t=0;
      for(k=0;k<v[j].size();k++){
        t+=dd[v[j][k]];
      }
      t/=v[j].size();
      t+=1;
      dd[j]=t;
    }
    ans=min(ans,dd[0]);
  }
  cout<<fixed<<setprecision(15)<<ans<<endl;

}

Measured memory_bytes: 7784
#include <iostream> // cin, cout, cerr
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota
#include <cstdio> // printf, scanf
#include <string> // string, stoi, to_string
#include <vector> // vector
#include <queue> // queue, priority_queue
#include <deque> // deque
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <iomanip> // cout<<setprecision(n)
#include <functional> // function<void(int)>
#include <cmath>
#include <cassert>
#include <bitset>

#ifdef DEBUG
#include "debug.hpp"
#else
#define debug(...)
#endif

#define int long long // at least int64 > 9*10^18
#define EL '\n'
#define rep(i,n) for(int i = 0; i < (n); i++)
#define print(i) std::cout << (i) << '\n'
#define all(v) (v).begin(), (v).end()
/* libraries */

constexpr int MOD = 1e9+7;
struct mint
{
	int v;
	mint():v(0){}
	mint(int v):v((v+MOD)%MOD){}
	mint operator-()const{ return mint(0) - *this; }
	mint& operator+=(const mint& a){ if((v+=a.v)>=MOD) v-=MOD; return *this; }
	mint& operator-=(const mint& a){ if((v+=MOD-a.v)>=MOD) v-=MOD; return *this; }
	mint& operator*=(const mint& a){ (v*=a.v)%=MOD; return *this; }
	mint& operator/=(const mint& a){ (*this) *= a.inv(); return *this; }
	mint operator+(const mint& a)const{ return mint(*this) += a; }
	mint operator-(const mint& a)const{ return mint(*this) -= a; }
	mint operator*(const mint& a)const{ return mint(*this) *= a; }
	mint operator/(const mint& a)const{ return mint(*this) /= a; }
	bool operator<(const mint& a)const{ return v < a.v; }
	bool operator==(const mint& a)const{ return v == a.v; }
	mint pow(int k)const{ mint r(1),t(v); while(k){ if(k&1) r*=t; t*=t; k>>=1; } return r; }
	mint inv()const{ return pow(MOD-2); }
	static mint comb(int n, int k) {
		if(n-k<k) k=n-k;
		mint num(1), dom(1);
		for(int i=0;i<k;i++) { num*=n-i; dom*=i+1; }
		return num/dom;
	}
};
std::istream& operator>>(std::istream&i,mint&a){ int t; i>>t; a=mint(t); return i; }
std::ostream& operator<<(std::ostream&o,const mint&a){ o<<a.v; return o; }


std::vector<mint> construct_comb(int n) {
	std::vector<mint> c(n+1);
	mint a = 1;
	c[0] = a;
	for(int i=1;i<=n;i++) {
		a = a*mint(n+1-i)/i;
		c[i] = a;
	}
	return c;
}


signed main() {
	int n,k;
	std::cin >> n >> k;
	std::vector<int> a(n);
	rep(i,n) std::cin >> a[i];
	std::sort(all(a));
	std::map<int,int> map;
	rep(i,n) map[a[i]]++;
	mint sum=0;
	std::vector<mint> fact(n+1,1);
	for(int i=2;i<=n;i++) fact[i]=fact[i-1]*mint(i);
	// for max
	for(auto p:map) {
		int x=p.first,y=p.second;
		auto ub=std::upper_bound(all(a),x);
		auto lb=std::lower_bound(all(a),x);
		int m=ub-a.begin();
		int m2=lb-a.begin();
		mint c=0;
		if(m>=k) c+=fact[m]/fact[k]/fact[m-k];
		if(m2>=k) c-=fact[m2]/fact[k]/fact[m2-k];
		sum+=mint(x)*c;
		mint c2=0;
		if(a.end()-lb>=k) c2+=fact[a.end()-lb]/fact[k]/fact[a.end()-lb-k];
		if(a.end()-ub>=k) c2-=fact[a.end()-ub]/fact[k]/fact[a.end()-ub-k];
		sum-=mint(x)*c2;
	}
	print(sum);

	return 0;
}


Measured memory_bytes: 7552
import sys

input = sys.stdin.readline


def main():
    n, x = [int(i) for i in input().split()]
    l_list = [int(i) for i in input().split()]
    n += 1
    d = 0
    num = 1
    for i in range(1, n):
        d = d + l_list[i - 1] * (i <= n + 1)
        if d > x:
            break
        num += 1
    print(num)


if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
# coding UTF-8
# 
# problem A
# 

r = input()
if r == 'SUN':
    print(7)
if r == 'MON':
    print(6)
if r == 'TUE':
    print(5)
if r == 'WED':
    print(4)
if r == 'THU':
    print(3)
if r == 'FRI':
    print(2)
if r == 'SAT':
    print(1)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

typedef tuple<int, int, int, int> TP;
TP narabi(int a, int b, int c, int d) {
	TP kari[4];
	kari[0] = tie(a, b, c, d);
	kari[1] = tie(b, c, d, a);
	kari[2] = tie(c, d, a, b);
	kari[3] = tie(d, a, b, c);
	sort(kari, kari + 4);
	return kari[0];
}

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


	int N;
	cin >> N;
	TP C[400];
	map<TP, int> MP;
	rep(i, N) {
		int a, b, c, d;
		cin >> a >> b >> c >> d;
		C[i] = narabi(a, b, c, d);
		MP[C[i]]++;
	}

	ll kotae = 0;
	rep(i, N) rep(j, N) if (i != j) {
		MP[C[i]]--;
		MP[C[j]]--;

		int a, b, c, d, e, f, g, h;
		a = get<0>(C[i]);
		b = get<1>(C[i]);
		c = get<2>(C[i]);
		d = get<3>(C[i]);
		e = get<0>(C[j]);
		f = get<1>(C[j]);
		g = get<2>(C[j]);
		h = get<3>(C[j]);

		rep(x, 4) {
			TP D[4];
			D[0] = narabi(a, d, f, e);
			D[1] = narabi(a, e, h, b);
			D[2] = narabi(b, h, g, c);
			D[3] = narabi(c, g, f, d);
			ll kari = 1;
			rep(k, 4) {
				kari *= MP[D[k]]--;
				if (get<0>(D[k]) == get<2>(D[k]) && get<1>(D[k]) == get<3>(D[k])) {
					kari *= 2;
					if (get<1>(D[k]) == get<2>(D[k])) kari *= 2;
				}
				if (kari < 0) kari = 0;
			}
			rep(k, 4) MP[D[k]]++;
			kotae += kari;

			int tmp = e;
			e = f;
			f = g;
			g = h;
			h = tmp;
		}

		MP[C[i]]++;
		MP[C[j]]++;
	}
	co(kotae / 6);

	Would you please return 0;
}

Measured memory_bytes: 80128
package main

import (
  "fmt"
)

func main() {
  var x, k, d int
  fmt.Scan(&x, &k, &d)

  if x < 0 {
    x *= -1
  }
  
  ans := 0
  if k <= x / d {
    ans = x - (k * d)
  } else {
    n := int(x / d)
    even := x % d
    
    if (k - n) % 2 == 0 {
      ans = even
    } else {
      ans = d - even
    }
  }
  fmt.Println(ans)
}

Measured memory_bytes: 1768
N = int(input())
S = []
for i in range(N):
    S.append(input())
A = []
from collections import Counter
d = Counter(S)
md = d.most_common(1)[0][1]
for key, value in d.items():
    if value == md:
        A.append(key)
As = sorted(A)
for a in As:
    print(a)

Measured memory_bytes: 35476
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/range/adaptor/reversed.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
typedef long long int ll;

#define PI (acos(-1))
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define dumparr(x) cerr << #x ; for(auto elem: x){cerr << " " << elem;} cerr << endl;
#define dumppairs(x) cerr << #x ; for(auto elem: x){cerr << "(" << elem.first << " " << elem.second << ") ";} cerr << endl;
#define dumpline cerr << "**********************" << endl;
#define dumpwline(x) cerr << "******** " << #x << "=" << (x) << " ********" << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

int main(void){
    ll h; cin >> h;
    ll w; cin >> w;
    ll k; cin >> k;
    vector <vector <ll>> cake;
    vector <ll> strawberry_h;
    REP(i, h){
        string s; cin >> s;
        REP(j, w){
            if (s[j] == '#'){
                strawberry_h.push_back(i);
                break;
            }
        }
        vector <ll> row;
        REP(j, w){
            if (s[j] == '#'){
                row.push_back(j);
            }
        }
        row.push_back(w);
        cake.push_back(row);
    }
    strawberry_h.push_back(h);
    vector <vector <ll>> ans(h, vector<ll>(w, -1));
    ll num = 1;
    REP(i, strawberry_h.size()-1){
        ll height = strawberry_h[i];
        ll begin_h = height;
        if (i==0){
            begin_h = 0;
        }
        ll end_h = strawberry_h[i+1];

        vector <ll> row = cake[height];
        REP(j, row.size()-1){
            ll begin_w = row[j];
            if (j==0){
                begin_w = 0;
            }
            ll end_w = row[j+1];
            for(int hh=begin_h; hh<end_h; hh++) {
                for (int ww = begin_w; ww < end_w; ww++) {
                    ans[hh][ww] = num;
                }
            }
            num += 1;
        }
    }
    REP(i, h){
        REP(j, w-1){
            cout << ans[i][j] << " ";
        }
        cout << ans[i][w-1] << endl;
    }
    return 0;
}

Measured memory_bytes: 2176
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


n = int(input())
a = [int(input()) for _ in range(n)]
M = 998244353
s = sum(a)
l = s//2 + int(s%2==1)
# dp = [[0]*(s+1) for _ in range(n+1)]
dp = [0]*(s+1)
dp2 = [0]*(s+1)
dp[0] = pow(2, n, M)
dp2[0] = 1
inv2 = pow(2, M-2, M)
for i in range(1,n+1):
    num = a[i-1]
    for j in range(s, -1, -1):
        if j>=num:
            dp[j] += dp[j-num]*inv2
            dp[j] %= M
            dp2[j] += dp2[j-num]
            dp2[j] %= M
val = sum(dp[i] for i in range(l, s+1)) * 3
if s%2==0:
    val -= dp2[s//2]*3
ans = (pow(3,n,M) - val)%M
print(ans%M)

Measured memory_bytes: 72228
object Main extends App {

  while(true) {
    val cards = io.StdIn.readLine()
    if(cards == "-") System.exit(0)

    var sb = StringBuilder.newBuilder
    val buf = StringBuilder.newBuilder

    sb.append(cards)
    val cnt = io.StdIn.readInt()
    for(_ <- 1 to cnt) {
      val h = io.StdIn.readInt()
      buf.append(sb.substring(h)).append(sb.substring(0,h))
      sb.clear()
      sb.append(buf)
      buf.clear()
    }

    println(sb)
  }
}



Measured memory_bytes: 43880
import std.stdio, std.conv, std.string;

void main(){
	while(1){
		string[] input = split(readln());
		int h = to!int(input[0]);
		int w = to!int(input[1]);

		if(h == 0 && w == 0) break;
		double diag = h*h + w*w;
		double ah = 151;
		double aw = 151;

		auto setAns = delegate void(int ht, int wt) {
			auto digt = ht*ht + wt*wt;
			auto diga = ah*ah + aw*aw;
			if(digt < diga){
				ah = ht;
				aw = wt;
			}else if(digt == diga && ht < ah){
				ah = ht;
				aw = wt;
			}
		};

		foreach(i ; 1 .. 151){
			foreach(j ; i+1 .. 151){
				auto dig2 = i*i + j*j;
				if(diag < dig2){
					setAns(i, j);
				}else if(diag == dig2 && h < i){
					setAns(i, j);
				}
			}
		}

		writeln(ah, ' ', aw);
	}
}

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

//typedefリスト
typedef vector<int> vint;
typedef vector<string> vstr;

int main(void) {
	int X,num,ans;
	ans = 1001;
	cin >> X;
	if (X < 4)cout << 1 << endl;
	else {
		for (int i = 2; i < 32; i++) {
			num = i;
			while (X >= num) {
				num *= i;
			}
			if (num != i * i) {
				num /= i;
				ans = min(X - num, ans);
			}
		}
		cout << X-ans << endl;
	}
}


Measured memory_bytes: 256
#include <iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<math.h>
#include<tuple>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
int main() {
	int n, k;
	cin >> n >> k;
	vector<int>a(n);
	rep(i, n)cin >> a[i];
	cout << (n-1+k-2)/(k-1) << endl;
	return 0;
}


Measured memory_bytes: 640
import java.util.Scanner;
import java.util.ArrayList;

class Main {

	public static void main(String[] args) {
	
		Scanner sc = new Scanner(System.in);
		
		ArrayList<Integer> x = new ArrayList<Integer>();
		ArrayList<Integer> y = new ArrayList<Integer>();
		
		int a,b;
		
		while(true){
			a = sc.nextInt();
			b = sc.nextInt();
			
			if(a == 0 && b == 0)
				break;
			
			x.add(a);
			y.add(b);
			
		}
		
		int temp;
		int i;
		
		for(i = 0; i < x.size(); i++){
			int val1 = x.get(i);
			int val2 = y.get(i);
			
			if(val1 > val2){
				temp = val2;
				val2 = val1;
				val1 = temp;
			}
			
			System.out.println(val1 + " " + val2);
		}
		
	}

}

Measured memory_bytes: 36092
/*@sh*/
#include<bits/stdc++.h>
using namespace std;
#include<cstdio>
#define pi 3.141592653589
#define pb push_back
#define ld long double
#define rem 1000000007
#define F first
#define S second
#define pii pair<long long,long long>
#define el "\n"
#define sp " "
typedef long long ll;
ll  p = 1000000007;
ll Pow(ll,ll,ll);
ll Pow(ll a,ll b,ll p){
	if(b==0) return 1;
	return !(b%2) ? (Pow(a,b/2,p)%p)*(Pow(a,b/2,p)%p)%p : (a%p)*(Pow(a,b-1,p))%p;
}   
main()
{ 
	// fast io
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);ll i; 
	ll n;
	cin>>n;
	vector <ll> a(n),dp(n,rem);
	for(i=0;i<n;i++)
	cin>>a[i];
	dp[0]=0;
	dp[1]=abs(a[1]-a[0]);
	for(i=2;i<n;i++)
	{
		dp[i]=min(dp[i-1]+abs(a[i]-a[i-1]),dp[i-2]+abs(a[i]-a[i-2]));
		//cout<<dp[i]<<sp;
	}
	cout<<dp[n-1];
}


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

int main()
{
    int a[100];
    int d=3;
    for(int i=1;i<=3;i++)
        cin>>a[i];
    sort(a+1,a+d+1);
    cout<<(((a[3]*10)+a[2])+a[1])<<endl;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    long N,x;
    cin>>N>>x;
    long a[N];
    for(int i=0;i<N;i++){
        cin>>a[i];
    }
    long count=0;
    for(int i=0;i<N-1;i++){
       long sum=a[i]+a[i+1];
       long d=sum-x;
       if(a[i+1]>=d&&d>=0) {a[i+1]=a[i+1]-d; count+=d;}
       else if(a[i+1]<d&&d>=0) {a[i+1]=0; count+=d;}
    }
    
    cout<<count;
    return 0;
}


Measured memory_bytes: 1024
while True:
    m,f,r=map(int,input().split())
    if(m,f,r)==(-1,-1,-1):
        break
    x=m+f
    if m<0 or f<0:
        print("F")
    elif x<30:
        print("F")
    elif x>=80:
        print("A")
    elif x>=65:
        print("B")
    elif x>=50:
        print("C")
    elif r>=50:
        print("C")
    else:
        print("D")


Measured memory_bytes: 5600
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <limits>

using namespace std;

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

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18


int main() {

	LL n; cin >> n;
	vector<LL> a(5);

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

	LL mi = *min_element(a.begin(), a.end());


	LL cnt = (LL)ceil((double)n / mi);
	LL ans = 4 + cnt;

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#pragma once
#include <stdio.h>
#include <sstream>
#include <string.h>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <deque>
#include <limits>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define bit(x,v) ((ll)x << v)

const ll INF = 1000000007;
const ll MAX = 210000;
const ll 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 gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
int pr[100010];
void uini(int n) {
	for (size_t i = 0; i <= n; i++)
	{
		pr[i] = i;
	}
}

int parent(int x) {
	if (x == pr[x]) return x;
	return pr[x] = parent(pr[x]);
}

bool unit(int x, int y) {
	int px = parent(x);
	int py = parent(y);

	if (px == py) return false;
	if (px < py) {
		pr[py] = px;
	}
	else {
		pr[px] = py;
	}
	return true;
}

// res[i][c] := i 文字目以降で最初に文字 c が登場する index (存在しないときは n)
vector<vector<int> > calcNext(const string & S) {
	int n = (int)S.size();
	vector<vector<int> > res(n + 1, vector<int>(26, n));
	for (int i = n - 1; i >= 0; --i) {
		for (int j = 0; j < 26; ++j) res[i][j] = res[i + 1][j];
		res[i][S[i] - 'a'] = i;
	}
	return res;
}
// mod 1000000007 の世界で a += b する関数
void add(long long& a, long long b) {
	a += b;
	if (a >= MOD) a -= MOD;
}
const ll ainf = 998244353;

void solv() {
	int n;
	cin >> n;

	ll a[100010];
	int neg = 0;
	ll res = 0;

	for (size_t i = 0; i < n; i++)
	{
		cin >> a[i];
		if (a[i] < 0) neg++;
		res += abs(a[i]);
	}
	if (neg % 2 == 0) {
		cout << res << endl;
	}
	else {
		ll mi = INF;
		for (size_t i = 0; i < n; i++)
		{
			mi = min(abs(a[i]),mi);
		}
		cout << res - (mi * 2) << endl;
	}
}

int main() {
	//COMinit();
	solv();

	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S; cin >> S;
    int n = S.length();
    int ans0 = 0, ans1 = 0;
    rep(i, n) {
        if(i % 2 == 0 && S[i] == '0') ans0++;
        else if(i % 2 == 1 && S[i] == '1') ans0++;
        else if(i % 2 == 0 && S[i] == '1') ans1++;
        else if(i % 2 == 1 && S[i] == '0') ans1++;
    }
    cout << min(ans0, ans1) << endl;

    return 0;
}


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

#define fo(i, n) for(i=0; i<n; i++)
#define ll long long

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

	int t, i, k;
	priority_queue <ll> q;
	ll temp;
	cin >> t >> k;
	fo(i, t) {
		cin >> temp;
		q.push(temp);
	}
	fo(i, k) {
		temp = q.top();
		q.pop();
		q.push(temp / 2);
	}
	temp = 0;
	while (!q.empty()) {
		temp += q.top();
		q.pop();
	}
	cout << temp;
	return 0;
}

Measured memory_bytes: 4272
# -*- coding: utf-8 -*-
import heapq
import math
import sys
import bisect

N = int(input())
ABC = []
for i in range(3):
    tmp = input()
    t = [int(a) for a in tmp.split()]
    ABC.append(sorted(t))
ABC = ABC[::-1]
cumulative = [[i for i in range(N+1)][::-1]
               if j == 0 else [0 for i in range(N+1)]
              for j in range(3)]
for i in range(1, 3):
    for j, a in enumerate(ABC[i]):
        k = bisect.bisect_right(ABC[i-1], a)
        cumulative[i][j] = cumulative[i-1][k]
    for j, _ in enumerate(ABC[i]):
        cumulative[i][N-j-1] = cumulative[i][N-j-1] + cumulative[i][N-j]

print(cumulative[2][0])


Measured memory_bytes: 30628
//{{{
#include<algorithm>
#include<cmath>
#include<fstream>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<random>
#include<set>
#include<sstream>
#include<sys/time.h>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(prints) FUNC(printw) FUNC(printwe) FUNC(printb) FUNC(printbe) FUNC(printd) FUNC(printde) FUNC(printdu);
#endif
template <class S, class T>
istream& operator >> (istream& in, pair<S, T>& p){ return in >> p.first >> p.second; }
template <class T>
istream& operator >> (istream& in, vector<T>& v){ for(auto& e : v){ in >> e; } return in; }
//}}}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int x, a;
    cin >> x >> a;
    cout << (x < a ? 0 : 10) << '\n';
}


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

const vector<long long> B={1000000000000000003LL,1000000000000000003LL};
const long long P=1000000000000000031LL;

long long pow_binary_mod(long long x,long long y,long long mod){
	long long z=1;
	for(;y;y>>=1){
		if((y&1)!=0)z=(__int128_t)z*x%mod;
		x=(__int128_t)x*x%mod;
	}
	return z;
}

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

	int T;
	string s;
	cin>>T>>T>>s;
	vector<long long> Brev(2);
	for(int i=0;i<2;i++){
		Brev[i]=pow_binary_mod(B[i],P-2,P);
	}
	set<vector<long long> > se;

	int l=0,r=0;
	vector<long long> c={s[0],s[0]};
	for(;T--;){
		string q;
		cin>>q;
		if(q=="L--"){
			l--;
			for(int i=0;i<2;i++)c[i]=(s[l]*(__int128_t)pow_binary_mod(B[i],r-l,P)+c[i])%P;
		}else if(q=="L++"){
			for(int i=0;i<2;i++)c[i]=((c[i]-s[l]*(__int128_t)pow_binary_mod(B[i],r-l,P))%P+P)%P;
			l++;
		}else if(q=="R--"){
			for(int i=0;i<2;i++)c[i]=((c[i]-s[r])%P+P)%P*(__int128_t)Brev[i]%P;
			r--;
		}else if(q=="R++"){
			r++;
			for(int i=0;i<2;i++)c[i]=(c[i]*(__int128_t)B[i]+s[r])%P;
		}
		se.insert(c);
	}
	printf("%d\n",se.size());
}



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

int main(void){
	int n;
	while(cin>>n && n){
		int maxP=-1,maxD=0;
		for(int i=0;i<n;i++){
			int p,d1,d2;
			cin>>p>>d1>>d2;
			if(maxD < d1 + d2){
				maxP = p;
				maxD = d1 + d2;
			}
		}

		cout<<maxP<<" "<<maxD<<endl;
	}

	return 0;
}

Measured memory_bytes: 868
import math
import fractions
l, r, p1, p2 = list(map(int, input().split()))
lcm = p1*p2 // fractions.gcd(p1, p2)
ans = (r-l+1) - (r//p1-(l-1)//p1) - (r//p2-(l-1)//p2) + (r//lcm)-(l-1)//lcm
print(ans)


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

using namespace std;

typedef long long ll;
typedef pair<ll,ll> pi;

ll N, M, P, Q, R, A, B, C, X, Y, Z, arr[100005];

string s;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cin >> A >> P;
	cout << (3*A+P)/2 << '\n';
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define PI pair<int,int>
#define ff first
#define ss second
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL)
#define INF LONG_MAX
#define io freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);

int32_t main()
{
   // io;
    boost;
  int n;
  cin>>n;
    string a,b,ans="";
    cin>>a>>b;
    for(int i=0;i<a.size();i++)
    {
        ans+=a[i];
        ans+=b[i];
    }
    cout<<ans<<endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cstdint>
#include <cassert>

using namespace std;
using i64 = int64_t;
using i32 = int32_t;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (size_t i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (size_t i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

i64 n, x;
array<i64, 51> ps, pbs;

i64 f(i64 lv, i64 x) {
  if (lv == 0) return 1;
  if (x <= 1) return 0;
  if (x < pbs[lv] / 2 + 1) return f(lv - 1, x - 1);
  if (x == pbs[lv] / 2 + 1) return ps[lv - 1] + 1;
  if (x < pbs[lv]) return ps[lv - 1] + 1 + f(lv - 1, x - pbs[lv - 1] - 2);
  /* if (x == pbs[lv]) */ return ps[lv];
}

int main() {
  cin >> n >> x;
  ps[0] = pbs[0] = 1;
  for (i64 lv = 1; lv <= n; ++lv) {
    ps[lv] = 2 * ps[lv - 1] + 1;
    pbs[lv] = 2 * pbs[lv - 1] + 3;
  }
  cout << f(n, x) << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;
import static java.lang.System.*;
import static java.lang.Math.*;
public class Main {
public static void main(String[] args){
Scanner sc = new Scanner(in);
int[] l=new int[3];
    for (int i = 0; i < 3; i++) {
        l[i]=Integer.parseInt(sc.next());
    }
Arrays.sort(l);
int ans=l[0]+l[1];

out.println(ans);
}
}

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

int main() {
    int n, x, sum = 0, count = 0;
    cin >> n >> x;
    vector<int> vec(n);

    for(int i = 0; i < n; i++) {
        cin >> vec.at(i);
        sum += vec.at(i);
    }
    
    sort(vec.begin(), vec.end());

    count = n + (x-sum)/vec.at(0);
    cout << count << endl;
}

Measured memory_bytes: 256