akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <bitset>
#include <cmath>
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define Rep(i, b, e) for(int (i) = (b); (i) < (e); ++(i))
#define Repr(i, b, e) for(int (i) = (b) - 1; (i) >= (e); --(i))
#define Print(x) cout << (x) << endl 
#define Min2(a, b) ((a) < (b)) ? (a) : (b)
#define Max2(a, b) ((a) > (b)) ? (a) : (b)

typedef long long ll;

using namespace std;

bool match(string S, string T, int head){
    Rep(i, 0, T.length()){
        if(S[head + i] == T[i] || S[head + i] == '?') continue;
        else return false;
    }
    return true;
}

int main(){
    string S, T;
    cin >> S >> T;
    Repr(i, S.length() - T.length() + 1, 0){
        if(match(S, T, i)){
            S.replace(i, T.length(), T);
            replace(S.begin(), S.end(), '?', 'a');
            Print(S);
            return 0;
        }
    }
    Print("UNRESTORABLE");
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int main(){
  int n,mini;
  cin >> n;
  vector <string> data1(n),data2(n);
  for(int i=0;i<n;i++){
    cin >> data1[i];
    data2[i] = data1[i];
  }
  for(int i=0;i<n-1;i++){
    for(int j=n-1;j>i;j--){
      if(data1[j][1]<data1[j-1][1]) swap(data1[j],data1[j-1]);
    }
  }
  for(int i=0;i<n;i++){
    mini = i;
    for(int j=i;j<n;j++){
      if(data2[j][1]<data2[mini][1]) mini = j;
    }
    if(mini != i) swap(data2[i],data2[mini]);
  }
  for(int i=0;i<n;i++) cout << (i!=0?" ":"") << data1[i];
  cout << endl << "Stable" << endl;
  for(int i=0;i<n;i++) cout << (i!=0?" ":"") << data2[i];
  if(data1==data2) cout << endl << "Stable" << endl;
  else cout << endl << "Not stable" << endl;
}

Measured memory_bytes: 1212
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

#include <limits.h>

using namespace std;

typedef long long ll;

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

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

int main(void) {
    ll a, b, c, k;
    cin >> a >> b >> c >> k;

    vector<ll> xs = {a, b, c};
    sort(xs.begin(), xs.end());

    ll ans = 0;
    ans += xs[0];
    ans += xs[1];

    ll x = xs[2];
    for (int i = 0; i < k; i++) {
        x = x * 2;
    }
    ans += x;

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (ll i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define m1(x) memset(x,-1,sizeof(x))
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const double PI = 3.141592653589;

int main(){
  int n, k;
  cin >> n >> k;
  int l[50];
  rep(i, n) cin >> l[i];
  sort(l, l+n);
  reverse(l, l+n);
  int ans = 0;
  rep(i, k){
    ans += l[i];
  }
  cout << ans <<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <math.h>
using namespace std;

int main(){
  string S;
  string s[] = {"SUN","MON","TUE","WED","THU","FRI","SAT"};
  cin >> S;

  for(int i=0;i<7;i++){
    if(S == s[i]){
      cout << 7-i << endl;
      break;
    }
  }
  
  return 0;
}


Measured memory_bytes: 256
#include<algorithm>
#include<bitset>
#include<iostream>
#include<iomanip>
#include<set>
#include<string>
#include<math.h>
#include<string>
using namespace std;

class zahyo{
	public:
	int x;
	int y;
	zahyo(){
		x=0;
		y=0;
	}
	zahyo(int x_,int y_){
		x=x_;
		y=y_;
	}
	void print(){
		cout<<x<<" "<<y;
	}
	zahyo operator+(zahyo add){
		add.x=this->x+add.x;
		add.y=this->y+add.y;
		return add;
	}
	zahyo operator-(zahyo add){
		add.x=this->x-add.x;
		add.y=this->y-add.y;
		return add;
	}
	bool operator==(const zahyo add) const{
		if(add.x==this->x and add.y==this->y){return true;}
		else{return false;}
	}
	bool operator!=(const zahyo add) const{
		if(add.x==this->x or add.y==this->y){return false;}
		else{return true;}
	}
	bool operator<(const zahyo add) const{
		if(this->x<add.x){return true;}
		else if(this->x==add.x and this->y<add.y){return true;}
		else{return false;}
	}
	bool operator>(const zahyo add) const{
		if(this->x>add.x){return true;}
		else if(this->x==add.x and this->y>add.y){return true;}
		else{return false;}
	}
	void input(){
		cin>>x>>y;
	}
};


int main(){
int n;cin>>n;
int a[4]={};
string hoge[4]={"AC","WA","TLE","RE"};
for(int i=0;i<n;i++){
	string temp;
	cin>>temp;
	for(int j=0;j<4;j++){
		if(temp==hoge[j]){
			a[j]++;
		}
	}
}
for(int i=0;i<4;i++){
	cout<<hoge[i]<<" x "<<a[i]<<endl;
}
}


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

struct lowlink{
  vector<int> ord,low,used;
  vector<vector<int>> adj,tree;
  int root,n;
  lowlink(){}
  lowlink(vector<vector<int>> const& a,int r):adj(a),root(r){
    n = adj.size();
    ord.resize(n);
    low.resize(n);
    used.resize(n,-1);
    tree.reserve(n);
    int k=0;
    dfs(r,-1,k);
  }
  void dfs(int cur,int par,int& k){
    ord[cur] = k++;
    low[cur] = ord[cur];
    used[cur] = 1;
    for(auto nxt:adj[cur]){
      if(used[nxt]==-1){
        dfs(nxt,cur,k);
        tree[cur].emplace_back(nxt);
        low[cur] = min(low[cur],low[nxt]);
      }
      else if(ord[nxt]<ord[cur]&&nxt!=par){
        low[cur] = min(low[cur],ord[nxt]);
      }
    }
  }
  vector<int> articulation_points(){
    // 関節点 := 頂点u,子vについて、ord[u] <= low[v] or 根の次数>1
    vector<int> res;
    if(tree[root].size()>1)res.emplace_back(root);
    for(int u=0;u<n;++u){
      if(u==root)continue;
      for(auto v:tree[u]){
        if(ord[u]<=low[v]){
          res.emplace_back(u);
          break;
        }
      }
    }
    return res;
  }
  void dump(){
    cout<<"idx : ";
    for(int i=0;i<n;++i)cout<<i<<(i+1<n?" ":"\n");
    cout<<"ord : ";
    for(int i=0;i<n;++i)cout<<ord[i]<<(i+1<n?" ":"\n");
    cout<<"low : ";
    for(int i=0;i<n;++i)cout<<low[i]<<(i+1<n?" ":"\n");
  }
};

signed main(){

  int n,m;
  cin>>n>>m;
  vector<vector<int>> adj(n);
  for(int i=0;i<m;++i){
    int u,v;cin>>u>>v;
    adj[u].emplace_back(v);
    adj[v].emplace_back(u);
  }

  lowlink g(adj,0);
  for(auto ans:g.articulation_points()){
    cout<<ans<<endl;
  }
  

}


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

int main(){
    int n,k,x,y;
    cin >> n >> k >> x >> y;
    int ans = 0;
    for(int day = 0; day < n; day++){
        if(day < k) ans += x;
        else ans += y;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = (a); i <= (b); ++i)
#define per(i, a, b) for (int i = (a); i >= (b); --i)
#define pb push_back
#define mp make_pair
#define pr pair<int, int>
#define x first
#define y second
using namespace std;

template<typename T>
void read(T& n){
	char ch; int sign = 1;
	while (!isdigit(ch = getchar())) if (ch == '-') sign = -1;
	n = ch - '0';
	while (isdigit(ch = getchar())) n = n * 10 + ch - '0';
	n *= sign;
}
typedef long long ll;
const int INF = 1e9 + 7;
int n, x, s2, s4;

int main(){
	read(n);
	rep(i, 1, n) read(x), s2 += x % 2 == 0&&x % 4 != 0, s4 += x % 4 == 0;
	puts(s4 + 1 >= n - s4 - s2 + (s2 > 0) ? "Yes" : "No");
	return 0;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(m)]
ans = []
for i in range(m):
    G = [[] for _ in range(n)]
    for ii, jj in enumerate(a):
        if ii != i:
            j, k = jj
            j -= 1
            k -= 1
            G[j].append(k)
            G[k].append(j)
    #print(G)

    visit = [False] * n


    def dfs(p, visit):
        visit[p] = True
        for p2 in G[p]:
            if visit[p2]:
                continue
            dfs(p2, visit)


    dfs(0, visit)
    if all(visit):
        pass
    else:
        ans.append(i)
print(len(ans))


Measured memory_bytes: 42588
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
 
#define FOR(i,k,n) for (int (i)=(k); (i)<(n); ++(i))
#define rep(i,n) FOR(i,0,n)
#define all(v) begin(v), end(v)
#define debug(x) cerr<< #x <<": "<<x<<endl
#define debug2(x,y) cerr<< #x <<": "<< x <<", "<< #y <<": "<< y <<endl
 
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ll> vll;
typedef vector<vector<ll> > vvll;
typedef deque<bool> db;
template<class T> using vv=vector<vector< T > >;

int main() {
  vvi c(3, vi(3, 0));
  rep (i, 3) {
    rep (j, 3) {
      scanf("%d", &c[i][j]);
    }
  }
  vi diff(2, 0);
  diff[0] = c[2][0] - c[2][1];
  diff[1] = c[2][1] - c[2][2];
  rep (i, 2) {
    rep (j, 2) {
      if (c[i][j] - c[i][j+1] == diff[j]) {
      } else {
        printf("No\n");
        return 0;
      }
    }
  }
  printf("Yes\n");

  return 0;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define FORR(i, a, b) for (int i = a; i <= b; i++)
#define REP(i, a, b) for (int i = b - 1; i >= a; i--)
#define FORI(i, a, b, inc) for (int i = a; i <= b; i += inc)
#define FORRI(i, a, b, inc) for (int i = a; i < b; i += inc)
#define REPD(i, a, b, dec) for (int i = b - 1; i >= a; i -= dec)
#define SORT(a, n) sort(a, a + n, greater<int>())
#define PREC(n) cout << fixed << setprecision(n)
#define ULL unsigned long long
#define FT first
#define SN second
#define Vsort(v) sort(v.begin(), v.end())
#define FORV(it, l) for (auto it : l)
#define MP make_pair
#define PB push_back
#define PF push_front
#define POB pop_back
#define POF pop_front
#define RESET(a, b) memset(a, b, sizeof(a))
#define PI acos(-1)
#define S " "
#define VSE(v) v.begin(), v.end()
typedef vector<int> VC;
typedef vector<long long> VCL;
typedef vector<VC> VCC;
typedef pair<int, int> PR;
typedef vector<PR> VPR;
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef set<PR> STP;

void solve()
{
    /*Md. Bokhtiar Nadeem Shawon
    Institute of Information Technology
    Jahangirnagar University
    */
    int a,b,h,m;
    cin >> a >> b >> h >> m;
    double d,ans;
    d =abs((((60 * h) + m) * 1.00000000000000000000) / 2.00000000000000000000) - (6 * m);
    if(d>180.00000000000000000000)
        d = 360.00000000000000000000 - d;
    d = (PI * d) / 180.00000000000000000000;
    ans = sqrt(a * a + b * b - (2 * a * b * cos(d)));
    PREC(20) << ans << endl;
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t;
    /*cin >> t;
    while (t--)*/
    solve();
    return 0;
}

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

using namespace std;

int n;
int a[200001];
int b[200001];
int flag[200001];

int main()
{
    scanf("%d",&n);
    int ans = 0;
    memset(b,0,sizeof b);
    for(int i = 1;i <= n;i++)
        scanf("%d",&a[i]);
    for(int i = n;i >= 1;i--)
    {
        int s = 0;
        for(int j = i;j <= n;j = j + i)
            s += b[j];
        if(s % 2 != a[i])
        {
            b[i] = 1;
            flag[++ans] = i;
        }
    }
    printf("%d\n",ans);
    if(ans)
    {
        for(int i = 1;i < ans;i++)
            printf("%d ",flag[i]);
        printf("%d\n",flag[ans]);
    }
    return 0;
}


Measured memory_bytes: 3072
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
using namespace std;
int main() {
  
  vector<int> vec(3);
  cin>>vec[0]>>vec[1]>>vec[2];
  
  sort(vec.begin(),vec.end());
  
  if(vec[2]>vec[1]){
    cout<<vec[2]<<endl;
  }
  else{
    cout<<vec[0]<<endl;
  }
}

Measured memory_bytes: 3592
mod = 10 ** 9 + 7

n, m = map(int, input().split())
a = tuple(int(input()) for _ in range(m))
b = [False] * (n + 1)
for aa in a:
    b[aa] = True

dp = [0] * (n + 5)
dp[0] = 1

for i in range(n):
    if not b[i]:
        dp[i + 1] += dp[i]
        dp[i + 1] %= mod
        dp[i + 2] += dp[i]
        dp[i + 2] %= mod
print(dp[n])


Measured memory_bytes: 9600
import java.util.*;
import static java.lang.Math.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int h = sc.nextInt();
        int w = sc.nextInt();
        String s[] = new String[h];
        boolean x[] = new boolean[w];
        boolean y[] = new boolean[h];

        Arrays.fill(x, false);
        Arrays.fill(y, false);

        for(int i=0; i<h; i++){
            s[i] = sc.next();
        }

        for(int i=0; i<h; i++){
            for(int j =0; j<w; j++){
                if(s[i].charAt(j)=='#'){
                    x[j] = true;
                    y[i] = true;
                }
            }
        }

        for(int i=0; i<h; i++){
            if(y[i]){
                for(int j=0; j<w; j++){
                    if(x[j]){
                        System.out.print(s[i].charAt(j));
                    }
                }
                System.out.println();
            }
        }
    }
}

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

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

    vector<int> a(1000000);

    int result=0;
    a[0]=s;

    if(a[0]==1 || a[0]==2){
        result=4;
    }else{
        for(int i=1; i<1000000; i++){
            if(a[i-1]==1){
                result=i+1;
                break;
            }
            if(a[i-1]%2==0){
                a[i]=a[i-1]/2;
            }else{
                a[i]=3*a[i-1]+1;
            }
        }
    }
    
    cout<<result<<endl;
}

Measured memory_bytes: 4096
#include <bits/stdc++.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <algorithm>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define print(s) cout << s << endl
#define acc(v) accumulate(v.begin(), v.end(), 0)

using namespace std;
typedef long long ll;
const int INF = 1e9;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;
typedef pair<int, int> pii;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<char> vchar;

int used[110];

int main()
{
	int n;
	cin >> n;
	vector<pii> x(n), y(n);
	rep(i, n)
	{
		int a, b;
		cin >> a >> b;
		x[i] = make_pair(a, b);
	}
	rep(i, n)
	{
		int a, b;
		cin >> a >> b;
		y[i] = make_pair(a, b);
	}
	sort(all(x));
	sort(all(y));
	int ans = 0;
	rep(i, n)
	{
		int m = -1;
		int index = -1;
		rep(k, n)
		{
			if (used[k])
				continue;
			if (x[k].first < y[i].first && x[k].second < y[i].second && x[k].second > m)
			{
				m = x[k].second;
				index = k;
			}
		}
		if(index >= 0){
			used[index] = 1;
			ans++;
		}
		}
	cout << ans << endl;
}


Measured memory_bytes: 256
use strict;
use warnings;
package SuffixArray;
#sub sa_is(\@$);
sub sa_is{
	my$upper=shift;
	my@s=@_;
	my$n=@s;
	if($n==0){
		return();
	}
	elsif($n==1){
		return(0);
	}
	elsif($n==2){
		if($s[0]<$s[1]){
			return(0,1);
		}
		else{
			return(1,0);
		}
	}
	my@sa=(0)x$n;
	my@ls;
	$ls[$n-1]=undef;
	for(my$i=$n-2;$i>=0;$i--){
		$ls[$i]=$s[$i]==$s[$i+1]?$ls[$i+1]:$s[$i]<$s[$i+1];
	}
	my@sum_l=(0)x($upper+1);
	my@sum_s=(0)x($upper+1);
	for(0..$n-1){
		if($ls[$_]){
			$sum_l[$s[$_]+1]++;
		}
		else{
			$sum_s[$s[$_]]++;
		}
	}
	for(0..$upper){
		$sum_s[$_]+=$sum_l[$_];
		$sum_l[$_+1]+=$sum_s[$_]if$_<$upper;
	}
	my$induce;
	$induce=sub{
		my$n=shift;
		my$s=shift;
		my$ls=shift;
		my$sum_l=shift;
		my$sum_s=shift;
		my@sa=(-1)x$n;
		my@buf=@$sum_s;
		for(@_){
			next if$_==$n;
			$sa[$buf[$s->[$_]]++]=$_;
		}
		@buf=@$sum_l;
		$sa[$buf[$s->[$n-1]]++]=$n-1;
		for(0..$n-1){
			my$v=$sa[$_];
			$sa[$buf[$s->[$v-1]]++]=$v-1if$v>=1&&!$ls->[$v-1];
		}
		@buf=@$sum_l;
		for(my$i=$n-1;$i>=0;$i--){
			my$v=$sa[$i];
			$sa[--$buf[$s->[$v-1]+1]]=$v-1if$v>=1&&$ls->[$v-1];
		}
		return@sa;
	};
	my@lms_map=(-1)x($n+1);
	my$m=0;
	my@lms=();
	for(1..$n-1){
		if(!$ls[$_-1]&&$ls[$_]){
			$lms_map[$_]=$m++;
			push@lms,$_;
		}
	}
	@sa=$induce->($n,\@s,\@ls,\@sum_l,\@sum_s,@lms);
	if($m>0){
		my@sorted_lms;
		for(@sa){
			push@sorted_lms,$_ if$lms_map[$_]!=-1;
		}
		my@rec_s=();
		my$rec_upper=0;
		$rec_s[$lms_map[$sorted_lms[0]]]=0;
		for(1..$m-1){
			my$l=$sorted_lms[$_-1];
			my$r=$sorted_lms[$_];
			my$end_l=$lms_map[$l]+1<$m?$lms[$lms_map[$l]+1]:$n;
			my$end_r=$lms_map[$r]+1<$m?$lms[$lms_map[$r]+1]:$n;
			my$same=1;
			if($end_l-$l!=$end_r-$r){
				$same=0;
			}
			else{
				$l++,$r++while$l<$end_l&&$s[$l]==$s[$r];
				$same=0if$l==$n||$r==$n||$s[$l]!=$s[$r];
			}
			$rec_upper++if!$same;
			$rec_s[$lms_map[$sorted_lms[$_]]]=$rec_upper;
		}
		my@rec_sa=sa_is($rec_upper,@rec_s);
		$sorted_lms[$_]=$lms[$rec_sa[$_]]for 0..$m-1;
		@sa=$induce->($n,\@s,\@ls,\@sum_l,\@sum_s,@sorted_lms);
	}
	return@sa;
}
sub suffix_array(\$){
	my@s=map ord,split"",${$_[0]};
	return sa_is(255,@s);
}
package LcpArray;
sub lcp(\@\@){
	my@s=@{$_[0]};
	my$n=@s;
	my@sa=@{$_[1]};
	my@rnk=(0)x$n;
	$rnk[$sa[$_]]=$_ for 0..$n-1;
	my@lcp=(0)x($n-1);
	my$h=0;
	for(0..$n-1){
		$h--if$h>0;
		next if$rnk[$_]==0;
		my$j=$sa[$rnk[$_]-1];
		$h++while$j+$h<$n&&$_+$h<$n&&$s[$j+$h]==$s[$_+$h];
		$lcp[$rnk[$_]-1]=$h;
	}
	return@lcp;
}
sub lcp_array(\$\@){
	my@s=map ord,split"",${$_[0]};
	return lcp(@s,@{$_[1]});
}
package main;
my$s=<>;
chomp$s;
my@sa=SuffixArray::suffix_array($s);
my@lcp=LcpArray::lcp_array($s,@sa);
my$ans=@sa*(@sa+1)/2;
$ans-=$_ for@lcp;
print$ans,$/;


Measured memory_bytes: 266844
#include<bits/stdc++.h>
using namespace std;
int main(){
  string S;
  cin >> S;
  int a=S.size();
  int count=0;
  for(int i=0;i<a;i++){
    if(S.at(i)=='o'){
      count++;
    }
    else{
      count+=0;
    }
  }
  string ans;
  int k=15-a;
  if(count + k>=8){
    ans = "YES";
  }
  else{
    ans="NO";
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;

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

    if(n<10){
    }else if(n>=10&&n<100){
      n = n % 10;
    }else if(n>=100){
    n = n%100;
    n = n%10;
    }


    if(n==3){
      System.out.println("bon");
    }else if((n==0||n==1)||(n==6||n==8)){
      System.out.println("pon");
    }else{
      System.out.println("hon");
    }
  }
}

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

int main(){
    int N,A,B;
    cin >> N >> A >> B;
    long long X[N];
    for(int i=0;i<N;i++){
        cin >> X[i];
    }
    long long ans = 0;
    for(int i=0;i<N-1;i++){
        if ((X[i+1]-X[i])*A<B){
            ans += (X[i+1]-X[i])*A;
        }
        else{
            ans += B;
        }
    }
    cout << ans;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
//size_t f = string::npos
//make pair, tuple

int main(){
      int a[3];cin >> a[0] >> a[1] >> a[2];
      sort(a, a + 3);
      if(a[0] == 5 && a[1] == 5 && a[2] == 7)cout << "YES";
      else cout << "NO";
}

Measured memory_bytes: 256
h,w=map(int,input().split())
l=[[1 if i=='.' else 0 for i in input()] for _ in range(h)]
for i in range(w):
    if l[0][i]==0:
        for j in range(i+1,w):
            l[0][j]=0
        break
for i in range(h):
    if l[i][0]==0:
        for j in range(i+1,h):
            l[j][0]=0
        break
for i in range(1,h):
    for j in range(1,w):
        if l[i][j]!=0:
            l[i][j]=l[i-1][j]+l[i][j-1]
print(l[h-1][w-1]%(10**9+7))


Measured memory_bytes: 204904
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int x1,y1,x2,y2;
    cin >> x1 >> y1 >> x2 >> y2;
    int a = x2 - x1,b = y2 - y1;
    cout << x2 - b << " " << y2 + a << " " << x1 - b << " " << y1 + a;

    return 0;
}

Measured memory_bytes: 256
/*
 * ID: adityaa
 * LANG: C++
 */
#include <bits/stdc++.h>
using namespace std;

#define fio ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define mem(x, y) memset(x, y, sizeof x);
#define fi first
#define se second
#define pb push_back
#define pii pair<int , int>
#define asdfg y1
#define int long long
#define double long double
#define endl '\n'
#define PI 3.14159265359

/*-----------------------------------------------------------------------*/

#define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

/*-----------------------------------------------------------------------*/

// check base cases n = 0 , n = 1
// max / min questions - check for binary search
const int maxn = (int) 1e6 + 6;
const double EPS = 1e-9;
const int INF = (int)1e18 + 18;
const int mod = (int) 998244353;
int n , a[maxn] , b[maxn] , c[maxn];
int dp[maxn][3];

int get(int index , int type){
    if(type == 0) return a[index];
    else if(type == 1) return b[index];
    else return c[index];
}

signed main() {
    
    fio;
    cin >> n;
    for(int i = 1; i <= n; i++){
        cin >> a[i] >> b[i] >> c[i];
    }
    
    dp[1][0] = a[1]; dp[1][1] = b[1]; dp[1][2] = c[1];
    for(int i = 2; i <= n; i++){
        for(int cur = 0; cur < 3; cur++){
            for(int prev = 0; prev < 3; prev++){
                if(cur == prev) continue;
                dp[i][cur] = max(dp[i][cur] , dp[i - 1][prev] + get(i , cur));
            }
        }
    }
    
    cout << max(dp[n][0] , max(dp[n][1] , dp[n][2])) << endl;
    
    
    return 0;
    
}


Measured memory_bytes: 10496
N, M = map(int, input().split())
A = list(map(int, input().split()))
all_A = sum(A)
flag = False
for i in range(M):
  if max(A) >= all_A / (4 * M):
    A.remove(max(A))
  else:
    flag = True
  

print("No" if flag else "Yes")

Measured memory_bytes: 3060
def num_of_division_by_2(num):
    # O(log(num))
    count = 0
    current_num = num
    while current_num % 2 == 0:
        current_num //= 2
        count += 1
    return count

N = int(input())
a_list = [int(elem) for elem in input().split(' ')]
assert len(a_list) == N

total_num_division = 0
for a in a_list:
    total_num_division += num_of_division_by_2(a)

print(total_num_division)


Measured memory_bytes: 4148
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> pii;
const int maxn=100005;
int n,x[maxn],a[16],dp[1<<16],s,mask[1<<16];
vector<int> v;
vector<pii> G[maxn];
void dfs(int u,int fa) {
    for (int i=0;i<(int)G[u].size();++i) {
        int v=G[u][i].first,w=G[u][i].second;
        if (v==fa)
            continue;
        x[v]=w^x[u];
        dfs(v,u);
    }
}
int main()
{
    scanf("%d",&n);
    for (int i=0;i<n-1;++i) {
        int u,v,w;
        scanf("%d%d%d",&u,&v,&w);
        x[u]^=w;
        x[v]^=w;
        G[u].push_back(pii(v,w));
        G[v].push_back(pii(u,w));
    }
    //dfs(0,-1);
    for (int i=0;i<n;++i)
        ++a[x[i]];
    int res=n-a[0];
    for (int i=1;i<16;++i) {
        if (a[i]%2==1)
            v.push_back(i);
        res-=a[i]/2;
    }
    if (!v.size())
        return 0*printf("%d\n",res);
    s=1<<v.size();
    for (int i=0;i<s;++i)
        for (int j=0;j<(int)v.size();++j)
            if (i&(1<<j))
                mask[i]^=v[j];
    for (int i=0;i<s;++i)
        for (int j=0;j<(int)v.size();++j)
            if (i&(1<<j))
                dp[i]=max(dp[i],dp[i^(1<<j)]+(mask[i]==0));
    printf("%d\n",res-dp[s-1]);
    return 0;
}


Measured memory_bytes: 7156
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
inline int read(){
	int s=0,f=1;char c=getchar();
	while(c<'0'||c>'9'){
		if(c=='-')f=-1;c=getchar();
	}
	while(c>='0'&&c<='9'){
		s=(s<<1)+(s<<3)+(c^48);c=getchar();
	}
	return f*s;
}
int main(){
	int a=read(),b=read();
	if(a>b){
		cout<<"safe"<<endl;
	}
	else{
		cout<<"unsafe"<<endl;
	}
	return 0;
}

Measured memory_bytes: 3632
N=int(input())
A=list(map(int,input().split()))
B=[0]*200000
total=0
mini=1000000000000000000
for i in range(N):
    total+=A[i]
    B[i]=total

for i in range(N-1):
    if abs(B[i]-(B[N-1]-B[i]))<mini:
        mini=abs(B[i] - (B[N - 1] - B[i]))
print(mini)

Measured memory_bytes: 23792
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
template<class T> bool umin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool umax(T &a, T b) { return a < b ? (a = b, true) : false; }
#define ALL(x) (x).begin(), (x).end()
LL POW(LL a,LL p,LL M){ if(!p) return 1LL;LL T = POW(a,p/2,M);T = T*T%M; if(p&1) T=T*(a%M)%M; return T; }
LL SQRT(LL a) { LL b = (LL)sqrtl(((double)a)+0.5); while(b*b<a) ++b; while(b*b>a) --b; return (b*b==a)?b:-1; }
//endl
//<------------------------edits---------------------------------------------->
const LL MOD = 1e9+7;//998244353
// #define LOCAL LDD
// #define int LL

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.precision(10);cout << fixed;
#ifdef LOCAL
  freopen("input.txt", "rt", stdin);
#endif
  int a,b,c,d;cin >> a >> b >> c >> d;
  while(a>0 && c>0){
    c -= b;
    if(c<=0){
      cout << "Yes\n";
      return 0;
    }
    a -= d;
    if(a<=0){
      cout << "No\n";
      return 0;
    }
  } 
  cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s\n";
  return 0;
}

Measured memory_bytes: 3672
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
using namespace std;
 
typedef pair<string, int> P;
 
bool compare(string s1, string s2){
  if(s1.size() < s2.size()) return true;
  else if(s1.size() > s2.size()) return false;
  else{
    if(s1 < s2) return true;
    else return false;
  }
}

int main(){
  map<string, int> data;
  vector<string> ans;
  int n;
  
  cin >> n;
  
  string s;
  int t;
  for(int i = 0 ; i < n ; i++){
    cin >> s >> t;
    data[s] += t;
  }
   
  for(map<string, int>::iterator it = data.begin() ; it != data.end() ; it++){
    ans.push_back(it->first);
  }
  
  sort(ans.begin(), ans.end(), compare);
   
  for(int i = 0 ; i < ans.size() ; i++){
    cout << ans[i] << ' ' << data[ans[i]] << endl;
  }
  return 0;
}

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

#ifdef LOCAL
#include "dump.hpp"
#else
#define dump(...)
#define dumpv(...)
#endif

#define rep(i, n) for (int i = 0; i < (n); i++)
typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
const int MOD = 1e9 + 7;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;

struct mint {
  ll v;
  mint() : v(0) {}
  mint(ll v) : v((v % MOD + MOD) % MOD) {}
  mint pow(ll t) const;
  mint inv() const;
};
mint& operator+=(mint& a, mint b) { return a = a.v + b.v; }
mint& operator-=(mint& a, mint b) { return a = a.v - b.v; }
mint& operator*=(mint& a, mint b) { return a = a.v * b.v; }
mint operator+(mint a, mint b) { return a += b; }
mint operator-(mint a, mint b) { return a -= b; }
mint operator*(mint a, mint b) { return a *= b; }
mint operator-(mint a) { return 0 - a; }
mint& operator/=(mint& a, mint b) { return a *= b.inv(); }
mint operator/(mint a, mint b) { return a /= b; }
mint mint::pow(ll t) const {
  if (!t) return 1;
  mint a = pow(t >> 1);
  a *= a;
  if (t & 1) a *= *this;
  return a;
}
mint mint::inv() const { return pow(MOD - 2); }
bool operator==(mint a, mint b) { return a.v == b.v; }
bool operator!=(mint a, mint b) { return a.v != b.v; }
istream& operator>>(istream& os, mint& a) { return (os >> a.v); }
ostream& operator<<(ostream& os, const mint& a) { return (os << a.v); }

mint dp[100005][2]; // [i][j][k] i:上からの桁数、j:より小さい

void solve() {
  string l;
  cin >> l;
  dump(l);
  int n = l.size();
  dump(n);
  dp[0][0] = 1;
  for (int i = 0; i < n; i++) rep(j, 2) {
    int d = (int)(l[i] - '0');
    dump(i, j, d);
    rep(x, 2) {
      int nj = j;
      if (j == 0 && d == 0 && x == 1) continue;
      if (j == 0 && d == 1 && x == 0) nj = 1;
      if (x == 1)
        dp[i + 1][nj] += dp[i][j] * 2;
      else
        dp[i + 1][nj] += dp[i][j];
    }
  }
  dump(dp[n][0], dp[n][1]);
  mint ans = 0;
  rep(j, 2) ans += dp[n][j];
  cout << ans << endl;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  // freopen("temp.1", "r", stdin);
  solve();
  return 0;
}

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

int wa(int n) {
  int sum = 0;
  while (n > 0) {
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

int main() {
  int n, a, b;
  cin >> n >> a >> b;
  int realsum = 0;
  for (int i = 1; i < n + 1; i++) { 
    if ((a <= wa(i)) && (wa(i) <= b)) {
      realsum += i;
    }
  }  
  cout << realsum << endl;  
}

      
      

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define For(i,x,y) for (register int i=(x);i<=(y);i++)
#define FOR(i,x,y) for (register int i=(x);i<(y);i++)
#define Dow(i,x,y) for (register int i=(x);i>=(y);i--)
#define Debug(v) for (auto i:v) printf("%lld ",i);puts("")
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define ep emplace_back
#define siz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define fil(a,b) memset((a),(b),sizeof(a))
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pa;
typedef pair<ll,ll> PA;
typedef vector<int> poly;
inline ll read(){
    ll x=0,f=1;char c=getchar();
    while ((c<'0'||c>'9')&&(c!='-')) c=getchar();
    if (c=='-') f=-1,c=getchar();
    while (c>='0'&&c<='9') x=x*10+c-'0',c=getchar();
    return x*f;
}

const int N = 1e5+10;
int n,a[N],tot,q[4];
pa p[N];
map<int,int>cnt;

int main(){
	n=read();
	For(i,1,n) cnt[a[i]=read()]++;
	for (auto i:cnt) p[++tot]=i;
	sort(p+1,p+1+tot,[](pa a,pa b){
		return a.se>b.se;
	});
	if (tot==1){
		if (p[1].fi==0) puts("Yes");
			else puts("No");
		return 0;
	}
	if (n%3) return puts("No"),0;
	if (tot==2){
		if (p[2].se!=n/3) return puts("No"),0;
		if (p[2].fi!=0) return puts("No"),0;
		return puts("Yes"),0;
	}
	if (tot!=3) return puts("No"),0;
	For(i,1,tot) if (p[i].se!=n/3) return puts("No"),0;
	For(i,1,3) q[i]=i;
	do {
		bool flag=1;
		For(i,1,3){
			int l=i==1?3:i-1,r=i==3?1:i+1;
			if ((p[q[l]].fi^p[q[r]].fi)!=p[q[i]].fi){
				flag=0;
				break;
			}
		}
		if (flag) return puts("Yes"),0;
	} while (next_permutation(q+1,q+1+tot));
	puts("No");
}

Measured memory_bytes: 8108
def inpf() a=gets.chomp.split(" ").map(&:to_f)end

def inps() a=gets.chomp.split(" ")end

def copy(a) Marshal.load(Marshal.dump(a)) end

def kaijo(n,r = 10**9+7)(n < 2)? 1 : (2..n).inject{|memo,u|memo=(memo*u)%r} end

def na(n,d=0) Array.new(n,d)end

def na2(n,m,d=0) Array.new(n){Array.new(m,d)}end

def na3(n,m,l,d=0) Array.new(n){Array.new(m){Array.new(l,d)}}end

def inp() a=gets.chomp.split(" ").map(&:to_i)end

def r_up(a, b) (a+b-1)/b
end #for auto indent of eclipse

n = inp[0]
a = inp

uu = []
mm = []
ans = 0
a.sort.each do |d|
  uu.push(d) if(d >= 0)
  mm.push(d) if(d < 0)
  ans += d.abs
end
mc = nil
unless (mm.size == 0)
  mc = mm[-1]
else
  mc = uu[0]
end
if(mm.size == 0 or uu.size == 0)
  p ans - mc.abs*2 
else
  p ans
end
unless (mm.size == 0)
  mc = mm.pop
else
  mc = uu.shift
end


(uu.size-1).times do |i|
  puts "#{mc} #{uu[i]}"
  mc = mc - uu[i]
end
if(uu.size != 0)
  puts "#{uu[uu.size-1]} #{mc}"
  mc = uu[uu.size-1] - mc
end
mm.each do |d|
  puts "#{mc} #{d}"
  mc = mc - d
end


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

const ll N_MAX = 1e9;

ll N;

void solve(){
  
  string ans = "";

  if(N == 0) ans = "0";
  ll b = 1;

  while(N != 0){
    if(N % 2 == 0) ans = '0' + ans;
    else {
      ans = '1' + ans;
      N -= b;
    }

    b *= -1;
    N /= 2;
  }

  cout << ans << endl;
}


int main() {

  cin >> N;

  solve();
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#define llint long long

using namespace std;

llint n, m;
llint x[100005];
vector<llint> vec;

int main(void)
{
	cin >> n >> m;
	for(int i = 0; i < m; i++) cin >> x[i];
	sort(x, x+m);
	
	for(int i = 0; i < m-1; i++) vec.push_back(x[i+1]-x[i]);
	sort(vec.begin(), vec.end());
	
	if(m <= n){
		cout << 0 << endl;
		return 0;
	}
	
	llint ans = 0;
	for(int i = 0; i < m-n; i++) ans += vec[i];
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 2168
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  int N;
  cin>>N;
  ll A[N+1];
  for(int i=0;i<N;++i) cin>>A[i+1];
  for(int i=1;i<=N;++i) A[i] += A[i-1];
  for(int i=0;i<=N;++i) A[i] %= mod;
  ll ans = 0;
  for(int i=0;i<N;++i) {
    ans += ((A[i+1]-A[i]+mod)%mod)*((A[N]-A[i+1]+mod)%mod)%mod;
    ans %= mod;
  }
  cout<<ans<<endl;
}




Measured memory_bytes: 5156
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define rep3(i, s, n) for (int i = s; i > (int)(n); i--)
#define all(obj) obj.begin(), obj.end()
#define db(x) cerr << #x << ":" << x << " "
#define dbl(x) cerr << #x << ":" << x << "\n"
#define dbv(vec) cerr << #vec << ":"; for (auto e : vec) cerr << e << " "; cout << "\n"
#define dbvv(vv) cerr << #vv << ":\n"; for (auto vec : vv) { for (auto e : vec) cerr << e << " "; cerr << endl; }
#define YN(f) cout << (f ? "YES" : "NO") << endl
#define Yn(f) cout << (f ? "Yes" : "No") << endl
#define yn(f) cout << (f ? "yes" : "no") << endl
/*
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
*/

int main() {
	string S; cin >> S;
	int N = S.length();
	bool f = true;
	for (int i = 0; i < N; i++) {
		if (S[i] != S[N - 1 - i]) {
			f = false;
		}
	}
	for (int i = 0; i < (N -1) / 2 ; i++) {
		if (S[i] != S[(N - 3) / 2 - i]) {
			f = false;
		}
	}
	Yn(f);
}

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

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

  vector<int> t(n + 1);
  vector<int> x(n + 1);
  vector<int> y(n + 1);
  for (int i = 1; i <= n; i++) {
    cin >> t.at(i) >> x.at(i) >> y.at(i);
  }

  bool canArrive = true;
  for (int i = 0; i < n; i++) {
    int dt = t.at(i + 1) - t.at(i);
    int dist = abs(x.at(i + 1) - x.at(i)) + abs(y.at(i + 1) - y.at(i));
    if (dist > dt) {
      canArrive = false;
      break;
    }
    if (dist % 2 != dt % 2) {
      canArrive = false;
      break;
    }
  }

  if (canArrive) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,n) for(int i=1;i<=n;i++)
const ll MOD = 1000000007;
long long modinv(long long a, long long m=MOD) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
    /*MODの割り算の際に
    a/＝b;
    を
    a *= modinv(b,MOD);
    とする。
        */
}
int main(){
    int X,Y,Z;
    cin >> X >> Y >> Z;
    swap(X,Y);
    swap(X,Z);
    cout << X << " " << Y << " "<< Z << endl;
    return 0;
}

Measured memory_bytes: 3628
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Runtime;

namespace b
{
    internal class Program
    {
        public static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());

            int[] p = new int[n];
            for (int i = 0; i < n; i++)
            {
                p[i] = int.Parse(Console.ReadLine());
            }

            int[] memo = new int[n + 1];
            for (int i = 0; i < n; i++)
            {
                if (memo[p[i] - 1] == 0)
                {
                    memo[p[i]] = 1;
                    continue;
                }
                memo[p[i]] = memo[p[i] - 1] + 1;
            }

            Console.WriteLine(n - memo.Max());
        }
    }
}

Measured memory_bytes: 18652
#include <cstdio>

using namespace std;

int a[100000];

int main() {
    int n, ans = 0, i, j;
    
    scanf("%d", &n);
    
    for (i = 0; i < n; i++) scanf("%d", &a[i]);
    
    for (i = 0; i < n; ) {
        for (j = i; j < n; j++) {
            if (a[j] != a[i]) break;
        }
        
        if (a[j] > a[i]) {
            for (; j < n; j++) {
                if (a[j] < a[j - 1]) break;
            }
        } else {
            for (; j < n; j++) {
                if (a[j] > a[j - 1]) break;
            }
        }
        
        ans++;
        i = j;
    }
    
    printf("%d\n", ans);
    
    return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef unsigned long long int ulli;
typedef long double ld;
const lli INF = 1e9 + 100;
const lli INF64 = (1LL << 61) + 100;
const lli MOD = 1e9 + 7;
const lli MH1 = 1599614977, MH2 = 2034417103, MH3 = 1090250123, MH4 = 2024491871; 
lli bpow(lli baseee, lli exponenttt) {
	if(exponenttt < 0) return 0;
	lli res = 1;
	baseee %= MOD;
	while (exponenttt > 0) {
		if ((exponenttt & 1) == 1) res = (res*baseee) % MOD;
		baseee = (baseee*baseee) % MOD;
		exponenttt >>= 1;
	}
	return res;
}
lli multInverse(lli a) {//if_mod_is_prime
	return bpow(a, MOD - 2);
}
lli divm(lli a, lli b) {//if_mod_is_prime
	return (a * multInverse(b)) % MOD;
}
lli multm(lli a, lli b) {
	return (a * b) % MOD;
}
lli subm(lli a, lli b) {
	a += MOD;
	lli r = a - b;
	if(r >= MOD) return r - MOD;
	return r;
}
lli addm(lli a, lli b) {
	lli r = a + b;
	if(r >= MOD) return r - MOD;
	return r;
}
signed main() {
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	//	freopen("input.txt", "r", stdin);
	//	freopen("output.txt", "w", stdout);
	string s, t;
	cin >> s >> t;
	int ans = 0;
	for(int i = 0; i < s.length(); i++)
		if(s[i] != t[i])
			ans++;
	cout << ans << "\n";
	return 0;
}

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

int n,a,b,c,l[10],ans=2e9;

void dfs(int i,int x,int y,int z,int combo){
    if(i>n){
        if(x&&y&&z){
            ans=min(ans,abs(x-a)+abs(y-b)+abs(z-c)+combo*10);
        }
        return;
    }
    dfs(i+1,x+l[i],y,z,combo+1);
    dfs(i+1,x,y+l[i],z,combo+1);
    dfs(i+1,x,y,z+l[i],combo+1);
    dfs(i+1,x,y,z,combo);
}

int main(){
    cin>>n>>a>>b>>c;
    for(int i=1;i<=n;i++){
        cin>>l[i];
    }
    dfs(1,0,0,0,-3);
    cout << ans <<endl;
    return 0;
}





Measured memory_bytes: 256
#include<bits/stdc++.h> 
using namespace std; 
const long long mod=1e9+7;
int main(){
  int N,M; 
  cin>>N>>M;
  vector<int>oks(N+1,true); 
  for(int i=0;i<M;++i){ 
    int a;cin>>a; 
    oks[a]=false; 
  }
  vector<long long int>dp(N+1); 
  dp[0]=1; 
  for(int now=0;now<N;++now){ 
    for(int next=now+1;next<=min(N,now+2);++next){ 
      if(oks[next]){
        dp[next]+=dp[now]; 
        dp[next]%=mod; 
      }
    }
  }
  cout<<dp[N]<<endl; 
  return 0; 
}



Measured memory_bytes: 1408
#include <bits/stdc++.h>
#include <unordered_map>
#include <queue>
#define MOD 1000000007

using namespace std;

int main() {
    long long N,M;
    priority_queue<long long> q;
    cin>>N>>M;
    for(long long i=1;i<=sqrt(M);i++){
        if(M%i==0){
            q.push(i);
            q.push(M/i);
        }
    }
    while(q.size()!=0){
        long long divisor = q.top();
        q.pop();
        if(M/divisor>=N){
            cout<<divisor;
            break;
        }
    }
    return 0;
}

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

#define MAX 100001

typedef long long llong;

llong n; //货物的个数
llong k; //车辆的个数
llong T[MAX]; //每个货物的重量

int check(llong P) {// 计算当最大的载重为P的时候 最多可以装多少货物
	int i = 0;
	
	for(int j = 0; j<k; j++){
		int sum = 0;
		while(sum+T[i]<=P){
			sum+=T[i];
			i++;
			if(i == n){
				return n;
			}
		}
	}
	return i;
}

int solve(){
	llong left = 0;
	llong right = 1e9;
	llong mid;

	while(left<right){
		mid = (left+right) / 2;
		int tem = check(mid); //返回mid时能装的货物的重量
		if(tem >= n){
			right = mid;
		}
		else{
			left = mid+1;
		}
	}

	return right;
}

int main(){

	cin>>n>>k;
	for(int i=0; i<n; i++){
		cin>>T[i];
	}
	int ans = solve();
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3900
import qualified Data.Vector.Unboxed as V
import Data.Array.IArray (listArray, accumArray, (!))
import Data.Array.MArray
import Data.Array.ST (STUArray, runSTUArray)
import Data.Array.Unboxed (UArray)
import Data.List (sortOn, sortBy, unfoldr, partition)
import Data.Char (isSpace)
import Control.Monad.ST (ST)
import Control.Monad.Trans.State (StateT(..))
import qualified Data.ByteString.Char8 as B

-- utility functions

--   Input functions
readInt = B.readInt . B.dropWhile isSpace

readInts :: Int -> B.ByteString -> [Int]
readInts n = take n . unfoldr readInt

readIntsV :: Int -> B.ByteString -> V.Vector Int
readIntsV n = V.unfoldrN n readInt

readIntsA :: Int -> B.ByteString -> UArray Int Int
readIntsA n bs = runSTUArray $ do
  arr <- newArray_ (0,n-1)
  go arr 0 bs
  return arr
  where
    go :: STUArray s Int Int -> Int -> B.ByteString -> ST s ()
    go arr i bs
      | i==n = return ()
      | otherwise = do
        let Just (x,bs') = readInt bs
        writeArray arr i x
        go arr (i+1) bs'

readTsV :: Int -> B.ByteString -> V.Vector (Int,Int)
readTsV n = V.unfoldrN n $ runStateT ((,) <$> StateT readInt <*> StateT readInt)

readTs :: Int -> B.ByteString -> [(Int,Int)]
readTs n = take n . unfoldr readT where
  readT = runStateT ((,) <$> StateT readInt <*> StateT readInt)

-- main

solv m ts = go 0 ts where
  go s ((pr,st):ts)
    | s+st>=m = pr * (m-s)
    | otherwise = go (s+st) ts + pr*st

main = do
  [n,m] <- map read . words <$> getLine
  ts <- sortOn fst . readTs n <$> B.getContents
  print $ solv m ts


Measured memory_bytes: 30076
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
int main() {
  cin.tie(0),cout.tie(0);
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  if(s=="SUN") {
    cout << 7 << endl;
  }
  if(s=="MON") {
    cout << 6 << endl;
  }
  if(s=="TUE") {
    cout << 5 << endl;
  }
  if(s=="WED") {
    cout << 4 << endl;
  }
  if(s=="THU") {
    cout << 3 << endl;
  }
  if(s=="FRI") {
    cout << 2 << endl;
  }
  if(s=="SAT") {
    cout << 1 << endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
    int n, k, a[55], s = 0, b;
    cin >> n >> k;
    for(int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    for(int i = 0; i< n; i++)
    {
        for(int j = 0; j < n; j++)
        {
            if(a[i] > a[j])
            {
                b = a[i];
                a[i] = a[j];
                a[j] = b;
            }
        }
    }

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

    cout << s;
}

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

int main()
{
    int n, m;
    char c[200], a, b, p;

    while( cin >> n )
    {
        if( n == 0 )
            break;    
        for( int i = 0; i < 200; i++ )
            c[i] = '.';
        for( int i = 0; i < n; i++ )
        {
            cin >> a >> b;
            c[a] = b;
        }

        cin >> m;

        for( int i = 0; i < m; i++ )
        {
            cin >> p;
            if( c[p] == '.' )
                cout << p;
            else
                cout << c[p];
        }
        cout << endl;
    }   
    return 0;
}


Measured memory_bytes: 3096
#include <algorithm>
#include <array>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;

constexpr ll infl = 1000000000000000007LL;
constexpr int inf = 1000000007;

int main() {
    int h, w; cin >> h >> w;
    vector<string> grid(h);
    for (int i = 0; i < h; ++i) {
        cin >> grid[i];
    }

    int ans = 0;

    for (int i = 0; i < h * w; ++i) {
        for (int j = 0; j < h * w; ++j) {
            int sx = i % w;
            int sy = i / w;
            int gx = j % w;
            int gy = j / w;

            if (grid[sy][sx] == '#' || grid[gy][gx] == '#') continue;

            vector<vector<int>> d(h, vector<int>(w, inf));
            d[sy][sx] = 0;
            queue<pair<int, int>> que;
            que.push(make_pair(sy, sx));

            pair<int, int> dir[] = {
                {1, 0},
                {0, 1},
                {-1, 0},
                {0, -1},
            };

            while (!que.empty()) {
                auto p = que.front(); que.pop();
                for (const auto& e : dir) {
                    int toy = e.first + p.first;
                    int tox = e.second + p.second;

                    if (0 <= toy && toy < h && 0 <= tox && tox < w && d[toy][tox] == inf && grid[toy][tox] != '#') {
                        d[toy][tox] = d[p.first][p.second] + 1;
                        que.push(make_pair(toy, tox));
                    }
                }
            }

            if (d[gy][gx] != inf) ans = max(ans, d[gy][gx]);
        }
    }

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

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int n,k;cin>>n>>k;
  long long c=0;
  for(long long kk=k;kk<=n+1;kk++){
    c=(kk*(n+1-kk)+1+c)%(1000000007);
  }
  cout<<c<<endl;
  return 0;
}


Measured memory_bytes: 3576
//----------------------------------------------------------------------
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
//----------------------------------------------------------------------

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

int main(void) {
    int n, m;
    cin >> n >> m;
    Graph G(n);
    rep(i, m) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    bool flag = false;

    for(auto v : G[0]) {
        for( auto v2 : G[v]) {
            if(v2 == n-1) {
                flag = true;
                break;
            }
        }
    }
     cout << (flag ? "POSSIBLE" : "IMPOSSIBLE") << endl;

    return 0;
}


Measured memory_bytes: 12016
#include<bits/stdc++.h>
using namespace std;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a, b, c;
  cin >> a >> b >> c;
  int ans = 0;
  int cnt = 0;
  if(a%2 == 0) cnt++;
  if(b%2 == 0) cnt++;
  if(c%2 == 0) cnt++;
  if(cnt == 1){
    if(a%2 == 1) a++;
    if(b%2 == 1) b++;
    if(c%2 == 1) c++;
    ans++;
  }
  else if(cnt == 2){
    if(a%2 == 0) a++;
    if(b%2 == 0) b++;
    if(c%2 == 0) c++;
    ans++;
  }
  ans += (max({a, b, c}) - a) / 2;
  ans += (max({a, b, c}) - b) / 2;
  ans += (max({a, b, c}) - c) / 2;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
mod = 1_000_000_007

n = gets.to_s.to_i

h = Hash.new{|h, k| h[k] = [0, 0] }
genten_iwashi = 0

$<.read.split.map(&:to_i).each_slice(2) do |(a,b)|

  if a == 0 && b == 0
    genten_iwashi += 1
  else
    f = a.zero? || a * b > 0
    r = ( f ? Rational(a,b) : -Rational(b,a) )
    h[r][ f ? 0 : 1 ] += 1
  end
end

ans = 1
h.each do |k, (a, b)|
  ans *= ( 2.pow(a,mod) + 2.pow(b, mod) - 1)
  ans %= mod
end

ans = ( ans - 1 + genten_iwashi ) % mod

puts ans

Measured memory_bytes: 72512