akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <algorithm>
#include <cmath>
#include <cstring>

using namespace std;

#define REP(i,n) for(int i = 0; i < n; i++)
#define RREP(i,n) for(int i = n - 1; i >= 0; i--)

#define ALL(v) v.begin(),v.end()
#define pb push_back
#define mp make_pair
#define F first
#define S second

#define UNIQUE(v) do{sort(v.begin(), v.end()); v.erase( unique(v.begin(), v.end()), v.end() );} while(0)

#define y0 y3487465
#define y1 y8687969

#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,63,sizeof(x))

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

double EPS = 1e-9;
int INFi = 1000000005;
long long INFll = 1000000000000000005ll;
double PI = acos(-1);
int dirx[8] = {-1,0,0,1,-1,-1,1,1};
int diry[8] = {0,1,-1,0,-1,1,-1,1};
ll MOD = 1000000007;

string S, T;
int q;
const int MAX_Q = 100000;
int a[MAX_Q], b[MAX_Q], c[MAX_Q], d[MAX_Q];

int main(){
  cin >> S >> T >> q;
  REP(i, q) cin >> a[i] >> b[i] >> c[i] >> d[i];
  int s = S.size(), t = T.size();
  int sa[s + 1], sb[s + 1], ta[t + 1], tb[t + 1];
  int cta = 0, ctb = 0;
  sa[0] = 0; sb[0] = 0; ta[0] = 0; tb[0] = 0;
  REP(i, s) {
    if(S[i] == 'A') cta++;
    else ctb++;
    sa[i + 1] = cta;
    sb[i + 1] = ctb;
  }
  cta = 0, ctb = 0;
  REP(i, t) {
    if(T[i] == 'A') cta++;
    else ctb++;
    ta[i + 1] = cta;
    tb[i + 1] = ctb;
  }

  // REP(i, s + 1) cout << sa[i] << "," << sb[i] << endl;

  REP(i, q) {
    int nsa = sa[b[i]] - sa[a[i] - 1], nsb = sb[b[i]] - sb[a[i] - 1];
    int nta = ta[d[i]] - ta[c[i] - 1], ntb = tb[d[i]] - tb[c[i] - 1];
    // cout << sa[b[i]] << ", " << sa[a[i] - 1] << ": : : " << sb[b[i]] << ", " << sb[a[i] - 1] << endl;;
    // cout << nsa << ", " << nsb << ", " << nta << ", " << ntb << endl;
    if ((nsa - nta - (nsb - ntb)) % 3 == 0) cout << "YES" << endl;
    else cout << "NO" << endl;
  }

  return 0;
}


Measured memory_bytes: 3968
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class AtCoderB
{
    static void Main()
    {
        var sc = new Scanner();

        int n = sc.NextInt();
        int[] h = sc.IntArray();

        int answer = 1;
        int max = h[0];
        for (int i = 1; i < n; i++)
        {
            if(h[i] >= max)
            {
                max = h[i];
                answer++;
            }
        }

        Console.WriteLine(answer);
    }

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}

Measured memory_bytes: 13396
#include<cstdio>
#include<iostream>
using namespace std;
int main()
{
	int x1,x2,x3,y1,y2;
	scanf("%d%d%d%d%d",&x1,&x2,&x3,&y1,&y2);
	printf("%d\n",min(x1,min(x2,x3))+min(y1,y2)-50);
	return 0;
}

Measured memory_bytes: 1184
#define LOCAL
#define _USE_MATH_DEFINES
#include <array>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
  out << "(" << a.first << "," << a.second << ")";
  return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
  out << "["; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
  return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
  out << "["; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
  return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
  out << "{"; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
  return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
  out << "{"; bool first = true;
  for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
  return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;
mt19937 mrand(random_device{}());
int rnd(int x) { return mrand() % x; }

struct fast_ios {
  fast_ios() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
  };
} fast_ios_;

int main() {
  int n;
  scanf("%d", &n);
  vector<int> a(n);
  map<int, int> cnt;
  for (int i = 0; i < n; ++i) {
    scanf("%d", &a[i]);
    cnt[a[i]]++;
  }
  int64 ret = 0;
  for (auto& p : cnt) {
    int64 v = p.second;
    ret += v * (v - 1) / 2;
  }
  for (int i = 0; i < n; ++i) {
    int old_v = cnt[a[i]];
    int64 cur = ret - old_v * (old_v - 1) / 2;
    int v = cnt[a[i]] - 1;
    cur += v * (v - 1) / 2;
    printf("%lld\n", cur);
  }
  return 0;
}


Measured memory_bytes: 8320
// -----------------------------------
// author   : MatsuTaku
// country  : Japan
// created  : 08/02/20 20:55:48
// -----------------------------------

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

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

  int n,k; cin>>n>>k;
  vector<int> A(n); for (auto& a:A) cin>>a;
  auto ok = [&](int m) {
    int cnt = 0;
    for (int a:A) {
      cnt += (a-1)/m;
      if (cnt > k)
        return false;
    }
    return true;
  };
  int l = 0, r = 1e9;
  while (l+1<r) {
    auto c = (l+r)/2;
    if (ok(c)) {
      r = c;
    } else {
      l = c;
    }
  }
  cout << r << endl;

  return 0;
}


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

#A >= Bか換金->交換の利得が少ないときはビスケットを叩き続ける
if A >= B - 2:
    print(K + 1)
else:
    #A<Bの時はビスケットをA枚まで貯めた後換金と交換を繰り返す
    n = int((K - (A - 1)) / 2)
    print(n*(B-A-2) + K + 1)

Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
long long i,j,a[1000000],n,b,c,l,k,s;
int main()
{
  for(cin>>a[i],i=1;i<1000000;i++){
    a[i]=(a[i-1]&1?3*a[i-1]+1:a[i-1]/2);
    for(j=0;j<i;j++)if(a[j]==a[i])return cout<<i+1,0;
  }
}

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

int main(void)
{
  char s[101];
  scanf("%s", s);
  
  int n = strlen(s);
  
  for (int i = 0; i < n; i+=2) {
    if (s[i] == 'L') {
      printf("No");
      return 0;
    }
    if(i+1 == n)
      break;
    if (s[i+1] == 'R') {
      printf("No");
      return 0;
    }
  }
  
  printf("Yes");
  
  return 0;
  
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define REP(i,n) for (int i=0; i<(n); ++i)
#define REPR(i,n,m) for (int i=(n); i>=(m); --i)
using namespace std;
using LL = long long;
using LD = long double;
using PLL = pair<long long, long long>;
using PLD = pair<long double, long double>;
using VLL = vector<long long>;
using VLD = vector<long double>;
using VPLD = vector<PLD>;

const int INF = numeric_limits<int>::max();

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

    int n; cin >> n;
    vector<int> a(n+1,0); for (int i=1;i<=n;i++) cin >> a[i];

    int ans = 0;
    for (int i=1; i<=n; i+=2) {
        if (a[i]%2==1) ans++;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3616
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>

using namespace std;

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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v; return v;}

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector< vector<int> > Mat;
typedef tuple<ll, ll, ll> T;

const int MOD = (int)1e9+7;
const int INF = (int)1e9;
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

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

    int N, M;
    cin >> N >> M;
    vector< vector<ll> > cake(3, vector<ll>(N));
    rep(i, N) cin >> cake[0][i] >> cake[1][i] >> cake[2][i];

    ll ans = -(1LL << 60);
    for(int bit = 0; bit < 8; bit++){
        vector<ll> xyz;
        for(int i = 0; i < N; i++){
            ll sum = 0;
            for(int k = 0; k < 3; k++){
                if(bit>>k & 1) sum -= cake[k][i];
                else sum += cake[k][i];
            }
            xyz.push_back(sum);
        }
        sort(xyz.begin(), xyz.end(), greater<ll>());
        ll total = 0;
        rep(i, M) total += xyz[i];
        ans = max(ans, total);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
A = [ list(map(int, input().split())) for i in range(3) ]
N = int(input())
B = [ int(input()) for i in range(N)]

bingo = False

# yoko
for i in range(3):
  cnt = 0
  for j in range(3):
    if A[i][j] in B:
      cnt += 1
  if cnt == 3:
    bingo = True

# tate
for j in range(3):
  Cnt = 0
  for i in range(3):
    if A[i][j] in B:
      Cnt +=  1
  if Cnt == 3:
    bingo = True

#naname
cnt = 0
for i in range(3):
  if A [i] [i] in B:
    cnt += 1
if cnt == 3:
  bingo = True
cnt = 0
for i in range(3):
  j = 2 -i
  if A[i][j] in B:
    cnt += 1
if cnt == 3:
  bingo = True
if bingo:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 9116
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <utility>
#include <string>
#include <algorithm>
#include <map>
#include <vector>
#include <climits>
#include <numeric>
#include<stdio.h>
#include <queue>
#include <iomanip>
#include <float.h>
#include <set>
#include<functional>
#include <stack>
#include <time.h>
#include <climits>
#include <bitset>
using namespace std;
typedef pair<long long, long long>p;
typedef pair<p, long long> pai;
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
long long mod = 1e9 + 7;
signed main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	vector<int>b(n);
	for (int i = 0; i < n; i++) {
		cin >> b[i];
	}
	vector<int> ans;
	for (int z = 0; z < n; z++) {
		for (int i = b.size()-1; i >=0; i--) {
			if (b[i] == i + 1) {
				ans.push_back(i+1);
				b.erase(b.begin()+i);
				break;
			}
			if (i == 0) {
				cout << -1; return 0;
			}
		}
	}
	for (int i = ans.size()-1; i >=0; i--) {
		cout << ans[i]<<"\n";
	}
}

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

int main() {
  int N, K;
  cin >> N >> K;
  
  int x, S;
  
  for (int i=0; i<N; i++) {
    cin >> x;

    if (2*x < K) {
      S += x;
    }
    else if (K > 1) {
      S += K-x;
    }
  }
  
  cout << 2*S << endl;
}

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


a = sorted(a)

num = 0
judge = 0

if len(a)%2 == 1:
    if a[0] == 0:
        for i in range(1, n, 2):
            if a[i] == i+1 and a[i+1] == i+1:
                num += 1
            else:
                print(0)
                judge = 1
                break
    else:
        print(0)
        judge=1
else:
    for i in range(0, n, 2):
            if a[i] == i+1 and a[i+1] == i+1:
                num += 1
            else:
                print(0)
                judge = 1
                break
        
if judge == 0:
    result = (2**num)%(10**9+7)
    print(result)

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

//-------------------------------------------------

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin>>n;
    vll a(n),b(n);
    rep(i,n) cin>>a[i];
    rep(i,n) cin>>b[i];
    ll ans=0;
    rep(i,30){
        vll A(n), B(n);
        ll T = 1<<i;
        rep(j,n) A[j]=a[j]%(2*T);
        rep(j,n) B[j]=b[j]%(2*T);
        sort(all(A));
        sort(all(B));
        int cnt=0;
        rep(j,n){
            cnt -= lower_bound(all(B), T-A[j])-B.begin();
            cnt += lower_bound(all(B), T*2-A[j])-B.begin();
            cnt -= lower_bound(all(B), T*3-A[j])-B.begin();
            cnt += lower_bound(all(B), T*4-A[j])-B.begin();
        }
        if (cnt&1) ans|=1<<i;
    }
    cout<<ans<<"\n";
    return 0;
}


Measured memory_bytes: 6572
#include<bits/stdc++.h>
#define f(i,a,b) for(long long i=a;i<b;i++)
#define pb(i) push_back(i)
#define mk(x,y) make_pair(x,y)
#define F first
#define S second
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
typedef long long ll;
using namespace std;

int main(){
	FIO;
	ll n,k,a,idx,mn=1e18,res=1e18;cin>>n>>k;
	f(i,1,n+1){
		cin>>a;
		if(a<mn){
			idx=i;mn=a;
			ll p=idx-1;ll q=n-idx;
			ll ans=ceil(p*1.0/(k-1))+ceil(q*1.0/(k-1));
			res=min(res,ans);
		}
	}
	cout<<res<<"\n";
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner scn = new Scanner(System.in);
        int N = scn.nextInt();
        String[] Am = (scn.nextLine()).split(" ");
        Am = (scn.nextLine()).split(" ");
        int[] Aresult = new int[N];
        int A = 0;
        for(int i=0;i<N-1;i++){
            A = Integer.valueOf(Am[i])-1;
            Aresult[A] = Aresult[A] + 1;
        }
        for(int i=0;i<N;i++){
            System.out.println(Aresult[i]);
        }
    }
}

Measured memory_bytes: 73528
#include<iostream>
#include<stdio.h>
#include<algorithm>
using namespace std;
int a[4];
int ans=0;
int main()
{
	scanf("%d%d%d",a+1,a+2,a+3);
	sort(a+1,a+4);
	ans=a[3]-a[1];
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
#pragma region
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <list>
#include <iomanip>
#include <cstdint>
#include <bitset>
#include <fstream>

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

#pragma region UnionFind
struct UnionFind
{
	vector<int> par;

	UnionFind(int n) : par(n, -1) {}
	void init(int n) { par.assign(n, -1); }

	int root(int x)
	{
		if (par[x] < 0) return x;
		else return par[x] = root(par[x]);
	}

	bool issame(int x, int y)
	{
		return root(x) == root(y);
	}

	bool merge(int x, int y)
	{
		x = root(x); y = root(y);
		if (x == y) return false;
		if (par[x] > par[y]) swap(x, y);
		par[x] += par[y];
		par[y] = x;
		return true;
	}

	int size(int x)
	{
		return -par[root(x)];
	}
};
#pragma endregion
#pragma region GCD
int gcd(int a, int b)
{
	if (a%b == 0)return b;
	return gcd(b, a%b);
}
#pragma endregion
#pragma region chmin
template<class T> inline bool chmin(T& a, T b)
{
	if (a > b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma region chmax
template<class T> inline bool chmax(T& a, T b)
{
	if (a < b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma endregion


int main()
{
	string s; cin >> s;
	cout << s.substr(0, s.size() - 8) << endl;
}

Measured memory_bytes: 3572
#include <iostream>
#include <vector>
using namespace std;
int main(){
    int N;
    cin>>N;
    vector<int> A(N);
    for(int i=0;i<N;i++) cin>>A[i];
    
    vector<int> rev(N);
    for(int i=0;i<N;i++) rev[A[i]-1]=i+1;
    for(int i=0;i<N;i++) cout<<rev[i]<<" ";
    cout << endl;
    return 0;
}

Measured memory_bytes: 1536
import java.util.*;

public class Main{
    
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        
        int N = sc.nextInt();
        int[][] A = new int[2][N];
        for(int i = 0; i < N; i++){
            A[0][i] = sc.nextInt();
            A[1][i] = sc.nextInt();
        }
        sc.close();

        long count = 0;

        for(int i = N-1; i >= 0; i--){
            long mod = (A[0][i]+count) % A[1][i];
            if(mod != 0)
                count += A[1][i] - mod;
        }

        System.out.println(count);
    }
}

Measured memory_bytes: 88108
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <ctype.h>
#include <map>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <cctype>
#include <queue>
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define REP1(j,n) for(int j=0;j<(int)n;++j)
#define REPD(i,n) for(int i=n;i>=0;--i)
#define REPD1(j,n) for(int j=n;j=>0;--j)
#define REPS(i,n) for(int i=1;i<=(int)n;++i)
#define REPS1(j,n) for(int j=1;j<=(int)n;++j)
#define rep(i,a,n) for(int i=a;i<=(int)n;++i)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define DescSort(a) sort(a.begin(),a.end(),std::greater<int>())

using namespace std;
typedef long long ll;
ll gcd(ll x, ll y) {
	ll r;
	if (x < y) swap(x, y);
	while (y > 0) {
		r = x % y;
		x = y;
		y = r;
	}
	return x;
}
int main(void) {
	int n;
	cin >> n;
	vector<ll> a(n);
	REP(i, n) {
		cin >> a[i];
	}
	vector<ll> L(n+1), R(n+1),m(n+1);
	L[0] = R[n] = 0;
	m[0] = 0;
	for (int i = 0; i< n; ++i) {
			L[i+1] = gcd(L[i], a[i]);
	}
	for (int i = n-1; i >= 0; --i) {
			R[i] = gcd(R[i + 1], a[i]);
	}
	ll ans = 0;
	for (int i = 0; i < n; i++) {
		m[i] = gcd(L[i], R[i + 1]);
		ans = max(ans, m[i]);
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 3328
#include <stdio.h>

int main(void)
{
  int a, b;
  scanf("%d %d", &a, &b);
  
  int dig = 0;
  int tmp = b;
  while (tmp > 0)
  {
    tmp /= 10;
    dig++;
  }
  while (dig > 0)
  {
    a *= 10;
    dig--;
  }
  a += b;
  
  int i = 0;
  while (a >= i * i)
  {
    i++;
  }
  i--;
  if (a == i * i)
  {
    printf("Yes");
  }
  else
  {
    printf("No");
  }
  return 0;
}

Measured memory_bytes: 128
n = int(input())
a = [list(map(int, input().split())) for i in range(n)]

INF = float('inf')
graph = [[INF for i in range(n)] for j in range(n)]

for i in range(n):
    for j in range(n):
        graph[i][j] = a[i][j]

for k in range(n):
    for i in range(n):
        for j in range(n):
            graph[i][j] = min(graph[i][j], graph[i][k] + graph[k][j])

for i in range(n):
    for j in range(n):
        if graph[i][j] < a[i][j]:
            print(-1)
            exit()

ans = 0

for i in range(n):
    for j in range(i+1, n):
        v = INF
        for k in range(n):
            if k == i or k == j:
                continue
            v = min(v, graph[i][k] + graph[k][j])
        if v != graph[i][j]:
            ans += graph[i][j]

print(ans)

Measured memory_bytes: 125276
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
b = 0
for i in range(N):
    if A[i]>B[i]:b+=(A[i]-B[i])
for i in range(N):
    if A[i]<B[i]:
        c = (B[i]-A[i])//2
        if c<=b:b-=c
        elif c>b:b=0
print("No" if b else "Yes")

Measured memory_bytes: 4596
/*input
codefestival
100

*/
#include <bits/stdc++.h>
#include <stdlib.h>
#include <time.h> 

using namespace std;
long long mod=1e9+7;
typedef long long int lld;
#define rep(i,a,n) for(long long int i = (a); i <= (n); ++i)
#define repI(i,a,n) for(int i = (a); i <= (n); ++i)
#define repD(i,a,n) for(long long int i = (a); i >= (n); --i)
#define repDI(i,a,n) for(int i = (a); i >= (n); --i)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define sc(a) scanf("%lld",&a)
#define sc2(a,b) scanf("%lld%lld",&a,&b)
#define sc3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define scd(a) scanf("%d",&a)
#define scd2(a,b) scanf("%d%d",&a,&b)
#define scd3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define scf(a) scanf("%lf",&a)
#define scf2(a,b) scanf("%lf%lf",&a,&b)
#define scf3(a,b,c) scanf("%lf%lf%lf",&a,&b,&c)
#define prL(a) printf("%lld\n",a)
#define prS(a) printf("%lld ",a)
#define prdL(a) printf("%d\n",a)
#define prdS(a) printf("%d ",a)
#define Error(x) cerr << #x << " = " << (x) <<endl;
#define Error2(a,b) cerr<<"( "<<#a<<" , "<<#b<<" ) = ( "<<(a)<<" , "<<(b)<<" )\n";
#define Error3(a,b,c) cerr<<"("<<#a<<" , "<<#b<<" , "<<#c<<" ) = ( "<<(a)<<" , "<<(b)<<" , "<<(c)<<")\n";
#define Error4(a,b,c,d) cerr<<"("<<#a<<" , "<<#b<<" , "<<#c<<" , "<<#d<<" ) = ( "<<(a)<<" , "<<(b)<<" , "<<(c)<<" , "<<(d)<<")\n";
#define errop(a) cerr<<#a<<" = ( "<<((a).x)<<" , "<<((a).y)<<" )\n";
#define popcount __builtin_popcountll
typedef pair<lld,lld> PA;
#define lim 1000010
#define lim2 3003
// inline lld sqr(lld x) { return x * x; }
// map<lld,lld>::iterator it;
// std::ios::sync_with_stdio(false);
// priority_queue<PA> Q;
// lld dp[1<<18];

lld A[lim],Fen[lim];

lld n,m,p,q;

lld P[lim];


lld powP(lld a,lld b){
    if(b==0) return 1%mod;
    lld k;
    k=powP(a,b/2);
    k=k*k%mod;
    if(b%2==0) return k;
    else return a*k%mod;
}


int main(){
    lld T,i,j,h,l,r,k,s,b,c,a,d,w,x,y,v,z,t,curr,prev,sum,ans,pos,val,countA,secondMin,indicator;
    string S;
    cin>>S;
    sc(k);
    n=S.size();
    rep(i,0,n-1){
        t=(26-(S[i]-'a'))%26;
        if(t<=k){
            S[i]='a';
            k-=t;
        }
    }
    k=k%26;
    S[n-1]=(S[n-1]-'a'+k)%26+'a';
    cout<<S<<endl;
    return 0;
}


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

int main(void) {
  char X[200010];
  int i, len, s, t, u;
  scanf("%s", &X);
  len = strlen(X);
  
  s = 0; u = 0;
  for (i=0;i<len;i++) {
    if (X[i] == 'S') s++;
    else if (s>0) s--;
    else u++;
  }
  u += s;
  printf("%d\n", u);
  return 0;
}


Measured memory_bytes: 384
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <map>
#include <bitset>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <utility>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;
#define all(c) (c).begin(), (c).end()
#define loop(i,a,b) for(ll i=a; i<ll(b); i++)
#define rep(i,b) loop(i,0,b)
#define each(e,c) for(auto&e:c)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define lb lower_bound
#define ub upper_bound
#ifdef DEBUG
#define dump(...) (cerr<<#__VA_ARGS__<<" = "<<(DUMP(),__VA_ARGS__).str()<<" ["<<__LINE__<<"]"<<endl)
struct DUMP:ostringstream{template<class T>DUMP &operator,(const T&t){if(this->tellp())*this<<", ";*this<<t;return *this;}};
#else
#define dump(...)
#endif
template<class T> ostream& operator<<(ostream& os, vector<T> const& v){
    rep(i,v.size()) os << v[i] << (i+1==v.size()?"":" ");
    return os;
}

double eps = 1e-9;

int n;
int x[24], y[24], r[24], c[24];
bool hit[24][24];
char dp[1<<24];

char dfs(int S){
    char & res = dp[S];
    if(res!=-1) return res;
    res = 0;
    rep(i,n){
        if(S>>i & 1){
            rep(j,i){
                if(S>>j & 1){
                    if(hit[i][j] || c[i]!=c[j]) continue;
                    bool ok = true;
                    rep(k,i) if(hit[i][k] && (S>>k & 1)) ok = false;
                    rep(k,j) if(hit[j][k] && (S>>k & 1)) ok = false;
                    if(!ok) continue;
                    S ^= 1<<i;
                    S ^= 1<<j;
                    res = max<char>(dfs(S)+2, res);
                    S ^= 1<<i;
                    S ^= 1<<j;
                }
            }
        }
    }
    return res;
}

int main(){
    while(cin>>n && n){
        memset(dp,-1,sizeof(dp));
        rep(i,n) cin >> x[i] >> y[i] >> r[i] >> c[i];
        rep(i,n)rep(j,i){
            int dx=x[i]-x[j], dy=y[i]-y[j];
            int d = dx*dx+dy*dy;
            hit[i][j] = hit[j][i] = d < (r[i]+r[j])*(r[i]+r[j]);
        }
        int S = 0;
        rep(i,n) S |= 1<<i;
        cout << (int)dfs(S) << endl;
    }
}

Measured memory_bytes: 17556
#include<bits/stdc++.h>
using namespace std;
//#define FOA(x) for(int i=0;i<x;i++)

int main(){
  int N;
  cin >> N;
  int count=0;
  for(int i=1;i<N;i++){
    count=count+(N-1)/i;
  }
  cout << count << endl;
}

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






int main() {
	int s,k,l;
	cin >> s>>k>>l;
	
	cout << (s*k*l)/(2*max(max(s,k),l)) << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <cstring>
#include <ctime>
#include <iostream>
#include <set>
#include <vector>
#include <sstream>
#include <typeinfo>
#include <fstream>
#include <algorithm>
#include <string>

using namespace std;
typedef long long ll;

int main(int argc, char *argv[]) {
  string s;
  cin >> s;
  cout << 700 + count(s.begin(), s.end(), 'o') * 100 << endl;
  return 0;
}


Measured memory_bytes: 256
S = list(input())
N = len(S)
# print(S)

if N % 2 == 0:
    div = int(N / 2)
else:
    div = int(N // 2)

# print(type(div),div)
S_pic = S[:div]
S_rev = list(reversed(S[div:]))

# print(S_pic)
# print(S_rev)

count = 0
for i in range(div):
    if S_pic[i] != S_rev[i]:
        count += 1

print(count)



Measured memory_bytes: 3060
#include <stdio.h>

int main() {
  int K, A, B;
  scanf("%d %d %d", &K, &A, &B);

  int flag = 0;
  for(int i = A; i <= B; i++) {
    if(i % K == 0) {
      printf("OK");
      flag = 1;
      break;
    }
  }

  if(!flag) {
    printf("NG");
  }
  return 0;
}

Measured memory_bytes: 1712
// include
// ------------------------------------------------
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;

// func
// ------------------------------------------------
int CalcSumOfDigit(int n);      // 各桁の和を計算する。
string upper(string str);       // 英字を大文字に変換する。
string lower(string str);       // 英字を小文字に変換する。

// define
// ------------------------------------------------
#define all(a)        (a).begin(),(a).end()
#define rall(a)       (a).rbegin(),(a).rend()
#define pb            push_back
#define sz(a)         int((a).size())
#define rep(i,n)      for(int(i)=0;(i)<(n);(i)++)
#define repe(i,n)     for(int(i)=0;(i)<=(n);(i)++)
#define vsort(v)      sort((v).begin(),(v).end())
#define rvsort(v)     sort(rall((v)))
#define vi            vector<int>
#define GCD(a,b)      __gcd((a),(b))
#define LCM(a,b)      (a)/GCD((a),(b))*(b)

const int INF = 1e9;

// code
// ------------------------------------------------
int main() {

  string s;
  cin >> s;

  string weekday[] = {"SUN" , "MON", "TUE","WED","THU","FRI","SAT"};

  int ans;
  rep(i,7)
  {
    if(weekday[i] == s)
    {
      ans = i;
      break;
    }
  }

  cout << 7 - ans;

  return 0;
}

// funcの実体
// ------------------------------------------------
int CalcSumOfDigit(int n)
{
  int s = 0;
  while(n)
  {
    s += n % 10;
    n = n / 10;
  }
  return s;
}

string upper(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(97 <= *itr && *itr <= 122)
    {
      *itr = *itr - 32;
    }
  }
  return str;
}

string lower(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(65 <= *itr && *itr <= 90)
    {
      *itr = *itr + 32;
    }
  }
  return str;
}


Measured memory_bytes: 256
N = int(input())


def dfs(n):
    if int(n) > N:
        return 0
    else:
        ret = 1 if all(n.count(c) > 0 for c in '753') else 0
        for c in '753':
            ret += dfs(n + c)
        return ret


print(dfs('0'))


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
/*
3
2 1 3
2,1,1,
1,1,
3
=9
[1-1][1-2][1-3]
[2-2][2-3]
[3-3]
全ての幅の最小値の総和。
しゃくとりっぽい
8
5 4 8 1 2 6 7 3
5,4,4,1,1,1,1,1,
  4,4,1,1,1,1,1,
    8,1,1,1,1,1,
      1,1,1,1,1,
        2,2,2,2,
          6,6,3,
            7,3,
              3,
左にある数*右にある数
数えるとTLE
効率化まぢむり。へいこうたんさくにぶんきりかいできない。
upper_boundとかでできないかな
8
5 4 8 1 2 6 7 3
abs(9-i)
4 5 1 8 7 3 2 6//右側に何個あるかを判定
5は何個ある？
4より上昇したらおしまい。lower_(0番目スタート,end,4+1)=1個目なので1個。
6 2 3 7 8 1 5 4//逆順に。左側に何個あるか判定できるか
upper_bound、sortしてる前提の二分探索だった･･･。期待はずれ･･･。
その数の左と右を探索、にこだわりすぎかな
1の両端OK
2は、1がくるまでか端までOK
3は、1，2までの幅
そんな感じで通行とめポイント増えてく
ああ、通行止めポイントの座標位置を、setで埋めてく感じ？
んで、その前後の値がとれればleftとright位置わかる。
毎回sort?それがset？
setは、数値はとれる。*ITとか。でもそれが配列の中の何番目かはとれない。
やっぱ配列で。
あああだめか。むしろ遅くなっている。毎回sortはだめか。
setだとして。
指定より大きい数の値をもってくることは可能。
問題は、指定より小さい数がもってこれない。
なんとかならんかな。
指定数がset配列の何番目か、がわかればいいんだけど。
もしくは、以下を探索。
S.find?
*/
int main(){
  ll N,ans=0; cin>>N;
  vector<ll> A(N+1,0), place(N+1,0);
  set<ll> S;
  S.insert(0);
  S.insert(N+1);
  for(int i=1; i<=N; i++){
    ll a; cin>>a;
    A[i]=a;
    place[a]=i;
  }
  for(int i=1; i<=N; i++){
    S.insert(place[i]);//1の場所から入れてく。
    //入れた値の前後の値をとってくる
    auto IT=S.find(place[i]);
    ll left=*IT;
    ll right=*IT;
    IT--;
    left-=*IT;
    IT++;
    IT++;
    right=*IT-right;
    ans+=left*right*i;
  }
  cout<<ans<<endl;
}

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

#define all(x) (x).begin(),(x).end()
#define rep(i,l,r) for(int i=(int)(l);i<(int)(r);i++)

typedef long long ll;
const ll MOD = 1e9 + 7;
const ll inf = 1LL<<60;
const double eps = 1e-9;

int main()
{
    int a, b;
    cin >> a >> b;
    cout << 6 - a - b << endl;
    return 0;
}



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

#define REP(i, m, n) for (int i = (m); i < (int)(n); i++)
#define REPS(i, m, n) for (int i = (m); i <= (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define reps(i, n) for (int i = 0; i <= (int)(n); i++)
#define rrep(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define rreps(i, x) for (int i = (int)(x); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int, int> P;
const int inf = INT_MAX;
const ll INF = 1LL << 60;
const ll mod = 1e9 + 7;
const double EPS = 1e-10;
const double PI = acos(-1.0);
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val) { fill( (T*)array, (T*)(array+N), val ); }
template <class T1, class T2, class Pred = std::less<T2> >
struct sort_pair_second {
    bool operator()(const std::pair<T1,T2>&left, const std::pair<T1,T2>&right) {
        Pred p;
        return p(left.second, right.second);
    }
};

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

    int A, B, M; cin >> A >> B >> M;
    vector<int> a(A), b(B);
    int mi = inf;
    int mi2 = inf;
    rep(i, A) {
        cin >> a[i];
        mi = min(mi, a[i]);
    }
    rep(i, B) {
        cin >> b[i];
        mi2 = min(mi2, b[i]);
    }
    int ans = mi + mi2;
    rep(i, M) {
        int x, y, c;
        cin >> x >> y >> c;
        if (a[x-1] + b[y-1] - c < ans) {
            ans = a[x - 1] + b[y - 1] - c;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>

int main()
{
	std::string a, b, c;
	std::cin >> a >> b >> c;

	std::string ans = "";
	if( a.back() == b.front() and b.back() == c.front() ) {
		ans = "YES";
	}
	else {
		ans = "NO";
	}

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


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR (i, 0, n)
#define _ << " _ " <<
#define TRACE(x) cerr << #x << " = " << x << endl
#define debug(...) fprintf(stderr, __VA_ARGS__)
//#define debug
//#define TRACE(x)

using namespace std;

typedef long long llint;

const int MAXN = 100010;

int n, a[MAXN];
llint sol;

int main(void) {
  scanf("%d",&n);
  REP(i, n) 
    scanf("%d",&a[i]);
  
  int prv = 0;
  REP(i, n) {
    if (a[i] == 0)
      prv = 0;
    else {
      a[i] += prv;
      sol += a[i] / 2;
      prv = a[i] % 2;
    }
  }

  printf("%lld\n",sol);
  
  return 0;
}


Measured memory_bytes: 640
{-# LANGUAGE ScopedTypeVariables #-}
import Data.Char
import Data.Int
import Data.Bifunctor
import qualified Data.Vector.Unboxed as U
import qualified Data.ByteString.Char8 as BS

readInt :: BS.ByteString -> Int
readInt s = case BS.readInt s of
              Just (x, _) -> x

main = do
  n <- readInt <$> BS.getLine
  -- xs <- U.fromListN . map read . words <$> getLine
  xs :: U.Vector Int64 <- U.unfoldrN n (fmap (bimap fromIntegral (BS.dropWhile isSpace)) . BS.readInt) <$> BS.getLine
  let negatives = U.filter (< 0) xs
      abss = U.map abs xs
  if even (U.length negatives)
    then print $ U.sum abss
    else print $ U.sum abss - 2 * U.minimum abss


Measured memory_bytes: 5756
#include<bits/stdc++.h>
using namespace std;
#define int long long
struct BIT{
  vector<int> bit;
  int n;
  //1-indexed
  BIT(){init();}
  BIT(int n):n(n){init();}
  void init(){
    bit.clear();
    bit.resize(n+1,0);
  }
  int sum(int i){
    int s=0;
    while(i>0){
      s+=bit[i];
      i-=i&-i;
    }
    return s;
  }
  void add(int i,int x){
    while(i<=n){
      bit[i]+=x;
      i+=i&-i;
    }
  }
  int sum0(int i){
    return sum(i+1);
  }
  void add0(int i,int x){
    add(i+1,x);
  }
};
signed main(){
  int n,q;
  cin>>n>>q;
  BIT bit(n);
  for(int i=0;i<q;i++){
    int c,x,y;
    cin>>c>>x>>y;
    if(c) cout<<bit.sum(y)-bit.sum(x-1)<<endl;
    else bit.add(x,y);
  }
  return 0;
}
/*
verified on 2017/04/22
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=DSL_2_B&lang=jp
 */

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

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

fn main() {
    let n: usize = read();
    let t: f64 = read();
    let a: f64 = read();
    let mut h: Vec<i64> = vec![];
    let mut ans = 0;

    for _ in 0..n {
        h.push(read());
    }

    let mut diff = (t - h[0] as f64 * 0.006 - a).abs();

    for i in 0..h.len() {
        let hi = h[i];
        if diff > (t - hi as f64 * 0.006 - a).abs() {
            diff = (t - hi as f64 * 0.006 - a).abs();
            ans = i;
        }
    }
    println!("{}", ans + 1);
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+100;
long long int arr[maxn];
int main()
{
    int n;
    cin>>n;
    long long int ans=1;
    bool flag=false;
    for(int i=0; i<n; ++i)
    {
        cin>>arr[i];
        if(arr[i]==0)
            flag=true;
    }
    if(flag)
        cout<<0<<endl;
    else
    {
        long long int temp=1e18;
        flag=true;
        for(int i=0; i<n; ++i)
        {
            if(temp/ans<arr[i])
                flag=false;
            else
                ans*=arr[i];
        }
        if(ans>temp)
            flag=false;
        if(flag)
            cout<<ans<<endl;
        else
            cout<<-1<<endl;
    }
    return 0;
}


Measured memory_bytes: 4428
import math
a,b=map(int,input().split())
r_max=int((b+1)//0.1)
r_min=int(b//0.1)
ans=0
for i in range(r_max,r_min,-1):
    if math.floor(i*0.08)==a:
        ans=i
print(-1 if ans==False else ans)

Measured memory_bytes: 61848
#include<bits/stdc++.h>
using namespace std;
const double PI=3.14159265358979323846;
#define int long long int
signed main(){
    int x;cin>>x;
    for(int i=-1000;i<1001;i++)for(int j=-1000;j<1001;j++)if((i*i*i*i*i)-(j*j*j*j*j)==x){cout<<i<<" "<<j<<endl;return 0;}
    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define dunk(a) cout << (a) << endl
#define rall(a) (a).rbegin(),(a).rend()
const int INF = 2e9;
using namespace std;
using Graph = vector<vector<int>>;
typedef pair<int,int> P;
typedef long long ll;

int main(){
    int n; cin >> n;
    ll ans = 1;
    rep(i,n){
        ans *= i+1;
        ans %= 1000000007;
    }

    cout << ans << endl;
}

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

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

using namespace std;

typedef long long ll;
const long long INF = 1e9;

int main()
{
  int N, W; cin >> N >> W;
  vector<ll> w(N), v(N);
  for(int i = 0; i < N; i++) cin >> w[i] >> v[i];

  vector<vector<ll> > dp(N + 1, vector<ll>(100100, 0));

  dp[0][0] = 0;
  for (int i = 0; i < N; i++)
  {
    for (int sum_w = 0; sum_w <= W; sum_w++)
    {
      if(sum_w - w[i] >= 0){
        chmax(dp[i + 1][sum_w], dp[i][sum_w - w[i]] + v[i]);
      }

      chmax(dp[i + 1][sum_w], dp[i][sum_w]);
    }
  }

  cout << dp[N][W] << endl;
  
}


Measured memory_bytes: 80256
n,x,y = map(int,input().split())

s = [0]*(n)

for i in range(1,n):
    for k in range(i+1,n+1):
        dist = min(k-i, abs(x-i) + 1 + abs(y-k))
        s[dist] += 1

for i in range(1,n):
    print(s[i])

Measured memory_bytes: 3444
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1000000000LL;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
  string a, b, c;
  cin >> a >> b;
  c = a + b;
  int num = atoi(c.c_str());

  bool f = false;
  for(int i = 1; i * i <= 100100; i++)
    if(i * i == num){
      f = true;
      break;
    }
  
  if(f) cout << "Yes" << ln;
  else cout << "No" << ln;
}


Measured memory_bytes: 256
n=int(input())
jumin=list(map(int,input().split()))
#print(jumin)
sum=0
energy=[]
#print(jumin)

for i in range(1,101):
    for j in jumin:
        sum+=(j-i)**2
        #print(j-i)
        #print(sum)
    energy.append(sum)
    sum=0
    #print(energy)
#print(min(energy))
min=min(energy)
print(min)

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

#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

// order statistics tree
typedef tree<pii, null_type, less<pii>, rb_tree_tag,
             tree_order_statistics_node_update> indexed_set;

#define F first
#define S second
#define PB push_back
#define MP make_pair

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define rrep(i, b, a) for(int i = b; i >= a; --i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()

const ll MOD = 1e9+7;
const int N = 2e3+10;
int n, k;
ll C[N][N];

int main() {
  cin.tie(0); cin.exceptions(cin.failbit);
  scanf("%d%d", &n, &k);

  rep(i, 0, n+1){
    rep(j, 0, i+1){
      if(j == 0 || j == i) C[i][j] = 1;
      else {
        C[i][j] = (C[i-1][j] + C[i-1][j-1]) % MOD;
      }
    }
  }

  rep(i, 1, k+1){
    ll ans = (C[n-k+1][i] * C[k-1][i-1]) % MOD;
    printf("%lld\n", ans);
  }
}


Measured memory_bytes: 30208
n,x=map(int,input().split())
a=list(map(int,input().split()))
c=max(0,a[0]-x)
a[0]=min(a[0],x)
for i in range(n-1):
  t=a[i]+a[i+1]
  if t>x:
    c+=t-x
    a[i+1]=x-a[i]
print(c)

Measured memory_bytes: 14540
/**
 *  @author: pr4shan7 (प्रशांत)
 */
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

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

// #define _DEBUG

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

#ifdef _DEBUG
  ifstream cin("input.txt");
  // ofstream cout("output.txt");
#endif

  int n;
  cin >> n;
  int ar[n];
  for (int i = 0; i < n; i++) {
    cin >> ar[i];
  }

  unsigned long long val;

  for (int i = 0; i < n - 1; i++) {
    for (int j = i + 1; j < n; j++) {
      val += 1ULL * ar[i] * ar[j];
    }
  }

  cout << val << '\n';
  return 0;
}


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

using i8  = int8_t;   /* -128 ~ 127 */
using u8  = uint8_t;  /* 0 ~ 255 */
using i16 = int16_t;  /* -32,768 ~ 32,767 */
using u16 = uint16_t; /* 0 ~ 65,535 */
using i32 = int32_t;  /* -2,147,483,648 ~ 2,147,483,647 */
using u32 = uint32_t; /* 0 ~ 4,294,967,295 */
using i64 = int64_t;  /* -9,223,372,036,854,775,808 ~ 9,223,372,036,854,775,807 */
using u64 = uint64_t; /* 0 ~ 18,446,744,073,709,551,615 */
using f32 = float;    /* (-3.4 * 10^38) ~ (3.4 * 10^38) */
using f64 = double;   /* (-1.7 * 10^308) ~ (1.7 * 10^308) */
using f80 = __float80;
template <class T> using Vec = vector<T>;
constexpr i64 INF = 1010000000000000017;
constexpr i64 MOD = 1e9 + 7;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
#define ALL(v) v.begin(), v.end()
#define GCD(a, b) __gcd(a, b) /* 最大公約数 */
#define LCM(a, b) a / __gcd(a, b) * b /* 最小公倍数 */

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}

void Main() {
    i32 N, K, Q;
    cin >> N >> K >> Q;
    Vec<i32> P(N + 1, 0);
    for (i32 i = 0; i < Q; i++) {
        i32 A; cin >> A;
        P[A]++;
    }
    Vec<bool> ans(N + 1, false);
    for (i32 i = 1; i <= N; i++) {
        if (K - Q + P[i] > 0) ans[i] = true;
    }
    for (i32 i = 1; i <= N; i++) {
        cout << ((ans[i])? "Yes" : "No") << endl;
    }
}


Measured memory_bytes: 3672
#include <bits/stdc++.h>
#define FOR(i, a, n) for(ll i = (ll)a; i < (ll)n; i++)
#define rep(i, n) FOR(i, 0, n)
#define ALL(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;

constexpr int Mod = 998244353;
constexpr int mod = 1e9 + 7;
constexpr ll inf = 1LL << 60;

template <typename T> constexpr bool chmax(T &a, const T &b) {
    if(a >= b) return false;
    a = b;
    return true;
}
template <typename T> constexpr bool chmin(T &a, const T &b) {
    if(a <= b) return false;
    a = b;
    return true;
}

/*-------------------------------------------*/

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

    int N;
    cin >> N;
    vector<ll> X(N), Y(N);
    bool odd = false, even = false;
    rep(i, N) {
        cin >> X[i] >> Y[i];
        (X[i] + Y[i] & 1 ? odd : even) = true;
        if(even) Y[i]--; //奇数の場合に帰着 最後に1,Uすればよい
    }
    if(odd && even) {
        cout << -1 << endl;
        return 0;
    }
    cout << 31 + even << endl;
    for(int i = 30; i >= 0; i--)
        cout << (1 << i) << " ";
    if(even) cout << 1;
    cout << endl;

    string s = "LDUR";
    rep(i, N) {
        ll a = X[i] + Y[i];
        ll b = X[i] - Y[i];
        string ans;
        ll nowa = 0, nowb = 0;
        for(int j = 30; j >= 0; j--) {
            int A, B;
            nowa += ((A = (nowa < a)) ? 1 : -1) << j;
            nowb += ((B = (nowb < b)) ? 1 : -1) << j;
            ans.push_back(s[2 * A + B]);
        }
        cout << ans;
        if(even) cout << "U";
        cout << endl;
    }

    return 0;
}

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

#define INF 10000001

#define MOD 1000000007

typedef long long ll;

std::map<int,std::vector<int>> mp;
std::vector<int> used;
std::vector<std::vector<int>> connect;

int dfs(int now,int depth,int n){
  if(used[now]){
    return 0;
  }
  if(depth==n){
    return 1;
  }

  used[now] = 1;

  int ans = 0;
  for(int i=0;i<n;i++){
    if(connect[now][i]){
      ans += dfs(i,depth+1,n);
    }
  }

  used[now] = 0;

  return ans;
}

int main(void){
  int n,m,a,b;
  std::cin >> n >> m;

  used = std::vector<int>(n,0);
  connect = std::vector<std::vector<int>>(n,std::vector<int>(n,0));
  for(int i=0;i<m;i++){
    std::cin >> a >> b;
    a -= 1; b -= 1;
    connect[a][b] = connect[b][a] = 1;
  }

  std::cout << dfs(0,1,n) << std::endl;
  return 0;
}


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

int main(){
int n,w;
  cin >> n >> w;
string d[50];
  for(int i=0;i<n;i++) cin >> d[i];
 int dx[8]={1,0,-1,0,1,1,-1,-1};
 int dy[8]={0,-1,0,1,1,-1,-1,1};
for(int i=0;i<n;i++){
  for(int j=0;j<w;j++){
    
    if(d[i][j]=='#')continue;
    int num=0;
    for(int k=0;k<8;k++){
     int x=j+dx[k];
     int y=i+dy[k];        
    if(x<0 | w<=x)continue;
    if(y<0 | n<=y)continue;
    if(d[y][x]=='#')num++;      
    }
    d[i][j]=char(num+'0');
  }
}  
for(int i=0;i<n;i++) cout << d[i] << endl;
  
  
}


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

using namespace std;

#define reset(x) memset(x, 0, sizeof(x));
#define recopy(a, b) memcpy(b, a, sizeof(a));
typedef unsigned long long ULL;
typedef long long LL;
const int mod = 1e9 + 7;
const int maxn = 2e5 + 10;

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

    int N, X, T;
    cin >> N >> X >> T;
    for (int i = 1; ; i++) {
        if (i * X >= N) {
            cout << i * T << endl;
            break;
        }
    }

    return 0;
}

Measured memory_bytes: 3604