akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ll one[4][11],two[4][11],three[4][11],four[4][11],n,i,j,k;
    cin>>n;
    ll b[n],f[n],r[n],v[n];
    for(i=1; i<=n; i++)
    {
        cin>>b[i]>>f[i]>>r[i]>>v[i];
    }
    for(i=1; i<=3; i++)
    {
        for(j=1; j<=10; j++)
        {
            one[i][j]=two[i][j]=three[i][j]=four[i][j]=0;
        }
    }
    for(i=1; i<=n; i++)
    {
        if(b[i]==1) one[f[i]][r[i]]+=v[i];
        if(b[i]==2) two[f[i]][r[i]]+=v[i];
        if(b[i]==3) three[f[i]][r[i]]+=v[i];
        if(b[i]==4) four[f[i]][r[i]]+=v[i];
    }
    for(i=1; i<=3; i++)
    {
        for(j=1; j<=10; j++)
        {
            cout<<" "<<one[i][j];
        }
        cout<<endl;
    }
    cout<<"####################"<<endl;
    for(i=1; i<=3; i++)
    {
        for(j=1; j<=10; j++)
        {
            cout<<" "<<two[i][j];
        }
        cout<<endl;
    }
    cout<<"####################"<<endl;
    for(i=1; i<=3; i++)
    {
        for(j=1; j<=10; j++)
        {
            cout<<" "<<three[i][j];
        }
        cout<<endl;
    }
    cout<<"####################"<<endl;
    for(i=1; i<=3; i++)
    {
        for(j=1; j<=10; j++)
        {
            cout<<" "<<four[i][j];
        }
        cout<<endl;
    }
    return 0;
}



Measured memory_bytes: 3068
#include<iostream>

using namespace std;
   
void Simultaneous()
{
    double a, b, c, d, e, f;
    double x, y;
      
    while(cin>>a>>b>>c>>d>>e>>f)  
    {
        x = ( c * e - b * f ) / ( a * e - b * d );
        y = ( a * f - c * d ) / ( a * e - b * d );
        
        cout.setf(ios::fixed); //"setf" is used for “half-adjusting”
        cout.precision(3); //precision is used for rould off three places of decimals
        
        //-0主要用来表&#36798;浮点数
        //-0有可能被用来表示一个可以四舍五入&#20026;零的&#36127;数，或者是一个从&#36127;方向上&#36235;近于零的数。
        // 下面的式子可&#35753;&#36127;0&#21464;成无符号的0
        if(x == 0)
        {
            x = 0;
        }
        
        if(y == 0)
        {
            y = 0;
        }
        
        cout<<x<<" "<<y<<endl;
    }
            
    return;
}
     
int main()
{     
    Simultaneous();
    return 0;
}

Measured memory_bytes: 1284
class UnionFind():
    """Union Find実装"""

    def __init__(self, n):
        """要素数nで初期化する"""
        self.n = n

        # rootノードでその木の要素数を記録する
        # root[x]<0ならそのノードが根かつその値が木の要素数
        self.root = [-1]*(n+1)
        
        # 木の高さを記録
        # Union時に高さの低い木を高い木にくっつける
        self.rank = [0]*(n+1)

    def find(self, x):
        """ノードXのルートノードを返す"""

        # root[x]<0ならそのノードが根かつその値が木の要素数
        if (self.root[x] < 0):
            return x
        
        # 経路圧縮しながらルートノードを見つける
        self.root[x] = self.find(self.root[x])
        return self.root[x]

    def union(self, x, y):
        """ノードxの属するツリーとノードyの属するツリーをくっつける"""
        
        # ルートノードを見つける
        x = self.find(x)
        y = self.find(y)

        # 同じ木の場合は何もしない
        if (x == y):
            return

        # 違う木の場合は木のたかさrankを見てくっつける木を選ぶ 
        # 高さが同じ場合はxをyにくっつける
        if (self.rank[x] > self.rank[y]):
            # 要素数を足す
            self.root[x] += self.root[y]
            # 木をくっつける
            self.root[y] = x
        else:
            self.root[y] += self.root[x]
            self.root[x] = y
            
            # rankが同じ場合は１増やす
            if (self.rank[x] == self.rank[y]): self.rank[y] += 1

    def same(self, x, y):
        """xとyが同じ木に属するかどうか判定する"""
        return self.find(x) == self.find(y)

    def count(self, x):
        """xが属する木のノード数を返す"""
        return -self.root[self.find(x)]
        
N, M, K = map(int, input().split())
uf = UnionFind(N)
blocks = [[] for i in range(N+1)]
friends = [0] * (N+1)

for i in range(M):
    a, b = map(int, input().split())
    friends[a] += 1
    friends[b] += 1
    uf.union(a, b)

for i in range(K):
    c, d = map(int, input().split())
    blocks[c].append(d)
    blocks[d].append(c)

ans = [0] * N
for i in range(1, N+1):
    block_num = 0
    for b in blocks[i]:
        if uf.same(i, b):
            block_num += 1
    ans[i-1] = uf.count(i) - block_num - friends[i] - 1

print(' '.join(map(str, ans)))

Measured memory_bytes: 34028
#include <iostream>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <limits>
#include <numeric>
#include <algorithm>
#include <functional>

using namespace std;

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

	int A, B;
	cin >> A >> B;

	if ((A + B) % 2 == 0)
	{
		cout << (A + B) / 2;
	}
	else
	{
		cout << "IMPOSSIBLE";
	}

	return 0;
}


Measured memory_bytes: 3612
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
using namespace std;
int main() {
	int a, b, d, e;
	cin >> a;
	if (a / 100 > a % 100 / 10) {
		cout << a / 100 << a / 100 << a / 100 << "\n";
	}
	else if (a / 100 == a % 100 / 10 && a / 100 >= a % 100 % 10) {
		cout << a / 100 << a / 100 << a / 100 << "\n";
	}

	else {
		cout << a / 100 + 1 << a / 100 + 1 << a / 100 + 1 << "\n";
	}
	cin >> e;
}

Measured memory_bytes: 256
//
//  main.cpp
//  ABC170F
#include <iostream>
#include <vector>
#include <queue> // priority_queueを使う
#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;
using ll = long long;
using P=pair<int,int>;
using LP=pair<ll,int>;
const ll INF=1e18;
const int di[]={-1,0,1,0};
const int dj[]={0,-1,0,1};
int main(int argc, const char * argv[]) {
    int h,w,k;
    cin >>h>>w>>k;
    int si,sj,ti,tj;
    cin>>si>>sj>>ti>>tj;
    --si;--sj;--ti;--tj;
    vector<string>g(h);
    rep(i,h) cin>>g.at(i);

    auto toID=[&](int i,int j,int v){
        return (i*w+j)*4+v;
    };
    auto modCeilK=[&](ll x){
        return (x+k-1)/k*k;
    };
    vector<ll>dist(h*w*4,INF);
    priority_queue<LP,vector<LP>,greater<LP>>q;
    auto push=[&](int i,int j,int v,ll x){
        int id=toID(i,j,v);
        if(dist.at(id)<=x) return;
        dist.at(id)=x;
        q.emplace(x,id);
    };
    rep(v,4) push(si,sj,v,0);
    while(!q.empty()){
        ll d=q.top().first;
        int id=q.top().second;
        q.pop();
        if (dist.at(id)!=d) {
            continue;
        }
        int i=id/w/4;
        int j=id/4%w;
        int v=id%4;
        rep(nv,4){
            push(i,j,nv,modCeilK(d));
        }
            int ni=i+di[v];
            int nj=j+dj[v];
            if(0<=ni&&ni<h&&0<=nj&&nj<w){
                if(g.at(ni).at(nj)=='.'){
                    push(ni,nj,v,d+1);
                }
            }
    }
    ll ans=INF;
    rep(v,4) ans=min(ans,dist.at(toID(ti,tj,v)));
    if (ans==INF) {
        cout<<-1<<endl;
    }else{
        ans=modCeilK(ans)/k;
        cout<<ans<<endl;
    }
    return 0;
}


Measured memory_bytes: 43528
<?php
list($K)=sscanf(trim(fgets(STDIN)),"%d");
$AAA = array(1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51);

echo (int)$AAA[$K-1];

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

int main(){
  char S[10];
  cin >> S;
  
  sort(S, S+4);
  
  if(S[0] == S[1] && S[1] != S[2] && S[2] == S[3]){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  
  return 0;
}

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

string s;

int main(){
  cin >> s;
  int n = s.size();
  string res = "YES";
  for(int i = n - 1; i >= 0;){
    //cerr << s.substr(i - 6, 7) << endl;
    if(i >= 6 && s.substr(i - 6, 7) == "dreamer"){
      i -= 7;
      continue;
    }else if(i >= 5 && s.substr(i - 5, 6) == "eraser"){
      i -= 6;
      continue;
    }else if(i >= 4 && s.substr(i - 4, 5) == "erase"){
      i -= 5;
      continue;
    }else if(i >= 4 && s.substr(i - 4, 5) == "dream"){
      i -= 5;
      continue;
    }
    res = "NO";
    break;
  }
  cout << res << endl;   
  return 0;
}


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

using namespace std;
typedef long long ll;
typedef long int li;
typedef long double lb;
#define rep(i,j,n) for (ll i = j; i < (n); i++)
#define repr(i,j,n) for(ll i = j; i >= (n); i--)
#define all(x) (x).begin(),(x).end()
#define CLR(mat,f) memset(mat, f, sizeof(mat))
#define IN(a, b, x) (a<=x&&x<b)
#define out(ans) cout << ans << endl
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef pair<ll,ll>P;
const ll mod=1e9+7;
const ll INF = 1LL<<60;

int main(){

  ll n,m;cin>>n>>m;
  vector<vector<ll> >v(m);
  rep(i,0,m){
    ll k;cin>>k;
    rep(j,0,k){
      ll s;cin>>s;
      v[i].push_back(--s);
    }
  }
  ll p[m];
  rep(i,0,m)cin>>p[i];

  ll ans=0;
  rep(bit,0,(1<<n)){
    bool e=true;
    rep(i,0,m){
      ll count=0;
      rep(j,0,v[i].size()){
        if((bit>>v[i][j])&1)count++;
      }
      if(count%2!=p[i])e=false;
    }
    if(e)ans++;
  }

  out(ans);

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  ios::sync_with_stdio(false);
  cin.tie(NULL);cout.tie(NULL);
  #ifndef ONLINE_JUDGE
      freopen("input.txt", "r", stdin);
      freopen("output.txt", "w", stdout);
  #endif
  int n;cin>>n;
  int a[n],b[n],c[n];
  for(auto &x : a) cin>>x;
  for(auto &y : b) cin>>y;
  for(int i=0;i<n;i++){
      c[i]=i+1;
  }
  bool ok(1),okk(1);
  int r1(0),r2(0);
  do{
    int p=0,q=0;
    if(ok){
      for(int i=0;i<n;i++){
        if(a[i]!=c[i]){
          p=1;break;
        }
      }r1++;
      if(p==0){
        ok=0;
      }
    }
    if(okk){
      for(int i=0;i<n;i++){
        if(b[i]!=c[i]){
          q=1;break;
        }
      }r2++;
      if(q==0){
        okk=0;
      }
    }
    if(p==0 and q==0)
      break;
  }while(next_permutation(c,c+n));
  cout<<abs(r1-r2);
}


Measured memory_bytes: 3576
#include<bits/stdc++.h>
using namespace std;
const long long INF = 1e9;
const long long MOD = 1000000007;
const long double PI = 3.1415926;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
#define ll long long int
typedef vector<int> vi;
typedef vector < pair<int, int > > vp;
typedef vector <string> vs;
typedef vector <char> vc;
ll  n, k, ans = 0, sum = 0, cnt = 0;
string s;
char c;

/*--------------------template--------------------*/

int main() {
	s = "YES";
	int n, m;
	cin >> n >> m;
	vi v(n + 1);
	REP(i, m) {
		int a, b;
		cin >> a >> b;
		v[a]++;
		v[b]++;
	}
	REP(i, n) v[i + 1] += v[i];
	REP(i, n + 1) {
		if (v[i] % 2 == 1) {
			s = "NO";
			break;
		}
	}
	cout << s << endl;
}

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

signed main()
{
	int n;
	cin>>n;
	ll cnt=0;
	for(int i=1;i<=n;i++){
		if(i%3&&i%5)cnt+=i;
	}
	cout<<cnt<<endl;
	return 0;
}

Measured memory_bytes: 3560
#include <iostream>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>

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

ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
typedef pair <ll,ll> P;


int main()
{
    string a, b , c;
    cin >> a >> b >> c;
    if (a.back() == b.front() & b.back() == c.front() ) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main()
{
    char str[200];
    int i;
    gets(str);
    for(i=0; i<=strlen(str); i++)
    {
        if(str[i]>=97&&str[i]<=122)
            str[i]=str[i]-32;
    }
    printf("%s\n",str);
    return 0;
}

Measured memory_bytes: 520
def solve() :
    x, y = map(int, input().split(" "))

    if y%2 :
        return "No"
        
    a = y-(2*x)
    if a%2 or a<0 :
        return "No"
    
    a = a//2
    if x-a < 0 :
        return "No"

    return "Yes"

print(solve())        

Measured memory_bytes: 9176
#include <iostream>
#include <queue>
#include <complex>

using namespace std;

struct Node {
	int x, y, step;
};

int _m[200][200] = {0};
bool _reached[200][200] = {0};
int main() {
	int t, n;
	while (cin >> t >> n, t || n) {
		fill(&_m[0][0], &_m[0][0]+200*200, 0);
		int (*m)[200] = _m + 100;

		for (int i = 0; i < n; ++i) {
			int x, y; cin >> x >> y;
			m[y][x] = true;
		}
		int sx, sy; cin >> sx >> sy;

		fill(&_reached[0][0], &_reached[0][0]+200*200, false);
		bool (*reached)[200] = _reached + 100;
		queue<Node> Q; Q.push({sx, sy, 0});
		while ( !Q.empty() ) {
			Node node = Q.front(); Q.pop();
			int step = node.step, x = node.x, y = node.y;
			if (step > t) continue;
			if (m[y][x]) continue;
			if (reached[y][x]) continue;
			reached[y][x] = true;

			Q.push({x+1, y+1, step+1});
			Q.push({x+1, y, step+1});
			Q.push({x, y-1, step+1});
			Q.push({x-1, y-1, step+1});
			Q.push({x-1, y, step+1});
			Q.push({x, y+1, step+1});
		}
		int ans = 0;
		for (int y = -60; y <= 60; ++y) {
			for (int x = -60; x <= 60; ++x) {
				if ( reached[y][x] ) {
					++ans;
				}
			}
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 1432
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,m;
    cin >> n >> m;
    vector<pair<long,long> >p(n);
    for(int i=0;i<n;i++){
        cin >> p[i].first >> p[i].second;
    }
    sort(p.begin(),p.end());
    
    long ans = 0;
    int i=0;
    while(m>0){
        if(p[i].second>0){
            ans += p[i].first;
            p[i].second--;
            m--;
        }else{
            i++;
        }
    }
    cout << ans << endl;

}

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

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

    int n;
    cin >> n;
    ll T;
    cin >> T;

    vector<ll> t(n);
    REP(i, n) cin >> t[i];

    ll res = 0;
    REP(i, n - 1)
        res += min(t[i + 1] - t[i], T);
    res += T;

    cout << res << '\n';
    return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
using namespace std;
using ll = long long;
 
int main() {
    ll X, K, D;
    cin >> X >> K >> D;
    X = abs(X);
 
    ll straight = min(K, X / D);
    K -= straight;
    X -= straight * D;
 
    if (K % 2 == 0) {
        cout << X << endl;
    } else {
        cout << D - X << endl;
    }
 
    return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define req(i,n) for(int i = 1;i <=n;i++)
#define pai 3.14159265358979323846
const int INF = 1001001001;
typedef long long ll;
int A[3][3], N;
bool punched[3][3];
bool ok[3][3];
using Graph = vector<vector<int>>;
vector<vector<int>> field;
vector<bool> seen;

const int MOD = 1000000007;
typedef pair<int,int> P;

//最大公約数
ll gcd(ll a,ll b){
	if (a%b == 0){
		return b;
	}
	else{
		return gcd(b,a%b);
	}

}

//最小公倍数
ll lcm(ll a,ll b){
	return a /gcd(a,b) * b;
}

//素数判定
bool is_prime(long long N) {
    if (N == 1) return false;
    for (long long i = 2; i * i <= N; ++i) {
        if (N % i == 0) return false;
    }
    return true;
}

// 素因数分解
vector<pair<long long, long long> > prime_factorize(long long n) {
    vector<pair<long long, long long> > res;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p != 0) continue;
        int num = 0;
        while (n % p == 0) { ++num; n /= p; }
        res.push_back(make_pair(p, num));
    }
    if (n != 1) res.push_back(make_pair(n, 1));
    return res;
}

// 10進数から2進数
int binary(int bina){
    int ans = 0;
    for (int i = 0; bina>0 ; i++)
    {
        ans = ans+(bina%2)*pow(10,i);
        bina = bina/2;
    }
    return ans;
}









int main() {
  ll x;
  cin >> x;
  
  cout << lcm(360,x)/x << endl;

}


Measured memory_bytes: 3704
#include <stdio.h>

int main(void)
{
	int b1, b2, b3;
	
	scanf("%d %d %d", &b1, &b2, &b3);
	
	if ((b1 == 1 && b2 == 0 && b3 == 0)||(b1 == 0 && b2 == 1 && b3 == 0)||(b1 == 0 && b2 == 0 && b3 == 0)){
		printf("Close\n");
	}
	
	else if ((b1 == 1 && b2 == 1 && b3 == 0 )||(b1 == 0 && b2 == 0 && b3 == 1)){
		printf("Open\n");
	}
	
	return(0);
}

Measured memory_bytes: 584
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, a, b) for (int i = (a); i < (int)(b); ++i)
#define rrep(i, a, b) for (int i = (int)(b) - 1; i >= (int)(a); --i)
#define all(c) c.begin(),c.end()
#define sz(x) ((int)x.size())
using pii = pair<int, int>;
using vvi = vector<vector<int>>;
using vi  = vector<int>;
constexpr int INF = 1001001001001001001LL;

struct ConvexHullTrick {
    deque<pii> L;
    pii prev_added = {INF, INF};
    int prev_query = -INF;
    ConvexHullTrick() {}
    int f(pii l, int x) {
        return l.first * x + l.second;
    }
    bool check(pii l1, pii l2, pii l3) {
        int a1, b1, a2, b2, a3, b3;
        tie(a1, b1) = l1;
        tie(a2, b2) = l2;
        tie(a3, b3) = l3;
        return (a2 - a1) * (b3 - b2) >= (b2 - b1) * (a3 - a2);
    }
    // 傾きが単調減少するように呼ぶ
    void add_line(pii line) {
        assert(prev_added > line);
        prev_added = line;
        int m = sz(L);
        while (m >= 2 && check(L[m - 2], L[m - 1], line)) {
            L.pop_back();
            m--;
        }
        L.push_back(line);
    }
    // xが単調増加するように呼ぶ
    int get_min(int x) {
        assert(sz(L));
        assert(prev_query < x);
        prev_query = x;
        while (sz(L) >= 2 && f(L[0], x) >= f(L[1], x)) {
            L.pop_front();
        }
        return f(L[0], x);
    }
};

signed main() {
    int N, C;
    cin >> N >> C;
    vector<int> h(N);
    rep(i, 0, N) cin >> h[i];
 
    vector<int> dp(N);
    ConvexHullTrick cht;
    auto add = [&](int idx) {
        cht.add_line({-2 * h[idx], h[idx] * h[idx] + dp[idx]});
    };
 
    dp[0] = 0;
    add(0);
 
    rep(i, 1, N) {
        dp[i] = cht.get_min(h[i]) + C + h[i] * h[i];
        add(i);
    }
 
    cout << dp[N - 1] << endl;
}

Measured memory_bytes: 5504
#include <iostream>
#include <vector>
 
using namespace std;
 
int main() {
    int n, k;
    cin >> n >> k;
 
    vector<int> h(n);
    for (int i=0; i<n; i++) cin >> h[i];
 
    sort(h.begin(), h.end());
    long long ans = 0;
    for (int i=0; i<n-k; i++) ans += h[i];
 
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <string>
#include <math.h>
#include <set>
#include <map>
#include <numeric>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define SZ(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define _printV(vec) for(int i = 0; i < SZ(vec); i++){cout << vec[i];if (i==SZ(vec)-1){cout<<endl;}else{cout << " ";}}
#define printV(vec) cout<<#vec<<":";_printV(vec)
#define _printA(arr,n) for(int i = 0; i < n; i++){cout << arr[i];if (i==n-1){cout<<endl;}else{cout << " ";}}
#define printA(arr) cout<<#arr<<":";_printA(arr,sizeof(arr)/sizeof(arr[0]))
#define LLINF = (1LL<<62)
#define puts(var) cout<<#var<<":"<<var<<" "
typedef long long ll;

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

  if(N%2 && M%2){
    cout << "Yes" << endl;

  }
  else{
    cout << "No" << endl;

  }

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>

int gcd(long unsigned int a, long unsigned int b) {
	// assuming a > b
	if (a % b == 0)
		return b;

	return gcd(b, a%b);
}

bool is_prime(long unsigned int n) {
	for (long unsigned int i = 2; i < n; i++) 
		if (gcd(n, i) != 1)
			return false;
	return true;
}


bool is_prime_A(long unsigned int n) {
	for (long unsigned int i = 2; i <= std::sqrt(n); i ++)
		if (gcd(n, i) != 1)
			return false;
	return true;
}


bool is_prime_E(long unsigned int n) {
	return true;
}

int main() {

	{
		using namespace std;
		
		long unsigned int n;
		cin >> n;

		int c = 0;
		for (long unsigned int i = 0; i < n; i++) {
			long unsigned int a;
			cin >> a;
			if (is_prime_A(a))
				c++;
		}
		cout << c << endl;
	}

	return 0;
}

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

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

    list<long long> a;
    long long buffer;
    for (int i = 0; i < n; i++)
    {
        cin >> buffer;
        if (i % 2 == 0)
        {
            a.push_back(buffer);
        }
        else
        {
            a.push_front(buffer);
        }
    }
    if (n % 2 == 1)
    {
        a.reverse();
    }
    for (auto itr = a.begin(); itr != a.end(); itr++)
    {
        cout << *itr << " ";
    }
    cout << endl;
}


Measured memory_bytes: 8448
#include<cstdio>
using namespace std;
int main(){
    char b;
    scanf("%c",&b);
    if(b=='A'){
        b='T';
    }
    else if(b=='T'){
        b='A';
    }
    else if(b=='C'){
        b='G';
    }
    else{
        b='C';
    }
    printf("%c\n",b);
}

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

using namespace std;
using ll=long long;

int main()
{
    ll x;
    cin >>x;
    ll k=x/11;
    x%=11;
    ll ans=2*k;
    if(x&&x>6)ans+=2;
    else if(x)ans++;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int SIZE = 3030;


int dp[SIZE][SIZE];
int tab[SIZE];
int n;

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

signed main(){

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

    input();

    for(int i = n - 1; i >= 0; i--){
        for(int k = i; k < n; k++){
            if(i == k) dp[i][k] = tab[i];
            else dp[i][k] = max(tab[i] - dp[i + 1][k], tab[k] - dp[i][k - 1]);
        }
    }
    cout << dp[0][n - 1];
    return 0;
}

Measured memory_bytes: 71936
import java.util.Scanner;
import java.util.Arrays;

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

    int n = sc.nextInt();
    int[] a = new int[n];
    for (int i = 0; i < n; i++) {
      a[i] = sc.nextInt();
    }
    Arrays.sort(a);

    int[] ctr = new int[1000001];

    for (int i = 0; i < n; i++) {
      for (int j = a[i]; j <= 1000000; j += a[i]) {
        if (j == a[i] && ctr[j] != 0) {
          ctr[j]++; break;
        }
        ctr[j]++;
      }
    }

    int result = 0;
    for (int i : a) {
      if (ctr[i] == 1) result++;
    }

    System.out.println(result);
  }
}


Measured memory_bytes: 51016
#include <bits/stdc++.h>
#define rep( i, n ) for( int ( i ) = 0; ( i ) < ( n ); ( i )++ )
#define repr( i, n ) for( int ( i ) = ( n ); ( i ) >= 0; ( i )-- )
#define FOR( i, m, n ) for( int ( i ) = ( m ); ( i ) < ( n ); ( i )++ )
#define all( x ) ( x ).begin(), ( x ).end()
typedef long long lint;
using namespace std;
 
int main( void ){
	
	int n;
	cin >> n;
	lint a[ 100 ];
	lint ans = 0;
	
	rep( i, n ){
		cin >> a[ i ];
	}
	
	rep( i, n - 1 ){
		FOR( j, i + 1, n ){
			if( a[ i ] > a[ j ] ){
				if( ans < a[ i ] - a[ j ] ){
					ans = a[ i ] - a[ j ];
				}
			}else{
				if( ans < a[ j ] - a[ i ] ){
					ans = a[ j ] - a[ i ];
				}
			}
		}
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;
 
int main() {
    ll n;
    cin >> n;

    vvl a(2, vl(n));
    rep(i, 2) {
        rep(j, n) {
            cin >> a[i][j];
        }
    }

    ll ans = 0;
    rep(i, n) {
        ll now = 0;
        exrep(j, 0, i) {
            now += a[0][j];
        }
        exrep(j, i, n-1) {
            now += a[1][j];
        }
        chmax(ans, now);
    }
    
    out(ans);
    re0;
}

Measured memory_bytes: 256
weather = input()
rainy_count = 0
max_rainy_count = 0

for i in range(3):
  if weather[i] == "R":
    rainy_count += 1
    if max_rainy_count < rainy_count:
        max_rainy_count = rainy_count
    
  else:
    rainy_count = 0
            
print(max_rainy_count)   

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

// Shortcut

#pragma optimize ("O3")
#define int long long
#define endl '\n'
#define eb emplace_back
#define pb push_back
#define pob pop_back
#define mp make_pair
#define upb upper_bound
#define lwb lower_bound
#define fi first
#define se second
#define For(i, l, r) for (int i = l; i < r; i++)
#define ForE(i, l, r) for (int i = l; i <= r; i++)
#define Ford(i, r, l) for (int i = r; i > l; i--)
#define FordE(i, r, l) for (int i = r; i >= l; i--)
#define Fora(i, a) for (auto i : a)

// I/O & Debug

#define PrintV(a) for (int iiii = 0; iiii < a.size(); iiii++) cout << a[iiii] << ' ';
#define PrintVl(a) for (int iiii = 0; iiii < a.size(); iiii++) cout << a[iiii] << endl;
#define PrintA(a, n) for (int iiii = 0; iiii < n; iiii++) cout << a[iiii] << ' ';
#define PrintAl(a, n) for (int iiii = 0; iiii < n; iiii++) cout << a[iiii] << endl;
#define Ptest(x) return cout << x, 0;
#define gl(s) getline(cin, s);
#define setpre(x) fixed << setprecision(x)
/*
#define debug(args...){ string _sDEB = #args; replace(_sDEB.begin(), _sDEB.end(), ',', ' '); stringstream _ssDEB(_sDEB); istream_iterator<string> _itDEB(_ssDEB); DEB(_itDEB, args); }
void DEB(istream_iterator<string> it) {}
template<typename T, typename... Args>
void DEB(istream_iterator<string> it, T a, Args... args){
    cout << *it << " = " << a << endl;
    DEB(++it, args...);
}
*/

// Functions

//#define isvowel(a) (a == 'a' || a == 'e' || a == 'i' || a == 'o' || a == 'u')
#define bend(a) a.begin(), a.end()
#define rbend(a) a.rbegin(), a.rend()
#define mset(a) memset(a, 0, sizeof(a));
#define mmset(a) memset(a, 0x3f, sizeof(a));
//mt19937 rando(chrono::steady_clock::now().time_since_epoch().count());

// Data Structure

#define pque priority_queue
#define mts multiset
#define y0 _y0_
#define y1 _y1_
typedef long long ll;
typedef long double ld;
typedef vector <int> vi;
typedef vector <ll> vll;
typedef vector <ld> vld;
typedef vector <string> vs;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef vector <vi > vvi;
typedef vector <vll > vvll;
typedef vector <pii > vpii;
typedef vector <pll > vpll;

const int N = 2e5 + 5, mod = 1e9 + 7, inf = 1e9 + 7;

int n;
int a[N];

signed main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    string s;
    cin >> s;
    For(i, 1, 4){
        if (s[i] == s[i - 1]) Ptest("Bad");
    }
    cout << "Good";
}

/*
==================================+
INPUT:                            |
------------------------------    |

------------------------------    |
==================================+
OUTPUT:                           |
------------------------------    |

------------------------------    |
==================================+
*/

Measured memory_bytes: 256
#include <iostream> 

using namespace std; 
 
 int main (void){ 
 int N; 
  cin >> N; 
  int num[N] = {0}; 
 for(int i = 0;i < N-1;i++){ 
  int a; 
   cin >> a; 
num[a-1]++; 
} 

for(int i=0;i < N;i++){ 
  cout << num[i] << endl; 
} 

  return 0; 
 }



Measured memory_bytes: 4368
def solve():
    S=input()
    T=input()
    i = -1
    for j in range(len(S)-len(T)+1):
        if all(a=="?" or a==b for a,b in zip(S[j:],T)):
            i = j
    if i == -1:
        print("UNRESTORABLE")
    else:
        ans = S[0:i] + T + S[i+len(T):]
        ans = ans.replace("?", "a")
        print(ans)
 
solve()

Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        // 整数の入力
        int A = sc.nextInt();
        int B = sc.nextInt();
        int C = sc.nextInt();
        int X = sc.nextInt();
		
    	int ans = 0;
    	
    	
        for(int i = 0;i <= A;i++){
           int ans1 =+ 500 * i;
                    
        	for(int j = 0;j <= B; j++){
              int  ans2 =+ 100 * j;

              for(int k = 0;k <= C;k++){
                 int ans3 =+ 50 * k;
            	if(ans1 + ans2 + ans3 == X){
                        ans++;
                }
            	}
            }
            
}

              System.out.print(ans);
    }
    }    



Measured memory_bytes: 23252
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
//#include <stdio.h>
//#include <stack>
//#include <queue>
#include <cstdio>
#include <cmath>
#include <iterator>
#include <map>
//#include <fstream>
//#include <list>
//#include <iomanip>
#include <stdlib.h>
#include <cctype>
 
using namespace std;
 
#define MOD 1000000007
#define Int int64_t
#define PI 3.14159265358979
#define ssort(z) sort(z.begin(),z.end())
#define rsort(z) sort(z.rbegin(),z.rend())
#define eerase(z) z.erase(unique(z.begin(),z.end()),z.end())
#define ccnt(z,w) count(z.begin(),z.end(),w)
 
 
void printVec(std::vector<int> & vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}
void printVec1(std::vector<string>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}
void printVec2(std::vector<Int>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}
 
Int gcd(Int a, Int b) {
	return b != 0 ? gcd(b, a % b) : a;
}
Int lcm(Int a, Int b) {
	return a / gcd(a, b) *b;
	//a*bは64bit integer overflow
}
 
bool comp(const string a, const string b) {
	return a.length() < b.length();
}
 
bool integer(double num) {
	return floor(num) == num;
}
 
string gen(int num) {
	string str = "";
	for (int i = 0; i < num; i++) str += ".";
	return str;
}
Int fact(int num) {
	if (num == 0) return 1;
	else return num * fact(num - 1);
}
 
 
int main() {
	int h, w; cin >> h;
	cout << 3 * h * h << endl;
 
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <vector>
#include <cstdio>

using namespace std;
int N,M;
bool graph[51][51];
bool vis[51];
int cnt;
void dfs(int x){
  if(cnt == N) return;
  for(int i = 0; i < N; i++){
    if(vis[i]) continue ;
    if(graph[x][i] == false) continue;
    vis[i] = true;
    cnt++;
    dfs(i);
  }
  return;
}

int main(){
  //intput
  cin >> N >> M;
  pair<int,int> edge[M];
  for(int i = 0; i < M; i++){
    scanf("%d %d",&edge[i].first,&edge[i].second);
    edge[i].first --; edge[i].second --;
    graph[edge[i].first][edge[i].second] = true;
    graph[edge[i].second][edge[i].first] = true;
  }

  int ans = 0;
  for(int i = 0; i < M; i++){
    graph[edge[i].first][edge[i].second] = false;
    graph[edge[i].second][edge[i].first] = false;
    for(int j = 0; j < N; j++) vis[j] = false ;
    vis[0] = true;
    cnt = 1;
    dfs(0);
    if(cnt != N) ans ++; 
    graph[edge[i].first][edge[i].second] = true;
    graph[edge[i].second][edge[i].first] = true;
  }

  cout << ans  << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <numeric>
#include <climits>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <functional>
#include <utility>
#include <cctype>
#include <iterator>
////////////////////////////////////////////////
#define REP(i, n) for (int i = 0; i < (int)n; i++)
#define FOR(i, m, n) for (int i = (int)m; i < (int)n; i++)
#define REPvec(itr, mp) for (auto itr = mp.begin(); itr != mp.end(); itr++)
#define REPe(e, mp) for (auto& e : mp)
#define all(x) x.begin(), x.end()
#define MOD 1000000007  // 1e9+7
using namespace std;
using ll = long long int;
using vecint = vector<int>;
using vecll = vector<ll>;
using vec2int = vector<vector<int>>;
using P = pair<int, int>;
////////////////////////////////////////////////
////////////////////////////////////////////////
int main() {
  ////////////////////////////////////////////////
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  ////////////////////////////////////////////////
  string s;
  cin >> s;
  REPe(e, s){
    if(e=='?'){
      e = 'D';
    }
  }
  cout << s << endl;
}
//////////////////////////////////////////////


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

int main() {
  
  string s,t;
  cin >> s >> t;
  
  for (int i = 0;i<s.size();i++){
    if(!(s.at(i) == t.at(i))){
      cout << "No" << endl;
      break;
    }else if(i == s.size() - 1){
      cout << "Yes" << endl;
    }
  }
}


Measured memory_bytes: 3632
parseInt(x)=parse(Int, x)
parseMap(x::Array{SubString{String},1})=map(parseInt, x)
function eval(a::Tuple{Int,Int,Int},b::Tuple{Int,Int,Int})
	if a[2]-a[3]<b[2]-b[3]
		1
	elseif a[2]-a[3]==b[2]-b[3]
		0
	else
		-1
	end
end

function hpush(h::Array{Tuple{Int,Int,Int},1},x::Tuple{Int,Int,Int})
	push!(h,x)
	if length(h) > 1
		l = length(h)
		k = l>>1
		while eval(x,h[k])==1&&k>=1
			tmp = h[k]
			h[k] = x
			h[l] = tmp
			k = max(k>>1,1)
			l = l>>1
		end
	end
end

function hpop(h::Array{Tuple{Int,Int,Int},1})
	x = h[1]
	z = pop!(h)
	if !isempty(h)
		h[1] = z
		k = 1
		l = length(h)
		while k <= l
			if 2*k>l
				break
			elseif 2*k+1>l
				if eval(z,h[2*k])>=0
					break
				else
					tmp = h[2*k]
					h[2*k] = z
					h[k] = tmp
					k = 2*k
				end
			else
				if eval(z,h[2*k])>=0&&eval(z,h[2*k+1])>=0
					break
				else
					t = eval(h[2*k],h[2*k+1])>=0 ? 2*k : 2*k+1
					tmp = h[t]
					h[t] = z
					h[k] = tmp
					k = t
				end
			end
		end
	end
	x
end


function main()
	t = readline() |> parseInt
	for iter in 1:t
		n = readline() |> parseInt
		a = Tuple{Int,Int,Int}[]
		b = Tuple{Int,Int,Int}[]
		s = 0
		for i in 1:n
			k,l,r = readline() |> split |> parseMap
			if l>r
				push!(a,(k,l,r))
			elseif r>l
				push!(b,(k,r,l))
			else
				s += r
			end
		end
		a = sort(a,by=x->x[1])
		b = sort(b,by=x->x[1],rev=true)
		h = Tuple{Int,Int,Int}[]
		ct = 0
		for i in a
			if ct<i[1]
				s += i[2]
				ct += 1
				hpush(h,i)
			else
				if length(h)==0
					s += i[3]
				else
					j = hpop(h)
					if i[2]-i[3]>j[2]-j[3]
						s += i[2]-j[2]+j[3]
						hpush(h,i)
					else
						s += i[3]
						hpush(h,j)
					end
				end
			end
		end
		ct = 0
		h = Tuple{Int,Int,Int}[]
		for i in b
			if ct<n-i[1]
				s += i[2]
				ct += 1
				hpush(h,i)
			else
				if length(h)==0
					s += i[3]
				else
					j = hpop(h)
					if i[2]-i[3]>j[2]-j[3]
						s += i[2]-j[2]+j[3]
						hpush(h,i)
					else
						s += i[3]
						hpush(h,j)
					end
				end
			end
		end
		println(s)
	end
end

main()

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

using namespace std;

const int N = 200200;

char s[N], t[N], d[N];

int main() {
  int n, m;
  scanf("%d %d %s", &n, &m, s + 1);
  for (int i = 1; i <= m; ++i) {
    scanf(" %c %c", &t[i], &d[i]);
  }
  auto gol = [&](int md) {
    int nw = md;
    for (int i = 1; i <= m; ++i) {
      if (nw == 0) return true;
      if (nw == n + 1) return false;
      if (s[nw] == t[i]) {
        if (d[i] == 'L') nw--;
        else nw++;
      }
    }
    return nw == 0;
  };
  int tl, tr;
  {
    int l = 0, r = n + 1;
    while (l < r) {
      int md = (l + r + 1) >> 1;
      if (gol(md)) l = md;
      else r = md - 1;
    }
    tl = l;
  }
  auto gor = [&](int md) {
    int nw = md;
    for (int i = 1; i <= m; ++i) {
      if (nw == 0) return false;
      if (nw == n + 1) return true;
      if (s[nw] == t[i]) {
        if (d[i] == 'L') nw--;
        else nw++;
      }
    }
    return nw == n + 1;
  };
  {
    int l = 0, r = n + 1;
    while (l < r) {
      int md = (l + r) >> 1;
      if (gor(md)) r = md;
      else l = md + 1;
    }
    tr = r;
  }
  printf("%d\n", tr - tl - 1);
}


Measured memory_bytes: 768
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <vector>
#include <algorithm>
#include <set>
#include <queue>
#include <map>
#include <climits>
#include <complex>
#include <numeric>
#include <list>
using namespace std;

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define RREP(i,n) for(int i=(int)n-1; i>=0; i--)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define RFOR(i,c) for(__typeof((c).rbegin())i=(c).rbegin();i!=(c).rend();++i)
#define ALL(c) (c).begin(), (c).end()

typedef vector<int> vi;

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

	if(a == 1 && b == 1) {
		cout << "2 2" << endl;
		cout << ".#" << endl;
		cout << "##" << endl;
		return 0;
	}
	else if(a == 1) b++;

	vector<vi> m(100, vi(100, 0));

	int x = 1, y = 1;
	while(--a) {
		for(int xx = x-1; xx <= x+1; xx++) {
			for(int yy = y-1; yy <= y+1; yy++) {
				m[xx][yy] = 1;	
			}
		}
		m[x][y] = 0;
		y += 3;
		if(y >= 100) {
			y = 1; x += 3;
		}
	}
	while(--b) {
		m[x][y] = 1;
		y += 3;
		if(y >= 100) {
			y = 1; x += 3;
		}
	}
	cout << "100 100" << endl;
	REP(i, 100) {
		REP(j, 100) {
			if(!m[i][j]) cout << '.';
			else	cout << '#';
		}
		cout << endl;
	}
	cout << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main()
{
	int n, m;
	while(scanf("%d %d", &n, &m))
	{
		int ans = 0;
		if(n == 0 && m == 0)
		{
			break;
		}
		for(int i = 1; i < n - 1; i++)
		{
			for(int j = i + 1; j < n; j++)
			{
				for(int k = j + 1; k < n + 1; k++)
				{
					if(m == i + j + k)
					{
						ans++;
					}
				}
			}
		}
		printf("%d\n", ans);
	}
	
	return 0;
} 


Measured memory_bytes: 2700
#include <bits/stdc++.h>
using namespace std;
char S[200010];

bool can(int a, int b){
    for(int i = a;i<b+1;i++){
        if(S[i] == '#'&&S[i+1] == '#') return false;
        if(i == b) return true;
    }
    return true;
}

bool triple(int b,int c){
    bool ans = false;
    for(int i = b; i<=c; i++){
        if(S[i-1] == '.' && S[i] == '.' && S[i+1] == '.') ans = true;
    }
    return ans;
}

int main(){
    int N,A,B,C,D;
    cin >> N >> A >> B >> C >> D;
    A--; B--; C--; D--;
    for(int i = 0;i<N; i++) cin >> S[i];
    string ans;

    if(C < D){
        if(can(A,C) && can(B,D))ans = "Yes";
        else ans = "No";
    }else{
        if(can(A,C) && can(B,D) && triple(B,D)) ans = "Yes";
        else ans = "No";
    }

    cout << ans << endl;
}

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

using namespace std;

void c()
{
    int n;
    cin >> n;
    vector<vector<int>> f(n, vector<int>(10));
    for(int i = 0; i < n; i++)
    {
        for(int j = 0; j < 10; j++)
        {
            cin >> f[i][j];
        }
    }
    vector<vector<int>> p(n, vector<int>(11));
    for(int i = 0; i < n; i++)
    {
        for(int j = 0; j < 11; j++)
        {
            cin >> p[i][j];
        }
    }
    vector<int> pattern = {1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0};
    sort(pattern.begin(), pattern.end());
    long long int benefit = -10e9;
    do{
        int check = 0;
        for(int i = 0; i < 10; i++)
        {
            check += pattern[i];
        }
        if(check == 0) continue;
        long long int temp_benefit = 0;
        for(int i = 0; i < n; i++)
        {
            int count = 0;
            for(int j = 0; j < 10; j++)
            {
                if(pattern[j] == 1 && f[i][j] == 1)
                {
                    count++;
                }
            }
            temp_benefit += p[i][count];
        }
        if(temp_benefit > benefit) {
            benefit = temp_benefit;
        }
    }while (next_permutation(pattern.begin(), pattern.end()));
    cout << benefit << endl;
}

int main() {
    c();
    return 0;
}


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

#define rep(i, n) for(long long i=0;i<(long long)(n);i++)
#define rep2(i, s, n) for(long long i=(s);i<(long long)(n);i++)
#define repi(i, n) for(int i=0;i<(int)(n);i++)
#define rep2i(i, s, n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(), v.end()

#define deg2rad(deg) (((deg)/360)*2*M_PI)
#define rad2deg(rad) (((rad)/2/M_PI)*360)

using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;

const ll INF = (1LL<<60);
const int INFi = (1<<29);

/*素数判定*/
bool is_prime(ll n){
    if(n==1) return false;
    for(ll i=2;i*i<=n;i++){
        if(n%i==0) return false;
    }
    return true;
}

/*約数列挙*/
vll enum_divisors(ll n){
    vll l;
    for(ll i=1;i*i<=n;i++){
        if(n%i==0){
            l.push_back(i);
            if(n/i != i) l.push_back(n/i);
        }
    }
   sort(all(l));
   return l;
}

/*素因数分解*/
vector<P> prime_factorize(ll n){
    vector<P> l;
    for(ll i=2;i*i<=n;i++){
        if(n%i!=0) continue;
        ll e = 0;
        while(n%i==0){
            e++;
            n /= i;
        }
        l.push_back({i, e});
    }
    if(n!=1) l.push_back({n, 1});
    return l;
}

int main(){

    string s; cin >> s;

    vll ans(s.size(), 0);

    auto subs_begin = s.begin();
    auto subs_end = s.begin();
    while(subs_end != s.end()){
        while(*subs_end == 'R') subs_end++;
        auto r = subs_end-1;
        auto l = subs_end;
        while(*subs_end == 'L') subs_end++;
        
        ll dist = distance(subs_begin, subs_end);
        ans[distance(s.begin(), r)] = dist/2;
        ans[distance(s.begin(), l)] = dist/2;

        if(dist%2 != 0){
            if(distance(subs_begin, r)%2 == 0){
                ans[distance(s.begin(), r)]++;
            }
            else{
                ans[distance(s.begin(), l)]++;
            }
        }

        subs_begin = subs_end;
    }

    rep(i, ans.size()) cout << ans[i] << " ";
    cout << endl;

    return 0;
}

Measured memory_bytes: 4300
//ITP1_5

using System;
using System.Collections.Generic;



class Program
{
    static void Main(string[] args)
    {
        int[] h = new int[50];
        int[] w = new int[50];

        int count = 0;

        while (true)
        {
            //?????????????????????????????????int??????iaaray????????????????????\

            int[] iarray = Array.ConvertAll<string, int>((Console.ReadLine().Split(' ')), delegate (string value)
            {
                return int.Parse(value);
            });
                
            h[count] = iarray[0];
            w[count] = iarray[1];

            if (h[count] == 0 && w[count] == 0)
                break;
            count++;

        }

        for (int c = 0; c < count; c++)
        {
            for (int i = 0; i < h[c]; i++)
            {
                for (int j = 0; j < w[c]; j++)
                {
                    Console.Write("#");
                }
                Console.Write("\r\n");
            }
            Console.Write("\r\n");
        }

    }
}

Measured memory_bytes: 8916
n = input()
length = len(n)
ans = 0
for i in range(1, length+1):
  if i % 2 == 1 and i < length:
    ans += 10**i - 10**(i-1)
  elif i == length and i % 2 == 1:
    ans += int(n) - 10**(length-1) + 1
print(ans)

Measured memory_bytes: 3060
#include<complex>
#include<cmath>
#include<cstdio>
using namespace std;
typedef complex<double> xy_t;
double dot_product(xy_t a,xy_t b)
{
  return (conj(a)*b).real();
}
int main()
{
  double x[3],y[3];
  xy_t p[3],a,b,c,d;
  while(~scanf("%lf,%lf,%lf,%lf,%lf,%lf",&x[0],&y[0],&x[1],&y[1],&x[2],&y[2])){
    p[0] = xy_t(x[0],y[0]);
    p[1] = xy_t(x[1],y[1]);
    p[2] = xy_t(x[2],y[2]);
    a = p[1] - p[0];
    b = p[2] - p[0];
    c = (dot_product(a,b)/norm(a)) * a;
    d = c - b + c + p[0];
    printf("%.4f %.4f\n",d.real(),d.imag());
  }
}

Measured memory_bytes: 1108
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
#define fi first
#define se second
#define sz(a) ((int)a.size())

const int MAXN = 1e5+100;
const int MOD = 1e9+7;


void solve(){
    ll x,y;
    cin >> x >> y;
    if(x%y==0){
        cout <<"-1";
    } else{
        cout << x;
    }
    cout <<endl;
}

int main(){
    #ifdef tw
        freopen("input.txt","r",stdin);
    #endif // zxc

    int t=1;
    while(t--)
        solve();
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define mod 1000000007
#define FT() int t; scanf("%d",&t); while(t--)
#define pb push_back
#define nl printf("\n")
#define fi(i,start,end) for(int i=start; i < (int)end ; ++i)
#define ip(n)   scanf("%d",&n)
#define mz(a)   memset(a,0,sizeof(a))
#define inpArr(A,n) fi(i,0,n)   ip(A[i]);
#define print(a)  for(auto i : a)   cout<<i<<" "; nl;
#define Fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;
ll max(ll a,ll b) { return a>b?a:b;}
ll min(ll a,ll b) { return a<b?a:b;}
void solve()
{   
}
int main() {
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    #endif
    
    int n,k;
    cin>>n>>k;
    int a[n];
    fi(i,0,n)
        cin>>a[i];
    sort(a,a+n);
    ll t =0;
    fi(i,0,k)
        t+=a[i];
    cout<<t;

    #ifndef ONLINE_JUDGE
    cout<<"\nTime Elapsed : " << 1.0*clock() / CLOCKS_PER_SEC << " s";
    #endif
    return 0;
}


Measured memory_bytes: 3600
import java.util.ArrayDeque

fun main() {
    val (n, m) = readLine()!!.split(' ').map { it.toInt() }
    val graph = mutableMapOf<Int, MutableList<Int>>()

    repeat(m) {
        val (a, b) = readLine()!!.split(' ').map { it.toInt() }
        graph[a] = graph[a] ?: mutableListOf()
        graph[b] = graph[b] ?: mutableListOf()
        graph[a]!!.add(b)
        graph[b]!!.add(a)
    }

    val visited = IntArray(n + 1) { -1 }
    val queue = ArrayDeque<Int>()

    queue.addLast(1)
    visited[1] = 0

    while (queue.isNotEmpty()) {
        val v = queue.removeFirst()
        for (u in graph[v]!!) {
            if (visited[u] == -1) {
                queue.addLast(u)
                visited[u] = v
            }
        }
    }

    if (visited.slice(2..n).count { it == -1 } > 0) {
        println("No")
    } else {
        println("Yes")
        println(visited.slice(2..n).joinToString("\n"))
    }

}


Measured memory_bytes: 89188
#include <bits/stdc++.h>
#include <cmath>
#include <map>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define been(ix) (ix).begin(),(ix).end()
using namespace std;
typedef long long ll; 
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<pair<int,int>> vp;
const ll INF = 1e18;
#define foreach(ix,a) for(auto& (ix) : (a) 
struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2
 
    UnionFind(int N) : par(N) {
        rep(i,N)par[i]=i;
    }
 
    int root(int x) { 
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }
 
    void unite(int x, int y) { 
        int rx = root(x); 
        int ry = root(y);
        if (rx == ry) return; 
        par[rx] = ry; 
    }
 
    bool same(int x, int y) { 
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main(){
    int n,m;
    cin>>n>>m;
    vi x(m),y(m);
    
    rep(i,m){
        int a,b;
        cin>>a>>b;
        a--;b--;
        x[i]=a;y[i]=b;
    }
    int ans=0;
    rep(i,m){
        UnionFind uf (n);
        rep(j,m){
            if(i!=j)uf.unite(x[j],y[j]);
        }
        if(!uf.same(x[i],y[i]))ans++;
    }
    cout<<ans<<endl;

}

Measured memory_bytes: 256