akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define mkt make_tuple
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll MOD=998244353;
template<class T> void chmin(T &a,const T &b){if(a>b) a=b;}
template<class T> void chmax(T &a,const T &b){if(a<b) a=b;}

#define MAX_N 1000010
ll inv[MAX_N+10],fac[MAX_N+10],ifac[MAX_N+10];

void setComb(){
  inv[0]=1;inv[1]=1;fac[1]=1;ifac[1]=1;fac[0]=1;ifac[0]=1;
  for(int i=2;i<MAX_N;i++){
    inv[i]=(-MOD/i)*inv[MOD%i]%MOD;
    fac[i]=fac[i-1]*i%MOD;
    ifac[i]=ifac[i-1]*inv[i]%MOD;

    inv[i]=(inv[i]+MOD)%MOD;
    fac[i]=(fac[i]+MOD)%MOD;
    ifac[i]=(ifac[i]+MOD)%MOD;
  }
  return;
}

ll comb(ll n,ll k){
  if(n<k||n<0||k<0) return 0;
  else return ((fac[n]*ifac[k]%MOD*ifac[n-k]%MOD+MOD)%MOD);
}

ll hcomb(ll n,ll r){// this size is really ok??
  if(n==0&&r==0) return 1;
  else if(n<0||r<0) return 0;
  else return comb(n+r-1,r);
}

ll mod_pow(ll x,ll n){
  x%=MOD;
  ll res=1;
  while(n>0){
    if(n&1) res=res*x%MOD;
    x=x*x%MOD;
    n>>=1;
  }
  return res;
}

void add(ll &a,ll b){
  a=(a+b)%MOD;
}

void mul(ll &a,ll b){
  a%=MOD;b%=MOD;
  a=a*b%MOD;
}

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

  int N,S;
  cin>>N>>S;
  vector<int> A(N);
  rep(i,N) cin>>A[i];

  vector<vector<ll>> dp(N+1,vector<ll> (S+1,0));
  dp[0][0]=1;
  for(int i=0;i<N;i++) for(int j=0;j<=S;j++){
      if(dp[i][j]==0) continue;
      add(dp[i+1][j],dp[i][j]*2%MOD);
      if(j+A[i]<=S) add(dp[i+1][j+A[i]],dp[i][j]);
  }

  cout<<dp[N][S]<<endl;

  return 0;
}


Measured memory_bytes: 73688
#include <iostream>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <functional>
#include <map>
#include <set>
#include <bitset>
//#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

#define rep(i,a,b) for(ll i=a;i<(ll)(b);i++)
#define rrep(i,a,b) for(ll i=a-1;i>=(ll)(b);i--)

#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める

#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)

#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

#define popcount __builtin_popcount
#define LIST(a) memset(a, 0, sizeof(a))


int main(void){
    ll n;
    cin >> n;
    vector<int> a(n), b(n), c(n);
    cin >> a[0] >> b[0] >> c[0];
    rep(i, 1, n){
        ll aa, bb, cc;
        cin >> aa >> bb >> cc;
        a[i] = aa + max(b[i - 1], c[i - 1]);
        b[i] = bb + max(a[i - 1], c[i - 1]);
        c[i] = cc + max(a[i - 1], b[i - 1]);
    }
    cout << max(max(a[n - 1], b[n - 1]), c[n - 1]) << endl;
    return 0;
}


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

using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using pii = pair<int, int>;

#define INF 1e9
#define MOD 1000000007
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define each(x, v) for (auto& x: (v))
#define all(x) (x).begin(), (x).end()
#define print(x) cout << (x) << endl

void solve();
void in(){} template<class T, class... U> void in(T &t, U &...u){ cin >> t; in(u...); }
int main() { cin.tie(0); ios::sync_with_stdio(0); solve(); }

void solve() {
  int N, M;
  in(N, M);
  vector<bool> ac(N);
  vector<int> pen(N);
  rep(i, 0, M) {
    int pi;
    string si;
    in(pi, si);
    pi--;
    if (ac[pi]) continue;
    if (si == "AC") {
      ac[pi] = true;
    } else {
      pen[pi]++;
    }
  }
  int acn = 0, penn = 0;
  rep(i, 0, N) {
    if (ac[i]) {
      acn++;
      penn += pen[i];
    }
  }
  cout << acn << ' ' << penn << endl;
}


Measured memory_bytes: 640
#!/usr/bin/env python3

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

b = 1 << 63
X = 0
ans = 0

for i in range(64):
    cnt = 0
    for a in A:
        if a & b:
            cnt += 1
    if N >= cnt*2 and (X ^ b) <= K:
        X ^= b
        ans += (N - cnt) * b
    else:
        ans += cnt * b
    b >>= 1
print(ans)

# zero.reverse()
# print(zero)
# print(k)

# k.reverse()
# zero.reverse()

# ans = 0
# count = 2**(len(k)-1)
# for i in range(len(zero)):
#     ans += count*max(zero[i], n-zero[i])
#     count //= 2
# print(ans)


Measured memory_bytes: 14708
import math
n,d=map(int,input().split())
x = [0] * n
y = [0] * n
c=0
for i in range(n):
    x[i], y[i] = map(int, input().split())
for i in range(n):
    if math.sqrt(x[i]**2+y[i]**2) <= d:
        c+=1
print(c)

Measured memory_bytes: 24700
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll w,h;
    cin >> w >> h;
    ll ans = 0;
    vector<pair<ll, int> > wh(w+h);
    REP(i,w){
        ll p;
        cin >> p;
        wh[i]=make_pair(p,0);
    }
    REP(i,h){
        ll q;
        cin >> q;
        wh[i+w] = make_pair(q,1);
    }
    ll wc = 0;
    ll hc = 0;
    sort(ALL(wh));
    REP(i,w+h){
        auto now = wh[i];
        if(now.se==0){
            ans+= (now.fi)*(h+1-hc);
            wc++;
        }else{
            ans+= (now.fi)*(w+1-wc);
            hc++;
        }
    }
    cout << ans << endl;

    return 0;
}

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

using namespace std;

int main()
{
    long long n , m ;
    cin>>n>>m ;
    long long ans = 0 ;
    map<long long , long long>mp ;
    long long sum = 0 ;
    for(long long i = 0 ; i < n ; ++i)
    {
        mp[sum % m]++ ;
        long long x ;
        cin>>x ;
        sum += x ;
        long long a = sum % m ;
        ans += mp[a];
    }
    cout<<ans;
    return 0 ;
}


Measured memory_bytes: 4224
# include <bits/stdc++.h>
# define INF 1e9
using namespace std;

int main(){

  int X;
  cin >> X;

  int ans = 1;
  for(int i= 2; i < int(sqrt(X))+1; ++i){
    int v = i*i;
    while(v <= X){
      ans = max(ans, v);
      v *= i;
    }
  }
  cout << ans << endl;


}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define fr(i,j,k) for(int i=j;i<k;i++)
#define f(n) fr(i,0,n)
#define f1(n) fr(i,1,n+1)
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    ll t;
    cin >> t;
    if ((b - d)*t >= abs(a-c)) {
        cout << "YES\n";
    }
    else {
        cout << "NO\n";
    }
}

Measured memory_bytes: 3652
#include <algorithm>
#include <bitset>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define MOD (1000000007l)
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)

using namespace std;

void solve() {
  while (true) {
    ll H, W;
    cin >> H >> W;
    if (H == 0 and W == 0) return;
    rep (h, H) {
      rep (w, W) cout << (((h+w)%2==0) ? "#" : ".");
      cout << endl;
    }
    cout << endl;
  }
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  cout << fixed;
  solve();
  return 0;
}



Measured memory_bytes: 3164
import std.algorithm, std.conv, std.range, std.stdio, std.string;

void main()
{
  auto n = readln.chomp.to!size_t;

  auto gij = new int[][](n, n);
  foreach (_; n.iota) {
    auto rd = readln.split.to!(size_t[]);
    auto u = rd[0] - 1;
    auto vi = rd[2..$].map!("a - 1").array;

    foreach (v; vi) gij[u][v] = 1;
  }

  gij.each!(gi => writeln(gi.to!(string[]).join(" ")));
}

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

using namespace std;

int main() {
	string s, t; cin >> s >> t;
	int n = s.length(), m = t.length();
	int ans = m;
	for (int l = 0, r = m - 1; r < n; l++, r++) {
		int k = 0;
		for (int i = l; i <= r; i++)
			if (s[i] != t[i - l])
				k++;
		ans = min(ans, k);
	}
	cout << ans << '\n';
	return 0;
}


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

int main() {
  int n , m;
  cin >> n >> m;
  vector<int> vec(n , 0);
  for(int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    vec.at(a-1) ++;
    vec.at(b-1) ++;
  }
  for(int i = 0; i < n; i++) {
  cout << vec.at(i) << endl;
  }
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
	
    int a[3],i,j=0;
	scanf("%d %d %d",&a[0],&a[1],&a[2]);
	
	for(i=0; i<2; i++){
		if(a[2]==a[i]){
			j++;
		}
	}

		if(a[1]==a[0]){
			j++;
		}
		
	if(j==1){
		printf("Yes\n");
		return 0;
	}
		
		else{
			
		printf("No\n");
		return 0;
	}
			
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vs=vector<string>;
using msi=map<string,int>;
using mii=map<int,int>;
using psi=pair<string,int>;
using pii=pair<int,int>;
using vlai=valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1e9
#define EPS 1e-9
#define MOD (1e9+7)
int main(void){
    int n,in;
    string s;
    cin>>n;
    list<int> l;
    rep(i,n){
        cin>>s;
        if(s=="insert"){
            cin>>in;
            l.push_front(in);
        }
        else if(s=="delete"){
            cin>>in;
            for(auto itr=l.begin();itr!=l.end();itr++){
                if(*itr==in){
                    itr=l.erase(itr);
                    break;
                }
            }
        }
        else if(s=="deleteFirst")l.pop_front();
        else l.pop_back();
    }
    auto goal=--l.end();
    for(auto itr=l.begin();itr!=l.end();itr++){
        cout<<*itr<<(itr!=goal?" ":"");
    }
    cout<<endl;
}






Measured memory_bytes: 34276
function Main(input) {
  var sum = 0;
  var i = 1;
  while(input!=1){
    sum += i;
    input = Math.floor(input/2);
    i *= 2;
  }
  console.log(sum*2+1)
}Main(require("fs").readFileSync("/dev/stdin", "utf8").trim());

Measured memory_bytes: 7372
using System;
using static System.Console;

class MainClass
{
    static void Main()
    {
        var XY = Array.ConvertAll(ReadLine().Split(),long.Parse);
        int ans = 0;
        while (XY[0] <= XY[1])
        {
            ans++;
            XY[0] *= 2;
        }
        WriteLine(ans);
    }
}


Measured memory_bytes: 27432
import java.util.*;
    public class Main{
        public static void main(String[] arg){
            int a, b, c;
            c = 0;
        	Scanner scan = new Scanner(System.in);
            for(;;){
                a = scan.nextInt();
                String op = scan.next();
                b = scan.nextInt();
                if(op.equals("?")) break;
                if(op.equals("+")){
                    c = a + b;
                }else if(op.equals("-")){
                    c = a - b;
                }else if(op.equals("*")){
                	c = a * b;
                }else if(op.equals("/")){
                    c = a / b;
                }
                System.out.printf("%d\n", c);
            }
            scan.close();
        }
    }


Measured memory_bytes: 26180
fun main(args: Array<String>) {
    val input = readLine()!!
    var cnt_max = 0
    var cnt = 0
    for (c in input) {
        if (c == 'A' || c == 'T' || c == 'G' || c == 'C' ){
            cnt += 1
        } else {
            if (cnt > cnt_max) {
                cnt_max = cnt
            }
            cnt = 0
        }
    }
    if (cnt > cnt_max) {
        cnt_max = cnt
    }

    print(cnt_max)
}

Measured memory_bytes: 33716
import java.util.Scanner;

public class Main {
	static Scanner scan = new Scanner (System.in); 
	public static void main(String args[]){
		run();
	}
	static void run(){
		int n;
		n = scan.nextInt();
		int[] a = new int[n];
		for(int i = 0; i < n; i++){
			a[i] = scan.nextInt();
		}
		shellSort(a, n);
		for(int i = 0; i < n; i++){
			
		}
	}
	static int insertSort(int[] a, int n, int g, int cnt){
		int v, j;
		for(int i = g; i < n; i++){
			v = a[i];
			j = i - g;
			while(j >= 0 && a[j] > v){
				a[j + g] = a[j];
				j = j - g;
				cnt++;
			}
			a[j + g] = v;
		}
		return cnt;
	}
	static void shellSort(int[] a, int n){
		int cnt, m, count, gCheck;
		cnt = 0;
		count = 0;
		gCheck = 1;
		
		while(n > gCheck){
			gCheck = gCheck * 2 + 1;
			count++;
		}
		if(count == 0){
			count = 1;
		}
		m = count ;
		int[] g = new int[m];
		g[m - 1] = 1;
		for(int i = 1; i < m; i++){
			g[m - i - 1] = g[m - i] * 2 + 1;
		}
		
		for(int i = 0; i < m; i++){
			cnt = insertSort(a, n, g[i], cnt);
		}
		System.out.println(m);
		for(int i = 0; i < m; i++){
			if(i == m - 1){
				System.out.println(g[i]);
			}else{
				System.out.print(g[i]+" ");
			}
		}
		System.out.println(cnt);
		for(int i = 0; i < n; i++){
			System.out.println(a[i]);
		}
	}
}

Measured memory_bytes: 298340
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
 
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
	template <class Arg1> void __f(const char* name, Arg1&& arg1) { cerr << name << " : " << arg1 << endl; }
	template <class Arg1, class... Args>
	void __f(const char* names, Arg1&& arg1, Args&&... args) {
		const char* sep = strchr(names + 1, ',');
		cerr.write(names, sep - names) << " : " << arg1 << "  ";
		__f(sep + 1, args...);
	}
#else
#define trace(...) 0
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("popcnt")
#pragma GCC target("avx2,sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS
#endif
 
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<int,pii> piii;
typedef pair<char,int> pci;
typedef pair<ll,ll> pll;
typedef pair<ll,pll> plll;
 

 
#define pb push_back
 
// order_of_key (k), find_by_order(k)
#define fi first
#define se second
#define input_arr(a,n) for(__typeof (n) i=0; i<n; ++i) {cin>>a[i];}
#define debug_arr(a,n) {{for(__typeof (n) i=0; i<n; ++i) {cout<<a[i]<<" ";}cout<<"\n";}}
#define maxheap priority_queue<ll>
#define minheap priority_queue<ll,vector<ll> ,greater<ll>>
#define itt iterator
#define initialise(a, x) memset(a, x, sizeof(a))
#define endl '\n'
#define isvowel(a) (a=='a'||a=='e'||a=='i'||a=='o'||a=='u')
#define ordered_set tree<pll, null_type,less<pll>, rb_tree_tag,tree_order_statistics_node_update>
#define MAX 1000020
#define maxn 200005
#define eps 0.0000001


#define int ll

const ll mod=1e9+7;
const ll inf=1e18;

int n;
int a[3005];
ll dp[3005][3002];

int find(int i,int j)
{
	if(j<i) return 0;
	if(dp[i][j]!=-inf) return dp[i][j];

	if(((j-i+1)&1)==(n&1))
	{
		return dp[i][j]=max(a[i]+find(i+1,j),a[j]+find(i,j-1));
	}
	return dp[i][j]=min(-a[i]+find(i+1,j),-a[j]+find(i,j-1));
}


signed main()
{

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

	// freopen("input.txt", "r", stdin);
	// freopen("out.txt", "w", stdout);

	cin>>n;

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

	for(int i=0;i<3005;i++) for(int j=0;j<3002;j++) dp[i][j]=-inf;


	cout<<find(0,n-1)<<'\n';

	return 0;
}

Measured memory_bytes: 71040
#include <iostream>

using namespace std;

int main(){
	int a,b,c,d;
	cin >> a >> b >> c >> d;
	
	int t_attack = (int)((double)c / (double)b + 0.9);
	int a_attack = (int)((double)a / (double)d + 0.9);
	
	if(t_attack > a_attack) cout << "No";
	else cout << "Yes";
	cout << endl;
	
	return 0;
	
}

Measured memory_bytes: 3584
#include<bits/stdc++.h>
using namespace std;
#define sc(a) scanf("%d", &a)
#define sc2(a,b) scanf("%d%d", &a, &b)
#define sc3(a,b,c) scanf("%d%d%d", &a, &b, &c)
#define pri(x) printf("%d\n", x)
#define mp make_pair
#define pb push_back
#define BUFF ios::sync_with_stdio(false);
#define imprime(v) for(int X=0;X<v.size();X++) printf("%d ", v[X]); printf("\n");
#define endl "\n"
const int INF= 0x3f3f3f3f;
const long double pi= acos(-1);
typedef long long int ll;
typedef long double ld;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector< vector< int > > vvi;
const int MOD=1e9+7;
const ll LINF=0x3f3f3f3f3f3f3f3f;
int n, m;
int a[305][305];
int qte[305];
bool tala[305];

void update(int id, priority_queue<ii> &pq) {
  set<int> mudou;
  for(int i = 1; i <= n; i++) {
    for(int j = 1; j <= m; j++) {
      if(tala[a[i][j]] and a[i][j] != id) break;
      if(tala[a[i][j]]) {
        for(int k = j + 1; k <= m; k++) {
          if(tala[a[i][k]]) {
            qte[a[i][k]]++;
            mudou.insert(a[i][k]);
            break;
          }
        }
        break;
      }
    }
  }
  tala[id] = false;
  for(int v : mudou) pq.push(mp(qte[v], v));
}

int main() {
  sc2(n, m);
  memset(tala, true, sizeof(tala));
  for(int i = 1; i <= n; i++) {
    for(int j = 1; j <= m; j++) {
      sc(a[i][j]);
    }
    qte[a[i][1]]++;
  }
  priority_queue<ii> pq;
  for(int i = 1; i <= m; i++) {
    pq.push(mp(qte[i], i));
  }
  int resp = INF;
  while(!pq.empty()) {
    ii p = pq.top();
    pq.pop();
    int id = p.second;
    int qt = p.first;
    if(qt != qte[id] or !tala[id]) continue;
    resp = min(resp, qt);
    update(id, pq);
  }
  pri(resp);
  return 0;
}

Measured memory_bytes: 640
#include <iostream>
using namespace std;
const int N_MAX = 100000;
int main(){
 int N,A,G[N_MAX];
 cin >> N;
 for(int id=1;id<=N;id++){
     cin >> A;
     G[--A]=id;
 }
 for(int i=0;i<N;i++){
     if(i)cout << " ";
     cout << G[i];
 }cout << endl;
}

Measured memory_bytes: 1152
#include<bits/stdc++.h>
#define lln long long int
#define llu unsigned lln
#define sc(n) scanf("%d",&n);
#define scl(n) scanf("%lld",&n);
#define scd(n) scanf("%lf",&n);
#define pf(res) printf("%d\n",res);
#define pfl(res) printf("%lld\n",res);
#define pfd(res) printf("%lf\n",res);
#define pb(n) push_back(n);
#define maxii 100005
using namespace std;
typedef pair<int,int> pii;
typedef pair<lln,lln> pll;
vector<int> vi[maxii];
vector<int>:: iterator child;
vector<lln> vl;
vector<vector<pair<int, int> > > vii;
//vector<pii> vii;
vector<pll> vll;
//vii.clear();
//vii.resize(n + 1);


int arr[maxii];
int arr2[maxii];
bool check[maxii];
bool check2[1000][1000];
int n,m;

void dfs(int node)
{
    check[node]=true;
    for(int child=0;child<vi[node].size();child++)
    {
        if(check[vi[node][child]]==false)
        {
            dfs(vi[node][child]);
        }
    }
}
int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    sc(n)
    sc(m)
    int a,b;
    for(int i=0;i<m;i++)
    {
        sc(a)
        sc(b)
        vi[a].pb(b)
        vi[b].pb(a)
    }
    int c=0;
    for(int i=1;i<=n;i++)
    {
        if(check[i]==false)
        {
            c++;
            dfs(i);
        }
    }
    cout<<c-1;
}






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

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)
#define TO_STRING(VariableName) # VariableName
#define LOG(x) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" ";
#define LOGE if(DEBUG)cout<<endl;

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

lli dd[60][60];

int main(){

	lli h,w;
	cin>>h>>w;

	REP(i,1,h+1)REP(j,1,w+1){
		char tmp;
		cin>>tmp;
		if(tmp=='#')dd[i][j]=1;
	}

	REP(i,1,h+1){
		REP(j,1,w+1){
			if(dd[i][j]){
				lli dx[4]={-1,0,1,0};
				lli dy[4]={0,1,0,-1};
				bool ok=false;

				REP(k,0,4){
					lli nI = i+dx[k];
					lli nJ = j+dy[k];

					if(dd[nI][nJ])ok=true;
				}
				if(!ok){
					cout<<"No"<<endl;
					return 0;
				}
			}
		}
	}

	cout<<"Yes"<<endl;


    return 0;
}


Measured memory_bytes: 256
/*Author - Shubham Gupta (@shubham107)*/
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef vector<ll> vl;		typedef vector<int> vi;
typedef vector<vl> vvl;	  	typedef vector<vi> vvi;
typedef pair<ll, ll> pll;	typedef pair<int, int> pii;
#define forn(i,n) for(int i=0;i<n;i++)
#define rforn(i,n) for(int i=n-1;i>=0;i--)
#define forne(i,n) for(int i=1;i<=n;i++)
#define forse(i,s,e) for(int i=s;i<e;i++)
#define rforse(i,s,e) for(int i=e-1;i>=s;i--)
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define MOD 1000000007
#define F first
#define S second
#define pb push_back
#define fill(a,x) memset(a,x,sizeof a);
#define trav(a,x) for(auto &a:x)
#define INF	ll(1e18)
#ifdef SHUBHAM107
#include "../code-pieces/trace.h"
#else
#define trace(args...)
#endif

ll modpow(ll a, ll b, ll m = MOD) {
	a %= m; ll res = 1; while (b) {if (b & 1)res = res * a % m; a = a * a % m; b >>= 1;}
	return res;
}
ll bpow(ll a, ll b) {ll res = 1; while (b) {if (b & 1)res = res * a; a = a * a; b >>= 1;} return res;}
ll modinv(ll a) {return modpow(a, MOD - 2, MOD);}
void graph(vvi &adj, int m) {int x, y; forn(i, m) {cin >> x >> y; adj[x - 1].pb(y - 1); adj[y - 1].pb(x - 1);}}

const int mxN = 2e5 + 5;
void solve() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	if((b+c-1)/b > (a+d-1)/d) cout << "No";
	else cout << "Yes";
}
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
#ifdef SHUBHAM107
	freopen("inp.txt", "r", stdin);
	freopen("out.txt", "w", stdout);
	freopen("err.txt", "w", stderr);
#endif
	int t = 1;
	// cin >> t;
	while (t--) {
		solve();
	}
}


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

// macro
#define rep(i,n) for(i=0;i<n;i++)
#define ll long long
#define all(v) v.begin(), v.end()

// code starts
int main()
{
  int n;
  cin >> n;
  ll ans = 0;
  int i,j;
  for(i=1;i<=n;i++)
  {
    ll to = n/i;
    ans += to*(to+1)/2*i;
  }
  cout << ans << "\n";
}



Measured memory_bytes: 3600
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)*}
    };
}

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, 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")
    };
}

fn main() {
    input! {
    x: usize,
    y: usize,
    z: usize,
    }
    println!("{} {} {}", z, x, y);
}


Measured memory_bytes: 4352
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#define rep(i, n) for(int i=0; i<n; i++)

using namespace std;

int main(){
  int N;
  cin >> N;
  long long A[N];
  rep(i, N)
    cin >> A[i];
  // 入力終了

  long long money = 1000;
  long long num;

  rep(i, N-1){
    // 翌日の株の方が儲けられる
    if(A[i] < A[i+1]){
      // 所持金で限界まで株を買う
      num = money/A[i];
      money = money - num*A[i];

      // 所持株で限界まで金に換算
      money = money + num*A[i+1];
    }
  }

  // 解答
  cout << money << endl;
  
  
  return 0;
}


Measured memory_bytes: 3620
package main

import "fmt"

var (
	a, b, c, d, e, f int
	g, h, t, s1, s2  int
)

func main() {
	fmt.Scan(&a, &b, &c, &d, &e, &f)
	a *= 100
	b *= 100

	for i := 0; i <= 30 && a*i <= f; i++ {
		for j := 0; j <= 30 && i*a+j*b <= f; j++ {
			if i == 0 && j == 0 {
				continue
			}
			g = i*a + j*b
			h = min(g*e/100, f-g)
			t := 0
			for k := 0; k <= 100 && c*k <= h; k++ {
				for l := 0; l <= 100 && c*k+d*l <= h; l++ {
					t = max(t, c*k+d*l)
					if s1 == 0 || t*(s1+s2) > s2*(g+t) {
						s1 = g
						s2 = t
					}
				}
			}
		}
	}
	fmt.Println(s1+s2, s2)
}

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

func max(x, y int) int {
	if x < y {
		return y
	}
	return x
}


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

void swap(int* x, int* y){
	int tmp = *x;
	*x = *y;
	*y = tmp;
}

int main(){
	int input = 0, a = 0, b = 0, c = 0;
	for(int i = 0; i < 10; i++){
		cin >> input;
		if(c < input){
			swap(&c, &input);
		}
		if(b < c){
			swap(&b, &c);
		}
		if(a < b){
			swap(&a, &b);
		}
	}
	cout << a << endl;
	cout << b << endl;
	cout << c << endl;
	return 0;
}

Measured memory_bytes: 1164
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <cmath>
#include <functional>
#define fi first
#define se second
using namespace std;
bool value(int y,int x,int R,int C){return 0<=y&&y<R&&0<=x&&x<C;}
typedef pair<int,int> pii;
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long > vll;
typedef vector< vi > vvi;
double pie=acos(-1);
int dx[4] = { 0,-1,0,1 };
int dy[4] = { -1,0,1,0 };
int main() {
	int a,b,n;
	int x,y;
	while(true){
		cin>>a>>b;
		if(a==0&&b==0) break;
		cin>>n;
		int dp[20][20];
		bool f[20][20];
		for(int i=0;i<20;i++){
			for(int j=0;j<20;j++){
				dp[i][j]=0;
				f[i][j]=true;
			}
		}
		for(int i=0;i<n;i++){
			cin>>x>>y;
			f[x][y]=false;
		}
		for(int i=1;i<=a;i++){
			for(int j=1;j<=b;j++){
				if(f[i][j]){
					dp[i][j]=dp[i][j-1]+dp[i-1][j];
					dp[1][1]=1;
				}
			}
		}
		cout<<dp[a][b]<<endl;
	}
}

Measured memory_bytes: 1160
// " every champion was once a contender who refused to give up " //
    // eat sleep code repeat :)
    // vectorTango
    // reapedJuggler
                            
    #include "bits/stdc++.h"
                                 
    #define FAST_IO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
    #define ld long int
    #define all(A) begin(A) , end(A)
    #define rep(i , a , b)  for(lld i = a; i < b ; i++)
    #define rep1(i , a , b) for(lld i = a ; i >= b ; i--)
    #define lld long long int 
    #define ulld unsigned long long int
    #define input lld* a = new lld [n] 
    #define input1 lld* b = new lld [n] 
    #define vec vector < lld >
    #define pb push_back          
    #define ss second
    #define ff first
    #define inf 999999999999999999
    #define fin -999999999999999999
    #define mod 1000000007
    #define umap unordered_map
    #define mpp make_pair
    #define finish(x) cout << v << " ";
    #define tolower(s)   std::transform(s.begin(), s.end(), s.begin(),[](unsigned char c){ return std::tolower(c); });
                                                      
    using namespace std;
                             
    void start()
    {
      #ifndef ONLINE_JUDGE 
      freopen("input.txt" , "r" , stdin) ;
      freopen("output.txt" , "w" , stdout) ;
      #endif
    } 

  //   vec g[200007];
  //   vec v;
  //   map<lld , bool> vis ; lld siz = 0 , ans = 1 ;

  //    void dfs(lld x , lld dest){
  
  //    vis[x] = 1;

  //    for(auto i : g[x]){
  //     if(!vis[i]){
  //       dfs(i);
  //     }
  //    }

  //    return;
  //   }

  // lld pow1(ulld  a , ulld y){
  //   // a %= mod;
  //   ulld  res = 1;

  //   while(y > 0){

  //     if(y & 1)
  //       res = (res*a)%mod;

  //     y = y >> 1;
  //     a = (a*a)%mod;
  //   }
  //   return res;
  // }

// bool sortbysec(const pair<lld ,lld > &a, const pair<lld ,lld > &b) { 
//   return (a.ss < b.ss); 
// } 
    
void sober(){
lld n , x = 0 , a = 0 , b = 0 , y = 0 , sum = 0 , k = 0 , m = 0;
string s;
cin >> s;
if(s == "ABC")
  cout << "ARC\n";
else
  cout << "ABC\n";
return;
}

signed main(){  
  start();  
  FAST_IO;
  lld t = 1; 
  // cin >> t;
  while(t--){
     sober();
  }
}      

//  c0ded by :
// - - - - - - - - - - - - - - - - - - - - - - s 0 b e r and s i m r a n


Measured memory_bytes: 3580
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <map>
using namespace std;

using ll = long long;

ll nCk(ll n, ll k) {
    k = min(k, n - k);
    if (k <= 0) return 1;
    else if (k == 1) return n;
    return n * nCk(n - 1, k - 1) / k;
}

int main() {
    int n, a, b;
    cin >> n >> a >> b;

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

    sort(v.begin(), v.end(), greater<ll>());
    ll sum = 0;

    map<ll, int> counter;

    for (int i = 0; i < a; i++) {
        sum += v[i];
    }
    cout << fixed << setprecision(10) << (double)sum / (double)a << endl;

    sum -= v[a];

    ll ans = 0;
    for (int i = a - 1; i < b; i++) {
        int num = i + 1;    // 要素数
        if (i >= a && sum * num > (sum + v[i]) * (num - 1)) break;

        sum += v[i];

        map<ll, int> p_counter,
                     s_counter;

        for (int v_i = 0; v_i < n; v_i++) {
            if (v_i <= i) p_counter[v[v_i]]++;
            else s_counter[v[v_i]]++;
        }

        ll a = p_counter[v[i]] + s_counter[v[i]],
           b = p_counter[v[i]];

        ans += nCk(a, b);
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>
using namespace std;
namespace adaptor = boost::adaptors;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define cy cout << "Yes" << endl
#define cn cout << "No" << endl
typedef long long ll;

void Main()
{
	ll N, M;
  	cin >> N >> M;
  	vector<ll> a(N), b(N);
	rep(i,N){
    	cin >> a[i] >> b[i];
    }
  	vector<ll> c(M), d(M);
	rep(i,M){
    	cin >> c[i] >> d[i];
    }

  	auto distance = [&](ll x1, ll y1, ll x2, ll y2){
	 	ll ans = abs(x1-x2)+abs(y1-y2);   	
		return ans;    
    };
  	  
	ll tempmin;
  	ll tempj;
  	rep(i,N){
      	tempmin = LLONG_MAX;
		rep(j,M){
          if(tempmin > distance(a[i],b[i],c[j],d[j])) {
          	tempj = j;
          	tempmin = distance(a[i],b[i],c[j],d[j]);
        	}
        }
        cout << tempj + 1 << endl;
    }  
  
    return;
}

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


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int N = sc.nextInt();
		int buff = N;
		int sum = 0;
		while(N!=0) {
			sum += N%10;
			N = (int)(N/10);
		}

		if(buff%sum==0) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 21844
ans=0
    pst=0
    (gets.chomp+'0').chars{|c|
      d=c.to_i
      if d>5
        ans+=11-d-pst
        pst=2
      elsif d==5
        if pst>0
          ans+=11-d-pst
          pst=2
        else
          ans+=d
          pst=1
        end
      elsif d==4
         ans+=d
         if pst>1
            pst=1
          else
            pst=0
          end
      else
        ans+=d
        pst=0
      end
    }
    puts ans

Measured memory_bytes: 4868
#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;
#define int ll

int n, q, k;
vector<vector<pll>> G;
int dis[100010];

void dfs(int v, int p, int d){
    dis[v] = d;
    for(auto nv : G[v]){
        if(nv.first == p) continue;

        dfs(nv.first, v, d + nv.second);
    }
}

signed main(){
    cin >> n;
    G.resize(n);
    int a, b, c;
    for (int i = 0; i < n - 1; ++i) {
        cin >> a >> b >> c;
        a--; b--;
        G[a].push_back(pii(b, c));
        G[b].push_back(pii(a, c));
    }
    cin >> q >> k;
    k--;
    dfs(k, -1, 0);

    vector<int> x(q), y(q);
    for (int i = 0; i < q; ++i) {
        cin >> x[i] >> y[i];
        x[i]--; y[i]--;
    }

    for (int i = 0; i < q; ++i) {
        cout << dis[x[i]] + dis[y[i]] << endl;
    }
}

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

int main(void) {

	double a, b, c, h, l, s, cc, i;

	scanf("%lf%lf%lf", &a, &b, &c);

	cc = c / 180 * 3.1415926535;

	s = 0.5 * a * b * sin(cc);

	i = sqrt(a*a + b*b - 2 * a*b*cos(cc));

	l = a + b + i;

	h = b * sin(cc);

	printf("%f\n%f\n%f\n", s, l, h);
	return 0;
}

Measured memory_bytes: 648
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

using namespace std;

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

const int INF = 1001001001;
const double EPS = 1e-10;

int w, h;
char field[60][60];
int color[60][60];
void dfs(int y, int x, int col)
{
	const int dy[] = {-1, 0, 1, 0};
	const int dx[] = {0, -1, 0, 1};
	
	rep(i, 4){
		int py = y + dy[i];
		int px = x + dx[i];
		if(py<0 || h<=py || px<0 || w<=px)
			continue;
		if(color[py][px] & col)
			continue;
		if(field[py][px] != '.')
			continue;
		
		color[py][px] |= col;
		dfs(py, px, col);
	}
}

int main()
{
	while(scanf("%d%d", &w, &h), w){
		rep(i, h) rep(j, w)
			color[i][j] = 0;
		
		rep(i, h)
			scanf("%s", field[i]);
		
		rep(i, h) rep(j, w){
			if(field[i][j] != '.'){
				dfs(i, j, field[i][j]=='W' ? 1 : 2);
			}
		}
		
		int a=0, b=0;
		rep(i, h) rep(j, w){
			a += color[i][j] == 1;
			b += color[i][j] == 2;
		}
		printf("%d %d\n", b, a);
	}
	
	return 0;
}

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

int main(){
  long long L,R,result=2018;
  cin >> L >> R;
  if(R-L>=2019){
    result = 0;
  }else{
    for(long long i=L;i<R;i++){
      for(long long j=i+1;j<=R;j++){
        result = min(result,(i*j)%2019);
      }
    }
  }
  cout << result << endl;
}


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

int main()
{


        long long n,m,a,b,c,d,e,f,g,h,p,q,r,fr,sc,tr,sz,tz,i,j,k,mx=LLONG_MIN,mn=LLONG_MAX;
        long long x=0,y=0,cnt=0,res=0,ttl=0,ans,sum=0; long long flg=0,flag=1,na=0,as=1;
        vector<long long>u,v,w; vector< pair<long long,long long> >vct; vector<string>vst;
        set<long long>st,nt,tt; map<string,long long>mp; string str,ttr,ntr;
        map<char,long long>nq;

        scanf("%lld",&n);
        cin>>str;

        long long lo=0,hi=n/2,mid;

        for(i=0;i<n;i++)
        {
            nq[str[i]]++; if(nq[str[i]]==2){  lo=1;  break;  }
        }

        if(lo==0)printf("%lld\n",lo);
        else
        {

            while(lo<hi)
            {

                mid=(lo+hi) >> 1; flg=0;


                for(i=0;i<=n-mid;i++)
                {
                    ttr=str.substr(i,mid);

                    if(mp[ttr]==0){  mp[ttr]=i+1; }


                }

                for(i=n-mid;i>=0;i--)
                {
                    ttr=str.substr(i,mid);


                    if(mp[ttr]!=0)
                    {
                        p=mp[ttr]+mid-1; q=i+1;
                        if(q>p){  flg=1; break; }
                    }

                }

                if(flg==1)
                {
                    ans=mid; lo=mid+1;

                    if(lo==hi)
                    {

                        ///

                             mid=(lo+hi) >> 1; flg=0;

                             for(i=0;i<=n-mid;i++)
                             {
                                    ttr=str.substr(i,mid);

                                    if(mp[ttr]==0){  mp[ttr]=i+1; }

                            }

                            for(i=n-mid;i>=0;i--)
                            {
                                 ttr=str.substr(i,mid);


                                 if(mp[ttr]!=0)
                                 {
                                      p=mp[ttr]+mid-1; q=i+1;
                                      if(q>p){  flg=1; break; }
                                 }

                            }

                            if(flg==1)
                            {
                                ans=mid;
                            }

                        ///

                    }


                }
                else
                {
                    hi=mid;
                }


            }


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


        }








    return 0;
}





Measured memory_bytes: 74728
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep2(i, m, n) for(int i=int(m); i<int(n); ++i)
#define drep2(i, m, n) for(int i=int(m-1); i>=int(n); --i)
#define rep(i, n) rep2(i, 0, n)
#define drep(i, n) drep2(i, n, 0)
#define all(a) a.begin(), a.end()
using ll = long long;
using ld = long double;
using V = vector<int>;
using Vll = vector<ll>;
using Vld = vector<ld>;
using Vbo = vector<bool>;
using VV = vector<V>;
using VVll = vector<Vll>;
using VVld = vector<Vld>;
using VVbo = vector<Vbo>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using Pld = pair<ld, ld>;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
template<typename T> istream &operator>>(istream &is, vector<T> &v) { for (auto &e : v) is >> e; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { for (auto &e : v) os << e << " "; return os; }
template<typename T> inline int count_between(vector<T> &a, T l, T r) { return lower_bound(all(a), r) - lower_bound(all(a), l); } // [l, r)
inline int Log2(ll x) { int k; for (k = 0; x > 0; ++k) x >>= 1; return k; } // number of binary digits
const int INF  = 1<<30;
const ll INFll = 1ll<<62;
const ld EPS   = 1e-10;
const int MOD  = int(1e9)+7;


int main() {
  ll n; cin >> n;
  Vll a(n); cin >> a;

  ll m = n/2;
  ll k = (n%2) ? 3 : 2;

  Vll dp(k);
  rep(i, m) drep(j, k) dp[j] = *max_element(dp.begin(), dp.begin()+j+1) + a[2*i+j];

  cout << *max_element(all(dp)) << endl;
  return 0;
}


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

#define rep(i, a, b) for(int i=a; i<=b; i++)
#define trav(a, x) for(auto& a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int) x.size()
#define pb push_back
#define MOD 1000000007	
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

ll n, u, v;
int par[100001];
vi adj[100001];
ll dp[100001][2];

//0 white 1 black
int calc(int x, int col){
	if(adj[x].empty()) return 1;
	if(dp[x][col]!=-1) return dp[x][col];
	ll ans=1;
	trav(k, adj[x]){
		if(k==par[x]) continue;
		par[k]=x;
		if(!col) ans=(ans*(calc(k, 0)%MOD+calc(k, 1)%MOD)%MOD)%MOD;
		else ans=(ans*calc(k, 0)%MOD)%MOD;
	}
	return dp[x][col]=ans;
}

int main(){
  // freopen("input.txt", "r", stdin); 
  // freopen("output.txt", "w", stdout);
  cin.sync_with_stdio(0); cin.tie();
  cin.exceptions(cin.failbit);

  cin >> n;
  rep(i, 1, n-1){
  	cin >> u >> v;
  	adj[u].pb(v);
  	adj[v].pb(u);
  }

  rep(i, 1, n){
  	rep(j, 0, 1){
  		dp[i][j]=-1;
  	}
  }
  cout << (calc(1, 0)+calc(1, 1))%MOD;
}

Measured memory_bytes: 17792
#include <iostream>
#include <math.h>
#include <iomanip>
#define PI 3.141592653589793
using namespace std;

int main()
{
	double a,b,C,S,L,h,R;
	cin >> a >> b >> C;

	R = C * PI / 180.0;

	S = (a*b*sin(R))/2;
	L = a + b + sqrt((a*a) + (b*b) - (2*a*b*cos(R)));
	h = b*sin(R);

	
	cout << fixed << std::setprecision(6) << S << endl;
	cout << fixed << std::setprecision(6) << L << endl;
	cout << fixed << std::setprecision(6) << h << endl;

	return 0;
}

Measured memory_bytes: 3496
#include <iostream>
#include <stdio.h>
#include <bits/stdc++.h>
#include <math.h>
#include <string>
#include <sstream>
#define ll long long
#define F first
#define S second
#define pb push_back
#define ld long double
#define pll pair<long long,long long>
#define pld pair<long double,long double>
#define ios     ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
using namespace std;
ll mod=1000000007;
ll gcd (ll a,ll b)
{
    if(b==0)
        return a;
    else
        return gcd(b,a%b);
}
ll fastexp(ll x ,ll n)
{
    ll result =1;
    while(n>0)
    {
        if(n%2==1)
            result*=x;
        x*=x;
        n=n/2;
    }
    return result;
}

ll modularExp(ll x,ll n,ll mod)
{
    ll result=1;
    while(n>0)
    {
        if(n%2==1)
            result=(result*x)%mod;
        x=((x%mod)*(x%mod))%mod;
        n=n/2;
    }
    return (result)%mod;
}
bool isPrime(ll n)
{
    for(ll i=2;i*i<=n;i++)
        if(n%i==0)
            return false;
    return true;
}
bool mycomp(pll &a,pll &b)
{
    if(a.F!=b.F)
        return a.F < b.F;
    else
        return a.S < b.S;
}

void solve()
{
     ll n,k;
     cin>>n>>k;
     vector<ll> v(n+1),w(n+1);
     ll i,j;
     for(i=1;i<=n;i++)
          cin>>w[i]>>v[i];
     vector< vector<ll> > dp(n+1,vector<ll> (k+1));
     for(i=1;i<=n;i++)
     {
          for(j=1;j<=k;j++)
          {
               dp[i][j]=dp[i-1][j];
               if(j-w[i]>=0)
                    dp[i][j]=max(dp[i][j],dp[i-1][j-w[i]]+v[i]);
          }
     }
     cout<<dp[n][k];
     
     
     
}

int main()
{
    ios;
    ll t;
//    cin>>t;
  t=1;
    while(t--)
        solve();
}

Measured memory_bytes: 80256
import sys
n = int(input())
n2 = n
while n>0:
    if n % 4 == 0 or n % 7 == 0:
        print("Yes")
        sys.exit()
    n -= 7
while n2>0:
    if n2 % 4 == 0 or n2 % 7 == 0:
        print("Yes")
        sys.exit()
    n2 -= 4
print("No")

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main()
{
  long n,i;
  cin>>n;
  long a[n];
  for(i=0;i<n;i++)
    cin>>a[i];
  long ans=0,mx=a[0];
  for(i=1;i<n;i++)
  {
    if(a[i]<mx)
    ans+=mx-a[i];
    else
    mx=a[i];
  }
  cout<<ans<<endl;
  return 0;
}


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

#define M_PI       3.14159265358979323846   // pi

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef pair<ll, ll> P;

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

struct PairCompare {
	inline bool operator() (const P& a1, const P& a2)
	{
		if (a1.first == a2.first)	return a1.second < a2.second;
		return a1.first < a2.first;
	}
};

int main(void)
{
	ll n, t;
	cin >> n >> t;
	vector<P> as(n);
	rep(i, n) {
		cin >> as[i].first >> as[i].second;
	}
	sort(as.begin(), as.end(), PairCompare());
	vector<vector<ll>> dp(n + 10, vector<ll>(6010, 0));
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < 6010; j++) {
			dp[i + 1][j] = dp[i][j];
		}
		for (int j = 0; j < t; j++) {
			dp[i + 1][j + as[i].first] = max(dp[i + 1][j + as[i].first],
				dp[i][j] + as[i].second);
		}
	}
	ll sum = 0;
	for (int i = 0; i < 6010; i++) {
		sum = max(sum, dp[n][i]);
	}
	cout << sum << endl;
	return 0;
}


Measured memory_bytes: 141824
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<bitset>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
using namespace std;
using ll = long long;
template<typename T>using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll inf = 1145141919810364364LL;
#define all(x) (x).begin(),(x).end()
#define puts(x) cout << x << endl
#define rep(i,m,n) for(ll i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(ll i = m;i >= n;--i)


ll mod = 1e9 + 7;

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

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


	map<int,ll> mp;
	mp[-1] = 3;
	ll ans = 1;
	for (int i = 0; i < N; i++) {
		ll temp = (mp[A[i] - 1]-mp[A[i]]);
		if (temp <= 0) {
			puts(0);
			return 0;
		}
		ans *= temp;
		ans %= mod;
		mp[A[i]]++;
	}
	puts(ans);
	return 0;
}

Measured memory_bytes: 6912
n, l = numbers = gets.split.map(&:to_i)
flaver = []
total = 0
(1..n).each do |n|
  value = n + l - 1
  total += value
  flaver << value
end

if flaver.all? {|f| f>=0}
  flaver.delete(flaver.min)
  p flaver.inject(:+)
elsif flaver.all? {|f| f<0}
  flaver.delete(flaver.max)
  p flaver.inject(:+)
else
  flaver.delete(0)
  p flaver.inject(:+)
end

Measured memory_bytes: 1788
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools
import time,random

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
mod2 = 998244353
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def pe(s): return print(str(s), file=sys.stderr)
def JA(a, sep): return sep.join(map(str, a))
def JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)


def main():
    s = S()
    if "7" in s:
        return 'Yes'

    return "No"


print(main())





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

#define Fast            ios_base::sync_with_stdio(false);cin.tie(nullptr);
#define fWrite          freopen ("out.txt","w",stdout);
#define TC              int t;cin >> t;FOR(tc,1,t)
#define LL              long long
#define ULL             unsigned long long
#define ff              first
#define ss              second
#define pb              push_back
#define pii             pair<int,int>
#define all(a)          a.begin(),a.end()
#define MEM(a,x)        memset(a,x,sizeof(a))
#define FOR(i,a,b)      for(int i=a;i<=b;i++)
#define ROF(i,a,b)      for(int i=a;i>=b;i--)
#define REP(i,b)        for(int i=0;i<b;i++)

#define Make(x,p)       (x  (1<<p))
#define DeMake(x,p)     (x & ~(1<<p))
#define Check(x,p)      (x & (1<<p))
#define popcount(x)     __builtin_popcount(x)

const LL MOD=1e9+7;
int n,k;
LL dp[2][100005]; //Line swap DP

int main()
{
    cin >> n >> k;
    dp[0][0]=1;
    int now=0,prev;
    REP(i,n){
        int x;
        cin >> x;
        prev=now;
        now=1-now;
        FOR(j,0,k){
            dp[now][j]=(j?dp[now][j-1]:0)+dp[prev][j]-(j-x-1>=0?dp[prev][j-x-1]:0);
            dp[now][j]=(dp[now][j]+MOD)%MOD;
        }
    }
    cout << dp[now][k];
}


Measured memory_bytes: 1792