akhauriyash/Code-Regression huggingface dataset:
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.LinkedList;
import java.util.List;
import java.util.Scanner;

public class Main {

    /**
     * @param args
     */
    @SuppressWarnings("unchecked")
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        for (;;) {
            int N = sc.nextInt();
            int M = sc.nextInt();
            if (N + M == 0)
                break;
            List<int[]> list[] = new List[N];
            for (int i = 0; i < list.length; i++) {
                list[i] = new ArrayList<int[]>();
            }
            int r = sc.nextInt();
            for (int i = 0; i < r; i++) {
                int t = sc.nextInt();
                int n = sc.nextInt() - 1;
                int m = sc.nextInt() - 1;
                int s = sc.nextInt();
                list[n].add(new int[] { t, m });
            }

            int q = sc.nextInt();
            for (int iii = 0; iii < q; iii++) {
                int t1 = sc.nextInt();
                int t2 = sc.nextInt();
                int n = sc.nextInt() - 1;
                int[][] sec = getSection(list, n);
                if (sec[0] == null) {
                    System.out.println(0);
                    continue;
                }
                Arrays.sort(sec, new Comparator<int[]>() {
                    @Override
                    public int compare(int[] a, int[] b) {
                        return a[0] - b[0];
                    }
                });
                int ans = 0;
                for (int i = 0; i < sec.length;) {
                    int s = sec[i][0];
                    int t = sec[i][1];
                    for (i++; i < sec.length; i++) {
                        if (t < sec[i][0])
                            break;
                        t = Math.max(t, sec[i][1]);
                    }
                    s = Math.max(s, t1);
                    t = Math.min(t, t2);
                    ans += Math.max(t - s, 0);
                }
                System.out.println(ans);
            }
        }
    }

    static int[][] getSection(List<int[]>[] list, int n) {
        List<int[]> secs = new LinkedList<int[]>();
        for (List<int[]> l : list) {
            boolean login = false;
            int prev = -1;
            for (int[] a : l) {
                if (a[1] != n)
                    continue;
                if (login) {
                    secs.add(new int[] { prev, a[0] });
                } else {
                    prev = a[0];
                }
                login = !login;
            }
        }
        return secs.toArray(new int[][] { {} });
    }
}

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

int main()
{
    int n,f;
    cin>>n;
    for(int i=1;i<=9;i++)
    {
        f=0;
        if(n%i==0)
        {
            
            if(n/i<10)
            {
                cout<<"Yes";
                f=1;
                break;
            }
        }
    }
    if(f==0)
    {
        cout<<"No";
    }
    return 0;
}


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


List = []
n = len(str(N))
ans = 0
if n >= 3:
    if n > 3:
        for i in range(2,n-1):
            ans += (3**(i+1)-3*2**(i+1)+3)
    for j in range(n):
        if j == 0:
            List = [3*10**(n-1),5*10**(n-1),7*10**(n-1)]
        else:
            for k in range(3**j):
                num = List.pop(0)
                List.append(num+3*10**(n-j-1))
                List.append(num+5*10**(n-j-1))
                List.append(num+7*10**(n-j-1))
    for l in range(len(List)):
        if List[l] <= N:
            s = str(List[l])
            if "3" in s and "5" in s and "7" in s:
                ans += 1

print(ans)

Measured memory_bytes: 3828
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {
    public static void main(String args[]) {
        Scanner scan = new Scanner(System.in);
        List<Integer> list = new ArrayList<>();
        int a = Integer.parseInt(scan.next());
        int b = Integer.parseInt(scan.next());
        int intans = 0;
        intans = a*b - (a+b-1);

        PrintWriter out = new PrintWriter(System.out);
        out.println(intans);
        out.flush();
        scan.close();
    }
}

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

int i;




int main (){
  int a[5];
  int k;
  int mami[2];
  for (i = 0;i<5;i++)
    cin >> a[i];

  cin >> k;

  int maxv = INT_MIN;
  int minv = INT_MAX;
  int ans[2];

  for (i=0;i<5;i++){
    if (a[i] > maxv)
      maxv = a[i];
    if (a[i] < minv)
      minv = a[i];
  }
  ans[0] = maxv;
  ans[1] = minv;

  if ((ans[0] - ans[1]) > k)
    cout << ":(" <<endl;
  else if((ans[0] - ans[1]) <= k)
    cout << "Yay!" <<endl;
}



Measured memory_bytes: 256
// https://atcoder.jp/contests/arc071/tasks/arc071_b
#include <bits/stdc++.h>
using namespace std;

#ifdef LOCAL
    #define D(a) cerr << #a << " = " << a << endl
#else 
    #define D(a) 8 
#endif
#define fastio ios_base::sync_with_stdio(0); cin.tie(0)
#define dforsn(i,s,n) for(int i=int(n-1);i>=int(s);i--)
#define forsn(i,s,n) for(int i=int(s);i<int(n);i++)
#define all(a) (a).begin(),(a).end()
#define dforn(i,n) dforsn(i,0,n)
#define forn(i,n) forsn(i,0,n)
#define si(a) int((a).size())
#define pb emplace_back
#define mp make_pair
#define snd second
#define fst first
#define endl '\n'
using pii = pair<int,int>;
using vi = vector<int>;
using ll = long long;

const int M = 1e9 + 7;
int add(int a, int b){ return a+b < M ? a+b : a+b-M; }
int mul(int a, int b){ return int(ll(a)*b % M); }
int normal(ll a){ return int(((a % M) + M) % M); } // For neg numbers

int main() {
	fastio;
	
    int n, m; cin >> n >> m;
    int sx = 0, sy = 0;
    forsn(i, 1, n+1) {
        ll x; cin >> x;
        sx = add(sx, normal(x * (2*i-1-n)));
    }
    forsn(i, 1, m+1) {
        ll y; cin >> y;
        sy = add(sy, normal(y * (2*i-1-m)));
    }
    cout << mul(sx, sy) << endl;
	return 0;
}


Measured memory_bytes: 3612
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <string>
#include <cmath>
#define ll long long
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
using namespace std;
//
const int INF=1e9+7;
const int mod=1e9+7;
//
struct poi{
	int X;int Y;int Z;
	bool operator<(const poi&R)const{
		return X==R.X ? Y==R.Y ? Z<R.Z : Y<R.Y : X<R.X;
	}
};
//
ll GCD(ll a,ll b){
	return (b==0)?(a):(GCD(b,a%b));
}
ll LCM(ll a,ll b){
	return a/GCD(a,b)*b;
}
//
int D,G;
int P[10],C[10];
int main(){
	cin>>D>>G;
	G/=100;
	FOR(i,0,D){
		cin>>P[i]>>C[i];
		C[i]/=100;
	}
	int ans=INF;
	int d=1;
	FOR(i,0,D){
		d*=2;
	}
	FOR(i,0,d){
		int cnt=0;
		int s=0;
		FOR(j,0,D){
			if(i&(1<<j)){
				s+=P[j]*(j+1)+C[j];
				cnt+=P[j];
			}
		}
		if(s>=G){
			ans=min(ans,cnt);
		}else{
			vector<int> V;
			FOR(j,0,D){
				if(!(i&(1<<j))){
					if((G-s)>P[j]*(j+1)+C[j]){
						continue;
					}else if((G-s)>=P[j]*(j+1)){
						V.push_back(P[j]);
					}else{
						V.push_back(((G-s)+(j+1)-1)/(j+1));
					}
				}
			}
			if(V.empty()){
				continue;
			}else{
				sort(V.begin(),V.end());
				ans=min(ans,cnt+V[0]);
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <iomanip>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<long double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }
#define INF 1LL<<60

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

    int ans = 0;
    REP(i, S.length()) {
        int j = i;
        int tmp = 0;
        while(S[j] == 'A' || S[j] == 'C' || S[j] == 'G' || S[j] == 'T' ) {
            tmp++;
            j++;
        }
        if(ans < tmp) ans = tmp;
    }

    cout << ans << endl;

    return 0;
}

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

int main(void) {
    string N; cin >> N;
    char N1 = N.substr(N.size() - 1).c_str()[0];
    if (N1 == '2' || N1 == '4' || N1 == '5' || N1 == '7' || N1 == '9') {
        cout << "hon" << endl;
    } else if (N1 == '0' || N1 == '1' || N1 == '6' || N1 == '8') {
        cout << "pon" << endl;
    } else {
        cout << "bon" << endl;
    }
}


Measured memory_bytes: 3596
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>

using namespace std;

#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ; //何もしない文
#endif

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size()) //unsignedのサイズをint型に変換


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


template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;

//ここから書き始める
int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);	
    int n,k;
    cin >> n >> k;
    VI f(n+10);
    priority_queue<PLL> q; //今選択していない集合
    priority_queue<PLL, vector<PLL>, greater<PLL>> q2; //今選択している集合
    for(int i = 0; i < n; i++)
    {
        int t,d;
        cin >> t >> d;
        q.push(PLL(d,t));
    }
    int co = 0; //??
    LL x = 0, s = 0, ans = 0;
    while(co < k)
    {
        PLL p = q.top(); q.pop(); // qの一番でかい順に取り出す
        q2.push(p); //取り出したのをq2に入れる
        s += p.first; //おいしさプラス
        if(f[p.second] == 0) x++;
        f[p.second]++;
        co++;
    }
    ans = s + x*x;
    while(!q.empty()) //ネタの種類を増やしていくフェーズ
    {
        PLL p = q.top(); q.pop();
        if(f[p.second]) continue; //すでに使われていたらスキップ
        LL m = -1;
        while(!q2.empty())
        {
            PLL p2 = q2.top(); q2.pop(); //q2の一番小さいやつを取り出す　
            if(f[p2.second] > 1) //2個以上使われてたら採用
            {
                f[p2.second]--;
                m = p2.first; //取り出すやつのおいしさ
                break;
            }
        }
        if(m==-1) break;
        x++;
        f[p.second]++;
        s += p.first;
        s -= m;
        ans = max(ans,s+x*x);

    }
    cout << ans << endl;


}


Measured memory_bytes: 5232
N,T = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]

maxdiff = 0
ct = 0
mintmp = float("inf")
for A_i in A:
    mintmp = min(A_i,mintmp)
    diff = A_i - mintmp
    if diff > maxdiff:
        maxdiff = diff
        ct = 1
    elif diff == maxdiff:
        ct += 1
print(ct)

Measured memory_bytes: 14252
import java.util.*;

public class Main {
	public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    
    int H = scanner.nextInt();
    int W = scanner.nextInt();
    StringBuilder sb = new StringBuilder();
    for (int i = 0; i < W + 2; i++) sb.append('#');
    sb.append('\n');
    for (int i = 0; i < H; i++) {
      sb.append('#').append(scanner.next().toCharArray()).append('#').append('\n');
    }
    for (int i = 0; i < W + 2; i++) sb.append('#');
    sb.append('\n');
    System.out.print(sb.toString());
	}
}

Measured memory_bytes: 23764
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int maxn = 1005 + 5;
int mp[maxn][maxn] , n , m;
struct Node
{
    int x , y;
    int dis;
    Node (int xx , int yy, int d = 1e7){
        x = xx;
        y = yy;
        dis = d;
    }
    bool operator < (const Node & a) const {
        return dis > a.dis;
    }
};
int book[maxn][maxn];
int dist[maxn][maxn];
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
priority_queue<Node>Q;
void Dijstra(pair<int,int> s){
    while(Q.size()) Q.pop();
    for (int i = 1 ; i <= n ; i++){
        for (int j = 1 ; j <= m ; j++){
            book[i][j] = 0;
            dist[i][j] = 1e7;
        }
    }
    dist[s.first][s.second] = 0;
    Q.push(Node(s.first , s.second , 0));
    while(Q.size())
    {
        Node temp = Q.top() ; Q.pop();
        int x = temp.x , y = temp.y;
        int dis = temp.dis;
        if (book[x][y]) continue;
        book[x][y] = 1;
        // 两种决策
        for (int i = 0 ; i < 4 ; i++){
            int nx = x + dx[i] , ny = y + dy[i];
            if (nx < 1 || nx > n || ny < 1 || ny > m || book[nx][ny] || mp[nx][ny]) continue;
            if (dist[nx][ny] > dis){
                dist[nx][ny] = dis;
                Q.push(Node(nx , ny , dist[nx][ny]));
            }
        }
        int cx = x - 2 , cy = y - 2;
        for (int i = 0 ; i < 5 ; i++){
            for (int j = 0 ; j < 5 ; j++){
                int nx = cx + i , ny = cy + j;
                if (nx < 1 || nx > n || ny < 1 || ny > m || book[nx][ny] || mp[nx][ny]) continue;
                if (dist[nx][ny] > dis + 1){
                    dist[nx][ny] = dis + 1;
                    Q.push(Node(nx , ny , dist[nx][ny]));
                }
            }
        }
    }
    return ;
}
int main()
{
    ios::sync_with_stdio(false);
    cin >> n >> m;
    pair<int,int> s; cin >> s.first >> s.second;
    pair<int,int> e; cin >> e.first >> e.second;
    for (int i = 1 ; i <= n ; i++){
        for (int j = 1 ; j <= m ; j++){
            char v;
            cin >> v;
            if(v == '.') mp[i][j] = 0;
            else mp[i][j] = 1;
        }
    }
    Dijstra(s);
    if (dist[e.first][e.second] == 1e7) cout << -1 << endl;
    else cout << dist[e.first][e.second] << endl;
    return 0;
}


Measured memory_bytes: 15480
import sys
n, m = map(int, input().split())
d = [10] * n
if m == 0:
    if n == 1:
        print(0)
        sys.exit()
    else:
        print('1' + (n - 1) * '0')
        sys.exit()
for _ in range(m):
    s, c = map(int, input().split())
    s = s - 1
    if d[s] == 10:
        d[s] = c
    elif d[s] != c:
        print(-1)
        sys.exit()
if d[0] == 0:
    if n == 1:
        print(0)
        sys.exit()
    else:
        print(-1)
        sys.exit()
if d[0] == 10:
    d[0] = 1
for i in d:
    print(0, end='') if i == 10 else print(i, end='')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define inf (ll)1e9
#define mod (ll)(1e9+7)
#define d(x) cerr<<#x<<"="<<x<<endl;
#define p(x) cout<<(x)<<endl
#define ps(x) cout<<(x);
#define pfix(d,x) cout << fixed << setprecision(d) << x << endl;
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define minel(v) *min_element(all(v))
#define minind(v) distance((v).begin(), min_element(all(v)))
#define maxel(v) *max_element(all(v))
#define maxind(v) distance((v).begin(), max_element(all(v)))
#define fi first
#define se second
ll a,b,c,d,n,m,x,y,z,k,h,w,sum,mi,ma,ans,s,t,l,r,res,tmp,itr,p,q;
bool flag;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
int dx8[8]={1,1,0,-1,-1,-1,0,1},dy8[8]={0,1,1,1,0,-1,-1,-1};
char cha;
string st;
typedef map<int, int> imap;
typedef pair<ll, ll> P;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<pair<ll,ll> > VP;

struct UnionFind {
  VL data;
  UnionFind(int size) : data(size, -1) { }
  bool unite(int x, int y) {
    x = root(x); y = root(y);
    if (x != y) {
      if (data[y] < data[x]) swap(x, y);
      data[x] += data[y]; data[y] = x;
    }
    return x != y;
  }
  bool find(int x, int y) {
    return root(x) == root(y);
  }
  int root(int x) {
    return data[x] < 0 ? x : data[x] = root(data[x]);
  }
  ll size(int x) {
    return -data[root(x)];
  }
  ll num_root(ll size){
    VL roots;
    rep(i,size)roots.pb(root(i));
    sort(all(roots));
    roots.erase(unique(all(roots)),roots.end());
    return roots.size();
  }
};

int main(void){
    cin>>n>>m;
    UnionFind uf(n);
    rep(i,m){
        cin>>a>>b>>c;
        a--; b--;
        uf.unite(a,b);
    }
    p(uf.num_root(n));
    return 0;
}


Measured memory_bytes: 2168
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 2e5 + 10;
int a[N], f[N], n;
ll k;

bool check(ll x) {
  ll pos = 0;
  for(int i = 1; i <= n; ++i) {
    ll gg = 1ll * a[i] * f[n - i + 1];
    if(gg <= x) continue;
    else {
      int yu = (gg - x) % f[n - i + 1];
      if(yu) yu = 1;
      pos += (gg - x) / f[n - i + 1] + yu;
    }
    if(pos > k) return false;
  }
  return pos <= k;
}

int main() {
  scanf("%d%lld", &n, &k);
  for(int i = 1; i <= n; ++i) {
    scanf("%d", &a[i]);
  }
  sort(a + 1, a + 1 + n);
  for(int i = 1; i <= n; ++i) {
    scanf("%d", &f[i]);
  }
  sort(f + 1, f + 1 + n);
  ll l = 0, r = 1e18, ans;
  while(l <= r) {
    ll mid = (l + r) >> 1;
    if(check(mid)) ans = mid, r = mid - 1;
    else l = mid + 1;
  }
  printf("%lld\n", ans);
  return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e15;

#include <math.h>
#define PI 3.14159265358979323846264338327950L
const int mxN = 1e9 + 7;


int main() {
    vector<int> a(3);
    for (int i = 0; i < 3; i++) cin >> a[i];
    int ans = 99999;
    for (int i = 0; i < 2; i++) {
        for (int j = i + 1; j < 3; j++) {
            ans = min(ans, a[i] + a[j]);
        }
    }
    cout << ans;

    return 0;
}

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

signed main () {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    int n;
    cin >> n;
    vector < vector < int > > ones(20);
    for (int i = 1; i <= n; ++i) {
        int x;
        cin >> x;
        for (int j = 0; j < 20; ++j) {
            if (x & (1 << j))
                ones[j].push_back(i);
        }
    }
    int64_t ans = 0;
    int r = n + 1;
    for (int l = n; l >= 1; --l) {
        for (int j = 0; j < 20; ++j) {
            auto i = lower_bound(ones[j].begin(), ones[j].end(), l);
            if (i != ones[j].end() && *i == l) {
                auto it = upper_bound(ones[j].begin(), ones[j].end(), l);
                if (it != ones[j].end())
                    r = min(r, *it);
            }
        }
        ans += r - l;
    }
    cout << ans << '\n';
}


Measured memory_bytes: 8264
#include <bits/stdc++.h>
using namespace std;
#define ll          long long
#define vl          vector<ll>
#define vi          vector<int>
#define pi          pair<int,int>
#define pl          pair<ll,ll>
#define all(a)      a.begin(),a.end()
#define mem(a,x)    memset(a,x,sizeof(a))
#define pb          push_back
#define mp          make_pair
#define F           first
#define S           second
#define trace(x)     cerr<<#x<<":"<<x<<endl;
#define trace2(x,y) cerr<<#x<<":"<<x<<"|"<<#y<<":"<<y<<endl;
#define trace3(x,y,z) cerr<<#x<<":"<<x<<"|"<<#y<<":"<<y<<"|"<<#z<<":"<<z<<endl;
#define fast_io     std::ios::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)

int main(){
	fast_io;
	long double r;
	cin>>r;
	long double piee = 3.14159265358979323846;
	long double c = (2*piee*r);
	cout<<setprecision(15)<<c;

	
	// cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
	return 0;
}


Measured memory_bytes: 3760
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define all(x) (x).begin(),(x).end()
#define pushb(x) push_back(x)
#define popb() pop_back()
#define makep make_pair
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& s, const vector< vector<T> >& vv);
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v);
template<typename T> ll gcd(T a,T b);
template<typename T> ll lcm(T a,T b);
int main(){
    vector<ll> x(3);
    map<ll,map<ll,map<ll,ll>>> m;
    vector<vector<ll>> v;
    rep(i,3){
        cin>>x[i];
    }
    ll k;cin>>k;
    vector<vector<ll>> a(3,vector<ll>(0,0));
    rep(j,3){
        rep(i,x[j]){
            ll num;cin>>num;
            a[j].push_back(num);
        }
        sort(all(a[j]),greater<ll>());
    }
    ll max=a[0][0]+a[1][0]+a[2][0];
    vector<ll> tv(3);
    tv[0]=tv[1]=tv[2]=0;
    v.pushb(tv);
    m[0][0][0]=1;
    cout<<max<<endl;
    rep(i,k-1){
        max=0;
        for(auto& y:v){
            rep(j,3){
                if(y[j]==x[j]-1)continue;
                y[j]++;
                // cout<<y<<endl;;
                if(m[y[0]][y[1]][y[2]]!=1){
                    ll sum=0;
                    sum+=a[0][y[0]];
                    sum+=a[1][y[1]];
                    sum+=a[2][y[2]];
                    if(max<sum){
                        max=sum;
                        tv[0]=y[0];
                        tv[1]=y[1];
                        tv[2]=y[2];
                    }
                }
                y[j]--;
            }
        }
        m[tv[0]][tv[1]][tv[2]]=1;
        v.push_back(tv);
        cout<<max<<endl;

    }

    return 0;
}

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

using std::cout;
using std::cin;
using std::endl;

int main() {
	long long n, k;
	cin >> n >> k;
	n %= k;
	for (;;)
	{
		long long i = std::abs(n - k);
		if (i < n)
		{
			n = i;
		}
		else
		{
			break;
		}
	}
	cout << n << endl;
}


Measured memory_bytes: 384
#include <iostream>
#include <cmath>
using namespace std;
#define EPS (1e-10)
#define equal(a,b) (fabs((a)-(b)) < EPS)

class Point{
public:
  double x,y;

  Point(double x = 0, double y = 0): x(x),y(y){}

  Point operator + (Point p){
    return Point( x+p.x , y+p.y );
  }
  Point operator - (Point p){
    return Point( x-p.x , y-p.y );
  }
  Point operator * (double a){
    return Point( a*x , a*y );
  }

  double abs(){
    return sqrt(norm());
  }
  double norm(){
    return x*x+y*y;
  }

  bool operator < (const Point &p)const{
    return x != p.x ? x < p.x : y < p.y;
  }

  bool operator == (const Point &p)const{
    return equal( x-p.x , y-p.y );
  }
};

typedef Point Vector;

double dot(Vector a,Vector b){
  return a.x*b.x + a.y*b.y;
}

double cross(Vector a,Vector b){
  return a.x*b.y - b.x*a.y;
}

static const int COUNTER_CLOCKWISE = 1;
static const int CLOCKWISE = -1;
static const int ONLINE_BACK = 2;
static const int ONLINE_FRONT = -2;
static const int ON_SEGMENT = 0;

int ccw( Point p0 , Point p1 , Point p2 ){
  Vector a = p1 - p0;
  Vector b = p2 - p0;
  if( cross(a,b) > EPS ) return COUNTER_CLOCKWISE;
  if( cross(a,b) < -EPS ) return CLOCKWISE;
  if( dot(a,b) < -EPS ) return ONLINE_BACK;
  if( a.norm() < b.norm() ) return ONLINE_FRONT;
  return ON_SEGMENT;
}

int main(){
  double x1,y1,x2,y2,x3,y3,xp,yp;

  while(cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> xp >> yp){
    int a = ccw(Point(x1,y1),Point(x2,y2),Point(xp,yp));
    int b = ccw(Point(x2,y2),Point(x3,y3),Point(xp,yp));
    int c = ccw(Point(x3,y3),Point(x1,y1),Point(xp,yp));

    if(a == b && b == c) cout << "YES" << endl;
    else cout << "NO" << endl;
  }  

  return 0;
}

Measured memory_bytes: 1216
#include <algorithm>
#include <iostream>
#include <queue>
using namespace std;
typedef long long ll;
typedef pair<ll, int> P;

int main()
{
    int n, k;
    cin >> n >> k;
    P p[100005];
    for(int i = 0; i < n; i++){
        int t;
        ll d;
        cin >> t >> d;
        t--;
        p[i] = P(d, t);
    }
    sort(p, p + n, greater<P>());
    bool b[100005]{0};
    priority_queue<ll, vector<ll>, greater<ll>> que;
    ll s = 0;
    ll c = 0;
    for(int i = 0; i < k; i++){
        if(b[p[i].second]){
            que.push(p[i].first);
        }
        else{
            b[p[i].second] = true;
            c++;
        }
        s += p[i].first;
    }
    ll ans = s + c * c;
    for(int i = k; i < n; i++){
        if(que.empty()) break;
        if(b[p[i].second]) continue;
        b[p[i].second] = true;
        s -= que.top();
        que.pop();
        s += p[i].first;
        c++;
        ans = max(ans, s + c * c);
    }
    cout << ans << endl;
}


Measured memory_bytes: 5488
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define _GLIBCXX_DEBUG
static const int MAX = 50;

int selectionSort(int A[], int N){
  int sw = 0, minj;

  rep(i, N - 1){
    minj = i;

    rep2(j, i, N){
      if (A[j] < A[minj])
        minj = j;
    }

    swap(A[i], A[minj]);
    if (i != minj)
      sw++;
  }

  return sw;
}

int main(){
  int N, p[MAX], sw;
  cin >> N;
  rep(i, N) cin >> p[i];
  
  sw = selectionSort(p, N);
  cout << (sw > 1 ? "NO" : "YES") << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
int main(){
	int a,b,k;
	scanf("%d%d%d",&a,&b,&k);
	for(int i=a;i<=min(a+k-1,b);i++)
		printf("%d\n",i);
	for(int i=max(a+k,b-k+1);i<=b;i++)
		printf("%d\n",i);
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef map<int, int> MPII;
typedef set<int> SETI;

int main()
{
    int N;
    cin >> N;
    bool ok = false;
    while (N > 0) {
        if (N % 10 == 7)
            ok = true;
        N /= 10;
    }
    cout << (ok ? "Yes" : "No");
}


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

using namespace std;

int main() {
    ios::sync_with_stdio(0) , cin.tie(0) , cout.tie(0);
    int n , k;
    cin >> n >> k;

    int p = (n - 1) * (n - 2) / 2;

    if (p < k) {
        cout << -1;
        return 0;
    }

    set<array<int , 2> > pairs;
    vector<array<int , 2> > edges;

    for (int i = 2 ;i < n ;i++)
        for (int j = i + 1 ;j <= n ;j++)
            pairs.insert({i , j});

    for (int i = 2 ;i <= n ;i++)
        edges.push_back({1 , i});

    while (p > k) {
        edges.push_back(*pairs.begin());
        pairs.erase(pairs.begin());
        p--;
    }

    cout << edges.size() << '\n';
    for (auto &e : edges)
        cout << e[0] << ' ' << e[1] << '\n';
}


Measured memory_bytes: 3756
function Scanner(input) {
	var self = this;
	self.itemNo = 0;
	self.orgStr = input;
	self.splitedStrs = (function(target) {
		var result = [];
		var target = target.replace(/[\n \t]+/g, " ");
		var strs = target.split(" ");
		for (var i = 0, len = strs.length; i < len; i++) {
			result.push(strs[i]);
		}
		return result;
	}(input));

	self.next = function() {
		var result = self.splitedStrs[self.itemNo];
		self.itemNo++;
		return (result != null) ? result : null;
	}

	self.nextInt = function() {
		var result = self.splitedStrs[self.itemNo];
		self.itemNo++;
		return (result != null) ? parseInt(result) : null;
	}

	self.nextBigDecimal = function() {
		var result = self.splitedStrs[self.itemNo];
		self.itemNo++;
		return (result != null) ? parseFloat(result) : null;
	}
	
	self.nextByte = function() {
		var result = self.splitedStrs[self.itemNo];
		self.itemNo++;
		return (result != null) ? new Int8Array(result) : null;
	}

}

function Main(sc) {

	var A = sc.nextInt();
	var B = sc.nextInt();
	
	console.log(A*B);
}
Main(new Scanner(require("fs").readFileSync("/dev/stdin", "utf8")));
// Main(new Scanner("10 1 2 5 3 4 6 7 3 2 4 1 2 2 3 3 4 4 5 3 6 6 7 1 8 8 9 9 10"));

// var str1 = sc.next(); // Stringで取得
// var int1 = sc.nextInt(); // intで取得
// var bd1 = sc.nextBigDecimal(); // BigDecimalで取得
// var byte1 = sc.nextByte(); // byteで取得
// for (var i = 0; i < 1000000000; i++) var toDelay = "aaa"; // 1000msくらいの遅延
// console.log(wrtnNos); return;


Measured memory_bytes: 29660
#include<iostream>
#include<iomanip>
#include<cmath>
#include<vector>
#include<map>
#include<string>
#include<algorithm>
using namespace std;
int main(){
  cout << setprecision(10);
  int N;
  cin >> N;
  double s = 0;
  for(int i=0; i<N; i++){
    int ai;
    cin >> ai;
    s += 1.0/ai;
  }
  cout << 1.0/s << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <limits.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <iostream>

using namespace std;

int main(void) {
	unsigned int N, A[200], i;
    cin >> N;
    for(i=0;i<N;i++) cin >> A[i];
    int n=0,a=1;
    while(1){
        for(i=0;i<N;i++){
            if (A[i]%2==1) {
                a=0;
                break;
            }
            else{
                A[i]=A[i]/2;
            }
        }
        if (!a) break;
        n++;
    }
    cout << n << endl;
	return 0;
}


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

int sum_digits(int x) {
  int ret = 0;
  while (x > 0) {
    ret += x % 10;
    x /= 10;
  }
  return ret;
}

int main(int argc, char *argv[]) {
  int N, A, B, ans = 0;
  scanf("%d %d %d", &N, &A, &B);
  for (int i = 1; i <= N; i++) {
    int sum = sum_digits(i);
    if (sum >= A && sum <= B)
      ans += i;
  }
  printf("%d\n", ans);
  return 0;
}


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

int main(){
  int count=0;
  int D,N;
  cin>>D>>N;
  if(D>8 or N>8){
    cout<<":(";
  }
  else{
    cout<<"Yay!";
  }
}


Measured memory_bytes: 256
#include <stdio.h>

int main(int argc, char** argv)
{
	int i, cnt, num1, num2, max, result[200];

	cnt = 0;
	memset(result, 0, sizeof(result));
	while (scanf("%d %d", &num1, &num2) != EOF) {
		int sum = num1 + num2;

		if (sum > 0) {
			result[cnt]++;

			int pos = 10;
			while (1) {
				int div = sum / pos;

				if (div > 0) {
					result[cnt]++;
					pos *= 10;
				}
				else {
					break;
				}
			}
		}
		cnt++;
	}
	max = cnt;

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

Measured memory_bytes: 600
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double dd;
const ll INF = 1e18L + 5;
void minself(ll &a, ll b)
{
		a = min(a, b); 
}
void solve()
{
		ll n, w;
		cin >> n >> w;
			vector <ll> weight(n), value(n);
			
		for(ll i = 0; i<n; i++)
		{
			cin >> weight[i] >> value[i];
		}	
		ll sum = 0;
		for(ll i : value)
			sum += i;
			
			vector <ll> dp(sum+1, INF);
			dp[0] = 0;
			
		for(ll i = 0; i<n; i++)
		{
			for(ll val = sum - value[i]; val >= 0; val--)
				minself(dp[val + value[i]], dp[val] + weight[i]);
			
		}
		
		ll ans = 0;
		for(ll i = 0; i<=sum; i++)
		{
			if(dp[i] <= w)
			ans = max(ans, (ll) i);
			
			//minself(ans, dp[i]); 
		}
			cout << ans; 
}

int main()
{
		ios::sync_with_stdio(false);
		cin.tie(nullptr);
		ll t = 1;
	//	cin >> t
		while(t--)
		{
			solve();
		}
	return 0;
}
	


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

using namespace std;
typedef long long ll;
#define sz(x) (ll)((x).size())
#define pb push_back
#define mp make_pair 
#define bg begin()
#define ed end()
#define all(x) (x).bg,(x).ed
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)

int main(){
	ll N; cin>>N;
    vector<ll>A(N);
    ll ans=0;
    rep(i,N) cin>>A[i];
    multiset<ll> C;
    C.insert(A[0]);

    rep1(i,N-1){
        auto it=C.lower_bound(A[i]);
        if(it==C.bg){
            C.insert(A[i]);
        }
        else{
            it--;
            C.erase(it);
            C.insert(A[i]);
        }
    }
    cout<<sz(C);
}

Measured memory_bytes: 5760
card_power = {'2':'1','3':'2','4':'3','5':'4','6':'5','7':'6','8':'7','9':'8','10':'9','11':'10','12':'11','13':'12',"1":'13'}
A,B = input().split()
if int(card_power[A]) == int(card_power[B]):
  print('Draw')
elif int(card_power[A]) > int(card_power[B]):
  print('Alice')
elif int(card_power[A]) < int(card_power[B]):
  print('Bob')


Measured memory_bytes: 3064
function Main(input){
    const len  = input.trim().length;
    const s = input.trim();
    const DFS = (i, string) => {
        if (i === len-1) return string.split('+').map(Number).reduce((a,b)=>a+b);
        return DFS(i+1, string+s[i+1]) + DFS(i+1, string+'+'+s[i+1]);
    }
    console.log(DFS(0, s[0]));
}
/**
 * イメージ(125の場合)
 * (0, 1) = (1,"12") + (1,"1+2")
 *   (1,"12") = (2, "125") + (2, "12+5") 
 *   (1,"1+2") = (2, "1+25") + (2,"1+2+5")
 *      (2, "125")  = 125
 *      (2, "12+5") = 17
 *      (2, "1+25") = 26
 *      (2,"1+2+5") = 8
 *  125 + 17 + 26 + 8 = 176
 * 
 *  if (すべての数値を確認) +を連結させた数値を足していく
 *  return  (今の数値 + 次の数値) + (今の数値 "+" 次の数値(+文字列))
 */
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 29732
#include "bits/stdc++.h"
using namespace std;

typedef long long int ll;

int main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int h, w, k;
	cin >> h >> w >> k;
	string c[h];
	for (int i = 0; i < h; i++)
		cin >> c[i];
	
	int ans = 0;
	for (int tutupR = 0; tutupR < (1 << h); tutupR++){
		for (int tutupC = 0; tutupC < (1 << w); tutupC++){
			int black = 0;
			// kalau 1 brrti ga dipilih, kalau 0 dipilih
			for (int i = 0; i < h; i++){
				for (int j = 0; j < w; j++){
					bool con1 = (tutupR >> i) & 1; // cek apakah bit di i dri blkg = 1
					bool con2 = (tutupC >> j) & 1; // cek apakah bit di j dri blkg = 1
					bool con3 = (c[i][j] == '#');
					if (con1 && con2 && con3) black++;
				}
			}
			if (black == k) ans++;
		}
	}
	cout << ans << '\n';
}

Measured memory_bytes: 3636
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>

#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define NDEBUG
#define eprintf(...) do {} while (0)
#endif
#include<cassert>

using namespace std;

typedef long long LL;
typedef vector<int> VI;

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

template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }
template<class Iter> void rprintf(const char *fmt, Iter begin, Iter end) {
    for (bool sp=0; begin!=end; ++begin) { if (sp) putchar(' '); else sp = true; printf(fmt, *begin); }
    putchar('\n');
}

template<class T> struct Fenwick {
    int n;
    T* d;
    Fenwick() : n(0), d(NULL) {}
    Fenwick(int n_) : n(n_) {
	d = new T[n_]();
    }
    Fenwick(const Fenwick &y) : n(y.n) {
	d = new T[n];
	memcpy(d, y.d, sizeof (T) * n);
    }
    ~Fenwick() {
	delete[] d; d = NULL;
	n = 0;
    }
    friend void swap(Fenwick &x, Fenwick &y) {
	swap(x.n, y.n); swap(x.d, y.d);
    }
    Fenwick& operator=(Fenwick y) {
	swap(*this, y);
	return *this;
    }
    inline void add(int i, const T &x) {
	for (; i<n; i|=i+1) d[i] += x;
    }
    inline T sum(int r) {
	T s = T();
	for (; r; r&=r-1) s += d[r-1];
	return s;
    }
    T sum(int l, int r) {
	return sum(r) - sum(l);
    }
};

int N;
int A[300011];

void MAIN() {
    scanf("%d", &N);
    REP (i, N) scanf("%d", A+i), A[i]--;

    bool yes = true;
    REP (i, N) if (A[i] % 2 != i % 2) {
	yes = false;
    }

    if (yes) {
	LL g[2] = {};
	REP (t, 2) {
	    Fenwick<int> F(N);
	    for (int i=t; i<N; i+=2) { 
		g[t] += F.sum(A[i], N);
		F.add(A[i], 1);
	    }
	}

	LL h = 0;
	REP (t, 2) {
	    Fenwick<int> F(N);
	    REP (i, N) {
		if ((i&1)==t) h += F.sum(A[i], N);
		else F.add(A[i], 1);
	    }
	}

	if ((g[0] + g[1]) * 2 != h) {
	    yes = false;
	}
    }
    puts(yes? "Yes": "No");
}

int main() {
    int TC = 1;
//    scanf("%d", &TC);
    REP (tc, TC) MAIN();
    return 0;
}



Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (long int i=a;i<n;i++)
#define per(i,a,n) for (long int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef vector<long long int> vi;
typedef long long int lli;
const lli mod=1000000007;
lli powmod(lli a,lli b) {lli res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
lli gcd(lli a,lli b) { return b?gcd(b,a%b):a;}
int main()
{
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    lli n,max11=0,max21=0,max12=0,max22=0,ind1=0,ind2=0;
    vi m1(100005,0),m2(100005,0);
    cin>>n;
    rep(i,0,n)
    {
        lli a;
        cin>>a;
        if(i&1)
        {
            m1[a]++;
            if(m1[a]>=max11)
            {
                if(ind1!=a)
                max12=max11;
                max11=m1[a];
                ind1=a;
            }
            else if(ind1!=a)
            {
                max12=max(max12,m1[a]);
            }
        }
        else
        {
            m2[a]++;
            if(m2[a]>=max21)
            {
                if(ind2!=a)
                max22=max21;
                max21=m2[a];
                ind2=a;
            }
            else if(ind2!=a)
                max22=max(max22,m2[a]);
        }
    }
    lli ans=0;
    if(ind1==ind2)
    {
        if(max12==0&&max22==0)
        {
            ans=n-max(max11,max21);
        }
        else if(max12==0)
        {
            ans=n-max11-max22;
        }
        else if(max22==0)
            ans=n-max21-max12;
        else
        {
            if(max11+max22>max21+max12)
                ans=n-max11-max22;
            else
                ans=n-max12-max21;

        }
    }
    else
        ans=n-max11-max21;
    cout<<ans<<endl;

}




Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define erep(i,a,b) for(int i=a;i<=(int)(b);++i)
#define per(i,a,b) for(int i=(b);i>(a);--i)
#define eper(i,a,b) for(int i=((int)(a));i>=b;--i)
#define pb push_back
#define mp make_pair
#define INF (1<<28)-1
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a, b)*b;}

int n, m;
int main() {
 ios::sync_with_stdio ( false );
 cin.tie ( 0 );
    cin >> n >> m;
    for (int x = 0; x <= 2000; x++) {
        for (int y = 0; y <= 2000; y++) {
            if (10000 * x + 5000 * y + 1000 * (n-x-y) == m && n - x - y >= 0) {
                printf("%d %d %d\n", x, y, n-x-y);
                return 0;
            }
        }
    }
    printf("-1 -1 -1\n");
    return 0;
}

Measured memory_bytes: 256
h,w = map(int,input().split())
l = [list(input()) for _ in range(h)]
n = [0,1,0,-1]
m = [1,0,-1,0]


def dfs(a,b):
  if 0<=a+n[0] and a+n[0]<=w-1 and 0<=b+m[0] and b+m[0]<=h-1 and 0<=a+n[1] and a+n[1]<=w-1 and 0<=b+m[1] and b+m[1]<=h-1:
    if l[b+m[0]][a+n[0]]=="#" and l[b+m[1]][a+n[1]]=="#":
      return print("Impossible")
  for i in range(4):
    if 0<=a+n[i] and a+n[i]<=w-1 and 0<=b+m[i] and b+m[i]<=h-1:
      if l[b+m[i]][a+n[i]]=="#":
        if i==2 or i==3:
          return print("Impossible")

        elif a+n[i]==w-1 and b+m[i]==h-1:
          cou = 0
          for i in l:
            for j in i:
              if j=="#":
                cou += 1
          if cou==2:
            return print("Possible")
          else:
            return print("Impossible")
        else:
          l[b+m[i]][a+n[i]] = "."
          #print(l)
          return dfs(a+n[i],b+m[i])
  else:
    return print("Impossible")
      
    
        
dfs(0,0)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int i,j,n,m,c,d,a,b;
string s;
int main(){
  cin>>a>>b;
  for(i=ceil(a/0.08);c<=b+1;i++){
    c=floor(i*0.1);
    if(floor(i*0.08)==a&&c==b)return cout<<i,0;
  }
  cout<<-1;
}

Measured memory_bytes: 256
count = 0
data = []
ans = []
while True:
    n, m = map(int, input().split())
    data.append([n,m])
    if data[count][0] == data[count][1] == 0:
        break
    count += 1
data.pop()
for i in data:
  count = 0
  for j in range(1, (i[0]+1)):
    for k in range(1, (i[0]+1)):
      for l in range(1, (i[0]+1)):
        if (j+k+l) == i[1] and j != k and j != l and k != l:
          count += 1
  ans.append(count)
for m in ans:
  print(m//6)


Measured memory_bytes: 5604
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef pair<P,int> T;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define LLINF 1000000000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repn(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define EQ(a,b) (abs((a)-(b))<eps)
template<class T> void chmin(T& a,const T& b){if(a>b)a=b;}
template<class T> void chmax(T& a,const T& b){if(a<b)a=b;}
ll N,X;
ll ans = 0;
void rec(ll a,ll b){
	//cout << a << ' ' << b << endl;
	if(a<b){
		rec(b,a);
		return;
	}
	if(a%b==0ll){
		ans += (2ll*(a/b)-1ll)*b;
		return;
	}
	ans += 2LL*(a/b)*b;
	rec(b,a%b);
}
int main(){
	cin >> N >> X;
	ans = N;
	rec(X,N-X);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int num = sc.nextInt();
        int[] series = new int[num];

        for (int i = 0; i < num; i++) {
            series[i] = sc.nextInt();
        }

        boolean isEven = isEven(series);
        int count = 0;
        while (isEven) {
            count++;

            for (int i = 0; i < num; i++) {
                series[i] /= 2;
            }
            isEven = isEven(series);
        }

        System.out.println(count);
    }

    private static boolean isEven(int[] series) {
        boolean isEven = true;
        for (int i = 0; i < series.length; i++) {
            if (series[i] % 2 != 0) {
                isEven = false;
                break;
            }
        }

        return isEven;
    }
}


Measured memory_bytes: 21972
fn c() {                                                                                                                     
    input! {                                                                                                                 
        h: usize,                                                                                                            
        w: usize,                                                                                                            
        k: u32,                                                                                                              
        c: [Chars; h]                                                                                                        
    }                                                                                                                        
                                                                                                                             
    let mut ans = 0;                                                                                                         
                                                                                                                             
    for y in 0..2_u32.pow(h as u32) {                                                                                        
        for x in 0..2_u32.pow(w as u32) {                                                                                    
            let mut count = 0;                                                                                               
            for j in 0..h {                                                                                                  
                for i in 0..w {                                                                                              
                    if (y >> j) & 1 != 0 {                                                                                   
                        continue;                                                                                            
                    }                                                                                                        
                    if (x >> i) & 1 != 0 {
                        continue;
                    }
                    if c[j as usize][i as usize] == '#' {
                        count += 1;
                    }
                }
            }
            if count == k {
                ans += 1;
            }
        }
    }
    println!("{}", ans);
}

use proconio::input;
use proconio::marker::Chars;

fn main() {
    c();
}

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

using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

int main() {

    ll n, m; cin >> n >> m;
    string s, t; cin >> s >> t;

    ll lcm = n * m / __gcd(n, m);

    map<ll, char> mp;

    ll cnt = 0;
    while (lcm / n * cnt + 1 <= lcm) {
        mp[lcm / n * cnt] = s[cnt];
        cnt++;
    }

    cnt = 0;
    while (lcm / m * cnt + 1 <= lcm) {
        if (!(mp.count(lcm / m * cnt) == 0 || mp.count(lcm / m * cnt) == 1 && mp[lcm / m * cnt] == t[cnt])) {
            cout << -1 << endl;
            return 0;
        }
        cnt++;
    }

    cout << lcm << endl;
}


Measured memory_bytes: 9492
MOD = 1_000_000_007

n, k = gets.split.map(&:to_i)
table = Array.new(k + 1, 0)
table[0] = 1
n.times do
  new_table = Array.new(k + 1, 0)
  (1..k).each do |i|
    new_table[i] = (table[i - 1] + table[i] * i) % MOD
  end
  table = new_table
end
p table.inject(:+) % MOD


Measured memory_bytes: 14680
import sys
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def dp2(ini, i, j): return [[ini]*i for i2 in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for i2 in range(j)] for i3 in range(k)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value

#with open('01.txt') as data:
    #lines = data.readlines()
    #N = int(lines[0].rstrip())
    #S = lines[1].rstrip()
'''
N = ii()
S = input()

w_cnt = 0
b_cnt = 0

for i in S:
    if i == '.':
        w_cnt += 1
    else:
        break

for i in S[::-1]:
    if i == '#':
        b_cnt += 1
    else:
        break

w = b = 0

for i in range(w_cnt, N - b_cnt):
    if S[i] == '#':
        b += 1
    else:
        w += 1

cnt = 0

for i in S:
    if i == '#':
        cnt += 1

#print(w_cnt, b_cnt, w, b)

print(min(w, b, cnt, N-cnt))
'''
N = ii()
S = input()

cnt = [0]*(N+1)
ans = N+1

for i in range(N):
    if S[i] == '.':
        cnt[i+1] += cnt[i] + 1
    else:
        cnt[i+1] += cnt[i]

for i in range(0, N+1):
    #print((i-cnt[i])+(cnt[N]-cnt[i]))
    ans = min(ans, (i-cnt[i])+(cnt[N]-cnt[i]))

print(ans)

Measured memory_bytes: 11492
import os
import sys

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7

N, M, K = list(map(int, sys.stdin.readline().split()))

ok = False
for n in range(N + 1):
    for m in range(M + 1):
        ok |= n * M + m * N - m * n * 2 == K
if ok:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 3064
#include<iostream>
#include<bitset>
#include<sstream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include<map>
#include<iomanip>
#include<stdio.h>

using namespace std;
long gcd(long x, long y){ if (x > y){ return gcd(y, x); } long r; while (y != 0) { r = x % y; x = y; y = r; } return x; }
long lcm(long x, long y){ return (x / gcd(x, y) * y); }

int main(void){

	long res = 0;
	long N, A, B; cin >> N >> A >> B;
	vector<long> X(N); for (int i = 0; i < N; i++) cin >> X[i];

	for (int i = 1; i < N; i++) res += min(A * (X[i] - X[i - 1]), B);

	cout << res << endl;
}

Measured memory_bytes: 1024