akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<utility>
#include<algorithm>
using namespace std;
int main(){
  int j=0;
  long n,k;
  pair<long,long> a[100000];
  scanf("%ld %ld",&n,&k);
  for(int i=0;i<n;i++)
    scanf("%ld %ld",&a[i].first,&a[i].second);
  sort(a,a+n);
  while(k>0){
    k-=a[j].second;
    j++;
  }
  printf("%ld\n",a[j-1].first);
}

Measured memory_bytes: 1664
import sys
input = sys.stdin.readline


def main():
    N = input().strip()
    hon = [2, 4, 5, 7, 9]
    pon = [0, 1, 6, 8]
    bon = [3]
    answer = int(N[len(N)-1])
    print("hon") if answer in hon else print(
        "pon") if answer in pon else print("bon")


if __name__ == '__main__':
    main()


Measured memory_bytes: 9184
N = int(input())
A = list(map(int, input().split()))

g = [1000, 0]

for i in range(1, N):
    if A[i] > A[i-1]:
        g[1] += g[0] // A[i-1] 
        g[0] %= A[i-1]
        g[0] += g[1] * A[i]
        g[1] = 0
    elif A[i] < A[i-1]:
        g[0] += g[1] * A[i-1]
        g[1] = g[0] // A[i]
        g[0] %= A[i]

print(g[0] + g[1] * A[-1])

Measured memory_bytes: 9220
def euclid(a, b):
    while b:
        a, b = b, a%b
    return a
  
K = int(input())

count=0
for i in range(1, K+1):
  for j in range(i, K+1):
    for k in range(j, K+1):
      if i == j and j == k:
        kake = 1
      elif i == j or j == k or i == k:
        kake = 3
      else:
        kake = 6
      count += euclid(euclid(i, j), k) * kake

print(count)

Measured memory_bytes: 68760
#include <iostream>
#include <algorithm>
#include <vector>
#include<string>
#include <set>
#include <map>
#include <queue>
#include <limits.h>
#include <bitset>
#include <cmath>

using namespace std;

#define rip(i, n, s) for (int i = (s);i < ( int )( n ); i++)
#define all(a) (a).begin(), (a).end()
typedef long long ll;

int main(){
    int n;
    cin >> n;
    map<ll, int> da;
    ll a;
    rip(i,n,0){
        cin >> a;
        if(da.count(a)){
            da[a]++;
        }
        else{
            da[a]=1;
        }
    }
    ll m,k;
    vector<pair<ll,int>> li;
    int co=0;
    for (auto i : da){
        if(i.second>1){
            li.push_back(i);
            co++;
        }
    }
    ll ans=0;
    if (li.size()){
    if(li.back().second>3){
        ans+=li.back().first*li.back().first;
    }
    else if(li.size()>1){
        ans=li.back().first*li[co-2].first;
    }
    }
    cout << ans << endl;
}

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

int main()
{
    int a[5], k;
    bool f=false;
    for(int i=0; i<5; i++) cin>>a[i];
    cin>>k;
    for(int i=0; i<5; i++)
        for(int j=0; j<5; j++)
            if(abs(a[i]-a[j])>k) f=true;

    cout<<(f?":(":"Yay!")<<endl;

    return 0;
}


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Azhan Khan
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastScanner in = new FastScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        AFrog1 solver = new AFrog1();
        solver.solve(1, in, out);
        out.close();
    }

    static class AFrog1 {
        public void solve(int testNumber, FastScanner in, PrintWriter out) {
            int n = in.nextInt();
            int[] arr = new int[n];
            for (int i = 0; i < n; i++) {
                arr[i] = in.nextInt();
            }

            int[] dp = new int[n];
            dp[0] = 0;
            dp[1] = Math.abs(arr[1] - arr[0]);
            for (int i = 2; i < n; i++) {
                int value1 = Math.abs(arr[i] - arr[i - 1]);
                int value2 = Math.abs(arr[i] - arr[i - 2]);
                dp[i] = Math.min(dp[i - 2] + value2, dp[i - 1] + value1);
            }

            out.print(dp[n - 1]);
        }

    }

    static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner(InputStream inputStream) {
            br = new BufferedReader(new InputStreamReader(inputStream));
        }

        public String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 32528
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
int N, Q, x;
int main() {
	while (cin >> N >> Q) {
		vector<int> c(N);
		for (int i = 0; i < N; i++) c[i] = i;
		while (Q--) {
			cin >> x;
			vector<int> a, b;
			for (int i = 0; i < N / 2; i++) b.push_back(c[i]);
			for (int i = N / 2; i < N; i++) a.push_back(c[i]);
			vector<int> f;
			while (a.size()) {
				if (a.size() >= x) {
					f.insert(f.end(), a.begin(), a.begin() + x);
					a.erase(a.begin(), a.begin() + x);
				}
				else {
					f.insert(f.end(), a.begin(), a.end());
					a.clear();
				}
				if (b.size() >= x) {
					f.insert(f.end(), b.begin(), b.begin() + x);
					b.erase(b.begin(), b.begin() + x);
				}
				else {
					f.insert(f.end(), b.begin(), b.end());
					b.clear();
				}
			}
			c = f;
		}
		cout << c.back() << endl;
	}
	return 0;
}

Measured memory_bytes: 3076
using System;
using System.Collections.Generic;
using System.Linq;
using static Input;

public class Prog
{
    private const int INF = 1000000007;
    public struct Pair<T> { public T x, y; public Pair(T x, T y) { this.x = x; this.y = y; } }
    public static void Solve()
    {
        int N = NextInt();
        List<Tuple<int, int>> d = Enumerable.Range(0, N).Select(v => new Tuple<int, int>(NextInt(), NextInt())).ToList();
        var sorted = d.OrderBy(x => x.Item2).ToList();

        //なるべく詰めて行う
        int time = 0;
        foreach (var e in sorted)
        {
            //現在時刻+残りの時刻
            time += e.Item1;
            if (e.Item2 < time) {
                Console.WriteLine("No");
                return;
            }
        }
        Console.WriteLine("Yes");
    }
    public static void Main()
    {
        var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
        Console.SetOut(sw);
        Solve();
        Console.Out.Flush();
    }
}
public class Input
{
    private static Queue<string> q = new Queue<string>();
    private static void Confirm() { if (q.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) q.Enqueue(s); }
    public static int NextInt() { Confirm(); return int.Parse(q.Dequeue()); }
    public static long NextLong() { Confirm(); return long.Parse(q.Dequeue()); }
    public static char NextChar() { Confirm(); return char.Parse(q.Dequeue()); }
    public static string NextString() { Confirm(); return q.Dequeue(); }
    public static double NextDouble() { Confirm(); return double.Parse(q.Dequeue()); }
    public static int[] LineInt() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
    public static long[] LineLong() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
    public static string[] LineString() { return Console.ReadLine().Split(' ').ToArray(); }
    public static double[] LineDouble() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
}


Measured memory_bytes: 34724
#!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.buffer.readline().split()]
def I(): return int(sys.stdin.buffer.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI()+[i] for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    def root(x):
        if par[x] == x:
            return x
        par[x] = root(par[x])
        return par[x]

    def unite(x,y):
        x = root(x)
        y = root(y)
        if rank[x] < rank[y]:
            par[x] = y
        else:
            par[y] = x
            if rank[x] == rank[y]:
                rank[x] += 1


    n = I()
    p = LIR(n)
    p.sort()
    par = list(range(n))
    rank = [0]*n
    q = []
    q2 = []
    for x,y,i in p:
        f = 0
        while q:
            yy,j = heappop(q)
            if y < yy:
                heappush(q,(yy,j))
                break
            f = 1
            unite(i,j)
            q2.append((yy,j))
        while q2:
            yy,j = q2.pop()
            heappush(q,(yy,j))
        if not f:
            heappush(q,(y,i))
    s = [0]*(n+1)
    for _,_,i in p:
        s[root(i)] += 1
    ans = [None]*n
    for _,_,i in p:
        ans[i] = s[root(i)]
    for i in ans:
        print(i)
    return

#Solve
if __name__ == "__main__":
    solve()


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

int main()
{
  ll n, m; cin>>n>>m;
  vector<vector<ll>> dp(n+1, vector<ll>(m+1, 0));
  vector<ll> v(n, 0);
  vector<ll> w(n, 0);
  rep(i, n) cin>>v[i]>>w[i];

  rep(i, n) for(int j=0; j<=m; j++) {
    dp[i+1][j] = dp[i][j];
    if (j >= w[i]) dp[i+1][j] = max(dp[i+1][j], dp[i][j-w[i]]+v[i]);
  }
  cout << dp[n][m] << endl;

  return 0;
}



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

using namespace std;

const int N = 100005;
int a[N];

int main()
{
  int n;
  scanf("%d", &n);
  
  long long res = 0;
  int cnt = 0;
  
  for (int i = 0; i < n; ++i) {
    scanf("%d", a + i);
    res += a[i] / 2;
    cnt += a[i] % 2;
    if (a[i] == 0) {
      res += cnt / 2;
      cnt = 0;
    }
  }
  
  res += cnt / 2;
  
  printf("%lld\n", res);
  return(0);
}

Measured memory_bytes: 640
#include <algorithm>
#include <iostream>
#include <limits.h>
#include <math.h>
#include <set>
#include <stack>
#include <stdlib.h>
#include <string>
#include <vector>

#define el endl
#define fd fixed
#define INF INT_MAX/2-1
#define pb push_back

using namespace std;

#define MAX 1000000

void makelist(int *list, int x) {
  for (int i = x; i < MAX; i++) {
    list[i] = min(list[i], list[i-x]+1);
  }
}

int main() {
  int list1[MAX], list2[MAX], x, n;
  for (int i = 1; i < MAX; i++) {
    list1[i] = list2[i] = INF;
  }
  for (int i = 1; ; i++) {
    x = i*(i+1)*(i+2)/6;
    if (x >= MAX) break;
    makelist(list1, x);
    if (x & 1) makelist(list2, x);
  }
  while (cin >> n, n) {
    cout << list1[n] << " " << list2[n] << el;
  }
}

Measured memory_bytes: 8972
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()

class LazySegmentTree(object):
    def __init__(self, A, dot, unit, compose, identity, act):
        """
        (M, dot, unit) : monoid
        (S, compose, identitiy) : sub monoid of End(M)
        A : array of M
        compose : (f, g) -> fg (f, g in S)
        act : (f, x) -> f(x) (f in S, x in M)
        """
        logn = (len(A) - 1).bit_length()
        n = 1 << logn
        tree = [unit] * (2 * n)
        for i, v in enumerate(A):
            tree[i + n] = v
        for i in range(n - 1, 0, -1):
            tree[i] = dot(tree[i << 1], tree[i << 1 | 1])
        self._n = n
        self._logn = logn
        self._tree = tree
        self._lazy = [identity] * (2 * n)
        self._dot = dot
        self._unit = unit
        self._compose = compose
        self._identity = identity
        self._act = act

    def _fix_ancestors(self, i):
        tree, lazy, dot, act = self._tree, self._lazy, self._dot, self._act
        while i > 1:
            i >>= 1
            tree[i] = act(lazy[i], dot(tree[i << 1], tree[i << 1 | 1]))

    def _propagate(self, i):
        tree, lazy, identity, compose, act = self._tree, self._lazy, self._identity, self._compose, self._act
        for k in range(self._logn, 0, -1):
            p = i >> k
            f = lazy[p]
            tree[p << 1], lazy[p << 1] = act(f, tree[p << 1]), compose(f, lazy[p << 1])
            tree[p << 1 | 1], lazy[p << 1 | 1] = act(f, tree[p << 1 | 1]), compose(f, lazy[p << 1 | 1])
            lazy[p] = identity

    def range_act(self, l, r, f):
        l += self._n
        r += self._n
        # propagation isn't needed if S is commutative
        self._propagate(l)
        self._propagate(r - 1)
        l0, r0 = l, r
        tree, lazy, act, compose = self._tree, self._lazy, self._act, self._compose
        while l < r:
            if l & 1:
                tree[l], lazy[l] = act(f, tree[l]), compose(f, lazy[l])
                l += 1
            if r & 1:
                r -= 1
                tree[r], lazy[r] = act(f, tree[r]), compose(f, lazy[r])
            l >>= 1
            r >>= 1
        self._fix_ancestors(l0)
        self._fix_ancestors(r0 - 1)

    def sum(self, l, r):
        l += self._n
        r += self._n
        self._propagate(l)
        self._propagate(r)
        l_val = r_val = self._unit
        tree, dot = self._tree, self._dot
        while l < r:
            if l & 1:
                l_val = dot(l_val, tree[l])
                l += 1
            if r & 1:
                r -= 1
                r_val = dot(tree[r], r_val)
            l >>= 1
            r >>= 1
        return dot(l_val, r_val)

def resolve():
    n,m=map(int,input().split())
    R=[[] for _ in range(n)]
    for _ in range(m):
        l,r,a=map(int,input().split())
        l-=1; r-=1
        R[r].append((l,a))
    from operator import add
    dp=LazySegmentTree([0]*n,max,0,add,0,add)
    for r in range(n):
        dp.range_act(r,r+1,dp.sum(0,r))
        for l,a in R[r]:
            dp.range_act(l,r+1,a)
    print(dp.sum(0,n))
resolve()

Measured memory_bytes: 113612
#include<iostream>

using namespace std;

int main() {
	int n,now;
	int before1=1, before2=1;
	cin >> n;
	if (n <= 1) {
		cout << 1<<endl;
		return 0;
	}
	for (int i = 2;i <= n;) {
		now = before1 + before2;
		before2 = before1;
		before1 = now;
		i++;
	}
	cout << now<<endl;
}


Measured memory_bytes: 3104
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace B
{
    public class Program
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var nx = Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();
            var n = nx[0];
            var x = nx[1];
            var min = x;
            for (var i = 0; i < n; i++)
            {
                var m = int.Parse(Console.ReadLine());
                x -= m;
                min = Math.Min(min, m);
            }
            Console.WriteLine(n + x / min);
        }
    }
}


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

int main(){

    int N,K;
    cin >> N >> K;
    vector<int64_t> H(N);
    for (int i = 0; i < N; i++) {
        cin >> H.at(i);
    }

    int64_t ans = 0;
    if(N > K){
        sort(H.begin(), H.end(), greater<int>());
        for(int i=K;i<N;i++){
            ans += H.at(i);
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 1792
import sys
input = sys.stdin.readline

n = int(input())
t = 0
x = 0
y = 0
judge = True

l = [list(map(int, input().split())) for _ in range(n)]

for t1, x1, y1 in l:
    if (abs(x1 - x) + abs(y1 - y))/(t1 - t) > 1 or (abs(x1 - x) + abs(y1 - y))%2 != (t1 - t)%2:
        print("No")
        exit()
    x = x1
    y = y1
    t = t1

print("Yes")

Measured memory_bytes: 27380
import java.util.Scanner;

public class Main{
  public static void main(String[] args){

Scanner sc = new Scanner(System.in);

while(true){

  int h = sc.nextInt();
  int w = sc.nextInt();

  if( h ==0 && w ==0 )break;


for(int i = 0;i < h; i++ ){
  for(int p = 0; p<w; p++){

if(i%2 ==0){
    if( p%2 == 0){
       System.out.print("#");
     }
    else{
     System.out.print(".");
   }
} else{
  if(p%2 ==1){
    System.out.print("#");
  }else {
    System.out.print(".");
  }

}


  }
System.out.println("");

}
System.out.println("");


}//while
  }//main


}//chess



Measured memory_bytes: 35288
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <math.h>
#include <tuple>

//#include <set>
//#include <unordered_map>
#include <stack>

using namespace std;

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

#define max_n 100

int N;
int TN[15];
vector<pair<int, int>> A[15];
stack<int> As[15];

int main() {

	int K, X;
	cin >> K >> X;

	if (K * 500 >= X)cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define E "\n"

using namespace std;
const long long MOD = (long long)1e9 + 7;

int h, n, a[1009], b[1009], dp[1001][20002];

int main()
{
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> h >> n;
	for (int i = 1; i <= n; i++) {
		cin >> a[i] >> b[i];
	}
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= 20000; j++) {
			dp[i][j] = 1e9;
		}
	}
	for (int j = 1; j <= 20000; j++) {
		if (j % a[1] == 0) {
			dp[1][j] = (j / a[1]) * b[1];
		}
	}
	for (int i = 2; i <= n; i++) {
		for (int j = 1; j <= 20000; j++) {
			if (j >= a[i])
				dp[i][j] = min(dp[i - 1][j], dp[i][j - a[i]] + b[i]);
			else
				dp[i][j] = dp[i - 1][j];
		}
	}
	int ans = 1e9;
	for (int i = 1; i <= n; i++) {
		for (int j = h; j <= 20000; j++) {
			ans = min(ans, dp[i][j]);
		}
	}
	cout << ans << E;
	//system("pause");
	return 0;
}

Measured memory_bytes: 78464
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
using namespace std;

int N;
vector<int> V;

int main(void){
    // Your code here!
    cin >> N;
    int a;
    for(int i = 0; i < N; i++) {
        cin >> a;
        V.push_back(a);
    }
    sort(V.begin(), V.end());
    
    int sum = 0;
    for(int i = 0; i < V.size(); i++) sum+=abs(V[i]);
    if(V.front() > 0) sum -= 2*V.front();
    if(V.back() < 0) sum += 2 * V.back();
    
    cout << sum << endl;
    
    int f = V.front();
    for(int i = 1; i < N-1; i++){
        if(V[i] >= 0){
            cout << f << " " << V[i] << endl;
            f -= V[i];
        }
    }
    
    cout << V.back() << " " << f << endl;
    f = V.back() - f;
    
    for(int i = 1; i < N-1; i++){
        if(V[i] < 0){
            cout << f << " " << V[i] << endl;
            f -= V[i];
        }
    }
    
    
}


Measured memory_bytes: 2424
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<int, int> P;


int main() {
  // #ifndef ONLINE_JUDGE
  // freopen("input", "r", stdin);
   vector<int> v(6);
   cin>>v[0]>>v[1]>>v[2];
   int ans=0;
   while(1)
  {
    if(v[0]%2==1||v[1]%2==1||v[2]%2==1)break;
    v[0]/=2;v[1]/=2;v[2]/=2;
    v[3]=v[1]+v[2];v[4]=v[0]+v[2];v[5]=v[0]+v[1];
    v[0]=v[3];v[1]=v[4];v[2]=v[5];
    ans++;
    if(ans>=10000){cout<<-1<<endl;return 0;}
  }
  cout<<ans<<endl;
   return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<vector>
#include<string>
#include<bitset>
#include<queue>
#include<set>
#include<map>
using namespace std;
 
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define ROF(i,b,a) for (int i=(b);i>(a);--i)
#define REP(i,n) FOR(i,0,n)
#define PER(i,n) ROF(i,n-1,-1)
 
typedef int i32;
typedef long long int i64;
typedef unsigned long long int ui64;
typedef float f32;
typedef double f64;
typedef long double f128;
typedef pair<int,int> Pi;
 
constexpr int INF = 1e9 + 7;
constexpr int dx[4] = {1,0,-1,0}, dy[4] = {0,1,0,-1};
 
int main() {
   int N; cin>>N;
   i64 cnt[5]; REP(i,5) cnt[i]=0;
   string S;
   char march[5] = {'M','A','R','C','H'};
   REP(i,N) {
       cin>>S;
       REP(i,5) if (S[0]==march[i]) cnt[i]++;
   }
   i64 ans = 0;
   ans = cnt[0]*cnt[1]*cnt[2] + cnt[0]*cnt[1]*cnt[3] + cnt[0]*cnt[1]*cnt[4] + cnt[0]*cnt[2]*cnt[3] + cnt[0]*cnt[2]*cnt[4] + cnt[0]*cnt[3]*cnt[4] + cnt[1]*cnt[2]*cnt[3]
   + cnt[1]*cnt[2]*cnt[4] + cnt[1]*cnt[3]*cnt[4] + cnt[2]*cnt[3]*cnt[4];  
   cout<<ans<<endl;
}

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

int main(){
	double tmp,maxa,mina,dif,flag = 1;
	while(cin>>tmp){
		if(flag){
			flag = 0;
			maxa = mina = tmp;
		}
		else{
			maxa = max(tmp,maxa);
			mina = min(tmp,mina);
		}
	}
		dif = maxa - mina;
		printf("%.2f",dif);
	return 0;
}

Measured memory_bytes: 1236
#include <iostream>
#include <bits/stdc++.h>
#include <math.h>
#include <stdio.h>
#include <algorithm>
using namespace std;
#define rep(i,n) for(int i = 0; i < n;i++)
#define ll long long

int main(){
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  int s=c-a,t=d-b;
  cout<<c-t<<' '<<d+s<<' '<<a-t<<' '<<b+s<<endl;
}

    

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector<char> vc;
typedef queue<ll> ql;
typedef deque<ll> dql;
typedef priority_queue<ll/*, vl, greater<ll>*/> pql; //降順(/*昇順*/)
typedef set<ll> sl;
typedef pair<ll, ll> pl;
typedef pair<pl, ll> ppl;
typedef vector<vl> vvl;
typedef vector<pl> vpl;
#define rep(i, n) for(ll i = 0; i < ll(n); i++)
#define rep2(i, k, n) for(ll i = ll(k); i <= ll(n); i++)
#define rep3(i, n, k) for(ll i = ll(n); i >= ll(k); i--)
#define all(v) (v).begin(), (v).end()
ll mod(ll a, ll b) {if(b == 0) return 0; return (a % b + b) % b;}
bool chmin(ll &a, ll b) {if(b < a) {a = b; return 1;} return 0;}
bool chmax(ll &a, ll b) {if(b > a) {a = b; return 1;} return 0;}
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;
const ll MAX = 1e9;
const char newl = '\n';

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

  string s;
  cin >> s;
  
  ll ans=0;
  rep(i, s.size()-1) if(s[i] != s[i+1]) ans++;
  cout << ans << newl;
  return 0;
}

Measured memory_bytes: 3688
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main() {
  string S;
  cin >> S;
  for (int i = 0; i < (int)S.size(); ++i) cout << "x";
  cout << endl;
  return 0;
}


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

int main(){
	int ans=0;
	string s;
	cin>>s;
	if(s[0]=='1') ans++;
	if(s[1]=='1') ans++;
	if(s[2]=='1') ans++;
	cout<<ans<<endl;
	return 0;
}

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

int main(){
  int H,W;
  while(1){
    cin >> H >> W;
    if(H==0&&W==0)break;
    for(int i = 0; i < H; i++){
      for(int j = 0; j < W; j++){
        if( (i%2==0 && j%2==0) || (i%2==1 && j%2==1) ){
          cout << "#";
        }else{
          cout << ".";
        }
      }
      cout << endl;
    }
    cout << endl;
  }
  return 0;
}

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

using namespace std;

string x;
int oper[3] = {0};
int flag = 0;

void compute (int it) {
	if (flag) return ;
	if (it == 3) {
		int sum = (x[0] - '0');
		for (int i = 0; i < 3; i++) {
			if (oper[i] == 0) 
				sum += (x[i + 1] - '0');
			else sum -= (x[i + 1] - '0');
		}
		if (sum == 7) 
			flag = 1;
		return ;
	}
	oper[it] = 0;
	compute (it + 1);
	if (flag)
		return ;
	oper[it] = 1;
	compute (it + 1);
}

int main() {
	cin >> x;
	compute(0);
	string ans = "";
	ans += x[0];
	for (int i = 0; i < 3; i++) {
		if (oper[i] == 0)
			ans += '+';
		else ans += '-';
		ans += x[i + 1];
	}
	ans += "=7";
	cout << ans << endl;
	return 0;
} 

Measured memory_bytes: 256
# Initializing variables
monsterCount, specialAttacks = map(int, input().split())
monsters = sorted(list(map(int, input().split())), reverse=True)
# NOTE: The sorted() function is in an ascending order in default. Now it's reversed.

# Calculating and judging the minimal number of attacks fennec needs to win.
if len(monsters) <= specialAttacks:
    print(0)
else:
    EntireMonsters = sum(monsters)
    destroyed = sum(monsters[:specialAttacks])
    print(EntireMonsters - destroyed)





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

int n;
int memo[35];

int solve(int n){
  if(memo[n] != -1)return memo[n];
  int rec = 0;
  if(n == 0 || n == 1)return memo[n] = 1;
  else if(n == 2)return memo[n] = 2;
  for(int i = 1;i <= 3;i++){
    rec += solve(n - i);
  }
  return memo[n] = rec;
}

int main(){
  while(cin >> n , n){
    memset(memo,-1,sizeof(memo));
    int ans = solve(n);
    cout << (ans - 1) / 3650 +1 <<endl;
  }
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i < (n + 1); ++i)
using namespace std;
using ll = long long;
const int INF = +100100100;
// typedef pair<int,int> P;
const int MAX = 1000000;
const ll MO = 1000000007;

ll pow(ll x, ll n, ll M){
    ll res = 1;
    if(n>0){
        res = pow(x,n/2,M);
        if(n%2==0)res=(res*res)%M;
        else res = (((res*res)%M)*x)%M;
    }
    return res;
}

int main(){
    int n,m;
    cin >> m >> n;
    // printf("%15d\n",rel);
    cout << pow(m,n, MO) << endl;
    return 0;
}


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

using namespace std;

#define int long long

using ll = long long;
using pii =  pair<int, int>;

const int IINF =  0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;
const int INF = sizeof(int) == sizeof(long long) ? LINF : IINF;
const ll MOD = 1e9+7;

#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_(i,0,n)
#define rrep(i,n) rfor_(i,0,n)

#define pb push_back
//#define eb emplace_back
#define mp make_pair
#define ft first
#define sd second

#define all(a) (a).begin(), (a).end()
#define sz(a) (int)(a).size()
#define rev(a) reverse(all(a))

#define endl '\n'

const int limit = 100007;

int N, K;
int x[104];
int s;

signed main(){
  cin.tie(0);
  cout.tie(0);
  ios_base::sync_with_stdio(false);
  
  cin>>N>>K;
  rep(i, N)cin>>x[i];
  
  rep(i, N) {
    s += min(x[i], K-x[i]);
  }
  
  cout<<2*s<<endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(n) begin(n), end(n)
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template <typename T, typename... Ts>
auto make_v(size_t a, Ts... ts)
{
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }

template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v)
{
    for (auto &e : t)
        fill_v(e, v);
}
vint ans;
int pts = 0,idx=0;
vint c;
vvint graph;
void dfs(int cur = 0,int prev = -1)
{
    ans[cur] = c[idx++];
    for (auto &&i : graph[cur])
    {
        if(i != prev)
        {
            dfs(i,cur);
        }
    }
    
    
}
int main()
{
    int N;
    cin>>N;
    graph.resize(N);
    int a,b;
    for (size_t i = 0; i < N-1; i++)
    {
        cin>>a>>b;
        a--;b--;
        graph[a].push_back(b);
        graph[b].push_back(a);
    }
    c.resize(N);
    for (size_t i = 0; i < N; i++)
    {
        cin>>c[i];
    }
    sort(all(c),greater<int>());
    ans.resize(N);
    dfs();
    cout<<accumulate(all(c),0LL) - c[0]<<endl;
    for (auto &&i : ans)
    {
        cout<<i<<" ";
    }
    
    return 0;
}


Measured memory_bytes: 4496
from collections import Counter

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

n,p=map(int,input().split())
c=Counter(prime_factorize(p)).most_common()
ans=1
for i in range(len(c)):
    if c[i][1]>=n:
        tmp=c[i][1]//n
        ans*=c[i][0]**tmp
print(ans)


Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
#define int long long
int MAX=1000000007;



signed main() {
    int n,a,b;
    cin>>n;
    pair<int,int> k[n];
    for(int i=0;i<n;i++){
        cin>>a>>b;
        k[i] =make_pair(b,a);
    }
    sort(k,k+n);
    int u=0,p=0;
    for(int i=0;i<n;i++){
        p+=k[i].second;
        if(p>k[i].first){
            u=1;
            break;
        }
    }
    if(u==1)cout<<"No";
    else cout<<"Yes";
    return 0;


}


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

int main() {
  int N, l[1000], r[1000], ans = 0;
  cin >> N;
  for(int i = 0; i < N; i++) {
    cin >> l[i] >> r[i];
    ans += r[i] - l[i] + 1;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,o,n) for(long long i = o;i<n;i++)
#define oneforall ios::sync_with_stdio(false);cin.tie(0);
#define all(v) (v).begin(),(v).end()
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) long long __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
#define int long long 
const long long inf=1e18;
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
typedef vector<int> vi;
typedef vector<long long> vl;
typedef long long ll;
typedef vector<pair<long, long > > vpll;
typedef vector<pair<int, int > > vpii;
#define FORR(x,arr) for(auto& x:arr)
#define ZERO(a) memset(a,0,sizeof(a))





//3111111111111111111111111111111
	


	void solve(){


		ini(n);
		ini(k);
		int morty[10];
		ZERO(morty);
		FOR(i,0,k){
			ini(x);
			morty[x] = 1;
		}
		FOR(i,n,100000){
			string tmp = to_string(i);
			int one = 1;
			FOR(i1,0,tmp.size()){
				if(morty[tmp[i1]-'0'])one = 0;
			}
			if(one)return out(i);
		}
		






	}























int32_t main() {
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall 
	oneforall

	solve();
	


	return 0;
}


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


int main()
{
  int n,t[100100],x[100100],y[100100];
  cin >> n;
  t[0] = 0;
  x[0] = 0;
  y[0] = 0;
  int tt = t[0];
  int j = 0;
  bool flag = false;
  for(int i = 1;i <= n;i++){
    cin >> t[i] >> x[i] >> y[i];
  }
  for(int i = 1;i <= n;i++){
    if((abs((x[i] - x[j])) + abs((y[i] - y[j])))> (t[i] - tt)){
      flag = false;
      break;
    }
    if((abs((x[i] - x[j])) + abs((y[i] - y[j])))%2 == (t[i] - tt)%2){
      flag = true;
    } else{
      flag = false;
      break;
    }
    j++;
    tt = t[i];
  }
  if(flag) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 1408
#include<iostream>
#include<string>
#include<algorithm>
#include<math.h>
#include<queue>
#include<set>
#include<map>

using namespace std;


int M, N;
int main() {
	while (cin >> M, M)
	{
		int sx[200], sy[200], skyx[1000], skyy[1000];
		set<pair<int, int>> ex;

		for (int i = 0; i < M; i++) {
			cin >> sx[i] >> sy[i];
		}

		cin >> N;
		for (int i = 0; i < N; i++) {
			cin >> skyx[i] >> skyy[i];

			ex.insert(make_pair(skyx[i], skyy[i]));
		}

		for (int i = 0; i < N; i++) {
			int dx = skyx[i] - sx[0];
			int dy = skyy[i] - sy[0];

			bool ok = false;
			for (int j = 0; j < M; j++) {
				if (ex.count(make_pair(sx[j] + dx, sy[j] + dy)) == 1) continue;

				ok = true;
				break;
			}

			if (ok) continue;

			cout << dx << " " << dy << endl;
		}
	}


	return 0;
}



Measured memory_bytes: 3144
def solve(N, M, ABs):
    ABs = sorted(ABs)
    ans = 0
    for a, b in ABs:
        if b < M:
            ans += a * b
            M -= b
        else:
            ans += M * a
            break
    return ans


if __name__ == "__main__":
    N, M = tuple(map(int, input().split(" ")))
    ABs = [tuple(map(int, input().split(" "))) for __ in range(N)]
    print(solve(N, M, ABs))


Measured memory_bytes: 17760
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

sum = 0
bf = -1

for i in A:
    sum += B[i-1]

    if i == bf + 1:
        sum += C[i-2]

    bf = i

print(sum)


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

#define si(a) scanf("%d",&a)
#define sl(a) scanf("%lld",&a)
#define sd(a) scanf("%lf",&a)
#define sc(a) scahf("%c",&a);
#define ss(a) scanf("%s",a)
#define pi(a) printf("%d\n",a)
#define pl(a) printf("%lld\n",a)
#define pc(a) putchar(a)
#define ms(a) memset(a,0,sizeof(a))
#define repi(i, a, b) for(register int i=a;i<=b;++i)
#define repd(i, a, b) for(register int i=a;i>=b;--i)
#define reps(s) for(register int i=head[s];i;i=Next[i])
#define ll long long
#define ull unsigned long long
#define vi vector<int>
#define pii pair<int,int>
#define mii unordered_map<int,int>
#define msi unordered_map<string,int>
#define lowbit(x) ((x)&(-(x)))
#define ce(i, r) i==r?'\n':' '
#define pb push_back
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define INF 0x3f3f3f3f
#define pr(x) cout<<#x<<": "<<x<<endl
using namespace std;

inline int qr() {
    int f = 0, fu = 1;
    char c = getchar();
    while (c < '0' || c > '9') {
        if (c == '-')fu = -1;
        c = getchar();
    }
    while (c >= '0' && c <= '9') {
        f = (f << 3) + (f << 1) + c - 48;
        c = getchar();
    }
    return f * fu;
}

int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const int N = 1e3 + 10, M = 1e6 + 10;
char a[N][N];
int d[N][N];
int n, m, sx, sy, tx, ty;

inline bool check(int x, int y) {
    return x >= 1 && x <= n && y >= 1 && y <= m && a[x][y] != '#';
}

inline int bfs() {
    priority_queue<pair<int,pii>>q;
    q.push({0,{sx, sy}}), d[sx][sy] = 0;
    while (!q.empty()) {
        pii t = q.top().se;
        q.pop();
        repi(i, 0, 3) {
            int nx = t.fi + dx[i], ny = t.se + dy[i];
            if (check(nx, ny) && d[nx][ny] > d[t.fi][t.se])
                d[nx][ny] = d[t.fi][t.se], q.push({-d[t.fi][t.se],{nx, ny}});
        }
        repi(i, max(1, t.fi - 2), min(n, t.fi + 2))repi(j, max(1, max(1, t.se - 2)), min(m, t.se + 2))if (
                        a[i][j] != '#' && d[i][j] > d[t.fi][t.se] + 1)
                    d[i][j] = d[t.fi][t.se] + 1, q.push({-d[i][j],{i, j}});
    }
    return d[tx][ty] == INF ? -1 : d[tx][ty];
}

int main() {
    n = qr(), m = qr();
    sx = qr(), sy = qr();
    tx = qr(), ty = qr();
    memset(d, 0x3f, sizeof(d));
    repi(i, 1, n)ss(a[i] + 1);
    pi(bfs());
    return 0;
}

Measured memory_bytes: 8880
def main():
    N, M, X, Y = map(int, input().split())
    x = list(map(int, input().split()))
    y = list(map(int, input().split()))

    xx = max(x)
    yy = min(y)

    if max(xx, X) < min(yy, Y):
        print("No War")
    else:
        print("War")


main()


Measured memory_bytes: 3060
/// {{{ Author: Wang, Yen-Jen
// include
#include <bits/stdc++.h>

// using
using namespace std;

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

// macro
#define SZ(x) ((int)x.size())
#define ALL(x) (x).begin() , (x).end()
#define REP(i , n) for(int i = 0; i < int(n); i++)
#define REP1(i , a , b) for(int i = a; i <= int(b); i++)
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define LC o<<1 , l , m
#define RC o<<1|1 , m + 1 , r
#define MS(x , v) memset(x , (v) , sizeof(x))

// input
inline bool SR(int &x) {
  return scanf("%d",&x) == 1;
}

inline bool SR(ll &x) {
  return scanf("%lld",&x) == 1;
}

inline bool SR(double &x) {
  return scanf("%lf",&x) == 1;
}

inline bool SR(char *s) {
  return scanf("%s",s) == 1;
}

inline bool RI() {
  return true;
}

template<typename I , typename... T> inline bool RI(I &x , T&... tail) {
  return SR(x) && RI(tail...);
}

// output
inline void SP(const int x) {
  printf("%d",x);
}

inline void SP(const ll x) {
  printf("%lld",x);
}

inline void SP(const double x) {
  printf("%.16lf",x);
}

inline void SP(const char *s) {
  printf("%s",s);
}

inline void PL() {
  puts("");
}

template<typename I , typename... T> inline void PL(const I x , const T... tail) {
  SP(x);
  if(sizeof...(tail)) putchar(' ');
  PL(tail...);
}

// debug
#define WangYenJen

#ifdef WangYenJen
template<typename I> void _DOING(const char *s , I&& x) {
  cerr << s << " = " << x << endl;
}

template<typename I , typename... T> void _DOING(const char *s , I&& x , T&&... tail) {
  int c = 0;
  while(*s != ',' || c != 0) {
    if(*s == '(' || *s == '[' || *s == '{') c++;
    if(*s == ')' || *s == ']' || *s == '}') c--;
    cerr << *s++;
  }
  cerr << " = " << x << " , ";
  _DOING(s + 1 , tail...);
}

#define DEBUG(...) \
do {\
  fprintf(stderr , "%s: Line %d - ",__PRETTY_FUNCTION__,__LINE__);\
  _DOING(#__VA_ARGS__ , __VA_ARGS__);\
} while(0);

#else
#define DEBUG(...)

#endif

// constant number
const int INF = 0x3f3f3f3f;
const ll INF64 = 0x3f3f3f3f3f3f3f3fll;

// random function
inline int RAND() {
  static int x = 880301;
  return (x = x * 0xdefaced + 1) % 0x7fffffff;
}
/// }}}

const int MAX_N = 100000 + 7;

ll ans[MAX_N], cnt[MAX_N];

int main() {
  int N, Q;
  RI(N, Q);
  vector<ll> A;
  A.PB(0);
  A.PB(N);
  REP(i, Q) {
    ll x;
    RI(x);
    while (SZ(A) > 1 && A.back() >= x) A.pop_back();
    A.PB(x);
  }
  cnt[SZ(A) - 1] = 1;
  for (int i = SZ(A) - 1; i > 0; i--) {
    ll p = A[i];
    while (p > A[1]) {
      int p2 = lower_bound(A.begin() + 1, A.end(), p) - A.begin() - 1;
      cnt[p2] += cnt[i] * (p / A[p2]);
      p %= A[p2];
    }
    ans[p] += cnt[i];
  }
  for (int i = N - 1; i > 0; i--) ans[i] += ans[i + 1];
  REP1(i, 1, N) PL(ans[i]);
  return 0;
}


Measured memory_bytes: 4212
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <map>
#include <utility>
#include <set>
#include <climits>

using namespace std;

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

const int MAXN = 55556;
bool is_prime[MAXN];

void get_prime () {
    memset (is_prime, true, sizeof(is_prime));
    is_prime[0] = is_prime[1] = false;
    for (int i = 0; i < MAXN; ++i) {
        if (!is_prime[i]) continue;
        for (int j = 2; i * j < MAXN; ++j) {
            is_prime[i * j] = false;
        }
    }
}


int main() {
    get_prime ();
    int n;
    scanf ("%d", &n);
    int i = 0, k = 0;
    while (k < n) {
        if (is_prime[i] && (i % 10 == 3)) {
            if (k > 0) printf (" ");
            printf ("%d", i);
            ++k;
        }
        ++i;
    }
    printf ("\n");
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i, m, n) for(int i = m; i < (n); i++)
#define print(x) cout << (x) << endl;
#define printa(x,n) for(int i = 0; i < n; i++){ cout << (x[i]) << " ";} cout << endl;
#define printa2(x,m,n) for(int i = 0; i < m; i++){ for(int j = 0; j < n; j++){ cout << x[i][j] << " ";} cout << endl;}
#define printp(x,n) for(int i = 0; i < n; i++){ cout << "(" << x[i].first << ", " << x[i].second << ") "; } cout << endl;
#define INF (1e18)

using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;

void foreach_permutation(int n, std::function<void(int *)> f) {
    int indexes[n];
    for (int i = 0; i < n; i++) indexes[i] = i+1;
    do {
        f(indexes);
    } while (std::next_permutation(indexes, indexes + n));
}

ll gcd(ll a, ll b)
{
    if (a == 0)
        return b;
    return gcd(b % a, a);
}


typedef struct{
    int x;
    int y;
} P;
typedef struct{
    ll to;
    ll cost;
} edge;
typedef pair<ll, ll> lpair;
template <typename Iterator>
inline bool next_combination(const Iterator first, Iterator k, const Iterator last)
{
    /* Credits: Thomas Draper */
    if ((first == last) || (first == k) || (last == k))
        return false;
    Iterator itr1 = first;
    Iterator itr2 = last;
    ++itr1;
    if (last == itr1)
        return false;
    itr1 = last;
    --itr1;
    itr1 = k;
    --itr2;
    while (first != itr1)
    {
        if (*--itr1 < *itr2)
        {
            Iterator j = k;
            while (!(*itr1 < *j)) ++j;
            iter_swap(itr1,j);
            ++itr1;
            ++j;
            itr2 = k;
            rotate(itr1,j,last);
            while (last != j)
            {
                ++j;
                ++itr2;
            }
            rotate(k,itr2,last);
            return true;
        }
    }
    rotate(first,k,last);
    return false;
}



int main() {
   int N,M,X;
   cin >> N >> M >> X;
   int C[N];
   int A[N][M];
   ll min = LONG_LONG_MAX;
   bool exist = false;
   for(int i=0;i<N;i++){
       cin >> C[i];
       for(int j=0;j<M;j++){
           cin >> A[i][j];
       }
   }

    vector<ll> v(N);
    iota(v.begin(), v.end(), 0);
    for(int k=1;k<=N;k++){
        do{
            int temp[M];
            ll nedan = 0;
            for(int i=0;i<M;i++){
                temp[i] = 0;
            }
            for(int i = 0; i < k; i++){
                //cout << (v[i]) << " ";
                nedan += C[v[i]];
                for(int j=0;j<M;j++){
                    temp[j]+=A[v[i]][j];
                }
            }
            //cout << endl;
            bool satis = true;
            for(int i=0;i<M;i++){
                //cout << temp[i] << " ";
                if(temp[i]<X){
                    satis = false;
                }
            }

            if(satis&&nedan<min){
                min = nedan;
                exist = true;
            }
            //cout << endl;


        }while(next_combination(v.begin(),v.begin() + k,  v.end()));


    }

    if(exist){
        cout << min << endl;
    }else{
        cout << -1 << endl;
    }



}


Measured memory_bytes: 3636
var obj = init();
Main();
function nextInt(){return myconv(next(),1);}
function nextStrArray(){return myconv(next(),2);}//半角スペース分割
function nextIntArray(){return myconv(next(),4);}//半角スペース + 数値化
function nextCharArray(){return myconv(next(),6);}//1文字分割
function next(){return obj.next();}
function hasNext(){return obj.hasNext();}
function myin(){return require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");}
function init(){
  var inputFile = myin();
  var returnObj = {
    "list" : inputFile, "index" : 0, "max" : inputFile.length,
    "hasNext" : function(){return (this.index < this.max);},
    "next" : function(){if(!this.hasNext()){return "";}else{var returnInput = this.list[this.index];this.index++;return returnInput;}}
  };
  return returnObj;
}
function myout(t){console.log(t);}//標準出力
function myerr(t){console.error(t);}//標準エラー出力
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す　1:数値へ変換
//2:半角SPで分割 4:半角SPで分割し、数値配列へ
//6:1文字で分割  7:1文字で分割し、数値配列へ
//8:半角SPで結合 9:改行で結合 0:文字なしで結合
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map((a)=>Number(a));case 6:return i.split("");case 7:return i.split("").map((a)=>Number(a));case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}
function Main(){
  var N = nextInt();
  var en500 = Math.floor(N / 500) * 1000;
  N = N % 500;
  var en5 = Math.floor(N / 5) * 5;
  myout(en500 + en5);
}

Measured memory_bytes: 21192
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s;
	cin>>s;
	int t=0;
	for(int i=0;i<s.length();i++)
	{
		t+=s[i] - '0';
	}
	if(t%9)
		printf("No\n");
	else
		printf("Yes\n");
}

Measured memory_bytes: 3732
#include <iostream>
#include <vector>
#include <set>
using namespace std;
#define rep(i, a, b) for(int i = a; i < (b); ++i)
int n, m, q;
int a[51], b[51], c[51], d[51];
int v[11];
int ans = 0;
 

int main() {
    string S;
 
    cin >> S;
    
    if (S == "ABC") {
        cout << "ARC" << endl;
    } else {
        cout << "ABC" << endl;
    }
    
  
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  char c;
  string result;

  cin >> c;
  (c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o')? result="vowel" : result="consonant";
  cout << result << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mt make_tuple
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<string,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef tuple<int,int,int> tp;
typedef vector<tp> vt;
typedef vector<vd> vvd;
typedef pair<int,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-7;
const int inf=1e9;
const ll INF=2e18;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int main(){
	ll a,b,c;
	cin>>a>>b>>c;
	int co=0;
	if(a==b&&b==c){
		if(a%2==0)cout<<-1<<endl;
		else cout<<0<<endl;
	}else{
		while(a%2==0&&b%2==0&&c%2==0){
			ll na=(b/2+c/2),nb=(a/2+c/2),nc=(b/2+a/2);
			co++;
			a=na;
			b=nb;
			c=nc;
		}
		cout<<co<<endl;
	}
}







Measured memory_bytes: 256
import java.util.Scanner;
class Main
 {
   public static void main(String[] args)
      {
   Scanner S = new Scanner(System.in);
      int a = S.nextInt();
      int b = S.nextInt();
      int d = a / b;
      int r = a % b;
      double f = (double)a / (double)b;
      System.out.printf("%d %d %.5f\n", d, r, f);

}

}



Measured memory_bytes: 26316