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


using ll = long long;
ll modinv(ll a, ll m) {
	assert(m > 0);
	if (m == 1) return 0;
	a %= m;
	if (a < 0) a += m;
	assert(a != 0);
	if (a == 1) return 1;
	return m - modinv(m, a) * m / a;
}

template <int MOD_> struct modnum {
private:
	int v;
public:
	static const int MOD = MOD_;

	modnum() : v(0) {}
	modnum(ll v_) : v(int(v_ % MOD)) { if (v < 0) v += MOD; }
	explicit operator int () const { return v; }
	friend bool operator == (const modnum& a, const modnum& b) { return a.v == b.v; }
	friend bool operator != (const modnum& a, const modnum& b) { return a.v != b.v; }

	modnum operator ~ () const {
		modnum res;
		res.v = modinv(v, MOD);
		return res;
	}

	modnum& operator += (const modnum& o) {
		v += o.v;
		if (v >= MOD) v -= MOD;
		return *this;
	}
	modnum& operator -= (const modnum& o) {
		v -= o.v;
		if (v < 0) v += MOD;
		return *this;
	}
	modnum& operator *= (const modnum& o) {
		v = int(ll(v) * ll(o.v) % MOD);
		return *this;
	}
	modnum& operator /= (const modnum& o) {
		return *this *= (~o);
	}

	friend modnum operator + (const modnum& a, const modnum& b) { return modnum(a) += b; }
	friend modnum operator - (const modnum& a, const modnum& b) { return modnum(a) -= b; }
	friend modnum operator * (const modnum& a, const modnum& b) { return modnum(a) *= b; }
	friend modnum operator / (const modnum& a, const modnum& b) { return modnum(a) /= b; }
};

using num = modnum<998244353>;



int main(){
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int n;
	cin >> n;
	string s;
	cin >> s;
	vector<int> colors(3*n);
	vector<vector<int> > r(3);
	for(int i = 0; i < 3*n; i++){
		if(s[i] == 'R'){
			colors[i] = 0;
		} else if(s[i] == 'G'){
			colors[i] = 1;
		} else if(s[i] == 'B'){
			colors[i] = 2;
		} else assert(false);
		r[colors[i]].push_back(i);
	}
	for(int i = 0; i < 3; i++){
		assert((int)r[i].size() == n);
	}
	vector<vector<pair<int,int> > > x1(9);
	vector<vector<pair<int,int> > > x2(9);
	for(int i = 0; i < n; i++){
		vector<pair<int,int> > z;
		for(int j = 0; j < 3; j++){
			z.push_back({r[j][i], j});
		}
		sort(z.begin(), z.end());
		int fl = z[0].second * 3;
		int fr = z[2].second;
		x1[fl].push_back({z[0].first, z[1].first});
		x2[fr].push_back({z[1].first, z[2].first});
	}
	num res = 1;
	for(int i = 1; i <= n; i++) res *= i;
	for(auto x : vector<vector<vector<pair<int,int> > > >({x1, x2})){
		for(vector<pair<int,int> > a : x){
			vector<pair<int,int> > events;
			for(pair<int,int> r : a){
				events.push_back({r.first, 1});
				events.push_back({r.second, -1});
			}
			sort(events.begin(), events.end());
			int cur = 0;
			for(pair<int,int> e : events){
				if(e.second == 1){
					cur += 1;
				} else {
					res *= cur;
					cur -= 1;
				}
				assert(cur >= 0);
			}
			assert(cur == 0);
		}
	}
	cout << (int) res << '\n';
}

Measured memory_bytes: 11868
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())

struct Choice {
    ll x, y, cnt;
};

const ll d[8][2] = {{0, -1}, {1, -1}, {1, 0}, {1, 1}, {0, 1}, {-1, 1}, {-1, 0}, {-1, -1}};
vector<string> s;

ll g(ll x, ll y, char c) {
    ll ans = 0;
    rep(i, 8) {
        ll ny = y, nx = x, cnt = 0;
        bool clr = false;
        while(true) {
            ny += d[i][1];
            nx += d[i][0];
            if ((ny < 0) || (ny >= 8) || (nx < 0) || (nx >= 8)) {
                break;
            }
            if (s[ny][nx] == '.') {
                break;
            }
            if (s[ny][nx] == c) {
                clr = true;
                break;
            }
            else {
                cnt++;
            }
        }
        if (clr) ans += cnt;
    }
    return ans;
}

Choice f(char c) {
    Choice ans;
    ans.cnt = 0;
    ll plus = (c == 'o') ? 1 : -1;
    ll x, y = (plus == 1) ? 0 : 7;
    while((y >= 0) && (y < 8)) {
        x = (plus == 1) ? 0 : 7;
        while((x >= 0) && (x < 8)) {
            if (s[y][x] != '.') {
                x += plus;
                continue;
            }
            ll v = g(x, y, c);
            if (v > ans.cnt) {
                ans.cnt = v;
                ans.x = x;
                ans.y = y;
            }
            x += plus;
        }
        y += plus;
    }
    return ans;
}

void h(ll x, ll y, char c) {
    s[y][x] = c;
    rep(i, 8) {
        ll ny = y, nx = x;
        bool rev = false;
        while(true) {
            ny += d[i][1];
            nx += d[i][0];
            if ((ny < 0) || (ny >= 8) || (nx < 0) || (nx >= 8)) break;
            if (s[ny][nx] == '.') break;
            if (s[ny][nx] == c) {
                rev = true;
                break;
            }
        }
        if (!rev) continue;
        ny = y; nx = x;
        while(true) {
            ny += d[i][1];
            nx += d[i][0];
            if ((ny < 0) || (ny >= 8) || (nx < 0) || (nx >= 8)) break;
            if (s[ny][nx] == c) break;
            s[ny][nx] = c;
        }
    }
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    s.resize(8);
    rep(i, 8) cin >> s[i];
    while(true) {
        Choice co = f('o');
        if (co.cnt > 0) h(co.x, co.y, 'o');
        Choice cx = f('x');
        if (cx.cnt > 0) h(cx.x, cx.y, 'x');
        if ((co.cnt == 0) && (cx.cnt == 0)) break;
    }
    rep(i, 8) cout << s[i] << endl;
    return 0;
}



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

using namespace std;

#define pb push_back
#define endl '\n'
#define all(x) (x).begin(),(x).end()
#define ff first
#define ss second
#define sz(x) (int)(x).size()
#define f(n) for(int i=0;i<n;++i)
#define f2(n) for(int j=0;j<n;++j)
#define f3(n) for(int k=0;k<n;++k)
#define F(i,x,n,y) for(i=x;i<n;i+=1)
#define fi(i) for(i=0;i<n;++i)
#define fa(x,y) for(auto x:y)

//Warsaw debug template
#define LOCAL
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
    enable_if<sizeof dud<c>(0) x 1,debug&>::type operator<<(c i){
sim > struct rge {c b,e;};
sim > rge<c> range(c i, c j) {return rge<c>{i,j};}
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug{
#ifdef LOCAL
~debug() {cerr<<endl; }
eni(!=) cerr<< boolalpha << i; ris;}
eni(==) ris <<range(begin(i),end(i)); }
sim, class b dor(pair<b,c> d){
ris<<"("<<d.first<<","<<d.second<<")";
}
sim dor(rge<c> d){
    *this << "[";
    for(auto it=d.b;it!=d.e;++it)
        *this <<"," +(it==d.b)<< *it;
    ris<<"]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) "["<<#__VA_ARGS__":"<<(__VA_ARGS__)<<"]"
//End of debug template        
    

typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef long long ll;


int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin>>n;
    int ans=0;
    f(n){
        int x;
        cin>>x;
        while(x%2==0){
            ++ans;
            x/=2;
        }
    }
    cout<<ans<<endl;

    return 0;
}


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

int main() {
    int N;
    int d[110];
    cin >> N;
    for (int i = 0; i < N; ++i) cin >> d[i];

    int num[110] = {0};  
    for (int i = 0; i < N; ++i) {
        num[d[i]] = 1;  
    }

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

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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define pb push_back
#define mp make_pair
#define PI ( acos(-1.0) )
#define IN freopen("C.in","r",stdin)
#define OUT freopen("output.txt","w",stdout)
#define FOR(i,a,b) for(i=a ; i<=b ; i++)
#define DBG printf("Hi\n")
#define i64 long long int
#define ui64 unsigned long long int
#define eps (1e-6)
#define xx first
#define yy second
#define ln 17
#define off 2

#define sq(x) ((x)*(x))

#define FASTIO ios_base::sync_with_stdio(false); cin.tie(NULL)

using namespace __gnu_pbds;
using namespace std ;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef tree< i64, null_type, less<i64>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef pair<int,int> pii;

#define log 20
#define mod 998244353LL
#define INF 1000000000000000000LL
#define maxn 300005

int dp[3005][3005] ;

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

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

    dp[a][b] = 1 ;

    for(int i=a+1 ; i<=c ; i++) dp[i][b] = (1LL*dp[i-1][b]*b)%mod ;
    for(int j=b+1 ; j<=d ; j++) dp[a][j] = (1LL*dp[a][j-1]*a)%mod ;

    for(int i=a+1 ; i<=c ; i++)
    {
        for( int j=b+1 ; j<=d ; j++)
        {
            dp[i][j] = ( 1LL*dp[i-1][j]*j + 1LL*dp[i][j-1]*i -1LL*dp[i-1][j-1]*(i-1)*(j-1) )%mod ;
        }
    }

    printf("%d\n", (dp[c][d]%mod + mod)%mod ) ;

    return 0 ;
}


Measured memory_bytes: 38812
#include <bits/stdc++.h>
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 all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
#define get_unique(x) x.erase(unique(all(x)), x.end());
typedef long long ll;
typedef complex<double> Complex;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
template <class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T& a, const T& b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

int main() {
    ll n, a, b, c, d, e;
    cin >> n >> a >> b >> c >> d >> e;
    ll x = min({a, b, c, d, e});
    cout << (n + x - 1) / x + 4 << endl;
}

Measured memory_bytes: 256
import java.util.*;
 
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 ans = 0;
 
        for (int i = 0; i < 1000000; i++) {
            if (a%2 == 0 && b%2 == 0 && c%2 == 0) {
                if (a == b && b ==c) {
                    System.out.println("-1");
                    return;
                }
                int tmpA = a;
                int tmpB = b;
                int tmpC = c;

                a = tmpB/2 + tmpC/2;
                b = tmpA/2 + tmpC/2;
                c = tmpA/2 + tmpB/2;
            } else {
                break;
            }
            ans++;      
        }
 
        System.out.println(ans);
 
        sc.close();
 
        }
 
    }

Measured memory_bytes: 35580
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <iomanip>

#define int long long int
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )

using namespace std;

typedef pair<int, int> P;

const int INF = 1e15;
const int MOD = 1e9+7;

template <typename T>
using vector2 = vector<vector<T>>;
template <typename T>
vector2<T> initVec2(size_t n0, size_t n1, T e = T()){
    return vector2<T>(n0, vector<T>(n1, e));
}

template <typename T>
using vector3 = vector<vector<vector<T>>>;
template <typename T>
vector3<T> initVec3(size_t n0, size_t n1, size_t n2, T e = T()){
    return vector3<T>(n0, vector2<T>(n1, vector<T>(n2, e)));
}

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

    int r, d, x;
    cin >> r >> d >> x;
    rep(i, 10){
        x = r * x - d;
        cout << x << endl;
    }

    return 0;
}


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

signed main()
{ 
    int n,q,r;
    cin>>n;
    n--;
    string res;
    while(n>=0)
    {
        r = n%26;
        res += 'a'+ r;
        n = n/26;
        n--;
    }
    reverse(res.begin(),res.end());
    cout<<res;
    return 0;
}


Measured memory_bytes: 3632
import bisect
N=int(input())
arr=list(map(int,input().split()))

arr.sort()

ans=0

for i in range(N-2):
    for j in range(i+1,N-1):
        k=bisect.bisect_left(arr,arr[i]+arr[j])
        if k>j:
            ans+=k-j-1
        else:
            pass
print(ans)

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

int main() {
  int n,m,waans = 0,acans = 0;
  cin >> n >> m;
  vector<bool>ACdata(n);
  vector<int>WAdata(n);
  for(int i = 0;i < n;i++){
    ACdata.at(i) = false;
    WAdata.at(i) = 0;
  }
  for(int i = 0;i < m;i++){
    int p;string s;
    cin >> p >> s;
    if(s == "AC" && ACdata.at(p-1) == false){
      ACdata.at(p-1) = true;
      acans++;
      waans += WAdata.at(p-1);
    }
    else if(ACdata.at(p-1) == false){
      WAdata.at(p-1)++;
    }
  }
  cout << acans << " " << waans << endl;
}


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

int main() {
  int H, W;
  cin >> H >> W;
  vector<vector <char>> masu( H, vector<char>( W ));

  int h, w;
  int check = 0;
  for ( h = 0; h < H; h++ ) {    
    for ( w = 0; w < W; w++ ) {
      cin >> masu.at( h ).at( w );
      if( masu.at( h ).at( w ) == '.' ) {
        check++;
      }
    }
    if( check == W ) {
      for ( int i = h; i < H; i++ ) {
        for ( int j = 0; j < W; j++ ) {
          if( i < H - 1 ) {
            masu.at( i ).at( j ) = masu.at( i + 1 ).at( j );
          }
        }
      }
      h--;
      H--;
    }
    check = 0;
  }      

  check = 0;
  for ( w = 0; w < W; w++ ) { 
    for ( h = 0; h < H; h++ ) { 
      if( masu.at( h ).at( w ) == '.' ) {
        check++;
      }
    }
    if( check == H ) {
      for ( int j = w; j < W; j++ ) {
        for ( int i = 0; i < H; i++ ) {
          if( j < W - 1 ) {
            masu.at( i ).at( j ) = masu.at( i ).at( j + 1 );
          }
        }
      }
      w--;
      W--;
    }
    check = 0;
  }
  for ( h = 0; h < H; h++ ) {
    for ( w = 0; w < W; w++ ) {
      cout << masu.at( h ).at( w );
    }
    cout << endl;
  }
  return 0;
}


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


int main(){

	ll n,W;
	cin>>n>>W;
	ll w[n+1],v[n+1];

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

   ll dp[n+1][W+1];
  
memset(dp,0,sizeof(dp));
	for(int i=1;i<=n;i++){
       for(int j=1;j<=W;j++){
       
            if(j>=w[i])
            dp[i][j]=max(dp[i-1][j-w[i]]+v[i],dp[i-1][j]);
            else
            dp[i][j]=dp[i-1][j];
       
       }
       cout<<endl;
       
	}

	cout<<dp[n][W]<<endl;
}

Measured memory_bytes: 79104
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1e9
#define PI 3.14159265359
#define MOD 1000000007
#define ALL(v) v.begin(),v.end()
#define ALLR(v) v.rbegin(),v.rend()
typedef long long ll;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//isPrime
//modpow modinv
//getDigit
int main() {
  cout << fixed << setprecision(10);
  int n,l;
  cin >> n >> l;
  int sum = 0;
  for(int i = 1; i<=n; i++){
    sum+=l+i-1;
  }
  int ans = INF;
  for(int i = 1; i<=n; i++){
    if(abs(ans)>abs(l+i-1)){
      ans = l+i-1;
    }
  }
  cout << sum - ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#define rep(i,n) for(int i=0; i<n; i++)
typedef long long ll;
typedef pair<int,int> P;
const ll MOD = (int)1e9+7;
const ll INF = MOD*MOD;
const ll powll = 1LL<<1;

int main(void){
  int n,m; cin >> n >> m;
  int a[n]; rep(i,n) cin >> a[i];

  sort(a,a+n,greater<int>());
  double sum = 0;
  rep(i,n) sum += a[i];
  string f = "Yes\n";
  rep(i,m){
    if(a[i] < sum/4.0/(double)m) f = "No\n";
  }
  cout << f;
}

Measured memory_bytes: 256
/*
　　　∫ ∫ ∫
　　　ノヽ
　　（＿　 ）
　（＿　　　 ）
（＿＿＿＿＿＿ ）
　ヽ(´･ω･)ﾉ　
　　 |　 /
　　 UU
*/
#pragma region macro
#include <bits/stdc++.h>
typedef long long int64;
using namespace std;
using P = pair<int64, int64>;
typedef vector<int> vi;
const int MOD = (int)1e9 + 7;
const int64 INF = 1LL << 62;
const int inf = 1<<30;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define REP(i, n) for (int i = 0; i < (n); i++)
#define FOR(i,s,n) for (int i = s; i < (n); i++)
#define ALL(obj) (obj).begin(), (obj).end() //コンテナじゃないと使えない!!
#define debug(x) cerr << #x << ": " << x << "\n";
#define mp make_pair
#define bn '\n'
template <typename T>
ostream& operator<<(ostream& os, const vector<T> &V){
    int N = V.size();
    REP(i,N){
        os << V[i];
        if (i!=N-1) os << " ";
    }
    os << "\n";
    return os;
}
template <typename T,typename S>
ostream& operator<<(ostream& os, pair<T,S> const&P){
    os << "(";
    os << P.first;
    os << " , ";
    os << P.second;
    os << ")";
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, set<T> &S){
    auto it=S.begin();
    while(it!=S.end()){
        os << *it;
        os << " ";
        it++;
    }
    os << "\n";
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, deque<T> &q){
    for(auto it=q.begin();it<q.end();it++){
        os<<*it;
        os<<" ";
    }
     os<<endl;
    return os;
}
vector<pair<int,int>> dxdy = {mp(0,1),mp(1,0),mp(-1,0),mp(0,-1)};
#pragma endregion
//fixed<<setprecision(10)<<ans<<endl;



int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,M;
    cin >> N >> M;
    vector<vector<int>> edge(3*N);

    int a,b;
    REP(i,M){
        cin >> a >> b;
        --a;--b;
        REP(v,3){
            edge[a+N*v].emplace_back(b+N*((v+1)%3));
        }
    }
    debug(edge)

    int S,T;
    cin >> S >> T;
    S--;T--;

    N*=3;

    queue<int> q;
    q.push(S);
    vector<bool> visited(N,false);
    vector<int> cost(N,0);
    while(not q.empty()){
        int v = q.front(); q.pop();
        int c = cost[v];
        for(auto to:edge[v]){
            if(to == T){
                cout << (c + 1)/3 << bn;
                return 0;
            }
            if(visited[to]) continue;
            visited[to] = true;
            q.push(to);
            cost[to] = c + 1;
        }
    }

    cout << -1 << endl;
}

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

int main(void){
  long long n, h, w;
  long long N, p, q;
  cin >> N;
  bool end = false;
  for(h = 1; h<=3500; h++){
    for(n = 1; n<=3500; n++){
      p = 4*h*n-N*n-N*h;
      q = N*h*n;
      if(p>0 && q%p == 0){
        w = q / p;
        cout << h << " " << n << " " << w;
        end = true;
        break;
      }
    }
    if(end) break;
  }
}


Measured memory_bytes: 256
// May this submission get accepted!

#pragma GCC optimize ("O3")
#pragma GCC target ("tune=native")
#pragma GCC target ("avx")

#include <bits/stdc++.h>

// 汎用マクロ
#define ALL_OF(x) (x).begin(), (x).end()
#define REP(i,n) for (long long i=0, i##_len=(n); i<i##_len; i++)
#define RANGE(i,is,ie) for (long long i=(is), i##_end=(ie); i<=i##_end; i++)
#define DSRNG(i,is,ie) for (long long i=(is), i##_end=(ie); i>=i##_end; i--)
#define STEP(i, is, ie, step) for (long long i=(is), i##_end=(ie), i##_step = (step); i<=i##_end; i+=i##_step)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
template<class T> bool chmax(T &a, const T &b) {if (a < b) {a = b; return true;} return false; }
template<class T> bool chmin(T &a, const T &b) {if (a > b) {a = b; return true;} return false; }
#define INF 0x7FFFFFFF
#define LINF 0x7FFFFFFFFFFFFFFFLL
#define Yes(q) ((q) ? "Yes" : "No")
#define YES(q) ((q) ? "YES" : "NO")
#define Possible(q) ((q) ? "Possible" : "Impossible")
#define POSSIBLE(q) ((q) ? "POSSIBLE" : "IMPOSSIBLE")
#define DUMP(q) cerr << "[DEBUG] " #q ": " << (q) << " at " __FILE__ ":" << __LINE__ << endl
#define DUMPALL(q) do { cerr << "[DEBUG] " #q ": ["; REP(i, (q).size()) { cerr << (q)[i] << (i == i_len-1 ? "" : ", "); } cerr << "] at " __FILE__ ":" << __LINE__ << endl; } while (false)
template<class T> T gcd(const T &a, const T &b) { return a < b ? gcd(b, a) : b ? gcd(b, a % b) : a; }
template<class T> T lcm(const T &a, const T &b) { return a / gcd(a, b) * b; }

// gcc拡張マクロ
#define popcount __builtin_popcount
#define popcountll __builtin_popcountll

// エイリアス
#define DANCE_ long
#define ROBOT_ unsigned
#define HUMAN_ signed
#define CHOKUDAI_ const
using  ll = DANCE_ HUMAN_ DANCE_;
using ull = DANCE_ ROBOT_ DANCE_;
using cll = DANCE_ DANCE_ CHOKUDAI_;
using  ld = long double;
using namespace std;

// モジュール


// 処理内容
int main() {
    
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    ll N; cin >> N;

    if (N % 2 == 0) {
        cout << N << " " << N << " " << N/2 << "\n";
        return 0;
    }

    RANGE(h, 1, 3500) RANGE(w, 1, 3500) {
        ll bb = h * w * 4 - N * (w + h);
        if (bb <= 0) continue;
        ll n = N * h * w / bb;
        if (h * w * n * 4 == N * (n * w + w * h + h * n)) {
            cout << h << " " << n << " " << w << "\n";
            return 0;
        }
    }
    cout << "I mistook!\n";
    
}

Measured memory_bytes: 384
#include <stdio.h>
#include <algorithm>

using namespace std;

long long x , ans;
void work () {
	scanf ( "%lld" , &x );
	ans = x / 11;
	ans = ans * 2;
	if ( x % 11 >= 1 && x % 11 <= 6 ) ans++;
	if ( x % 11 >= 7 ) ans += 2;
	printf ( "%lld\n" , ans );
}
int main () {
	work ();
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1000000007;
#define INF 1LL<<30
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()


int main(){
    string s;
    cin>>s;
    int n=s.size();
    
    ll r=0,l=0,ans=0;
    rep(i,n){
        if(s[i]=='>' && s[i+1]=='<'){
            l++;
            ll a=max(r,l);
            ll b=min(r,l)-1;
            ans+=a*(a+1)/2;
            ans+=b*(b+1)/2;
            r=0,l=0;
        }
        else if(s[i]=='>') l++;
        else r++;
    }

    if(r>0 || l>0){
        ll a=max(r,l);
        ll b=min(r,l)-1;
        ans+=a*(a+1)/2;
        ans+=b*(b+1)/2;
    }

    cout<<ans<<endl;
    
}




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

int main(){
    ll h;
    cin >> h;

    ll count = 0;

    while(h > 0){
        h /= 2;
        count++;
    }

    ll ans = 1;

    for(int i = 0; i < count; ++i){
        ans *= 2;
    }


    cout << ans - 1 << endl;
 
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <cmath>
#include <queue>
#include <numeric>
#include <climits>
#include <iterator>
#include <iomanip>
#include <stack>
#include <set>
#include <cstdio>
#include <bitset>
#include <functional>
#include <tuple>
#include <list>
#include <deque>
using namespace std;
typedef pair<int, int> P;

#define FOR(i, a, n) for (ll i = (ll)a; i<(ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)

typedef long long ll;
typedef vector<int> VI;

int a[200010];
int b[200010];
int main() {
    cin.tie(0);
   	ios::sync_with_stdio(false);
    
    int n;
    map<int, int> mp;
    cin >> n;
    REP(i, n){
        int a; cin >> a;
        mp[a]++;
    }
    int m; cin >> m;
    REP(i, m){
        int a; cin >> a;
        if(mp[a]) mp[a]++;
    }
    
    for(auto it=mp.begin(); it!=mp.end(); ++it){
        if(it->second==1) cout << it->first << endl;
    }
	return 0;
}


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

int main() {
	vector<int> money(3);
  for(int i = 0;i < 3;i++){
    cin >> money.at(i);
    }
  
  sort(money.begin(),money.end());
  reverse(money.begin(),money.end());
	cout << money.at(0)*10 + money.at(1) + money.at(2) << endl;    

}


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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) (r).begin(),(r).end()
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)
#define vvl(v,w,h,init) vector<vector<ll>> v(w,vector<ll>(h,init))
#define mp(a,b) make_pair(a,b)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using dict = map<string,int>;
using pii = pair<int,int> ;
using pll = pair<ll,ll> ;

const int mod = 1000000007;
constexpr int inf = ((1<<30)-1)*2+1 ;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0,1,-1,1,-1};
const int dx[] = {0,-1,0,1,1,-1,-1,1};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}

template<typename T>
void Unique(vector<T> &v){
  sort(all(v));
  v.erase(unique(all(v)),v.end());
}
template<typename T,typename U>
ll FindErase(T &v,U tar){
  ll cnt = 0;
  for(auto it = v.begin(); it != v.end();){
    if(*it == tar){
      it = v.erase(it);
      ++cnt;
    }
    else{
      ++it;
    }
  }
  return cnt;
}

struct Edge{
  int to;
  long long cost;
};

struct NODE{
  int pos;
  long long cost;
};
bool operator < (const NODE &a,const NODE &b){
  return a.cost > b.cost;
}
vector<Edge> g[100000],rg[100000];

int N;
const ll INF = 1e15;
vector<ll> dijkstra(vector<Edge> g[100000], int s){
  priority_queue<NODE> Q;
  Q.push({s,0});
  vector<ll> res(N,INF);
  while(Q.size()){
    NODE q= Q.top();Q.pop();
    if(res[q.pos] == INF){
      res[q.pos] = q.cost;
    }
    else{
      continue;
    }
    for(auto n : g[q.pos]){
      Q.push({n.to,q.cost+n.cost});
    }
  }
  return res;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll e,r;
  cin >> N >> e >> r;
  int s,t,d;
  rep(i,e){
    cin >> s >> t >> d;
    g[s].push_back({t,d});
  }
  auto u = dijkstra(g,r);
  rep(i,N){
    if(u[i] != INF)
      cout << u[i] << endl;
    else
      cout << "INF"<<endl;
  }
  return 0;
}

Measured memory_bytes: 23952
#include <iostream>
#include <string>

using namespace std;

int N, A, B;

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

int main(){
    cin >> N >> A >> B;
    int total = 0;
    for (int i=1; i<=N; ++i){
        int sum = findSumOfDigits(i);
        if (sum>=A && sum<=B){
            total += i;
        }
    }
    cout << total << endl;   
    
    return 0;
}

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

int main() {
  
  string n;
  cin >> n;
  
  for (int i = 0; i < 3; i++) {
    if (n.at(i) == '1') {
      n.at(i) = '9';
    }
    else if (n.at(i) == '9') {
      n.at(i) = '1';
    }
  }
  
  cout << n << endl;

return 0;
}

Measured memory_bytes: 3652
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cstdio>
#include <cstring>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>

typedef long long ll;
typedef unsigned long long ull;
using namespace std;

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i = 0;(i) < ((int)(n));++(i))
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define test(a) cout<<"line:"<<__LINE__<<"["<<(#a)<<": "<<(a)<<"]"<<endl

const int INF = 1e9+7;
const ll INFL = 9*1e18;

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

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

#define SUM(vec) accumulate(all(vec),0LL) // 配列の中身を全部足す
template<typename T>void print(T&& x){cout<<x<<endl;}// 改行付き出力
ll inline digit(ll num){int tmp = 0;while(num){tmp++;num/=10;}return tmp;} // 桁数
template<typename T>inline T digitSum(T num){T sum = 0;while(num){sum+=num%10;num/=10;}return sum;} // 各桁の和
template<typename T>inline T gcd(T a,T b){if(b == 0)return a;return gcd(b,a%b);} // 最大公約数
template<typename T>inline T lcm(T a, T b){T g = gcd(a,b);return a/g*b;} // 最小公倍数
template<typename T>inline T power(T a,T b){T tmp=1;rep(i,b){tmp*=a;}return tmp;} // 累乗
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; }
int ctoi(char c){return c-'0';}

// TODO: write
int main() {
  int n;cin>>n;
  set<string> s;
  rep(i,n){
    string str;cin>>str;
    s.insert(str);
  }
  print(s.size());
  return 0; 
}


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

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

int main(){
    ll X;
    cin >> X;

    ll A = 0;
    ll B = 0;

    A = X/500;

    X = X - 500 * A;

    B = X/5;
    X = X - 5 * B;

    cout << A*1000 + B*5 << endl;


    return 0;
}



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

int main() {
    constexpr int max_m = 1 << 21;
    int n; cin >> n;
    vector<int> cnt(max_m);
    for(int i = 0; i < n; ++i) {
        int a, b; cin >> a >> b;
        cnt[a + b] += 1;
    }
    for(int i = 0; i + 1 < max_m; ++i) {
        cnt[i + 1] += cnt[i] / 2;
        cnt[i] &= 1;
        if(cnt[i] & 1) cout << i << " " << 0 << endl;
    }
}



Measured memory_bytes: 11032
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep_inv(i, n, m) for(int i = (int)(n); i > (int)(m); i--)
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vc = vector<char>;
using vvl = vector<vl>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;

int main(){
  ll N, K;
  cin >> N >> K;

  if(N % K == 0)
    cout << 0 << endl;
  else
    cout << 1 << endl;
  
  return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) {
		FastScanner scan = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);
		long[][] pas = new long[110][110];
		pas[0][0] = 1;
		for(int i = 0; i < 109; i++) for(int j = 0; j <= i; j++) {
			pas[i+1][j+1] += pas[i][j];
			pas[i+1][j] += pas[i][j]; 
		}
		int n = scan.nextInt(), p = scan.nextInt();
		int a = 0, b = 0;
		for(int i = 0; i < n; i++){
			int x = scan.nextInt()%2;
			if(x == 0) a++;
			else b++;
		}
		long res = 0;
		if(p == 0) {
			for(int i = 0; i <= a; i++) for(int j = 0; j <= b; j+=2) res += pas[a][i]*pas[b][j];
		} else {
			for(int i = 0; i <= a; i++) for(int j = 1; j <= b; j+=2) res += pas[a][i]*pas[b][j];
		}
		out.println(res);
		out.close();
	}
	
	static class FastScanner {
		BufferedReader br;
		StringTokenizer st;

		public FastScanner() {
			try	{
				br = new BufferedReader(new InputStreamReader(System.in));
				st = new StringTokenizer(br.readLine());
			} catch (Exception e){e.printStackTrace();}
		}

		public String next() {
			if (st.hasMoreTokens())	return st.nextToken();
			try {st = new StringTokenizer(br.readLine());}
			catch (Exception e) {e.printStackTrace();}
			return st.nextToken();
		}

		public int nextInt() {return Integer.parseInt(next());}

		public long nextLong() {return Long.parseLong(next());}

		public double nextDouble() {return Double.parseDouble(next());}

		public String nextLine() {
			String line = "";
			if(st.hasMoreTokens()) line = st.nextToken();
			else try {return br.readLine();}catch(IOException e){e.printStackTrace();}
			while(st.hasMoreTokens()) line += " "+st.nextToken();
			return line;
		}

		public int[] nextIntArray(int n) {
			int[] a = new int[n];
			for(int i = 0; i < n; i++) a[i] = nextInt();
			return a;
		}

		public long[] nextLongArray(int n){
			long[] a = new long[n];
			for(int i = 0; i < n; i++) a[i] = nextLong();
			return a;
		}

		public double[] nextDoubleArray(int n){
			double[] a = new double[n];
			for(int i = 0; i < n; i++) a[i] = nextDouble();
			return a;
		}

		public char[][] nextGrid(int n, int m){
			char[][] grid = new char[n][m];
			for(int i = 0; i < n; i++) grid[i] = next().toCharArray();
			return grid;
		}
	}

}


Measured memory_bytes: 24788
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <numeric>
#include <set>
#include <list>
#include <map>
#include<queue>

const int INF = 1 << 28;
using namespace std;
using Graph = vector<vector<int>>;

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

vector<int> seen(50,-1);
int counter_for_dfs = 0;
void dfs(Graph &G, int v) {
	seen[v] = counter_for_dfs;
	counter_for_dfs++;
	for (auto v_next : G[v]) {
		if (seen[v_next]>=0)continue;

		dfs(G, v_next);
	}
}

void bfs(Graph &G) {
	vector<int> dist(G.size(), -1);
	queue<int> que;
	
	dist[0] = 0;
	que.push(0);
	while (!que.empty()) {
		int v = que.front();
		que.pop();

		for (int g : G[v]) {
			if (dist[g] != -1)continue;
			dist[g] = dist[v] + 1;
			que.push(g);
		}
	}
	for (auto i : dist) {
		cout << i << " ";
	}
}

int main()
{
	int a;
	string s;
	std::cin >> a >> s;
	string result;
	result = a >= 3200 ? s : "red";


	std::cout << result;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main() {
	string s;
	int times[26] = { 0 };

	getline(cin, s);

	while(s != "") {
		transform(s.begin(), s.end(), s.begin(), ::tolower);

		for(int i = 0;i < s.size();i++) {
			times[(int)s.at(i) - (int)'a']++;
		}

		getline(cin, s);
	}

	for(int i = 0;i < 26;i++) {
		cout << (char)(i + (int)'a') << " : " << times[i] << endl;
	}

	return 0;
}

Measured memory_bytes: 3224
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	static int[][] map;
	static int[][] directions8 = { { -1, -1 }, { -1, 0 }, { -1, 1 }, { 0, -1 }, { 0, 1 }, { 1, -1 }, { 1, 0 },
			{ 1, 1 } };
	static int[][] directions4 = { { -1, 0 }, { 1, 0 }, { 0, -1 }, { 0, 1 } };
	static int ans;

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		int K = sc.nextInt();
		int sMachine = sc.nextInt();
		int pMachine = sc.nextInt();
		int rMachine = sc.nextInt();

		String T = sc.next();

		ans = 0;

		boolean[] skipped = new boolean[N + 1];

		for (int i = 0; i < N; i++) {
			if (i < K || T.charAt(i - K) != T.charAt(i) || skipped[i - K]) {
				switch (T.charAt(i)) {
					case 'p':
						ans += pMachine;
						break;
					case 'r':
						ans += rMachine;
						break;
					case 's':
						ans += sMachine;
						break;
					default:
				}
			} else if (i >= K) {
				skipped[i] = true;
			}
		}

		System.out.println(ans);
	}

	// BFS用に二つの配列を足し算する
	static int[] addArrayElms(int[] a, int[] b) {
		int[] c = new int[a.length];
		for (int i = 0; i < a.length; i++) {
			c[i] = a[i] + b[i];
		}
		return c;
	}

	// //二分探索
	// k <= num となる最小の配列要素kのインデックスを返す
	static private int binarySearch(long num, long[] orderedArray) {
		int lowerBorder = -1;
		int upperBorder = orderedArray.length;
		int mid;

		while (upperBorder - lowerBorder > 1) {
			mid = (upperBorder + lowerBorder) / 2;
			if (orderedArray[mid] <= num) {
				lowerBorder = mid;
			} else {
				upperBorder = mid;
			}
		}
		return lowerBorder;
	}

	// 二分探索
	// k <= num となる最小のList要素kのインデックスを返す
	static private int binarySearch(long num, ArrayList<Long> orderedList) {
		int lowerBorder = -1;
		int upperBorder = orderedList.size();
		int mid;

		while (upperBorder - lowerBorder > 1) {
			mid = (upperBorder + lowerBorder) / 2;
			if (orderedList.get(mid) <= num) {
				lowerBorder = mid;
			} else {
				upperBorder = mid;
			}
		}
		return lowerBorder;
	}

	// aとbの最小公倍数を求める
	public static int gcd(int a, int b) {
		return b == 0 ? a : gcd(b, a % b);
	}

	public static long gcd(long a, long b) {
		return b == 0 ? a : gcd(b, a % b);
	}
}


Measured memory_bytes: 39936
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
ll const INF = 1LL << 60;

int main() {
  ll H, W;
  cin >> H >> W;
  vector<string> s(H);
  ll white_sum = 0, black_sum = 0;
  for (int i = 0; i < H; i++) {
    cin >> s[i];
    for (int j = 0; j < W; j++) {
      if (s[i][j] == '#') {
        black_sum++;
      } else {
        white_sum++;
      }
    }
  }
  priority_queue<pair<ll, pair<ll, ll>>> q;
  vector<vector<ll>> memo(H, vector<ll>(W, INF));
  q.push({0, {0, 0}});
  ll min_v = INF;
  bool clear = false;
  while (!q.empty()) {
    auto cost = q.top().first;
    auto pos = q.top().second;
    q.pop();
    if (memo[pos.first][pos.second] < cost) continue;
    ll h = pos.first, w = pos.second;
    if (h + 1 < H && s[h + 1][w] == '.' && cost + 1 < memo[h + 1][w]) {
      q.push({cost + 1, {h + 1, w}});
      memo[h + 1][w] = cost + 1;
    }
    if (0 <= h - 1 && s[h - 1][w] == '.' && cost + 1 < memo[h - 1][w]) {
      q.push({cost + 1, {h - 1, w}});
      memo[h - 1][w] = cost + 1;
    }
    if (w + 1 < W && s[h][w + 1] == '.' && cost + 1 < memo[h][w + 1]) {
      q.push({cost + 1, {h, w + 1}});
      memo[h][w + 1] = cost + 1;
    }
    if (0 <= w - 1 && s[h][w - 1] == '.' && cost + 1 < memo[h][w - 1]) {
      q.push({cost + 1, {h, w - 1}});
      memo[h][w - 1] = cost + 1;
    }
  }
  if (memo[H - 1][W - 1] != INF)
    cout << W * H - memo[H - 1][W - 1] - 1 - black_sum << endl;
  else
    cout << -1 << endl;
  return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define rep(i,j,k) for(int i = (int)j;i <= (int)k;i ++)
#define debug(x) cerr<<#x<<":"<<x<<endl
const int maxn=(int)1e6+5;
int low[maxn];
int vis[maxn],lv[maxn];
vector<int> E[maxn];
set<int> AP;//articulation points
map<pair<int,int>,int> V;
void dfs(int now,int curlv,int fa){
    low[now]=curlv;
    lv[now]=curlv;
    vis[now]=1;
    int son_cnt=0;
    for(auto v:E[now]){
        //1.tree edge to fa, or back edge visited by now's descendant
        if(v==fa)continue;
        //2.back edge to now's ancestor
        if(vis[v]) low[now]=min(low[now],lv[v]);
        //3.tree edge to son.
        else{
            son_cnt++;
            dfs(v,curlv+1,now);
            low[now]=min(low[now],low[v]);
            if(low[v]>=lv[now]){
                AP.insert(now);
            }
        }
    }
    if(lv[now]==0)//root
        if(son_cnt>1) AP.insert(now);
        else if(AP.count(now))AP.erase(now);//多加了
}

int main(){
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int n,m;
    cin>>n>>m;
    rep(i,1,m){
        int x,y;
        cin>>x>>y;
        E[x].push_back(y);
        E[y].push_back(x);
    }
    rep(i,0,n-1)if(!vis[i])dfs(i,0,-1);
   // rep(i,0,n-1)debug(i),debug(low[i]);
    for(auto v:AP)cout<<v<<endl;
}
/* 
4 4
0 1
0 2
1 2
2 3
 */


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

int main(){
  int n,sum;
  cin >> n;
  sum = 0;
  vector<int> ss(n);
  for(int i=0; i<n; ++i){
    cin >> ss[i];
    sum += ss[i];
  }
  sort(ss.begin(),ss.end());
  bool flag =1;
  int j=0;
  if (sum%10!=0) flag = 0; 
  while(flag&&j<n){
    if(ss[j]%10!=0){
      sum -=ss[j];
      flag = 0;
    }
    else j++;
  }
  if(j==n) sum=0;
  cout << sum << endl;
}

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

int main () {
  int N;
  cin >> N;
  int d_sum = 0;
  
  for (int i = 10; i <= N; i *= 10) {
    int x;
    x = (N % i) - (N % (i / 10));
    d_sum += x / (i / 10);
    if ((N / i) <= 9) 
      d_sum += N / i;
  }
  
  if (N <= 9) 
    d_sum += N;
  
  if (N % d_sum == 0)
    cout << "Yes" << endl;
  
  else {
    cout << "No" << 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();
		int M = sc.nextInt();
		int X = sc.nextInt();
		int Y = sc.nextInt();
      int w;
      int max = sc.nextInt();
        for(int i=0; i<N-1; i++){
          w = sc.nextInt();
          if(w > max)
            max = w;
        }
      if(max >= Y){
        System.out.println("War");
        System.exit(0);
      }
      int min = sc.nextInt();
        for(int i=0; i<M-1; i++){
          w = sc.nextInt();
          if(w < min)
            min = w;
        }
      if(min <= X){
        System.out.println("War");
        System.exit(0);
      }
      if(max < min )
        System.out.println("No War");
      else
        System.out.println("War");
	}
}

Measured memory_bytes: 25300
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define vi vector<int>
#define pb push_back
#define pii pair<int , int>
#define fast ios_base::sync_with_stdio(0)
#define mod 1000000007
int arr[22][22], n;
ll dp[21][(1<<21)+5];
/// women is mask
ll fun(int men, int women)
{
    if(women == (1<<n)-1) return 1;
    if(men==n) return 0;
    ll& ret = dp[men][women];
    if(ret!=-1) return ret;
    ret = 0;
    for(int i=0; i<n; i++){
        if(women&(1<<i));
        else if(arr[men][i]==1){
            ret+=fun(men+1, women|(1<<i));
            ret%=mod;
        }
    }
    return ret;
}
int main()
{
    fast;
    cin>>n;
    for(int i=0; i<n; i++)
        for(int j=0; j<n; j++)
            cin>>arr[i][j];
    memset(dp, -1, sizeof dp);
    cout<<fun(0,0)<<endl;
}


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

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define crap ios_base::sync_with_stdio(0);cin.tie(0)
#define ll long long
#define pb push_back
#define ff first
#define ss second
#define endl "\n"
#define int ll

using namespace std;
const int N = 105;
const ll INF = 1e18L+5;
int n,W;
int dp[N][100003];
int v[N];
int w[N];

int solve(int index,int val){
	if(val==0) return 0;
	if(val<0) return INF;
	if(index==-1 ) return INF;
    if(dp[index][val]!=-1) return dp[index][val];
	if(v[index]<=val){
		return dp[index][val] = min(solve(index-1, val-v[index]) + w[index], solve(index-1, val));
	}
	else 
		return dp[index][val] = solve(index-1, val);
}

int32_t main()
{
 
   
    crap;
    memset(dp,-1,sizeof(dp));
    cin>>n>>W;
    int sum=0;
    for(int i=0;i<n;i++){
    	cin>>w[i]>>v[i];
    	sum+=v[i];
    }
    
    //int ans = solve(n-1,sum);
    int f_ans=0;

    for(int i=sum;i>=1;i--){
    	if(solve(n-1,i)<=W){
    		f_ans=i;
    		break;
    	}
    }

    cout<<f_ans<<endl;
   
   
}

Measured memory_bytes: 82304
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const int dx[4] = { 0, -1, 1, 0 };
const int dy[4] = { -1, 0, 0, 1 };
const int INF = 1e9 + 7;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}

template<class T1, class T2> void chmin(T1 &a, T2 b) { if (a>b)a = b; }

template<class T1, class T2> void chmax(T1 &a, T2 b) { if (a<b)a = b; }
template<class T>
void Add(T &a, const T &b, const T &mod = 1000000007) {
	int val = ((a % mod) + (b % mod)) % mod;
	if (val < 0) { val += mod; }
	a = val;
}
////////////////////////////////////////

int main() {
	int N;
	string S;
	int K;
	cin >> N >> S >> K;
	string ans = "";
	for (int i = 0; i < S.size(); ++i) {
		if (S[i] != S[K - 1]) {
			ans += '*';
		}
		else {
			ans += S[i];
		}
	}
	cout << ans << endl;
	return 0;
}



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

int main(){
	int n;
	cin >> n;
	ll power = 1;
	ll mod = 1e9 + 7;

	rep(i,2,n+1){
		power *= i;
		power = power % mod;	
	}
	cout << power << endl;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int n, p, have[50], i, plate,winner;
  while(1){

    scanf("%d%d", &n, &p);

    if(n==0 && p==0) break;

    for(i=0; i<n; i++)have[i]=0;

    plate=p;

    i=0;

    while(1){
      
      if(plate!=0){
	have[i]++;
	plate--;
	if(have[i] == p && plate == 0){
	  winner=i;
	  break;
	}
	i++;
      }else{
	
	plate=have[i];
	have[i]=0;
	i++;

      }

      if(i==n) i=0;
    }
    
    printf("%d\n", winner);
    
  }
  return 0;
}
  

Measured memory_bytes: 600
#include<stdio.h>
#include<string.h>
int N,T,L,B,M[105],t,np,i,j,d;
double res,DP[105][105];
int main()
{
	for(;scanf("%d%d%d%d",&N,&T,&L,&B),N;)
	{
		res=0;
		memset(M,0,sizeof(M));
		memset(DP,0,sizeof(DP));
		DP[0][0]=1;
		for(i=0;i<L;i++){scanf("%d",&t);M[t]=1;}
		for(i=0;i<B;i++){scanf("%d",&t);M[t]=2;}
		for(i=0;i<T;i++)
			for(j=0;j<N;j++)
			{
				for(d=1;d<=6;d++)
				{
					np=j+d;
					if(np>N)np=N-(np-N);
 					if(M[np]==1)
						DP[i+2][np]+=DP[i][j]/6;
					else if(M[np]==2)
						DP[i+1][0]+=DP[i][j]/6;
					else
						DP[i+1][np]+=DP[i][j]/6;
				}
			}
		for(i=0;i<=T;i++)res+=DP[i][N];
		printf("%.10f\n",res);
	}
	return 0;
}

Measured memory_bytes: 728
import java.util.*;
public class Main 
{
	public static void main(String[] args) 
	{
		Scanner stdIn = new Scanner(System.in);
		int w = stdIn.nextInt();
		int n = stdIn.nextInt();
		List<Pair> list = new ArrayList<Pair>();
		for (int i = 0; i < n; i++) 
		{
			String str = stdIn.next();
			String[] arr = str.split(",");
			Pair p = new Pair();
			p.first = Integer.parseInt(arr[0]);
			p.second = Integer.parseInt(arr[1]);
			list.add(p);
		}
		List<Integer> pos = new ArrayList<Integer>();
		for(int i = 0; i < w; ++i)
		{
			pos.add(i + 1);
		}
		for(int i = 0; i < w; ++i)
		{
			int ans = i + 1;
			for(int j = 0; j < n; ++j)
			{
				if(list.get(j).first == ans)
				{
					ans = list.get(j).second;
				}
				else if(list.get(j).second == ans)
				{
					ans = list.get(j).first;
				}
			}
			pos.set(ans - 1, i + 1);
		}
		for(int i = 0; i < w; ++i)
		{
			System.out.println(pos.get(i));
		}
	}
}

class Pair
{
	int first;
	int second;
}

Measured memory_bytes: 17208