akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <queue>
#include <string>
#include <algorithm>
#include <atcoder/all>

using namespace atcoder;
using namespace std;
typedef long long ll;

#define rep(i, n) for (ll i = 0; i < n; i++)
#define rep1(i, n) for (ll i = 1; i < n + 1; i++)
#define repr(i, n) for (ll i = n - 1; i >= 0; i--)
#define repr1(i, n) for (ll i = n; i > 0; i--)
#define FOR(i, j, n) for (ll i = j; i < n; i++)

const ll MOD = 1000000007; // 10^9+7
const ll MOD2 = 998244353;
const ll INF = 10000000000;

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

    int a,b;
    dsu d(n);
    rep(i,m){
        cin >> a >> b;
        d.merge(a-1,b-1);
    }

    cout << d.groups().size() - 1 << endl;
    return 0;
}

Measured memory_bytes: 9108
#https://atcoder.jp/contests/abc167/tasks/abc167_c C - Skill Up
import numpy as np
from itertools import combinations
N,M,X=list(map(int,input().split()))
book_dict={}
for i in range(N):
    book_dict[i] = list(map(int,input().split()))

answer = (10**5*12)+1
for i in range(N,0,-1):
    for v in combinations(book_dict.keys(), i):
        search_book = list(map(lambda x:book_dict[x],list(v)))
        sum_search_book = np.array(np.sum(search_book,axis = 0))
        if (np.count_nonzero(sum_search_book[1:] >= X) == M) and sum_search_book[0] < answer:
            answer = sum_search_book[0]
                                                                                 
    
if answer == (10**5*12)+1:
    answer = -1

print(answer)


Measured memory_bytes: 27352
N = int(input())
 
li = [list(map(int,input().split())) for _ in range(N)]

k = 0
while li[k][2] == 0:
    k += 1
 
for x in range(101):
    for y in range(101):

        H = li[k][2]+abs(li[k][0]-x)+abs(li[k][1]-y)
        f = True

        for i in range(N):
            if li[i][2] != max(H-abs(li[i][0]-x)-abs(li[i][1]-y),0):
                f = False
                break
        if f:
            print(x,y,H)
            break
    else:
        continue
    break
 

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

int main() {

string A,B;
  cin>>A>>B;
  if(A==B){cout<<"EQUAL"<<endl;}
  else{
  if(A.length()>B.length()) cout<<"GREATER"<<endl;
  else if(B.length()>A.length()) cout<<"LESS"<<endl;
  else{ for(int i=0;i<A.length();i++){
    if(A.at(i)>B.at(i)){cout<<"GREATER"<<endl;break;}
    else if(B.at(i)>A.at(i)){cout<<"LESS"<<endl;break;}
  }
  }
  }
}


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


signed main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);

    double n;
    cin>>n;
    cout<<2*3.142*n<<"\n";
    return 0;
}

Measured memory_bytes: 3800
#include <bits/stdc++.h>
using namespace std;
int N, M; 
int A[50010], B[50010], C[50010]; 
long long MOD = 998244353;
long long dp[100010][8]; 
map<pair<int, int>, int> given; 
map<pair<int, int>, bool> seen; 
long long power(long long a, long long n){
	long long ans = 1; long long mul = a; 
	while(n){
		if(n & 1){
			ans *= mul; ans %= MOD; 
		}
		n >>= 1; 
		mul = mul * mul % MOD; 
	}
	return ans; 
}
void collision(int i){
	if(given[make_pair(i, i)] == 1){
		dp[i][4] = 0; dp[i][5] = 0; dp[i][6] = 0; dp[i][7] = 0; 
	}else if(given[make_pair(i, i)] == 2){
		dp[i][0] = 0; dp[i][1] = 0; dp[i][2] = 0; dp[i][3] = 0; 
	}
	if(given[make_pair(i, i+1)] == 1){
		dp[i][2] = 0; dp[i][3] = 0; dp[i][6] = 0; dp[i][7] = 0; 
	}else if(given[make_pair(i, i+1)] == 2){
		dp[i][0] = 0; dp[i][1] = 0; dp[i][4] = 0; dp[i][5] = 0; 
	}
	if(given[make_pair(i+1, i)] == 1){
		dp[i][1] = 0; dp[i][3] = 0; dp[i][5] = 0; dp[i][7] = 0; 
	}else if(given[make_pair(i+1, i)] == 2){
		dp[i][0] = 0; dp[i][2] = 0; dp[i][4] = 0; dp[i][6] = 0; 
	}
	if(given[make_pair(i+1, i+1)] == 1){
		dp[i][1] = 0; dp[i][2] = 0; dp[i][4] = 0; dp[i][7] = 0; 
	}else if(given[make_pair(i+1, i+1)] == 2){
		dp[i][0] = 0; dp[i][3] = 0; dp[i][5] = 0; dp[i][6] = 0; 
	}
}
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	cin >> N >> M; 
	for(int i = 0; i < M; i++){
		cin >> A[i] >> B[i] >> C[i]; 
		A[i] --; B[i] --; C[i] ++; 
		given[make_pair(A[i], B[i])] = C[i]; 
	} 
	long long out = (long long) (N-3) * (N-2) / 2; 
	long long ans1 = 1LL; // abs(i - j) >= 3 の部分
	for(int i = 0; i < M; i++){
		if(abs(A[i] - B[i]) <= 2) continue; 
		if(seen[make_pair(A[i], B[i])]) continue; 
		if(given[make_pair(A[i], B[i])] + given[make_pair(B[i], A[i])] == 3){
			cout << 0 << endl; return 0; 
		}
		out --; 
		seen[make_pair(A[i], B[i])] = true; 
		seen[make_pair(B[i], A[i])] = true; 
	}
	ans1 = power(2, out); 
	for(int i = 0; i < 8; i++) dp[0][i] = 1; 
	collision(0); 
	for(int i = 1; i < N-1; i++){
		for(int j = 0; j < 4; j++){
			dp[i][j] = (dp[i-1][0] + dp[i-1][3] + dp[i-1][5] + dp[i-1][6]) % MOD ;
		}
		for(int j = 4; j < 8; j++){
			dp[i][j] = (dp[i-1][1] + dp[i-1][2] + dp[i-1][4] + dp[i-1][7]) % MOD ;
		}
		collision(i); 
		int a = given[make_pair(i-1, i+1)]; 
		int b = given[make_pair(i+1, i-1)]; 
		if(a == 0 && b == 0){
			for(int j = 0; j < 8; j++){
				dp[i][j] *= 2; 
				if(dp[i][j] >= MOD) dp[i][j] -= MOD; 
			}
		}else if(a == b){
			dp[i][4] = 0; dp[i][5] = 0; dp[i][6] = 0; dp[
i][7] = 0; 
		}else if(a + b == 3){
			dp[i][0] = 0; dp[i][1] = 0; dp[i][2] = 0; dp[
i][3] = 0; 
		}
	}
	long long ans2 = 0; 
	for(int i = 0; i < 8; i++) ans2 += dp[N-2][i];
	ans2 %= MOD;  
	long long ans = ans1 * ans2 % MOD; 
	cout << ans << endl; 
}

Measured memory_bytes: 50816
// Ver19.02
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define INF 1 << 29
#define LLINF 4545454545454545454
#define MOD 1000000007
#define ll long long
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
int upll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? -1 : *(ll *)a > *(ll *)b ? 1 : 0; }
int downll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? 1 : *(ll *)a > *(ll *)b ? -1 : 0; }
void sortup(ll *a, int n) { qsort(a, n, sizeof(ll), upll); }
void sortdown(ll *a, int n) { qsort(a, n, sizeof(ll), downll); }

int main()
{
  int a[] = {1, 3, 5, 7, 8, 10, 12};
  int b[] = {4, 6, 9, 11};
  int x, y;
  scanf("%d%d", &x, &y);
  if (x == 2 || y == 2)
  {
    puts("No");
    return 0;
  }
  for (int i = 0; i < sizeof(a) / sizeof(int); i++)
  {
    if (x == a[i])
    {
      if (y == 4 || y == 6 || y == 9 || y == 11)
      {
        puts("No");
        return 0;
      }
      else
      {
        puts("Yes");
        return 0;
      }
    }
  }
  if (y == 4 || y == 6 || y == 9 || y == 11)
    puts("Yes");
  else
    puts("No");

  return 0;
}

Measured memory_bytes: 128
#include<algorithm>
#include<iostream>
#include<string>
#include<cstdlib>
#include<cstring>
#include<cmath>
using namespace std;
int main(){
  int h;
  int n;
  cin>>n;
  for(h=0;h<n;h++){
    int x=0,y=0;
    pair<int,pair<int,int> > a;
    a=make_pair(0,make_pair(0,0));
    int p,q;
    while(cin>>p>>q&&p+q){
      x+=p;
      y+=q;
      a=max(a,make_pair(x*x+y*y,make_pair(x,y)));
    }
    cout<<a.second.first<<" "<<a.second.second<<endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
#define INF LONG_LONG_MAX
#define MINF LONG_LONG_MIN
#define MAX_INT 100000
#define MOD 1000000007
#define forf(i,a,b) for(int i=a;i<=b;i++)

void solve()
{
    ll n;cin>>n;
    cin>>n;
    
    if(n%10==7) {std::cout << "Yes" << std::endl;return ;}
    n=n/10;
    if(n%10==7) {std::cout << "Yes" << std::endl;return ;}
    n=n/10;
    if(n%10==7) {std::cout << "Yes" << std::endl;return ;}
    cout<<"No";
    
}
    
    
int main()
{
    IOS;
    
    //ll t;cin>>t;while(t--)
        solve();
 
    return 0;
}

Measured memory_bytes: 3652
def main():
    S = list(input())
    K = int(input())
    k = K
    for i,c in enumerate(S):
        distance = (ord('z') + 1 - ord(c))%26
        if distance <= k:
            k -= distance
            S[i] = 'a'
    S[-1] = chr((ord(S[-1]) - ord('a') + k) % 26 + ord('a'))
    print(''.join(S))

main()

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


int main(){
  int N;
  cin >> N;
  vector<vector<int>> V(N+1, vector<int> (0));
  rep(i, N-1){
    int A;
    cin >> A;
    V[A].push_back(i+2);
  }
 
  
  rep(i, N){
    cout << V[i+1].size() << endl;
  }
  
}

      

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

int main(){
    int n;
    cin>>n;
    vector<int> a(n);
    rep(i,n) cin>>a[i];
    sort(a.rbegin(),a.rend());
    int alice = 0,bob=0;
    rep(i,n){
        if(i%2==0) alice+=a[i];
        if(i%2) bob+=a[i];
    }
    cout<< alice-bob << endl;
    
    return 0;
}


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

int main(){
	int n;
	cin >> n;
	vector<int> a(n);
	rep(i,n) cin >> a[i];
	int ans = 0;
	int up = 0;
	int down = 0;
	REP(i,n-1){
		if(a[i] > a[i-1]){
			up = 1;
		}
		if(a[i] < a[i-1]){
			down = 1;
		}
		if(up == 1 && down == 1){
			ans++;
			up = 0;
			down = 0;
		}
	}
	cout << ans + 1 << endl;
    return 0;
}

Measured memory_bytes: 640
#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>;

int main() {
    int a,b;
    cin>>a>>b;
    int w=1,count=0;
    while(w<b) {
        w--;
        w+=a;
        count++;
    }
    cout<<count<<endl;
}



Measured memory_bytes: 256
*s, = input()

less = [0]*(len(s)+1)
for i in range(len(s)):
    if s[i] == "<":
        less[i+1] = less[i] + 1

greater = [0]*(len(s)+1)
for i in range(len(s)-1, -1, -1):
    if  s[i] == ">":
        greater[i] = greater[i+1] + 1

ans = 0
for _l, _g in zip(less, greater):
    ans += max(_l, _g)

print(ans)


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

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());//int型
		int k = Integer.parseInt(sc.next());
		String sline = sc.next();
		int[] s = new int[n];
		for (int i=0; i<n; i++){
			s[i] = Integer.parseInt(String.valueOf(sline.charAt(i)));
		}
		sc.close();
		// 1-0-1-...でいくつセットで並んでいるか.00011100101=0332101(最初1は0個並んでいる.
		
		ArrayList<Integer> nums = new ArrayList<Integer>();
		
		int now = 1;// 今見ている数
		int cnt = 0;// nowがいくつ並んでいるか
		for (int i=0; i<n; i++){
			if (s[i] == now) {
				cnt++;
			} else {
				nums.add(cnt);
				now = 1 - now;// これで0,1の入れ替えができる.
				cnt = 1;
			}
		}
		if(cnt != 0){
			nums.add(cnt);
		}
		// 1-0-1-...-0-1という形でほしい
		// 0で終わっている時は一つ足す
		if (nums.size() % 2 == 0) {
			nums.add(0);
		}

		int Add = 2*k + 1;
		int ans = 0;
		
		/*
		 * forループの外側に定義
		 */
		int left = 0;
		int right = 0;
		int tmp = 0; // [left, right)のsum
		
		// 1-0-1-0-1と続くので偶数番目だけ見る
		for (int i = 0; i < nums.size(); i += 2) {
			/*
			 * 次のleft, rightを計算
			 */
			int nextleft = i;
			int nextright = Math.min(i+Add, nums.size());
			/* 
			 * left,rightを移動する
			 */
			while(nextleft > left) {
				tmp -= nums.get(left);
				left++;
			}
			while(nextright > right) {
				tmp += nums.get(right);
				right++;
			}
			ans = Math.max(tmp, ans);
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 33060
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdint.h> // uint64_t

#define max(a,b) ((a) > (b) ? (a) : (b))
#define min(a,b) ((a) > (b) ? (b) : (a))

int get_int2(int *a1, int *a2) {
  scanf("%d %d", a1, a2);
  return 0;
}

// <arr[0]> <arr[1]> .. <arr[size-1]>
int fget_array(int *arr, int size) {
    int i;
    for(i = 0; i < size; i++) {
        scanf("%d", &arr[i]);
    }
    return 0;
}

#define NUM_MAX 100000
#define INF (1e+9)

int asc(const void *a1, const void *a2) {
    return *(int*)a1 - *(int*)a2;
}

int main(void) {
    int num, selects;
    get_int2(&num, &selects);
    int arr[NUM_MAX];
    fget_array(arr, num);
    qsort(arr, num, sizeof(int), asc);

    int i;
    int ans = INF;
    for(i = selects-1; i < num; i++) {
        ans = min(ans, arr[i] - arr[i-selects+1]);
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 892
N, L = gets.split.map(&:to_i)
if L < 0
  if N + L <= 0
    puts (L...(N + L - 1)).inject(:+)
  else
    puts N.times.inject(0) {|r,n| r += L + n }
  end
else
  puts N * L + N.times.inject(:+) - L
end


Measured memory_bytes: 1788
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <vector>
#include <array>
#include <stack>
#include <list>
#include <queue>
#include <deque>
#include <climits>
#include <utility>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <complex>
#include <numeric>
#include <chrono>
#include <cmath>
#include <bitset>

using namespace std;

#define FOR(it, ar) for(auto &it: ar)
#define loop(i, start, end) for(auto i = (start); i <= (end); i++)
#define loopSkip(i, start, end, skip) for(auto i = (start); i <= (end); i += skip)
#define loopRev(i, start, end) for(int i = (start); i >= (end); i--)
#define FLASH ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define testCases(t) cin >> t; while(t--)
#define PN(n) cout << (n)
#define PN1(n) cout << (n) << " "
#define PN2(a, b) cout << (a) << " " << (b) << " "
#define PN3(a, b, c) cout << (a) << " " << (b) << " " << (c) << " "
#define PNN1(n) cout << (n) << "\n"
#define PNN2(a, b) cout << (a) << " " << (b) << "\n"
#define PNN3(a, b, c) cout << (a) << " " << (b) << " " << (c) << "\n"
#define PrintObject(ar) for(auto var: ar) cout << var << " "; cout << "\n"
#define PrintMap(map) for(auto var: map) PNN2(var.first, var.second)
#define PrintPair(pair) PNN2(pair.first, pair.second)
#define IN1(n) cin >> n
#define IN2(a, b) cin >> a >> b
#define IN3(a, b, c) cin >> a >> b >> c
#define ALL(s) s.begin(), s.end()
#define ENTER PNN1("")
#define llPair std::pair<lli, lli>
#define iiPair std::pair<int, int>

// Math macros
#define M_PI 3.14159265358979323846

typedef long long int lli;
typedef unsigned long long int ulli;
typedef long double ld;

template <typename T>
T ii() {
	T a;
	IN1(a);
	return a;
}

struct custom_hash {
  static uint64_t splitmix64(uint64_t x) {
      // http://xorshift.di.unimi.it/splitmix64.c
      x += 0x9e3779b97f4a7c15;
      x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
      x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
      return x ^ (x >> 31);
  }

  size_t operator()(uint64_t x) const {
      static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
      return splitmix64(x + FIXED_RANDOM);
  }
};

int main(void){
	FLASH
	#ifndef ONLINE_JUDGE
		freopen("input-stream.txt", "r", stdin);
		freopen("output-stream.txt", "w", stdout);
	#endif

	string s, t;
	IN2(s, t);

	int n = s.length(), m = t.length();
	int ans = n;

	loop(i, 0, n - 1) {
		int cur = 0;
		loop(j, 0, m - 1) {
			if(i + j >= n) goto nextIteration;
			if(s[i + j] != t[j]) ++cur;
		}

		ans = min(ans, cur);
		nextIteration:;
	}

	PNN1(ans);

	return 0;
}


Measured memory_bytes: 3612
#define _USE_MATH_DEFINES
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>

using namespace std;

typedef long long ll;
typedef pair<double,int> P;

static const double eps = 10e-9;

const int tgt[][2] = {{0,1},{1,0},{0,-1},{-1,0}};

void dfs(int stage[101][101],int x,int y,int dir,int w){

	//printf("x:%d y:%d\n",x,y);
	if(stage[y][x]) return;	

	int dx;
	int dy;

	int c=0;
	for(int i=0;i<4;i++){
		dx = x+tgt[i][0];
		dy = y+tgt[i][1];
		if(dx < 0 || dx >= w || dy < 0 || dy >= w) continue;
		if(stage[dy][dx]) c++;
	}

	if(c>=2) return;

	dx = x+tgt[dir][0];
	dy = y+tgt[dir][1];

	int jx = x+tgt[dir][0]*2;
	int jy = y+tgt[dir][1]*2;

	stage[y][x] = 1;

	if(!(jx < 0 || jx >= w || jy < 0 || jy >= w) && stage[jy][jx]){
		dx = x+tgt[(dir+1)%4][0];
		dy = y+tgt[(dir+1)%4][1];
		dfs(stage,dx,dy,(dir+1)%4,w);
	}

	else if(dx < 0 || dx >= w || dy < 0 || dy >= w){
		dx = x+tgt[(dir+1)%4][0];
		dy = y+tgt[(dir+1)%4][1];
		dfs(stage,dx,dy,(dir+1)%4,w);
	}


	else dfs(stage,dx,dy,dir,w);

}

int main(){
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		int w;
		scanf("%d",&w);
		int x=0;
		int y=0;

		int stage[101][101];
		memset(stage,0,sizeof(stage));
		int dir = 0;
		int change = 0;

		dfs(stage,0,0,0,w);
		for(int ty = w-1; ty>=0;ty--){
			for(int tx=0; tx<w;tx++){
				cout << (stage[ty][tx] ? '#' : ' ');
			}
			cout << endl;
		}

		if(i<n-1) cout << endl;
	}
}

Measured memory_bytes: 0
/*---> 11 May 2020 <--- > 01:47:15 <---*/
// #pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
// #pragma GCC optimize("unroll-loops")
// #pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
//#pragma GCC target ("sse4")
#include <bits/stdc++.h>
//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
using namespace std;
//template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
#define int long long
#define F first
#define S second
#define mod 1000000007
#define inf (int)1e18+5
#define sz(x) (int)x.size()
#define PI 3.141592653589793238510
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define __ ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define vi vector<int>
#define vpii vector<pair<int,int> > 
#define vvi vector<vector<int> >
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define PRINT_TIME cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s." <<endl;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename   enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
typedef long double ld;
typedef pair<int,int> pii;
///////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////
const int N=15;
int a[N],ans=inf,n,m,X,c[N],v[N][N];
void solve(int ind,int val){
	if(ind==n){
		bool ok=true;
		// for(int i=0;i<n;i++){
			for(int j=0;j<m;j++)
				if(a[j]<X)
				{
					ok=false;
					break;
				}
			// }
			// if(!ok)
				// break;
		// }
		if(ok)
			ans=min(ans,val);
		return;
	}
	solve(ind+1,val);
	for(int i=0;i<m;i++){
		a[i]+=v[ind][i];
	}
	solve(ind+1,val+c[ind]);
	for(int i=0;i<m;i++){
		a[i]-=v[ind][i];
	}
}
int32_t main(){__
	cin>>n>>m>>X;
	for(int i=0;i<n;i++){
		cin>>c[i];
		for(int j=0;j<m;j++){
			cin>>v[i][j];
		}
	}
	solve(0,0);
	cout<<(ans==inf ? -1 : ans)<<"\n";
return 0;
}

Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
#define MAXN 3
char s[MAXN+5];
int main(){
	int i,j;
	char a[4]={'a','b','c'},t;
	scanf("%s",s);
	for(i=0;i<=2;i++){
		for(j=i+1;j<=2;j++){
			if(s[i]>s[j]){
				t=s[i];
				s[i]=s[j];
				s[j]=t;
			}
		}
	}
	if(strcmp(s,a)==0)
		printf("Yes");
	else
		printf("No");
}

Measured memory_bytes: 256
#pragma GCC optimize(3, "Ofast", "inline")

#include <bits/stdc++.h>

#define start ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long
#define int ll
#define ls st<<1
#define rs st<<1|1
#define pii pair<int,int>
#define rep(z, x, y) for(int z=x;z<=y;++z)
#define com bool operator<(const node &b)
using namespace std;
mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
const int maxn = (ll) 3e5 + 5;
const int mod = 998244353;
const int inf = 0x3f3f3f3f;
int T = 1;

void solve() {
    char c;
    cin >> c;
    if (isupper(c))
        cout << "A";
    else
        cout << "a";
}

signed main() {
    start;
    while (T--)
        solve();
    return 0;
}

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

int main () {
    int N;
    cin >> N;
    int sum=0;

    for (int i=0; i<N; i++) {
        int l, r;
        cin >> l >> r;
        int Lithops=r-l+1;

        sum+=Lithops;
    }
    
    cout << sum << endl;
}

Measured memory_bytes: 3592
#include<stdio.h>
#include<algorithm>
using namespace std;
int gcd(int a,int b){
	while(a){
		b%=a;
		int c=a;
		a=b;
		b=c;
	}
	return b;
}
int main(){
	int a,b,c,d;
	while(scanf("%d%d%d%d",&a,&b,&c,&d),a){
//		if(b==0&&c==0&&d==0)d++;
		int C=c;
		int D=d;
		int B=b;
		while(1){
		c=C;
		d=D;
		b=B;
		int M=a*(60*c+d-60*d);
		int H=3600*b+60*c+d-a*60*d;
		int W=M+H;
		while(W<0){
			W+=3600*a;
		}
		while(W>=3600*a){
			W-=3600*a;
		}
		//printf("%d\n",W);

		int sb=119*a-1;
		int ss=W+sb*d;
		//printf("%d %d %d: %d %d\n",b,c,d,W,ss);
		while(sb*60<=ss){
			ss-=sb*60;
			c++;
		}
		while(c>=60){
			c-=60;
			b++;
		}
		b%=a;
		if( 60*ss!=60*c*sb+ss
		&& 60*(ss-30*sb)!=60*c*sb+ss
		&& 60*(ss+30*sb)!=60*c*sb+ss){
				printf("%d %d %d %d\n",b,c,ss/gcd(ss,sb),sb/gcd(ss,sb));
			break;
		}
		B=b;
		C=c;
		D=ss/sb+1;
		}

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

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void solve() {
    clock_t start = clock();
    ll D;
    cin >> D;
    vector<ll> C(26);
    rep(i, 26) cin >> C[i];
    vector<vector<ll>> S(D, vector<ll>(26));
    rep(i, D) {
        rep(j, 26) {
            cin >> S[i][j];
        }
    }
    vector<ll> T(D);

    rep(i, D) {
        ll r = rand() % 26;
        T[i] = r + 1;
    }
    vector<ll> last(26, 0);

    ll sum = 0;
    auto f = [&] {
        sum = 0;
        last.assign(26, 0);
        rep(d, D) {
            ll t = T[d];
            sum += S[d][t - 1];
            last[t - 1] = d + 1;
            rep(i, 26) {
                sum -= C[i] * ((d + 1) - last[i]);
            }
        }
        return sum;
    };
    ll ans = -INF;
    clock_t end = clock();
    double time = (end - start) / 1000;
    while (time <= 1900) {
        ll r = rand() % 26;
        r++;
        ll d = rand() % 365;
        ll old = T[d];
        T[d] = r;
        ll res = f();
        if (res > ans) {
            ans = res;
        }else {
            T[d] = old;
        }
        // cout << ans << '\n';
        end = clock();
        time = (end - start) / 1000;
    }
    // cout << time << '\n';
    rep(d, D) {
        cout << T[d] << '\n';
    }
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
    return 0;
}


Measured memory_bytes: 3772
#include<iostream>
#include<algorithm>
#include<string>
#include<cctype>
 
#define rep(i,n) for((i)=0;(i)<(n);i++)
 
using namespace std;
 
int p,q,r,now;
string s;
 
int formula(void){
     
    if(isdigit(s[now])){return s[now++]-'0';}
    if(s[now]=='P'){now++;return p;}
    if(s[now]=='Q'){now++;return q;}
    if(s[now]=='R'){now++;return r;}
     
    int res=0;
    if(s[now]=='-'){now++;return 2-formula();}
    if(s[now]=='('){
        now++;
        res=formula();
        if(s[now]=='*'){now++;res=min(res,formula());}
        else if(s[now]=='+'){now++;res=max(res,formula());}
        now++;
    }
    return res;
}
 
int main(void){
     
    while(cin >> s,s!="."){
         
        int cnt=0;
        rep(p,3)rep(q,3)rep(r,3){
            now=0;
            if(formula()==2)cnt++;
        }
        cout << cnt << endl;
    }
    return 0;
}

Measured memory_bytes: 1188
#include<iostream>
#include<vector>
#include <cmath>
#include <map>
#include <algorithm>
using namespace std;
int main(void){
    int N ;
    cin >> N ;

    vector<int>a(N,0) ;
    for( int i = 0; i < N; i++ ){
        cin >> a[i] ;
    }

    sort( a.begin(), a.end()) ;
    int high = a[N-1] ;
    int sum = 0 ;

    for(int j = 0; j < N-1; j++ ){
        sum += a[j] ;
    }

    if(high < sum ){
        cout << "Yes" << endl;
    } else {
        cout << "No" <<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;
/*template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
*/typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll,ll> pl;
typedef pair<int,int> pii;

#define int ll
#define LOCAL 0
#define dbg(x) cout << #x << " is " << x << "\n"
#define gll(x) scanf("%d",&x)
#define gll2(x,y) scanf("%d%d",&x,&y)
#define gll3(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define gllarr(arr,n) f(i,n) gll(arr[i]);
#define sz(x) ((int)x.size())
#define s(x) sort(x.begin(),x.end())
#define all(v) v.begin(),v.end()
#define rs(v) { s(v) ; r(v) ; }
#define r(v) {reverse(all(v));}
#define pb push_back
#define f(i,n) for(int i=0;i<n;i++)
#define fr(i,n) for(int i=n-1;i>=0;i--)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=a;i>=b;i--)

const ll mod = (ll)1e9 + 7;
const ll inf = (ll)1e16;
const ld eps = 1e-12;
const ll N = (int)1e5 + 5;
const ll LOGN = 19;
const ld PI = 3.14159265358979323846;
inline ll mul(ll a, ll b, ll m = mod) { return (ll)(a * b) % m;}
inline ll add(ll a, ll b, ll m = mod) { a += b; if(a >= m) a -= m; if(a < 0) a += m; return a;}
inline ll power(ll a, ll b, ll m = mod) { if(b == 0) return 1; if(b == 1) return (a % m); ll x = power(a, b / 2, m); x = mul(x, x, m); if(b % 2) x = mul(x, a, m); return x;}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    if (LOCAL) {
        freopen("C:\\Users\\Dishant\\Desktop\\Collection-DEV c++\\input.txt", "r", stdin);
        freopen("C:\\Users\\Dishant\\Desktop\\Collection-DEV c++\\output.txt", "w", stdout);
    }
    int k, n;
    cin>>k>>n;
    vector<int> a(n);
    f(i, n) cin>>a[i];
    s(a);
    int ans = a[n - 1] - a[0];
    int agad[n], pachad[n];
    f(i, n) {
        agad[i] = k - a[i];
        pachad[i] = a[i];
    }
    for(int i = 1; i < n; i++) {
        ans = min(ans, agad[i] + pachad[i - 1]);
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 4992
import java.util.*;
import java.io.*;

public class Main {
	static int n;
	static int k;
	static int[] w;
	
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);

		n = scanner.nextInt();
		k = scanner.nextInt();
		
		w = new int[n];

		int i = 0, j = 0;
		
		for (int l = 0; l < n; l ++) {
			w[l]  = scanner.nextInt();
			j += w[l];
		}

		scanner.close();
		
		while (i < j) {
			int p = (i + j) / 2;
			if (f(p) < n) {
				i = p + 1;
			} else {
				j = p;
			}
		}

		System.out.println(i);
	} 

	static int f(int p) {
		int v = 0;

		for (int i = 0; i < k; i ++) {
			for (int v0 = w[v++]; v0 <= p; v0 += w[v++]) {
				if (w[v - 1] > p) {
					return 0;
				}
				if (v >= n) {
					return n; 
				}
			}
			v--;
		}

		return v;
	} 
} 



Measured memory_bytes: 71052
import java.util.*;
import java.util.InputMismatchException;
public class Main {
	public static void main(String[] args){
      try{
		Scanner sc = new Scanner(System.in);
     
	      int a = sc.nextInt();
	      int b = sc.nextInt();
	      int k;
      
	      if(a == b){
 	  	     System.out.println("IMPOSSIBLE");
          }else if(a < 0){
            System.out.println("IMPOSSIBLE");
          }else if (b > 1000000000){
            System.out.println("IMPOSSIBLE");
	      }else{
	        k=(b+a)/2;
            if((k*2) != (a+b)){
              System.out.println("IMPOSSIBLE");
            }else{
			System.out.println(k);
            }
	      } 
      }catch(InputMismatchException e){
        System.out.println("IMPOSSIBLE");
      }
	}
}


Measured memory_bytes: 21716
int main()
{
  long n, k;
  scanf("%ld %ld", &n, &k);
  int i;
  long a[n];
  for (i = 0; i < n; i++)
    scanf("%ld", &a[i]);
  int j;
  for (i = k; i < n; i++)
  {
    if (a[i - k] < a[i])
      printf("Yes\n");
    else
      printf("No\n");
  }
}

Measured memory_bytes: 3216
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define rrep(i, n) for (int i = (int)n-1; i >= 0; --i)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;

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

__attribute__ ((constructor))
void fastio() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
}

int main(){
    string s;
    cin >> s;
    if(s[int(s.size())-1] == 's')
        s += "es";
    else
        s += "s";
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 3624
n,k=map(int,input().split())
ans=0 
curr=0 
l=[int(i) for i in input().split()]
for i in range(39,-1,-1):
    c=0 
    for j in range(n):
        if l[j]&(1<<i):
            c+=1 
    a=c 
    b=n-c 
    if b>a:
        if curr+(1<<i)<=k:
            curr+=(1<<i)
print(sum(i^curr for i in l))

Measured memory_bytes: 14620
from collections import Counter

n = int(input())
blue_cards = [input() for i in range(n)]
m = int(input())
red_cards = [input() for i in range(m)]

blue_c = Counter(blue_cards)
red_c = Counter(red_cards)

score = 0
for k,v in blue_c.most_common():
    score = max(score, v - red_c[k])

print(score)

Measured memory_bytes: 3316
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] a = new int[N];

		int Max = 0;
		int min = 1000;
		for(int i=0; i<N; i++) {
			a[i] = sc.nextInt();
			if(a[i] > Max) {
				Max = a[i];
			}
			if(a[i] < min) {
				min = a[i];
			}
		}

		System.out.println(Max - min);

	}

}


Measured memory_bytes: 20820
#include <stdio.h>

int a,b;
int c;
int d;
main(){

scanf("%d%d",&a,&b);

if(a>=1 && b<=100){

c= (a*b);
d= (2*a) + (2*b);
}

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


return 0;
}

Measured memory_bytes: 596
#include <algorithm>
#include <iostream>
#include <complex>
#include <vector>
#include <cmath>
using namespace std;
using llong = long long;
using ldouble = long double;
using cd = complex<ldouble>;
using vcd = vector<complex<ldouble>>;
const ldouble PI = acos((ldouble)-1);
#define BUGO(x) cerr << #x << " = " << (x) << '\n';
#define BUGOARR(a) {cerr << #a << ": "; for (auto i: a) cerr << i << ' '; cerr << '\n';}
#ifndef MANSON
#define BUGO(x)
#define BUGOARR(x)
#endif
ostream& operator<<(ostream& out, const pair<auto, auto>& p) {
    return out << "{" << p.first << ", " << p.second << "}";
}
const int maxN = 200'005;
const int mod = 200'003;

int rev[4 * maxN];
cd roots[4 * maxN];
void fft(vcd& a)
{
    int n = a.size();
    for (int i = 0; i < n; ++i)
        if (i < rev[i])
            swap(a[i], a[rev[i]]);
    for (int len = 1, step = n / 2; len < n; len <<= 1, step >>= 1)
        for (int st = 0; st < n; st += len + len)
            for (int i = 0, root = 0; i < len; ++i, root += step)
            {
                cd u = a[st + i], v = roots[root] * a[st + len + i];
                a[i + st] = u + v;
                a[st + len + i] = u - v;
            }
}
void inv(vcd& a) {
    fft(a);
    reverse(a.begin() + 1, a.end());
    for (cd& i: a)
        i /= a.size();
}
void conv(vcd& a, vcd b)
{
    int n = 1, h = -1;
    while (n < a.size() + b.size()) n <<= 1, ++h;
    while (a.size() < n) a.push_back(0);
    while (b.size() < n) b.push_back(0);
    rev[0] = 0;
    for (int i = 1, j = -1; i < n; ++i)
    {
        j += !(i & (i - 1));
        rev[i] = rev[i ^ (1 << j)] | (1 << (h - j));
    }
    ldouble sector = 2. * PI / n;
    for (int i = 0; i < n; ++i)
        roots[i] = cd(cos(i * sector), sin(i * sector));
    fft(a); fft(b);
    for (int i = 0; i < n; ++i)
        a[i] *= b[i];
    inv(a);
}
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        if (!a[i]) {
            swap(a[i], a.back());
            a.pop_back();
            --n;
            --i;
        }
    }
    vector<int> c(mod);
    for (int i = 0, pw = 1; i < mod - 1; ++i, pw = (pw * 2) % mod)
        c[pw] = i;
    vcd b(mod - 1);
    for (int i: a)
        b[c[i]] += 1;
    conv(b, b);
    vector<llong> d(b.size());
    for (int i = 0; i < b.size(); ++i)
        d[i] = (b[i].real() + 0.5);
    for (int& i: a)
        --d[2 * c[i]];
    llong ans = 0;
    for (int i = 0, pw = 1; i < d.size(); ++i, pw = pw * 2LL % mod)
        ans += d[i] * (llong)pw;
    cout << ans / 2LL;
}


Measured memory_bytes: 68740
import java.util.*;
 
public class Main {
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		int ans = 0;
    if (A*C <= B) {
      ans = C;
		}
		else {
			ans = B/A;
		}
		System.out.println(ans);
  }
}

Measured memory_bytes: 35524
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include <iomanip>
using namespace std;


int main(){
	long long int n,ans=1;

	cin>>n;
	
	for(int i=0;n>0;i++){
		n=n/2;
		ans=ans*2;
	}
	ans--;
	cout<<ans<<endl;
    
    return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split(" ")))
mod = 10 ** 9 + 7
s = 0
for i in range(n):
    s = (s + a[i])
s = (s * s)
for i in range(n):
    s = (s - (a[i] ** 2) )
s = (s // 2) %mod
print(s)


Measured memory_bytes: 96588
#include <iostream>
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <cctype>
#include <string>
#include <map>
#include <set>
#include <math.h>
#include <cmath>
#define ll long long

using namespace std;
using P = pair<int,int>;

int main(){

  int h, w;
  cin >> h >> w;
  vector<vector<string>> vec(h+2, vector<string>(w+2));
  for (int i = 0; i < h+2; i++) {
    for (int j = 0; j < w+2; j++) {
      vec.at(i).at(j) = "*";
    }
  }

  string s;
  for (int i = 1; i < h+1; i++) {
    cin >> s;
    for (int j = 1; j < w+1; j++) {
      vec.at(i).at(j) = s[j-1];
    }
  }

  // 処理
  for (int i = 1; i < h+1; i++) {

    for (int j = 1; j < w+1; j++) {
      if(vec.at(i).at(j) != "#"){
        int x = 0;
        if(vec.at(i-1).at(j-1) == "#") x++;
        if(vec.at(i-1).at(j) == "#")   x++;
        if(vec.at(i-1).at(j+1) == "#") x++;
        if(vec.at(i).at(j-1) == "#")   x++;
        if(vec.at(i).at(j+1) == "#")   x++;
        if(vec.at(i+1).at(j-1) == "#") x++;
        if(vec.at(i+1).at(j) == "#")   x++;
        if(vec.at(i+1).at(j+1) == "#") x++;
        vec.at(i).at(j) = to_string(x);
      }
      // cout << vec.at(i).at(j) << " ";
    }
    // cout << endl;
  }

  // // 【確認用】
  // // 全体
  // for (int i = 0; i < h+2; i++) {
  //   for (int j = 0; j < w+2; j++) {
  //     cout << vec.at(i).at(j) << " ";
  //   }
  //   cout << endl;
  // }

  // cout << " " << endl;

  // 該当のみ
  for (int i = 1; i < h+1; i++) {
    for (int j = 1; j < w+1; j++) {
      cout << vec.at(i).at(j) << "";
    }
    cout << endl;
  }

  return 0;
}

Measured memory_bytes: 3684
#include <stdio.h>
int main(void){
    
    int a,b,c,tmp;
    scanf("%d %d %d",&a,&b,&c);

    if(a>b){
        tmp=a;
        a=b;
        b=tmp;
    }
    if(b>c){
        tmp=b;
        b=c;
        c=tmp;
    }
        if(a>b){
        tmp=a;
        a=b;
        b=tmp;
    }
    
    printf("%d %d %d\n",a,b,c);
    return 0;
}


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

int main(){

    char s[100];
    char p[100];
    char a[200];

    scanf("%s",s);
    scanf("%s",p);

    strcpy(a,s);
    strcat(a,s);

    if(strstr(a,p))
        printf("Yes\n");
    else
        printf("No\n");
    
return 0;

}

Measured memory_bytes: 540
#ABC 009 B
N=int(input())
W= [int(j) for j in input().split()]
MIN=sum(W)
for i in range(N-1):
    if abs(sum(W[:i+1])-sum(W[i+1:]))  < MIN:
        MIN =abs(sum(W[:i+1])-sum(W[i+1:]))
print(MIN)


Measured memory_bytes: 2940
n = input()
a = map(int, raw_input().strip().split())
b = map(int, raw_input().strip().split())

ans = 0
for i in xrange(n):
    can = b[i]
    x1 = min(a[i], can)
    a[i] -= x1
    can -= x1
    ans += x1

    x2 = min(a[i + 1], can)
    a[i + 1] -= x2
    can -= x2
    ans += x2

print ans


Measured memory_bytes: 49208
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll binarySearch(ll arr[], ll l, ll r, ll x)
{
    if (r >= l) {
        ll mid = l + (r - l) / 2;
        if (arr[mid] == x)
            return mid;
        if (arr[mid] > x)
            return binarySearch(arr, l, mid - 1, x);

        return binarySearch(arr, mid + 1, r, x);
    }
    return -1;
}
int main(){
    ll n;
    cin>>n;
    ll value=1000;
    ll i=2;
    while(n>value){
        value=value+1000;
    }
    cout<<value-n<<endl;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
#define f first
#define se second
#define pb push_back
#define mp make_pair
#define vi vector<int>
#define pi pair<int,int>
#define all(x) x.begin(),x.end()
#define lp(i,n) for(int i =0;i<n;i++)
#define mem(a,v) memset(a,v,sizeof(a))
#define X real()
#define Y imag()
#define angle(a) (atan2(a.Y , a.X))
#define vec(a,b) ((b)-(a))
//#define length(a) (hypot(a.Y , a.X))
#define normalize(a) (a)/length(a)
#define dotP(a,b) ((conj(a)*b).X)
#define crossP(a,b) ((conj(a)*b).Y)
#define same(p1,p2) (dotP(vec(p1,p2),vec(p1,p2))<EPS)
#define lengthSqr(a)   dotP(a,a)
#define rotate0(p,ang) ((p)*exp(point(0,ang)))
#define rotateA(p,ang,about) (rotate0(vec(about,p),ang)+about)
#define reflect0(v,m) conj(v/m)*m
const double PI = acos(-1.0);
const double EPS = (1e-10);
const long long int INF = 0x3f3f3f3f;
const long long mod  = (1e9)+7;
typedef long long int ll;
typedef unsigned long long ull;
typedef complex<double> point;
ll my_mod(ll num,ll mod){
    ll ret = num%mod;
    while(ret<0)ret+=mod;
    return ret;
}
int main(){
	//ios::sync_with_stdio(false);
   int h,w;
    cin>>h>>w;
    int n;
    cin>>n;
    int grid[h][w];
    mem(grid,0);
    vector<int> a(n);
    lp(i,n)cin>>a[i];
    int cr = 0 ,cc = 0;
        int current = 1 ,cnt = 0;
        for(int r = 0 ; r <h ;r++){
            if(r%2){
                for(int c = w-1 ; c>=0  ;c--){
                    if(grid[r][c] == 0){
                        grid[r][c] = current;
                        cnt++;
                        if(cnt == a[current-1]){
                            current++;
                            cnt = 0;
                        }
                    }
                }
            }else{
                for(int c = 0 ; c< w  ;c++){
                    
                        grid[r][c] = current;
                        cnt++;
                        if(cnt == a[current-1]){
                            current++;
                            cnt = 0;
                        }
                }
                
            }
    }
    lp(i,h){
        lp(j,w){
            cout<<grid[i][j]<<" ";
        }
        cout<<endl;
    }
    return 0;
}


Measured memory_bytes: 384
// Library
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

// TYPEDEFS
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pi;

// CONSTANTS
#define SZA 0
#define SZB 0

// MACRO
#define MAX(X, Y) (((X) > (Y))? (X) : (Y))
#define MIN(X, Y) (((X) < (Y))? (X) : (Y))
#define ABS(X) (((X) > 0)? (X) : -(X))
#define YN(X) ((X)? "Yes" : "No")
#define SWAP(T, X, Y) {T t; t = X; X = Y; Y = t;}

// Global Tables

//ull gPreProcess[SZA][SZB];

// Functions

void Print2DVector(vector<vector<int>>& v)
{
    ull i, j; 
    for(i = 0; i < v.size(); i++)
    {
        for(j = 0; j < v[i].size(); j++)
        {
            cout << v[i][j];
            if(j == v[i].size()-1)
            {
                cout << endl;
            }
            else
            {
                cout << " ";
            }
        }
    }
}

void PrintVector(vi& v)
{
    ull i;
    for(i = 0; i < v.size(); i++)
    {
        cout << v[i];
        if(i == v.size()-1)
        {
            cout << endl;
        }
        else
        {
            cout << " ";
        }
    }
}

void PrintArr(int* a, ull N)
{
    ull i;
    for(i = 0; i < N; i++)
    {
        cout << a[i];
        if(i == N-1)
        {
            cout << endl;
        }
        else
        {
            cout << " ";
        }
    }
}

void PreProcessTables()
{
    ull i, j;
    for(i = 0; i < SZA; i++)
    {
        for(j = 0; j < SZB; j++)
        {
            break;
        }
        break;
    }
}

void TC(int t)
{
    int mx = 0, curr;
    string S, T;
    cin >> S >> T;
    for(int i = 0; i < S.size()-T.size()+1; i++)
    {
        curr = 0;
        for(int j = 0; j < T.size(); j++)
        {
            if(S[i+j] == T[j])
            {
                curr++;
            }    
        }
        mx = max(curr, mx);
    }
    cout << T.size() - mx << endl;
}   

// Main

int main(void)
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
 
    PreProcessTables();

    int T = 1, t;
    for(t = 1; t <= T; t++)
    {
        TC(t);
    }
    return 0;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define inf (ll)1e9
#define mod (ll)(1e9+7)
#define d(x) cerr<<#x<<"="<<x<<endl;
#define p(x) cout<<(x)<<endl
#define ps(x) cout<<(x);
#define pfix(d,x) cout << fixed << setprecision(d) << x << endl;
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define minel(v) *min_element(all(v))
#define minind(v) distance((v).begin(), min_element(all(v)))
#define maxel(v) *max_element(all(v))
#define maxind(v) distance((v).begin(), max_element(all(v)))
#define fi first
#define se second
ll a,b,c,d,n,m,x,y,z,k,h,w,sum,mi,ma,ans,s,t,l,r,res,tmp,itr,p,q;
bool flag;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
int dx8[8]={1,1,0,-1,-1,-1,0,1},dy8[8]={0,1,1,1,0,-1,-1,-1};
char cha;
string st;
typedef map<int, int> imap;
typedef pair<ll, ll> P;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<pair<ll,ll> > VP;


int main(){
    cin>>n>>a>>b;
    p((n*a<b)?n*a:b);
    return 0;
}


Measured memory_bytes: 256
package main

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

var scanner = bufio.NewScanner(os.Stdin)

func nextString() string {
	scanner.Scan()
	return scanner.Text()
}

func nextInt() (int, error) {
	return strconv.Atoi(nextString())
}

type Pair struct {
	key   int
	value int
}

func main() {
	scanner.Split(bufio.ScanWords)

	counts := map[int]int{}
	for {
		n, err := nextInt()
		if err != nil {
			break
		}

		counts[n]++
	}

	pairs := []Pair{}
	for k, v := range counts {
		pairs = append(pairs, Pair{k, v})
	}
	sort.Slice(pairs, func(i, j int) bool {
		if pairs[i].value == pairs[j].value {
			return pairs[i].key < pairs[j].key
		}
		return pairs[i].value > pairs[j].value
	})

	vMax := 0
	for _, pair := range pairs {
		if vMax != 0 && vMax != pair.value {
			break
		}
		if pair.value > vMax {
			vMax = pair.value
		}
		fmt.Println(pair.key)
	}
}



Measured memory_bytes: 1124
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, ll> Pil;

double D, T, S;

int main() {
    cin >> D >> T >> S;

    if (D/S <= T) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 3696
mod = 10**9+7
import sys
from collections import Counter, defaultdict, deque
from itertools import product, permutations, combinations
from itertools import accumulate
from operator import itemgetter
from bisect import bisect_left,bisect
from heapq import heappop,heappush
from math import ceil,floor
from copy import deepcopy
from heapq import heappop,heappush,heapify
import heapq


sys.setrecursionlimit(10 ** 6)

int1 = lambda x: int(x) - 1

# リストの要素を改行を挟んで表示する
p2D = lambda x: print(*x, sep="\n")
# 入力を整数に変換して受け取る
def II(): return int(sys.stdin.readline())

def MI(): return map(int, sys.stdin.readline().split())
def MI1(): return map(int1, sys.stdin.readline().split())

# 入力全てを整数に変換したものの配列を受け取る
# def LI(): return list(map(int, sys.stdin.readline().split()))
# 入力全てを整数に変換して1引いたものの配列を受け取る
def LLI(rows_number): return [LI() for _ in range(rows_number)]


def LI(): return list(map(lambda x:int(x), sys.stdin.readline().split()))
def HI(): return list(map(lambda x:int(x)*(-1), sys.stdin.readline().split()))


N,K = MI()
a = N%K
print(min(a,K-a))







Measured memory_bytes: 38384
#include <bits/stdc++.h>
#define pb push_back
#define all(v) (v).begin() , (v).end()

using namespace std;

typedef vector<int> vi;
typedef long long   ll;

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

int main()
{
    int num;
    cin >> num;
    int s = sqrt(num);
    cout << s * s << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
int main(){
  while(true){
    string s;cin>>s;
    if(s=="0000"){
      return 0;
    }
    int k = 0;
    while(true){
      if(s=="6174"){
        cout << k << endl;
        break;
      }
      k++;
      sort(s.begin(),s.end());
      //cout <<"!!" <<s << endl;
      int a = 0;
      for(int i = 0; 4 > i; i++){
        a*=10;
        a+=s[i]-'0';
        //cout << a << endl;
      }
      int b = 0;
      for(int i = 3; 0 <= i; i--){
        b*=10;
        b+=s[i]-'0';
      }
      //cout << a << " " << b << endl;
      int c = b-a;
      //cout <<c << endl;
      if(c == 0){
        cout << "NA" << endl;
        break;
      }
      if(c == 6174){
        cout << k << endl;
        break;
      }
      s[0] = c/1000;
      s[1] = (c/100)%10;
      s[2] = (c/10)%10;
      s[3] = c%10;
    }
  }
}


Measured memory_bytes: 3124
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int l,r,d;
    cin>>l>>r>>d;
    int u=r/d;
    int n;
    if(l%d==0)
    {
       n=(l/d)-1;
    }
    else
    {
        n=l/d;
    }
    cout<<u-n;
}


  

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

typedef unsigned long long ull;
typedef long long ll;

int main(){ 
  int N, M;
  cin>>N>>M;
  vector<int> a(M);
  int sum=0;
  for(int i=0; i<M; i++)
  {
    cin >> a[i];
    sum+=a[i];
  }
  if(N<sum) cout << -1 <<endl;
  else cout << N-sum <<endl;
  
}


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

using namespace std;

typedef long long lint;
const lint N = 1e5+100;
lint n, happiness[N][3], abc[N][3];

int main(){
#ifdef LOCAL
	freopen("input", "r", stdin);
#endif

	scanf("%lld", &n);

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

	happiness[0][0] = abc[0][0]; happiness[0][1] = abc[0][1]; happiness[0][2] = abc[0][2];

	for (int i = 1; i < n; i++){
		for (int j = 0; j < 3; j++){
			if (j==2) happiness[i][j] = max(happiness[i-1][0] + abc[i][j], happiness[i-1][1] + abc[i][j]);
			else if (j==1) happiness[i][j] = max(happiness[i-1][0] + abc[i][j], happiness[i-1][2] + abc[i][j]);
			else happiness[i][j] = max(happiness[i-1][1] + abc[i][j], happiness[i-1][2] + abc[i][j]);
		}
	}
	
	printf("%lld\n", max(happiness[n-1][0], max(happiness[n-1][1], happiness[n-1][2])));

	return 0; 
}

Measured memory_bytes: 8536