akhauriyash/Code-Regression huggingface dataset:
//#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <iomanip>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <climits>
#include <bitset>

using namespace std;

const int SIZE = 1 << 17;
int pointer = SIZE;
char buffer[SIZE];

char Advance() {
    if (pointer == SIZE) {
        fread(buffer, 1, SIZE, stdin);
        pointer = 0;
    }
    return buffer[pointer++];
}

int Read() {
    int answer = 0;
    char ch = Advance();
    while (!isdigit(ch))
        ch = Advance();
    while (isdigit(ch)) {
        answer = answer * 10 + ch - '0';
        ch = Advance();
    }
    return answer;
}

const int MAXN = 200000;
const int SIGMA = 26;

char s[1 + MAXN];
deque<int> where[SIGMA];
int fenwick[1 + MAXN];

bool Check(int n) {
    for (int i = 1; i <= n; i++)
        where[s[i] - 'a'].push_back(i);
    int odd = 0;
    for (int i = 0; i < SIGMA; i++)
        if (where[i].size() % 2)
            odd++;
    if ((n % 2 == 0 && odd == 0) || (n % 2 == 1 && odd == 1))
        return true;
    return false;
}

void Update(int x, int n, int add) {
    for (; x <= n; x += x & -x)
        fenwick[x] += add;
}

int Query(int x) {
    int answer = 0;
    for (; x > 0; x -= x & -x)
        answer += fenwick[x];
    return answer;
}

void Initialize(int n) {
    for (int i = 1; i <= n; i++)
        Update(i, n, 1);
}

long long Solve(int n) {
    Initialize(n);
    long long answer = 0;
    for (int i = 1; 2 * i <= n; i++) {
        int best = 4 * MAXN, which = -1;
        for (int j = 0; j < SIGMA; j++)
            if (where[j].size() >= 2) {
                int a = where[j].front(), b = where[j].back();
                int moves = Query(a - 1) + Query(n) - Query(b);
                if (moves < best) {
                    best = moves;
                    which = j;
                }
            }
        answer += best;
        Update(where[which].front(), n, -1);
        Update(where[which].back(), n, -1);
        where[which].pop_front();
        where[which].pop_back();
    }
    return answer;
}

int main() {
    //freopen("tema.in", "r", stdin);
    //freopen("tema.out", "w", stdout);
    scanf("%s", s + 1);
    int n = strlen(s + 1);
    if (!Check(n)) {
        printf("-1\n");
        return 0;
    }
    printf("%lld\n", Solve(n));
    return 0;
}


Measured memory_bytes: 2048
import Data.List
import Control.Monad
import Control.Applicative

main :: IO ()
main = do
  t <- readLn :: IO Int
  replicateM_ t $ do
    [n, k] <- map read . words <$> getLine :: IO [Int]
    xs <- map read . words <$> getLine :: IO [Int]
    print $ if n - k <= 0 then 0 else sum $ take (n - k) $ sort $ zipWith (-) (tail xs) xs

Measured memory_bytes: 36392
// 2017/12/03
// Problem URL:

import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] num = br.readLine().trim().split("");
        int count = 0;
        for(int i=0; i<num.length-1; i++){
            if(num[i].equals(num[i+1])){
                count++;
                if(count == 2) break;
            }else{
                count = 0;
            }
        }
        if(count == 2) System.out.println("Yes");
        else System.out.println("No");
    }
}

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

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

    int N;
    cin >> N;

    vector<int> A(N);

    for(int i = 0; i < N; i++) cin >> A[i];

    sort(A.begin(), A.end(), greater<int>());

    int a = 0, b = 0;

    for(int i = 0; i < N; i++) {
        if(i % 2) b += A[i];
        else a += A[i];
    }

    cout << a - b << endl;
}

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


  
int stringcount(string s, char c) {
    return count(s.cbegin(), s.cend(), c);
}

int main(){

  int N,X=0;
  
  cin>>N>>X;
  
  int m[N];
  int sum=0;

  int count=0;
  int min=2000;
  rep(i,N){
	cin>>m[i];
    sum+=m[i];
    count++;
    if(min>m[i])min=m[i];
  }
  X-=sum;
  while(X>=min){
	X-=min;
    count++;
  }
  cout<<count<<endl;
  

  
}






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

vector<vector<int>> DIRECTIONS = {{0,1},{0,-1},{1,0},{-1,0}};


void bfs(int Sh, int Sw, vector<string> &S, vector<vector<bool>> &visited, queue<pair<int,int>> &now_pos) {
  queue<pair<int,int>> q;
  q.push(make_pair(Sh, Sw));
  int h, w, y, x;
  while (!q.empty()) {
    tie(h, w) = q.front(); q.pop();
    now_pos.push(make_pair(h, w));
    for (auto next: DIRECTIONS) {
      y = h + next[0];
      x = w + next[1];
      if (S[y][x] == '#') continue;
      if (visited[y][x]) continue;
      q.push(make_pair(y, x));
      visited[y][x] = true;
    }
  }
}


void move_b(int Sh, int Sw, vector<string> &S, vector<vector<bool>> &visited, queue<pair<int,int>> &next_pos) {
  int h, w;
  for (int i: {-2, -1, 0, 1, 2}) {
    h = Sh + i;
    for (int j: {-2, -1, 0, 1, 2}) {
      w = Sw + j;
      if (S[h][w] == '#') continue;
      if (visited[h][w]) continue;
      next_pos.push(make_pair(h, w));
      visited[h][w] = true;
    }
  }
}


int main() {
  int H, W, Ch, Cw, Dh, Dw;
  cin >> H >> W >> Ch >> Cw >> Dh >> Dw;
  Ch++; Cw++; Dh++; Dw++;
  vector<string> S(H + 4);
  for (int i: {0, 1, H + 2, H + 3}) {
    S[i] = string(W + 4, '#');
  }
  string s;
  for (int i = 2; i < H + 2; i++) {
    cin >> s;
    S[i] = "##" + s + "##";
  }

  int ans = 0;
  vector<vector<bool>> visited(H + 4, vector<bool>(W + 4, false));
  queue<pair<int,int>> now_pos;
  queue<pair<int,int>> next_pos;
  next_pos.push(make_pair(Ch, Cw));
  visited[Ch][Cw] = true;
  int h, w;
  while (true) {
    while (!next_pos.empty()) {
      tie(h, w) = next_pos.front(); next_pos.pop();
      bfs(h, w, S, visited, now_pos);
    }

    if (visited[Dh][Dw]) break;

    while (!now_pos.empty()){
      tie(h, w) = now_pos.front(); now_pos.pop();
      move_b(h, w, S, visited, next_pos);
    }
    if (next_pos.empty()) {
      ans = -1;
      break;
    }
    ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 5752
#include<bits/stdc++.h>
typedef long long ll;
typedef long double ld;
using namespace std;
const int nmax = 100005;
const ll mod = 1e4;
const ll inf = 1e9;
const ld EPS = 1e-2;
const ld PI = acos(-1.0);
const int kor = 320;
ll rec(ll a, ll b){
    if (a > b) swap(a, b);
    ll d = b / a;
    if (b % a == 0) return (d + d - 1) * a;
    else return (d + d) * a + rec(a, b % a);
}
int main(){
    ios_base::sync_with_stdio(false);
    ll n, x;
    cin >> n >> x;
    cout << n + rec(x, n - x) << '\n';
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const ll mod = 1000000007;
const ll INF = mod * mod;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
typedef vector<int> vec;
typedef vector<string> svec;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
//#define int long long

void solve() {
    int N; cin >> N;
    ld A[110];
    rep(i, N) {
        cin >> A[i];
        A[i] = (ld)1 / A[i];
    }
    ld ans = 0;
    rep(i, N) {
        ans += A[i];
    }
    ans = (ld)1 / ans;
    cout << ans << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(10);
	//init();
	solve();
	//cout << "finish" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define SC               scanf
#define PF               printf
#define ull              unsigned long long
#define ld               long double
#define D                double
#define F                first
#define S                second
#define pb               push_back
#define pf               push_front
#define MP               make_pair
#define sort_a(a)        sort(a.begin(),a.end());
#define sort_d(a)        sort(a.rbegin(),a.rend());
#define READ(f)          freopen(f, "r", stdin)
#define WRITE(f)         freopen(f, "w", stdout)
#define rev(s)           reverse(s.begin(),s.end())
#define it(it,mp)        for(auto it=mp.begin() ; it!=mp.end() ; it++)
#define IOS              ios_base :: sync_with_stdio(false); cin.tie(NULL);
#define ll long long
typedef pair<int,int>                   PII;
#define ordered_set Tree<PII, null_type,less<PII>, rb_Tree_tag,Tree_order_statistics_node_update>
const int N = 1e5 + 5;
const int inf = 1e9 + 1;
const double eps = 1e-15;
const double EPS = 1e-9;
const double PI = acos(-1.0);
int main()
{
    // IOS
    // READ("0in.txt");
    // WRITE("0out.txt");
    ll d, n ;
    cin >> d >> n ;
    ll temp = pow(100 , d) ;
    ll res = n == 100 ? n + 1 : n ;
   // cout<<temp<<" "<<res<<endl ;
    cout<< res * temp << endl ;


}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define print(x)cout<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

int main() {
  int n;
  cin>>n;
  vi a(n+1);
  int cnt = 0;
  rep(i,n){
    cin>>a[i];
    a[i]--;
  }

  rep(i,n){
    if(a[i] == i){
      swap(a[i],a[i+1]);
      cnt++;
    }
  }
  print(cnt);
  return 0;
}

Measured memory_bytes: 640
n,k = map(int,input().split())
a = list(map(int,input().split()))
mod = 10**9 + 7

dp = [[0]*(k+1) for _ in range(n+1)]
dp[0][0] = 1

for i in range(n):
    dpsum = [0]*(k+2)
    for l in range(k+1):
        dpsum[l+1] = dpsum[l] + dp[i][l]
        dpsum[l+1] %= mod
    for j in range(k+1):
        dp[i+1][j] = (dpsum[j+1] - dpsum[max(0,j-a[i])])%mod
print(dp[n][k])


Measured memory_bytes: 135868
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
using namespace std;

int main(){
    int k,x;
    cin >> k >> x ;
    if (500*k >= x)
    {
        cout << "Yes" << endl;
    }else
    {
        cout << "No" << endl;
    }
    
        
}

Measured memory_bytes: 256
from heapq import heappush, heappop

R = lambda: map(int, input().split())
n, m = R()
c = [[] for _ in range(m)]
for _ in range(n):
    a, b = R()
    if a <= m:
        c[a - 1].append(b)
r=0
h = []
for l in c:
    for x in l:
        heappush(h, -x)
    if h:
        r -= heappop(h) 
print(r)


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

int main() {
    // input-----------------------------------------------------------
    int N, A, B;
    cin >> N >> A >> B;
    
    //calculate--------------------------------------------------------
    vector<vector<int>> vec_1(N,vector<int>(5));
    vector<int> vec_2(N);
    vector<int> vec_3(N);
    //vec_1-------------------------------
    for (int i=0; i<N; i++) {
        int v5, v4, v3, v2;
        v5 = vec_1.at(i).at(4) = (i+1)/10000;
        v4 = vec_1.at(i).at(3) = ((i+1)-v5*10000)/1000;
        v3 = vec_1.at(i).at(2) = ((i+1)-v5*10000-v4*1000)/100;
        v2 = vec_1.at(i).at(1) = ((i+1)-v5*10000-v4*1000-v3*100)/10;
        vec_1.at(i).at(0) = (i+1)-v5*10000-v4*1000-v3*100-v2*10;
    }
    //vec_2-------------------------------
    for (int i=0; i<N; i++) {
        for (int j=0; j<5; j++) {
            vec_2.at(i) += vec_1.at(i).at(j);
        }
    }
    //vec_3-------------------------------
    for (int i=0; i<N; i++) {
        vec_3.at(i) = i+1;
    }
    //count-------------------------------
    int count = 0;
    for (int i=0; i<N; i++) {
        if (vec_2.at(i) >= A && vec_2.at(i) <= B) {
            count += vec_3.at(i);
        }
    }

    //output--------------------------------------------------------
    cout << count << endl;
}

Measured memory_bytes: 3916
#include <iostream>
#include <cstdio>
#include <cstring>
typedef long long lint;
const int N=1e5+5;
int n,m,cf[N],val[N],nxt[62][N],ans[N];
lint q;

template <class T> inline T nxi(){
	T x=0;
	char c;
	while(((c=getchar())>'9'||c<'0')&&c!='-');
	const bool f=c=='-'&&(c=getchar());
	while(x=x*10-48+c,(c=getchar())>='0'&&c<='9');
	return f?-x:x;
}

int main(){
	n=nxi<int>();
	for(int i=1; i<=n; ++i){
		val[i]=nxi<int>();
		nxt[0][i]=i;
		cf[i]=val[i]-val[i-1];
	}
	m=nxi<int>(),q=nxi<lint>();
	for(int i=1; i<=m; ++i){
		const int x=nxi<int>();
		std::swap(nxt[0][x],nxt[0][x+1]);
	}
	for(int i=1; i<62; ++i){
		for(int j=1; j<=n; ++j){
			nxt[i][j]=nxt[i-1][nxt[i-1][j]];
		}
	}
	for(int i=1; i<=n; ++i){
		int tmp=i;
		for(int j=61; ~j; --j){
			if(q>>j&1) tmp=nxt[j][tmp];
		}
		ans[i]=cf[tmp];
	}
	lint sum=0;
	for(int i=1; i<=n; ++i){
		printf("%lld\n",sum+=ans[i]);
	}
	return 0;
}

Measured memory_bytes: 26624
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

#define MOD 1000000007
#define MOD2 998244353
#define int long long
//#define PI 3.14159265358979

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

using namespace std;

template < typename T >
ostream &operator<<(ostream &os, const vector< T > &A) {
	for (int i = 0; i < A.size(); i++)
		os << A[i] << " ";
	os << endl;
	return os;
}
template <>
ostream &operator<<(ostream &os, const vector< vector< int > > &A) {
	int N = A.size();
	int M;
	if (N > 0)
		M = A[0].size();
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < M; j++)
			os << A[i][j] << " ";
		os << endl;
	}
	return os;
}

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

struct edge {
	int from, to, d, c;
	edge(int _from = 0, int _to = 0, int _d = 0, int _c = 0) {
		from = _from;
		to = _to;
		d = _d;
		c = _c;
	}
	bool operator<(const edge &rhs) const {
		return (d == rhs.d) ? (c < rhs.c) : (d < rhs.d);
	}
};
struct aabb {
	int x1, y1, x2, y2;
	aabb(int x1, int y1, int x2, int y2) : x1(x1), y1(y1), x2(x2), y2(y2) {}
};

typedef vector< edge > edges;
typedef vector< edges > graph;
struct flow {
	int to, cap, rev, cost;
	flow(int to = 0, int cap = 0, int rev = 0, int cost = 0) : to(to), cap(cap), rev(rev), cost(cost) {}
};
typedef vector< vector< flow > > flows;

const int di[4] = {0, -1, 0, 1};
const int dj[4] = {-1, 0, 1, 0};
const int ci[5] = {0, 0, -1, 0, 1};
const int cj[5] = {0, -1, 0, 1, 0};
const ll LINF = LLONG_MAX / 2;
const int INF = INT_MAX / 2;
const double PI = acos(-1);

template < typename T, typename U >
bool chmin(T &x, const U &y) {
	if (x > y) {
		x = y;
		return true;
	}
	return false;
}
template < typename T, typename U >
bool chmax(T &x, const U &y) {
	if (x < y) {
		x = y;
		return true;
	}
	return false;
}

struct initializer {
	initializer() {
		cout << fixed << setprecision(11);
	}
};
initializer _____;

int N, M, K, T, Q;
signed main() {
	vector< int > A(3), B(3);
	cin >> N;
	rep(i, 3) cin >> A[i];
	rep(i, 3) cin >> B[i];
	vector< int > dp(30000000);
	rep(_, 2) {
		dp.assign(30000000, -1);
		dp[0] = N;
		rep(i, 3) {
			rep(k, dp.size()) {
				if (dp[k] == -1)
					continue;
				int next = k + A[i];
				if (next < dp.size())
					chmax(dp[next], dp[k] - A[i] + B[i]);
			}
		}
		int tmp = 0;
		rep(k, dp.size()) {
			if (k > N)
				break;
			chmax(tmp, dp[k]);
		}
		chmax(N, tmp);
		swap(A, B);
		//cout << N << endl;
	}
	cout << N << endl;
	return 0;
}

Measured memory_bytes: 234624
if __name__ == '__main__':
    N = int(input())
    A_list = list(map(int, input().split()))

    minus_cnt = 0

    for A in A_list:
        if A < 0:
            minus_cnt += 1

    answer = 0

    if minus_cnt % 2 == 0:
        for A in A_list:
            answer += abs(A)
    else:
        min_abs_A = pow(10, 9)
        for A in A_list:
            answer += abs(A)
            if min_abs_A > abs(A):
                min_abs_A = abs(A)
        answer -= min_abs_A * 2

    print(answer)

Measured memory_bytes: 14332
#include<stdio.h>
int n,m,ans,k[13][12],p[12];
int mj(int x)
{
    int a[12],i,j,s;
    bool f=0;
    for(i=n; i>=1; i--)
    {
        a[i]=x%2;
        x/=2;
    }
    for(i=1; i<=m; i++)
    {
        s=0;
        for(j=1; j<=k[i][0]; j++)
        {
            s+=a[k[i][j]];
        }
        s%=2;
        if(s!=p[i])
        {
            f=1;
            break;
        }
    }
    if(f==1)
        return 0;
    else
    {
        return 1;
    }
}
int main()
{
    int i,j,u;
    scanf("%d%d",&n,&m);
    for(i=1; i<=m; i++)
    {
        scanf("%d",&k[i][0]);
        for(j=1; j<=k[i][0]; j++)
        {
            scanf("%d",&k[i][j]);
        }
    }
    for(i=1; i<=m; i++)
    {
        scanf("%d",&p[i]);
    }
    ans=0;
    u=1;
    for(i=1; i<=n; i++)
        u*=2;
    u--;
    for(i=0; i<=u; i++)
    {
        if(mj(i))
        {
            ans++;
        }
    }
    printf("%d\n",ans);
}


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

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

ll dp[100][100][3000];

int main() {
    int n, a;
    cin >> n >> a;
    ll ans = 0;
    vector<int> x(n);
    rep(i, n) cin >> x[i];
    dp[0][0][0] = 1;
    dp[0][1][x[0]] = 1;
    for(int i = 0; i < n - 1; i++) {
        for(int j = 0; j <= n; j++) {
            for(int k = 0; k <= 2500; k++) {
                if(dp[i][j][k] == 0) continue;
                dp[i+1][j+1][k+x[i+1]] += dp[i][j][k];
                dp[i+1][j][k] += dp[i][j][k];
            }
        }
    }

    for(int i = 1; i <= n; i++) {
        int avg = i * a;
        if(avg <= 2500 and dp[n-1][i][avg] != 0) ans += (ll)dp[n-1][i][avg];
    }

    cout << ans << endl;


}


Measured memory_bytes: 112896
#include<iostream>
#include<string>
using namespace std;
int main(){
string::size_type j=0,k=0;
string s;
getline(cin,s);
for(;;){
j=s.find("apple",j+1);
k=s.find("peach",k+1);
if(j==string::npos)break;
if(k==string::npos)break;
if(j<k){s.replace(j,5,"peach");k=j;}
else{s.replace(k,5,"apple");j=k;}
}
if(j==string::npos){
for(;;){
s.replace(k,5,"apple");
k=s.find("peach",k+1);
if(k==string::npos)break;
}
}else{
for(;;){
s.replace(j,5,"peach");
j=s.find("apple",j+1);
if(j==string::npos)break;
}
}
cout<<s<<endl;
return 0;
}

Measured memory_bytes: 1180
n,W = map(int,input().split())
v = [];w = []
for _ in range(n):
    x,y = map(int,input().split())
    v.append(x)
    w.append(y)

dp = [[0 for _ in range(W+1)] for _ in range(n+1)]

for i in range(n):
    for j in range(W+1):
        if j < w[i]:
            dp[i+1][j] = dp[i][j]
        else:
            dp[i+1][j] = max(dp[i][j],dp[i+1][j-w[i]]+v[i])
print(dp[-1][-1])



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

#ifdef LOCAL
#include "debug.h"
#else
#define DEBUG(...)
#endif

struct dsu {
  int cc;
  vector<int> p, sz;
  dsu(int n = 0) : cc(n), p(n, -1), sz(n, 1) {}
  int root(int v) const {
    while (p[v] != -1) v = p[v];
    return v;
  }
  bool unite(int u, int v) {
    u = root(u), v = root(v);
    if (u == v) return false;
    --cc;
    if (sz[u] < sz[v]) swap(u, v);
    p[v] = u;
    sz[u] += sz[v];
    return true;
  }
  bool same(int u, int v) const { return root(u) == root(v); }
  int size(int v) const { return sz[root(v)]; }
};

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  dsu d(n), b(2 * n + 1);
  long long res = -m;
  while (m--) {
    int u, v;
    cin >> u >> v;
    --u, --v;
    d.unite(u, v);
    b.unite(u, n + v);
    b.unite(n + u, v);
  }
  for (int v = 0; v < n; ++v) {
    if (b.same(v, n + v)) {
      cout << "-1\n";
      exit(0);
    }
    if (b.same(v, 2 * n) or b.same(n + v, 2 * n)) continue;
    b.unite(v, 2 * n);
  }
  vector<int> x(n), y(n);
  for (int v = 0; v < n; ++v) {
    if (b.same(v, 2 * n)) {
      ++x[d.root(v)];
    } else {
      ++y[d.root(v)];
    }
  }
  bitset<100001> dp;
  dp[0] = 1;
  for (int v = 0; v < n; ++v) {
    if (v != d.root(v)) continue;
    dp = dp << x[v] | dp << y[v];
  }
  for (int i = n / 2; ; --i) {
    if (dp[i]) {
      assert(dp[n - i]);
      res += (long long)i * (n - i);
      break;
    }
  }
  cout << res << '\n';
}



Measured memory_bytes: 6004
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=2e5+5;
ll a[maxn];
int main()
{
    int n;
    scanf("%d",&n);
    ll sum=0;
    for(int i=0;i<n;i++) scanf("%lld",&a[i]),sum+=a[i];
    if(n==2)
    {
        printf("%lld\n",abs(a[0]-a[1]));
        return 0;
    }
    ll ans=0,s=1e18;
    for(int i=0;i<n-1;i++)
    {
        ans+=a[i];
        ll k=sum-ans;
        s=min(s,abs(k-ans));
    }
    printf("%lld\n",s);
}


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

using namespace std;
using ull = unsigned long long;
using ll = long long;
using ld = long double;
using D = double;
using ii = pair<int, int>;
using vi = vector<int>;
using vii = vector<ii>;

#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define makeunique(x) sort(all(x)), (x).resize(unique(all(x)) - (x).begin())
#define rep(i, x)  for(int i = 0; i < (x); i++)
#define rrep(i, x) for(int i = (x - 1); i >= 0; i--)
#define sqrt(x) sqrt(abs(x))
#define y1 y1_1234413
#define j1 j1_235
#define y0 y0_235
#define j0 j0_256
#define fi first
#define se second
#define re return
#define prev PREV
#define next NEXT
#define sz(x) ((int)x.size())

template<typename T> T sqr(T a) { re a * a; }
template<typename T> T gcd(T a, T b) { re b ? gcd(b, a % b) : a; }
template<typename T> T sgn(T a) { re a > 0 ? 1 : (a < 0 ? -1 : 0); }
template<typename T> T abs(T a) { re a > 0 ? a : -a; }

const int inf = 2e9;
const ld st = 0.000001;
const ld pi = acos((ld)-1);

const int N = 2e5 + 10;

#define FILENAME ""

int n;
int m;

int h[N], dp[N];

bool was[N];

int f (int x) {
	if (x >= n) re inf;
	if (x == n - 1) re 0;
	if (x == n - 2) re abs (h[x] - h[x + 1]);
	if (was[x]) re dp[x];
	dp[x] = min (f (x + 1) + abs (h[x] - h[x + 1]), f (x + 2) + abs (h[x] - h[x + 2])); 
	was[x] = true;
	re dp[x];
}

int main()
{
	ios::sync_with_stdio(0);
    cin.tie(NULL);
//	freopen(FILENAME ".in", "r", stdin);
//	freopen(FILENAME ".out", "w", stdout);
	cin >> n;
	for (int i = 0; i < n; i++) cin >> h[i];
	cout << f (0);	



	re 0;
}     







Measured memory_bytes: 2688
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using pint = pair<int,int>;
ll mod = 1000000007;
int dx[8] = {1,0,-1,0,1,1,-1,-1};
int dy[8] = {0,1,0,-1,1,-1,1,-1};
void chmin(long long &a, long long b) { if (a > b) a = b; }
const long long INF = 1LL<<60;
ll gcd(ll a,ll b){
    if(b == 0) return a;
    else return gcd(b,a%b);
}
int main() {
    int n;
    cin >> n;
    for (int i = 1; i <= 9; ++i) {
        for (int j = 1; j <= 9; ++j) {
            if(i*j == n){
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
//#include <bits/stdc++.h>
//#include <stdio.h>
#include<iostream>
#include<cstdio>
#include<bitset>
#include<algorithm>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<string>
#include<string.h>
#include<cmath>
#include<utility>
#include<functional>
#include<map>
#include<set>
#include<cctype>
#include<fstream>


#define FOR(i, a, b) for( int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for( int i=(a);i>=(b);i--)
#define LFOR(i, a, b) for( long long int i=(a);i<=(b);i++)
#define LRFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 1000000000 //2000000000
#define LLINF 1000000000000000000 //9000000000000000000
#define PI 3.14159265358979
#define MAXI 7500000

using namespace std;
typedef long long int ll;
typedef pair< long long int, long long  int> P;

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

bool isprime(long long int x) { //与えられた整数が素数ならtrueを返す
	if (x == 2) {
		return true;
	}
	if (x < 2 || x % 2 == 0) {
		return false;
	}
	long long int i = 3;
	for (i; i <= sqrt(x); i += 2) {
		if (x%i == 0) {
			return false;
		}
	}
	return true;
}


int main(void) {
	
	long long int n, p;
	long long int maxi = 1;
	long long int i = 2;


	cin >> n >> p;
	if (n == 1) {
		maxi = p;
	}
	else {
		while (p != 1) {
			while (isprime(i) == false) {
				i++;
			}
			if ((long long int)(pow(i, n)) < 0) {
				//cout << "a " << i << endl;
				break;
			}
			if (p < (long long int)(pow(i, n))) {
				//cout << "b " << i << endl;
				break;
			}
			while (1) {
				if (p % (long long int)(pow(i, n)) == 0) {
					//cout << "c " << i << endl;
					p /= (long long int)(pow(i, n));
					maxi *= i;
				}
				else {
					break;
				}
			}

			i++;
		}
	}
	

	cout << maxi << endl;


	return 0;
}

Measured memory_bytes: 640
import java.util.Scanner;
import java.util.Arrays;

public class Main {

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

    void solve() {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        if (a * b == 15) {
            System.out.println("*");
        } else if (a + b == 15) {
            System.out.println("+");
        } else {
            System.out.println("x");
        }
    }
}

Measured memory_bytes: 24144
def d(a,b,c):
  return max(a,b,c)-min(a,b,c)

H,W=map(int,input().split())

ans=10**10
for i in range(1,H):
  ans=min(ans,d(i*W,((H-i)//2)*W,(H-i-(H-i)//2)*W))
for i in range(1,H):
  ans=min(ans,d(i*W,(H-i)*(W//2),(H-i)*(W-W//2)))

H,W=W,H
for i in range(1,H):
  ans=min(ans,d(i*W,((H-i)//2)*W,(H-i-(H-i)//2)*W))
for i in range(1,H):
  ans=min(ans,d(i*W,(H-i)*(W//2),(H-i)*(W-W//2)))

print(ans)

Measured memory_bytes: 3064
import java.util.*;

public class Main {

    public static void main(String[] args) {
        // write your code here
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        HashSet<String> set = new HashSet<>();
        for (int i = 0; i < n; i++) {
            set.add(sc.next());
        }
        System.out.println(set.size());
    }
}

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

const int mod = 1e9+7;

const int N = 3010;
int memo[N][N];
int prefix[N];

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
    string s;
    cin >> n >> s;
    s = '$' + s;
    /*
    for(int i = 1; i < n; ++i) {
        cout << s[i] << ' ';
    }
    cout << '\n';*/
    memo[0][1] = 1;
    for(int i = 1; i < n; ++i) {
        prefix[0] = memo[i-1][0];
        //prefix[0] = 0;
        for(int j = 1; j <= i+1; ++j) {
            prefix[j] = prefix[j-1] + memo[i-1][j];
            if(prefix[j] >= mod) prefix[j] -= mod;
            assert(0 <= prefix[j] && prefix[j] < mod);
        }
        for(int j = 1; j <= i+1; ++j) {
            if(s[i] == '>') {
                memo[i][j] = prefix[i+1] - prefix[j-1];
                if(memo[i][j] < 0) memo[i][j] += mod;
            } else {
                memo[i][j] = prefix[j-1];
            }
            assert(0 <= memo[i][j] && memo[i][j] < mod);
        }
    }
    
    int res = 0;
    for(int i = 1; i <= n; ++i) {
        res += memo[n-1][i];
        if(res >= mod) res -= mod;
    }
    cout << res << '\n';
}


Measured memory_bytes: 34304
#include <cstdio>
#include <algorithm>

using namespace std;

const int N = 1000;

int h, w, a, b, Mxa, Mxb;

int map[N+5][N+5];

int main()
{
//	freopen("*.in","r",stdin);
//	freopen("*.out","w",stdout);
	
	scanf("%d %d %d %d", &h, &w, &a, &b);

	for(register int i=1; i<=h; i++)
	{
		if(i<=b)
		{
			for(register int j=1; j<=a; j++)
				printf("1");
			for(register int j=a+1; j<=w; j++)
				printf("0");
		}
		else
		{
			for(register int j=1; j<=a; j++)
				printf("0");
			for(register int j=a+1; j<=w; j++)
				printf("1");
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) begin(v),end(v)
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
using ll = long long;
using pii = pair<int, int>;
constexpr ll INF = 1ll<<30;
constexpr ll longINF = 1ll<<60;
constexpr ll MOD = 1000000007;
constexpr bool debug = 0;
//---------------------------------//

int main() {
	int N;
	string S;
	cin >> N >> S;
	int Q;
	cin >> Q;
	while (Q--) {
		int K;
		scanf("%d", &K);
		
		ll ans = 0;
		ll cntm = 0, cntc = 0, cur = 0, pos = 0;
		REP(i, N) {
			while(pos < N && pos < i + K) {
				if (S[pos] == 'M') ++cntm;
				else if (S[pos] == 'C') {
					++cntc;
					cur += cntm;
				}
				++pos;
			}
			if (S[i] == 'D') ans += cur;
			else if (S[i] == 'M') {
				--cntm;
				cur -= cntc;
			}
			else if (S[i] == 'C') {
				--cntc;
			}
		}
		printf("%lld\n", ans);
	}
	
	return 0;
}


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

int n, a[200004];

int main() {
	cin>>n;
	for(int i = 0; i < n; i++)	cin>>a[i];
	sort(a, a+n);
	bool chk = true;
	for(int i = 1; i <n; i++)	if(a[i] == a[i-1])	chk = false;
	cout<<(chk? "YES" : "NO");
	return 0;
}

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

#define ll long long
#define mtv(kit) cout<<#kit<<" - "<<kit<<"\n";
#define ff first
#define ss second
#define pb push_back
#define rep(i,a,b) for(i=a;i<b;i++)
#define pii pair<ll , ll>
#define ump unordered_map<ll , ll>

void doit(){
	ll n,i,j,k,c,ans=0,x;
	cin >> x >> n;
	ump mp;
	for(i=0;i<n;i++){
		cin >> k;
		mp[k]=1;
	}
	ll i1=x,j1=x;
	while(1){
		if(mp.find(i1)==mp.end()){
			ans=i1;
			break;
		}
		if(mp.find(j1)==mp.end()){
			ans=j1;
			break;
		}
		i1--;j1++;
	}
	cout << ans <<"\n";
	
	
	}

int main() {
#ifndef ONLINE_JUDGE
	freopen("input1.txt","r",stdin);
	freopen("output1.txt","w",stdout);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll t = 1;
	//cin>>t;
	for(ll i = 1; i <= t; i++){
		doit();
	}
}


Measured memory_bytes: 3632
#include <stdio.h>
#include<stdlib.h>
struct Node{
    long long int data;
    struct Node* next;
    struct Node* prev;
};
struct Node* listS;
long long int count;

void insertS(long long int data){
    struct Node* newN = (struct Node*)malloc(sizeof(struct Node));
    newN->data = data;
    newN->prev = NULL;
    newN->next = NULL;
    if(listS == NULL){
        listS = newN;
        return;
    }
    listS->prev = newN;
    newN->next = listS;
    listS = newN;
}
void findX(long long int x){
    struct Node* temp = listS;
    struct Node* p;
    struct Node* n;
    while(temp != NULL){
        if(temp->data == x){
            count++;
            p = temp->prev;
            n = temp->next;
            if(p == NULL && n == NULL) {
                listS = NULL;
                break;
            }
            if(p == NULL){
                listS = temp->next;
                listS->prev = NULL;
            }else p->next = n;
            if(n!=NULL)n->prev = p;
            break;
        }
        temp = temp->next;
    }
}

int main(){
    listS = NULL;

    long long int n, q, s, t, c;
    count = 0;
    scanf("%lld", &n);
    while(n--){
        scanf("%lld", &s);
        insertS(s);
    }
    scanf("%lld", &q);
    while(q--){
        scanf("%lld", &t);
        findX(t);
    }
    printf("%lld\n", count);
    return 0;
}



Measured memory_bytes: 2104
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repi(i, s, n) for (int i = (s); i < (n); i++)
#ifdef LOCAL
#define INPUT_FILE                    \
  ifstream in("abc169/abc169_a.txt"); \
  cin.rdbuf(in.rdbuf());
#define print_vec(v)                        \
  rep(l, v.size()) { cout << v[l] << " "; } \
  cout << endl;
#else
#define INPUT_FILE
#define print_vec(v)
#endif
#define CIN_OPTIMIZE \
  cin.tie(0);        \
  ios::sync_with_stdio(false);
typedef pair<int, int> P;
typedef long long ll;
typedef pair<ll, ll> pl;
const int INF = 100100100;
const ll LINF = 1e18 + 100;
const int MOD = 1e9 + 7;

int main() {
  INPUT_FILE CIN_OPTIMIZE;

  int A, B;
  cin >> A >> B;

  cout << A * B << endl;
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define rrep(i,a,b) for(int i=(a);i>=(b);--i)
#define PB push_back
#define ar2 array<int, 2>
typedef long long LL;
const LL P = 998244353;
const int N = 1e5+5;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int n, x, ma, a[N];

LL pw(LL x,int n){
	LL res = 1;
	for(;n;n>>=1,x=x*x%P) if(n&1) res=res*x%P;
	return res;
}

int main(){
	scanf("%d",&n);
	rep(i,1,n){
		scanf("%d",&x), a[x]++, ma = max(ma, x);
		if(i==1 && x!=0 || i!=1 && x==0){
			cout<<"0\n";
			return 0;
		}
	}
	LL ans = 1;
	rep(i,1,ma) ans = ans * pw(a[i-1],a[i]) % P;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define ALL(v) v.begin(),v.end()
using ll = long long;
using pii = pair<int,int>;
using vi = vector<int>;
using vs = vector<string>;
using vb = vector<bool>;
using vll = vector<long long>;
using vpii = vector<pair<int,int>>;
using vivi = vector<vector<int>>;
using vbvb = vector<vector<bool>>;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
const int mod = 1000000007;
const int inf = 1001001001;

int main(void) {
  int n;
  cin >> n;
  vi a(n);
  ll sum  = 0;
  rep(i,n) {
    cin >> a[i];
    a[i]-=i+1;
    
  }
  sort(ALL(a));
  int p = lower_bound(ALL(a),1)-a.begin();
  int q = a[n/2];
  
  rep(i,n){
    a[i]-=q;
    sum+=abs(a[i]);
  }
  
  cout << abs(sum) << endl;
  
}




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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll, int> plli;
typedef pair<int, pii> pipii;
typedef vector<vector<int> > mati;
typedef vector<vector<double> > matd;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vector<vector<bool>>> vvvb;

#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)
#define REP(i,y) FOR(i, 0, y)
#define RFOR(i,x,y) for(ll i=(ll)x; i>=(ll)y; --i)
#define RREP(i,x) RFOR(i, x, 0)

template <typename T>
void vec_print(vector<T> VEC){
  REP(i, VEC.size()){
    cout << VEC[i] << " ";
  }
  cout << "\n";
};

template <typename T>
void mat_print(vector<vector<T> > MAT){
  REP(i, MAT.size()){
    REP(j, MAT[i].size()){
      cout << MAT[i][j] << " ";
    }
    cout << "\n";
  }
};

template <typename CLASS1, typename CLASS2>
class HOGE{
  public:
    CLASS1 key;
    CLASS2 value;
    HOGE(void){
      return;
    };
    HOGE(CLASS1 key, CLASS2 value){
      this->key = key;
      this->value = value;
    };
    ~HOGE(void){
      return;
    };

    void print(void){
      cout << "key : " << key << ", value : " << value << "\n";
      return;
    };
    
    bool operator==(const HOGE &obj){
      return (this->value == obj.value);
    };
    bool operator<(const HOGE &obj){
      return (this->value < obj.value);
    };
    bool operator>(const HOGE &obj){
      return (this->value > obj.value);
    };
};

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;
constexpr ll MOD = (ll)((1E+9)+7);

ll calc_f(ll b, ll n){
  if(n<b) return n;
  return calc_f(b, n/b) + n%b;
}

int main(){
  cin.tie(0); // cut the cin and cout (default, std::flush is performed after std::cin)
  ios::sync_with_stdio(false); // cut the iostream and stdio (DON'T endl; BUT "\n";)

  ll n, s;
  cin >> n >> s;

  ll N = (ll)(sqrt((double)n)+1.0);

  FOR(b, 2, N+1){
    if(s == calc_f(b, n)){
      //cout << "p:" << s << " " << b << " " << n << "\n";
      cout << b << "\n";
      return 0;
    }
  }


  ll ans = -1;
  // N*b+k=n && N+k=s ~ 1*b+k=n && 1+k==s
  FOR(N_tmp, 1, N+1){
    ll k = s-N_tmp;
    if(n-k<=0) continue;
    if((n-k)%N_tmp==0){
      ll b = (n-k)/N_tmp;
      if(b<2) continue;
      if(s == calc_f(b, n)){
        ans = b;
        //cout << "h:" <<  s << " " << ans << " " << n << "\n";
      }
    }
  }

  if(ans>0){
    cout << ans << "\n";
    return 0;
  }

  for(ll b=max(n-1, (ll)2); b<n+2; ++b){
    if(s == calc_f(b, n)){
      //cout << "p:" << s << " " << b << " " << n << "\n";
      cout << b << "\n";
      return 0;
    }
  }

  cout << "-1" << "\n";

  return 0;
}


Measured memory_bytes: 256
N = int(input())
a = list(map(int,input().split()))

z = {}
for i in a:
    try:
        z[i] += 1
    except KeyError:
        z[i] = 1

ans = 0
for q in z.keys():
    if z[q] > q:
        ans += z[q] - q
    elif z[q] < q:
        ans += z[q]

print(ans)


Measured memory_bytes: 18168
#include <iostream>
using namespace std;
bool r(int &i,string S);
bool a(int &i,string S);
bool r(int &i,string S){
    while(i<S.size()){
        switch(S[i]){
            case '(':
                i++;
                if(!r(i,S)) return false;
                break;
            case ')':
                i++;
                return true;
            case '[':
                i++;
                if(!a(i,S)) return false;
                break;
            case ']':
                i++;
                return false;
            default:
                i++;
                break;
        }
    }
    return false;
}
 
bool a(int &i,string S){
    while(i<S.size()){
        switch(S[i]){
            case '(':
                i++;
                if(!r(i,S)) return false;
                break;
            case ')':
                i++;
                return false;
            case '[':
                i++;
                if(!a(i,S)) return false;
                break;
            case ']':
                i++;
                return true;
            default:
                i++;
                break;
        }
    }
    return false;
}
 
int main(){
    string str;
    while(true){
        getline(cin,str);
        if(str==".") return 0;
        else str.push_back(']');
        int i=0;
        if(a(i,str)&&i==str.size()){
            cout<<"yes"<<endl;
        }else{
            cout<<"no"<<endl;
        }
    }
    return 0;
}

Measured memory_bytes: 3160
local read = setmetatable({}, {__index = function(t, k) local a = {} for i=1,#k do table.insert(a, '*'..string.sub(k, i, i)) end local r = io.read local u = table.unpack or unpack return function() return r(u(a)) end end})
read.N = function(N) local t={} for i=1,N do t[i]=read.n() end return t end
string.totable = function(s) local t={} local u=string.sub for i=1,#s do t[i] = u(s, i, i) end return t end
string.split = function(s) local t={} for w in string.gmatch(s, "[^%s]+") do table.insert(t, w) end return (table.unpack or unpack)(t) end
local function array(dimensi0n, default_val) assert(type(default_val) ~= 'table') local n=dimensi0n local m={}if default_val~=nil then m[1]={__index=function()return default_val end}end for i=2,n do m[i]={__index=function(p, k)local c=setmetatable({},m[i-1])rawset(p,k,c)return c end}end return setmetatable({},m[n])end
local function tostringxx(o, depth) depth = depth or 0 if depth > 10 then return "<too deep!>" end if o == _G then return "<_G>" end local indent0 = (" "):rep((depth) * 2) local indent1 = (" "):rep((depth+1) * 2) local indent2= (" "):rep((depth+2) * 2) if type(o) == 'table' then local keys = {} local types = {} for k in pairs(o) do types[type(k)] = true table.insert(keys, k) end local types_count = 0 local lasttype for k in pairs(types) do types_count = types_count + 1 lasttype = k end if types_count == 1 and (lasttype == 'string' or lasttype == 'number') then table.sort(keys) end local inside = {} for i=1,#keys do local k = keys[i] local v = o[k] if type(k) == 'string' then k = string.format('%q', k) end table.insert(inside, indent1 .. '['..tostring(k)..'] = ' .. tostringxx(v, depth + 1)) end return '{\n' .. table.concat(inside, ',\n') .. '\n' .. indent0 .. '}' else if type(o) == 'string' then o = string.format('%q', o) end return tostring(o) end end
local function richtraceback() local x = 2 while true do local info = debug.getinfo(x) if not info then break end local fname = '<' .. info.short_src .. ":" .. info.linedefined .. ">" if info.name then fname = info.name end print(info.short_src .. ":" .. info.currentline .. ": in " .. ("%q"):format(fname)) print(" LOCALS:") local p = 1 while true do local name, val = debug.getlocal(x,p) if not name then break end print(" " .. name .. ": " .. tostringxx(val, 3)) p = p + 1 end print(" UPVALUES:") for p=1,info.nups do local name, val = debug.getupvalue(info.func,p) if not name then break end print(" " .. name .. ": " .. tostringxx(val, 3)) end x = x + 1 end end
local function myassert(b) if not b then richtraceback() error("assertion failed") end end 
--
local X, K, D = read.nnn()
if X < 0 then
    X = -X
end
local a = X // D
local b = X % D
local ans = 10^15
if a < K then
    local r = K - a
    if r % 2 == 0 then
        ans = b
    else
        ans = D - b
    end
elseif a == K then
    ans = b
elseif a > K then
    ans = D * (a - K) + b
end
print(ans)

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

int main(void){
    int n;
    int m;
    int i;
    int j;
    int count;
    
    cin >> n;
    vector<int> ans(n);
    count = 0;
    i = -1;
    while (++i < n)
    {
        cin >> m;
        j = -1;
        while (++j < i)
            if (ans.at(j) == m)
            {
                count--;
                break;
            }
        ans.at(i) = m;
        count++;
    }
    cout << count << endl;
}


Measured memory_bytes: 256
use std::env;
use std::io::*;
use std::str::*;
use std::mem;
use std::collections::HashMap;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let s = stdin.bytes().map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    s.parse::<T>().ok().unwrap()
}
fn read_char() -> char {
    let c = read::<String>();
    let c = c.chars().collect::<Vec<char>>();
    c[0]
}
fn read_String_Vec() -> Vec<char> {
    let S = read::<String>();
    S.chars().collect::<Vec<char>>()
}

fn vecchar_to_String(Vs: Vec<char>) -> String {
    let mut S = String::new();
    for i in 0..Vs.len() {
        S.push(Vs[i]);
    }
    S
}

/*
A : 65
Z : 90
a : 97
z : 122
*/

/*
let N = read::<i32>();
let S = read::<String>();
let S = read_String_Vec();
let C = read_char();
*/

/*
 .to_string() : * -> String
 &*S          : String -> &str
*/

fn main() {
    // main の引数
    /*
        引数なしのときargs.len() = 1;
    */
    let args: Vec<String> = env::args().collect();

    let S = read_String_Vec();
    let mut string = Vec::new();
    for n in 0..S.len() {
        let c = S[n];
        if c == 'B' {
            let len = string.len();
            if len > 0 {
                string.remove(len - 1);
            }
        } else {
            string.push(c);
        }

    }
    println!("{}", vecchar_to_String(string));

}


Measured memory_bytes: 4352
#include<stdio.h>
int main()
{
    int a,b,t,c,d,e;

    scanf("%d%d%d",&a,&b,&t);

    if(t<a)
    {
        c=0;
    }
  else
    c=(t/a);

   printf("%d\n",c*b);
    return 0;
}


Measured memory_bytes: 128
def main():
    from builtins import int, map, list, print, len
    from collections import defaultdict
    import sys
    sys.setrecursionlimit(10 ** 6)

    input = (lambda: (sys.stdin.readline()).rstrip())
    input_list = (lambda: input().split())
    input_number = (lambda: int(input()))
    input_number_list = (lambda: list(map(int, input_list())))

    D = input_number()
    c = input_number_list()
    last = defaultdict(lambda: 0)
    s = []
    c_pt = c.copy()
    c_total = sum(c)
    ans_pt = 0
    for i in range(D):
        s.append(input_number_list())
    for i in range(D):
        pt_ls = s[i].copy()

        # 一番ポイント高いのを選ぶ
        t_idx = pt_ls.index(max(pt_ls))
        ans_pt += pt_ls[t_idx]

        # 不幸値を計算
        for j in range(len(c)):
            if j == t_idx:
                # リセット
                c_pt[j] = c[j]
            else:
                ans_pt -= c_pt[j]
                c_pt[j] += c[j]

        # 出力
        print(t_idx + 1)

        # 選択したものの不幸値をリセット
        c_pt[t_idx] = 0


if __name__ == '__main__':
    main()


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

#define ll long long
#define ld long double
#define precision(x,d) cout<<fixed<<setprecision(d)<<x
#define IOS ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);srand(time(NULL));
#define MOD 1000000007
#define INF LONG_LONG_MAX
#define NINF LONG_LONG_MIN
#define yes cout<<"YES"<<endl
#define no cout<<"NO"<<endl

int main(){

    IOS;

    ll t,n,k,m;
    t=1;
    while(t--)
    {
        cin >> n >> k;
        vector<ll> w(n+1);
        vector<ll> v(n+1);
        vector<vector<ll>> dp(n+1,vector<ll>(100001));
        for(ll i=1;i<=n;i++)
        {
            cin >> w[i] >> v[i];
        }

            for(int i=0; i<=n; i++)
            {
        		for(int j=0; j<=100000; j++)
                {
        			if(j==0)
                    {
        				dp[i][j]=0;
        				continue;
        			}
        			if(i==0)
                    {
        				dp[i][j]=k+1;
        				continue;
        			}
        			if(j-v[i]>=0)
                    {
        				dp[i][j]=min(dp[i-1][j], dp[i-1][j-v[i]]+w[i]);
        			}
        			else
                    {
        				dp[i][j]=min(w[i], dp[i-1][j]);
        			}
        		}
        	}
    	int i=0;
    	int ans=0;
    	for(int i=0; i<=100000; i++){
    		if(dp[n][i]<=k){
    			ans=max(ans,i);
    		}
    	}

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


Measured memory_bytes: 80256
#include<iostream>
#include<set>
#include<string.h>
#include<cmath>
#include<queue>
#include<algorithm>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
int l, r; 
ll mx;
signed main(){
    while (~scanf("%d%d", &l, &r))
    {
    	mx = 2019;
    	if (r / 2019 - (l - 1) / 2019 > 0)
    		printf("0\n");
    	else
    	{
    		for (int i = l; i <= r; i++)
			{
				for (int j = i + 1; j <= r; j++)
				{
					mx = min((ll)i * (ll)j % 2019, mx);
				}
			}
			printf("%lld\n", mx);		
		}
	}
}


Measured memory_bytes: 256