akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <unordered_map>
#include <algorithm>

using namespace std;

vector<int> diff(const vector<int>& a, const vector<int>& b)
{
    vector<int> res(10);
    for (int i = 1; i <= 9; i++) {
        res[i] = a[i] - b[i];
    }
    return res;
}

bool check_diff(const vector<int>& a, const vector<int>& b)
{
    for (int i = 1; i <= 9; i++) {
        if (a[i] < b[i]) return 0;
    }
    return 1;
}

using ull = unsigned long long;

class Hash {
  public:
    size_t operator () (const vector<int>& v) const
    {
        const ull B = 100000007;
        ull r = 0;
        for (const auto& n : v) {
            r = r * B + n;
        }
        return r;
    }
};

unordered_map<vector<int>, int, Hash> mem;
vector<vector<int>> pat;

bool check(const vector<int>& p)
{
    int res = 0, cnt = 0;
    for (int i = 1; i <= 9; i++) {
        cnt += p[i];
        res += p[i] * i;
    }
    return (res == 10 && cnt > 2);
}

void make_pattern(int n, const vector<int>& p)
{
    if (n == 10) {
        if (check(p)) {
            pat.emplace_back(p);
        }
        return;
    }
    for (int i = 0; i <= 10 / n; i++) {
        vector<int> np = p;
        np[n] += i;
        make_pattern(n + 1, np);
    }
}

int solve(const vector<int>& m_cnt)
{
    int res = 0;
    if (mem.count(m_cnt) != 0) {
        return mem[m_cnt];
    }

    for (const auto& p : pat) {
        if (check_diff(m_cnt, p)) {
            res = max(res, solve(diff(m_cnt, p)) + 1);
        }
    }
    return mem[m_cnt] = res;
}

int main()
{
    int N;
    make_pattern(1, vector<int>(10));
    while (cin >> N, N > 0) {
        vector<int> m_cnt(10);
        for (int i = 0; i < N; i++) {
            int m;
            cin >> m;
            m_cnt[m]++;
        }

        int res = 0;
        for (int i = 1; i <= 5; i++) {
            int mini = min(m_cnt[i], m_cnt[10 - i]); 
            if (i == 5) mini /= 2;
            res += mini;
            m_cnt[i] -= mini;
            m_cnt[10 - i] -= mini;
        }
        mem.clear();
        res += solve(m_cnt);
        cout << res << endl;
    }        
    return 0;
}

Measured memory_bytes: 8864
#include <bits/stdc++.h>
#define mem(dp,a) memset(dp,a,sizeof(dp))
#define pb(x) push_back(x)
#define m_p(x,y) make_pair(x,y)
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define repush_back(i,a,b) for(ll i=a;i>=b;i--)
#define f(n) for(ll i=0;i<n;i++)
#define r(n) for(ll j=0;j<n;j++)
#define F first
#define S second
#define pi 3.14159265359
#define hs ios_base::sync_with_stdio(false);cin.tie(NULL);
using namespace std;
typedef long long int ll;
ll HRX=1e18;
ll INF=1e9+7;

int main()
{
 hs;
 ll n;
 cin>>n;
 ll ans=((n)*(n-1))/2;
 cout<<ans<<endl;
 return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  int e=a*1000+b*100+c*10+d;
  if(e==1479 or e==1497 or e==1749 or e==1794 or e==1947 or e==1974 or e==4179 or e==4197 or e==4719 or e==4791 or e==4917 or e==4971 or e==7149 or e==7194 or e==7419 or e==7491 or e==7914 or e==7941 or e==9147 or e==9174 or e==9417 or e==9471 or e==9714 or e==9741 )
    cout<<"YES"<<endl;
  else
    cout<<"NO"<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <cassert>
#include <cmath>
using namespace std;
using VI = vector<long>;

int main() {
    int q;
    cin >> q;
    for (int i = 0; i < q; i++) {
        long a, b, aa, bb;
        cin >> a >> b;
        aa = min(a, b);
        bb = max(a, b);
        if (a == b) {
            cout << 2 * a - 2 << endl;
            continue;
        }
        if (aa + 1 == bb) {
            cout << 2 * aa - 2 << endl;
        } else {
            long c = sqrt(aa * bb);
            if (c * c == a * b) {
                c--;
            }
            assert(c * c < a * b);
            assert((c + 1) * (c + 1) >= a * b);
            if (c * (c + 1) >= aa * bb) {
                cout << 2 * c - 2 << endl;
            } else {
                cout << 2 * c - 1 << endl;
            }
        }
    }
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        long N = sc.nextLong();

        System.out.println(solve(N));
    }
    static
    long solve(long N){

        long ans = 0;
        //factors of N
        for(long l: listFactors(N)){
            long temp = N;
            if(l==1) continue;
            while(temp % l ==0) temp= temp/l;
            if(temp%l==1) ans++;
        }

        ans += listFactors(N-1).size()-1;

        return ans;
    }
    static Collection<Long> listFactors(long N ){
        Set<Long> l = new HashSet<>();

        for (long i = 1; i*i <= N ; i++) {
            if(N%i==0){
                l.add(i);
                l.add(N/i);
            }
        }
        return l;
    }


}


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

int main() {
  int N, M;
  cin >> N >> M;
  int sum = 0;
  for (int i = 0; i < M; i++) {
    int A;
    cin >> A;
    sum += A;
  }
  if (N < sum) {
    cout << -1 << endl;
  } else {
    cout << N - sum << endl;
  }
}

Measured memory_bytes: 3628
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

const int N = 1000+10;
const int MOD = 1000*1000*1000+7;

long long Pom[3][3];
char Plansza[N][N];
int l_zajetych;
int pol_poz,pol_pion;
int kol_pion,kol_poz;

void Wczytaj(int w,int h){
	int i,j;
	for(i=0; i<w; i++){
		for(j=0; j<h; j++){
			cin >> Plansza[i][j];
			if(Plansza[i][j] == '#') l_zajetych++;
		}
	}
	for(i=0; i<w; i++) if(Plansza[i][0] == '#' && Plansza[i][h-1] == '#') pol_poz++;
	for(i=0; i<h; i++) if(Plansza[0][i] == '#' && Plansza[w-1][i] == '#') pol_pion++;
	for(i=1; i<w; i++){
		for(j=0; j<h; j++) if(Plansza[i][j] == '#' && Plansza[i-1][j] == '#') kol_pion++;
	}
	for(i=1; i<h; i++){
		for(j=0; j<w; j++) if(Plansza[j][i] == '#' && Plansza[j][i-1] == '#') kol_poz++;
	}
}

long long Poteguj(long long a,long long k,long long mod){
	long long res;
	res = 1;
	while(k>0){
		if(k%2 == 1) res *= a;
		a *= a;
		a %= mod;
		res %= mod;
		k /= 2;
	}
	return res;
}

void MnozMacierze(vector < vector <long long> > &M1,vector < vector <long long> > M2){
	int i,j,k;
	for(i=0; i<2; i++) for(j=0; j<2; j++) Pom[i][j] = 0;
	for(i=0; i<2; i++){
		for(j=0; j<2; j++){
			for(k=0; k<2; k++) Pom[i][j] = (Pom[i][j]+M1[i][k]*M2[k][j])%MOD;
		}
	}
	for(i=0; i<2; i++) for(j=0; j<2; j++) M1[i][j] = Pom[i][j];
}

void PotegujMacierz(vector < vector <long long> > &A,vector < vector <long long> > &B,long long k){
	while(k>0){
		if(k%2 == 1) MnozMacierze(B,A);
		MnozMacierze(A,A);
		k /= 2;
	}
}

int main(){
    vector < vector <long long> > A,Res;
    vector <long long> X;
    int w,h;
    long long k;
    cin >> w >> h >> k;
    Wczytaj(w,h);
    X.push_back(0);
    X.push_back(1);
   	Res.push_back(X);
    Res.push_back(X);
    Res[0][0] = 1; Res[0][1] = 0;
    A = Res;
    if(pol_poz > 0 && pol_pion > 0) cout << 1 << "\n";
    if(pol_poz == 0 && pol_pion == 0) cout << Poteguj(l_zajetych,k-1,MOD) << "\n";
    if(pol_poz > 0 && pol_pion == 0){
		//cout << "WOW" << "\n";
		A[0][0] = l_zajetych; A[0][1] = (-kol_poz+MOD)%MOD; A[1][0] = 0; A[1][1] = pol_poz;
		PotegujMacierz(A,Res,k-1);
		cout << (Res[0][0]+Res[0][1])%MOD << "\n";
    }
	if(pol_poz==0 && pol_pion>0){
		A[0][0] = l_zajetych; A[0][1] = (-kol_pion+MOD)%MOD; A[1][0] = 0; A[1][1] = pol_pion;
		PotegujMacierz(A,Res,k-1);
		cout << (Res[0][0]+Res[0][1])%MOD << "\n";
	}
    return 0;
}


Measured memory_bytes: 1280
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

N, M, K = map(int, input().split())
uf = UnionFind(N)
a = [0] * M
b = [0] * M
for i in range(M):
    a[i], b[i] = map(int, input().split())
    uf.union(a[i]-1, b[i]-1)

ans = [uf.size(i) - 1 for i in range(N)]

for i in range(M):
    if uf.same(a[i]-1, b[i]-1):
        ans[a[i]-1] -= 1
        ans[b[i]-1] -= 1

for i in range(K):
    c, d = map(int, input().split())
    if uf.same(c-1, d-1):
        ans[c-1] -= 1
        ans[d-1] -= 1

print(' '.join(map(str, ans)))

Measured memory_bytes: 97624
a = input()
if a == "SAT":
		print(1)
		
elif a == "FRI" :
		print(2)
		
elif a == "THU" :
		print(3)
			
elif a == "WED" :
		print(4)		
		
elif a == "TUE" :
		print(5)		
	
elif a == "MON" :
		print(6)

else :
		print(7)

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

#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define endl '\n'
#define fcin ios::sync_with_stdio(false); cin.tie(nullptr);
#define INF 0x3f3f3f3f
#define all(x) x.begin(), x.end()
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

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

int main(){
    fcin;
    string s;
    cin >> s;
    if(s[2] == s[3] and s[4] == s[5]) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
int main()
{
  string s;
  cin >> s;
  int N=s.size()+1;
  vector<ll>ans(N,0);
  for(int i=0;i<N-1;i++){
     if(s[i]=='<'){
        ans[i+1]=max(ans[i+1],ans[i]+1);
     }
  }
  for(int i=N-1;i>=1;i--){
     if(s[i-1]=='>'){
        ans[i-1]=max(ans[i-1],ans[i]+1);
     }
  }
  ll k=0;
  rep(i,N)k+=ans[i];
  cout << k << endl;
  return 0;
}

Measured memory_bytes: 4740
NK = input().split()
N = int(NK[0])
K = int(NK[1])
Hs = input().split()
Hs = [int(h) for h in Hs]

import numpy as np
Hs = np.array(Hs)
Hs = np.sort(Hs, kind="quick_sort")
if K > 0:
  s = np.sum(Hs[0:-K]) if N > K else 0
else:
  s = np.sum(Hs)
print(s)

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

#define x first
#define y second
#define pb push_back
#define mp make_pair

#define all(a) (a).begin(), (a).end()

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a, b, c;
    cin >> a >> b >> c;
    if (a + b + c >= 22) {
        cout << "bust";
    } else {
        cout << "win";
    }
    return 0;
}


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

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

int main(){
    int n;cin >>n;
    vector<int>l(2*n);
    for (int i = 0; i <2*n; ++i) {
        cin >>l[i];
    }
    sort(all(l));
    ll ans=0;
    for (int i = 0; i < 2*n; i+=2) {
        ans+=min(l[i],l[i+1]);
    }
    cout <<ans<<endl;
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    if (a+b+c >= 22)
        cout << "bust" << endl;
    else
        cout << "win" << endl;
    return 0;
}




Measured memory_bytes: 256
import java.util.Scanner;


public class Main {
	public static void main(String[] args){
		try(Scanner sc = new Scanner(System.in)) {
		
			long a = sc.nextLong();
			long b = sc.nextLong();
			
			long gcd = gcd(a, b);
			
			long afactor = a / gcd;
			long bfactor = b / gcd;
			
			System.out.println(gcd * afactor * bfactor);

		}
	}
	
	public static long gcd(long a, long b) {
		if ( a > b ) {
			return gcd(b, a);
		}
		
		if ( b % a == 0) {
			return a;
		}
		else {
			return gcd(a, b % a);
		}
	}

}

Measured memory_bytes: 35744
input()
int_list = list(map(int, input().split()))
max_num = 10**18
ans = 1

if 0 in int_list:
    print(0)
    exit()
  
for i in int_list:
    ans *= i
    if ans > max_num:
        print(-1)
        break
else:
    print(ans)


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

using namespace std;

int main(){
    string s, t, u;
    int a, b; cin >> s >> t >> a >> b >> u;

    if(s == u) {
        cout << (a - 1) << " " << b << endl;
    } else if (t == u){
        cout << a << " " << (b - 1) << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef long double ld;
 
#define REP(i,a,n) for(int (i)=(a); (i)<(int)(n); (i)++)
#define rep(i,n) REP(i,0,n)
#define vec vector 


int char_to_int(char c){
  switch(c){
    case '0': return 0;
	case '1': return 1;
	case '2': return 2;
	case '3': return 3;
	case '4': return 4;
	case '5': return 5;
	case '6': return 6;
	case '7': return 7;
	case '8': return 8;
	case '9': return 9;
	default: return 0;
  }
}


int main(){
  string S;
  cin >> S;
  string res = "Yes";
  
  if(S.size()%2 == 1){
    res = "No";
  }else{
    rep(i, S.size()){
      if(i%2 == 0 && S.at(i) != 'h') res = "No";
      if(i%2 == 1 && S.at(i) != 'i') res = "No";
    }
  }
  
  cout << res;
        
    
  
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
using namespace std;
int N;
int baga(int val){
    string ans;
    cout << val << endl;
    cin >> ans;
    if(ans == "Male"){
        return 0;
    }
    if(ans == "Female"){
        return 1;
    }
    exit(0);
}
int main(){
    cin >> N;
    int tmp = baga(0);
    int st = 0,dr = N;
    while(dr - st > 1){
        int mid = (st + dr) / 2;
        int tmp2 = baga(mid);
        if(tmp2 == tmp ^ (mid % 2)){
            st = mid;
        }
        else{
            dr = mid;
        }
    }
    baga(st);
    baga(dr);
    return 0;
}


Measured memory_bytes: 852
#標準入力受け取り
N = int(input())
shougen = []
A_lis = []
for _ in range(N):
    A = int(input())
    A_lis.append(A)
    minishougen = []
    for j in range(A):
        xy = list(map(int, input().split()))
        minishougen.append(xy)
    shougen.append(minishougen)

#ビットの配列作る
bit_lis = []
for i in range(2 ** N):
    mini_bit_lis = []
    for j in range(N):
        mini_bit_lis.append(i % 2)
        i = i // 2
    bit_lis.append(mini_bit_lis)
    
#ビットの配列について全探索を行う
ans = 0
for i in range(2 ** N):
    flag = 0
    for l in range(N):
        if bit_lis[i][l] == 1:
            for k in range(A_lis[l]): 
                if shougen[l][k][1] != bit_lis[i][shougen[l][k][0] - 1]:
                    flag = 1
                    break
        if flag == 1:
            break
    if flag == 0:
        tmp = sum(bit_lis[i])
        if tmp > ans :
            ans = tmp
print(ans)

Measured memory_bytes: 9972
k = int(input())
l = [2, 7, 17, 37, 47, 67, 97, 107, 127, 137, 157, 167, 197, 227, 257, 277, 307, 317, 337, 347, 367, 397, 457, 467, 487, 547, 557, 577, 587, 607, 617, 647, 677, 727, 757, 787, 797, 827, 857, 877, 887, 907, 937, 947, 967, 977, 997, 1087, 1097, 1117, 1187, 1217, 1237, 1277, 1297]
print(" ".join(map(str,l[0:k])))

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>
#include <cmath>
#include <stack>
#include <map>
#include <iomanip>
using namespace std;

int64_t min(int64_t a,int64_t b) {
    if (a > b)
    {
        return b ;
    }else
    {
        return a ;
    }
}


int main(){
    string s ;
    int ans = 0 ;
    int temp = 0 ;
    cin >> s ;
    for (size_t i = 0; i < s.size(); i++)
    {
        if (s.at(i) == 'A' || s.at(i) == 'G' || s.at(i) == 'C' || s.at(i) == 'T')
        {
            temp ++ ;
        }else
        {
            temp = 0 ;
        }
        ans = max(ans,temp) ;
        
    }
    cout << ans << endl ;   
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <limits>

int main() {
	std::vector<int> v;
	int n, x;
	std::cin >> n; 
	for (int i = 0; i < n; i++) {
		std::cin >> x;
		v.push_back(x);
	}
	std::sort(v.begin(), v.end());
	long long ans = std::numeric_limits<long long>::max();
	for (int i = v[0]; i <= v[n-1]; i++) {
		long long temp = 0;
		for (int j = 0; j < n; j++) {
			temp += (i - v[j]) * (i - v[j]);
		}
		ans = std::min(temp, ans);
	}
	std::cout << ans;
	return 0;
}

Measured memory_bytes: 256
#ABC103D - Islands War
from operator import itemgetter
n, m = list(map(int,input().split()))
#keyのitemgetterによって前と後ろどちらの数字でsortするか決まる
ab = sorted([tuple(map(int,input().split())) for i in range(m)], key = itemgetter(1))
removed = -1
ans = 0

for a,b in ab:
    if a > removed:
        removed = b-1
        ans += 1
        
print(ans)

Measured memory_bytes: 18988
#include <stdio.h>

int main() {

  int A, B;

  scanf("%d", &A);
  scanf("%d", &B);

  int a,b,c;
  a = A + B;
  b = A - B;
  c = A * B;

  if(a >= b && a >= c) {
    printf("%d\n", a);
  } else if(b > a && b >= c) {
    printf("%d\n", b);
  } else {
    printf("%d\n", c);
  }

  return 0;
}


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

using namespace std;

int main(){
  int a[4];
  char s[2] = {'+', '-'};
  string input;
  cin >> input;
  for (int i=0;i<4;i++) {
    a[i] = (int)(input[i]) - 48;
  }
  
  for (int i=0;i<2;i++) {
    int r1 = a[0];
    r1 = i==0?r1+a[1]:r1-a[1];
    for (int j=0;j<2;j++) {
      int r2 = r1;
      r2 = j==0?r2+a[2]:r2-a[2];
      for (int k=0;k<2;k++) {
	int r3 = r2;
	r3 = k==0?r3+a[3]:r3-a[3];
	if (r3==7) {
	  cout << a[0] << s[i] << a[1] << s[j] << a[2] << s[k] << a[3] << "=7" << endl;
	  return(0);
	}
      }
    }
  }
  return(0);
}



Measured memory_bytes: 256
#include<map>
#include<set>
#include<cmath>
#include<regex>
#include<queue>
#include<stack>
#include<bitset>
#include<vector>
#include<cstdio>
#include<string>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<unordered_map>
#include<unordered_set>

#pragma warning(disable:4996)
using namespace std;

constexpr int MAXN = 105;
constexpr int INF = 100000000;

struct Node {
	int u, v, w;
};

int N;
int M;
Node var[MAXN*MAXN];
int dis[MAXN][MAXN];

int main() {
	scanf("%d%d\n", &N, &M);
	for (int i = 1; i <= M; ++i) {
		scanf("%d%d%d", &var[i].u, &var[i].v, &var[i].w);
	}
	for (int i = 1; i <= N; ++i) {
		for (int j = i; j <= N; ++j) {
			dis[i][j] = dis[j][i] = INF;
		}
	}
	for (int i = 1; i <= M; ++i) {
		int u = var[i].u;
		int v = var[i].v;
		int w = var[i].w;
		dis[u][v] = dis[v][u] = w;
	}
	for (int k = 1; k <= N; ++k) {
		for (int i = 1; i <= N; ++i) {
			for (int j = 1; j <= N; ++j) {
				dis[i][j] = min(dis[i][j], dis[i][k] + dis[k][j]);
			}
		}
	}
	int tempAns = 0;
	for (int i = 1; i <= M; ++i) {
		int u = var[i].u;
		int v = var[i].v;
		int w = var[i].w;
		if (dis[u][v] < w) {
			++tempAns;
		}	
	}
	printf("%d\n", tempAns);
	return 0;
}

Measured memory_bytes: 384
su = [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(su[k-1])

Measured memory_bytes: 3316
n = int(input())
tmp = input().split()
a = []
minus_count = 0
abs_sum = 0
min_num = min_num = abs(int(tmp[0]))
for i in range(n):
    b = int(tmp[i])
    a.append(b)
    if (b < 0):
        minus_count += 1
    abs_sum += abs(b)
    if abs(b) < min_num:
        min_num = abs(b)

ans = 0
if minus_count % 2 == 0:
    ans = abs_sum
else:
    ans = abs_sum - (min_num * 2)

print(ans)



Measured memory_bytes: 14380
inline fun CharSequence.countIndexed(predicate: (index: Int, Char) -> Boolean): Int {
    var count = 0
    var index = 0
    for (element in this) if (predicate(index++, element)) ++count
    return count
}

fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val ff = Array(n) { readLine()!!.split(' ').map { it == "1" } }
    val pp = Array(n) { readLine()!!.split(' ').map(String::toInt) }
    var ans = Int.MIN_VALUE
    for (i in 1..1023) {
        val ot = Integer.toString(i, 2).padStart(10, '0')
        var ur = 0
        for (j in 0 until n) {
            val f = ff[j]
            val p = pp[j]
            val cnt = ot.countIndexed { k, c -> c == '1' && f[k] }
            ur += p[cnt]
        }
        ans = Math.max(ans, ur)
    }
    println(ans)
}


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

using namespace std;
using ll = long long;

const int mod = 1000000007;
struct mint {
  ll x;
  mint(ll x = 0) : x(x % mod) {}
  mint operator-() const { return mint(-x); }
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) {
      x -= mod;
    }
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod - a.x) >= mod) {
      x -= mod;
    }
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    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 pow(ll t) const {
    if (!t) {
      return 1;
    }
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1) {
      a *= *this;
    }
    return a;
  }

  mint inv() const { return pow(mod - 2); }
  mint& operator/=(const mint a) { return *this *= a.inv(); }
  mint operator/(const mint a) { return mint(*this) /= a; }
};

istream& operator>>(istream& is, mint& a) {
  return is >> a.x;
}
ostream& operator<<(ostream& os, const mint& a) {
  return os << a.x;
}

int main() {
  int s;
  cin >> s;
  vector<mint> dp(4010, 1);
  dp[0] = dp[1] = dp[2] = 0;
  for (int i = 3; i <= 2000; i++) {
    for (int j = 3; j <= 2000; j++) {
      dp[i + j] += dp[i];
    }
  }
  cout << dp[s] << endl;
  return 0;
}


Measured memory_bytes: 3628
from operator import itemgetter
n=int(input())
l = []
for i in range(n):
	l.append(list(map(int,input().split())))
l.sort(key=itemgetter(1))
t=0
for pair in l:
	t+=pair[0]
	if(t>pair[1]):
		print("No")
		exit()
print("Yes")


Measured memory_bytes: 53720
k,n = map(int,input().split())
lst_a = list(map(int,input().split()))
dis_max = 0
lo_last = lst_a[0]
for i in range(1,n):
    ilo = lst_a[i]
    dis_max = max(dis_max, ilo-lo_last)
    lo_last = ilo
ilo = lst_a[0]
dis_max = max(dis_max, ilo+k-lo_last)
print(k-dis_max)

Measured memory_bytes: 26444
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <cstring>
#include <string>
#include <cstdlib>
#include <cstdio>
using namespace std;
#define INF 1e8
#define LX 100
#define LY 100

int d[2][7][2]={
{{0,1},{1,0},{1,-1},{0,-1},{-1,-1},{-1,0},{0,0}},
{{0,1},{1,1},{1,0},{0,-1},{-1,0},{-1,1},{0,0}}};
int n;
int sx,sy,gx,gy,lx,ly;
int G[204][204][6];
int farn[202][202];

class DP{
public:
	int cost, x, y, t;
	
	DP(){}
	DP(int cc, int xx, int yy, int tt){
		cost = cc;x=xx;y=yy;t=tt;
	}
	
	bool operator< (const DP &opp) const {
		return cost>opp.cost;
	}
};

main(){
	int i,j,k,x,y;
	
	for(i=0;i<=LX*2;i++){
		for(j=0;j<=LY*2;j++){
			for(k=0;k<6;k++){
				G[i][j][k] = INF;
			}
			farn[i][j] = 0;
		}
	}
	
	cin >> sx >> sy >> gx >> gy >> n;
	for(i=0;i<n;i++){
		cin >> x >> y;
		farn[x+LX][y+LY] = 1;
	}
	cin >> lx >> ly;
	priority_queue<DP> dp;
	DP S;
	G[sx+LX][sy+LY][0] = 0;
	dp.push(DP(0, sx, sy, 0));
	while(!dp.empty()){
		S = dp.top();
		dp.pop();
//		printf("%d %d %d %d\n", S.cost, S.x, S.y, S.t);
		if(S.x == gx && S.y == gy) break;
		for(i=0;i<7;i++){
			int dx = S.x + d[(S.x+LX)%2][i][0];
			int dy = S.y + d[(S.x+LX)%2][i][1];
			int dc = S.cost + (abs(S.x*S.y*S.t) % 6 == i ? 0 : 1);
			int dt = (S.t+1)%6;
			if(farn[dx+LX][dy+LY] || lx < abs(dx) || ly < abs(dy)) continue;
			if(dc < G[dx+LX][dy+LY][dt]){
				G[dx+LX][dy+LY][dt] = dc;
				dp.push(DP(dc, dx, dy, dt));
//				printf("push %d %d %d %d\n", dc, dx, dy, dt);
			}
		}
	}
	cout << (S.x == gx && S.y == gy ? S.cost : -1) << endl;
	return 0;
}

Measured memory_bytes: 2452
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.util.stream.Collectors;
import java.util.stream.IntStream;

public class Main {

	public static void main(String[] args) {
		OriginScanner os = new OriginScanner();
		PrintWriter pw = new PrintWriter(System.out);
		
		int k = os.nextInt();
		int x = os.nextInt();
		
		String str =IntStream.rangeClosed(x - (k - 1), x + (k - 1)).mapToObj(i -> String.valueOf(i)).collect(Collectors.joining(" "));
		
		pw.println(str);
		pw.close();
	}
	
	static class OriginScanner {
		private BufferedReader br;
		private StringTokenizer st;
		
		public OriginScanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}
		String nextLine() {
			String str = null;
			try {
				str = br.readLine();
			}
			catch (IOException e) {
				System.out.println(e);
			}
			return str;
		}
		String next() {
			if (st == null || !st.hasMoreTokens()) {
				st = new StringTokenizer(nextLine());
			}
			return st.nextToken();
		}
		int nextInt() {
			return Integer.parseInt(next());
		}
		long nextLong() {
			return Long.parseLong(next());
		}
	}
}

Measured memory_bytes: 27860
#pragma optimization_level 3
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#include<bits/stdc++.h>
#define F first
#define S second
#define vec vector
#define ms multiset
#define pb push_back
#define pll pair<ll,ll>
#define pdd pair<ld, ld>
#define pq priority_queue
#define umap unordered_map
#define uset unordered_set
#define pii pair<int, int>
#define pnn pair<Node*, Node*>
#define uid uniform_int_distribution
#define FILE ifstream in("board.in");ofstream out("board.out");
#define fast cin.tie(0);cout.tie(0);cin.sync_with_stdio(0);cout.sync_with_stdio(0);
using namespace std;
typedef string str;
typedef long long ll;
typedef long double ld;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count()); //uid<int> u1(5, 10); u1(rnd);

int main() {
    fast;
    ll a; cin>>a;
    vec<int> m(a);
    int x=0, y=0;
    for(int q=0; q<a; q++){
        int i; cin>>i;
        m[q] = i;
        if(i>=x) y = x, x=i;
        else if(i>y) y = i;
    }
    for(int q=0; q<a; q++){
        if(m[q]<x) cout<<x<<"\n";
        else cout<<y<<"\n";
    }
}

Measured memory_bytes: 2432
//#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <climits>
#include <iomanip>

using namespace std;

#define FAST       			ios_base :: sync_with_stdio(false); cin.tie(NULL); 
#define endl "\n"

typedef long long int  ll;
typedef unsigned long long int ull;


int main()
{
	FAST;
	string s[3];
	cin >> s[0] >> s[1] >> s[2];
	
	int index[3] = {0 , -1 , -1};

	int t = 0;
	while(1)
	{
		if(index[t] == s[t].size())
		{
			cout << (char)(t+'A');
			return 0;
		}
        t = s[t][index[t]]-'a';
		index[t]++;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<string.h>
 
typedef long long int ll;
#define all(x) (x).begin(), (x).end()
 
using namespace std;

int nxt() {
    int x;
    cin >> x;
    return x;
}

ll nxtl(){
    ll x;
    cin>>x;
    return x;
}
 
void SieveOfEratosthenes(int n,vector <int> &primes) 
{ 
    // Create a boolean array "prime[0..n]" and initialize 
    // all entries it as true. A value in prime[i] will 
    // finally be false if i is Not a prime, else true. 
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
    // Print all prime numbers 
    for (int p=2; p<=n; p++) 
       if (prime[p]) 
          primes.push_back(p);
} 
 
ll max(ll a,ll b)
{
    if(a>b)
        return a;
    return b;
}
 
ll power(ll x, ll y,ll mod) 
{ 
    ll temp; 
    if( y == 0) 
        return 1; 
    temp = power(x, y/2,mod); 
    if (y%2 == 0) 
        return (temp*temp)%mod; 
    else
        return (((x*temp)%mod)*temp)%mod; 
}

ll binomialCoeff(ll n, ll k) 
{ 
    ll C[k+1]; 
    memset(C, 0, sizeof(C)); 
  
    C[0] = 1;  // nC0 is 1 
  
    for (ll i = 1; i <= n; i++) 
    { 
        // Compute next row of pascal triangle using 
        // the previous row 
        for (ll j = min(i, k); j > 0; j--) 
            C[j] = C[j] + C[j-1]; 
    } 
    return C[k]; 
} 

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n=nxt();
    string s;
    cin>>s;
    string test="";
    int i=0;
    int tot=0;
    while(i<n)
    {
        if(s[i]==')')
        {
            int c=0;
            while(i<n&&s[i]==')')
            {
                i++;
                c++;
            }
            tot+=c;
            for(int i=0;i<c;i++)
                test.push_back(')');
        }
        else
        {
            int c=1;
            i++;
            test.push_back('(');
            while(i<n&&c!=0)
            {
                if(s[i]=='(')
                    c++;
                else
                    c--;
                test.push_back(s[i]);
                i++;
            }
            if(i>=n&&c!=0)
                while(c--)
                    test.push_back(')');
        }
    }
    string test2="";
    while(tot--)
        test2.push_back('(');
    cout<<test2<<test<<endl;
    
    return 0;   
}




 
 


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <vector>
#include <bitset>
#include <queue>
using namespace std;

int main(){
    int N, M;
    cin >> N;
    int T[N];
    int sum = 0;
    for(int i = 0; i < N; i++){
        cin >> T[i];
        sum += T[i];
    }
    cin >> M;
    int p[M];
    int x[M];
    for(int i = 0; i < M; i++){
        cin >> p[i] >> x[i];
    }
    for(int i = 0; i < M; i++){
        cout << sum - (T[p[i]-1] - x[i]) << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma gcc optimize("ofast")
using namespace std;

#define ll long long
#define ull unsigned long long
#define ui unsigned int
#define mod 1000000007
#define us unsigned short
#define IOS ios_base::sync_with_stdio(0);
#define INF LONG_MAX
#define PI 3.1415926535897932384626
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define rep(x,j,n)for(int x=j;x<n;x++)
typedef vector<pair<ll,ll>> vpi;
typedef vector<ll> vi;
typedef vector<vi> vvi;

ll modexp(ll a,ll b,ll m)
{
	ll r=1;
	a=a%m;
	while(b>0)
	{
	if(b&1)
		r=(r*a)%m;
	b=b/2;
	a=(a*a)%m;
	}
	return r%m;
}
ll n,k;
vi arr,brr;

bool check(ll mid)
{
    ll tmp = 0;
    rep(i,0,n)
    {
        ll x = mid/brr[i],z=0;
        tmp+=max(z,arr[i]-x);
    }
    return k>=tmp;
}
int main() {
   cin>>n>>k;
   arr = vi(n);
   brr = vi(n);
   ll y = 0;
   rep(i,0,n)
   {
       cin>>arr[i];
       y+=arr[i];
   }
   rep(i,0,n)cin>>brr[i];
   if(y<=k)
   {
       cout<<0<<endl;
       return 0;
   }
   sort(arr.begin(),arr.end());
   sort(brr.rbegin(),brr.rend());
   ll l = 1 , r=INT_MIN,ans = 0;
   rep(i,0,n)r=max(r,arr[i]*brr[i]);
   while(l<=r)
   {
       ll mid = l+(r-l)/2;
       if(check(mid))
       {
           ans = mid;
           r = mid-1;
       }
       else l = mid+1;
   }
   cout<<ans<<endl;
   return 0;
}



Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mset(m,v) memset(m,v,sizeof(m))
#define pr(a,s) printf("Case #%lld: %lld\n",a,s)
#define mod 1000000007
#define mp make_pair
#define all(a)                a.begin(),a.end()
#define pb push_back
#define scan(a) scanf("%d",&a)
#define scanl(a) scanf("%lld",&a)
#define se second
#define fi first
#define pi 3.14159265358979323
#define pii pair<ll,ll>

#define trace1(x)             cout <<#x<<": "<<x<< endl;
#define trace2(x, y)          cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<< endl;
#define trace3(x, y, z)       cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl;
#define trace4(a, b, c, d)    cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl;
#define trace5(a, b, c, d, e) cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<<": "<<e<<endl;

const int MAXM = 1e5+3;
const ll inf = 1e15;

ll arr[MAXM];

int main()
{
	int a,b;
	cin>>a>>b;
	if (b==1){
		cout << 0 << endl;
		return 0;
	}
	for (int i=1;i<=30;i++){
		int x = (a*i)-i+1;
		if (x >= b) {
			cout << i << endl;
			return 0;	
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mem(a,b) memset(a,b,sizeof(a))
#define inf 0x3f3f3f3f
#define ll long long
#define pb push_back
#define PII pair<int,int>
#define X first
#define Y second
#define MP make_pair
#define PI acos(-1.0)
#define eps 1e-8
const int maxn=5e3+10;
const int mod=1e9+7;
using namespace std;
int main(){
    int n;
    scanf("%d",&n);
    int m=sqrt(n);
    ll ans=0;
    for(int i=1;i<=n;i++){
        ll a,b;
        a=i;
        if(n%i==0){
            b=n/i-1;
        }
        else{
            b=n/i;
        }
        ans+=b;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3736
#include <bits/stdc++.h>
#define FOR(i, a, n) for(int (i) = (int)(a); (i) < (int)(n); ++(i))
#define FORe(i, a, n) for(int (i) = (int)(a); (i) <= (int)(n); ++(i))
#define rFOR(i, a, n) for(int (i) = (int)(n)-1; (i) >= (int)(a); --(i))
#define rFORe(i, a, n) for(int (i) = (int)(n); (i) >= (int)(a); --(i))
#define REP(i, n) FOR((i), 0, (n))
#define REPe(i, n) FORe((i), 1, (n))
#define REPo(i, n) FORe((i), 0, (n))
#define rREP(i, n) rFOR((i), 0, (n))
#define rREPe(i, n) rFORe((i), 1, (n))
#define rREPo(i, n) rFORe((i), 0, (n))
#define rep(i, n) FOR((i), 0, (n))
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define fi first
#define se second
#define dup(x, y) (((x)+(y)-1)/(y))
#define vc(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
using ll = long long;
using P = pair<int,int>;
using pll = pair<ll,ll>;
using T = tuple<int,int,int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vs = vector<string>;
using vp = vector<P>;
using vt = vector<T>;

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

int main() {
  vi x(5);
  REP(i, 5) cin >> x[i];
  REP(i, 5) {
    if(x[i] == 0) {
      cout << i+1 << endl;
      return 0;
    }
  }

  return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <iomanip>
#include <ios> 
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>
#include <map>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define sz(c) ((int)(c).size())

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
const int MAX=1e5+5;
const int MOD=1e9+7;


//dp[i][j]/Kの上からi桁目まで以下の数で、modDでjのものの個数
int dp[MAX][100];

int main(){
	string K;
	cin>>K;
	int D;
	cin>>D;
	int N=sz(K);
	vector<int> v={0};
	rep(i,N){
		int x=K[i]-'0';
		v.push_back(x);
	}
	int s[MAX];
	s[0]=v[0];
	rep1(i,N)s[i]=s[i-1]+v[i];
	
	dp[0][0]=1;
	rep1(i,N){
		rep(j,D)rep(k,10)dp[i][j]=(dp[i][j]+dp[i-1][(j+10*D-k)%D])%MOD;
		for(int k=s[i]+1;k<=s[i-1]+9;k++)dp[i][k%D]=(dp[i][k%D]+MOD-1)%MOD;
	}
 	cout<<(dp[N][0]+MOD-1)%MOD<<endl;
}


Measured memory_bytes: 4480
#include <stdio.h>

int main(){
  long n,a,i,m=0;
  scanf("%ld",&n);
  for(i=0;i<n;i++){
    scanf("%ld",&a);
    m+=((long)1<<40)/a;
  }
  a=((long)1<<62)/m;
  printf("%ld.",a>>22);
  a&=((long)1<<22)-1;
  for(i=0;i<6;i++){
    a*=10;
    printf("%ld",a>>22);
    a&=((long)1<<22)-1;
  }
  return(0);
}

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

#ifdef _DEBUG
inline void dump() { cerr << endl; }
template<typename Head> void dump(Head&& head) { cerr << head; dump(); }
template<typename Head, typename... Tail> void dump(Head&& head, Tail&&... tail) { cerr << head << ", "; dump(forward<Tail>(tail)...); }
#define debug(...) do {cerr << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; dump(__VA_ARGS__); } while (false)
#else
#define dump(...)
#define debug(...)
#endif

template<typename T>
struct edge {
  int src, to;
  T cost;
  edge(int to, T cost) : src(-1), to(to), cost(cost) {}
  edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}
  edge &operator=(const int &x) {
    to = x;
    return *this;
  }
  operator int() const { return to; }
};
template<typename T>
using Edges = vector<edge<T>>;
template<typename T>
using WeightedGraph = vector<Edges<T>>;
using UnWeightedGraph = vector<vector<int>>;
template<typename T>
using Matrix = vector<vector<T>>;

/////////////////////////////////////////////////////////////////////
const ll inf = 1LL<<60;

int main()
{
  int m; cin>>m;
  cout << 48-m << endl;

  return 0;
}


Measured memory_bytes: 3568
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <numeric>
#include <complex>
#include <iomanip>
#include <cassert>
#include <random>


int main() {
    int n; std::cin >> n;
    std::vector<std::vector<int>> edg(n);
    for (int i = 0; i < n - 1; i++) {
        int a, b; std::cin >> a >> b;
        a--; b--;
        edg[a].push_back(b);
        edg[b].push_back(a);
    }
    auto dijkstra = [&](int start, auto &dist) {
        std::deque<int> que;
        que.emplace_back(start);
        dist[start] = 0;
        while (!que.empty()) {
            int pos = que.front();
            que.pop_front();
            for (int u : edg[pos]) {
                if (dist[u] <= dist[pos] + 1) continue;
                dist[u] = dist[pos] + 1;
                que.emplace_back(u);
            }
        }
    };
    std::vector<int> distf(n, 1e9), dists(n, 1e9);
    dijkstra(0, distf);
    dijkstra(n - 1, dists);
    int s = 0;
    for (int i = 0; i < n; i++) {
        s += distf[i] <= dists[i];
    }
    std::cout << (s > (n - s) ? "Fennec" : "Snuke") << std::endl;
    return 0;
}


Measured memory_bytes: 6528
package main

import "fmt"

func main() {
	var n int
	var s string
	fmt.Scan(&n)
	fmt.Scan(&s)

	memo := make([]int, n)

	for i := 1; i < n; i++ {
		if s[i] == 'E' {
			memo[0]++
		}
	}

	for i := 1; i < n; i++ {
		if s[i] == 'E' {
			memo[i] = memo[i-1] - 1
		} else {
			memo[i] = memo[i-1]
		}

		if s[i-1] == 'W' {
			memo[i]++
		}
	}

	fmt.Println(min(memo))
}

func min(arr []int) int {
	min := 100000000
	for _, v := range arr {
		if v < min {
			min = v
		}
	}
	return min
}


Measured memory_bytes: 4864
#include<stdio.h>
#include<stdlib.h>

int main(void)
{
  int sx,sy,tx,ty;
  scanf("%d%d%d%d",&sx,&sy,&tx,&ty);
    for(int i=0; i<abs(tx-sx); i++){
      printf("%c",'R');
    }
    for(int i=0; i<abs(ty-sy); i++){
      printf("%c",'U');
    }  
    for(int i=0; i<abs(tx-sx); i++){
      printf("%c",'L');
    }
    for(int i=0; i<abs(ty-sy); i++){
      printf("%c",'D');
    }  

    printf("%c",'D');
    for(int i=0; i<abs(tx-sx)+1; i++){
      printf("%c",'R');
    }    
    for(int i=0; i<abs(ty-sy)+1; i++){
      printf("%c",'U');
    }  
      printf("%s","LU");
    for(int i=0; i<abs(tx-sx)+1; i++){
      printf("%c",'L');
    }
    for(int i=0; i<abs(ty-sy)+1; i++){
      printf("%c",'D');
    }
      printf("%c",'R');

  return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
typedef long long LL;
int N;
vector<string> w[101];
int main(){
	int K;
	int cnt=0;
	cin>>K;
	if(K<10){
		cout<<K<<endl;
		return 0;
	}
	vector<string>v;
	REP(i,9){
		string a;
		a.push_back('1'+i);
		w[0].push_back(a);
		cnt++;
	}
	int now=0;
	while(cnt<K){
		REP(i,w[now].size()){
			string a=w[now][i];
			if(a[a.size()-1]!='0'){
				string b=a;
				b.push_back(b[b.size()-1]-1);
				w[now+1].push_back(b);
			}
			if(a[a.size()-1]!='9'){
				string b=a;
				b.push_back(b[b.size()-1]+1);
				w[now+1].push_back(b);
			}
			string b=a;
			b.push_back(b[b.size()-1]);
			w[now+1].push_back(b);
		}
		sort(w[now+1].begin(),w[now+1].end());
		w[now+1].erase(unique(w[now+1].begin(),w[now+1].end()),w[now+1].end());
		cnt+=w[now+1].size();
		now++;
		//cout<<cnt<<" "<<now<<endl;
	}
	int x=0;
	bool check=false;
	REP(i,101){
		//cout<<x<<endl;
		REP(j,w[i].size()){
			x++;
			if(x==K){
				cout<<w[i][j]<<endl;
			}
		}
	}
}

Measured memory_bytes: 16008
from collections import deque, Counter as cnt
from collections import defaultdict as dd
from operator import itemgetter as ig
from bisect import bisect_right as bsr
from math import factorial, ceil, floor
import sys
sys.setrecursionlimit(1000000)

# お約束
args = None
INF = float("inf")
MOD = int(1e9 + 7)


def input(*ps):
    if type(ps[0]) is list:
        return [input(*ps[0][:-1]) for _ in range(ps[0][-1])]
    elif len(ps) == 1:
        return ps[0](next(args))
    else:
        return [p(next(args)) for p in ps]


def nlist(n, v):
    if not n:
        return [] if type(v) is list else v
    return [nlist(n[1:], v) for _ in range(n[0])]


def yesno(v):
    print(["Yes", "No"][not v])


# エントリーポイント
def main():
    L = input(int)
    print(L / 3 * L / 3 * L / 3)


if __name__ == '__main__':
    args = iter(sys.stdin.read().split())
    main()


Measured memory_bytes: 3436
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long a = sc.nextLong(), b = sc.nextLong();
        if((a + b) % 2 == 0) System.out.println((a + b) / 2);
        else System.out.println("IMPOSSIBLE");
    }
}


Measured memory_bytes: 23764
A,B,C=list(input()),list(input()),list(input())
Q=[A,B,C]
i=["a","b","c"]
k=A[0]
while(True):
  j=i.index(k)
  if len(Q[j])==0:
    print(k.upper())
    exit()
  k=Q[j][0]
  Q[j]=Q[j][1:]

Measured memory_bytes: 3064
def main():
    k,n = map(int, input().split())
    s = list(map(int, input().split()))
    l = []
    for i in range(n):
        if i == 0:
            l.append(k - (s[-1] - s[0]))
        else:
            a = s[i] - s[i-1]
            l.append(a)
    print(k - max(l))

if __name__ == '__main__':
    main()


Measured memory_bytes: 100904
import std.stdio, std.string, std.range, std.conv, std.array, std.algorithm, std.math, std.typecons;

void main() {
    auto S = readln.chomp.map!(c => c.to!(int) - '0');
    auto K = readln.chomp.to!long;
    long pos = 1;
    foreach(x; S) {
        if (x == 1 && pos < K) {
            pos++;
        } else {
            writeln(x);
            return;
        }
    }
    assert(false);
}



Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <cmath>
using namespace std;
int main()
{
 int i,j,k,n;
 cin >> n >> k;
 int a[n],b[n];
 for(i=0;i<n;i++)
 cin >> a[i];
 b[0]=0;
 b[1]=abs(a[0]-a[1]);
 for(i=2;i<n;i++)
 {
  b[i]=b[i-1]+abs(a[i]-a[i-1]);
  j=i-k;
  if(j<0)
  j=0;
  while(j<(i-1))
  {
   b[i]=min(b[j]+abs(a[i]-a[j]),b[i]);
   j++;
  }
 }
 cout << b[n-1];
 return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
int main(){
  int n,m;
  cin >> n >> m;
  int ac=0,wa=0;
  map<int,int> mp;
  rep(i,m){
    int a;
    string s;
    cin >> a >> s;
    if(mp[a]==-1){continue;}
    if(s=="AC"){
      wa +=mp[a];
      mp[a]=-1;
      ac++;
    }
    else{mp[a]++;}
  }
  cout << ac << " "<< wa <<endl; 
  return 0;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) begin(v),end(v)
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
using ll = long long;
using pii = pair<int, int>;
constexpr ll INF = 1ll<<30;
constexpr ll longINF = 1ll<<60;
constexpr ll MOD = 1000000007;
constexpr bool debug = 0;
//---------------------------------//

ll dp[51][51][2501];
int N, K;

int main() {
	cin >> N >> K;
	
	dp[0][0][0] = 1;
	
	REP(i, N) REP(j, i + 1) REP(k, K + 1) {
		if (dp[i][j][k] == 0) continue;
		
		int nk = k + (j + 1) * 2;
		if (nk <= K) (dp[i + 1][j + 1][nk] += dp[i][j][k]) %= MOD;
		
		nk = k + j * 2;
		if (nk <= K) (dp[i + 1][j][nk] += dp[i][j][k] * j * 2) %= MOD;
		
		if (j) {
			nk = k + (j - 1) * 2;
			if (nk <= K) (dp[i + 1][j - 1][nk] += dp[i][j][k] * j * j) %= MOD;
		}
		
		nk = k + j * 2;
		if (nk <= K) (dp[i + 1][j][nk] += dp[i][j][k]) %= MOD;
	}
	
	cout << dp[N][0][K] << endl;
	
	return 0;
}


Measured memory_bytes: 48512
n = int(input())
c = list(map(int, input().split()))
count=0
for i in range(1, n-1):
  temp = []
  temp.append(c[i-1])
  temp.append(c[i])
  temp.append(c[i+1])
  temp.sort()
  if c[i] == temp[1]:
    count += 1
    
print(count)

Measured memory_bytes: 3064
#include<iostream>

using namespace std;

int main(){
  int a,b,c;
  cin>>a>>b>>c;
  if(a==b||b==c||a==c){
    
    if(a==b&&b==c&&a==c) cout<<"No"<<endl;
    else cout<<"Yes"<<endl;
  }
  else cout<<"No"<<endl;
  return 0;
}


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

#define LL long long
#define LD long double
#define SC(t,x) static_cast<t>(x)
#define AR(t) vector < t >
#define PII pair < int, int >
#define PLL pair < LL, LL >
#define PIL pair < int, LL >
#define PLI pair < LL, int >
#define MP make_pair
#define PB push_back
#define PF push_front
#define POB pop_back
#define POF pop_front
#define PRF first
#define PRS second
#define INIT(ar,val) memset ( ar, val, sizeof ( ar ) )
#define lp(loop,start,end) for ( int loop = start; loop < end; ++loop )
#define lpd(loop,start,end) for ( int loop = start; loop > end; --loop )
#define lpi(loop,start,end) for ( int loop = start; loop <= end; ++loop )
#define lpdi(loop,start,end) for ( int loop = start; loop >= end; --loop )
#define qmax(a,b) (((a)>(b))?(a):(b))
#define qmin(a,b) (((a)<(b))?(a):(b))
#define qabs(a) (((a)>=0)?(a):(-(a)))

const int INF = 0x3fffffff;
const int SINF = 0x7fffffff;
const long long LINF = 0x3fffffffffffffff;
const long long SLINF = 0x7fffffffffffffff;
const int MAXN = 200007;

int n, X;
int a[MAXN];
LL ps[MAXN];

void init ();
void input ();
void work ();



int main ()
{
	init ();
	input ();
	work ();
}



void init ()
{
	// Init Everything Here

	ios::sync_with_stdio ( false );
}

void input ()
{
	// input method

	scanf ( "%d%d", &n, &X );
	lpi ( i, 1, n ) scanf ( "%d", &a[i] );
}

void work ()
{
	// main work

	lpi ( i, 1, n ) ps[i] = ps[i - 1] + a[i];

	LL ans = LINF, cur, nc;
	int ub;
	lpi ( i, 1, n ) {
		cur = 0;
		ub = ( n + i - 1 ) / i;
		lpi ( j, 1, ub ) {
			nc = ps[n - ( j - 1 ) * i] - ps[max ( n - j * i, 0 )];
			cur += ( ( j == 1 ) ? 5 : ( 2 * j + 1 ) ) * nc;
			if ( cur > LINF ) cur = LINF;
		}
		ans = qmin ( ans, cur + SC ( LL, i + n ) * X );
	}

	cout << ans << endl;
}

Measured memory_bytes: 2560