akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s,t;
	cin >> s >> t;
	int n = s.length();
	int m = t.length();
	int dp[n+1][m+1];// dp[i][j] is LCS with first i characters of s and first j characters of m
	vector<char> ans;
	for(int i=0;i<=n;i++){
		for(int j=0;j<=m;j++){
			if(i == 0 || j == 0){
				dp[i][j] = 0;
				continue;
			}
			if(s[i-1] == t[j-1])
				dp[i][j] = 1+dp[i-1][j-1];
			else
				dp[i][j] = max(dp[i-1][j],dp[i][j-1]);
		}
	}
	int i=n;
	int j=m;
	while(i && j){
		if(s[i-1] == t[j-1]){
			ans.push_back(s[i-1]);
			i--;
			j--;
			continue;
		}
		if(dp[i-1][j] > dp[i][j-1])
			i--;
		else
			j--;
	}
	for(int i=ans.size()-1;i>=0;i--)
		cout << ans[i];
	cout << "\n";
}

Measured memory_bytes: 38760
//#include <bits/stdc++.h>
#include<iostream>
#include<vector>
#include<map>
#include<math.h>

#define irep(i,n) for(int i = 0; i < (int)(n); i++)
#define irep2(i,a,n) for(int i = (int)(a); i <= (int)(n); i++)
#define irrep(i,n) for(int i = (int)(n-1); i > -1; i--)
#define irrep2(i,n,a) for(int i = (int)(n); i >= (int)(a); i--)

#define fi first
#define se second

using namespace std;

using ll = long long;
using v_int = vector<int>;
using v2_int = vector<v_int>;
using v_ll = vector<ll>;
using v2_ll = vector<v_ll>;
using v_string = vector<string>;
using v_bool = vector<bool>;
using v2_bool = vector<v_bool>;
using pii = pair<int, int>;
using mii = map<int, int>;

const double PI = 3.1415926535897932;
const int INF = (int)2e9;
const ll LINF = (ll)2e18;
const ll MOD = 1000000007;
const int dc[8] = {1, -1, 0,  0, 1, -1,  1, -1};
const int dr[8] = {0,  0, 1, -1, 1,  1, -1, -1};

template<typename T, typename U> inline
ostream& operator<<(ostream &o, pair<T,U> &p) {
    return o << "{" << p.first << "," << p.second << "}";
}
template<typename T> inline
istream& operator>>(istream &is, vector<T> &vec) {
    for(auto &v : vec) { is >> v; }
    return is;
}
template<typename T> inline
ostream& operator<<(ostream &os, vector<T> &vec) {
    for(auto &v : vec) { os << v << ",";}
    return os;
}
template<typename T> inline
ostream& operator<<(ostream &os, vector<vector<T> > &mat) {
    for(auto &row : mat) { os << row << endl; }
    return os;
}
template<typename T> inline
void chmin(T &a, T b) { a = min(a, b); }
template<typename T> inline
void chmax(T &a, T b) { a = max(a, b); }

int main(void)
{
    int n;
    cin >> n;
    int sum = 0;
    
    v_int a(n);
    irep(i, n) {
        cin >> a[i];
        sum += a[i];
    }

    int ans = INF;
    int tmp = 0;

    irep(i, n-1) {
        tmp += a[i];
        sum -= a[i];
        chmin(ans, abs(tmp-sum));
    }
    cout << ans << endl;
    return 0;
} /*atcoder*/


Measured memory_bytes: 3600
#include <bits/stdc++.h>
#include <string>
#include <algorithm>
#include <string.h>
#include <ctype.h>
#include <math.h>
#include <float.h>
#include <iomanip>
#include <iostream>
using namespace std;


int main(){

    double N,H[1010]={},T,A, mindiff=DBL_MAX,temp,ans;
    cin>>N;
    cin>>T>>A;

    for(int i=1;i<=N;i++){
        cin>>H[i];
        temp = abs((T - (H[i]*0.006))-A);
        if(temp<mindiff){
            mindiff=temp;
            ans=i;
        }
    }

    cout << ans<<endl;


    return 0;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n int
	fmt.Scan(&n)

	scores := make([]int, n)
	for i := range scores {
		fmt.Scan(&scores[i])
	}

	ans := availableScore(scores)
	fmt.Println(ans)
}

func availableScore(scores []int) int {
	max := sum(scores)
	if bugCal(max) != 0 {
		return max
	}

	sort.Ints(scores)
	for _, s := range scores {
		available := max - s
		if bugCal(available) != 0 {
			return available
		}
	}

	return 0
}

func sum(scores []int) int {
	var sum int
	for _, s := range scores {
		sum += s
	}
	return sum
}

func bugCal(score int) int {
	if score%10 == 0 {
		return 0
	}
	return score
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define ll int64_t
#define ALL(a)  (a).begin(),(a).end()
 
const ll mod = 1000000007;
const ll LINF = 1e13;
const ll LLINF = 1e18;
const ll ALPHABET = 26;
 
template <class T>
void Swap(T& r, T& l) {
  T tmp = r;
  r = l;
  l = tmp;
}
 
template<typename T>
istream& operator >> (istream& is, vector<T>& vec) {
  for (T& x : vec) is >> x; //for(int i=0; i<vec.size(); i++) is >> x[i]; とかでもいい
  return is;
}


int main(){
  ll n,k,r,s,p;
  string t;
  cin >> n >> k;
  cin >> r >> s >>p;
  cin >> t;

  map<char,ll> mp;
  mp['r'] = p; //g(r)にかつ時のポイント　= ポイントp (pa)
  mp['s'] = r; //シザースに勝つのはg
  mp['p'] = s; //pにかつポイント = point s(チョキ)


  ll ans = 0;
  vector<bool> battle(n,true);
  for (ll i = 0; i < n; i++){ // kは幅
    if (i >= k){  //一つ前と同じのは出せない
      if (t[i-k] == t[i]){
        if (battle[i-k] == true){
          battle[i] = false;
        }else{
          ans += mp[t[i]];
        }
      }else{
        ans += mp[t[i]];
      }
      
    }else{
      ans += mp[t[i]];
    }
  }
  



    cout << ans;
}


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

int main() {
    int ans = 0;
    map<int, int> mp;
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        int x;
        cin >> x;
        if (x >= 3200) ans++;
        else mp[x / 400]++;
    }
    if (ans > 0 and mp.empty()) cout << 1 << endl;
    else cout << mp.size() << endl;
    cout << ans + (int)mp.size() << endl;
}


Measured memory_bytes: 256
#4 B - ss
S = list(input())

def judge(A):
    if len(A)%2 == 0:
        if A[:len(A)//2] == A[len(A)//2:]:
            return True
    return False

for i in range(len(S)):
    S.pop()
    if judge(S):
        break
print(len(S))

Measured memory_bytes: 9004
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		LinkedList<Double> list = new LinkedList<Double>();
		while(s.hasNext()){
		    list.add(s.nextDouble());
		}
		Collections.sort(list);
		System.out.println(list.get(list.size()-1)-list.get(0));
	}
}

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

using namespace std;
string s;

int main() {
    cin >> s;
    sort(s.begin(), s.end());
    if (s[0] == 'a' && s[1] == 'b' && s[2] == 'c')
    cout << "Yes";
    else cout << "No";
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
  int N;
  scanf("%d", &N);
  int a[N];
  for(int i = 0; i < N; i++){
    scanf("%d", &a[i]);
  }
  
  int ans = 10000000, cand, tmp;
  //printf("%d\n", ans);
  for(int i = -100; i < 101; i++){
    cand = 0;
    for(int j = 0; j < N; j++){
      tmp = a[j] - i;
      //printf("%d\n", tmp);
      cand += (tmp*tmp);
      //printf("%d\n", cand);
    }
    if(ans > cand) ans = cand;
  }
  
  printf("%ld\n", ans);
  return 0;
}

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

int main(){
    long long n,a,b,rpta = 0;
    cin >> n >> a >> b;
    long long num = n / (a+b);
    long long res = n % (a+b);
    rpta = num*a;
    rpta += min(res,a);
    cout << rpta;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.lang.*;
import java.util.stream.*;

public class Main {
    public static void main(String[] args) {
        //コード
        Scanner scanner = new Scanner(System.in);
        Long n = scanner.nextLong();
        Long k = scanner.nextLong();

        Long x = n % k;
        System.out.println(Math.min(x, Math.abs(k-x)));

    }
}


Measured memory_bytes: 22996
#!/usr/bin/env python3
import sys


def solve(N: int, A: "List[int]"):
    for a in A:
        if a % 2 > 0:
            print('first')
            return
    print('second')
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    a = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"
    solve(N, a)

if __name__ == '__main__':
    main()


Measured memory_bytes: 7104
N = int(input())

M1 = -10 ** 10
M2 = - 10 ** 10

m1 = 10 ** 10
m2 = 10 ** 10

for i in range(N):
  x, y = map(int, input().split())
  M1 = max(x + y, M1)
  m1 = min(x + y, m1)
  M2 = max(x - y, M2)
  m2 = min(x - y, m2)
print(max(M1 - m1, M2 - m2))

Measured memory_bytes: 69728
#include<iostream>
using namespace std;
int main(){
    char s[15];
    cin >> s;
    int count=0;
    for(int i=0;i<15;i++){
        if(s[i] == 'x'){
            count++;
        }
    }
    if(count >= 8){
        cout << "NO" << endl;
    }else{
        cout << "YES" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
using System;

namespace ABC174
{
    class Program
    {
        static void Main(string[] args)
        {
            int a = int.Parse(Console.ReadLine());
            //string str = Console.ReadLine();
            //string[] stra = Console.ReadLine().Split(' ');//2つ以上のスペース区切り入力の取得
            if (a >= 30)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}


Measured memory_bytes: 27516
#include<iostream>
#include<cstdio>
#define MAX 1000001
using namespace std;

bool eratos[MAX];

void MakePrimes(){
	for(int i = 0; i < MAX; ++i){
		eratos[i] = true;
	}
	eratos[1] = false;
	for(int i = 2; i < MAX; ++i){
		if( eratos[i] ){
			for(int j = 2; i * j < MAX; ++j){
				eratos[ i * j ] = false;
			}
		}
	}
}

int main(){
	MakePrimes();
	while(true){
		int ans = 0;
		int a,d,n;
		scanf("%d%d%d", &a, &d, &n);
		if( a == 0 && d == 0 && n == 0 ) break;
		for(int i = 0, j = 0; i < n; ++j){
			if( eratos[ a + j * d ] ) ++i;
			if( i == n )
				ans = a + j * d;
		}
		printf("%d\n", ans);
	}
	return 0;
}

Measured memory_bytes: 0
#[allow(unused_macros)]
macro_rules! invec {
    ( $t:ty ) => {{
        let mut s = String::new();
        match std::io::stdin().read_line(&mut s) {
            Ok(0) => Vec::<$t>::new(),
            Ok(n) => s.trim().split_whitespace().map(|s| s.parse::<$t>().unwrap()).collect::<Vec<$t>>(),
            Err(_) => Vec::<$t>::new(),
        }
    }}
}

#[allow(unused_macros)]
macro_rules! input {
    ( $($t:ty),* ) => {{
        let mut s = String::new();
        std::io::stdin().read_line(&mut s);
        let mut splits = s.trim().split_whitespace();
        ($(
            {
                 splits.next().unwrap().parse::<$t>().unwrap()
            },
        )*)
    }}
}

#[allow(unused_must_use)]
#[allow(unused_variables)]
fn solve() {
    let (n, k) = input!(usize, usize);

    let mut cnt = 0;
    for b in (k+1)..(n+1) {
        cnt += (n / b) * (b - k);
        cnt += if n % b + 1 > k { n % b - k + 1} else { 0 };
    }
    if k == 0 {
        cnt -= n;
    }

    println!("{}", cnt);
}

fn main() {
    solve();
}


Measured memory_bytes: 4352
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<int, int> PII;
#define MOD (1000000007ll)

int main(void){
	int x,y,z;
	cin >> x >> y >> z;
	cout << ((x-z)/(y+z)) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,N) for(int i = 0 ; i < int(N);i++)
using namespace std ;
typedef long long ll;
typedef pair <int , int >pi;
typedef vector <int> vi ;
typedef vector <string> si;



int main (){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int a,b,c ;
	cin >> a >> b >> c;
	if (a <= b*c ) {
		cout << "Yes";
	}
	else {
		cout << "No";
	}

	return 0 ;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define ll long long
#define N 100007
#define inf 1000000007
#define pb push_back
#define all(v) v.begin(),v.end()
#define ff first
#define ss second
#define mp make_pair
using namespace std;
int n,a,b;
main(){
	cin>>n>>a>>b;
	cout<<min(n*a,b);
}

Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<map>
int main()
{
	int n, a, b, c, d;
	int sum = 0;
	scanf("%d", &n);
	a = n/1000;
	b = (n-(a*1000))/100;
	c = ((n-(a*1000))-b*100)/10;
	d = (n-(a*1000))- (b*100)-(c*10);
	//printf("%d %d %d %d\n",a,b,c,d);
	if(a==b&&a==c&&a==d)printf("Yes\n");
	else if(a==b&&a==c)printf("Yes\n");
	else if(b==c&&b==d)printf("Yes\n");
	else printf("No\n");
return 0;
}

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

int arr[105];

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> arr[i];
    }
    bool flag = false;
    for (int i = 0; i < n; i++)
    {
        if (!(arr[i]%2))
        {
            if ((arr[i]%3) && (arr[i]%5))
            {
                flag = true;
                break;
            }
        }
    }
    if (flag)
        cout << "DENIED";
    else
        cout << "APPROVED";
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <cstdio>
//#include <functional>
#include <iostream>
//#include <cfloat>
//#include <climits>
//#include <cstdlib>
//#include <cstring>
//#include <cmath>
//#include <map>
//#include <queue>
//#include <set>
//#include <sstream>
//#include <stack>
#include <string>
//#include <time.h>
#include <vector>
//#include <random>
//#include <unordered_set>
//#include <complex>
//#include <string.h>
#define rt0 return 0
#define rep(i,n) for(int i=0;i<n;i++)
#define LL long long
#define pb push_back
using namespace std;
vector <int> v;
int n;
int main()
{
	int a,b;
	cin>>a>>b;
	int p=(b-a)*(b-a+1)/2-b;
	cout<<p;
    rt0;
}

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

#define for_(i,a,b) for(int i=a;i<b;++i)
#define ALL(a) a.begin(),a.end()
#define INIT(a,b) memset(a,b,sizeof(a))
using lint = long long int;

struct Edge {
    int to;
    lint A;
    lint B;
};

struct State {
    int v;
    int num;
    lint cost;
    bool operator > (const State& o) const { return cost > o.cost; }
};

int N, M, S, C[55], D[55];
lint dst[55][2501];
vector<Edge> edge[55];

int main() {
    cin >> N >> M >> S;

    for_(i,0,M) {
        int u, v, a, b;
        cin >> u >> v >> a >> b;
        --u; --v;
        edge[u].push_back(Edge{v, a, b});
        edge[v].push_back(Edge{u, a, b});
    }

    for_(i,0,N) cin >> C[i] >> D[i];

    const int MAX_CNT = N * 50;
    for_(i,0,N) for_(j,0,MAX_CNT+1) dst[i][j] = 1LL << 60;
    priority_queue<State, vector<State>, greater<State>> que;
    que.push(State{0, min(S, MAX_CNT), 0LL});
    dst[0][0] = 0;

    while (!que.empty()) {
        State s = que.top(); que.pop();
        if (dst[s.v][s.num] < s.cost) continue;

        for (const Edge& e : edge[s.v]) {
            int nxt_num = s.num - e.A;
            lint nxt_cost = s.cost + e.B;
            if (nxt_num >= 0 and dst[e.to][nxt_num] > nxt_cost) {
                dst[e.to][nxt_num] = nxt_cost;
                que.push(State{e.to, nxt_num, nxt_cost});
            }

            while (nxt_num < MAX_CNT) {
                nxt_num = min(nxt_num + C[s.v], MAX_CNT);
                nxt_cost += D[s.v];
                if (nxt_num >= 0 and dst[e.to][nxt_num] > nxt_cost) {
                    dst[e.to][nxt_num] = nxt_cost;
                    que.push(State{e.to, nxt_num, nxt_cost});
                }
            }
        }
    }

    for_(i,1,N) cout << *min_element(dst[i], dst[i] + MAX_CNT + 1) << endl;
}


Measured memory_bytes: 37208
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(a) a.begin(), a.end()
#define P pair<int, int>
#define F first
#define S second
#define mod 1000000007
#define INF 4000000000000000000
int dx8[8]={-1,0,1,1,1,0,-1,-1};
int dy8[8]={1,1,1,0,-1,-1,-1,0};
int dx4[4]={-1,0,1,0};
int dy4[4]={0,-1,0,1};
int gcd(int a,int b){
    if(b==0)return a;
    return abs(gcd(b,a%b));
}
int uni[100010];
int root(int a){
    if(uni[a]<0)return a;
    return uni[a]=root(uni[a]); 
}
bool connect(int a,int b){
    a=root(a);
    b=root(b);
    if(a==b)return false;
    if(uni[a]>uni[b]){
        swap(a,b);
    }
    uni[a]=uni[a]+uni[b];
    uni[b]=a;
    return true;
}
signed main(void){
    int n;string s;cin>>n>>s;
    int ans=0;
    rep(i,n-2){
        if(s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C')ans++;
        
    }
    cout<<ans<<endl;
}
        


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define all(a) a.begin(),a.end()
#define sz(a) a.size()
#define re return 
#define MP make_pair
#define pb push_back
#define pii pair<int,int>
#define se second
#define fi first
using namespace std;
int n,k;
int ans=1;
signed main(){
	ios_base::sync_with_stdio(0);
	cin>>n>>k;
	while(n--) ans+=min(ans,k);
	cout<<ans;
	re 0;
}

Measured memory_bytes: 3648
#include <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <tuple>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#include <complex>
#include <iterator>
#include <array>
#include <memory>
#include <stack>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<double,double>pdd;
typedef pair<ll,ll>pll;
int main(){
    int n;
    while(cin>>n,n){
        string s; cin>>s;
        rep(_,n){
            string temp;
            vb used(10,true);
            for(int  i=0; i<s.size();i++){
                    int res=0;
                    char key=s[i];
                    for(int j=i;s[j]==key&&j<s.size();res++,j++);
                    temp+=to_string(res);
                    temp.push_back(key);
                i+=res-1;
            }
            s=temp;
        }
        cout<<s<<endl;
    }
}

Measured memory_bytes: 3380
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <set>
using namespace std;
typedef long long ll;
#define rep(i,s,n)for(ll i = s;i<n;i++)
#define repe(i,s,n)for(ll i = s;i<=n;i++)
ll p[10000000] = {};
bool v[10000000] = {};
ll s = 10000000;

int main() {
	for (int i = 2; i*i < s; i++) {
		ll k = i;
		//v[k] = true;
		for (int j = 2; j*j < s; j++) {
			v[j * k] = true;
		}
	}
	ll cnt = 0;
	ll N; cin >> N;

	rep(i, 2, 10000) {
		if (!v[i] && (i % 10 == 3)) {
			cout << i;
			cnt++;
			if (cnt == N) {
				break;
			}
			else {
				cout << " ";
			}
		}
	}
	return 0;
}

Measured memory_bytes: 10496
import java.util.*;
import java.io.*;
public class Main {
    public static void main(String[] args) throws Exception{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String input = br.readLine();
      String[] split = input.split(" ");
        int totalPower = Integer.parseInt(split[0]);
        int n = Integer.parseInt(split[1]);
      int[] n1 = new int[n];
      String a = br.readLine();
      String[] split1 = a.split(" ");
      int sum =0;
      boolean canBreak = false;
      for(int i=0;i<n;i++){
        n1[i]= Integer.parseInt(split1[i]);
        sum+=n1[i];
        if(totalPower<=sum){
          System.out.println("Yes");
          canBreak = true;
          break;
      }
      }
      if(canBreak == false){
          System.out.println("No");
      }
     
    
}
}


Measured memory_bytes: 36060
n, m, x, y = [int(i) for i in input().split()]
x1 = max([int(i) for i in input().split()])
y1 = min([int(i) for i in input().split()])

for i in range(x+1,y):
    if x1 < i and i <= y1:
        print("No War")
        break
else:
    print("War")


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define ull unsigned long long
#define ll long long
const int w=2e6+5;
struct node
{
    int x,h;
}s[w];
int cmp(node x,node y)
{
    if(x.x!=y.x)
        return x.x<y.x;
    else
        return x.h<y.h;
}
node a[w];
int main()
{
    int i;
    int n,r,m;
    //cin>>n>>r>>m;
    scanf("%d %d %d",&n,&r,&m);
    r*=2;
    r=min(r,(int)1e9);
    for(i=1;i<=n;i++)
        scanf("%d %d",&s[i].x,&s[i].h);
    sort(s+1,s+1+n,cmp);
    ll ans=0;
    int j=1,k=0;
    ll num=0;
    for(i=1;i<=n;i++)
    {
        while(j<=k&&s[i].x>a[j].x)
            num-=a[j].h,j++;
        int u=s[i].h/m;
        if(s[i].h%m!=0)
            u++;
        u-=num;
        if(u<=0)
            continue;
        k++;
        a[k]={s[i].x+r,u};
        ans+=u;
        num+=u;
        //cout<<ans<<" "<<j<<" "<<k<<endl;
    }
    //cout<<ans<<endl;
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 5888
#include <cstdio>
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <tuple>
#include <assert.h>
#include <deque>
#include <bitset>
#include <iomanip>
#include <limits>
#include <chrono>
#include <random>
#include <array>
#include <unordered_map>
#include <functional>
#include <complex>
#include <numeric>
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; }
//constexpr long long MAX = 5100000;
constexpr long long INF = 1LL << 60;
constexpr int inf = 1000000007;
constexpr long long mod = 1000000007LL;
//constexpr long long mod = 998244353LL;
const long double PI = acos((long double)(-1));

using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;

void solve() {
    int W, H; cin >> W >> H;
    vector<string> vs(H); for (int i = 0; i < H; i++) cin >> vs[i];
    int se = 0, sw = 0;
    for (int i = 0; i < H; i++) for (int j = 0; j < W; j++) {
        sw += (vs[i][j] == 'W');
    }
    int idx = 0;
    int res = sw;
    for (int i = 0; i < W; i++) {
        for (int j = 0; j < H; j++) {
            if (vs[j][i] == 'E') {
                se++;
            }
            else {
                sw--;
            }
        }
        if (chmin(res, se + sw)) {
            idx = i + 1;
        }
    }
    printf("%d %d\n", idx, idx + 1);
}

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

	int kkt = 1;
	while (kkt--) {
		solve();
	}
    return 0;
}


Measured memory_bytes: 4272
#![allow(non_snake_case, unused_imports)]

// Input
macro_rules! input { (source = $s:expr, $($r:tt)*) => { let mut iter = $s.split_whitespace(); let mut next = || { iter.next().unwrap() }; input_inner!{next, $($r)*} }; ($($r:tt)*) => { let stdin = std::io::stdin(); let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock())); let mut next = move || -> String{ bytes.by_ref().map(|r|r.unwrap() as char).skip_while(|c|c.is_whitespace()).take_while(|c|!c.is_whitespace()).collect() }; input_inner!{next, $($r)*} }; }
macro_rules! input_inner { ($next:expr) => {}; ($next:expr, ) => {}; ($next:expr, $var:ident : $t:tt $($r:tt)*) => { let $var = read_value!($next, $t); input_inner!{$next $($r)*} }; ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => { let mut $var = read_value!($next, $t); input_inner!{$next $($r)*} }; }
macro_rules! read_value { ($next:expr, ( $($t:tt),* )) => { ( $(read_value!($next, $t)),* ) }; ($next:expr, [ $t:tt ; $len:expr ]) => { (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>() }; ($next:expr, [ $t:tt ]) => { { let len = read_value!($next, usize); (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>() } }; ($next:expr, chars) => { read_value!($next, String).chars().collect::<Vec<char>>() }; ($next:expr, bytes) => { read_value!($next, String).into_bytes() }; ($next:expr, usize1) => { read_value!($next, usize) - 1 }; ($next:expr, $t:ty) => { $next().parse::<$t>().expect("Parse error") }; }

// Module
use std::cmp::{min,max};
use std::collections::{HashSet,HashMap,BTreeMap,VecDeque};

// Functions

// Main
fn main(){
    input!{
        W: chars,
    }
    let mut map = HashMap::new();
    for w in W{
        *map.entry(w).or_insert(0) += 1;
    }
    let mut ans = "Yes";
    for m in map{
        if m.1%2 != 0{
            ans = "No";
            break;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>

using namespace std;
int n,m;
int main()
{
	scanf("%d%d",&n,&m);
	if(n==0)
	{
		if(m==100) cout<<"101";
		else cout<<m;
		return 0; 
	}
	else
	if(n==1)
	{
		if(m==100) cout<<"101";
		else cout<<m;
		cout<<"00";
	}
	else
	if(n==2)
	{
		if(m==100) cout<<"101";
		else cout<<m;
		cout<<"0000";
	}
	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 ll long long
#define puts(i) cout<<i<<endl

int main(){
	int a,b,k;
	cin>>a>>b>>k;
	if(b-a+1<2*k){
		for(int i=a;i<b+1;i++)puts(i);
	}else{
		for(int i=a;i<a+k;i++)puts(i);
		for(int i=b-k+1;i<b+1;i++)puts(i);
	}
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    ios :: sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    int n, k; cin >> n >> k;
    vector <int> x(n), y(n);
    vector <int> vx, vy;
    for (int i = 0; i < n; ++ i) {
        cin >> x[i] >> y[i];
        vx.push_back(x[i]);
        vy.push_back(y[i]);
    }
    sort(vx.begin(), vx.end());
    sort(vy.begin(), vy.end());
    ll ans = 0x7fffffffffffffff;
    for (int a = 0; a < n; ++ a) {
        for (int b = a + 1; b < n; ++ b) {
            for (int c = 0; c < n; ++ c) {
                for (int d = c + 1; d < n; ++ d) {
                    int cnt = 0;
                    for (int i = 0; i < n; ++ i) {
                        if (x[i] >= vx[a] && x[i] <= vx[b]) {
                            if (y[i] >= vy[c] && y[i] <= vy[d]) {
                                ++ cnt;
                            }
                        }
                    }
                    if (cnt >= k) {
                        ans = min(ans, 1LL * (vx[b] - vx[a]) * (vy[d] - vy[c]));
                    }
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <algorithm>

using namespace std;

int main() {

	int W, H, x, y, r;
	cin >> W >> H >> x >> y >> r;

	if (x + r > W || y + r > H) {
		cout << "No" << endl;
	}
	else if (x + r < 0 || y + r < 0) {
		cout << "No" << endl;
	}
	else if (x - r < 0 || y - r < 0) {
		cout << "No" << endl;
	}
	else {
		cout << "Yes" << endl;
	}

	return 0;
}


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

int main(){

char hoge[199];
int fuga;
int flag=0;
char* tp;

scanf("%d\n", &fuga);
scanf("%[a-zA-Z ]", hoge);
tp = strtok(hoge," ,");

while(tp){

if(strcmp( tp, "Y") ==0){
flag = 1;
}
tp = strtok(NULL," ,");
}

if(flag){
printf("Four");
}
else{
printf("Three");
}

return 0;
}

Measured memory_bytes: 128
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
typedef long long ll;
string S;
inline int read() {
	int x=0,f=1;char c=getchar();
	while (c<'0'||c>'9') {if (c=='-') f=-1;c=getchar();}
	while (c>='0'&&c<='9') x=x*10+c-'0',c=getchar();
	return x*f;
}
inline void smax(int &x,int y) {
	x=x<y?y:x;
}
inline void smin(int &x,int y) {
	x=x>y?y:x;
}
int main() {
//	freopen("in.txt","r",stdin);
	cin>>S;
	for (int i=S.length();i;--i)
		cout<<'x';
	return 0;
}

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

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vector<vector<bool>>> vvvb;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<vpll> vvpll;
typedef vector<double> vd;
typedef vector<vd> vdd;

#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)
#define REP(i,y) FOR(i, 0, y)
#define RFOR(i,x,y) for(ll i=(ll)x; i>=(ll)y; --i)
#define RREP(i,x) RFOR(i, x, 0)
#define ALL(a) a.begin(), a.end()
#define pb push_back
#define debug_print(x...) cerr << "line " << __LINE__ << " : "; debug_print_in(x);

template <typename First>
void debug_print_in(First first){
  cerr << first << endl;
  return;
}

template <typename First, typename... Rest>
void debug_print_in(First first, Rest... rest){
  cerr << first << " ";
  debug_print_in(rest...);
  return;
}

void IN(void){
  return;
}

template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){
  cin >> first;
  IN(rest...);
  return;
}

template <typename First>
void OUT(First first){
  cout << first << endl;
  return;
}

template <typename First, typename... Rest>
void OUT(First first, Rest... rest){
  cout << first << " ";
  OUT(rest...);
  return;
}

template<class t, class u> void chmax(t&a,u b){if(a<b)a=b;};
template<class t, class u> void chmin(t&a,u b){if(a>b)a=b;};
int popcount(int t){return __builtin_popcount(t);} //GCC
int popcount(ll t){return __builtin_popcountll(t);} //GCC

template <typename T>
void vec_print(vector<T> VEC){
  REP(i, VEC.size()){
    cerr << VEC[i] << " ";
  }
  cerr << endl;
};

template <typename T>
void mat_print(vector<vector<T> > MAT){
  REP(i,MAT.size()){
    REP(j,MAT[i].size()){
      cerr << MAT[i][j] << " ";
    }
    cerr << endl;
  }
};

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;
constexpr ll MOD = (ll)((1E+9)+7);

ll calc(ll A1, ll A2, ll A3){
  if(A3==0){
    if(A1<A2) return INFLL/4;
    return (A1-A2)/2;
  }
  if((A1+A2+A3)%2==1){
    return INFLL/4;
  }
  ll x = calc(A1/2, A2/2, A3/2)*2;
  ll y = calc((A1-1)/2, (A2+1)/2, A3/2)*2+1;
  ll tmp = min(x,y);
  if(tmp>INFLL/4){
    tmp = INFLL/4;
  }

  return min(x,y);
}

int main(){
  cin.tie(0); // cut the cin and cout (default, std::flush is performed after std::cin)
  ios::sync_with_stdio(false); // cut the iostream and stdio (DON'T endl; BUT "\n";)

  ll N;
  IN(N);
  vll A(N);
  REP(i,N) IN(A[i]);

  ll A1 = A[0];
  ll A2 = A[1];
  ll A3 = 0;
  FOR(i,2,N) A3 ^= A[i];

  ll ans = calc(A1, A2, A3);

  if(ans>=INFLL/4 || ans>=A1){
    OUT(-1);
  }else if(((A1-ans)^(A2+ans))!=A3){
    OUT(-1);
  }else{
    OUT(ans);
  }


  return 0;
}


Measured memory_bytes: 3656
/***********************
*  Author: xuziyuan    * 
***********************/

#include <bits/stdc++.h>

#define rt0 return 0
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define replet(c) for(char c='a';c<='z';c++) 
#define LL long long
#define pii pair <int,int>
#define pb push_back
#define fi first
#define se second
#define mpr make_pair
#define sqr(a) ((a)*(a))

using namespace std;

const LL MOD=1e9+7;

LL n,k,dp[2010][2010],dp2[2010][2010];

int main()
{
	cin>>n>>k;
	dp[0][0]=dp2[0][0]=1;
	repn(i,k) repn(j,k) dp[i][j]=(dp[i-1][j-1]+dp[i-1][j])%MOD;
	repn(i,n-k) repn(j,n-k) dp2[i][j]=(dp2[i-1][j-1]+dp2[i-1][j])%MOD;
	repn(i,k)
	{
		if(i-1>=k)
		{
			puts("0");
			continue;
		}
		cout<<(dp2[n-k][i]*dp[k][i]*2+dp2[n-k][i+1]*dp[k][i]+dp2[n-k][i-1]*dp[k][i])%MOD<<endl;
	}
	rt0;
}

Measured memory_bytes: 34176
from itertools import combinations

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

C, A = [], []
for i in range(N):
    c, *a = map(int, input().split())
    C.append(c)
    A.append(a)

INF = 10**10
answer = INF
L = list(range(N))
for n in range(1,N+1):
    for comb in combinations(L, n):
        cost = 0
        S = [0]*M
        for i in comb:
            cost += C[i]
            for m in range(M):
                S[m] += A[i][m]
        if all(s >= X for s in S):
            answer = min(answer, cost)

if answer == INF:
    print(-1)
else:
    print(answer)


Measured memory_bytes: 9008
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main() {

	string s[3];
	cin>>s[0]>>s[1]>>s[2];
	ll len = s[0].size() + s[1].size() + s[2].size();
	ll turn = 0;
	int t[3];
	for(int i=0;i<3;i++) {
		t[i] = 0;
	}
	while(1) {
		if(t[turn] == s[turn].size()) {
			cout<<char('A'+turn)<<"\n";
			return 0;
		}
		ll ind = t[turn];
		t[turn] ++;
		turn = s[turn][ind]-'a';
	}
	return 0;
}

Measured memory_bytes: 256
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
	n = readline() |> parseInt
	a = zeros(Int,n,2)
	for i in 1:n
		a[i,:] = readline() |> split |> parseMap
	end
	d = zeros(Float64,n,n)
	cx = zeros(Float64,n,n)
	cy = zeros(Float64,n,n)
	vx = zeros(Float64,n,n)
	vy = zeros(Float64,n,n) 
	for i in 1:n-1
		for j in i+1:n
			d[i,j] = sqrt((a[i,1]-a[j,1])^2+(a[i,2]-a[j,2])^2)
			cx[i,j] = 0.5*(a[i,1]+a[j,1])
			cy[i,j] = 0.5*(a[i,2]+a[j,2])
			vx[i,j] = (a[i,1]-a[j,1])/d[i,j]
			vy[i,j] = (a[i,2]-a[j,2])/d[i,j]
		end
	end
	l = 0.0
	r = 1000.0
	for iter in 1:50
		m = 0.5*(r+l)
		mm = m*m
		f = 0
		for i in 1:n-1
			for j in i+1:n
				hd = 0.5*d[i,j]
				if hd<=m
					h = sqrt(mm-hd^2)
					dx = cx[i,j]+vy[i,j]*h
					dy = cy[i,j]-vx[i,j]*h
					ex = cx[i,j]-vy[i,j]*h
					ey = cy[i,j]+vx[i,j]*h
					fa = 0
					fb = 0
					for k in 1:n
						if k!=i&&k!=j
							if (dx-a[k,1])^2+(dy-a[k,2])^2>mm
								fa = 1
							end
							if (ex-a[k,1])^2+(ey-a[k,2])^2>mm
								fb = 1
							end
						end
					end
					if fa==0||fb==0
						f = 1
					end
				end
			end
		end
		if f == 1
			r = m
		else
			l = m
		end
	end
	println(r)
end
main()

Measured memory_bytes: 117432
#include <bits/stdc++.h>
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define ff first
#define ss second
#define P 1000000007
#define in(x, a, b) (a <= x && x < b)

using namespace std;
using ll = long long;
typedef pair<int, int> ii;
typedef vector<ii> vii; 
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
const ll inf = 1000000001, INF = (ll)1e18 + 1;

void solve() {
	int n;
	cin >> n;
	
	vi a(n);
	for(int i = 0; i < n; i++) cin >> a[i];
	int g = a[0];
	for(int i = 1; i < n; i++) g = __gcd(g, a[i]);
	
	if(g != 1) {
		cout << "not coprime" << endl;
		return;
	} else {
		sort(all(a));
		for(int i = 2; i <= a[n - 1]; i++) {
			int cnt = 0;
			for(int j = i; j <= a[n - 1]; j += i) {
				if((int)(upper_bound(all(a), j) - lower_bound(all(a), j)) != 0) cnt++;
			}
			
			if(cnt >= 2) {
				cout << "setwise coprime" << endl;
				return;
			}
		}
	}
	
	cout << "pairwise coprime" << endl;
}

int main() {
	ios_base::sync_with_stdio(false);
	solve();
    return 0;
}

Measured memory_bytes: 7224
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define N 1000005
typedef long long int ll;
// int n,m;
// vector<int> adj[mx];

//---dfs--
// bool visited[mx];
// vector<int> val(n,0);

// void dfs(int s, int & cnt_vert, int & cnt_edge){
// 	assert(!visited[s]);
// 	visited[s]=true;
// 	++cnt_vert;
// 	cnt_edge+=adj[s].size();
// 	for(int b:adj[s]){
// 		if(!visited[b]){
// 			dfs(b,cnt_vert,cnt_edge);
// 		}
// 	}
// }
//---dfs---

//---primes---
// const int N = 1e7 + 10;
 
// bool prime[N];
 
// int spf[N];
 
// void calc(){
// 	for(int i = 2; i<1e4; i++){
// 		if(prime[i])
// 			continue;
// 		spf[i] = i;
// 		for(int j = i * i; j < N; j += i){
// 			prime[j] = 1;
// 			spf[j] = i;
// 		}
// 	}
// 	for(int i = 2; i < N; i++)
// 		if(!spf[i])
// 			spf[i] = i;
// }

// vector<pair<int,int>> getp(int x){
// 	int curr=x;
// 	vector<pair<int,int>> ans;
// 	while(curr>1){
// 		int a=spf[curr];
// 		int count=0;
// 		while(curr%a==0){ curr/=a; count++;}
// 		ans.push_back(make_pair(a,count));
// 	}
// 	return ans;
// }

// bool ispr(int n) {
//     for (int i=2;i*i<=n;++i){
//         if(n%i==0){
//             return false;
//         }
//     }
//     return true;
// }
//---primes---

//---segment_tree---
// int upd(int t,int val,int l,int r,int y, int z){
// 	if(y<l||y>r) return tr[val];
// 	if(l==r) return tr[val]=z;
// 	int s=(l+r)/2;
// 	upd(t^1,2*val+1,l,s,y,z);
// 	upd(t^1,2*val+2,s+1,r,y,z);
// 	if(t) tr[val]=tr[2*val+1]|tr[2*val+2];
// 	else tr[val]=tr[2*val+1]^tr[2*val+2];
// 	return tr[val];
// }
//int query(){}
//---segment_tree---
//vector<int> a(1003);
// int mex(vector<int> &a){
// 	vector<int> b=a;
// 	sort(b.begin(),b.end());
// 	int ans;
// 	set<int> s;
// 	for(int i=0;i<n;i++){
// 		s.insert(b[i]);
// 	}
// 	for(int i=0;i<=n;i++){
// 		if(s.find(i)==s.end()){ans=i; break;}
// 	}
// 	return ans;
// }

int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);cout<<setprecision(25);
	int t=1;
	//cin>>t;
	while(t--){
		int n;
		cin>>n;
		int x=n/1000;
		int y=x+1;
		if(n%1000==0) y--;
		//int ans=min(abs(x*1000-n),abs(y*1000-n));
		int ans=abs(y*1000-n);
		cout<<ans<<"\n";
	}
}


Measured memory_bytes: 3648
import java.util.Scanner;

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

        // 初期値を仮で最小値に
        int minv = scan.nextInt();
        // 更新できるように最大値に十分小さい値を
        int maxv = Integer.MIN_VALUE;

        for(int i=1;i<n;i++){
           int in = scan.nextInt();
           // 最大値の更新
           maxv = Math.max(maxv, in-minv);
           // 最小値の更新
           minv = Math.min(minv, in);
        }
        System.out.println(maxv);
    }
}

Measured memory_bytes: 94376
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
#define INF 1e9

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef vector < pair<int, int> > vii;
typedef long double ld;
typedef tree<pair<int,int>, null_type, less<pair<int,int> >, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

ll cost, n, ans;
ll a[101];

int main()
{
	ans=INF;
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> a[i];
	}
	for(int i = -200; i <= 200; i++){
		cost=0;
		for(int j = 0; j < n; j++){
			cost+=(i-a[j])*(i-a[j]);
		}
		ans=min(ans,cost);
	}
	cout << ans;
	
	return 0;
}


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

if(B == 1):
  count = 0
  print(count)
else:  
 num = B - A
 count = 1
 if(num <= 0):
   print(count)
 else:
  if(num%(A-1)==0): count += num//(A-1)
  else: count += num//(A-1)+1
  print(count)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main() {
    int S, W;
    cin >> S >> W;
    if (W >= S)cout << "unsafe" << endl;
    else cout << "safe" << endl;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
set<string>ss;
string s,t;

bool Search(int i)
{
    int k=0;
    for(int j=i;j<=i+t.length()-1;)
    {
        if(s[j]==t[k]||s[j]=='?')
        {
            k++;
            ++j;
        }
        else
        {
            return false;
        }
    }
    if(k==t.length())
    {
        string z=s;
        int temp=0;
        for(int j=i;j<=i+t.length()-1;++j)
        {
            z[j]=t[temp];
            temp++;
        }
        int pos=z.find('?');
        while(pos!=-1)
        {
            z[pos]='a';
            pos=z.find('?');
        }
        ss.insert(z);
        return true;
    }
    else
    {
        return false;
    }
}
int main(void)
{
    cin>>s>>t;
    if(t.length()>s.length())
    {
        cout <<"UNRESTORABLE"<<endl;
        return 0;
    }
    for(int i=0;i<=s.length()-t.length();++i)
    {
        Search(i);
    }
    if(ss.empty())
    {
        cout <<"UNRESTORABLE"<<endl;
    }
    else
    {
        cout <<*ss.begin()<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
import sys
S = input()
if S[0] != 'A':
    print('WA')
    sys.exit()
    
n = len(S)
ct = 0
for i in range(1, n):
    if S[i].islower() == False:
        if i == 1 or i == n - 1 or S[i] != 'C':
            print('WA')
            sys.exit()
        ct += 1
if ct == 1:
    print('AC')
else:
    print('WA')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define mp make_pair
#define pb(x) push_back(x)
#define vi vector<int>
#define vs vector<string>
#define vll vector<long long>
#define vc vector<char>
#define vs vector<string>
#define pii pair<int, int>
#define pll pair<long long, long long>
#define pil pair<int, long long>
#define pli pair<long long, int>
#define pcc pair<char, char>
#define pdd pair<double, double>
#define mll map<long long, long long>
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(), (v).end()
#define flsh fflush(stdout)
#define gcd __gcd
#define clr(x) memset(x, 0, sizeof(x))
#define mod 1000000007LL
#define mod2 998244353LL
#define INF 1000000000007
 

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> o_tree;


void solve()
{
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    ll maxprod = max({b*d,a*c,a*d,b*c});
    cout<<maxprod<<"\n";
}


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


if (fopen("input.txt","r" ))
  {
     freopen("input.txt", "r", stdin);
     freopen("output.txt", "w", stdout);
  }
cout<<setprecision(20);


ll t=1;


// cin>>t;


while(t--)
{
solve();
} 


return 0;
}

Measured memory_bytes: 3656
#include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef long long LL;

template<typename T>
istream& operator >> (istream& is, vector<T>& vs){
  for(T& v: vs) is >> v;
  return is;
}

LL extract_base(LL v, const vector<LL>& base) {
  for (LL b : base) {
    v = min(v, v^b);
  }
  return v;
}

int solve() {
  int N; cin >> N;
  vector<LL> A(N); cin >> A;
  string S; cin >> S;

  vector<LL> base;
  for (int i = N - 1; i >= 0; --i) {
    LL a = A[i];
    if (S[i] == '0') {
      a = extract_base(a, base);
      if (a != 0) base.push_back(a);
    } else {
      a = extract_base(a, base);
      if (a != 0) return 1;
    }
  }
  return 0;
}

int main() {
  int N; cin >> N;
  for (int i = 0; i < N; ++i) {
    cout << solve() << endl;;
  }
}


Measured memory_bytes: 3460
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int cnt = sc.nextInt();
        int[][] cards = new int[4][13];
        for(int i=0;i<cnt;i++){
            String mark = sc.next();
            int num = sc.nextInt() - 1;
            switch (mark) {
                case "S":
                    cards[0][num] = 1;
                    break;
                case "H":
                    cards[1][num] = 1;
                    break;
                case "C":
                    cards[2][num] = 1;
                    break;
                case "D":
                    cards[3][num] = 1;
                    break;
            }
        }
        for(int i=0;i<4;i++){
            for(int j=0;j<13;j++){
                if(cards[i][j] != 1){
                    switch (i){
                        case 0:
                            System.out.printf("S %d%n",j+1);
                            break;
                        case 1:
                            System.out.printf("H %d%n",j+1);
                            break;
                        case 2:
                            System.out.printf("C %d%n",j+1);
                            break;
                        case 3:
                            System.out.printf("D %d%n",j+1);
                            break;
                    }
                }
            }
        }
    }
}



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

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

    vector<long> A(N);
    rep(i, N) cin >> A.at(i);

    long mod = pow(10, 9) + 7;

    long length = 0;
    rep(i, N)
    {
        length += A.at(i);
        length %= mod;
    }

    long area = length * length % mod;

    long diag = 0;
    rep(i, N)
    {
        diag += (A.at(i) * A.at(i)) % mod;
        diag %= mod;
    }

    if (area <= diag)
    {
        area += mod;
    }
    
    long ans = 0;
    if ((area - diag) % 2 == 0)
    {
        ans = (area - diag) / 2;
    }
    else
    {
        ans = (area - diag + mod) / 2;
    }

    cout << ans % mod << endl;

    return 0;
}


Measured memory_bytes: 4784
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N=1e5+2;
int ar[N],sum[N];
signed main(){
	int n,i,j,k,l,p,v,ans,m;
	cin>>n>>m>>v>>p;		//m nguoi,v bai,lay top p
	ans=n;
	for(i=1;i<=n;i++){	
		cin>>ar[i];
	}
	sort(ar+1,ar+1+n);
	for(i=1;i<=n;i++){
		sum[i]=sum[i-1]+ar[i];
	}
	for(i=n-p;i>=1;i--){
		j=upper_bound(ar+1,ar+1+n,ar[i]+m)-ar;
		j--;
		if(j<=n-p){
			ans=n-i;
			break;
		}
		int new_sum=(n-p+1-i)*(ar[i]+m)-sum[n-p+1]+sum[i],new_num=max(0ll,v-i-(p-1));
//		cout<<(n-p+1-i+1)*(ar[i]+m)<<' '<<sum[n-p+1]-sum[i-1]<<endl;
//		cout<<i<<' '<<new_sum<<' '<<new_num<<' '<<new_num*m<<endl;
		if(new_sum<new_num*m){
			ans=n-i;
			break;
		}
	}
	cout<<ans;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define rrep2(ri,x,n) for(int ri = (int)(n-1); ri >= (int)(x); ri--)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  vector<vector<int>> a(3, vector<int>(3));
  rep(i, 3)rep(j, 3) cin >> a.at(i).at(j);
  vector<vector<bool>> chk(3, vector<bool>(3, false));
  int n;
  cin >> n;
  rep(i, n){
    int in;
    cin >> in;
    rep(j, 3)rep(k, 3) if(a.at(j).at(k) == in) chk.at(j).at(k) = true;
  }
  bool f = false;
  rep(i, 3) if(chk.at(i).at(0) == true && chk.at(i).at(1) == true && chk.at(i).at(2) == true) f = true;
  rep(i, 3) if(chk.at(0).at(i) == true && chk.at(1).at(i) == true && chk.at(2).at(i) == true) f = true;
  if(chk.at(0).at(0) == true && chk.at(1).at(1) == true && chk.at(2).at(2) == true) f = true;
  if(chk.at(0).at(2) == true && chk.at(1).at(1) == true && chk.at(0).at(2) == true) f = true;
  if(f == true) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3632