akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define lli long long int
#define ulli unsigned long long int
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define loopl(i,a,b) for(lli i=a;i<b;i++) 
#define loop(i,a,b) for(int i=a;i<b;i++)
#define all(v) v.begin(), v.end()
#define mod 998244353
#define mod2 1000000006
#define inf 1000000000000000000
#define lld long double
#define pll pair<long long int,long long int>
#define pii pair<int,int>
#define vll vector<lli>
#define vii vector<int>
#define is indexed_set
#define eps 0.000001
#define endl '\n'
#define mo 998244353
#define pi 3.141592653589793
using namespace std ;
 
const lli dx4[] = {-1, 0, 1, 0};
const lli dy4[] = {0, 1, 0, -1};
const lli dx8[] = {-1, 0, 1, 0, -1, -1, 1, 1};
const lli dy8[] = {0, 1, 0, -1, -1, 1, -1, 1};
 
typedef tree<pll,null_type,less<pll>,rb_tree_tag,
tree_order_statistics_node_update> indexed_set;
 
#define N 200005

void solve()
{
	string s;
	cin>>s;

	if(s[2]==s[3] && s[4]==s[5])
		cout<<"Yes"<<endl;
	else cout<<"No"<<endl;

}
 
int main()
{
/////////////////////////////////////
    
    fastio;
 
/////////////////////////////////////  
 	
	lli t;
	t=1;
 
	while(t--)
		solve();
 
}

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

int main(){
    int k,s,z,count;
    count=0;
    cin>>k>>s;

    for(int i=0;i<=k;i++){
        for(int j=0;j<=k;j++){
            z=s-i-j;
            if(0<=z && z<=k)count++;
        }
    }

    cout<<count<<endl;

}

Measured memory_bytes: 256
h, w = gets.split.map(&:to_i)
ans = 1e11

def min(ans, arr)
  mn, mx = arr.minmax
  return ((mx - mn) < ans ? (mx - mn) : ans)
end

# 1
(h + 1).times do |i|
  sa = w * i
  # tate
  wi = w / 2
  sb = (h - i) * wi
  sc = (h - i) * (w - wi)
  ans = min(ans, [sa, sb, sc])
  # yoko
  hi = (h - i) / 2
  sb = hi * w
  sc = (h - hi - i) * w
  ans = min(ans, [sa, sb, sc])
end
# 2
(w + 1).times do |i|
  sa = h * i
  # yoko
  hi = h / 2
  sb = (w - i) * hi
  sc = (w - i) * (h - hi)
  ans = min(ans, [sa, sb, sc])
  # tate
  wi = (w - i) / 2
  sb = wi * h
  sc = (w - wi - i) * h
  ans = min(ans, [sa, sb, sc])
end
p ans


Measured memory_bytes: 1788
#include<iostream>
using namespace std;
int main() {
	int l[10];
	for (int i = 0; i < 10; i++){
		cin >> l[i];
	}
	cout << l[0] + l[1] + l[2] + l[3] + l[4] + l[5] + l[6] + l[7] + l[8] + l[9] << endl;
}

Measured memory_bytes: 3068
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 
int main() {
    ll n,d,x=0,s=0;
    cin >> n >> d >> x;
    for(int i=0;i<n;i++){
        int a;
        cin >>a;
        for(int j=0;j<d;j++){
            if(a*j<d) s++;
            else break;
        }
    }
    cout << s+x <<endl;
}


Measured memory_bytes: 256
<?php
while (true) {
    fscanf(STDIN, "%d %d", $inputNum1, $inputNum2);
    if ($inputNum1 === 0 && $inputNum2 === 0) {
        break;
    }
    echo orderByAskForTwoNums($inputNum1, $inputNum2), PHP_EOL;
}

function orderByAskForTwoNums($inputNum1, $inputNum2)
{
    return min($inputNum1, $inputNum2).' '.max($inputNum1, $inputNum2);
}

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

using namespace std ;

#define sz(v) (int)v.size()
#define ll long long
#define all(v)  v.begin() , v.end()
#define rall(v)  v.rbegin() , v.rend()
#define pf push_front
#define pb push_back
#define fast FastInputOutput() ;
#define Clear( container , value ) memset( container , value , sizeof container )
#define PI acos( -1.0 )
#define forn( t , v , be , n ) for( t v = be ; v < n ; v++ )
#define fore( x , j ) for( auto x : j )
#define se second
#define fr first
//#define c_b fflush(stdin);

const ll Long_max = numeric_limits < ll > :: max() ;
const int Int_max = numeric_limits < int > :: max() ;

void File_input( string pathIn ) {
    freopen( pathIn.c_str(), "r", stdin ) ;
}

void File_output( string pathOut ) {
    freopen( pathOut.c_str(), "w", stdout ) ;
}

int msg() {
    srand( time( 0 ) ) ;
    vector < string > st = {
        "Wish everyone high ratings!",
        "Good luck!",
        "Have fun!",
        "Please, read all the problems!",
        "Go Go fight!"
    } ;
    cerr << st[ rand() % sz( st ) ] ;
    return 0 ;
}

void FastInputOutput() {
    ios_base :: sync_with_stdio( 0 ) ;
    cin.tie( 0 ) ;
    cout.tie( 0 ) ;
}

const int N = 200 ;
vector < int > adj[ N ] ;
int n , m ;
vector < bool > vis( N ) ;
int cn = 0 ;
set < int > in ;

void DFS( int u , int frq[] , int c ){
  vis[ u ] = 1;
  if( frq[ u ] + 1 >= 2 ) return ;
  frq[ u ]++ ;
    fore( i , adj[ u ] ){
       if( !vis[ i ] ){
         vis[ i ] = 1 ;
         DFS( i , frq , c + 1 ) ;
       }
       vis[ i ] = 0 ;
    }
  if( c == sz( in ) ) cn++ ;
  frq[ u ]-- ;
}

int main() {
    cin >> n >> m ;
    int a , b ;
    while( m-- ){
        cin >> a >> b ;
        adj[ a ].pb( b ) ;
        adj[ b ].pb( a ) ;
        in.insert( a ) ;
        in.insert( b ) ;
    }

    int frq[ N ] = { 0 } ;
    DFS( 1 , frq , 1 ) ;
    cout << cn ;

    return 0 ;
}



Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <vector>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <climits>
#include <stack>
#include <queue>
#include <set>
#include <cctype>
#include <bitset>
#include <type_traits>

#include <list>
using namespace std;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define YES(j) cout << (j ? "YES" : "NO") << endl;
#define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
#define yes(j) std::cout << (j ? "yes" : "no") << endl;

int main(void)
{
    int k;
    cin >> k;
    int a[] = {1,
               1,
               1,
               2,
               1,
               2,
               1,
               5,
               2,
               2,
               1,
               5,
               1,
               2,
               1,
               14,
               1,
               5,
               1,
               5,
               2,
               2,
               1,
               15,
               2,
               2,
               5,
               4,
               1,
               4,
               1,
               51};
    cout << a[k - 1] << endl;
}

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

int lcm(int a, int b) {
   int c = b;
   while(c % a != 0) {
      c += b;
   }
   return c;
}

int main() {
   int X; cin >> X;
   cout << lcm(X, 360)/X << endl;
}


Measured memory_bytes: 3636
#include <stdio.h>

int main(void){
  int i,n;
  long long int a, kians=0, guans=0, kisum=0, gusum=0;

  scanf("%d", &n);

  for(i=0;i<n;i++){
    scanf("%lld", &a);
    kisum+=a;
    gusum+=a;
    if(i%2==0){
      if(gusum<=0){
        guans=guans-gusum+1;
        gusum=1;
      }
      if(kisum>=0){
        kians=kians+kisum+1;
        kisum=-1;
      }
    }
    else{
      if(gusum>=0){
        guans=guans+gusum+1;
        gusum=-1;
      }
      if(kisum<=0){
        kians=kians-kisum+1;
        kisum=1;
      }
    }
  }
  if(kians>guans) printf("%lld\n", guans);
  else printf("%lld\n", kians);

  return 0;
}


Measured memory_bytes: 128
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define rep2(i, l, r) for (int i = (l); i < (r); i++)
#define ALL(x) (x).begin(), (x).end()     //昇順
#define RALL(x) (x).rbegin(), (x).rend()  // 降順
const long long mod = 1e9 + 7;
typedef long long ll;
typedef priority_queue<int> PQ;
typedef vector<long long> VL;
typedef vector<bool> VB;
typedef vector<int> VI;  // VI a(n);
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<char> VC;
typedef vector<VS> VSS;
typedef vector<VC> VCC;
typedef vector<VI> VII;  // VII a(n,vector<int>(m)) n * m
typedef vector<VL> VLL;
typedef pair<int, int> PII;
typedef map<int, int> MP;  // MP a;
typedef vector<pair<ll, ll>> PS;
 
template <class T, class U> bool chmax(T &a, U b) { if (a <= b) {a = b; return 1;} return 0; }
template <class T, class U>  bool chmin(T &a, U b) { if (a > b) { a = b; return 1; } return 0; }
template <typename T>  ostream &operator<<(ostream &os, vector<T> &v) { os << "{"; rep(i, (int)v.size()) { os << v[i] << (i < v.size() - 1 ? ", " : ""); } os << "}"; return os; }
 
// g++ -std=c++11 prac.cpp
// operator << (cout,a);
// chmin(min,a)
    
int main() {
    ll x=0,y=0,z=0,k,n,m,h,w,ans=0,sum=0,Max=-1,Min=1e9+1;
    bool ok = true;
    string t;
    cin >> k >> x >> y;
    for(int i=x; i<=y; i++){
        if(i%k==0){
            cout << "OK" << endl;
            return 0;
        }
    }
    cout << "NG" << endl;
    return 0;
}

Measured memory_bytes: 3592
use strict;
use warnings;
use feature 'say';

my $KX = <>; chomp($KX);
my ($K, $X) = split " ", $KX;

my $start = $X - $K + 1;
my $res = [];

for (0..$K*2-2) {
    push @$res, $start + $_;
}

say "@$res";

Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define INF 999999999
#define rep(i,n) for(int i=0;i<n;i++)
const int mod = 1000000007;
ll cnt = 0;
ll gcd(ll x,ll y){
   return y ? gcd( y , x%y ) : x;
}



int main(){
   int n;   cin >> n;
   int a[n],maxhigh;
   rep(i,n)cin >> a[i];

   maxhigh=0;

   for(int i=0;i<n;i++){
       if(maxhigh<=a[i]){
           cnt ++;
           maxhigh = a[i];
       }
   }
   cout << cnt << endl;
   
}

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

namespace AtCoder_solve
{
    class Program
    {
        public const ulong mod = 1000000007;

        static void Main(string[] args)

        {
            var n = Console.ReadLine();
            var ans = "No";

            for(int i = 0; i < n.Length; i++)
            {
                if (n[i] == '7') ans = "Yes";
            }

            Console.WriteLine(ans);
                
                





        }

       
        static public long Input()
        {
            return long.Parse(Console.ReadLine());
        }

        static public string[] Input2()
        {
            return Console.ReadLine().Split();
        }

        static public long[] Input3()
        {
            string[] data = Console.ReadLine().Split();
            long[] res = new long[data.LongLength];
            for(long i = 0; i < data.LongLength; i++)
            {
                res[i] = long.Parse(data[i]);
            }
            return res;
        }
        public static long Choose(long n, long a)
        {
            long x = 1;
            long y = 1;
            for (long i = 0; i < a; i++)
            {
                x *= n - i;
                y *= i + 1;
            }
            return x / y;
        }
    }
}


Measured memory_bytes: 17336
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;



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

    #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif

    string a,b,c;
    cin>>a>>b>>c;

    if(*(a.end()-1) == *b.begin() && *(b.end()-1) == *c.begin()){
        cout<<"YES"<<endl;
    }else{
        cout<<"NO"<<endl;
    }

}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std ;
const double pi = 3.1415926535897 ;
double a , b , h , m ;
double x , y ;
signed main () {
    cin >> a >> b >> h >> m ;
    x = 360 / 12 * h + m / 60 * 30 ; y = 360 / 60 * m ;
    double t = min ( fabs ( x - y ) , 360 - fabs ( x - y )  );
    double tt = t * pi / ( double ) 180 ;
    // cout << x << " " << y << endl ;
    cout << fixed << setprecision ( 10 ) << sqrt ( a * a + b * b - 2 * a * b * cos ( tt ) ) << endl ;
    return 0 ;
}

Measured memory_bytes: 4216
import sys
sys.setrecursionlimit(10**9)

def mi(): return map(int,input().split())
def ii(): return int(input())
def isp(): return input().split()
def deb(text): print("-------\n{}\n-------".format(text))

INF=10**20
def main():
    N = ii()
    ac,wa,tle,re = 0,0,0,0
    for i in range(N):
        t = input()
        if t == "AC":
            ac+= 1
        elif t == "WA":
            wa += 1
        elif t == "TLE":
            tle+= 1
        else:
            re += 1

    print("AC x {}".format(ac))
    print("WA x {}".format(wa))
    print("TLE x {}".format(tle))
    print("RE x {}".format(re))



if __name__ == "__main__":
    main()

Measured memory_bytes: 74732
#include"bits/stdc++.h"
using namespace std;
#define LL long long
#define PB push_back
#define MP make_pair

#include<unordered_map>

int main(){
	int N;
	LL M;
	cin >> N >> M;
	unordered_map<LL, LL> mp;
	LL sum = 0;
	mp[0]++;
	LL ans = 0;
	for(int i=0; i<N; i++){
		LL a;
		cin >> a;
		sum += a;
		ans += mp[sum%M];
		mp[sum%M]++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 3596
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String w = sc.next();
		char c = w.charAt(0);
		int cc = 0;
		for(int i = 0 ; i < w.length() ; i++){
			if(c == w.charAt(i)){
				cc++;
			}
			String a = c + "";
			if(i == w.length() - 1){
				w = w.replaceAll(a , "");
				if(cc % 2 != 0){
					System.out.println("No");
					break;
				}
				if(w.length() != 0){
					c = w.charAt(0);
					cc = 1;
					i = 0;
				} else if(w.length() == 0){
					System.out.println("Yes");
					break;
				}
			}
		}
	}
}


Measured memory_bytes: 22996
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

int main(){
  int N;
  std::cin>>N;
  std::vector<std::string> w(N);

  for(auto i = w.begin();i != w.end();i++){
    std::cin>>*i;
  }
  std::vector<std::string> v;
  std::copy(w.begin(), w.end(), std::back_inserter(v));

  std::sort(v.begin(), v.end());
  v.erase(std::unique(v.begin(), v.end()), v.end());

  bool flag = false;
  for(auto i = w.begin();i != w.end()-1;i++){
    if((*i).back() != (*(i+1)).front()){
      flag = true;
      break;
    }
  }

  if(w.size() != v.size() || flag == true){
    std::cout<<"No"<<std::endl;
  }else{
    std::cout<<"Yes"<<std::endl;
  }
  return 0;
}

Measured memory_bytes: 256
N=int(input())
a=list(map(int,input().split()))
ave=[sum(a)//N,sum(a)//N+1]
ans=[0,0]
for i in range(N):
  ans[0]+=(a[i]-ave[0])**2
  ans[1]+=(a[i]-ave[1])**2
print(min(ans))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); i++)
using ll = long long;
using namespace std;
using P = pair<int,int>;
const int nmax = 8;
bool graph[nmax][nmax];

int dfs(int v, int n, bool visited[nmax]){
    bool all_visited = true;

    for(int i = 0; i < n; i++){
        if(visited[i] == false){
            all_visited = false;
        }
    }

    if(all_visited){
        return 1;
    }

    int ret = 0;

    for(int i = 0; i < n; i++){
        if(graph[v][i] == false) continue;
        if(visited[i]) continue;

        visited[i] = true;
        ret += dfs(i, n, visited);
        visited[i] = false;
    }

    return ret;
}

int main(){
    int n, m;
    cin >> n >> m;

    for(int i = 0; i < m; i++){
        int a, b;
        cin >> a >> b;
        graph[a - 1][b - 1] = graph[b - 1][a - 1] = true;
    }

    bool visited[nmax];

    for(int i = 0; i < n; i++){
        visited[i] = false;
    }

    visited[0] = true;

    cout << dfs(0, n, visited) << endl;

    return 0;
}

Measured memory_bytes: 3636
n, k = map(int, input().split())
a = list(map(int, input().split()))

cs_a, cnt = [0] * n, 0
for i in range(n):
    cnt += a[i]
    cs_a[i] = cnt
dp = [[0] * (k + 1) for i in range(n + 1)]

for i in range(n + 1):
    for j in range(k + 1):
        if j == 0:
            dp[i][j] = 1
        elif (i == 0) or (j > cs_a[i - 1]):
            dp[i][j] = 0
        elif j - a[i - 1] - 1 < 0:
            dp[i][j] = dp[i - 1][j] + dp[i][j - 1]
        else:
            dp[i][j] = dp[i - 1][j] + dp[i][j - 1] - dp[i - 1][j - a[i - 1] - 1]
        dp[i][j] %= 10 ** 9 + 7

print(dp[n][k])


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

typedef long long ll;
typedef long double ld;
typedef vector<vector<int>> Graph;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
#define pi 3.14159265359
#define inf 2147483647
#define INF 9223372036854775807
#define mod 1000000007
#define mod2 998244353

int main() {
	ll N; cin >> N;
	bool isPrime = true;
	vector<ll> div;
	for(ll i = 1; i * i <= N; i++) {
		if(N % i == 0) {
			if(i != 1) isPrime = false;
			div.push_back(i);
		}
	}
	ll n = div.back(), m = N / n;
	string ans = to_string(m);
	cout << ans.size() << endl;
	return 0;
}

Measured memory_bytes: 3688
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <utility>
#include <iostream>
#include <algorithm>
#include <functional>

using namespace std;

#define INF (1 << 30)
#define INFL (1LL << 62)
#define MOD7 1000000007
#define MOD9 1000000009
#define EPS 1e-10

#define ll long long
#define ull unsigned long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pul pair<ull, ull>
#define all(a) (a).begin(), (a).end()
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);--i)
#define REP(i,n) for (int i=0;i<(n);++i)
#define RREP(i,n) for (int i=(n)-1;i>=0;--i)

void YES() { cout << "YES" << endl; }
void NO() { cout << "NO" << endl; }
void Yes() { cout << "Yes" << endl; }
void No() { cout << "No" << endl; }
void yes() { cout << "yes" << endl; }
void no() { cout << "no" << endl; }
void Taka() { cout << "Takahashi" << endl; }
void Aoki() { cout << "Aoki" << endl; }
void digit(int d) { cout << fixed << setprecision(d); }
void IOup() { cin.tie(0); ios::sync_with_stdio(false); }

int main() {
	int d, c;
	cin >> d >> c;
	cout << d * c << endl;

	return 0;
}

Measured memory_bytes: 3104
from heapq import*
i=input
s=sorted
def f(x):
 s,n,*h=0,len(x)
 while n:
  while x and x[-1][0]>=n:k,l,r=x.pop();heappush(h,(r-l,l,r))
  if h:s+=heappop(h)[1]
  n-=1
 return s+sum(r for*_,r in x+h)
for _ in'_'*int(i()):
 n,x,*y=int(i()),[]
 for _ in'_'*n:
  k,l,r=map(int,i().split())
  if l>r:x+=(k,l,r),
  else:y+=(n-k,r,l),
 print(f(s(x))+f(s(y)))

Measured memory_bytes: 122008
#include <stdio.h>
#include <string.h>

#define N (2000000)
int array[N];
int num;

void swap(int* a, int *b) {
  int tmp = *a;
  *a = *b;
  *b = tmp;
}

void swap_array(int n) {
  if (n == 0) return;
  int parent = (n - 1) / 2;
  if (array[n] > array[parent]) {
    swap(&array[n], &array[parent]);
    swap_array(parent);
  }
}

void shift_down(int i) {
  int child = 2 * i + 1;
  if (child >= num) return; 
  if (array[child] < array[child + 1]) {
    child++;
  }
  if (array[i] < array[child]) {
    swap(&array[i], &array[child]);
    shift_down(child);
  }
}

void push(int n) {
  array[num] = n;
  num++;
  swap_array(num - 1);
}

int pop() {
  int t = array[0];
  array[0] = array[--num];
  shift_down(0);
  return t;
}

int main() {
  char s[80];
  while (scanf("%s", &s)) {
    if (strcmp(s, "end") == 0) break;
    if (s[0] == 'e') {
      printf("%d\n", pop());
    } else {
      int d;
      scanf("%d", &d);
      push(d);
    }
  }

  return 0;
}

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

bool warenai3(int n){
  if(n%3!=0)return true;
  else return false;
}

bool warenai5(int n){
  if(n%5!=0)return true;
  else return false;
}

int main(){
  int N;
  cin>>N;
  
  long long sum = 0;
  
  for(int i=1;i<=N;i++){
    if(warenai3(i)&&warenai5(i))
      sum+=i;
  }
  
  cout<<sum<<endl;
  return 0;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
 
#define f(i,a,b) for( ll i = a; i < (ll) b ; i++ ) 
#define af(i,a,b) for( ll i = a; i >= (ll) b ; i--)
#define rep(i,a,b,k) for(ll i = a; i < (ll) b ; i+= k )
#define arep(i,a,b,k) for( ll i = a; i >= (ll) b ; i-= k)
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define sz(a) (ll) a.size()
#define all(a) a.begin(), a.end()
#define sor(a) sort( a.begin(), a.end() )
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
#define inter ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nuintptr)
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> ii ;
typedef vector<ll>  vi ;
typedef vector<ii> vii ;
 
const ll MAX= 3e3+6;
const ll inf =1e9;

ll a[20][20],c[20],l[20];

int main(){
	ll n,m,x,ans=1e12;
	cin>>n>>m>>x;
	f(i,0,n) {
		cin>>c[i];
		f(j,0,m) cin>>a[i][j];
	}
	f(mask,1,(1<<n)){
		ll cost=0;
		f(i,0,n){
			if((mask>>i)&1){
				f(j,0,m) l[j]+=a[i][j];
				cost+=c[i];
			}
		}
		bool go=true;
		f(j,0,m) if(l[j]<x) go=false;
		if(go) ans=min(ans,cost);
		f(j,0,m) l[j]=0;
	}
	if(ans==(ll)1e12) cout<<"-1\n";
	else cout<<ans<<endl;
}	

Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <climits>
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

#define INF INT_MAX/3
#define REP(i,n) for(int i=0;i<n;i++)

ll gcd(ll m, ll n){
	ll a;

	while(m % n != 0){
		a = n;
		n = m % n;
		m = a;
	}
	return n;
}


ll lcm(ll m, ll n){
	return m * n / gcd(m,n);
}


int main(){
	ll N,M;

	vector<ll> arr;

	cin>>N>>M;

	arr.resize(N);
	for(auto& s : arr){
		cin>>s;
	}



	//2dewareru kazu

	int count = 0;

	ll tmp = arr[0];
	while(tmp % 2 == 0){
		count++;
		tmp /= 2;
	}
	//cout<<"c : "<<count<<endl;

	bool res = true;
	for(int i = 1; i < N; i++){
		int now_count = 0;
		ll tmp = arr[i];
		while(tmp % 2 == 0){
			now_count++;
			tmp /= 2;
		}
		//cout<<"nc: "<<now_count<<endl;
		res = res && (count == now_count);
	}

	if(res){

		ll lcm_arr = 1;
		REP(i,N){
			lcm_arr = lcm(arr[i] / 2,lcm_arr);
			if(lcm_arr > M){
				cout<<0<<endl;
				return 0;
			}
		}

		ll ans = (M / lcm_arr);

		if(ans % 2 == 0){
			cout<<ans / 2 <<endl;
		}
		else{
			cout<<ans/2 + 1<<endl;
		}


	}
	else{
		cout<<0<<endl;
		//cout<<"gusu"<<endl;
	}
	return 0;
}



Measured memory_bytes: 1024
#pragma GCC optimize("O3")
#pragma GCC target("sse4")

#include <bits/stdc++.h>

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <typeinfo>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<ld, ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;

template <class T>
using Tree =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define FOR(i, a, b) for (int i = a; i < (b); i++)
#define F0R(i, a) for (int i = 0; i < (a); i++)
#define FORd(i, a, b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i, a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define shandom_ruffle random_shuffle

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001;  // check the limits, dummy

typedef long long ll;
const int inf = INT_MAX / 2;
const ll infl = 1LL << 60;
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 <class T>
void print(const vector<T> v) {
  cout << "[ ";
  F0R(i, v.size()) { cout << v[i] << ' '; }
  cout << "]" << '\n';
}

int mod(int i, int j) {
  return (i % j) < 0 ? (i % j) + 0 + (j < 0 ? -j : j) : (i % j + 0);
}

// --------------------------------------------------------
// This is tool
// --------------------------------------------------------
void Main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  int N, b, bb, c;
  cin >> N;
  ll a = 0;
  FOR(i, 0, N + 1) {
    if (i % 3 != 0 && i % 5 != 0) {
      a += i;
    }
  }
  cout << a << endl;
}

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  Main();
}

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

#define cc(x) cout << (x) << endl
#define rep(i,n) for(int i = 0; i < int(n); i++)
#define repi(i,a,b) for(int i = int(a); i < int(b); ++i)
typedef long long ll;

template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }


int n,m;
int a, b, c;
const ll inf = 1LL<<58;
const int iinf = 1<<30;


int main(){
    cin >> a >> b >> c;
    if(b/a>c){
        cc(c);
    }else{
        cc(b/a);
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v)   (v).begin(),(v).end()
#define debug(x) cerr<<#x<<": "<<(x)<<endl
using namespace std;
using llong = long long;
using vi    = vector<int>;
using vvi   = vector<vi >;
using vvvi  = vector<vvi >;
using pii   = pair<int,int>;
constexpr int    INF=1e9;
constexpr double EPS=1e-9;
constexpr int    MOD=1e9+7;
template<class Type>
void line(const Type &a){int cnt=0;for(const auto &elem:a){cerr<<(cnt++?' ':'>');cerr<<elem;}cerr<<endl;}

template<typename T>
class SegmentTree{
	using F=function<T(T,T)>;
	int n,offset;	//n:=(葉の数（2の階乗数）),offset:=(n-1).
	T e;			//e:=(単位元).
	vector<T> node;
	F f_query;		//f_query:=(クエリ関数).
	F f_update;		//f_update:=(更新関数).
	
	int bufsize(int n_){//木に必要なノード数を返す.
		n=1;
		while(n<n_) n<<=1;
		offset=n-1;
		return 2*n-1;
	}
	void build(int l=0,int r=-1){//木を構築する. O(N).
		if(r<0) r=n;
		l+=offset, r+=offset;
		do{
			l=(l-1)/2, r=(r-1)/2;
			for(int i=l;i<r;++i) node[i]=f_query(node[2*i+1],node[2*i+2]);
		}while(l>0);
	}
	
public:
	/*constructor.*/
	SegmentTree(int n_,T e_,const F &f_query_,const F &f_update_)
	:node(bufsize(n_),e_),e(e_),f_query(f_query_),f_update(f_update_){}
	SegmentTree(const vector<T> &v_,T e_,const F &f_query_,const F &f_update_)
	:node(bufsize(v_.size()),e_),e(e_),f_query(f_query_),f_update(f_update_){
		copy(ALL(v_),node.begin()+offset);//<algorithm>.
		build();
	}
		
	void init(){fill(ALL(node),e);}//初期化する.
	void update(int k,T a){//k番目の要素をaに更新する. O(log N).
		k+=offset;
		node[k]=f_update(node[k],a);
		while(k>0){
			k=(k-1)/2;//parent.
			node[k]=f_query(node[2*k+1],node[2*k+2]);
		}
	}
	/*[a,b)間のクエリ結果を返す. O(log N).
	（後ろの3つの引数は計算の簡単のための引数. kはノード番号,lとrはそのノードが[l,r)に対応づいているかを表す. 外からはquery(a,b,0,0,n)と呼ぶ.）*/
	T query(int a,int b,int k=0,int l=0,int r=-1){
		if(r<0) r=n;
		if(b<=l or r<=a) return e;//[a,b)と[l,r)が交差しなければe.
		if(a<=l and r<=b) return node[k];//[a,b)が[l,r)を完全に含んでいれば,この節点の値.
		T vl=query(a,b,2*k+1,l,(l+r)/2);
		T vr=query(a,b,2*k+2,(l+r)/2,r);
		return f_query(vl,vr);//交差する場合,2つの子をクエリ処理して比較.
	}
	
	typename vector<T>::reference operator[](int i){return node[i+offset];}
};

int main(){
	int n,k;
	cin>>n>>k;
	
	vi a(n);
	REP(i,n) cin>>a[i];
	
	using type=int;
	auto f_query=[](type a,type b)->type{return max(a,b);};//クエリ関数.
	auto f_update=[](type a,type b)->type{return max(a,b);};//更新関数.
	SegmentTree<type> tree(3e5+1,0,f_query,f_update);//(データ,単位元,クエリ関数,更新関数).
	
	REP(i,n){
		int l=max(0,a[i]-k), r=min(a[i]+k,(int)3e5+1)+1;
		tree.update(a[i],tree.query(l,r)+1);
		debug(tree.query(a[i],a[i]+1));
	}
	
	cout<<tree.query(0,(int)3e5+1)<<endl;
}

Measured memory_bytes: 15208
#include<bits/stdc++.h>
#include<ctype.h>
# define pb push_back
#define fst first
#define sec second
#define For(i,a,b) for(int i=a;i<b;i++)
#define ll long long int
#define ull unsigned long long int
#define mod 1000000007
#define fo(i,n) for(ll i=0;i<n;i++)
#define endl "\n"
#define rev(i,n) for(ll i=n-1;i>=0;i--)
#define fo1(i,n) for(ll i=1;i<=n;i++)
#define boolsize 1000001
#define pi pair<ll,ll>
#define vi vector<ll>
#define vii vector<pi>
using namespace std;
template<typename T>
void showvector(vector <T> v)
{
    for(T x:v)
        cout<<x<<" ";
    cout<<endl;

}
template<typename T>
void showvector1(vector <T> v)
{
    ll n=v.size();
    fo1(i,n-1)
        cout<<v[i]<<endl;

}
template<typename T>
void showset(set <T> s)
{
    for(T x: s)
        cout<<x<<" ";
    cout<<endl;
}
template<class T>
void showvectorpair(vector<T> v)
{
    for(auto it=v.begin();it!=v.end();it++)
        cout<<it->first<<" "<<it->second<<endl;
    cout<<endl;
}
template<typename T,typename P>
void showmap(map <T,P> m)
{
    for(auto it=m.begin();it!=m.end();it++)
        cout<<it->first<<" "<<it->second<<endl;
    cout<<endl;
}
template<typename T>
bool comp(T a,T b)
{
    return (a>b);
}
template<class T>
bool comppair(T a,T b)
{
    if(a.first==b.first)
        return(a.second>b.second);
    return (a.first>b.first);
}
bool sameparity(ll a,ll b)
{
    return (a%2==b%2);
}
bool difparity(ll a,ll b)
{
    return !(a%2==b%2);
}
bool isprime(ll x)
{   if(x<=1)
     return false;
    for(ll i=2;i<=sqrt(x);i++)
    {
        if(x%i==0)
            return false;
    }
    return true;
}
bool iseven(ll x)
{
    return !(x%2);
}
bool isodd(ll x)
{
    return (x%2);
}
/// check for test case before submitting
void vfun()
{
    ll n,k;
    cin>>n;
    vector <ll> v(n);
    fo(i,n)
    cin>>v[i];

}

int main()
{
    #ifndef ONLINE_JUDGE
    freopen("inputh.txt", "r", stdin);
    freopen("outputh.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(0); ///cant use scanf, printf
    cin.tie(0);cout.tie(0); /// no longer auto flush cout before each cin, remove for interactive
    //cout << fixed << setprecision(11); /// no scientific output
    ll test=1;
    //cin>>test;
    while(test--)
    {

            map <ll,ll> m;
            ll n;
            cin>>n;
            ll x;
            fo(i,n)
            {
                cin>>x;
                m[x]++;
                m[x-1]++;
                m[x+1]++;
            }
            ll ans=0;
            for(auto it=m.begin();it!=m.end();it++)
            {
                ans=max(ans,it->second);
            }
            cout<<ans;
//         if(vfun())
//            cout<<"YES\n";
//         else
//            cout<<"NO\n";
    }
}
///before sub
/// check for value of zero and single input in array
///loop vars,1LL in mult, equal, one, bounds, int v ll, endl, finish taking inputs
/// check whether test cases are given or not






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

using namespace std;
typedef long long LL;
typedef pair<int,int> P;

int main(){
	int A, B, C;
	cin >> A >> B >> C;
	cout << min(B/A, C) << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <bitset>
#include <iomanip>
#include <deque>
#include <tuple>
#include <algorithm>

using namespace std;

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

    if (s[1] == 'B') {
        cout << "ARC" << endl;
    }
    else {
        cout << "ABC" << endl;
    }
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
#define ms(x,y) memset(x, y, sizeof(x))
#define lowbit(x) ((x)&(-x))
#define sqr(x) ((x)*(x))
typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;


void run_case() {
    int n; cin >> n;
    vector<int> a(n+1);
    for(int i = 1; i <= n; ++i) {
        int x; cin >> x;
        a[x] = i;
    }
    for(int i = 1; i <= n; ++i)
        cout << a[i] << " ";
}


int main() {
    //freopen("input", "r", stdin);
    ios::sync_with_stdio(false), cin.tie(0);
    cout.flags(ios::fixed);cout.precision(9);
    //int t; cin >> t;
    //while(t--)
    run_case();
    cout.flush();
    return 0;
}

Measured memory_bytes: 3708
#include<bits/stdc++.h>
using namespace std;
using ll=long long;

const ll MOD=1000000007;

int main(){
  int i,j,cnt=0;
  int n;
  string s;
  cin>>n;
  cin>>s;
  ll a[26];
  for(i=0;i<26;i++)a[i]=0;
  for(i=0;i<26;i++){
    for(j=0;j<n;j++){
      if(s[j]==(char)('a'+i))a[i]++;
    }
  }
  ll prod=1;
  for(i=0;i<26;i++){
    if(a[i]!=0){
      prod=prod*(a[i]+1)%MOD;
    }
  }
  cout<<prod-1;
}

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

int main() {
  int n, m;
  cin >> n >> m;
  ll ans = (ll)abs(n - 2) * abs(m - 2);
  cout << ans << endl;
  return 0;
}

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

int main(){
	string S;
	cin >> S;
	
	if (S[0] == S[1]){
		cout << "Bad" << endl;
		return 0;
	}
	if (S[1] == S[2]){
		cout << "Bad" << endl;
		return 0;
	}
	if (S[2] == S[3]){
		cout << "Bad" << endl;
		return 0;
	}
	
	cout << "Good" << endl;
	
	
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //GCC5.4.1で配列の範囲外アクセスをエラーにする

//cmdで g++ test.cpp とするとコンパイルできる
//制限1秒なら10^6は余裕 10^7は多分間に合う 10^8はよほど単純でないと厳しい
// https://github.com/atcoder/live_library
// cppdbg: test.exeのterminalに標準入力を打てる

#define ALL(x) x.begin(),x.end()
#define get_tp(t,i) get<i>(t)
#define len(x) (ll)(x.size())
#define ub(a,x) (upper_bound(ALL(a),x)-a.begin())
#define lb(a,x) (lower_bound(ALL(a),x)-a.begin())
typedef long long ll; //long long
typedef pair<int,int> pii; //pair<int,int>
typedef pair<long long,long long> pllll; //pair<ll,ll>
typedef vector<int> vi; //vector<int>
typedef vector<vector<int>> vvi; //vector<vector<int>>
typedef vector<ll> vll; //vector<long long>
typedef vector<vector<ll>> vvll; //vector<vector<long long>>
typedef priority_queue<ll, vector<ll>, greater<ll> > gpq; //逆順priority_queue
typedef priority_queue<ll> pq;

//const int MOD=998244353;
const int MOD=1000000007; //10^9+7
const long double PI=3.1415926535897932;

int main(){
    int a,b,c,d,e,k;
    cin>>a>>b>>c>>d>>e>>k;
    cout<<((e-a<=k)?"Yay!":":(")<<endl;
}


Measured memory_bytes: 3608
#include <stdio.h>

int main (){
  char s[4];
  scanf("%s", s);

  for (int i = 0; i < 3; i++) {
    if((s[i]=='A' && s[i+1]=='B') || s[i]=='B' && s[i+1]=='A'){
      printf("Yes\n");
      return 0;
    }
  }
  printf("No\n");


  return 0;
}


Measured memory_bytes: 128
#include <set>
#include <map>
#include <deque>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <bitset>
#include <cstdio>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <iostream>
#include <algorithm>
#define mem(a,b) memset(a,b,sizeof (a))
#define gcd(a,b) __gcd(a,b)
#define all(a) a.begin(),a.end()
#define in(a) insert(a)
#define sz() size()
#define endl '\n'
#define pb push_back
typedef unsigned long long ll;
const int maxn=100010;
const int inf=1e9;
const ll mod=998244353;
const double pi=3.14159265358979;
const double ep=0.0;
using namespace std;
int main()
{
    string s;
    int k,ans=0;
    cin>>s>>k;
    int n=s.sz();
    if (n>1)
    {
        if (k==1)
            ans+=(n-1)*9;
        else if (k==2)
            ans+=(n-1)*(n-2)/2*9*9;
        else
            ans+=(n-1)*(n-2)*(n-3)/6*9*9*9;
    }
    if (k==1)
        ans+=s[0]-'0';
    if (k==2)
    {
        ans+=(s[0]-'1')*(n-1)*9;
        s.erase(0,1);
        n--;
        while (s[0]=='0')
        {
            s.erase(0,1);
            n--;
        }
        if (n>=1)
        {
            ans+=(n-1)*9;
            ans+=(s[0]-'0');
        }
    }
    if (k==3)
    {
        ans+=(s[0]-'1')*(n-1)*(n-2)/2*9*9;
        s.erase(0,1);
        n--;
        while (s[0]=='0')
        {
            s.erase(0,1);
            n--;
        }
        if (n>1)
        {
            ans+=(n-1)*(n-2)/2*9*9;
            ans+=(s[0]-'1')*(n-1)*9;
            s.erase(0,1);
            n--;
            while (s[0]=='0')
            {
                s.erase(0,1);
                n--;
            }
            if (n>=1)
            {
                ans+=(n-1)*9;
                ans+=(s[0]-'0');
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string b;
  cin >> b;
  if (b=="A"){
    cout << "T" << endl;
  }
  else if (b=="T"){
    cout << "A" << endl;
  }
  else if (b=="G"){
    cout << "C" << endl;
  }
  else {
    cout << "G" << endl;
}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,s,e) for(int i=(s); i<(e);i++)
#define rep(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n)
#define repe(i,n) for(auto &&i:n)
#define all(v) (v).begin(),(v).end()
#define decimal fixed<<setprecision(20)
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)
using namespace std;
using LL = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = 1e9;
const LL LLINF = 1e16;

LL dp[101010][13];
LL mod = 1000000007;

int main(){
	string s;
	cin >> s;
	rep(i, s.size()){
	  if(i == 0){
	    if(s[i] == '?'){
	     	rep(j, 10) dp[i+1][j] = 1;
	    }else{
	      dp[i+1][s[i]-'0'] = 1;
	    }
	    continue;
	  }
	  if(s[i] == '?'){
	    rep(j, 10){
	      rep(k, 13){
	      		(dp[i+1][(k*10+j)%13] += dp[i][k]) %= mod;
	      	}
		}
	  }else{
	    int j = s[i] - '0';
	    rep(k, 13){
	      (dp[i+1][(k*10+j)%13] += dp[i][k]) %= mod;	  	 }	  
	  }
	}
	cout << dp[s.size()][5] << endl;
	
	//rep(i, s.size()+1){
		//rep(j, 13)cout << dp[i][j] << " ";
		//cout << endl;
	  //}
			     

}

Measured memory_bytes: 10752
import Control.Applicative
import Control.Monad

rect :: Int -> Int -> String
rect h w = unlines $ replicate h (replicate w '#')

main :: IO ()
main = do
    xss <- fmap (fmap read . words) . lines <$> getContents :: IO [[Int]]
    forM_ (takeWhile (/= [0, 0]) xss) $ \[h, w] -> do
        putStrLn $ rect h w



Measured memory_bytes: 4596
#include <stdio.h>

typedef enum {
	S = 0,
	N,
	W,
	E
} cmd;


void showdice(int dice[7]) {
	int i;

	for (i = 1; i <= 6; ++i) {
		printf("%d ", dice[i]);
	}
	printf("\n");
	return;
}

void rotation(cmd command, int dice[7]) {
	int tmp;
	switch (command) {
	case S:
		tmp = dice[1];
		dice[1] = dice[5];
		dice[5] = dice[6];
		dice[6] = dice[2];
		dice[2] = tmp;
		break;
	case N:
		tmp = dice[1];
		dice[1] = dice[2];
		dice[2] = dice[6];
		dice[6] = dice[5];
		dice[5] = tmp;
		break;
	case W:
		tmp = dice[1];
		dice[1] = dice[3];
		dice[3] = dice[6];
		dice[6] = dice[4];
		dice[4] = tmp;
		break;
	case E:
		tmp = dice[1];
		dice[1] = dice[4];
		dice[4] = dice[6];
		dice[6] = dice[3];
		dice[3] = tmp;
	}
//	showdice(dice);
	return;
}

void toFront(int front, int dice[7]) {

	 if (front == dice[1]) {
		rotation(S, dice);
	} else if(front == dice[2]) {
		;
	} else if (front == dice[3]) {
		rotation(E, dice);
		rotation(N, dice);
	} else if (front == dice[4]) {
		rotation(W, dice);
		rotation(N, dice);
	} else if (front == dice[5]) {
		rotation(S, dice);
		rotation(S, dice);
	} else {
		rotation(N, dice);
	}
//	 showdice(dice);
	return;
}

int isMatch(int dice1[7], int dice2[7]) {
	int i;
	
	toFront(dice1[2], dice2);
//	showdice(dice2);
	for (i = 0; (i < 3) && dice1[1] != dice2[1] ; ++i) {
//		showdice(dice2) ;
		rotation(W, dice2);
	}
	if (dice1[1] != dice2[1]) return 0;
	for (i = 3; i <= 6; ++i) {
		if (dice1[i] != dice2[i]) return 0;
	}
	return 1;
}

int main(void) {
	int i, j, n;
	int dices[100][7] = {0};

	scanf("%d", &n);

	for (i = 0; i < n; ++i) {
		for (j = 1; j <= 6; ++j) {
			scanf("%d", &dices[i][j]);
		}
	}
	for (i = 0; i < n; ++i) {
		for (j = 0; j < n; ++j) {
			if (i != j) {
				if (isMatch(dices[i], dices[j])) {
					printf("No\n");
					return 0;
				}
			}
		}
	}
	printf("Yes\n");
	return 0;
}

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

int main() {
    std::cout<<std::fixed<<std::setprecision(10);
    
    int N; cin >> N;
    ll ans = 0;
    unordered_map<string, int> H;

    rep(i, N) {
        string S; cin >> S;
        sort(S.begin(), S.end());
        if (H.count(S) != 0) {
            // HにSが存在する場合
            ans += H[S];
            H[S]++;
        } else {
            H[S] = 1;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 10660
use std::io;

fn main() {
    let n = parse_line::<usize>();
    let v1 = parse_values::<i32>(n);
    let v2 = parse_values::<i32>(n);
    let (mut smaller, bigger) = if v1 < v2 { (v1, v2) } else { (v2, v1) };

    let mut i = 0;
    while smaller != bigger {
        smaller.next_permutation();
        i += 1;
    }
    println!("{}", i);
}

fn parse_line<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn parse_values<T: std::str::FromStr>(n: usize) -> Vec<T> {
    let line = parse_line::<String>();
    let mut split = line.split_whitespace();
    let mut values = Vec::with_capacity(n);
    for _ in 0..n {
        let v = split.next().unwrap().parse::<T>().ok().unwrap();
        values.push(v);
    }
    values
}

pub trait LexicalPermutation {
    /// Return `true` if the slice was permuted, `false` if it is already
    /// at the last ordered permutation.
    fn next_permutation(&mut self) -> bool;
    /// Return `true` if the slice was permuted, `false` if it is already
    /// at the first ordered permutation.
    fn prev_permutation(&mut self) -> bool;
}

impl<T> LexicalPermutation for [T]
where
    T: Ord,
{
    /// Original author in Rust: Thomas Backman <serenity@exscape.org>
    fn next_permutation(&mut self) -> bool {
        // These cases only have 1 permutation each, so we can't do anything.
        if self.len() < 2 {
            return false;
        }

        // Step 1: Identify the longest, rightmost weakly decreasing part of the vector
        let mut i = self.len() - 1;
        while i > 0 && self[i - 1] >= self[i] {
            i -= 1;
        }

        // If that is the entire vector, this is the last-ordered permutation.
        if i == 0 {
            return false;
        }

        // Step 2: Find the rightmost element larger than the pivot (i-1)
        let mut j = self.len() - 1;
        while j >= i && self[j] <= self[i - 1] {
            j -= 1;
        }

        // Step 3: Swap that element with the pivot
        self.swap(j, i - 1);

        // Step 4: Reverse the (previously) weakly decreasing part
        self[i..].reverse();

        true
    }

    fn prev_permutation(&mut self) -> bool {
        // These cases only have 1 permutation each, so we can't do anything.
        if self.len() < 2 {
            return false;
        }

        // Step 1: Identify the longest, rightmost weakly increasing part of the vector
        let mut i = self.len() - 1;
        while i > 0 && self[i - 1] <= self[i] {
            i -= 1;
        }

        // If that is the entire vector, this is the first-ordered permutation.
        if i == 0 {
            return false;
        }

        // Step 2: Reverse the weakly increasing part
        self[i..].reverse();

        // Step 3: Find the rightmost element equal to or bigger than the pivot (i-1)
        let mut j = self.len() - 1;
        while j >= i && self[j - 1] < self[i - 1] {
            j -= 1;
        }

        // Step 4: Swap that element with the pivot
        self.swap(i - 1, j);

        true
    }
}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
int main(){
  long A, B, C, K, Ans = 0, count = 1;
  
  cin >> A >> B >> C >> K;
  
  for(int i = 1; i <= A; i++){
    if(count > K) break;
    Ans++;
    count++;
  }
  
  count += B;
  
  for(int i = 1; i <= C; i++){
    if(count > K) break;
    Ans--;
    count++;
  }
  
  cout << Ans << endl;
  
  return 0;
}

Measured memory_bytes: 3636
// Prep to Republic Olymp
#include <bits/stdc++.h>

#define x first
#define y second
#define pb push_back
#define mp make_pair
#define SZ(x) x.size()
#define NAME "main"
#define in insert
#define whole(x) x.begin(), x.end()
#define watch(x) cout << (#x) << " " << "is" << " " << x << endl

using namespace std;

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

const int N = 2 * (1e5);
const int MOD = (1e9) + 7;
const double pi = acos(0.0);
const ll INF = (1e17) + 6969;


signed main() {
#ifdef LOCAL 
	freopen(NAME".in", "r", stdin);
	freopen(NAME".out", "w", stdout);
#endif 
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr), cout.tie(nullptr);                          
	int n;
	cin >> n;
	int mx = -1;
	int ans = 0;
	while(n--) { 	
		int x;
		cin >> x;
		mx = max(mx, x);
		ans += x;
	}
	if (ans - mx <= mx)
		cout << "No";
	else
		cout << "Yes";
	return false;
}

Measured memory_bytes: 256
//大文字->小文字 tolower(),逆はtoupper()
//int a = stoi(c); 文字列をintへ
//途中の出力をそのまま残さない
//数値計算 個数以外はdouble
//map<キー,値> p は辞書。p[キー] = 値
//map 全探索
//auto begin = p.begin(), end = p.end();
//for (auto it = begin; it != end; it++) {}
//mapのキー：it->first mapのバリュー：it->second
//絶対値 abs()
//入力は空白で切れる
//大文字判定 isupper(文字) 小文字判定 islower(文字)
//do{}while(next_permutation(ALL(配列)))
//while(N)で回すとき、Nはコピーを作っておく
//小文字に対応する文字コード：S[i] - 'a'
//文字コード→小文字：(char)(数字+'a')
//グラフの距離:隣接行列で扱う
#include <bits/stdc++.h>
#define rep(i,N) for(int i = 0; i < N;i++)
#define ALL(a) (a).begin(),(a).end()
#define ll long long int
using namespace std;

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

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

//円周率
const double PI = 3.14159265358979323846;

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

	ll f = 0, t = 0;
	rep(i, N) {
		if (a[i] % 4 == 0) f++;
		else if (a[i] % 2 == 0)t++;
	}

	ll cnt = 0;
	if (t == 0) cnt = 2 * f + 1;
	else cnt = f * 2 + t;

	if (cnt >= N) cout << "Yes" << endl;
	else cout << "No" << endl;
}

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

using ll = long long;
using ii = pair<int, int>;
ll fn(ll a, ll b) {
	return a+(b-a-1)/2;
}
int main(int argc, char const *argv[])
{
#ifdef LOCAL
	freopen("in", "r", stdin);
#endif
	ll n, a, b;
	cin >> n >> a >> b;
	if(a > b) swap(a, b);
	if(~(a ^ b) & 1) cout << (b-a)/2 << endl;
	else cout << min({fn(a, b), fn(n-b+1, n-a+1)}) << endl;
	return 0;
}

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

int main() {
    fast;
    int a; cin>>a;
    vec<int> m(a);
    for(int q=0; q<a; q++) cin>>m[q];
    int o=0;
    for(int q=1; q+1<a; q++){
        o+= (m[q-1]<m[q] && m[q]<m[q+1]) || (m[q-1]>m[q] && m[q]>m[q+1]);
    }
    cout<<o;
}

Measured memory_bytes: 256