akhauriyash/Code-Regression huggingface dataset:
n = int(input())
lis = [int(x) for x in input().split()]
arai = sum(lis) - lis[0]
sunu = lis[0]
mn = abs(arai - sunu)

for i in lis[1:-1]:
    arai -= i
    sunu += i
    mn = min(mn,abs(arai - sunu))
print(mn)

Measured memory_bytes: 24812
#include <iostream>
#include <map>
using namespace std;
 
int main(){
  int n;
  map<string,int> cnt;
  cin>>n;
  for(int i=0; i<n; i++){
    string str;
    cin>>str;
    cnt[str]++;
  }
  printf("AC x %d\n",cnt["AC"]);
  printf("WA x %d\n",cnt["WA"]);
  printf("TLE x %d\n",cnt["TLE"]);
  printf("RE x %d\n",cnt["RE"]);
}


Measured memory_bytes: 3712
k = int(input())
m = 7 % k 
s = set()
cnt = 1
while(1):
    if m == 0:
        print(cnt)
        break
    elif m in s:
        print(-1)
        break
    else:
        s.add(m)
    m = ((m * (10 % k)) % k + 7 % k) % k
    cnt += 1


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

typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=2003;

int main(){
    
    int N;cin>>N;
    vector<int> S(N);
    for(int i=0;i<N;i++){
        cin>>S[i];
    }
    
    sort(all(S));
    
    if(S[N-1]-S[0]>=2) cout<<"No"<<endl;
    else if(S[N-1]==S[0]){
        if(S[0]==N-1) cout<<"Yes"<<endl;
        else{
            if(S[0]*2<=N) cout<<"Yes"<<endl;
            else cout<<"No"<<endl;
        }
    }else{
        int cnt=0;
        for(int i=0;i<N;i++){
            if(S[i]==S[0]) cnt++;
        }
        int rem=N-cnt;
        if(rem/2+cnt-1>=S[0]&&1+cnt-1<=S[0]) cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }
}



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

bool cmp(pair<int, int> a, pair<int, int> b) {
  return a.second == b.second ? a.first < b.first : a.second < b.second;
}

int main() {
  int N, M; cin >> N >> M;
  vector<pair<int, int>> order(M);
  for (int i = 0; i < M; i++) {
    cin >> order[i].first >> order[i].second;
  }

  sort(order.begin(), order.end(), cmp);

  int cnt = 0, end = 0;
  for (int i = 0; i < M; i++) {
    if (order[i].first >= end) {
      cnt++;
      end = order[i].second;
    }
  }
  cout << cnt << endl;
}

Measured memory_bytes: 1024
A,B,C=map(int,raw_input().strip().split())
if A==B and A==C:
    if A%2==0:
        print -1
    else:
        print 0
else:
    ans = 0
    while A%2==B%2==C%2==0 and ans<10000:
        tmp1,tmp2 = A,B
        A = B/2 + C/2
        B = tmp1/2+C/2
        C = tmp1/2+tmp2/2
        ans += 1
    print -1 if ans == 10000 else ans
    
    

Measured memory_bytes: 28012
h,w=map(int,input().split())

li=[]
for i in range(h):
    li.append(list(input()))

new_li=[[0]*w for i in range(h)]

#＃の位置をリストに集める
sharp_li=[]
for i in range(h):
    for j in range(w):
        if li[i][j]=='#':
            sharp_li.append([i,j])   

for k in range(len(sharp_li)):
    #y行X列を扱う
    y=sharp_li[k][0]
    x=sharp_li[k][1]
    
    #tryの例外処理だとうまくいかなかったので、端の場合を自力で書いて場合わけする
    if x==0:
        if w!=1:             #1行や1列の場合がエラーの原因なので、無理やりif文で処理
            xli=[0,1]
        else:
            xli=[0]
    elif x==w-1:
        xli=[w-2,w-1]
    else:
        xli=[x-1,x,x+1]
    
    if y==0:
        if h!=1:
            yli=[0,1]
        else:
            yli=[0]
    elif y==h-1:
        yli=[h-2,h-1]
    else:
        yli=[y-1,y,y+1]
        
        
    for l in xli:
        for m in yli:
            new_li[m][l]+=1           #m行l列なので
           
        
ans=[]             
for n in range(h):
    stred=list(map(str,new_li[n]))
    ans.append(stred)
#もともとの爆弾の部分を＃に戻す

for o in range(len(sharp_li)):
    ans[sharp_li[o][0]][sharp_li[o][1]]='#'


for p in range(h):
    tans=''.join(ans[p])
    print(tans)

Measured memory_bytes: 3444
#include <bits/stdc++.h>
#define LL long long
#define PII pair<int, int>
#define PLL pair<LL, LL>
#define all_of(v) (v).begin(), (v).end()
#define sort_unique(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define fi first
#define se second
//const int MAXN = 200005;
//const LL INF = (LL) 1e9 + 8763;
//const LL MOD = (LL) 1e9 + 7;
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

pair<LL, LL> ext_gcd( LL a, LL b) {
	if (b == 0) return make_pair(1, 0);
    if (a % b == 0) return make_pair(0, 1);
    pair<LL, LL> t = ext_gcd(b, a % b);
    return make_pair( t.second, t.first - a / b * t.second);
}

void solve() {
	LL n;
	cin >> n;
	
	LL tmp = 2 * n;
	vector<LL> fac;
	for (LL i = 2; i * i <= tmp; i++) {
		if (tmp % i == 0) {
			LL tot = 1;
			while (tmp % i == 0) {
				tmp /= i;
				tot *= i;
			}
			fac.push_back(tot);
		}
	}
	if (tmp != 1) {
		fac.push_back(tmp);
	}
//	cout << "Tot " << fac.size() << '\n';
	
	LL ans = 2 * n;
	for (int i = 0; i < (1 << fac.size()); i++) {
		LL l = 1, r = 1;
		for (int j = 0; j < fac.size(); j++) {
			if (i >> j & 1) l *= fac[j];
			else r *= fac[j];
		}
		PLL res = ext_gcd(l, r);
		LL k = l * -res.fi;
		
		if (k <= 0) {
			k += l * r;
		}
//		cout << "At " << l << ' ' << r << " get " << res.fi <<  ' ' << res.se << ' ' << k << endl;
//		assert(k * (k + 1) / 2 % n == 0);
		ans = min(ans, k);
	}
	
	cout << ans << '\n';
}

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

	int tc = 1;
//	cin >> tc;
	for (int i = 1; i <= tc; i++) {
		solve();
	}

	return 0;
} 

Measured memory_bytes: 3660
seq = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

k = int(input())
print(seq[k - 1])

Measured memory_bytes: 3060
use std::io::*;
use std::str::*;

fn read <T: FromStr>(s: &mut StdinLock) -> Option<T> {
    let s = s.by_ref().bytes().map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    s.parse::<T>().ok()
}

pub fn main() {
    let stdin = stdin();
    let mut stdin = stdin.lock();

    let n: u32 = read(&mut stdin).unwrap();
    let nums: Vec<u32> = (0..n).map(|_x| read(&mut stdin).unwrap()).collect();

    let mut res: [u32; 100] = [0; 100];
    for num in nums {
        let num = (num - 1) as usize;
        res[num] += 1;
    }
    let result = res.iter().filter(|x| x > &&0).fold(0, |acc, _x| acc + 1);
    println!("{:?}", result);
}


Measured memory_bytes: 4352
#include<iostream>
#include <string>
#include<bits/stdc++.h>
#define ll long long int
#define ld long double
#define pb push_back
#define endl "\n"
#define mp make_pair
#define M 1000000007
#define all(v) v.begin(),v.end()
#define fr(a,b,c) for(ll i=a;i<=b;i+=c)
#define inarr(arr,n); for(ll i=0;i<n;i++) cin >> arr[i];
#define outarr(arr,n); for(ll i=0;i<n;i++) cout<<arr[i]<<" ";
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
const ll inf = 9e18;
const ld pi = 2*acos(0.0);
using namespace std;
ll gcd(ll a, ll b) 
{ 
    if (a == 0) 
        return b; 
    return gcd(b % a, a); 
} 
int main(){
    ios_base::sync_with_stdio(false);
    ll t;
    t=1;
    while(t--){
        ll a;
        string s;
        cin>>a>>s;
        if(a>=3200){
            cout<<s<<endl;
        }
        else{
            cout<<"red"<<endl;
        }
    }
    return 0;

}

Measured memory_bytes: 384
#include <numeric>
#include <string>
#include <algorithm>
#include <vector>
#include <iostream>
#include <cstdlib>
 
#define repd(i,a,b); for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define ll long long int
 
 
using namespace std;
int main() {
  int n; cin >> n;
  if(n == 1 || n == 2 || n == 3 || n == 5 || n == 6 || n == 9 || n == 10 || n == 13 || n == 17 || n ==  23){
    cout << "No";
  } else {
    cout << "Yes";
  }
 return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main()
{
    string s , t;
    int i;
    cin >> s >> t;
    int l1 = s.size();
    int ans = 0;

    for(i=0;i<l1;i++)
    {
        if(s[i]!=t[i])
        ans++;
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 3904
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<string>
#include<cstring>
#include<algorithm>
#include<functional>
#include<vector>
#include<map>

using namespace std;
#define endl '\n'
#define pb push_back
#define fst first
#define scd second
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MOD (1e9 + 7)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define REP(i,n) for(int i = 0;i < (n);i++)
#define FOR(i,a,b) for(int i = (a);i <= (b);i++)
#define YES(n) cout << ((n) ? "YES" : "NO" ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No" ) << endl


typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vector<int>> vii;

template <class T = int> T in() { T x; cin >> x; return (x); }
template <class T = int> void out(T x) { cout << (x) << endl; }

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

void solve() {

	vi a(3);
	REP(i, 3) {
		cin >> a[i];
	}

	sort(ALL(a));

	out(a[2] * 10 + a[1] + a[0]);

	return;

}

int main() {

	cin.tie(0);
	ios::sync_with_stdio(false);

	solve();

	return 0;

}

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


int main() {
int x,y;
cin >> x >> y;
cout << x+ y/2 << endl;
return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
using tpl = tuple<char, int>;
typedef pair<int,int> pii;
typedef long long ll;

void fastStream(){cin.tie(0);std::ios_base::sync_with_stdio(0);}

int a, b;

int main(){

    cin>> a >> b;
    if((a*b)%2){
        cout << "Odd" << endl;
    }
    else cout << "Even"<<endl;

    return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };

ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

int main() {
	for (;;) {
		string s; cin >> s;
		if (s == "0") break;
		int n = s.length();
		vector<int> mod(n + 1);
		vector< vector<int> > a(n + 1);
		a[0] = vector<int>(11);
		for (int i = 1; i <= n; i++) {
			int x = s[i - 1] - '0';
			if (i % 2) x = 11 - x;
			mod[i] = (mod[i - 1] + x) % 11;
			a[i] = a[i - 1];
			a[i][mod[i]]++;
		}
		int cnt = 0;
		for (int i = 0; i <= n; i++)
			if (s[i] != '0')
				cnt += a[n][mod[i]] - a[i][mod[i]];
		cout << cnt << endl;
	}
}

Measured memory_bytes: 8456
#include <iostream>
#include <algorithm>
#include <vector>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
typedef long long ll;
int main()
{
  int n;cin >> n;
  vector<ll> a(n);rep(i,n) cin >> a[i];
  ll sum = 0,sum2 = 0;
  rep(i,n){
    sum += a[i];
    if(i%2==1) sum2 += a[i];
  }

  ll x = sum/2-sum2;
  vector<ll> res(n);res[0] = 2*x;
  rep(i,n){
    x = a[i]-x;
    if(i==n-1) break;
    res[i+1] = 2*x;
  }
  rep(i,n) cout << res[i] << " ";
  cout  << "\n";
  
  return 0;
}


Measured memory_bytes: 2816
//g++ -std=c++14 test.cpp -o test.out
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <map> 
#include <utility>
#include <limits.h>
#include <bitset>
#include <set>
using namespace std;
 
#define LL long long int
const LL INF = (LL)(1e18)+1;
const int INF_INT = 2147483647;
const LL mod = 1000000007ll;

int A[3][3];
int N;
int b[10];
 
string ans = "No";

bool isbingo(){
	return 
		(
			(A[0][0]==-1 && A[0][1]==-1 && A[0][2]==-1) ||
			(A[1][0]==-1 && A[1][1]==-1 && A[1][2]==-1) ||
			(A[2][0]==-1 && A[2][1]==-1 && A[2][2]==-1) ||

			(A[0][0]==-1 && A[1][0]==-1 && A[2][0]==-1) ||
			(A[0][1]==-1 && A[1][1]==-1 && A[2][1]==-1) ||
			(A[0][2]==-1 && A[1][2]==-1 && A[2][2]==-1) ||

			(A[0][0]==-1 && A[1][1]==-1 && A[2][2]==-1) ||
			(A[2][0]==-1 && A[1][1]==-1 && A[0][2]==-1)
		);
}
 
void solve(){
	for(int i=0;i<N;i++){
		for(int j=0;j<3;j++){
			for(int k=0;k<3;k++){
				if(A[j][k]==b[i]){
					A[j][k] = -1;
					break;
				}
			}
		}
		if(isbingo()) ans = "Yes";
	}
}
 
int main(){
	for(int i=0;i<3;i++){
		for(int j=0;j<3;j++) cin >> A[i][j];
	}
	cin >> N;
	for(int i=0;i<N;i++) cin >> b[i];
 
	solve();
 
	cout << ans << endl;
	return 0;
}

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

struct Node{
	Node(){
		parent = -1;
		left = -1;
		right = -1;
	}
	int parent;
	int left;
	int right;
};

void set_node(Node Tree[], int id, int l, int r)
{
	int deg = 0;
	if (l != -1)  //左小孩 
	{
		Tree[l].parent = id;
	}
	if (r != -1) //右小孩 
	{
		Tree[r].parent = id;
	}
	
	//自己 
	Tree[id].left = l;
	Tree[id].right = r;
}

//輸出 
void Print_Preorder(Node Tree[], int root)
{
	//root -> left subtree -> right subtree
	cout << " " << root;
	
	if (Tree[root].left != -1)
	{
		Print_Preorder(Tree, Tree[root].left);
	}
	
	if (Tree[root].right != -1)
	{
		Print_Preorder(Tree, Tree[root].right);
	}
}

void Print_Inorder(Node Tree[], int root)
{
	//left subtree -> root -> right subtree
	if (Tree[root].left != -1)
	{
		Print_Inorder(Tree, Tree[root].left);
	}
	
	cout << " " << root;
	
	if (Tree[root].right != -1)
	{
		Print_Inorder(Tree, Tree[root].right);
	}
}

void Print_Postorder(Node Tree[], int root)
{
	//left subtree -> right subtree -> root
	if (Tree[root].left != -1)
	{
		Print_Postorder(Tree, Tree[root].left);
	}
	
	if (Tree[root].right != -1)
	{
		Print_Postorder(Tree, Tree[root].right);
	}
	
	cout << " " << root;
}

int find_root(Node Tree[], int n)
{
	for (int i = 0;i < n;i++)
	{
		if (Tree[i].parent == -1)
		{
			return i;
		}
	}
}

int main ()
{
	int n;
	cin >> n;
	Node *B_Tree = new Node [n];
	
	for (int i = 0;i < n;i++)
	{
		int id, left, right;
		cin >> id >> left >> right;
		
		set_node(B_Tree, id, left, right);
	}
	
	int root = find_root(B_Tree, n);
	
	cout << "Preorder" << endl;
	Print_Preorder(B_Tree, root);
	cout << endl;
	
	cout << "Inorder" << endl;
	Print_Inorder(B_Tree, root);
	cout << endl;
	
	cout << "Postorder" << endl;
	Print_Postorder(B_Tree, root);
	cout << endl;
	
	return 0;
 } 


Measured memory_bytes: 3132
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1LL<<60;
#define all(x) (x).begin(),(x).end()
#define REP(i,n) for(int i=0; i<(n);++i)
#define FOR(i,k,n) for(int i=(k);i<(n);++i)

void dfs(int s,ll c,vector<vector<pair<int,ll>>> &G,vector<ll> &d){
    d[s]=c;
    for(auto v:G[s]){
        if(d[v.first]==INF)dfs(v.first,d[s]+v.second,G,d);
    }
}

int main(){
    int N;cin>>N;
    vector<vector<pair<int,ll> > > G(N);
    int a,b;ll c;
    REP(i,N-1){
        cin>>a>>b>>c;a--;b--;
        G[a].push_back(make_pair(b,c));
        G[b].push_back(make_pair(a,c));
    }
    int q,k;cin>>q>>k;k--;
    vector<ll> d(N,INF);
    dfs(k,0,G,d);
    REP(i,q){
        cin>>a>>b;a--;b--;
        cout<<d[a]+d[b]<<endl;
    }
    return 0;
}

Measured memory_bytes: 15872
fun main(args: Array<String>) = run {
    val (h,w) = readLine()!!.split(" ").map { it.toInt() }
    val s = (1..h).map { readLine()!! }

    val ms = Array(h) { IntArray(w) }
    for (i in s.indices) {
        for (j in s[i].indices) {
            if (s[i][j] == '.') continue
            for (dx in -1..1) for (dy in -1..1) {
                val x = j+dx
                val y = i+dy
                if(x in 0..w-1 && y in 0..h-1) ms[y][x]++
            }
        }
    }

    for (i in s.indices) {
        for (j in s[i].indices) {
            print(if (s[i][j]=='#') "#" else ms[i][j])
        }
        println()
    }

}


Measured memory_bytes: 37612
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
using namespace std;
typedef long long ll;
ll MOD = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)
int main() {
    string s1, s2, s3;
    cin >> s1 >> s2 >> s3;
    cout << (char)(s1[0] - 'a' + 'A') << (char)(s2[0] - 'a' + 'A') << (char)(s3[0] - 'a' + 'A') << endl;
    return 0;
}


Measured memory_bytes: 256
while(<>){
	chomp;
	$dishes{$.} = $_;
	$cost{$.} = 10 - ($_ % 10);
	$cost{$.} = 0 if($cost{$.} == 10);
}

$r = 0;
$cnt = 1;
for (sort {$cost{$a} <=> $cost{$b}} keys %cost){
	$r += $dishes{$_};
	$r += $cost{$_} if($cnt != 5);
	$cnt++;
}

print "$r\n";


Measured memory_bytes: 384
const log = console.log;

const parseSpaceSeparated = (line: string) => line.trim().split(" ");
const parseDecimalInt = (s: string) => parseInt(s);
const parseSpaceSeparatedDecimalInt = (line: string) =>
  parseSpaceSeparated(line).map(parseDecimalInt);

const createDigitArray = (num: number, capacity: number, base = 10) => {
  const array = new Array<number>(Math.max(1, capacity)).fill(0);
  let i = 0;

  while (num > 0) {
    array[i] = num % base;
    num = (num / base) | 0;
    i += 1;
  }

  return array;
};

// ----

function Main(input: string): void {
  const [a, b] = parseSpaceSeparatedDecimalInt(input);

  let count = 0;

  for (let i = a; i <= b; i += 1) {
    const digits = createDigitArray(i, 1, 10);
    const lastIndex = digits.length - 1;
    const halfLen = (digits.length / 2) | 0;
    let isPalindromic = true;

    for (let k = 0; k < halfLen; k += 1) {
      if (digits[k] === digits[lastIndex - k]) continue;

      isPalindromic = false;
      break;
    }

    if (isPalindromic) count += 1;
  }

  log(count);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 10160
#include <iostream>
#include <cmath>
using namespace std;
int main(int argc, const char * argv[]) {
    int a, b, k;
    cin >> a >> b >> k;
    
    int cnt = 0, ans = -1;
    for (int i = min(a, b); i >= 0 && cnt != k; i--) {
        if (a % i == 0 && b % i == 0) {
            cnt++;
            ans = i;
        }
    }
    cout << ans << endl;
}


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

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

int main(){
  int H,tree[100001];
  scanf("%d",&H);
  
  for(int i=1;i<=H;++i) scanf("%d",&tree[i]);

  for(int i=1;i<=H;++i){
    printf("node %d: ",i);
    printf("key = %d, ",tree[i]);
    if(parent(i)!=0)
      printf("parent key = %d, ",tree[parent(i)]);
    if(left(i)<=H)
      printf("left key = %d, ",tree[left(i)]);
    if(right(i)<=H)
      printf("right key = %d, ",tree[right(i)]);

    printf("\n");
  }
    
  return (0);
}



Measured memory_bytes: 3192
unittest
{
	assert( [ "2 2" ].parse.expand.solve == 2 );
	assert( [ "1 10" ].parse.expand.solve == 10 );
	assert( [ "10 8" ].parse.expand.solve == 322828856 );
}



import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto nk = input.front.split.to!( long[] );
	return tuple( nk[ 0 ], nk[ 1 ] );
}

auto solve( long n, long k )
{
	return k * ( k - 1 ) ^^ ( n - 1 );
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	string s,t,ans;cin>>s>>t;
  	vector<string> answers;
  	//tの文字列のほうが長いとき
  	if(s.size()<t.size()){
      cout<<"UNRESTORABLE"<<endl;
      return 0;
    }
  	for(int i=0;i<s.size()-t.size()+1;i++){
    	string temp=s.substr(i,t.size());
    	bool found=true;
      	
      	for(int j=0;j<t.size();j++){
        	if(temp[j]!='?' && temp[j]!=t[j]){
            	found=false;
              	break;
            }
        }  
      
      	if(found==true){
        	ans=s.substr(0,i)+t+s.substr(i+t.size());
          	for(int k=0;k<ans.size();k++){
            	if(ans[k]=='?') ans[k]='a';
            }
          	answers.push_back(ans);
        }
    }
  	if(answers.size()==0){
    	 cout<<"UNRESTORABLE"<<endl;
         return 0;
    }else{
  		sort(answers.begin(),answers.end());
  		cout<<answers[0]<<endl;
    }
}


Measured memory_bytes: 256
#input of int(split by space)
def get_i()
  return gets.chomp.split(" ").map(&:to_i)
end
#input of float(split by space)
def get_f()
  return gets.chomp.split(" ").map(&:to_f)
end
#input of string(split by space)
def get()
  return gets.chomp.split(" ")
end
#input of string(split per one character)
def get_nsp()
  return gets.chomp.split("")
end
#yes or no decision
def yn_judge(bool,y="Yes",n="No")
  return bool ? y : n 
end
#create of array
def array(size1,init=nil,size2=-1)
  if size2==-1
    return Array.new(size1){init}
  else
    return Array.new(size2){Array.new(size1){init}}
  end
end

def max(a,b)
    return a>b ? a : b
end

def min(a,b)
    return a>b ? b : a
end

INF=Float::INFINITY

N=gets.to_i
A=get_i
ans=1
if A.include?(0)
    puts 0
    exit
end
A.each do|a|
    ans*=a
    if ans>10**18
        puts "-1"
        exit
    end
end
puts ans

Measured memory_bytes: 23364
n,k=map(int,input().split())
X=list(map(int,input().split()))
A=[]
for i in range(n-k+1):
  A.append(min(abs(X[i])+abs(X[i]-X[i+k-1]),abs(X[i+k-1])+abs(X[i]-X[i+k-1])))
print(min(A))

Measured memory_bytes: 14384
#define _USE_MATH_DEFINES
#include<iostream>
#include<algorithm>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<deque>
#include<queue>
#include<map>
#include<set>
#define ll long long
#define str string
#define ld long double
#define vec vector
#define vll vec<ll>
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rrep(i,b,a) for(ll i=b;i>=a;i--)
#define ALL(a) a.begin(),a.end()
#define rALL(a) a.rbegin(),a.rend()
#define kai "\n"
#define yuque priority_queue
#define pub push_back
#define pob pop_back
#define puf push_front
#define pof pop_front
#define mie min_element
#define mae max_element
#define tos to_string
#define sep setprecision
#define lob lower_bound
#define upb upper_bound
#define nep next_permutation
#define MOD 1000000007ll
#define MIN (1e-10)
#define equal(a,b) (abs((a)-(b))<MIN)
#define v2 ten
#define chokusen senbun
#define kakkei vec<ten>
using namespace std;
void solve();
int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed;
	solve();
}
struct pea{
	ll f,s;
	bool operator<(const pea &p)const{
		return f!=p.f?f<p.f:s<p.s;
	};
};
struct tri{
	ll f,s,t;
	bool operator<(const tri &p)const{return f<p.f;};
};
class ten{
public:
	ld x,y;
	ten operator+(ten p){return{x+p.x,y+p.y};}
	ten operator-(ten p){return{x-p.x,y-p.y};}
	ten operator*(ld k){return{k*x,k*y};}
	ten operator/(ld k){return{x/k,y/k};}
	ld abs(){return sqrt(abs2());}
	ld abs2(){return x*x+y*y;};
	bool operator<(const ten &p)const{return x!=p.x?x<p.x:y<p.y;};
	bool operator==(const ten &p)const{return (-MIN<x-p.x)&&(x-p.x<MIN)&&(-MIN<y-p.y)&&(y-p.y<MIN);};
	ld naiseki(v2 b){return x*b.x+y*b.y;}
	ld gaiseki(v2 b){return x*b.y-y*b.x;}
};
struct senbun{ten p1,p2;};
struct en{ten o;ld r;};
ten shaei(ten p,chokusen l){
	v2 a=l.p2-l.p1;
	return l.p1+a*a.naiseki(p-l.p1)/a.abs2();
}
ten hansha(ten p,chokusen l){return shaei(p,l)*2-p;}
ld tenchoku(ten p,chokusen l){
	v2 a=l.p2-l.p1;
	return abs(a.gaiseki(p-l.p1))/a.abs();
}
ld tensen(ten p,senbun s){
	if((p-s.p1).naiseki(s.p2-s.p1)<0)return (p-s.p1).abs();
	if((p-s.p2).naiseki(s.p1-s.p2)<0)return (p-s.p2).abs();
	return tenchoku(p,s);
}
ll ccw(ten p0,ten p1,ten p2){
	v2 a=p1-p0,b=p2-p0;
	if(a.gaiseki(b)>MIN)return -1;
	if(a.gaiseki(b)<-MIN)return 1;
	if(a.naiseki(b)<-MIN)return -2;
	if(a.abs2()<b.abs2())return 2;
	return 0;
}
bool majiwaru(senbun s,senbun t){
	
}
ld sensen(senbun s,senbun t){
	if(majiwaru(s,t))return 0;
	return min({tensen(s.p1,t),tensen(s.p2,t),tensen(t.p1,s),tensen(t.p2,s)});
}
void solve(){
	ten p0,p1,p2;
	cin>>p0.x>>p0.y>>p1.x>>p1.y;
	ll n;cin>>n;
	rep(i,0,n){
		cin>>p2.x>>p2.y;
		ll b=ccw(p0,p1,p2);
		if(b==-1)cout<<"COUNTER_CLOCKWISE"<<kai;
		else if(b==1)cout<<"CLOCKWISE"<<kai;
		else if(b==-2)cout<<"ONLINE_BACK"<<kai;
		else if(b==2)cout<<"ONLINE_FRONT"<<kai;
		else cout<<"ON_SEGMENT"<<kai;
	}
}


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

int mod = 1'000'000'007;

long long modpow(int x, int y){
    if (y == 0) return 1;
    if (y % 2 == 0) return modpow(x, y/2) * modpow(x, y/2) % mod;
    return x * modpow(x, y-1) % mod;
}

void getcomb(vector<long long> &cmb){
    int k = (int)cmb.size() - 1;
    cmb[0] = 1;
    for (int i = 0; i < k; i++){
        cmb[i+1] = ((cmb[i] * (k - i)) % mod) * modpow(i + 1, mod - 2) % mod;
    }
}

void getcc(vector<long long> &cc){
    cc[0] = 1;
    for (int i = 1; i < 4000; i++){
        cc[i] = cc[i-1] * i % mod;
    }
}

int main(){
    int n, k;
    cin >> n >> k;
    vector<long long> cmb(n-k+2, 0);
    getcomb(cmb);
    vector<long long> cc(4000);
    getcc(cc);
    for (int i = 1; i <= k; i++){
        if (i > n - k + 1) cout << 0 << endl;
        else {
            long long ans = ((cmb[i] * cc[k-1] % mod) * modpow(cc[i-1], mod-2) % mod) * modpow(cc[k-i], mod-2) % mod;
            cout << ans << endl;
        }
    }
}

Measured memory_bytes: 256
n,d = map(int, input().split())
x = [list(map(int, input().split())) for _ in range(n)]

ans = 0
for i in range(n-1):
  for j in range(i+1, n):
    t = 0
    for k in range(d):
      t += (x[i][k]-x[j][k])**2
    t = t**0.5
    if t.is_integer():
      ans += 1
print(ans)

Measured memory_bytes: 3064
import java.util.*;

public class Main{
	public static void main(String[] args){
		try(Scanner sc = new Scanner(System.in)){
			while(true){
				int m = sc.nextInt(), f = sc.nextInt(), r = sc.nextInt();
				if(m == -1 && f == -1 && r == -1){
					break;
				}
				if(m == -1 || f == -1){
					System.out.println("F");
				}else if(m + f >= 80){
					System.out.println("A");
				}else if(m + f >= 65){
					System.out.println("B");
				}else if(m + f >= 50){
					System.out.println("C");
				}else if(m + f >= 30){
					if(r >= 50){
						System.out.println("C");
					}else{
						System.out.println("D");
					}
				}else{
					System.out.println("F");
				}
			}
		}
	}
}

Measured memory_bytes: 26052
#include <bits/stdc++.h>
#include <math.h>
#include <float.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rrep(i, n) for(int i = 0; i <= (n); i++)
using namespace std;
typedef long long ll;
 
const ll INF = 1LL<<62;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// 多次元 vector 生成
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

const int MOD = 1000000007;

int main(){
    ll N,M; cin >> N >> M;

    ll ans = 0;

    if (2*N <= M){
        ans = N + (M-2*N)/4;
    }
    else{
        ans = M/2;
    }

    cout << ans << endl;
}

Measured memory_bytes: 3560
#include <bits/stdc++.h>
using namespace std;
#include <iostream>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <math.h>
#include <sstream>
#include <numeric>
#include <cctype>
#include <bitset>
#include <cassert>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define SIZE 100005
#define INF 1000000000000000LL
using pint = pair<int,int>;
using vec = vector<int>;
using ll=long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }


int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n,d;cin>>n>>d;
    vector<vector<int>> a(n,vector<int> (d));

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

    int cnt=0;
    for(int i=0; i<n; i++){
        for(int k=1+i; k<n; k++){
            float ans=0;
            for(int j=0; j<d; j++){
                ans += (a[i][j]-a[k][j])*(a[i][j]-a[k][j]);
            }
            ans=sqrt(ans);
            if(ans==(int)ans) cnt++;
            int b=0;
        }
    }
    
    cout<<cnt<<endl;
    return 0;
}

Measured memory_bytes: 256
// ---------- BEG ../defs.hpp BEG ----------
#ifndef atcoder_defs_hpp
#define atcoder_defs_hpp
#include <cstdio>
#include <cstdint>
#include <cinttypes>
#include <cmath>
#include <string>
#include <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <numeric>
#include <functional>
using namespace std;
using i8t = std::int64_t;
using u8t = std::uint64_t;
using vi8t = std::vector<i8t>;
using vvi8t = std::vector<std::vector<i8t>>;
using vu8t = std::vector<u8t>;
#include <limits>
static const i8t i8t_max=numeric_limits<i8t>::max();
static const i8t i8t_min=numeric_limits<i8t>::min();
#include <unordered_map>
#include <unordered_set>
template<typename Key,typename Value> using map_t=std::unordered_map<Key, Value>;
template<typename Key> using set_t=std::unordered_set<Key>;
#define F3(i,i0,iN,step) for(i8t i=i0,i##_N=iN;i<i##_N;i+=step)
#define F2(i,i0,iN) F3(i,i0,iN,1)
#define F(i,N) F3(i,0,N,1)
#define FR(i,N) for(i8t i=N;i--;)
#define R(V) i8t V;std::cin>>V;
#define RV(V,N) std::vector<i8t> V;F(_i,N){R(_x)V.push_back(_x);}
#define RL1(line) std::getline(std::cin,line);
#define RL(line) std::string line;RL1(line)
#define RM(V,L,C) std::vector<char> V;F(_i,L){RL(_l)F(_j,C)V.push_back(_l[_j]);}
#define P(X) std::cout<<(X)<<std::endl;
template<typename T> T umax(T& ans,T const& value) {if(value>ans)ans=value;return ans;}
template<typename T> T umin(T& ans,T const& value) {if(value<ans)ans=value;return ans;}
template<typename T> struct identity { using type = T; };
#endif
// ---------- END ../defs.hpp END ----------

int main() {
  RL(line)
  P(!(line=="AAA"||line=="BBB")?"Yes":"No");
  return 0;
}


Measured memory_bytes: 380
#include <iostream>
#include <cmath>
#include <algorithm>
#include <string>
using namespace std;

int main() {
    int n, res = 0;
    string a, b, c;
    cin >> n >> a >> b >> c;
    for(int i = 0; i < n; i++){
        if(a[i] != b[i] && a[i] != c[i] && b[i] != c[i]) res += 2;
        else if(a[i] == b[i] && a[i] == c[i] && b[i] == c[i]) continue;
        else res++;
    }

    cout << res << "\n";
}


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

int MAX=200000;

int main(void){
    int n,R[MAX];
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>R[i];
    }
    int maxv=-2000000000;
    int minv=R[0];
    for(int i=1;i<n;i++){
        maxv=max(maxv,R[i]-minv);
        minv=min(minv,R[i]);
    }
    cout<<maxv<<"\n";
}


Measured memory_bytes: 3852
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(int i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(int i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(int i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define uniq(x) (x).erase(unique((x).begin(), (x).end()), (x).end())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n;
    string s;
    cin >> n >> s;
    int l = 0, r = n;
    
    while ((l + 1) < r) {
        int m = (l + r) / 2;
        
        bool ok = [&] {
            rep(i, n - m) {
                if (s.rfind(s.substr(i, m)) >= (i + m)) {
                    return true;
                }
            }
            
            return false;
        } ();
        
        if (ok) {
            l = m;
        }
        else {
            r = m;
        }
    }
    
    cout << l << endl;
    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define rep(i,l,r) for(int i=l;i<r;i++)
#define put(x) cout<<#x<<" = "<<x<<endl;
#define X first
#define Y second
#define pb push_back
#define pp pop_back
#define int num
#pragma GCC optimize("O2")
using namespace std;
typedef long long num;
typedef pair<int,int> point;
const int maxn=2e5+10;

int n,k,A[maxn],xr[maxn];
num sum[maxn];

bool check(int l,int r){
    num s=sum[r]-sum[l];
    return (1ll*(xr[r]^xr[l])==s);
}

int BS(int l0,int l,int r){
    if(r-l==1){
	return l;
    }
    int mid=(l+r)>>1;
    if(check(l0,mid)){
	return BS(l0,mid,r);
    }else{
	return BS(l0,l,mid);
    }
}

int32_t main(){
    scanf("%lld",&n);
    rep(i,0,n){
	scanf("%lld",A+i);
	sum[i+1]=sum[i]+1ll*A[i];
	xr[i+1]=xr[i]^A[i];
    }
    num ans=0;
    rep(i,0,n){
	ans+=BS(i,i,n+1)-i;
    }
    printf("%lld\n",ans);
}


Measured memory_bytes: 4992
#include <iostream> // {{{
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
#include <cstdio> // }}}

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

using namespace std;

int main() {
    char a,b;
    cin >> a >> b;
    cout << ((a == b) ? "=" : ((a < b) ? "<" : ">")) << endl;
    return 0;
}


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

int A,B,C;

int main() {
  cin >> A >> B >> C;
  
  if(A == B) {
    if(B == C) {
      cout << "No" << endl;
    } else {
      cout << "Yes" << endl;
    }
  } else {
    if(B == C || A == C) {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
  }
}

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

int main(){
	int N;
	string S;
	cin >> N >> S;
	if(N%2==1){
		cout << "No" << endl;
		return 0;
	}
	N/=2;
	bool flag=true;
	for(int i=0;i<N;i++)if(S[i]!=S[i+N])flag=false;
	if(flag)cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
#define chmin(a, b) ((a)=min((a), (b)))
#define chmax(a, b) ((a)=max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;

const ll MOD=1e9+7;
const ll INF=1e18;
const double pi=acos(-1);
const double eps=1e-10;

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

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

    int allw=0, allb=0;
    for(int i=0; i<n; i++){
        if(s[i] == '.') allb++;
        else allw++;
    }

    vector<int> sumw(n+10, 0), sumb(n+10, 0);
    for(int i=0; i<n; i++){
        if(s[i] == '.'){
            sumw[i+1] = sumw[i] + 1;
            sumb[i+1] = sumb[i];
        }
        else{
            sumw[i+1] = sumw[i];
            sumb[i+1] = sumb[i] + 1;
        }
    }

    int ans=1e9;
    for(int i=0; i<=n; i++){
        int Rallb = sumw[n] - sumw[i];
        int Lallw = sumb[i];
        chmin(ans, Rallb + Lallw);
    }

    cout << ans << endl;
}

Measured memory_bytes: 2180
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <unordered_map>
using namespace std;

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

const int maxn = 1e5 + 10;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;

#define dbg(x1) cout<<#x1<<" = "<<(x1)<<endl
#define dbg2(x1,x2) cout<<#x1<<" = "<<(x1)<<" "<<#x2<<" = "<<(x2)<<endl
#define dbg3(x1,x2,x3) cout<<#x1<<" = "<<(x1)<<" "<<#x2<<" = "<<(x2)<<" "<<#x3<<" = "<<(x3)<<endl
char s[maxn],t[maxn];
int sum[2][maxn];
int main() {
    //freopen(".in", "r", stdin);
    scanf("%s",s+1);
    scanf("%s",t+1);
    int lens=strlen(s+1);
    int lent=strlen(t+1);
    for(int i=1;i<=lens;i++) sum[0][i]=sum[0][i-1]+(s[i]=='A');
    for(int i=1;i<=lent;i++) sum[1][i]=sum[1][i-1]+(t[i]=='A');
    int q;scanf("%d",&q);
    while(q--)
    {
        int a,b,c,d;scanf("%d%d%d%d",&a,&b,&c,&d);
        int sum1a = (sum[0][b]-sum[0][a-1]);
        int sum1b = b-a+1-sum1a;
        int sum2a = (sum[1][d]-sum[1][c-1]);
        int sum2b = d-c+1-sum2a;
        int t1 = (sum1a+sum1b*2)%3;
        int t2 = (sum2a+sum2b*2)%3;
        if(t1==t2) printf("YES\n");
        else printf("NO\n");
    }
    return 0;
}



Measured memory_bytes: 1536
n, a = map(int, input().split())
x = list(map(int, input().split()))
for i in range(n):
    x[i] -= a
dp = [[0 for i in range(100 * n + 1)] for j in range(n + 1)]
dp[0][50 * n] = 1
for i in range(n):
    for j in range(100 * n + 1):
        j2 = j - 50 * n
        num = x[i]
        if -50 * n <= j2 - num <= 50 * n:
            dp[i + 1][j] = dp[i][j] + dp[i][j - num]
        else:
            dp[i + 1][j] = dp[i][j]
print(dp[n][50 * n] - 1)

Measured memory_bytes: 11384
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>
#include <cmath>
#include <climits>

using namespace std;
typedef long long ll;

int main()
{
    ll N, A, B;
    cin >> N >> A >> B;
    ll ans = 0;
    ll prev;
    for (ll i = 0; i < N; i++) {
        ll X;
        cin >> X;
        if (i != 0) {
            ans += min((X - prev) * A, B);
        }
        prev = X;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

struct str{
	int x0;
	int y0;
	int z0;
	int w0;
}x[20];
int a,b,c;
int A[20];
long long int ans = 0;
void func(int s, int t)
{
	if(s>a)
	{
		long long int count = 0;
		for(int i=1;i<=c;i++)
		{
			if(A[x[i].y0] - A[x[i].x0] == x[i].z0) count+=x[i].w0;
		}
		ans = ans>count?ans:count;
		return;
	}
	else
	{
		for(int i=t;i<=b;i++)
		{
			A[s] = i;
			func(s+1,i);
			A[s] = 0;
		}
	}
}
int main()
{
	scanf("%d%d%d",&a,&b,&c);
	for(int i=1;i<=c;i++) scanf("%d%d%d%d",&x[i].x0,&x[i].y0,&x[i].z0,&x[i].w0);
	
	func(1,1);
	printf("%lld",ans);
}

Measured memory_bytes: 1732
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
	class Program
	{
		static void Main(string[] args)
		{
			var s = Console.ReadLine().Split(' ');
			List<int> alist = new List<int>();
			foreach (var ss in s)
			{
				alist.Add(int.Parse(ss));
			}

			int ans = 0;

			for (int i = 0; i < 2; i++)
			{
				if (alist[0] > alist[1])
				{
					ans += alist[0];
					alist[0] = alist[0] - 1;
				}
				else
				{
					ans += alist[1];
					alist[1] = alist[1] - 1;
				}
			}

			Console.Write(ans.ToString() + "\n");
		}
	}
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (ll i = a; i < b; i++)
#define REP(i,b) FOR(i,0,b)
#define RFOR(i,a,b) for (ll i = a-1; i >= b; i--)
#define RREP(i,a) RFOR(i,a,0)
#define REPALL(i,x) for (ll i = 0; i < x.size(); i++)
#define RREPALL(i,x) for (ll i = x.size()-1; i >= 0; i--)
#define REPITR(itr,x) for (auto itr = (x).begin(); itr != (x).end(); itr++)
#define ALL(x) (x).begin(), (x).end()
#define SORT(x) sort(ALL(x))
#define MIN_ELEMENT(x) min_element(ALL(x))
#define MAX_ELEMENT(x) max_element(ALL(x))
#define COUNT(x,num) count(ALL(x), num)
#define MEMSET(x,val) memset(x, val, sizeof(x))
#define CHMAX(a,b) a = max(a,b)
#define CHMIN(a,b) a = min(a,b)
#define debug(x) cerr<<__LINE__<<": "<<(#x)<<" = "<<(x)<<endl;
void YES(bool flag) {cout<<(flag ? "YES" : "NO")<<endl;}
void Yes(bool flag) {cout<<(flag ? "Yes" : "No")<<endl;}
void yes(bool flag) {cout<<(flag ? "yes" : "no")<<endl;}
#define e1 first
#define e2 second
#define newline putchar('\n')
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef vector<ll> VLL;
typedef vector<vector<ll>> VVLL;
const int INF = 1e7;
const ll MOD = 1e9 + 7;
const double pi = 3.141592653589793;
const VI dx = {1, 0, -1, 0};
const VI dy = {0, 1, 0, -1};

int main()
{
    int n,k;
    cin>>n>>k;
    VI p(n);
    REP(i,n) cin>>p[i];
    SORT(p);
    int ans = 0;
    REP(i,k) ans += p[i];
    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 3572
# For taking integer inputs.
import math


def inp():
    return(int(input()))


# For taking List inputs.
def inlist():
    return(list(map(int, input().split())))


# For taking string inputs. Actually it returns a List of Characters, instead of a string, which is easier to use in Python, because in Python, Strings are Immutable.
def instr():
    s = input()
    return(list(s[:len(s)]))


# For taking space seperated integer variable inputs.
def invr():
    return(map(int, input().split()))


r, c = invr()

a = []
for _ in range(r):
    a.append(instr())

for i in range(r):
    h = a[i].count("#")
    if h == 0:
        for j in range(c):
            a[i][j] = "-1"
for i in range(c):
    count = 0
    for j in range(r):
        if a[j][i] == "#":
            count += 1
    if count == 0:
        for j in range(r):
            a[j][i] = "-1"

for i in range(r):
    f = 0
    for j in range(c):
        if a[i][j] != "-1":
            f = 1
            print(a[i][j], end="")
    if f:
        print()


Measured memory_bytes: 4596
ma = lambda :map(int,input().split())
lma = lambda :list(map(int,input().split()))
ni = lambda:int(input())
yn = lambda fl:print("Yes") if fl else print("No")
import collections
import math
import itertools
import heapq as hq
n = ni()
A = lma()
l = max(A)
cnts = [0 for i in range(l+3)]
for a in A:
    cnts[a]+=1
    cnts[a-1] +=1
    cnts[a+1] +=1
print(max(cnts))


Measured memory_bytes: 20896
#include <iostream>
#include <vector>
using namespace std;
const long long mod = 1e9+7;
long long mod_pow(long long a, long long b){
    long long res = 1;
    a %= mod;
    while(b > 0){
        if(b%2 == 1) res = (res * a) % mod;
        a = (a * a) % mod;
        b /= 2;
    }
    return res;
}
int main(void){
    int n, c;
    vector<int> a, b;
    vector< vector<long long> > dp, v;
    cin >> n >> c;
    a.assign(n, 0);
    b.assign(n, 0);
    for(int i=0;i<n;i++){
        cin >> a[i];
    }
    for(int i=0;i<n;i++){
        cin >> b[i];
    }
    
    v.assign(n, vector<long long>());
    for(int i=0;i<n;i++){
        v[i].assign(c+1, 0);
        for(int j=0;j<=c;j++){
            for(int k=a[i];k<=b[i];k++){
                v[i][j] += mod_pow(k, j);
                v[i][j] %= mod;
            }
        }
    }
    
    dp.assign(2, vector<long long>());
    dp[0].assign(c+1, 0);
    dp[1].assign(c+1, 0);
    for(int i=0;i<n;i++){
        int t = i%2, u = (i+1)%2;
        for(int j=0;j<=c;j++){
            if(i == 0){
                dp[t][j] = v[i][j];
                continue;
            }
            dp[t][j] = 0;
            for(int k=0;k<=j;k++){
                dp[t][j] += dp[u][k] * v[i][j-k];
                dp[t][j] %= mod;
            }
        }
    }
    cout << dp[(n+1)%2][c] << endl;
}


Measured memory_bytes: 1536
n, m = map(int, input().split())
h = list(map(int, input().split()))
is_good = [True for i in range(n)]
for i in range(m):
	a, b = map(int, input().split())
	a -= 1
	b -= 1
	if h[a] <= h[b]:
		is_good[a] = False
	if h[a] >= h[b]:
		is_good[b] = False

print(sum(is_good))

Measured memory_bytes: 85088
import java.util.*;

public class Main {
 	public static void main(String[] args) {
      
      Scanner sc = new Scanner(System.in);
      
      String str; 
      str = sc.next();
      
      int leng = str.length();
      int idx = 0;
      
   	  while(leng > idx) {
        	System.out.print("x");
        idx++;
      }

	}
}

Measured memory_bytes: 23764
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
using namespace std;

const long long INF = LLONG_MAX / 2;

int main()
{
    int n, bag;
    cin >> n >> bag;
    vector<int> w(n), v(n);
    for(int i=0; i<n; ++i)
        cin >> w[i] >> v[i];

    vector<vector<long long> > dp(n+1, vector<long long>(3*n+1, -INF));
    dp[0][0] = 0;
    for(int i=0; i<n; ++i){
        for(int a=n; a>=0; --a){
            for(int b=0; b<=3*n; ++b){
                if(dp[a][b] >= 0){
                    int b2 = b + w[i] - w[0];
                    dp[a+1][b2] = max(dp[a+1][b2], dp[a][b] + v[i]);
                }
            }
        }
    }

    long long ans = -INF;
    for(int a=0; a<=n; ++a){
        for(int b=0; b<=3*n; ++b){
            if(a * (long long)w[0] + b <= bag)
                ans = max(ans, dp[a][b]);
        }
    }
    cout << ans << endl;

    return 0;
}


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

int main(){
  string a;
  cin >>a;
  int b =a.size();
  int ans1 =0;
for(int i =0;i<b;i+=2){
if(a.at(i)=='L'){
ans1 ++;
  break;
}
}
  
  for(int i =1;i<b;i+=2){
  if(a.at(i)=='R'){
  ans1 ++;
    break;
  }
  }
  
  if(ans1==0) cout <<"Yes";
  else cout <<"No";
  
}

Measured memory_bytes: 256
# AtCoder Grand Contest 033
# https://atcoder.jp/contests/agc033
import sys

s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in list(ss)]
ss2nnn = lambda ss: [s2nn(s) for s in list(ss)]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [sys.stdin.readline() for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))



def main():
    R, G, B, N = i2nn()
    #a = []
    cnt = 0
    for r in range(N // R + 1):
        for g in range((N - R * r) // G + 1):
            #print([r, g, 0], N - R * r - G * g)
            if (N - R * r - G * g) % B == 0:
                cnt += 1
                #a.append([r,g,(N - R * r - G * g) // B])
    #print(a)
    print(cnt)
main()


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

int N, K; int ans = 0;
int main(){
    scanf("%d %d", &N, &K);
    for (int i = 0, x; i < N; i++) {
        scanf("%d", &x);
        if(x>=K) ans++;
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  long N;
  long two = 0;
  long four = 0;
  scanf("%lld",&N);
  vector <long> num(N);
  for(int i = 0;i<N;i++){
    scanf("%d", &num.at(i));
  }
  for(int i = 0;i<N;i++){
    if(num.at(i)%2 == 0){
      two++;
    }
    if(num.at(i)%4 == 0){
      two--;
      four++;
    }
  }
  if(N <= 2*four+two || N <= 2*four+1){
    printf("%s","Yes");
  }
  else{
    printf("%s","No");
  }
  return 0;
}

Measured memory_bytes: 1024