akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;

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

    int N; cin >> N;
    int cnt = 0;
    int p = INT_MAX;

    for (int i = 0; i < N; ++i) {
        int v; cin >> v;
        if (v <= p) {
            ++cnt;
        }
        p = v;
    }

    cout << cnt << endl;
    cout << N << endl;

    return 0;
}



Measured memory_bytes: 3216
#include <bits/stdc++.h>
using namespace std;
const int mxH=10, mxW=1e3;
int h, w, k, ans=1e9;
string g[mxH];
vector<int> v[mxW];

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

	cin >> h >> w >> k;
	for(int i=0; i<h; ++i)
		cin >> g[i];
	for(int i=0; i<1<<h-1; ++i) {
		int ca=__builtin_popcount(i);
		for(int j=0; j<w; ++j) {
			int s=0;
			for(int k=0; k<h; ++k) {
				s+=g[k][j]&1;
				if(i>>k&1) {
					v[j].push_back(s);
					s=0;
				}
			}
			v[j].push_back(s);
			for(int vi : v[j])
				if(vi>k)
					ca=1e9;
		}
		vector<int> u(v[0].size());
		for(int j=0; j<w; ++j) {
			bool split=0;
			for(int l=0; l<u.size(); ++l)
				split|=u[l]+v[j][l]>k;
			if(split) {
				++ca;
				u=vector<int>(u.size());
			}
			for(int l=0; l<u.size(); ++l)
				u[l]+=v[j][l];
			v[j].clear();
		}
		ans=min(ca, ans);
	}
	cout << ans;
}


Measured memory_bytes: 384
h, w, a, b = map(int, input().split( ))

ans = [[0 for i in range(w)] for j in range(h)]

for i in range(h):
    tmp = ''
    for j in range(w):
        w_check = 1
        h_check = 1
        if j < a:
            w_check = -1
        if i < b:
            h_check = -1
        
        if w_check * h_check == 1:
            ans[i][j] = 0
        else:
            ans[i][j] = 1
        
        tmp += str(ans[i][j])
    print(tmp)


Measured memory_bytes: 14068
N,M=map(int, input().split()) 
S = [list(map(int, input().split()))[1:] for _ in range(M)]
P = list(map(int, input().split()))

ans = 0
for i in range(1 << N):
    flg = True
    for j in range(M):
        cnt = 0
        for s in S[j]:
            if i & (1<<(s-1)):
                cnt += 1
        if cnt % 2 != P[j]:
            flg = False
            break

    if flg:
        ans += 1

print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,b,a) for(int i=b;i>=a;i--)
#define fori(a) for(auto i : a )
#define all(a) begin(a), end(a)
#define set(a,b) memset(a,b,sizeof(a))
#define sz(a) a.size()
#define pi 3.14159
#define ll long long
#define ull unsigned long long
#define pb push_back
#define PF push_front //deque
#define mp make_pair
#define pq priority_queue
#define mod 1000000007
#define f first
#define s second
#define pii pair< int, int >
#define vi vector<int>
#define vpii vector<pii>
#define debug(v) for(auto i:v) cout<<i<<" ";
#define tc int t; cin >> t; while(t--)

using namespace std;
string repeat(string s, int n) {
    string s1 = "";
    for (int i=0; i<n;i++)
        s1+=s;
    return s1;
}
string getString(char x) {
    string s(1, x);
    return s;
}

void optimizeIO(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}
int gcd(int a, int b){
    if (a == 0)  return b;
    return gcd(b % a, a);
}
struct dsu{
	std::vector<int> par,rank;
	dsu(int n):par(n+1),rank(n+1,1){
		rep(i,1,n+1) par[i]=i;
	}
	int root(int a){
		if(a==par[a]) return a;
		return par[a]=root(par[a]);
	}
	void merge(int a,int b){
		a=root(a);
		b=root(b);
		if(a==b) return;
		if(rank[b]>rank[a]) swap(a,b);
		par[b]=a;
		rank[a]+=rank[b];
	}
};
void  solve(){
	int n,m,x,y;
	cin>>n>>m;
	int  p[n+1];
	rep(i,1,n+1) cin>>p[i];
	dsu d(n);
	rep(i,0,m){
		cin>>x>>y;
		d.merge(x,y);
	}
	map<int,int> m1;
	rep(i,1,n+1){
		m1[p[i]]=i;
	}
	int ans=0;
	rep(i,1,n+1){
		if(d.root(i)==d.root(m1[i])) ans++;
	}
	cout<<ans<<endl;
}
int main(){
    optimizeIO();
    // tc
    { solve();
    }
}


Measured memory_bytes: 8972
<?php

  list($s) = explode(" ", trim(fgets(STDIN)));

//  $s = str_repeat("?", 100000);
  $n = strlen($s);

  $s = strrev($s);
  $s = str_split($s);

  $mod = 1000000007;

  $dp = [];
  $dp[0] = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
  $mul = 1;

  for ($i=0; $i<$n; ++$i) {
    $dp[$i+1] = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
    if($s[$i] === '?'){
      for($k=0; $k<10; $k++){
        $diff = $mul * $k % 13;
        for($j=0; $j<13; ++$j){
          $dp[$i+1][($diff+$j)%13] += $dp[$i][$j];
        }
      }
    }else{
      $diff = $mul * $s[$i] % 13;
      for($j=0; $j<13; $j++){
        $dp[$i+1][($diff+$j)%13] += $dp[$i][$j];
      }
    }
    for($k=0; $k<13; $k++){
      $dp[$i+1][$k] %= $mod;
    }
    $mul = $mul * 10 % 13;
  }
//var_dump($dp);

  echo $dp[$n][5];

Measured memory_bytes: 84596
from collections import deque
def bfs(loc):
  global ans
  d=[[float('inf')]*w for i in range(h)]
  dx=[1,0,-1,0]
  dy=[0,1,0,-1]
  que=deque([])
  que.append(loc)
  d[loc[0]][loc[1]]=0
  while que:
    p=que.popleft()
    for i in range(4):
      nx=p[0]+dx[i]
      ny=p[1]+dy[i]
      if 0<=nx<h and 0<=ny<w and maze[nx][ny]=='.' and d[nx][ny]==float('inf'):
        d[nx][ny]=d[p[0]][p[1]]+1
        que.append([nx,ny])
        if ans<d[nx][ny]:ans=d[nx][ny]
  return ans

h,w=map(int,input().split())
maze=[list(input()) for i in range(h)]
a=0
ans=0
loc=[]
for i in range(h):
  for j in range(w):
    if maze[i][j]!='#':
      loc=[i,j]
    else:continue
    a=max(a,bfs(loc))
print(a)

Measured memory_bytes: 3316
n, m, s = map(int, input().split())

edges = [[] for _ in range(n)]
amax = 0
for _ in range(m):
   u, v, a, b = map(int, input().split())
   edges[u-1].append((v-1, a, b))
   edges[v-1].append((u-1, a, b))
   amax = max(a, amax)

lcoins = amax * (n - 1)

cost = []
time = []
for _ in range(n):
   c, d = map(int, input().split())
   cost.append(c)
   time.append(d)

from heapq import *


INF = 1<<61
M = 2500
if s >= M:
   s = M - 1

dist = [[INF] * M for _ in range(n)]
dist[0][s] = 0
q = [(0, s, 0)]

while q:
   dv, num, v = heappop(q)

   if dist[v][num] < dv:
      continue

   # update
   if num + cost[v] < M and dv + time[v] < dist[v][num+cost[v]]:
      dist[v][num+cost[v]] = dv + time[v]
      heappush(q, (dv+time[v], num+cost[v], v))

   for next, a, b in edges[v]:
      if num >= a and dv+b < dist[next][num-a]:
         dist[next][num-a] = dv+b
         heappush(q, (dv+b, num-a, next))


for i in range(1, n):
   print(min(dist[i]))


Measured memory_bytes: 26140
#include <stdio.h>

int sumDigit(int n);

int main(void){
    int n,a,b,i,sum=0,sumd;
    scanf("%d %d %d",&n,&a,&b);
    for(i=1;i<=n;i++){
        sumd=sumDigit(i);
        if(sumd>=a && sumd<=b){
            sum+=i;
        }
    }
    printf("%d\n", sum);
    return 0;
}

int sumDigit(int n){
    int sum=0;
    while(n>0){
        sum+=n%10;
        n=n/10;
    }
    return sum;
}

Measured memory_bytes: 128
#include <stdio.h>

int main(void) {
	int c[3]={0,0,0};

	int i;
	for(i=0;i<3;i++) {
		scanf("%d",&c[i]);
	}
	
	int j=3;
	for(i=0;i<2;i++) {
		if(c[i]==c[i+1]) {
			j--;
		}
	}
	if(c[0]==c[2]) {
		j--;
	}
	if(c[0]==c[1]&&c[1]==c[2]) {
		j++;
	}

	printf("%d\n",j);

	return 0;
}


Measured memory_bytes: 128
#include <iostream>

using namespace std;

typedef long long ll;
void show_path_list();

ll path_list[10][10];

void init(){
  for(int i = 0; i < 10; i++){
    for(int j = 0; j < 10; j++){
      path_list[i][j] = 99999999999;
    }
  }
}

int main(){
  int n, from, to, cost, t;

  while(true){
    t = 0;

    init();
    cin >> n;

    if( n == 0 ) break;

    for(int i = 0; i < n; i++){
      cin >> from >> to >> cost;
      path_list[from][to] = cost;
      path_list[to][from] = cost;
      t = max( t, max( from, to ) );
    }
    t++;

    for(int i = 0; i < t; i++){
      path_list[i][i] = 0;
    }

    for(int k = 0; k < t; k++){
      for(int i = 0; i < t; i++){
        for(int j = 0; j < t; j++){
          path_list[i][j] = min( path_list[i][j], path_list[i][k] + path_list[k][j] );
        }
      }
    }

    ll min_town, min_cost = 9999999999;

    for(int i = 0; i < t; i++){
      ll cost = 0;
      for(int j = 0; j < t; j++){
        cost += path_list[i][j];
      }
      if( cost < min_cost ){
        min_town = i;
        min_cost = cost;
      }
    }
    //show_path_list();

    cout << min_town << " " << min_cost << endl;
  }
}

void show_path_list(){
  for(int i = 0; i < 10; i++){
    for(int j = 0; j < 10; j++){
      cout << path_list[i][j] << " ";
    }
    cout << endl;
  }
}

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

int N;
int f[100],a[100],t[100],x[100],y[100];

int main(){
    cin>>N;
    for(int i=0;i<N;i++)cin>>f[i]>>a[i]>>t[i]>>x[i]>>y[i];
    for(int b=0;b<2;b++){
        int dist=-1,tim=-1;

        for(int i=0;i<N-1;i++){
            if(t[i]==t[i+1]&&t[i]==b&&a[i]!=a[i+1]){
                int d=(x[i]-x[i+1])*(x[i]-x[i+1])+(y[i]-y[i+1])*(y[i]-y[i+1]);
                int x=f[i+1]-f[i];
                if(dist<d){
                    dist=d;
                    tim=x;
                }
                else if(dist==d){
                    tim=min(tim,x);
                }
            }
        }
        if(dist==-1)puts("-1 -1");
        else printf("%.20lf %.20lf\n",sqrt(dist),tim/60.0);
    }
    return 0;
}

Measured memory_bytes: 1196
#include <iostream>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <math.h>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <climits>
#include <bitset>
#include <list>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

int main(){
    ll x, y;
    cin >> x >> y;
    if(x%y==0) cout << -1 << endl;
    else cout << x << endl;
    return 0;
}

Measured memory_bytes: 256
#include<algorithm>
#include<iostream>
#include<cstdlib>
#include<iomanip>
#include<cstring>
#include<complex>
#include<vector>
#include<cstdio>
#include<string>
#include<bitset>
#include<ctime>
#include<cmath>
#include<queue>
#include<stack>
#include<map>
#include<set>
#define Cpy(x,y) memcpy(x,y,sizeof(x))
#define Set(x,y) memset(x,y,sizeof(x))
#define FILE "a"
#define mp make_pair
#define pb push_back
#define RG register
#define il inline
using namespace std;
typedef unsigned long long ull;
typedef vector<int>VI;
typedef long long ll;
typedef double dd;
const int N=100010;
const int mod=19940417;
const int base=26;
const dd eps=1e-6;
const int inf=2147483647;
const ll INF=1ll<<60;
const ll P=100000;
il ll read(){
  RG ll data=0,w=1;RG char ch=getchar();
  while(ch!='-'&&(ch<'0'||ch>'9'))ch=getchar();
  if(ch=='-')w=-1,ch=getchar();
  while(ch<='9'&&ch>='0')data=data*10+ch-48,ch=getchar();
  return data*w;
}

il void file(){
  srand(time(NULL)+rand());
  freopen(FILE".in","r",stdin);
  freopen(FILE".out","w",stdout);
}

int n,m,x[N],y[N],p[N],q[N],k[N],s[N];
il void er(){puts("-1");exit(0);}
int main()
{
  n=read();m=31;
  for(RG int i=1;i<=n;i++){
    x[i]=read();y[i]=read();
    p[i]=x[i]+y[i];q[i]=x[i]-y[i];
    x[i]=abs(x[i]);y[i]=abs(y[i]);
    if(i!=1&&((x[i-1]+y[i-1])&1)!=((x[i]+y[i])&1))er();
  }
  m+=(!((x[n]+y[n])&1));
  printf("%d\n",m);
  for(RG int i=0;i<31;i++)printf("%d ",1<<i);
  if(!((x[n]+y[n])&1))printf("1 ");puts("");
  for(RG int i=1;i<=n;i++){
    memset(k,0,sizeof(k));memset(s,0,sizeof(s));
    //printf("%d,%d\n",p[i],q[i]);
    if(m==32){k[32]=s[32]=1;p[i]--;q[i]--;}
    for(RG int j=30;~j;j--)
      if(p[i]>0)k[j+1]=1,p[i]-=(1<<j);
      else k[j+1]=0,p[i]+=(1<<j);
    for(RG int j=30;~j;j--)
      if(q[i]>0)s[j+1]=1,q[i]-=(1<<j);
      else s[j+1]=0,q[i]+=(1<<j);
    for(RG int j=1;j<=m;j++)
      if(k[j]&&s[j])putchar('R');
      else if(k[j]&&!s[j])putchar('U');
      else if(!k[j]&&s[j])putchar('D');
      else if(!k[j]&&!s[j])putchar('L');
    puts("");
  }
  return 0;
}


Measured memory_bytes: 1152
#include<iostream>
#include<map>
using namespace std;
typedef long long ll;
#define REP(i,n) for(ll i=0;i<n;i++)
#include<algorithm>
int main(){
ll n,k;
cin >>n>>k;
ll a[n],b[n];
REP(i,n){
cin >>a[i]>>b[i];
}
map<ll,ll> number;
REP(i,n){
number[a[i]]+=b[i];
}
sort(a,a+n);
ll now=a[0];
ll count=number[now];
bool flag=true;
REP(i,n){
if(k<=count){
cout<<now;
flag=false;
break;
}
if(now!=a[i]){
count+=number[a[i]];
now=a[i];
}

}

if(flag){
cout<<a[n-1];
}
return 0;
}


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

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
#define PI 3.14159265359 //πの値
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

 
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
ll A,B;
cin >> A >> B;
if(A<=B*2) cout << 0;
else cout << A-B*2;
}

Measured memory_bytes: 3640
#include<iostream>

using namespace std;

class Cube{
public:
    int f[6];
    Cube(){} //??????
    void roll_y(){roll(0,2,5,3);} // to W  W１回で, 上面は1 \to 3に変わる
    void roll_x(){roll(0,1,5,4);} // to N N１回で, 上面は 1 \to 2へ変わる
    void roll(int i, int j, int k, int l){
        int t = f[i]; f[i] = f[j]; f[j] = f[k]; f[k] = f[l]; f[l] = t; //上面の値をfへ避難させておく
    }
    void move(char ch){
        if(ch == 'E') for(int i = 0; i < 3; i++) roll_y(); //東に1動くことは, 西へ三回動かすことと同値である.
        if(ch == 'W') roll_y();
        if(ch == 'N') roll_x();
        if(ch == 'S') for(int i = 0; i < 3; i++) roll_x(); //南に1動くことは, 北へ三回動かすことと同値である.
    }
};

int main(){
    Cube c;
    string com;
    
    for(int i = 0; i < 6; i++) cin >> c.f[i]; //６つの側面の数字を保持する
    cin >> com;
    
    for(int i = 0; i < com.size(); i++) c.move(com[i]); //命令に従いサイコロを転がす
    
    cout << c.f[0] << endl; //サイコロを転がし終わった後の上面の値を出力する
    return 0;
}



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

int main() {
	int n, k, x, y, a, b;
	cin >> n >> k >> x >> y;
	a = (n > k) ? k : n;
	b = (n > k) ? n - k : 0;
	cout << (a * x + b * y) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define pii pair<int, int>
#define F first
#define S second
#define pb push_back

const int P = 1e9+7;

using namespace std;

int n, h, w;
pii p[3030];
int dp[3030], f[202020];

int add(int a, int b){
	a += b;
	if(a>=P) return a-P;
	return a;
}
int sbt(int a, int b){
	a -= b;
	if(a<0) return a+P;
	return a;
}
int mul(int a, int b){
	ll ab = (ll)a*b;
	int c = ab/P;
	ll cP = (ll)c*P;
	return ab-cP;
}

int pow(int a, int b){
	if(b==0) return 1;
	if(b&1) return mul(a, pow(a, b-1));
	return pow(mul(a, a), b/2);
}

int abCb(int a, int b){
	return mul(f[a+b], mul(pow(f[b], P-2), pow(f[a], P-2)));
}

int main(){


	cin >> h >> w >> n;
	for(int i=1; i<=n; i++) cin >> p[i].F >> p[i].S;
	p[n+1] = {h, w};
	sort(p, p+n+2);

	f[0] = 1;
	for(int i=1; i<=h+w; i++) f[i] = mul(f[i-1], i);

	dp[0] = 1;

	for(int i=1; i<n+2; i++){
		dp[i] = abCb(p[i].F-1, p[i].S-1);
		for(int j=1; j<i; j++){
			if(p[j].S <= p[i].S){
				int pth = mul(dp[j], abCb(p[i].F-p[j].F, p[i].S-p[j].S));
				dp[i] = sbt(dp[i], pth);
			}
		}
	}

	cout << dp[n+1] << endl;

	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
#define INF ((1<<30)-1)
#define LINF (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; }
typedef long long ll;
typedef pair<int,int> P;

int main(){
    int n;
    cin >> n;
    vector<string> v[20];
    for(int i=1;i<10;i++)v[1].push_back(to_string(i));
    // if(n<10){
    //     cout << n << endl;
    //     return 0;
    // }
    for(int i=2;i<13;i++){
        for(auto s:v[i-1]){
            if(s[i-2]!='0')v[i].push_back(s+(char)(s[i-2]-1));
            v[i].push_back(s+to_string(s[i-2]-'0'));
            if(s[i-2]!='9')v[i].push_back(s+to_string(s[i-2]-'0'+1));
        }
    }
    int id = n;
    for(int i=1;i<13;i++){
        if(id<v[i].size()){
            cout << v[i][id-1] << endl;
            return 0;
        }
        else {
            id -= v[i].size();
        }
    }
}

Measured memory_bytes: 108908
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
const int maxn=2e5+10;
int n;
long long a[maxn],cnt[maxn];
int main()
{
    memset(cnt,0,sizeof(cnt));
    long long sum=0;
    scanf("%d",&n);
    for(int i=0;i<n;i++)
    {
        scanf("%lld",&a[i]);
        cnt[a[i]]++;
    }
    for(int i=1;i<maxn;i++)
        sum+=cnt[i]*(cnt[i]-1)/2;
    for(int i=0;i<n;i++)
        printf("%lld\n",sum-(cnt[a[i]]-1));
    return 0;
}


Measured memory_bytes: 5632
#include <bits/stdc++.h>
#define D(a) do{cout<<#a<<": ";for(auto i:a)cout<<i<<' ';cout<<endl;}while(0)
using namespace std;
int main()
{
    int A, B, C; cin >> A >> B >> C;
    cout << min(C, A + B + 1) + B << endl;
    return 0;
}

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

using namespace std;

const int MAXN=100100;

int split(int* A,int s,int t)
{
	int x=A[t];
	int i=s-1;
	for(int j=s;j<t;j++)
		if(A[j]<=x)
			swap(A[j],A[++i]);
	swap(A[++i],A[t]);
	return i;
}

int main()
{
	int n;
	static int A[MAXN];
	scanf("%d",&n);
	for(int i=0;i<n;i++)
		scanf("%d",&A[i]);
	int w=split(A,0,n-1);
	for(int i=0;i<n;i++)
		if(i==w) printf("[%d]%c",A[i],i+1==n?'\n':' ');
		else printf("%d%c",A[i],i+1==n?'\n':' '); 
	return 0;
}

Measured memory_bytes: 3500
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
   string s;
   cin>>s;
   vector<int>v(222);
   int c=0;
   for(int i=0;i<v.size();i++)
   {
      v[i]=0;

   }
   for(int i=0;i<s.size();i++)
   {

      v[s[i]]++;

   }
 /* for(int i=0;i<v.size();i++)
  {
      if(v[i]!=0)
      cout<<v[i]<<" ";
  }*/
   for(int i=0;i<v.size();i++)
   {
    if(v[i]%2!=0)
    {
         cout<<"No";

         return 0;
    }
   }

    cout<<"Yes";


    return 0;
}

Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
#define     ll           long long
#define     sf(n)        scanf("%lld",&n)
#define     pf(n)        printf("%lld\n",&n)
#define     ct(p)        cout<<p<<endl
#define     mem(a)       memset(a,0,sizeof a)
#define     yes          cout<<"YES"<<endl
#define     no           cout<<"NO"<<endl
ll a[10000000],b[1000000];
map<ll,ll>mp;

///......................................///

int main()
{
    cin.sync_with_stdio(false);
    ll i,j,k,l,c,v,b[1000],aa[1000],bb[10000],n,m,r,t;
    // ll bb[10][10];
    ll x1,x2,y1,y2,x3,x4,x5,x6;
    string s,s1,s2,s3,ss[10000];
    s1="CODEFORCES";

    while(cin>>s)
    {
        c=0;
        for(i=0; i<s.size(); i++)
        {
            if(s[i]=='1')
                c++;
        }
        cout<<c<<endl;
    }
}






Measured memory_bytes: 384
B = int(input())
b = {}
for i in range(B):
    a = input()
    if a in b:
        b[a] += 1
    else:
        b[a] = 1

R = int(input())
for i in range(R):
    a = input()
    if a in b:
        b[a] -= 1
    else:
        b[a] = -1
ans = max(b.values())
if max(b.values()) < 0:
    ans = 0

print(ans)

Measured memory_bytes: 3064
import java.util.*;
  public class Main {
     public static void main(String[] args) {
         Scanner sc = new Scanner(System.in);
         int a = sc.nextInt();
         int b = sc.nextInt();
         if (a + b >= 24) System.out.print(a + b - 24);
             else System.out.print(a + b);
     }
}


Measured memory_bytes: 22100
import qualified Data.Text as T
import qualified Data.Text.IO as T
import qualified Data.Text.Read as T
import Data.List (sort, group)

main :: IO ()
main = do
  n <- unsafeSignedDecimal <$> T.getLine :: IO Int
  ss <- sequence . replicate n $ getLine :: IO [String]
  print . sum . map (count . length) . group . sort . map sort $ ss

count :: Int -> Int
count k = (k * (k - 1)) `div` 2

unsafeSignedDecimal :: T.Text -> Int
unsafeSignedDecimal s = case T.signed T.decimal s of
  Right (n, _) -> n


Measured memory_bytes: 114044
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>
#define rep(i,n) for(int long long i=0;i<n;i++)
typedef int long long ll;
using namespace std;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
ll m[100001];

int main(){
    ll n,a,b;
    cin>>n>>a>>b;
    vector<ll> v;
    rep(i,n){
        ll x;cin>>x;
        v.push_back(x);
    }
    ll ans=0;
    for(int i=0;i<v.size()-1;i++){
        ll k=v[i+1]-v[i];
        k=k*a;
        if(k<=b){
            ans+=k;
        }else{
            ans+=b;
        }
        
    }
    cout<<ans<<endl;
    
return 0;
}


Measured memory_bytes: 1400
n = int(input())
A = list(map(int,input().split()))

xn = 0
for i in range(n-1):
    xn = xn + (-1) ** (i+1) * int(A[i])

xn = xn + A[n-1]

x = []
x1 = 2*A[n-1]-xn
x.append(x1)

for i in range(n-1):
    xi=2*A[i]-x1
    x.append(xi)
    x1 = xi
print(*x)


Measured memory_bytes: 14028
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string { sc.Scan(); return sc.Text() }
func scanInt() int { a,_ := strconv.Atoi(scanString()); return a }
func scanInt64() int64 { a,_ := strconv.ParseInt(scanString(),10,64); return a }
func scanFloat64() float64 { a,_ := strconv.ParseFloat(scanString(),64); return a }

func scanInts(n int) []int {
	res := make([]int, n); for i := 0; i < n; i++ { res[i] = scanInt() }; return res
}

func abs(a int) int { if a<0 { return -a }; return a }
func min(a,b int) int { if a<b { return a }; return b }
func max(a,b int) int { if a>b { return a }; return b }

//•*¨*•.¸¸♪Main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1000000)

	h := scanInt()
	w := scanInt()
	a := scanInt()
	b := scanInt()

	c,d := 0,1
	for i := 0; i < h; i++ {
		if i != b {
			c,d = d,c
		}
		for j := 0; j < w; j++ {
			if j == a {
				c,d = d,c
			}
			fmt.Fprint(wr,c)
		}
		fmt.Fprintln(wr)
	}
	wr.Flush()
}

Measured memory_bytes: 6400
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define pb emplace_back
#define mp make_pair
#define f(i,a,n) for(int i=a ; i<n ; i++)
#define F first
#define S second
#define vll vector<ll>
#define fast ios:: sync_with_stdio(false),cin.tie(0);
#define COUT cout<<fixed<<setprecision(12)
#define SET set<ll,greater<ll>>gquiz
#define ITERATOR set<ll,greater<ll>> :: iterator itr
#define V vector<ll>vector
#define sz size()
#define A vector<pair<ll,ll>>vect
ll N=100000,M=100000;
#define B vect.push_back(make_pair(N,M));
ll MOD=1000000007;
 
ll gcd(ll a,ll b) 
{ 
    if (a == 0) 
        return b; 
    return gcd(b % a, a); 
} 
int main()
{
	ll a,b;
	cin>>a>>b;
	ll c=a-2*b;
	if(c<=0)
	cout<<"0";
	else
	cout<<c;
	
}

Measured memory_bytes: 256
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import (division, absolute_import, print_function,
                        unicode_literals)

from sys import stdin
from string import ascii_lowercase
from itertools import count

def gcd(m, n):
    m, n = sorted([m, n])
    while n:
        m, n = n, m % n
    return m

def encode(char, A, B):
    return chr(((A * (ord(char) - 97) + B) % 26) + 97)

def solve(words):
    for a in (i for i in count(0) if gcd(i, 26) == 1):
        for b in range(26):
            for word in words:
                that = ''.join(encode(c, a, b) for c in 'that')
                if word == that:
                    return (a, b)
                this = ''.join(encode(c, a, b) for c in 'this')
                if word == this:
                    return (a, b)

def main():
    for _ in range(int(stdin.readline())):
        line = stdin.readline()
        a, b = solve([s for s in line.split() if len(s) == 4])
        d = {encode(c, a, b): c for c in ascii_lowercase}
        d[b' '] = b' '
        d[b'\n'] = ''
        print(''.join(d[c] for c in line))

if __name__ == '__main__':
    main()

Measured memory_bytes: 4596
#include<bits/stdc++.h>
using namespace std;
int main(){
    int A,B,K;
    int count=0;
    int ans=0;
    cin >> A >> B >> K;
    for (int i=100; i>=1; i--){
        if (A%i==0 && B%i==0) count++;
        if (count == K){
            ans = i;
            break;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
package main

import(
    "fmt"
)

func main() {
    var s string
    fmt.Scan(&s)
    if s == "SUN" {
        fmt.Println(7)
    } else if s == "MON" {
        fmt.Println(6)
    } else if s == "TUE" {
        fmt.Println(5)
    } else if s == "WED" {
        fmt.Println(4)
    } else if s == "THU" {
        fmt.Println(3)
    } else if s == "FRI" {
        fmt.Println(2)
    } else if s == "SAT" {
        fmt.Println(1)
    }
}


Measured memory_bytes: 512
#include <algorithm>
#include <iostream>
#include <queue>
#include <cmath>
#include <map>
#include <set>
#include <iomanip>
#include <vector>
using namespace std;
typedef long long ll;
typedef long double ld;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
#define INF 100000000
#define MAX 200001
#define MOD 1000000009
ll fac[MAX],finv[MAX],inv[MAX];
typedef vector<vector<int> > Graph;
const int m=2019;

int main(){
    string s;cin>>s;
    int n=s.size();
    reverse(s.begin(),s.end());
    int x=1,tot=0;
    vector<int> cnt(m);
    ll ans=0;
    for(int i=0;i<n;i++){
        cnt[tot]++;
        tot+=(s[i]-'0')*x;
        tot%=m;
        ans+=cnt[tot];
        x=x*10%m;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3692
#include <iostream>
#include <vector>

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

  std::vector<int> v(n);
  for (auto&& vi : v) std::cin >> vi;

  std::vector<int> c(n);
  for (auto&& ci : c) std::cin >> ci;

  int max = 0;
  for (int i = 0; i < n; ++i) {
    const auto diff = v[i] - c[i];
    if (diff > 0) max += diff;
  }

  std::cout << max << std::endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(){
  int a,b;
  scanf("%d%d",&a,&b);
  if(a<b){
    printf("a < b\n");
  }
  if(a>b){
    printf("a > b\n");
  }
  if(a==b){
    printf("a == b\n");
  }
  return 0;
}

Measured memory_bytes: 2596
#include <iostream>
#include <vector>
//#include <string>
//#include <algorithm>
//#include <math.h>
//#include <queue>
//#include <stack>
//#include <iomanip>

// sometimes used
//#include <set>
//#include <map>
//#include <numeric>
//#include <list>
//#include <deque>
//#include <unordered_map>

typedef long long LL;
//typedef long double LD;
using namespace std;
 
//#define MOD 1000000007
//#define MAX 200100
//#define NIL -1

LL gcd(LL a, LL b){
    LL tmp; 
    if(a<b){
        tmp = a;
        a = b;
        b = tmp;
    }
    tmp = a%b;
    while(tmp!=0){
        a = b;
        b = tmp;
        tmp = a%b;
    }

    return b;
}

int main() {
    int n;
    vector<LL> t;
    LL tmp_t;
    cin >> n;
    for(int i=0; i<n; i++){
        cin >> tmp_t;
        t.push_back(tmp_t);
    }

    //sort(t.begin(), t.end(), greater<LL>());

    LL ans=1;
    for(int i=0; i<n; i++){
        LL tmp_ans=ans;
        LL tmp_gcd=gcd(ans, t[i]);
        ans=t[i]/tmp_gcd;
        ans=ans*tmp_ans;
        //cout << ans << endl;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;


ll n, m;
ll a[2005], b[2005];
ll dp[2005][2005], sum[2005][2005];
 
int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    cin >> n >> m;
  for(int i = 1; i <= n; i++) cin >> a[i];
  for(int i = 1; i <= m; i++) cin >> b[i];
 
  dp[0][0] = 1;
  for(int i = 0; i <= n; i++) sum[i][0] = 1;
  for(int i = 0; i <= m; i++) sum[0][i] = 1;
 
  for(int i = 1; i <= n; i++){
    for(int j = 1; j <=m; j++){
      if(a[i] == b[j]) dp[i][j] = sum[i-1][j-1];
      sum[i][j] = sum[i-1][j] + sum[i][j-1] - sum[i-1][j-1] + dp[i][j] + mod;
      sum[i][j] %= mod;
    }
  }
  cout << sum[n][m] << endl;
    return 0;
}


Measured memory_bytes: 62848
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
#define all(x) (x).begin(), (x).end()
ll inf = LLONG_MAX;
long double pi = M_PI;
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

int main() {
  ll n;
  cin >> n;
  vll a(n);
  for (ll i = 0; i < n; i++) cin >> a[i];
  sort(all(a));
  cout << a[n - 1] - a[0] << endl;
}


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

ll modinv(ll a,ll m){
   ll b=m,u=1,v=0;
   while(b){
      ll t=a/b;
      a-=t*b; 
      swap(a,b);
      u-=t*v; 
      swap(u,v);
   }
   u%=m;
   if(u<0) u+=m;
   return u;
}

ll gcd(ll x,ll y){
   if(y==0) return x;
   else return gcd(y,x%y);
}
ll lcm(ll x,ll y){
   return x/gcd(x,y)*y;
}



int main(){
   int n,m;
   cin>>n>>m;
   int a[n],b[n],c[m],d[m];
   rep(i,n){
      cin>>a[i]>>b[i];
   }
   rep(i,m){
      cin>>c[i]>>d[i];
   }

   rep(i,n){
      int ans;
      int x=a[i],y=b[i];
      int kyori=1000000000;
      rep(j,m){
         int kari=abs(x-c[j])+abs(y-d[j]);
         if(kari<kyori){ 
            ans=j+1; 
            kyori=kari;
         }
      }
      cout<<ans<<endl;
   }

   
   

   return 0;
}



Measured memory_bytes: 256
#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 = (a); i > (b); --i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOREACH(x, a) for (auto &(x) : (a))
#define VECCIN(x)            \
	for (auto &youso_ : (x)) \
	cin >> youso_
#define mp make_pair
#define bitcnt __builtin_popcount
#define All(a) (a).begin(), (a).end()
template <typename T = long long>
inline T IN()
{
	T x;
	cin >> x;
	return (x);
}
inline void CIN() {}
template <class Head, class... Tail>
inline void CIN(Head &&head, Tail &&... tail)
{
	cin >> head;
	CIN(move(tail)...);
}
#define CINT(...)    \
	int __VA_ARGS__; \
	CIN(__VA_ARGS__)
#define LCIN(...)   \
	ll __VA_ARGS__; \
	CIN(__VA_ARGS__)
#define SCIN(...)       \
	string __VA_ARGS__; \
	CIN(__VA_ARGS__)
#define Yes(a) cout << (a ? "Yes" : "No") << "\n"
#define YES(a) cout << (a ? "YES" : "NO") << "\n"

typedef long long ll;
typedef vector<int> V;
typedef vector<ll> VL;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef priority_queue<int> PQ;
typedef priority_queue<int, V, greater<int>> PQG;

const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

int A, B, C;

int main()
{
	bool judge = false;
	cin >> A >> B >> C;
	if ((A <= C && C <= B) || (B <= C && C <= A))
	{
		cout << "Yes"
			 << "\n";
	}
	else
	{
		cout << "No"
			 << "\n";
	}
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <iomanip>

using namespace std;

int main(){
	int n,a,b;
	cin>>n>>a>>b;
	if(n<=a+b){
		cout << min(a,b) << " " << a+b-n << endl;
	}else if(n>a+b){
		cout << min(a,b) << " " << "0" << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i= (a); i < (b); ++i)
typedef long long ll;
typedef pair<int,int> P;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
int main() { int N, A, B;
  cin >> N >> A >> B;
  if(abs(N-A)<abs(N-B)){
    puts("A");
  }else{
    puts("B");
  }
}

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

using ll = long long;

int main() {
    int H, W, A, B;
    cin >> H >> W >> A >> B;
    rep(i, H) {
        rep(j, W) {
            if ((i < B) ^ (j < A)) cout << "0";
            else cout << "1";
        }
        cout << "\n";
    }
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
const int SIZE = 1<<18;
using ll = long long;
using pll = pair<ll, ll>;
int h[200001];
struct LiChao{
	struct Node{
		int l=0,r=0;
		pll line = pll(0, (ll)1e18);
	} node[2*SIZE];
	int cnt;
	inline ll f(pll line, int x){
		return line.first*x + line.second;
	}
	void update(int nn, int ns, int ne, pll newLine){
		auto &cur = node[nn];
		pll l1 = cur.line, l2 = newLine;
		if(f(l1, ns) > f(l2, ns)) swap(l1, l2);
		if(f(l1, ne) <= f(l2, ne)){
			cur.line = l1;
			return;
		}
		int m = (ns+ne)>>1;
		if(f(l1, m) <= f(l2, m)){
			cur.line = l1;
			if(!cur.r) cur.r = cnt++, node[cur.r].line = l1;
			update(cur.r, m+1, ne, l2);
		}
		else{
			cur.line = l2;
			if(!cur.l) cur.l = cnt++, node[cur.l].line = l2;
			update(cur.l, ns, m, l1);
		}
	}
	ll query(int nn, int ns, int ne, int x){
		auto &cur = node[nn];
		if(ns==ne) return f(cur.line, x);
		int m = (ns+ne)>>1;
		if(m<x) return min(f(cur.line, x), cur.r?query(cur.r, m+1, ne, x):(ll)1e18);
		return min(f(cur.line, x), cur.l?query(cur.l, ns, m ,x):(ll)1e18);
	}
} L;
int N;
ll dp[200001], C;
int main(){
	scanf("%d%lld",&N,&C);
	for(int i=1; i<=N; ++i) scanf("%d",h+i);
	L.cnt = 1;
	L.update(0, 0, 1e6, pll(-2ll*h[1], 1ll*h[1]*h[1]));
	for(int i=2; i<=N; ++i){
		dp[i] = 1ll*h[i]*h[i]+C+L.query(0, 0, 1e6, h[i]);
		L.update(0, 0, 1e6, pll(-2ll*h[i], 1ll*h[i]*h[i]+dp[i]));
	}
	printf("%lld",dp[N]);
	return 0;
}

Measured memory_bytes: 14848
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#define int long long
#define ld long double
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define all(x) x.begin(),x.end()
#define LOL cout << '\n';
#define sz(x) ((int)x.size())
#define INF LONG_LONG_MAX
#define NINF LONG_LONG_MIN
#define deb(x) cout << "[" << (#x) << "=" << x << "]" << '\n';
#define deb2(x,y) cout << "[" << (#x) << "=" << x << "] [" << (#y) << "=" << y << "]" << '\n';
#define deb3(x,y,z) cout << "[" << (#x) << "=" << x << "] [" << (#y) << "=" << y << "] [" << (#z) << "=" << z << "]" << '\n';

void solve(){
  int a,b,c,d; cin>>a>>b>>c>>d;
  int lol[10];
  lol[0]=a*c;
  lol[1]=a*d;
  lol[2]=b*c;
  lol[3]=b*d;
  for(int i=0 ; i<4 ; i++){
    lol[0]=max(lol[0],lol[i]);
  }
  cout<<lol[0];LOL
}

signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
  int _ = 1; //cin >> _;
  for(int i = 1 ; i <= _ ; i++){
    //cout << "Case #" << i << ": ";
    solve();
  }
  return 0;
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
ll strtoint(string str);
int main(){
	fast;
	ll n,m;
	cin>>n>>m;
	(m==n)?cout<<"Yes\n":cout<<"No\n";
	return 0;
}
ll strtoint(string str){
	ll x=0;
	stringstream ss;
	ss<<str;
	ss>>x;
	return x;
}

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

int main() {
	int n, k, u, mn = 0x7ffffff, tot = 0;

	scanf("%d %d", &n, &k);

	for (int i = 0;i < n;++i) {
		scanf("%d", &u);

		tot += u;

		if (mn > u)
			mn = u;
	}

	printf("%d", n + (k - tot) / mn);

	return 0;
}

Measured memory_bytes: 256
s = input()
count = [0, 0, 0, 0]
for i in range(len(s)):
  if s[i] == "N":
    count[0] = 1
  if s[i] == "S":
    count[1] = 1
  if s[i] == "W":
    count[2] = 1
  if s[i] == "E":
    count[3] = 1
if (count[0] + count[1])%2 or (count[2] + count[3])%2:
  print("No")
else:
  print("Yes")

Measured memory_bytes: 3064
#include <stdio.h>
#include <string.h>
 
int search (char* word,char* sentence); //関数予告 お楽しみに！
 
int main () {
    char W[11],T[1001];
    int count = 0;
    //wordは1回読めばいい
    scanf ("%s",&W);
    /*sentenceは単語単位に分けます
    while文をbreak条件まで回す
    scanfは空白も理解*/
    while (1) {
        scanf ("%s",&T); //文字列はs!
        if (strcmp (T,"END_OF_TEXT") == 0) { 
            //strcmp 一致してたら0を返す
            break;
        }
        /*それでは、searchパイセンよろしくお願いしまーす!
        (サマーウォーズ風)*/
        if (search (W,T) == 0) {
            count ++;
            //何単語あるか調べるんだよね
        }
         
    }
    printf ("%d\n",count);
     
    return 0;
}
 
int search (char* word,char* sentence) {
//pointerの*です　そんな怖くないよ…ね？
//あ、注意　sentenceだけどsentenceの1単語やからな
 
    //さてさて、まず長さが等しくないと話にならないっしょ
    int word_length = 0,sent_length = 0;
    int i;
    for (i = 0;word[i] != '\0';i ++) {
        // '\0' はcharによる
        word_length ++;
    }
    for (i = 0;sentence[i] != '\0';i ++) {
        sent_length ++;
    }
    if (word_length != sent_length) {
        return -1;
    }
     
    /*次、長さ同じなら文字が一つずつ同じか
    ただし、大文字、小文字は区別しない*/
    for (i = 0;word[i] != '\0';i ++) {
        if (word[i] - sentence[i] != 0
            && word[i] - sentence[i] != 32
            && word[i] - sentence[i] != -32) {
            /*ascii code
            a -> 97   A -> 65*/
                return -1;
            }
    }
    return 0;
    //ほう、よくこれほどの条件をくぐり抜けてきたな
}


Measured memory_bytes: 2068
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a, b;
  string op;
  cin >> a >> op >> b;
  if(op == "+") cout << a + b << "\n";
  else cout << a - b << "\n";
  return 0;
}


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

#define rep(i,n) for(long long int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(long long int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(long long int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define Abs(a,b) max(a,b)-min(a,b)
#define YES(condition) if(condition){cout << "YES" << endl;}else{cout << "NO" << endl;}
#define Yes(condition) if(condition){cout << "Yes" << endl;}else{cout << "No" << endl;}
#define Cout(x) cout<<(x)<<endl
#define POSSIBLE(condition) if(condition){cout << "POSSIBLE" << endl;}else{cout << "IMPOSSIBLE" << endl;}
#define Possible(condition) if(condition){cout << "Possible" << endl;}else{cout << "Impossible" << endl;}
#define possible(condition) if(condition){cout << "possible" << endl;}else{cout << "impossible" << endl;}
#define Size(n) (n).size()

typedef long long ll;


using namespace std;

const int INF = 1e9,MOD = 1e9 + 7,ohara = 1e6;
const ll LINF = 1e18;


long long int n,cnt=0,ans=0,a,b,c,d,cmp,cmpp,m,h,w,x,y,sum=0,pos;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl=true;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

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

      
      cin>>x>>y;
      if(x>0&&y>0){
        if(x<y)ans=y-x;
        else{
          ans=x-y;
          ans+=2;
        }
      }
      else if(x<0&&y<0){
        if(x<y){
          ans=(x*-1)-(y*-1);
        }
        else{
          ans=(y*-1)-(x*-1);
          ans+=2;
        }
      }
      else if(x>0&&y<0){
        if(x*-1<y){
          ans=x-(y*-1)+1;
        }
        else{
          ans=(y*-1)-x+1;
        }
      }
      else if(x<0&&y>0){
        if(x*-1>y){
          ans=(x*-1)-y+1;
        }
        else{
          ans=y-(x*-1)+1;
        }
      }
      else{
        if(x>0)ans=x+1;
        else if(y<0)ans=(y*-1)+1;
        else{
          ans=max(abs(x),abs(y));
        }
      }
      Cout(ans);
     

       
return 0;
}


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

using namespace std;

void Main()
{
    int a, b;
    cin >> a >> b;
    if (b % a == 0)
        cout << a + b;
    else
        cout << b - a;
}

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

    std::cout << std::fixed << std::setprecision(10);

#ifdef DEBUG_BUILD
    while (true)
    {
        Main();
        cout << std::endl;
    }
#endif

    Main();
    cout << endl;

    return 0;
}

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

int main() {
  int n;
  cin >> n;
  int a[200];
  int i;
  for(i=0;i<n;i++){
    cin >> a[i];
  }
  sort(a,a+n);
  int ans=0;
  if(n%2 != 0){
    ans += a[n-1];
    for(i=n-2;i >= 0; i=i-2){
      ans -= a[i];
      ans += a[i-1];
    }
  }
  else{
    for(i=n-1;i >= 0; i=i-2){
      ans += a[i];
      ans -= a[i-1];
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<long long> vll;
typedef vector<pair<int, int>> vpi;
typedef vector<pair<long long, long long>> vpl;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define FOR(i, k, n) for (int i = (k); i < (int)(n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.begin(), a.end(), greater<int>()
#define ROT(a) a.begin(), a.begin() + 1, a.end()
#define RROT(a) a.begin(), a.end() - 1, a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
#define sz(a) a.size()
const ll MOD = 1e9 + 7;
const int MAX = 10000000;
template <typename T1, typename T2>
inline bool chmin(T1& a, T2 b)
{
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T1, typename T2>
inline bool chmax(T1& a, T2 b)
{
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
T gcd(T a, T b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
//cout << 'H' << endl;
/*--------------------------------------------*/

int main()
{
    //cout << fixed << setprecision(10)
    cin.tie(0);
    ios::sync_with_stdio(false);

    ll N, M;
    cin >> N >> M;

    vector<ll> h(N);
    rep(i, N)
    {
        cin >> h[i];
    }

    vector<int> j(N, 1);

    rep(i, M)
    {
        int a, b;
        cin >> a >> b;
        --a;
        --b;

        if (h[a] == h[b]) {
            j[a] = 0;
            j[b] = 0;
        } else if (h[a] < h[b]) {
            j[a] = 0;
        } else {
            j[b] = 0;
        }
    }

    ll ans = 0;
    rep(i, N)
    {
        ans += j[i];
    }

    cout << ans << endl;
}


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

void print_vec_data(vector<int> in){

    for(int i=0;i<in.size();i++){
    if(i<in.size()-1)
      cout<<in.at(i)<<' ';
    else
      cout<<in.at(i)<<endl;
  }
}

vector<int> InsersionSort(vector<int> A ,int N){

  print_vec_data(A);

  for(int i=1;i<N;i++){
    int v=A.at(i);
    int j=i-1;
    while(j>=0 && A.at(j)>v){
        j--;
    }

    A.erase(A.begin()+i);
    A.insert(A.begin()+j+1,v);

    print_vec_data(A);
  }

  return A;
}



int main() {

  int n;
  cin>>n;

  vector<int> in(n);
  for(int i=0;i<n;i++){
    cin>>in.at(i);
  }

  vector<int> out(n);
  out = InsersionSort(in,n);

  return 0;
}


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

#define ll long long 
#define pb push_back
#define mem0(a) memset(a,0,sizeof(a))
#define mem1(a) memset(a,-1,sizeof(a))
#define memf(a) memset(a,false,sizeof(a))
#define all(v) v.begin(),v.end()
#define sz(a) (ll)a.size()
#define F first
#define S second
#define INF 2000000000000000000
#define endl "\n"
#define _time_ 1.0 * clock() / CLOCKS_PER_SEC
#define popcount(x) __builtin_popcountll(x)
#define pll pair<ll,ll> 
#define ld long double

const int M=1000000007;
const int MM=998244353;
const long double PI = acos(-1);

ll power(ll b,ll e,ll m)
{
    if(e==0) return 1;
    if(e&1) return b*power(b*b%m,e/2,m)%m;
    return power(b*b%m,e/2,m);
}
ll power( ll b, ll e)
{
    if(e==0) return 1;
    if(e&1) return b*power(b*b,e/2);
    return power(b*b,e/2);
}
template<typename T, typename U> static inline void amin(T &x, U y){ if(y<x) x=y; }
template<typename T, typename U> static inline void amax(T &x, U y){ if(x<y) x=y; }
template<typename T, typename U> ostream& operator<<(ostream &os, const pair<T, U> &p)
{ 
    return os<<'('<<p.F<< ","<<p.S<<')'; 
}

int _runtimeTerror_()
{
    string s;
    cin>>s;
    (s.back()=='s')?s+="es":s+="s";
    cout<<s;
    return 0;
}

int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    #ifdef runSieve
        sieve();
    #endif
    #ifdef NCR
        initialize();
    #endif
    int TESTS=1;
    //cin>>TESTS;
    while(TESTS--)
        _runtimeTerror_();
    return 0;
}

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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}

int nextInt() { int x; scanf("%d", &x); return x;}
ll nextLong() { ll x; scanf("%lld", &x); return x;}

int main2() {
  int H = nextInt();
  int W = nextInt();
  int N = nextInt();

  int X = max(H, W);
  int ans = (N + X - 1) / X;
  cout << ans << endl;
  return 0;
}

int main() {

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<queue>
#include<vector>
#define Max (int)1e5*2
#define MAX_INT (int)1e15+2
using namespace std;

vector<int>vec[Max];
queue<int>q;

int dp[Max];

void init(){
	int i;
	for(i=0;i<Max;i++)
		dp[i] = -1;
}

int getMax(int a,int b){
	return (a<b)?b:a;
}

int solve(int u){
	if(dp[u] != -1)
		return dp[u];

	int i,max = 0;
	for(i=0;i<vec[u].size();i++){
		max = getMax(max,solve(vec[u][i])+1);
	}
	dp[u] = max;
	return dp[u];	
}

int main(){
	int n,m,incoming[Max],i,x,y;

	init();

	scanf("%d%d",&n,&m);
	for(i=0;i<m;i++){
		scanf("%d%d",&x,&y);
		vec[x].push_back(y);
	}

	int max = 0;
	for(i=1;i<=n;i++){
		max = getMax(max,solve(i));
	}

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

/*int solve(int n){
	int i,u;
	int vis[Max];

	for(i=0;i<Max;i++)
		vis[i] = 0;

	while(!q.empty()){
		u = q.front();
		q.pop();
		if(vis[u])
			continue;
		vis[u] = 1;
		for(i=0;i<vec[u].size();i++){
			dp[vec[u][i]] = getMax(dp[vec[u][i]],dp[u]+1);
			q.push(vec[u][i]);
		}
	}

	int max = 0;
	for(i=1;i<=n;i++)
		max = getMax(max,dp[i]);
	
	return max;
}

int main(){
	int n,m,incoming[Max],x,y,i;
	for(i=0;i<Max;i++)
		incoming[i] = 0;

	scanf("%d%d",&n,&m);
	for(i=0;i<m;i++){
		scanf("%d%d",&x,&y);
		vec[y].push_back(x);
		incoming[y]++;
	}
	for(i=1;i<=n;i++){
		if(incoming[i] == 0)
			q.push(i);
	}


	int max = solve(n);
	printf("%d\n",max);
	return 0;
}*/


Measured memory_bytes: 10880
import itertools
import numpy as np


def resolve():
    N, M, X = map(int, input().split())

    C = []
    Q = []
    for i in range(N):
        QQ = list(map(int, input().split()))
        C.append(QQ[0])
        Q.append(QQ[1:])

    C = np.array(C)
    Q = np.array(Q)
    ok = False

    NN = range(N)
    ans = np.sum(C)

    for j in range(1, N + 1):
        for jj in list(itertools.combinations(NN, j)):
            tmp_value = C[list(jj)]
            tmp_score = Q[list(jj)]
            sum_ = tmp_score.sum(axis=0)
            finish_sum_ = len(list(filter(lambda x: x >= X, sum_)))

            if finish_sum_ == M:
                ans = min(ans, tmp_value.sum())
                ok = True

    if not ok:
        print(-1)
        return

    print(ans)


resolve()

Measured memory_bytes: 27508