akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

template <typename InputIterator>
typename InputIterator::value_type summation(InputIterator first,
                                             InputIterator last) {
  return std::accumulate(first, last, typename InputIterator::value_type());
}
template <typename T>
std::istream &operator>>(std::istream &stream, std::vector<T> &v);
template <typename T1, typename T2>
std::istream &operator>>(std::istream &stream, std::pair<T1, T2> &p);
template <typename T>
std::istream &operator>>(std::istream &stream, std::vector<T> &v) {
  for (auto &i : v) {
    stream >> i;
  }
  return stream;
}
template <typename T1, typename T2>
std::istream &operator>>(std::istream &stream, std::pair<T1, T2> &p) {
  stream >> p.first >> p.second;
  return stream;
}
template <typename T>
T modinv(T a, const T m) {
  T b = m, u = 1, v = 0;
  while (b != 0) {
    const auto t = a / b;
    a -= t * b;
    std::swap(a, b);
    u -= t * v;
    std::swap(u, v);
  }
  u %= m;
  if (u < 0) {
    u += m;
  }
  return u;
}
int main() {
  int64_t n;
  std::cin >> n;
  std::vector<int64_t> x(n);
  std::cin >> x;
  constexpr int64_t mod = 1000000007;

  int64_t prod = 1;

  for (int64_t i = 1; i < n; i++) {
    prod *= i;
    prod %= mod;
  }
  std::vector<int64_t> p(n);

  p[1] = prod;
  for (int64_t i = 2; i < n; i++) {
    p[i] = (prod * modinv(i, mod)) % mod;
  }

  int64_t ans = 0;
  int64_t sum = 0;

  for (int64_t i = 1; i < n; i++) {
    const auto d = (x[i] - x[i - 1]) % mod;
    sum += p[i];
    sum %= mod;

    ans += (sum * d) % mod;
    ans %= mod;
  }

  std::cout << ans << std::endl;

  return 0;
}


Measured memory_bytes: 1792
package main

import (
	"fmt"
	"bufio"
	"os"
	"reflect"
	"strconv"
	"strings"
)

func reverse(s string) string {
    r := []rune(s)
    for i, j := 0, len(r)-1; i < len(r)/2; i, j = i+1, j-1 {
        r[i], r[j] = r[j], r[i]
    }
    return string(r)
}

func mapf(f interface{}, list interface{}) interface{} {
	fv, listv := reflect.ValueOf(f), reflect.ValueOf(list)

	if fv.Kind() != reflect.Func || listv.Kind() != reflect.Slice {
		return nil
	}

	len := listv.Len()
	ret := reflect.MakeSlice(reflect.SliceOf(fv.Type().Out(0)), len, listv.Cap())

	for i := 0; i < len; i++ {
		v := fv.Call([]reflect.Value{listv.Index(i)})
		ret.Index(i).Set(v[0])
	}

	return ret.Interface()
}

func main() {
	var s string
	var q int

	fmt.Scan(&s)
	fmt.Scan(&q)

	scanner := bufio.NewScanner(os.Stdin)
	for i := 0; i < q; i++ {
		scanner.Scan()
		ops := strings.Fields(scanner.Text())
		op := ops[0]
		x := mapf(strconv.Atoi, ops[1:3]).([]int)
		p := strings.Join(ops[3:], "")

		switch op {
		case "print":
			fmt.Println(s[x[0]:x[1]+1])
		case "reverse":
			s = s[:x[0]] + reverse(s[x[0]:x[1]+1]) + s[x[1]+1:]
		case "replace":
			s = s[:x[0]] + p + s[x[1]+1:]
		}
	}
}



Measured memory_bytes: 1596
import java.util.*;
public class Main {
	Scanner sc = new Scanner(System.in);
	int a,b,c,d,e,f,k,l,m,n,x,y,z;
	int ans;
	String[] S;

	Main(){
		// 整数の入力
		n = sc.nextInt();
		a = sc.nextInt();
		b = sc.nextInt();

		// 出力
		System.out.println(Math.min(a*n,b));
	}

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

Measured memory_bytes: 21844
mod=1000003
fact=[1]
for i in range(1,2*mod):
  fact.append((fact[-1]*i)%mod)
q=int(input())
for _ in range(q):
  x,d,n=map(int,input().split())
  if d==0:
    print(pow(x,n,mod))
    continue
  if n>=mod or x==0:
    print(0)
    continue
  x*=pow(d,mod-2,mod)
  x%=mod
  ans=fact[x+n-1]*pow(fact[x-1],mod-2,mod)*pow(d,n,mod)
  ans%=mod
  print(ans)

Measured memory_bytes: 204428
# nの素数判定
def is_prime(n):
    if n == 1:
        return False
    for i in range(2, int(n**0.5)+1):
        if n % i == 0:
            return False
    return True

# nの約数列挙


def divisor(n):
    ass = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            ass.append(i)
            ass.append(n//i)
    return ass  # sortされていない

# nの素因数分解(O(n**0.5)


def prime_factor(n):
    ass = []
    for i in range(2, int(n**0.5)+1):
        while n % i == 0:
            ass.append(i)
            n = n//i
    if n != 1:
        ass.append(n)
    return ass


if __name__ == '__main__':
    ta, tb = map(int, input().split())

    # めんどくさいのでa<=bの場合で考える
    if ta > tb:
        a = tb
        b = ta
    else:
        a = ta
        b = tb

    a_div_set = set(divisor(a))
    b_div_set = set(divisor(b))
    common_div_set = (a_div_set & b_div_set)

    answer = 0
    for e in common_div_set:
        if e == 1 or is_prime(e):
            answer += 1
    print(answer)


Measured memory_bytes: 5068
#include <iostream>
#include <iomanip>
#include <cmath>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
    int a,b;
    vector<pair<int,int>> c;

    pair<int,int> buf;
    while(cin >> a >> b){
        if(a == 0 && b == 0){
            break;
        }

        buf.first = a;
        buf.second = b;

        c.push_back(buf);
    }

    for(auto k : c){
        a = k.first;
        b = k.second;

        for (int c = 0; c < a; ++c) {
            for (int d = 0; d < b; ++d) {
                if(c % 2 == 0){
                    if(d % 2 == 0){
                        cout << "#";
                    }else{
                        cout << ".";
                    }
                }else{
                    if(d % 2 == 0){
                        cout << ".";
                    }else{
                        cout << "#";
                    }
                }
            }
            cout << endl;
        }
        cout << endl;
    }

    return 0;
}

Measured memory_bytes: 3108
fn read_stdin() -> String {
    use std::io::Read;
    let mut input = String::new();
    std::io::stdin().read_to_string(&mut input).unwrap();
    input
}

fn scan<'a, I: Iterator<Item = &'a str>, T: std::str::FromStr>(tokens: &mut I) -> T {
    tokens.next().unwrap().parse().ok().unwrap()
}

fn main() {
    let input = read_stdin();
    let tokens = &mut input.split_whitespace();
    let s: String = scan(tokens);
    let _: String = scan(tokens);
    let mut a: usize = scan(tokens);
    let mut b: usize = scan(tokens);
    let u: String = scan(tokens);
    if s == u {
        a -= 1;
    } else {
        b -= 1;
    }
    println!("{} {}", a, b);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define MS(ARRAY,VALUE) memset(ARRAY,VALUE,sizeof(ARRAY))
#define Fin freopen("input.txt","r",stdin)
#define ll long long
#define pll pair<ll,ll>
#define pii pair<int,int>


#define MOD 1000000007ll
#define MX 2000006 //200005

ll m, n;
ll a[MX];
int main()
{
    #ifndef ONLINE_JUDGE
    //Fin;
    #endif
    int test=1;
    ll x, ans;
    ll y,s,i;
    //cin>>test;
    //test=1;
    while(test--)
    {
        y=1000;
        s=0;
        cin>>n;
        m=300;
        for(i=1;i<=n;i++){
                scanf("%lld",&a[i]);
                m=min(m,a[i]);
        }
         //for(i=1;i<=k;i++)r*=a[i];
        for(i=1;i<n;i++)
        {
            if(a[i]<a[i+1]){
                x=y/a[i];
                y-=(x*a[i]);
                s+=x;
            }
            else{
                x=s*a[i];
                y+=x;
                s=0;
            }
        }
        y+=(s*a[n]);
        cout<<y<<endl;
    }
    return 0;
}



Measured memory_bytes: 3800
#include<bits/stdc++.h>
#define ll long long
#define N 25010
#define K 410
#define mo 1000000007
using namespace std;
int a[N],we[K],n,m,k;
ll dp[N][K],su[N][K],p[K],q[K],ans,d1[N][K],d2[N][K];
ll po(ll x,ll y){ll z=1;while (y){if (y%2)z=x*z%mo;x=x*x%mo;y/=2;}return z;}
int main(){
	cin>>n>>k>>m;
	for (int i=1;i<=m;i++)cin>>a[i];
	int la=0;
	for (int i=1;i<=m;i++){
		la=max(la,we[a[i]]);we[a[i]]=i;
		if (la+k==i){
			cout<<(n-m+1)*po(k,n-m)%mo<<endl;
			return 0;
		}
	}
	if (la==0){
		dp[0][0]=1;su[0][0]=0;
		for (int i=1;i<=n;i++){
			for (int j=k;j>=1;j--)p[j]=(p[j+1]+dp[i-1][j])%mo,q[j]=(q[j+1]+su[i-1][j])%mo;
			for (int j=1;j<=k;j++){
				dp[i][j]=(dp[i-1][j-1]*(k-j+1)+p[j])%mo;
				su[i][j]=(su[i-1][j-1]*(k-j+1)+q[j])%mo;
			}
			for (int j=1;j<=k;j++){
				if (j>=m){
					if (j==k)dp[i][j]=su[i][j]=0;
					else su[i][j]=(su[i][j]+dp[i][j])%mo;
				}
			}
		}
		for (int i=1;i<k;i++)ans=(ans+su[n][i])%mo;
		for (int i=k-m+1;i<=k;i++)ans=ans*po(i,mo-2)%mo;
		cout<<((n-m+1)*po(k,n-m)-ans+mo)%mo<<endl;
	}else{
		int qi,ho;
		memset(we,0,sizeof(we));
		for (int i=1;i<=m;i++){if (we[a[i]]){qi=i-1;break;}we[a[i]]=i;}
		memset(we,0,sizeof(we));
		for (int i=m;i>=1;i--){if (we[a[i]]){ho=m-i;break;}we[a[i]]=i;}
		d1[0][qi]=1;d2[0][ho]=1;
		for (int i=1;i<=n;i++){
			for (int j=k;j>=1;j--)p[j]=(p[j+1]+d1[i-1][j])%mo,q[j]=(q[j+1]+d2[i-1][j])%mo;
			for (int j=1;j<k;j++){
				d1[i][j]=(d1[i-1][j-1]*(k-j+1)+p[j])%mo;
				d2[i][j]=(d2[i-1][j-1]*(k-j+1)+q[j])%mo;
			}
		}
		for (int x=0;x+m<=n;x++){
			ll s1=0,s2=0;
			for (int j=0;j<=k;j++)s1=(s1+d1[x][j])%mo,s2=(s2+d2[n-m-x][j])%mo;
			ans=(ans+s1*s2)%mo;
		}
		cout<<((n-m+1)*po(k,n-m)-ans+mo)%mo<<endl;
	}
	return 0;
}

Measured memory_bytes: 162176
#include<iostream>
#include<string>
using namespace std;
int main(){
  string str;
  cin >> str;
  int i;
  int m,b;
  while(str!="-"){
    cin >> m;
    for(i=0;i<m;i++){
      cin >> b;
      str=str.substr(b,str.size()-b)+str.substr(0,b);
    }
    cout << str << endl;
    cin >> str;
  }
  
}


Measured memory_bytes: 3208
#include<bits/stdc++.h>
using namespace std;
int n,m,x,p[12];
bool f[1<<12],b[12][12];
char a[12][12];
int main(){
	random_device ra;
	mt19937 gen(ra());
	scanf("%d%d",&n,&m);
	for(int i=0;i<n;i++) p[i]=i;
	for(int i=0;i<n;i++) scanf("%s",a[i]);
	for(int ite=1;ite<=50000;ite++){
		shuffle(p,p+n,gen);
		memset(b,1,sizeof(b));
		for(int i=0;i<m;i++) for(int j=i;j<m;j++) for(int k=0;k<n;k++)
			if(a[p[k]][i]!=a[p[n-k-1]][j])
				b[i][j]=0;
		memset(f,0,sizeof(f));
		f[0]=1;
		for(int k=0;k<(1<<m);k++) if(f[k])
			for(int i=0;i<m;i++) for(int j=i+1;j<m;j++)
				if(!(1<<i&k)&&!(1<<j&k)&&b[i][j])
					f[k|(1<<i)|(1<<j)]=1;
		bool chk=0;
		if(!(m&1))
			chk=f[(1<<m)-1];
		else for(int i=0;i<m;i++)
			chk|=f[(1<<m)-1-(1<<i)];
		if(chk) {
			puts("YES");
			return 0;
		}
	}
	puts("NO");
	return 0;
}


Measured memory_bytes: 384
#include <iostream>
using namespace std;
 
 
int N, M,ans = 0;
int dp[10010][10010] = { 0 };
int main() {
	cin >> N >> M;
  	if(!M%N){
		cout << M /N << endl;
    }else{
    	for (int i = (M/N); i >= 1; i--) {
	    	if ((M - i * (N - 1) )% i == 0) {
		    	ans = i;
                break;
    		}
    	}
        cout << ans << endl;
    }
	
	return 0;
}

Measured memory_bytes: 256
from sys import exit
A,B = [int(n) for n in input().split()]
# N = int(input())
# a = [int(input()) for _ in range(N)]
# S = str(input())
# L = len(S)
# T = str(input())
# exit()

if(A > B):
    ans= A
    A-=1
else:
    ans=B
    B-=1
print(ans+max(A,B))


Measured memory_bytes: 3064
import java.util.*;

public class Main {
    public static final long DIV = 998244353;
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        long a = sc.nextLong();
        long b = sc.nextLong();
        long k = sc.nextLong();
        sc.close();

        long[] comb = new long[(int)n+1];

        comb[0] = 1;
        for(int i=0; i<n; i++){
            comb[i+1] = comb[i] * (n-i);
            if(comb[i+1] > DIV) comb[i+1] = comb[i+1] % DIV;
            comb[i+1] = comb[i+1] * modinv(i+1, DIV);
            if(comb[i+1] > DIV) comb[i+1] = comb[i+1] % DIV;
        }

        long ans = 0;

        for(int i=0; i<=n; i++){
            if((k-a*i) % b != 0) continue;

            long tmp = (k-a*i) / b;
            if(tmp > n || tmp < 0) continue;
            int bi = (int)tmp;
            ans += comb[i] * comb[bi];
            if(ans >= DIV) ans = ans % DIV;
        }

        System.out.println(ans);
    }

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

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

main(){

  ll n;
  cin>>n;
  vector<ll> a(n);
  rep(i,n)cin>>a[i];

  vector<pair<ll,ll>> b;
  rep(i,n)b.emplace_back(a[i],i+1);
  sort(b.begin(),b.end());
  rep(i,n)cout<<b[i].second<<" ";
  cout<<endl;

}

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

int main() {
  int N,M;
  cin >> N >> M;
  vector<int> a(N);
  vector<int> b(N+1);
  b[0]=0;
  for(int i=0;i<N;i++){
    cin >> a[i];
    b[i+1]=(b[i]+a[i])%M;
  }
  map<int,int> ma;
  long sum=0;
  for(int i=0;i<b.size();i++){
    sum+=ma[b[i]];
    ma[b[i]]++;
  }
  cout << sum << endl;    
}

Measured memory_bytes: 3968
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;
const int MAX = 510000;

int main() {
  string S;
  cin >> S;
  int win = 0;
  for (int i=0; i<S.size(); i++) {
    if (S[i]=='o') win++;
  }
  if (win+15-S.size()>=8) cout << "YES" << endl;
  else cout << "NO" << endl;
}

Measured memory_bytes: 384
#include<iostream>
#include<cstdlib>
using namespace std;
int main(){
  int n;
  cin>>n;
  int a[n+2];
  int d[n+1];
  int sum=0;
  a[0]=a[n+1]=0;
  for(int i=1;i<n+1;i++){
    cin>>a[i];
    d[i-1]=abs(a[i]-a[i-1]);
    sum+=d[i-1];
  }
  d[n]=abs(a[n+1]-a[n]);
  sum+=d[n];
  for(int i=1;i<n+1;i++){
    int tmp=sum;
    tmp-=(d[i-1]+d[i]);
    tmp+=abs(a[i+1]-a[i-1]);
    cout<<tmp<<endl;
  }
  return 0;
}


Measured memory_bytes: 2048
from collections import defaultdict

N = int(input())

s = [input() for i in range(N)]

line = defaultdict(int)

for anagram in s:
  a = sorted(anagram)
  line[''.join(a)] += 1

_sum = 0

for i in line:
  _sum += int((line[i] * (line[i] - 1)) / 2)

print(_sum)


Measured memory_bytes: 25332
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
using namespace std;
typedef long long ll;
typedef pair<int, int> P; 
const int inf = 1<<21;
const ll INF = 1LL << 60;
const ll mod = 1e9+7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    vector<char> aa = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};
    ll n;
    cin >> n;
    string ans = "";
    while(n>0){
        ll w=(n-1)/26;
        ll a=n%26;
        if (a==0){
            a = 26;
        }
        ans += aa[a-1];
        n = w;
    }
    reverse(ans.begin(), ans.end());
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3652
/*
有障碍的网格路径数 
*/
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
#define MAXN 1005
#define MOD 1000000007
int dp[MAXN][MAXN];
char grid[MAXN][MAXN];
int h, w;
int main(){
    scanf("%d%d", &h, &w);
    for(int i = 1; i <= h; i++)
        scanf("%s", &grid[i][1]);
    dp[1][1] = 1;
    for(int i = 2; i <= h; i++)
        if(grid[i][1] == '.')
            dp[i][1] = dp[i-1][1];
        else
            dp[i][1] = 0;
    for(int i = 2; i <= w; i++)
        if(grid[1][i] == '.')
            dp[1][i] = dp[1][i-1];
        else
            dp[1][i] = 0;
    for(int i = 2; i <= h; i++)
        for(int j = 2; j <= w; j++)
            if(grid[i][j] == '#')
                dp[i][j] = 0;
            else
                dp[i][j] = (dp[i-1][j] + dp[i][j-1]) % MOD;
    printf("%d\n", dp[h][w]);
}

Measured memory_bytes: 5120
import java.io.PrintWriter

fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun nextList() = next().split(" ")
fun nextIntList() = nextList().map(String::toInt)
fun nextLongList() = nextList().map(String::toLong)
fun nextDoubleList() = nextList().map(String::toDouble)

val pw = PrintWriter(System.out)
fun print(s: Any = "") = pw.print(s)
fun println(s: Any = "") = pw.println(s)

fun <T> Iterable<T>.join(separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "") = joinToString(separator, prefix, postfix)
fun <T> Array<T>.join(separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "") = joinToString(separator, prefix, postfix)

fun main(args: Array<String>) {
    main()
    pw.flush()
}

fun main() {
    val C = Array(3) { nextIntList().toTypedArray() }
    for (c in C) {
        val m = c.min()!!
        c[0] -= m
        c[1] -= m
        c[2] -= m
    }
    var ans = true
    for (i in 0..2) {
        if (C[0][i] != C[1][i] || C[1][i] != C[2][i]) {
            ans = false
        }
    }
    println(if (ans) "Yes" else "No")
}

Measured memory_bytes: 37852
/*input
7
bass
bass
kick
kick
bass
kick
kick
*/

#include <bits/stdc++.h>
 
using namespace std;
const long long MOD = 1e9+7;
vector<int> prime;
const int MAX = 100;


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    bool flag = true;
    int n;
    cin >> n;
    map<string,int> mp;
    int ans = 0;
    for(int i=0;i<n;i++){
        string s;
        cin >> s;
        mp[s]++;
        ans = max(ans,mp[s]);
    }
    for(auto it: mp){
        if(it.second==ans)
            cout << it.first << "\n";
    }


}



Measured memory_bytes: 23808
a = str(input())

cnt = 0
cnt_max = 0



for i in range(len(a)):
    if((a[i]=="A") or(a[i]=="C") or (a[i]=="G") or (a[i]=="T")):
        cnt += 1
    else:
        cnt = 0
    
    if(cnt >= cnt_max):
        cnt_max = cnt
        

print(cnt_max)

Measured memory_bytes: 3060
#include <iostream>

using namespace std;

#define IN(v) int v;cin>>v;
#define OUT(v) cout<<v<<endl

int main() {
  string s;
  cin >> s;

  int len = s.length();
  for (int i = len - 1; i >= 0; --i) {
    if (s.substr(i-4, 5) == "dream" || s.substr(i-4, 5) == "erase")
      i -= 4;
    else if (s.substr(i-5, 6) == "eraser")
      i -= 5;
    else if (s.substr(i-6, 7) == "dreamer")
      i -= 6;
    else {
      OUT("NO");
      return 0;
    }
  }
  OUT("YES");

  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define elif else if
using namespace std;
int a;
signed main()
{
	cin>>a;
	rep(i,25){
		rep(j,15){
			if(i*4+j*7==a){
				cout<<"Yes";
				return 0;
			}
		}
	}
	cout<<"No";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  
  if (a+b==c+d) cout << "Balanced" << endl;
  else if (a+b>c+d) cout << "Left" << endl;
  else cout << "Right" << endl;
}

Measured memory_bytes: 256
def solve_knapsack(weight, items):
    """
    ???????¨?????????§???????????¶????????????????§£???
    :param weight: ?¨±???????????????????????????
    :param items: ???????????¨???????????¨????????¨????????????????????????????????¨????????????????????£????????????[0]???????????§[1]????????????items[0]?????????????????????
    :return: ??????????¶??????????????????§??¢??????????????°??????????????´????????????????????§???
    """
    dp = [[0]*(weight+1) for _ in range(len(items))] #  ?¨????:???????????????:?????¨????????¢?????????????¨???? ??§2?¬??????????????????????0??§????????????
    for i, item in enumerate(items[1:], start=1):
        for w in range(1, weight+1):
            # i????????¨?????????i-1??????????????????
            if item[1] <= w:
                if item[0] + dp[i-1][w-item[1]] > dp[i-1][w]: #  ????????¢??????????????\???????????¨????????£??????????????????????????????up????????´???
                    dp[i][w] = item[0] + dp[i-1][w-item[1]] #  dp[i-1][w-itemm[1]]??????????????¢??????????????\???????????¨??????????????????????????¨?????????????????¶????????¨????????????
                else:           #  ??¢??????????????????????????´????????????????????????????´?????????????????????????
                    dp[i][w] = dp[i-1][w]
            else:
                dp[i][w] = dp[i-1][w]
    return dp[-1][-1]



if __name__ == '__main__':
    # ??????????????\???
    # f = open('input.txt')
    num_of_sack, total_capacity = [int(x) for x in input().strip().split(' ')]
    items = [[]]                #  index[1]??????????????????????????????????????????????????????l0]????????????????????\????????????
    for _ in range(num_of_sack):
        items.append([int(x) for x in input().strip().split(' ')])
    # f.close()

    # ????????¨???????????¨???
    result = solve_knapsack(total_capacity, items)
    print(result)

Measured memory_bytes: 27580
// review
#include <iostream>

using namespace std;

string s;
void solve() {
  if (s[0] == s[s.size()-1] ^ s.size() % 2 != 1) {
    cout << "Second" << endl;
  } else {
    cout << "First" << endl;
  }
}

int main() {
  cin >> s;
  solve();
}


Measured memory_bytes: 512
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif

#include <bits/stdc++.h>

using namespace std;

typedef long double ld;

#ifdef DEBUG
#define eprintf(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#else
#define eprintf(...) ;
#endif

#define sz(x) ((int) (x).size())
#define TASK "text"

const int inf = (int) 1.01e9;
const long long infll = (long long) 1.01e18;
const ld eps = 1e-9;
const ld pi = acos((ld) -1);

mt19937 mrand(random_device{} ()); 

int rnd(int x) {
  return mrand() % x;
}

void precalc() {
}

const int maxn = 2005;
int n;
int a[maxn];

int read() {
  if (scanf("%d", &n) < 1) {
    return false;
  }
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
  }
  return true;
}

const int maxx = maxn * maxn;
bitset<maxx> dp;

void solve() {
  dp.reset();
  dp[0] = true;
  int s = 0;
  for (int i = 0; i < n; i++) {
    dp = dp | (dp << a[i]);
    s += a[i];
  }
  for (int x = (s + 1) / 2;; x++) {
    if (dp[x]) {
      printf("%d\n", x);
      return;
    }
  }
  assert(false);
}

int main() {
  precalc();
#ifdef DEBUG
  assert(freopen(TASK ".in", "r", stdin));
  assert(freopen(TASK ".out", "w", stdout));
#endif
  while (read()) {
    solve();
#ifdef DEBUG
    eprintf("Time %.2f\n", (double) clock() / CLOCKS_PER_SEC);
#endif
  }
  return 0;
}


Measured memory_bytes: 2176
use proconio::input;

fn main() {
    input! {
        h: usize,
        w: usize,
        k: usize,
        hw: [String; h],
    }

    let mut hc = vec![0; h];
    let mut wc = vec![0; w];
    let mut all = 0;
    for l in 0..h {
        // println!("{:?}", hw[l]);
        let chars: Vec<char> = hw[l].chars().collect();

        let mut sum = 0;
        for c in 0..w {
            if chars[c] == '#' {
                wc[c] += 1;
                sum += 1;
            }
        }
        hc[l] = sum;
        all += sum;
    }

    let mut ans = 0;

    // println!("{:?}", wc);
    for s in 0..1 << h {
        let mut all_black = all;
        let mut this_line = wc.to_vec();
        // println!("{:b}", s);
        for i in 0..h {
            // もしi行目を消すのならば
            if s >> i & 1 == 1 {
                all_black -= hc[i];
                let chars2: Vec<char> = hw[i].chars().collect();
                // println!("rm: {:?}", hw[i]);
                for c in 0..w {
                    if chars2[c] == '#' {
                        this_line[c] -= 1;
                    }
                }
            }
        }
        // println!("all_black: {}, line: {:?}", all_black, this_line);
        if all_black >= k {
            let need = all_black - k;

            for sw in 0..1 << w {
                let mut w_sum = 0;
                for j in 0..w {
                    if sw >> j & 1 == 1 {
                        w_sum += this_line[j];
                    }
                }
                if w_sum == need {
                    ans += 1;
                }
            }
        }
    }
    println!("{}", ans);
}

Measured memory_bytes: 2168
#include<bits/stdc++.h>
 using namespace std;
#define INF 1000000000
#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
typedef long long LL;
LL H,W;
typedef pair<LL,LL> P;
map<P,int> m;
int N;
LL c[10];
int main(){
    cin>>H>>W;
    cin>>N;
    REP(i,N){
        LL a,b;
        cin>>a>>b;
        a--;
        b--;
        for(int i=-1;i<=1;i++){
           for(int j=-1;j<=1;j++){
               LL c=a+i;
               LL d=b+j;
               if(c<0)continue;
               if(H<=c)continue;
               if(d<0)continue;
               if(W<=d)continue;
               if(m.find(P(c,d))==m.end()){
                  m[P(c,d)]=1;
               }else{
                  m[P(c,d)]+=1;
               }
           }
        }
    }
    REP(i,10)c[i]=0;
    c[0]=(H-2)*(W-2);
    for(map<P,int>::iterator it=m.begin();it!=m.end();it++){
        if(it->first.first==0)continue;
        if(it->first.first==H-1)continue;
        if(it->first.second==0)continue;
        if(it->first.second==W-1)continue;
        //cout<<"a"<<it->first.first<<"b"<<it->first.second<<"c"<<it->second<<endl;
        c[0]--;
        c[it->second]++;
    }
    REP(i,10){
        cout<<c[i]<<endl;
    }
    
    return 0;
}

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

using ll = long long;

const int mod = 1000000007;
const int INF = 1000000000;
const double EPS = 1e-9;

struct Point {
    double x, y;
};

int N;
vector<Point> p;

double dist(Point a, Point b) {
    double dx = a.x - b.x;
    double dy = a.y - b.y;
    return sqrt(dx * dx + dy * dy);
} 

double f(double x, double y) {
    double res = 0;
    for (int i = 0; i < N; ++i) {
        res = max(res, dist((Point){x, y}, p[i]));
    }
    return res;
}

double g(double x) {
    double l = 0, r = 1000;
    for (int i = 0; i < 100; ++i) {
        double c1 = (l*2 + r) / 3.0;
        double c2 = (l + r*2) / 3.0;
        if (f(x, c1) > f(x, c2)) l = c1;
        else r = c2;
    }
    return f(x, l);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N;
    p = vector<Point>(N);
    for (int i = 0; i < N; ++i) cin >> p[i].x >> p[i].y;
    double l = 0, r = 1000;
    for (int i = 0; i < 100; ++i) {
        double c1 = (l*2 + r) / 3.0;
        double c2 = (l + r*2) / 3.0;
        if (g(c1) > g(c2)) l = c1;
        else r = c2;
    }
    double ans = g(l);
    printf("%.10f\n", ans);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
map<long long,long long  >mp;
int main()
{
    long long n,a,i,arr[100003],j=0,sum=0;
    scanf("%lld",&n);
    for(i=0; i<n; i++)
    {
        scanf("%lld",&a);
        mp[a]++;
        if(mp[a]==1)
            arr[j++]=a;
    }
    // printf("sakib %d\n",j);
    //printf("%lld %lld %lld\n\n",arr[0],arr[1],arr[2]);
    for(i=0; i<j; i++)
    {
        if(mp[arr[i]]>arr[i])
        {
            sum+=mp[arr[i]]-arr[i];
        }
        //printf("sdf  %lld\n",sum);}
        if(mp[arr[i]]<arr[i])
        {
            sum+=mp[arr[i]];
            //printf("kkk  %lld\n",sum);
        }
    }
    printf("%lld\n",sum);
    return 0
    ;
}


Measured memory_bytes: 7040
#include <iostream>

using namespace std;

int main()
{
  int a,b,ans;
  long long x[1100] = {0};

  cin >> a >> b;

  for(int i = 1;i <= 999;i++){
    x[i] = x[i-1] + i;
  }

  for(int j = 1;j < 999;j++){
    if(x[j] - a == x[j+1] - b){
      ans = x[j] - a;
      cout << ans << endl;
      return 0;
    }
  }

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<vector>
#include<cstdlib>
#include<numeric>
#include<climits>
#define REP(i,m,n) for(int i = m; i < n; i++)
#define rep(i,n) REP(i,0,n)
template<class T> void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> void chmin(T& a, T b) { if (a > b) { a = b; } }
using namespace std;

int main(void) {
	long long n, m;
	cin >> n >> m;
	vector<long long> passable_gate_of_id(200100);

	int l, r;
	for (int i = 1; i <= m; i++)
	{
		cin >> l >> r;
		passable_gate_of_id[l]++;
		passable_gate_of_id[r + 1]--;
	}
	for (int i = 1; i <= n; i++)
	{
		passable_gate_of_id[i] += passable_gate_of_id[i - 1];
	}
	int count = 0;
	for (int i = 1; i <= n; i++)
	{
		if (passable_gate_of_id[i] == m) {
			count++;
		}
	}

	cout << count << endl;
}

Measured memory_bytes: 1792
#template
def inputlist(): return [int(k) for k in input().split()]
#template
N,M,Q = inputlist()
l = [0]*Q
for i in range(Q):
    l[i] = inputlist()
li = [int(i) for i in range(1,M+1)]
from itertools import combinations_with_replacement
h = combinations_with_replacement(li,N)
ans = 0
for v in h:
    va = list(v)
    tmp = 0
    for i in range(Q):
        a,b,c,d = l[i]
        a-=1
        b-=1
        if va[b] - va[a] == c:
            tmp += d
    ans = max(tmp,ans)
print(ans)


Measured memory_bytes: 68444
#include <bits/stdc++.h>
#define rep(i,m,n) for(int i=m;i<n;i++)
#define co(n) cout<<n<<endl
using namespace std;

int main(){ 
  int n,x=0,y=0,ans=100000,c=0;
  cin>>n;
  int a[2*n];
  rep(i,0,2*n) cin>>a[i];
  sort(a,a+2*n);
  rep(i,0,n){
    c+=a[2*i];
  }
  co(c);
  
  return 0;
}

Measured memory_bytes: 256
// skip until line 65
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <istream>
#include <iterator>
#include <sstream>
#include <list>
#include <map>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iomanip>
using namespace std;

#define BR "\n"
#define REP(i, n) for(int (i)=0;(i)<(n);++(i))
#define ALL(cont) begin(cont),end(cont)
#define AS_MOD(a, b) ((((a) % (b) ) + (b)) % (b))
#define MO(a) AS_MOD(a,mod)
#define FEACH(it, cont) for(auto (it) = begin(cont); it!=end(cont);++it)
#define FEACHR(it, cont) for(auto (it) = rbegin(cont); it!=rend(cont);++it)
#define pb push_back
#define pob pop_back
#define fi first
#define se second
#define getll() ([](){ll s;scanf("%lld", &s);return s;})()
#define getld() ([](){ld s;scanf("%Lf", &s);return s;})()
#define prl(P) printf("%lld", P)
#define prd(P) printf("%.10Lf", P)
#define pr(P) printf(P)
#define MAX(V, T) V=max(V,T)
#define MIN(V, T) V=min(V,T)

#define DumpArray(cont, from, to) for(int __i=from;__i<to;++__i) {cout<<"(" <<__i<<": " << cont[__i]<<")";} cout<<endl;
#define DumpPairs(cont, from, to) for(int __i=from;__i<to;++__i) {cout<<"(" <<__i<<": " << cont[__i].fi <<"," << cont[__i].se<<")";} cout<<endl;
/*
 * ***_bound(6)
 * 5 6 6 6 6 6 7 7 7
 *   ^lower    ^upper
 * void reverse(c.begin(), c.end())
 *
 * graph
 * seg tree
 * dp
 * brute force
 */
struct Comparator{
    int operator()(int l, int r) const {
        return r<l;
    }
};
struct Vec;
//set<int, Comparator> S;

// solution below
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;

int main() {
    cout.precision(15);
    cout << fixed;
    int X,Y;
    cin >> X >> Y;
    if (Y%2==0 && Y<=4*X && Y>=2*X) {
        cout << "Yes"<<endl;
    } else {
        cout<<"No"<<endl;
    }

}


Measured memory_bytes: 3620
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long int
#define MAX 1000000007
using namespace std;



int main(void){
	int n;
	cin>>n;
	ll a[n+1];
	a[0]=0;
	rep(i,n){
		cin>>a[i+1];
		a[i+1]+=a[i];
		//cout<<a[i+1]<<" ";
	}
	//cout<<endl;


	ll left=1,right=3,lmin,lmax,rmin,rmax,ans=MAX;
	for(int i=2;i<n-1;i++){
		while(a[left]*2 < a[i])left++;
		if(abs(a[i]-2*a[left]) > abs(a[i]-2*a[left-1]))left--;
		if(a[left] < a[i]-a[left]){
			lmin = a[left];
			lmax = a[i]-a[left];
		}
		else{
			lmin = a[i]-a[left];
			lmax = a[left];
		}

		while((a[right]-a[i])*2 < a[n]-a[i])right++;
		if(abs(a[n]-a[i]-(a[right]-a[i])*2) > abs(a[n]-a[i]-(a[right-1]-a[i])*2))right--;
		if(a[right]-a[i] < a[n]-a[right]){
			rmin = a[right]-a[i];
			rmax = a[n]-a[right];
		}
		else{
			rmax = a[right]-a[i];
			rmin = a[n]-a[right];
		}
		ll work0,work1;
		if(rmax < lmax)work0=lmax;
		else work0=rmax;
		if(rmin < lmin)work1=rmin;
		else work1=lmin;
		//cout<<a[left]<<","<<a[i]-a[left]<<","<<a[right]-a[i]<<","<<a[n]-a[right]<<endl;
		if(work0-work1 < ans)ans=work0-work1;
	}

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


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

#define int long long

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

	int l = 1;
	int r = 10;
	for(int i = 1;i < n;i++){
		l *= 10;
		r *= 10;
	}

	if(n == 1) l = 0;

	int ll[10] = {};
	memset(ll, -1, sizeof(ll));

	int s[10], c[10];
	for(int i = 0;i < m;i++){
		cin >> s[i] >> c[i];
		s[i]--;
	}

	for(int i = 0;i < m;i++){
		if(ll[s[i]] != -1 && ll[s[i]] != c[i]){
			cout << -1 << endl;
			return 0;
		}
		ll[s[i]] = c[i];
	}

	for(int i = l;i < r;i++){
		string num = to_string(i);
		int j;
		for(j = 0;j < n;j++){
			if(ll[j] != -1 && ll[j] != num[j]-'0'){
				break;
			}
		}
		if(j == n){
			cout << num << endl;
			return 0;
		}
	}

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


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<queue> 
#define rg register
using namespace std;
typedef long long LL;
template<typename T> inline void read(T &x){
	x=0; T f=1; char ch=getchar();
	while(ch<'0'||ch>'9') f=ch=='-'?-1:1, ch=getchar();
	while(ch>='0'&&ch<='9') x=(x<<3)+(x<<1)+(ch^'0'), ch=getchar();
	x=x*f;
}

const int N=110;

int n;
bool vis[N];

int main(){
	read(n);
	for(int i=1;i<=n;i++){
		int a,b;
		read(a),read(b);
		vis[i]=(a==b);
	}
	
	bool flag=false;
	int s=0;
	for(int i=1;i<=n;i++)
		if(vis[i]){
			s++;
			if(s>=3) flag=true;
		}
		else s=0;
	if(flag) puts("Yes");
	else puts("No");
	return 0;
}

Measured memory_bytes: 3600
local mod = 1000000007

local function bmul(x, y)
  return (x * y) % mod
end

local function badd(x, y)
  return (x + y) % mod
end

local function bsub(x, y)
  return x < y and x - y + mod or x - y
end

local function modpow(src, pow)
  local res = 1
  while 0 < pow do
    if pow % 2 == 1 then
      res = bmul(res, src)
      pow = pow - 1
    end
    src = bmul(src, src)
    pow = pow // 2
  end
  return res
end

local function modinv(src)
  return modpow(src, mod - 2)
end

local function getComb(n, k)
  local ret = 1
  local inv = 1
  for i = 1, k do
    ret = bmul(ret, n + 1 - i)
    inv = bmul(inv, i)
  end
  return bmul(ret, modinv(inv))
end

local n, m, k = io.read("*n", "*n", "*n")
local a = bmul(n, n)
a = bmul(a, bmul(modinv(6), bmul(bmul(m + 1, m), m - 1)))
local b = bmul(m, m)
b = bmul(b, bmul(modinv(6), bmul(bmul(n + 1, n), n - 1)))
local r = badd(a, b)
r = bmul(r, getComb(n * m - 2, k - 2))
print(r)


Measured memory_bytes: 2748
#include<iostream>
#include<cassert>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<vector>
#include<queue>
#include<algorithm>
#include<string>
#include<sstream>
#include<cctype>
#include<cmath>
#include<iomanip>
#include<map>
#include<stack>
#include<set>
#include<functional>
#define in(x) x=read()
#define qr read()
#define int ll
#define mp make_pair
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
namespace fastIO
{
    #define BUF_SIZE 100000
    bool IOerror=0;
    inline char nc()
	{
        static char buf[BUF_SIZE],*p1=buf+BUF_SIZE,*pend=buf+BUF_SIZE;
        if (p1==pend){
            p1=buf; pend=buf+fread(buf,1,BUF_SIZE,stdin);
            if (pend==p1){IOerror=1;return -1;}
        }
        return *p1++;
    }
    inline bool blank(char ch){return ch==' '||ch=='\n'||ch=='\r'||ch=='\t';}
    inline ll read()
	{
        bool sign=0; char ch=nc();ll x=0;
        for (;blank(ch);ch=nc());
        if (IOerror)return 0;
        if (ch=='-')sign=1,ch=nc();
        for (;ch>='0'&&ch<='9';ch=nc())x=x*10+ch-'0';
        if (sign)x=-x;
        return x;
    }
    #undef BUF_SIZE
};
using namespace fastIO;
struct node
{
	int x,y;
}e[10000010],a[10000010],b[10000010];
int w,h,n;
bool cmp(node a,node b)
{
	return a.x==b.x?a.y<b.y:a.x<b.x;
}
int c[10000010],col[10000010];
void pushup(int x)
{
	c[x]=max(c[x<<1],c[x<<1|1]);
}
void pushdown(int x)
{
	if(col[x])
	{
		col[x<<1]+=col[x];
		col[x<<1|1]+=col[x];
		c[x<<1]+=col[x];
		c[x<<1|1]+=col[x];
		col[x]=0;
	}
}
void modify(int nl,int nr,int l,int r,int v,int x)
{
	if(l<=nl&&nr<=r)
	{
		col[x]+=v;
		c[x]+=v;
		return;
	}
	int mid=(nl+nr)/2;
	pushdown(x);
	if(l<=mid)modify(nl,mid,l,r,v,x<<1);
	if(r>mid)modify(mid+1,nr,l,r,v,x<<1|1);
	pushup(x);
}
int ans=0;
void solve()
{
	memset(c,0,sizeof(c));
	memset(col,0,sizeof(col));
	sort(e+1,e+1+n,cmp);
	int t1=0,t2=0;
	for(int i=1;i<n;i++)
	{
		if(e[i].y<=h/2)
		{
			int pre=i-1;
			while(t1&&a[t1].y<e[i].y)
			{
				modify(1,n,a[t1].x,pre,a[t1].y-e[i].y,1);
				pre=a[t1].x-1;
				t1--;
			}
			if(pre!=i-1)a[++t1]=(node){pre+1,e[i].y};
		}
		else
		{
			int pre=i-1;
			while(t2&&b[t2].y>e[i].y)
			{
				modify(1,n,b[t2].x,pre,e[i].y-b[t2].y,1);
				pre=b[t2].x-1;
				t2--;
			}
			if(pre!=i-1)b[++t2]=(node){pre+1,e[i].y};
		}
		a[++t1]=(node){i,0};
		b[++t2]=(node){i,h};
		modify(1,n,i,i,h-e[i].x,1);
		ans=max(ans,e[i+1].x+c[1]);
	}
}
signed main()
{
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	w=qr,h=qr,n=qr;
	for(int i=1;i<=n;i++)
	{
		in(e[i].x),in(e[i].y);
	}
	e[++n]=(node){0,0}; 
	e[++n]=(node){w,h};
	solve();
	for(int i=1;i<=n;i++)swap(e[i].x,e[i].y);
	swap(w,h);
	solve();
	cout<<ans*2;
	return 0;
}

Measured memory_bytes: 172416
#include <iostream>
#include <algorithm>
#include <limits>
#include <vector>
#include <map>
#include <cmath>
#include <limits>
#include <iomanip>
#define ll long long int
#define rep(i,n) for(int i = 0;i < n;i++)
#define pb push_back
#define mp make_pair

using namespace std;

int main(){

    vector<int> a(3);
    cin >> a[0] >> a[1] >>a[2];

    sort(a.begin(),a.end());

    if(a[0] + a[1] == a[2]){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include "bits/stdc++.h"
using namespace std;
typedef long long unsigned int ll;

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

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

int main(){
    ll N,result;
    cin>>N;
    for(ll i=1;i*i<=N;i++){
        if(N%i==0)
            result=N/i;
    }
    cout<<to_string(result).size()<<endl;
 }

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll,ll> P;
typedef string str;
typedef vector<P> vp;
typedef vector<string> vs;
typedef vector<bool> vb;

const ll mod=1e9+7;
const ll inf=1e18;

#define rep(i,m,n) for(ll i=m;i<n;i++)
#define repr(i,m,n) for(ll i=m-1;i>=n;i--)
#define fi first
#define se second
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
#define eb(x) emplace_back(x)
#define pb(x) pop_back(x)
#define all(x) x.begin(),x.end()
#define allr(x) x.rbegin(),x.rend()
#define sum(x) accumulate(all(x),0)
#define pc(x) __builtin_popcount(x)
#define gll greater<ll>()

void solve(){
  ll x;
  cin >> x;
  cout << 1-x << endl;
}
int main(){
   cin.tie(nullptr);
  ios::sync_with_stdio(false);
  solve();
}

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

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

using namespace std;
using lint=long long;

int main(){
	lint n; cin>>n;
	for(lint a=1;a<=3500;a++) for(lint b=1;b<=3500;b++) {
		lint d=4*a*b-n*a-n*b;
		if(d>0 && n*a*b%d==0){
			cout<<a<<' '<<b<<' '<<n*a*b/d<<'\n';
			return 0;
		}
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll L(ll a,ll b){
    ll tmp;
    ll x = a*b;
    if(a<b){
        tmp = a;
        a = b;
        b = tmp;
    }
    ll r = a%b;
    while(r!=0){
        a = b;
        b = r;
        r = a%b; 
    }
    return x/b;
}
int main(){
    ll A,B,C,D;
    cin >> A >> B >> C >> D;
    ll countC = 0, countD = 0;
    countC = B/C - A/C;
    countD = B/D - A/D;
    if(A%D==0) countD++;
    if(A%C==0) countC++;
    ll LC = L(C,D);
    ll countLC = 0;
    countLC = B/LC - A/LC;
    if(A%LC==0) countLC++;
    ll ans = (B-A) - (countC+countD-countLC);
    cout << ans+1 << endl;
}


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

int main() {
    string S;
    cin >> S;
    if (S[2] == S[3]){
        if (S[4] == S[5]) {
            cout << "Yes" << endl;
        }
        else {
            cout << "No" << endl;
}
        }
    else {
        cout << "No" << endl;
    }
}

 


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

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

    int res = 30;
    for (int i = 0; i < N; i++)
    {
        cin >> A;
        int cnt = 0;
        while (A % 2 == 0)
        {
            A /= 2;
            cnt++;
        }
        res = min(res, cnt);
    }
    cout << res << endl;
}

Measured memory_bytes: 256
import java.util.Map;
import java.util.Map.Entry;
import java.util.Scanner;
import java.util.TreeMap;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		Map<Double, Integer> map1 = new TreeMap<Double, Integer>();
		Map<Double, Integer> map2 = new TreeMap<Double, Integer>();
		Map<Double, Integer> map3 = new TreeMap<Double, Integer>();
		slove(map1, scanner);
		slove(map2, scanner);
		slove(map3, scanner);
		Map<Double, Integer> map4 = new TreeMap<Double, Integer>();
		out(map1, map4);
		out(map2, map4);
		out(map3, map4);
		out(map4);
	}

	private static void out(Map<Double, Integer> map4) {
		int count = 0;
		for (Entry<Double, Integer> entry : map4.entrySet()) {
			System.out.println(entry.getValue() + " " + entry.getKey());
			if (count == 1) {
				return;
			}
			count++;
		}

	}

	private static void out(Map<Double, Integer> map1, Map<Double, Integer> map4) {
		int count = 0;
		for (Entry<Double, Integer> entry : map1.entrySet()) {
			if (count < 2) {
				System.out.println(entry.getValue() + " " + entry.getKey());
			} else {
				map4.put(entry.getKey(), entry.getValue());
			}
			count++;
		}
	}

	private static void slove(Map<Double, Integer> map, Scanner scanner) {
		int m = 8;
		while (m-- > 0) {
			int a = scanner.nextInt();
			double b = scanner.nextDouble();
			map.put(b, a);
		}
	}
}

Measured memory_bytes: 20188
#include <bits/stdc++.h>
using namespace std;
int n;
const int N = 1000000;
int a[N], ans = 1;
int main()
{
    cin >> n;
    for (int i = 1; i <= n; ++ i)
        cin >> a[i];

    for (int i = 2, nw = 0; i <= n; ++ i)
    {
        if (a[i] != a[i - 1])
        {
            if (nw == 0) nw = a[i] < a[i - 1]? 1: -1;
            else if ((a[i] < a[i - 1]? 1: -1) * nw == -1) nw = 0, ans ++;
        }
    }
    cout << ans << "\n";
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define rep(i,n) for (int i=0;i<(int)(n);i++)
#define codefor int test;scanf("%d",&test);while(test--)
#define yn(ans) if(ans)printf("Yes\n");else printf("No\n")
#define YN(ans) if(ans)printf("YES\n");else printf("NO\n")
#define vector2d(type,name,h,...) vector<vector<type>>name(h,vector<type>(__VA_ARGS__))
#define umap unordered_map
#define uset unordered_set
using namespace std;
using ll = long long;
const int MOD=1000000007;
//入力系
void scan(int& a){scanf("%d",&a);}
void scan(long long& a){scanf("%lld",&a);}
template<class T> void scan(T& a){cin>>a;}
template<class T> void scan(vector<T>& vec){for(auto&& it:vec)scan(it);}
void in(){}
template <class Head, class... Tail> void in(Head& head, Tail&... tail){scan(head);in(tail...);}
//出力系
void print(const int& a){printf("%d",a);}
void print(const long long& a){printf("%lld",a);}
void print(const double& a){printf("%.15lf",a);}
template<class T> void print(const T& a){cout<<a;}
template<class T> void print(const vector<T>& vec){if(vec.empty())return;print(vec[0]);for(auto it=vec.begin();++it!= vec.end();){putchar(' ');print(*it);}}
void out(){putchar('\n');}
template<class T> void out(const T& t){print(t);putchar('\n');}
template <class Head, class... Tail> void out(const Head& head,const Tail&... tail){print(head);putchar(' ');out(tail...);}
//デバッグ系
template<class T> void dprint(const T& a){cerr<<a;}
template<class T> void dprint(const vector<T>& vec){if(vec.empty())return;cerr<<vec[0];for(auto it=vec.begin();++it!= vec.end();){cerr<<" "<<*it;}}
void debug(){cerr<<endl;}
template<class T> void debug(const T& t){dprint(t);cerr<<endl;}
template <class Head, class... Tail> void debug(const Head& head, const Tail&... tail){dprint(head);cerr<<" ";debug(tail...);}

int main(){
    string s;
    getline(cin,s);
    rep(i,s.length()){
        if(s[i]>='a'&&s[i]<='z')s[i]=s[i]-'a'+'A';
        else if(s[i]>='A'&&s[i]<='Z')s[i]=s[i]-'A'+'a';
    }
    cout<<s<<endl;
}



Measured memory_bytes: 3196
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>
#include<utility>

using namespace std;

#define int long long
#define endl "\n"

constexpr long long INF = (long long)1e18;
constexpr long long MOD = 1'000'000'007; 

struct fast_io {
	fast_io(){
		std::cin.tie(nullptr);
		std::ios::sync_with_stdio(false);
	};
} fio;

signed main(){
	cout<<fixed<<setprecision(10);
	
	long double pi = acos(-1), R;
	
	cin>>R;
	
	R *= pi * 2;
	
	cout<<R<<endl;
	
	
	return 0;
}

//

Measured memory_bytes: 3796
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
int main(){
  ll n,w;
  cin >> n >> w;
  vector<vector<ll>> a(4);
  ll base = 0;
  for(int i = 0;i < n;i++){
    ll inv,inw;
    cin >> inw >> inv;
    if(i == 0){
      a[0].push_back(inv);
      base = inw;
    }
    else{
      a[inw - base].push_back(inv);
    }
  }
  ll res = 0;
  for(int i = 0;i < 4;i++)sort(a[i].rbegin(),a[i].rend());
  for(int i = 0;i <= a[0].size();i++){
    for(int j = 0;j <= a[1].size();j++){
      for(int k = 0;k <= a[2].size();k++){
        for(int l = 0;l <= a[3].size();l++){
          ll noww = base * i + (base+1) * j + (base+2) * k + (base+3) * l;
          if(noww > w)continue;
          ll nowv = 0;
          for(int m = 0;m < i;m++)nowv += a[0][m];
          for(int m = 0;m < j;m++)nowv += a[1][m];
          for(int m = 0;m < k;m++)nowv += a[2][m];
          for(int m = 0;m < l;m++)nowv += a[3][m];
          res = max(res,nowv);
        }
      }
    }
  }
  cout << res << endl;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;

int W, H;
int p[100010], q[100010];
vector<pii> v;

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  cin >> W >> H;
  for (int i = 0; i < W; i++) {
    cin >> p[i];
    v.emplace_back(p[i], 0);
  }
  for (int i = 0; i < H; i++) {
    cin >> q[i];
    v.emplace_back(q[i], 1);
  }
  sort(v.begin(), v.end());
  ll ans = 0, nw = 0, nh = 0;
  for (int i = 0; i < W+H; i++) {
    if (v[i].second == 0) {
      ans += v[i].first * (H+1-nh);
      nw++;
    } else {
      ans += v[i].first * (W+1-nw);
      nh++;
    }
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 2932
import sys
n=int(input())
A=list(map(int,input().split()))
count=0
for elem in A:
    if elem < 0:
        count+=1
if count%2==0:
    for i in range(len(A)):
        A[i]=abs(A[i])
    print(sum(A))
    sys.exit()
else:
    tmp=1000000000000
    for elem in A:
        tmp=(min(tmp,abs(elem)))
    for i in range(len(A)):
        A[i]=abs(A[i])
    print(sum(A)-2*tmp)
    

Measured memory_bytes: 20116