akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define v vector<ll> 
#define vv vector<v>
#define p pair<ll,ll>
#define arrayinput int n; int m; cin>>n>>m; v arr (n+1,-1); for (int i=0; i<n; i++){int temp; cin>>temp;arr[i]=temp;}
#define vp vector<pair<int,p> >
int LIM=2e5+10;
ll MOD=1e9+7;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    v arr(n+1,-1);
    int count=0;
    for (int i=1; i<=n; i++)
    {
        cin>>arr[i];
        if (arr[i]!=i)
            count++;
    }
    if (count==0 || count==2)
        cout<<"YES";
    else
        cout<<"NO";

    return 0;
}

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

using namespace std;

int solve(const int n, const int c, const vector<int>& v, const vector<int>& w) {
    vector<int> dp(c + 1, 0);
    for (int i = 0; i < n; i++) {
        for (int j = 1; j <= c; j++) {
            if (j >= w[i]) {
                dp[j] = max(dp[j], dp[j - w[i]] + v[i]);
            }
        }
    }
    return dp[c];
}

int solve_a(const int n, const int c, const vector<int>& v, const vector<int>& w) {
    vector<int> dp(c + 1, 0);
    for (int j = 1; j <= c; j++) {
        for (int i = 0; i < n; i++) {
            if (j >= w[i]) {
                dp[j] = max(dp[j], dp[j - w[i]] + v[i]);
            }
        }
    }
    return dp[c];
}

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

    vector<int> v(n);
    vector<int> w(n);

    for (int i = 0; i < n; i++) {
        cin >> v[i] >> w[i];
    }
    int ans = solve_a(n, c, v, w);
    cout << ans << endl;
    return 0;
}

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

int main()
{
    int N;
    cin >> N;
    vector <long long> L(N);
    rep (i, N) cin >> L.at(i);

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

    long long res = 0;

    for (int i = 0; i < N; i++) {
        for (int j = i + 1; j < N; j++) {
            int k = lower_bound(L.begin(), L.end(), L[i] + L[j]) - L.begin();

            res += max(k - (j + 1), 0);
        }
    }

    cout << res << endl;
    
    return 0;
}

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

using namespace std;

const long long INF = 9999999999;

int main() {
	long long n, t, a[100000], def = 0, ans = 0;
	cin >> n >> t;
	for (long long i = 0, amin = INF; i < n; i++) {
		cin >> a[i];
		amin = min(amin, a[i]);
		def = max(def, a[i] - amin);
	}
	for (long long i = 0, amin = INF; i < n; i++) {
		amin = min(amin, a[i]);
		if (a[i] == amin + def)ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <stack>
#include <map>
#include <queue>
#include <functional>
using namespace std;
typedef long long ll;


//Union-Findライブラリ.
class UF{
public:
    int par[200000];
    int ran[200000];

    void init(int n){
        for(int i = 0;i < n;i++){
            par[i] = i;
            ran[i] = 0;
        }
    }

    int find(int x){
        if(par[x] == x)return x;
        else return par[x] = find(par[x]);
    }

    void unite(int x,int y){
        x = find(x);
        y = find(y);

        if(ran[x] < ran[y])par[x] = y;
        else{
            par[y] = x;
            if(ran[x] == ran[y])ran[x]++;
        }
    }

    bool same(int x,int y){
        return find(x) == find(y);
    }
};

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

    UF uf1;
    uf1.init(n);
    for(int i = 0;i < k;i++){
        int p,q;
        cin >> p >> q;
        p--,q--;
        uf1.unite(p,q);
    }

    UF uf2;
    uf2.init(n);
    for(int i = 0;i < l;i++){
        int p,q;
        cin >> p >> q;
        p--,q--;
        uf2.unite(p,q);
    }

    map<pair<int,int>,int> cnt;
    for(int i = 0;i < n;i++){
        int a = uf1.find(i); 
        int b = uf2.find(i);
        cnt[make_pair(a,b)]++;
    }

    for(int i = 0;i < n;i++){
        int a = uf1.find(i);
        int b = uf2.find(i);
        cout << cnt[make_pair(a,b)] << endl;
    }
}


Measured memory_bytes: 15232
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)

#include <bits/stdc++.h>
using namespace std;



int main() {
    string S,T;

    cin >> S >> T;
    for(int i=0; i<S.size(); i++){
        if(S[i] != T[i]){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}


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

int N, L;
pair<int, int> pees[200+9];
int main(){
    scanf("%d %d", &N, &L);
    for(int i=0;i<N;i++) pees[i].first = abs(L+(i+1)-1), pees[i].second=((L+(i+1)-1 < 0) ? -1 : 1);
    sort(pees, pees+N);
    long long ans=0;
    for(int i=1;i<N;i++) ans += pees[i].first*pees[i].second;
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
  let stdin = stdin();
  let stdin = stdin.lock();
  let token: String = stdin
    .bytes()
    .map(|c| c.expect("failed to read char") as char)
    .skip_while(|c| c.is_whitespace())
    .take_while(|c| !c.is_whitespace())
    .collect();
  token.parse().ok().expect("failed to parse token")
}

use std::cmp::{max, min};
use std::collections::HashMap;

fn main() {
  let a = read::<String>();
  let b = read::<String>();

  let a_len = a.len();
  let b_len = b.len();

  let a_char: Vec<char> = a.chars().collect();
  let b_char: Vec<char> = b.chars().collect();
  let mut ans = "";

  if a_len < b_len {
    ans = "LESS"
  } else if b_len < a_len {
    ans = "GREATER"
  } else {
    for i in 0..a_len {
      if a_char[i] == b_char[i] {
        if i == a_len - 1 {
          ans = "EQUAL";
          break;
        }
        continue;
      } else {
        if a_char[i].to_digit(10).unwrap() < b_char[i].to_digit(10).unwrap() {
          ans = "LESS"
        } else {
          ans = "GREATER"
        }
        break;
      }
    }
  }

  println!("{}", ans);

}

Measured memory_bytes: 4352
#include <iostream>
#include <cmath>
#include <queue>

using namespace std;

struct Info{
	int num, cost;
	Info(int n1, int n2){
		num = n1;
		cost = n2;
	}

};

int main(){
	int h, w;
	cin >> h >> w;

	int c[10][10];
	for(int i = 0; i < 10; i++){
		for(int j = 0; j < 10; j++){
			cin >> c[i][j];
		}
	}

	int change[10];
	for(int i = 0; i < 10; i++){
		change[i] = 1000;
	}

	change[1] = 0;

	queue<Info> que;
	for(int i = 0; i < 10; i++){
		if(i == 1)continue;
		que.push(Info(i, c[i][1]));
	}

	while(!que.empty()){
		Info info = que.front();
		que.pop();
		int num = info.num;
		int cost = info.cost;

		if(change[num] <= cost)continue;
		change[num] = cost;

		for(int i = 0; i < 10; i++){
			if(num == i)continue;
			que.push(Info(i, cost + c[i][num]));
		}
	}


	int ans = 0;
	for(int i = 0; i < h; i++){
		for(int j = 0; j < w; j++){
			int in;
			cin >> in;
			if(in == -1)continue;
			ans += change[in];
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 764
#include <algorithm>
#include <array>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
using ll=long long int;
using vi=vector<int>;
using vl=vector<ll>;
using vs=vector<string>;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORR(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define RANGE(i,a,b) for(int i=(a);i<=(b);i++)
#define RANGER(i,a,b) for(int i=(b);i>=(a);i--)
#define REP(i,n) FOR(i,0,n)
#define REPR(i,n) FORR(i,0,n)

#define EVALe 1

#ifdef EVAL
#define LOG(i) 0
#else
#define LOG(i) cerr<<#i<<": "<<i<<endl
#endif

void solve(){
	ll H,cnt=1,ans=0;
	for(cin>>H;H>0;H/=2,cnt*=2){
		ans+=cnt;
	}
	cout<<ans<<endl;
	//cout<<(H<=0?"Yes":"No")<<endl;
}
int main(){
	solve();
	return 0;
}

Measured memory_bytes: 256
N, K = map(int, input().split())
R, S, P = map(int, input().split())
cpu = [c for c in input()]
point = 0
henkan = {'r':0, 's':1, 'p':2}
haiten = [P, R, S]
for i in range(K):
    count = 1
    j = i
    while j < N - K:
        if cpu[j] == cpu[j + K]:
            count += 1
        else:
            point += haiten[henkan[cpu[j]]] * ((count + 1) // 2)
            count = 1
        j += K
    point += haiten[henkan[cpu[j]]] * ((count + 1) // 2)
print(point)

Measured memory_bytes: 4212
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>

using namespace std;
int N;
int a[120000];
int j;
int kotae;



int main(){
	cin >> N;
	for(int i=0;i<N;i++){
		cin >> j;
		a[j]++;
		a[j+1]++;
		a[j+2]++;
	}
	for(int i=0;i<100010;i++){
		if (kotae<a[i]) kotae=a[i];
	}
	cout << kotae << endl;
	return 0;
}

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

using namespace std;

int n;
vector<int> vec;

void rec(int N, int M){
  if(N == 0){
    int size = vec.size();
    for(int i = 0 ; i < size ; i++){
      cout << vec[i] << (i != size-1 ? ' ' : '\n');
    }
  }else{
    for(int i = 0 ; i < M ; i++){
      if(N - M + i >= 0){
        vec.push_back(M-i);
        rec(N - M + i, M - i);
        vec.pop_back();
      }
    }
  }
}

int main(){

  while(cin >> n, n){
    rec(n, n);
  }

  return 0;
}

Measured memory_bytes: 1216
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
 
def main():
    a, b, c, d = map(int, input().split())
    while 1:
        c -= b
        if c <= 0:
            break
        a -= d
        if a <= 0:
            break
    if a <= 0:
        print('No')
    else:
        print('Yes')
if __name__ == '__main__':
    main()


Measured memory_bytes: 9120
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <utility>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>


using namespace std;

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


int main() {
	ll n,hp;
	cin >> n >> hp;
	//vector<pair<int, int> > katana0;
	vector<ll> katana1;

	ll a_max = 0;
	for(int i = 0; i < n; i++) {
		ll a, b;
		cin >> a >> b;
		//katana0.push_back(make_pair(a, b));
		a_max = max(a, a_max);
		katana1.push_back(b);
	}
	//sort(katana0.begin(), katana0.end());
	sort(katana1.rbegin(), katana1.rend());
	
	ll count = 0;

	for (int i = 0; i < n; i++) {
		int cur = katana1[i];
		if (cur <= a_max) break;

		hp -= cur;
		count++;
		if (hp <= 0) {
			cout << count << endl;
			return 0;
		}
	}

	cout << count + ((hp + a_max - 1) / a_max) << endl;
	return 0;
}

Measured memory_bytes: 1400
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<random>
#include <iomanip>

//使い方がよくわからない
#include<stack>
#include<queue>
#include<bitset>
#include<sstream>

#define rep(i,n) for(int i=0;i<(n);i++) 
#define rep1(i,n) for(int i=1;i<(n);i++)
#define co(x) cout << x << endl
#define cosp(x) cout << x << " "

using namespace std;
using ll = long long;

int main(int argc, const char *argv[]){
    int n;
    cin >> n ;
    vector<int> x(n),y(n);
    rep(i,n) cin >> x[i] >> y[i];
    double ans = 0;
    rep(i,n-1){
        for(int j=i+1;j<n;j++){
            ans += sqrt((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j]))*2/(double)(n);
        }
    }
    std::cout << std::fixed;
    std::cout << std::setprecision(10) << ans << endl;
    return 0;
}

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

#define ll long long
#define ld long double
#define pb push_back
#define eb emplace_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()

#define int long long
using namespace std;
const int INF = 2e16;
const int MOD = 1e9 + 7;
const int MB = 20;
const int K = 500;
const int maxN = 5001;

int bin_pow(int a, int b) {
	if (!b) return 1;
	if (b % 2) return a * bin_pow(a, b - 1) % MOD;
	int q = bin_pow(a, b / 2);
	return q * q % MOD;
}

vector<pair<int, int>> getDivs(int n) {
	vector<pair<int, int>> res;
	for (int d = 2; d * d <= n; d++) {
		if (n % d == 0) {
			int cnt = 0;
			while (n % d == 0) {
				n /= d;
				cnt++;
			}
			res.pb({ d, cnt });
		}
	}
	if (n > 1) res.pb({ n, 1 });
	return res;
}

void solve() {
	int n;
	cin >> n;
	vector<int> a(n);
	map<int, int> now;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		vector<pair<int, int>> d = getDivs(a[i]);
		for (auto& p : d) {
			now[p.first] = max(now[p.first], p.second);
		}
	}
	int lcm = 1;
	for (auto& p : now) {
		lcm = lcm * bin_pow(p.first, p.second) % MOD;
	}

	int ans = 0;
	for (int i = 0; i < n; i++) {
		ans += lcm * bin_pow(a[i], MOD - 2) % MOD;
		ans %= MOD;
	}

	cout << ans;
}

signed main() {
	/*
	freopen("search.in", "r", stdin);
	freopen("search.out", "w", stdout);
	*/
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	solve();
}

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

using namespace std;

long long ans, A, B;

int main(){
	cin >> A >> B;
	ans = 1001;
	for(int i = 1000; i >= 0; --i){
		if((long long)(0.08*i) == A && (long long)(0.1*i) == B){
			ans = i;
		}
	}
	if(ans != 1001) cout << ans << endl;
	else cout << -1 << endl;
}

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

int main() {
	long A, B, K;
	cin>>A>>B>>K;
	if(A<=K){
		K -= A;
		A = 0;
		if(B <= K){
			B = 0;
		}
		else {
			B -= K;
		}
	}
	else {
		A -= K;
	}
	cout<<A<<" "<<B<<endl;
}


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

int gcd(int a, int b){
	while(1){
		if(a<b){
			swap(a, b);
		}
		if(b == 0){
			break;
		}
		a %= b;
	}
	return a;
}

int main(){
	int N;
	cin >> N;
	int A[N];
	for(int i=0; i<N; i++){
		cin >> A[i];
	}
	int t = A[0];
	for(int i=1; i<N; i++){
		t = gcd(t, A[i]);
	}
	cout << t << endl;
	return 0;
}


Measured memory_bytes: 640
import java.util.Scanner;

public class Main {

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

		if (a >= 13) {
			System.out.println(b);
		} else if (a <= 5) {
			System.out.println(0);
		} else {
			System.out.println(b / 2);
		}

	}
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
using vstr=vector<string>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i=(s);i<(int)(n);i++)
#define _GLIBCXX_DEBUG
int main()
{
    int n,k;
    cin>>n>>k;
    vin h(n);
    rep(i,n)cin>>h[i];
    int sum=0;
    rep(i,n){
        if(h[i]>=k)sum++;
    }
    cout<<sum<<endl;
}

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

x, k, d = map(int, input().split())
x = abs(x)

ans = 0

if x > k*d:
  ans = x-k*d
else:
  p = x // d
  if (k-p) % 2 == 0:
    ans = x%d
  else:
    ans = d - x%d 
  

print(ans)

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

int main() {
  int N;
  cin>>N;
  
  vector<int> P(N);
  for(int i=0;i<N;i++){
    cin>>P.at(i);
  }
  
  vector<int> Q(N);
  for(int i=0;i<N;i++){
    cin>>Q.at(i);
  }
  vector<int> V(N);
  for(int i=1;i<N+1;i++){
    V.at(i-1)=i;
  }

  int cnt=0,cnta=0,cntb=0;
  do{
    if(V==P)
      cnta=cnt;
    if(V==Q)
      cntb=cnt;
     cnt++;
  }while(next_permutation(V.begin(),V.end()));
  
  cout<<abs(cntb-cnta)<<endl;
  
  return 0;
}

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

N, M = map(int, input().split())
graph = [[] for _ in range(N)]
for _ in range(M):
    a, b = map(int, input().split())
    graph[a-1].append(b-1)
    graph[b-1].append(a-1)


q = [0]
par = [-1]*N
par[0] = 0
while q:
    qq = []
    for p in q:
        for np in graph[p]:
            if par[np] == -1:
                par[np] = p+1
                qq.append(np)
    q = qq

print("Yes")
print(*par[1:], sep="\n")

Measured memory_bytes: 38292
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.Scanner;

public class Main {

	static Scanner scanner;

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

        double a=gd();
        double b=gd();
        double h=gd();
        double m=gd();

        //System.out.println("No");

        BigDecimal hk=BigDecimal.valueOf((h*60+m)/2);
        BigDecimal mk=BigDecimal.valueOf(m*6);
        BigDecimal k=BigDecimal.valueOf(Math.abs(hk.subtract(mk).doubleValue()));
        if (k.doubleValue()>180) k=BigDecimal.valueOf(360).subtract(k);
        k=BigDecimal.valueOf(Math.PI).multiply(k);
        k=k.divide(BigDecimal.valueOf(180), 11, RoundingMode.HALF_UP);
        double s=a*a+b*b;
        k=BigDecimal.valueOf(Math.cos(k.doubleValue()));
        k=k.multiply(BigDecimal.valueOf(a)).multiply(BigDecimal.valueOf(2*b));

        System.out.print(Math.sqrt(BigDecimal.valueOf(s).subtract(k).doubleValue()));
	}


	public static long d(long n) {
		String a=String.valueOf(n);
		return (long)a.length();
	}

	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}

	// doubleとして入力を取得
	public static double gd() {
		return Double.parseDouble(scanner.next());
	}
}

Measured memory_bytes: 36240
using System;

class Program
{
    static void Main()
    {
        var N = int.Parse(Console.ReadLine());
        var S = Console.ReadLine();

        var l = 0;
        var r = N - 1;
        var result = 0;

        while (true)
        {
            if (r <= l)
            {
                break;
            }
            if (S[l] == 'R')
            {
                l++;
            }
            else if (S[r] == 'W')
            {
                r--;
            }
            else
            {
                l++;
                r--;
                result++;
            }
        }
        Console.WriteLine(result);
    }
}


Measured memory_bytes: 28220
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

int main(){
    int n;
    cin>>n;
    vector<pair<long long, long long>> p(n);
    for(int i=0;i<n;++i){
        long long x,l;
        cin>>x>>l;
        p[i]=make_pair(x+l,x-l);
    }

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

    int ans=0;
    int crt=-1e9+1;
    for(int i=0;i<n;++i){
        if(p[i].second>=crt){
            crt=p[i].first;
            ++ans;
        }
    }

    cout<<ans<<endl;
} 

Measured memory_bytes: 1792
import Data.List

main = do
  getLine
  a <- getLine >>= return . sum . map (\(x,y) -> if x<=y then y-x else y) . f . sort . map read . words :: IO Int

  print a

  where
    f [] = []
    f xs@(x:rest) = (x, len) : f (drop len xs)
      where
        r = takeWhile (==x) xs
        len = length r


Measured memory_bytes: 39548
#include <iostream>
#include <numeric>
#include <cmath>
#include <limits>
#include <stdio.h>
#include <iomanip>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
using ll = long long;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
ll Max(ll(a), ll(b), ll(c)) {
	return max(max(a, b), c);
}
ll Min(ll(a), ll(b), ll(c)) {
	return min(min(a, b), c);
}





int main() {

	ll N;
	
	cin >> N;


	cout << 8-(N-400)/200 << endl;

	
}


Measured memory_bytes: 3592
#include<iostream>
#include<string>
#include<queue>
#include<map>
#include<vector>
#include <cstdlib>
#include<algorithm>
#include <cstdio>
#include <cctype>
using namespace std;
const long long INF=1000000000LL;
typedef long long ll;
typedef pair<int,string> P;
ll N,M,K;
ll A,B,C,T;
ll S[3005];
string str;
string n[100002];
map<string,int> m;
int main(){
	cin>>A>>B>>C;
	if(A<=C&&C<=B){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
	return 0;
}


Measured memory_bytes: 1024
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

fn main(){
    let a:i64 = read();
    let b : i64 = read();
    let h : i64 = read();
    let ans = (a + b) * h /2 ;
    println!("{}",ans );
}

Measured memory_bytes: 4352
//#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<set>
#include<map>

/*
#include<boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/rational.hpp>
namespace mp = boost::multiprecision;
using Real = mp::number<mp::cpp_dec_float<1024>>;
using Bint = mp::cpp_int;
*/

using namespace std;

#define int long long
#define REP(i,s,e) for((i)=(s);(i)<(e);(i)++)
#define RREP(i,s,e) for((i)=((s)-1);(i)>=(e);(i)--)
#define FOR(i,n) for((i)=(0);(i)<(n);(i)++)
#define RFOR(i,n) for((i)=((n)-1);(i)>=(0);(i)--)
#define MOD 1000000007


signed main(){
    int A,B,K;
    cin>>A>>B>>K;
    cout<<min(K,B/A)<<endl;
}


Measured memory_bytes: 3564
#define ll long long
#define lld long double
#define cn(n)  ll n;cin >> n;
#define tes(t) ll t;cin>>t;while(t--) 
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define rep(i, a, b) for (int i = a; i <= b; i++)
#define repd(i, a, b) for (int i = a; i >= b; i--)
#define pii pair<int, int>
#define pll pair<ll, ll>
#define al(v) v.begin(), v.end()
#define oset(X) tree<X, null_type, less<X>, rb_tree_tag, tree_order_statistics_node_update>
#define roset(X) tree<X, null_type, greater<X>, rb_tree_tag, tree_order_statistics_node_update>
const ll MOD = 1000 * 1000 * 1000 + 7;
const ll INF = 1ll * 1000 * 1000 * 1000 * 1000 * 1000 * 1000 + 7;
const ll MOD2 = 998244353;
const long double PI = 3.141592653589793;
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>
using namespace __gnu_pbds;
using namespace std;
ll power(ll x, ll y, ll p){ll res = 1;x %= p;while (y > 0){if (y & 1)res = (res * x) % p;y = y >> 1;x = (x * x) % p;}return res;}
ll po(ll base, ll powerRaised){if (powerRaised != 0)return (base * po(base, powerRaised - 1));else return 1;}
ll gcd(ll a, ll b){if (b == 0)return a;return gcd(b, a % b);}
ll lcm(ll a, ll b){return (a * b) / gcd(a, b);}
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
// #ifndef ONLINE_JUDGE
//   freopen("input.txt", "r", stdin);
//   freopen("output.txt", "w", stdout);
// #endif //*
  // tes(t)
  // {
  // }
  string s;
  cin>>s;
  int n=s.length();
  ll ans=0;
  rep(i,0,n-1)
  {
    int dig=s[i]-'0';
    ans=(ans+dig)%9;
  }
  if(ans%9==0)
  cout<<"Yes";
  else cout<<"No";

}


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

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class T> inline T sqr(T x) {return x*x;}

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

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair
#define each(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define exist(s,e) ((s).find(e)!=(s).end())
#define range(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  range(i,0,n)
#define clr(a,b) memset((a), (b) ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const double eps = 1e-10;
const double pi  = acos(-1.0);
const ll inf =1LL << 62;

ll gcd (ll a,ll b){
	if(b==0) return a;
	return gcd (b,a%b);
}

ll lcm(ll a,ll b){
	return a/gcd(a,b)*b;
}

int main(void){
	int n;
	ll runner[10][2];
	ll change[10];
	ll ans[10];
	while(cin >> n,n){
		rep(i,n) cin >> runner[i][0] >> runner[i][1];  // d // v
		//gcd
		rep(i,n) {
			ll tmp=gcd(runner[i][0],runner[i][1]);
			runner[i][0]/=tmp;
			runner[i][1]/=tmp;
		}
		// lcm
		ll l=runner[0][0];
		rep(i,n-1) l=lcm(l,runner[i+1][0]);
		rep(i,n) ans[i]=l/runner[i][0]*runner[i][1];
		
		// gcd
		ll g=ans[0];
		rep(i,n-1) g=gcd(g,ans[i+1]);
		rep(i,n) ans[i]/=g;
		
		rep(i,n) cout << ans[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 1164
#include <stdio.h>
int main(void){
	int a,b[1001],c,i,j,x,k;
	scanf("%d",&a);
	for(i=0;i<a;i++)
		scanf("%d",&b[i]);
	for(i=0;i<a;i++){
		if(i==0)
			goto out;
		for(j=i-1;j>=0;j--){
			if(b[j] > b[j+1]){
				c = b[j];
				b[j] = b[j+1];
				b[j+1] = c;
			}
		}
		out:
		for(k=0;k<a;k++){
			printf("%d",b[k]);
			if(k!=a-1)
				printf(" ");
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 608
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 50;
 
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
using namespace std;
 
void solve(){
    double n;
    cin>>n;
    cout<<((int)(n+1)/2)/n<<endl;
}
 
signed main(){
	std::ios::sync_with_stdio(false);
    std::cin.tie(0);
	solve();
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
using namespace std;
char s[100010];
int n,sum;
int main()
{
	scanf("%s",s+1);
	n=strlen(s+1);
	for (int i=2;i<=n;i++)
		if (s[i]!=s[i-1])
			sum++;
	printf("%d",sum);
	return 0;
}

Measured memory_bytes: 256
def check(si, xs, checked):
    q = {si}
    while q:
        i = q.pop()
        xi = xs[i]
        for j, d in links[i]:
            if checked[j]:
                continue
            if j not in xs:
                xs[j] = xi + d
            elif xi + d != xs[j]:
                return False
            q.add(j)
        checked[i] = True
    return True


def solve():
    checked = [False] * n
    for i in range(n):
        if not checked[i]:
            xs = {}
            xs[i] = 0
            if not check(i, xs, checked):
                return False
    return True


n, m = map(int, input().split())
links = [set() for _ in range(n)]
for _ in range(m):
    l, r, d = map(int, input().split())
    l -= 1
    r -= 1
    links[l].add((r, d))
    links[r].add((l, -d))
print('Yes' if solve() else 'No')


Measured memory_bytes: 95956
from math import gcd
n = int(input())
a = [int(i) for i in input().split()]

g = a[0]
for i in range(n):
    g = gcd(g,a[i])
if g != 1:
    print("not coprime")
    exit()

s = set(a)
a.sort()
m = a[-1]
isPrime = [False]*(m+1)
for i in range(2,m+1):
    if isPrime[i]: continue
    flag = False
    for j in range(i,m+1,i):
        isPrime[j] = True
        if j in s:
            if flag:
                print("setwise coprime")
                exit()
            flag = True
print("pairwise coprime")

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

int main(void)
{
  int i,o = 0,x = 0;
  char s[16];
  scanf("%s",s);
  for(i = 0;i < strlen(s);i++) {
    if(s[i] == 'o') o++;
    else if(s[i] == 'x') x++;
  }

  if((15 - strlen(s)) + o >= 8) printf("YES\n");  
  else printf("NO\n"); 
  
  return 0;
}

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

typedef long long int ll;
#define pll pair <ll, ll>
#define pii pair <int, int>
#define f first
#define s second
#define pb push_back
#define vll vector <ll> 
#define mll map <ll ,ll> 
#define prtq  priority_queue <long long>
#define rep(a,b) for(i=a;i<b;i++) 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define inf 1e18
using namespace std;
#define Mod 1000000007
////////////////////////////////////////////////////////////////////

void fio()
{
#ifndef ONLINE_JUDGE
freopen("input1.txt", "r", stdin);
freopen("output1.txt", "w", stdout);
#else
#endif
}

void tim()
{
   #ifndef ONLINE_JUDGE
   cerr << "Time elapsed: " << clock() / 1000 << " ms" << endl;
   #endif
}

int sumofdigit(ll n){
  ll temp=n; int sum=0;
   while(temp){
      sum+=temp%10;
      temp/=10;
    }
    return sum;
}



int main()
{
  fio();  
   IOS; 
    
  int t=1;
// cin>>t;
  while(t--){
    ll n,k;
    cin>>n>>k;
    vll h(n+1);
    int i;
    rep(1,n+1)cin>>h[i];

    vll dp(n+1,0);

    int j;
    for(i=2;i<=n;i++)
    {   
        ll temp=10000000000000;
      for(j=1;j<=k;j++){
        if(j<i)temp=min(temp,dp[i-j]+abs(h[i]-h[i-j]));
      }
      dp[i]=temp;
    }

    cout<<dp[n];


    
 }

   tim();
    return 0; 
 
}

// //
// 199
// 200
// 500
// 1000

// 112
// 120

Measured memory_bytes: 4720
#include<stdio.h>

int main(){
	
	//配列S,cntの用意
	char s[4];
	int cnt[4];
	scanf("%s" ,s);
	for(int i = 0; i < 4; i++){
		cnt[i] = 0;
	}
	//同じ文字が何回出てくるかカウント
	for(int i = 0; i < 4; i++){
		for(int j = 0; j < 4; j++){
			if(s[i] == s[j]){
				cnt[i]++;
			}
		}
	}
	//カウントが２かどうかチェック
	int flg = 0;
	for(int i = 0; i < 4; i++){
		if(cnt[i] != 2){
			flg = 1;
		}
	}
	//表示
	if(flg == 0){
		printf("Yes\n");
	}else{
		printf("No\n");
	}

	return 0;
}

Measured memory_bytes: 128
#include <iostream>
using namespace std;
int main(){
  int N;
  cin >> N;
  long long int s1 = 0, s2 = 0, ans[] = {0, 0};
  //s1 = + - + - ...
  //s2 = - + - + ...
  long long int a, b;
  for(int i = 0; i < N; ++i){
    cin >> a;
    b = a;
    if(i%2){
      s1 += a;
      s2 += a;
      if(s1 >= 0){
        ans[1] += s1 + 1;
        a -= s1 + 1;
        s1 = -1;
      }
      if(!a){
        --a;
        --s1;
        ++ans[1];
      }
      if(s2 <= 0){
        ans[0] -= s2 - 1;
        b -= s2 - 1;
        s2 = 1;
      }
      if(!b){
        ++b;
        ++s2;
        ++ans[0];
      }
    }else{
      s1 += a;
      s2 += a;
      if(s2 >= 0){
        ans[0] += s2 + 1;
        a -= s2 + 1;
        s2 = -1;
      }
      if(!a){
        ++ans[0];
        --a;
        --s2;
      }
      if(s1 <= 0){
        ans[1] -= s1 - 1;
        b -= s1 - 1;
        s1 = 1;
      }
      if(!b){
        ++ans[1];
        ++b;
        ++s1;
      }
    }
  }
  cout << min(ans[0], ans[1]) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#define ll unsigned long long
#define ull unsigned long long
#define dd double
#define oo 1001007000
#define ff float
#define ooo 1000000100000000000
#define iii pair<ll,ll>
#define vii vector<ll>
#define viii vector<iii>
#define sss pair<str,str>
#define str string
#define sii set<ll>
#define siii set<iii>
#define st size_t
#define r0 return 0
#define pb push_back
#define sz size
using namespace std;

const char E='\n';
const int N=105;
const int NN=1000001;
const ll md=998244353;



int main(){
    cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0);
    int n,m;
    cin >> n >> m;
    int a[N][N]={0};
    int dp[N][N]={0};
    for (int i=1;i<=n;i++){
        for (int j=1;j<=m;j++){
            char z;
            cin >> z;
            if (z=='#')a[i][j]=1;
        }
    }
    dp[1][1]=a[1][1];
    //cout << dp[1][1] << " ";
    for (int i=1;i<=n;i++){
        for (int j=1;j<=m;j++){
            if (i+j==2)continue;
            int q1=oo;
            int q2=oo;
            if (i>=2){
                if (a[i][j]==a[i-1][j]){
                    q1=dp[i-1][j];
                }else
                    q1=dp[i-1][j]+a[i][j];
            }
            if (j>=2){
                if (a[i][j]==a[i][j-1]){
                    q2=dp[i][j-1];
                }else
                    q2=dp[i][j-1]+a[i][j];
            }
            dp[i][j]=min(q1,q2);
            //cout << dp[i][j] << " ";

        }
        //cout << E;
    }
    cout << dp[n][m] << E;
    r0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int main () {
    ll n;
    cin >> n;
    
    ll sum = 0;
    for(ll i = 0; i <= n; i++) {
        if( (i%3!= 0)  && (i%5!= 0)) {
            sum += i;
        }
    }


    cout << sum << endl;

}

 


Measured memory_bytes: 3636
#include <bits/stdc++.h>
 
using namespace std;
 
#define rep(i, n) for(int i=0; i<(n); i++)
#define FOR(i, m, n) for(int i=(m);i<(n);i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define RSORT(x) sort((x).rbegin(),(x).rend())
#define REVE(x) reverse((x).begin(),(x).end())
#define mp make_pair
#define pb push_back
#define chmax(x,y) x = max(x,y)

 
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<vector<int> > VVI;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<bool> VB;
typedef vector<LL> VL;
typedef vector<vector<long long>> VVLL;
typedef vector<set<int>> VSI;
const int MOD = 1e9+7;
const int INF = 1e9;
const LL LINF = 1e18;
int gcd(int a, int b)
{
   if (a%b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a%b));
   }
}

int lcm(int a, int b)
{
   return a * b / gcd(a, b);
}
struct UnionFind {
    VI d;
    UnionFind(int n = 0): d(n,-1) {}
    int find(int x) {
        if(d[x] < 0) return x;
        return d[x] = find(d[x]);
    }
    bool unite(int x,int y) {
        x = find(x); y = find(y);
        if(x == y) return false;
        if(d[x] > d[y]) swap(x,y);
        d[x] += d[y];
        d[y] = x;
        return true;
    }
    bool same(int x,int y) { return find(x) == find(y); }
    int size(int x) { return -d[find(x)]; }
};
int deg[100005];
VI to[100005];

struct mint {
  LL x; // typedef long long ll;
  mint(LL x=0):x((x%MOD+MOD)%MOD){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += MOD-a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= MOD;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(LL t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
 
  // for prime mod
  mint inv() const {
    return pow(MOD-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

mint f(int n) {
    if(n == 0) return 1;
    mint x = f(n/2);
    x *= x;
    if(n%2 == 1) x *= 2;
    return x;
}

mint choose(int n,int a) {
    mint x = 1, y = 1;
    rep(i,a) {
        x *= n-i;
        y *= i+1;
    }
    return x/y;
}

int main() {
    int n;
    string s;
    cin >> n >> s;
    int ans = 0;

    rep(i,n-2) {
      if(s[i]=='A' and s[i+1] == 'B' and s[i+2] == 'C') ans++;
    }

    cout << ans << endl;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
//#define vi vector<int>
#define vb vector<bool>
#define pii pair<int, int>
#define mii map<int, int>
#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define tr(container, it) for (typeof(container.begin()) it = container.begin(); it != container.end(); it++)
#define gcd(a, b) __gcd(a, b)
#define lcm(a, b) (a * b) / gcd(a, b)
#define inf (long long)1e18
#define F first
#define S second
#define SZ(x) ((int)(x).size())
//#define rep(i, n) for (int i = 0; i < n; i++)
//#define repd(i,n) for(int i=n-1;i>=0;i--)
//#define rep1(i,n) for(int i=1;i<=n;i++)
const int N = 1e9 + 7;

int pow(int x, int y)
{
    int res = 1;
    while (y > 0)
    {
        if (y & 1)
            res = ((res) * (x));
        res %= N;
        y = y >> 1;
        x = ((x) * (x));
    }
    return res;
}
int powm(int x, int y, int p)
{
    int res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return res;
}

int gcd(int a, int b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
ll mxn(ll a, ll b)
{
    if (a > b)
        return a;
    else
    {
        return b;
    }
}

void solve()
{
    float n, x;
    int t;
    cin >> n >> x >> t;
    float p = n / x;
    int q = n / x;
    if (p > q)
    {
        q++;
    }

    cout << q * t;
}

int32_t main()

{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    // int t;
    // cin >> t;
    // while (t--)
    // {
    solve();
    // }
}

Measured memory_bytes: 3736
using System;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
        string[] ab = Console.ReadLine().Split(' ');
        int a = int.Parse(ab[0]);
        int b = int.Parse(ab[1]);
        for (int i = 13; i <= 1000; i++)
        {
            int at = i * 8 / 100;
            int bt = i / 10;
            if (at == a && bt == b)
            {
                Console.WriteLine(i);
                return;
            }
        }
        Console.WriteLine(-1);
    }
}

Measured memory_bytes: 13140
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

bool check(const vector<int>& a, int ignore, int M){
	if(a[ignore] >= M) return true;
	vector<int> reach(M-a[ignore], 0);
	reach[0] = 1;
	for(int i=0;i<a.size();i++){
		if(i == ignore) continue;
		for(int j=reach.size()-1;j>=0;j--){
			if(!reach[j]) continue;
			int nxt = j + a[i];
			if(M - a[ignore] <= nxt && nxt < M) return true;
			if(nxt < reach.size()) reach[nxt] = 1;
		}
	}
	return false;
}

int main(){
	int N, M;
	while(cin >> N >> M){
		vector<int> a(N);
		for(int& t : a) cin >> t;
		sort(a.begin(), a.end());
		int L = -1, R = N;
		while(R-L > 1){
			int mid = (L+R)/2;
			if(check(a, mid, M)){
				R = mid;
			} else {
				L = mid;
			}
		}
		cout << R << endl;
	}
}


Measured memory_bytes: 256
N = int(input())
nums = [i for i in map(int, input().split())]
nums = sorted(nums)
max = nums[-1]
dp = [1]*(max+1)
ans = 0

for i in range(len(nums)-1):
    p = nums[i]
    if dp[p] ==1:
        for q in range(max//p+1):
            dp[p*q]=0
        if nums[i] != nums[i+1]:
            ans+=1
if dp[max]==1:
    ans+=1
print(ans)

Measured memory_bytes: 32116
#include <bits/stdc++.h>
using namespace std;
//#define _GLIBCXX_DEBUG //GCC5.4.1で配列の範囲外アクセスをエラーにする

//cmdで g++ test.cpp とするとコンパイルできる
//制限1秒なら10^6は余裕 10^7は多分間に合う 10^8はよほど単純でないと厳しい

typedef long long ll; //long long
typedef pair<int,int> pii; //pair<int,int>

const int MOD=1000000007; //10^9+7
const double PI=3.1415926535;

int main(){
    int N;
    cin>>N;
    double sum;
    for(int i=0;i<N;i++){
        double r;
        cin>>r;
        sum+=1.0/r;
    }
    cout<<setprecision(10)<<1.0/sum<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cmath>
#include <vector>
#define ll long long int
#define mp make_pair
#define pb push_back
#define vi vector<int>
using namespace std;
struct objects{
    int weight,value;
};
ll solve(){
   int n,w;
   cin>>n>>w;
   objects object[n];
   int totalvalue=0;
   for(int i=0;i<n;i++){
       cin>>object[i].weight>>object[i].value;
       totalvalue+=object[i].value;
   }
   ll dp[n+1][totalvalue+1];
    //dp[i][j] denotes the least weight to get a value of
   // j from the first i objects
   dp[0][0]=0;//It takes 0 weight here
   int ans=0;
   for(int i=1;i<=totalvalue;i++){
       dp[0][i]=1e18;
      // Just set it arbitrarily large
       //because it's not possible 
   }
   for(int i=0;i<n;i++){
       for(int j=0;j<=totalvalue;j++){
           if(j>=object[i].value){
                dp[i+1][j]=min(dp[i][j],dp[i][j-object[i].value]+object[i].weight);
                //Either don't choose this object(dp[i][j]) or choose this object
                //The value without it would be j-object[i].value
                //the minimum weight would be the minimum weight needed to
                //get a value of j- object[i].value and add the weight of this object.
           }
           else{
               //If I choose this object the value will go over j
               dp[i+1][j]=dp[i][j];
           }
           if(dp[i+1][j]<=w){//Is it possible to get value of j in less than w weight
               ans=max(ans,j);//Find maximum such j
           }
       }
   }
   return ans;
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout<<solve();
}


Measured memory_bytes: 82492
#include<iostream>
using namespace std;
#define lli unsigned long long int
#include<bits/stdc++.h>
bool primer(lli p){
  if(p==1)
    return false;
  for(lli i=2;i*i<=p;i++){
    if(p%i==0)
      return false;
  }
  return true;
}
int main(){
  lli n,k;
  cin>>n;
  k=n;
  while(!primer(k))k++;
  cout<<k<<"\n";
  return 0;
}

Measured memory_bytes: 256
from itertools import product
n=int(input())
XY=[]
ans=0
for i in range(n):
    a=int(input())
    B=[]
    for _ in range(a):
        x,y=map(int,input().split())
        B.append([x-1,y])
    XY.append(B)
seigo = list(product([1,0],repeat=n))
for i in range(2**n):
    kumiawase = seigo[i]
    ninzu = sum(kumiawase)
    flag=0
    for j in range(n):#j+1人目の発言検証
        if kumiawase[j]==1:#正直者パターン
            for a, b in XY[j]:
                if b==1:
                    if kumiawase[a]==1:
                        flag+=0
                    else:
                        flag=1
                else:
                    if kumiawase[a]==0:
                        flag+=0
                    else:
                        flag=1
    if flag==0:
        ans=max(ans,ninzu)
print(ans)

Measured memory_bytes: 8820
#include<stdio.h>


void swap( int *a ,int *b )
{
	*a = *a + *b ;
	*b = *a - *b ;
	*a = *a - *b ;
}


#define W_ 30


int Ameda[ W_ + 1 ] ;


int main( void )
{
	int W ,N ;
	scanf( "%d %d" ,&W ,&N ) ;

	int i ;
	for( i = 1 ; i <= W ; ++i )
	{
		Ameda[ i ] = i ;
	}

	for( i = 0 ; i < N ; ++i )
	{
		int a ,b ;
		scanf( "%d,%d" ,&a ,&b ) ;

		swap( &Ameda[ a ] ,&Ameda[ b ] ) ;
	}

	for( i = 1 ; i <= W ; ++i )
	{
		printf( "%d\n" ,Ameda[ i ] ) ;
	}

	return 0 ;
}


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

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;

#define REP(k, n) for (ll k = 0; k < (ll)(n); ++k)
#define REPREV(k, n) for (ll k = (ll)(n)-1; k >= 0; --k)
#define FOR(k, a, b) for (ll k = (ll)(a); k < (ll)(b); ++k)
#define FORREV(k, a, b) for (ll k = (ll)(b)-1; k >= (ll)(a); --k)
#define FOREACH(e, v) for (auto& e : v)

#define TGET(t, i) get<i>(t)
#define TSET(t, i, a) get<i>(t) = a
// MinHeap - priority_queue<ll, vll, greater<ll>> pq;

#define EVEN(n) ((n)&1) == 0
#define ODD(n) ((n)&1) == 1

#define SORT(v) sort(v.begin(), v.end())
#define SORTREV(v) sort(v.rbegin(), v.rend())
#define SHUFFLE(v) random_shuffle(v.begin(), v.end())
//srand(unsigned(time(0)));

#define REMOVEAT(v, i) v.erase(v.begin() + i)
#define REVERSE(v) reverse(v.begin(), v.end())
#define UNIQUE(v) \
    SORT(v);      \
    v.resize(distance(v.begin(), unique(v.begin(), v.end())))

ostream& operator<<(ostream& str, const pll& p) {
    str << p.first << " " << p.second;
    return str;
}

template <typename T>
void join(T& arr, string sep) {
    bool first = true;
    for (auto t : arr) {
        if (first) {
            first = false;
            cout << t;
        } else {
            cout << sep << t;
        }
    }
    cout << "\n";
}

const ll md = 1e9 + 7;
ll MOD(ll x) {
    ll r = x % md;
    if (r < 0) {
        r += md;
    }
    return r;
}

#define POS "POSSIBLE"
#define IMPOS "IMPOSSIBLE"

// #define INF DBL_MAX
// #define INF LLONG_MAX
// #define MINF LLONG_MIN
#define INF 1e18
#define MINF -INF

void solve() {
    ll n;
    cin >> n;
    ll res = 0;
    cout << 1 - n << endl;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int tt = 1;
    // cin >> tt;
    for (int t = 1; t <= tt; t++) {
        // cout << "Case #" << t << ": ";
        solve();
    }
    //cin.rdbuf()->in_avail()
    return 0;
}

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

using namespace std;

#define ll long long
#define X first
#define Y second
#define all(x) x.begin(), x.end()

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
	enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
	ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
	*this << "[";
	for (auto it = d.b; it != d.e; ++it)
		*this << ", " + 2 * (it == d.b) << *it;
	ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

const int mod = (int)1e9 + 7;
const int MX = (int)1e5 + 10;

void add_self(int &x, int y){x += y; if(x >= mod) x -= mod;}
void sub_self(int &x, int y){x -= y; if(x < 0) x += mod;}
void mul(int &x, int y){x = x * 1LL * y % mod;}


int main(){

	cin.tie(0); cout.tie(0);
	ios_base::sync_with_stdio(0);

	int x, y;
	cin >> x >> y;

	int base = 100000;

	ll res = 0;

	if(x <= 3) res += (4 - x) * base;
	if(y <= 3) res += (4 - y) * base;

	if(x == 1 && y == 1) res += 4 * base;

	cout << res << endl;

	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef signed long long ll;
typedef vector<int> vi;
 
#define REP(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define ALL(a) (a).begin(), (a).end()
#define out(a) cout << (a) << endl

int main(){
	int i,j,k,n,m,l,f,x,y,z; string s;
	cin >> n >> s;
	vi e(n), w(n);
	w[0]   = 0;
	e[n-1] = 0;
	f = 1000000;

	REP(i, 1, n){
		w[i] = w[i-1];
		if(s[i-1] == 'W') w[i] = w[i-1] + 1;

		e[n-i-1] = e[n-i];
		if(s[n-i] == 'E') e[n-i-1] = e[n-i] + 1; 
	}

	rep(i, n) f = min(f, w[i] + e[i]);

	out(f);
}

Measured memory_bytes: 3076
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
using namespace std;
#define ARRAY_MAX 1000000

string alpha = "abcdefghijklmnopqrstuvxxyz";

int main(){

    string s;
    cin >> s;
    //cout << s << endl;
    vector<char> a(ARRAY_MAX);
    vector<bool> alpha(26);

    for(int i = 0;i < s.length();i++){
        a[i] = s[i];
        //cout << a[i];
    }
    //cout << "h" << endl;


    for(int i = 0;i < alpha.size();i++){
        alpha[i] = false;
    }
    //cout << alpha.size();
    //cout << "j" << endl;
    

    for(int i = 0;i < s.length();i++){
        alpha[a[i]-'a'] = true;
    }
    //cout << "k" << endl;
    
    for(int i = 0;i < alpha.size();i++){
        //cout << "h" << endl;
        if(!alpha[i]){
            //cout << "a" << endl;
            cout << char(i+'a') << endl;
            return 0;
        }
    }

    cout << "None" << endl;

    



    return 0;
}

Measured memory_bytes: 1408