akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const long long INF = 1LL<<60;
const long long MOD = 1000000000+7;
#define rev(s) (string((s).rbegin(), (s).rend()))
// cout << fixed << setprecision(10) << ans << endl; 有効桁数指定
// *min_element(c + l, c + r) *max_element(c + l, c + r) 配列の中のmin-max
// int dx[8]={1,1,0,-1,-1,-1,0,1};
// int dy[8]={0,1,1,1,0,-1,-1,-1};
// int dx[4]={1,0,-1,0};
// int dy[4]={0,1,0,-1};
// ~ は、-1の時だけfalse

long long GCD(long long a, long long b) {
    if (b == 0) return a;
    else return GCD(b, a % b);
}

long long LCM(long long a, long long b) {
    return a / GCD(a, b) * b;
}

// ax + by = gcd(a, b) となるような (x, y) を求める
// 多くの場合 a と b は互いに素として ax + by = 1 となる (x, y) を求める
long long extGCD(long long a, long long b, long long &x, long long &y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    // 再帰的に解く (x, y を入れ替えておく)
    long long d = extGCD(b, a % b, y, x); 
    y -= a / b * x;
    return d;
}

// 素因数分解
vector<pair<long long, long long> > prime_factorize(long long N) {
    vector<pair<long long, long long> > res;
    for (long long a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;
        long long ex = 0;
        while (N % a == 0) {
            ++ex;
            N /= a;
        }
        res.push_back({a, ex});
    }
    if (N != 1) res.push_back({N, 1});
    return res;
}

//約数列挙
vector<long long> enum_divisors(long long N) {
    vector<long long> res;
    for (long long i = 1; i * i <= N; ++i) {
        if (N % i == 0) {
            res.push_back(i);
            // 重複しないならば i の相方である N/i も push
            if (N/i != i) res.push_back(N/i);
        }
    }
    // 小さい順に並び替える
    sort(res.begin(), res.end());
    return res;
}

ll a[100010];
ll s1[100010],s2[100010];


int main () {

    ll n,m;cin>>n>>m;

    string s,t;cin>>s>>t;

    ll l = LCM(n,m);

    if (n>m) {
        swap(n,m);
        swap(s,t);
    }

    bool ok=true;

    rep(i,n) {
        if (l/n*i%(l/m)==0) {
            if (s[i]!=t[(l/n*i)/(l/m)]) {
                ok=false;
                break;
            }
        }
    }

    if (ok) {
        cout<<l<<endl;
    } else {
        cout<<-1<<endl;
    }

}

Measured memory_bytes: 512
using System;

class Program
{
    static void Main(string[] args)
    {
        var n = int.Parse(Console.ReadLine());
        var x = new int[n];
        var y = new int[n];
        var h = new int[n];
        for (int i = 0; i < n; i++)
        {
            var s = Console.ReadLine().Split(' ');
            x[i] = int.Parse(s[0]);
            y[i] = int.Parse(s[1]);
            h[i] = int.Parse(s[2]);
        }

        for (int i = 0; i <= 100; i++)
        {
            for (int j = 0; j <= 100; j++)
            {
                var ans = 0;
                for (int k = 0; k < n; k++)
                {
                    if (h[k] != 0)
                    {
                        if (ans == 0)
                        {
                            ans = m1(i, j, x[k], y[k], h[k]);
                        }
                        else if (ans != m1(i, j, x[k], y[k], h[k]))
                        {
                            ans = 0;
                            break;
                        }
                    }
                }

                if (ans == 0) continue;

                for (int k = 0; k < n; k++)
                {
                    if (h[k] == 0)
                    {
                        if (m1(i, j, x[k], y[k], h[k]) < ans)
                        {
                            ans = 0;
                            break;
                        }
                    }
                }

                if (ans == 0) continue;

                Console.WriteLine($"{i} {j} {ans}");
                return;
            }
        }
    }

    public static int m1(int x1, int y1, int x2, int y2, int h)
    {
        return Math.Abs(x1 - x2) + Math.Abs(y1 - y2) + h;
    }
}

Measured memory_bytes: 13140
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")
}

fn main() {
    let n: usize = read();
    let mut prev = 0;
    let mut ans = 0;

    for i in 0..n {
        let ni = read();
        if ni > prev {
            ans += (ni - prev);
        }
        prev = ni;
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <cstdio>
int a,b,c,n,r;
int main()
{
    while(scanf("%d%d%d",&a,&b,&c),(a|b|c)) {
        a*=a;b*=b;c*=c;
        scanf("%d",&n);
        while(n--){
            scanf("%d",&r);
            r*=4*r;
            puts((a+b<r||b+c<r||c+a<r)?"OK":"NA");
        }
    }
    return 0;
}

Measured memory_bytes: 0
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<string>
#include<iostream>
typedef long long ll;
using namespace std;
int INF=10000;
int dp[1000][1000][100];

int main(){
    int n,ma,mb;cin>>n>>ma>>mb;
    int a[n+1],b[n+1],c[n+1];for(int i=1;i<=n;i++)cin>>a[i]>>b[i]>>c[i];
    
    for(int i=0;i<=400;i++)for(int j=0;j<=400;j++)for(int k=0;k<=n;k++)dp[i][j][k]=INF;
    dp[0][0][0]=0;
    for(int i=0;i<=400;i++)for(int j=0;j<=400;j++)for(int k=1;k<=n;k++){
        if(i<a[k]||j<b[k])dp[i][j][k]=dp[i][j][k-1];
        else dp[i][j][k]=min(dp[i][j][k-1],dp[i-a[k]][j-b[k]][k-1]+c[k]);
    }
    int min=INF;
    for(int i=1;i<=400/(max(ma,mb));i++){
        if(dp[i*ma][i*mb][n]<min)min=dp[i*ma][i*mb][n];
    }
    if(min==INF)cout<<"-1"<<endl;
    else cout<<min<<endl;
    return 0;
}


Measured memory_bytes: 156800
#include <bits/stdc++.h>
using namespace std;
struct ios_accelerate { ios_accelerate() { ios::sync_with_stdio(false); cin.tie(nullptr); } } CALL;

#define REP(i, n) for(auto (i) = (n)*0; (i) < (n); (i)++)
#define RNG(i, a, b) for(auto (i) = (a); (i) < (b); (i)++)
#define RBF(i, v) for(auto& (i) : (v))
#define ALL(x) (x).begin(), (x).end()

using LL = long long;
using UL = unsigned long;
using ULL = unsigned long long;
template<typename T> using V = vector<T>;
template<typename T> using VV = vector<vector<T>>;
template<typename T> using P = pair<T, T>;

const double PI = 3.141592653589793;
const int MOD = 1000000007;
const LL INF64 = static_cast<LL>(1e18) + 2;
const int INF = static_cast<int>(1e9) + 2;

template<typename T> inline void upsort(vector<T>& x) { sort(x.begin(), x.end()); }
template<typename T> inline void downsort(vector<T>& x) { sort(x.begin(), x.end(), greater<T>()); }
template<typename T> inline void col(T x) { cout << x << '\n'; }
template<> inline void col(double x) { cout << fixed << setprecision(12) << x << '\n'; }

signed main() {
	int n;
	cin >> n;
	V<int> x(n);
	RBF(xi, x) cin >> xi;
	auto sqr = [](int x) {return x * x; };

	int ans = INF;
	RNG(p, 1, 101) {
		int sum = 0;
		RBF(xi, x) {
			sum += sqr(xi - p);
		}
		ans = min(ans, sum);
	}
	col(ans);
	return 0;
}


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

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

  int n, q; cin >> n >> q;
  VI c(n); rep(i, n) cin >> c[i];
  vector<pair<int, int>> lr(q); rep(i, q) cin >> lr[i].first >> lr[i].second;
  rep(i, q) lr[i].first--;

  const int sq = 700;
  vector<tuple<int, int, int>> lri(q);
  rep(i, q) lri[i] = make_tuple(lr[i].first / sq, lr[i].second, i);
  sort(lri.begin(), lri.end());

  VI ans(q);

  VI cnt(n+1);
  int prev = -1;
  int lx, rx; lx = rx = get<0>(lri[0]);
  int sum = 0;
  VI changed;
  for (auto [ls, r, i] : lri) {



    // ここのコメントを外すとhandmade03-05, random06がWAになる

    // if (ls != prev) {
    //   for (auto cx : changed) cnt[cx] = 0;
    //   changed.clear();
    //   lx = rx = r;
    //   prev = ls;
    // }



    int l = lr[i].first;
    assert(r == lr[i].second);  // assert(rx <= r);
    int cx;
    while (lx > l) if (cnt[cx=c[--lx]]++ == 0) sum += 1;//, changed.push_back(cx);
    while (lx < l) if (--cnt[c[lx++]] == 0) sum -= 1;
    while (rx > r) if (--cnt[c[--rx]] == 0) sum -= 1;
    while (rx < r) if (cnt[cx=c[rx++]]++ == 0) sum += 1;//, changed.push_back(cx);
    ans[i] = sum;
  }
  rep(i, q) cout << ans[i] << "\n";
}


Measured memory_bytes: 19396
n = int(input())
if n == 4 or n == 7 or n == 8 or n == 11 or n == 12 or n == 14 or n == 15 or n == 16 or n == 18 or n == 19 or n == 20 or n == 21 or n == 22 or n == 23 or n == 24 or n == 25 or n == 26 or n == 27 or n == 28 or n == 29 or n == 30 or n == 31 or n == 32 or n == 33 or n == 34 or n == 35 or n == 36 or n == 37 or n == 38 or n == 39 or n == 40 or n == 41 or n == 42 or n == 43 or n == 44 or n == 45 or n == 46 or n == 47 or n == 48 or n == 49 or n == 50 or n == 51 or n == 52 or  n == 53 or n == 54 or n == 55 or n == 56 or n == 57 or n == 58 or n == 59 or n == 60 or n == 61 or n == 62 or n == 63 or n == 64 or n == 65 or n == 66 or n == 67 or n == 68 or n == 69 or n == 70 or n == 71 or n == 72 or n == 73 or n == 74 or n == 75 or n == 76 or n == 77 or n == 78 or n == 79 or n == 80 or n == 81 or n == 82 or n == 83 or n == 84 or n == 85 or n == 86 or n == 87 or n == 88 or n == 89 or n == 90 or n == 91 or n == 92 or n == 93 or n == 94 or n == 95 or n == 96 or n == 97 or n == 98 or n == 99 or n == 100:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
# ????°??????¨?????§????????????????????????????????????
while True:
    # n : num of judges
    n = int(input())
    if n == 0:
        break

    scores = []
    for i in range(n):
        scores.append(int(input()))

    final_score = int( (sum(scores) - max(scores) - min(scores)) / (n - 2) )
    print(final_score)

Measured memory_bytes: 7504
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String {
            bytes
                .by_ref()
                .map(|r| r.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
    input!{
        n: usize,
        v: [usize; n]
    }
    let mut col = vec![0; 8];
    let mut free = 0;
    for &x in &v {
        if x >= 3200 {
            free += 1;
        } else {
            col[x / 400] = 1;
        }
    }
    let mut kind = col.iter().cloned().sum::<usize>();
    if kind == 0 {
        kind = 1;
        free -= 1;
    }
    println!("{} {}", kind, kind + free);
}


Measured memory_bytes: 4352
import java.lang.reflect.Array;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		int N,K;
		N = s.nextInt();
		K = s.nextInt();
		int xp[] = new int[N];
		int sp = -1;
		for(int i=0;i<N;i++) {
			xp[i] =s.nextInt();
			
			if(i==0&&xp[i]>=0) {
				sp=0;
			}else if(xp[i]>=0&&xp[i-1]<0){
				sp=i;
			}
		}
		
		int step =1000000000;
		if(sp<1) {
			if(xp[0]>=0) {
				step=Math.abs(xp[K-1]);
			}else if(xp[N-1]<=0) {
				step=Math.abs(xp[N-K]);
			}
		}else{
			if(sp>=K) {
				step=getstep(xp,K,K,sp);
			}else {
				step=getstep(xp,sp,K,sp);
			}
			
			
		}
		
		System.out.println(step);					
	}
	
	public static int getstep(int[] a, int qd,int cd,int yd) {
		int st =1000000000;
		int tst=0;
		int ls=0;
		int rs=0;
		for(int i=0;i<cd;i++) {
			
			ls=Math.abs(a[yd-qd+i]);
			if(cd-1+i>=Array.getLength(a)) {
				break;
			}
			rs=Math.abs(a[cd-1+i]);
		
			if(ls>rs) {
				tst=2*rs+ls;
			}else {
				tst=2*ls+rs;
			}
			if(tst<st) {
				st=tst;
			}
			
		}
		
		
		
		
		
		return st;
	}

}

Measured memory_bytes: 50376
n = int(input())
p = list(map(int, input().split()))

ans = 0
for i in range(1, n - 1):
    is_asc = p[i - 1] < p[i] < p[i + 1]
    is_desc = p[i - 1] > p[i] > p[i + 1]
    if is_asc or is_desc:
        ans += 1

print(ans)


Measured memory_bytes: 61812
import java.util.Scanner;
import java.util.InputMismatchException;

public class Main{
	public static void main(String[] args){
		try{
			Scanner scanner = new Scanner(System.in);
			String input = scanner.nextLine();
			String[] nums = input.split(" ", 0);
			
			int n = Integer.parseInt(nums[0]);
			
			System.out.println(180*(n-2));
			
		} catch(IndexOutOfBoundsException e){
			e.printStackTrace();
		} catch(NumberFormatException e){
			e.printStackTrace();
		}
	}
}

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

inline int to_number(const char a, const char b, const char c) {
  return (a - '0') * 100 + (b - '0') * 10 + (c - '0');
}

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

int main() {
  string S;
  cin >> S;
  int diff = 100000;
  for(int i = 0; i < S.size() - 2; ++i) {
    chmin(diff, abs(753 - to_number(S[i], S[i + 1], S[i + 2])));
  }
  cout << diff << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue> 
#include <stack>
#include <set>

using namespace std;
typedef long long ll;
#define rep(i, s, e) for (int(i) = (s); (i) <= (e); ++(i))
#define all(x) x.begin(),x.end()


int main()
{
	int n; cin >> n;
	int ans = 1;
	vector<int> b;
	int f; cin >> f;
	b.push_back(f);
	rep(i, 1, n - 1)
	{
		int a; cin >> a;
		if (b[0] >= a)b.insert(b.begin(), a);
		else
		{
			int pos = upper_bound(all(b), a - 1) - b.begin();
			b[pos - 1] = a;
		}
	}
	cout << b.size() << endl;
}

Measured memory_bytes: 892
#include <stdio.h> //printf()
#include <stdlib.h> //exit()

int main(void) {
  int A, B;
  if (scanf("%d %d", &A, &B) < 0) {
    exit(1);
  }
  if (A==1) {
	A = 14;
  }
  if (B==1) {
    B = 14;
  }
  if (A > B) {
    printf("Alice\n");
  }else if (A < B) {
	printf("Bob\n");
  }else {
    printf("Draw\n");
  }
  return 0;
}
    

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

using namespace std;

int N;
int d[100001];

int main(){
  cin >> N;
  for (int i=0;i<N;i++) {
    cin >> d[i];
  }

  sort(d, d+N);

  cout << d[N/2] - d[N/2-1] << endl;

  return 0;
}


Measured memory_bytes: 640
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  int n, m;
  cin >> n >> m;
  int tot = 0;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    tot += a[i];
  }
  int cnt = 0;
  for (int i = 0; i < n; i++) {
    if (tot <= 4 * m * a[i]) cnt++;
  }
  cout << (cnt >= m ? "Yes\n" : "No\n");
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int n;
int a[51];
int b[51];
bool flag[51];
bool used[51];

bool check(int st){
	for(int i=0;i<n;i++){
		memset(used,false,sizeof(used));
		queue<int> que;
		que.push(a[i]);
		used[a[i]]=true;
		while(que.size()){
			int v=que.front();
			que.pop();
			for(int j=1;j<st;j++){
				if(!used[v%j]){
					used[v%j]=true;
					que.push(v%j);
				}
			}
			for(int j=st;j<=50;j++){
				if(!used[v%j] && flag[j]){
					used[v%j]=true;
					que.push(v%j);
				}
			}
		}
		if(!used[b[i]])return false;
	}
	return true;
}

int main(void){
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	for(int i=0;i<n;i++){
		scanf("%d",&b[i]);
	}
	ll ans=0;
	for(int i=50;i>=1;i--){
		if(!check(i)){
			ans+=1LL<<i;
			flag[i]=true;
		}
	}
	printf("%lld\n",check(1)?ans:-1);
	return 0;
}

Measured memory_bytes: 256
//Jai Shree Krishna
#include <vector>
#include <list>
#include <map>
#include <set>
#include "queue"
#include <deque>
#include <stack>
#include <numeric>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <complex>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstring>
#include <climits>
#include <cassert>
#include <iostream>
#include "fstream"
using namespace std;
#define PI acos(-1)
#define MOD (ll)1000000007
#define pii pair<long long ,long long >
#define ll  long long int
#define loop(i,n) for(ll i=0;i<n;i++)
#define loop2(i,n) for(ll i = 1;i<=n;i+=1)
#define pb push_back
#define mp make_pair
#define EPS 1e-10
void display(vector<int> v1){loop(i,v1.size()){cout<<v1[i]<<" ";}cout<<endl;}
ll dx[8] = {0,1,0,-1,1,1,-1,-1};
ll dy[8] = {1,0,-1,0,1,-1,1,-1};

//Never giving in, fighting to the end

ll x[(ll)1e6+1000];
ll y[(ll)1e6+1000];
ll a[(ll)1e6];
ll b[(ll)1e6];

ll multit(ll a,ll b)
{
    return (a*b)%MOD;
}


ll addit(ll a,ll b)
{
    return (a+b)%MOD;
}



int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    int n,m;cin>>n>>m;
    for(int i=0;i<n;i++) cin>>x[i];
    for(int i=0;i<m;i++) cin>>y[i];
    for(int i=0;i+1<n;i++) a[i]=x[i+1]-x[i];
    for(int i=0;i+1<m;i++) b[i]=y[i+1]-y[i];
    n--; m--;
    ll ans1 = 0;
    ll ans2 = 0;
    for(int i = 0; i < n; i++)
    {
        ans1 = addit(ans1,multit(i+1,multit(n-i,a[i])));
    }
    for(int i = 0; i < m; i++)
    {
        ans2 = addit(ans2,multit(i+1,multit(m-i,b[i])));
    }
    cout<<multit(ans1,ans2)<<'\n';
    
    

    return 0;
}

Measured memory_bytes: 11264
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    for (int& it : a)
        cin >> it;
    sort(a.begin(), a.end());
    int ans = 0;
    for (int i = 0; i < k; i++)
        ans += a[i];
    cout << ans << endl;
    return 0;
}

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


int main() {
  int a,b,c; cin >> a >> b >> c;
  if ((a==5 && b==5 && c==7) || (a==5 && b==7 && c==5) || (a==7 && b==5 && c==5)) cout << "YES";
  else cout << "NO";
  cout << endl;

}

Measured memory_bytes: 256
function main(input) {
  const inputData = input.replace(/\s*$/g, '').split('\n');
  const k = parseInt(inputData[0]);
  let s = inputData[1];

  if (s.length > k) {
    s = s.slice(0, k) + '...';
  }

  console.log(s);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 29548
#include <iostream>
#include <math.h>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

#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()

typedef long long lint;

using namespace std;

int main(){
  string S;
  cin>>S;
  for(int i=0;i<S.size();i+=2)cout<<S[i];
  cout<<endl;
  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)
#define repitr(itr,a) for(auto itr=a.begin();itr!=a.end();++itr)
#define P pair<int,int>
const int MOD=998244353;
const int INF=2e9;
const double PI=acos(-1);


int main() {
    ios_base::sync_with_stdio(false);

    int x,n;
    cin >> x >> n;
    vector<int> p(220);
    rep(i,n) {
        int pin;
        cin >> pin;
        p[pin]=1;
    }
    int ans=0;
    rep(i,x+1) {
        if (p[x-i]==0) {
            ans=x-i;
            break;
        } else if (p[x+i]==0) {
            ans=x+i;
            break;
        }
    }
    cout << ans << endl;
     
    return 0;   
}

Measured memory_bytes: 3580
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;
 
int main() {
    ll n;
    cin >> n;

    vvl c(10, vl(10));  // c[i][j] : 先頭がiで末尾がjのn以下の数の個数
    exrep(i, 1, n) {
        string s = to_string(i);
        ll m = s.size();
        ll x = s[0] - '0';
        ll y = s[m-1] - '0';
        c[x][y]++;
    }

    ll ans = 0;
    exrep(i, 1, 9) {
        exrep(j, 1, 9) {
            ans += c[i][j]*c[j][i];
        }
    }

    out(ans);
    re0;
}

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

using namespace std;
using namespace atcoder;
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
#define rep(i,n) for(ll i = 0;i < (ll)n;i++)
#define ALL(x) (x).begin(),(x).end()
#define MOD 1000000007


int main(){
  
  int n,m;
  cin >> n >> m;
  vector<ll> v(n),w(m);
  rep(i,n)cin >> v[i];
  rep(i,m)cin >> w[i];
  vector<ll> res(convolution(v,w));
  rep(i,res.size())cout << res[i] << (i+1 == res.size() ? "\n" : " ");

  return 0;
}

Measured memory_bytes: 27280
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<algorithm>
#include<functional>
#include<utility>
#include<bitset>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<cstdio>
using namespace std;
int a,b;
int main()
{
	cin>>a>>b;
	if(abs(a-b)%2==1)
	{
		cout<<"IMPOSSIBLE"<<endl;
	}
	else
	{
		cout<<(a+b)/2<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

#define loopinc(i, a, b, inc) for(int i = a; i < (b); i += inc)
#define loop(i, a, b) for(int i = a; i < (b); i++)
#define rep(i, n) loop(i, 0, n)
#define rrep(i, n) for (int i = n-1; i >= 0; i--)
#define endl "\n"
#define all(c) (c).begin(),(c).end()
#define lloopinc(i, a, b, inc) for(ll i = a; i < (b); i += inc)
#define lloop(i, a, b) for(ll i = a; i < (b); i++)
#define lrep(i, n) lloop(i, 0, n)
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef tuple<int, int, int> tiii;
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

signed main() {
	// freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
	std::ios::sync_with_stdio(false);
	cin.tie(0);
	
	int n, m;
	cin >> n >> m;
	vi arr(n);
	rep(i, m) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		if (a == 0 or a == n-1) arr[b]++;
		if (b == 0 or b == n-1) arr[a]++;
	}
	rep(i, n) if (arr[i] == 2) {
		cout << "POSSIBLE\n";
		return 0;
	}
	cout << "IMPOSSIBLE\n";
}


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

n, m = map(int, input().split())
if n == 1 or m == 1:
    if n == m == 1:
        ans = 1
    else:
        ans = max(n - 2, m - 2)
else:
    ans = (n - 2) * (m - 2)
print(ans)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(x) x.begin(),x.end()
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    int pre, now;
    ll rest = 1000, cnt = 0;
    cin >> pre;
    while(--n) {
        cin >> now;
        cnt = rest / pre;
        rest += max(0, (now - pre)) * cnt;
        pre = now;
    }
    cout << rest << endl;
    return 0;
}

Measured memory_bytes: 3648
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T> V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> > Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T> mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }

/*
 <url:http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1589>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

ll solve(){
    ll res = 0;
    int N,M,L; cin >> N >> M >> L;
    vector<int> d(M),a(M),k(M),t(M);
    for(int i = 0; i < M;i++) cin >> d[i] >> a[i] >> k[i] >> t[i];
    vector<vector<pll>> event(5*N+1);
    for(int i = 0; i < M;i++){
        event[d[i]*N+a[i]].push_back(make_pair(k[i],t[i]));
    }
    vector<vector<ll>> dp(5*N+2,vector<ll>(L+1,0));
    for(int i = 0; i <= 5*N;i++){
        for(int j = 0; j <= L;j++){
            dp[i+1][j] = max(dp[i+1][j],dp[i][j]);
            if(j == L) continue;
            for(auto e:event[i]){
                dp[i+e.first][j+1] = max(dp[i+e.first][j+1],dp[i][j]+e.second);
            }
        }
    }
    res = *max_element(dp[5*N+1].begin(), dp[5*N+1].end());
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    cout << solve() << endl;
    return 0;
}



Measured memory_bytes: 3236
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll>
#define cvector vector<char>
#define svector vector<string>
#define lque queue<ll>
#define lpque priority_queue<ll>
#define dlpque priority_queue<ll,lvector,greater<ll>>
#define P pair<ll,ll>
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define rep(i,n) for(ll i=0; i<n; ++i)
#define print(a) cout << (a) << endl

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n,ans=1,m=1e18;cin>>n;
  lvector A(n);rep(i,n) cin>>A[i];
  sort(ALL(A));
  for(ll i:A) {
    if(i!=0&&ans>m/i) {
      ans=-1;
      break;
    }
    ans*=i;
  }
  print(ans);
  return 0;
}

Measured memory_bytes: 3936
n = gets.to_i
rec = Array.new(26,10**9)
n.times do
  xc = gets.strip.chars
  ary = Array.new(26,0)
  for i in 0..xc.size-1
    ary[xc[i].ord-97] += 1
  end
  for i in 0..25
    if ary[i] < rec[i]
      rec[i] = ary[i]
    end
  end
end
sa = []
for i in 0..25
  if rec[i] != 0
    sa << Array.new(rec[i],(97+i).chr)
  end
end
if sa.size != 0
  sa.flatten!
  puts sa.join("")
end

Measured memory_bytes: 14352
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <cfloat>
#include <map>
#include <set>
#include <array>
#include <stdio.h>
#include <string.h>
using ll = long long;
using ull = unsigned long long;
using namespace std;
#define int long long
#define CONTAINS_VEC(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define ARY_REVERSE(v,a) (reverse((v), (v)+(a)))
#define REP(i, n) for (int (i)=0; (i) < (n); (i)++)
#define CONTAINS_MAP(m, a) (m).find((a)) != m.end()
#define CONTAINS_SET(m, a) (m).find((a)) != m.end()
void YesNo(bool b) { cout << (b ? "Yes" : "No") << endl; }
void YESNO(bool b) { cout << (b ? "YES" : "NO") << endl; }

signed main()
{
	int N, M, X, Y;
	cin >> N >> M >> X >> Y;

	int x[101];
	int y[101];

	REP(i, N) cin >> x[i];
	REP(i, M) cin >> y[i];

	for (int i = X + 1; i <= Y; i++)
	{
		bool valid = true;

		REP(n, N)
		{
			if (i <= x[n]) valid = false;
		}
		REP(m, M)
		{
			if (i > y[m]) valid = false;
		}

		if (valid)
		{
			cout << "No War" << endl;
			return 0;
		}
	}
	cout << "War" << endl;
}



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

N, M, V, P = map(int, input().split())
A = list(map(int, input().split()))
B = []
C = []

A.sort()
for _ in range(P-1):
    B.append(A.pop())

try:
    C.append(A.pop())
    while C[-1] == A[-1]:
        C.append(A.pop())
except:
    pass

A_length = len(A)
B_length = len(B)
C_length = len(C)
sm = sum(C)
count = 0

for _ in range(len(A)):
    now = A[-1]
    new = now + M
    threshhold = C
    remain = V - B_length - (A_length - count)
    if new >= C[0]:
        if remain <= 0:
            val = A.pop()
            C.append(val)
            sm += val
            count += 1
        elif sm <= new * (C_length + count) - remain*M:
            val = A.pop()
            C.append(val)
            sm += val
            count += 1
print(len(B+C))

Measured memory_bytes: 14252
#include <iostream>
#include <string>
#include <cctype>
#include <vector>
#include <stdexcept>
using namespace std;
string input;

inline bool is_all_digit(string in)
{
	for (auto i : in)
	{
		if (!isdigit(i))
			return false;
	}
	return true;
}
vector<string> split(string in)
{
	vector<string> spl;
	int pos = 0;
	if (in[pos] == '-') 
	{
		pos++;
		while (pos < in.size()) {
			if (isdigit(in[pos])) {
				pos++;
			}
			else {
				break;
			}
		}
		spl.push_back(in.substr(0, pos));
		in.erase(0, pos);
		pos = 0;
	}
	while ( pos < in.size())
	{
		if (!isdigit(in[pos]))
		{
			if (pos != 0)
			{
				spl.push_back(in.substr(0, pos));
				in.erase(0, pos);
				pos = 0;
			}
			else
			{
				if (in[0] == '(')
				{
					int cnt = 1;
					int r_pos = 1;
					for (r_pos = 1; r_pos < in.size(); r_pos++)
					{
						if (in[r_pos] == '(')
							cnt++;
						if (in[r_pos] == ')')
							cnt--;
						if (cnt == 0)
							break;
					}
					spl.push_back(in.substr(pos + 1, r_pos - 0 - 1));
					in.erase(0, r_pos + 1);
					pos = 0;
					continue;
				}
				else if (in[0] == '+' || in[0] == '-' || in[0] == '*' || in[0] == '/')
				{
					spl.push_back(in.substr(0, 1));
					in.erase(0, 1);
					pos = 0;
				}
			}
		}
		else {
			pos++;
		}
	}
	if (in.size() != 0) spl.push_back(in);
	return spl;
}
int cal(string &in_str) {
	auto in = split(in_str);
	while (in.size() == 1) {
		if (in[0][0] == '-'&&is_all_digit(in[0].substr(1))) break;
		if (is_all_digit(in[0])) break;
		in = split(in[0]);
	}
	while (in.size() != 1) {
		auto pos = in.begin();
		while (pos != in.end()) 
		{
			if (*pos == "*") {
				pos--;
				*pos = to_string(cal(*pos)*cal(*(pos + 2)));
				in.erase(pos+1 , pos + 3);
			}
			else if (*pos == "/") {
				pos--;
				*pos = to_string(cal(*pos)/cal(*(pos + 2)));
				in.erase(pos+1, pos + 3);
			}
			if (in.size()==1) break;
			if (pos != in.end()) pos++;
		}
		pos = in.begin();
		while (pos != in.end()) {
			if (*pos == "+") {
				pos--;
				*pos = to_string(cal(*pos)+cal(*(pos + 2)));
				in.erase(pos+1, pos + 3);
			}
			else if (*pos == "-") {
				pos--;
				*pos = to_string(cal(*pos) - cal(*(pos + 2)));
				in.erase(pos+1, pos + 3);
			}
			if (in.size()==1) break;
			if(pos != in.end()) pos++;
		}
	}
	try {
		return(stoi(in[0]));
	}
	catch (const std::invalid_argument& a) {
		cerr << a.what() << input << endl;
	}
}
int main()
{
	
	int n;
	cin >> n;
	while (n--) {
		cin >> input;
		input.erase(input.end() - 1);
		cout << cal(input) << endl;
	}

	return 0;
}


Measured memory_bytes: 3204
#include<bits/stdc++.h>
using namespace std;
int main(){
    int h,w;
    cin >> h >> w;
    int dp[h+2][w+2];
    for(int i = 0; i < h + 2; i++)
        for(int j = 0; j < w + 2; j++)
            dp[i][j] = 100000000;
    dp[0][0] = dp[1][0] = dp[0][1] = 0;
    string in;
    for(int i = 1; i <= h; i++){
        cin >> in;
        for(int j = 1; j <= w; j++){
            dp[i][j] = in[j - 1] - '0';
        }
    }
    for(int i = 1; i <= h; i++)
        for(int j = 1; j <= w; j++)
            dp[i][j] = min(dp[i][j] + dp[i-1][j] , dp[i][j] + dp[i][j-1]);
    cout << dp[h][w] << endl;
}

Measured memory_bytes: 3228
#include<bits/stdc++.h>
using namespace std;
const long double mx = 1e18;
int main()
{
cout.precision(0);
 long double s=1;
 int n,f=0;
 cin>>n;
 for(int i=1;i<=n;i++)
 {
    long double k;
     cin>>k;
     s*=k;
     if(k==(long double)0)f=1;
 }
 if(s>mx)cout<<-1<<endl;
  else if(f==1)cout<<0<<endl;
 else cout<<fixed<<s<<endl;
}


Measured memory_bytes: 3692
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<cctype>
#include<complex>
#include<iostream>
#include<sstream>
#include<algorithm>
#include<functional>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<map>

using namespace std;
const int dx[] = {1,0,-1,0},dy[] = {0,1,0,-1};
#define INF 1e+8
#define rep(i,j) for(int i = 0; i < (j); i++)
#define reps(i,j,k) for(int i = j; i < k; i++)
typedef long long ll;
typedef unsigned long long ull;
int cost[128][128];
int mincost[128];
bool used[128];
int V,E;
void init(){
	rep(i,V)rep(j,V)cost[i][j] = INF;
	fill(mincost,mincost+V,INF);
	fill(used,used+V,false);
}
int prim(){
	mincost[0] = 0;
	int res = 0;
	while(true){
		int v = -1;
		rep(u,V)if(!used[u] && (v == -1 || mincost[u] < mincost[v]))v = u;
		if(v == -1)break;
		used[v] = true;
		res += mincost[v];
		rep(u,V)mincost[u] = min(mincost[u],cost[v][u]);
	}
	return res;
}
int main(){
	int n,m;
	while(scanf("%d%d",&n,&m),n|m){
		V = n;
		init();
		rep(i,m){
			int from,to,pay;
			scanf("%d%d%d",&from,&to,&pay);
			cost[from][to] = pay;
			cost[to][from] = pay;
		}
		printf("%d\n",prim());
	}
	return 0;
}

Measured memory_bytes: 1232
#include <bits/stdc++.h>
//#define int long long

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

#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)

#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

const int INF = (int)1e9;
const LL INFL = (LL)1e15;
const int MOD = 1e9 + 7;

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

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int a, b;
    cin >> a >> b;
    if(a + b == 15) cout << "+" << endl;
    else if(a * b == 15) cout << "*" << endl;
    else cout << "x" << endl;
}


Measured memory_bytes: 256
using namespace std;
#include<iostream>
#include<vector>
#include<queue>
#include<map>
#include <unordered_set>
#include <set>
#include <unordered_map>
#include<stack>

#define MOD1e9 1000000007
#define INT_MAX       2147483647
#define INT_MIN     (-2147483647 - 1)
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);
#define rep(c) for(int i = 0; i <(c); ++i)
#define rrep(n) for(int i = (n) ; i >=0 ; --i)
#define fora(i, s, c) for(int i = (s); i < (c); ++i)
#define forr(i, s, c) for(int i = (s); i > (c); --i)
#define endl "\n"
#define ret(n) return n
#define pb push_back
#define eb emplace_back
#define ff first;
#define ss second;
#define mp make_pair;
#define all(p) p.begin(),p.end()
#define mid(s,e) (s+(e-s)/2)
//Typedefs
typedef long long ll;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef priority_queue<int> pqint;
typedef priority_queue<ll> pqll;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<long> vl;
typedef vector<vl> vvl;
typedef vector<bool> vb;
//Testcase start
#define tcs() int testcases; cin >> testcases; while(testcases--)

constexpr auto MAX_V = 1000;
constexpr auto INF = 1e9 + 7;
ll Knapsack2(vi& wt, vll& v, int n, int KNAP_CAP)
{
	//dp[i][j] = wi => i items choose karke jinki total j value hai humara min wt in knapsack is wi
	int maxval = MAX_V * n;
	//n is number of items in knapsack
	//MAX v is 1000, if we select each item then max can be nX1000
	vvll dp(n + 1, vll(maxval + 1, 0));

	for (int i = 0; i <= maxval; ++i)
		dp[1][i] = INF; //base case: 1 item each having value i, but we cannot chose it so marking it infinity
	dp[1][0] = 0; //1 item: with value 0 => wt in knapsack has to be 0
	dp[1][v[1]] = wt[1]; // 1 item choose kiya jiska value v[1] tha toh knapsack ka wt wt[1] hoga
	
	for (int i = 2; i <= n; ++i)
	{
		for (int j = 0; j <= maxval; ++j)
		{
			//current item i hai
			//hum i ko nahi le sakte then dp[i][j] = dp[i-1][j] humne i ko nahi liya toh i-1 wali value hogi
			dp[i][j] = dp[i - 1][j]; 
			
			//ya fir hum i ko le sakte hai
			//hum i ko tabhi le sakte hai jabki j (joki current val hai) v[i] se jyada ho ho
			if (v[i] > j) //current item ki value j se jyada hia toh continue
				continue;

			//nahi to le sakte hai
			// agar wt[i] le liya jiska value v[i] hai 
			// toh j will decrease to j - v[i]
			dp[i][j] = min(dp[i][j], wt[i] + dp[i - 1][j - v[i]]);
		}
	}

	//now we will choose largest j or value such that dp[i][j] <= knapsack capacity

	ll ans = 0;
	for (int j = 0; j <= maxval; ++j)
	{
		if (dp[n][j] <= KNAP_CAP)
		{
			ans = j;
		}
	}

	return ans;
}

int main()
{

	int n, w;
	cin >> n >> w;
	vi wts(n + 1); //for indexing 1 to n
	vll price(n + 1);
	rep(n)
	{
		cin >> wts[i + 1] >> price[i + 1];
	}
	
	auto ans = Knapsack2(wts, price, n, w);
	cout << ans;
	ret(0);
}


Measured memory_bytes: 80256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		Integer oneCount = 0;
		if(s.charAt(0) == '1') {
			oneCount ++;
		}
		if(s.charAt(1) == '1') {
			oneCount ++;
		}
		if(s.charAt(2) == '1') {
			oneCount ++;
		}
		System.out.println(oneCount);
	}
}

Measured memory_bytes: 23252
#include <iostream>

using namespace std;

int main() {
    int X;
    cin >> X;
    if (400 <= X && X <= 599) {
        cout << 8 << endl;
    }
    else if (600 <= X && X <= 799) {
        cout << 7 << endl;
    }
    else if (800 <= X && X <=999 )
    {
        cout << 6 << endl;
    }
    else if (1000 <= X && X <=1199 )
    {
        cout << 5 << endl;
    }
    else if (1200 <= X && X <=1399)
    {
        cout << 4 << endl;
    }
    else if (1400 <= X && X <=1599)
    {
        cout << 3 << endl;
    }
 
     else if (1600<= X && X <=1799 )
    {
        cout << 2 << endl;
    }
    else if (1800 <= X && X <=1999)
    {
        cout << 1 << endl;
    }
    else {cout << "error input" << endl;}

    return 0;
}

Measured memory_bytes: 3628
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#define F first
#define S second
using namespace std;
typedef pair<int,int> P;


int main(){
  int n,m;
  P p;
 
  while(cin >> n >> m && n && m){
    int ans = 0;
    bool matrix[n+2][n+2];
    for(int i=0;i<n+2;i++)for(int j=0;j<n+2;j++)matrix[i][j] = false;
    for(int i=0;i<m;i++){
      cin >> p.F >> p.S;
      matrix[p.F][p.S] = matrix[p.S][p.F] = true; 
    }

    int here;
    map<int,bool> cnt;
    for(int i=1;i<=n;i++){
      if(matrix[1][i]){
	here = i;
	cnt[here] = true;
	for(int j=1;j<=n;j++){
	  if(i == j)continue;
	  if(matrix[here][j]){
	    cnt[j] = true;
	  }
	}
      }
    }
    map<int,bool>::iterator it = cnt.begin();
    while(it != cnt.end() ){
      if((*it).F != 1)ans++;
      it++;
    } 

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

Measured memory_bytes: 1460
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb emplace_back
#define x first
#define y second
#define sz(a) ((int)(a).size())
#define rep(i,a,b) for(auto i=(a); i<(b); i++)
#define dec(i,n,a) for(auto i=(n); i>=(a); i--)
#define clr(a,v) memset(a, v, sizeof(a))
#define all(a) (a).begin(),(a).end()
#define EPS 5e-9
#define fcin ios_base::sync_with_stdio(false)
#define db(x) cerr << #x << " == " << x << endl
#define _ << " " <<
#define MAXN 505050
#define LOGN 18
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define int ll

int n, m, a, b;
ll dis[MAXN], pdvai[MAXN], pdvem[MAXN], mod = 1e9+7;
vi adj[MAXN], cost[MAXN], pai[MAXN], vai[MAXN], vem[MAXN];
char jav[MAXN], pvai[MAXN], pvem[MAXN];
set<pair<ll, int> > fila;

void recupera(int v){
	if(jav[v]) return;
	jav[v]=1;
	rep(i,0,sz(pai[v])){
		int u = pai[v][i];
		vai[u].pb(v);
		vem[v].pb(u);
		recupera(u);
	}
}

ll solvevai(int v){
	if(v == b) return 1;
	ll & ret = pdvai[v];
	if(ret != -1) return ret;
	ret = 0;
	rep(i,0,sz(vai[v])) ret = (ret + solvevai(vai[v][i]))%mod;
	return ret;
}

ll solvevem(int v){
	if(v == a) return 1;
	ll & ret = pdvem[v];
	if(ret != -1) return ret;
	ret = 0;
	rep(i,0,sz(vem[v])) ret = (ret + solvevem(vem[v][i]))%mod;
	return ret;
}

char podevai(int v){
	if(v == b) return 1;
	char & ret = pvai[v];
	if(ret != 2) return ret;
	ret = 0;
	rep(i,0,sz(vai[v])) ret |= podevai(vai[v][i]);
	return ret;
}

char podevem(int v){
	if(v == a) return 1;
	char & ret = pvem[v];
	if(ret != 2) return ret;
	ret = 0;
	rep(i,0,sz(vem[v])) ret |= podevem(vem[v][i]);
	return ret;
}

int32_t main(){
	clr(dis,-1);
	clr(pdvai,-1);
	clr(pdvem,-1);
	clr(pvai,2);
	clr(pvem,2);
	scanf("%lld%lld%lld%lld", &n, &m, &a, &b);
	a--, b--;
	rep(i,0,m){
		int u, v, c;
		scanf("%lld%lld%lld", &u, &v, &c);
		u--, v--;
		adj[u].pb(v);
		adj[v].pb(u);
		cost[u].pb(c);
		cost[v].pb(c);
	}
	dis[a]=0;
	fila.insert(mp(dis[a],a));
	while(!fila.empty()){
		ll d = fila.begin()->x;
		int v = fila.begin()->y;
		fila.erase(fila.begin());
		if(dis[v] != d) continue;
		rep(i,0,sz(adj[v])){
			int u = adj[v][i];
			int c = cost[v][i];
			if(dis[u] == -1 || dis[u] > dis[v] + c){
				pai[u].clear();
				dis[u] = dis[v] + c;
				fila.insert(mp(dis[u],u));
			}
			if(dis[u] == dis[v] + c)
				pai[u].pb(v);
		}
	}
	recupera(b);
	ll ans = solvevai(a)*solvevai(a)%mod;
	rep(i,0,n) if(2*dis[i] == dis[b] && podevai(i) && podevem(i)){
		ll q = solvevai(i)*solvevem(i)%mod;
		ans = ((ans - q*q)%mod + mod)%mod;
	}
	rep(i,0,n) rep(j,0,sz(vai[i])) if(2*dis[i] < dis[b] && 2*dis[vai[i][j]] > dis[b] && podevai(vai[i][j]) && podevem(i)){
		ll q = solvevai(vai[i][j])*solvevem(i)%mod;
		ans = ((ans - q*q)%mod + mod)%mod;
	}
	printf("%lld\n", ans);
}


Measured memory_bytes: 95360
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::{Bytes, Chars};
#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
	input! {
		a: String,
		b: String,
	}

	let n = usize::from_str_radix(&(a+&b), 10).unwrap();

	let mut i = 0;
	loop {
		let i2 = i*i;
		if n == i2 {
			println!("Yes");
			return;
		}
		if n < i2 {
			println!("No");
			return;
		}
		i += 1;
	}
}



Measured memory_bytes: 2060
# -*- coding: utf-8 -*-
import math
Q = int(input())

ls = []
rs = []
for n in range(Q):
    l, r = map(int, input().split())
    ls.append(l)
    rs.append(r)
    num = 0

max_r = max(rs)

def eratos(n):
    if n == 1:
        return set()
    primes = [1 for i in range(n+1)]
    primes[0] = 0
    primes[1] = 0
    for i in range(2,math.floor(math.sqrt(n))+1):
        if primes[i] == 1:
            j = i + i
            while j <= n:
                primes[j] = 0
                j = j + i
    return primes


def count_similar(era, n):
    count_similar = [0 for i in range(n+1)]
    for i in range(1,n+1):
        count_similar[i] = count_similar[i-1]
        if era[i] == 1 and era[int((i+1)/2)] == 1:
            count_similar[i] += 1
    return count_similar




era = eratos(max_r)
cnt = count_similar(era, max_r)

for l, r in zip(ls, rs):
    print(cnt[r] - cnt[l-1])



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

int main() {
  int H, W;
  cin >> H >> W;
  vector<vector<char>> data(H, vector<char>(W));
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cin >> data.at(i).at(j);
    }
  }
  vector<bool> row(H, false);
  vector<bool> col(W, false);
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      if (data.at(i).at(j) == '#') {
        row.at(i) = true;
        col.at(j) = true;
      }
    }
  }
  for (int i = 0; i < H; i++) {
    if (row.at(i)) {
      for (int j = 0; j < W; j++) {
        if (col.at(j)) {
          cout << data.at(i).at(j);
        }
      }
      cout << endl;
    }
  }
}
    
  




Measured memory_bytes: 256
n, m= map(int, input().split())

links = [[] for x in range(n + 1)]
sums = [0 for x in range(n + 1)]
adds = [0 for x in range(n + 1)]

links[0].append(1)

buf = [map(int, input().split()) for _ in range(n - 1)]

for link in buf:
  a, b= link
  links[a].append(b)
  links[b].append(a)

for _ in range(m):
  p, x = map(int, input().split())
  adds[p] += x

que = [0,[1]]
checked = [0 for x in range(n+1)]

que = [[-1, [0]]]

while que:
  link = que.pop()
  par = link[0]
  childs = link[1]

  for child in childs:
    if checked[child] != 1:
      sums[child] = sums[par] + adds[child]
      que.append([child, links[child]])
      checked[child] = 1

  
print(*sums[1:])

Measured memory_bytes: 138496
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
  int n,a[10001];
long long c[3]={0};
  cin >> n;
  for(int i=0;i<n;i++)
    cin >> a[i];
  for(int k=0;k<n;k++)
    c[2]+=a[k];
  for(int bb=0;bb<n;bb++){
    for(int j=n-1;j>bb;j--){
       if(a[j-1]>a[j]){
	int tmp=a[j-1];
	a[j-1]=a[j];
	a[j]=tmp;
      }
    }
  }
  c[0]=a[0];
  c[1]=a[n-1];
  for(int s=0;s<3;s++){
    cout << c[s];
    if(s!=2)
      cout<<" ";
  }
  cout<<endl;
  return 0;
}

Measured memory_bytes: 3100