akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
//#include<cctype>
#include<climits>
#include<iostream>
#include<string>
#include<vector>
#include<map>
//#include<list>
#include<queue>
#include<deque>
#include<algorithm>
//#include<numeric>
#include<utility>
//#include<memory>
#include<functional>
#include<cassert>
#include<set>
#include<stack>
#include<random>

const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, -1, 0, 1};
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;

std::random_device rnd;
const ull mul[2] = {10000 + (rnd()%10000), 10000 + (rnd()%10000)};
const ull mod[2] = {1000000007, 1000000009};

class RollingHash {
public:
    RollingHash() {}
    template<class T>
    RollingHash(const T& s) {
        init(s);
    }
    template<class T>
    void init(const T& s) {
        n = s.size();
        for (int i = 0; i < 2; i++) {
            pow[i].resize(n+1);
            h[i].resize(n+1);
            pow[i][0] = 1; h[i][0] = 0;
        }
        for (int i = 0; i < 2; i++) {
            for (int j = 0; j < n; j++) {
                pow[i][j+1] = (mul[i]*pow[i][j]) % mod[i];
                h[i][j+1] = (s[j] + h[i][j]*mul[i]) % mod[i];
            }
        }
    }
    inline pair<ull, ull> hash(int i) const {return make_pair(h[0][i], h[1][i]);}
    // [l, r)
    inline pair<ull, ull> hash(int l, int r) const {
        ull p0 = (h[0][r] - (h[0][l]*pow[0][r-l]%mod[0]) + mod[0]) % mod[0];
        ull p1 = (h[1][r] - (h[1][l]*pow[1][r-l]%mod[1]) + mod[1]) % mod[1];
        return make_pair(p0, p1);
    }
private:
    int n;
    vector<ull> pow[2], h[2];
};


int calc(int num, int n, const RollingHash rh) {
    set<pair<ull, ull> > S;
    int ans = 0;
    for (int i = 0; i+num <= n; i++) {
        auto p = rh.hash(i, i+num);
        if (S.find(p) == S.end()) {
            ans++;
            S.insert(p);
        }
    }
    return ans;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string T;
    cin >> T;
    int n = T.size();
    RollingHash rh(T);
    int low = 0, high = n;
    while (high - low > 1) {
        const int med = (high+low)/2;
        if (calc(med, n, rh) == n-med+1) high = med;
        else low = med;
    }
    cout << calc(high, n, rh) << endl;
    return 0;
}


Measured memory_bytes: 12936
#include<bits/stdc++.h>
#define ll long long
#define pll pair<ll,ll>
#define pii pair<int,int>
#define rep(i,a,b) for(int i=a;i<=b;++i)
#define per(i,a,b) for(int i=a;i>=b;--i)
#define mem0(x) memset(x,0,sizeof(x))
#define meminf(x) memset(x,0x3f,sizeof(x))
#define VI vector<int>
#define VL vector<ll>
using namespace  std;

double a[200005];
int n,k;

int check(double x){
    ll cnt = 0;
    rep(i,1,n){
        cnt += (ll)(a[i]/x);
        if(fabs(a[i]-(ll)(a[i]/x)*x)<=0.001) {
            --cnt;
        }
    }
    return cnt>k;
}
int main(){
    ios::sync_with_stdio(0);
    cin>>n>>k;

    double l = 1,r= 0;
    rep(i,1,n){
        cin>>a[i];
        r = max(r,a[i]);
    }
    int cnt = 0;
    while(cnt++<100){
        double mid = (l+r)/2;
        if(check(mid)){
            l = mid;
        }else{
            r = mid;
        }
    }
    cout<<(ll)ceil(l);
}


Measured memory_bytes: 5304
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<iomanip>



#define REP(i,n) for (int i = 0; (i) < (n); ++ (i))

using namespace std;
string a,b;

int main(){
  cin >> a >> b;
  if(a[0]==b[2]&&a[1]==b[1]&&a[2]==b[0]) cout << "YES" <<endl;
  else cout << "NO" <<endl;
  return 0;
}


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

ll mod = pow(10, 9) + 7;

ll modpow(ll a, ll n) {
    if (mod <= 0) return 0;
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

int main() {
    ll N;
    cin >> N;
    ll ans = modpow(10, N) - 2 * modpow(9, N) + modpow(8, N);
    ans = (ans + mod * 100) % mod;
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 3660
A, B, K = map(int, input().split())

for i in range(1, K+1):
    #Takahashi
    if i % 2:
        if A % 2:
            A -= 1
        A, B = A/2, B+A/2
    else:
        if B % 2:
            B -= 1
        A, B = A+B/2, B/2

print(int(A), int(B))

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

string st;

int main() {
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    cin >> st;
    int a=(st[0]-'0')*10+(st[1]-'0');
    int b=(st[2]-'0')*10+(st[3]-'0');
    if((b==0||b>12)&&(a>12||a==0)) cout << "NA\n";
    else if((a>12||a==0)&&b<=12&&b>0) cout << "YYMM\n";
    else if(a<=12&&a>0&&(b>12||b==0)) cout << "MMYY\n";
    else cout << "AMBIGUOUS\n";
    return 0;
}


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

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned __int128 HASH;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll,int> plli;
typedef pair<double, int> pdbi;
typedef pair<int,pii> pipii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<pii> vpii;
typedef vector<vector<int>> mat;

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n);i>0;i--)
#define rrep2(i,a,b) for (int i=(a);i>b;i--)
#define pb push_back
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()

const ll hmod1 = 999999937;
const ll hmod2 = 1000000000 + 9;
const ll INF = 1<<30;
const ll mod = 10000 + 7;
const int dx4[4] = {1, 0, -1, 0};
const int dy4[4] = {0, 1, 0, -1};
const int dx8[8] = {1, 1, 1, 0, 0, -1, -1, -1};
const int dy8[8] = {0, 1, -1, 1, -1, 0, 1, -1};
const double pi = 3.141592653589793;

//#define int long long
#define addm(X, Y) (X) = ((X) + ((Y) % mod) + mod) % mod

int dp[20000 + 5][256];

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    while (true) {
        int n, m;
        cin >> n >> m;
        if (n == 0) break;
        int c[m] = {}, x[n] = {};
        rep(i, m) cin >> c[i];
        rep(i, n) cin >> x[i];
        rep(i, n + 1)rep(j, 256) dp[i][j] = INF;
        dp[0][128] = 0;
        rep(i, n) {
            rep(j, 256) {
                rep(k, m) {
                    if (j + c[k] < 0) {
                        dp[i + 1][0] = min(dp[i + 1][0], dp[i][j] + x[i] * x[i]);
                        continue;
                    }
                    else if (j + c[k] > 255) {
                        dp[i + 1][255] = min(dp[i + 1][255], dp[i][j] + (255 - x[i]) * (255 - x[i]));
                        continue;
                    }
                    dp[i + 1][j + c[k]] = min(dp[i + 1][j + c[k]], dp[i][j] + (j + c[k] - x[i]) * (j + c[k] - x[i]));
                }
            }
        }
        int ans = INF;
        rep(j, 256) ans = min(ans, dp[n][j]);
        cout << ans << endl;

    }
}

Measured memory_bytes: 23220
H,W = map(int,input().split())
c = []
dicta = {}
dicta[-1] = 0
for i in range(10):
    c.append(list(map(int,input().split())))
    dicta[i] = 0
c = [i for i in zip(*c)]
for i in range(H):
    a = list(map(int,input().split()))
    for i in a:
        dicta[i] += 1
dicta.pop(-1)
cost = [0 for i in range(10)]
def dijkstra_heap(start,node,cost):
    import heapq
    d = [float('inf') for i in range(node)]
    used = [False for i in range(node)]
    d[start] = 0
    d2 = [[0,start]]
    heapq.heapify(d2)
    while True:
        flag = True
        while d2:
            c,v = heapq.heappop(d2)
            if not used[v]:
                flag = False
                break
        if flag:
            break
        used[v] = True
        for j in range(node):
            d[j] = min(d[j],d[v]+cost[v][j])
            heapq.heappush(d2,[d[j],j])
    return d

cost = dijkstra_heap(1,10,c)
ans = 0
for k,v in dicta.items():
    ans += v*cost[k]
print(ans)



Measured memory_bytes: 3192
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author HARSHAD
 */

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

class TaskC {
public:
	void solve(std::istream& in, std::ostream& out) {
		int n, m; in>>n>>m;
		char arr[n][m];
		for(int i = 0; i<n; ++i) for(int j = 0; j<m; ++j) in>>arr[i][j];
		int dx[] = {1, 0, -1, 0};
		int dy[] = {0, 1, 0, -1};

		for(int i = 0; i<n; ++i){
			for(int j = 0; j<m; ++j){
				if(arr[i][j] != '#') continue;
				bool flag = false;
				for(int k = 0; k<4; ++k){
					int ni = i + dx[k], nj = j + dy[k];
					if(ni>=0 and ni<n and nj>=0 and nj<m and arr[ni][nj]=='#') flag = true;
				}
				if(!flag){
					out<<"No";
					return;
				}
			}
		}
		out<<"Yes";
	}
};


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	TaskC solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


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

bool binarySearch(int *n, int countN, int key) {
    int left = 0, right = countN, middle;
    while (left < right) {
        middle = (left + right) / 2;
        if (n[middle] == key) {
            return true;
        } else if (key < n[middle]) {
            right = middle;
        } else {
            left = middle + 1;
        }
    }

    return false;
}
        
int main() {
    int countN, n[999999], countQ;

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

    cin >> countQ;
    int t = 0, match = 0;
    for (int i = 0; i < countQ; i++) {
        cin >> t;
        if (binarySearch(n, countN, t)) match++;
    }

    cout << match << endl;
   

    /***
    cin >> countQ;
    for (int i = 0; i < countQ; i++) {
        cin >> t[i];
    }

    int match = 0;
    for (int i = 0; i < countQ; i++) {
        if (binarySearch(n, countN, t[i])) match++;
    }

    cout << match << endl;
    ***/

    /***
    int match = 0;
    for (int j = 0; j < countQ; j++) {
        for (int i = 0; i < countN; i++) {
            if (n[i] == t[j]) {
                match++;
                break;
            }
        }
    }
    cout << match << endl;
    ***/
}

Measured memory_bytes: 1556
#include <iostream>
#include <algorithm>
#include <utility>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <math.h>
#include <string.h>
#include <iomanip>
#include <numeric>
#include <cstdlib>
#include <cstdint>
#include <cmath>
#include <functional>
#include <limits>
#include <cassert>
#include <bitset>

using namespace std;

/* template */

using ll = long long;

void debug_out() { std::cout << std::endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << H << " ";
  debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cout << "debug: "; debug_out(__VA_ARGS__)
#else
#define debug(...) 
#endif

#define rep(i, a, n) for (int i = (int)(a); i < (int)(n); i++)
#define rrep(i, a, n) for (int i = ((int)(n-1)); i >= (int)(a); i--)
#define Rep(i, a, n) for (long long i = (long long)(a); i< (long long)(n); i++)
#define RRep(i, a, n) for (long long i = ((long long)(n-1ll)); i>=(long long)(a); i--)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()

template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (std::size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}

struct Edge{
    int to;
    ll weight;
    Edge(int t, ll w) : to(t), weight(w){ }
};

struct edge{
    int from;
    int to;
    ll weight;
    edge(int f,int t,ll w) : from(f), to(t), weight(w){ }
};


using Graph = vector<vector<Edge>>;
using graph = vector<vector<int>>;
using edges = vector<edge>;

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

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

template <class T>
T lcm(T a, T b){
    return (a*b)/gcd(a,b);
}

constexpr ll LNF = 1LL<<60;

constexpr int INF = 1e9+7;

const double PI=3.14159265358979323846;


vector<int> dx = {-1,0,1,0,-1,1,-1,1};
vector<int> dy = {0,-1,0,1,1,-1,-1,1};

/* template */

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll n,a,b,c,d; cin >> n >> a >> b >> c >> d;
    ll x = b-a;
    Rep(i,0,n){
        ll l = c*(n-i-1) -d*i;
        ll r = d*(n-i-1) -c*i;
        if(l<= x && x <= r){
            cout << "YES" << endl;
            return 0;
        }
    }
    cout << "NO" << endl;
} 

Measured memory_bytes: 256
from collections import deque

def bfs(S,s,H,W):
    dx=[1,0,0,-1]
    dy=[0,1,-1,0]
    d=deque([s])
    visited=[[-1 for _ in range(W)] for _ in range(H)]
    visited[s[0]][s[1]]=0
    max_time_=0
    while d:
        root=d.popleft()
        prev=visited[root[0]][root[1]]
        for n in range(len(dx)):
            n_x=root[0]+dx[n]
            n_y=root[1]+dy[n]
            if (0<=n_x<=H-1) and (0<=n_y<=W-1):
                if S[n_x][n_y]=="." and visited[n_x][n_y]==-1:
                    d.append((n_x,n_y))
                    visited[n_x][n_y]=prev+1
                    max_time_=max(max_time_,prev+1)
    return max_time_

def main():
    #スタート地点を固定し、全てのマスへの移動回数を全探索し、最大移動回数を求める。
    #スタート地点を全探索し、最大移動回数内の最大値を答えとして出力する。
    #input
    H,W=map(int,input().strip().split())
    S=[list(input()) for _ in range(H)]
    
    #スタート地点を固定し、sg_listに格納。
    #スタート地点〜全ての"."を探索し、最も遠い点をsg_listに格納する。
    #最も遠い点までの移動回数をturns_listに格納する。
    sg_list=[]
    max_time=0
    for w in range(W):
        for h in range(H):
            if S[h][w]=="." and (h,w) not in sg_list:
                start=(h,w)
                sg_list.append((h,w))
                max_time=max(max_time,bfs(S,start,H,W))
    return max_time

if __name__=="__main__":
    print(main())

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


int main() {

    ll n;
    cin >> n;
    for (ll i = 1; i < 100000; ++i) {
        if (i * i > n) {
            cout << (i-1) * (i-1) << endl;
            return 0;
        }
    }
    return 0;
}

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

const ll inf=1e15;
const int MAX_V=100;

int V,E;
ll G[MAX_V+1][MAX_V+1];

int main() {
  cin>>V>>E;
  rep(i, V) rep(j, V) G[i][j]=(i!=j)*inf;
  rep(i, V) G[i][i]=0;
  rep(i, E) {
    int a,b,c; cin>>a>>b>>c;
    G[a][b]=c;
  }
  rep(k, V) rep(i, V) rep(j, V) G[i][j]=min(G[i][j], G[i][k]+G[k][j]);
  bool ok=true;
  rep(i, V) if (G[i][i]<0) ok=false;
  if (ok) {
    rep(i, V) {
      rep(j, V) {
        if (j) cout<<" ";
        if (G[i][j]>inf/2) cout<<"INF";
        else cout<<G[i][j];
      }
      cout<<endl;
    }
  }
  else cout<<"NEGATIVE CYCLE"<<endl;
}



Measured memory_bytes: 3172
//#include"pch.h"
//#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<stdlib.h>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<algorithm>
#include<iostream>
using namespace std;

int main() {
	char S[10];
	int ans = 0;
	cin >> S;
	size_t size = strlen(S);
	for (int i = 0; i < size; i++) {
		ans -= (S[i] == '+') ? -1 : 1;
	}
	cout << ans;

	return(0);
}

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

int main(){
    string s;
    cin >> s;
    int n = s.size();
    int ans[n] = {0};
    int cnt = 0;
    for (int i = 0; i < n; ++i) {
        if (s[i] == 'R') cnt++;
        else {
            ans[i-1] += (cnt+1) / 2;
            ans[i] += cnt / 2;
            cnt = 0;
        }
    }

    for  (int i = n-1; 0 <= i; --i) {
        if (s[i] == 'L') cnt++;
        else {
            ans[i+1] += (cnt+1) / 2;
            ans[i] += cnt / 2;
            cnt = 0;
        }
    }

    for (int i = 0; i < n; ++i) {
        printf("%d%c", ans[i], (i == n-1) ? '\n' : ' ');
    }
}


Measured memory_bytes: 1152
def main():
    N, M, K = [int(x) for x in input().split()]
    if M == 1:
        if K == N - 1:
            return 1
        else:
            return 0
    if N == 1:
        return M
    mod = 998244353
    fact = [1]
    for i in range(1, N):
        fact.append(fact[-1] * i % mod)
    count = 0
    for k in range(K + 1):
        current = pow(M - 1, N - k - 1, mod) * M % mod
        rev = pow(fact[k] * fact[N - 1 - k] % mod, mod - 2, mod)
        current = (current * fact[N - 1] % mod) * rev % mod
        count = (count + current) % mod
    return count


if __name__ == "__main__":
    print(main())


Measured memory_bytes: 16776
#include<stdio.h>
int main(void){
  char s[200001],t[200001];
  scanf("%s%s",&s,&t);
  int c=0;
  for(int i=0;i<strlen(s);i++){
	if(s[i]!=t[i])c++;
  }
  printf("%d",c);
  return 0;
}

Measured memory_bytes: 2128
#include <algorithm>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>

using namespace std;

typedef long long ll;
// constexpr ll MOD = 998244353;
constexpr ll MOD = 1000000007;

// struct UnionFind {
//     vector<int> par;
    
//     UnionFind(int N): par(N) {
//         for (int i=0;i<N;i++) par[i] = i;
//     }

//     int root(int x) {
//         if (par[x] == x) return x;
//         else 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;
//     }
// };

vector<ll> fact(100010,0), factinv(100010,0);

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

void init(int N) {
    fact[0] = 1, fact[1] = 1;
    for (int i=2;i<=N;i++) fact[i] = i*fact[i-1] % MOD;
    factinv[0] = 1, factinv[1] = 1;
    for (int i=2;i<=N;i++) factinv[i] = modpow(fact[i],MOD-2) % MOD;
}

int main(void) {
    int N, K;
    cin >> N >> K;
    vector<ll> A;
    for (int i=0;i<N;i++) {
        ll X; cin >> X;
        A.push_back(X);
    }
    init(N);
    sort(A.begin(),A.end());
    ll res = 0;
    K = N-K;
    for (int i=N-1;i>=N-K-1;i--) {
        // cout << A[i] << "," << fact[i]*factinv[N-K-1] % MOD *factinv[i-(N-K-1)] % MOD << endl;
        res += ((A[i] % MOD) * (((fact[i] % MOD) * factinv[N-K-1] % MOD) * factinv[i-(N-K-1)] % MOD)) % MOD;
        res %= MOD;
    // cout << res << endl;
    }
    for (int i=0;i<=K;i++) {
        // cout << A[i] << "," << fact[N-1-i]*factinv[N-K-1] % MOD *factinv[K-i] % MOD << endl;
        res -= ((A[i] % MOD) * (((fact[N-1-i] % MOD) * factinv[N-K-1] % MOD) * factinv[K-i] % MOD)) % MOD;
        res %= MOD;
    // cout << res << endl;
    }
    if (res<0) res += (-res/MOD+1)*MOD;
    cout << res % MOD << endl;

    return 0;
}


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

typedef pair<int,int> P;
#define ll long long
#define ld long double
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define sz(x) ((int)(x).size())
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)

const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
int main()
{
    int hgt,w;cin >>hgt >> w;
    int n;cin >> n;
    vector<int> a(n);rep(i,n)cin >> a[i];
    vector<vector<int> > c(hgt, vector<int>(w));
    int h,l;h = 0;l = 0;
    int flag = 0;
    int color = 0;
    while(color < n)
    {
        rep(j,a[color])
        {
            if(flag == 0)
            {
                if(l>=w)
                {
                    h++;
                    flag++;
                    l = w-1;
                    c[h][l] = (color+1);
                    l--;
                    continue;
                }
                c[h][l] = (color+1);
                l++;
            }else
            {
                if(l<0)
                {
                    h++;
                    flag  = (flag+1)%2;
                    l=0;
                    c[h][l] = (color+1);
                    l++;
                    continue;
                }
                c[h][l] = (color+1);
                l--;
            }
            
        }
        color++;
    }
    rep(i,hgt)
    {
        rep(j,w)
        {
            cout << c[i][j] << " ";
        }
        cout  << endl;
    }
}

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

using namespace std;

#define ALL(x) (x).begin(), (x).end()

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.precision(15);
    cout << fixed;

    string s;
    cin >> s;
    
    bool yes = true;

    for (int i = 0; i < s.length(); i++) {
        if (s[i] == 'R' && i % 2 == 1)
            yes = false;
        if (s[i] == 'L' && i % 2 == 0)
            yes = false;
    }

    if (yes)
        cout << "Yes" << '\n';
    else
        cout << "No" << '\n';

    return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func getNextLine(scanner *bufio.Reader) string {
	var buffer string
	for {
		line, isPrefix, _ := scanner.ReadLine()
		buffer += string(line)
		if isPrefix == false {
			break
		}
	}
	return buffer
}

func getIntList(scanner *bufio.Reader) []int {
	list := strings.Split(getNextLine(scanner), " ")
	l := len(list)
	result := make([]int, l)
	for i := 0; i < l; i++ {
		result[i], _ = strconv.Atoi(list[i])
	}
	return result
}

func main() {
	fp := os.Stdin
	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
	}

	scanner := bufio.NewReader(fp)

	var n, m, q, l, r int

	fmt.Sscan(getNextLine(scanner), &n, &m, &q)
	counter := make([][]int, n+1)
	for i := 0; i <= n; i++ {
		counter[i] = make([]int, n+1)
	}
	for i := 0; i < m; i++ {
		lr := getIntList(scanner)
		l, r = lr[0], lr[1]
		counter[l][r]++
	}
	for i := 1; i <= n; i++ {
		for j := 1; j <= n; j++ {
			counter[i][j] += counter[i][j-1]
			counter[i][j] += counter[i-1][j]
			counter[i][j] -= counter[i-1][j-1]
		}
	}
	for i := 0; i < q; i++ {
		lr := getIntList(scanner)
		l, r = lr[0], lr[1]
		fmt.Println(counter[r][r] - counter[l-1][r] - counter[r][l-1] + counter[l-1][l-1])
	}
}


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

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

int main(){
    ll h,w;
    cin>>h>>w;
    if(h==1||w==1){
        cout<<1;
    }else{
        cout<<(h*w+1)/2;
    }
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>

#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define NDEBUG
#define eprintf(...) do {} while (0)
#endif
#include<cassert>

using namespace std;

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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(),i##_end=(c).end();i!=i##_end;++i)

template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }
template<class Iter> void rprintf(const char *fmt, Iter begin, Iter end) {
    for (bool sp=0; begin!=end; ++begin) { if (sp) putchar(' '); else sp = true; printf(fmt, *begin); }
    putchar('\n');
}

int N;
char S[30011];

bool D1[10];
bool D2[100];
bool D3[1000];


void MAIN() {
    scanf("%d", &N);
    scanf("%s", S);
    REP (i, N) {
	int d = S[i]-'0';
	REP (t, 100) if (D2[t]) {
	    D3[t*10 + d] = true;
	}
	REP (t, 10) if (D1[t]) {
	    D2[t*10 + d] = true;
	}
	D1[d] = true;
    }

    int ans = 0;
    REP (t, 1000) if (D3[t]) ans++;
    printf("%d\n", ans);
}

int main() {
    int TC = 1;
//    scanf("%d", &TC);
    REP (tc, TC) MAIN();
    return 0;
}



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

#define ll long long

using namespace std;

const int MAXN = 100010;
const int MAXM = 100010;
const int INF = 0x3f3f3f3f;
const int mod = 1e9 + 7;

ll n, m, k;
int ans, tot, cnt;

int a[MAXN];

string s;

int main(){
	int t = 0;
	cin >> n;
	ll now = 100;
	while (now < n) {
		t++;
		now += (ll)(now / 100.0);
//		cout << now << endl;
	}
	cout << t << endl;
	return 0;
}



Measured memory_bytes: 3628
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N=sc.nextInt();
		int[] arr=new int[2*N];
		int index=0;
		while(index<2*N){
			arr[index++]=sc.nextInt();
		}
		Arrays.sort(arr);
		int res=0;
		for(int i=0;i<2*N;i +=2){
			res +=arr[i];
		}
		System.out.println(res);
	}
}

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

#define rep(i, a, b) for (ll i = (a); i < (b); i++)
typedef uint64_t ull;
typedef int64_t ll;
typedef std::pair<ll, ll> PLL;

using namespace std;

bool isM(ll x){
  return 1<=x && x<=12;
}

signed main() {
  ll s;
  cin>>s;
  ll l = s%100;
  ll u = s/100;

  if (isM(l) && isM(u)) {
    cout<<"AMBIGUOUS"<<endl;
  } else if (isM(l)) {
    cout<<"YYMM"<<endl;
  } else if (isM(u)) {
    cout<<"MMYY"<<endl;
  } else {
    cout<<"NA"<<endl;
  }
  return 0;
}


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

#define int long long
const int maxn = 1e5 + 87;
int sz[3], mark[maxn], M;
vector <int> adj[maxn], radj[maxn];
bool T;

bool dfs(int v) {
	sz[mark[v]]++;
	bool f = 1;
	M += adj[v].size();
	T = T | ((bool)adj[v].size() & (bool)(radj[v].size()));
	for (auto u: adj[v]) {
		if (mark[u] == -1) {
			mark[u] = (mark[v] + 1) % 3;
			f = dfs(u) & f;
		}
		else if (mark[u] != (mark[v] + 1) % 3) f = 0;
	}
	for (auto u: radj[v]) {
		if (mark[u] == -1) {
			mark[u] = (mark[v] + 2) % 3;
			f = dfs(u) & f;
		}
		else if (mark[u] != (mark[v] + 2) % 3) f = 0;
	}
	return f;
}

int32_t main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, m;
	cin >> n >> m;
	for (int i = 0; i < m; i++) {
		int v, u;
		cin >> v >> u;
		v--;
		u--;
		adj[v].push_back(u);
		radj[u].push_back(v);
	}
	int ans = 0;
	fill(mark, mark + n, -1);
	for (int i = 0; i < n; i++) {
		if (mark[i] == -1) {
			T = 0, M = 0;
			mark[i] = 0;
			sz[0] = sz[1] = sz[2] = 0;
			if (dfs(i)) {
				if (T)
					ans += sz[0] * sz[1] + sz[1] * sz[2] + sz[2] * sz[0];
				else ans += M;
//				cout << "SAL " << endl;
			}
			else {
				ans += (sz[0] + sz[1] + sz[2]) * (sz[0] + sz[1] + sz[2]);
//				cout << "AJAB" << ' ' << sz[0] << ' ' << sz[1] << ' ' << sz[2] << ' ' << ans << endl;
			}
		}
	}
	cout << ans;
}


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

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

#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define sz(x) ll(x.size())
//typedef pair<ll, int> P;
typedef pair<ll, ll> P;
//const double INF = 1e10;
const ll INF = LONG_LONG_MAX / 100;
//const ll INF = (1ll << 31) - 1;
//const ll INF = 1e15;
const ll MINF = LONG_LONG_MIN;
//const int INF = INT_MAX / 10;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
//typedef pair<int, int> P;
//typedef pair<double, double> P;

bool contain(set<P> &s, P a) { return s.find(a) != s.end(); }

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
const int mod = 1000000007;
typedef priority_queue<long long, vector<long long>, greater<long long>> PQ_ASK;


void print_line(vector<string> &line) {
    if (line.size() == 0ll) {
        cout << endl;
        return;
    }
    for (ll i = 0; i < line.size(); i++) {
        cout << line[i];
        if (i == line.size() - 1) cout << endl;
        else cout << ' ';
    }
}


class UnionFind {
public:
    // 親の番号を格納する。親だった場合-size
    vector<int> parents;

    UnionFind(int n) {
        parents = vector<int>(n, -1);
    }

    // aがどのグループに属しているか
    int root(int a) {
        if (parents[a] < 0) {
            return a;
        }
        return parents[a] = root(parents[a]);
    }

    int size(int a) {
        return -parents[root(a)];
    }

    // aとbをくっつける
    bool connect(int a, int b) {
        int ra = root(a);
        int rb = root(b);
        if (ra == rb) {
            return false;
        }
        // 大きいほうにA
        if (size(ra) < size(rb)) {
            swap(ra, rb);
        }
        parents[ra] += parents[rb];
        parents[rb] = ra;
        return true;
    }

    bool is_union(int a, int b) {
        int ra = root(a);
        int rb = root(b);
        return ra == rb;
    }

};

struct Edge {
    ll from, to, cost;
};


int main() {
    int v, e;
    cin >> v >> e;

    vector<Edge> edges;
    rep(i, e) {
        Edge edge;
        cin >> edge.from >> edge.to >> edge.cost;
        edges.push_back(edge);
    }

    sort(edges.begin(), edges.end(), [](Edge &e, Edge &f) {
        return e.cost < f.cost;
    });

    ll ans = 0;
    UnionFind uf(v);

    for (Edge &edge : edges) {
        if (uf.is_union(edge.from, edge.to)) {
            continue;
        }
        ans += edge.cost;
        uf.connect(edge.from, edge.to);
    }
    cout << ans << endl;

}





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


int main() {
  int N;
  cin >> N;
  int bt, bx, by, diffx, diffy, difft;

  vector<int> t(N);
  vector<int> x(N);
  vector<int> y(N);

  bool ans = true;

  for(int i = 0; i < N; ++i){
    cin >> t.at(i) >> x.at(i) >> y.at(i);
  }

  bt = 0;
  bx = 0;
  by = 0;
  for(int i = 0; i < N; i++){
    diffx = max(x.at(i), bx) - min(x.at(i), bx);
    diffy = max(y.at(i), by) - min(y.at(i), by);
    difft = t.at(i) - bt;
    if((difft < diffx + diffy )|| (difft - diffx - diffy) % 2 == 1){
      ans = false;
      break;
    }

    bt = t.at(i);
    bx = x.at(i);
    by = y.at(i);
  }

  if(ans){
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }



}


Measured memory_bytes: 1408
N, X, Y, Z = [int(_) for _ in input().split()]
mod = 10**9 + 7
dp = [0] * (2**(X + Y + Z))
dp[0] = 1
al = (2**(X + Y + Z)) - 1
ng = (2**Z + 2**(Y + Z) + 2**(X + Y + Z)) // 2
for _ in range(N):
    dpn = [0] * (2**(X + Y + Z))
    for i in range(1, 11):
        for b in range(2**(X + Y + Z)):
            nb = (b << i | 1 << (i - 1)) & al
            if ng & nb == ng:
                continue
            dpn[nb] += dp[b]
    for b in range(2**(X + Y + Z)):
        dpn[b] %= mod
    dp = dpn
ans = 10**N % mod
ans -= sum(dp)
ans %= mod
print(ans)


Measured memory_bytes: 83676
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>  // std::unique
#include <cmath>
#include <limits.h>
#include <unordered_map>
using namespace std;

using ll = long long;
constexpr auto PrimeBigNum10_9_7 = 1000000007;

// 素数判定
template <typename T>
bool IsPrimeNumber(T value) {

	for (int i = 2; i * i <= value; ++i) {
		if ((value % i) == 0) {
			return true;
		}
	}
	return false;
}

// 桁数判定
template <typename T>
T GetFigureLength(T value) {
	T figure = 1;
	while (value >= 10) {
		value /= 10;
		++figure;
	}
	return figure;
}

// 素因数分解結果
template <typename T>
map<T, T> GetPrimeFactorize(T value) {

	map<T, T> res;

	for (T i = 2; i * i <= value; ++i) {
		if ((value%i) != 0)	continue;

		T count = 0;
		while ((value % i) == 0) {
			value /= i;
			++count;
		}

		res[i] = count;
	}

	if (value != 1) {
		res[value] = 1;
	}
	return res;
}

void DebugPrint(const vector<ll>& vec) {
	cout << "{";
	for (auto itr = vec.begin(); itr != vec.end(); ++itr) {
		cout << *itr << ",";
	}
	cout << "}" << endl;
}

// valueが2のx乗以下である計算
ll calc2x(ll value) {
	ll n = 0;
	while (value > 0) {
		value /= 2;
		++n;
	}
	return n;
}

int main(void) {

	ll n;
	cin >> n;
	string str;
	cin >> str;

	string ans = str;

	if (ans.length() > n) {
		ans = ans.substr(0, n) + "...";
	}

	auto output = ans;
	cout << output;

	return 0;
}


Measured memory_bytes: 3628
#include<iostream>
#include<string>
using namespace std;
int main(void)
{
	string set;
	int joi = 0;
	int ioi = 0;
	for (int a = 0; a < 5; a++)
	{
		cin >> set;
		int b = set.size();
		for (int c = 0; c < b - 2; c++)
		{
			if (set.substr(c,3) == "JOI") joi++;
			if (set.substr(c, 3) == "IOI")ioi++;
		}
		cout << joi << endl << ioi << endl;
		joi = 0;
		ioi = 0;
	}
	return 0;
}

Measured memory_bytes: 3016
k = int(input())

if k%2==0:
	print(-1)
	quit()

sevens = 7
for i in range(1000000):
	if sevens % k == 0:
		print(str(i+1))
		quit()
	else :
		sevens = (sevens % k) * 10 + 7

print(-1)
quit()

Measured memory_bytes: 9188
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <math.h>
#include <complex>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <functional>
#include <assert.h>
#define int long
#define ll long long
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define SZ(x) x.size()
#define fi first
#define se second
const int INF = 1e9;
using namespace std;

template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;

using pi=pair<int,int>;
using vi=vc<int>;

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

int gcd(int a,int b){return b ? gcd(b,a%b) : a;}
int lcm(int a,int b){return a/gcd(a,b)*b;}

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(20);

    int N,M; cin >> N >> M;
    int A[N];
    rep(i,N) cin >> A[i];
    int cnt;
    bool can = true;
    rep(i,N){
        int pos=0;
        int now=A[i];
        while((now>0) && now%2==0){
            now/=2;
            pos++;
        }
        if(!i) cnt=pos;
        if(cnt!=pos) can = false;
    }
    if(!can){
        cout << 0 << endl;
        return 0;
    }
    int a=1;
    rep(i,N){
        a=lcm(a,A[i]/2);
    }
    if(M<a) cout << 0 << endl;
    else cout << ((M/a+1)/2) << endl;
}


Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#define MAX 10000000
#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
using namespace std;
typedef pair<int,int> P;
int used[MAX];

P getRecurringCycle(int fraction,int denominator)
{
  rep(i,MAX)used[i] = -1;
  fraction *= 10;
  used[fraction] = 0;
  int cnt = 0;
  while(true)
    {
      cnt++;
      fraction -= fraction/denominator*denominator;
      fraction *= 10;
      if(fraction == 0)return P(cnt,0);
      if(used[fraction] != -1)break;
      used[fraction] = cnt;
    }
  return P(used[fraction],cnt-used[fraction]);
}

int main()
{
  int x,y;
  while(cin >> x >> y,x|y)
    {
      P p = getRecurringCycle(x,y);
      cout << p.first << " " << p.second << endl;
    }
  return 0;
}

Measured memory_bytes: 40220
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<int(n);++i)
#define all(a) (a).begin(),(a).end()
typedef long long ll;
#define rep1(i,n) for(int i=1;i<=int(n);++i)
#define lb(s,x) (lower_bound(all(s),x)-s.begin())
#define ub(s,x) (upper_bound(all(s),x)-s.begin())
#define uniq(a) a.erase(unique(all(a)),a.end())
#define bit(k) (1LL<<(k))
const int INF = 1e9;

#define debug(x) cerr<<(#x)<<": "<<(x)<<endl
template<class T,class U>
ostream& operator<<(ostream& o, const pair<T,U> &p){
    o<<"("<<p.first<<", "<<p.second<<")";
    return o;
}
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }


int main(void){
    int a,b,c,n;
    cin >> a >> b >> c >> n;
    int cnt = 0;
    rep(i, 3001){
        rep(j,3001){
            if (n < (i*a + j*b)) continue;
            int k = (n - (i*a + j*b))/c;
            if (i*a + j*b + k*c == n) {
                cnt ++;
            }
        }
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 256
from collections import deque
import itertools
def main():
    H, W = list(map(int, input().split()))
    A = [['#'] * (W + 2)] + [['#', ] + list(input()) + ['#', ] for _ in range(H)] + [['#'] * (W + 2)]
    DXY = [[1, 0], [-1, 0], [0, 1], [0, -1]]
    ans = 0
    INF = 10000
    for h in range(1, H + 1):
        for w in range(1, W + 1):
            if A[h][w] == '#':
                continue
            count = [[-1 if i == '#' else INF for i in a] for a in A]
            count[h][w] = 0
            stack = deque([[h, w], ])
            visited = [[0] * W for _ in range(H)]
            while stack:
                x, y = stack.popleft()
                if visited[x - 1][y - 1] == 1:
                    continue
                else:
                    visited[x - 1][y - 1] = 1
                for (dx, dy) in DXY:
                    X = x + dx
                    Y = y + dy
                    if A[X][Y] == '.':
                        if visited[X - 1][Y - 1] == 0:
                            stack.append([X, Y])
                        count[X][Y] = min(count[X][Y], count[x][y] + 1)
            count = list(itertools.chain.from_iterable(count))
            ans = max(ans, max(count))
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3316
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner scan = new Scanner(System.in);
    int X = scan.nextInt();
    int Y = scan.nextInt();
    int Z = scan.nextInt();
    scan.close();

    System.out.println(Z + " " + X + " " + Y);
  }
}

Measured memory_bytes: 21588
import java.util.HashSet;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		int n, i;
		String str, str1;
		Scanner sc = new Scanner(System.in);
		HashSet<String> hs = new HashSet<String>();
		n = sc.nextInt();
		for (i = 0; i < n; ++i) {
			str = sc.next();
			if (str.equals("insert")) {
				str1 = sc.next();
				hs.add(str1);
			}
			if (str.equals("find")) {
				str1 = sc.next();
				if (hs.contains(str1)) {
					System.out.println("yes");
				} else {
					System.out.println("no");
				}
			}
		}
		sc.close();
	}

}



Measured memory_bytes: 258004
S = input()

while True:
  if S[-5:] == 'dream':
    S = S[:-5]
    continue
  elif S[-7:] == 'dreamer':
    S = S[:-7]
    continue
  elif S[-5:] == 'erase':
    S = S[:-5]
    continue
  elif S[-6:] == 'eraser':
    S = S[:-6]
    continue
  break

answer = 'YES' if not S else 'NO'
print(answer)

Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define intput(i) cout << i << endl
#define ll long long
#define stringput(s) cout << (string)(s) << endl

ll GCD(ll a, ll b){
    if(a < b) return GCD(b,a);
    if(b == 0) return a;
    else return GCD(b,a%b);
}

ll LCM(ll a, ll b){
    return (a*b/GCD(a,b));
}


int main(){
  int a, b;
  cin >> a >> b;
  cout << LCM(a,b) << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		int n = scn.nextInt();
		int max = scn.nextInt();
		int min = max;
		for(int i=0;i<n-1;i++){
			int a = scn.nextInt();
			if(a > max){
				max = a;
			}
			if( a < min){
				min = a;
			}
		}

		System.out.println(max - min);
	}
}


Measured memory_bytes: 23636
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define show(x) cout << #x << " = " << (x) << endl;
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = 1<<30;
const ll INFLL = 1LL<<60;
//cout << fixed << setprecision(10);

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

int main () {
  int n;
  cin >> n;
  vi s(n);
  rep(i,n) cin >> s[i];
  
  int sum = 0;
  rep(i,n) sum += s[i];

  int ans = sum;
  if (ans%10 == 0) {
    sort(s.begin(), s.end());
    rep(i,n) {
      if (s[i]%10 != 0) {
        ans -= s[i];
        cout << ans << endl;
        return 0;
      }
    }
  }
  else {
    cout << ans << endl;
    return 0;
  }
  cout << 0 << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    string s;
    cin>>n>>s;
    int siz=s.size();
    for(int i=0;i<siz;i++)
    {
        if(s[i]+n>90)
        {
            int x=s[i]+n;
            x=x-90;
            s[i]='A'+x-1;
        }
        else
        {
            s[i]=s[i]+n;
        }
    }

    cout<<s;


    return 0;

}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)

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

ll w0;

void dfs(const vector<vector<ll> > &diff, int v, ll w_rem, ll tot, ll &ma) {
  ll round_sum = 0;
  if (v == 4) {
    ma = max(ma, tot);
    return;
  }
  REP(i, 0, diff[v].size() + 1) {
    if (w_rem < (w0 + v) * i) {
      break;
    }
    dfs(diff, v + 1, w_rem - (w0 + v) * i, tot + round_sum, ma);
    if (i < (int) diff[v].size()) {
      round_sum += diff[v][i];
    }
  }
}

int main(void){
  int n;
  ll w_tot;
  cin >> n >> w_tot;
  vector<ll> w(n), v(n);
  REP(i, 0, n) {
    cin >> w[i] >> v[i];
  }
  vector<vector<ll> > diff(4);
  w0 = w[0];
  REP(i, 0, n) {
    diff[w[i] - w[0]].push_back(v[i]);
  }
  REP(i, 0, 4) {
    sort(diff[i].rbegin(), diff[i].rend());
  }
  ll ma = 0;
  dfs(diff, 0, w_tot, 0, ma);
  cout << ma << endl;
}


Measured memory_bytes: 256
#include <cstring>
#include <iostream>
#include <queue>
#include <vector>

using namespace std;

vector<pair<int, int> > edges[100000];

vector<int> vtx;
int comp[100000], x[100000];
int mini, cur;
bool error;

void dfs(int v) {
    comp[v] = cur;
    vtx.push_back(v);
    
    for (auto e : edges[v]) {
        int w = e.first;

        if (comp[w] == -1) {
            x[w] = x[v] + e.second;
            mini = min(mini, x[w]);
            dfs(w);
        } else if (x[w] != x[v] + e.second)
            error = true;
    }
}

int main() {
    ios::sync_with_stdio(false);

    int n, m;
    cin >> n >> m;

    for (int i = 0; i < m; i++) {
        int l, r, d;
        cin >> l >> r >> d;
        edges[l-1].emplace_back(r-1, d);
        edges[r-1].emplace_back(l-1, -d);
    }

    memset(comp, -1, sizeof comp);
    
    for (int i = 0; i < n; i++)
        if (comp[i] == -1) {
            mini = 0;            
            dfs(i);
            cur++;

            for (auto v : vtx)
                x[v] -= mini;
            vtx.clear();
        }

    for (int i = 0; i < n; i++)
        if (x[i] > 1000000000)
            error = true;
    
    if (error)
        cout << "No" << endl;
    else
        cout << "Yes" << endl;
                
}


Measured memory_bytes: 12924
#include <stdio.h>

int main(void){
    int n,m,c,i,j,x,ans=0,b[20],aij;
    scanf("%d%d%d",&n,&m,&c);
    for(i=0;i<m;i++)scanf("%d",&b[i]);
    for(i=0;i<n;i++){
        x=c;
        for(j=0;j<m;j++){
            scanf("%d",&aij);
            x+=aij*b[j];
        }
        if(x>0)ans++;
    }
    printf("%d",ans);
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = LONG_LONG_MAX / 2;
const ll mod = 1000000000 + 7;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main() {
  int N, i;
  cin >> N >> i;
  cout << N - i + 1 << endl;
}


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

using namespace std;

int main() {
#ifdef wxh010910
  freopen("input.txt", "r", stdin);
#endif
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n, m;
  cin >> n >> m;
  vector<vector<int>> adj(n);
  for (int i = 0; i < n - 1; ++i) {
    int from, to;
    cin >> from >> to;
    --from;
    --to;
    adj[from].push_back(to);
    adj[to].push_back(from);
  }
  vector<vector<int>> parent(n, vector<int>(n, -1));
  for (int i = 0; i < n; ++i) {
    function<void(int)> dfs = [&](int x) {
      for (auto y : adj[x]) {
        if (y != parent[i][x]) {
          parent[i][y] = x;
          dfs(y);
        }
      }
    };
    dfs(i);
  }
  vector<vector<bool>> graph(n, vector<bool>(n));
  vector<vector<int>> top(n, vector<int>(n, -1));
  function<void(int, int)> add = [&](int from, int to) {
    if (top[from][to] == to || top[to][from] == from) {
      return;
    } else if (top[from][to] != -1) {
      add(top[from][to], to);
    } else if (top[to][from] != -1) {
      add(top[to][from], from);
    } else {
      vector<pair<int, int>> edges;
      for (int rep = 0; rep < 2; ++rep) {
        graph[from][to] = true;
        top[from][to] = to;
        queue<int> q;
        q.push(to);
        while (!q.empty()) {
          int x = q.front();
          q.pop();
          for (auto y : adj[x]) {
            if (y != parent[from][x]) {
              if (top[from][y] == -1) {
                top[from][y] = to;
                q.push(y);
              } else if (graph[from][y]) {
                graph[from][y] = graph[y][from] = false;
                edges.emplace_back(to, y);
              }
            }
          }
        }
        swap(from, to);
      }
      for (auto p : edges) {
        add(p.first, p.second);
      }
    }
  };
  for (int i = 0; i < m; ++i) {
    int from, to;
    cin >> from >> to;
    --from;
    --to;
    add(from, to);
  }
  int ans = 0;
  for (int i = 0; i < n; ++i) {
    function<void(int, int)> dfs = [&](int x, int t) {
      if (top[t][x] == x) {
        ++ans;
        t = x;
      }
      for (auto y : adj[x]) {
        if (y != parent[i][x]) {
          dfs(y, t);
        }
      }
    };
    for (auto j : adj[i]) {
      dfs(j, i);
    }
  }
  cout << ans / 2 << "\n";
  return 0;
}


Measured memory_bytes: 33024
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define rep(i, a, b) for(int i=(a); i<(b); i++)
#define per(i, a, b) for(int i=(b)-1; i>=(a); i--)
#define sz(a) (int)a.size()
#define de(a) cout << #a << " = " << a << endl
#define dd(a) cout << #a << " = " << a << " "
#define all(a) a.begin(), a.end()
#define pw(x) (1ll<<(x))
#define endl "\n"
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
char a[10]={'R','G','B'};
ll sum[1000000][4];
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	int n;
	cin >> n;
	string s;
	cin >> s;
	rep(i,0,n){
		if(s[i]=='R'){
			sum[i][0]=1;
		}
		else if(s[i]=='G'){
			sum[i][1]=1;
		}
		else if(s[i]=='B'){
			sum[i][2]=1;
		}
		if(i!=0){
			rep(j,0,3){
				sum[i][j]+=sum[i-1][j];
			}
		}
	}
/*rep(i,0,n){
		rep(j,0,3){
			cout<<sum[i][j]<<" ";
		}
		cout<<endl;
	}*/
	ll res=0;
	rep(i,0,n){
		rep(j,0,i){
			if(s[i]==s[j]) continue;
			int pos;
			rep(k,0,3){
				if(s[i]!=a[k]&&s[j]!=a[k]){
					pos=k;
					break;
				}
			}
			res+=sum[n-1][pos]-sum[i][pos];
			//cout<<i<<" "<<j<<" "<<pos<<" "<<sum[n-1][pos]<<" "<<sum[i][pos]<<" "<<res<<endl;
			if(2*i-j<n&&s[2*i-j]==a[pos]) res--;
		}
	}
	cout<<res<<endl;
	return 0;
}



Measured memory_bytes: 3744