akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<math.h>
int main()
{
	int i,n,j;
	int a[100];
	a[0]=1;
	j=0;
	scanf("%d",&n);
	for(i=1;i<=n;i++)
	{
		a[i]=pow(2,i);
		if(a[i]>n)
		{
			j=a[i-1];
			break;
		}
	}
	printf("%d\n",j);
}

Measured memory_bytes: 128
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <string>
#include <cstring>
#include <complex>
#include <ctime>
#include <cstdlib>

using namespace std;

inline int to_int(string s) {int v; istringstream sin(s); sin >> v; return v;}
template<class T> inline string to_str(T x) {ostringstream sout; sout << x; return sout.str();}

typedef long long ll;

int main()
{
	float x1, y1, x2, y2, x3, y3, x4, y4;

	while(scanf("%f%f%f%f%f%f%f%f",&x1 ,&y1 ,&x2 ,&y2 ,&x3 ,&y3 ,&x4 ,&y4) != EOF)
	{	
		if(( y2 == y1 && x3 == x4 )||(x1 == x2 && y3 == y4))
		{
			cout << "YES" << endl;
		}
		else if((y2-y1)/(x2-x1) * (y3-y4)/(x3-x4) == -1.0)
		{
			cout << "YES" << endl;
		}
		else
		{
			cout << "NO" << endl;
		}
	}
}

Measured memory_bytes: 1224
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		if(a < b) {
			for(int i=0; i<b; i++) {
				System.out.print(a);
			}
			}else {
				for(int i=0; i<a; i++) {
					System.out.print(b);
				}
			}

	}

}


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

#include <fstream>
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstdlib>
#include <tuple>
#include <queue>
#include <functional>
#include <stack>
#include <numeric>
#include <cassert>
#include <sstream>

using namespace std;

class abc085_d {
public:
    void solve(istream& in, ostream& out) {
        int N, H;
        in >> N >> H;
        vector<int> b(N);
        int a = 0;
        for (int i = 0; i < N; ++i) {
            int tmp;
            in >> tmp >> b[i];
            a = max(a, tmp);
        }
        sort(b.begin(), b.end());
        reverse(b.begin(), b.end());
        int res = 0;
        for (int x : b) {
            if (H > 0 && x > a) {
                H -= x;
                ++res;
            }
        }
        if (H > 0)
            res += (H + a - 1) / a;
        out << res << "\n";
    }
};


int main() {
	std::ios::sync_with_stdio(false); cin.tie(nullptr);
	abc085_d solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	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 REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
using LL=long long;
const int INF = numeric_limits<int>::max();
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
int main()
{
    int N, K;
    cin >> N >> K;
    int res{ 1 };
    REP( i, N )
    {
        res = min( res * 2, res + K );
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys


def solve(n: int):
    sn = str(n)
    print(sn.translate({ord("1"): "9", ord("9"): "1"}))


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    n = int(next(tokens))  # type: int
    solve(n)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<utility>

#define lli long long
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(),i.rend()
#define rep0(i,j) for(int i=0;i<j;i++)
#define rep1(i,j) for(int i=1;i<=j;i++)
#define rep0d(i,j) for(int i=j-1;i>=0;i--)
#define MAX 1000000007

using namespace std;

bool cmps(const pair<lli, lli> left, const pair<lli, lli> right) {
	return left.second > right.second;
}
bool cmpf(const pair<lli, lli> left, const pair<lli, lli> right) {
	return left.first > right.first;
}
bool cmpfs(const pair<lli, lli> left, const pair<lli, lli> right) {
	if (left.first != right.first) {
		return left.first > right.first;
	}
	else return left.second > right.second;
}
bool cmpsf(const pair<lli, lli> left, const pair<lli, lli> right) {
	if (left.second != right.second) {
		return left.second > right.second;
	}
	else return left.first > right.first;
}


lli n, m, p[100000], y[100000];
int main() {
	cin >> n >> m;

	vector<vector<lli>> vec(100001);
	rep0(i, m)cin >> p[i] >> y[i], vec[p[i]].push_back(y[i]);
	rep1(i, n)sort(all(vec[i]));

	rep0(i, m)printf("%06lld%06lld\n", p[i], (lli)(lower_bound(all(vec[p[i]]), y[i]) - vec[p[i]].begin()) + 1);
}

Measured memory_bytes: 8576
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); i++)
#define int long long
#define double long double
#define P pair<long long,long long>
#define all(a) a.begin(),a.end()
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; }
using namespace std;

int n,m;
int dist[100010][3];
vector<int> g[100010];

const int inf=1000000000000;

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

    cin>>n>>m;
    rep(i,m){
        int u,v; cin>>u>>v; u--; v--;
        g[u].push_back(v);
    }

    int s,t; cin>>s>>t; s--; t--;
    memset(dist,-1,sizeof(dist)); dist[s][0]=0;
    queue<P> que; que.push(P(s,dist[s][0]));

    while(!que.empty()){
        P p=que.front(); que.pop();
        int v=p.first, mod3=(p.second+1)%3; 
        for(int i:g[v]){
            if(dist[i][mod3]==-1){
                dist[i][mod3]=dist[v][(mod3+2)%3]+1;
                que.push(P(i,mod3));
            }
        }
    }

    if(dist[t][0]>=0 and dist[t][0]%3==0)cout<<dist[t][0]/3<<endl;
    else cout<<-1<<endl;

}

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

int main() 
{
    int n , k , p[1000] , ans = 0;
    
    cin >> n >> k;
    for(int i=0 ;i<n ;i++ ){
        cin >> p[i];
    }
    
    sort(p , p+n);
    
    for(int i=0 ;i<k ;i++ ){
        ans += p[i];
    }
    
    cout << ans << endl;
    return (0);
}

Measured memory_bytes: 3640
#include "bits/stdc++.h"

using namespace std;

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

    int n, k;
    int a[100000];
    cin >> n >> k;
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    int mx = a[0];
    int gc = a[0];

    for(int i = 0; i < n; i++){
        gc = __gcd(gc, a[i]);
        mx = max(mx, a[i]); 
    }
    if(mx >= k && k % gc == 0)  cout << "POSSIBLE\n";
    else{
        cout << "IMPOSSIBLE\n";
    }
    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <set>
#include <iomanip>
#include <fstream>
#include <stdint.h>
#include <cmath>
#include <algorithm>
#include <array>
#include <utility>
#include <numeric>
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 FOR(i, l, r) for(int i = l; i < r; i++)
#define RFOR(i, l,r) for(int i= (l)-1; i>= (r) ; i--)

int H, W, N;

set<pair<int, int>> M;
set<pair<int, int>> serch;

void ser_insert(int y, int x)
{
    if(x >= 1 && y >= 1 && x < W -1 && y < H - 1)
        serch.insert({y, x});
}

int main()
{
    cin >> H >> W >> N;
    REP(i, N)
    {
        int a, b;
        cin >> a >> b;
        M.insert({a-1, b-1});
    }
    for(auto k : M)
    {
        for(int i = -1; i <= 1; i++)
            for(int j = -1; j <= 1; j++)
                ser_insert(k.first + i, k.second + j);
    }
    long long ans[10] = {};
    ans[0] = (H-2LL) * (W-2LL);

    for(auto k : serch)
    {
        int sum = 0;
        for(int i = -1; i < 2; i++)
            for(int j = -1; j < 2; j++)
                sum += M.count({k.first + i,k.second + j});
        ans[sum]++;
        ans[0]--;
    }
    REP(i, 10)
        cout << ans[i] << ' ';
    cout << '\n';
}


Measured memory_bytes: 47104
#include <bits/stdc++.h>
using namespace std;
 
int main() {

  string S;

  cin >>S;
  
  bool n=false,s=false,w=false,e=false;


  for(int i=0;i<S.size();i++){    
    if(S.at(i)=='N') n=true;
    if(S.at(i)=='S') s=true;
    if(S.at(i)=='W') w=true;
    if(S.at(i)=='E') e=true;
  }

  if(n==s&&w==e) cout << "Yes" << endl;

  else cout <<"No" << endl;  

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <vector>

using namespace std;

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

    for (int i = 0; i < s.size(); i++) {
        if (i % 2 == 0) {
            sum += s[i];
        }
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define len(v) ll(v.size())
#define fi first
#define se second

template <class T>
void cout_vec(const vector<T> &vec){
  for(auto itr:vec) cout<<itr<<' ';
  cout<<'\n';
}

typedef pair<ll,ll> P;
const ll mod=1e9+7;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int r;
    cin>>r;
    cout<<3*r*r<<endl;
}

Measured memory_bytes: 256
import sys
from collections import deque

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

in_n = lambda: int(readline())
in_nn = lambda: map(int, readline().split())
in_s = lambda: readline().rstrip().decode('utf-8')
in_nl = lambda: list(map(int, readline().split()))
in_nl2 = lambda H: [in_nl() for _ in range(H)]
in_map = lambda: [s == ord('.') for s in readline() if s != ord('\n')]
in_map2 = lambda H: [in_map() for _ in range(H)]
in_all = lambda: map(int, read().split())


def main():

    N = in_n()

    s = in_s()

    red = deque()
    white = deque()

    for i in range(N):
        if s[i] == 'R':
            red.append(i)
        else:
            white.append(i)

    if len(red) == 0:
        print(0)
        exit()
    if len(white) == 0:
        print(0)
        exit()

    cnt = 0
    while True:
        if len(red) == 0 or len(white) == 0:
            break
        if white[0] > red[-1]:
            break

        white.popleft()
        red.pop()
        cnt += 1

    print(cnt)


if __name__ == '__main__':
    main()


Measured memory_bytes: 70452
//{{{
#include<algorithm>
#include<cmath>
#include<deque>
#include<fstream>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<random>
#include<set>
#include<sstream>
#include<sys/time.h>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(printde) FUNC(printdbe) FUNC(printdwe) FUNC(printdu);
#endif
template <template <class T, class = std::allocator<T>> class V, class E>
istream& operator >> (istream& in, V<E>& v){ for(auto& e : v){ in >> e; } return in; }
//}}}

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    int n; cin >> n;
    vector<int> as(n); cin >> as;
    vector<int> bs(n); cin >> bs;
    map<int, vector<int>> mp;
    for(size_t i = 0; i < bs.size(); i++){
        auto& b = bs[i];
        if(b < as[i]){
            cout << -1 << '\n';
            return 0;
        }else if(b != as[i]){
            mp[- b].push_back(i);
        }
    }
    ll ans = 0;
    while(mp.size()){
        auto ite = mp.begin();
        int i = ite->second.back();
        ite->second.pop_back();
        if(ite->second.empty()){
            mp.erase(ite);
        }
        int b1 = bs[(i + 1) % n], b2 = bs[(i - 1 + n) % n];
        int sum = b1 + b2;
        // int cnt = (bs[i] - as[i]) / sum;
        int cnt = (bs[i] - max({as[i], b1, b2})) / sum;
        cnt = max(cnt, 1);
        bs[i] -= cnt * sum;
        ans += cnt;
        // bs[i] -= ;
        if(bs[i] < as[i]){
            cout << -1 << '\n';
            return 0;
        }else if(bs[i] != as[i]){
            mp[- bs[i]].push_back(i);
            // ite->second.pop_back();
        }
        // ans++;
        printde(bs);
        printde(mp);
    }
    cout << ans << '\n';
}


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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    ll N;
    ll ans;
    vector<ll> S, T;
    cin >> N;
    S.resize(N);
    rep(i, N) cin >> S[i];
    ans = accumulate(S.begin(), S.end(), 0);
    copy_if(S.begin(), S.end(), back_inserter(T), [](ll a) { return a % 10 != 0; });
    sort(T.begin(), T.end());
    if(!T.empty() && ans % 10 == 0) ans -= T.front();
    if(ans % 10 == 0) ans = 0;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <stdio.h>
#include <algorithm>
#include <string.h>
#include <string>
#include <cmath>
#include <complex>
#include <map>
using namespace std;

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

static const double PI=6*asin(0.5);
typedef complex<double> P;
typedef long long ll;

double xa,ya,ra,xb,yb,rb;
int n;

double dist(P a,P b){
	return sqrt(real(a-b)*real(a-b)+imag(a-b)*imag(a-b));
}

int main(){
	cin>>n;
	rep(i,n){
		cin>>xa>>ya>>ra>>xb>>yb>>rb;
		P a(xa,ya), b(xb,yb);
		double r=dist(a,b);
		double rr=ra-rb;
		if(rr<0) rr=-rr;
		if(ra+rb<r) cout<<0<<endl;
		else if(rr<=r&&r<=ra+rb) cout<<1<<endl;
		else if(ra<rb) cout<<-2<<endl;
		else cout<<2<<endl;
		
	}
	return 0;
}

Measured memory_bytes: 1232
#include <bits/stdc++.h>
using namespace std;
using ll=long long int;
using ld=long double;
using VI=vector<ll>;
using VD=vector<ld>;
using VVI=vector<VI>;
using VC=vector<char>;
using VVC=vector<VC>;
using VS=vector<string>;
using PLL =pair<ll,ll>;
using PLD=pair<ld,ld>;
using VPLL=vector<PLL>;
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element((x).begin(),(x).end())
#define MIN(x) *min_element((x).begin(),(x).end())
#define SORTR(x) sort((x).rbegin(),(x).rend())
#define SORT(x) sort((x).begin(),(x).end())
#define SUM(x) accumulate((x).begin(),(x).end(), 0)
#define FILL(x,a) fill(x.begin(),x.end(),a)
#define EACH(i,x) for(typeof((x).begin()) i=(x).begin(); i!=(x).end(); ++i)

const long long  int INF = 1e18;
const ld EPS   = 1e-10;
const int MOD  = int(1e9)+7;
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 (b<a) { a=b; return 1; } return 0; }
template <class BidirectionalIterator>
bool next_partial_permutation(BidirectionalIterator first, BidirectionalIterator middle,BidirectionalIterator last){reverse(middle, last); return next_permutation(first , last);}
#define COUT(x) cout<<x<<"\n"
class UnionFind{
public:
	vector<int> par;	// par[i]:iの親の番号 (例) par[3] = 2 : 3の親が2
	vector<int> rank;	//ランク
	vector<ll> diff_weight;

	UnionFind(int N=1,int SUM_UNITY=0){
		par.resize(N),	rank.resize(N),	diff_weight.resize(N);
		for (int i = 0; i < N; ++i) par[i] = i,rank[i]=0,diff_weight[i]=SUM_UNITY;
	}
	int root(int x){// データxが属する木の根を再帰で得る：root(x) = {xの木の根}
		if(par[x]==x)return x;
		else{
			int r=root(par[x]);
			diff_weight[x]+=diff_weight[par[x]];	//累積和を取る
			return par[x]=r;
		}
	};

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

	// weight(ry)-weight(rx)=wとなるようにmergeする
	bool merge(int x,int y,int w){
		w+=weight(x);		//rootとの重み差分を補正
		w-=weight(y);
		int rx = root(x); 	//xの根をrx
		int ry = root(y); 	//yの根をry
		if (rx == ry) return false; //xとyの根が同じ(=同じ木にある)時はそのまま
		if(rank[rx]<rank[ry])	swap(rx, ry),w=-w;// rank[rx] >= rank[ry] となるように rx と ry を swap (それに合わせて w も符号反転します)
		if (rank[rx] == rank[ry]) ++rank[rx];// y (のroot) を x (のroot) の下にくっつける
		par[ry] = rx; 		//xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
		diff_weight[ry]=w;	// x が y の親になるので、x と y の差分を diff_weight[y] に記録
		return true;
	}
	ll weight(int x){
		root(x);	//経路圧縮
		return diff_weight[x];
	}
	int diff(int x,int y){
		return weight(y)-weight(x);
	}
};

void Main()
{
	ll N,M;
	ll result=0;
	string S;
	cin>>N>>M;
	VI p(N);
	REP(i,N) cin>>p[i];
	ll l,r,d;
	UnionFind uni(N);
	REP(i, M)
	{
		cin >> l>>r;
		l--,r--;
		uni.merge(l,r,0);
	}
	REP(i,N){
		if(uni.issame(i,p[i]-1)) result++;
	}
	COUT(result);
	return;
}


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


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define REP(i,n) for (ll i = 0; i < (n); ++i)

int main(){
    string s;
    getline(cin, s);
    for(char c : s){
        if(c >= 'a' && c <= 'z'){
            cout << (char)(c - 'a' + 'A');
        }else if(c >= 'A' && c <= 'Z'){
            cout << (char)(c - 'A' + 'a');
        }else{
            cout << c;
        }
    }
    cout << endl;
    return 0;
}



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

int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  int n, k;
  int r, s, p;
  cin >> n >> k >> r >> s >> p;
  vector<char> a(n), t(n);
  vector<char> te = {'r', 's', 'p'};
  rep(i,n) { 
    char c;
    cin >> c;
    t[i] = c;
    if (c == 'r') a[i] = 'p';
    else if (c == 's') a[i] = 'r';
    else a[i] = 's';
  }
  rep(i,n-k) {
    if (a[i] == a[i+k]) {
      if (i+k+k < n) {
        rep(j,3) {
          if (a[i] != te[j] && a[i+k+k] != te[j]) a[i+k] = te[j];
        }
      }
      else {
        rep(j,3) {
          if (a[i] != te[j]) a[i+k] = te[j];
        }
      }
    }
  }
  ll ans = 0;
  rep(i,n) {
    if (a[i] == 'r' && t[i] == 's') ans += r;
    else if (a[i] == 's' && t[i] == 'p') ans += s;
    else if (a[i] == 'p'  && t[i] == 'r') ans += p;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 896
using System;

class Program
{
    static void Main()
    {
            int a, b;
            string inp = Console.ReadLine();
            string[] data = inp.Split(' ');
            a = int.Parse(data[0]);
            b = int.Parse(data[1]);
            if (a >= -1000 && b <= 1000)
            {
                if (a == b)
                {
                    Console.WriteLine("a == b");
                }
                else if (a < b)
                {
                    Console.WriteLine("a < b");
                }
                else if (a > b)
                {
                    Console.WriteLine("a > b");
                }

            }
    }
}


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

using namespace std;
const long long mod = 1e9 + 7;

int n, k, a[610], b[610], pd[610];
long long cnt[610][610], dp[610][610], g[2000], ans;

int main() {
    scanf("%d%d", &n, &k);
    for(int i = 1; i <= k; ++i) {
        scanf("%d%d", &a[i], &b[i]);
        pd[a[i]] = b[i];
        pd[b[i]] = a[i];
    }
    n <<= 1;
    g[0] = 1;
    for(int i = 2; i <= n; i += 2) g[i] = (g[i - 2] * (i - 1)) % mod;
    for(int i = 1; i <= n; ++i) {
        for (int j = i; j <= n; ++j) cnt[i][j] = cnt[i][j - 1] + (!pd[j]);
    }
    for(int i = 1; i <= n; ++i) {
        for(int j = i; j <= n; ++j) {
            int ji = 0;
            for(int k = i; k <= j; ++k) {
                if (pd[k] && (pd[k] > j || pd[k] < i))
                    ji = 1;
            }
            if(ji == 1)
                continue;
            dp[i][j] = g[cnt[i][j]];
            for(int k = i + 1; k <= j - 1; ++k)
                dp[i][j] = (dp[i][j] - 1ll * dp[i][k] * g[cnt[k + 1][j]] % mod + mod) % mod;
        }
    }
    for(int i = 1; i <= n; ++i) {
        for(int j = i; j <= n; ++j) ans = (ans + dp[i][j] * g[(n / 2 - k) * 2 - cnt[i][j]] % mod) % mod;
    }
    printf("%lld\n", ans);
    return 0;
}



Measured memory_bytes: 6016
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define MIN(a,b) ((a) <= (b) ? (a) : (b))
#define ALL(v) (v).begin(), (v).end()
#define SORT(v) sort( ALL(v) )

using namespace std;
using ll = long long;
using P = pair<int,int>;
int main()
{
    set<int> st;
    int a,b,c; cin>>a>>b>>c;
    st.insert(a);
    st.insert(b);
    st.insert(c);

    if(st.size()==2)
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }

    return 0;
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i < (int)(n); i++)
typedef long long ll;

int main() {
    int n; cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    int cnt = 1;
    int j = 0;
    rep(i,n){
        if(a[j] == 2) break;
        j = a[j] - 1;
        cnt++;
    }
    if(cnt == n+1) cout << -1 << endl;
    else cout << cnt << endl;
}

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

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2
    vector<int> rank;

    UnionFind(int N) : par(N), rank(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++){
            par[i] = i;
            rank[i] = 0;
        }
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x){
            return x;
        }else{
            return par[x] = root(par[x]);
        }
    }

    void unite(int x, int y) { // xとyの木を併合
        x = root(x); //xの根をrx
        y = root(y); //yの根をry
        if (x == y) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        if (rank[x] < rank[y]){
            par[x] = y; 
        }else{
            par[y] = x; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
        }
        if(rank[x] == rank[y]) rank[x]++;
    }

    bool same(int x, int y){ // 2つのデータx, yが属する木が同じならtrueを返す
        return root(x) == root(y);
    }
};


int main(){
    // int MAX = 403;
    int h, w;
    cin >> h >> w;
    
    char m[h*w];
    rep(i, h*w){
        cin >> m[i];
    }

    UnionFind uf(h*w);
    
    rep(i,h*w){
        if(i%w != 0 && m[i]!=m[i-1]){
            uf.unite(i-1, i);
        }
        if(i>=w && m[i]!=m[i-w]){
            uf.unite(i-w, i);
        }
    }

    int c[h*w] = {0};
    int s[h*w] = {0};
    rep(i,h*w){
        if(m[i]=='.'){
            c[uf.root(i)]++;
        }else{
            s[uf.root(i)]++;
        }
    }

    ll sum = 0;
    rep(i,h*w){
        sum += (ll)c[i] * (ll)s[i];
    }
    cout << sum << endl;
}

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

int main()
{
  string s1, s2, s3;
  cin >> s1 >> s2 >> s3;
  
  char dif = 'A' - 'a';
  char S1 = s1.at(0) + dif;
  char S2 = s2.at(0) + dif;
  char S3 = s3.at(0) + dif;
  
  cout << S1 << S2 << S3 << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
    int a,b;
    char op;
    while(1){
        scanf("%d %c %d", &a,&op,&b);
        if(op=='+'){
            printf("%d\n",a+b);
        }
        else if(op=='-'){
            printf("%d\n",a-b);
        }
        else if(op=='*'){
            printf("%d\n",a*b);
        }
        else if(op=='/'){
            printf("%d\n",a/b);
        }
        else if(op=='?'){
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 2008
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<map>
using namespace std;
int main() {
  int n,k,a[100000]={},M=0,G;
  cin >> n >> k;
  for(int i=0; i<n; i++) {
    cin >>a[i];
    M=max(M,a[i]);
    if(i==0) {
      G=a[0];
    }
    else {
      G=__gcd(G,a[i]);
    }
  }
  if(k%G==0&&k<=M) {
    cout << "POSSIBLE" << endl;
  }
  else {
    cout << "IMPOSSIBLE" << endl;
  }
}

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

#define M 100

int main(){
  int n,p[M + 1],m[M + 1][M + 1];

  cin >> n;
  for(int i = 1;i <= n;i++){
    cin >> p[i - 1] >> p[i];
  }

  for(int i = 1;i <= n;i++) m[i][i] = 0;
  for(int l = 2;l <= n;l++){
    for(int i = 1;i <= n - l + 1;i++){
      int j = i + l - 1;
      m[i][j] = (1 << 21);
      for(int k = i;k <= j - 1;k++){
        m[i][j] = min(m[i][j],m[i][k] + m[k + 1][j] + p[i - 1] * p[k] * p[j]);
      }
    }
  }

cout << m[1][n] << endl;

return 0;
}



Measured memory_bytes: 3148
// --------------------<optimizations>--------------------
#pragma GCC optimize("O3")
//(UNCOMMENT WHEN HAVING LOTS OF RECURSIONS)\
#pragma comment(linker, "/stack:200000000")
//(UNCOMMENT WHEN TRYING TO BRUTEFORCE WITH A LOT OF LOOPS)\
#pragma GCC optimize("unroll-loops")

#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")

#include<bits/stdc++.h>

using namespace std;

#define int long long
#define ll long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define pii pair<ll,ll>
#define vpii vector<pair<ll,ll> >
#define F first
#define S second
#define ld long double
#define built __builtin_popcountll
#define mst(a,i) memset(a,i,sizeof(a))
#define all(x) x.begin(),x.end()
#define itit(it,a) for(auto it=(a).begin(); it!=(a).end(); it++)
#define rep(i,a,b) for(ll i=a; i<b; i++)
#define repr(i,a,b) for(ll i=a; i>b; i--)
#define reprr(i,a,b) for(ll i=a; i>=b; i--)
#define pi 3.14159265358979323846264338327950288419716939937510582097494459230
ll max3(ll x,ll y,ll z) {return max(max(x,y),z);}
ll min3(ll x,ll y,ll z) {return min(min(x,y),z);}
const ll N=1e4+5,M=105,M2=1e6+10,mod=1e9+7,inf=1e17+10;
const int INF=1e9+7;
void add(int& a, int b) {a+=b;if(a>=mod){a-=mod;}}

#define trace(...) cerr<<"Line:"<<__LINE__<<" "; __f(#__VA_ARGS__, __VA_ARGS__)
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...);
}

int X[] = {0, 1, 0, -1};
int Y[] = {-1, 0, 1, 0};
//assic value of ('0'-'9') is(48 - 57) and (a-z) is (97-122) and (A-Z) is(65-90) and 32 for space
ll power(ll x,ll n){ll result=1;while(n>0){if(n%2==1)result=(result*x)%mod; x=((x%mod)*(x%mod))%mod;n=n/2;}return result;}

string n;
int d;

int x[N];
int sz;
int cache[N][M][2];

int dp(int idx, int rem, int less){
    if(idx==sz+1){
        return (rem==0);
    }
    int &ans=cache[idx][rem][less];
    if(ans!=-1) return ans;
    ans=0;
    if(!less){
        for(int i=0; i<=x[idx]; i++) ans+=dp(idx+1,(rem+i)%d,less|(i<x[idx]));
    }
    else{
        for(int i=0; i<=9; i++) ans+=dp(idx+1,(rem+i)%d,1);
    }
    ans%=mod;
    return ans;
}

int f(string &s){
    sz=s.size();
    for(int i=0; i<sz; i++){
        x[i+1]=s[i]-'0';
    }
    mst(cache,-1);
    return dp(1,0,0);
}

int32_t main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin >> n;
    cin >> d;
    int ans=f(n);
    ans-=1;
    ans+=mod;
    ans%=mod;
    cout << ans;
    return 0;
}

Measured memory_bytes: 17792
// D - Banned K
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vl = vector<ll>;
#define rep(i,n) for(int i=0;i<(n);++i)

int main(){
	int N; cin>>N;
	vl A(N), C(N);
	rep(i, N){cin>>A[i]; A[i]--;}//値補正

	rep(i, N) C[A[i]]++;//値の種類毎の計数

	ll all = 0;//組み合わせの総計
	rep(a, N){
		ll c = C[a];
		if(c>=2) all += c*(c-1)/2;//組み合わせ
	}

	vl ans(N, 0);
	rep(k, N){
		int c = C[A[k]];// ak の値の個数
		ll del = c>=2? c*(c-1)/2: 0;// ak の値の組み合わせ
		c--;// 1 個減
		ll add = c>=2? c*(c-1)/2: 0;// ak の値の組み合わせ
		ans[k] = all - del + add;
	}

	rep(i, N) cout<< ans[i] <<endl;
}

Measured memory_bytes: 7296
#include <iostream>
#include <vector>
#include <algorithm>
#include <climits>
#include <string>
#include <unordered_map>
using namespace std;


int main() {

    long N;
    cin >> N;

    long sum = 0;

    for(int i = 1; i <= N; i++){
        if(i%3 == 0) {
            continue;
        }
        if(i%5 == 0) {
            continue;
        }
        sum += i;
    }

    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include <sstream>
#include <string>
#include <stack>
#include <cstdlib>
using namespace std;

int main() {
  int t;
  double a, b;
  const char *op[4] = {"+", "-", "*", "/"};
  stack<double> s;
  string buf, buf2;

  cout.setf(ios::fixed);
  while (getline(cin, buf)) {
    istringstream istr(buf);
    while (istr >> buf2) {
      for (t=0; t<4; t++) {
        if (buf2 == op[t]) break;
      }
      if (t == 4) {
        s.push(atof(buf2.c_str()));
      } else {
        b = s.top(); s.pop();
        a = s.top(); s.pop();
        if (t == 0) s.push(a+b);
        else if (t == 1) s.push(a-b);
        else if (t == 2) s.push(a*b);
        else s.push(a/b);
      }
    }
    a = s.top(); s.pop();
    cout.precision(6);
    cout << a << endl;
  }

  return 0;
}

Measured memory_bytes: 1288
#include <iostream>
using namespace std;
//ITP2の9番台はPythonで実装したら負けだという気がしたのでc++で書きます。

int main(void){
  int n,m;
  cin>>n;
  long A[n];
  for(int i=0;i<n;i++){
    cin>>A[i];
  }
  cin>>m;
  long B[m];
  for(int i=0;i<m;i++){
    cin>>B[i];
  }
  int i=0;
  int j=0;
  while(i<n and j<m){

    if(A[i]<B[j]){
      cout<<A[i]<<endl;
      i++;
    }
    else if(A[i]>B[j]){
      cout<<B[j]<<endl;
      j++;
    }
    else{
      cout<<A[i]<<endl;
      i++;
      j++;
    }

  }
  for(int k=i;k<n;k++){
    cout<<A[k]<<endl;
  }
  for(int k=j;k<m;k++){
    cout<<B[k]<<endl;
  }

  return 0;
}



Measured memory_bytes: 6160
#include <iostream>
#include <vector>
#include <algorithm>
#include <ctime>
#include <cmath>
#include <string>
#include <stdlib.h>
#include <fstream>
#include <set>
#include <map>
#include <stack>
#include <deque>
#include <iterator>
#include <iomanip>
#include <queue>
using namespace std;


int main(){
    long long a, b, c;
    cin >> a >> b >> c;
    cout << c << " " << a << " " << b;
}


Measured memory_bytes: 888
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <tuple>
#include <cmath>
#include <cstdio>
#include <cassert>
#include <functional>
#define _LIBCPP_DEBUG 0
using namespace std;

int main(void){
    int x;
    cin >> x;
    for (int i = x;; i++)
    {   
        int j;
        for (j = 2; j <= x; j++)
        {
            if (i%j==0)
            {   
                if (i==j)
                {
                    j=x+1;
                }
                break;
            }
        }
        if (j==x+1)
        {
            cout << i << endl;
            return 0;
        }
        
        
    }
}


Measured memory_bytes: 3644
#include <stdio.h>

int main(void)
{
	int i;
	int n;
	int a[100];

	scanf("%d", &n);

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

	for(i = 0; i < n; i++)
	{
		if(i == n-1)
		{
			printf("%d", a[0]);
			printf("\n");
		}else
		{
			printf("%d", a[n-i-1]);
			printf(" ");
		}
	}

	return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
const int MX = 200005;



int main() {
  string s;
  cin>>s;
  int a = 0;
  ll ans = 0;
  rep(i,sz(s)) {
    if (s[i] == 'B') {
      ++a;
    } else {
      ans += a;
    }
  }
  cout<<ans<<endl;
  return 0;
}






















Measured memory_bytes: 640
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int an[] = new int[a+1];
		long ans=1;
		int c=0;
		int d = (int)Math.pow(10, 9)+7;
		for(int i=0;i<a+1;i++){
			an[i]=1;
		}
		for(int i=2;i<=a;i++){
			c=i;
			while(c%2 == 0){
				c/=2;
				an[2]++;
			}
			for(int n=3;n*n<=c;n+=2){
				while(c%n==0){
				c /= n;
				an[n]++;
				}
			}
			if(c>1){
				an[c]++;
			}
		}
		for(int i=0;i<an.length;i++){
			ans = (long)ans*an[i]%d;
		}
		System.out.println(ans);
 }
}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int mod=998244353;

int n,ans;
int a[200005];

struct node
{
	int x,y,z;
};

map<int,int> m;

inline bool ge(int x,int y,int z)
{
	if (x+y<=z)  return false;
	else return true;
}

signed main()
{
	cin>>n;
	for (int i=1;i<=n;i++)  cin>>a[i];
	sort(a+1,a+n+1);
	
	for (int i=1;i<=n-2;i++)
	{
		for (int j=i+1;j<=n-1;j++)
		{
			for (int k=j+1;k<=n;k++)
			{
				if (a[i]!=a[j]&&a[i]!=a[k]&&a[j]!=a[k]&&ge(a[i],a[j],a[k]))  ans++;
			}
		}
	}
	cout<<ans<<endl;
	
	return 0;
}

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, M;
  cin >> N >> M;
  vector<vector<int>> G(N);
  for (int i = 0; i < M; i++) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    G[a].emplace_back(b);
    G[b].emplace_back(a);
  }
  function<bool(int, int)> f = [&](int u, int c) {
    if (c == 2) return false;
    bool res = false;
    for (int v : G[u]) {
      if (v == N - 1) {
        cout << "POSSIBLE" << '\n';
        exit(0);
      }
      f(v, c + 1);
    }
    return false;
  };

  if (f(0, 0)) {
    cout << "POSSIBLE" << '\n';
  } else {
    cout << "IMPOSSIBLE" << '\n';
  }
  return 0;
}


Measured memory_bytes: 12016
N=int(input())
for h in range(1,3501):
    for n in range(1,3501):
        if 4*h*n-(h+n)*N>0:
            if (h*n*N)%(4*h*n-(h+n)*N)==0 and (h*n*N)//(4*h*n-(h+n)*N)>=1:
                print(h,n,(h*n*N)//(4*h*n-(h+n)*N))
                exit()


Measured memory_bytes: 40684
#include <iostream>

using namespace std;

int main(){
	
	cin.tie(0); ios_base::sync_with_stdio(0);
	char c[] = {'R','G','B'};
	int n;
	string en;
	cin>>n>>en;
	int s[n][3];
	for(int i=0;i<n;i++){
		if(i)for(int j=0;j<3;j++)s[i][j]=s[i-1][j];
		else for(int j=0;j<3;j++)s[i][j]=0;
		int j =0;
		while(c[j]!=en[i])j++;
		s[i][j]++;
	}
	long long res =0;
	for(int i=n-1;i>=2;i--)for(int j=i-1;j>=1;j--)if(en[i]!=en[j]){
		int d = i-j;
		int k =0;
		while(c[k]==en[i]||c[k]==en[j])k++;
		long long can=s[j-1][k];
		if(j-d>=0&&en[j-d]==c[k])can--;
		res+=can;
	}
	cout<<res<<endl;
	
	return 0;
}

Measured memory_bytes: 3204
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>

typedef long long ll;

int max(int a, int b){
  if(a > b) return a;
  else return b;
}
int min(int a, int b){
  if(a < b) return a;
  else return b;
}

int sort(const void *a ,const void *b){
  return *(int*)a - *(int*)b;
}

int f(int a){
  int count = 0;
  int flag = 0;
  for(int i = 1; i <= pow(a,0.5); ++i){
    if(a % i == 0) count ++;
    if(i*i == a)flag = 1;
  }
  count *= 2;
  if(flag == 1) --count;
  return count;
}


int main(){

  int n;
  scanf("%d",&n);

  for(int i = 1; i < 10 ; ++i){
    if((n % i == 0) && (n / i < 10)){
      printf("Yes");
      return 0;
    }
  }
  printf("No");

  return 0;
}


Measured memory_bytes: 2152
S=input()

while(1):
    length = len(S)
    if length==0:
        break
    if S[length-5:length]=="dream":
        S = S[:length-5]
    elif S[length-5:length]=="erase":
        S = S[:length-5]
    elif S[length-6:length]=="eraser":
        S = S[:length-6]
    elif S[length-7:length]=="dreamer":
        S = S[:length-7]
    else:
        print("NO")
        exit(0)
print("YES")

Measured memory_bytes: 3316
#include<bits/stdc++.h>
using namespace std;
vector<int> arrN;
vector<int> arrW;
vector<vector<long long>> dp;
long long knapSackAt(int n,int w){
    if(dp[n][w]!=-1){
        return dp[n][w];
    }
    if(n==0){
        if(arrN[0]<=w){
            dp[n][w] = arrW[0];
            return dp[n][w];
        }else {
            dp[n][w] = 0;
            return dp[n][w];
        }

    }if(arrN[n]<=w){
        dp[n][w] = max(knapSackAt(n-1,w),(arrW[n]+knapSackAt(n-1,w-arrN[n])));
        return dp[n][w];
    }else{
        dp[n][w] = knapSackAt(n-1,w);
        return dp[n][w];
    }
}

long long knapBottomUp(int n,int w){
    long long maxval =0;
    for(int i =0;i<=w;i++){
        if(arrN[i]<=w){
            dp[0][i] = arrW[0];
            maxval = arrW[0];
        }else dp[0][i] = 0;
    }
    for(int i=1;i<n;i++){
        for(int j=0;j<=w;j++){
            if(arrN[i]<=j){
                dp[i][j] = max(arrW[i]+dp[i-1][w-j],dp[i-1][j]);
            }else dp[i][j] = dp[i-1][j];
            if(maxval<dp[i][j])maxval = dp[i][j];
        }
    }
    return maxval;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,w;
    cin >> n >> w;
    arrN = vector<int>(n);
    arrW = vector<int>(n);
    for(int i =0;i<n;i++){
        cin >> arrN[i] >> arrW[i];
    }   
    dp = vector<vector<long long>>(n,vector<long long>(w+1,-1));

    cout << knapSackAt(n-1,w) << "\n";
    // cout << knapBottomUp(n,w) << "\n";
    return 0;
}

Measured memory_bytes: 82240
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define rep2(i,s,n) for (int i = s; i < n; ++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define tmax(a,b,c) max(a,max(b,c))
#define tmin(a,b,c) min(a,min(b,c))
#define pb push_back
#define eb emplace_back
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vs vector<string>
#define vc vector<char>
#define vb vector<bool>
#define vp vector<P>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using LP = pair<ll,ll>;
template<class T> istream& operator>>(istream& is,vector<T>& v) { for(T& t:v){is>>t;} return is; }
template<class T> ostream& operator<<(ostream& os,const vector<T>& v) { for(T t:v){os<<t<<" ";} os<<"\n"; return os; }
void Yes(bool b) { cout << (b ? "Yes" : "No") << endl; }
void YES(bool b) { cout << (b ? "YES" : "NO") << endl; }
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;}
const int inf = 1001001001;
const ll linf = 1001001001001001001;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);
    string s;
    cin >> s;
    if(s == "ABC") cout << "ARC" << endl;
    else cout << "ABC" << endl;
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
#define all(v) (v).begin(),(v).end()
using namespace std;
using LL = long long;
const int INF = 1e9;
const int MOD = 1000000007;

int main(void)
{
    LL N;
    LL A;
    cin >> N;
    LL c1 = 0, c2 = 0, c3 = 0;
    LL X = 1;
    for (LL i = 0; i < N; i++) {
        LL v = 0;
        cin >> A;
        v = (v + (c1==A) + (c2==A) + (c3==A)) % MOD;
        X = (X*v) % MOD;
        if (c1 == A) {
            c1++;
        } else if (c2 == A) {
            c2++;
        } else {
            c3++;
        }
    }
    cout << X << endl;
    return 0;
}



Measured memory_bytes: 384
import fractions

a = list(map(int,input().split()))
A = a[0]
B = a[1]
C = a[2]
D = a[3]
CD = C*D//fractions.gcd(C, D)

#Aまでの個数
AC = (A-1)//C
AD = (A-1)//D
ACD = (A-1)//CD

#Bまでの個数
BC = B//C
BD = B//D
BCD = B//CD

ans = (B-A+1) - ((BC-AC)+(BD-AD)-(BCD-ACD)) 

print(ans)

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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef long long ll;

const int MOD = 1000000007;

const int MAXN = 1005;
const int MAXV = MAXN * (MAXN - 1) / 2;

vector<int> to[MAXV];
int id[MAXN][MAXN];

int toId(int i, int j) {
    if (i > j) swap(i, j);
    return id[i][j];
}

bool visited[MAXV];
bool calculated[MAXV];
int dp[MAXV]; // max length of path from v

// グラフの最長経路を求める
int dfs(int v) {
    if (visited[v]) {
        if (!calculated[v]) return -1;  // ループ検出の場合
        return dp[v];
    }
    visited[v] = true;
    dp[v] = 1;
    for (int u : to[v]) {
        int res = dfs(u);
        if (res == -1) return -1;
        dp[v] = max(dp[v], res + 1);
    }
    calculated[v] = true;
    return dp[v];
}

int main() {
    int N;
    cin >> N;
    vector<vector<int>> a(N, vector<int>(N - 1));
    rep(i, N) {
        rep(j, N - 1) {
            cin >> a[i][j];
            a[i][j]--;
        }
    }

    int V = 0;
    rep(i, N) {
        rep(j, N) {
            if (i < j) {
                id[i][j] = V++; // 試合(i,j)の頂点番号をセット
            }
        }
    }

    rep(i, N) {
        rep(j, N - 1) {
            a[i][j] = toId(i, a[i][j]); // 試合(i,j) => 頂点番号V
        }

        rep(j, N - 2) {
            to[a[i][j + 1]].push_back(a[i][j]); // 頂点の向きを逆向きでセット
        }
    }

    int ans = 0;
    rep(i, V) {
        int res = dfs(i);
        if (res == -1) {
            puts("-1");
            return 0;
        }
        ans = max(ans, res);
    }
    cout << ans << endl;
}


Measured memory_bytes: 38528
#include <stdio.h>
int main(){
  int a=0,b=0,c=0;
  scanf("%d %d",&a,&b);
  if(a<=0 || a>=10 || b<=0 || b>=10){
    printf("-1");
    return 0;
  }
  else{
    c=a*b;
    printf("%d",c);
    return 0;
  }
}

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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) std::cout << x << '\n'
#define all(a) a.begin(), a.end()
#define pb push_back
#define sz(x) ((int)(x).size())
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { ll g = gcd(a, b); return a / g * b; }
const int dx[4] = { 1, 0, -1,  0 };
const int dy[4] = { 0, 1,  0, -1 };
const int INF = (int)1e9;
const ll  inf = (ll)1e18;
const int mod = 1000000007;
const int MAX_N = 100010;

bool comp(P a, P b) {
	return a.second > b.second;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(10);
	/*------------------------------*/

	int n, m;
	cin >> n >> m;
	
	vl a(n);
	rep(i, n) cin >> a[i];
	sort(all(a));

	vector<P> bc(m);
	rep(i, m) {
		cin >> bc[i].first >> bc[i].second;
	}
	sort(bc.begin(), bc.end(), comp);

	ll sum = 0;
	ll k = 0;
	for (int i = 0; i < m; i++) {
		for (int j = 0; j < bc[i].first; j++) {
			if (k >= n) break;
			sum += max(a[k++], bc[i].second);
		}
	}

	for (int i = k; i < n; i++) sum += a[i];

	out(sum);

	return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
#define endl "\n"
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
#define traceV(v) for(auto x:v)cout<<x<<" ";cout<<endl
#define traceM(mp) for(auto x:mp)cout<<x.first<<" "<<x.second<<endl

//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
const ll INF = 2e+9 + 10;
typedef pair<ll, ll> P;

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

  int A,B,C,D,E,F;
  cin>>A>>B>>C>>D>>E>>F;

  int res1, res2;
  double maxv = 0;
  rep(i,100) rep(j,100) rep(k,100) rep(l,100) {
    int water = 100*A*i+100*B*j;
    int sugar = C*k+D*l;
    if(water+sugar<=F && sugar<=water/100*E){
      double val = 100.0*sugar/(water+sugar);   // ここをint計算しててハマった．
      if(val >= maxv) {                         // ここの等号を入れてなくてハマった．＞だと，濃度０が最大の時にres1,res2に値が格納されない．
        res1 = water+sugar; res2 = sugar;
        maxv = val;
      }
    }
  }
  cout << res1 << " " << res2 << endl;

  return 0;
}


Measured memory_bytes: 256