akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

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

        if (a == b && a != c && b != c || a == c && a != b && b != c || b == c && a != b && a != c) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}


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

int main() {
  int n;
  cin >> n;
  vector<int> h(n);
  for(int i=0;i<n;i++){
    cin >> h.at(i);
  }
  bool a=true;
  for(int i=n-1;i>0;i--){
    if(h.at(i)<h.at(i-1)){
      if(h.at(i)<h.at(i-1)-1){
      a=false;
      break;
     }
     else{
       h.at(i-1)--;
       }
    }
  }
  if(a==true)
  cout << "Yes" << endl;
  else
  {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>

using namespace std;

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

int dist[1010][1010];

int main(void){
	int h, w, n; cin >> h >> w >> n;
	vector<string> fieldMap(h);
	queue<pair<int, int> > que;
	for(int i=0; i<h; i++){
		cin >>  fieldMap[i];
		for(int j=0; j<w; j++){
			if(fieldMap[i][j] == 'S'){
				fieldMap[i][j] = '0';
				que.push(make_pair(i, j));
			}
		}
	}

	int ans = 0;
	fill(dist[0], dist[h], -1);
	for(int g=1; g<=n; g++){
		pair<int, int> pos = que.front();
		dist[pos.first][pos.second] = 0;
		bool find = false;
		while(!que.empty() && !find){
			pair<int, int> pos = que.front(); que.pop();
			int ncost = dist[pos.first][pos.second];
			for(int i=0; i<4; i++){
				int ny = pos.first + dy[i];
				int nx = pos.second + dx[i];
				if(ny < 0 || h <= ny || nx < 0 || w <= nx) continue;
				if(fieldMap[ny][nx] == 'X') continue;
				if(fieldMap[ny][nx] - '0' == g){
					ans += ncost + 1;
					while(!que.empty()) que.pop();
					que.push(make_pair(ny, nx));
					fill(dist[0], dist[h], -1);
					dist[ny][nx] = 0;
					find = true;
					break;
				}
				if(dist[ny][nx] == -1){
					dist[ny][nx] = ncost + 1;
					que.push(make_pair(ny, nx));
				}
			}
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 7952
import scala.io.StdIn.{readLine,readInt}

object Main extends App {

  var index = 1
  Iterator.continually(readInt).takeWhile ( w => w != 0).foreach { w =>
    val n = readInt
    val wv = Array.ofDim[Int](n+1,2)
    val m = Array.ofDim[Int](n+1,w+1)

    for(i<-1 to n) wv(i) = readLine.split(",").map(_.toInt)
    for(i<-1 to n;j<-0 to w) {
      if(j >= wv(i)(1) && m(i-1)(j) <= wv(i)(0) + m(i-1)(j-wv(i)(1)))
        m(i)(j) = wv(i)(0) + m(i-1)(j-wv(i)(1))
      else
        m(i)(j) = m(i-1)(j)
    }
    println("Case "+index+":")
    println(m(n)(w))
    println((0 to w).find(m(n)(_) == m(n)(w)).get)
    index += 1
  }
}

Measured memory_bytes: 49460
#include <bits/stdc++.h>
#define N 100001
using namespace std;
typedef pair<string,int> P;
typedef set<P>::iterator It;


void solve(string str,set<P> A,vector<int> &L){
  for(int i=0;i<str.size();i++){
    string t;
    t+=str[i];
    It it;
    while((it=A.lower_bound(P(t,-1)))!=A.end()){
      if(it->first.substr(0,t.size())!=t)break;
      while(it!=A.end()&&it->first==t) L[it->second] = i,A.erase(it++);
      if(i+t.size()>=str.size())break;
      t+=str[i+t.size()];
    }
  }
}

int main(){
  string str;
  cin>>str;
  int len=str.size(),n;
  cin>>n;
  set<P> A,B;
  string a[N],b[N];
  for(int i=0;i<n;i++){
    cin>>a[i]>>b[i];
    A.insert(P(a[i],i));
    reverse(b[i].begin(),b[i].end());
    B.insert(P(b[i],i));
  }
  vector<int> L(N,-1),R(N,-1);
    solve(str,A,L);
  reverse(str.begin(),str.end());
  solve(str,B,R);

  for(int i=0;i<n;i++){
    int cnt=0,alen = a[i].size(),blen=b[i].size();
    while(cnt<min(alen,blen)&&a[i][alen-cnt]==b[i][cnt])cnt++;
    if(L[i]==-1||R[i]==-1||len-R[i]<L[i]+alen-cnt)printf("0\n");
    else printf("%d\n",len-R[i]-L[i]);
  }  
  return 0;
}

Measured memory_bytes: 38428
n = int(input())
A = [None] + [int(i) for i in input().split()]

B = [0] * (n + 1)  # 1-indexed
ans = []

for i in range(1, n + 1)[::-1]:
    _tmp = sum(B[i * 2::i])
    if _tmp % 2 != A[i]:
        B[i] += 1
        ans.append(str(i))

print(len(ans))
print(" ".join(ans))


Measured memory_bytes: 98288
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;
#define INF 1000000000

int main(void){
	int n,k;
	cin >> n >> k;
	vector<int> y(n);
	int ans = INF;
	for(int i = 0; i < n; ++i){
		cin >> y[i];
	}
	for(int i = 0; i < n-k+1; ++i){
		int j = i+k-1;
		ans = min(ans,min(abs(y[i]-y[j])+abs(y[j]),abs(y[i]-y[j])+abs(y[i])));
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define FOR(i,a,b) for(int i=(a); i<=(b); i++) 
#define rep(i,n); for(int i = 0; i < (n); i++)
#define chmin(a,b) if((a)>(b)) (a)=(b); 
#define chmax(a,b) if((a)<(b)) (a)=(b);
#define vi vector<int>
int gcd(int a,int b){/*a>=0,b>=0,￢(a=b=0)*/
  while(min(a,b)>0){if(a<b)swap(a,b);a%=b;}return max(a,b);
}
int dx[]={0,1,0,-1,1,-1,-1,1};
int dy[]={1,0,-1,0,1,1,-1,-1};
const int MOD = 1e9+7;
const int INF = 1e10+10;

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

signed main(){
  int n;
  cin>>n;
  vi r(n);
  rep(i,n) cin>>r[i];
  int ans=-INF;
  int minr=r[0];
  FOR(i,1,n-1){
    chmax(ans,r[i]-minr);
    chmin(minr,r[i]);

  }

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


Measured memory_bytes: 4380
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    long[] t = new long[n];
    long sum = 0;
    for(int i = 0; i < n; i++) {
      t[i] = sc.nextLong();
      sum += t[i];
    }
    int m = sc.nextInt();
    for(int i = 0; i < m; i++) {
      int p = sc.nextInt() - 1;
      long x = sc.nextLong();
      long ans = sum - t[p] + x;
      System.out.println(ans);
    }
  }
}

Measured memory_bytes: 21844
#include<stdio.h>
int main()
{
    int A,B,rem,d;
    double result;
    scanf("%d%d",&A,&B);
    d=A/B;
    rem=A%B;
    result=(double)A/B;
    printf("%d %d %0.5f\n",d,rem,result);
    return 0;


}



Measured memory_bytes: 2148
let () =
  Scanf.scanf "%d %d %d" @@ fun n m q ->
  let lr = Array.init m (fun _ -> Scanf.scanf " %d %d" (fun x y -> x-1, y-1)) in
  let pq = Array.init q (fun _ -> Scanf.scanf " %d %d" (fun x y -> x-1, y-1)) in

  let co = Array.init n (fun _ -> Array.make n 0) in
  lr |> Array.iter (fun (l, r) -> co.(l).(r) <- co.(l).(r) + 1);

  for w = 1 to n-1 do
    for j = 0 to n-1-w do
      co.(j).(j+w) <-
        co.(j).(j+w) + co.(j+1).(j+w) + co.(j).(j+w-1) - co.(j+1).(j+w-1);
    done
  done;

  pq |> Array.iter (fun (p, q) -> Printf.printf "%d\n" co.(p).(q))

Measured memory_bytes: 15872
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000001;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

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

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

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};


///////////////////////////

bool solve(vector<ll> a, ll n) {
	if (a[n] == 1) { return false; }
	if (a[1] == 0) { return false; }
	repn(i, n - 1) { if (a[i] != a[n - i]) { return false; } }
	return true;
}



int main() {

	string s;
	cin >> s;

	vector<char> head[2];

	ll Q;
	cin >> Q;

	ll c = 0;

	repn(i, Q) {
		ll t;
		cin >> t;
		if (t == 1) { c++; continue; }

		ll f;
		char cc;
		cin >> f >> cc;

		head[(c + f + 1) % 2].push_back(cc);
	}

	if (c % 2 == 0) {
		rep(i, head[0].size()) {
			cout << head[0][head[0].size() - 1 - i];
		}
		cout << s;
		rep(i, head[1].size()) {
			cout << head[1][i];
		}
	}

	if (c % 2 == 1) {
		rep(i, head[1].size()) {
			cout << head[1][head[1].size() - 1 - i];
		}
		rep(i, s.size()) {
			cout << s[s.size() - 1 - i];
		}
		;
		rep(i, head[0].size()) {
			cout << head[0][i];
		}
	}



	system("PAUSE");

}





Measured memory_bytes: 1272
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>
#define sz(v)   ((int)(v).size())
#define  all(v)    ((v).begin()),((v).end())
#define  allr(v)    ((v).rbegin()),((v).rend())
#define   pb         push_back
#define   mp         make_pair
#define   mt         make_tuple
//#define   Y            imag()
//#define   X            real()
#define    clr(v,d)      memset( v, d ,sizeof(v))
#define   angle(n)      atan2((n.imag()),(n.real()))
#define   vec(a,b)       ((b)-(a))
//#define   length(a)      hypot( (a.imag()),(a.real()) )
#define   normalize(a)      (a)/(length(a))
//#define    dp(a,b)          (((conj(a))*(b)).real())
//#define    cp(a,b)          (((conj(a))*(b)).imag())
#define    lengthsqrt(a)       dp(a,a)
#define    rotate0( a,ang)    ((a)*exp( point(0,ang) ))
#define    rotateA(about,p,ang)   (rotate0(vec(about,p),ang)+about)
#define    reflection0(m,v)         (conj((v)/(m))*(m))
#define     reflectionA(m,v,p0)     (conj( (vec(p0,v))/(vec(p0,m)) ) * (vec(p0,m)) ) + p0
//#define     same(p1,p2)               ( dp(  vec(p1,p2),vec(p1,p2)) < eps )
#define     point                    complex<int>
#define outfile freopen("out.out", "w", stdout);
#define infile  freopen("in.in", "r", stdin);
#define PI acos(-1)
typedef  long long     ll ;
typedef  unsigned long long ull;
const double eps= (1e-9);
using namespace std;
using namespace __gnu_pbds;
int dcmp(double a,double b){   return fabs(a-b)<=eps ? 0: (a>b)? 1:-1  ;}
int getBit(int num, int idx) {return ((num >> idx) & 1) == 1;}
ll setBit1(ll num, int idx) {return num | (1ll<<idx);}
ll setBit0(ll num, int idx) {return num & ~(1ll<<idx);}
ll flipBit(int num, int idx) {return num ^ (1<<idx);}
void FS(){ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);}
vector<double> v;
int n;
int main()
{
    cin>>n;
    double no;
    for(int i=0;i<n;i++)
        cin>>no,v.pb(no);
    sort(all(v));
    double ans=v[0];
    for(int i=1;i<sz(v);i++)
    {
        ans=(ans+v[i])/2;
    }
    cout<<fixed<<setprecision(12)<<ans<<endl;
}












Measured memory_bytes: 256
import java.math.BigInteger;
import java.util.Scanner;

public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ


		Scanner scan = new Scanner(System.in);
		while(scan.hasNext()){
			BigInteger a = new BigInteger(scan.next());
			BigInteger b = new BigInteger(scan.next());
			System.out.println(a.gcd(b)+" "+(long)a.intValue()*b.intValue()/a.gcd(b).intValue());
		}
	}

}

Measured memory_bytes: 12000
#include <vector>
#include <list>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <cstdio>
#include <climits>
#include <complex>
#include <cstdint>
#include <tuple>

#define M_PI       3.14159265358979323846

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }
inline int readInt() { int x; scanf("%d", &x); return x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util

//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SQ(a) ((a)*(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
struct Edge {
    int to, cost;
    Edge(int to, int cost): to(to), cost(cost) {}
};

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<Edge>> AdjList;
AdjList graph;

const int INF = 100000000;

LL N, M;

map<int, char> mp;

int main() {
    //cout << fixed << setprecision(15);
    int n;
    LL a, b, c; cin >> a >> b >> c;
    vector<pair<int, int> >vp;
    vp.push_back({0, a});
    int cnt=1;
    while(cnt!=500){
        vp.push_back({cnt*(a+b), (cnt+1)*a + cnt*b});
        cnt++;
    }

    vector<int> v;
    for(int i=0; i<1000; ++i){
        v.push_back(60*i+c);
    }

    REP(i, 500){
        REP(j, vp.size()){
            if(v[i] < vp[j].first) break;

            if(v[i]>=vp[j].first && v[i]<=vp[j].second){
                cout << v[i] << endl;
                return 0;
            }
        }
    }
    cout << -1 << endl;
    return 0;
}


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

count = 0
for i in range(1, 10):
    for j in range(10):
        for k in range(10):
            num = int(str(i) + str(j) + str(k) + str(j) + str(i))
            if A <= num <= B:
                count += 1
print(count)
    

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

using namespace std;

template <typename T> T gcd(T x, T y) {
  if (y == 0)
    return x;
  return gcd(y, x % y);
}

template <typename T> T lcm(T x, T y) {
  if (x == 0 || y == 0)
    return 0;
  return x / gcd(x, y) * y;
}

const int mod = 1000000007;

int main() {
  string S;
  cin >> S;
  int n = S.size();
  int k = INT_MAX;
  for (int i = 0; i < n - 1; i++) {
    if (S[i] != S[i + 1])
      k = min(k, max(i + 1, n - i - 1));
  }
  cout << (k == INT_MAX ? n : k) << endl;
}

Measured memory_bytes: 512
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<algorithm>
#include<math.h>
#include<numeric>
#include<iomanip>
#include<deque>
#include<tuple>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<cstdint>
#include<unordered_map>
#include<boost/multiprecision/cpp_int.hpp>

#define rep(i, n) for(int i = 0; i < ( int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define vi vector<int>
#define vll vector<ll>
#define all(x) (x).begin(),(x).end()
#define F first
#define S second
#define pb push_back

namespace mp = boost::multiprecision;

using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;

typedef pair<int, int> P;

bool ps1(const P& element1, const P& element2)
{//first昇順
	return element1.first < element2.first;
}
bool ps2(const P& element1, const P& element2)
{//first降順
	return element1.first > element2.first;
}
bool ps3(const P& element1, const P& element2)
{//second昇順
	return element1.second < element2.second;
}
bool ps4(const P& element1, const P& element2)
{//second降順
	return element1.second > element2.second;
}

int main()
{
	int a, p;
	cin >> a >> p;
	int ans = a * 3 + p;
	cout << ans / 2 << endl;
}



Measured memory_bytes: 256
///***Bismillahir Rahmanir Rahim***///

///*********************************///
///******Ashraful Haque Toni********///
///********Dept. of CSE,JnU*********///
///email:ashrafulhaquetoni@gmail.com///
///*******contact:01640690531*******///
///*********************************///


#include<bits/stdc++.h>

using namespace std;

#define         ash ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define         pb push_back
#define         mp make_pair
#define         sc(n) scanf("%d",&n);
#define         scl(n) scanf("%I64d",&n);
#define         sc2(m,n) scanf("%d%d",&m,&n);
#define         sc2l(m,n) scanf("%I64d%I64d",&m,&n);
#define         pf printf
#define         Big(x,y) max(x,y);
#define         Small(x,y) min(x,y);
#define         input(array,size) for(int i=0;i<size;i++)cin>>array[i];
#define         newline pf("\n");
#define         f(s,l,in) for(ll i=s;i<l;i+=in)
#define         Max INT_MAX
#define         Min INT_MIN
#define         pi acos(-1.0)
#define         Memset(a,val) memset(a,val,sizeof(a));

const int mod =1e9+7;
const int N =5e6+5;
typedef long long ll;



int main()
{

    ash;
    ll a,b;
    cin>>a>>b;
    if(a>=b)cout<<10<<endl;
    else cout<<0<<endl;



    return 0;
}




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

typedef long long lint;
typedef pair<int, int> P;
#define REP(i, x, n) for(lint i = x ; i < n ; i++)
#define rep(i, n) REP(i, 0, n)
#define repr(i, n) for(lint i = n - 1 ; i >= 0 ; i--)
#define SORT(c) sort((c).begin(), (c).end())

const int IINF = 1e9 + 10;
const lint LLINF = (lint)1e18 + 10;
const lint MOD = (lint)1e9 + 7;
const int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};

lint d, n, m;
vector<lint> shop, house;

int main(){
    while(cin >> d, d){
        cin >> n >> m;
        shop.resize(n-1);
        rep(i, n-1){
            cin >> shop[i];
        }
        shop.push_back(0);
        shop.push_back(d);
        SORT(shop);
        house.resize(m);
        rep(i, m){
            cin >> house[i];
        }
        lint ans = 0;
        rep(i, m){
            int k = (upper_bound(shop.begin(), shop.end(), house[i]) - shop.begin());
            lint tmp = min(abs(shop[k] - house[i]), abs(house[i] - shop[k-1]));
            ans += tmp;
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 4672
#include <stdio.h>
#include <math.h>

int main()
{
	int n = 1, count = 0, hensa_num = 0;
	double bunsann = 0, heikin = 0, hensa[1000], sum = 0;
	int point[1000];


	scanf( "%d", &n );
	while ( n ) { 
		while ( count < n )
		{
			scanf("%d", &point[count]);
			sum = sum + point[count];
			count = count + 1;
		}

		heikin = sum / n;
		count = 0;
		bunsann = 0;
		sum = 0;

		while ( count < n )
		{
			bunsann = bunsann + ( point[count] - heikin ) * ( point[count] - heikin );
			count = count + 1;
		}
		hensa[hensa_num] = sqrt( bunsann / n );
		hensa_num = hensa_num + 1;
		count = 0;
		scanf( "%d", &n );
	}

	count = 0;
	while ( count < hensa_num ){
		printf("%f\n", hensa[count] );
		count = count + 1;
	}
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#include<set>
#include <algorithm>
#define ll long long 
#include <string.h>
using namespace std;

int main()
{
	string s;
	cin>>s;
	if (s=="ARC")
	cout<<"ABC"<<endl;
	else
	cout<<"ARC"<<endl;
	
	
} 




Measured memory_bytes: 3624
#include <fstream>
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <sstream>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <cmath>
#include <queue>
#include <random>

using namespace std;

#define INT_MAX_VALUE 2147483647
#define LONG_LONG_MAX_VALUE 9223372036854775807
#define ll long long
#define ld long double

struct XX{
    ll x;
    ll y;
    ll px;
    ll py;
};

class xxGreater {
public:
    bool operator()(const XX& riLeft, const XX& riRight) const {
        //第2条件
        if((riLeft.x) == (riRight.x)){
            return riLeft.y < riRight.y;//<:昇順(小さいものから順番)、>:降順(大きいものから順番)
            //プライオリティキューの場合は > で、top()すると値の小さいものがとれる
        }
        //第1条件
        return (riLeft.x) < (riRight.x);
    }
};

//map<long long,long long> prime_f(long long n){
//    map<long long,long long>res;
//    for(int i=2;i*i<=n;i++){
//        while(n%i==0){
//            ++res[i];
//            n/=i;
//        }
//    }
//    if(n!=1)res[n]=1;
//    return res;
//}

//int n;
////int dat[2*10000000];
////int dat2[2*10000000];
//int dat[10];
//int dat2[10];
//
//void init(int n_){
//    n=1;
//    while(n<n_)n*=2;
//    for(int i=0;i<2*n-1;i++){
//        dat[i]=0;
//        dat2[i]=0;
//    }
//}
//
//void initset(int k,int a){
//    k+=n-1;
//    dat[k]=a;
//    while(k>0){
//        k=(k-1)/2;
//        dat[k]=dat[k*2+1]+dat[k*2+2];
//    }
//}
//
////[a,b)の間を[l,r]区間で比較しアップデート
////引数のindexに注意
////nは固定。initで計算すみ
////update2(L[i],R[i]+1,0,0,n,D[i]);
//void update2(int a,int b,int k,int l,int r,int v){//v更新値、区間は0-index
//    if(r<=a || b<=l)return;
//    if(a<=l && r<=b){
//        dat[k]+=dat2[k];
//        if(r-l>1){
//            dat2[k*2+1]+=dat2[k]/2;
//            dat2[k*2+1]+=dat2[k]/2;
//        }
//        dat2[k]=v*(r-l);
//        return;
//    }else{
//        update2(a,b,k*2+1,l,(l+r)/2,v);
//        update2(a,b,k*2+2,(l+r)/2,r,v);
//        return;
//    }
//}
//
//int query(int a,int b,int k,int l,int r){
//    if(r<=a || b<=l)return 0;
//    if(a<=l && r<=b){
//        dat[k]+=dat2[k];
//        if(r-l>1){
//            dat2[k*2+1]+=dat2[k]/2;
//            dat2[k*2+1]+=dat2[k]/2;
//        }
//        dat2[k]=0;
//        return dat[k];
//    }
//    else{
//        int vl=query(a,b,k*2+1,l,(l+r)/2);
//        int vr=query(a,b,k*2+2,(l+r)/2,r);
//        return vl+vr;
//    }
//}






int main(int argc, const char * argv[])
{
    //scanf("%s",S);
    //scanf("%d",&N);
    //scanf("%lld %lld",&target1,&target2);
    //sscanf(tmp.c_str(),"%dd%d%d",&time[i], &dice[i], &z[i]);
    //getline(cin, target);
    //ifstream ifs("3.txt");//テスト用
    //ifs >> a;
    //ここから
    
    //入力高速化
    ios::sync_with_stdio(false);
    cin.tie(0);

    int N,A,B;
    cin >> N>>A>>B;
    int ans1=0;
    ans1=min(A,B);
    int ans2=A+B-N;
    if(ans2<0){
        ans2=0;
    }


    cout << ans1 << " "<< ans2 << endl;
    
    //ここまで
    //cout << "ans" << endl;
    //printf("%.0f\n",ans);//小数点以下表示なし
    //printf("%.7f\n",p);
    
    return 0;
}


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

using namespace std;

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

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

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

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int gcd(int a, int b){
   int tmp;
   while(a%b==0){
      tmp=a%b;
      a=b;
      b=tmp;
   }
}

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

bool prime_number(int n){
   vector<bool> i;
   if(n < 2){
      return false;
   }
   else if(n == 2){
      return true;
   }
   if(n % 2 == 0){
      return false;
   }
   for(int i=3;i<=n/i;i+=2){
      if(n % i == 0) return false;
      return true;
   }
}

int main(){
   vector<string> s;
   string a,ans1,ans2;
   int tmp, f=0, l=0;
   while(cin>>a) s.PB(a);
   REP(i,s.size()){
      tmp=count(ALL(s),s[i]);
      if(f<tmp){
         f=tmp;
         ans1=s[i];
      }
      if(l<s[i].size()){
         l=s[i].size();
         ans2=s[i];
      }
   }
   cout << ans1 << " " << ans2 << endl;
}

Measured memory_bytes: 1204
#include<iostream>
#include<string>
#include<map>
#include<string.h>
#include<vector>
#include<set>
#include<stdio.h>
#include<math.h>
#include<queue>
using namespace std;
int main()
{
	int X,A,B,k;
	cin>>X>>A>>B;
	X-=A;
	k=X%B;
	cout<<k;
	system("pause");
  return 0;
}

Measured memory_bytes: 504
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
#include<iomanip>
#include<sstream>

#define fast_io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

using namespace std;

#define deb(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) { cout << '\n';}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cout << '[' << *it << " = " << a << "]  ";
    err(++it, args...);
}

#define fcout cout<<fixed<<setprecision(15)
#define repp(i,j,k) for(int i=j; i<k; ++i)
#define rep(i,j) repp(i,0,j)
#define rrep(i,j,k) for(int i=j; i>=k; --i)
#define all(x) (x).begin(), (x).end()
#define sort(x) sort(x.begin(), x.end())
#define lb(x,val) lower_bound(x.begin(), x.end(), val)
#define ub(x,val) upper_bound(x.begin(), x.end(), val)
#define pb(x) emplace_back(x);

typedef long long int lli;
typedef pair<int,int> pii;
typedef pair<lli,lli> pll;
typedef vector<int> vi;
typedef vector<lli> vl;
typedef tuple<lli, lli> tii;
typedef tuple<lli, lli, lli> tiii;

//const lli M=998244353ll;
const lli M=1000000007ll;
const double D=1.0;


void solve(){
	lli x; cin>>x;
	lli p=100ll,t=0;
	while(1){
		lli c=(p+p/100);
		t++;
		if(c>=x) break;
		p=c;	
	}
	cout<<t;

}

int main(){
	fast_io
	int tc=1;
	//cin>>tc;
	while(tc--){solve();}
	return 0;
}

Measured memory_bytes: 3192
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		int c = scan.nextInt();
		int z;
		if(a>b){
			z=a;
			a=b;
			b=z;
		}
		if(b>c){
			z=b;
			b=c;
			c=z;
		}
		if(a>b){
			z=a;
			a=b;
			b=z;
		}
		System.out.println(a+" "+b+" "+c);
	}
}

Measured memory_bytes: 17316
#include<stdio.h>
int main(){
  int r,g,b,n,count=0;
  int i,j;
  scanf("%d %d %d %d",&r,&g,&b,&n);
  for(i=0;i<=n/r;i++){
    for(j=0;j<=(n-r*i)/g;j++){
      if((n-r*i-g*j)%b==0)
        	count++;
    }
  }
  printf("%d\n",count);
  return 0;
}

Measured memory_bytes: 128
import sys
import math
MAX_INT = int(10e15)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

def tami(n, cnt, aoki, aoki_visited, edge):
  aoki_visited[n] = True
  aoki[n] = cnt
  for x in edge[n]:
    if aoki_visited[x] == False:
      tami(x, cnt+1, aoki, aoki_visited, edge)

def tami2(n, cnt, choku, choku_visited, edge, aoki):
  choku_visited[n] = True
  if cnt <= aoki[n]:
    choku[n] = cnt
    for x in edge[n]:
      if choku_visited[x] == False:
        tami2(x, cnt+1, choku, choku_visited, edge, aoki)


def main():
  N, u, v = IL()
  ab = [IL() for _ in range(N-1)]

  aoki = [0]*(N+1)
  aoki_visited = [False]*(N+1)
  choku = [0]*(N+1)
  choku_visited = [False]*(N+1)

  edge = [[] for _ in range(N+1)]
  for a,b in ab:
    edge[a].append(b)
    edge[b].append(a)

  ans = 0
  tami(v, 0, aoki, aoki_visited, edge)
  tami2(u, 0, choku, choku_visited, edge, aoki)
  #print(aoki)
  #print(choku)

  for i in range(N+1):
    if choku[i] == 0 and i != u:
      continue
    if aoki[i] > choku[i]:
      ans = max(ans, aoki[i] - 1)

  print(ans)

main()

Measured memory_bytes: 154404
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Collections;
import java.util.PriorityQueue;
import java.util.StringTokenizer;

/*
1
2
1 5 10
2 15 5

1
3
2 93 78
1 71 59
3 57 96

1
4
1 100 0
1 100 0
2 0 1
2 0 1
 */
public class Main {

	public static void main(String[] args) {
		FastScanner fs=new FastScanner();
		int T=fs.nextInt();
		PrintWriter out=new PrintWriter(System.out);
		for (int tt=0; tt<T; tt++) {
			int n=fs.nextInt();
			ArrayList<Camel> goLeft=new ArrayList<>();
			ArrayList<Camel> goRight=new ArrayList<>();
			long ans=0;
			for (int i=0; i<n; i++) {
				int k=fs.nextInt()-1, l=fs.nextInt(), r=fs.nextInt();
				if (l>=r) {
					goLeft.add(new Camel(k, l-r));
					ans+=r;
				}
				else {
					goRight.add(new Camel(n-1-(k+1), r-l));
					ans+=l;
				}
			}
//			System.out.println("Initially ans: "+ans);
			ans+=solve(goLeft);
			ans+=solve(goRight);
			out.println(ans);
		}
		out.close();
	}
	
	//wants to go left
	static long solve(ArrayList<Camel> camels) {
		Collections.sort(camels);
		int lastPos=-1;
		int nSpaces=0;
		PriorityQueue<Integer> removableDeltas=new PriorityQueue<>();
		for (Camel c:camels) {
			int dPositions=c.splitPoint-lastPos;
			lastPos=c.splitPoint;
//			System.out.println("Processing camel at split point "+c.splitPoint+" "+c.difference+" "+dPositions+" "+lastPos);
			nSpaces+=dPositions;
			if (nSpaces>0) {
//				System.out.println("Extra space ");
				removableDeltas.add(c.difference);
				nSpaces--;
				continue;
			}
			else {
//				System.out.println("No room");
				if (removableDeltas.isEmpty()) continue;
				if (removableDeltas.peek()<c.difference) {
					removableDeltas.remove();
					removableDeltas.add(c.difference);
				}
			}
		}
		long ans=0;
		for (long l:removableDeltas) ans+=l;
		return ans;
		
	}
	
	static class Camel implements Comparable<Camel> {
		int splitPoint;
		int difference;
		public Camel(int splitPoint, int difference) {
			this.splitPoint=splitPoint;
			this.difference=difference;
		}
		
		public int compareTo(Camel o) {
			return Integer.compare(splitPoint, o.splitPoint);
		}
	}

	static void sort(int[] a) {
		ArrayList<Integer> l=new ArrayList<>();
		for (int i:a) l.add(i);
		Collections.sort(l);
		for (int i=0; i<a.length; i++) a[i]=l.get(i);
	}
	
	static class FastScanner {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");
		String next() {
			while (!st.hasMoreTokens())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}
		
		int nextInt() {
			return Integer.parseInt(next());
		}
		int[] readArray(int n) {
			int[] a=new int[n];
			for (int i=0; i<n; i++) a[i]=nextInt();
			return a;
		}
		long nextLong() {
			return Long.parseLong(next());
		}
	}

	
}


Measured memory_bytes: 62444
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <climits>

int main(int argc, char **argv) {
        int a ,b;
        std::cin >> a >> b;

        if (a == 1) {
                a = 14;
        }
        if (b == 1) {
                b = 14;
        }
        if (a < b) {
                std::cout << "Bob" << std::endl;
        } else if (a > b) {
                std::cout << "Alice" << std::endl;
        }  else {
                std::cout << "Draw" << std::endl;
        }
        return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.buffer.readline
N,M = map(int,input().split())
AB = [list(map(int,input().split())) for i in range(M)]

AB = sorted(AB,key=lambda x : x[1])

remove = [-1]

for a,b in AB:
    if remove[-1] <= a:
        remove.append(b)

print(len(remove)-1)




Measured memory_bytes: 58972
#include <iostream>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<math.h>
#include<bits/stdc++.h>
#include<cmath>
#include<iomanip>
#include<queue>
#include<string>
using namespace std;

const double PI  =3.141592653589793238463;
#define pb push_back
#define pf push_front
#define sz(v)  ((int)(v).size());
#define all(v) ((v).begin()),((v).end())
typedef unsigned long long ull;
typedef long long ll;

typedef vector<int> vi;
typedef pair<int,int> pi;
//2 7 3 4 9

void printVec(vi v1)
{
    for(int i=0; i<v1.size(); i++)
        cout<<v1[i]<<" ";
    cout<<endl;
}
ll rec(ll r,ll c){

if(r<=1 || c<=1){
    return 1;
}


return rec(r-1,c)+rec(r,c-1);
}

int main()
{
    ios::sync_with_stdio(false);
    cout.tie(NULL);
    cin.tie(NULL);
ull n;cin>>n;
string str="";
while(n>=1){
    n--;
    str+='a'+(n%26);
    n/=26;
}reverse(str.begin(),str.end());
 cout<<str;
    return 0;
}


Measured memory_bytes: 3628
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <iomanip>
#include <map>
#include <set>
#include <tuple>
#include <unordered_map>
#include <iterator>
#include <string>
#include <limits>

using namespace std;

using i64 = int64_t;
using P = pair<i64, i64>;
i64 mod = 1000000007;
int int_max = 2147483647;
i64 INF = 1e16;
int max_n = 1e5;

__int128_t UPPER=1e18;

std::ostream &operator<<(std::ostream &dest, __int128_t value) {
  std::ostream::sentry s(dest);
  if (s) {
    __uint128_t tmp = value < 0 ? -value : value;
    char buffer[128];
    char *d = std::end(buffer);
    do {
      --d;
      *d = "0123456789"[tmp % 10];
      tmp /= 10;
    } while (tmp != 0);
    if (value < 0) {
      --d;
      *d = '-';
    }
    int len = std::end(buffer) - d;
    if (dest.rdbuf()->sputn(d, len) != len) {
      dest.setstate(std::ios_base::badbit);
    }
  }
  return dest;
}

int main(int argc, char **argv) {
    i64 n;
    cin >> n;

    __int128_t ans{1};
    vector<i64> as(n);
    for (int i=0; i<n; ++i) {
        i64 a;
        cin >> a;
        as[i] = a;
        if (as[i] == 0) {
            cout << 0 << endl;
            return 0;
        }
    }
    for (int i=0; i<n; ++i) {
        ans *= as[i];
        if (ans > UPPER) {
            cout << -1 <<endl;
            return 0;
        }
    }


    cout << ans<< endl;

    return 0;
}


Measured memory_bytes: 4052
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <stack>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <bitset>
using namespace std;
#define endl '\n'

const int inf = 1e9;

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int h,w;
    cin >> h >> w;
    vector<string> grid(h);
    for(int i = 0; i < h; ++i) {
        cin >> grid[i];
    }
    const vector<int> di = {-1,1,0,0};
    const vector<int> dj = {0,0,-1,1};

    int res = 0;
    for(int i = 0; i < h; ++i) {
        for(int j = 0; j < w; ++j) {
            if(grid[i][j] == '#') continue;
            queue<pair<int,int>> q;
            vector<vector<int>> d(h,vector<int>(w, inf));
            d[i][j] = 0;
            q.push({i,j});
            while(!q.empty()) {
                const int I = q.front().first;
                const int J = q.front().second;
                q.pop();
                res = max(res, d[I][J]);
                for(int k = 0; k < 4; ++k) {
                    const int toI = I + di[k];
                    const int toJ = J + dj[k];
                    if(toI < 0 || toI >= h || toJ < 0 || toJ >= w) continue;
                    if(grid[toI][toJ] == '#') continue;
                    if(d[toI][toJ] > 1 + d[I][J]) {
                        d[toI][toJ] = 1 + d[I][J];
                        q.push({toI,toJ});
                    }
                }
            }
        }
    }
    cout << res;
}


Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections;

class Program{
    public static void Main(){
        var input = Console.ReadLine().Split(' ').Select(m => int.Parse(m)).ToArray();
        if(input[0]+input[1]==input[2] || input[0]+input[2]==input[1] || input[1]+input[2]==input[0]){
            Console.WriteLine("Yes");
        }else{
            Console.WriteLine("No");
        }
    }
}


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

## Library

import sys
from fractions import gcd
import math
from math import ceil,floor
import collections
from collections import Counter
import itertools

## input

# n=int(input())
# A,B,C,D=map(int, input().split())
# string = input()
# yoko = list(map(int, input().split()))
# tate = [int(input()) for _ in range(N)]
# N, M = map(int,input().split()) 
#    P = [list(map(int,input().split())) for i in range(M)]

H = int(input())
count = 1
tmp = 2

while H > 1:
    count += tmp
    tmp = tmp * 2
    H = H//2

print(count)

Measured memory_bytes: 65260
#include <iostream>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <functional>
#include <iterator>
#include <bitset>
#include <string>
#include <list>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>

typedef   signed long long int slli;
typedef unsigned long long int ulli;
const slli MAX_SLLI = 0x7FFFFFFFFFFFFFFF;
const slli MIN_SLLI = 0x8000000000000000;
const ulli MAX_ULLI = 0xFFFFFFFFFFFFFFFF;
const ulli MIN_ULLI = 0x0000000000000000;

#define N_TIMES(i, n)     for (ulli i = 0;     i <  n; ++i)
#define N_TIMES_REV(i, n) for (slli i = n - 1; i >= 0; --i)

#ifdef __DEBUG__
template<typename T>
std::ostream& operator<<(std::ostream &os, const std::list<T> &list)
{
  const std::string delim = ", ";
  typename std::list<T>::const_iterator itr = list.begin();
  while (itr != list.end()) {
    os << *itr;
    ++itr;
    if(itr != list.end()) os << delim;
  }
  return os;
}

template<typename T>
std::ostream& operator<<(std::ostream &os, const std::vector<T> &v)
{
  const std::string delim = ", ";
  for (unsigned n = 0; n < v.size(); ++n) {
    os << v[n];
    if((n + 1) < v.size()) os << delim;
  }
  return os;
}
#endif /* __DEBUG__ */

int main(int argc, char **argv)
{
  long A, B, C, X, Y;
  std::cin >> A >> B >> C >> X >> Y;
  
  // ABを z (<= Z) 枚買う
  long Z = 2 * std::max(X, Y);
  long S = MAX_SLLI;
  for (long z = 0; z <= Z; ++z) {
    long x = std::max(static_cast<long>(0), X - (z / 2));
    long y = std::max(static_cast<long>(0), Y - (z / 2));
    
    long s = A * x + B * y + C * z;
    
    S = std::min(s, S);
  }
  std::cout << S << std::endl;
  
  return 0;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val (a,v) = readLine()!!.split(" ").map{it.toLong()}
	val (b,w) = readLine()!!.split(" ").map{it.toLong()}
	val t = readLine()!!.toLong()
  
  	if (a < b && (a + t*v == b + t*w || a + t*v > b + t*w)) {
    	println("YES")
    } else if (a > b && (a - t*v == b - t*w || a - t*v < b - t*w)) {
      	println("YES")
    } else {
      	println("NO")
    }
  	
}

Measured memory_bytes: 36328
n, m, c = gets.split.map(&:to_i)
bs = gets.split.map(&:to_i)

ans = n.times.map do
  true if (gets.split.map(&:to_i).zip(bs).map {|(a, b)| a * b }.inject(:+) + c) > 0
end.compact.size

puts ans


Measured memory_bytes: 1788
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#define rep(i,n)for(int i=0;i<n;i++)
using namespace std;
int fact(int n) {
	if (n == 0)return 1;
	return n * fact(n - 1);
}
int dp[114514];
signed main() {
	int a[12] = { 1,6,9,36,81,216,729,1296,6561,7776,46656,59049 };
	int n;
	cin >> n;
	for (int i = 0; i <= n; i++)dp[i] = 1e9;
	for (int i = 1; i <= n; i++) {
		for (int j = 0; j < 12; j++) {
			dp[0] = 0;
			if (i < a[j])continue;
			dp[i] =min(dp[i],dp[i - a[j]] + 1);
		}
	}
	cout << dp[n] << endl;
	getchar(); getchar(); return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define REP(i, n) for(int i=0; i<=n; i++)
#define repr(i, n) for(int i=n; i>0; i--)
#define REPR(i, n) for(int i=n; i>=0; i--)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define ALL(v) v.begin(),v.end()
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
template<class T> void puts(T x) { std::cout << x << std::endl; }
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 N, W, w[110], v[110];
ll dp[110][100010];

int main() {
    cin >> N >> W;
    rep(i, N) cin >> w[i] >> v[i];

    rep(i, N) {
        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]);
        }
    }

    ll ans = 0;
    for (int sum_w = 0; sum_w <= W; ++sum_w) {
        chmax(ans, dp[N][sum_w]);
    }
    cout << ans << endl;
}


Measured memory_bytes: 79360
#include<bits/stdc++.h>
using namespace std;
#define ll long long int 
int main()
{
     string s;
     cin>>s;
     ll l=s.length();
     ll ans=0;
     for(int i=0;i<l;i++)
     {
         ans+=s[i]-'0';
     }
     if(ans%9==0)
     {
         cout<<"Yes"<<endl;
     }
     else
     {
         cout<<"No"<<endl;
     }


    return 0;
}

Measured memory_bytes: 3728
n=int(input())
lists=list(map(int,input().split()))


if 0 in lists:
    ans=0
    for _ in lists:
        ans+=abs(_)
    print(ans)
        #ok
    
    
else:
    abslists=[]
    for j in lists:
        abslists.append(abs(j))
        
    ans=0
    count=0
    
    for inner in lists:
        if inner<0:
            count+=1
        
        else:
            continue
            
    if count%2==0:
        for _ in lists:
            ans+=abs(_)
        print(ans)
        
    else:
        for _ in lists: 
            ans+=abs(_)  
        min1=min(abslists)
        print(ans-2*min1)

Measured memory_bytes: 14468
#include<stdio.h>
int main(){
    int n;
    scanf("%d",&n);
    n=n%100;
    n=n%10;
    if(n==3){
        printf("bon\n");
    }else if(n==0 || n==1 || n== 6|| n==8){
        printf("pon\n");
    }else{
        printf("hon\n");
    }
    return 0;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
int DP[2 * 3333][2];
int main() {
	int N, T;
	scanf("%d%d", &N, &T);
	--T;
	for (int i = 1; i <= N; ++i) {
		int a, b;
		scanf("%d%d", &a, &b);
		for (int j = T; j >= 0; --j) {
			if (j + a <= T) {
				DP[j + a][0] = max(DP[j + a][0], DP[j][0] + b);
				DP[j + a][1] = max(DP[j + a][1], DP[j][1] + b);
			}
			DP[j][1] = max(DP[j][1], DP[j][0] + b);
		}
	}
	int r = 0;
	for (int i = 0; i <= 3333; ++i) r = max({r, DP[i][0], DP[i][1]});
	printf("%d\n", r);
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
int main() {
	int n, k, d,numofnusuke,count=0;
	cin >> n >> k;
	vector<bool> nusuke(n,false);
	for (int i = 0; i < k; i++) {
		cin >> d;
		for (int j = 0; j < d; j++) {
			cin >> numofnusuke;
			nusuke[numofnusuke-1] = true;
		}
	}
	for (int i = 0; i < n; i++) {
		if (nusuke[i] == false)
			count++;
	}
	cout << count;
}

Measured memory_bytes: 3584
#include <iostream>
#include <iomanip>
#include <algorithm>
using namespace std;
#include <cstdio>
#include <tuple>
#include <string>
#include <vector> 
#include <set>
#include <string.h>
#include <map>
#include <cmath>
using Graph = vector<vector<int>>;
using Graph_Wei = vector<vector<pair<int,int>>>;
using ll = long long;
const long long INF = 1LL<<60; // 仮想的な無限大の値
vector<bool> seen;

Graph G;

int main() {
    
    string s;
    cin >> s;

    int lastIndex;
    lastIndex = s.length()-1;

    int cnt = 0;
    for(int i = 0; i < s.length()/2 ;i++){

        if(s[i] != s[lastIndex - i]){
            cnt++;
        }
    }

    cout << cnt << endl;

    return 0;

}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.logging.Logger;

public class Main {

	public static void main(String[] args) {
		printAnswer();
	}

	private static void printAnswer() {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		try {
			int pointA =0;
			int pointB =0;
			int numOfCardsSet = Integer.valueOf(br.readLine());//??????????????§????????????????????????

			while(true){
				if(numOfCardsSet != 0){
					for(int i = 0; i < numOfCardsSet; i++){
						String[] cardsSet = br.readLine().split(" ");
						int cardA = Integer.valueOf(cardsSet[0]);
						int cardB = Integer.valueOf(cardsSet[1]);

						if(cardA > cardB){
							pointA += cardA + cardB;
						} else if(cardA < cardB){
							pointB += cardA + cardB;
						} else {
							pointA += cardA;
							pointB += cardB;
						}
					}
					System.out.println(pointA + " " + pointB);
					pointA = 0;
					pointB = 0;
					numOfCardsSet =  Integer.valueOf(br.readLine());
				}else {
					break;
				}
			}
		} catch (IOException e) {
			Logger.getGlobal();
			throw new RuntimeException(e);
		} finally {
			try {
				br.close();
			} catch (IOException e) {
				Logger.getGlobal();
			}
		}
	}


}

Measured memory_bytes: 34076
import java.io.BufferedInputStream;
import java.util.*;
import java.util.stream.Collectors;

public class Main {
    static final int MAX = 1_000_000_000;
    public static void main(String[] args) {
        //System.setIn(Main.class.getResourceAsStream("input"));
        Scanner sc = new Scanner(new BufferedInputStream(System.in));
        int n= sc.nextInt();
        sc.nextLine();
        String s = sc.next();
        String t = sc.next();
        String res = "";
        for (int i = 0; i < n; i++) {
            res += s.charAt(i) + "" + t.charAt(i);
        }
        System.out.println(res);
    }
    private static int nextInt(Scanner sc) {
        return Integer.valueOf(sc.nextLine());
    }
    private static int[] toArray(String text) {
        return Arrays.stream(text.split("")).mapToInt(Integer::valueOf).toArray();
    }

}

Measured memory_bytes: 23764
M, D = map(int, input().split())
d10 = D // 10
d1 = D % 10
count = 0
if D >= 22:
    for i in range(4,M+1):
        for j in range(2, d10):
            for k in range(2, 10):
                if i == j * k:
                    count += 1
        for j in range(2, d1+1):
            if i == j * d10:
                count += 1

print(count)

Measured memory_bytes: 3064