akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <set>
#include <algorithm>
#include <unordered_map>
#include <queue>
#include <iomanip>
#include <map>
#include <utility>
#include <numeric>
#include <chrono>
#include <ctime>
#include <bitset>
#include <iterator>
#include <cmath>
#include <stack>
#include <random>

#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define debug(x) cerr << #x << ": " << x << ", "
#define debugln(x) cerr << #x << ": " << x << '\n'

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

using namespace std;
using ll = long long;
using P = pair<int, int>;

constexpr ll mod = 1e9+7;
const double PI = acos(-1.0);
mt19937_64 engine(chrono::steady_clock::now().time_since_epoch().count());

vector<bool> ok(10);
vector<string> dp(10010);
vector<int> cnt(10);

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

  int n, m; cin >> n >> m;
  rep(i, m) {
    int a; cin >> a;
    ok[a] = true;
  }

  cnt[1] = 2;
  cnt[2] = 5;
  cnt[3] = 5;
  cnt[4] = 4;
  cnt[5] = 5;
  cnt[6] = 6;
  cnt[7] = 3;
  cnt[8] = 7;
  cnt[9] = 6;
  
  for(int i=0; i<=n; i++) {
    int isize = dp[i].size();
    if (i != 0 && dp[i].size() == 0) continue;
    for(int j=1; j<=9; j++) {
      if (!ok[j]) continue;
      string now = dp[i];
      now.push_back('0'+j);
      if (now.size() > dp[i+cnt[j]].size() || now > dp[i+cnt[j]]) {
        dp[i+cnt[j]] = now;
      }
    }
  }
  string ans = dp[n];
  cout << ans << endl;
}


Measured memory_bytes: 43776
const [a, b, C] = require('fs').readFileSync('/dev/stdin', 'utf8').split(/\s/).map(Number);
let S = (a * b * Math.sin(C* (Math.PI / 180)) / 2).toFixed(8);
let L = (a + b + Math.sqrt(Math.pow(a, 2) + Math.pow(b, 2) - 2 * a * b * Math.cos(C * (Math.PI / 180)))).toFixed(8);
let h = (b * Math.sin(C* (Math.PI / 180))).toFixed(8);

console.log(S);
console.log(L);
console.log(h);


Measured memory_bytes: 15428
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

    void run() {
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int[] as = new int[n];
        Map<Integer, Integer> dm = new HashMap<>();

        for (int i = 0; i < n; i++) {
            as[i] = sc.nextInt();
            if (i % 2 == 0) {
                dm.put(as[i], dm.getOrDefault(as[i], 0) + 1);
            }
        }

        Arrays.sort(as);

        int cnt = 0;
        for (int i = 0; i < n; i += 2) {
            if (dm.containsKey(as[i]) && dm.get(as[i]) != 0) {
                dm.put(as[i], dm.get(as[i]) - 1);
            } else {
                cnt += 1;
            }
        }

        System.out.println(cnt);
    }

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


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

int main(){
  int n; cin>>n;
  string s; cin>>s;
  long long ans=1;
  vector<long long> num(26,1);
  for(int i=0;i<n;i++){
    num[s[i]-'a']++;
  }for(int i=0;i<26;i++){
    ans*=num[i];
    ans%=1000000007;
  }
  cout<<ans-1<<endl;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/





int N, Z, W, A[2010];
#define INF INT_MAX/2
//---------------------------------------------------------------------------------------------------
int memo[2010][2];
int f(int id, int turn, int x, int y) {
    if (id == N) return abs(x - y);

    if (0 <= memo[id][turn]) return memo[id][turn];

    if (turn == 0) {
        int ma = -1;
        rep(i, id, N) ma = max(ma, f(i + 1, 1 - turn, A[i], y));
        return memo[id][turn] = ma;
    } else {
        int mi = INF;
        rep(i, id, N) mi = min(mi, f(i + 1, 1 - turn, x, A[i]));
        return memo[id][turn] = mi;
    }
}
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> N >> Z >> W;
    rep(i, 0, N) cin >> A[i];

    rep(i, 0, N) rep(t, 0, 2) memo[i][t] = -1;
    cout << f(0, 0, Z, W) << endl;
}

Measured memory_bytes: 384
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
 
#include<bits/stdc++.h>
 
using namespace std;
#define ll long long
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define ins insert
#define ull unsigned long long
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define ff first
#define ss second
#define fast ios::sync_with_stdio(0) , cin.tie(0) , cout.tie(0); 
#define nl "\n"
#define sz(a) (int)(a).size() 
#define all(a) (a).begin(),(a).end()
#define fl(a,x) memset(a,x,sizeof(a));
#define pt(a,x) cout << get<x>(a) << " " ;  
#define mt make_tuple 
#define vec vector
 
#define int long long 
 
const int mod = (int) 1e9 + 7 ;
const int MOD = (int) 998244353 ;
const int INF = (int) 1e18 ;
 
typedef vector<int> vii;
typedef pair<int,int> pii;
typedef vector<pii> vpi;
typedef vector<vector<int> > vv;
 
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
 
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}

void solve(int test) {
	
	int x; cin >> x;
	int l = 360 * x / __gcd(360ll,x) ;
	cout << l/x ; 
}
 
int32_t main() {
 
 
    fast; 
	int t=1;
	// cin>>t;
	rep(i,0,t) {
		solve(i) ;
	}
 
	// cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
	return 0;
}

Measured memory_bytes: 3648
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<math.h>
using namespace std;
#define N (1000000000+7)
#define INF 1e16
typedef long long ll;
typedef pair<int,int> P;

 
int main(void){
    int n,k,s;
    cin>>n>>k>>s;
    vector<int>a(n);
    if(k == 0){
        if(s>100000){
            for(int i=0;i<n;i++)a[i]=1;
        }
        else{
            for(int i=0;i<n;i++)a[i]=s+1;
        }
    }
    else{
        if(s==1000000000){
            for(int i=0;i<n;i++){
                if(k>0)a[i]=s,k--;
                else a[i]=1;
            }
        }
        else{
            for(int i=0;i<n;i++){
                if(k>0)a[i]=s,k--;
                else a[i]=s+1;
            }
        }
    }
    for(int i=0;i<n;i++){
        if(i==n-1)cout<<a[i]<<endl;
        else cout<<a[i]<<" ";
    }
    return 0;
}

Measured memory_bytes: 1664
#include<bits/stdc++.h>
using namespace std;
#define rg register
#define ll long long 
inline ll read()
{
    ll x=0,f=1;
    char c=getchar();
    while(c<'0'||c>'9')
    {
        if(c=='-')
        {
            f=-1;
        }
        c=getchar();
    }
    while(c<='9'&&c>='0')
    {
        x=(x<<1)+(x<<3)+(c^48);
        c=getchar();
    }
    return x*f;
}
int n;
ll a[233333];
deque<ll> q;
int main()
{
	n=read();
	for(rg int i=1;i<=n;++i)
	{
		a[i]=read();
		q.push_back(a[i]);
	}
	q.push_back(a[n]);
	int tot=0;
	int flag=0;
	bool flag1=0;
	while(q.size()!=0)
	{
//		cout<<tot<<" "<<q.size()<<endl;
		int top=q.front();
		q.pop_front();
		if(top==q.front())
		{
			continue;
		}
		int top2=q.front();
		if(top<top2&&flag==0)//单增 
		{
			tot++;
			flag=1;
			continue;
		}
		else if(top>top2&&flag==0)
		{
			tot++;
			flag=2;
			continue;
		}
		else if(top>top2&&flag==1)
		{
		
			flag=0;
			continue;
		}
		else if(top<top2&&flag==2)
		{
	
			flag=0;
			continue;
		}
	}
//	a[n+1]=a[n];
//	for(rg int i=1;i<=n;++i)
//	{
//		if(a[i]==a[i+1])
//		{
//			continue;
//		}
//		if(a[i]<a[i+1]&&flag1==0)
//		{
//			flag1=1;
//			flag=1;//1--单增 2--单减 
//			tot++;
//		}
//		else if(a[i]>a[i+1]&&flag1==0)
//		{
//			flag1=1;
//			flag=2;
//			tot++;
//		}
//		else if(a[i]<a[i+1]&&flag1==1&&flag==2)//现在为单增却标记为单减 
//		{
//			tot++;
//			flag1=0;
//			flag=1;
//			++i;
//		}
//		else if(a[i]>a[i+1]&&flag1==1&&flag==1)//现在为单减却标记为单增 
//		{
//			tot++;
//			flag=2;
//			flag1=0;
//			++i;
//		}
////		cout<<"i="<<i<<" "<<tot<<" "<<flag<<endl;
//	}
	cout<<tot;
}

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

const int MaxN = 100000;
int S[ MaxN + 10 ];

int main()
{
int i;
int N;
int M;
long long A;
long long x;
long long iCnt;
int iSum;

	scanf( "%d %d", &N, &M );

	iSum = 0;
	iCnt = 0;
	for( i = 1; i <= N; i++ )
	{
		scanf( "%lld", &A );

		iSum += A;
		iSum %= M;
		S[ i ] = iSum;
	}

	sort( S, S + ( N + 1 ) );

	x = 0;
	for( i = 1; i <= N; i++ )
	{
		if( S[ i - 1 ] == S[ i ] )
			x++;
		else
		{
			iCnt += ( x + 1 ) * x / 2;
			x = 0;
		}
	}

	if( x > 0 ) iCnt += ( x + 1 ) * x / 2;

	printf( "%lld\n", iCnt );

	return 0;
}


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

const int MAX = 1000000007;
 
 


 stack<int> evenp,oddp;
    stack<pair<int,int>> rin;
signed main(){
    int n;
    cin>>n;
    int p[n];
    for(int i=0;i<n;i++)cin>>p[i];
    vector<pair<int,int>> vec[n+1];
    
    oddp.push(0);
    for(int i=0;i<n;i++){
        if(i%2==0){
            while(!evenp.empty()&&(evenp.top()>p[i])){
                rin.push(make_pair(evenp.top(),oddp.top()));
                evenp.pop();
                oddp.pop();
            }
            while(!rin.empty()){
                vec[oddp.top()].push_back(rin.top());
                rin.pop();
            }
            evenp.push(p[i]);
        }else{
            while(oddp.top()>p[i]){
                rin.push(make_pair(oddp.top(),evenp.top()));
                oddp.pop();
                evenp.pop();
            }
            while(!rin.empty()){
                vec[evenp.top()].push_back(rin.top());
                rin.pop();
            }
            oddp.push(p[i]);
        }
    }
    while(!evenp.empty()){
                rin.push(make_pair(evenp.top(),oddp.top()));
                evenp.pop();
                oddp.pop();
            }
            while(!rin.empty()){
                vec[oddp.top()].push_back(rin.top());
                rin.pop();
            }
          

    priority_queue<pair<int,int>, vector<pair<int,int>>, greater<pair<int,int>> > ans;
    queue<pair<int,int>> tame;
    pair<int,int> w;
    for(int i=0;i<vec[0].size();i++){
        tame.push(vec[0][i]);
        while(!tame.empty()){
            w=tame.front();
            tame.pop();
            ans.push(w);
            for(int j=0;vec[w.second].size()>j;j++)tame.push(vec[w.second][j]);
         }
        }
       
         
    pair<int,int> tans;
    while(!ans.empty()){
        tans=ans.top();
        ans.pop();
        cout<<tans.first<<' '<<tans.second<<' ';
        for(int i=0;i<vec[tans.first].size();i++){
            tame.push(vec[tans.first][i]);
            while(!tame.empty()){
            w=tame.front();
            tame.pop();
            ans.push(w);
            for(int j=0;vec[w.second].size()>j;j++)tame.push(vec[w.second][j]);
         }
        }
    }
    
    return 0;
}

Measured memory_bytes: 13552
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <stack>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>

#define REP(i,n) for(int i=0;i<n;++i)
#define REPR(i,n) for(int i=n;i>=0;--i)
#define REPI(itr,v) for(auto itr=v.begin();itr!=v.end();++itr)
#define REPIR(itr,v) for(auto itr=v.rbegin();itr!=v.rend();++itr)
#define FOR(i,a,b) for(int i=a;i<b;++i)
#define SORT(v,n) sort(v, v+n)
#define SORTV(v) sort(v.begin(), v.end())
#define ALL(v) v.begin(),v.end()
#define llong long long
#define INF 999999999
#define SUR 1000000007
#define pb push_back
#define pf push_front
#define MP make_pair

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

using namespace std;

typedef pair<int,int> pii;

int main(){

  const int N = 1001;
  
  llong table[N] = {};
  FOR(i,1,N){
    table[i] = table[i - 1] + i;
  }

  while(true){
    int n;
    scanf("%d", &n);

    if(n == 0){
      break;
    }

    llong ans = 0;
    FOR(i,1,N){
      for(int j = 1; j < i; j++){
        if(n == table[i] - table[j - 1]){
          ans++;
          //cout << table[j] << " " << table[i] << endl;
        }
      }
    }

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




Measured memory_bytes: 3168
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees#, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7
#from decimal import *

N = INT()

print(-(-N//2)-1)




Measured memory_bytes: 5144
import java.util.Arrays;
import java.util.LinkedList;
import java.util.Scanner;
public class Main
{
	public static void main(String[] args) 
	{
		Scanner in=new Scanner(System.in);
		int dx[]={1,0,-1,0};
		int dy[]={0,1,0,-1};
		for(;;)
		{
			int W=in.nextInt();
			int H=in.nextInt();
			if((H|W)==0)
				return;
			int sh=0,sw=0;
			int cost[][]=new int[H][W];
			char map[][]=new char[H][W];
			LinkedList<String>que=new LinkedList<String>();
			for(int p[]: cost)
				Arrays.fill(p, 100);
			for(int i=0;i<H;i++)
			{
				String st=in.next();
				for(int j=0;j<W;j++)
				{
					map[i][j]=st.charAt(j);
					if(map[i][j]=='&')
					{
						sh=i;
						sw=j;
					}
				}
			}
			cost[sh][sw]=0;
			que.add(sh+" "+sw);
			while(!que.isEmpty())
			{
				int size=que.size();
				for(int i=0;i<size;i++)
				{
					String now[]=que.poll().split(" ");
					int nh=Integer.valueOf(now[0]);
					int nw=Integer.valueOf(now[1]);
					for(int j=0;j<4;j++)
					{
						int h=dy[j]+nh;
						int w=dx[j]+nw;
						if(h>=0&&h<H&&w>=0&&w<W)
						{
							if((map[nh][nw]=='#'||map[h][w]=='.')&&cost[nh][nw]<cost[h][w])
							{
								cost[h][w]=cost[nh][nw];
								que.add(h+" "+w);
							}
							else if(map[nh][nw]!='#'&&map[h][w]=='#'&&cost[nh][nw]+1<cost[h][w])
							{
								cost[h][w]=cost[nh][nw]+1;
								que.add(h+" "+w);
							}
						}
					}
				}
			}
			int ans=100;
			for(int i=0;i<H;i++)
			{
				for(int j=0;j<W;j++)
				{
					if(i<1||i>H-2||j<1||j>W-2)
						ans=Math.min(ans, cost[i][j]);
				}
			}
			System.out.println(ans);
		}
	}
}

Measured memory_bytes: 133632
mod = 10**9 + 7
H,W = map(int,input().split())
A = [list( input()) for i in range(H)]
dp = [ [0 for _ in range(W)] for _ in range(H)]
for i in range(H):
    for j in range(W):
        if i == 0 and j == 0:
            dp[0][0] = 1
            continue
        if A[i][j] == ".":
            dp[i][j] = dp[i-1][j] + dp[i][j-1] 
print(dp[-1][-1]%mod)


Measured memory_bytes: 248796
#include <iostream>
using namespace std;
int main(){

  int n,m,d,s,v,day[360]={};
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>m>>d>>v>>s;
    int d1=(m-1)*30+d-1;
    for(int j=0;j<v;j++){
      int tmp=(d1+j)%360;
      day[tmp]=max(day[tmp],s);
    }
    for(int j=0;j<s;j++){
      int tmp1=d1-j;
      while(tmp1<0) tmp1+=360;
      day[tmp1]=max(day[tmp1],s-j);
      int tmp2=d1+v+j;
      tmp2%=360;
      day[tmp2]=max(day[tmp2],s-j-1);
    }
  }
  int md=1001;
  for(int i=0;i<360;i++) md=min(md,day[i]);
  cout<<md<<endl;
  // for(int i=0;i<360;i++) if(day[i]==md) cout<<i/30+1<<" "<<i%30+1<<endl;

  return 0;

}

Measured memory_bytes: 3096
/*input
3 5
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define pb push_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
	out<<'('<<P.F<<','<<P.S<<')';
	return out;
}

//}}}
const ll maxn=300005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const double PI=acos(-1);
//const ll p=880301;
//const ll P=31;

ll mypow(ll a,ll b){
	ll res=1LL;
	while(b){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		
		b>>=1;
	}
	return res;
}

int main()
{
	IOS;
	int a,b;
	cin>>a>>b;
	cout<<max({a+a-1,b+b-1,a+b});
	return 0;
}



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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
//const ull mod = 1e9 + 7;
const ll mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

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

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

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

    ll N, K, S;
    cin >> N >> K >> S;

    const ll ma = 1e9;

    vector<ll> C(N, 0);
    if(S != ma){
	    REP(i, N){
	    	if(i<K) C[i] = S;
	    	else C[i] = ma;
	    }
	}else{
		REP(i, N){
	    	if(i<K) C[i] = ma;
	    	else C[i] = 1;
	    }
	}
	REP(i, N){
		cout << C[i] << " ";
	}
	cout << endl;
    return 0;
}

Measured memory_bytes: 2176
//#include<bits/stdc++.h>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<stdlib.h>
#include<queue>
#include<map>
#include<vector>
#include<cmath>
#include<fstream>
#include <set>
//freopen(".in","r",stdin);
//freopen(".out","w",stdout);
//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);
const int  MAXN =2e5+10;
const int mod = 1e9 + 7;
const long long INF = 0x7f7f7f7f7f7f7f7f;
const int inf= 0x3f3f3f3f;
#define eps 1e-8
#define PI 3.1415926535898
#define lowbit(x) (x&(-x))
using namespace std ;
//getline(cin,s);
//set<ll>::iterator it;
//map<int,int>::iterator it;
typedef long long ll;
int n;
ll a[MAXN];
int main()
{
	ll ans=0,max1=0;
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%lld",&a[i]);
	max1=a[1];
	for(int i=2;i<=n;i++)
	{
		if(a[i]<max1)
		{
			ans+=(max1-a[i]);
		}
		else
		{
			max1=max(max1,a[i]);
		}
	}
	printf("%lld\n",ans);
}

Measured memory_bytes: 5228
#include <iostream>
#include<math.h>
#include<cstdio>
using namespace std;
  
int main(){
    double x1,x2,x3,y1,y2,y3,trgr,trgx,trgy,A1,B1,C1,A2,B2,C2;
    int i,n;
    cin>>n;
    for(i=0;i<n;i++){
    cin>>x1>>y1>>x2>>y2>>x3>>y3;
    A1=2*(x2-x1);
    B1=2*(y2-y1);
    C1=x1*x1-x2*x2+y1*y1-y2*y2;
    A2=2*(x3-x1);
    B2=2*(y3-y1);
    C2=x1*x1-x3*x3+y1*y1-y3*y3;
     
    trgx=(B1*C2-B2*C1)/(A1*B2-A2*B1);
    trgy=(C1*A2-C2*A1)/(A1*B2-A2*B1);
    trgr=sqrt((trgx-x1)*(trgx-x1)+(trgy-y1)*(trgy-y1));
        printf("%.3lf %.3lf %.3lf\n",trgx,trgy,trgr);
    }
    return 0;
}
 

Measured memory_bytes: 1244
package main

import "fmt"

func main() {
	for {
		var h, w int
		fmt.Scan(&h)
		fmt.Scan(&w)

		if h == 0 && w == 0 {
			break
		}

		for i := 0; i < h; i++ {
			for j := 0; j < w; j++ {
				fmt.Print("#")
			}
			fmt.Print("\n")
		}
		fmt.Print("\n")
	}
}

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

#define ll long long

int main(void) 
{
	int x, y;
	cin >> x >> y;
	if(y >= 2*x && y <= 4*x) {
		if(y % 2 == 0) cout << "Yes\n";
		else cout << "No\n";
	} else {
		cout << "No\n";
	}
	return 0;
}


Measured memory_bytes: 3640
#include <iostream>
#include <utility>
#include <stdint.h>
#include <vector>

using namespace std;

int main()
{
  int N;
  cin >> N;
  int X[15][15];

  for (int ii=0; ii<15; ++ii)
    for (int jj=0; jj<15; ++jj)
      X[ii][jj] = 9;

  for (int n=0; n<N; ++n) {
    int A;
    cin >> A;
    for (int a=0; a<A; ++a) {
      int x, y;
      cin >> x >> y;
      X[n][--x] = y==1 ? 1 : 0;
    }
  }

  int max_count = 0;
  
  for (int pattern = (1<<N)-1; pattern>=0; --pattern) {
    int pattern_for_count = pattern;
    int bit_count = 0;
    while(pattern_for_count) {
      bit_count += (pattern_for_count&1);
      pattern_for_count >>= 1;
    }
    if (max_count >= bit_count)
      continue;
    
    bool flag = true;
    for (int n=0; n<N && flag; ++n) {
      if (!(pattern & (1<<n)))
	continue;
      for (int x=0; x<N && flag; ++x) {
	if (x==n)
	  continue;
	int x_state = (pattern&(1<<x));
	if (X[n][x]==0 && x_state)
	  flag = false;
	else if (X[n][x]==1 && !x_state)
	  flag = false;
      }
    }
    if (!flag)
      continue;
      
    max_count = bit_count;
  }

  cout << max_count << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
signed main()
{
    ios::sync_with_stdio(0);
	int n,RE=0,AC=0,TLE=0,WA=0;
	string s;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>s;
		if(s=="RE")RE++;
		else if(s=="AC")AC++;
		else if(s=="TLE")TLE++;
		else if(s=="WA")WA++;
	}
	cout<<"AC x "<<AC<<endl;
	cout<<"WA x "<<WA<<endl;
	cout<<"TLE x "<<TLE<<endl;
	cout<<"RE x "<<RE<<endl;
    return 0;
}


Measured memory_bytes: 3656
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String boardStr = null;
		while((boardStr = br.readLine()) != null){
			System.out.println(judgeWinner(boardStr));
		}
	}

	public static final char CIRCLE = 'o';
	public static final char CROSS = 'x';
	public static final char DRAW = 'd';	
	public static char judgeWinner(String boardStr){
		char[][] board = createBoard(boardStr);
		if(judgeWin(board, CIRCLE))	return CIRCLE;
		if(judgeWin(board,CROSS))	return CROSS;
		return DRAW;
	}
	
	private static final int WIN = 3;
	private static boolean judgeWin(char[][] board, char player){
		int count = 0;
		//横
		for(int i = 0; i < board.length; i++){
			count = 0;
			for(int j = 0; j < board[0].length; j++){
				if(board[i][j] == player)	count++;
			}
			if(count == WIN)	return true;
		}
		//縦
		for(int j = 0; j < board[0].length; j++){
			count = 0;
			for(int i = 0; i < board.length; i++){
				if(board[i][j] == player)	count++;
			}
			if(count == WIN)	return true;
		}
		//斜め
		count = 0;
		for(int i = 0; i < board.length; i++){
			if(board[i][i] == player)	count++; 
		}
		if(count == WIN)	return true;

		count = 0;
		if(board[2][0] == player)	count++; 
		if(board[1][1] == player)	count++; 
		if(board[0][2] == player)	count++; 
		if(count == WIN)	return true;
		return false;
	}
	
	private static char[][] createBoard(String boardStr){
		char[][] board = new char[3][3];
		String line = null;
		for(int i = 0; i < 3; i++){
			line = boardStr.substring(i * 3, i * 3 + 3);
			board[i] = line.toCharArray();
		}
		return board;
	}
}

Measured memory_bytes: 17032
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {

	private static final String RIGHT_TRIANGLE = "YES";
	private static final String NOT_RIGHT_TRIANGLE = "NO";

	/**
	 * <p>
	 * 与えられた三辺で直角三角形が作れるかを判定する。
	 * </p>
	 *
	 * @param args
	 *            利用しない。
	 * @throws IOException
	 */
	public static void main(String[] args) throws NumberFormatException,
			IOException {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int lineCount = Integer.parseInt(br.readLine());
		for (int i = 0; i < lineCount; i++) {

			String[] input = br.readLine().split(" ");
			int[] side = { Integer.parseInt(input[0]),
					Integer.parseInt(input[1]), Integer.parseInt(input[2])};
			Arrays.sort(side);

			if (isRightTriangle(side[2], side[0], side[1])) {
				System.out.println(RIGHT_TRIANGLE);
			} else {
				System.out.println(NOT_RIGHT_TRIANGLE);
			}
		}
	}

	/**
	 * 三辺の長さから、直角三角形であるかどうかを判定する。<br>
	 * 注意：第一引数に最も長い辺を与えること。
	 *
	 * @param side1 辺1
	 * @param side2 辺2
	 * @param side3 辺3
	 * @return 直角三角形であるかどうか
	 */
	private static boolean isRightTriangle(int side1, int side2, int side3) {
		return (side1 * side1 == side2 * side2 + side3 * side3);
	}
}

Measured memory_bytes: 20392
//hinagata.cpp
/*includes*/
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <stdio.h>
#include <numeric>
#include <iomanip>
#include <limits>
/*namespace*/
using namespace std;
using ll= long long;
/*define macro*/
#define REP(i,n) for(int i=0;i<(n);i++)
#define REPi(i,a,b) for(int i=(a);i<(b);i++)
#define REPRi(i,a,b) for(int i=(a);i>(b);i--)
#define ALL(x) (x).begin(),(x).end()

int main(){
    int N,K;
    cin>>N>>K;
    vector<int> H(N);
    REP(i,N){
        cin>>H[i];
    }
    sort(ALL(H));
    int ans=1e9;
    REP(i,N+1-K){
        ans=min(ans,H[i+K-1]-H[i]);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 640
sa=list(input())
sb=list(input())
sc=list(input())
cnt=sa[0]
sa.remove(sa[0])
while len(sa)!=0 or len(sb)!=0 or len(sc)!=0:
    #print(sa,sb,sc)
    if cnt=='a':
        if sa!=[]:
            cnt=sa[0]
            sa.remove(sa[0])
    elif cnt=='b':
        if sb!=[]:
            cnt=sb[0]
            sb.remove(sb[0])
    elif cnt=='c':
        if sc!=[]:
            cnt=sc[0]
            sc.remove(sc[0])
    if len(sa)==0 and cnt=='a':
        print("A")
        break
    elif len(sb)==0 and cnt=='b':
        print("B")
        break
    elif len(sc)==0 and cnt=='c':
        print("C")
        break


Measured memory_bytes: 3064
#include <bits/stdc++.h>
 
#define loop(n, i) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define HERE cout << "HERE: " << __LINE__ << endl;
#define INSP(v) cout << v << " at " << __LINE__ << endl;

using namespace std;
typedef long long ll;
typedef tuple<int, int, int> T;

int main()
{
    while (1) {
        int n, l; cin >> n >> l;
        if (!n) break;

        vector<T> crr;
        loop (n, i) {
            char d; int p; cin >> d >> p;
            int id = d == 'L' ? -1 : 1;
            crr.emplace_back(p, i, id);
        }
        sort(all(crr));

        int time = 0;
        while (1) {
            if (crr.size() <= 2) {
                int ok = 1;
                for (T a : crr) {
                    int p = get<0>(a);
                    ok = ok && (p == 0 || p == l);
                }
                if (ok) {
                    cout << time << " " << get<1>(crr[0])+1 << endl;
                    break;
                }
            }
            vector<T> next;
            for (T a : crr) {
                int p = get<0>(a), id = get<1>(a), d = get<2>(a);
                if (p+d >= 0 && p+d <= l) {
                    next.emplace_back(p+d, id, d);
                }
            }
            sort(all(next));
            loop (next.size()-1, i) {
                if (get<0>(next[i]) == get<0>(next[i+1])) {
                    next[i] = T{
                        get<0>(next[i]),
                        get<1>(next[i]),
                        -get<2>(next[i])
                    };
                    next[i+1] = T{
                        get<0>(next[i+1]),
                        get<1>(next[i+1]),
                        -get<2>(next[i+1])
                    };
                }
            }
            crr = next;
            time++;
        }
    }
    return 0;
}

Measured memory_bytes: 3024
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int  n = sc.nextInt();
        String s = sc.next().toLowerCase();
        if(n>=3200)System.out.println(s);
        if(n<3200)System.out.println("red");
    }
}


Measured memory_bytes: 20820
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
bool isACGT(char C){
	return C=='A'||C=='C'||C=='G'||C=='T';
}
int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
	string S;
	cin >> S;
	int ans = 0;
	for (int i = 0; i < S.length(); i++)
	{
		if(!isACGT(S[i]))continue;
		int tmp = 1;
		for (int j = i+1; j < S.length(); j++)
		{
			if(isACGT(S[j]))tmp++;
			else break;
		}
		if(tmp>ans)ans=tmp;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
import scala.math._

object Main extends App {
  val sc = new java.util.Scanner(System.in)
//  val list = List.fill(3)(sc.nextInt)
  val n = sc.next

  val ans = if (n.contains('9')) "Yes" else "No"

  println(ans)

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

  def bigIterator(start: BigInt, end: BigInt, step: BigInt = 1) =
    Iterator.iterate(start)(_ + step).takeWhile(_ <= end)

  def lcm(a :Int, b :Int): Int =
    a / gcd(a, b) * b

  def lcm(a :Long, b :Long): Long =
    a / gcd(a, b) * b

  def gcd(a: Int, b: Int): Int =
    if (b == 0) a else gcd(b, a % b)

  def gcd(a: Long, b: Long): Long =
    if (b == 0) a else gcd(b, a % b)

  def setOrUpdated[A, B](a: Map[A, B], key: A, value: B, f: (B, B) => B) =
    a.get(key) match {
      case Some(v) => a.updated(key, f(value, v))
      case _ => a + (key -> value)
    }
}

Measured memory_bytes: 25672
#include <bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
#define INF 1e18

using namespace std;

int main(void){
  ll n, k;
  cin >> n >> k;
  
  vector<ll> a(n);
  for (int i = 0; i < n; i++){
    cin >> a[i];
  }


  ll res = 0;

  vector<ll> s(n + 1, 0);
  for (int i = 0; i < n; i++){
    s[i + 1] = s[i] + (a[i] > 0 ? a[i] : 0);
  }

  ll u = 0;
  for (int i = 0; i < k; i++){
    u += a[i];
  }

  ll v = s[0], w = s[n] - s[k];
  res = max(res, max(v + w, v + w + u));
  for (int i = 1; i < n - k + 1; i++){
    u += a[i + k - 1] - a[i-1];
    ll v = s[i];
    ll w = s[n] - s[i + k];
    res = max(res, max(v + w + u, v + w));
  }

  cout << res << endl;

  return 0;
}


Measured memory_bytes: 1792
n = int(input())
v = list(map(int, input().split()))

s = [[],[]]
for i in range(n):
    s[i % 2].append(v[i])

t = []
t.append(list(set(s[0])))
t.append(list(set(s[1])))

#print(s, t)

t_dict = [{}, {}]

for j in range(2):
    for i in range(len(t[j])):
        t_dict[j][t[j][i]] = 0

for j in range(2):
    for i in range(len(s[j])):
        t_dict[j][s[j][i]] += 1

for j in range(2):
    t_dict[j] = list(reversed(sorted(t_dict[j].items(), key=lambda x:x[1])))

#print(t_dict)
if t_dict[0][0] != t_dict[1][0]:
    print( len(s[0]) - t_dict[0][0][1] + len(s[1]) - t_dict[1][0][1])
elif len(t[0]) == 1 and len(t[1]) == 1:
    print(n // 2)
elif len(t[1]) == 1:
    print(1)
else:
    print(len(s[0]) + len(s[1]) - t_dict[0][0][1] - max(t_dict[0][1][1], t_dict[1][1][1]))

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

typedef long long ll;
typedef pair<int,int> pii;

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

const int MAX = 1e5+9;
const ll MOD = 1e9+7;

ll x[MAX], v[MAX];
ll d1[MAX], d2[MAX];

int main () {
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	int n; ll c;
	cin >> n >> c;
	for (int i = 0; i < n; i++)
		cin >> x[i] >> v[i];
	ll sum = 0;
	for (int i = 0; i < n; i++) {
		sum += v[i];
		if (i == 0)
			d1[i] = max(sum - x[i], (ll)0);
		else
			d1[i] = max(d1[i-1], sum - x[i]);
	}
	sum = 0;
	for (int i = n-1; i >= 0; i--) {
		sum += v[i];
		if (i == n-1)
			d2[i] = max(sum - (c-x[i]), (ll)0);
		else
			d2[i] = max(d2[i+1], sum - (c-x[i]));
	}
	ll res = 0;
	sum = 0;
	for (int i = 0; i < n; i++) {
		sum += v[i];
		res = max(res, sum - 2*x[i] + d2[i+1]);
		res = max(res, sum - x[i]);
	}
	sum = 0;
	for (int i = n-1; i >= 0; i--) {
		sum += v[i];
		res = max(res, sum - 2*(c-x[i]) + ((i) ? d1[i-1] : 0));
		res = max(res, sum - (c-x[i]));
	}
	cout << res << "\n";
}

Measured memory_bytes: 3328
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <vector>
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long int
#define MAX 1000000007
using namespace std;

int main(void){
  string a,b,c;
  cin >> a >> b >> c;
  cout << a[0] << b[1] << c[2] << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,x,n) for(int i=x;i<n;i++)
#define mod 1000000007 //10^9+7
#define INF 1000000000000 //10^12
#define F first
#define S second
#define P pair<int,int>
#define all(vec) vec.begin(),vec.end()
//library begin
int gcd(int a,int b){
    if(a%b==0)return b;
    return gcd(b,a%b);
}
int lcm(int a,int b){
    return a*b/gcd(a,b);
}
int log(int a){
    int b=a;
    int cnt=0;
    while(b%2==0){
        b/=2;
        cnt++;
    }
    return cnt;
}
int mypow(int a,int b){
    if(b==0)return 1;
    if(b==1)return a;
    int t=mypow(a,b/2);
    if(b%2==0)return t*t;
    return t*t*a;
}
//Union-Find;
#define MAX_N 200000
int par[MAX_N];
int siz[MAX_N];
int Rank[MAX_N];
void init(int n){
    rep(i,n){
        par[i]=i;
        siz[i]=1;
        Rank[i]=0;
    }
}
int find(int x){
    if(par[x]==x){
        return x;
    }else{
        return par[x]=find(par[x]);
    }
}
void unite(int x,int y){
    x=find(x);
    y=find(y);
    if(x==y)return;
    if(Rank[x]<Rank[y]){
        par[x]=y;
        siz[par[x]]=siz[x]+siz[y];
    }else{
        par[y]=x;
        siz[par[y]]=siz[x]+siz[y];
        if(Rank[x]==Rank[y])Rank[x]++;
    }
}
bool same(int x,int y){
    return find(x)==find(y);
}

//library end
int n;
int a[114];
bool ans=true;
signed main(){
    cin>>n;
    rep(i,n){
        cin>>a[i];
        if(a[i]%2==0){
            if(a[i]%3&&a[i]%5)ans=false;
        }
    }
    if(ans)puts("APPROVED");
    else puts("DENIED");
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <vector>

using namespace std;

typedef long long ll;

void solve() {
  int n, h, w;
  cin >> n >> h >> w;
  cout << (n+1-h) * (n+1-w) << endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
  solve();
  /*
  int t;
  cin >> t;
  for(int i = 1; i <= t; i++) {
    cout << "Case #" << i << ": ";
    solve();
  }
  */
}


Measured memory_bytes: 256
import sys
import math
from collections import deque
from collections import defaultdict

def main():
    n = int(sys.stdin.readline())
    n = n % 10
    hon = [2, 4, 5, 7, 9]
    pon = [0, 1, 6, 8]
    
    if n == 3:
        print("bon")
        return 0
    if n in hon:
        print("hon")
        return 0
    if n in pon:
        print("pon")
        return 0
    return 0

if __name__ == "__main__":
    main()

Measured memory_bytes: 9480
# AFTER EDITORIAL


def solve(ls):
    n = len(ls)
    num_w = len([x for x in ls if x == "W"])
    num_r = n - num_w
    left_w = 0
    right_r = num_r
    result = num_r
    for i in range(n):
        if ls[i] == 'W':
            left_w += 1
        else:
            right_r -= 1
        result = min(result, max(left_w, right_r))
    return result


def main(istr, ostr):
    (n,) = list(map(int, istr.readline().strip().split()))
    s = istr.readline().strip()
    result = solve(s)
    print(result, file=ostr)


if __name__ == "__main__":
    import sys

    main(sys.stdin, sys.stdout)


Measured memory_bytes: 10744
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;

int main() {

	int a, b; cin >> a >> b;
	if (a + b == 15)cout << "+" << endl;
	else if (a*b == 15)cout << "*" << endl;
	else cout << "x" << endl;
	return 0;
}

Measured memory_bytes: 764
function K_kuri(N,P,M)
    ( P ≤ 0 )  && return 1
    ( P%2==0 ) && return K_kuri(N,P÷2,M)^2 % M
    N*K_kuri(N,P-1,M) % M
end

function CmbMod(a,b,M)
    A=B=1
    for i in 1:b
        A*=(a-i+1)%M
        B*=K_kuri(i,M-2,M)
        A%=M
        B%=M
    end
    A*B%M
end

input=split(readline())
MOD=10^9+7
N,a,b=map(x->parse(Int,x),input)

print((K_kuri(2,N,MOD)-1-CmbMod(N,a,MOD)-CmbMod(N,b,MOD)+3MOD)%MOD)


Measured memory_bytes: 112924
/////////////////////////////////TEST CASES////////////////////////////////////
/*

*/
/////////////////////////////////////CODE/////////////////////////////////////
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define FORD(i, a, b) for (ll i = a ; i > b ; i--)
#define fastio ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define PI 3.14159265
typedef long long ll;
#define VL vector<ll> 
#define IN(inp) ll inp;cin>>inp;
#define pb push_back
#define all(a) a.begin(),a.end()
#define what(A) cout<<#A<<" is "<<A<<endl;
ll MAX = 1000000000;
ll MOD = 1000000007;
int main()
{
	fastio
	//freopen("input.txt", "rt", stdin);
	//freopen("output.txt", "wt", stdout);
	ll test = 1;
	//cin>>test;
	while (test--)
	{
		IN(n);
        string s;
        cin>>s;
        ll r=0,w=0;
        FOR(i,0,n)
        {
            if(s[i]=='R')
                r++;
            else
                w++;
        }
        ll ans=0;
        FOR(i,0,r)
        {
            if(s[i]=='W')
        		ans++;
        }
        cout<<ans;
	}
}

Measured memory_bytes: 3768
#include <cstdio>
#include <string>
#include <cmath>
#include <string>
#include <algorithm>
#include <iostream>
#include <map>
#include <vector>
#include <iomanip>
#include <tuple>
#include <queue>
#include <numeric>
using namespace std;
typedef long long ll;
#define rep(i, a, n) for (int i=a;i<n;++i)
#define repeq(i, a, n) for(int i=a;i<=n;++i)
#define repi(m, itr) for (auto itr = m.begin();itr != m.end();++itr)
#define per(i, a, n) for (int i=n-1; i>=a;--i)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
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; }


// D - Knapsack 1
ll N, W;
ll w[110];
ll v[110];
ll ans = 0;
ll dp[110][120000];

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

    dp[0][0] = 0;
    rep(i, 0, N){
        repeq(j, 0, W){
            if(j>=w[i]){
                chmax(dp[i+1][j], dp[i][j-w[i]] + v[i]);
            }
            chmax(dp[i+1][j], dp[i][j]);
        }
    }

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




Measured memory_bytes: 95360
#include<stdio.h>
#include<string.h>
typedef struct{char c;int n;} card;
card B[36],S[36];
int bubble(card A[36],int N)
{
    int i,j,c=0;
    card stock;
    for(i=0;i<N;i++){
        for(j=N-1;j>0;j--){
            if(A[j].n<A[j-1].n)
            {
                stock=A[j];
                A[j]=A[j-1];
                A[j-1]=stock;
                c++;
            }       
        }
    }
    return c;
}
int selection(card A[36],int N)
{
    int i,j,d,minj,c=0;
    card stock;
    for(i=0;i<N;i++)
    {
        minj=i;
        for(d=0,j=i;j<N;j++)
        {
            if(A[j].n<A[minj].n){minj=j;d=1;}
        }
        stock=A[i];
        A[i]=A[minj];
        A[minj]=stock;
        if(d)c++;
    }
    return c;
}
int main(void)
{
    int n,i,j;
    scanf("%d",&n);
    for(i=0;i<n;i++){
      scanf(" %c%d",&B[i].c,&B[i].n);
    }
    memcpy(S,B,sizeof(B));
    bubble(B,n);
    selection(S,n);
    for(i=0;i<n;i++)
    {
        printf("%c%d",B[i].c,B[i].n);
        if(i<n-1){
	  printf(" ");
	}
        else{
	  printf("\n");
	}
    }
    printf("Stable\n");
    for(i=0;i<n;i++)
    {
        printf("%c%d",S[i].c,S[i].n);
        if(i<n-1){
	  printf(" ");
	}
        else{
	  printf("\n");
	}
    }
    if(!memcmp(B,S,sizeof(B))){
      printf("Stable\n");
    }
    else{
      printf("Not stable\n");
    }
 
    return 0;
}

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

int main(){
    int n;
    cin >> n;
    vector<int> a;
    for(int i=0; i<n; i++){
        int aa;
        cin >> aa;
        a.push_back(aa);
    }
    int m;
    cin >> m;
    vector<int> b;
    for(int i=0; i<m; i++){
        int bb;
        cin >> bb;
        b.push_back(bb);
    }

    vector<int> result;
    // a - bの差集合を作る->O(N+M)
    set_difference(begin(a), end(a), begin(b), end(b), inserter(result, end(result)));

    for(int i=0; i<result.size(); i++){
        cout << result[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 5904
judgeString :: Ord a => a -> a -> String
judgeString a b | a > b = "a > b"
                | a < b = "a < b"
                | otherwise = "a == b"

main :: IO ()
main = do input <- getLine
          let a : b : _ = map read $ words input :: [Int]
          putStrLn $ judgeString a b

Measured memory_bytes: 3600
import java.util.*;

/*
問題文
高橋君は九九を覚えたので、1 以上 9 以下の 2 つの整数の積を計算することができます。

整数 N が与えられるので、N を 1 以上 9 以下の2 つの整数の積として表すことができるか
判定し、できるなら Yes を、できないなら No を出力して下さい。

制約
1≤N≤100
N は整数である。

*/

public class Main {
    public static void main(String[] args){

        Scanner s = new Scanner(System.in);
        int n = s.nextInt();
        
        int check[] = {2, 3, 4, 5, 6, 7, 8, 9};
        
        String ans = "No";

        if (n >= 10) {
          for (int i = 0; i < check.length; i++) {
            if (n % check[i] == 0 && n / check[i] < 10) {
              ans = "Yes";
              break;
            }
          }
        } else {
          ans = "Yes";
        }
        System.out.println(ans);
    }
}

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

#define ll long long

ll f(ll h) {
	if (h == 1) return 1;
	return 2 * f(h / 2) + 1;
}

int main() {
	ll h; scanf("%lld", &h);
	printf("%lld\n", f(h));
	return 0;
}

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

#define int long long

using namespace std;

const int mod = 1e9+7;

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    int x[n];
    int y[m];
    int xmin = 1e9;
    int xmax = -1e9;
    int ymin = 1e9;
    int ymax = -1e9;
    for (int i = 0; i < n; i++) {
        cin >> x[i];
        xmin = min(xmin, x[i]);
        xmax = max(xmax, x[i]);
    }
    for (int i = 0; i < m; i++) {
        cin >> y[i];
        ymin = min(ymin, y[i]);
        ymax = max(ymax, y[i]);
    }
    int res = 0;
    vector<int> xv, yv;
    int xsum = 0;
    int ysum = 0;
    for (int i = 1; i < n; i++) {
        int dx = x[i] - x[i-1];
        int contrib = ((((i)*(n-i))%mod)*dx)%mod;
        xv.push_back(contrib);
        xsum += contrib;
        xsum %= mod;
    }
    for (int i = 1; i < m; i++) {
        int dy = y[i] - y[i-1];
        int contrib = ((((i)*(m-i))%mod)*dy)%mod;
        yv.push_back(contrib);
        ysum += contrib;
        ysum %= mod;
    }
    for (int i : xv) {
        res += (i*ysum)%mod;
        res %= mod;
    }
    //for (int i : yv) {
        //res += i*xsum;
    //}
    cout << res << '\n';
}
/*

 */

Measured memory_bytes: 7144
#define _CRT_SECURE_NO_WARNINGS
#define _SCL_SECURE_NO_WARNINGS
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <algorithm>
#include <functional>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
#include <sstream>
#include <numeric>
#include <list>
#include <bitset>
#include <fstream>

using namespace std;
#define REP(i,a,n) for(int i = (a); i < (int)(n); ++i)
#define REM(i,a,n) for(int i = ((n) - 1); i >= (a); --i)
#define EPS 1e-11
#define INF 0x3FFFFFFF
#define INFLL 0x3FFFFFFF3FFFFFFF
#define INFD 1.0e+308
#define FLOAT setprecision(16)
const double PI = 3.1415926535897932;
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<LL, LL> PP;

template <class T, class U>
istream& operator>>(istream& ist, pair<T, U>& right) { return ist >> right.first >> right.second; }
template <class T, class U>
ostream& operator<<(ostream& ost, pair<T, U>& right) { return ost << right.first << ' ' << right.second; }
template <class T, class TCompatible, size_t N>
void Fill(T(&dest)[N], const TCompatible& val) { fill(begin(dest), end(dest), val); }
template <class T, class TCompatible, size_t M, size_t N>
void Fill(T(&dest)[M][N], const TCompatible& val) { for (int i = 0; i < M; ++i) Fill(dest[i], val); }
//sum, 累積和
// 負のときの割り算に注意
#if 0
#include <array>
#include <unordered_set>
#include <unordered_map>
template<class T>
using PriorityQ = priority_queue<T, vector<T>, greater<T> >;	// コスト小を優先
#endif

//#ifdef _DEBUG
//#include "IntMod.h"
//#include "Union_Find.h"
//#include "Graph.h"
//#include "Suffix_Array.h"
//#include "Matrix.h"
//#endif

#ifdef __GNUC__
typedef __int128 LLL;
istream& operator>> (istream& ist, __int128& val) { LL tmp;  ist >> tmp; val = tmp; return ist; }
ostream& operator<< (ostream& ost, __int128 val) { LL tmp = val; ost << tmp; return ost; }
#endif

int H, W;
int A[10][10];
int main() {
	cin >> H >> W;
	REP(i, 0, 10) {
		REP(j, 0, 10) {
			cin >> A[i][j];
		}
	}

	REP(k, 0, 10) {
		REP(i, 0, 10) {
			REP(j, 0, 10) {
				A[i][j] = min(A[i][j], A[i][k] + A[k][j]);
			}
		}
	}
	
	LL sum = 0;
	REP(i, 0, H) {
		REP(j, 0, W) {
			int c;
			cin >> c;
			if (c == -1) continue;
			sum += A[c][1];
		}
	}
	cout << sum << endl;
	return 0;
}



Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;

  int x = (c + b - 1) / b;
  int y = (a + d - 1) / d;
  if (x <= y) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


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



int main() {
 int N;
 cin >> N;
  
    vector<int> a(N);
     for(int i=0; i<N;i++)
       cin >> a.at(i);

    for(int i=0; i<N; i++){
      for(int j=0; j<N-1-i; j++){
        if(a[j] < a[j+1]){
          int tmp = a[j];
          a[j] = a[j+1];
          a[j+1] = tmp;
      }
    }
  }
    
  
 
 
    
  int ans = 0;

  for(int i=0; i<N; i+=2)
    ans += a.at(i);
  for(int i=1; i<N; i+=2)
    ans -= a.at(i);
  
  
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
  string s;
  cin>>s;
  vector<int> ans(2);
  rep(i,s.size()){
    if(s[i]=='1')ans[i%2]++;
    else ans[(i+1)%2]++;
    }
  cout<<min(ans[0],ans[1])<<endl;


    return 0;
}


Measured memory_bytes: 512