akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

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

		int n = scan.nextInt();
		int m = scan.nextInt();
		int l = scan.nextInt();
	    int [][] detA = new int [n][m];
	    int [][] detB = new int [m][l];
	    long [][] detC = new long [n][l];

	    for(int i = 0 ; i < detA.length ; i++){
	    	for(int j = 0 ; j < detA[i].length ; j++){
	    		detA[i][j] = scan.nextInt();
	    	}
	    }

	    for(int i = 0 ; i < detB.length ; i++){
	    	for(int j = 0 ; j < detB[i].length ; j++){
	    		detB[i][j] = scan.nextInt();
	    	}
	    }

	    for(int i = 0 ; i < n ; i++){
	    	for(int j = 0 ; j < l ; j++){
	    		for(int k = 0 ; k < m ; k++){
	    			detC[i][j] += detA[i][k]*detB[k][j];
	    		}
	    	}
	    }

	    for(int i = 0 ; i < detC.length ; i++){
	    	for(int j = 0 ; j < detC[i].length ; j++){
	    		System.out.print(detC[i][j]);
                  if(j == detC[i].length -1) continue;
	    		System.out.print(" ");
	    	}
	    	System.out.println();
	    }

	    scan.close();
 	}
}

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

#define FOR(i,a,b) for(int i=(a); i<(b); i++)
#define REP(i,n) FOR(i,0,n)
#define ll long long
#define endl '\n'

using namespace std;

const ll MOD = 1e9+7;
const int MAXN = 2015;

ll fac[MAXN],povrh[MAXN][MAXN],dp[MAXN][MAXN],sumpovrh[MAXN][MAXN];

ll add(ll a, ll b){return (a+b)%MOD;}
ll mul(ll a, ll b){return (a*b)%MOD;}

int A,B;

void input(){
    cin>>A>>B;
}

int precalc(){
    fac[0] = 1;
    FOR(i,1,MAXN) fac[i] = mul(fac[i-1],i);
    povrh[0][0]=1;
    FOR(i,1,MAXN){
        povrh[i][0] = 1;
        FOR(j,1,i+1)
            povrh[i][j] = add(povrh[i-1][j-1],povrh[i-1][j]);
    }
    sumpovrh[0][0] = 1;
    FOR(i,1,MAXN){
        sumpovrh[i][0] = 1;
        FOR(j,1,i+1)
            sumpovrh[i][j] = add(povrh[i][j],sumpovrh[i][j-1]);
    }
    REP(i,MAXN){
        dp[i][0] = 1;
        dp[0][i] = 1;
    }
    FOR(i,1,MAXN){
        FOR(j,1,MAXN){
            dp[i][j] = add(dp[i-1][j],sumpovrh[j-1][min(j-1,i)]);
        }
    }
}

void solve(){
    precalc();
    ll sol = 0;
    REP(i,A+1){
        REP(j,min(A-i,B-1)+1){
            sol = add(sol,mul(povrh[B-1][j],dp[A-i-j][j]));
        }
    }
    cout<<sol<<endl;
}

int main(){
    ios_base::sync_with_stdio(false);cin.tie(0);
    input();
    solve();
    return 0;
}


Measured memory_bytes: 94080
N,M,X,Y=map(int,input().split())
x=max(map(int,input().split()))
y=min(map(int,input().split()))
P=0
for i in range(X+1,Y+1) :
  if X < i and i <=Y and x < i and i <= y :
    P+=1
if P==0 :
  print("War")
else :
  print("No War")

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

#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")

#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long int
#define ull unsigned long long
#define ld long double

#define mod 1000000007
#define EULER 2.7182818284
#define INF 1000000000

#define pb push_back
#define ins insert
#define IT iterator
#define PQ priority_queue
#define    nl           "\n"
#define fi first
#define se second
#define maxe max_element
#define mine min_element
#define er erase
#define lb lower_bound
#define ub upper_bound

#define vi vector<int>
#define vll vector<ll>
#define vb vector<bool>
#define pi pair<int,int>
#define pll pair<ll,ll>


#define mem(v,i) memset(v,i,sizeof(v)) // v is array. To set all elements to 0 or -1 only. mem(arr,0);


#define repab(i,a,b) for(int i=(a);i<=(b);i++)
#define reprab(i,a,b) for(int i=(a);i>=(b);i--)
#define repll(i,a,b) for(ll i=(a);i<=(b);i++)
#define rep(i,n) for(int i=(0);i<(n);i++)
#define repr(i,n) for(int i=(n);i>=0;i--)
#define bs bitset
#define bpc(a) __builtin_popcount(a)
#define tc int t;cin>>t;while(t--)
template<typename T> void TIME(T start, T end)
{
#ifndef ONLINE_JUDGE
    double time_taken =  chrono::duration_cast<chrono::nanoseconds>(end - start).count();
    time_taken *= 1e-9;
    cout << "\nExecuted in: " << fixed
         << time_taken << setprecision(9);
    cout << " sec";
#endif
}

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

ll max(ll a,ll b)
{
    if(a>b)return a;return b;
}
ll min(ll a,ll b)
{
    if(a<b)return a;return b;
}

ll mypow(ll a, ll b) {
    ll res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}
ll gcd(ll a,ll b)
{
    if(b==0)
    return a;
    return gcd(b,a%b);
}
//..............................!!!!!!Get ready to fight!!!!!!............................


int main()
{   
     auto start = chrono::high_resolution_clock::now();
    fast
    int a[5],k;
    rep(i,5){
        cin>>a[i];
        if(a[i]==0){
            k=i+1;
        }
    }
    cout<<k<<"\n";
    auto end = chrono::high_resolution_clock::now();
    TIME(start, end);
    return 0;
}

Measured memory_bytes: 3632
#include <algorithm>
#include <iostream>
#include <vector>
#include <cctype>
#include <cstdio>
using namespace std;

#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define ALL(c) (c).begin(), (c).end()

int64_t read_int() noexcept {
    int64_t ret = 0, sgn = 1;
    int ch = getchar_unlocked();
    if (isspace(ch)) { ch = getchar_unlocked(); }
    if (ch == '-') { sgn = -1; ch = getchar_unlocked(); }
    while (isdigit(ch)) {
        ret = (ret * 10) + (ch - '0');
        ch = getchar_unlocked();
    }
    ungetc(ch, stdin);
    return sgn * ret;
}

inline pair<int64_t, int64_t> read_pair() noexcept {
    int a = read_int();
    int b = read_int();
    return {a, b};
}

int main() {
    int N = read_int();
    vector<pair<int64_t, int64_t>> points(N);
    REP(i, N) points[i] = read_pair();

    vector<vector<int64_t>> f(N);
    REP(i, N) {
        auto [x, y] = points[i];
        f[i] = {x-y, x+y};
    }

    int64_t ans = numeric_limits<int64_t>::min();
    REP(d, 2) {
        auto m1 = numeric_limits<int64_t>::max();
        auto m2 = numeric_limits<int64_t>::min();
        REP(i, N) m1 = min(m1, f[i][d]);
        REP(i, N) m2 = max(m2, f[i][d]);
        ans = max(ans, m2 - m1);
    }
    cout << ans << endl;
}


Measured memory_bytes: 16808
#include<stdio.h>

int max_sort(int n){
	
	int num[4]={},max,i,j,maxj,t;
	
		
		num[0]=n%10;
		num[1]=(n%100)/10;
		num[2]=(n%1000)/100;
		num[3]=n/1000;
		
		for(i=0;i<4;i++){
			max=-1;
			maxj = i;
			for(j=i;j<4;j++){
				if(max<num[j]){
					max = num[j];
					maxj = j;
				}else{
					;
				}
			}
			t = num[i];
			num[i] = num[maxj];
			num[maxj] = t;
	}
	return num[0]*1000+num[1]*100+num[2]*10+num[3];
}

int min_sort(int n){
	
	int num[4]={},min,i,j,minj,t;
	
		
		num[0]=n%10;
		num[1]=(n%100)/10;
		num[2]=(n%1000)/100;
		num[3]=n/1000;
		
		for(i=0;i<4;i++){
			min=10000;
			minj = i;
			for(j=i;j<4;j++){
				if(min>num[j]){
					min = num[j];
					minj = j;
				}else{
					;
				}
			}
			t = num[i];
			num[i] = num[minj];
			num[minj] = t;
	}
	return num[0]*1000+num[1]*100+num[2]*10+num[3];
}


int main (void){
	
	int n,count;
	
	while(1){
	count=0;
	scanf("%d",&n);
	if(n==0000)break;
	if(n%1111==0){
		printf("NA\n");
	}else{
		
		for(;;){
			if(n == 6174)break;
			n = max_sort(n)-min_sort(n);
			count++;
		}
	
	printf("%d\n",count);
	}
	}
return 0;
}

Measured memory_bytes: 608
#include "bits/stdc++.h"
#define ALL(x) x.begin(), x.end()
#define LEN(x) (int)x.size()
#define iostreamBooster() do{ cin.tie(nullptr); ios_base::sync_with_stdio(false); }while(0)
using namespace std;
typedef int64_t i64;
typedef pair<int,int> pii;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr int INF = 0x3f3f3f3f;

signed main()
{
  i64 N;
  array<i64, 5> a;

  cin >> N;

  i64 minv = LLONG_MAX;
  for (int i = 0; i < 5; ++i) {
    cin >> a[i];
    chmin(minv, a[i]);
  }

  i64 len = (N + minv - 1) / minv;

  // clog << "len = " << len << endl;

  cout << (5 + len - 1) << endl;

  return 0;
}



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

int main(void) {
  int n, k; cin >> n >> k;
  vector<int> a(n);
  for (int i=0; i<n; i++) cin >> a[i];
  vector<int> ans(n, 0);
  
  for (int i=0; i<k; i++) {
    vector<long long> ls(n, 0);
    vector<long long> rs(n, 0);
    
    for (int j=0; j<n; j++) {
      int l = max(j - a[j], 0);
      int r = min(j + a[j], n-1) + 1;
      ls[l]++;
      if (r < n) rs[r]++;
    }
    
    ans[0] = ls[0] - rs[0];
    
    for (int j=1; j<n; j++) {
      ls[j] += ls[j-1];
      rs[j] += rs[j-1];
      ans[j] = ls[j] - rs[j];
    }
      
    for (int j=0; j<n; j++) a[j] = ans[j];
    if (i  > 4 * ceil(log(n))) break;
    
  }
  
  for (int i=0; i<n; i++) cout << ans[i] << " ";

}


Measured memory_bytes: 8244
import java.util.LinkedList;
import java.util.Scanner;
import java.util.Iterator;

class Graph {
	private int totalVertex;
	//adjMatrix[u][v] = 1 if there is an edge from u to v, otherwise 0
	private int[][] adjMatrix;
	//adjWeight[u][v] -- the weight of the edge from u to v if there is one
	private int[][] adjWeight;
	//if a node is settled (e.g., processed in the Dijkstra's algorithm)
	private Boolean[] ifSettled;
	public Graph() { totalVertex = 0; }
	public int getTotalVertex() { return totalVertex; }
	//load graph from standard input
	public void loadAdjMatrix() {
		Scanner in = new Scanner(System.in);
		totalVertex = in.nextInt();
		adjMatrix = new int[totalVertex][totalVertex];
		adjWeight = new int[totalVertex][totalVertex];
		ifSettled = new Boolean[totalVertex];
		int i, j;
		for(i = 0; i < totalVertex; i ++) {
			ifSettled[i] = false;
			for(j = 0; j < totalVertex; j ++) {
				adjMatrix[i][j] = adjWeight[i][j] = 0;
			}
		}
		int u, v;
		for(i = 0; i < totalVertex; i ++) {
			u = in.nextInt();
			int degree = in.nextInt();
			for(j = 0; j < degree; j ++) {
				v = in.nextInt(); 
				adjMatrix[u][v] = 1;
				adjWeight[u][v] = in.nextInt();
			}	
		}
		in.close();
	}
	//return weight of the edge from u to v if there is one
	public int getWeight(int u, int v) {
		return adjWeight[u][v];
	}
	//return neighbors of u as a LinkedList
	public LinkedList<Integer> getNeighbors(int u) {
		LinkedList<Integer> tmp = new LinkedList<Integer>();
		for(int v = 0; v < totalVertex; v ++) {
			if(adjMatrix[u][v] == 1) tmp.add(v);
		}
		return tmp;
	}
	//return unsettled neighbors of u as a LinkedList
	public LinkedList<Integer> getUnsettledNeighbors(int u) {
		LinkedList<Integer> tmp = new LinkedList<Integer>();
		for(int v = 0; v < totalVertex; v ++) {
			if((adjMatrix[u][v] == 1) && (ifSettled[v] == false)) tmp.add(v);
		}
		return tmp;
	}
	//return the unsettled node that has the smallest dist
	public int getUnsettledNearest(int[] dist) {
		int md = Integer.MAX_VALUE;
		int mv = -1;
		int v;
		for(v = 0; v < totalVertex; v ++) {
			if((ifSettled[v] == false) && (dist[v] < md)) {
				md = dist[v];
				mv = v;
			}
		}
		return mv;
	}
	//implement the following	
	public int[] Dijkstra(int s) {
		int[] distance = new int[totalVertex];
		Boolean visited[] = new Boolean[totalVertex];
		for(int i = 1; i < distance.length; i++) {
			distance[i] = Integer.MAX_VALUE;	
		}
		int source = s;
		int v = getUnsettledNearest(distance);
		distance[source] = 0;
		while(v > -1) {
			ifSettled[v] = true;
			LinkedList<Integer> neighbors = getUnsettledNeighbors(v);
			for(Integer n : neighbors) {
					distance[n] = Math.min(distance[n], distance[v] + getWeight(v,n));
			}
			v = getUnsettledNearest(distance);
		}
		return distance;
	}
}

public class Main {
	public static void main(String[] args) {
		Graph g = new Graph();
		g.loadAdjMatrix();
		int[] dist = g.Dijkstra(0);
		for(int i = 0; i < g.getTotalVertex(); i ++) {
			System.out.println(i + " " + dist[i]);
		}
	}
}



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

typedef long long ll;
const int N = 2000006;
const ll MOD = 1e9+7;

int n;
int a[N];
int idx[N];

int main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>a[i];
		idx[a[i]] = i;
	}
	
	ll ans = 0;
	ll x = n - idx[1] + 1;
	ll y = idx[1];
	ans += x*y;
	set<int> st;
	st.insert(idx[1]);
	
	for(int i=2;i<=n;i++){
		if( idx[i] < *st.begin()){
			x = *st.begin() - idx[i];
			y = idx[i];
			ans += x * y * i;
			st.insert(idx[i]);
			//cout<<i<<" "<<x<<" "<<y<<endl;
			continue;
		}
		if(idx[i] > *st.rbegin()){
			x = n - idx[i] + 1;
			y = idx[i] - *st.rbegin();
			ans += x * y * i;
			st.insert(idx[i]);
			//cout<<i<<" "<<x<<" "<<y<<endl;
			continue;
		}
		x = *(st.upper_bound(idx[i])) - idx[i];
		y = idx[i] - *(--st.upper_bound(idx[i]));
		ans += x * y * i;
		//cout<<i<<" "<<x<<" "<<y<<endl;
		st.insert(idx[i]);
	}
	
	cout<<ans;
	
	return 0;
}


Measured memory_bytes: 14552
restrunt_num = int(input())

restrunt_list = []
for i in range(1, restrunt_num+1):
    city, point = input().split()
    restrunt_list.append([city, int(point), i])

sorted_list = sorted(restrunt_list, key=lambda x: (x[0], -x[1]))
for r in sorted_list:
    print(r[2])


Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
    int n,m,sum=0;
    int a[110];
    cin>>n>>m;
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    sort(a, a+n, greater<int>());
    for(int i=0;i<n;i++){
        sum+=a[i];
    }
    if(a[m-1]*4*m<sum)cout<<"No"<<endl;
    else cout<<"Yes"<<endl;
}

Measured memory_bytes: 256
# Grand Garden
N = int(input().strip())
h = list(map(int, input().strip().split()))

def mizu(h, s):
	for k in range(s, len(h)):
		if h[k] > 0:
			h[k] -= 1
		else:
			break
	return h
	
def find_start(h):
	s = min((i for i in range(len(h)) if h[i] > 0), default = -1)
	return s

def is_finish(h):
	return sum(h) == 0

count = 0
while True:
	s = find_start(h)
	if s == -1:
		break
	else:
		h = mizu(h, s)
		count += 1

print(count)

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

unsigned long long a,b,c,d,ans,gcd;

unsigned long long Gcd(llu x,llu y){
	return y?Gcd(y,x%y):x;
}

int main(){
	scanf("%llu%llu%llu%llu",&a,&b,&c,&d);
	ans=b-a+1;
	ans-=(b/c-a/c);
	if(a%c==0)--ans;
	ans-=(b/d-a/d);
	if(a%d==0&&a%c!=0)--ans;
	if((a%d==0||a%d==0)&&a&(c*d)==0)++ans;
	gcd=c*d/Gcd(c,d);
	ans+=(b/gcd-a/gcd);
	cout<<ans<<endl;
	return 0;
}

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

int main()
{
	int a, b, c, d, e, f;
	cin >> a >> b >> c >> d >> e >> f;
	int ans_w = 0, ans_s = 0;
	for(auto i = 0; i * a * 100 <= f; ++i){
		for(auto j = 0; (i * a + j * b) * 100 <= f; ++j){
			int w = (i * a + j * b) * 100;
			for(auto k = 0; k * c <= f - w; ++k){
				for(auto l = 0; k * c + l * d <= f - w; ++l){
					int s = k * c + l * d;
					if(s > e * (w / 100)) break;
					if(ans_w + ans_s == 0 || ans_s * (w + s) < s * (ans_w + ans_s)){
						ans_w = w;
						ans_s = s;
					}
				}
			}
		}
	}
	cout << ans_w + ans_s << " " << ans_s << endl;
	return 0;
}

Measured memory_bytes: 256
N = int(input())
S = input()

S1 = []
S2 = []

for i in range(int(N/2)):
    S1.append(S[i])
    S2.append(S[i+int(N/2)])
    
if S1 == S2:
    if N%2 == 1:
        print('No')
    else:
        print('Yes')
else:
    print('No')

Measured memory_bytes: 3060
import java.util.*;

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


class Pair implements Comparable<Pair> {
    int order;
    int index;

    public Pair(int order, int index) {
        this.order = order;
        this.index = index;
    }

    @Override
    public int compareTo(Pair other) {
        return this.order - other.order;
    }
}

class Solver {

    public void run() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        ArrayList<Pair> d = new ArrayList<Pair>();

        for (int i = 0; i < N; i++) {
            d.add(new Pair(sc.nextInt(), i));
        }
        Collections.sort(d);

        StringBuilder sb = new StringBuilder();
        for (Pair p : d) {
            sb.append(p.index + 1);
            sb.append(" ");
        }
        System.out.println(sb.toString().trim());

        return;
    }

}

Measured memory_bytes: 53020
use std::cmp;

fn main() {
    let mut sc = Scanner::new();
    let n: usize = sc.read();
    let a: usize = sc.read();
    let b: usize = sc.read();
    let x: Vec<usize> = (0..n).map(|_| sc.read()).collect();

    let mut ans = 0;
    for i in 1..n {
        let distance = x[i] - x[i - 1];
        ans += cmp::min(a * distance, b);
    }
    println!("{}", ans);
}

struct Scanner {
    ptr: usize,
    length: usize,
    buf: Vec<u8>,
    small_cache: Vec<u8>,
}

impl Scanner {
    fn new() -> Scanner {
        Scanner {
            ptr: 0,
            length: 0,
            buf: vec![0; 1024],
            small_cache: vec![0; 1024],
        }
    }

    fn load(&mut self) {
        use std::io::Read;
        let mut s = std::io::stdin();
        self.length = s.read(&mut self.buf).unwrap();
    }

    fn byte(&mut self) -> u8 {
        if self.ptr >= self.length {
            self.ptr = 0;
            self.load();
            if self.length == 0 {
                self.buf[0] = b'\n';
                self.length = 1;
            }
        }

        self.ptr += 1;
        return self.buf[self.ptr - 1];
    }

    fn is_space(b: u8) -> bool {
        b == b'\n' || b == b'\r' || b == b'\t' || b == b' '
    }

    fn read<T>(&mut self) -> T
    where
        T: std::str::FromStr,
        T::Err: std::fmt::Debug,
    {
        let mut b = self.byte();
        while Scanner::is_space(b) {
            b = self.byte();
        }

        for pos in 0..self.small_cache.len() {
            self.small_cache[pos] = b;
            b = self.byte();
            if Scanner::is_space(b) {
                return String::from_utf8_lossy(&self.small_cache[0..(pos + 1)])
                    .parse()
                    .unwrap();
            }
        }

        let mut v = self.small_cache.clone();
        while !Scanner::is_space(b) {
            v.push(b);
            b = self.byte();
        }
        return String::from_utf8_lossy(&v).parse().unwrap();
    }
}


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

int main() {
	long s;
	cin >> s;
	long m = 1e9;
	long a = (s + m - 1) / m;
	long d = (s + a - 1) / a;
	long b = a * d - s;
	cout << "0 0 " << a << ' ' << b << " 1 " << d << endl;
	return 0;
}


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

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

	public void solve() throws IOException {
		FastScanner fs = new FastScanner();
		int n = fs.nextInt();
		String s = fs.next();
		String t = fs.next();
		
		System.out.println(getStart(s,t) + t.length());
	}
	
	
	public int getStart(String s, String t) {
		int startPos = 0;
		int tAt = 0;
		for(int i = 0; i < s.length(); i++) {
			if(s.charAt(i) == t.charAt(tAt)) {
				tAt++;
			}else {
				if(s.charAt(i) == t.charAt(0)) {
					tAt = 1;
					startPos = i;
				}else {
					tAt = 0;
					startPos = i+1;
				}
			}
		}
		
		return startPos;
	}

	

	public class FastScanner {

		BufferedReader reader;
		private StringTokenizer st;

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

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

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

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

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

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

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

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


}


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

#define d(x) cerr << #x ":" << x << endl;
#define dd(x, y) cerr << "(" #x "," #y "):(" << x << "," << y << ")" << endl
#define rep(i, n) for (int i = (int)(0); i < (int)(n); i++)
#define repp(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define all(v) v.begin(), v.end()
#define dump(v)                  \
    cerr << #v ":[ ";            \
    for (auto macro_vi : v) {    \
        cerr << macro_vi << " "; \
    }                            \
    cerr << "]" << endl;
#define ddump(v)                           \
    cerr << #v ":" << endl;                \
    for (auto macro_row : v) {             \
        cerr << "[";                       \
        for (auto macro__vi : macro_row) { \
            cerr << macro__vi << " ";      \
        }                                  \
        cerr << "]" << endl;               \
    }
using lint       = long long;
const int INF    = 1e9;
const lint LINF  = 1e18;
const lint MOD   = 1e9 + 7;
const double EPS = 1e-10;

int main() {
    string S, T;
    cin >> S >> T;
    if (T.substr(0, S.size()) == S) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 3632
import sys
input = sys.stdin.readline
rs = lambda: input().strip()
ri = lambda: int(input())
rl = lambda: list(map(int, input().split()))
mod = 10**9 + 7

N = ri()
K = ri()

nums = list(map(int, list(str(N))))
L = len(nums)
dp = [ [[0]*2 for _ in range(K+2)] for _ in range(L+1)]

dp[0][0][0] = 1

for i in range(L):
	for j in range(K+1):
		for k in range(2):
			for d in range(10):
				ni, nj, nk = i+1, j, k
				if d > 0:
					nj += 1
				if nj > K: continue
				if k == 0:
					if d < nums[i]:
						nk = 1
					elif d > nums[i]:
						continue
				dp[ni][nj][nk] += dp[i][j][k]
print(sum(dp[L][K]))


Measured memory_bytes: 40944
def hoge(X,K,D):
  abs_X=abs(X)
  if K*D<abs_X:
    return abs_X-K*D
  K-=X//D
  X=X%D
  if K%2==0:
    return X
  else:
    return abs(X-D)

X,K,D=list(map(int,input().split()))
print(hoge(X,K,D))
  

Measured memory_bytes: 9184
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rep2(i,s,n) for (int i = s; i < n; ++i)
#define all(a) a.begin(),a.end()
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
    int d,n;
    cin >> d >> n;
    if(n == 100) n++;
    if(d == 0) cout << n << endl;
    else if(d == 1) cout << n*100 << endl;
    else cout << n*10000 << endl;
}

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



int main()
{
        string s;
        cin >> s;
        string ans;
        rep(i, 0, len(s)) {
                char c = s[i];
                if (c == '0') {
                        ans += '0';
                } else if (c == '1') {
                        ans += '1';
                } else {
                        if (len(ans) > 0) {
                                ans = ans.substr(0, len(ans) - 1);
                        }
                }
        }
        cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<functional>
#include<utility>
#include<cmath>
#include<iomanip>
#include<algorithm>
#include<string>
#include<vector>
using namespace std;
string s;

int main() {
	cin >> s;
	for (int i = 0; i < s.size(); i++)
	{
		if(s[i]=='A')cout<<"T";
		if (s[i] == 'G')cout << "C";
		if (s[i] == 'C')cout << "G";
		if (s[i] == 'T')cout << "A";
	}
	cout << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define maxn 405
#define ll long long
#define p 1000000007
ll sum[maxn][maxn],f[maxn][maxn];
int n,m,a[maxn],b[maxn];
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;++i)
		scanf("%d",&a[i]);
	for(int i=1;i<=n;++i)
		scanf("%d",&b[i]);
	for(int i=1;i<=400;++i)
	{
		sum[i][0]=1;
		for(int j=1;j<=400;++j)
			sum[i][j]=1ll*sum[i][j-1]*i%p;
	}
	for(int i=1;i<=400;++i)
		for(int j=0;j<=400;++j)
			sum[i][j]+=sum[i-1][j],sum[i][j]%=p;
	f[0][0]=1;
	for(int i=1;i<=n;++i)
		for(int j=0;j<=m;++j)
			for(int k=0;k<=j;++k)
			{
				f[i][j]+=0ll+1ll*f[i-1][j-k]*(sum[b[i]][k]-sum[a[i]-1][k])%p;
				f[i][j]%=p;
			}
	printf("%lld\n",(f[n][m]%p+p)%p);
	return 0;
}

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

using namespace std;

typedef long long int ll;
typedef long double ld;

void solve()
{
//	ld a, b;
//	cin >> a >> b;
//	cout << (ll)(a * b) << "\n";
//	return;
	ll n;
	cin >> n;
	__int128_t sum = 1;
	ll arr[n];
	ll x = 1e18;
	for(int i = 0; i < n; i++)
	{
		cin >> arr[i];
	}
	sort(arr,arr+n);
	for(int i = 0; i < n; i++) 
	{
		sum = sum * arr[i];
		if(sum > x)
		{
			cout << -1;
			return;
		}
	}
	cout << (ll)sum;
}

int main()
{
	int t = 1;
//	cin >> t;
	while(t--)
	{
		solve();
	}
	return 0;
}



Measured memory_bytes: 4336
s = input()

def isk(s):
    n = len(s)
    for i in range(n):
        if s[i] != s[n - 1 - i]:
            return False
    return True
n = len(s)
if isk(s) and isk(s[:(n - 1) // 2]) and isk(s[(n + 3) // 2 - 1:]):
    print('Yes')
else:
    print("No")

Measured memory_bytes: 38256
//config = {stdin: 'tmp', newline: '\r\n'}; // win
config = {stdin: '/dev/stdin', newline: '\n'}; // linux

line = require('fs').readFileSync(config.stdin, 'ascii')
       .split(config.newline, 3)
       .map(function(line) {
         return line.split(' ').map(Number);
       });

dist = (function (x, y) {
  var res = [];
  for (var i in x) res.push(Math.abs(x[i] - y[i]));
  return res;
}) (line[1], line[2]);

console.log(
  dist.reduce(function (prev, cur) { return prev + cur; }, 0));
console.log(
  Math.sqrt(
    dist.reduce(function (prev, cur) { return prev + cur * cur; }, 0)));
console.log(
  Math.pow(
    dist.reduce(function (prev, cur) { return prev + cur * cur * cur; }, 0),
    1/3));
console.log(
  dist.reduce(function (prev, cur) { return Math.max(prev, cur); }, 0));

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

static const long MAX = 1000;
static const long VMAX = 10000;

long n, A[MAX], s;
long B[MAX], T[VMAX + 1];

long solve(){
	long ans = 0;
	bool V[MAX];
	for (long i = 0; i < n; i++){
		B[i] = A[i];
		V[i] = false;
	}
	sort(B, B + n);
	for (long i = 0; i < n; i++) T[B[i]] = i;
	for (long i = 0; i < n; i++){
		if (V[i]) continue;
		long cur = i, S = 0, m = VMAX, an = 0;
		while (1){
			V[cur] = true;
			an++;
			long v = A[cur];
			m = min(m, v);
			S += v;
			cur = T[v];
			if (V[cur]) break;
		}
		ans += min(S + (an - 2) * m, m + S + (an + 1) * s);
	}
	return ans;
}

int main(){
	cin >> n;
	s = VMAX;
	for (long i = 0; i < n; i++){
		cin >> A[i];
		s = min(s, A[i]);
	}
	long ans = solve();
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1220
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <bitset>
#include <utility>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<pair<int,int>> vpii;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
#define rep(i,n) for(int i=0;i<n;i++)
#define fin(ans) cout<<(ans)<<endl
#define P 1000000007
#define STI(s) atoi(s.c_str())//string to int
#define mp(p,q) make_pair(p,q)
#define Sort(a) sort(a.begin(),a.end())
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;}
const int INF = INT_MAX;
const long long LLINF = 1LL<<60;
//g++ -std=c++1z temp.cpp
//./a.exe
int digit(int a){
    int count = 0;
    for (int i = 0; i < a; i++)
    {   if (a == 0)
        {
            break;
        }else
        {
            a = a/10;
            count++;
        }     
    }
    return count;
}
//pow(x,n) == x^n

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

long long int n;
cin >> n;
vector <long long int> l(n+1);
l[0] = 2; l[1] = 1;
for (int i = 2; i < n+1; i++)
{
    l[i] = l[i-1] + l[i-2];
}

cout << l[n] << endl;





//////////////////////////////////////////////////////
return 0;}

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

int main()
{
    int a,b;
    cin >> a >> b;
    cout << max(a+b,max(a-b,a*b)) << endl;
    return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**7)
n = int(input())
def nana(cur, x):
  if cur == 9:
    if int(x) <= n and set(x) >= {"3", "5", "7"}:
      return 1
    return 0
  return (nana(cur+1, x+"0") if not x or x[-1]=="0" else 0) + nana(cur+1, x+"3") + nana(cur+1, x+"5") + nana(cur+1, x+"7")
print(nana(0, ""))

Measured memory_bytes: 3064
import Foundation

let N = readLine()!

if N.last == "2" ||  N.last == "4" || N.last == "5" ||  N.last == "7" ||  N.last == "9" {
    print("hon")
} else if  N.last == "0" ||  N.last == "1" || N.last == "6" ||  N.last == "8" {
    print("pon")
} else {
    print("bon")
}

Measured memory_bytes: 13144
#include <bits/stdc++.h>
using namespace std;
int INF = 1000000000;
int ford_fulkerson(vector<unordered_map<int, int>> &E, int s, int t){
	int N = E.size();
	int F = 0;
	while (1){
		vector<int> d(N, INF);
		vector<int> m(N, INF);
		vector<int> prev(N, -1);
		d[s] = 0;
		queue<int> Q;
		Q.push(s);
		while (!Q.empty()){
			int v = Q.front();
			Q.pop();
			for (auto P : E[v]){
				int w = P.first;
				if (d[w] == INF){
					prev[w] = v;
					d[w] = d[v] + 1;
					m[w] = min(m[v], P.second);
					Q.push(w);
				}
			}
		}
		if (d[t] == INF){
			break;
		}
		int f = m[N - 1];
		int c = N - 1;
		while (c != 0){
			if (E[prev[c]][c] == f){
				E[prev[c]].erase(c);
			} else {
				E[prev[c]][c] -= f;
			}
			E[c][prev[c]] += f;
			c = prev[c];
		}
		F += f;
	}
	return F;
}
int main(){
  int N, M;
  cin >> N >> M;
  vector<unordered_map<int, int>> E(N);
  for (int i = 0; i < M; i++){
    int u, v, c;
    cin >> u >> v >> c;
    E[u][v] = c;
  }
  cout << ford_fulkerson(E, 0, N - 1) << endl;
}


Measured memory_bytes: 3176
#include <iostream>
#include <algorithm>
#define rep(i, a, n) for(int i = a;i < n;i++)
using namespace std;


int main(){
	int a, b;

	cin >> a >> b;

	if((a*b)%2 == 0) cout << "Even" << endl;
	else cout << "Odd" << endl;

	return 0;
}

Measured memory_bytes: 256
S = list(input())
K = int(input())

ref = 0
for i in range(len(S)):
    if S[i] == "1":
        ref += 1
    else:
        break

ans = ""
if ref == 0:
    ans = S[0]
else:
    if ref >= K:
        ans = "1"
    else:
        ans = S[ref]

print(ans)

Measured memory_bytes: 9172
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(int i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(int i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(int i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define uniq(x) (x).erase(unique((x).begin(), (x).end()), (x).end())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // std::ifstream in("input.txt");
    // std::cin.rdbuf(in.rdbuf());
    ll n, k;
    cin >> n >> k;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    vector<ll> f(n);
    rep(i, n) cin >> f[i];
    sort(all(a));
    sort(all(f));
    reverse(all(f));
    ll l = -1 * 1e18, r = 1e18;
    while((l + 1) < r) {
        ll m = (l + r) / 2;
        ll sum = 0;
        rep(i, n) sum += max(0LL, a[i] - m / f[i]);
        if (sum <= k) r = m;
        else l = m;
    }
    cout << max(0LL, r) << endl;
    return 0;
}


Measured memory_bytes: 3456
#include<cstdio>
#include<queue>
#include<vector>
#include<algorithm>
using namespace std;
typedef pair<int, int> P;
static const int MAX_W = 20;
static const int MAX_H = 20;
static const int MAX_V = 10;
static const int INF = 1 << 30;

int w, h;
char field[MAX_H][MAX_W + 1];
int dist[MAX_V + 1][MAX_V + 1], dist2[MAX_H][MAX_W];
int dy[] = {0, -1, 0, 1};
int dx[] = {1, 0, -1, 0};

void bfs(int s, vector<P> va){
	dist[s][s] = 0;
	fill(dist2[0], dist2[h], INF);
	queue<P> qa;
	qa.push(va[s]);
	dist2[va[s].first][va[s].second] = 0;
	while(!qa.empty()){
		P cc = qa.front(); qa.pop();
		int cy = cc.first, cx = cc.second;
		for(int i = 0; i < 4; i++){
			int ny = cy + dy[i], nx = cx + dx[i];
			if(ny < 0 || ny >= h || nx < 0 || nx >= w) continue;
			if(field[ny][nx] == 'x') continue;
			if(dist2[ny][nx] != INF) continue;
			qa.push(P(ny, nx));
			dist2[ny][nx] = dist2[cy][cx] + 1;
			if(field[ny][nx] == 'o' || field[ny][nx] == '*'){
				for(int j = 0; j < va.size(); j++){
					if(ny == va[j].first && nx == va[j].second){
						dist[s][j] = dist2[ny][nx];
						break;
					}
				}
			}
		}
	}
	return ;
}

int main(){
	for(;;){
		scanf("%d %d", &w, &h);
		if(w == 0 && h == 0) break;
		vector<P> va;
		va.push_back(P(0, 0));
		int cnt = 1;
		for(int i = 0; i < h; i++){
			scanf("%s", field[i]);
			for(int j = 0; j < w; j++){
				if(field[i][j] == 'o') va[0] = P(i, j);
				if(field[i][j] == '*'){
					va.push_back(P(i, j));
					cnt++;
				}
			}
		}
		fill(dist[0], dist[cnt], INF);
		for(int i = 0; i < cnt; i++) bfs(i, va);
		bool flag = true;
		for(int i = 0; i < cnt; i++){
			for(int j = 0; j < cnt; j++){
				if(dist[i][j] == INF) flag = false;
			}
		}
		vector<int> vb(cnt - 1);
		for(int i = 0; i < cnt - 1; i++) vb[i] = i + 1;
		int res = INF;
		do{
			int sum = 0;
			for(int i = 0; i < vb.size(); i++){
				if(i == 0) sum += dist[0][vb[i]];
				else sum += dist[vb[i - 1]][vb[i]];
			}
			res = min(res, sum);
		}while(next_permutation(vb.begin(), vb.end()));
		printf("%d\n", (flag ? res : -1));
	}
	return 0;
}


Measured memory_bytes: 2828
#include <iostream>
#include <vector>
#include <iterator>
#include <cmath>
#include <algorithm>

int N, A, B, C;
std::vector<int> l;

int dfs(int n, int a, int b, int c){
  if(n == N){
    if(std::min( {a, b, c} ) > 0){
      return std::fabs(a - A) + std::fabs(b - B) + std::fabs(c - C) - 30;
    }else{
      return 100000;
    }
  }

  int mp1 = dfs(n + 1, a, b, c);
  int mp2 = dfs(n + 1, a + l[n], b, c) + 10;
  int mp3 = dfs(n + 1, a, b + l[n] ,c) + 10;
  int mp4 = dfs(n + 1, a, b, c + l[n]) + 10;
  return std::min( {mp1, mp2, mp3, mp4} );
}

int main(){
  std::cin >> N >> A >> B >> C;
  std::copy_n(std::istream_iterator<int>(std::cin), N, std::back_inserter(l));
  std::cout << dfs(0, 0, 0, 0) << std::endl;
  return 0;
}


Measured memory_bytes: 256
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Scanner;

public class Main {
	
	long gcd(long a,long b) {
		return a==0?b:gcd(b%a,a);
	}

	void run() {
		Scanner sc=new Scanner(System.in);
		PrintWriter pw=new PrintWriter(System.out);
		long ans=0;
		int N=sc.nextInt();
		char[] cs=sc.next().toCharArray();
		int[][] cnt=new int[N][3];
		for (int i=0;i<N;++i) {
			if (cs[i]=='R') ++cnt[i][0];
			else if(cs[i]=='G') ++cnt[i][1];
			else ++cnt[i][2];
			if (i>0) cnt[i][0]+=cnt[i-1][0];
			if (i>0) cnt[i][1]+=cnt[i-1][1];
			if (i>0) cnt[i][2]+=cnt[i-1][2];
		}
		for (int i=0;i<N;++i) {
			if (cs[i]!='R') continue;
			for (int j=0;j<N;++j) {
				if (cs[j]!='G') continue;
				ans+=cnt[N-1][2];
			}
		}
		for (int i=0;i<N;++i) {
			for (int len=1;len<=N;++len) {
				if (i+len>=N||i+2*len>=N) continue;
				if (cs[i]==cs[i+len]) continue;
				if (cs[i+len]==cs[i+2*len]) continue;
				if (cs[i]==cs[i+2*len]) continue;
				--ans;
			}
		}
		pw.println(ans);
		pw.close();
	} 
	
	void tr(Object...objects) {System.out.println(Arrays.deepToString(objects));}
	
    public static void main(String[] args) {
    	new Main().run();
    }
}


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

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

        int n = cin.nextInt();
        int k = cin.nextInt();
        int q = cin.nextInt();

        int[] a = new int[n];
        for(int i=0;i<q;i++) {
            a[cin.nextInt()-1]++;
        }
        for(int i=0;i<n;i++) {
            if(k - q + a[i] > 0) cout.println("Yes");
            else cout.println("No");
        }

        cout.close();
    }
}


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

bool g[1000][1000];

vector<int> extract_cycle(vector<int>& path) {
	if (path.size() <= 1) {
		return vector<int>();
	}

	int v = path[path.size() - 1];
	for (int i = path.size() - 2; i >= 0; --i) {
		if (g[v][path[i]]) {
			vector<int> cycle(path.size() - i);
			copy(path.begin() + i, path.end(), cycle.begin());

			return cycle;
		}
	}

	return vector<int>();
}

vector<int> find_cycle(int n, int start, vector<int>& path) {
	path.push_back(start);

	vector<int> cycle = extract_cycle(path);
	if (!cycle.empty()) {
		return cycle;
	}
	
	for (int dest = 0; dest < n; ++dest) {
		if (g[start][dest]) {
			vector<int> cycle = find_cycle(n, dest, path);
			if (!cycle.empty()) {
				return cycle;
			}
		}
	}

	path.pop_back();

	return vector<int>();
}

int main() {
	memset(g, false, sizeof(g));

	int n, m;
	cin >> n >> m;

	for (int i = 0; i < m; ++i) {
		int a, b;
		cin >> a >> b;
		g[a - 1][b - 1] = true;
	}

	vector<int> res;

	for (int i = 0; i < n; ++i) {
		vector<int> p;
		vector<int> cycle = find_cycle(n, i, p);

		if (!cycle.empty()) {
			res = cycle;
		}
	}

	if (res.empty()) {
		cout << -1;
		return 0;
	}

	cout << res.size() << endl;
	for (int c : res) {
		cout << c + 1 << endl;
	}
	
	return 0;
}


Measured memory_bytes: 1408
import sys
input = sys.stdin.readline


def max2(x, y):
    """ pythonの組み込み関数 max は2変数に対しては遅い！！ """
    if x > y:
        return x
    else:
        return y


def knapsack_weight(single=True):
    """
    重さが小さい時のナップサックDP
    :param single: True = 重複なし
    """
    N, W = map(int, input().split())  # N: 品物の種類 W: 重量制限

    """ dp[weight <= W] = 重さ上限を固定した時の最大価値 """
    dp_min = 0  # 総和価値の最小値
    dp = [dp_min] * (W + 1)

    for _ in range(N):
        w, price = map(int, input().split())
        if single:
            S = reversed(range(w, W + 1))
        else:
            S = range(w, W + 1)
        for weight in S:
            dp[weight] = max2(dp[weight], dp[weight - w] + price)
    return dp[W]

#######################################################################################################


print(knapsack_weight(single=True))


Measured memory_bytes: 74080
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0; i<n; i++)
typedef long long ll;
typedef long long unsigned int llu;
ll MOD = 1000000007;
ll INF = 1000000009;

/*
偶数
123456
5,3,1,1,3,5

奇数
1234567
6,4,2,0,2,4,6

偶数ならpow(2,n/2)
奇数ならpow(2,(n-1)/2)
*/

void solve(){
    int n;
    cin >> n;
    int a[n+10];
    rep(i,n){
        cin >> a[i];
    }
    sort(a,a+n);
    bool b=true;
    if(n%2==0){
        for(int i=0; i<n; i=i+2){
            if(a[i]!=i+1) b = false;
            if(a[i+1]!=i+1) b = false;
        }
    }
    else if(n%2==1){
        for(int i=0; i<n-1; i=i+2){
            if(a[i]!=i) b = false;
            if(a[i+1]!=i+2) b = false;
        }
        if(a[n-1]!=n-1) b = false;
    }
    ll ans;
    if(b){
        ans = 1;
        ll tmp = (n-(n%2))/2;
        while(tmp!=0){
            ans = (ans * 2) % MOD;
            tmp = tmp-1;
        }
    }
    else {
        ans = 0;
    }
    cout << ans << endl;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  solve();
  return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<math.h>
#include<vector>
#include<algorithm>
#include<string.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
int main(){
	int a,p;
	cin>>a>>p;
	int apple;
	apple=a*3+p;
	cout<<apple/2<<endl;
	return 0;
}

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

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

    int evenans, oddans;
    if (N >= 2){
        evenans = N * (N - 1) / 2;
    }else{
        evenans = 0;
    }

    if (M >= 2){
        oddans = M * (M - 1) / 2;
    }else{
        oddans = 0;
    }

    cout << evenans + oddans << endl;
    return 0;
}

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

int main()
{
    int n, a, b, c, d;
    cin >> n >> a >> b >> c >> d;

    --n;

    // plus를 a번 하면 minus는 n - a번

    for (int p = 0; p <= n; p++)
    {
        long long maxima = a + 1ll * p * d - 1ll * (n - p) * c;
        long long minima = a + 1ll * p * c - 1ll * (n - p) * d;

        if (maxima >= b && b >= minima)
        {
            printf("YES\n");
            return 0;
        }
    }
    printf("NO\n");
}


Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <iostream>
#include <random>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include <fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;

using ll = long long;
using vll = vector<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using vb = vector<bool>;
using mll = map<ll, ll>;
using sll = stack<ll>;
#define REP(i,n) for(ll i(0);(i)<(n);(i)++)
#define rep(i,n) for(ll i(0);(i)<(n);(i)++)
#define ALL(a) a.begin(), a.end()
#define enld endl //* missspell check
const ll INF = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }

ll getMin(ll h, ll m){return h*60+m;}

void solve(std::vector<long long> H, std::vector<long long> M, long long K){
    ll T0 = getMin(H[0], M[0]);
    ll T1 = getMin(H[1], M[1]);
    cout<<(T1-T0)-K<<endl;
}
int main(){
    std::vector<long long> H(2);
    std::vector<long long> M(2);
    for(int i = 0 ; i < 2 ; i++){
        scanf("%lld",&H[i]);
        scanf("%lld",&M[i]);
    }
    long long K;
    scanf("%lld",&K);
    solve(std::move(H), std::move(M), K);
    return 0;
}


Measured memory_bytes: 3240
#include<cstdio>
using namespace std;

int prime[10000];
int primeN = 0;

int main() {
	for (int i = 2; i < 100000; i++) {
		bool flag = true;
		for (int j = 0; j < primeN; j++) {
			if (i % prime[j] == 0) {
				flag = false;
				break;
			}
		}
		if (flag) prime[primeN++] = i;
	}
	int a, d, n;
	while (1) {
		scanf("%d%d%d", &a, &d, &n);
		if (a == 0) break;
		for (int i = a;; i += d) {
			if (i <= 1) continue;
			bool flag = true;
			for (int j = 0; prime[j] * prime[j] <= i; j++) {
				if (i % prime[j] == 0) {
					flag = false;
					break;
				}
			}
			if (flag) n--;
			if (n == 0) {
				printf("%d\n", i);
				break;
			}
		}
	}
}


Measured memory_bytes: 2624
#include<bits/stdc++.h>
using namespace std;
#define gc getchar_unlocked
#define fo(i,n) for(i=0;i<n;i++)
#define Fo(i,k,n) for(i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ll long long
#define si(x)	scanf("%d",&x)
#define sl(x)	scanf("%lld",&x)
#define ss(s)	scanf("%s",s)
#define pi(x)	printf("%d\n",x)
#define pl(x)	printf("%lld\n",x)
#define ps(s)	printf("%s\n",s)
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
typedef pair<int, int>	pii;
typedef pair<ll, ll>	pl;
typedef vector<int>		vi;
typedef vector<ll>		vl;
typedef vector<pii>		vpii;
typedef vector<pl>		vpl;
typedef vector<vi>		vvi;
typedef vector<vl>		vvl;
int mpow(int base, int exp); 
void ipgraph(int m);
void dfs(int u, int par);
const int mod = 1000000007;
const int N = 3e5, M = N;
//=======================

vi g[N];
int a[N];

void solve(){
	int i, j, k, p, q, r, x, y, u, v, n, m;
    cin>>x;
    if(x==0){
        cout<<1<<endl;
    }
    else if(x==1){
        cout<<0<<endl;
    }


}

int main() {
	ios_base::sync_with_stdio(0);
	int i,t=1;
	//cin>>t;
	for(i=1;i<=t;i++){
		solve();
	}
	return 0;
}

int mpow(int base, int exp) {
	base %= mod;
	int result = 1;
	while (exp > 0) {
		if (exp & 1) result = ((ll)result * base) % mod;
		base = ((ll)base * base) % mod;
		exp >>= 1;
	}
	return result;
}

void ipgraph(int n, int m){
	int i, u, v;
	while(m--){
		cin>>u>>v;
		g[u-1].pb(v-1);
		g[v-1].pb(u-1);
	}
}

void dfs(int u, int par){
	for(int v:g[u]){
		if (v == par) continue;
		dfs(v, u);
	}
}




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

int n, dp[101000], h[101000];

int main()
{
    cin>>n;
    for(int i=1; i<=n; i++)
    {
        cin>>h[i];
    }
    dp[1]=0;
    dp[2]=abs(h[1]-h[2]);
    for(int i=3; i<=n; i++)
    {
        dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]), dp[i-2]+abs(h[i]-h[i-2]));
    }
    cout<<dp[n];
}


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

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;

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

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

int main(){
    ll n, x; cin>>n>>x;
    ll a=x, b=n-x;
    if(a<b) swap(a, b);
    ll ans=n;
    while(b){
        ll k=a/b;
        ans+=2*k*b;
        ll c=a%b;
        a=b, b=c;
    }
    ans-=a;
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;


public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int L = sc.nextInt();
        int R = sc.nextInt();
        int d = sc.nextInt();

        int cnt = 0;

        for (int i = L; i <= R; i++) {
            if (i % d == 0) {
                cnt++;
            }
        }


        System.out.println(cnt);
    }

}


Measured memory_bytes: 35656
#include <iostream>
#include <string>

using namespace std;

int main(int argc, char** argv){
    string S;
    cin >> S;
    int k = S.length();
    int win = 0;
    for (int i=0; i<k; i++) if (S[i] == 'o') win++;
    if ((15-k) + win >= 8) cout << "YES\n";
    else cout << "NO\n";

    return 0;
}


Measured memory_bytes: 256