akhauriyash/Code-Regression huggingface dataset:
i,j,x,y,n,s;
main(t){
  char a[99],b[99],c[99];
 scanf("%d",&n);
 while(n>0)
   {
     x=y=s=t=0;
     scanf("%s%s",a,b);
     while(a[++x]!='\0');
     while(b[++y]!='\0');
     x--;y--;
     //     printf("a[%d]= %c\n",x,a[x]);
     // printf("b[%d]= %c\n",y,b[y]);
     while(x>=0 || y>=0 || t!=0)
       {
	 if(x<0)
	   i=0;
	 else
	   i=(int)a[x]-'0';
	 if(y<0)
	   j=0;
	 else
	   j=(int)b[y]-'0';
	 t=i+j+t;
	 if(t>9)
	   {
	     c[s]=t%10+'0';
	     t=t/10;
	   }
	 else
	   {
	     c[s]=t+'0';
	     t=0;
	   }
	 if(x>=0)
	   x--;
	 if(y>=0)
	   y--;
	 s++;
	 if(s>80)
	   break;
	 //     printf("%d\n",t);
	 
       }
     //   printf("%s\n",b);
 if(s>80)     
   puts("overflow");
 else
   {
     while(s-->0)
       printf("%c",c[s]);
     puts("");
   }
 n--;
   }

 exit(0);
}

Measured memory_bytes: 0
/*    ####################  */
/*   # I_LOVE_THUY_LINH #  */
/*  ####################  */
#include <bits/stdc++.h>
#define ll long long
#define db double
#define ld long double
#define ii pair<int,int>
#define pb push_back
#define vi vector<int>
#define vii vector<ii>
#define matrix vector<vector<ll>>
#define fir first
#define sec second
#define all(s) s.begin(),s.end()
#define rall(s) s.rbegin(),s.rend()
#define uni(a) (a).erase(unique(all(a)),(a).end())
#define sz(a) int((a).size())
#define ms(s,val) memset(s,val,sizeof(s))
#define bitcount(n) __builtin_popcountll(n)
#define getbit(s,k) ((s >> k)&1)
#define turnbit(s,k) (s | (1<<k))
#define offbit(s,k) (s & ~(1<<k))
#define flipbit(s,k) (s ^ (1<<k))
#define prec(n) fixed<<setprecision(n)
#define sqr(x) (ll)(x)*(ll)(x)
#define lcm(a,b) ((ll)a/__gcd((ll)a,(ll)b)*(ll)(b))
#define gcd(a,b) __gcd(a,b)
using namespace std;
const int INF = int(1e9);
int n;
int main(){
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    cin >> n;
    vector<int> a(n);
    int ans = 0;
    int cur = n;
    for (int &i: a){
        cin >> i;
        cur = min(cur,i);
        if (i <= cur) ans++;

    }
    cout << ans;
    return 0;
}

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

int price[10] = {0};

int main()
{
	int n = 0;
	int sum = 0;
	int max = 0;
	int i = 0;

	scanf("%d", &n);
	for(i = 0; i < n; i++) {
		scanf("%d", &price[i]);
		if(price[i] > max) {
			max = price[i];
		}
		sum += price[i];
	}

	printf("%d", ((sum - max) + (max/2)));
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std ;
int main()
{
    while(1) // for test
    {
    unsigned long long a , b , x , cnt = 0;
    cin >>  a >> b >> x ;
    cnt = (b / x) - (a / x) ;
    if(!(a % x)) cnt++ ;
    cout << cnt <<endl ;
    break ;
    }

}


Measured memory_bytes: 3620
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<vector>
#include<string>
#include<queue>
#include<map>

using namespace std;

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

typedef vector<int> vi;
typedef vector<vi> vii;
typedef pair<int,int> pii;

int main(){
	A:;
	
	int n;
	cin>>n;
	if(n==0)return 0;
	
	map<int,pii> box;
	box[0] = pii(0,0);
	
	int minix = 0;
	int maxix = 0;
	int miniy = 0;
	int maxiy = 0;
	
	reps(i,1,n){
		int a,b;
		cin>>a>>b;
		int dx[]={-1,0,1,0};
		int dy[]={0,1,0,-1};
		
		int x = box[a].first;
		int y = box[a].second;
		
		int nx = x+dx[b];
		int ny = y+dy[b];
		
		minix = min(minix, nx);
		miniy = min(miniy, ny);
		maxix = max(maxix, nx);
		maxiy = max(maxiy, ny);
		
		box[i] = pii(nx,ny);
	}
	
	printf("%d %d\n",(maxix-minix+1),(maxiy-miniy+1));
	
	goto A;
}

Measured memory_bytes: 1188
#include<stdio.h>
int main(void)
{
	int n;
	int i,j;
	int data[11][11];
	
	scanf("%d",&n);
	while(n!=0){

		for(j=0;j<=n;j++){
			data[n][j]=0;
		}
		for(i=0;i<n;i++){
			data[i][n]=0;
			for(j=0;j<=n-1;j++){
				scanf("%d",&data[i][j]);
				data[i][n] += data[i][j];
				data[n][j] += data[i][j];
				data[n][n] += data[i][j];
			}
		}
		for(i=0;i<=n;i++){
			for(j=0;j<=n;j++){
				printf("%5d",data[i][j]);
			}
		printf("\n");
		}
	scanf("%d",&n);
	}
	return 0;
}

Measured memory_bytes: 1040
#include <iostream>
#include <iomanip>
#include <list>
#include <map>
#include <algorithm>
#include <stack>

#define AGE 1000
#define DEBUG 0

using namespace std;


int main(){
	int reverseMoney = 100000;
	int week = 0;
	while(cin >> week){
		reverseMoney = 100000;
		for(int i = 0; i < week; i++){
			reverseMoney += reverseMoney * 5 / 100;
			if(reverseMoney % AGE != 0 && reverseMoney % AGE < 1000){
#if DEBUG
				cout << "reverseMoney % AGE : " << reverseMoney % AGE << endl;
#endif
				reverseMoney -= reverseMoney % AGE;
				reverseMoney += AGE;
			}
#if DEBUG
			cout << reverseMoney << endl;
#endif
		}
		cout << reverseMoney << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include<iostream>
#include<string>
using namespace std;
 
int main() {
	string S;
	cin >> S;
	if (S == "RRR") {
		cout << "3\n";
	}
	else if (S == "SSS") {
		cout << "0\n";
	}
	else if ((int)S.find("RR") >= 0) {
		cout << "2\n";
	}
	else {
		cout << "1\n";
	}
	return 0;
}

Measured memory_bytes: 3580
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <random>
#include <iterator>

using namespace std;

#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(v) reverse((v).begin(),(v).end())
#define ANS(ans) cout<<(ans)<<endl;
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
typedef vector<int> VI;
typedef pair<int, int> P;

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  for (int i = 0; i < (n); ++i)


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

	if (k == 1) {
		ANS(0);
	}
	else {
		ANS(n - k);
	}

	return 0;
}


Measured memory_bytes: 256
N,X,Y=map(int,input().split())
L=[0]*(N)
for i in range(N-1):
	for j in range(i,N):
		d=min(j-i,abs(X-1-i)+1+abs(Y-1-j),abs(Y-1-i)+1+abs(X-1-j))
		L[d]+=1
for i in range(1,N):
	print(L[i])

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

#define debug(x) cout <<"DEBUG"<<" "<< #x << ":" << x << '\n'

// n回繰り返し
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順
#define rep1(i,n) for(int i = 1; i <= ((int)(n)); i++) // 1-indexed昇順
#define rrep(i,n) for(int i = ((int)(n)-1); i >= 0; i--)  // 0-indexed降順
#define rrep1(i,n) for(int i = ((int)(n)); i >= 1; i--)   // 1-indexed降順
#define all(x) (x).begin(),(x).end()

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vii;  // 2次元配列
typedef vector<ll> vll;
typedef vector<double> vd;
typedef pair<int, int> PII;

template<typename T>
using vec = vector<T>;
template<class T>
using maxheap = std::priority_queue<T>;
template<class T>
using minheap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

template<class T,class U> inline bool chmax(T &a, const U &b){if(a<b){a=b;return 1;}return 0;}
template<class T,class U> inline bool chmin(T &a, const U &b){if(a>b){a=b;return 1;}return 0;}

const ld Pi = std::acos(-1.0L);
const ll infll = (1LL<<62)-1;
const int inf = (1<<30)-1;
const int mod = 1000000007;
// const int mod = 998244353;


/*FUNCs=================================================*/


/*MAIN==================================================*/
signed main(){
    int START_TIME = clock();
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化
    // cout << fixed << setprecision(15);

    int n; cin >> n;
    int a, t4_ = 0, tn4_ = 0, t2_ = 0;
    rep(i,n) {
        cin >> a;
        if(a%4==0) ++t4_;
        else if(a%2==0) ++t2_;
        else ++tn4_;
    }

    tn4_ += (t2_>=1 ? 1 : 0);
    if(t4_ >= tn4_ - 1) cout << "Yes" << '\n';
    else cout << "No" << '\n';



    // printf("ExecutionTime: %d /ms\n",1000*(int)((clock()-START_TIME)/CLOCKS_PER_SEC));
}


Measured memory_bytes: 256
macro_rules! get {
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
                    get!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
                    get!($($t),*)
        ).collect::<Vec<_>>()
    };
    ($t:ty |) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty | $n:expr) => {
        (0..$n).map(|_| get!($t |)).collect::<Vec<_>>()
    };
}
macro_rules! tern {
    ($condition: expr, $_true: expr, $_false: expr) => {
        if $condition {
            $_true
        } else {
            $_false
        }
    };
}
fn main() {
    let N = get!(usize);
    let S = get!(String).chars().map(|c| c as usize - '0' as usize).collect::<Vec<_>>();
    let mut map = vec![false; 11 * 11 * 11];
    for s in S {
        let mc = map.clone();
        for k in 1..(11*11) {
            if !mc[k] {
                continue;
            }
            if k < 11 {
                map[k + (s + 1) * 11] = true;
                continue;
            }
            if k < 11 * 11 {
                map[k + (s + 1) * 11 * 11] = true;
            }
        }
        if !map[s + 1] {
            map[s + 1] = true;
        }
    }
    let cnt = map.iter().skip(11*11).filter(|x| **x).count();
    println!("{}", cnt);
}


Measured memory_bytes: 4352
import sys
N = int(input())
A = list(map(int,input().split()))
count = 0
frag = 0
for i in range(N):
  if A[i]%2 == 0:
    count = count+1
    if A[i]%3 == 0 or A[i]%5 == 0:
      frag = frag+1
if frag == count:
  print('APPROVED')
else:
  print('DENIED')

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


int main() {
    
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    map<string,int>mp;
    for(int i=0;i<n;i++)
    {
        string s;
        cin>>s;
        mp[s]++;
    }
    int c=0;
     for (auto itr = mp.begin(); itr != mp.end(); ++itr)
     {
         //if(itr->second>=1)
         c++;
     }
     cout<<c<<endl;
	// your code goes here
	return 0;
}



Measured memory_bytes: 19268
#include <bits/stdc++.h>
using namespace std;
constexpr int Bsize=1000;


int N,Q,C[500000],L[500000],R[500000],res[500000],b[500000],c[500000],tree[1<<20];
vector<int>q[500000];

void add(int x){
	x+=(1<<19);
	while(x){
		tree[x]++;
		x/=2;
	}
}
void erase(int x){
	if(x==-1)return;
	x+=(1<<19);
	while(x){
		tree[x]--;
		x/=2;
	}
}

int calc(int l,int r){
	int s=0;
	l+=(1<<19);
	r+=(1<<19);
	while(l<r){
		if(l&1)s+=tree[l];
		if(~r&1)s+=tree[r];
		l=(l+1)/2;
		r=(r-1)/2;
	}
	if(l==r)s+=tree[l];
	return s;
}

int main(){
	cin>>N>>Q;
	for(int i=0;i<N;i++){
		cin>>C[i];
		C[i]--;
	}
	for(int i=0;i<Q;i++){
		cin>>L[i]>>R[i];
		L[i]--;
		R[i]--;
		q[R[i]].push_back(i);
	}
	for(int i=0;i<N;i++){
		c[i]=-1;
	}
	for(int i=0;i<N;i++){
		b[i]=c[C[i]];
		c[C[i]]=i;
	}
	for(int i=0;i<N;i++){
		add(i);
		erase(b[i]);
		for(int j:q[i]){
			res[j]=calc(L[j],R[j]);
		}
	}
	for(int i=0;i<Q;i++){
		cout<<res[i]<<endl;
	}
}


Measured memory_bytes: 40048
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        while(true) {
        	int H = sc.nextInt();
        	int W = sc.nextInt();
        	if(H == 0 && W == 0) {
        		break;
        	}else {
        		for(int i = 1;i < H+1;i++) {
            		for(int j = 1;j < W+1;j++) {
            			if(i % 2 == 0) {
            				if(j % 2 == 0) {
            					System.out.print("#");
            				}else {
            					System.out.print(".");
            				}
            			}else {
            				if(j % 2 == 0) {
            					System.out.print(".");
            				}else {
            					System.out.print("#");
            				}
            			}

            		}
            		System.out.println();
            	}
        		System.out.println();
        	}

        }
    }
}


Measured memory_bytes: 34868
import java.util.Scanner;

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

        int x = sc.nextInt();
        int a = sc.nextInt();
        int b = sc.nextInt();

        
        System.out.println((Math.abs(x - a) < Math.abs(x - b))? "A": "B");
    }
}

Measured memory_bytes: 21716
# -*- coding: utf-8 -*-
"""
Created on Sun Apr 26 20:54:00 2020
"""

import sys
#import numpy as np

sys.setrecursionlimit(10 ** 9)
#def input():
#    return sys.stdin.readline()[:-1]
mod = 10**9+7

#N = int(input())
s, w = map(int,input().split())
#A = list(map(int,input().split()))

if w >= s:
    print('unsafe')
else:
    print('safe')


Measured memory_bytes: 9168
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
void start(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    #ifndef ONLINE_JUDGE
    if(fopen("input.txt","r")){
        freopen ("input.txt" , "r" , stdin);
        freopen ("output.txt" , "w" , stdout);
    }
    #endif
}
signed main(){
    start();

    int n;
    cin>>n;
    int temp = n%10;
    if(temp ==2 || temp==4 ||temp ==5|| temp==7||temp==9) cout<<"hon";
    else if(temp==0 ||temp==1||temp==6||temp==8) cout<<"pon";
    else if(temp==3) cout<<"bon";

    return 0;
}

Measured memory_bytes: 3652
from collections import deque

def bfs(graph,root,distK):
    visited = set([root])       # 訪問済みノードを管理する 
    queue = deque([root]) # 訪れるべきノードを管理するqueueを作成
    while queue:          # list queueが空になるまで行う
        vertex = queue.popleft()         # 頂点を極める
        for neighbour in graph[vertex]:  # 頂点の近隣のノードに調べる
            node = neighbour[0]
            dist = neighbour[1]
            if node not in visited:
                visited.add(node)
                queue.append(node)
                distK[node] = distK[vertex] + dist
    return distK

N = int(input())
graph = {i:[] for i in range(1,N+1)}
for _ in range(N-1):
    a,b,c = map(int,input().split())
    graph[a].append([b,c])
    graph[b].append([a,c])

Q,K = map(int,input().split())
distK = {K:0}
distK = bfs(graph,K,distK)
for _ in range(Q):
    x,y = map(int,input().split())
    print(distK[x] + distK[y])

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

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    int k, x;
    cin >> k >> x;
    for (int i = x - k + 1; i < k + x; i++) {
        cout << i;
        if (i == k + x - 1) cout << "\n";
        else cout << " ";
    }
    return 0;
}

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

using namespace std;

int c[4][4];

void solve() {
    int a[4] = {0}, b[4] = {0};
    for (int i = 0; i < 100; ++i) {
        a[1] = i;
        b[1] = c[1][1] - a[1];
        a[2] = c[2][1] - b[1];
        b[2] = c[2][2] - a[2];
        a[3] = c[3][2] - b[2];
        b[3] = c[3][3] - a[3];
        bool flag = true;
        for (int j = 1; j <= 3; j++) {
            for (int k = 1; k <= 3; k++) {
                if (c[j][k] != a[j] + b[k]) {
                    flag = false;
                }
            }
        }
        if (flag) {
            printf("Yes\n");
            return;
        }
    }
    printf("No\n");
}

int main() {
    for (int i = 1; i <= 3; ++i) {
        for (int j = 1; j <= 3; ++j) {
            cin >> c[i][j];
        }
    }
    solve();
    return 0;
}


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

int main(){
  int a,b;
  cin >> a >> b;
  if(a*b==2){
    cout << 3 << endl;
  }else if(a*b==3){
    cout << 2 << endl;
  }else{
    cout << 1 << endl;
  }
  
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    bool s=true;
    string a,b;
    cin>>a>>b;
    for(int i=0;i<b.size()-1;i++)
    {
        if(a[i]!=b[i])
        {
            s=false;
            break;
        }
    }
    if(s)
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }
    return 0;
}


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

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

using namespace std;
int main () {
  int n, k, q;
  cin >> n >> k >> q;
  int a[n];
  rep(i,n) {
    a[i] = 0;
  }
  rep(i,q) {
    int d;
    cin >> d;
    a[d-1]++;
  }
  rep(i,n) {
    string ans = a[i] > q-k ? "Yes" : "No";
    cout << ans << endl;
  }

  return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {

    void solve() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] a = new int[N + 1];
        for (int i = 1; i <= N; i++) {
            a[i] = sc.nextInt();
        }
        int[] b = new int[N + 1];

        int allCount = 0;
        // 少なくとも後半半分は a[i] がそのまま b[i] になる。
        for (int i = N; i >= 1; i--) {
            if (i >= (N/2 + 1)) {
                b[i] = a[i];
                if (b[i] == 1) {
                    allCount++;
                }
            }
            else {
                int count = 0;
            
                if (i == 1) {
                    count = allCount;
                }
                else {
                    for (int j = i; j <= N; j += i) {
                        if (b[j] == 1) {
                            count++;
                        }
                    }
                }

                // count と a[i] に合わせて、b[i] を決める。
                if (count % 2 == 0) {
                    if (a[i] == 0) {
                        b[i] = 0;
                    }
                    else { // a[i] == 1
                        b[i] = 1;
                        allCount++;
                    }
                }
                else { // count % 2 == 1
                    if (a[i] == 0) {
                        b[i] = 1;
                        allCount++;
                    }
                    else { // a[i] == 1
                        b[i] = 0;
                    }
                }
            }
        }
        System.out.println(allCount);
        for (int i = 1; i <= N; i++) {
            if (b[i] == 1) {
                System.out.print(i + " ");
            }
        }
    }
    // Main
    public static void main(String[] args) {
        new Main().solve();
    }
}



Measured memory_bytes: 65252
s=input()

sum = 0

for bit in range(2 ** (len(s) - 1)):
    t = []
    
    idx=0
    for i in range(len(s) - 1):
        if 1 & (bit >> i):
            t.append(s[idx:i+1])
            idx = i+1
        
    t.append(s[idx:])

    for tt in t:
        sum+=int(tt)

print(sum)

Measured memory_bytes: 3060
hamming_distance = lambda S1,S2:sum(s1 != s2 for s1,s2 in zip(S1,S2))

S = input()
end_s_1 = ''.join([str(i%2) for i in range(len(S))])
end_s_2 = ''.join([str((i+1)%2) for i in range(len(S))])

# print(end_s_1, hamming_distance(S, end_s_1))
# print(end_s_2, hamming_distance(S, end_s_2))
ret = min(hamming_distance(S, end_s_1), hamming_distance(S, end_s_2))
print(ret)

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

int main(){
    int n,m;
    cin >> n >> m;
    if (n == m) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3600
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cfloat>
#include<climits>
#include<cmath>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;

using lint = long long;
using P = pair<int, int>;
using LLP = pair<long long, long long>;

#define REP(i, x, n) for(int i = (x), i##_len = (int)(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = (int)(n) ; i < i##_len ; ++i)
#define reps(i, n) for(int i = 1, i##_len = (int)(n) ; i <= i##_len ; ++i)
#define rrep(i, n) for(int i = (int)(n) - 1 ; i >= 0 ; --i)
#define rreps(i, n) for(int i = (int)(n) ; i > 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())
#define SORT_INV(x) sort((x).rbegin(), (x).rend())
#define REVERSE(x) reverse((x).begin(), (x).end())
#define TWINS(x) cout << ((x) ? "Yay!" : ":(") << '\n'

constexpr int IINF = (1 << 30) - 1;
constexpr long long LLINF = 1LL << 61;
constexpr double EPS = 1e-10;

constexpr int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
constexpr int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};

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

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

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

    int h1, m1, h2, m2, k;
    cin >> h1 >> m1 >> h2 >> m2 >> k;

    int s = h1 * 60 + m1;
    int t = h2 * 60 + m2;

    cout << t - s - k << endl;

    cout << flush;

    return 0;
}

Measured memory_bytes: 3652
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ITP2_8_A
{
    public class Program

    {
        public static void Main(string[] args)
        {
            int n = ReadInt();
            Dictionary<string,int> di = new Dictionary<string, int>();
            for (int i = 0 ; i < n ; i++)
            {
                string[] line = ReadStAr();
                switch (int.Parse(line[0]))
                {
                    case 0:
                        if (di.ContainsKey(line[1]))
                        {
                            di[line[1]] = int.Parse(line[2]);
                        }
                        else
                        {
                            di.Add(line[1], int.Parse(line[2]));
                        }
                        break;
                    case 1:
                        Console.WriteLine(di[line[1]]);
                        break;
                }

            }
        }

        static string ReadSt() { return Console.ReadLine(); }
        static int ReadInt() { return int.Parse(Console.ReadLine()); }
        static long ReadLong() { return long.Parse(Console.ReadLine()); }
        static double ReadDouble() { return double.Parse(Console.ReadLine()); }
        static string[] ReadStAr(char sep = ' ') { return Console.ReadLine().Split(sep); }
        static int[] ReadIntAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => int.Parse(e)); }
        static long[] ReadLongAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => long.Parse(e)); }
        static double[] ReadDoubleAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => double.Parse(e)); }
        static string WriteAr(int[] array, string sep = " ") { return String.Join(sep, array.Select(x => x.ToString()).ToArray()); }
        static string WriteAr(double[] array, string sep = " ") { return String.Join(sep, array.Select(x => x.ToString()).ToArray()); }
        static string WriteAr(long[] array, string sep = " ") { return String.Join(sep, array.Select(x => x.ToString()).ToArray()); }

    }

}



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

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

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()

int ask(int p)
{
	printf("%d\n", p);
	fflush(stdout);
	char c[10];
	scanf("%s", c);
	string res = c;

	int t;

	if (res == "Vacant") {
		t = -1;
	} else if (res == "Male") {
		t = 0;
	} else {
		t = 1;
	}
	return t;
}

int N;

int main() {
	cin >> N;

	int l = 0, r = N-1;

	int cl = ask(0);
	if (cl == -1) return 0;

	int cr = ask(N-1);
	if (cr == -1) return 0;

	while (true) {
		int m = (l + r) / 2;
		int cm = ask(m);
		if (cm == -1) {
			return 0;
		}
		if (cm == cl != ((m-l+1) & 1)) {
			r = m;
			cr = cm;
		} else {
			l = m;
			cl = cm;
		}
	}

	return 0;
}

Measured memory_bytes: 852
N, Q = gets().split.map(&:to_i)
w = Array.new( N, 0 )
v = Array.new( N, 0 )

N.times do |i|
	vt, wt = gets().split.map(&:to_i)
	w[i] = wt
	v[i] = vt
end

dp = Array.new(N+1){ Array.new(Q+1, 0) }

N.times do |i|
	(Q+1).times do |j|
		if j-w[i] >= 0
			dp[i+1][j] = [dp[i][j], dp[i][j-w[i]]+v[i]].max
		else
			dp[i+1][j] = dp[i][j]
		end
	end
end

puts dp[N][Q]

Measured memory_bytes: 16760
#include <bits/stdc++.h>
using namespace std;
const long long mod = pow(10, 9) + 7;
const long long MOD = 998244353;
const long long INF = 1LL << 60;
const int inf = pow(10, 9) + 7;
template <class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template <class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
int divCeil(int A, int B) {return (A + (B - 1)) / B;}
long long divCeil(long long A, int B) {return (A + (B - 1)) / B;}
long long divCeil(int A, long long B) {return (A + (B - 1)) / B;}
long long divCeil(long long A, long long B) {return (A + (B - 1)) / B;}

int main()
{
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  
  int ans = max({0, min(B, D) - max(A, C), min(A, C) - max(B, D)});
  
  cout << ans << endl;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

import sys
input = sys.stdin.readline

def io_generator():
	return input()

#+++++++++++++++++++
def m2(a,b,c):
	min_pos=min(a,b)
	max_pos=max(a,b)
	return (min_pos<=c) and (c<=max_pos)
	
def main(io):
	a,b,c= map(int, io().split())
	return 'Yes' if m2(a,b,c) else 'No'

#++++++++++++++++++++

if __name__ == "__main__":
	io= lambda : io_generator()
	print (main(io))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i, start, end) for (long long i = start; i < end; ++i)
#define repreverse(i, start, end) for (long long i = start; i >= end; --i)
#define all(x) (x).begin(), (x).end()
#define len(x) ((long long)(x).size())
#define g(a, b) __gcd((a), (b))
#define l(a, b) ((a) / __gcd((a), (b)) * (b))
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vllvll = vector<vll>;
using pll = pair<ll, ll>;
template<class T>void print1d(T x,ll n=-1){if(n==-1)n=x.size();rep(i,0,n){cout<<x[i]<<' ';}cout<<'\n';}
template<class T>void print2d(T x,ll r=-1,ll c=-1){if(r==-1)r=x.size();if(c==-1)c=x[0].size();rep(i,0,r)print1d(x[i],c);}
template<class T, class U>bool haskey(T mp, U key) { return mp.find(key) != mp.end(); }
template<class T, class U>bool isin(T el, U container) { return find(all(container), el) != container.end(); }
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
template<class T, class U>T rem(T a, U b) { return a - b*floor(a/b); }
template<class T>ld deg2rad(T deg) { return M_PI * deg / 180.0; }
template<class T>ld rad2deg(T rad) { return 180.0 * rad / M_PI; }
const long double pi = M_PI;
const long long big = 1LL << 50;
const long long inf = 1LL << 60;
const long long mod = 1e9 + 7;



int main()
{
        ll N, K;
        cin >> N >> K;
        vll A(N);
        rep(i, 0, N) cin >> A[i];

        map<ll, ll> mp;
        rep(i, 0, N) {
                mp[A[i]]++;
        }

        vector<pll> tmp;
        for (auto el : mp) {
                tmp.push_back(pll{el.second, el.first});
        }

        sort(all(tmp));

        ll ans = 0;
        if (len(tmp) <= K) {
                cout << 0 << endl;
                return 0;
        } else {
                rep(i, 0, len(tmp)-K) {
                        ans += tmp[i].first;
                }
        }
        cout << ans << endl;
} 

Measured memory_bytes: 19568
#include <stdio.h>
#include <math.h>
#include <string.h>
typedef long long ll;
int main(int argc,int *argv[])
{
	ll n,b,r,count=0,k,q;
	scanf("%lld%lld%lld",&n,&b,&r);
	k = n/(b+r);
	q = n%(b+r);
	if(q <=b )
		count = q;
	else
		count = b;
	count += k*b;
	printf("%lld",count);
	return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>

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

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

#define BIT_ON(x,b) ((x)|=(b))
#define BIT_OFF(x,b) ((x)&=~(b))
#define BIT_IS_ON(x,b) (((x)&(b))==(b))


using namespace std;

int main(void){
  int N,Y;
  cin >> N >> Y;
  Y /= 1000;

  int Y_N = Y-N;

  // Y = N
  if(Y_N == 0 ){
    cout << "0 0 " <<N<< endl;
    return 0;
  }
  else if(Y_N < 0){
    cout << "-1 -1 -1" << endl;
    return 0;
  }

  pair<int, int> yz;

  int yMax = Y_N / 4 + 1;
  int zMax = Y_N / 9 + 1;

  int x,y,z;
  for(y = 0; y<yMax; y++){
    for(z = 0; z<zMax; z++){
      
      int t = 4*y + 9*z;
      
      if(t == Y_N){
        x = Y - 10*z - 5*y;
        if(x<0) continue;
        cout << z << " " << y<<" "<<x<<endl;
        return 0;
      }
    }
  }
  

  cout << "-1 -1 -1" << endl;
  return 0;
}



Measured memory_bytes: 256
//abc099a.java
import java.util.Scanner;

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

        if(n < 1000) num = "ABC";
        else num = "ABD";

        System.out.println(num);
        
        sc.close();
    }
}

Measured memory_bytes: 21844
#include<iostream>
#include<iomanip>
#include<math.h>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<string>
#include<complex>
 
#define INF (long long)1000000000
#define MOD 1000000007
#define EPS 1e-8
 
#define REP(i, m) for(long long i = 0; i < m; ++i)
#define FOR(i, n, m) for(long long i = n; i < m; ++i)
#define ALL(v) v.begin(), v.end()
#define pb push_back
 
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef long double ld;
 
int main() {
	int n;
	long long d;
	cin>>n>>d;
	vector<P> a(n);
	REP(i, n) cin>>a[i].first>>a[i].second;
	int half = n / 2;
	vector<P> v1(pow(3, half));
	for(int bit = 0; bit < pow(3, half); ++bit) {
		int buf = bit;
		ll norm = 0;
		ll ov = 0;
		REP(i, half) {
			if(buf % 3 == 0) {
				norm += a[i].first;
				ov -= a[i].second;
			} else if(buf % 3 == 1) {
				norm -= a[i].first;
				ov += a[i].second;
			}
			buf /= 3;
		}
		v1[bit].first = norm;
		v1[bit].second = ov;
	}
	int end = n - half;
	vector<P> v2(pow(3, end));
	for(int bit = 0; bit < pow(3, end); ++bit) {
		int buf = bit;
		ll norm = 0;
		ll ov = 0;
		REP(i, end) {
			if(buf % 3 == 0) {
				norm += a[half + i].first;
				ov -= a[half + i].second;
			} else if(buf % 3 == 1) {
				norm -= a[half + i].first;
				ov += a[half + i].second;
			}
			buf /= 3;
		}
		v2[bit].first = norm;
		v2[bit].second = ov;
	}
	sort(ALL(v1), greater<P>());
	sort(ALL(v2));
	ll res = -(INF*INF);
	int ub = 0;
	priority_queue<P> q;
	for(int i = 0; i < v1.size(); ++i) {
		int nub = (int)(upper_bound(ALL(v2), P(d-v1[i].first+1, -(INF*INF))) - v2.begin());
		for(int j = ub; j < nub; ++j) {
			q.push(P(v2[j].second, v2[j].first));
		}
		ub = nub;
		while(!q.empty() && !((q.top()).second >= -d-v1[i].first && (q.top()).second <= d-v1[i].first)) {
			q.pop();
		}
		if(!q.empty()) {
			res = max(res, v1[i].second + (q.top()).first);
		}
	}
	cout<<res<<endl;
}

Measured memory_bytes: 564080
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long T = sc.nextLong();
		long[] input = new long[N];
		for (int i = 0; i < N; i++) {
			input[i] = sc.nextLong();
		}
		long sum = T;
		for (int i = 0; i < N - 1; i++) {
			long next = input[i + 1] - input[i];
			sum += Math.min(T, next);
		}
		System.out.println(sum);

	}

}

Measured memory_bytes: 63736
#include <bits/stdc++.h>
using namespace std;
int main ()
{
 long long int N;
 long long int res;
 cin>>N;

 for(int i = N;; i+=N){
   if(i%2 == 0)
    if(i % N == 0){
     res = i; break;
     }
 }

 cout<<res;



 return 0;
}


Measured memory_bytes: 256
from collections import defaultdict
n = int(input())
MOD = 10**9+7


def factorization(n):
    retval = []
    tmp = n
    for i in range(2, int(-(-n**.5//1))+1):
        if tmp % i == 0:
            cnt = 0
            while tmp % i == 0:
                cnt += 1
                tmp //= i
            retval.append((i, cnt))
    if tmp != 1:
        retval.append((tmp, 1))
    if not retval:
        retval.append((n, 1))
    return retval


d = defaultdict(int)
for i in range(1, n+1):
    f = factorization(i)
    for k, v in f:
        d[k] += v

ans = 1

for k, v in d.items():
    if k == 1:
        continue
    ans = ans*(v+1) % MOD

print(ans)


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


using namespace std;

#define fastio() ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define ll long long
#define mk make_pair
#define pb push_back
#define fi first
#define se second
#define all(x) x.begin(), x.end()
#define sz(x) (int) (x).size()

int sum(int n) {
	if(n==0) return n;
	else return n%10 + sum(n/10);
}
void go(){
	int n;cin>>n;
	if(n%sum(n)==0) cout << "Yes";
	else cout << "No";
}
int main(){
   
   fastio();
   cin.tie(0);
   cout.tie(0);

   go();

   return 0;
}




Measured memory_bytes: 3588
#include<stdio.h>
#include<math.h>

typedef struct Point{
	double x;
	double y;
} P;

void Koch(int , P, P);

int main(){
	int n;
	P s,t;

	scanf("%d",&n);

	s.x = 0;
	s.y = 0;
	t.x = 100;
	t.y = 0;

	printf("%.8f %.8f\n",s.x,s.y);
	Koch(n, s, t);
	printf("%.8f %.8f\n",t.x,t.y);

	return 0;
}



void Koch(int n,P p1,P p2){
	P s,t,u;

	if(n == 0)return;

	double rad = M_PI * 60.0 / 180.0;

	s.x = (2.0 * p1.x + 1.0 * p2.x) / 3.0;
	s.y = (2.0 * p1.y + 1.0 * p2.y) / 3.0;
	t.x = (1.0 * p1.x + 2.0 * p2.x) / 3.0;
	t.y = (1.0 * p1.y + 2.0 * p2.y) / 3.0;

	u.x = (t.x - s.x) * cos(rad) - (t.y - s.y) * sin(rad) + s.x;
	u.y = (t.x - s.x) * sin(rad) + (t.y - s.y) * cos(rad) + s.y;

	Koch(n - 1, p1, s);
	printf("%.8f %.8f\n",s.x,s.y);
	Koch(n - 1, s, u);
	printf("%.8f %.8f\n",u.x,u.y);
	Koch(n - 1, u, t);
	printf("%.8f %.8f\n",t.x,t.y);
	Koch(n - 1, t, p2);
}



Measured memory_bytes: 2000
#! /usr/bin/env python
# -*- coding: utf-8 -*-
# vim:fenc=utf-8
#

"""
AGC021 B
"""

import math
from collections import defaultdict

n = int(input())
ps = [tuple(map(int, input().split())) for i in range(n)]


def dist(rad, p):
    radtmp = 2*math.pi*rad/maxcut
    return -p[0]*math.cos(radtmp)-p[1]*math.sin(radtmp)


def closest(rad):
    tmp = dist(rad, ps[0])
    itmp = 0
    for i, pp in enumerate(ps):
        tmp2 = dist(rad, pp)
        if tmp2 < tmp:
            itmp = i
            tmp = tmp2
    return itmp


maxcut = 2**20


binary = defaultdict(int)
binary[0] = closest(0)
binary[maxcut] = binary[0]
binary[maxcut//2] = closest(maxcut//2)
binary[maxcut//4] = closest(maxcut//4)
binary[3*maxcut//4] = closest(3*maxcut//4)


def fillbinary(ll, rr):
    if binary[ll] != binary[rr] and rr-ll != 1:
        mm = (ll+rr)//2
        binary[mm] = closest(mm)
        fillbinary(ll, mm)
        fillbinary(mm, rr)


fillbinary(0, maxcut//4)
fillbinary(maxcut//4, maxcut//2)
fillbinary(maxcut//2, 3*maxcut//4)
fillbinary(3*maxcut//4, maxcut)


binkeys = sorted(binary.keys())
ansli = [0]*n
beforekey = 0
for i in binkeys:
    ansli[binary[i]] += i-beforekey
    beforekey = i


for i in range(n):
    print(ansli[i]/maxcut)





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

int main(){
  int n,k;
  cin >> n >> k;
  vector<int> h(n);
  for(int i=0;i<n;i++) cin >> h[i];
  
  vector<int> dp(n);
  
  for(int i=1;i<n;i++){
    int a=1000000000;
    for(int j=max(0,i-k);j<i;j++){
      a=min(a,dp[j]+abs(h[i]-h[j]));
    }
    dp[i]=a;
  }
  
  cout << dp[n-1] << endl;
  
}

Measured memory_bytes: 4048
#include <assert.h>
#include <ctype.h>
#include <float.h>
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>

#include <algorithm>
#include <complex>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;

#define SZ(a) (int)(a).size()
#define FOR(i,a,b) for (int i=(a); i<=(b); ++i)
#define REP(i,n) for (int i=0; i<(n); ++i)
#define ALL(c) c.begin(), c.end()
#define CLR(c,n) memset(c, n, sizeof(c))
#define TR(it, c) for(typeof(c.begin()) it = c.begin();it != c.end(); ++it)
#define CONTAIN(it, c) (c.find(it) != c.end())
typedef vector<int> VI;
typedef pair<int, int> PII;
template <class T> void checkmin(T &a, T b) { if (b<a) a=b; }
template <class T> void checkmax(T &a, T b) { if (b>a) a=b; }
const int INF=0x3F3F3F3F;

typedef pair<double, int> P;
const int N=10000;
int n, m;
int x[N], y[N];
vector<P> edge[N];
double best[N];
bool v[N];
int main(int argc, char *argv[]) {
  while (scanf("%d %d", &n, &m) == 2) {
    REP(i, n) scanf("%d %d", &x[i], &y[i]);
    vector<PII> e(m);
    REP(i, m) {
      scanf("%d %d", &e[i].first, &e[i].second);
      --e[i].first;
      --e[i].second;
      if (e[i].first > e[i].second) swap(e[i].first, e[i].second);
    }
    sort(e.begin(), e.end());
    REP(i, n) edge[i].clear();
    double ans = 0;
    for (int start = 0; start < SZ(e); ) {
      int end = start;
      while (end < SZ(e) && e[end] == e[start]) ++end;
      int i = e[start].first, j = e[start].second;
      double dist = hypot(x[j] - x[i], y[j] - y[i]) * (end - start);
      ans += dist;
      edge[i].push_back(P(dist, j));
      edge[j].push_back(P(dist, i));
      start = end;
    }
    CLR(best, 0);
    CLR(v, 0);
    REP(id, n) if (!v[id]) {
      priority_queue<P> q;
      q.push(P(0.0, id));
      while (!q.empty()) {
        int idx = q.top().second;
        q.pop();
        if (v[idx]) continue;
        v[idx] = true;
        ans -= best[idx];
        REP(i, SZ(edge[idx])) {
          int next = edge[idx][i].second;
          if (!v[next] && best[next] < edge[idx][i].first) {
            best[next] = edge[idx][i].first;
            q.push(P(best[next], next));
          }
        }
      }
    }
    printf("%.3f\n", ans);
  }
}

Measured memory_bytes: 3640
N = gets.to_i
S = gets.chomp

b_sum = S.count(?#)
b = 0
p (N+1).times.map{|i|
  w = i - b
  rest_b = b_sum - b
  rest_w = (N - b_sum) - w
  # p [b,w,rest_b,rest_w]
  b + rest_w.tap{ b += 1 if S[i] == ?# }
}.min


Measured memory_bytes: 3832
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>

#include <math.h>
using namespace std;


int main(int argc, const char * argv[]) {
    // fasten cin
    cin.tie(0);
    ios::sync_with_stdio(false);
    // implement
    int n;
    cin >> n;
    vector<int> v(n);
    for(int i=0; i<n; i++){
        cin >> v.at(i);
    }
    vector<int> result(n);
    for(int i=0; i<n; i++){
        result.at(v.at(i) - 1) = i + 1;
    }
    for(int i=0; i<n; i++){
        cout << result.at(i) << " ";
    }
    cout << endl;
}


Measured memory_bytes: 1664
/*Author - Shubham Gupta (@shubham107)*/
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef vector<ll> vl;		typedef vector<int> vi;
typedef vector<vl> vvl;	  	typedef vector<vi> vvi;
typedef pair<ll, ll> pll;	typedef pair<int, int> pii;
#define forn(i,n) for(int i=0;i<n;i++)
#define rforn(i,n) for(int i=n-1;i>=0;i--)
#define forne(i,n) for(int i=1;i<=n;i++)
#define forse(i,s,e) for(int i=s;i<e;i++)
#define rforse(i,s,e) for(int i=e-1;i>=s;i--)
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define MOD 1000000007
#define F first
#define S second
#define pb push_back
#define fill(a,x) memset(a,x,sizeof a);
#define trav(a,x) for(auto &a:x)
#define INF	ll(1e18)
#ifdef SHUBHAM107
#include "../code-pieces/trace.h"
#else
#define trace(args...)
#endif

ll modpow(ll a, ll b, ll m = MOD) {
	a %= m; ll res = 1; while (b) {if (b & 1)res = res * a % m; a = a * a % m; b >>= 1;}
	return res;
}
ll bpow(ll a, ll b) {ll res = 1; while (b) {if (b & 1)res = res * a; a = a * a; b >>= 1;} return res;}
ll modinv(ll a) {return modpow(a, MOD - 2, MOD);}
void graph(vvi &adj, int m) {int x, y; forn(i, m) {cin >> x >> y; adj[x - 1].pb(y - 1); adj[y - 1].pb(x - 1);}}

const int mxN = 2e5 + 5;
void solve() {
	int n, m, x;
	cin >> n >> m >> x;
	vvi prices(n, vi(m+1, 0));
	forn(i, n) forn(j, m+1) cin >> prices[i][j];
	int ans = INT_MAX;
	forn(i, 1<<n){
		vi know(m, 0);
		int cost = 0;
		forn(j, n){
			if(i>>j & 1){
				cost += prices[j][0];
				forn(k, m){
					know[k] += prices[j][k+1];
				}
			}
		}
		bool ok = true;
		forn(j, m) ok &= (know[j] >= x);
		if(ok){
			ans = min(ans, cost);
		}
	}
	if(ans != INT_MAX){
		cout << ans;
	}else{
		cout << -1;
	}
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
#ifdef SHUBHAM107
	freopen("inp.txt", "r", stdin);
	freopen("out.txt", "w", stdout);
	freopen("err.txt", "w", stderr);
#endif
	int t = 1;
	// cin >> t;
	while (t--) {
		solve();
	}
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define IO(i, o) freopen(i, "r", stdin), freopen(o, "w", stdout)

using namespace std;
string S;

int main(void){
	//IO("test.in", "test.out");
	cin >> S;
	printf("%c%d%c\n", S[0], S.length() - 2, S[S.length() - 1]);
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<set>
#include<cstdio>
using namespace std;
multiset<int>a;
int main()
{
    int n,choose,temp,l,r;
    scanf("%d", &n);
    while (n--)
    {
        scanf("%d", &choose);
        switch (choose)
        {
        case 0:
            scanf("%d", &temp);
            a.insert(temp);
            printf("%d\n", a.size());
            break;
        case 1:
            scanf("%d", &temp);
            printf("%d\n", count(a.lower_bound(temp), a.upper_bound(temp), temp) );
            break;
        case 2:
            scanf("%d", &temp);
            a.erase(temp);
            break;
        case 3:
            scanf("%d", &l);
            scanf("%d", &r);
            set<int>::iterator begin, end;
            begin = a.lower_bound(l);
            end = a.upper_bound(r);
            for (; begin != end; begin++)
            {
                printf("%d\n", *begin);
            }
        }
    }
    
}


Measured memory_bytes: 12428
cnt = 0
n,m,c=gets.split.map &:to_i
b=gets.split.map &:to_i
(1..n).map{gets.split.map &:to_i}.each{|a|
    s=c
    for i in 0...m
        s = s + b[i]*a[i]
    end
    cnt+=1 if s > 0
}
p cnt

Measured memory_bytes: 1788
#include <iostream>
#include <string>
#include<algorithm>
using namespace std;


int main(){
	string str;
	string com;
	string k;
	int q, a, b, p = 0;
	cin >> str >> q;

	for (int i = 0; i < q; i++){
		cin >> com;
		if (com == "print"){
			cin >> a >> b;
			cout << str.substr(a, b-a+1) << endl;
		}
		else if (com == "reverse"){
			cin >> a >> b;
			k = str.substr(a,b-a+1);
			reverse(k.begin(), k.end());
			str = str.substr(0,a)+k+str.substr(b+1,str.size()-a-1);
		}
		else if (com == "replace"){
			cin >> a >>  b;
			cin >> k;
			str = str.substr(0, a) + k + str.substr(b+1, str.size() - a - 1);
		}
	}
}



Measured memory_bytes: 3196
#include<stdio.h>
#include<math.h>
#include<string.h>
int main() {
	long long int m,n,num;//n个S,m个C 
	scanf("%lld %lld",&n,&m);
	if(2*n<m){
		num=(2*n+m)/4;
	}else if(2*n==m){
		num=n;
	}else{
		num=m/2;
	}
	printf("%lld",num);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include<math.h>
#include<list>
#include <algorithm>
#include<set>
#include<vector>
#include<math.h>
#include<map>
#include<string>
#include <numeric>
#include <queue>
#include <sstream>
#include <bitset>
#include<stack>

using namespace std;
using ll = long long;
using vll = vector<long long>;
using sll = set<long long>;

template<typename T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }

template<typename T>
map<T, T> getPrimeFactor(T n) {
	map<T, T> res;
	for (T i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			res[i] ++;
			n /= i;
		}
	}
	if (n != 1) res[n] = 1;
	return res;
}

template<typename T>
bool IsPrimeNumber(T num)
{
	if (num <= 2) return true;
	else if (num % 2 == 0) return false;

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			return false;
		}
	}

	return true;
}

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


#define in(x) cin >> x
#define out(x) cout << x
#define outn(x) cout << x << '\n'
#define outs(x) cout << x << ' '
#define rep(i,s,e) for(ll i=s;i<e;i++)
#define repeq(i,s,e) for(ll i=s;i<=e;i++)


map<ll, vll> m;

ll func(ll s) {
	ll ret = 0;
	rep(i, 0, m[s].size()) {
		ret = max(ret, func(m[s][i]));
	}
	return ret + 1;
}

int main() {
	ll N, ans = 0;
	std::cin >> N;
	vll A(N), B(N);

	rep(i, 0, N) {
		std::cin >> A[i]>>B[i];
	}
	for (ll i = N - 1; i >= 0; i--) {

		ll tmp = (((A[i] + ans) / B[i])*B[i]);
		if (tmp < A[i] + ans) {
			tmp += B[i];
		}

		ans += tmp - A[i]-ans;
	}

	std::cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;cin>>s;
  int x,y;cin>>x>>y;
  vector<int> v,w;
  int now=0;
  int c=0;
  for(int i=0;i<s.size();i++){
    if(s[i]=='F')now++;
    else{
        if(c==0)v.push_back(now);
        else w.push_back(now);
      
      c=c^1;
      now=0;
    }
  }
  
    if(c==0)v.push_back(now);
    else w.push_back(now);
  
  bool used[16001];
  fill(used,used+16001,false);
  used[8000]=true;
  for(int i=0;i<v.size();i++){
    if(i==0){
      used[8000+v[0]]=true;
      continue;
    }
    bool us[16001];
    fill(us,us+16001,false);
    for(int j=0;j<16001;j++){
      if(used[j]==false)continue;
      us[j+v[i]]=true;
      us[j-v[i]]=true;
    }
    for(int i=0;i<16001;i++)used[i]=us[i];
  }
  if(used[8000+x]==false){
    cout<<"No"<<endl;
    return 0;
  }
  fill(used,used+16001,false);
  used[8000]=true;
  for(int i=0;i<w.size();i++){
    bool us[16001];
    fill(us,us+16001,false);
    for(int j=0;j<16001;j++){
      if(used[j]==false)continue;
      us[j+w[i]]=true;
      us[j-w[i]]=true;
    }
    for(int i=0;i<16001;i++)used[i]=us[i];
  }
  if(used[y+8000]==false)cout<<"No"<<endl;
  else cout<<"Yes"<<endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include <functional>
#include <cmath>
#include <cfenv>
using ll = unsigned long long;
using namespace std;

int main(){
    int n;
    cin >> n;
    vector<pair<int,int>> vec(n);
    for(int i=0;i<n;i++){
        int x;
        cin >> x;
        vec[i]=make_pair(x,i);
    }
    sort(vec.begin(),vec.end());
    int c=0;
    for(int i=0;i<n;i++){
        if(abs(vec[i].second-i)%2==1)c++;
    }
    cout<<c/2<<endl;
}

Measured memory_bytes: 1024