akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define REP(i, n) for (ll (i) = 0 ; (i) < (ll)(n) ; ++(i))
#define REPN(i, m, n) for (ll (i) = m ; (i) < (ll)(n) ; ++(i))
#define REP_REV(i, n) for (ll (i) = (ll)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (ll (i) = (ll)(n) - 1 ; (i) >= m ; --(i))

#define INF 2e9
#define INF_LL 1LL<<60
#define ll long long

typedef pair<ll, ll> P;

int main(){
    ll n, m, ans = 0;
    cin >> n >> m;
    vector<ll> a(n);
    vector<P> card(m);
    REP(i, n) cin >> a[i];
    sort(a.begin(), a.end());
    REP(i, m) {
        ll b, c;
        cin >> b >> c;
        card[i] = make_pair(c, b);
    }
    sort(card.begin(), card.end());
    reverse(card.begin(), card.end());
    
    int card_idx = 0;
    int card_idx_in = 0;

    REP(i, n) {
        if(a[i] < card[card_idx].first) {
            a[i] = card[card_idx].first;
            card_idx_in++;
            if(card_idx_in == card[card_idx].second) {
                //cout << card_idx_in << endl;
                card_idx++;
                card_idx_in = 0;
            }
            if(card_idx == m) break;
        }
    }

    REP(i, n) ans += a[i];

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
int main(){
  int N,MOD=1e9+7;
  cin>>N;
  vector<vector<ll>> DP(101,vector<ll>(64,0));
  //0123=AGCT;
  
  //XAGC==012
  //XACG==021
  //XGAC==102
  //AXGC=0X12
  //AGXC=01X2(0122は012カウント）
  //加算できるものを加算してるかんじ？
  //AGCX系はDP[i-1]で網羅
  
  //ああわかったかも、常に3桁の情報残しておいて、4桁にしたときにOKかどうかDPか
  //D[3][0]=1//AAAが1個
  //D[4][0]=4//XAAAなので4個になるはず
  //D[3][(AAA)]+A,(GAA)(CAA)(TAA)か。
  //64*4*100通りですべてもとめられそう

  //i=3のときだけどうしよう。1入れるか、式でおぎなえるのか。
  for(int j1=0; j1<4; j1++){
    for(int j2=0; j2<4; j2++){
      for(int j3=0; j3<4; j3++){
        if(j1==0 &&j2==1 &&j3==2) continue;
        if(j1==1 &&j2==0 &&j3==2) continue;
        if(j1==0 &&j2==2 &&j3==1) continue;
        DP[3][j1*16+j2*4+j3]++;
      }
    }
  }
  for(int i=4; i<=N; i++){
    for(int j1=0; j1<4; j1++){
      for(int j2=0; j2<4; j2++){
        for(int j3=0; j3<4; j3++){
          for(int j4=0; j4<4; j4++){
            if(        j2==0 &&j3==1 &&j4==2) continue;
            if(        j2==1 &&j3==0 &&j4==2) continue;
            if(        j2==0 &&j3==2 &&j4==1) continue;
            if(j1==0         &&j3==1 &&j4==2) continue;
            if(j1==0 &&j2==1         &&j4==2) continue;
            DP[i][j2*16+j3*4+j4]+=DP[i-1][j1*16+j2*4+j3];
            DP[i][j2*16+j3*4+j4]%=MOD;
          }
        }
      }
    }
  }
  ll ans=0;
  for(int i=0; i<64; i++){
    ans+=DP[N][i];
    ans%=MOD;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;


public class Main 
{
	public static void main(String[] args)
	{
		Scanner scanner = new Scanner(System.in);
		
		long n = scanner.nextLong();
		long p = 1;
		for(; n>0; n--)
		{
			p *= n;
		}
		
		System.out.println(p);
	}
}

Measured memory_bytes: 26056
#include<bits/stdc++.h>
using namespace std;
const int N = 1e3 + 1;
int n , m , dp[N][N] , mod = 1e9 + 7;
string s[N];
int main(){
    cin >> n >> m;
    for(int i = 0 ; i < n ; i++)
        cin >> s[i];
    dp[n - 1][m - 1] = 1;
    for(int i = n - 1 ; i >= 0 ; i--){
        for(int j = m - 1; j >= 0 ; j--){
            if(i == n - 1 && j == m - 1)continue;
            if(i + 1 < n && s[i + 1][j] != '#')
                dp[i][j] = dp[i + 1][j];
            if(j + 1 < m && s[i][j + 1] != '#')
                dp[i][j] = (dp[i][j] + 1LL * dp[i][j + 1]) % mod;
        }
    }
    cout<<dp[0][0];
    return 0;
}

Measured memory_bytes: 5248
n=int(input())
a=list(map(int,input().split()))
b=[]
for i in range(n):
	b.append(-a[i]-i)
for i in range(n):
	a[i]-=i
a.sort()
b.sort()
import bisect
ans=0
for i in range(n):
	ans+=bisect.bisect_right(b,a[i])-bisect.bisect_left(b,a[i])
print(ans)

Measured memory_bytes: 32364
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <stack>
#include <queue>
#include <string>

#define REP(i,n)for (int i=0;i<(n);i++)
#define PB push_back
#define MP make_pair
#define ALL(a) (a).begin(),(a).end()
#define ll long long
using namespace std;
typedef pair<int,int> P;

ll dp[31][50];
bool is_ok[31][50];

int main(){
	int n;
	while(1){
		cin>>n;
		if(n==0)break;

		REP(i,31)REP(j,50)dp[i][j]=0LL;
		memset(is_ok,false,sizeof(is_ok));

		REP(i,n){
			int f;
			cin>>f;
			REP(j,f){
				int a;cin>>a;is_ok[a][i]=true;
			}
		}

		REP(i,n)dp[0][i]=1LL<<i;
		int ans=-1;
		for(int i=1;i<=30;i++){
			REP(j,n){
				dp[i][j]=dp[i-1][j];
				if(is_ok[i][j]){
					REP(k,n){
						if(is_ok[i][k])dp[i][j]|=dp[i-1][k];
					}
				}
			}
			REP(j,n){
				if(dp[i][j]==(1LL<<n)-1)ans=i;
			}
			if(ans!=-1)break;
		}
		cout<<ans<<endl;
	}
}


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

ll solve() {
    ll R;
    cin >> R;
    cout << R * M_PI * 2 << "\n";
    return 0;
}

int main() {
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}

Measured memory_bytes: 3784
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <bitset>
#include <random>
#include <chrono>
#include <complex>
#include <algorithm>
#include <utility>
#include <functional>
#include <cmath>
#include <cstring>
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iomanip> 

using namespace std;

#define sqr(x) ((x)*(x))
#define mp make_pair
#define pb push_back
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define RE(i, n) FOR(i,1,n)
#define REP(i,n) FOR(i, 0, (int)(n)-1)
#define fst first
#define snd second

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
typedef long double ld;
typedef tuple<int,int,int> iii;

string to_string(string s) {
    return '"' + s + '"';
}
    
string to_string(const char* s) {
    return to_string((string) s);
}
    
string to_string(bool b) {
    return (b ? "true" : "false");
}
    
template <typename A, typename B>
string to_string(pair<A, B> p) {
    return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
    
template <typename A>
string to_string(A v) {
    bool first = true;
    string res = "{";
    for (const auto &x : v) {
        if (!first) {
            res += ", ";
        }
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H);
    debug_out(T...);
}

void fastIO() {
    cin.sync_with_stdio(false);
    cin.tie(0);
}


int XMOV[4] = {0, 0, 1, -1};
int YMOV[4] = {1, -1, 0, 0};

//#############################
const int MAXN = 1000005;

int main() {
    int k, n;
    vector<ll> a, diff;
    ll x;

    cin >> k >> n;
    REP(i, n){
        cin >> x;
        a.pb(x);
    }

    
    diff.pb(0);
    for(int i = 1; i < n; i++) {
        diff.pb(a[i] - a[i-1] + diff[i-1]);
    }
    ll aux = (k+a[0]) - a[n-1];
    ll cw, ccw, ans = 1e18;
    for (int i = 0; i < n; i++) {
        cw = diff[n-1] - diff[i];
        if (i > 0)
            cw += aux + diff[i-1];
        ccw = diff[i]; 
        if (i < n-1)
            ccw += aux;
        if (i < n-2)
            ccw += diff[n-1] - diff[i+1];
        ans = min(ans, ccw);
        ans = min(ans, cw);
    }

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

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

int main(){

  ios_base::sync_with_stdio(false);
  cin.tie(0),cout.tie(0);

  string s,s1;
  cin>>s>>s1;

  int ans = 0;
  for(int i=0;i<s.size();i++){
    if(s[i]!=s1[i]){
        ans++;
    }
  }
  cout<<ans<<endl;

return  0;
}


Measured memory_bytes: 3888
L, R = gets.split.map(&:to_i)

counter = 2020
right = [R, L + 2020].min
(L..right).each do |i|
  ((i + 1)..[R, i + 2020].min).each do |j|
    r = i * j % 2019
    counter = r if counter > r
  end
end
p counter

Measured memory_bytes: 1788
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

const INFINITY = math.MaxInt64/2 - 1

func exec(stdin *Stdin, stdout *Stdout) {
	n := stdin.ReadInt()
	s := stdin.Read()

	a := []int{0, 0, 0}
	for i := 0; i < n; i++ {
		if s[i] == 'R' {
			a[0]++
		} else if s[i] == 'G' {
			a[1]++
		} else {
			a[2]++
		}
	}

	ans := a[0] * a[1] * a[2]

	for i := 0; i < n; i++ {
		for j := i + 1; j < n; j++ {
			k := j + (j - i)
			if k < n && s[i] != s[j] && s[i] != s[k] && s[j] != s[k] {
				ans--
			}
		}
	}

	stdout.Println(ans)
}

func main() {
	stdout := NewStdout()
	defer stdout.Flush()
	exec(NewStdin(bufio.ScanWords), stdout)
}

type Stdin struct {
	stdin *bufio.Scanner
}

func NewStdin(split bufio.SplitFunc) *Stdin {
	s := Stdin{bufio.NewScanner(os.Stdin)}
	s.stdin.Split(split)
	s.stdin.Buffer(make([]byte, bufio.MaxScanTokenSize), INFINITY)
	return &s
}

func (s *Stdin) Read() string {
	s.stdin.Scan()
	return s.stdin.Text()
}

func (s *Stdin) ReadInt() int {
	n, _ := strconv.Atoi(s.Read())
	return n
}

func (s *Stdin) ReadFloat64() float64 {
	n, _ := strconv.ParseFloat(s.Read(), 64)
	return n
}

type Stdout struct {
	stdout *bufio.Writer
}

func NewStdout() *Stdout {
	return &Stdout{bufio.NewWriter(os.Stdout)}
}

func (s *Stdout) Flush() {
	s.stdout.Flush()
}

func (s *Stdout) Println(a ...interface{}) {
	fmt.Fprintln(s.stdout, a...)
}

func Min(a int, b ...int) int {
	for _, v := range b {
		if v < a {
			a = v
		}
	}
	return a
}

func Max(a int, b ...int) int {
	for _, v := range b {
		if a < v {
			a = v
		}
	}
	return a
}

func Abs(x int) int {
	if x > 0 {
		return x
	} else {
		return x * -1
	}
}

func Pow(x, y int) int {
	z := 1
	for y > 0 {
		if y%2 == 0 {
			x *= x
			y /= 2
		} else {
			z *= x
			y -= 1
		}
	}
	return z
}

func CreateMatrix(x, y int) [][]int {
	matrix := make([][]int, x)
	for i := 0; i < x; i++ {
		matrix[i] = make([]int, y)
	}
	return matrix
}


Measured memory_bytes: 1820
def main():
    N = int(input())
    A = list(map(int,input().split()));
    
    if 0 in A:
        print(0)
        return
    
    prod = 1
    
    for a in A:
        prod *= a
        
        if prod > 10**18:
            print(-1)
            return
        
    print(prod)

main()

Measured memory_bytes: 21644
x, n = [int(i) for i in input().split()]
p = [int(i) for i in input().split()]

i = 0
loop = True
while loop:
	for j in range(-1*i, i+1):
		if x+j not in p:
			ans = x+j
			loop = False 
			break

	i += 1


print(ans)


Measured memory_bytes: 9056
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

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

int main(int argc, const char * argv[]) {
    
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int A, B;
    
    cin >> A >> B;
    
    cout << max(max(A+B, A*B),A-B) << endl;
    
    return 0;
}

Measured memory_bytes: 256
// B - Exponential

#include <bits/stdc++.h>
using namespace std;

int main() {
  int N, D;
  cin >> N >> D;

  vector<vector<int>> vec(N, vector<int>(D));

  for (int i = 0; i < N; i++) {
    for (int j = 0; j < D; j++) {
      cin >> vec[i][j];
    }
  }

  int count = 0;
  for (int i = 0; i < N - 1; i++) {
    for (int j = i + 1; j < N; j++) {
      int kyori = 0;
      for (int k = 0; k < D; k++) {
        kyori += pow((vec[i][k] - vec[j][k]), 2);
      }
      //平方数チェック
      int l = 0;
      while (l * l <= kyori) {
        l++;
        if (l * l == kyori) {
          count++;
          break;
        }
      }
    }
  }

  cout << count << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define f first
#define s second
#define MOD 1000000007
#define PMOD 998244353
#define pb(x) push_back(x)
using namespace std;

typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> plii;
typedef pair<int, pii> piii;
const int INF = 1e9+10;
const ll LINF = 1LL*INF*INF;
const int MAXN = 2e5+10;
const int MAXM = 5e3+10;

priority_queue<int> pq;
vector<vector<int> > graph;
queue<int> que;

ll A[MAXN];
char S[MAXN];

int main()
{
    int n,m,k,a,b,x,y,q;
    int sum = 0;
    int cnt = 0;
    int mx = 0;
    int mn = INF;
    int cur = 0, idx = -1;
    int tc;

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin>>n;

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

    ll res = LINF;
    ll L,R;

    for(int i=1;i<=n;i++){
        L = A[i];
        R = A[n]-A[i];
        res = min(res,max(L-R,R-L));
    }

    cout<<res<<"\n";

    return 0;
}


Measured memory_bytes: 1792
#include <set>
#include <string>
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <limits>
#include <map>
#include <numeric>

#define ll long long
using namespace std;
static ll imin = std::numeric_limits<ll>::min();
static ll imax = std::numeric_limits<ll>::max();
#define rep(i, n) for(int i = 0; (i)<(n); ++(i))
#define rep1(i, n) for(int i = 1; (i)<(n); ++(i))
#define rev_rep(i, n) for(int i = (n) - 1; (i) >= 0; --(i))
#define range(a, i, b) for(int i = (a); (i) < (b); ++(i))
#define dump(x) cout << #x << ":" << x << "\n";
#define all(v) v.begin(), v.end()
#define readl(N) ll N; cin >> N
#define readlv(N, vec) vector<ll> vec(N); rep(i, N){cin >> vec[i];}
#define greater_than [](ll l, ll r){return l > r;}
template<class T1, class T2>
std::ostream& operator << (std::ostream& os, std::map<T1, T2>& mp);
template<class T1, class T2>
std::ostream& operator << (std::ostream& os, std::pair<T1, T2>& pair);
template<class T>
std::ostream& operator << (std::ostream& os, std::vector<T>& vec);
template<class T1, class T2>
std::ostream& operator << (std::ostream& os, std::pair<T1, T2>& pair){
  os << '(' << pair.first << ',' << pair.second << ')';
  return os;
}

template<class T>
std::ostream& operator << (std::ostream& os, std::vector<T>& vec){
  std::size_t n = vec.size();
  if(n == 0){
    return os;
  }
  os << " ";
  for(ll i = 0; i<n - 1; ++i){
    os << vec[i] << " ";
  }
  os << vec[n - 1];
  os << std::endl;
  return os;
}

template<class T1, class T2>
std::ostream& operator << (std::ostream& os, std::map<T1, T2>& mp){
  std::size_t n = mp.size();
  if(n == 0){
    return os;
  }
  os << " ";
  for(auto && x:mp){
    os << x << " ";
  }
  os << std::endl;
  return os;
}

template<class T>
std::ostream& operator << (std::ostream& os, std::set<T>& mp){
  std::size_t n = mp.size();
  if(n == 0){
    return os;
  }
  os << " ";
  for(auto && x:mp){
    os << x << " ";
  }
  os << std::endl;
  return os;
}

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

#ifndef BOOST_TEST_MAIN
int main(int const argc, char const** argv){
  readl(N);
  vector<vector<ll> > f(N, vector<ll>(10));
  vector<vector<ll> > p(N, vector<ll>(11));
  rep(n, N){
    rep(i, 10){
      cin >> f[n][i];
    }
  }
  rep(n, N){
    rep(i, 11){
      cin >> p[n][i];
    }
  }

  // dump(f);
  // dump(p);
  ll res = imin;

  for(int mask = 1; mask < (1 << 10); mask++){
    ll rr = 0;
    rep(i, N){
      ll r = 0;
      rep(j, 10){
        if(mask & (1 << j) && f[i][j] == 1){
          r++;
        }
      }
      rr += p[i][r];
    }
    res = max(rr, res);
  }
  cout << res;
}
#endif


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

int main() {

    char S[14];
    char H[14];
    char C[14];
    char D[14];

    int card=0;
    cin >> card;

    char v;
    int r;

    for (int j = 0; j < card ; ++j) {
        cin >> v >> r;
        if (v == 'S')
            S[r] = v;

        if (v == 'H')
            H[r] = v;

        if (v == 'C')
            C[r] = v;

        if (v == 'D')
            D[r] = v;
    }

    for (int i = 1; i < 14; ++i) {
        if(S[i] != 'S')
            cout << 'S' << " " << i << endl;
    }
    for (int k = 1; k < 14; ++k) {
        if(H[k] != 'H')
            cout << 'H' << " " << k << endl;
    }
    for (int l = 1; l < 14; ++l) {
        if(C[l] != 'C')
            cout << 'C' << " " << l << endl;
    }
    for (int m = 1; m < 14; ++m) {
        if(D[m] != 'D')
            cout << 'D' << " " << m << endl;
    }

    return 0;
}


Measured memory_bytes: 3108
#include <bits/stdc++.h>
#define ll long long int
#define ld double
#define f first
#define s second
#define pb push_back
#define mk make_pair
#define MOD 1000000007
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
#define boost ios::sync_with_stdio(false); cin.tie(0)
using namespace std;
int main()
{
	boost;
	int n, i, j;
	string s;
	cin >> s;
	n = s.length();
	int ans[n];
	memset(ans, 0, sizeof ans);
	for(i = 0; i < n; i = j){
		j = i;
		if(s[i] == 'R'){
			int cnt = 0;
			while(j < n && s[j] == 'R'){
				cnt++;
				j++;
			}
			if(j != n){
				ans[j] += cnt / 2;
				ans[j - 1] += cnt - cnt / 2;
			}
			else ans[n - 1] += cnt;
		}
		else
		j++;
	}
	for(i = n - 1; i >= 0; i = j){
		if(s[i] == 'L'){
			int cnt = 0;
			while(j >= 0 && s[j] == 'L'){
				cnt++;
				j--;
			}
			if(j >= 0){
				ans[j] += cnt / 2;
				ans[j + 1] += cnt - cnt / 2;
			}
			else
			ans[0] += cnt;
		}
		else
		j--;
	}
	for(int x : ans)
	cout << x << ' ';
}


Measured memory_bytes: 1104
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll ;
long long gcd(long long aaa,long long bbb) {
    if(bbb==0) {
        return aaa;
    }
    return gcd(bbb,aaa%bbb);
}

int main (){

    ll N,ans=0;
    cin >> N;
    ll a[N];
    for(ll i = 0; i < N; i++) {
        cin >> a[i];
        ans += a[i]-1;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
from itertools import accumulate
import bisect


def main():
    N, M, K = map(int, input().split())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))
    accumulateA = list(accumulate(A))
    accumulateB = list(accumulate(B))
    accumulateA.insert(0, 0)
    accumulateB.insert(0, 0)
    count = 0
    for i in range(N+1):
        j = bisect.bisect(accumulateB, K - accumulateA[i]) - 1
        if j >= 0:
            count = max(count, i + j)
    print(count)


if __name__ == "__main__":
    main()


Measured memory_bytes: 47412
#include <stdio.h>

int main(void)
{
    int i, j, h[10], t;

    for (i = 0; i < 10; ++i)
        scanf("%d", &h[i]);

    for (i = 0; i < 9; ++i) {
        for (j = 8; j >= i; --j) {
            if (h[j] < h[j + 1]) {
                t = h[j];
                h[j] = h[j + 1];
                h[j + 1] = t;
            }
        }
    }

    for (i = 0; i < 3; ++i)
        printf("%d\n", h[i]);

    return 0;
}

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

int main() {
    int n;
    cin >> n;

    vector<int> R(n);
    for (int i=0; i<n; i++) {
        cin >> R.at(i);
    }

    int maxr = -2000000000;
    int minr = R.at(0);

    for (int i=1; i<n; i++) {
        maxr = max(maxr, R.at(i) - minr);
        minr = min(minr, R.at(i));
    }

    cout << maxr << endl;
    return(0);
}


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

int main() {
	
	string s;
	cin>>s;
	
	int k = 0;
	int n = s.size();
	for(int i = 0; i < n-1; i++)
	{
		if(i == -1)
		{
			i++;
		}
		if(s[i] != s[i+1])
		{
			k+=2;
			s.erase(i,2);
			i-=2;
			n-=2;
		}
	}
	cout<<k;
	return 0;
}

Measured memory_bytes: 3724
area :: Double -> Double -> Double
area x h = x * x + 2 * x * sqrt (halfx * halfx + h * h)
  where halfx = x / 2

main :: IO ()
main = getContents >>= f . map read . lines
  where f []       = return ()
        f [_]      = return ()
        f (0:0:_)  = return ()
        f (x:h:xs) = print (area x h) >> f xs

Measured memory_bytes: 3824
#include<bits/stdc++.h>
using namespace std;
static const int64_t mod=1000000007;
int64_t f(int64_t x,int64_t y){
if(y==0)
  return 1;
  else if(y%2==0)
    return (f(x,y/2)*f(x,y/2))%mod;
  else
    return (x*((f(x,y/2)*f(x,y/2))%mod))%mod;
}
int main(){
  int64_t K; string s;
  cin>>K>>s;
  int64_t N=s.size();
  int64_t ans=0; int64_t a=1;int64_t b=f(25,K);
  int64_t c=1;
  for(int64_t i=1;i<=N-1;i++)
    c=(c*(((K+i)*f(i,mod-2))%mod))%mod;
  for(int64_t i=K;0<=i;i--){
  int64_t d=(a*((b*c)%mod))%mod;
    ans=(ans+d)%mod;
    a=(a*26)%mod;
    b=(b*f(25,mod-2))%mod;
    c=(c*((f(i+N-1,mod-2)*i)%mod))%mod;
  
  }cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 5328
#include<iostream>
#include<cmath>
#include<vector>
#include<cstdio>
#include<algorithm>
using namespace std;
#define EPS (1e-10)
#define equals(a, b) (fabs((a) - (b)) < EPS )
class Point{
public:
  double x, y;
  Point ( double x = 0, double y = 0): x(x), y(y){}
  Point operator + ( Point p ){ return Point(x + p.x, y + p.y); }
  Point operator - ( Point p ){ return Point(x - p.x, y - p.y); }
  Point operator * ( double a ){ return Point(x*a, y*a); }
  Point operator / ( double a ){ return Point(x/a, y/a); }
  double abs() { return sqrt(norm());}
  double norm() { return x*x + y*y; }
  bool operator < ( const Point &p ) const {
    return x != p.x ? x < p.x : y < p.y;
  }
  bool operator == ( const Point &p ) const {
    return fabs(x-p.x) < EPS && fabs(y-p.y) < EPS;
  }
};
class Segment{
public:
  Point p1, p2;
  Segment ( Point p1 = Point(0.0,0.0), Point p2 = Point(0.0,0.0)): p1(p1), p2(p2){}
  double abs() { return sqrt(norm());}
  double norm() { return (p2.x - p1.x)*(p2.x - p1.x) + (p2.y - p1.y)*(p2.y - p1.y); }
};
typedef Point Vector;
typedef Segment Line;
double norm( Vector a ){ return a.x*a.x + a.y*a.y; }
double abs( Vector a ){ return sqrt(norm(a)); }
double dot( Vector a, Vector b ){ return a.x*b.x + a.y*b.y; }
double cross( Vector a, Vector b ){ return a.x*b.y - a.y*b.x; }
double getDistanceLP(Line s,Point p){
  return abs(cross(s.p2-s.p1,p-s.p1)/abs(s.p2-s.p1));
}
double getDistanceSP(Segment s,Point p){
  if(dot(s.p2-s.p1,p-s.p1)<0.0)return abs(p-s.p1);
  if(dot(s.p1-s.p2,p-s.p2)<0.0)return abs(p-s.p2);
  return getDistanceLP(s,p);
}
  
Point project(Segment s,Point p){
  Vector base = s.p2-s.p1;
  double t = dot(p-s.p1,base)/norm(base);
  return s.p1+base*t;
}
  
Point p;
double r;
Segment s;
  
Point rotate( Point a, double si,double co){
  return Point(a.x*co-a.y*si,a.x*si+a.y*co);
}
  
vector<Point> solve(){
  vector<Point> res;
  Point q=project(s,p);
  double d=sqrt(r*r-abs(p-q)*abs(p-q));
  Vector base=s.p1-s.p2;
  res.push_back(q+base*(d/abs(base)));
  res.push_back(q-base*(d/abs(base)));
  return res;
}
  
int main(){
  cin>>p.x>>p.y>>r;
  int tc;
  cin>>tc;
  for(int i=0;i<tc;i++){
    cin>>s.p1.x>>s.p1.y>>s.p2.x>>s.p2.y;
    vector<Point> t=solve();
sort(t.begin(),t.end());
    printf("%.8f %.8f %.8f %.8f\n",t[0].x,t[0].y,t[1].x,t[1].y);
  }
  return 0;
}

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

using namespace std;

int factorial(int n){
    int ret = 0;

    for(int i = 1; i < n; ++i){
        ret += i;
    }

    return ret;
}

int main(int argc, char* argv[]){

    int n, m;
    cin >> n >> m;
    cout  << factorial(n) + factorial(m) << endl;

}


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

int main(){
    long long a, b;cin>>a>>b;
    if (a > 0){
        cout << "Positive" << endl;
    } else if (a <= 0 && b >= 0){
        cout << "Zero" << endl;
    } else {
        if (((b - a) + 1) % 2 == 1){
            cout << "Negative" << endl;
        } else {
            cout << "Positive" << endl;
        }
    }
    return 0;
}

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

int main() {
    int n, m;
    cin >> n >> m;

    vector< pair<int, int> > sc(m);
    for(int i = 0; i < m; i++) cin >> sc[i].first >> sc[i].second;
    sort(sc.begin(), sc.end());

    vector<int> ans(n, -1);
    bool is_exist = true;
    for(int i = 0; i < m; i++) {
        int digit = sc[i].first - 1;
        int num = sc[i].second;
        if(ans[digit] == -1) {
            ans[digit] = num;
        } else if(ans[digit] != num) {
            is_exist = false;
            break;
        }
    }

    if(!is_exist) {
        cout << -1 << endl;
    } else {
        int sum = 0;
        for(int i = 0; i < n; i++) {
            if(ans[i] == -1) {
                if(n != 1 && i == 0) ans[i] = 1;
                else                 ans[i] = 0;
            }
            sum += ans[i];
        }
        if(n != 1 && sum == 0) {
            cout << -1 << endl;
        } else {
            for(auto c : ans) {
                cout << c;
            }
            cout << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const long long INF = 1LL<<60;
#define REP(i,n) for(int i=0;i<n;i++)
#define REP2(i,m,n) for(int i=m;i<n;i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
int main(){
    int rate[4];
    REP(i,4){
        cin >> rate[i];
    }
    sort(rate,rate+4);

    cout << abs(rate[3]+rate[0] -rate[2]-rate[1])<<endl;

}


Measured memory_bytes: 3156
def lcm(a, b):
	return a // gcd(a, b) * b

def gcd(a, b):
	while b != 0:
		r = a % b
		a = b
		b = r
	return a

while True:
    try:
        a = list(map(int, input().split()))
        print(gcd(a[0], a[1]), lcm(a[0], a[1]))
    except EOFError:
        break



Measured memory_bytes: 5600
import copy
import math

ms = []
for i in range(1, int(300000/7)+1):
    ms.append(i*7-1)
    ms.append(i*7+1)

delete = []
for i, n in enumerate(ms):
    for j, m in enumerate(ms[:int(math.sqrt(len(ms)))+1]):
        if j < i and n % m == 0:
            delete.append(i)
            break

for i in reversed(delete):
    del ms[i]

while True:
    num = input()
    num = int(num)

    if num == 1:
        break

    divisors = []
    for d in ms:
        if num % d == 0:
            divisors.append(str(d))

    output_str = " ".join(divisors)
    print("%d: %s" % (num, output_str))

Measured memory_bytes: 13344
#include<iostream>
#include<string>
using namespace std;
int main(){
	int n,m;
	char s;
	while(true){
	cin>>n;
	if(n==0)
		break;
	cin>>m;
	bool cut=true;
	int start=0,count=0,ans=0;
	for(int i=0;i<m;i++){
		cin>>s;
		if(cut==true){
			if(s=='I'){
				start=i;
				count=1;
				cut=false;
			}
		}
		else{
			if(((i-start)%2==1&&s!='O')||((i-start)%2==0&&s!='I')){
				cut=true;
				ans+=max(0,count-n);
				if(s=='I'){
				    start=i;
				    count=0;
				    cut=false;
			    }
			}
			if((i-start)%2==0&&s=='I')
				count++;
		}
	}
	cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 1160
def iput(): return int(input())
def mput(): return map(int, input().split())
def lput(): return list(map(int, input().split()))

def solve():
    x, n = mput()
    p = lput()
    ans = []
    for i in range(x, x-n-1, -1):
        boo = i in p
        if boo != True:
            ans.append(i)
            break
    for i in range(x, x+n+1):
        boo = i in p
        if boo != True:
            ans.append(i)
            break
    if abs(x-ans[0]) <= abs(x-ans[1]):
        print(ans[0])
    else:
        print(ans[1])
    return 0

if __name__ == "__main__":
    solve()

Measured memory_bytes: 9224
#include <algorithm>
#include <iostream>
#include <string>
#include <random>
#include <cassert>
#include <cstring>
#include <chrono>

using namespace std;

typedef long long ll;

bool Check(ll n, ll m, ll v, ll p, vector<ll> a, int ind) {
  ll sum = (p - 1) * m;
  ll cap = a[ind] + m;
  for (int i = p - 1; i < n; ++i) {
    ll can = cap - a[i];
    if (can < 0) {
      return false;
    }
    if (can > m) {
      can = m;
    }
    sum += can;
  }
  return sum >= m * v;
}

int main()
{
  ll n, m, v, p;
  cin >> n >> m >> v >> p;
  vector<ll> a(n);
  for (int i = 0; i < n; ++i) {
    int x;
    scanf("%d", &x);
    a[i] = x;
  }
  sort(a.rbegin(), a.rend());
  int left = 0, right = n;
  while (right - left > 1) {
    int middle = (left + right) / 2;
    if (Check(n, m, v, p, a, middle)) {
      left = middle;
    } else {
      right = middle;
    }
  }
  cout << left + 1 << endl;
  return 0;
}


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

using namespace std;

int main() {

	long long x;
	cin >> x;

	long long ten=0;
	long amari = 0;
	if (x <= 6) {
		ten = 1;
	}
	else if( x <= 11) {
		ten = 2;
	}
	else {
		ten = (x / 11)*2;
		amari = x % 11;
		if (amari == 0) {
			ten = ten;
		}
		else if (amari <= 6) {
			ten ++;
		}
		else {
			ten =ten+2;
		}
	}
	cout << ten << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    int h,a;
    cin>>h>>a;
    ll ans=0;
    while(h>0)
    {
        h-=a;
        ans++;
    }
    cout<<ans;
    return 0;
}









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

using namespace std;

int main() {
  int x,n;
  cin>>x>>n;
  int ans=500;
  set<int> s;
  for (int i=-100;i<101;i++){
    s.insert(i);
  }
  
      
  for (int i = 0; i < n; i++) {
    int a;
    cin>>a;
    s.erase(a-x);
  }
    
  for(int i=0; i<=100;i++){
    if(s.count(-i)){
      cout<<x-i<<endl;
      return 0;
    }
    if(s.count(i)){
      cout<<x+i<<endl;
      return 0;
    }
  }
  
}


Measured memory_bytes: 3640
// Author : Mohamed Sameh
#include <bits/stdc++.h>
typedef long long ll ;
#define pb push_back
#define f first
#define s second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define SZ(a) (int)a.size()
#define Flush fflush(stdout);
using namespace std ;
int n , m , k ;
int a[100000];
int main ()
{
    scanf ("%d%d%d" , &n ,&k , &m );
    for (int i =0 ; i < n ;i++)
    {
        a[i] = k - m;
    }
    for (int i =0 ; i < m ;i++)
    {
        int id ;
        scanf ("%d" , &id );
        id--;
        a[id]++;
    }
    for (int i =0 ; i < n ;i++)
    {
        if (a[i] <= 0)cout <<"No\n"; else cout <<"Yes\n";
    }


}


Measured memory_bytes: 1024
#include<iostream>
#include<queue>
#include<memory>
#include<map>
#include<set>
#include<unordered_map>
#include<array>
#include<vector>
#include<algorithm>
#include<list>
#include<limits>
#include<stdio.h>
#include<math.h>
#include<string>
#include<fstream>
#include<functional>


using namespace std;
using ll = long long;
using vec = vector<int>;
using mat = vector<vec>;
using lst = list<int>;
using pr  = pair<int, int>;


int main() 
{
	int N;
	string c;
	cin >> N >> c;

	int l = -1, r = N;
	int i = 0;
	for (i = 0;l<r; ++i)
	{
		
		do
		{ 
			l++; 
			if(l==N)
			{
				cout << i << endl; return 0;
			}
		}while (c[l] != 'W');

		do
		{
			r--;
			if (r == -1)
			{
				cout << i << endl; return 0;
			}
		} while (c[r] != 'R');

		c[l] = 'R';
		c[r] = 'W';
	}

	cout << i-1 << endl;
	return  0;

}


Measured memory_bytes: 3756
import math


def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))


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

if n <= 1:
    ans1 = 0
else:
    ans1 = combinations_count(n, 2)
if m <= 1:
    ans2 = 0
else:
    ans2 = combinations_count(m, 2)
print(ans1 + ans2)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin>>n;
  vector<vector<int> >adj(n);
  vector<pair<int,int> >a;
  vector<int>visited(n);
  map<pair<int,int>,int >ans;
  vector<int>p(n,0);
  queue<int>q;
  for(int i=0;i<n-1;i++)
  {
    int s,t;
    cin>>s>>t;
    adj[s-1].push_back(t-1);
    adj[t-1].push_back(s-1);
    a.emplace_back(s-1,t-1); 
  }
  int ac=0;
  q.push(0);
  visited[0]=1;
  while(!q.empty())
  {  
    int u=q.front();q.pop();
    if(ac<adj[u].size())ac=adj[u].size();
    int cur=1;
    for(auto x : adj[u])
    {
      if(visited[x])continue;
      visited[x]=1;
      
      if(p[u]==cur)cur++;
      p[x]=ans[{u,x}]=ans[{x,u}]=cur;
      cur++;
      q.push(x);
    }
  }
    cout<<ac<<endl;
    for(auto t:a)cout<<ans[t]<<endl;
  return 0;
}

Measured memory_bytes: 20212
#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b){
  bool bk = 1;
  while(bk){
    a = a%b;
    swap(a,b);
    if(a*b == 0){
      return a+b;
      bk = 0;
    }
  }
}

int main() {
  vector<long long>prime(1,2);
  for(int i = 3; i <= 1000003; i++){
    for(long long p : prime){
      if(i%p == 0)
        break;
      else if(p*p > i){
        prime.push_back(i);
        break;
      }
    }
  }
  long long a, b;
  cin >> a >> b;
  long long d = gcd(a,b);
  int ans = 1;
  for(long long p : prime){
    if(d%p == 0){
      ans++;
      while(d%p == 0)
        d /= p;
    }
    if(p*p > d && d > 1){
      ans++;
      break;
    }
  }
  cout << ans << endl;
}



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

int main(){
	int height[10];
	int i , j;
	for(i=0 ; i<10 ; i++){
		cin >> height[i] ;
	}
	for(i=9 ; i>0 ; i--){
		for(j=0 ; j<i ; j++){
			if (height[j]>=height[j+1]){
				height[j]^=height[j+1];
				height[j+1]^=height[j];
				height[j]^=height[j+1];
			}
		}
	}
	for(i=9 ; i>6 ; i--){
		cout << height[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
package main

import (
	"fmt"
	"sort"
	"strconv"
)

func main() {
	var N, K, w int
	fmt.Scan(&N, &K)
	m := map[int]int{}
	for i := 0; i < K; i++ {
		fmt.Scan(&w)
		m[w]++
	}
	var a []int
	for i := 0; i < 10; i++ {
		if _, ok := m[i]; !ok {
			a = append(a, i)
		}
	}
	var p []string
	for i := 0; i < len(a); i++ {
		p = append(p, strconv.Itoa(a[i]))
	}
	for i := 1; i < 6; i++ {
		q := len(p)
		for j := 0; j < q; j++ {
			if len(p[j]) == i {
				for k := 0; k < len(a); k++ {
					p = append(p, p[j]+strconv.Itoa(a[k]))
				}
			}
		}
	}
	var r []int
	for i := 0; i < len(p); i++ {
		v, _ := strconv.Atoi(p[i])
		r = append(r, v)
	}
	sort.Sort(sort.IntSlice(r))
	for i := 0; i < len(r); i++ {
		if r[i] >= N {
			fmt.Println(r[i])
			return
		}
	}
}

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

int main() {
    char c[10];
    int price = 700;
    for (int i=0; i<3; i++) {
        cin >> c[i];
        if (c[i] == 'o') price += 100;
    }

    cout << price << endl;

    return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
#define rep(i,n) for (ll i = 0; i < (ll)(n); ++i)
#define rrep(i,j,n) for(ll i = (ll)(j); i < (ll)(n); i++)
#define mrep(i,n) for (ll i = (ll)(n); i > 0; i--)
#define be(v) (v).begin(), (v).end()
#define dcout cout << fixed << setprecision(20) 
ll INF = 1LL << 60;
ll mod = 1e9 + 7;

int main() {
	int a,b,c,d; cin >> a >> b >> c >> d;
	if(a+b==c+d) cout << "Balanced" << endl;
	else if(a+b>c+d) cout << "Left" << endl;
	else cout << "Right" << endl;
}

Measured memory_bytes: 3644
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String {
            bytes
                .by_ref()
                .map(|r| r.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
    input!{
        n: usize,
        v: [usize; n]
    }
    println!("{}", if v.iter().all(|&x| x % 2 == 1 || x % 3 == 0 || x % 5 == 0) {"APPROVED"} else {"DENIED"});
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define mod 1000000007
#define MAX 1000000000000000
#define all(v) v.begin(),v.end()
#define rep(i,a,b) for(i=(ll)a;i<(ll)b;i++)
#define revrep(i,a,b) for(i=(ll)a;i>=(ll)b;i--)
#define ii pair<ll,ll>
#define MP make_pair
#define pb push_back
#define f first
#define se second
#define ll long long int
#define vi vector<ll>
ll modexp(ll a,ll b){ ll res = 1; while(b > 0){  if(b & 1) res = (res * a)%mod;  a = (a * a)%mod;  b/=2;  }  return res; }
#define rs resize
typedef tree< ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update > OST;
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cout << name << " : " << arg1 << endl;
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
#else
#define trace(...)
#endif

const ll N = 1e3 + 2;
ll a,b;
int main()
{
    std::ios_base::sync_with_stdio(false); cin.tie(NULL);
    cin>>a>>b;
    cout<<max(a + b, max(a + a - 1,b + b - 1));
    return 0;
}

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

int main(){
  int  Rs,W,C,R;
  while(1){
    cin>>Rs>>W>>C>>R;
    if(Rs==0&&W==0&&C==0&&R==0)break;
    for(int x=0;;x++){
      if((Rs+x*R)/C-W>=0){
	cout<<x<<endl;
	break;
      }
    }
  }
  return 0;
}

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

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define ALL(v) (v.begin(),v.end())
#define COUT(x) cout<<(x)<<"\n"

int main(){
    int x;
    cin >> x;
    for(int i=0;i<1001;i++){
        for(int j=-1000;j<i;j++){
            if(pow(i,5)-pow(j,5)==x){
                cout << i << " " << j << endl;
                return 0;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 4032
#include <bits/stdc++.h>
#define ll long long
#define fir first
#define sed second
#define i64 int64_t
#define ui64 uint64_ti
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define kpair pair<int, pair<int,int>
#define lwb lower_bound
#define upb upper_bound
const int mod = 1e9+7;
const int maxn = 1e5;
 
using namespace std;
ifstream fi("");
ofstream fo("");
ll maxv[100001];
ll n,wmax,w,v,res=0;
int main(){
    ios::sync_with_stdio(0);cin.tie(0);
    cin>>n>>wmax;
    for(int i=0;i<n;i++){
        cin>>w>>v;
        for(int j = wmax;j>=w;j--) maxv[j]= max(maxv[j-w]+v,maxv[j]);
    }
    for(int i=0;i<=wmax;i++){
        res = max(res,maxv[i]);
    }
    //cout<<endl;
    cout<<res;
}

Measured memory_bytes: 4336
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String S = sc.next();

        if (S.equals("Sunny")) {
            S = "Cloudy";
        }
        else if (S.equals("Cloudy")) {
            S = "Rainy";
        }
        else {
            S = "Sunny";
        }
        System.out.println(S);
    }
}

Measured memory_bytes: 21332
import java.util.Scanner;

public class Main{ 
 public static void main(String[] args){
  
   Scanner scan = new Scanner(System.in);
   int input =scan.nextInt();
   
   int a=input%10;
   int b=input%100;
   int c=input/100;
   int i=0;
   if(a==7){
     i++;
   }else if(70<=b && b<80){
     i++;
   }else if(c==7){
     i++;
   }
   
   if(i==1){
  System.out.println("Yes\n");
   }
   else{
     System.out.println("No\n");
   }
     
 }
}

Measured memory_bytes: 35636
#include <iostream>
using namespace std;
 
int main() {
  int n, a, b, pointA, pointB;

  cin >> n;
  while(n != 0) {
    

    pointA = 0;
    pointB = 0;

    for(int i = 0; i < n; i++) {
      cin >> a >> b;
 
      if(a > b) {
        pointA += (a + b);
      } else if(a < b) {
        pointB += (a + b);
      } else {
        pointA += a;
        pointB += b;
      }
    }

    cout << pointA << ' ' << pointB << endl;
    cin >> n;
  }   
 
  return 0;
}
 

Measured memory_bytes: 3072
from itertools import permutations
from copy import deepcopy

N,M = [int(i) for i in input().split()]
links  = [[int(i) for i in input().split()] for _ in range(M)]

ans = 0

for path in permutations(range(2,N+1)):
    l = deepcopy(links)
    p_node = 1
    for n_node in path:
        if sorted([p_node,n_node]) in l:
            l.pop(l.index(sorted([p_node,n_node])))
            p_node = n_node
            continue
        else:
            break
    else:
        ans += 1 
print(ans)   


Measured memory_bytes: 3436
'use strict'

const main = (INPUT) => {
  const input = INPUT.split('\n')
  const a = input[1].split(' ')
  let ans = 0
  for (let i = 0; i < a.length; i += 2) {
    if (a[i] % 2 == 1) {
      ans++
    }
  }
  console.log(ans)
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'))


Measured memory_bytes: 30596
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  ll N; cin >> N;
  vector<ll> vec(100100,0);
  //貪欲法でいく
  for(ll i = 1; i <= N; i++){ ll a; cin >> a; vec[i] = a;}
  ll ans = 0;
  for(ll i = 1; i <= N; i++){
    //vec[i]以下の最大の偶数を求める
    ll r = 0;//vec[i]が奇数か偶数か判定
    if( vec[i] % 2){  r = 1; vec[i]--;}
    ans += vec[i]/2; 
    
    if( i < N && r){
      //vec[i]が奇数だった時、vec[i]とvec[i+1]同士でもう一つペアが作れないかを考える
      if(vec[i+1] > 0){ vec[i]--; vec[i+1]--; ans++;}}
  }
  
  cout << ans << endl; return 0;}
      
  

Measured memory_bytes: 1152
import sys


def main():
    X, N = list(map(int, input().split()))
    ans = 999
    dis = 999
    if N == 0:
        print(X)
        sys.exit()
    P = list(map(int, input().split()))
    for i in range(0, 102):
        if i not in P:
            if dis > abs(i - X):
                dis = abs(i - X)
                ans = i
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9192
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T>& V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> >& Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T>& mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }
template<typename T>vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>auto make_v(size_t a,Ts... ts){return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type fill_v(T &t,const V &v){t=v;}
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type fill_v(T &t,const V &v){for(auto &e:t) fill_v(e,v);}
/*
 <url:https://atcoder.jp/contests/abc127/tasks/abc127_b>
 問題文============================================================
 =================================================================
 解説=============================================================
 やるだけ
 ================================================================
 */

template<class Type>
Type solve(Type res = Type()){
    ll r,D,x; cin >> r >> D >> x;
    
    for(int i = 0; i < 10;i++){
        x = r*x - D;
        cout << x << endl;
    }
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    solve(0);
    // cout << fixed << setprecision(15) << solve<ll>() << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <math.h>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <bitset>
#include <tuple>
#include <climits>
#include <sstream>
using namespace std;

vector<int> h;

int main(int argc, char *argv[])
{
    int res = 0, n;

    cin >> n;

    for (int i = 0; i < n; i++)
    {
        int tmp;
        cin >> tmp;
        h.push_back(tmp);

        bool flag = true;
        for (int j = 0; j < i; j++)
        {
            if (h[j] > h[i])
            {
                flag = false;
                break;
            }
        }

        if (flag)
        {
            res++;
        }
    }

    cout << res;
    return 0;
}

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

int main(){
  long N,K;
  cin >> N >> K;
  map<long, long> v;
  for(int i =0; i < N; i++){
    long tmp;
    cin >> tmp;
    auto itr = v.find(tmp);
    if(itr == v.end()){
      v[tmp] = 1;
    } else { 
      v[tmp] += 1;
    }
  }
    
  priority_queue<long> q;
  for(auto x : v){
    q.push(x.second);
  }
  
  long count = 0;
  long ans = 0;
  while(!q.empty()){
    count += 1;
    ans += q.top();
    if(count == K) break;
    q.pop();
  }
  cout << N - ans << endl;
    
  
}

Measured memory_bytes: 14964
//**PEACE BE UPON YOU**
// AZMAYEN FAYEK SABIL
// IUT CSE SWE-19

#include <iostream>
#include <bits/stdc++.h>

#include <cmath>
#include <string>
#include <algorithm>
using namespace std;


int main()

{
    int n;
    cin>>n;

    int a[200005];
    int c[200005]={0};

    int i;

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

    for(i=0;i<n;i++)
    {
       c[a[i]-1]++;
    }

    for(i=0;i<n;i++)
    {
        cout<<c[i]<<endl;
    }


    return 0;
}


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

namespace ProconTemplate
{
    class Doing
    {
        public static void Main(string[] args)
        {
            var inputList = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();

            var exportCount = inputList[2] / inputList[0];
            Console.WriteLine(exportCount * inputList[1]);
        }
    }
}


Measured memory_bytes: 11348
// C.

#include <iostream>
#include <sstream>
#include <tuple>
#include <algorithm>
#include <numeric>
#include <set>
#include <vector>

using namespace std;

typedef long long LL;

int main(int argc, char* argv[]) {
	LL n;
	cin >> n;
	string ans;
	while (n > 0) {
		--n;
		ans += ('a' + n % 26);
		n /= 26;
	}
	reverse(ans.begin(), ans.end());
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3572
#include<bits/stdc++.h>
#include<iomanip>
#define fast {ios_base::sync_with_stdio(false);cin.tie(NULL);}
#define ar array
#define mxn 2005
#define mod 998244353
#define ld long double
#define pb push_back
#define inf 1e9+5
#define fi first
#define se second
typedef long long int ll;
using namespace std;
int main(void){
		#ifndef ONLINE_JUDGE
	freopen("input1.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif
	fast;
	string s;
	cin>>s;
	int r=0,i;
	for(i=0;i<3;i++){
		if(s[i]=='R')
		r++;
	}
	if(s[1]=='R')
	cout<<r;
	else
	cout<<min(r,1);
	
}


Measured memory_bytes: 3648