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

int main()
{
  int n, m, ans = 0, tmp1 = 0, tmp2 = 0;
  cin >> n >> m;
  vector<int> A(n);
  vector<pair<int, int>> SC;
  for (int i = 0; i < m; i++)
  {
    int s, c;
    cin >> s >> c;
    SC.push_back(make_pair(s, c));
  }
  sort(SC.begin(), SC.end());

  for (int i = 0; i < m; i++)
  {
    if (SC[i].first == 1 and SC[i].second == 0 and n > 1) {
      ans = -1;
      break;
    }
    if (tmp1 == SC[i].first)
    {
      if (tmp2 != SC[i].second)
      {
        ans = -1;
        break;
      }
      else
        continue; 
    }
    tmp1 = SC[i].first;
    tmp2 = SC[i].second;
    ans += tmp2 * pow(10, n - tmp1);
  }
  if (n > 1 and ans != -1 and ans < pow(10, n-1)) ans += pow(10, n-1);
  cout << ans << endl;
}

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

int main()
{
    char s[101];
    cin>>s;
    char *p=strchr(s,'C');
    if(!p){
        cout<<"No";
        return 0;
    }
    p=strchr(p,'F');
    if(p){
        cout<<"Yes";
    }
    else
        cout<<"No";
    return 0;
}


Measured memory_bytes: 888
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  int N,K,g=0,m=0;
  cin>>N>>K;
  while(N--){
    int i;
    cin>>i;
    g=__gcd(g,i),m=max(m,i);
  }
  if(m<K || K%g!=0) puts("IMPOSSIBLE");
  else puts("POSSIBLE");
}

Measured memory_bytes: 3580
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let n = read::<i64>();
    let mut n_chars = 1;
    let mut cur_max = 26;
    let mut prev_max = 0;
    while cur_max < n {
        n_chars += 1;
        debug!(cur_max);
        prev_max = cur_max;
        cur_max += 26i64.pow(n_chars);
    }

    debug!(n_chars, cur_max, prev_max);
    let mut answers = vec!['A'; n_chars as usize];
    let mut n = n - prev_max - 1;
    for i in 0..n_chars as usize {
        answers[n_chars as usize - 1 - i] =
            std::char::from_digit((n % 26) as u32 + 10, 36).unwrap();
        n /= 26;
    }
    for ans in answers {
        print!("{}", ans);
    }
    println!("");
}

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


Measured memory_bytes: 2112
#include<stdio.h>
int main(void)
{
	int a,b,c,s,d;
	scanf("%d",&s);
	d=s/60;
	c=s%60;
	a=d/60;
	b=d%60;
	printf("%d:%d:%d\n",a,b,c);
	return 0;
}
	
	

Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<string>
#include<stack>
#include<cstdio>
#include<cmath>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<int,P> P1;

#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define rep(i,x) for(int i=0;i<x;i++)
#define rep1(i,x) for(int i=1;i<=x;i++)
#define rrep(i,x) for(int i=x-1;i>=0;i--)
#define rrep1(i,x) for(int i=x;i>0;i--)
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
#define mp1(a,b,c) P1(a,P(b,c))

const int INF=1000000000;
const int dir_4[4][2]={{1,0},{0,1},{-1,0},{0,-1}};
const int dir_8[8][2]={{1,0},{1,1},{0,1},{-1,1},{-1,0},{-1,-1},{0,-1},{1,-1}};

int main(){
	static int n;
	static int a[100010];
	scanf("%d",&n);
	for(int i = 1 ; i <= n ; i ++){
		scanf("%d",&a[i]);
	}
	
	bool ret = false;
	for(int i = 1 ; i <= n ; i ++){
		if(a[i]&1)ret = true;
	}
	
	if(ret)puts("first");
	else puts("second");
}



Measured memory_bytes: 640
/* << IN THE NAME OF GOD >> */
#include <bits/stdc++.h>
using namespace std;



#define err(x) cerr << #x  << " = "<<  x << '\n'
#define out(x) cout << x << '\n'
#define forp(i, r, l) for(int i = int(r); i < int(l); i++)
#define forn(i, r, l) for(int i = int(r); i > int(l); i--)
#define FAST ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll ,ll> pll;
const int maxn = 2e5 + 120;


int main(){FAST;   
    string str; ll k ,i;
    cin >> str >> k;
    ll si = str.size();

    for(i = 0; i < min(si ,k); i++)
        if(str[i] >= '2')
            return cout << str[i] ,0;
    cout << 1;
    
return 0;
}
 










Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
typedef  long long ll;
double pi=3.1415926535898;
//double pi=acos(-1.0);
#define speed      ios::sync_with_stdio(false);cin.tie(NULL); cout.tie(NULL);
#define rng(i,a,b) for(int i=a;i>=int(b);i--)
#define rep(i,a,b) for(int i=a;i<=int(b);++i)
#define lop(i,n)   for(int i=0;i<int(n);i++)
#define ms(x,a)    memset(x,a,sizeof(x))
#define all(x)     (x).begin(),(x).end()
#define sz(x)      int(x.size())
#define pb         push_back
#define r0         return 0;
#define CC         continue;
#define bb(x)      cerr<< x <<endl;
#define pii        pair<int,int>
#define pis        pair<int,string>
#define vi         vector<int>
#define F          first
#define S          second
//#define max(a,b) a<b?b:a  __builtin_popcount;
//#define min(a,b) a<b?a:b
//freopen("output.txt","w",stdout),freopen("input.txt","r",stdin);
const ll M  = 1e9+7 ;
const int N = 50500;
const int inf = INT_MAX;
const double eps = 1e-6;
//////////////////////    Hi    ^_^  hack me if you can :P
int n,m;
int a,b;
int ans;
vector<int > v [15];
bool vis[15];
void dfs (int i,int s)
{
    if (s==n)
    {
        ans++;
        return;
    }
    vis[i]=1;
    for (auto j:v[i])
    {
        if (!vis[j])
            dfs(j,s+1);
    }
    vis[i]=0;
}
int main()
{
    cin>>n>>m;
    lop(i,m)
    {
        cin>>a>>b;
        v[a].pb(b);
        v[b].pb(a);
    }
    dfs(1,1);
    cout<<ans;
}
/*



https://ideone.com/goT6Vy//http:
codeforces.com/problemset/problem/466/D

, vector < pair <int,int > >, greater <pair <int, int> >
http://codeforces.com/contest/295/submission/17929453
freopen("output.txt","w",stdout);
freopen("input.txt","r",stdin);

ll pwmod(ll a, ll n, ll mod)
{
    ll ret = 1;
    while (n)
    {
        if (n & 1) ret = ret * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return ret;
}

for (int i=0; i<n; i++)            Hi    ^_^  hack me if you can :P

int mx[]= {0,0,1,-1, 1,1,-1,-1};
int my[]= {1,-1,0,0, 1,-1,1,-1};
bool inside (int i,int j){return (i>=0 && i<n && j>=0 && j<m);}

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

void gcd(LL n,LL m,LL &d,LL &xx,LL &yy)
{
    if(!m)
    {
        d=n;
        xx=1;
        yy=0;
    }
    else
    {
        gcd(m,n%m,d,yy,xx);
        yy-=xx*(n/m);
    }
}

int getm(int l,int r)
{
    if(l>r)
        return N;
    if(l==r)
        return 0;
    if(l==r-1)
        return s[l] != s[r];
    if(s[l]==s[r])
        return getm(l+1,r-1);
    else
        return 1+min(getm(l+1,r),getm(l,r-1));
}

int BIT[si], a[si], n;
void update(int x, int delta)
{
    for(; x <= N; x += x&-x)
        BIT[x] += delta;
}
int query(int x)
{
    int sum = 0;
    for(; x > 0; x -= x&-x)
        sum += BIT[x];
    return sum;
}

#define sc(x)      scanf("%d",&x)
#define scl(x)     scanf("%lld",&x)
#define pr(x)      printf("%d ",x)
#define prl(x)     printf("%lld ",x)
#define prln(x)    printf("%d\n",x)
#define prlln(x)   printf("%lld\n",x)
#define scd(x)     scanf("%lf",&x)
#define prd(x)     printf("%.10f\n",x)


*/


Measured memory_bytes: 256
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, std.bitmanip;

immutable long MOD = 10^^9 + 7;

bool valid(int mask) {
    while (mask > 0) {
        if ((mask & 0b11) == 0b11) {
            return false;
        }
        mask >>= 1;
    }
    return true;
}

void main() {
    auto s = readln.split.map!(to!int);
    auto H = s[0];
    auto W = s[1];
    auto K = s[2] - 1;

    auto dp = new int[][](H+1, W);
    dp[0][0] = 1;

    auto masks = (1<<(W-1)).iota.filter!(a => valid(a)).array;

    foreach (i; 0..H) {
        foreach (j; 0..W) {
            foreach (mask; masks) {
                if (j > 0 && (mask & (1 << (j - 1)))) {
                    (dp[i+1][j-1] += dp[i][j]) %= MOD;
                } else if (j < W - 1 && (mask & (1 << j))) {
                    (dp[i+1][j+1] += dp[i][j]) %= MOD;
                } else {
                    (dp[i+1][j] += dp[i][j]) %= MOD;
                }
            }
        }
    }

    dp[H][K].writeln;
}


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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
using P = pair<ll,ll>;
using ld=long double;

int main(){
   ll ans=0;
   vector<ll>t(5);
    for (int i = 0; i < 5; ++i) {
        cin >>t[i];
        ans+=(t[i]/10)*10;
        t[i]%=10;
        if(!t[i])t[i]+=10;
    }
    sort(all(t));
    ans+=t[0]%10;
    for (int i =1; i < 5; ++i) {
        if(t[i]!=10)ans+=10;
    }
    cout <<ans <<endl;
   return 0;
}

Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author tatsumack
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(12)

using namespace std;

typedef pair<int, int> P;

class BPostdocs {
public:
    void solve(std::istream& cin, std::ostream& cout) {
        string T;
        cin >> T;

        vector<vector<int>> dp(T.size() + 1, vector<int>(2));
        vector<vector<int>> par(T.size(), vector<int>(2,-1));
        for (int i = 0; i < T.size(); i++) {
            auto c = T[i];
            if (c == 'D') {
                dp[i + 1][0] = max(dp[i][0] + 1, dp[i][1] + 2);
                if (dp[i][0]+1 > dp[i][1]+2) {
                    par[i][0] = 0;
                } else {
                    par[i][0] = 1;
                }
            }
            if (c == 'P') {
                dp[i + 1][1] = max(dp[i][0], dp[i][1]);
                if (dp[i][0] > dp[i][1]) {
                    par[i][1] = 0;
                } else {
                    par[i][1] = 1;
                }
            }
            if (c == '?') {
                // D
                dp[i + 1][0] = max(dp[i][0] + 1, dp[i][1] + 2);
                if (dp[i][0] + 1 > dp[i][1] + 2) {
                    par[i][0] = 0;
                } else {
                    par[i][0] = 1;
                }
                // P
                dp[i + 1][1] = max(dp[i][0], dp[i][1]);
                if (dp[i][0] > dp[i][1]) {
                    par[i][1] = 0;
                } else {
                    par[i][1] = 1;
                }
            }
        }
        int cur = dp[T.size()][0] > dp[T.size()][1] ? 0 : 1;
        string res = cur == 0 ? "D" : "P";
        for (int i = T.size() - 1; i >= 1; i--) {
            res += par[i][cur] == 0 ? "D" : "P";
            cur = par[i][cur];
        }
        reverse(res.begin(), res.end());
        cout << res << endl;
    }
};


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    std::istream& in(std::cin);
    std::ostream& out(std::cout);

    BPostdocs solver;
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 25696
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    println(problem111b(n))
}

fun problem111b(n: Int): String {
    val ns = n.toString()
    if (ns[0] == ns[1] && ns[1] == ns[2]) return ns
    if (ns[0] == ns[1] && ns[1] < ns[2]) {
        return if (ns[0] <= ns[2]) "${ns[0] + 1}${ns[0] + 1}${ns[0] + 1}" else {
            "${ns[0]}${ns[0]}${ns[0]}"
        }
    }
    if (ns[0] == ns[1] && ns[1] > ns[2]) {
        return "${ns[0]}${ns[0]}${ns[0]}"
    }
    if (ns[0] < ns[1]) return "${ns[0] + 1}${ns[0] + 1}${ns[0] + 1}"
    if (ns[0] > ns[1]) {
        return "${ns[0]}${ns[0]}${ns[0]}"
    }
    return ""
}

Measured memory_bytes: 29472
use permutohedron::heap_recursive;
use proconio::marker::Usize1;
use proconio::{fastout, input};

#[allow(unused_mut)]
#[fastout]
fn main() {
    input! {
        n: usize,
        m: usize,
        a: [(Usize1,Usize1); m]
    }
    let mut graph: Vec<Vec<usize>> = vec![vec![]; n];
    a.iter().for_each(|s| {
        graph[s.0].push(s.1);
        graph[s.1].push(s.0);
    });
    let mut tmp: Vec<usize> = (1..n).collect();
    let mut pattern = Vec::new();
    heap_recursive(&mut tmp, |pat| pattern.push(pat.to_vec()));
    let mut res = 0;
    for pat in pattern.iter() {
        let mut before = 0;
        let mut can = true;
        for i in pat.iter() {
            if !graph[before].contains(i) {
                can = false;
            }
            before = *i;
        }
        if can {
            res += 1;
        }
    }
    println!("{}", res);
}


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

using namespace std;
using ll = long long;

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

int main() {
  int x, y, z, k;
  cin >> x >> y >> z >> k;
  vector<ll> a(x), b(y), c(z);
  rep(i, x) cin >> a[i];
  rep(i, y) cin >> b[i];
  rep(i, z) cin >> c[i];

  vector<ll> ab(x * y);
  rep(i, x) rep(j, y) ab[i * y + j] = a[i] + b[j];
  sort(ab.rbegin(), ab.rend());

  vector<ll> abc(min(k, x * y) * z);
  rep(i, min(k, x * y)) rep(j, z) abc[i * z + j] = ab[i] + c[j];

  sort(abc.rbegin(), abc.rend());
  rep(i, k) cout << abc[i] << endl;
  return 0;
}


Measured memory_bytes: 34680
#include <iostream>
#include <algorithm>
#include <vector>
#include <array>
using namespace std;
int main()
{
	int n;

	cin >> n;
	vector <double> a(n);
	for (int i = 0; i < n; i++)
		cin >> a[i];
	sort(a.begin(), a.end());
	double sum = 0;
	for (int i = 0; i < n - 1; i++)
	{
		if (sum == 0)
			sum = sum + ((a[i] + a[i + 1]) / 2);
		else
			sum = (sum + a[i + 1]) / 2;
	}
	cout<< sum;
}

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

a=min(a,n-a)
b=min(b,n-b)

mod=10**9+7

def modinv(n):
    return pow(n,mod-2,mod)

ra=1
for i in range(a):
    ra*=(n-i)
    ra*=modinv(i+1)
    ra%=mod

rb=1
for i in range(b):
    rb*=(n-i)
    rb*=modinv(i+1)
    rb%=mod
    
r=((2**n-1)%mod-ra-rb)%mod

print(r)

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

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

    int num[110]={0};
    for(int i =0;i<N;i++){
        num[d[i]]++;
    }
    int res =0;
    for(int i=1; i<=100;i++){
        if(num[i]){
            res++;
        }
    }
    cout <<res<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF = 2e9;
const ll MOD = 1e9 + 7;
// ------------------------------------------------

int main(void) {
    int N;
    cin >> N;
    vector<int> b(N);
    for (int i = 0; i < N; i++) {
        int temp;
        cin >> temp;
        b[i] = temp - 1;
    }

    vector<int> ans;
    while (b.size() != 0) {
        int prevLen = b.size();
        for (int i = b.size() - 1; i >= 0; i--) {
            if (i == b[i]) {
                ans.push_back(i);
                b.erase(b.begin() + i);
                break;
            }
        }
        int nowLen = b.size();
        if (prevLen == nowLen) {
            break;
        }
    }

    if (b.size() == 0) {
        for (int i = ans.size() - 1; i >= 0; i--) {
            cout << ans[i] + 1 << endl;
        }
    } else {
        cout << -1 << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define sz(v)   ((int)(v).size())
#define  all(v)    ((v).begin()),((v).end())
#define  allr(v)    ((v).rbegin()),((v).rend())
#define   pb         push_back
#define   mp         make_pair
#define   mt         make_tuple
#define   Y            imag()
#define   X            real()
#define    clr(v,d)      memset( v, d ,sizeof(v))
#define   angle(n)      atan2((n.imag()),(n.real()))
#define   vec(a,b)       ((b)-(a))
//#define   length(a)      hypot( (a.imag()),(a.real()) )
#define   normalize(a)      (a)/(length(a))
#define    dp(a,b)          (((conj(a))*(b)).real())
//#define    cp(a,b)          (((conj(a))*(b)).imag())
#define    lengthsqrt(a)       dp(a,a)
#define    rotate0( a,ang)    ((a)*exp( point(0,ang) ))
#define    rotateA(about,p,ang)   (rotate0(vec(about,p),ang)+about)
#define    reflection0(m,v)         (conj((v)/(m))*(m))
#define     reflectionA(m,v,p0)     (conj( (vec(p0,v))/(vec(p0,m)) ) * (vec(p0,m)) ) + p0
//#define     same(p1,p2)               ( dp(  vec(p1,p2),vec(p1,p2)) < eps )
#define     point                    complex<double>
#define outfile freopen("out.out", "w", stdout);
#define infile  freopen("in.in", "r", stdin);
#define PI acos(-1)
typedef  long long     ll ;
typedef  unsigned long long ull;
const double eps= (1e-9);
using namespace std;
int dcmp(double a,double b){   return fabs(a-b)<=eps ? 0: (a>b)? 1:-1  ;}
int getBit(ll num, ll idx) {return ((num >> idx) & 1ll) == 1;}
ll setBit1(ll num, int idx) {return num | (1ll<<idx);}
ll setBit0(ll num, int idx) {return num & ~(1ll<<idx);}
ll flipBit(int num, int idx) {return num ^ (1<<idx);}
void FS(){ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);}
const ll mod=1e9+7;
ll L,R;
int mem[62][2][2][2];
int solve(int bit,int fL,int fR,int fS)
{
    if(bit==-1)
        return 1;
    int &ret=mem[bit][fL][fR][fS];
    if(ret!=-1)
        return ret;
    ll ans=0;
    //0 0
    if(getBit(L,bit)==0||fL)
      ans+= solve(bit-1,fL,(fR)||(getBit(R,bit)==1),fS);
    if(ans>=mod)
        ans-=mod;
    // 1 1
    if(fR||getBit(R,bit)==1)
        ans+= solve(bit-1,(fL||(getBit(L,bit)==0)),fR,1);
    if(ans>=mod)
        ans-=mod;
    // 1 0
    if((fR||getBit(R,bit)==1)&&(fL||getBit(L,bit)==0)&&fS)
        ans+= solve(bit-1,fL,fR,fS);
    if(ans>=mod)
        ans-=mod;
    return ret=ans;
}
int main()
{
    cin>>L>>R;
    clr(mem,-1);
    cout<<solve(60,0,0,0)<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef int AHAHA;
#define OMG main
#define HAHAHA(x) cin>>x;
#define YEAH(x,y) cout<<(x-1)*(y-1)<<endl;
typedef void Smile;


AHAHA OMG(Smile){
    AHAHA haha,hahaha;
    HAHAHA(haha);HAHAHA(hahaha);
    YEAH(haha,hahaha);
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#define maxn 200010
using namespace std;
typedef long long ll;
int read()
{
    int x=0,f=1;
    char ch=getchar();
    while(ch-'0'<0||ch-'0'>9){if(ch=='-') f=-1;ch=getchar();}
    while(ch-'0'>=0&&ch-'0'<=9){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
int T,n;
char op[200010];
ll a[maxn];
int top;
void merge()
{
    top=0;
    a[++top]=a[1];
    op[0]='+';
    for(int i=2;i<=n;i++)
    {
        if(op[i-1]=='+'&&op[top-1]=='+')  a[top]+=a[i];
        else{
            op[top]=op[i-1];
            a[++top]=a[i];
        }
    }
    n=top;
}
ll sum[maxn],f[maxn];
int main()
{
        n=read();
        for(int i=1;i<=2*n-1;i++)
        {
            if(i&1)  a[(i+1)/2]=read();
            else{
                char s[3];
                scanf("%s",s);
                op[i/2]=s[0];
            }
        }
        merge();
        sum[n+1]=0;
        for(int i=n;i>=1;i--)  sum[i]=sum[i+1]+a[i];
        f[n]=a[n];
        for(int i=n-1;i>=1;i--)
        {
            if(op[i]=='+')  f[i]=f[i+1]+a[i];
            else{
                if(i==n-1)
                {
                    f[i]=a[i]-a[i+1];
                    continue;
                }
                else{
                    if(op[i+1]=='-')  f[i]=a[i]-a[i+1]+sum[i+2];
                    else              f[i]=max(a[i]-a[i+1]+f[i+2],a[i]-a[i+1]-a[i+2]+sum[i+3]);
                }
            }
        }
        printf("%lld\n",f[1]);
    return 0;
}

Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9;

vector<vector<int>> g;
vector<int> d;
vector<int> tr;
vector<int> sz;

void dfs(int cur, int pre, int dst) {
  tr[cur] = pre;
  d[cur] = dst;
  sz[cur] = 1;
  for (auto&& w : g[cur]) {
    if (w != pre) {
      dfs(w, cur, dst + 1);
      sz[cur] += sz[w];
    }
  }
}

void add_edge(int a, int b) {
  g[a].push_back(b);
  g[b].push_back(a);
}

int main() {
  int n;
  cin >> n;
  g.resize(n);
  d.resize(n, inf);
  sz.resize(n, 1);
  tr.resize(n, inf);

  for (int i = 0; i < n - 1; i++) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    add_edge(a, b);
  }
  dfs(0, -1, 0);
  int t = (d[n - 1]+1) / 2;
  int rt = n - 1;
  for (int i = 0; i < t-1; i++) rt = tr[rt];

  string ans = ((n - sz[rt] > sz[rt]) ? "Fennec" : "Snuke");
  cout << ans << endl;
//  cerr << rt << " " << sz[rt] << endl;
//  for (auto&& w : sz) cerr << sz[w] << " ";
}


Measured memory_bytes: 13184
#include<bits/stdc++.h>
using namespace std;
int A[300005];
int main(){
int n,h;cin>>n>>h;
if(h==1||h==2*n-1){
    puts("No");
    return 0;
}
puts("Yes");
int cnt=n-1;
for(int i=1;i<2*n;i++)A[i]=i;
if(n!=h){
    if(h>n&&h!=n+1){
        if(h!=n+1)
        swap(A[n],A[n+2]);
    }
    else{
        if(h!=n-1)
            swap(A[n],A[n-2]);
    }
swap(A[h],A[n]);
if(h>n)
    swap(A[2*n-2+1],A[n+1]);
else
    swap(A[1],A[n-1]);
}
for(int i=1;i<2*n;i++)
    cout<<A[i]<<'\n';
return 0;}


Measured memory_bytes: 2304
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1LL<<60;
const int inf = 2000000000; 
#define rep(i,n) for(int i=0; i<(n);++i)

int main(){
    int N,K;cin>>N>>K;
    vector<ll> h(N),dp(N);
    rep(i,N)dp[i]=INF;
    dp[0]=0LL;
    rep(i,N)cin>>h[i];
    rep(i,N){
        rep(j,K){
            if(i+j+1>=N)continue;
            else{
                dp[i+j+1]=min(dp[i+j+1],dp[i]+abs(h[i]-h[i+j+1]));
            }
        }
    }
    cout<<dp[N-1]<<endl;
    return 0;
}

Measured memory_bytes: 1792
n = int(input())

a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
c = [int(i) for i in input().split()]

sum = 0
temp = -1
for i in a:
  sum += b[i-1]
  if i-1 == temp:
    sum += c[temp-1]
  temp = i
  
print(sum)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int a[200005];
multiset<int> s;
int main(){
    int n;
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>a[i];
        s.insert(a[i]);
    }
    for(int i=1;i<=n;i++){
        s.erase(s.lower_bound(a[i]));
        cout<<*s.rbegin()<<endl;
        s.insert(a[i]);
    }
}

Measured memory_bytes: 11776
#include <iostream>

using namespace std::literals;

namespace abc086
{
	namespace task_B
	{
		struct PairIntegers
		{
			private: unsigned int a;
			private: unsigned int b;

			public:
				void cin (/* No argument */)
				{
					std::cin >> this->a >> this->b;
				}

			public:
				unsigned int Connected (/* No argument */)
				{
					if      (this->b <  10U) return   10U * (this->a) + (this->b);
					else if (this->b < 100U) return  100U * (this->a) + (this->b);
					else                     return 1000U * (this->a) + (this->b);
				}

			private:
				bool IsSquare (/* No argument */)
				{
					unsigned int prod = this->Connected();

					for (unsigned int iter = 1U; iter * iter <= prod; ++iter)
					{
						if (prod == iter * iter) return true;
					}

					return false;
				}

			public: void Answerer (/* No argument */)
			{
				if   ( this->IsSquare() ) std::cout << "Yes"s;
				else                      std::cout <<  "No"s;

				std::cout << "\n"s;
			}
		};
	} // namespace task_B
	
} // namespace abc086


int main (void)
{
	// variables for main process
	abc086::task_B::PairIntegers given_data;

	// STEP.01
	// read out the given data
	given_data.cin();

	// STEP.02
	// output the answer of this task
	given_data.Answerer();

	// STEP.END
	return EXIT_SUCCESS;
}

Measured memory_bytes: 256
use proconio::input;

fn main() {
  input! {
    n: usize, k: usize,
    mut p: [usize; n]
  }

  p.sort();

  let mut ans = 0;
  for i in 0..k {
    ans += &p[i];
  }

  println!("{}", ans);


  //println!("Hello, AtCoder!");
}


Measured memory_bytes: 2144
#include <bits/stdc++.h>
using namespace std;
int main() {
	long a, b;
	cin >> a >> b;
	long ans = a;
	if ((b - a) < 100) {
		for (long i = a + 1; i <= b; i++) {
			ans ^= i;
		}
		cout << ans << endl;
		return 0;
	}
	int mod1 = a % 4, mod2 = b % 4;
	for (int i = 1; i <= 3 - mod1; i++) {
		ans ^= a + i;
	}
	for (int i = 0; i <= mod2; i++) {
		ans ^= b - i;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
//by tzupengwang™
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<vector>
#include<queue>
#include<set>
#include<iostream>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> ii;

int n;
int s[55];

void init() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i ++) {
    scanf("%d", &s[i]);
  }
}

void process() {
  vector<int> p, v;
  int pm = 0, nm = 0;
  int pp = 0, np = 0;

  for (int i = 1; i <= n; i ++) {
    if (s[i] >= 0) {
      if (s[i] >= pm)
        pm = s[i], pp = i;
    }
    if (s[i] < 0) {
      if (s[i] <= nm) {
        nm = s[i], np = i;
      }
    }
  }

  vector<ii> ans;
  if (pm + nm >= 0) {
    for (int i = 1; i <= n; i ++) {
      ans.push_back(ii(pp, i));
    }
    for (int i = 1; i < n; i ++) {
      ans.push_back(ii(i, i + 1));
    }
  } else {
    for (int i = 1; i <= n; i ++) {
      ans.push_back(ii(np, i));
    }
    for (int i = n; i > 1; i --) {
      ans.push_back(ii(i, i - 1));
    }
  }
  printf("%d\n", (int)ans.size());
  for (ii x : ans) {
    printf("%d %d\n", x.first, x.second);
  }
}

int main() {
/*
#ifdef ONLINE_JUDGE
freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);
#endif
  int Cases;
  scanf( "%d" , &Cases ) ;
  for ( int cases = 1 ; cases <= Cases ; cases ++ ) {
*/
    init() ;
    process() ;
/*
  }
*/
  return 0 ;
}


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

int main(){
  int n;
  cin>>n;
  string ans;
  if(n==0){
    cout<<0<<endl;
  }
  while(n!=0){
    if(n%2!=0){
      n--;
      ans='1'+ans;
    }else{
      ans='0'+ans;
    }
    n/=-2;
  }
  cout<<ans<<endl;
} 

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

int main()
{
    ll result = 0;
    ll N;
    cin >> N;
    vector<ll> A(N);
    for(int i=0;i<N;i++){
        cin >> A[i];
    }
    for (ll i = 0; i < N; i++)
    {
        while (i + 1 < N && A[i + 1] == A[i])
        {
            i++;
        }
        if (i + 1 < N && A[i + 1] > A[i])
        {
            while (i + 1 < N && A[i + 1] >= A[i])i++;
        }
        else if (i + 1 < N && A[i + 1] < A[i])
        {
            while (i + 1 < N && A[i + 1] <= A[i])
                i++;
        }
        result++;
    }
    cout << result << endl;
}

Measured memory_bytes: 3976
import Control.Applicative
import Control.Monad

solver :: Int -> Int -> Int -> [String]
solver 1 _ w = [concat (replicate w "#")]
solver n h w =
  if n == h
    then concat (replicate w "#") : solver (n-1) h w
  else
    ("#" ++ concat (replicate (w - 2) ".") ++ "#") : solver (n-1) h w


main :: IO()
main = do
  (h:w:_) <- map (read :: String -> Int) . words <$> getLine
  unless (h == 0 && w == 0) $ do
    mapM_ putStrLn $ solver h h w
    putStrLn ""
    main

Measured memory_bytes: 4088
mod = 10**9+7
rng = 100100
fctr = [1]
finv = [1]
for i in range(1,rng):
  fctr.append(fctr[-1]*i%mod)
for i in range(1,rng):
  finv.append(pow(fctr[i],mod-2,mod))
n = int(input())
a = list(map(int,input().split()))
b = [a[i]-a[i-1] for i in range(1,n)]
lsini = [1,3]
ls = [fctr[n-1],fctr[n-1]*3*finv[2]%mod]
for i in range(2,n-1):
  x = lsini[-1]
  lsini.append(((i+1)*x+fctr[i])%mod)
  ls.append((lsini[-1]*fctr[n-1]*finv[i+1])%mod)
ans = 0
for i in range(n-1):
  ans = (ans + ls[i]*b[i])%mod
print(ans)

Measured memory_bytes: 27128
#include <bits/stdc++.h>
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define all(x) x.begin(), x.end()

using namespace std;

typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
typedef long long ll;

template <typename T> void max_self(T& a, T b){
  a = max(a,b);
}

template <typename T> void min_self(T& a, T b){
  a = min(a,b);
}

void solve(){	
  int n;cin>>n;
  map<string,int> m;
  string str;
  for(int i=0;i<n;i++){
    cin>>str;
    m[str]++;
  }
  vector<string> par = {"AC", "WA", "TLE", "RE"};
  for(auto it:par){
    cout<<it<<" x "<<m[it]<<endl;
  }
}

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


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);

    double L;
    cin>>L;

    double x=L/3;
    double y=(L-x)/2;
    double z=L-x-y;
    printf("%lf\n",x*y*z);

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#define MAX(x,y) (x > y ? x : y)
typedef long long int lld;
typedef unsigned long long int llu;

int main(void) {
  int n, w, vs[100], ws[100], t[100][10001];

  scanf("%d%d", &n, &w);
  for (int i = 0; i < n; i++) {
    scanf("%d%d", &vs[i], &ws[i]);
  }

  for (int i = 0; i < n; i++) {
    for (int j = 0; j <= w; j++) {
      if (ws[i] <= j) {
        t[i][j] = i ? MAX(t[i - 1][j - ws[i]] + vs[i], t[i - 1][j]) : vs[i];
      } else {
        t[i][j] = i ? t[i - 1][j] : 0;
      }
    }
  }
  printf("%d\n", t[n - 1][w]);
  return 0;
}


Measured memory_bytes: 5612
n,k = map(int,input().split())
mod = 10**9+7
ans = [0]*(k+1)
fac = [0]*(n+1)
inv = [0]*(n+1)
def comb(n,k):
    if n < k: return 0
    if n < 0 or k < 0: return 0
    return fac[n]*inv[k]%mod*inv[n-k]%mod
fac[0] = inv[0] = 1
for i in range(1,n+1):
    fac[i] = fac[i-1]*i%mod
    inv[i] = pow(fac[i],mod-2,mod)
for i in range(1,k+1):
    ans = comb(n-k+1,i)%mod*comb(k-1,i-1)%mod
    print(ans)

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

#define rep(ver,n) rep2(ver,0,n)
#define rep2(ver,m,n) for(int ver=m;i<(n);i++)
#define dup(x,y) (((x)+(y)-1)/(y))
#define vecadd emplace_back

typedef long long ll;

int main(){
  int n;
  int a[22],c[22];
  cin>>n;
  int ans=0;
  rep(i,n){
    cin>>a[i];
  }
  rep(i,n){
    int b;
    cin>>b;
    ans+=b;
  }
  rep(i,n-1){
    cin>>c[i];
  }
  
  rep2(i,1,n){
      if(a[i-1]+1==a[i]){
        ans+=c[a[i-1]-1];
    }
  }
  
  cout<<ans;
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define F first
#define S second
#define pb push_back
#define eb emplace_back
#define INF LLONG_MAX
#define PI 3.14159265359
#define sz(c) (int)c.size()
#define len(c) (int)c.length()
#define hcf(a, b) __gcd(a, b)
#define all(c) c.begin(), c.end()
#define vint vector<int>
#define vll vector<ll>
#define vpint vector<pair<int, int>>
#define vpll vector<pair<ll, ll>>
#define tr(con, it) \
    for (auto it = con.begin(); it != con.end(); it++)
#define fr(it, a, b) \
    for (int it = (a); it < (b); it++)
#define present(con, ele) (con.find(ele) != con.end())
#define cpresent(con, ele) (find(all(con), ele) != con.end())
#define maximum(a, b, c) (a > b ? (a > c ? a : c) : (b > c ? b : c))
#define minimum(a, b, c) (a < b ? (a < c ? a : c) : (b < c ? b : c))
typedef long long ll;
typedef long double lf;
typedef unsigned long long lu;
const ll mod = 1e9 + 7;
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n, m, x, ans = 1e9;
    cin>>n>>m>>x;
    vint cos(n);
    vector<vint> a(n, vint(m));
    fr(i, 0, n)
    {
        cin >> cos[i];
        fr(j, 0, m)
        {
            cin >> a[i][j];
        }
    }
    int tp = pow(2, n);
    fr(i, 0, tp)
    {
        bitset<12> b(i);
        int cost = 0, flag = 1;
        vint sk(m, 0);
        fr(j, 0, n)
        {
            if (b[j] == 1)
            {
                cost += cos[j];
                fr(k, 0, m)
                {
                    sk[k] += a[j][k];
                }
            }
        }
        fr(j, 0, m)
        {
            if (sk[j] < x)
            {
                flag = 0;
            }
        }
        if (flag)
        {
            ans = min(ans, cost);
        }
    }
    ans == 1e9 ? cout << -1 << "\n" : cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 4012
#include <iostream>

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

using namespace std;

int area[50][50], cnt = 0;
int w, h;

void dfs(int x ,int y)
{
  area[x][y] = 0;

  for(int dx = -1 ; dx <= 1 ; dx++){
    for(int dy = -1 ; dy <= 1 ; dy++){
      int nx = x + dx, ny = y + dy;

      if(0 <= nx && nx < w && 0 <= ny && ny < h && area[nx][ny] == 1){
	dfs(nx, ny);
      }
    }
  }
}

int main()
{
  while(true){
    cin >> w >> h;
    if(w == 0 && h == 0) break;

    rep(j, h){
      rep(i, w){
	cin >> area[i][j];
      }
    }

    rep(i, w){
      rep(j, h){
	if(area[i][j] == 1){
	  dfs(i, j);
	  cnt++;
	}
      }
    }
    
    cout << cnt << '\n';
    cnt = 0;
  }
}

Measured memory_bytes: 1348
h, w = map(int, input().split())
l = [list(map(str, input().split())) for _ in range(h)]

ans = ""
for i in range(h):
    for j in range(w):
        if l[i][j] == "snuke":
            ans = "{}{}".format(chr(ord('A')+j), i+1)


print(ans)


Measured memory_bytes: 3060
#include <iostream>
#include <map>

using namespace std;

#define dump(n) cout<<"# "<<#n<<'='<<(n)<<endl

map<string,int> f;
string s;
int i;

int molecules();
int molecule();
int atom();
int number();

int molecules()
{
	//cout<<"molecules "<<i<<endl;
	int x=0;
	while(i<s.size() && s[i]!=')')
		x+=molecule();
	return x;
}

int molecule()
{
	//cout<<"molecule "<<i<<endl;
	if(i==s.size())
		return 0;
	if(s[i]=='('){
		i++;
		int m=molecules();
		i++;
		int n=number();
		return m*n;
	}
	int x=atom();
	if(i<s.size() && isdigit(s[i]))
		x*=number();
	return x;
}

int atom()
{
	//cout<<"atom "<<i<<endl;
	string a(1,s[i++]);
	if(i<s.size() && islower(s[i]))
		a+=s[i++];
	if(!f.count(a))
		throw "UNKNOWN";
	return f[a];
}

int number()
{
	//cout<<"number "<<i<<endl;
	int n=0;
	while(i<s.size() && isdigit(s[i]))
		n=n*10+s[i++]-'0';
	return n;
}

int main()
{
	while(cin>>s && s!="END_OF_FIRST_PART"){
		int w; cin>>w;
		f[s]=w;
	}
	while(cin>>s && s!="0"){
		i=0;
		try{
			cout<<molecules()<<endl;
		}
		catch(const char* message){
			cout<<message<<endl;
		}
	}
}

Measured memory_bytes: 1296
#include<cstdio>
#include<iostream>
int main(void){
    int d,sum;
    while(scanf("%d",&d)!=EOF){
    sum=0;
    for(int i=d;i<600;i+=d){
        sum+=i*i*d;
    }
    printf("%d\n",sum);
    }
    return 0;
}

Measured memory_bytes: 1188
N, M = [int(x) for x in input().split()]
S1 = []
S2 = []
for i in range(M):
	S1 = [int(x) for x in input().split()]
	if S1[0] == 1:
		S2.append(S1[1])
	if S1[1] == N:
		S2.append(S1[0])
		
if len(S2) == len(set(S2)):
	print("IMPOSSIBLE")
else:
	print("POSSIBLE")



Measured memory_bytes: 23280
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <time.h>
#include <stdlib.h>
#include <string>
#include <bitset>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <sstream>
#include <stack>
#include <iomanip>
using namespace std;
#define pb push_back
#define mp make_pair
typedef pair<int,int> pii;
typedef long long ll;
typedef double ld;
typedef vector<int> vi;
#define fi first
#define se second
#define fe first
#define FO(x) {freopen(#x".in","r",stdin);freopen(#x".out","w",stdout);}
#define Edg int M=0,fst[SZ],vb[SZ],nxt[SZ];void ad_de(int a,int b){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;}void adde(int a,int b){ad_de(a,b);ad_de(b,a);}
#define Edgc int M=0,fst[SZ],vb[SZ],nxt[SZ],vc[SZ];void ad_de(int a,int b,int c){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;vc[M]=c;}void adde(int a,int b,int c){ad_de(a,b,c);ad_de(b,a,c);}
#define es(x,e) (int e=fst[x];e;e=nxt[e])
#define esb(x,e,b) (int e=fst[x],b=vb[e];e;e=nxt[e],b=vb[e])
#define SZ 233333
ll f[333][333],t[333][333];
int n,k,MOD;
ll C[333][333];
int main()
{
	cin>>n>>k>>MOD;
	for(int i=0;i<=303;++i)
	{
		C[i][0]=1;
		for(int j=1;j<=i;++j)
			C[i][j]=(C[i-1][j-1]+C[i-1][j])%MOD;
	}
	for(int i=1;i<=k;++i)
		f[1][i]=t[1][i]=i;
	for(int i=2;i<=n;++i)
	{
		int su=0;
		for(int r=1;r<=k;++r)
			(su+=t[i-1][r-1])%=MOD,f[i][r]=su;
		for(int j=1;j<=k;++j)
		{
			t[i][j]=f[i][j];
			for(int a=1;a<i;++a)
				(t[i][j]+=f[a][j]*t[i-a][j]%MOD*C[i-1][i-a])%=MOD;
		}
	}
	ll ans=t[n][k];ans=(ans%MOD+MOD)%MOD;
	printf("%lld\n",ans);
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
int flag[1001];
map<int,int>mp;
map<int,int>mp1;
int ara[5];
int main()
{
    string s,s1;
    int c=0,f=0,i,a,b;
    cin>>a;
    cin>>s>>s1;
    for(i=0;i<a;i++)
    {
       cout<<s[i];
       cout<<s1[i];
    }
    cout<<"\n";
}


Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
#define ll long long
#define pb push_back
#define empb emplace_back
#define mp make_pair
#define F first
#define S second
#define endl "\n"
#define vii vector<int>
#define vll vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define vpii vector<pii>
#define mapii map<int,int> 
#define mapll map<ll,ll>
#define all(a) a.begin(),a.end()
#define test ll t; cin>>t; while(t--)
#define prec(n) fixed<<setprecision(n)
#define jaldibazi ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define mod 1000000007


int main(){
	jaldibazi;

	int n; cin >> n;
	vii a(n);
	int s = 0;
	for(int & i : a) cin >> i, s+=i;


	int m ; cin>> m;
	while(m--) {
		int x, y; cin >> x >> y;
		--x;
		int z = y - a[x];
		// cout << x << " " << y <<" " << a[x] << " " << z << "\n";
		cout << s+ z  << "\n";
	}	
}

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

using namespace std;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
typedef vector<pi> vpi;
typedef vector<bool> vbool;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define forall(it,s) for(auto it = s.begin(); it != s.end(); ++it)
#define F0(i,n) for(ll i = 0; i < n; i++)
#define F1(i,n) for(ll i = 1; i <= n; i++)
#define rep(i,a,b) for(int i = a; i <= b; i++)
#define per(i,a,b) for(int i = b-1; i >= a; i--)
#define FIN ios::sync_with_stdio(false);cin.tie(0);
#define db(x) cout<<#x<<" = "<<x<<"\n"
#define all(v) v.begin(),v.end()
#define modulo(a,b) ((a%b)+b)%b
#define F first
#define S second
#define INF 1000000010
#define INFLL 1000000000000000000
#define eps 0.000000000001
#define mod 1000000007
template<class C> void mini(C&a, C b){ a=min(a, b);}
template<class C> void maxi(C&a, C b){a=max(a,b);}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}

//=======================//
const int maxn = 100, maxv = 1e3 * 100 + 3;
ll  n,W;
ll dp[maxn][maxv];
vll w,v;

int main () {
	//FIN

	cin >> n >> W;
	w = v = vll(n);
	F0(i,n) cin >> w[i] >> v[i];
	F0(i,maxn) F0(j,maxv) dp[i][j] = INFLL;
	dp[0][0] = 0;
	dp[0][v[0]] = w[0];
	F0(i,n-1) F0(j,maxv) {
		mini(dp[i+1][j], dp[i][j]);
		if (j + v[i+1]  < maxv) mini(dp[i+1][j+v[i+1]], dp[i][j] + w[i+1]);
	}
	ll res = 0;
	F0(i,maxv) {
		if (dp[n-1][i] <= W) maxi(res, i);
	}
	cout << res << "\n";

	return 0;
}










Measured memory_bytes: 81740
//sppsfver - 20.08.2020
#include <bits/stdc++.h>
using namespace std;

using ll = long long;
using pll = pair <ll, ll>;
const int MAX = 1e5+5;

ll a, b, c, d;

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

	cin >> a >> b >> c >> d;
	cout << max ({a*c, b*d, a*d, b*c}) << endl;

    return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
//----***やべーやつら***----
using namespace std;
#define int long long

//----***型定義***----
using ll = long long;
using P = pair<int,int>;

//----***Like a Pythonista***----
#define REP(ii,jj,nn) for (ll ii=jj;ii<(nn);ii++)
#define RREP(ii,nn,jj) for (ll ii = nn; jj<ii;ii--)
#define each(i,...) for (auto&& i:__VA_ARGS__)
#define ALL(vec) (vec).begin(),(vec).end()
#define sum(...) accumulate(ALL(__VA_ARGS__),0LL)
#define dsum(...) accumulate(ALL(__VA_ARGS__),0.0)
#define vec(type,name,...) vector<type> name(__VA_ARGS__)
template<class T> inline auto max(const T& a){ return *max_element(ALL(a)); }
template<class T> inline auto min(const T& a){ return *min_element(ALL(a)); }
inline ll gcd(ll a,ll b){if(b == 0) return a;return  gcd(b,a%b);}
inline ll lcm(ll a,ll b){ll g = gcd(a,b);return a / g * b;}

//----***定数***----
#define MOD 1000000007
#define INF 100000000000000000
#define EPS 1e-9
#define PI  acos(-1)
const vector<vector<int>> DXY={{-1,0},{1,0},{0,-1},{0,1}};

//----***パーツ***----
#define fi first
#define se second
#define pb push_back
#define re return
#define br break

//----***入出力***---
void print() { std::cout << "\n"; }
template <class T>void print(const T &x) {std::cout << x<<"\n";}
template <class T, class... Args>void print(const T &x, const Args &... args) {std::cout << x << " ";print(args...);}
#define debug(var)  do{std::cerr << #var << " ↓ "<<"\n";view(var);}while(0);
#define dbg cerr<<"🥺🥺🥺🥺🥺🥺"<<endl;
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }

//----***初期時読み込み***----
struct initial{initial(){cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(15);};}initial_;

signed main(){
  char c;cin>>c;
  int a=(int)c-'a'+1;
  c=a+'a';
  print(c);


}


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

int main() {

	int a, b; cin >> a >> b;
	bool can = false;
	if (a <= 8 && b <= 8) can = true;
	if (can) cout << "Yay!" << endl;
	else cout << ":(" << endl;
	return 0;
}

Measured memory_bytes: 3632
#define _USE_MATH_DEFINES 
#include<iomanip> 
#include<cmath>  
#include<iostream>
#include<fstream>
#include<vector>
#include<algorithm>
#include<numeric>
#include<bitset>
#include<map>
#include<unordered_map>
#include<set>
#include<unordered_set>
#include<queue>
#include<deque>
#include<stack>
using namespace std;
typedef long long ll;
#define repi(i,a,b) for(ll i = (ll)(a) ; i < (ll)(b) ; i++)
#define repd(i,a,b) for(ll i = (ll)(a) ; i > (ll)(b) ; i--)
#define rd(x) cin >> x
#define wr(x)  cout << x
#define wrln(x) cout << x << endl

ll N;
ll pow2[3];

int main() {
	rd(N);
	repi(i, 0, N) {
		ll a;
		rd(a);
		if (a % 4 == 0) pow2[2]++;
		else if (a % 2 == 0) pow2[1]++;
		else pow2[0]++;
	}
	if (pow2[0] <= pow2[2]) wrln("Yes");
	else if (pow2[0] == pow2[2] + 1 && pow2[1] == 0) wrln("Yes");
	else wrln("No");
	return 0;
}

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

cnt = 0
Ans = "No"

while cnt <= K:
  if A >= B:
    B *= 2
    cnt += 1
  else:
    break
    
while cnt <= K:
  if B >= C:
    C *= 2
    cnt += 1
  else:
    Ans = "Yes"
    break

print(Ans)


Measured memory_bytes: 9184
#include<bits/stdc++.h>
#define ll long long

using namespace std;

int main()
{
	 string s;
	 cin>>s;
	 cout<<"2018";
	 for(int i = 4 ; i < s.size() ; i++)
	 {
	 	cout<<s[i];
	 }
	 cout<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define nl "\n"
#define pi acos(-1)
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define pcase printf("Case %d:\n",ca)
int ca=1;
using namespace std;
int main(){
    int n ;
    cin>>n;
    int arr[n];
    for(int i = 0;i<n;i++){
        cin>>arr[i];
    }
    int sum = 0;
    sort(arr,arr+n);
    for(int i = 0;i<n;i++){
       for(int j = i+1;j<n;j++){
        for(int k = j+1;k<n;k++){
            if(arr[i]+arr[j]>arr[k] && arr[j]+arr[k]>arr[i] && arr[k]+arr[i]>arr[j] && arr[i]!= arr[j]&& arr[i]!=arr[k] && arr[j]!=arr[k]){

                sum++;
              //  cout<<arr[i]<<arr[j]<<arr[k]<<nl;
            }
             
        }
       }
    }
    cout<<sum<<nl;
}


Measured memory_bytes: 3624
main = do
  [a, _] <- map read . words <$> getLine
  s <- getLine
  putStr $ solve a s

solve (-1) [] = "Yes"
solve (-1) (x:xs)
  | x `elem` ['0'..'9'] = solve (-1) xs
  | otherwise = "No"
solve 0 (x:xs)
  | x == '-' = solve (-1) xs
  | otherwise = "No"
solve a (x:xs)
  | x `elem` ['0'..'9'] = solve (a - 1) xs
  | otherwise = "No"


Measured memory_bytes: 508
#include <functional>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;

int main() {
    cin.sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int n;
    cin >> n;

    int cur = 0;
    int no_use = -1;
    int i = 1;
    for (; i <= n; i++) {
        cur += i;
        if (cur >= n) {
            no_use = cur - n;
            break;
        }
    }

    for (int j = 1; j <= i; j++) {
        if (j != no_use) cout << j << '\n';
    }

    return 0;
}

Measured memory_bytes: 256
/* [Template].cpp 
Example code to use when starting new code. This particular problem was problem 
977A_Wrong_Subtraction from CodeForces

Compile: g++  -o A.exe A.cpp 
Execute: ./A
*/ 

#include <cstdio>
#include <iostream>
#include <cmath> 
#include <limits> 
#include <iomanip>
#include <cstring> 
#include <bits/stdc++.h>
#include <string>  
using namespace std;

int main() { 	
	char a, b, c; 
	int result = 0; 
	
	cin >> a >> b >> c; 
		
	if(a == 'R') {
		if(b == 'R') {
			if(c == 'R') 
				result = 3; 
			else 
				result = 2; 
		} else {
			result = 1; 
		}
	} else {
		if(b == 'R') {
			if(c == 'R')
				result = 2; 
			else 
				result = 1; 
		} else {
			if(c == 'R')
				result = 1;
			else 
				result = 0; 
		}
	}
	
	cout << result << endl; 
	
	return 0; 
} 


Measured memory_bytes: 3620
const stdin = require('fs')
  .readFileSync('/dev/stdin', 'utf8')
  .trim()

const [l, r] = stdin
  .split('\n')[0]
  .split(' ')
  .map(Number)

const ans = () => {
  if (r - l >= 2019) {
    return 0
  } else {
    let min = Infinity
    for (let i = l; i < r; i++) {
      for (let j = i + 1; j <= r; j++) {
        if (i !== j) {
          const mod = ((i % 2019) * (j % 2019)) % 2019

          min = Math.min(min, mod)
        }
      }
    }

    return min
  }
}

console.log(ans())


Measured memory_bytes: 7500