akhauriyash/Code-Regression huggingface dataset:
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); i++)

int main() {
    int n;
    cin >> n;
    vector<int> L(n);
    REP(i, n) cin >> L[i];
    // int n = 2000;
    // vector<int> L(n);
    // random_device rnd;
    // REP(i,n)L[i] = rnd() % 100;


    sort(L.begin(),L.end(),greater<int>());
    int ans = 0;
    for(int i = 0; i < n - 2; i++) {
        for(int j = i + 1; j < n - 1; j++) {
            for(int k = j + 1; k < n; k++) {
                if((L[i] < L[j] + L[k]))
                    ans++;
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
import itertools
N = int(input())
P = list(map(int, input().split()))
Q = list(map(int, input().split()))
a = 0
b = 0
cnt = 0
for n in itertools.permutations(range(1, N+1)):
    if P == list(n):
        a = cnt
    if Q == list(n):
        b = cnt
    cnt += 1
total = abs(a-b)
print(total)

Measured memory_bytes: 3064
N, K = map(int, input().split())
V = list(map(int, input().split()))

ans = float('-inf')
for l in range(min(N+1, K+1)):
  for r in range(min(N-l+1, K-l+1)):
    arr = V[:l] + V[N-r:]
    t = sum(arr)
    arr.sort()
    for i in range(min(l+r, K-l-r)):
      a = arr[i]
      if a >= 0:
        break
      t -= a
    ans = ans if ans > t else t
print(ans)

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

int main (){
    int n;
    cin>>n;
    if(n<=9)puts("Yes");
    else {
        for(int i=2;i<=9;i++){
            for(int j=2;j<=9;j++){
                if(i*j==n){
                    puts("Yes");
                    return 0;
                }
            }
        }
        puts("No");
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
template <typename X> ostream& operator << (ostream& x,const vector<X>& v){for(ll i=0;i<v.size();++i) x<<v[i]<<" ";return x;}
template <typename X> ostream& operator << (ostream& x,const set<X>& v){for(auto it:v) x<<it<<" ";return x;}
template <typename X, typename Y> ostream& operator << (ostream& x, const pair<X,Y>& v) {x<<v.ff<<" "<<v.ss;return x;}
template <typename T, typename S> ostream& operator << (ostream& os, const map<T, S>& v) { for (auto it : v) os << it.first << "=>" << it.second << endl; return os; }
struct pair_hash {inline std::size_t operator()(const std::pair<ll, ll> & v) const {return v.first*31+v.second;}};
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC targett("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL)
#define pb push_back
#define fr first
#define sc second
#define prnt(m) for(auto it = m.begin() ; it != m.end() ; ++it){cout<<*it<<endl;}
#define tra(it,m) for(auto it=m.begin();it!=m.end();++it)
#define DBG(x) cout<<"# # #     "<<x<<'\n';
#define fri(i,s,n) for(ll i=s;i<n;i++)
#define mod 1000000007LL
#define mod2 998244353
#define vct2 vector<vector<ll>>
#define vct vector<ll>
#define pll pair<ll,ll>
#define rz(n) resize(n)
#define all(v) v.begin(),v.end()
#define mkp make_pair
#define arrin(a,n) for(ll i = 0; i < n ; i++){cin>>a[i];}
#define arrout(a,n) for(ll i = 0;i < n; i++){cout<<a[i]<<" ";}
#define ex(s) cout<<s<<endl,exit(0);
#define inf 2e18
#define h_p 1110111110111;
#define five 100005;
#define six 1000005;
#define printclock cerr<<"Time "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
//_______________________________________________________________________________
int main()
{
       ll a,b,n;
       cin>>a>>b>>n;
       if(b == 1)
       {
              cout<<0<<endl;
              return 0;
       }
       if(n < b-1)
       {
              ll xx = (a*n)/b ;
              cout<<xx<<endl;
       }
       else
       {
              ll xx = (a*(b-1))/b;
              cout<<xx;
       }


}


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

signed main(){
    int n, k, sum = 0, ans = 0;
    cin >> n >> k;
    vector<int> a(n), b(n);
    for(int i = 0; i < n; i++){
        cin >> a[i] >> b[i];
        sum += b[i];
    }
    bool f[114514] = {};    
    for(int i = 30; i >= 0; i--){
        if(k & (1LL << i)){
            int tmp = 0;
            for(int j = 0; j < n; j++){
                if(!f[j] && a[j] & (1LL << i)) tmp += b[j];
            }
            ans = max(ans, sum - tmp);
        }else{
            for(int j = 0; j < n; j++){
                if(!f[j] && a[j] & (1LL << i)){
                    sum -= b[j];
                    f[j] = true;
                }
            }
        }
    }
    cout << max(ans, sum) << endl;
}

Measured memory_bytes: 1920
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws Exception {
	    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

	    String[] line = br.readLine().split(" ");
	    int n = Integer.parseInt(line[0]);
	    int m = Integer.parseInt(line[1]);
	    int l = Integer.parseInt(line[2]);

	    // parse A
	    long[][] a = new long[n][m];
	    for (int i = 0; i < n; i++) {
	    	line = br.readLine().split(" ");
	    	for (int j = 0; j < m; j++) {
		    	a[i][j] = Integer.parseInt(line[j]);
	    	}
	    }

	    // parse B
	    long[][] b = new long[m][l];
	    for (int i = 0; i < m; i++) {
	    	line = br.readLine().split(" ");
	    	for (int j = 0; j < l; j++) {
		    	b[i][j] = Integer.parseInt(line[j]);
	    	}
	    }

	    // Calculation
	    long[][] ans = new long[n][l];
	    for (int i = 0; i < n; i++) {
	    	for (int j = 0; j < l; j++) {
	    		for (int k = 0; k < m; k++) {
		    		ans[i][j] += (a[i][k] * b[k][j]);
	    		}
	    	}
	    }

	    // Display Answer
	    StringBuilder sb = new StringBuilder();
	    for (int i = 0; i < n; i++) {
	    	for (int j = 0; j < l; j++) {
	    		sb.append(ans[i][j]);
		    	if (j < l - 1) {
		    		sb.append(" ");
		    	}
	    	}
	    	sb.append("\n");
	    }
	    System.out.print(sb.toString());
	}
}

Measured memory_bytes: 31316
#include<bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
using LL = long long;
const LL LINF = 1e18;
using namespace std;
#define COUT(v) cout<<(v)<<endl
#define CIN(n)  int(n);cin >> (n)
#define YES(n) cout<<((n)? "YES" : "NO")<<endl
#define Yes(n) cout<<((n)? "Yes" : "No")<<endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) <<endl

#define FOR(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 ALL(obj) (obj).begin(),(obj).end()

#define P pair<int,int>
#define I vector<int>
#define S set<int>
#define pb(v) push_back(v)
#define V vector
#define rt return
#define rmsame(a) sort(ALL(a)),a.erase(unique(ALL(a)), a.end())
class Edge{
public:
    int from,to,value;
    Edge(int a,int b,int c){
        from = a;
        to = b;
        value = c;
    }
    Edge(int a,int b){
        from = a;
        to = b;
    }
};
int main(){
    CIN(N);
    COUT(N*800-N/15*200);
    return 0;
}


Measured memory_bytes: 256
N, M = map(int, input().split())

s = []
c = []
for i in range(M):
    x,y = map(int,input().split())
    s.append(x)
    c.append(y)

ans_list = [-1 for i in range(N)]

for i in range(M):
    if ans_list[s[i]-1] != -1 and ans_list[s[i]-1] != c[i]:
        print(-1)
        exit()
    else:
         ans_list[s[i]-1] = c[i]
#print(ans_list)
if ans_list[0] == 0 and N>=2:
    print(-1)
    exit()

ans = 0
for i in range(N):
    if ans_list[i] == -1 and i != 0:
        ans_list[i] = 0
    if ans_list[i] == -1 and i == 0 and N >= 2:
        ans_list[i] = 1
    if ans_list[i] == -1 and i == 0 and N == 1:
        ans_list[i] = 0
    ans += ans_list[i] * (10**(N-i-1))

print(ans)


Measured memory_bytes: 9252
// includes {{{
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<tuple>
#include<cmath>
#include<random>
#include<cassert>
// #include<deque>
// #include<multiset>
// #include<bitset>
// #include<cstring>
// #include<bits/stdc++.h>
// }}}
using namespace std;
using ll = long long;

int main() {
  ios::sync_with_stdio(false), cin.tie(0);
  int n, x, y;
  cin >> n >> x >> y;
  cout << min(x, y) << " " << max(x + y - n, 0) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#define MIN(x, y) (((x) > (y)) ? (y) : (x))
#define ABS(x) ((x) >= 0 ? (x) : (-(x)))

int main()
{
  int x;
  scanf("%d", &x);
  /*
  long long pre = 0;
  for (int i = 0; i < 121; i++) {
    long long i_5 = (long long)i*i*i*i*i;
    printf("%d, %lld, %lld\n", i, i_5, i_5 - pre);
    pre = i_5;
    i_5[i] = (long long)i * i * i * i * i;
  }
  */
  
  for (int b = -120; b <= 120; b++) {
    //long long root =  - x
    for (int a = -120; a < 121; a++) {
      if ((long long)x == (long long)a * a * a * a * a - (long long) b * b * b * b * b ) {
        printf("%d %d", a, b);
        return 0;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 2156
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <set>
#include <cstring>

using namespace std;

struct node {
	map<char, node> next;
	set<int> state;
};

bool dp[5002][(1 << 12) + 2];
int len_pat[13];

int main() {
	int N, M;
	cin >> N >> M;
	while (N != 0 && M != 0) {
		node top;

		string pat;
		for (int i = 0; i < N; i++) {
			cin >> pat;
			len_pat[i] = pat.size();

			node* current = &top;
			for (int k = 0; k < pat.length(); k++) {
				auto res = current->next.insert({ pat[k], node() });
				current = &res.first->second;
			}
			current->state.insert(i);
		}

		string s;
		string temp;
		for (int i = 0; i < M; i++) {
			cin >> temp;
			s += temp;
		}

		vector<set<int>> occ(s.length());

		for (int i = 0; i < s.length(); i++) {
			node* current = &top;
			for (int k = i; k < s.length() + 1; k++) {
				for (auto item : current->state) {
					occ[i].insert(item);
				}

				if (k == s.length())
					break;

				auto res = current->next.find(s[k]);
				if (res == current->next.end()) {
					break;
				}

				current = &res->second;
			}


		}

		memset(dp, 0, sizeof(dp));
		for (int i = 0; i < s.length(); i++) {
			dp[i][0] = true;
			for(int bit = 0; bit < (1 << N); bit++)
			{
				if (!dp[i][bit]) continue;
				for(int p : occ[i])
				{
					if ((bit >> p) & 1) continue;
					if(i + len_pat[p] <= s.length())
					{
						dp[i + len_pat[p]][bit | (1 << p)] = true;
					}
				}
			}
		}

		int ans = 0;
		for(int i=0;i<=s.length();i++)
		{
			if(dp[i][(1 << N) - 1])
			{
				ans++;
			}
		}
		cout << ans << endl;


		cin >> N >> M;
	}

	return 0;
}

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

typedef pair<int,int> P;
int field[302][302];
int main(){
  int h,w,k;
  cin>>h>>w>>k;
  char c;
  int cnt=1;
  for(int i=0;i<h+2;i++){
    for(int j=0;j<w+2;j++){
      field[i][j]=-1;
    }
  }
  
  for(int i=1;i<=h;i++){
    for(int j=1;j<=w;j++){
      cin>>c;
      if(c=='#'){
        field[i][j]=cnt;
        cnt++;
      }
      else field[i][j]=-1;
    }
  }
  
//下埋め
  for(int i=1;i<=h;i++){
    for(int j=1;j<=w;j++){
      if(field[i][j]==-1) field[i][j]=field[i-1][j];
    }
  }
//上埋め
  for(int i=h;i>=1;i--){
    for(int j=1;j<=w;j++){
      if(field[i][j]==-1) field[i][j]=field[i+1][j];
    }
  }
//右埋め
  for(int i=1;i<=h;i++){
    for(int j=1;j<=w;j++){
      if(field[i][j]==-1) field[i][j]=field[i][j-1];
    }
  }
//左埋め
  for(int i=1;i<=h;i++){
    for(int j=w;j>=1;j--){
      if(field[i][j]==-1) field[i][j]=field[i][j+1];
    }
  }

  for(int i=1;i<=h;i++){
    for(int j=1;j<=w;j++){
      cout<<field[i][j];
      if(j !=w) cout<<" ";
    }
    cout<<endl;
  }

}



Measured memory_bytes: 3960
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin>>n;
  vector<int>a(n);
  int count=0;
  int ecount=0;
  for(int i=0;i<n;i++)
  {
    cin>>a[i];
    if(a[i]%4==0)count++;
    else if(a[i]%2==0)ecount++;
  }
  n-=(ecount);
  if(count>(n/2))cout<<"Yes"<<endl;
  else if(n%2==0 && count==(n/2))cout<<"Yes"<<endl;
  else if(n%2!=0 && count==(n/2) && ecount==0)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}

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


int main() {
  int N, K;
  cin >> N >> K;
  vector<int> vec(N);
  for(int i = 0; i < N; i++){
    cin >> vec.at(i);
  }
  sort(vec.begin(), vec.end());
  int ans = 0;
  for(int i = 0; i < K; i++){
    ans += vec.at(i);
  }
  cout << ans << endl;
}


Measured memory_bytes: 3628
n=int(input())
A=list(input())

w=A.count("W")
r=A.count("R")

W=0 ; R=r
ans=R
for i in range(n):
    if A[i]=="W": W+=1
    else: R-=1
    ans=min(ans, max(W,R))

print(ans)
    

Measured memory_bytes: 10484
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	Scanner sc = new Scanner(System.in);
	public void run() {
		while(sc.hasNext()){
			int w = sc.nextInt();
			int h = sc.nextInt();
			sc.nextLine();
			if(w == 0 && h == 0)break;
			else calc(w, h);
			
		}
	}
	public void calc(int w, int h){
		String[][] matrix = new String[h][w];
		for(int i = 0; i < h; i++){
			String line = sc.nextLine();
			for(int j = 0; j < w; j++){
				String c = line.substring(j, j+1);
				matrix[i][j] = c;
			}
		}
		num = new String[h][w];
		String max = "0";
		for(int i = 0; i < w; i++){
			for(int j = 0; j < h; j++){
				if(num[j][i] == null) numCalc(matrix, i, j, w, h);
				if(num[j][i] != "-1") max = compare(retNum(num[j][i]) , max);
			}
		}
		System.out.println(max);
	}
	String[][] num;
	public String retNum(String t){
		int size = t.length();
		for(int i = 0; i < size - 1; i++){
			if(t.charAt(0) == '0') t = t.substring(1);
			else break;
		}
		return t;
	}
	
	public String compare(String i, String j){
		if(i.length() > j.length()){
			return i;
		}
		else if(i.length() < j.length()){
			return j;
		}
		else if(i.compareTo(j) < 0) return j;
		else return i;
	}
	public String numCalc(String[][] matrix, int x, int y, int w, int h){
		if(num[y][x] != null) return num[y][x];
		else{
			String c = matrix[y][x];
			if(c.equals("0") || c.equals("1") || c.equals("2") || c.equals("3") || c.equals("4")
					|| c.equals("5") || c.equals("6") || c.equals("7") || c.equals("8") || c.equals("9")){
				String a1 = null;
				if(x < w-1 && num[y][x+1] == null) {
					String t = numCalc(matrix, x+1, y, w, h);
					if(!t.equals("-1")) a1 = c + t;
				}
				else if(x < w-1 && !(num[y][x+1].equals("-1"))) a1 = c + num[y][x+1];
				String a2 = null;
				if(y < h-1 && num[y+1][x] == null) {
					String t = numCalc(matrix, x, y+1, w, h);
					if(!t.equals("-1")) a2 = c + t;
				}
				else if(y < h-1 && !(num[y+1][x].equals("-1"))) a2 = c + num[y+1][x];
				
				if(a1 != null && a2 != null){
					num[y][x] = compare(a1, a2);
				}
				else if(a1 == null && a2 == null) num[y][x] = c;
				else if(a1 == null) num[y][x] = a2;
				else num[y][x] = a1;
			}
			else num[y][x] = "-1";
			return num[y][x];
		}
	}

	
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 58492
program prob3
    implicit none
    integer(8)::a,b,c, aa, bb, cc, rem, k, e, gcd
    integer(16)::ans
    read(*,*) k
    ans = 0

    do a = 1, k
        do b = 1, k
            aa = max(a,b)
            bb = min(a,b)
            rem = mod(aa, bb)

            do while(rem /= 0)
                aa = bb
                bb = rem
                rem = mod(aa, bb)
            end do
            gcd = bb
            
            do c = 1, k
                aa = max(c,gcd)
                bb = min(c,gcd)
                rem = mod(aa, bb)
                do while(rem /= 0)
                    aa = bb
                    bb = rem
                    rem = mod(aa,bb)
                end do
                ans = ans + bb
            end do
        end do
    end do

    write(*,*) ans
    stop
end program prob3

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

using namespace std;

int main()
{
    int h, w;
    cin >> h >> w;
    vector<string> c(h);

    for (int i = 0; i < h; ++i) {
        cin >> c[i];
    }

    for (int i = 0; i < h; ++i) {
        cout << c[i] << endl;
        cout << c[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;
// #pragma GCC optimize("O2")
typedef long long int ll;
typedef long double ld;
typedef map <ll,ll> mm;
typedef vector <ll> mv;
typedef pair <ll,ll> mp;
typedef set <ll> ms;
typedef multiset <ll> mms;
typedef queue <ll> mq;
typedef deque <ll> mdq;
typedef stack <ll> mst;
typedef priority_queue <ll> mpq;
typedef priority_queue <ll, vector<ll>, greater<ll> > mmh;
typedef complex<double> cd;
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
#define ordered_multiset tree<ll,null_type,less_equal<ll>,rb_tree_tag,tree_order_statistics_node_update>
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define flush cout.flush();
#define all(v) v.begin(),v.end()
#define deb(x) cout << #x << " " << x << endl;
#define ff first
#define ss second
#define pb(v) push_back(v)
#define lb(v) lower_bound(v)
#define ub(v) upper_bound(v)
#define cn continue
#define forl(i,n) for(ll i=0;i<n;i++)
#define forlr(i,n) for(ll i=n-1;i>=0;i--)
#define rev(s) reverse(s.begin(),s.end())
void swap(ll &a,ll &b) {
	ll tmp=a;
	a=b;
	b=tmp;
}
ll atoistring(string s) {
	stringstream lol(s);
	ll x;
	lol>>x;
	return x;
}
void pv(mv v) {
	forl(i,v.size()) cout<<v[i]<<" ";
	cout<<"\n";
}
void pa(ll *v, ll size) {
	forl(i,size) cout<<v[i]<<" ";
	cout<<"\n";
}
void removeDups(mv &v) {
	sort(all(v));
	mv::iterator it = unique(v.begin(), v.end());
	v.resize(distance(v.begin(), it));
}
inline ld kthRoot(ld n, ll k) {
	return pow(k, (1.0 / k) * (log(n) / log(k)));
}
ll power(ll x, ll y, ll p) {
	ll res=1;
	x=x%p;
	while(y>0) {
		if(y&1) res = (res*x)%p;
		y=y>>1;
		x=(x*x)%p;
	}
	return res;
}
void checkmod(ll &x, ll mod) {
	if(x>=mod) x%=mod;
}

ll mod = 1e9 + 7;

bool donee[1000006];
void thisIsMain() {
	ll n;
	cin>>n;
	ll gc = 0;
	bool f = 1;
	forl(i,n) {
		ll x;
		cin>>x;
		gc = __gcd(gc, x);
		ll sqr = sqrt(x);
		for(ll j=2;j<=sqr && f;j++) {
			if(x % j != 0) cn;
			if(donee[j]) {
				f = 0;
				break;
			}
			donee[j] = 1;
			while(x % j == 0) x /= j;
		}
		if(x > 1) {
			if(donee[x]) {
				f = 0;
				break;
			}
			donee[x] = 1;
		}
	}
	if(f) {
		cout<<"pairwise coprime\n";
		return ;
	}
	if(gc == 1) {
		cout<<"setwise coprime\n";
		return ;
	}
	cout<<"not coprime\n";
}

int main(void)
{
	fastio
	ll t = 1;
	// cin>>t;
	while(t--) thisIsMain();
	return 0;
}

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

int main(){
int N;
  cin >> N;
  vector<int> x(N),y(N),h(N);
  for(int i=0;i<N;i++){
    cin >> x[i] >> y[i] >> h[i];
  }
int max=100;
  for(int posy=0;posy<=max;posy++){
    for(int posx=0;posx<=max;posx++){
    int needh=-1;
      for(int i=0;i<N;i++){
        if(h[i]>0){
          int tmp=h[i]+abs(posy-y[i])+abs(posx-x[i]);
          if(needh==-1){
           needh=tmp;
          }
          else{
            if(needh!=tmp){
            needh=-2;
            break;
            }
          }
        }
      }
     if(needh==-2) continue;
     for(int i=0;i<N;i++){
       if(h[i]==0){
       int dist = abs(posy-y[i])+abs(posx-x[i]);
         if(needh>dist){
           needh=-2;
           break;
         }
       }
     } 
     if(needh==-2)continue;
     cout << posx << " " << posy << " " << needh << endl;
    }
  }


}


Measured memory_bytes: 3516
a = list(map(int, input().split()))

if a[0] == a[1] and a[0] != a[2]:
    print("Yes")
elif a[1] == a[2] and a[1] != a[0]:
    print("Yes")
elif a[0] == a[2] and a[1] != a[2]:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
#include<cmath>
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<functional>
#define INF 1e16
#define N (1000000000+7)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,P> Q;

ll sum[505][505];

int main(void){
    int n,m,q;
    cin>>n>>m>>q;
    for(int i=0;i<m;i++){
        int p,q;
        cin>>p>>q;
        sum[p][q]++;
    }
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            sum[i][j]=sum[i][j]+sum[i][j-1];
        }
    }
    for(int j=1;j<=n;j++){
        for(int i=1;i<=n;i++){
            sum[i][j]=sum[i][j]+sum[i-1][j];
        }
    }
    for(int i=0;i<q;i++){
        int P,Q;
        cin>>P>>Q;
        cout<<sum[Q][Q]+sum[P-1][P-1]-sum[P-1][Q]-sum[Q][P-1]<<endl;
    }
    return 0;
}

Measured memory_bytes: 2944
#include<iostream>
#include<cstring>
using namespace std;
int main(){
	string s;
	cin>>s;
	int a=0;
	for(int i=0;i<s.length()/2;i++){
		if(s[i] != s[s.length()-i-1]){
			a++;
		}
	}
	cout<<a;
	return 0;
}

Measured memory_bytes: 256
#include<vector>
#include<stack>
#include<bitset>
#include<cstdlib>
#include<cmath>
#include<set>
#include<list>
#include<deque>
#include<map>
#include<queue>
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#define ll long long
using namespace std;
const double PI = acos(-1.0);
const double eps = 1e-6;
ll read()
{
	char ch = getchar();
	ll x = 0;
	while (ch > '9' || ch < '0') ch = getchar();
	while (ch <= '9' && ch >= '0') x = x * 10 + ch - '0', ch = getchar();
	return x;
}
ll n, m;
ll dp[100005];
bool broken[100005];
ll dfs(ll step)
{
	if (broken[step]) return dp[step] = 0;
	else if (dp[step] != -1) return dp[step] % 1000000007;
	else return dp[step] = ((dfs(step - 1) % 1000000007) + (dfs(step - 2) % 1000000007)) % 1000000007;
}
int main()
{
	
	memset(dp, -1, sizeof(dp));
	memset(broken, 0, sizeof(broken));
	n = read(), m = read();
	dp[1] = 1;
	dp[2] = 2;
	for (ll i = 1; i <= m; i++) {
		ll c = read();
		broken[c] = 1;
	}
	if (broken[1] == 1) {
		dp[1] = 0;
		dp[2] = 1;
	}
	if (broken[2] == 1) dp[2] = 0;
	if (broken[1] == 1 && broken[2] == 1) {
		cout << 0;
		return 0;
	}
	for (int i = 1; i <= n - 1; i++) {
		if (broken[i] == 1 && broken[i + 1] == 1) {
			cout << 0;
			return 0;
		}
	}
	//printf("%d %d\n", dp[1], dp[2]);
	ll ans = dfs(n) % 1000000007;
	cout << ans;
	return 0;
}


Measured memory_bytes: 4224
#include <bits/stdc++.h>
#define fore(i,a,b) for(int i=int(a); i < int(b); i++)
#define foro(i,a,b) for(int i=int(a); i >= int(b); i--)
 
using namespace std;
 
int main(){
	int a, b; cin >> a >> b;

	int ans;
	
	fore(i,1,4) { if (i!=a && i!=b) ans=i; }
	
	cout << ans;
	
	return 0;
}

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

using namespace std;

typedef long double ld;
typedef long long ll;


ll sum(ll n) {
  return n * (n + 1) / 2;
}

int main() {
#ifdef LOCAL
  assert(freopen("b.in", "r", stdin));
#endif

  ios_base::sync_with_stdio(false);

  ll n;
  cin >> n;
  ll m = n;

  vector<ll> ans;

  while (m > 0) {
    while (sum(n - 1) >= m)
      --n;
    m -= n;
    ans.push_back(n);
    --n;
  }
  for (ll x : ans)
    cout << x << endl;
  return 0;

}



Measured memory_bytes: 384
#include <stdio.h>
typedef long long ll;

const ll modulus = (ll)(1e9) + 7;

ll dp[200005] = {1};
ll add[200005];

ll n;
ll c[200005];
ll cnt;

int main()
{
    scanf("%lld", &n);

    cnt = 1;
    for (int i = 0; i < n; cnt++, i++) {
        scanf("%lld", &c[cnt]);

        if (c[cnt - 1] == c[cnt]) {
            cnt--;
        }
    }
    cnt--;

    for (int i = 1; i <= cnt; i++) {
        dp[i] = dp[i - 1] + add[c[i]];

        dp[i] %= modulus;

        add[c[i]] = dp[i];
    }

    printf("%lld\n", dp[cnt]);

    return 0;
}


Measured memory_bytes: 4864
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
	
	public static void main(String[] args) throws IOException {
		Main mainObj = new Main();
		mainObj.solve();
	}

	public void solve() throws IOException {
		FastScanner fs = new FastScanner();
		int a = fs.nextInt();
		int b = fs.nextInt();
		
		if(a * b == 15) {
			System.out.println("*");
		}else if (a + b == 15) {
			System.out.println("+");
		}else {
			System.out.println("x");
		}
	}

	

	public class FastScanner {

		BufferedReader reader;
		private StringTokenizer st;

		public FastScanner() {
			st = null;
			reader = new BufferedReader(new InputStreamReader(System.in));
		}

		public String next() throws IOException {
			if (st == null || !st.hasMoreElements()) {
				st = new StringTokenizer(reader.readLine());
			}
			return st.nextToken();
		}

		public String nextLine() throws IOException {
			st = null;
			String readLine = null;
			readLine = reader.readLine();
			return readLine;
		}

		public int nextInt() throws NumberFormatException, IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws NumberFormatException, IOException {
			return Long.parseLong(next());
		}

		public int[] nextIntArr(int n) throws NumberFormatException, IOException {
			int[] retArr = new int[n];
			for (int i = 0; i < n; i++) {
				retArr[i] = nextInt();
			}
			return retArr;
		}

		public long[] nextLongArr(int n) throws NumberFormatException, IOException {
			long[] retArr = new long[n];
			for (int i = 0; i < n; i++) {
				retArr[i] = nextLong();
			}
			return retArr;
		}

		public void close() throws IOException {
			reader.close();
		}
	}


}


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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define UB upper_bound
#define LB lower_bound
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

int H, W, h, w;

int main() {
	cin >> H >> W >> h >> w;
	
	if(H % h == 0 && W % w == 0) {
		cout << "No" << endl;
	} else {
		cout << "Yes" << endl;
		inc1(i, H) {
		inc1(j, W) {
			cout << (j == 1 ? "" : " ") << (i % h == 0 && j % w == 0 ? -(256 * (h * w - 1) + 1): 256);
		} cout << "\n";
		}
	}
	
	return 0;
}


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

int get_head (int num) {
    int head;
    while ( num != 0 ) {
        head = num;
        num /= 10;
    }
    return head;
}

int get_tail (int num) {
    return num % 10;
}


int main (void) {
    int n, ans = 0, i, j;
    int head, tail;
    int table[10][10];
    memset(table, 0, sizeof(table));
    scanf("%d", &n);

    for ( i = 1; i <= n; i++ ) {
        head = get_head(i);
        tail = get_tail(i);
        table[head][tail]++;
    }

    for ( i = 1; i <= 9; i++ ) {
        for ( j = 1; j <= 9; j++ )
            ans += table[i][j] * table[j][i];
    }

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

    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define INF 10**9

int main() {
    int n,m,k;
    ll t = 0;
    cin >> n >> m >> k;
    vector<ll> A(n),B(m);
    rep(i,n){
        cin >> A.at(i);
    }
    rep(i,m){
        cin >> B.at(i);
        t += B.at(i);
    }
    int j=m;
    int ans = 0;
    rep(i,n+1){
        while (j > 0 && t > k ){
            j--;
            t -= B.at(j);
        }
        if (t > k){
            break;
        }
        ans = max(ans,i+j);
        if (i==n){
            break;
        }
        t += A[i];
    }
    cout << ans << endl;
}

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

#define sync ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define file freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout)
#define endl "\n"
#define ends " "
#define die(x) return cout << x << endl, 0
#define all(v) v.begin(), v.end()
#define sz(x) (int)(x.size())
#define debug(x) cerr << #x << ": " << x << endl
#define debugP(p) cerr << #p << ": {" << p.first << ", " << p.second << '}' << endl
typedef long long ll;
const ll INF = 1e9, MOD = INF + 7;

/////////////////////////////////////////////////////////////////////

const int N = 3e5 + 5;

int main(){
	
	sync;

	int a; cin >> a;
	string s; cin >> s;

	if (a >= 3200) cout << s << endl;
	else cout << "red" << endl;

	return 0;
}


Measured memory_bytes: 256
#include  <iostream>
#include  <cstdlib>


int main(void)
{
	int x[5];

	std::cin >> x[0] >> x[1] >> x[2] >> x[3] >> x[4];

	int i;
	for(i = 0; i < 5; i++){
		if(x[i] == 0)
			break;
	}

	std::cout << i + 1 << std::endl;

	return EXIT_SUCCESS;
}


Measured memory_bytes: 3628
N, M = map(int, input().split())
S = input()
T = input()

def f(a, b):
    if b < a:
        a, b = b, a
    
    while b % a != 0:
        a, b = b % a, a
    return a

if S[0] != T[0]:
    print(-1)

else:
    p = f(N, M)
    k = N // p
    l = M // p

    for n in range(p):
        if S[n * k] != T[n * l]:
            print(-1)
            break
    else:
        print(N * M // p)

Measured memory_bytes: 3316
import sys
# from collections import defaultdict, deque
# import math
# import copy
# from bisect import bisect_left, bisect_right
# import heapq

# sys.setrecursionlimit(1000000)

# input aliases
input = sys.stdin.readline

getS = lambda: input().strip()
getN = lambda: int(input())
getList = lambda: list(map(int, input().split()))
getZList = lambda: [int(x) - 1 for x in input().split()]

INF = 10 ** 20
MOD = 1000000007

def solve():
    a,b = getList()
    print(max([a+b, a - b, a * b]))
    return
def main():
    n = getN()
    for _ in range(n):
        solve()
if __name__ == "__main__":
    # main()
    solve()


Measured memory_bytes: 61540
S = list(input())
T = input()
len_t = len(T)


def is_valid(start, end):
    for t_i, s_i in enumerate(range(start, end)):
        if S[s_i] == "?" or S[s_i] == T[t_i]:
            continue
        else:
            return False
    return True


def assign(start, end):
    for t_i, s_i in enumerate(range(start, end)):
        S[s_i] = T[t_i]
    for i in range(len(S)):
        if S[i] == "?":
            S[i] = "a"


ok = False
for i in range(len_t-1, len(S))[::-1]:
    if S[i] == "?" or S[i] == T[-1]:
        start = i - len_t + 1
        end = i + 1
        if is_valid(start, end):
            ok = True
            assign(start, end)
            break

if ok:
    print("".join(S))
else:
    print("UNRESTORABLE")


Measured memory_bytes: 3064
#include<iostream>
using namespace std;
int main()
{
    int a,b;
    cin >> a >> b;
    if(a > b){
        cout <<"a > b" <<endl;
    }else if (a < b){
        cout <<"a < b" <<endl;
    }else{
        cout <<"a == b" <<endl;
    }
}


Measured memory_bytes: 3096
import java.util.Scanner;
import java.util.HashMap;
import java.util.Map;

public class Main{
    public static void main(final String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int[] a = new int[n];
        Map<Integer, Integer> mp = new HashMap<Integer, Integer>();
        for (int i = 0; i < n; i++) {
            a[i] = scan.nextInt();
            mp.put(a[i], 1);
        }
        int q = scan.nextInt();
        int ans = 0;
        while (q > 0) {
            final int s = scan.nextInt();
            if(mp.containsKey(s)) ans++;
            q--;
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 92936
n,a = map(int,input().split())
x = list(map(int,input().split()))
mx = max(x)
mx = max(mx,a)
dp = [[[0]*(n*mx+1) for _ in range(n+1)] for _ in range(n+1)]
dp[0][0][0] = 1
for i in range(1,n+1):
    for j in range(i+1):
        for k in range(n*mx+1):
            if k<x[i-1]:
                dp[i][j][k] = dp[i-1][j][k]
            elif j>0 and k>=x[i-1]:
                dp[i][j][k] = dp[i-1][j][k]+dp[i-1][j-1][k-x[i-1]]
ans = 0
for i in range(n+1):
        ans += dp[n][i][a*i]
print(ans-1)

Measured memory_bytes: 92892
#include <bits/stdc++.h>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second
  
#define X real()
#define Y imag()
#define x(p) real(p)
#define y(p) imag(p)
#define curr(P, i) P[i]
#define next(P, i) P[(i+1)%P.size()]
#define prev(P, i) P[(i+P.size()-1)%P.size()]

typedef double D;

const D EPS = 1e-8;
const D INF = 1e12;
const D PI = acos(-1);
typedef complex<D> P;
typedef complex<D> point;
namespace std {
    bool operator < (const P& a, const P& b) {
        return x(a) != x(b) ? x(a) < x(b) : y(a) < y(b);
    }
}
D cross(const P& a, const P& b) {
    return y(conj(a)*b);
}
D dot(const P& a, const P& b) {
    return x(conj(a)*b);
}

struct L : public vector<P> {
    L(const P &a, const P &b) {
        push_back(a); push_back(b);
    }
};

typedef vector<P> G;
typedef vector<P> polygon;

struct C {
    P p; D r;
    C(const P &p, D r) : p(p), r(r) { }
};
//点の進行方向
int ccw(P a, P b, P c) {
    b -= a; c -= a;
    if (cross(b, c) > 0)   return +1;       // counter clockwise
    if (cross(b, c) < 0)   return -1;       // clockwise
    if (dot(b, c) < 0)     return +2;       // c--a--b on line
    if (norm(b) < norm(c)) return -2;       // a--b--c on line
    return 0;
}

//凸包 - convex hull  同一直線上の点は除去（除去したくない場合は、ccw(...)<=0 ==> ccw(...)!=-1)             CGL_4_A
vector<point> convex_hull(vector<point> ps) {
    int n = ps.size(), k = 0;
    sort(ps.begin(), ps.end());
    vector<point> ch(2*n);
    for (int i = 0; i < n; ch[k++] = ps[i++]) // lower-hull
        while (k >= 2 && ccw(ch[k-2], ch[k-1], ps[i]) <= 0) --k;
    for (int i = n-2, t = k+1; i >= 0; ch[k++] = ps[i--]) // upper-hull
        while (k >= t && ccw(ch[k-2], ch[k-1], ps[i]) <= 0) --k;
    ch.resize(k-1);
    return ch;
}

int main(){
    int n;
    cin >> n;
    vector<P> ps_orige(n);
    rep(i, n) {
        double x, y;
        cin >> x >> y;
        ps_orige[i] = P{x, y};
    }
    cout << fixed << setprecision(15);
    if(ps_orige.size() == 2) {
        cout << 0.5 << endl;
        cout << 0.5 << endl;
        return 0;
    }
    auto ps = convex_hull(ps_orige);
    vector<D> ans(n);
    rep(i, ps.size()) {
        auto cur = curr(ps, i);
        auto pre = prev(ps, i);
        auto nxt = next(ps, i);
        D a = atan2((pre - cur).Y, (pre - cur).X);
        D b = atan2((nxt - cur).Y, (nxt - cur).X);
        D dif = max(a, b) - min(a, b);
        rep(j, n) {
            if(cur == ps_orige[j]) {
                ans[j] = abs((PI - dif) / (2*PI));
            }
        }
    }
    rep(i, n) {
        cout << ans[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 256
N,Q = gets.split(" ").map(&:to_i);
S = gets.chomp
t = Array.new(N+1, 0)
for i in 0..N-1
   if S[i, 2] === "AC"
    t[i+1] = t[i] + 1
   else
    t[i+1] = t[i]
   end
end
for i in 1..Q
  l,r = gets.split(" ").map(&:to_i);
  puts t[r-1] - t[l-1]
end

Measured memory_bytes: 5372
#include <bits/stdc++.h>
#define int long long
#define D long double
using namespace std;
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s;
    cin >> s;
    bool nole = true;
    vector<int> x, y;
    int X, Y;
    cin >> X >> Y;
    int now = 0, coord = 0;
    bool ch = true;
    for (int i=0; i < s.size(); i++){
        if (s[i] == 'F') now++;
        else{
            if (nole){
                coord = now;
                nole  =false;
            }
            else{
                if (ch) x.push_back(now);
                else y.push_back(now);
            }
            ch ^= 1;
            now = 0;
        }
    }
    if (nole){
        coord = now;
        ch = false;
    }
    else{
        if (ch) x.push_back(now);
        else y.push_back(now);
    }
    int K = 8000;
    vector<bool> dp1(16001), dp2(16001);
    fill (dp1.begin(), dp1.end(), false);
    dp1[K+coord] = true;
    for (int i=0; i < x.size(); i++){
        for (int j=0; j < 16001; j++) dp2[j] = dp1[j];
        fill(dp1.begin(), dp1.end(), false);
        for (int j=0; j < 16001; j++){
            if (j - x[i] >= 0 && dp2[j-x[i]]) dp1[j] = true;
            if (j + x[i] <= 16000 && dp2[j+x[i]]) dp1[j] = true;
        }
    }
    if (!dp1[K+X]){
        cout << "No" << endl;
        return 0;
    }
    fill (dp1.begin(), dp1.end(), false);
    dp1[K] = true;
    for (int i=0; i < y.size(); i++){
        for (int j=0; j < 16001; j++) dp2[j] = dp1[j];
        fill(dp1.begin(), dp1.end(), false);
        for (int j=0; j < 16001; j++){
            if (j - y[i] >= 0 && dp2[j-y[i]]) dp1[j] = true;
            if (j + y[i] <= 16000 && dp2[j+y[i]]) dp1[j] = true;
        }
    }
    if (!dp1[K+Y]){
        cout << "No" << endl;
        return 0;
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <string>
using namespace std;
int main(int argc, char const *argv[]) {
  int n=0,s=0,e=0,w=0;
  string a;
  cin>>a;
  for(int i=0;i<a.size();i++){
    if(a[i]=='N') n++;
    if(a[i]=='S') s++;
    if(a[i]=='E') e++;
    if(a[i]=='W') w++;
  }
  if((n>0&&s>0)||(n==0&&s==0)){
    if((e>0&&w>0)||(e==0&&w==0)){
      cout<<"Yes"<<endl;
    }else{
      cout<<"No"<<endl;
    }
  }else{
    cout<<"No"<<endl;
  }
  return 0;
}


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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template < typename T >
void vprint(T &v){
	REP(i, v.size()){
		cout << v[i] << " ";
	}
	cout << endl;
}

int main(){
	ll N, K;
	cin >> N >> K;
	vector<pll> sushis(N);
	REP(i, N){
		cin >> sushis[i].second >> sushis[i].first;
	}
	sort(sushis.rbegin(), sushis.rend());
	ll sum = 0;
	vector<ll> syu(N+1, 0);
	REP(i, K){
		sum += sushis[i].first;
		syu[sushis[i].second] += 1;
	}
	ll total_syu = 0;
	REP(i, N+1){
		if(syu[i]>0)total_syu += 1;
	}

	ll ma = sum + total_syu*total_syu;

	vector<ll> maxs(101010, -1);
	for(int i=K;i<N;i++){
		maxs[sushis[i].second] = max(maxs[sushis[i].second], sushis[i].first);
	}
	REP(i, K){
		maxs[sushis[i].second] = -1;
	}

	vector<ll> cand;
	REP(i, 101010){
		if(maxs[i]>0) cand.push_back(maxs[i]);
	}
	sort(cand.rbegin(), cand.rend());

	vector<ll> mama[101010];
	vector<ll> ax;
	REP(i, K){
		mama[sushis[i].second].push_back(sushis[i].first);
	}
	REP(i, 101010){
		if(mama[i].size()>1) sort(mama[i].rbegin(), mama[i].rend());
	}
	REP(i, 101010){
		for(int j=1;j<mama[i].size();j++){
			ax.push_back(mama[i][j]);
		}
	}
	sort(ax.begin(), ax.end());

	//vprint(cand);
	//vprint(ax);

	REP(i, min(cand.size(), ax.size())){
		sum -= ax[i];
		sum += cand[i];
		total_syu += 1;
		ma = max(ma, sum + total_syu*total_syu);
	}

	cout << ma << endl;

    return 0;
}

Measured memory_bytes: 8444
n, m, x = [int(x) for x in input().split()]
c = []
a = []
for i in range(n):
  tmp = [int(x) for x in input().split()]
  c.append(tmp[0])
  a.append(tmp[1:])
#全探索
ans = 10**8 # as INF
for s in range(2**n):
  cost = 0
  d = [0 for j in range(m)]
  for i in range(n):
    is_use = bin(s>>i&1) == bin(1)
    if is_use:
      cost += c[i]
      for j in range(m):
        d[j]+=a[i][j]
  ok = True
  for j in range(m):
    if d[j] < x:
      ok = False
  if ok and cost < ans:
    ans = cost
if ans == 10**8:
  print(-1)
else:
  print(ans)
  	


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

#define ll long long


int main() {
    std::ios::sync_with_stdio(false);
    using namespace std;
    const int max_n = 16;
    int n, A[max_n][max_n];
    cin >> n;
    for(int i = 0; i < n; i++)
        for(int j = 0; j < n; j++)
            cin >> A[i][j];

    vector< vector<ll> > D(n, vector<ll>(1<<n));
    for(int bm = 0; bm < (1<<n); bm++) {
        ll res = 0;
        for(int i = 0; i < n; i++)
            for(int j = i + 1; j < n; j++)
                if(bm & (1<<i) && bm & (1<<j))
                    res += A[i][j];
        D[0][bm] = res;
    }

    for(int i = 1; i < n; i++) {
        for(int bm = 0; bm < (1<<n); bm++) {
            for(int bn = bm - 1; bn > 0; bn = (bn - 1) & bm)
                if((bn & bm) == bn) {
                    D[i][bm] = max(D[i][bm], D[i - 1][bn] + D[0][bm & (~bn)]);
                }
        }
    }

    ll res = 0;
    for(int i = 0; i < n; i++)
        res = max(res, D[i][(1<<n) - 1]);

    cout << res << "\n";

    return 0;
}


Measured memory_bytes: 10620
import java.io.IOException;
import java.util.BitSet;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int k = in.nextInt();
		BitSet set = new BitSet();
		boolean hasWild = false;
		while ((n != k) && (n != 0)) {
			set.clear();
			hasWild = false;
			for (int i = 0; i < k; i++) {
				final int nextInt = in.nextInt();
				if (nextInt != 0) {
					set.set(nextInt);
				} else {
					hasWild = true;
				}
			}
			int start = set.nextSetBit(0);
			int sizeMax = 0;
			while (start != -1) {
				int end = set.nextClearBit(start) - 1;
				int nextstart = set.nextSetBit(end+1);
				if (hasWild && set.get(end + 2)) {
					end += 2;
					end = set.nextClearBit(end) - 1;
				}
				final int size = (end - start) + 1;
				sizeMax = Math.max(sizeMax, size);
				start=nextstart;
			}
			System.out.println(sizeMax);
			n = in.nextInt();
			k = in.nextInt();
		}

	}
}

Measured memory_bytes: 62100
#include <algorithm>
#include <cstring>
#include <iostream>
#include <vector>
#include <cmath>
#include <math.h>
#include <stdio.h>
#include <iomanip>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <functional>
#define rep(i,n) for (int i = 0; i < (n); ++i)

using namespace std;
const int MOD = 1000000007;


typedef long long int ll; 
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;

void floatOutPutSetup(){
    cout << fixed;
    cout << setprecision(10);
}

int main(){

    string s,t;
    cin >>s>>t;
    if(s.size()+1!=t.size())cout<<"No"<<endl;
    else{
        rep(i,s.size()){
            if(s[i]!=t[i]){
                cout<<"No"<<endl;
                return 0;
            }
        }
        cout<<"Yes";
    }

    return 0;
}

Measured memory_bytes: 3628
from collections import defaultdict

N, A = map(int, input().split())
X = list(map(int, input().split()))
X = [x - A for x in X]

d = defaultdict(int)
d[0] = 1

for x in X:
    for k, v in list(d.items()):
        d[k+x] += v
print(d[0]-1)

Measured memory_bytes: 3572
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <numeric>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

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


int main() {

  int n;
  cin >> n;

  ll min_l = INF;
  ll max_l = 0;
  ll tmp;
  REP(i, n){
    cin >> tmp;
    max_l = max(max_l, tmp);
    min_l = min(min_l, tmp);
  }

  cout << max_l - min_l << endl;



  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 10000000000000009
//#define INF 9223372036854775807
typedef long long ll;
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define ORREP(i,n) for(int i=(n);i>=1;--i)
#define ZREP(i,n) for(int i=1;i<(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define rollcall cout<<"I'm Sucu."<<endl;
#define YES(s) s?cout << "YES" << endl:cout << "NO" << endl
#define Yes(s) s?cout << "Yes" << endl:cout << "No" << endl
#define Taka(s) s?cout << "Takahashi" << endl:cout << "Aoki" << endl
#define out(s,t,u) s?cout << t << endl:cout << u << endl
#define int ll
#define Endl endl
   

signed main(){
    int N,A,B,P[104];
    cin >> N >> A >> B;
    REP(i,N){cin >> P[i];}
    int L=0,M=0,H=0;
    REP(i,N){
        if(P[i]<=A){
            L++;
        }else if(B<P[i]){
            H++;
        }else{
            M++;
        }
    }
    cout << min(L,min(M,H))<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i <(n); ++i)
#define ALL(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int,int>;


int main(){

  int n;
  cin >> n;
  vector<int> p(n);
  REP(i,n) cin >> p[i];


  int minp = p[0];
  int ans = 1;
  for(int i = 1; i < n; ++i){
    minp = min(p[i],minp);
    if(minp >= p[i]) ans++; 

  }

  cout << ans << endl;

  return 0;
}

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

int main()
{
  string N;

  cin >> N;
  if ((N[0] == N[1] && N[1] == N[2]) || N[1] == N[2] && N[2] == N[3])
  {
    cout << "Yes" << endl;
  }
  else
  {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const int INT_INF = 2147483647;
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 pair<int,int> P;

int main(){
  string a;
  cin >> a;
  if(a=="Sunny")cout << "Cloudy" << endl;
  else if(a=="Cloudy")cout <<"Rainy" << endl;
  else cout <<"Sunny" << endl;
}


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

int main(void) {
  int i, j;

  for (i = 1; i <= 9; i++) {
    for (j = 1; j <= 9; j++) {
      printf("%dx%d=%d\n", i, j, i * j);
    }
  }

  return EXIT_SUCCESS;
}

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

int main(){
    int h , n;
    cin >> h >> n;
    int tmp= 0;
    
    for(int i = 0; i < n; i++){
        cin >> tmp;
        h = h - tmp;
    }

    if(h <= 0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256