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

#define int long long
#define INT int
#define MOD 1000000007

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()
#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second
template <typename T>
void print(T x)
{
    std::cout << x << '\n';
}
typedef long long ll;
const long long INF = 1LL << 60;

signed main()
{

    int x,k,d;
    cin>>x>>k>>d;
    int ans = 1e16;

    int cnt= abs(x)/d;
    int nokori = k-cnt;


    if(cnt>=k){
        if(x<=0){
            ans = x + (k*d);
        }else{
            ans = x-(k*d);
        }
    }else{
        if(x<=0){
            ans = x+(cnt*d);
            if(nokori%2==0){

            }else{
                ans = ans+d;
            }
        }else{
            ans = x-(cnt*d);
             if(nokori%2==0){

            }else{
                ans = ans-d;
            }
        }
    }
if(ans>=0){
    cout<<ans<<endl;
}else{
    ans = -1*ans;
    cout<<ans<<endl;
}

    return 0;
}


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

using namespace std;

typedef long long ll;

int main(int, char**)
{
	ll n, num = 0, aal = 0, mn = 1000000001, ans = 0;
	cin >> n;

	for (unsigned int i = 0; i < n; ++i) {
		ll x;
		cin >> x;
		if (x >= 0) {
			aal += x;
			mn = min(mn, x);
		} else {
			num++;
			aal -= x;
			mn = min(mn, -x);
		}
	}

	if (num % 2 > 0)
		cout << (aal - mn - mn) << endl;
	else
		cout << aal << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <functional>
#include <climits>
#include <string>
#include <cstring>
#include <cmath>
#include <cassert>

#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>

using namespace std;
// using namespace __gnu_pbds;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using ld = long double;
// using ht = gp_hash_table<int, int>;
// using ordered_set = tree<pii, null_type, less<>, rb_tree_tag, tree_order_statistics_node_update>;

#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int) (x).size()
#define all(x) x.begin(), x.end()
#define lc (i << 1)
#define rc (i << 1 | 1)
// #define m ((l + r) >> 1)

const int INF = 0x3f3f3f3f;
const ll INFLL = 0x3f3f3f3f3f3f3f3fLL;
const int MOD = 1e9 + 7;
const double EPS = 1e-6;
const int MN = 1001, LN = 17;

int main() {
    ios_base::sync_with_stdio(false), cin.tie(nullptr);
    ll N; cin >> N;
    ll temp = N - 1, tot = 1;
    if (temp > 1) {
        for (int i = 2; i <= sqrt(temp); i++) {
            if (temp % i == 0) {
                int cnt = 0;
                while (temp % i == 0) cnt++, temp /= i;
                tot *= (cnt + 1);
            }
        }
        if (temp > 1) tot *= 2;
    }
    for (int i = 2; i <= sqrt(N); i++) {
        if (N % i == 0) {
            ll j = N / i;
            while (j % i == 0) j /= i;
            if (j % i == 1) tot++;
        }
    }
    cout << tot << '\n';
    return 0;
}


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

using namespace std;

template<typename Weight>
struct Dinic {
    struct Edge {
        int src, dst, rev;
        Weight weight;
        Edge(int f, int t, Weight cap, int rev = 0) :
            src(f), dst(t), rev(rev), weight(cap) {}
    };

    int n;
    vector<vector<Edge>> adj;
    const Weight INF;

    Dinic(int _n, Weight inf = numeric_limits<Weight>::max() / 10)
        : n(_n), adj(n), INF(inf) {}

    void add_edge(const int src, const int dst, const Weight cap) {
        adj[src].emplace_back(Edge(src, dst, cap, adj[dst].size()));
        adj[dst].emplace_back(Edge(dst, src, 0, adj[src].size() - 1));
    }

    Weight MaximumFlow(const int s, const int t) {
        Weight flow = 0;
        while(true) {
            vector<int> level(n, -1);
            vector<size_t> iter(n);
            // fill(level.begin(), level.end(), -1);
            // fill(iter.begin(), iter.end(), 0);
            Bfs(s, level);
            if(level[t] == -1) break;
            for (Weight f = 0; (f = Dfs(s, t, INF, level, iter)) > 0; )
                flow += f;
        }
        return flow;
    }

    void Bfs(const int s, vector<int> &level){
        queue<int> que;
        for (level[s] = 0, que.push(s); !que.empty(); ) {
            const int v = que.front(); que.pop();
            for (const auto &e : adj[v])
                if(0 < e.weight && level[e.dst] == -1){
                    level[e.dst] = level[v] + 1;
                    que.push(e.dst);
                }
        }
    }

    Weight Dfs(int v, int t, Weight flow, vector<int> &level, vector<size_t> &iter) {
        if(v == t) return flow;
        for ( ; iter[v] < adj[v].size(); ++iter[v]) {
            Edge &e = adj[v][iter[v]];

            if(0 < e.weight && level[v] < level[e.dst]){
                Weight d = Dfs(e.dst, t, min(flow, e.weight), level, iter);
                if(0 < d){
                    e.weight -= d;
                    adj[e.dst][e.rev].weight += d;
                    return d;
                }
            }
        }
        return 0;
    }
};

int Solve() {
    int h, w;
    cin >> h >> w;

    vector<string> hasu(h);
    for (auto &&x : hasu) cin >> x;

    const int s = h + w, t = h + w + 1;
    Dinic<int> g(h + w + 2);

    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            if (hasu[i][j] == 'o') {
                g.add_edge(i, j + h, 1);
                g.add_edge(j + h, i, 1);
            }
            else if (hasu[i][j] == 'S') {
                g.add_edge(s, i, g.INF);
                g.add_edge(s, j + h, g.INF);
            }
            else if (hasu[i][j] == 'T') {
                g.add_edge(i, t, g.INF);
                g.add_edge(j + h, t, g.INF);
            }
        }
    }

    int res = g.MaximumFlow(s, t);
    return (res < g.INF ? res : -1);
}

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

    cout << Solve() << endl;

    return 0;
}


Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
const long long INF = (1LL << 32);
const long long MOD = 1000000007;
const long double PI = 3.1415926;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
typedef long long int ll;
typedef vector<ll> vi;
typedef vector<pair<ll, ll>> vp;
typedef vector<string> vs;
typedef vector<char> vc;
typedef list<ll> lst;
typedef pair<ll, ll> P;
template <class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <class T> T &chmax(T &a, const T &b) { return a = max(a, b); }

ll n, m, k, ans = 0, sum = 0, cnt = 0;
string s;
char c;

#define Endl endl

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


int main() {
    cin >> n >> m;
    if(n%500<=m){
        cout << "Yes" << endl;
        
    }else{
        cout << "No" << endl;
        
    }
}

Measured memory_bytes: 256
N = 50
A = [i for i in range(N)]
K = int(input())
a = K//N
k = K%N
A = [A[i]+a for i in range(N)]
for _ in range(k):
    amin = 10**17
    for i in range(N):
        if A[i]<amin:
            ind = i
            amin = A[i]
    for i in range(N):
        if i==ind:
            A[i] += N
        else:
            A[i] -= 1
print(N)
print(*A)

Measured memory_bytes: 63916
main(n,m,e,j,t){while(scanf("%d",&n),n)for(;n--;puts(m>99|e>99|j>99|m+e>179|t>239?"A":t>209|t>149&(m>79|e>79)?"B":"C"))scanf("%d%d%d",&m,&e,&j),t=m+e+j;}

Measured memory_bytes: 0
#include <iostream>
#include <cstdio>

using namespace std;

int main() {
    int h, n, ai, s;
    s = 0;
    cin >> h >> n;
    for (int i=0; i<n; i++){
        cin >> ai;
        s += ai;
    }
    if (s < h) {
        cout << "No";
    } else {
        cout << "Yes";
    }

    // puts(x<h?"No":"Yes")
}

Measured memory_bytes: 3656
import sys
input = sys.stdin.readline

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    s=input()
    ans=[]
    N=len(s)
    for i in range(0,N,2):
        ans.append(s[i])
    print(''.join(map(str, ans)))

main()


Measured memory_bytes: 44400
import java.util.Scanner;
class Main {
    public static void main (String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        for(int i=1; i<n+1; i++) {
        	String s = String.valueOf(i);
        	if (i%3 == 0) {
        		System.out.print(" " + i);
        	} else if(s.contains("3")) {
        		System.out.print(" " + i);
        	}
        }
        System.out.println();
    }
}


Measured memory_bytes: 29860
from math import ceil, log
n, k = map(int, input().split())
if n > k:
    ans = (n-k)/n
    l = k
else:
    ans = 0
    l = n

for i in range(1, l+1):
    ans +=  1 / (n * 2**ceil(log(k/i, 2)))
print(ans)

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

#define ll long long
#define mp make_pair
#define pb push_back

#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#define rep(i, n) for (int i = 0; i < (int)(n); ++ i)
#define forall(it, c) for (__typeof(c.begin()) it = c.begin(); it != c.end(); ++ it)

template <typename T> inline void read(T &x) {
	x = 0; bool f = 1; char c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') f = 0;
	for (;  isdigit(c); c = getchar()) x = x * 10 + (c & 15);
	if (!f) x = -x;
}

int main() {
	int n; read(n);
	map <int, string> ms;
	ms[2] = ms[4] = ms[5] = ms[7] = ms[9] = "hon";
	ms[0] = ms[1] = ms[6] = ms[8] = "pon";
	ms[3] = "bon";
	printf("%s\n", ms[n % 10].c_str());
	return 0;
}


Measured memory_bytes: 3624
#include<iostream>
#include<vector>
#include<algorithm>
#define f first
#define s second
#define INF (1<<29)
using namespace std;

typedef pair<int,int> P;

int h,w,s,u[34][34];
P memo[34][34][34][34];

P rec(int x1,int y1,int x2,int y2){
	
	P a,b,res;
	
	if(memo[x1][y1][x2][y2]!=P(0,INF))return memo[x1][y1][x2][y2];
	
	if(u[h-1][w-1]-(u[y2-1][x2-1]-u[y2-1][x1-1]-u[y1-1][x2-1]+u[y1-1][x1-1])>s)return P(0,INF);
	
	res=P(1,s-(u[h-1][w-1]-(u[y2-1][x2-1]-u[y2-1][x1-1]-u[y1-1][x2-1]+u[y1-1][x1-1])));
	
	for(int i=y1+1;i<y2;i++){
		a=rec(x1,y1,x2,i);
		b=rec(x1,i,x2,y2);
		res=max(res,P(a.f+b.f,min(a.s,b.s)));
	}
	
	for(int i=x1+1;i<x2;i++){
		a=rec(x1,y1,i,y2);
		b=rec(i,y1,x2,y2);
		res=max(res,P(a.f+b.f,min(a.s,b.s)));
	}
	
	return memo[x1][y1][x2][y2]=res;
}

int main(void){
	
	while(cin >> h >> w >> s,h|w|s){
		
		h++,w++;
		fill(u[0],u[33],0);
		
		for(int i=0;i<34;i++)
			for(int j=0;j<34;j++)
				for(int k=0;k<34;k++)
					for(int l=0;l<34;l++)memo[i][j][k][l]=P(0,INF);
		
		for(int i=1;i<h;i++)
			for(int j=1;j<w;j++)cin >> u[i][j];
		
		for(int i=1;i<h;i++)
			for(int j=1;j<w;j++)
				u[i][j]+=u[i-1][j]+u[i][j-1]-u[i-1][j-1];
		
		P ans=rec(1,1,w,h);
		cout << ans.f << " " << ans.s << endl;
	}
	return 0;
}

Measured memory_bytes: 11616
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define ALL(c) (c).begin(), (c).end()

class Compare {
 public:
  bool operator()(const tuple<int, int, int, ll>& lhs,
                  const tuple<int, int, int, ll>& rhs) {
    return get<3>(lhs) < get<3>(rhs);
  }
};
string encodeIdx(int u, int v, int w) {
  string tmp = to_string(u) + ":" + to_string(v) + ":" + to_string(w);
  return tmp;
}

int main() {
  int x, y, z, k;
  cin >> x >> y >> z >> k;
  vl a(x), b(y), c(z);
  rep(i, x) cin >> a[i];
  rep(i, y) cin >> b[i];
  rep(i, z) cin >> c[i];
  sort(ALL(a), greater<ll>());
  sort(ALL(b), greater<ll>());
  sort(ALL(c), greater<ll>());

  priority_queue<tuple<int, int, int, ll>, vector<tuple<int, int, int, ll>>,
                 Compare>
      que;
  unordered_set<string> s;
  que.push({0, 0, 0, a[0] + b[0] + c[0]});
  s.insert(encodeIdx(0, 0, 0));
  while (k > 0) {
    tuple<int, int, int, ll> p = que.top();
    int u = get<0>(p);
    int v = get<1>(p);
    int w = get<2>(p);
    ll total = get<3>(p);
    que.pop();
    cout << total << endl;
    k--;

    if (u + 1 < x && s.find(encodeIdx(u + 1, v, w)) == s.end()) {
      que.push({u + 1, v, w, a[u + 1] + b[v] + c[w]});
      s.insert(encodeIdx(u + 1, v, w));
    }
    if (v + 1 < y && s.find(encodeIdx(u, v + 1, w)) == s.end()) {
      que.push({u, v + 1, w, a[u] + b[v + 1] + c[w]});
      s.insert(encodeIdx(u, v + 1, w));
    }
    if (w + 1 < z && s.find(encodeIdx(u, v, w + 1)) == s.end()) {
      que.push({u, v, w + 1, a[u] + b[v] + c[w + 1]});
      s.insert(encodeIdx(u, v, w + 1));
    }
  }
  return 0;
}


Measured memory_bytes: 896
process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', function(chunk) {
    main(chunk.trim());
});

function main(chunk){
    var lines = chunk.split("\n");
    for(var i in lines){
        console.log(Number(lines[i].split(" ")[0]) + Number(lines[i].split(" ")[1]));
    }
}

Measured memory_bytes: 16996
import math
X = int(input())
def isprime(n):
    max_n = math.floor(math.sqrt(n))
    for i in range(2, max_n+1):
        if n % i != 0:
            continue
        else:
            return False
    else:
        return True
while(not(isprime(X))):
    X = X+1
print(X)

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <unordered_set>
#include <unordered_map>

using namespace std;
const int MAXN = 100;
int a[MAXN];
bool dp[100001];

int main()
{
    int N, K;
    cin >> N >> K;
    for(int i = 0; i < N; i++) cin >> a[i];
    dp[0] = false;
    for(int i = 1; i <= K; i++)
    {
        dp[i] = false;
        for(int j = 0; j < N; j++) if(i-a[j]>=0&&dp[i-a[j]]==false) dp[i] = true;
    }
    if(dp[K]) cout << "First";
    else cout << "Second";
}

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

int main(){
	int A, B, M;
	cin >> A >> B >> M;
	vector<int> a(A), b(B);
	for(int i=0;i<A;i++) cin >> a[i];
	for(int i=0;i<B;i++) cin >> b[i];
	vector<int> val;
	for(int i=0;i<M;i++) {
		int x, y, c;
		cin >> x >> y >> c;
		x--, y--;
		val.push_back(a[x] + b[y] - c);
	}
	sort(a.begin(),a.end());
	sort(b.begin(),b.end());
	val.push_back(a[0] + b[0]);
	sort(val.begin(),val.end());
	cout << val[0] << endl;
}

Measured memory_bytes: 1660
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    
    // 標準入力から整数を取得
    // N,K,X,Y
 
    int n = scanner.nextInt();
    int k = scanner.nextInt();
    int x = scanner.nextInt();
    int y = scanner.nextInt();
    
    //NがK以下の場合、宿泊数 * X
    if(n <= k) {
      System.out.println(n * x);
	
    // NがKより大きい場合、K * X + (N - K) * Y　を出力 
    } else {
      int z = n - k;
      System.out.println(k * x + z * y);
    }
  }
}

Measured memory_bytes: 35188
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define endl "\n"
using namespace std;
const int INF = 1e9+5;
int main()
{
    int n, k;
    cin >> n >> k;
    vector<int> h(n);
    REP(i,n) cin>>h[i];
    vector<int> dp(n,INF);
    dp[0]=0;
    REP(i,n){
        for(int j=i+1;j<=i+k;j++){
            if(j<n){
                dp[j] = min(dp[j],dp[i]+abs(h[i]-h[j]));
            }
        }
    }cout<<dp[n-1]<<endl;
    return 0;
}


Measured memory_bytes: 4036
#define _GLIBCXX_DEBUG
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>

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

int main(int argc, char* argv[])
{
  int H, W;
  std::cin >> H >> W;
  std::vector< std::string > vs(H, "");

  for (int h = 0; h < H; h++) {
    std::string s;
    std::cin >> s;
    vs[h] = s;
  }

  for (int h = 0; h < H; h++) {
    for (int w = 0; w < W; w++) {
      int cnt = 0;
      for(int axis = 0; axis < 8; axis++) {
	if (vs[h][w] == '#') {
	  cnt = -1;
	  break;
	} else {
	  int x = h+dx[axis];
	  int y = w+dy[axis];
	  if (x >= 0 &&
	      y >= 0 &&
	      x <  H &&
	      y <  W &&
	      vs[x][y] == '#') {
	    cnt++;
	  }
	}
      }
      if (cnt < 0) {
	std::cout << '#';
      } else {
	std::cout << cnt;
      }
    }
    std::cout << std::endl;
  }

  return 0;
}


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

int main() {
	int N, K;
	cin >> N >> K;
	int R, S, P;
	cin >> R >> S >> P;
	string T;
	cin >> T;

	int ans = 0;
	rep(i, K) {
		int pos = i;
		char memory = 'a';
		while (pos < N) {
			if (memory != T[pos]) {
				if (T[pos] == 'r') {
					ans += P;
				}
				else if (T[pos] == 's') {
					ans += R;
				}
				else if (T[pos] == 'p') {
					ans += S;
				}
				memory = T[pos];
			}
			else {
				memory = 'a';
			}
          	pos += K;
		}
	}

	cout << ans << endl;
}

Measured memory_bytes: 512
#include<iostream>
#include<cstdio>
#include<stack>
#include<queue>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<vector>
#include<math.h>
#include<tuple>
#include<string.h>
#include <numeric> 
#include<unordered_map>
using namespace std; 
#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 << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define pp(...) "\033[94m [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "]\033[0m"
#define pp1(...) "\033[1;47;35m" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "]\033[0m"
#define dg(x) debug() << pp1(x)
#define dg1(x) debug() << "[line : " << __LINE__ <<"]"<< pp(x)
#define dg2(x,y) debug() << "[line : " << __LINE__ <<"]"<< pp(x) pp(y)
#define dg3(x,y,z) debug() << "[line : " << __LINE__ <<"]"<< pp(x) pp(y) pp(z)
#define dg4(w,x,y,z) debug() << "[line : " << __LINE__ <<"]"<< pp(w) pp(x) pp(y) pp(z)
#define int long long
#define all(x) x.begin() , x.end()
#define clr(x , y) memset(x , y , sizeof x);
#define sz(x) (int)x.size()
template<typename T> void db(T x ){ debug() <<">>> " <<  x; }
template<typename T> void db(T x , T y){ debug() <<">>> " <<  x <<" , "<< y; }
template<typename T> void db(T x , T y , T z){ debug() <<">>> "<< x <<" , "<< y <<" , "<< z; }
template<typename T> void db(T x , T y , T z , T a){ debug() <<">>> "<< x <<" , " << y <<" , "<< z <<" , "<< a; }
const int xx = 2e5;
const int Mod = 1e9 + 7;
const int inf = 1e18;
const int Maxn = 20010;

int mat[3003][3003];
int dp[3003][3003][4];
int N , M , K;

int cal(int i ,int j , int r) {
  if(i >= N) return 0;
  if(j >= M) return 0;
  if(dp[i][j][r] != -1) return dp[i][j][r];
  int ans = 0;
  ans = max({ans , cal(i , j + 1, r), cal(i+1 , j , 0)});
  if(r < 3) {
    ans = max(ans , cal(i , j + 1, r + 1) + mat[i][j]);
    ans = max(ans , cal(i + 1, j , 0) + mat[i][j]);
  }
  return dp[i][j][r] = ans;
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> N >> M >> K;
  for(int i = 0; i < K; i++) {
    int r , c, v;
    cin >> r >> c >> v;
    r--,c--;
    mat[r][c] = v;
  }   
  clr(dp , -1);
  int ans = cal(0, 0, 0);
  cout << ans << '\n';
}

Measured memory_bytes: 356208
#include<string>
#include<algorithm>
#include<functional>
#include<vector>
#include<cmath>
#include<iomanip>
#include<iostream>
using namespace std;

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	int ans;
	ans = a / (b + c);
	if ((ans*(b+c)+ c) > a)
		cout << ans-1 << endl;
	else
		cout << ans  << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		Integer input = new Integer(scanner.next());
		Integer count = 0;
		Integer data = 2;

		while(input >= data) {
			data = data*2;
			count ++ ;
		}


		System.out.println(data/2);

		scanner.close();
	}

}

Measured memory_bytes: 22612
#include <bits/stdc++.h>
#define N 10

using namespace std;
typedef long long ll;

template <class T> inline void read(T &x) {
	char ch; bool flag = false;
	while (!isdigit(ch = getchar())) flag |= ch == '-';
	for (x = ch ^ 48; isdigit(ch = getchar()); x = x * 10 + (ch ^ 48));
	if (flag) x = -x;
}

inline int input() {
	int x; char ch; bool flag = false;
	while (!isdigit(ch = getchar())) flag |= ch == '-';
	for (x = ch ^ 48; isdigit(ch = getchar()); x = x * 10 + (ch ^ 48));
	return flag ? -x : x;
}

const int mod = 1e9 + 7;
inline int add(int x, int y) { x += y; return x >= mod ? x - mod : x; }
inline void inc(int &x, int y) { x += y; x -= x >= mod ? mod : 0; }

inline int Power(int x, int y) {
	int res = 1;
	while (y) {
		if (y & 1) res = (ll) res * x % mod;
		x = (ll) x * x % mod, y >>= 1;
	} return res;
}

template <class T> void chkmax(T &x, T y) { x = x > y ? x : y; }
template <class T> void chkmin(T &x, T y) { x = x < y ? x : y; }
template <class T> T gcd(T x, T y) { return !y ? x : gcd(x % y, y); }

int n, c;
int len[N];
ll f[50][500];
int p[N];

ll calc() {
	memset(f, 0, sizeof f);
	f[0][len[n] * n] = 1;
	for (int i = 0; i < n * c; ++i) {
		if (!(i % n)) continue;
		int x = p[i % n];
		for (int S = 0; S < (1 << (n - 1)); ++S) {
			if (S & (1 << x - 1)) continue;
			for (int j = i; j <= n * c; ++j)
				f[S | (1 << x - 1)][min(n * c, max(j, i + n * len[x]))] += f[S][j];
		}
	}
	return f[(1 << (n - 1)) - 1][n * c];
}

int main() {
	cin >> n >> c;
	for (int i = 1; i <= n; ++i) cin >> len[i];
	sort(len + 1, len + n + 1);
	for (int i = 1; i < n; ++i) p[i] = i;
	long double ans = 0;
	do { ans += calc(); } while (next_permutation(p + 1, p + n));
	for (int i = 1; i < n; ++i) ans /= 1.0L * i * c;
	printf("%.12Lf\n", ans);
	return 0;
}

Measured memory_bytes: 512
fun main(args: Array<String>) {
    val N = nextInt()
    val X = Math.ceil(N.toDouble() / 1.08).toInt()
    val Y = Math.floor(X.toDouble() * 1.08).toInt()
    println(if (N == Y) X else ":(")
}
fun next() = readLine()!!
fun nextInt(delta: Int = 0) = Integer.parseInt(next()) + delta

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

using namespace std;

int main(){
  int arr[26]={};
  string s;
  cin >> s;
  for (auto &c:s) {
    arr[c-'a']++;
    if (arr[c-'a']==2) {
      printf("no\n");
      return 0;
    }
  }
  printf("yes\n");
  return 0;
}

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

using namespace std;

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

	int X;
	cin >> X;

	for (int i = 1; i <= 360; i++)
	{
		if ((i * X) >= 360 && (i * X) % 360 == 0)
		{
			cout << i;
			return 0;
		}
	}

	return 0;
}


Measured memory_bytes: 3620
/*
	Solved!
	Time: 05:23:26 PM
	Date: 05-04-2020
*/
#include <bits/stdc++.h>
using namespace std;
 
typedef unsigned long long  ll;
typedef vector<int>         vi;
typedef vector<ll>          vll;

#define ff                  first
#define sf                  scanf
#define pf                  printf
#define ss                  second
#define ppb                 pop_back
#define pb                  push_back
#define MP                  make_pair
#define MAXN                5000005
#define MOD                 100000007
#define inf                 0x3f3f3f3f
#define PI                  (2.0*acos(0.0))
#define INF                 0x3f3f3f3f3f3f3f3f
#define rev(v)              reverse(all(v))
#define all(v)              v.begin(), v.end()
#define __lcm(x, y)         (x * y) / __gcd(x, y)
#define FOR(i, x, y)        for(int i = x; i < y; i++)
#define RFOR(i, x, y)       for(int i = x; i >= y; i--)
#define MEM(arr, val)       memset(arr, val, sizeof(arr));
#define unq(v)              (v).resize(unique(all(v)) - v.begin())
#define READ()              freopen("input.txt", "r", stdin)
#define WRITE()             freopen("output.txt", "w", stdout)
#define si(n)               scanf("%d", &n)
#define sl(n)               scanf("%lld", &n)
#define sii(a, b)           scanf("%d %d", &a, &b)
#define sll(a, b)           scanf("%lld %lld", &a, &b)
#define siii(a, b, c)       scanf("%d %d %d", &a, &b, &c)
#define slll(a, b, c)       scanf("%lld %lld %lld", &a, &b, &c)
#define siiii(a, b, c, d)   scanf("%d %d %d %d", &a, &b, &c, &d)
#define sllll(a, b, c, d)   scanf("%lld %lld %lld %lld", &a, &b, &c, &d)
#define vout(v)             for(int i = 0; i < v.size(); i++) {cout << v[i]; if(i < v.size() - 1) cout << ' '; else cout << endl;}

int main(){
    /*#ifndef ONLINE_JUDGE
        double start = clock(); READ(); WRITE();
    #endif*/
        string s; cin >> s;
        string tmp = s;
        rev(tmp);
        int ans = 0;
        if(s == tmp){
        	tmp = "";
        	int len = s.size();
        	int st = ((len - 1) / 2);
        	FOR(i, 0, st) tmp += s[i];
        	string t = tmp;
        	rev(t);
        	if(t == tmp){
        		tmp = "";
        		st = ((len + 3) / 2) - 1;
	        	FOR(i, st, len) tmp += s[i];
	        	t = tmp;
	        	rev(t);
	        	if(t == tmp) ans = 1;
        	}
        }
        puts(ans ? "Yes" : "No");


   /* #ifndef ONLINE_JUDGE
        printf("\n>>Runtime: %.10fs\n", (double)(clock() - start) / CLOCKS_PER_SEC);
    #endif*/

    return 0;
}

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

using namespace std;

const  int N = 1e5 + 10;

int n, a[N], b[N], c[N];

int main() {
  cin >> n;
  int ans = 0;
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int i = 1; i <= n; i++) cin >> b[i];
  for (int i = 2; i <= n; i++) cin >> c[i];
  for (int i = 1; i <= n; i++) {
    ans += b[a[i]];
    if (i > 1 && a[i] == a[i - 1] + 1) ans += c[a[i]];
  }
  cout << ans << endl;
  return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=(n)-1;i>=0;i--)
#define VSORT(v) sort(v.begin(), v.end())
#define DVSORT(v) sort(v.begin(), v.end(),greater<int>())
#define SORT(v, n) sort(v, v+n)
#define DSORT(v,n) sort(v, v+n,greater<int>())
#define vi vector<int>
#define pb push_back
#define P pair<int,int>


template <class T> void chmin(T&a, const T&b) { a = min(a,b); }
template <class T> void chmax(T&a, const T&b) { a = max(a,b); }

const double EPS =1e-9;
const long INF =999999999;
const long MOD =1000000007; //10^9+7
#define PI 3.14159265258979

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


int main(){
	int X,A,B;
	cin>>X>>A>>B;
	if(A>=B) puts("delicious");
	else{
		if(X>=(B-A)) puts("safe");
		else puts("dangerous");
	}
	return 0;
}



Measured memory_bytes: 256
import copy
n = int(input())
t = list(map(int,input().split()))
m = int(input())
p = [list(map(int,input().split())) for i in range(m)]

for i in range(m):
    ans = copy.copy(t)
    ans[(p[i][0])-1] =  p[i][1]
    print(sum(ans))


Measured memory_bytes: 3444
#include <bits/stdc++.h>
#define int long long
#define len(x) x.size()
#define rep(i,a) for(int i=0;i<a;i++)
#define f(i,a,b) for(int i=a;i<=b;i++)
using namespace std;

signed main(){
  
	string a,b,s;
	cin >> a >> b;
	int x,y;
	scanf("%lld %lld", &x, &y);
	cin >> s;
	if(s==a) x--;
	else y--;
	printf("%lld %lld",x,y);
	return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
 
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？

n = ii()
arr=llint(n)
arr.sort(key=lambda x: x[1])
cnt=0
chk=True
for i,j in arr:
    if cnt + i <=j:
        cnt +=i
    else:
        chk=False
if chk:
    print("Yes")
else:
    print("No")




Measured memory_bytes: 108760
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 
#define PI acos(-1)
#define pcnt __builtin_popcountll
#define rng(a) a.begin(), a.end()
#define sz(x) (int)(x).size()
#define v(T) vector<T>
#define vv(T) v(v(T))
#define fi first
#define se second

using namespace std;
using ll = long long;
using P = pair<int, int>;
using LP = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;

template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
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; }

ll INF = 1001001001;
ll LINF = 1001001001001001001ll;

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

    int m1, d1, m2, d2;
    cin>>m1>>d1>>m2>>d2;
    if (d2 == 1) cout<<1<<endl;
    else cout<<0<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for(int i = 1, i##_len = (n); i < i##_len; ++i)
#define ALL(x) (x).begin(), (x).end()
#define PRINT(A) std::cout << (#A) << ":" << (A) << std::endl;

typedef long long int ll;
const int MOD = 1e9 + 7;
const int INF = 1e9;

using namespace std;

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

  int N = 100001;
  int p[N];

  for(int i = 0; i < N; i++) {
    if(i == 0 || i == 1) {
      p[i] = 0;
    } else {
      p[i] = 1;
    }
  }

  for(int i = 2; i < sqrt(N); i++) {
    if(p[i]) {
      for(int j = 0; i * (j + 2) < N; j++) {
        p[i * (j + 2)] = 0;
      }
    }
  }

  auto like = vector<bool>(N, false);
  for(int i = 1; i < N; i++) {
    if(p[i] && p[(i + 1) / 2]) {
      like[i] = true;
    }
  }

  auto like_cnt = vector<int>(N, 0);
  for(int i = 1; i < N; i++) {
    if(like[i]) {
      like_cnt[i] = like_cnt[i - 1] + 1;
    } else {
      like_cnt[i] = like_cnt[i - 1];
    }
  }

  REP(i, Q) {
    int l, r;
    cin >> l >> r;
    cout << like_cnt[r] - like_cnt[l - 1] << endl;
  }
}


Measured memory_bytes: 1920
#include <iostream>
#include<string>
#include<time.h>
#include<math.h>
#include<stdlib.h>
#include<map>
using namespace std;

int main(){
	int N, M,s[10],c[10],ans,x,buff;
	int i,j;
	ans = 1;
	x = 0;
	cin >> N >> M;
	for (i = 0; i < M; ++i) {
		cin >> s[i] >> c[i];
	}
	if (N==1) {
		ans = 0;
		for (i = 0; i < M - 1; ++i) {
			for (j = i + 1; j < M; ++j) {
				if ((s[i] == s[j]) && (c[i] != c[j])) {
					x = 1;
				}
			}
		}
		for (i = 0; i < M ; ++i) {
			if (ans < c[i]) {
				ans = c[i];
			}
		}
	}
	else {
		for (i = 0; i < M-1; ++i) {
			for (j = i+1; j < M; ++j) {
				if ((s[i] == s[j]) && (c[i] != c[j])) {
					x = 1;
				}
			}
		}
		for (i = 0; i < M; ++i) {
			if ((s[i] == 1) && (c[i] == 0)) {
				x = 1;
			}
		}
		for (i = 0; i < N-1; ++i) {
			ans = 10 * ans;
		}

		for (i = 1; i <= N; ++i) {
			buff = 0;
			for (j = 0; j < M; ++j) {
				if (s[j] == i) {
					if (buff<c[j]){
						buff = c[j];
					}
				}
			}
			if (i == 1) {
				for (j = 0; j < buff - 1; ++j) {
					ans = ans+pow(10, N-1);
				}
			}
			else {
				for (j = 0; j < buff ; ++j) {
					ans = ans + pow(10, N - i);
				}
			}

		}
		
		
	
	}

	if (x == 1) {
		cout << x-2 << endl;
	}
	else {
		cout << ans << endl;
	}
	return 0;
}

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

int main() {
    int N,K;
    int a[55];
    cin >> N >> K;
    for (int i = 0; i < N; ++i) cin >> a[i];

    sort(a, a + N, greater<int>());
    int total = 0;
    for (int i = 0; i < K; ++i) {
        total += a[i];
    }
    cout << total << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
    string s; cin >> s;
    int a = 10e6, b = 0;
    for (int i = 0; i < s.length(); i++) {
        if (s[i] == 'C') a = min(a, i);
        if (s[i] == 'F') b = max(b, i);
    }
    if (a < b) printf("%s\n", "Yes");
    else printf("%s\n", "No");
}

Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int N; cin >> N;
    int M; cin >> M;
    vector<int> A(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }
    sort(A.begin(), A.end());
    
    vector<int> B(M);
    vector<int> C(M);
    for (int i = 0; i < M; i++) {
        cin >> B[i] >> C[i];
    }
    
    vector<pair<int, int>> Q(M);
    for (int i = 0; i < M; i++) {
        Q[i] = {C[i], B[i]};
    }
    sort(Q.begin(), Q.end(), greater<pair<int, int>>());
    
    long long ans = 0;
    int erased = 0;

    for (int i = 0; i < M; i++) {
        int right = (int)(upper_bound(A.begin(), A.end(), Q[i].first) - A.begin());
        int cnt = 0;
        for (int j = erased; j < right && j < erased + Q[i].second; j++) {
            ans += Q[i].first;
            cnt++;
        }
        erased += cnt;
    }
    for (int i = erased; i < A.size(); i++) {
        ans += A[i];
    }
    cout << ans << endl;
}


Measured memory_bytes: 2176
#include<stdio.h>
int main(void){
int all,a,b,i;
for(;;){
b=0;
scanf("%d",&all);
if(all==0)break;
for(i=0;i<9;i++){
    scanf("%d",&a);
    b=b+a;
}
printf("%d\n",all-b);
}
return 0;
}

Measured memory_bytes: 1028
#include <iostream>
#include <cstdio>
#define n 10
#define INF 1000000007
using namespace std;

int N;
int F[100][n+2];
int P[101][n+1];
int fu[n];
int x=(-INF);

void dfs(int pos) {
  if (pos==n) {
    int now=0;
    int c=0;
    for (int i=0; i<10; i++) {
      c+=fu[i];
    }
    if (c==0) {
      return;
    }
    for (int i=0; i<N; i++) {
      int cnt=0;
      for (int j=0; j<10; j++) {
        if (F[i][j]==1 && fu[j]==1) {
          cnt++;
        }
      }
      now+=P[i][cnt];
    }
    x=max(x,now);
  }else{
    fu[pos]=1;
    dfs(pos+1);
    fu[pos]=0;
    dfs(pos+1);
  }
}
int main() {
  scanf("%d",&N);
  for (int i=0; i<N; i++) {
    for (int j=0; j<5; j++) {
      scanf("%d %d",&F[i][j*2],&F[i][j*2+1]);
    }
  }
  for (int i=0; i<N; i++) {
    for (int j=0; j<=10; j++) {
      scanf("%d",&P[i][j]);
    }
  }
  dfs(0);
  printf("%d\n",x);
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll mod = 1e9+7;

int main(){
	ll n,k;
	cin>>n>>k;
	int cnt = 0;

	while(n){
		cnt++;
		n/=k;
	}

	cout<<cnt<<"\n";
	return 0;
}

Measured memory_bytes: 256
fun isNewBiggerThanOld(new: String, old: String) : Boolean {
    if (new.length != old.length) {
        return new.length > old.length
    }
    var i = 0
    while (i < new.length) {
        if (new[i] > old[i]) {
            return true
        } else if (new[i] < old[i]) {
            return false
        }
        i++
    }
    // Other
    return false
}

fun generateNext(str: String, number: Char) : String {
    val buffer = StringBuffer()
    var used = false
    var i = 0
    while (i < str.length) {
        val c = str[i]
        if (used) {
            buffer.append(str.substring(i))
            break
        }

        if (!used && number > c) {
            buffer.append(number)
            buffer.append(c)
            used = true
        } else {
            buffer.append(c)
        }
        i++
    }

    if (!used) {
        buffer.append(number)
    }

    return buffer.toString()
}
fun main(args : Array<String>) {
    val (N, M) = readLine()!!.split(" ").map { it.toInt() }
    val A = readLine()!!.split(" ").map { it.toCharArray()[0] }
    val numToCost = listOf(-1, 2, 5, 5, 4, 5, 6, 3, 7, 6)
    val default = ""
    val dp = Array(N + 1, { default })

    (1..N).forEach { i ->
        var max = dp[i]
        A.forEach {
            val num = it
            val cost = numToCost[num - '0']
            if (i - cost >= 0) {
                var new = ""
                if (dp[i - cost] == default) {
                    if (i - cost == 0) {
                        new = num.toString()
                    }
                } else {
                    new = dp[i-cost] + num
                }
                if (isNewBiggerThanOld(new, max)) {
                    max = new
                }
            }
        }
        dp[i] = max
    }
    println(dp[N])
}

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

using namespace std;
using ll = long long;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int n, m;
  cin >> n >> m;
  cout << (n * (n - 1)) / 2 + (m * (m - 1)) / 2 << '\n';
  return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class Main {

    public static void main(String[] args) throws Exception {
        String[] inputs = Io.read();
        String[] meta = inputs[0].split(" ");

        int N = Integer.parseInt(meta[0]);
        int M = Integer.parseInt(meta[1]);
        int C = Integer.parseInt(meta[2]);

        int[][] sources = parse(inputs, N, M);

        int count = 0;

        for (int i = 1; i < sources.length; i++) {
            count += isCorrect(sources[0], sources[i], C) ? 1 : 0;
        }

        Io.write(count);
    }

    private static int[][] parse(String[] lines, int N, int M) {
        int[][] result = new int[N + 1][M];
        for (int i = 0; i < N + 1; i++) {
            String[] split = lines[i + 1].split(" ");
            for (int x = 0; x < M; x++) {
                result[i][x] = Integer.parseInt(split[x]);
            }
        }
        return result;
    }

    private static boolean isCorrect(int[] Bs, int[] As, int C) {
        int sum = C;
        for (int i = 0; i < Bs.length; i++) {
            sum += Bs[i] * As[i];
        }
        return sum > 0;
    }
}


class Io {

    /**
     * 標準入力から1行ずつ受け取る
     * @return
     * @throws IOException
     */
    public static String[] read() throws IOException
    {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        List<String> inputs = new ArrayList<>();
        String line;
        while ((line = br.readLine()) != null) {
            if (line.equals(""))
                break;

            inputs.add(line);
        }
        br.close();
        return inputs.toArray(new String[0]);
    }

    /**
     * 標準出力
     * @param answer
     */
    public static void write(int answer)
    {
        System.out.println(answer);
    }
}


Measured memory_bytes: 23252
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC155
{
    class Program
    {
        static void Main(string[] args)
        {
            b();
        }

        public static void b()
        {
            int n = int.Parse(Console.ReadLine());
            int[] a = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            bool flg = true;
            for(int i = 0; i < n; i++)
            {
                if(a[i] % 2 == 0 && (a[i] % 3 != 0 && a[i] % 5 != 0))
                {
                    flg = false;
                }
            }
            if (flg)
                Console.WriteLine("APPROVED");
            else
                Console.WriteLine("DENIED");
        }
    }
}


Measured memory_bytes: 13268
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <algorithm>
#define rep(i, a, b) for (int i = (a), _ = (b); i <= _; ++ i)
#define per(i, a, b) for (int i = (a), _ = (b); i >= _; -- i)
#define For(i, a, b) for (int i = (a), _ = (b); i < _; ++ i)
#define ri rd<int>
#define rl rd<LL>
typedef long long LL;
using namespace std;
const int maxN = 1e3 + 7;
const int mod = 1e9 + 7;

inline int pls(int x, int y) {return (x + y) % mod;}
inline int mns(int x, int y) {return pls(x, mod - y);}
inline int mul(int x, int y) {return 1LL * x * y % mod;}
inline void Add(int &x, int y) {x = pls(x, y);}
inline void Mul(int &x, int y) {x = mul(x, y);}
inline void Minus(int &x, int y) {x = mns(x, y);}
inline int pwr(int x, LL tms) {int res = 1; for (; tms > 0; tms >>= 1, Mul(x, x)) if (tms & 1) Mul(res, x); return res;}

template<class T> inline T rd() {
	bool f = 1; char c = getchar(); for (; !isdigit(c); c = getchar()) if (c == '-') f = 0;
	T x = 0; for (; isdigit(c); c = getchar()) x = x * 10 + c - 48; return f ? x : -x;
}

int n, m; LL T;
int A, B, C;
char s[maxN][maxN], t[maxN][maxN];

struct Mat {
	int a[2][2];

	inline void clear(int d = 0) {
		memset(a, 0, sizeof a);
		if (d) rep (i, 0, 1) a[i][i] = d;
	}

	inline Mat operator * (const Mat &v) {
		Mat res; res.clear();
		rep (i, 0, 1) rep (k, 0, 1) rep (j, 0, 1) Add(res.a[i][j], mul(a[i][k], v.a[k][j]));
		return res;
	}

	friend Mat pwr(Mat x, LL tms) {
		Mat res; res.clear(1);
		for (; tms > 0; tms >>= 1, x = x * x)
			if (tms & 1) res = res * x;
		return res;
	}

	inline int* operator [] (int x) {return a[x];}

}a, trans;

int main() {

	n = ri(), m = ri(), T = rl();
	if (T == 0 || T == 1) {puts("1"); return 0;}
	rep (i, 1, n) scanf("%s", s[i]+1);

	rep (i, 1, n) rep (j, 1, m) if (s[i][j] == '#') ++ B;

	bool h = 0, w = 0;
	rep (i, 1, m) h |= (s[1][i] == '#' && s[n][i] == '#');
	rep (i, 1, n) w |= (s[i][1] == '#' && s[i][m] == '#');

	if (h && w) puts("1");
	else if (!h && !w) printf("%d\n", pwr(B, T-1)); 
	else {
		if (h) {
			rep (i, 1, n) rep (j, 1, m) t[i][j] = s[i][j];
			rep (i, 1, n) rep (j, 1, m) s[j][i] = t[i][j];
			swap(n, m);
		}
		rep (i, 1, n) For (j, 1, m) if (s[i][j] == '#' && s[i][j+1] == '#') ++ A;
		rep (i, 1, n) if (s[i][1] == '#' && s[i][m] == '#') ++ C;

		a.clear(), trans.clear();
		a[0][0] = a[1][0] = 1;
		trans[0][0] = B, trans[0][1] = mns(0, A);
		trans[1][0] = 0, trans[1][1] = C;
		a = pwr(trans, T-1) * a;
		printf("%d\n", a[0][0]);
	}

	return 0;
}

Measured memory_bytes: 2176
#include<algorithm>
#include<climits>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<utility>
#include<vector>

#define lint long long
#define VI vector<int>
#define VL vector<lint>
#define VC vector<char>
#define VVI vector<vector<int>>
#define rep(i, n) for(int i = 0 ; i < n ; i++)
#define SORT(c) sort((c).begin(), (c).end())
#define SORT_INV(c) sort((c.begin(), c.end(), greater<int>())
#define IINF INT_MAX
#define LLINF LLONG_MAX

using namespace std;

int main(){
    int n;
    cin >> n;
    VI a(n);
    rep(i, n){
        cin >> a[i];
    }
    int cnt = 0, j = 0;
    bool flag = true;
    while(flag){
        flag = false;
        for(int i = n - 1 ; i > j ; i--){
            if(a[i] < a[i-1]){
                swap(a[i], a[i-1]);
                cnt++;
                flag = true;
            }
        }
        j++;
    }
    rep(i, n){
        cout << a[i];
        if(i == n - 1){
            cout << endl;
        }else{
            cout << " ";
        }
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 3064
use std::io::{self, BufRead};

fn gcd(x: usize, y: usize) -> usize {
  let (mut a, mut b) = if x < y {
    (y, x)
  } else {
    (x, y)
  };
  while b != 0 {
    let r = a % b;
    a = b;
    b = r;
  }
  a
}

fn main() {
  let stdin = io::stdin();
  let mut lines = stdin.lock().lines();
  let line = lines.next().unwrap().unwrap();
  let n: usize = line.parse().unwrap();

  let mut memo = vec![vec![0; n]; n];
  for i in 0..n {
    for j in 0..n {
      memo[i][j] = gcd(i+1, j+1);
    }
  }
  let mut total: usize = 0;
  for i in 0..n {
    for j in 0..n {
      for k in 0..n {
        total += memo[memo[i][j]-1][k];
      }
    }
  }
  println!("{}", total);
}

Measured memory_bytes: 2396
N = int(input())
As = list(map(int, input().split()))

As.sort(reverse=True)
#print('As:', As)

ans = As[0]
i = 1
num = 0
for _ in range(N-2):
    ans += As[i]
    num += 1
    if num >= 2:
        i += 1
        num = 0

print(ans)


Measured memory_bytes: 31444