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

public class Main {

    Scanner sc = new Scanner(System.in);

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

    void run() {

        int n = sc.nextInt();
        char[] arr = sc.next().toCharArray();

        long ans = 0;

        int[] cntR = new int[n];
        int[] cntG = new int[n];
        int[] cntB = new int[n];

        int tmpR = 0;
        int tmpG = 0;
        int tmpB = 0;

        for (int i=0; i<n; i++) {
            if (arr[i]=='R') {
                cntR[i] = ++tmpR;
                cntB[i] = tmpB;
                cntG[i] = tmpG;
            } else if (arr[i]=='G') {
                cntG[i] = ++tmpG;
                cntB[i] = tmpB;
                cntR[i] = tmpR;
            } else {
                cntB[i] = ++tmpB;
                cntR[i] = tmpR;
                cntG[i] = tmpG;
            }
        }


        for (int i=0; i<n-2; i++) {
            inner:
            for (int j=i+1; j<n-1; j++) {
                char first = arr[i];
                char second = arr[j];
                if (first==second) continue inner;
//                char[] rgb = {'R', 'G', 'B'};
                int cR = 0;
                int cG = 0;
                int cB = 0;
                if (first=='R') cR++;
                if (first=='G') cG++;
                if (first=='B') cB++;
                if (second=='R') cR++;
                if (second=='G') cG++;
                if (second=='B') cB++;
                char third = 'X';
                if (cR==0) third = 'R';
                if (cG==0) third = 'G';
                if (cB==0) third = 'B';

                if (j+(j-i)>=n) {
                    if (third=='R') {
                        ans += cntR[n-1]-cntR[j];
                    } else if (third=='G') {
                        ans += cntG[n-1]-cntG[j];
                    } else {
                        ans += cntB[n-1]-cntB[j];
                    }
                } else {
                    if (third=='R') {
                        if (arr[j+(j-i)]=='R') ans += (cntR[n-1]-cntR[j]-1);
                        else ans += (cntR[n-1]-cntR[j]);
                    } else if (third=='G') {
                        if (arr[j+(j-i)]=='G') ans += (cntG[n-1]-cntG[j]-1);
                        else ans += (cntG[n-1]-cntG[j]);
                    } else {
                        if (arr[j+(j-i)]=='B') ans += (cntB[n-1]-cntB[j]-1);
                        else ans += (cntB[n-1]-cntB[j]);
                    }

                }
//                System.out.print(ans);
            }
        }

        System.out.println(ans);

    }

}


Measured memory_bytes: 36692
#include<bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
const long double PI = acos(-1);
typedef long long int ll;
typedef unsigned long long ull;
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define fo(i,n) for(int i=0;i<(int)n;i++)
#define fo1(i,n) for(int i=1;i<=(int)n;i++)
#define deb(x) cout<<#x<<"="<<x<<endl

void solve(int tc)
{
    int x, y, d, c = 0;
    cin >> x >> y >> d;
    for(; x <= y; x++) if(x % d == 0)c++;
    cout << c << endl;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int tc = 1;
    fo1(t, tc)
    {
        solve(t);
    }
    return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <vector>
std::vector<std::string> day = {"SUN","MON","TUE","WED","THU","FRI","SAT"};

int main(int argc, char** argv) {
  std::string s;
  std::cin >> s;
  for (auto i = 0;i < day.size();++i) {
    if (s==day[i]) {
      std::cout << (7-i) << '\n';
      break;
    }
  }
}


Measured memory_bytes: 256
# coding:utf-8

a,b,c,x,y = map(int, input().split())
price = [] 

for i in range(1000000):
    p = 2 * c * i
    if i < x:
        p += a * (x - int(i))
    if i < y:
        p += b * (y - int(i))
    
    price.append(p)

print(min(price))
    

"""
if (a>c):
    p += c*x*2
    flag = 1

else:
    p += a*x
    flag = 0

if (b>c) :
    if (flag==1):
        p+= (y-int(x/2)) * c
    else:
        p+= c*y*2
else:
    if (flag==1):
        p+= (y-int(x/2)) * c
    else:
        p+= b*y

print(p)

"""





Measured memory_bytes: 42708
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <cstring>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<long long, long long> P;
#define rep(i, n) for(long long i=0; i<n; i++)
#define reps(i, s, e) for(long long i=s; i<e; i++)
#define repr(i, n) for(long long i=n-1; i>=0; i--)
#define reprs(i, s, e) for(long long i=e-1; i>=s; i--)

ll const MOD = 1000000007;


int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    ll n; cin >> n;
    ll a[n];
    rep(i, n){
        cin >> a[i];
    }

    ll ans = 1;
    map<ll, ll> mpcnt;
    ll cnt0 = 0;

    rep(i, n){
        if(a[i] == 0){
            ans = (ans * (3 - cnt0)) % MOD;
            mpcnt[0]++;
            cnt0++;
        }
        else{
            ans = (ans * (mpcnt[a[i]-1])) % MOD;
            mpcnt[a[i]-1]--;
            mpcnt[a[i]]++;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 7296
//AOJ V28_2800 Mod!Mod!
//Author:Mikoron

#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int main(void) {

        int det_num, det_count = 0, sum = 0;
        int count_zero = 0, count_one = 0, count_two = 0;
        int i;
        char *tp, uma_rod[500000*2];

        scanf("%d\n", &det_num);
        if(det_num < 0 || det_num > 500000) return 1;

        fgets(uma_rod, sizeof(uma_rod),stdin);
        tp = strtok(uma_rod, " ");
        i = 0;
        while(tp) {
                uma_rod[i] = atoi(tp);
                if(uma_rod[i] < 1 || uma_rod[i] > 9) return 1;
                tp = strtok(NULL, " ");
                i++;
        }

        //mod 3 の結果でケースを分ける
        for(i = 0; i < det_num; i++) {
                switch(uma_rod[i]%3) {
                        case 0:
                                count_zero++;
                                break;
                        case 1:
                                count_one++;
                                break;
                        case 2:
                                count_two++;
                                break;
                        default:
                                return 1;
                }
        }

        //printf("case0:%d, case1:%d, case2:%d\n", count_zero, count_one, count_two);

        //各ケースから数を取り出し足し合わせて,盗める人数を計算
        while(1) {

                //printf("det_num=%d:sum=%d:count_zero=%d:count_one=%d:count_two=%d\n", det_num, sum, count_zero, count_one, count_two);

                //1回目にケース0しかない場合はその時点で終了
                if(det_count == 0 && count_one == 0 && count_two == 0) {
                        det_count++;
                        break;
                }

                //合計が3の倍数にならないように、かつ、個数の多いケースから足し合わせていく
                if((count_one >= count_two || count_two <= 0 || (sum+2)%3 == 0) && (sum+1)%3 != 0 && count_one > 0) {
                        count_one--;
                        det_count++;
                        sum++;
                }else if((sum+2)%3 != 0 && count_two > 0) {
                        count_two--;
                        det_count++;
                        sum += 2;
                }else if(count_zero > 0) {
                        count_zero--;
                        det_count++;
                }else{
                        if(count_one > 0 || count_two > 0) det_count++;
                        break;
                }
        }

        printf("%d\n", det_count);

        return 0;
}



Measured memory_bytes: 2844
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cmath>
#include <utility>

#define ll (long lon
#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 RFOR(i,a,b) for(int i = (a);i>(b);i--)

using namespace std;

int main (void){
    
    int tate,bnumber;
    int bridge[31][2] = {0};
    int answer[31] = {0};
    bool roopjudge = true;
    int temp = 0;
    int tempnumber = 0;
    int i,j,k,l;
    
    cin >> tate >> bnumber;
    for(i = 0;i< bnumber;i++)
        scanf("%d%*c%d",&bridge[i][0],&bridge[i][1]);
    /*
    REP(i, bnumber)
    cout << bridge[i][0] << ","<< bridge[i][1] << endl;
    */
    
    for(i = 1; i<=tate; i++)
    {
        temp = i;
        for(k = 0; k<bnumber;k++)
        {
            if(temp == bridge[k][0])
                temp = bridge[k][1];
            else if(temp == bridge[k][1])
                temp = bridge[k][0];
        }
        answer[temp] = i;
    }
    
    REP(i,tate)
    cout << answer[i+1] << endl;
    return 0;
    
}

Measured memory_bytes: 1240
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using static System.Math;
using static System.Array;
using static AtCoderSolve.Tool;

namespace AtCoderSolve
{
    class Solve
    {
        const int mod = 1000000007;
        const int INF = int.MaxValue / 2;
        const long SINF = long.MaxValue / 2;


        static void Main(string[] args)
        {
            //var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            //Console.SetOut(sw);
            var cin = new Scanner();

            int N = int.Parse(Console.ReadLine());
            string s = Console.ReadLine();
            int K = int.Parse(Console.ReadLine());

            var ans = new StringBuilder();
            for(var i = 0; i < s.Length; i++)
            {
                ans.Append(s[i] != s[K - 1] ? '*' : s[i]);
            }

            Console.WriteLine(ans);

            //Console.Out.Flush();
        }
        

    }

    public class Scanner
    {
        public int[] SplitReader()
        {
            int[] array = Console.ReadLine().Split().Select(int.Parse).ToArray();
            return array;
        }
        public long[] SplitReaderL()
        {
            long[] array = Console.ReadLine().Split().Select(long.Parse).ToArray();
            return array;
        }
    }

    public static class Tool
    {
        static public void Initialize<T>(ref T[] array, T initialvalue)
        {
            for(var i = 0; i < array.Length; i++)
            {
                array[i] = initialvalue;
            }
        }
        static public long ModuloP(long value,long mod)
        {
            long r = value % mod;
            
            if (r * mod < 0)
            {
                r += mod;
            }
            return r;
        }

    }

    struct Pair<T> : IComparable<Pair<T>> where T : IComparable<T>
    {
        public T variable;
        public int index;

        public Pair(T val, int i)
        {
            variable = val;
            index = i;
        }

        public int CompareTo(Pair<T> otherPair)
        {
            return variable.CompareTo(otherPair.variable);
        }

        public int CompareIndex(Pair<T> otherPair)
        {
            return index.CompareTo(otherPair.index);
        }
    }


}






Measured memory_bytes: 13140
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll dp[110][100100]; 

void chmin( ll &a, ll b){
  if( a > b){ a = b;} return;}
const ll inf = 1LL << 60;
int main(){ ll max_v = 0;
  for(ll i = 0; i < 110; i++){for(ll j = 0; j < 100100; j++){ dp[i][j] = inf;}}
  
  ll N,W; cin >> N >> W;
  
  vector<ll> w(N); vector<ll> v(N);
  
  for(ll i = 0; i < N; i++){ cin >> w[i] >> v[i]; max_v += v[i];}
  
  dp[0][v[0]] = w[0]; dp[0][0] = 0;
  
  for(ll i = 0; i < N - 1; i++){
    for(ll j = 0; j < 100100; j++){
      
      chmin(dp[i+1][j], dp[i][j]);
      if( j-v[i+1] >= 0){
      chmin(dp[i+1][j], dp[i][j-v[i+1]] + w[i+1]);}
    }
  }
  ll res = 0;
  for(ll i = 0; i <= max_v; i++){
    if(dp[N-1][i] <= W){ res = i;}
  }
  
  cout << res << endl; return 0;}
      

Measured memory_bytes: 86272
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int>pint;
typedef vector<int>vint;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);i++)
template<class T,class U>void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>void chmax(T &t,U f){if(t<f)t=f;}

int N;
vint vec;

bool check(vint &v){
    rep(i,v.size())if(v[i]!=i+1)return false;
    return true;
}

void solve(){
    vec.resize(N);
    rep(i,N)cin>>vec[i];

    if(check(vec)){
        cout<<0<<endl;
        return;
    }

    rep(i,10000){
        vint nxt;
        rep(i,vec.size()){
            if(vec[i]>1)nxt.pb(vec[i]-1);
        }
        nxt.pb(vec.size());
        vec=nxt;
        if(check(vec)){
            cout<<i+1<<endl;
            return;
        }
    }

    cout<<-1<<endl;
}
int main(){
    while(scanf("%d",&N),N)solve();
    return 0;
}

Measured memory_bytes: 1296
// cout << "Case #" << test << ": ";
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
typedef long long ll;
#define MOD 1000000007
using namespace std;
int main() {
    int n;
    cin >> n;
    ll sum = 0;
    for(int i = 1; i <= n; i++) {
        if(i % 3 != 0 && i % 5 != 0) {
            sum += i;
        }
    }
    cout << sum << endl;
}


Measured memory_bytes: 3636
#include <iostream>
#include <algorithm>

#define MAXN 200000
typedef long long ll;

using namespace std;

int A[MAXN];

int main()
{
  int N,K;
  ll sum = 0;
  int pos, cnt;
  int kcnt = 0;

  cin >> N >> K;

  for ( int i = 0; i < N; ++i ) {
    int tmp;
    scanf("%d", &tmp);
    --tmp;
    ++A[tmp];
  }

  for ( int i = 0; i < N; ++i ) if ( A[i] > 0 ) ++kcnt;
  sort( A, A+N );

  pos = cnt = 0;
  while ( cnt < kcnt-K ) {
    if ( A[pos] > 0 ) {
      sum += A[pos];
      ++cnt;
    }
    ++pos;
  }

  //for ( int i = 0; i < N; ++i ) cout << A[i] << " ";
  //cout << "\n";
  cout << sum << "\n";
}


Measured memory_bytes: 1024
#include "bits/stdc++.h"
#define REP(i, m, n) for(long long i = m; i < n; ++i)
#define CO(n) cout << n << endl
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

int N, W;
int v[10000],w[10000];
int dp[101][10001];
//dp[i+1][j] i番目の品物までを使い，重さj以下の条件下で最大の価値

int main()
{
    ios::sync_with_stdio(false);
    cin >> N >> W;
    REP(i,0,N) cin >> v[i] >> w[i];
    REP(j,0,W+1) dp[0][j] = 0;
    REP(i,0,N){
        REP(j,0,W+1){
            if (j>=w[i]) dp[i+1][j] = max(dp[i][j], dp[i][j-w[i]]+v[i]);
            else dp[i+1][j] = dp[i][j];
        }
    }
    CO(dp[N][W]);
    return 0;
}


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

#define ll long long
#define ull unsigned long long 
int main(){
    int n;
    cin >> n;
    set<int> s;
    int gm = 0;
    for(int i=0; i<n; ++i){
        int x;
        cin >> x;

        if(x < 3200)
            s.insert(x/400);
        else
            gm++;
    }

    if(gm == n)
        cout << 1 << " " << gm;
    else
        cout << s.size() << " " << s.size()+gm;

}

Measured memory_bytes: 3532
#include<iostream>
#include<cstdlib>
#include<cmath>
#include<string>
#include<algorithm>
using namespace std;

#define ll long long
#define int ll

int ans;
int n, m;
int k, x[50];
int a;

signed main()
{
	cin >> n >> m;
	for (int i = 1; i <= n; i++) {
		cin >> k;
		for (int j = 1; j <= k; j++) {
			cin >> a;
			x[a]++;
		}
	}

	for (int i = 1; i <= 30; i++) {
		if (x[i] == n) {
			ans++;
		}
	}
	cout << ans << endl;

	//system("pause");
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<cmath>
#define pb push_back
#define ld long double
#define mp make_pair
#define vl vector<ll> 
#define vd vector<double>
#define vld vector<long double>
#define ll long long int
#define pl pair<ll, ll>
#define all(a) a.begin(), a.end()
#define forr(i, n) for(ll i=0; i<n; i++) 
#define forr1(i, n) for(ll i=1; i<=n; i++)
using namespace std;
const ld PI =3.1415926535897923846;
const ll MOD = 1000000007;
const ll N=998244353;
ll power(ll x,ll n){ll res=1;while(n>0){if(n&1) res=res*x%MOD;x=x*x%MOD;n>>=1;}return res;}
ll modinverse(ll a){return power(a, MOD-2);}
ll r, c;
vector<vl> mat1, mat2;
void solve()
{
    cin>>r>>c;
    mat1.resize(r, vl(c, 0));
    mat2.resize(r, vl(c, 0));
    forr(i, r)
    {
    	forr(j, c)
    	{
    		cin>>mat1[i][j];
    	}
    }
    forr(i, r)
    {
    	forr(j, c)
    	{
    		cin>>mat2[i][j];
    	}
    }
    vector<vector<vector<bool>>> dp(r, vector<vector<bool>>(c, vector<bool>(160 * 80 + 1, false)));
    dp[0][0][(ll)abs(mat1[0][0]-mat2[0][0])]=true;
    for(ll i=0; i<r; i++)
    {
    	for(ll j=0; j<c; j++)
    	{
    		for(ll k=0; k<=160*80+1; k++)
    		{
    			if(i)
    			{
    				if(abs(k+abs(-mat1[i][j]+mat2[i][j]))<=160 * 80 + 1)
    					dp[i][j][k]=dp[i][j][k]|dp[i-1][j][abs(k+abs(-mat1[i][j]+mat2[i][j]))];
    				if(abs(k-abs(-mat1[i][j]+mat2[i][j]))<=160 * 80 + 1)
    					dp[i][j][k]=dp[i][j][k]|dp[i-1][j][abs(k-abs(-mat1[i][j]+mat2[i][j]))];
    			}
    			if(j)
    			{
    				if(abs(k+abs(-mat1[i][j]+mat2[i][j]))<=160 * 80 + 1)
    					dp[i][j][k]=dp[i][j][k]|dp[i][j-1][abs(k+abs(-mat1[i][j]+mat2[i][j]))];
    				if(abs(k-abs(-mat1[i][j]+mat2[i][j]))<=160 * 80 + 1)
    					dp[i][j][k]=dp[i][j][k]|dp[i][j-1][abs(k-abs(-mat1[i][j]+mat2[i][j]))];
    			}
    		}
    	}
    }
    forr(i, 160 * 80 + 1)
    {
    	if(dp[r-1][c-1][i])
    	{
    		cout<<i<<endl;
    		return;
    	}
    }
}
int main()
{
	#ifndef ONLINE_JUDGE
        // for getting input from input.txt
        freopen("input.txt", "r", stdin);
        // for writing output to output.txt
        freopen("output.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll test=1;
    //cin>>test;
    while(test--)
    {
        solve();
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}

Measured memory_bytes: 14020
import qualified Data.ByteString.Char8 as BS
import Data.Maybe

main :: IO ()
main = do
  ah <- BS.unpack <$> BS.getLine :: IO String
  bh <- BS.unpack <$> BS.getLine :: IO String
  ch <- BS.unpack <$> BS.getLine :: IO String
  let table = (P A ah, P B bh, P C ch)
  putStr $ game table A

type Hands = String 
type Card = Char
data Name = A | B | C deriving Show
data Player = P Name Hands deriving Show
type Table = (Player, Player, Player)

class Play p where
  nextCard :: p -> Maybe Card
  nextHands :: p -> Hands

instance Play Player where
  nextCard (P _ "") = Nothing
  nextCard (P _ (x:_)) = Just x
  nextHands (P _ "") = ""
  nextHands (P _ (_:xs)) = xs
  
showNext :: Maybe Char -> Name
showNext (Just 'a') = A
showNext (Just 'b') = B
showNext (Just 'c') = C

game :: Table -> Name -> String
game (a,b,c) A 
  | isNothing (nextCard a) = "A"
  | otherwise = game (P A hands, b, c) (showNext card)
    where card = nextCard a
          hands = nextHands a
game (a,b,c) B
  | isNothing (nextCard b) = "B"
  | otherwise = game (a, P B hands, c) (showNext card)
    where card = nextCard b
          hands = nextHands b
game (a,b,c) C
  | isNothing (nextCard c) = "C"
  | otherwise = game (a, b, P C hands) (showNext card)
    where card = nextCard c
          hands = nextHands c

Measured memory_bytes: 508
H, W, A, B = map(int, input().split())
ret = [[0] * W for _ in range(H)]
for h in range(H):
    for w in range(W):
        if w < A and h < B:
            ret[h][w] = 1
        elif w >= A and h >= B:
            ret[h][w] = 1

for row in ret:
    print(''.join([str(i) for i in row]))


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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    string S;
    cin >> S;
    int N = S.size();

    vector<int> R_tmp(N);
    vector<int> L_tmp(N);
    vector<int> Count(N);

    for (int n = 0; n < N; n++) {
        Count[n] = 0;
    }

    int rec_zero = N - 1;
    for (int n = N - 1; n >= 0; n--) {
        if (S[n] == 'R') {
            R_tmp[n] = R_tmp[n + 1] + 1;
            if (R_tmp[n] % 2 == 0) {
                Count[rec_zero]++;
            } else {
                Count[rec_zero - 1]++;
            }
        } else {
            R_tmp[n] = 0;
            rec_zero = n;
        }
    }

    rec_zero = 0;
    for (int n = 0; n < N; n++) {
        if (S[n] == 'L') {
            L_tmp[n] = L_tmp[n - 1] + 1;
            if (L_tmp[n] % 2 == 0) {
                Count[rec_zero]++;
            } else {
                Count[rec_zero + 1]++;
            }
        } else {
            L_tmp[n] = 0;
            rec_zero = n;
        }
    }

    for (int n = 0; n < N; n++) {
        cout << Count[n] << " ";
    }

    return 0;
}


Measured memory_bytes: 1872
h, w = map(int, input().split())
c = [list(input()) for i in range(h)]

ac = [[0] * (w) for i in range(2*h)]
for i in range(2*h):
    for j in range(w):
        ac[i][j] = c[i//2][j]

for s in ac:
    print(*s, sep='')

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

#ifdef NON_SUBMIT
#define TEST(n) (n)
#define tout cerr
#else
#define TEST(n) ((void)0)
#define tout cin
#endif

using namespace std;

int D[200000];
pair<int,int> R[100000];
vector<int> x, P[200000];

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	TEST(freopen("input.txt","r",stdin));
	TEST(freopen("output.txt","w",stdout));
	TEST(freopen("debug.txt","w",stderr));
	int N;
	cin>>N;
	for(int i=0;i<N;i++) {
		cin>>R[i].first>>R[i].second;
		R[i]={R[i].first-R[i].second,R[i].first+R[i].second};
		x.push_back(R[i].first);
		x.push_back(R[i].second);
	}
	sort(x.begin(),x.end());
	x.resize(unique(x.begin(),x.end())-x.begin());
	for(int i=0;i<N;i++) {
		R[i].first=lower_bound(x.begin(),x.end(),R[i].first)-x.begin();
		R[i].second=lower_bound(x.begin(),x.end(),R[i].second)-x.begin();
		P[R[i].first].push_back(R[i].second);
	}
	for(auto n: P[0]) D[n]=1;
	for(int i=1;i<200000;i++) {
		D[i]=max(D[i],D[i-1]);
		for(auto n: P[i]) D[n]=max(D[n],D[i]+1);
	}
	cout<<D[199999]<<'\n';
	return 0;
}

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

using namespace std;


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

    long long n, k;
    cin >> n >> k;
    long long res_0 = 0;
    long long res_half = 0;
    for (long long i = 1; i <= n; ++i) {
        res_0 += (i % k == 0);
        res_half += (i % k == (k * 1.0 / 2) );
    }

        long long result = pow(res_0, 3) + pow(res_half, 3);
    cout <<  result << '\n';

    return 0;
}


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

int main (){
    int n,flg;
    flg = 1;
    cin >> n;
    vector<int> a(n);

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

    for (int j = 0; j < n; j++){
        if(a[j] % 2 == 0){
            if(a[j] % 3 != 0 && a[j] % 5 != 0)
                flg = 0;
        }
    } 

    if(flg)
    cout << "APPROVED" << endl;
    else
    cout << "DENIED" << endl;
    return 0;

}

Measured memory_bytes: 256
using System;

namespace A___Five_Antennas
{
    class Program
    {
        static void Main(string[] args)
        {
            var array = new int[5];
            for (var i = 0; i < 5; i++)
            {
                array[i] = int.Parse(Console.ReadLine());
            }
            var k = int.Parse(Console.ReadLine());
            for (var i = 0; i < 4; i++)
            {
                for (var j = 1; j < 5; j++)
                {
                    if (array[j] - array[i] > k)
                    {
                        Console.WriteLine(":(");
                        return;
                    }
                }
            }
            Console.WriteLine("Yay!");
        }
    }
}

Measured memory_bytes: 13140
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>

typedef long long ll;
ll H, W;

template <typename T> void print(T a) {std::cout << a << std::endl;}
template <typename T> void print(std::string s, T a) {std::cout << s << " " << a << std::endl;}
template<typename Iterator> void print(Iterator begin, Iterator end)
{
  for (Iterator it = begin; it != end; it++) {
    std::cout << "[" << std::distance(begin, it) << "] "<< *it << " ";
    if (std::distance(begin, it) % 50 == 49) { std::cout << std::endl; }
  }
  std::cout << std::endl;
}

int main()
{
  ll N;
  std::cin >> H >> W >> N;

  std::vector< ll > va(N, 0LL);
  for (ll i = 0; i < N; i++) {
    std::cin >> va[i];
  }

  std::vector< std::vector< ll > > vv(H, std::vector< ll >(W, 0));

  ll cnt = 0;
  for (ll y = 0; y < H; y++) {
    if (y % 2 == 0) {
      for (ll x = 0; x < W; x++) {
	while (va[cnt] == 0) {
	  cnt++;
	}
	vv[y][x] = cnt + 1;
	va[cnt]--;
      }
    } else {
      for (ll x = W-1; x >= 0; x--) {
	while (va[cnt] == 0) {
	  cnt++;
	}
	vv[y][x] = cnt + 1;
	va[cnt]--;
      }
    }
  }

  for (ll y = 0; y < H; y++) {
    for (ll x = 0; x < W; x++) {
      std::cout << vv[y][x] << " ";
    }
    std::cout << std::endl;
  }

  return 0;
}


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

int main(){
    double ans=0.0;
    ll n,k;
    cin >> n >> k;
    vector<double> vec(n);
    vector<double> vec2(n);
    double bai=1.0;
    ll kaisu=0;
    for(double i=n;i>=1;i--){
        while(i*bai<k*1.0){
            bai*=2.0;
            kaisu++;
        }
        vec[i-1]=bai;
    }
    
    for(ll i=0;i<n;i++){
        ans+=1.0/vec[i];
    }
    
    printf("%.10f\n",ans/(n*1.0));

    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using int64 = int64_t;
#define int int64
// 赤と青の数は決め打ちできる
// e.g.)
// 5
// a + 2b = 5(k)
// a + b <= 4(sm)
// = 3
// (a,b) = (1,2)
// (1,0,2) 4C1*3C1
// (0,1,1) 4C1*3C1
// = 4
// (a,b) = (3,1)
// (3,0,1) 4C1
// (2,1,0) 4C1*3C1

int MOD = 998244353;
constexpr int MAX_N = 303030;

int fact[MAX_N];
int ifact[MAX_N];
 
int power(int x, int n) {
	int res = 1LL;
	while (n > 0) {
		if (n & 1) (res *= x) %= MOD;
		(x *= x) %= MOD;
		n >>= 1;
	}
	return res % MOD;
}
 
int inv(int x) {
	return power(x, MOD - 2);
}
 
int nCr(int n, int r) {
	if (n < 0 || r < 0 || r > n) return 0;
	if (r > n / 2) r = n - r;
	return fact[n] * ifact[r] % MOD * ifact[n - r] % MOD;
}

signed main(){
  int n,a,b,k;cin>>n>>a>>b>>k;
	fact[0] = ifact[0] = 1;
	for(int i=1;i<MAX_N;++i) {
		(fact[i] = fact[i - 1] * i) %= MOD;
		ifact[i] = inv(fact[i]);
	}

  int ans = 0;
  for(int aa=0;aa<=n;++aa){
    int bb = (k-aa*a)/b;
    if((k-aa*a)%b!=0) continue;
    if(!(aa>=0&&bb>=0)) continue;

    int res = nCr(n,aa) % MOD;
    (res *= nCr(n,bb)) %= MOD;
    // cerr << res << endl;
    (ans += res) %= MOD;
  }
   
  cout<<ans<<endl;
  
  return 0;
}

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

using namespace std;

template<typename T>
ostream& operator<<(ostream& os, vector<T> v) {
  os << "[";
  for (T &i: v) os << i << ",";
  os << "]";
  return os;
}

template<class TH> void _dbg(const char *sdbg, TH h){ cout<<sdbg<<'='<<h<<endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')cout<<*sdbg++;
  cout<<'='<<h<<','; _dbg(sdbg+1, a...);
}

#ifdef __DJKIM613
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug(...) (__VA_ARGS__)
#endif

int N;
int A[110];
vector<int> ans;
void process(){
  for(int i = 1 ; i <= N ; i++){
    if(A[i] == 0) continue;
    int pos = i;
    while(pos > 1 && A[pos - 1] == 0) {
      A[pos - 1] = A[pos];
      A[pos] = 0;
      pos--;
    }
  }
}
int main(void){
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr), cout.tie(nullptr);

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

  for(int i = 1 ; i<= N ; i++){
    int ck = 0;
    for(int j = N - i + 1 ; j >= 1 ; j--) {
      if(A[j] == j) {
        ck = 1;
        debug(A[j]);
        ans.push_back(A[j]), A[j] = 0;
        break;
      }
    }
    process();
    if(!ck) return cout << -1 << '\n', 0;
  }

  reverse(ans.begin(), ans.end());
  for(int val : ans) cout << val << '\n';
  cout <<'\n';
  return 0;
}

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

int main() {
  int a, b;
  cin >> a >> b;
  if (a > b) {
    cout << 2 * a - 1 << endl;
  }
  else if (a < b) {
    cout << 2 * b - 1 << endl;
  }
  else {
    cout << 2 * a << endl;
  }
}


Measured memory_bytes: 256
S=input()
if S=="SSS":
  print(0)
elif S=="RSS":
  print(1)
elif S=="RRS":
  print(2)
elif S=="RRR":
  print(3)
elif S=="SRS":
  print(1)
elif S=="SRR":
  print(2)
elif S=="RSR":
  print(1)
elif S=="SSR":
  print(1)


Measured memory_bytes: 60608
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

void main() {
    auto nk = readints;
    int n = nk[0], k = nk[1];
    writeln(n - k + 1);
}


Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include<math.h>
#include<iomanip>
#include<functional>
using namespace std;

#define ll long long
using vt = ll; //ここで数値の型を変えられる
#define rep(i, n) for (vt i = 0; i < (vt)(n); i++)
#define reps(i, s, n) for(vt i = (vt) (s); i < (vt) (n); i++) 
#define all(v) v.begin(), v.end()
#define P pair<int, int>
const ll  MOD = 1000000007;

int main() {
	ll n, m = 0;
	cin >> n;
	vector<ll> a(n), b(n + 1, 0);
	rep(i, n) cin >> a.at(i);
	for (ll i = n - 1; i >= 0; i--) {
		ll s = 0, k = 1;
		while ((i + 1) * k <= n) {
			s += b.at((i + 1) * k);
			k++;
		}
		if (s % 2 != a.at(i)) {
			b.at(i + 1)++;
			m++;
		}
	}
	cout << m << endl;
	rep(i, n + 1) {
		if (b.at(i) == 1) {
			cout << i << " ";
		}
	}
	return 0;
}

Measured memory_bytes: 3968
import java.io.*;
import java.util.*;

public class Main {
	String diff = "CODEFESTIVAL2016";
	public void solve() {
		String str = next();
		int cnt = 0;
		for(int i = 0; i < str.length(); i++){
			if(str.charAt(i) != diff.charAt(i)){
				cnt++;
			}
		}
		out.println(cnt);
	}

	private static PrintWriter out;

	public static void main(String[] args) {
		out = new PrintWriter(System.out);
		new Main().solve();
		out.flush();
	}

	public static int nextInt() {
		int num = 0;
		String str = next();
		boolean minus = false;
		int i = 0;
		if(str.charAt(0) == '-'){
			minus = true;
			i++;
		}
		int len = str.length();
		for(; i < len; i++){
			char c = str.charAt(i);
			if(!('0' <= c && c <= '9')) throw new RuntimeException();
			num = num * 10 + (c - '0');
		}
		return minus ? -num : num;
	}

	public static long nextLong() {
		long num = 0;
		String str = next();
		boolean minus = false;
		int i = 0;
		if(str.charAt(0) == '-'){
			minus = true;
			i++;
		}
		int len = str.length();
		for(; i < len; i++){
			char c = str.charAt(i);
			if(!('0' <= c && c <= '9')) throw new RuntimeException();
			num = num * 10l + (c - '0');
		}
		return minus ? -num : num;
	}

	public static String next() {
		int c;
		while(!isAlNum(c = read())){}
		StringBuilder build = new StringBuilder();
		build.append((char)c);
		while(isAlNum(c = read())){
			build.append((char)c);
		}
		return build.toString();
	}

	private static byte[] inputBuffer = new byte[1024];
	private static int bufferLength = 0;
	private static int bufferIndex = 0;

	private static int read() {
		if(bufferLength < 0) throw new RuntimeException();
		if(bufferIndex >= bufferLength){
			try{
				bufferLength = System.in.read(inputBuffer);
				bufferIndex = 0;
			}catch(IOException e){
				throw new RuntimeException(e);
			}
			if(bufferLength <= 0) return(bufferLength = -1);
		}
		return inputBuffer[bufferIndex++];
	}

	private static boolean isAlNum(int c) {
		return '!' <= c && c <= '~';
	}
}


Measured memory_bytes: 8148
import numpy as np
def main():
    A, B, H, M = map(int, input().split())
    omega_m = 1.0/60.0
    omega_h = 1.0/12.0
    a = (H + M/60.0) * omega_h
    b = (60.0*H + M) * omega_m
    theta = (a - b) * 360.0
    c = np.sqrt(A**2 + B**2 - 2.0*A*B*np.cos(theta/180.0*np.pi))
    print(c)
if __name__ == '__main__':
    main()

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

using namespace std;

#define ll long long
#define ull unsigned long long
#define vll vector<ll>
#define pii pair<int, int>
#define vii vector<pii>
#define vs vector<string>
#define vb vector<bool>
#define vi vector<int>
#define vd vector<double>
#define vvi vector< vector<int> >
#define vvii vector< vector< pii > >
#define ld long double
#define mapii map<int, int>
#define mapsi map<string, int>
#define erep(i, x, n) for (auto i = x; i<=(ll)(n); i++)
#define rep(i, x, n) for(auto i = x; i<(ll)(n); i++)
#define INF  LLONG_MAX
#define all(v) ((v).begin()), ((v).end())
#define sz(v) ((int)((v).size()))
#define pie  acos(-1)
#define mod(n,m) ((n % m + m) % m)
#define eps (1e-8)
#define reset(n, m) memset(n, m, sizeof n)
#define endl '\n'
#define output freopen("output.txt", "w", stdout)
#define mp(x, y, z) {{x, y}, z}

ll f[100002], modulo = 1000000007;

ll pow(ll a, ll b, ll MOD)
{
    ll x=1,y=a;
    while(b > 0)
    {
        if(b%2 == 1)
        {
            x=(x*y);
            if(x>MOD) x%=MOD;
        }
        y = (y*y);
        if(y>MOD) y%=MOD;
        b /= 2;
    }
    return x;
}

ll InverseEuler(ll n, ll MOD)
{
    return pow(n,MOD-2,MOD);
}

ll C(ll n, ll r, ll MOD)
{

    return (f[n]*((InverseEuler(f[r], MOD) * InverseEuler(f[n-r], MOD)) % MOD)) % MOD;
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    f[0] = f[1] = 1;
    erep(i, 2, 100001)
    {
        f[i] = f[i-1]*i;
        f[i] %= modulo;
    }
    int n;
    cin >> n;
    vi temp(n+1, -1);
    vi vec(n+1);
    int d = 0;
    erep(i, 0, n)
    {
        cin >> vec[i];
        if (temp[vec[i]] == -1) temp[vec[i]] = i;
        else d = i - temp[vec[i]];
    }
    erep(i, 1, n+1)
    {
        ll hoba = C(n+1, i, modulo);
        if (n-d >= i-1) hoba -= C(n-d, i-1, modulo);
        cout << mod(hoba, modulo) << endl;
    }


    /*vvi temp(n+2);
    erep(i, 0, n) temp[mp[vec[i]]].push_back()*/
    return 0;
}


Measured memory_bytes: 2816
import math
import copy
from copy import deepcopy
import sys
import fractions
# import numpy as np
from functools import reduce
# import statistics
import heapq
import collections
import itertools
sys.setrecursionlimit(100001)

# input = sys.stdin.readline
# sys.setrecursionlimit(10**6)

# ===FUNCTION===

def getInputInt():
    inputNum = int(input())
    return inputNum


def getInputListInt():
    outputData = []
    inputData = input().split()
    outputData = [int(n) for n in inputData]

    return outputData


def getSomeInputInt(n):
    outputDataList = []
    for i in range(n):
        inputData = int(input())
        outputDataList.append(inputData)

    return outputDataList


def getSomeInputListInt(n):
    inputDataList = []
    outputDataList = []
    for i in range(n):
        inputData = input().split()
        inputDataList = [int(n) for n in inputData]
        outputDataList.append(inputDataList)

    return outputDataList


# ===CODE===

# n, m = map(int, input().split())

h, w = map(int, input().split())

ans = 0
ans += w * math.floor(h / 2)

if h % 2 == 1:
    ans += math.floor(w / 2) + math.floor(w % 2)

if w == 1 or h == 1:
    ans = 1

print(int(ans))


Measured memory_bytes: 5444
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#pragma GCC optimize("Ofast")
//*********************************************DO IT NOW****************************************************************
#include<bits/stdc++.h> 
#include<random>
#define int long long   
#define pp pair<int,int> 
#define ss second 
#define ff first 
#define pb push_back
#define mod 1000000007
#define pi 3.14159265359
#define mk(arr,n,type)  type *arr=new type[n];
#define sl s1.length();
#define yes cout<< "YES"<<endl
#define no  cout<< "NO"<<endl
#define all(v) (v).begin(),(v).end()
#define s(v)   sort(v,v+n)
#define  mt mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define read(a,n) for(int i=0;i<n;i++)cin>>a[i]
#define print(a,n) for(int i=0;i<n;i++)cout<<a[i]<<" "
#define for1(i,a,n)  for(int i=0;i<n;i++)
#define rep(i, c) for(int i = 0; i < (int)c; i++)
#define set(x) cout<<fixed<<setprecision(x);
using namespace std;
//**********************************************DO IT NO****************************************************************
void fastio()
{  
  #ifndef ONLINE_JUDGE
  freopen("INPUT.txt","r",stdin);
  freopen("OUTPUT.txt","w",stdout); 
  #endif
  ios_base :: sync_with_stdio(false); 
  cin.tie(NULL) ; 
  cout.tie(NULL);
}
int dp[101][1001],ans1=1e9,dp1[1000001];
int num[10];
int a[1000000];
signed main()
{   
    fastio();
    int t=1;
   // cin>>t;
    while(t--)
    {  
      int a,b,c,x;
      cin>>a>>b>>c>>x;
      int count =0;
      for(int i=0;i<=a;i++)
      {
          for(int j=0;j<=b;j++)
          {
              for(int k=0;k<=c;k++)
              {
                  if(i*500+j*100+k*50==x)
                  count++;
              }
          }
      }
      cout<<count;
      
    }
}
    
// 🍪 🍪 🍪


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

int hit(string a,string b){
  int res = 0;
  for(int i=0;i<4;i++){
    if(a[i] == b[i]) res++;
  }
  return res;
}

int blow(string a,string b){
  int res = 0;
  for(int i=0;i<4;i++){
    for(int j=0;j<4;j++){
      if(i != j && a[i] == b[j]){
        res++;
        break;
      }
    }
  }
  return res;
}

int main(void){
  string a,b;

  while(cin>>a>>b, a!="0"){
    cout<<hit(a,b)<<" "<<blow(a,b)<<endl;
  }

  return 0;
}

Measured memory_bytes: 1192
#include <stdio.h>

int main(void)
{
    int x;
    int i = 1;

    while (1)
    {
        scanf("%d", &x);
        if (x == 0)
        {
            break;
        }
        printf("Case %d: %d\n", i, x);
        i++;
    }
}


Measured memory_bytes: 2012
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define T int t;cin>>t;while(t--)
#define f(i,n) for (int i=0;i<n;i++)
#define fa(i,a,b) for (int i=a;i<b;i++)
#define b(i,a,b) for (int i=a;i>=b;i--)
#define pb push_back
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define mp make_pair
#define fi first    
#define se second
#define SZ(x) ((int)(x).size())
#define debug(x) cout<<">"<<#x<<" = "<<x<<endl;
// #define MOD 1000000007
#define ce cout<<"\n"

int main()
{
    int n, i, j;
    cin>>n;
    string s;
    cin>>s;
    if(n%2==0)
    {
        int f=1;
        for(i=0, j=n/2; j<n; i++, j++)
        {
            if(s[i] != s[j]){
                f=0;
                break;
            }
        }
        if(f)
            cout<<"Yes\n";
        else
            cout<<"No\n";
    }
    else
        cout<<"No\n";
    return 0;
}

Measured memory_bytes: 384
n=int(input())
a=list(map(int,input().split()))
b=[a[0]]
for i in range(n-1):
	b.append(b[-1]+a[i+1])
b.append(0)
b.sort()
cnt=0
ans=0
def c(a,b):
	u=1
	for i in range(a-b+1,a+1):
		u*=i
	for i in range(1,b+1):
		u//=i
	return u
p=b[0]
for i in range(n+1):
	if b[i]==p:
		cnt+=1
	else:
		p=b[i]
		ans+=c(cnt,2)
		cnt=1
if cnt>1:
	ans+=c(cnt,2)
print(ans)

Measured memory_bytes: 25976
#include<algorithm>
#include<iostream>
using namespace std;
int main(){
  int i,j;
  int n;
  cin>>n;
  pair<int,int> a[101];
  for(i=1;i<=n;++i)
    a[i]=make_pair(0,i);
  for(i=0;i<n*(n-1)/2;++i){
    int p,q,r,s;
    cin>>p>>q>>r>>s;
    if(false){
    }else if(r<s){
      a[q].first+=3;
    }else if(r>s){
      a[p].first+=3;
    }else{
      ++a[p].first;
      ++a[q].first;
    }
  }
  sort(a+1,a+n+1,greater<pair<int,int> >());
  for(i=1;i<=n;++i){
    for(j=1;a[j].second!=i;++j);
    for(;j>1&&a[j-1].first==a[j].first;--j);
    cout<<j<<endl;
  }
  return 0;
}

Measured memory_bytes: 0
#!/usr/bin/env python
# coding: utf-8

def readInt():
    return int(input())

def readList():
    return list(input().split())

def readListI():
    return list(map(int, input().split()))

def main():
    n = readInt()
    print((n-2)*180)


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include<stdio.h>
int main(){
  int K,A,B,flag=0;
  scanf("%d",&K);
  scanf("%d %d",&A,&B);
  for(int i=1;K*i<=B;i++){
    if(K*i>=A && K*i<=B){printf("OK"); flag=1; break;}
  }
  if(flag==0) printf("NG");
}

Measured memory_bytes: 1708
//@source: 
//@create: 18:59:18 Sunday 02/08/2020
//@author: nghethuat102
#include <bits/stdc++.h>
using namespace std;

#define len(x) (int) x.size()
#define all(x) x.begin(), x.end()
#define discrete(x) sort(all(x), x.erase(unique(all(x)), x.end())

void solve() {
    int n;
    cin >> n;
    if (n < 30) {
        cout << "No\n";
    } else {
        cout << "Yes\n";
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int t = 1;
    for (int it = 1; it <= t; ++it) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3648
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int m = in.nextInt();
		long[] w = new long[n+1];
		long[] v = new long[n+1];
		long max = 0;
		for(int i=1;i<=n;i++) {
			w[i] = in.nextInt();
			v[i] = in.nextInt();
			if(v[i]>max) {
				max = v[i];
			}
		}
		long[][] dp = new long[n+1][(int)max*n+1];
		for(int i=1;i<=(int)max*n;i++) {
			dp[0][i] = 1000000000;
			dp[0][i] = dp[0][i]*100;
		}
		dp[0][0] = 0;
		for(int i=1;i<=n;i++) {
			dp[i][0] = 0;
			for(int j=1;j<=(int)max*n;j++){
				dp[i][j] = dp[i-1][j];
				//System.out.println(i+" "+j+" "+(j-(int)v[i]));
				if(j>=v[i])dp[i][j] = Math.min(dp[i][j], dp[i-1][j-(int)v[i]]+w[i]);
			}
		}
		/*
		for(int i=0;i<=n;i++) {
			System.out.println(Arrays.toString(dp[i]));
		}
		*/
		for(int i=dp[0].length-1;i>=0;i--) {
			if(dp[n][i]<=m) {
				System.out.println(i);
				break;
			}
		}
	}
}

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

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

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())

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

const double EPS = 1e-9;
const double PI  = acos(-1.0);
const int INT_INF = 2147483647;
const long long LL_INF = 1LL<<60;
const long long MOD = 1000000007;

#define CLR(a) memset((a), 0 ,sizeof(a))

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

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

int main(void){
    double a,b,x; cin >> a >> b >> x;
    double theta;
    if(x > a*a*b/2){
        double y = 2*(b-x/(a*a));
        theta = atan(y/a);
    }
    else{
        double y = 2*x/(a*b);
        theta = atan2(b,y);
    }
    double ans = 180*theta/PI;
    cout << fixed << setprecision(10) << ans << endl;
    return 0;
}

Measured memory_bytes: 384
N=parse(Int,readline())
Ai=map(x->parse(Int,x),split(readline()," "))
#N=2*10^5
#Ai=[1,2,1,4,2,1,4,1]
c=zeros(Int,N)
for i in 1:N
    c[Ai[i]]+=1
end
ret=""
sum0=0

for i in 1:N
    sum0+=binomial(c[i],2)
end

for i in 1:N-1
    sumk=sum0+binomial(c[Ai[i]]-1,2)-binomial(c[Ai[i]],2)
    #ret*=string(sumk)*"\n"
    println(sumk)
end
i=N
print(sum0+binomial(c[Ai[i]]-1,2)-binomial(c[Ai[i]],2))

Measured memory_bytes: 215832
while True:
    w = int(input())
    if w==-1: break
    
    if w <= 10:
        mon = 1150
    elif 10 < w <= 20:
        mon = 1150 + (w-10)*125
    elif 20 < w <= 30:
        mon = 1150 + 1250 +(w-20)*140
    else:
        mon = 1150 + 1250 + 1400 +(w-30)*160
    
    print(4280-mon)


Measured memory_bytes: 5588
import sys
sys.setrecursionlimit(10000000)
MOD = 10 ** 9 + 7
INF = 10 ** 15

def main():
    N,K = map(int,input().split())
    A = list(map(int,input().split()))

    if N == K:
        ans = 1
        for a in A:
            ans *= a
            ans %= MOD
        print(ans)
        return
    
    if all(a < 0 for a in A) and K%2 == 1:
        A.sort(reverse = True)
        ans = 1
        for i in range(K):
            ans *= A[i]
            ans %= MOD
        print(ans)
        return
    
    A.sort(key = abs,reverse = True)
    cnt_m = 0
    ans = 1
    last_p = -1
    last_m = 1
    for i in range(K):
        if A[i] == 0:
            print(0)
            return
        elif A[i] < 0:
            ans *= A[i]
            ans %= MOD
            cnt_m += 1
            last_m = A[i]
        else:
            ans *= A[i]
            ans %= MOD
            last_p = A[i]
    if cnt_m%2 == 0:
        print(ans)
    else:
        diff1 = last_p
        diff2 = last_m
        inv1 = pow(last_m,MOD - 2,MOD)
        inv2 = pow(last_p,MOD - 2,MOD)
        for i in range(K,N):
            if A[i] >= 0:
                diff1 *= A[i]
                inv1 *= A[i]
                inv1 %= MOD
                break
            if i == N - 1:
                diff1 = -1
        for i in range(K,N):
            if A[i] < 0:
                diff2 *= A[i]
                inv2 *= A[i]
                inv2 %= MOD
                break
            if i == N - 1:
                diff2 = -1
        
        if last_p > 0:
            if diff1 < diff2:
                ans *= inv2
                ans %= MOD
            else:
                ans *= inv1
                ans %= MOD
        else:
            ans *= inv1
            ans %= MOD
        print(ans)
if __name__ == '__main__':
    main()

Measured memory_bytes: 105244
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string>
using namespace std;
int main(){

	while(1){
        int n,m;
        int a[20010] = {0},b[20010] = {0};
        short flg[30000] = {0};
        cin >> n >> m;
        if(n == 0 && m == 0) break;

        for(int i = 1; i <= m; i++){
            cin >> a[i] >> b[i];
            if(a[i] == 1) flg[b[i]] = 2;
            if(b[i] == 1) flg[a[i]] = 2;
        }
        for(int i = 1; i <= m; i++){
            if(flg[a[i]] == 2 && flg[b[i]] != 2) flg[b[i]] = 3;
            if(flg[b[i]] == 2 && flg[a[i]] != 2) flg[a[i]] = 3;
        }
        int cnt = 0;
        for(int i = 2; i <= n; i++){
            if(flg[i] == 2 || flg[i] == 3) cnt++;
        }
        cout << cnt << endl;

	}

	return 0;
}

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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;
typedef pair<ll, ll> PL;
typedef pair<P, ll> PPL;

#define INF INT_MAX/3

#define MAX_N 1000

int main(){
	cin.sync_with_stdio(false);
	int k, s;
	cin >> k >> s;

	int cnt = 0;
	rep(i, k + 1) {
		if (i < s - 2 * k || i > s) continue;
		rep(j, k + 1) {
			if (i + j < s - k || i + j > s) continue;
			cnt++;
		}
	}

	cout << cnt << endl;

	return 0;
}

Measured memory_bytes: 256