akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <random>
#include <unordered_map>
#include <unordered_set>
#define all(a) a.begin(),a.end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define pb push_back
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;
typedef complex<ld> com;
constexpr int inf = 1000000010;
constexpr ll INF = 1000000000000000010;
constexpr ld EPS = 1e-12;
constexpr ld PI = 3.141592653589793238;
template<class T, class U> inline bool chmax(T &a, const U &b) { if (a < b) { a = b; return true; } return false; }
template<class T, class U> inline bool chmin(T &a, const U &b) { if (a > b) { a = b; return true; } return false; }


signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(20);

	int n, m;
	cin >> n >> m;
	if (n & 1) rep(i, m) cout << i + 1 << ' ' << n - i << '\n';
	else {
		rep(i, (m + 1) / 2) cout << i + 1 << ' ' << (m + 1) / 2 * 2 - i << '\n';
		int s = (m + 1) / 2 * 2 + 1;
		rep(i, m / 2) cout << s + i << ' ' << s + m / 2 * 2 - i << '\n';
	}
}

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

int main(){
    int N;cin>>N;
    vector<int>v(N);
    for(int i=0;i<N;i++)cin>>v[i];
    int dp[N+1];
    memset(dp,0,sizeof dp);
    for(int i=0;i<N;i++){
        if(i == 0){
            dp[i] = 0;
        }
        else if(i == 1){
            dp[i] = abs(v[i]-v[i-1]);
        }
        else {
            dp[i] = min(abs(v[i]-v[i-1])+dp[i-1],
                        abs(v[i] - v[i-2])+dp[i-2]);
        }
     //   cout<<i<< " "<<dp[i]<<endl;
    }
    cout<<dp[N-1]<<endl;
	return 0 ;
}


Measured memory_bytes: 1024
from statistics import median
n = int(input())
a = [int(i) for i in input().split()]
b = []

for i in range(n):
    b.append(a[i] - (i+1))

m = int(median(b))

sum = 0
for i in range(n):
    sum += abs(a[i] - (m+i+1))

print(sum)

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

using namespace std;

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

	int N_size = N.size();

	int sum = 0;

	for(int i = 0; i < N_size; i++) {
		sum += N[i] - '0';
	}

	if(sum % 9 == 0) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 3744
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(long long i=0; i<(int)n; i++)
#define rep2(i,a,n) for(long long i=(a); i<(int)(n); i++)
#define all(vec) vec.begin(),vec.end()
using vi = vector<int>;
using vs = vector<string>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using psi = pair<string, int>;
const int dx[4] = {1, 0,-1, 0};
const int dy[4] = {0, 1, 0,-1};
const int mod = 1e9+7;
int gcd(int a, int b){if(a%b == 0){return(b);}else{return(gcd(b, a%b));}}
int lcm(int a, int b){return a * b / gcd(a, b);}

int N, M, K, H, W, L, R, X;
//string S, T;

signed main(){
  cin >> N;
  map<int, int> mp;
  vi A(N); rep(i,N){int a; cin >> a; mp[a]++;}
  if(mp[0] > 1){cout << 0 << endl; return 0;}
  int ans = 1;
  for(auto itr : mp){
    if(itr.second > 2){cout << 0 << endl; return 0;}
    if(itr.second != 0){
      ans *= itr.second;
      ans %= mod;
    }
  }
  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 7892
import java.util.*;
import java.math.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

		Deque<Integer> deque = new ArrayDeque<Integer>();

        while(sc.hasNextInt()){
        	int in = sc.nextInt();

        	if(in > 0){
        		deque.addFirst(in);
        	}else{
        		System.out.println(deque.removeFirst());
        	}
        }
    }
}

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

#define N 100100

int n, a[N], l[N], r[N];

int main() {
    scanf("%d", &n);
    for (int i = 1; i <= n; i ++) scanf("%d", &a[i]);
    for (int i = 1; i <= n; i ++) l[i] = __gcd(l[i-1], a[i]);
    for (int i = n; i; i --) r[i] = __gcd(r[i+1], a[i]);
    int ans = 0;
    for (int i = 1; i <= n; i ++) ans = max(ans, __gcd(l[i-1], r[i+1]));
    printf("%d\n", ans);

    return 0;
}


Measured memory_bytes: 1408
#include<iostream>
#include<cstring>
using namespace std;
int const MAXN=1e2+9;
int n;
int m;
int res;
char a[MAXN][MAXN]={0};
int next[4][2]={{0,1},{0,-1},{1,0},{-1,0}};

void dfs(int x,int y,char c)
{
	a[x][y]=0;
	for(int i=0;i<4;i++)
	{
		int tx=x+next[i][0];
		int ty=y+next[i][1];
		if(0<=tx<n&&0<=ty<m&&a[tx][ty]==c)
			dfs(tx,ty,c);
	}
}

int main()
{
	while(cin>>n>>m&&n&&m)
	{
		res=0;
		memset(a,0,sizeof(a));
		for(int i=0;i<n;i++)
			for(int j=0;j<m;j++)
				cin>>a[i][j];
		for(int i=0;i<n;i++)
			for(int j=0;j<m;j++)
				if(a[i][j])
				{
					res++;
					dfs(i,j,a[i][j]);
				}
		cout<<res<<endl;
	}
	return 0;
}


Measured memory_bytes: 3640
#include <iostream>
using namespace std;
int main(void){
   int W, H, x, y, r;
    cin >> W >> H >> x >> y >> r;
 
   if (x-r >= 0 && x+r <= W && y-r >= 0 && y+r <= H){
        cout << "Yes";
    }else {
        cout << "No";
    }
    cout << endl;
}
//ITP1_2_D


Measured memory_bytes: 3108
#include<iostream>
#include<cstdio>
#include<vector>
typedef std::pair<int,int> P;
const int N=105;
std::vector<P> ans;
int n,blg[N];
int main() {
    scanf("%d",&n);
    int v=n-(n&1),cnt=0;
    for(int l=1,r=v;l<r;l++,r--) {
        blg[l]=blg[r]=++cnt;
    }
    for(int i=1;i<=n;i++) for(int j=i+1;j<=n;j++) if(blg[i]!=blg[j]) {
        ans.push_back(P(i,j));
    }
    printf("%d\n",int(ans.size()));
    for(auto c:ans) printf("%d %d\n",c.first,c.second);
    return 0;
}


Measured memory_bytes: 384
def search_root(x):
    i = x
    while True:
        if i == nodes[i]:
            nodes[x] = i
            return i
        else:
            i = nodes[i]

def unite(x,y):
    nodes[search_root(x)] = search_root(y)

def same(x,y):
    if search_root(x) == search_root(y):
        print(1)
    else:
        print(0)


n, q = map(int, input().split())
nodes = [i for i in range(n)]
commands = []
for _ in range(q):
    commands.append(input())
for cmd in commands:
    c,x,y = map(int,cmd.split())
    if c == 0:
        unite(x,y)
    else:
        same(x,y)



Measured memory_bytes: 13772
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <bitset>
#include <utility>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<pair<int,int>> vpii;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
#define rep(i,n) for(int i=0;i<n;i++)
#define fin(ans) cout<<(ans)<<endl
#define P 1000000007
#define STI(s) atoi(s.c_str())//string to int
#define mp(p,q) make_pair(p,q)
#define Sort(a) sort(a.begin(),a.end())
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 = INT_MAX;
const long long LLINF = 1LL<<60;
//g++ -std=c++1z temp.cpp
//./a.exe
int digit(int a){
    int count = 0;
    for (int i = 0; i < a; i++)
    {   if (a == 0)
        {
            break;
        }else
        {
            a = a/10;
            count++;
        }     
    }
    return count;
}
//pow(x,n) == x^n

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

string s;
cin >> s;
cout << s.at(0) << s.size()-2 << s.at(s.size()-1) << endl;



//////////////////////////////////////////////////////
return 0;}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
	int m, f, r;
	for(int i=0; ; i++){
		scanf("%d %d %d", &m, &f, &r);
		if(m==-1&&f==-1&&r==-1) break;
		else if(m==-1||f==-1) printf("F\n");
		else if (m+f>=80) printf("A\n");
		else if(m+f>=65) printf("B\n");
		else if(m+f>=50) printf("C\n");
		else if(m+f>=30){
			if(r>=50) printf("C\n");
			else printf("D\n");
		}
		else printf("F\n");
	}
}


Measured memory_bytes: 2696
#include<iostream>
#include<string>
#include<vector>
#include<math.h>
#include<algorithm>
#include<cstdio>
#include<stdio.h>
#include<stack>
#include<sstream>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<list>
#include<numeric>
typedef long long ll;

#define pi 3.14159265358979323846
#define VI vector<int>
#define VLL vector<long long>
#define MAX max_element
#define MIN min_element
#define all(v) v.begin(), v.end()
const ll MOD = 1e9 + 7;
using namespace std;
template<typename T>
T gcd(T a, T b) {
	return b ? gcd(b, a % b) : a;
}
template<typename T>
T lcm(T a, T b) {
	return a * b / gcd(a, b);
}

template<typename T>
T finder(vector<T> vec, T number) {
	auto itr = find(vec.begin(), vec.end(), number);
	size_t index = distance(vec.begin(), itr);
	if (index != vec.size()) { // 発見できたとき
		return 1;
	}
	else { // 発見できなかったとき
		return 0;
	}
}
ll frac(ll n)
{
	if (n == 0) {
		return 1;
	}
	return (n * frac(n - 1)) % MOD;
}

/*char r[4];
int yaju[4];
char op[3];
int sum = 0;
scanf("%s", r);
for (int i = 0;i < 4;i++) {
	yaju[i] = r[i] - '0';
}
*/
int main() {
	ll X; cin >> X;
	ll place = 0;
	for (int i = 1;;i++) {
		place += i;
		if (place >= X) {
			cout << i << endl;
			break;
		}
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int64_t MAXN = 100000;
int64_t N, M, x, y;
vector<vector<int64_t>> adj(MAXN);
vector<int64_t> DP(MAXN, -1);

int64_t dfs(int64_t cur)
{
  if (DP.at(cur) != -1)
    return DP.at(cur) + 1;
  int64_t ret = 0;
  for (int i = 0; i < adj.at(cur).size(); i++)
  {
    ret = max(ret, dfs(adj.at(cur).at(i)));
  }
  DP.at(cur) = ret;
  return ret + 1;
}

int main()
{
  cin >> N >> M;
  for (int i = 0; i < M; i++)
  {
    cin >> x >> y;
    x--;
    y--;
    adj.at(x).push_back(y);
  }

  for (int i = 0; i < N; i++)
  {
    dfs(i);
  }

  int64_t ans = 0;
  for (int i = 0; i < N; i++)
  {
    if (DP.at(i) > ans)
      ans = DP.at(i);
  }
  cout << ans << endl;
}


Measured memory_bytes: 9216
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#define lol(i,n) for(int i=0;i<n;i++)
#define mod 1000000007
typedef long long ll;
using namespace std;
int cnt[100010];
int main(){
	int n;
	cin>>n;
	lol(i,n)cnt[i]=0;
	bool ok=true;
	lol(i,n){
		int a;cin>>a;
		if(a>n-1)ok=false;
		else cnt[a]++;
	}
	for(int i=1+(n%2);i<n;i+=2)if(cnt[i]!=2)ok=false;
	if(ok){
		ll ans=1;
		lol(i,n/2)ans=ans*2%mod;
		cout<<ans<<endl;
	}
	else cout<<"0"<<endl;
	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int (i) = 0; (i) <(n); (i)++) 
#define so(v) sort(v.begin(),v.end())
using ll = long long;
using vi=vector<int>;
using vii=vector<vi>;
int main() {
  ll a,b,c,n,m,x,y;
  cin>>n>>a>>b;
  ll ans=0;
  ans=a*(n/(a+b));
  ans+=min(a,n%(a+b));
  cout<<ans;

   
}

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

aa = [[int(n) for n in input().split()] for i in range(n)]

s = [0] * 3

for a in aa:
    s = [max(s[1], s[2]) + a[0], 
        max(s[0], s[2]) + a[1],
        max(s[0], s[1]) + a[2]
    ]

print(max(s))

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

int main() {
  int N, m, f = 0, j = 0;
  cin >> N;
  vector<int> d(N);
  for (int i = 0; i < N; i++) cin >> d.at(i);

  while (j < N) {
    m = d.at(j);
    if (m != 0) f++;
    for (int i = j + 1; i < N; i++) if (d.at(i) == m) d.at(i) = 0;
    j++;
  }

  cout << f << endl;
}

Measured memory_bytes: 3620
s = list(input())

if len(s) % 2 == 0:
    flag1 = True
else:
    flag1 = False

if s[0] == s[-1]:
    flag2 = True
else:
    flag2 = False

if (flag1 ^ flag2):
    print ('Second')
else:
    print ('First')

# print (s)

Measured memory_bytes: 4084
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <climits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>

using namespace std;

typedef pair<int, int> ii;
typedef long long int64;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;

int main() {
    int n, m;
    cin >> n >> m;
    if (m > n) swap(n, m);
    int i = m;
    while (i < n) {
	if (abs(n - i) == abs(m - i)) {
	    cout << i << endl;
	    return 0;
	}
	++i;
    }
    cout << "IMPOSSIBLE" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int x = 1,y = 1;
	int num1[3000];
	int num2[3000];
	int i = 0,j,n;
	
	while(x != 0 || y != 0){
		scanf("%d %d",&x,&y);
		if(x != 0 || y != 0){
			num1[i] = x;
			num2[i] = y;
			i++;
		}
	}
	for(j = 0;j < i;j++){
		if(num1[j] > num2[j]){
			printf("%d %d\n",num2[j],num1[j]);
		}
		else if(num1[j] < num2[j]){
			printf("%d %d\n",num1[j],num2[j]);
		}
		else if(num1[j] == num2[j]){
			printf("%d %d\n",num1[j],num2[j]);
		}
	}
	
	return(0);
}

Measured memory_bytes: 620
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
 
#define endl '\n'
#define loop(i, m, n) for (ll i = m; i < n; i++)
#define loope(i, m, n) for (ll i = m; i <= n; i++)
#define epool(i, m, n) for (ll i = m; i >= n; i--)
#define mod 1000000007
#define mod2 998244353
#define vi vector<ll>
#define pll pair<ll, ll>
#define fi first
#define se second
#define pb push_back
#define MP make_pair
#define empf emplace_front
#define empb emplace_back
#define ret(x) return cout << x,0;
#define all(v) v.begin(),v.end()
#define maxheap priority_queue<ll>
#define minheap priority_queue<ll,vector<ll>,greater<ll>>
const ll INF=1e18;
const double PI=4*atan(1);

#define SpeedForce                    \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);

using namespace __gnu_pbds;
using namespace std;
typedef tree<int,null_type,less<int>,rb_tree_tag,
tree_order_statistics_node_update> indexed_set;

ll mpow(ll base,ll exp);
ll POW(ll base,ll exp);
ll gcd(ll a,ll b);
ll modInverse(ll n);
ll nCr(ll n, ll r);
ll myxor(ll a,ll b);

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

void solve(){
    ll n;
    cin >> n;
    vi a(n);
    loop(i,0,n) cin >> a[i];
    ll ans=0;
    loop(i,1,n){
        if(a[i]<a[i-1]){
            ans+=(a[i-1]-a[i]);
            a[i]=a[i-1];
        }
    }
    // if(n>=2)
    //     if(a[n-1]<a[n-2]){
    //         ans+=(a[n-2]-a[n-1]);
    //     }

    cout << ans << endl;

}

int32_t main(){
    SpeedForce
    ll i = 0,j = 0;

    int t;
    t=1;
    //cin >> t;
    while (t--){
        //cout << fixed << setprecision(10);
        solve();
    }
}

ll POW(ll base,ll exp){
    ll result = 1;
    while (exp > 0){
        if (exp & 1)
            result = ((ll)result * base);
        base = ((ll)base * base);
        exp >>= 1;
    }
    return result;
}

ll mpow(ll base, ll exp){
    base %= mod;
    ll result = 1;
    while (exp > 0){
        if (exp & 1)
            result = ((ll)result * base) % mod;
        base = ((ll)base * base) % mod;
        exp >>= 1;
    }
    return result;
}

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

ll modInverse(ll n) { 
    return mpow(n, mod-2); 
}
 
ll nCr(ll n, ll r){ 
   if (r==0) 
      return 1; 
    ll fac[n+1]; 
    fac[0] = 1; 
    for (int i=1 ; i<=n; i++) 
        fac[i] = (fac[i-1]*i)%mod; 
    return ((fac[n]* modInverse(fac[r]) % mod * 
            modInverse(fac[n-r]) % mod)%mod)%mod; 
}

ll myxor(ll a,ll b){
    return (a|b)&(~a|~b);
}

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

using ll = int64_t;
#define int ll

#define FOR(i, a, b) for (int i = int(a); i < int(b); i++)
#define REP(i, b) FOR(i, 0, b)
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(x) x.begin(), x.end()

using pi = pair<int, int>;
using vi = vector<int>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  REP(i, (int)v.size()) {
    if (i) os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

ll read() {
  ll i;
  scanf("%" SCNd64, &i);
  return i;
}

void printSpace() { printf(" "); }

void printEoln() { printf("\n"); }

void print(ll x, int suc = 1) {
  printf("%" PRId64, x);
  if (suc == 1) printEoln();
  if (suc == 2) printSpace();
}

string readString() {
  static char buf[3341000];
  scanf("%s", buf);
  return string(buf);
}

char *readCharArray() {
  static char buf[3341000];
  static int bufUsed = 0;
  char *ret = buf + bufUsed;
  scanf("%s", ret);
  bufUsed += strlen(ret) + 1;
  return ret;
}

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

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

template <class T>
T Sq(const T &t) {
  return t * t;
}

signed main() {
  int sum = 0, tmp, maxDiff = 0;
  REP(i, 5) {
    tmp = read();
    sum += tmp;
    if (tmp % 10 > 0) {
      sum += 10 - (tmp % 10);
      chmax(maxDiff, 10 - (tmp % 10));
    }
  }
  print(sum - maxDiff);
}


Measured memory_bytes: 256
n = int(input())
A = sorted(map(int, input().split()))

U = 10**6
line = [1]*(U+1)
ans = set()
depricated = set()
cnt = [0]*(U+1)
for a in A:
    cnt[a] += 1
    if cnt[a] == 2 and line[a]:
        depricated.add(a)
        continue
    if 2 < cnt[a]:
        continue
    if line[a]:
        ans.add(a)
        for p in range(2*a, U+1, a):
            line[p] = 0
print(len(ans-depricated))

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

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORR(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define RANGE(i,a,b) for(int i=(a);i<=(b);i++)
#define RANGER(i,a,b) for(int i=(b);i>=(a);i++)
#define REP(i,n) FOR(i,0,n)
#define REPR(i,n) FORR(i,0,n)
using ll=long long int;
using vi=vector<int>;
using vii=vector<vi>;
using pi=pair<int,int>;
constexpr int INF=1<<30;
constexpr ll INTL=1ll<<60;
int main(){
  int n,l;
  cin>>n>>l;
  int sum=0,nearzero=INF;
  FOR(i,l,n+l){
    sum+=i;
    if(abs(nearzero)>abs(i)){
      nearzero=i;
    }
  }
  cout<<(sum-nearzero)<<endl;
  return 0;
}

Measured memory_bytes: 256
object Main {
  def main(args: Array[String]): Unit = {
    val num = io.StdIn.readInt()
    var first_last_num_pair: Map[( Int, Int ), Int ] = Map.empty
    (1 to num).foreach { i =>
      val pair = pairFirstAndLast( i )
      if( first_last_num_pair.contains( pair ) ) first_last_num_pair = first_last_num_pair + ( pair -> ( first_last_num_pair( pair ) + 1 ) )
      else                                       first_last_num_pair = first_last_num_pair + ( pair -> 1 )
    }

    var ans = 0
    ( 1 to num ).foreach{ i =>
      val pair = pairFirstAndLast( i )
      val change_pair = ( pair._2, pair._1 )
      if( first_last_num_pair.contains( change_pair ) ) ans += first_last_num_pair( change_pair )
    }
    println( ans )
  }

    def pairFirstAndLast( num: Int ): ( Int, Int ) = {
      val num_str   = num.toString
      val first_num = num_str(0).toInt - 48
      val last_num  = num_str( num_str.length - 1 ).toInt - 48

      return ( first_num, last_num )
    }
}

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

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    vector<int> p(n);
    for (int i = 0; i < n; ++i) {
        cin >> p[i];
    }
    set<int> S;
    S.insert(-p[0]);
    int ans = 1;
    for (int i = 1; i < n; ++i) {
        if (S.upper_bound(-p[i]) == S.end()) ++ans;
        S.insert(-p[i]);
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 10368
require 'pp'
pa, pb, pc, x, y = gets.chomp.split(" ").map(&:to_i)

a, b, c = 0, 0, 0

min_total = x * pa + y * pb

(1..10**5*2).each do |hc|
  c = hc * 2
  a = [x - hc, 0].max
  b = [y - hc, 0].max
  total = a * pa + b * pb + c * pc

  if total < min_total
    min_total = total
  end
end


puts min_total


Measured memory_bytes: 2428
#include <stdio.h>

int main(void){
  int N;
  int B[110];
  int i;

  scanf("%d", &N);
  for (i = 1; i <= N-1; i++) {
    scanf("%d", &B[i]);
  }

  int A[110];
  A[1] = B[1];
  A[N] = B[N-1];

  for (i = 2; i <= N-1; i++) {
    if (B[i] < B[i-1]) {
      A[i] = B[i];
    }else{
      A[i] = B[i-1];
    }
  }

  int ans = 0;

  for (i = 1; i <= N; i++) {
    ans += A[i];
  }

  printf("%d\n", ans);
}


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

struct edge
{
	int to;
	long long cost;
};

int n, m;
std::vector<edge> e[100005];
long long v[100005];
bool visited[100005];

int main()
{
	std::cin >> n >> m;

	int start;
	for (int i = 0; i < m; ++i) {
		int l, r, d;
		std::cin >> l >> r >> d;
		--l, --r;
		if (i == 0)
			start = l;

		edge tmp;
		tmp.to = r, tmp.cost = d;
		e[l].emplace_back(tmp);
		tmp.to = l, tmp.cost = -d;
		e[r].emplace_back(tmp);
	}

	for (int i = 0; i < n; ++i) {
		if (!visited[i]) {
			visited[i] = 1;
			v[i] = 0;
			std::queue<int> q;
			q.push(i);
			while (!q.empty()) {
				int val = q.front(); q.pop();
				for (int p = 0; p < e[val].size(); ++p) {
					if (visited[e[val][p].to]) {
						if (v[val] + e[val][p].cost != v[e[val][p].to]) {
							std::cout << "No" << std::endl;
							return 0;
						}
					}
					else {
						v[e[val][p].to] = v[val] + e[val][p].cost;
						visited[e[val][p].to] = 1;
						q.push(e[val][p].to);
					}
				}
			}
		}
	}

	std::cout << "Yes" << std::endl;
	return 0;
}


Measured memory_bytes: 13952
var input = require('fs').readFileSync('/dev/stdin', 'utf8');

var list = input.split('\n');

var n = Number(list[0]);

var a = list[1].split('');

var b = list[2].split('');

var c = list[3].split('');

var num = 0;

var getIndex = (i)  => {
  if (a[i] === b[i] || b[i] === c[i] || c[i] === a[i]) {
    return true;
  }
  return false;
}

for (var j = 0; j < n; j++) {
  if (!getIndex(j)) {
    num += 2;
  } else if (a[j] === b[j] && b[j] === c[j]) {
  } else {
    num += 1;
  }
}

console.log(num);


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

#define pb emplace_back
#define fi first
#define se second
#define all(x) x.begin(), x.end()
#define vi vector
#define forn(i, l, r) for(int i = l; i <= r; i++)
#define IO ios :: sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define pii pair<int,int>
#define f80 double
#define LOCAL 0
#define endl '\n'

typedef long long int ll;
#define int long long int

const int mod = 1e9 + 7;
const int N = 100005;
const int inf = 2e9;

pii a[N];
signed main(){
    IO;
    if(LOCAL){
        freopen("inp.txt", "r", stdin);
    }
    int n, m;
    cin >> n >> m;
    forn(i, 1, m){
        cin >> a[i].se >> a[i].fi;
        a[i].fi--;
    }
    sort(a + 1, a + m + 1);
    int r = a[1].fi;
    int ans = 1;
    for(int i = 1; i <= m; i++){
        if(a[i].se > r){
            r = a[i].fi;
            ans++;
        }
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define endl '\n'

using namespace std;

typedef unsigned long long ull;
typedef long long lld;
typedef long double ld;

typedef pair<int,int> pii;
typedef map<int,int> mii;
typedef vector<int> vi;

int t;

int main()
{
    //freopen("IN.txt","r",stdin);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    string s;
    cin>>s;
    if(s=="ARC")cout<<"ABC";
    else cout<<"ARC";
    return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define INF 2000000000000000000
#define ll long long
using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll M, K;
  cin >> M >> K;
  ll big = pow(2, M) - 1;
  if (K > big) {
    cout << -1 << "\n";
  }
  else if (M == 1) {
    if (K != 0) {
      cout << -1 << "\n";
    }
    else {
      cout << "0 0 1 1" << "\n";
    }
  }
  else {
    cout << K << " ";
    for (ll i = 0; i <= big; ++i) {
      if (i != K) {
        cout << i << " ";
      }
    }
    cout << K << " ";
    for (ll i = big; i >= 0; --i) {
      if (i != K) {
        cout << i << " ";
      }
    }
    cout << "\n";
  }
}


Measured memory_bytes: 4120
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define ls rt << 1
#define rs rt << 1 | 1
#define mp make_pair
#define pb push_back
#define pii pair<int, int>
#define X first
#define Y second
#define pii pair<int, int>
#define pcc pair<char, char>
#define rep(i, x, y) for(int i = x; i <= y; i ++)
#define rrep(i, x, y) for(int i = x; i >= y; i --)
#define eps 1e-9
#define ALL(x) (x).begin(), (x).end()
using namespace std;
inline int read()
{
	int x = 0, f = 1; char ch = getchar();
	while (ch < '0' || ch > '9') { if (ch == '-') f = -1; ch = getchar(); }
	while (ch >= '0' && ch <= '9') { x = x * 10 + ch - '0'; ch = getchar(); }
	return x * f;
}
int len, L, R, aL, aR, ans = 0;
char s[500010];
bool flag = true;
int main()
{
	scanf("%s", s + 1);
	len = strlen(s + 1);
	L = 1; R = len;
	while(L <= R) 
	{
		while(s[L] == 'x') L ++;
		while(s[R] == 'x') R --;
		if(L >= R) break;
		if(s[L] != s[R]) {flag = false; break;}
		while(s[L] == s[R]) L ++, R --;
	}	 	
	if(flag == false) { printf("-1\n"); return 0; }
	L = 1; R = len;
	while(L <= R) 
	{
		aL = 0; 
		aR = 0;
		while(s[L] == 'x') L ++, aL ++;
		while(s[R] == 'x') R --, aR ++;
		ans += abs(aL - aR);
		while(s[L] == s[R]) L ++, R --;
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define int long long
int32_t main(){
   int n ,k;
   cin >> n>>k;
   vector<int> h(n);
  for(int i=0;i<n;i++){
    int x; 
    cin>>x;
    h[i]=x;
  }
   vector<int> dp(n,INT_MAX);
   dp[0]=0;
   if(n>1)
   dp[1]=abs(h[1]-h[0]);
   for(int i=2;i<n;i++){
     for(int j=1;j<=k;j++){
        if(i-j>=0){
         dp[i]=min(abs(h[i]-h[i-j])+dp[i-j],dp[i]);
        }
     }
   }
  cout<<dp[n-1]<<'\n';
}

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

int main(){
    int n;
    cin >> n;
    int arr[n];
      for(int i=0;i<n;i++){
        cin >> arr[i];
    }
    int dp[n];
      dp[0] = 0;
      dp[1] = abs(arr[0] - arr[1]);
      for(int i=2;i<n;i++){
        dp[i] = min( (abs(arr[i] - arr[i-1]) + dp[i-1]), (abs(arr[i] - arr[i-2]) + dp[i-2]));
    }
      cout<< dp[n-1];
      return 0;
}

Measured memory_bytes: 1024
s = input()

is_yes = True
for i in range(len(s)):
    if (i+1)%2 == 0 and s[i] == "R":
        is_yes = False
        break

    if (i+1)%2 == 1 and s[i] == "L":
        is_yes = False
        break

if is_yes is True:
    print("Yes")
else:
    print("No")



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

using namespace std;

bool Solve() {
    string s, t;

    cin >> s >> t;
    s += s;
    const int n = t.size();
    for (int i = 0; i < n; ++i)
        if (s.substr(i, n) == t) return true;
    return false;
}

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

    cout << (Solve() ? "Yes" : "No") << endl;

    return 0;
}


Measured memory_bytes: 256
n, m = map(int, input().split())
s = [0 for _ in range(n + 2)]
s[0] = 1
for _ in range(m):
  i = int(input())
  s[i] = -1
for i in range(n):
  if s[i] != -1:
    if s[i + 1] != -1:
      s[i + 1] += s[i]
    if s[i + 2] != -1:
      s[i + 2] += s[i]
print(s[n] % 1000000007)

Measured memory_bytes: 462744
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
#include<fstream>
#include<set>
using namespace std;
typedef long long ll;

#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++)
#define out(str) cout << str << endl
#define ALL(a) (a).begin(),(a).end()
#define INF (1<<29)

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

ll mod=1e9+7;
ll v[3000][3000]={};
ll N,K;

int main(){
    cin>>N>>K;
    for(int i=0;i<N+1;i++){
        for(int j=0;j<=i;j++){
            if(j==0||j==i){
                v[i][j]=1;
            }
            else{
                v[i][j]=(v[i-1][j-1]+v[i-1][j])%mod;
            }
        }
    }
    rep(i,K){
        out((v[K-1][i]*v[N-K+1][i+1])%mod);
    }

}


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

int main()
{
    int A, B, C;
    cin >> A >> B >> C;

    if (A == B && A != C)
    {
        cout << "Yes" << endl;
    }
    else if (A == C && B != C)
    {
        cout << "Yes" << endl;
    }
    else if (A != C && B == C)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <time.h>
#include <stdlib.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define pb push_back
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
#define ull unsigned long long
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/__gcd((a),(b))
#define clr(x) x.clear()
#define vi vector<int>
#define vll vector<long long>
#define vvi vector<vi>
#define mp make_pair
#define hell 1000000007
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vpii vector<pii>
#define vpll vector<pll>
#define all(a) a.begin(),a.end()
#define ign cin.ignore();

#define o_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define o_setll tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
//member functions :
//1. order_of_key(k) : number of elements strictly lesser than k
//2. find_by_order(k) : k-th element in the set

using namespace std;
using namespace __gnu_pbds;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifdef MY_PROJECT
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

int main()
{
    IOS
    string s;
    cin>>s;
    if(s[2]==s[3]&&s[4]==s[5]){
        cout<<"Yes\n";
    }
    else cout<<"No\n";
    return 0;
}


Measured memory_bytes: 256
#pragma region Header
#ifdef DEBUG
#include "debug.hpp"
#else
#define debug(...)
#define IFD(...)
#ifndef NDEBUG
#define NDEBUG
#endif
#endif
#include <utility>
#include <cstdint>
#include <cmath>
#include <cassert>
#include <vector>
#include <array>
#include <deque>
#include <queue>
#include <stack>
#include <tuple>
#include <set>
#include <map>
#include <unordered_map>
#include <bitset>
#include <string>
#include <functional>
#include <algorithm>
#include <numeric>
#include <stdexcept>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <boost/hana/functional/fix.hpp>
using boost::hana::fix;
using namespace std;
using i32 = int32_t;
using i64 = int64_t;
using u32 = uint32_t;
using u64 = uint64_t;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repd(i, n) for (int i = (n)-1; i >= 0; --i)
#define FOR(i, a, b) for (int i = (a); i <= (b); ++i)
#define FORD(i, b, a) for (int i = (b); i >= (a); --i)
template <typename T>
int SZ(T const &x)
{
    return static_cast<int>(x.size());
}
template <class T>
bool chmax(T &a, T const &b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class T>
bool chmin(T &a, T const &b)
{
    if (b < a)
    {
        a = b;
        return true;
    }
    return false;
}
#pragma endregion

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

    i64 n;
    cin >> n;
    if (n & 1)
    {
        cout << 0 << endl;
        return 0;
    }

    n /= 2;
    i64 ans = 0;
    while (n > 0)
    {
        n /= 5;
        ans += n;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3632
//#include "bits/stdc++.h"

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>
#include<unordered_set>
#include<bitset>
#include<complex>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

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

	int ans[2] = { 0 };
	int N, A[110];
	cin >> N;
	rep(i, 0, N)
	{
		cin >> A[i];
	}

	sort(A, A + N,greater<int>());

	rep(i, 0, N)
	{
		ans[i % 2] += A[i];
	}
	cout << ans[0] - ans[1] << endl;

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main() {
    for (;;) {
        char c = getchar();
        if (c == EOF) break;
        if (c >= 'a' && c <= 'z') {
            c = c + 'A' - 'a';
        } else if (c >= 'A' && c <= 'Z') {
            c = c - 'A' + 'a';
        }
        putchar(c);
    }
}


Measured memory_bytes: 2104
#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<ll, ll>;
using Graph = vector<vector<int>>;
const int INF = 1000000007;

struct UnionFind {
  vector<int> par;  // par[i]:iの親の番号　

  UnionFind(int N) : par(N) {  //最初は全てが根であるとして初期化
    for (int i = 0; i < N; i++) par[i] = i;
  }

  int root(int x) {  // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
    if (par[x] == x) return x;
    return par[x] = root(par[x]);
  }

  void unite(int x, int y) {  // xとyの木を併合
    int rx = root(x);         // xの根をrx
    int ry = root(y);         // yの根をry
    if (rx == ry) return;  // xとyの根が同じ(=同じ木にある)時はそのまま
    par[rx] =
        ry;  // xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
  }

  bool same(int x, int y) {  // 2つのデータx, yが属する木が同じならtrueを返す
    int rx = root(x);
    int ry = root(y);
    return rx == ry;
  }
};

int main() {
  int n, m;
  cin >> n >> m;
  UnionFind tree(n);
  rep(i, m) {
    int x, y, z;
    cin >> x >> y >> z;
    --x, --y;
    tree.unite(x, y);
  }
  vector<bool> e(n);
  int cnt = 0;
  rep(i, n) {
    int r = tree.root(i);
    if (e[tree.root(i)] == false) {
      e[tree.root(i)] = true;
      cnt++;
    }
  }
  cout << cnt << endl;
}


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

using namespace std;

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

namespace std {
    template <>
    struct hash<std::vector<int>> {
        size_t operator()(const vector<int>& v) const {
            std::hash<int> hasher;
            size_t seed = 0;
            for (int i : v) {
                seed ^= hasher(i) + 0x9e3779b9 + (seed<<6) + (seed>>2);
            }
            return seed;
        }
    };
}

int main() {
    int n;
    unordered_set<vector<int>> used;
    while(cin>>n, n) {
        int ans = 0;
        used.clear();
        int nr = (int)sqrt(n) + 1;
        rep(i, nr) {
            int p = i*i;
            if(p > n) break;
            rep(j, nr) {
                int q = p + j*j;
                if(q > n) break;
                rep(k, nr) {
                    int r = q + k*k;
                    if(r > n) break;
                    int l = sqrt(n-r);
                    if(r + l*l != n) continue;
                    vector<int> v = {i, j, k, l};
                    sort(v.begin(), v.end());
                    if(!used.count(v)) {
                        used.insert(v);
                        ans++;
                    }
                }
            }
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 3304
#include<iostream>
#include<iomanip>
#include<cmath>
using namespace std;
int main()
{
  long double i,n,k,temp,res=0, sum = 0.00, p=0.0;
  cin>>n>>k;
  for(i=1;i<=n;i++)
  {
    res = i;
    while(res<k)
    {
      res = res*2;
      p++;
    }
    sum += (1/n)*pow(0.5,p);
    p = 0;
  }
  cout << fixed << setprecision(12) << sum;
}

Measured memory_bytes: 512
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define brep(i,n) for(int i=n-1;i>=0;i--)
#define rep1(i,n) for(int i=1;i<n;i++)
#define cY cout<<"Yes"<<endl
#define cN cout<<"No"<<endl

int main(void){
    string a;
    string b;
    cin >> a >>b;
    int n = a.size();
    int check[26];
    rep(i,26)check[i] = -1;
    rep(i,n){
        if(check[b[i]-'a'] >= 0){
            if(a[check[b[i]-'a']] != a[i]){
                cN; 
                return 0;
            }
        }
        else check[b[i]-'a'] = i;
    }
    rep(i,26)check[i] = -1;
        rep(i,n){
        if(check[a[i]-'a'] >= 0){
            if(b[check[a[i]-'a']] != b[i]){
                cN; 
                return 0;
            }
        }
        else check[a[i]-'a'] = i;
    }
    cY;
    return 0;
}


Measured memory_bytes: 776
/* ****mittal**** */
#include<bits/stdc++.h>
#define ll          long long int 
#define pb          push_back
#define endl        '\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define jell        998244353
#define rep(i,a,b)    for(ll int i=a;i<b;i++)
#define repr(i,a,b)   for(ll int i=a;i>=b;i--)
#define lbnd    lower_bound
#define ubnd        upper_bound
#define mp          make_pair
#define DEC(N)  cout << std::fixed; cout << setprecision(N);
using namespace std;
ll add(ll x,ll y)
{
return (x%hell+y%hell)%hell;
}
ll mul(ll x,ll y)
{
return ((x%hell)*(y%hell))%hell;
}
ll sub(ll x,ll y)
{
return (x-y+hell)%hell;
}
#define N  100005
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll t=1;
  // cin>>t;
    for(int ok=1;ok<=t;ok++)
    {
          
         ll n,m;
         cin>>n>>m;
         ll x;
         cin>>x;
         ll c[n+2],a[n+2][m+2];
         ll ans=hell;
         for(int i=1;i<=n;i++)
         {
         	cin>>c[i];
         	for(int j=1;j<=m;j++)
         	{
         		cin>>a[i][j];
         	}
         }
         ll op=(1<<n)-1;
         for(int i=0;i<=op;i++)
         {
         	  std::vector<ll> v(m+2,0);
         	  ll cnt=0;
         	  for(int j=1;j<=n;j++)
         	  {
         	  	 if((1<<(j-1))&i)
         	  	 {
         	  	 	 cnt+=c[j];
         	  	 	 for(int k=1;k<=m;k++)
         	  	 	 	v[k]+=a[j][k];
         	  	 }
         	  }
         	  ll w=0;
         	  for(int j=1;j<=m;j++)
         	  {
         	  	 if(v[j]<x)
         	  	 	w=1;
         	  }
         	  if(w==0)
         	  {
         	  	 ans=min(ans,cnt);
         	  }
         }
         if(ans==hell)
         	cout<<-1<<endl;
         else
         	cout<<ans<<endl;
    }
    return 0;
}

Measured memory_bytes: 3664
#! /usr/bin/env python


class NodeBintree:

    def __init__(self, key, parent=None):
        self.key = key
        # self.parent = parent
        self.left = None
        self.right = None

    def insert_node (self, n):
        if (self.key is None) or (self.key > n.key):
            if self.left is None:
                self.left = n
                # n.parent = self
            else:
                self.left.insert_node(n)
        else:
            if self.right is None:
                self.right = n
                # n.parent = self
            else:
                self.right.insert_node(n)

    def traverse_inorder (self):
        ret = ""

        if self.left is not None:
            ret += self.left.traverse_inorder()
            # for less in self.left.traverse_inorder():
            #     yield less

        if self.key is not None:
            ret += " {0}".format(self.key)
            # print(" {0}".format(self.key), end="")
            # yield
            # yield self.key
            # yield " {0}".format(self.key)

        if self.right is not None:
            ret += self.right.traverse_inorder()
            # for more in self.right.traverse_inorder():
            #     yield more
        return ret

    def traverse_preorder (self):
        ret = ""

        if self.key is not None:
            ret += " {0}".format(self.key)
            # print(" {0}".format(self.key), end="")
            # yield
            # yield self.key
            # yield " {0}".format(self.key)

        if self.left is not None:
            ret += self.left.traverse_preorder()
            # for less in self.left.traverse_preorder():
            #     yield less

        if self.right is not None:
            ret += self.right.traverse_preorder()
            # for more in self.right.traverse_preorder():
            #     yield more
        return ret

def proc_inputs ():
    num_inputs = int(input())
    inputs = [proc_command(input().split()) for i in range(num_inputs)]
    return inputs

def proc_command (l):
    if len(l) > 1:
        arg = l[1]
    else:
        arg = None
    return {"command": l[0], "arg": arg}

def execute_command (tree, command):
    if command["command"] == "insert":
        tree.insert_node(NodeBintree(int(command["arg"])))
        # return tree

    elif command["command"] == "print":
        print(tree.traverse_inorder() )
        # print()
        print(tree.traverse_preorder() )
        # print()
        #     pass
        # print("")
        # for n in tree.traverse_preorder():
        #     pass
        # print("")
        # print("".join([" {0}".format(n) for n in tree.traverse_inorder()]))
        # print("".join([" {0}".format(n) for n in tree.traverse_preorder()]))

    return


def main ():
    inputs = proc_inputs()
    # print(inputs)
    tree = NodeBintree(None)
    # map(execute_command, tree, inputs)
    for command in inputs:
        execute_command(tree, command)
    exit(0)


if __name__ == "__main__":
    main()





Measured memory_bytes: 293568
#include "bits/stdc++.h"

using namespace std;

using ll = long long;
using ld = long double;
using P = pair<int, int>;
constexpr ld EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr int MOD = 1e9 + 7;

template <typename T>
void printv(const vector<T> &v)
{
    int sz = v.size();
    for (int i = 0; i < sz; i++)
    {
        cout << v[i] << " \n"[i == sz - 1];
    }
}

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

    string s, t;
    cin >> s >> t;
    int n = s.length(), m = t.length();
    s = '$' + s;
    t = 't' + t;
    vector<vector<int>> dp(n + 1, vector<int>(m + 1, 0));
    for (int i = 1; i <= n; i++)
    {
        for (int j = 1; j <= m; j++)
        {
            if (s[i] == t[j])
            {
                dp[i][j] = dp[i - 1][j - 1] + 1;
            }
            else
            {
                dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
            }
        }
    }
    string res = "";
    int i = n, j = m;
    while (i || j)
    {
        int x = dp[i][j];
        if (i && dp[i - 1][j] == x)
        {
            i--;
        }
        else if (j && dp[i][j - 1] == x)
        {
            j--;
        }
        else
        {
            res += s[i];
            i--;
            j--;
        }
    }
    reverse(res.begin(), res.end());
    cout << res << endl;
}

Measured memory_bytes: 35584
#include<iostream>
#include<string>
#include <vector>
#include<stack>
#include<queue>
#include<map>
#include<algorithm>
#include<iomanip>
#include<cmath>
#include<bitset>
using namespace std;
using vi = vector<int>;
using vii = vector<vi>;
using vs = vector<string>;
using pii = pair<int, int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,m,n) for(int i=m;i<n;i++)
#define vsort(v) sort(v.begin(), v.end())
#define rv(v) reverse(v.begin(), v.end())
#define ll long long
#define PI 3.141592653589793
using vll = vector<ll>;
using Graph = vii;
const ll MOD = 1e9 + 7;

int main() {
	string s;
	cin >> s;
	int n = s.size();
	int cnt = 0;
	rep(i, n) {
		if (s[i] != s[n - 1 - i]) cnt++;
	}
	cout << cnt / 2 << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<vector>
#include<string>
#include<iostream>
#include<queue>
#include<map>
#include<set>
#include<complex>
#include<stack>
#include<cmath>

using namespace std;

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

int main(){
	
	double xa,ya,xb,yb,xc,yc,xd,yd;
	while(scanf("%lf%lf%lf%lf%lf%lf%lf%lf",&xa,&ya,&xb,&yb,&xc,&yc,&xd,&yd)!=EOF){
		if(xa>xb)swap(xa,xb);
		if(ya>yb)swap(ya,yb);
		
		if(xc>xd)swap(xc,xd);
		if(yc>yd)swap(yc,yd);
		
		//printf("((%.3lf %.3lf)(%.3lf %.3lf))  ((%.3lf %.3lf)(%.3lf %.3lf))\n",xa,ya,xb,yb,xc,yc,xd,yd);
		
		bool xin = (xa<xd && xb>=xc) || (xc<xb && xd>=xa);
		bool yin = (ya<yd && yb>=yc) || (yc<yb && yd>=ya);
		
		if(xin&&yin)puts("YES");
		else puts("NO");
	}
}

Measured memory_bytes: 1188
# coding: utf-8
# Your code here!

n = int(input())

a = list(map(int,input().split(" ")))

dai = 0

for i in range(1,n):
    if a[i] < a[i-1]:
        dai += a[i-1] - a[i]
        a[i] = a[i-1]
        
print(dai)

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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
//#pragma GCC optimize ("-O3") 
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x) 
#endif
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2019/03/11  Problem: ABC 088 A / Link: http://abc088.contest.atcoder.jp/tasks/abc088_a  ----- */


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

	LL N, A; cin >> N >> A;
	N %= 500;


	LL ans = A>=N;
	
	
	cout << (ans?"Yes":"No") << "\n";

	return 0;
}


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

typedef long long ll;
using namespace std;

int main(void) {
   ll N;
   cin>>N;
   string s;
   cin>>s;
   if (N>=3200) cout<<s<<endl;
   else cout<<"red"<<endl;

   return 0;
}

Measured memory_bytes: 256