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

// 深さ優先探索
vector<bool> seen;
int p=0;
int d[200],f[200];
void dfs(const Graph &G, int v) {
    if (!seen[v]) d[v]=p+1;
    seen[v] = true; // v を訪問済にする
    p++;f[v]=p;

    // v から行ける各頂点 next_v について
    for (auto next_v : G[v]) {
        if (seen[next_v]) {
            continue; // next_v が探索済だったらスルー
        }
        dfs(G, next_v); // 再帰的に探索
    }
    p++;f[v]=p;
}

int main() {
   int n;
   cin >> n;
   Graph G(n+1);
   for (int i=0; i<n; i++) {
       int u,k;
       cin >> u >> k;
       for (int j=0; j<k; j++) {
           int v;
           cin >> v;
           G[u].push_back(v);
       }
   }
   seen.assign(n+1,false);
   for (int i=1; i<n+1; i++) {
       if (!seen[i]) {
           dfs(G,i);
       }
   }
   for (int i=1; i<n+1; i++) {
       cout << i << " " << d[i] << " " << f[i] << endl;
   }
}


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

using namespace std;
const int maxN = 2e5 + 10;

int X[maxN], Y[maxN];
char dir[maxN];
char dx[] = {'U', 'D', 'R', 'L'};
char dy[] = {'R', 'L', 'D', 'U'};
int n;

#define maxM 200000

void Rotate() {
  for (int i = 1; i <= n; ++i) {
    int new_x = Y[i], new_y = maxM - X[i];
    char new_dir;
    for (int j = 0; j < 4; ++j) {
      if (dir[i] == dx[j]) {
        new_dir = dy[j];
      }
    }
    X[i] = new_x; Y[i] = new_y; dir[i] = new_dir;
  }
}

int case_1() {
  int ret = 1 << 24;
  vector< vector < pair<int, char> > > v1(maxN);
  for (int i = 1; i <= n; ++i) {
    if (dir[i] == 'U' || dir[i] == 'D') {
      v1[X[i]].push_back({Y[i], dir[i]});
    }
  }
  for (int i = 0; i <= maxM; ++i) {
    sort(v1[i].begin(), v1[i].end());
    for (int j = 1; j < v1[i].size(); ++j) {
      if (v1[i][j].second == 'D' && v1[i][j-1].second == 'U')
        ret = min(ret, v1[i][j].first - v1[i][j-1].first);
    }
  }
  return ret * 5;
}

int case_2() {
  int ret = 1 << 24;
  vector< vector < pair<int,char> > > v2(2*maxN);
  for (int i = 1; i <= n; ++i) {
    if (dir[i] == 'R' || dir[i] == 'U') {
      v2[X[i] + Y[i]].push_back({X[i], dir[i]});
    }
  }
  for (int i = 0; i <= 2 * maxM; ++i) {
    sort(v2[i].begin(), v2[i].end());
    for (int j = 1; j < v2[i].size(); ++j) {
      if (v2[i][j].second == 'U' && v2[i][j-1].second == 'R')
        ret = min(ret, v2[i][j].first - v2[i][j-1].first);
    }
  }
  return ret * 10;
}

int main(){
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//  freopen("abc.inp", "r", stdin); freopen("abc.out", "w", stdout);
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    cin >> X[i] >> Y[i] >> dir[i];
  }
  int ans = 1 << 24;
  for (int t = 1; t <= 4; ++t) {
    ans = min(ans, case_1()); ans = min(ans, case_2());
    Rotate();
  }
  if (ans == (1 << 24)) cout << "SAFE";
  else cout << ans;
  return 0;
}


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

int solve() {
    int N, M, Q;
    cin >> N >> M >> Q;
    vector<int> A(Q), B(Q), C(Q), D(Q);
    for ( int i = 0; i < Q; i++ ) {
        cin >> A[i] >> B[i] >> C[i] >> D[i];
        A[i]--, B[i]--;
    }
    int ans = 0;
    vector<int> v(N);
    function<void(int,int)> dfs = [&](int d, int k) {
        v[d] = k;
        if ( d == N-1 ) {
            int s = 0;
            for ( int q = 0; q < Q; q++ ) {
                if ( v[B[q]] - v[A[q]] == C[q]) s += D[q];
            }
            ans = max(ans, s);
            return;
        }
        for ( int i = k; i <= M; i++ ) {
            dfs(d+1, i);
        }
    };
    dfs(0,1);
    return ans;
}

int main() {
    auto ans = solve();
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp(x) fixed << setprecision(x)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = (1<<30)-1;
const ll INF = (1LL<<60)-1;
const ld EPS = 1e-10;
template<typename T> bool chmax(T &x, const T &y) {return (x < y)? (x = y, true) : false;};
template<typename T> bool chmin(T &x, const T &y) {return (x > y)? (x = y, true) : false;};

const int MAX_V = 100000;
vector<int> es[MAX_V];
vector<int> c(MAX_V, -1);
ll cnt[] = {0, 0};
bool flag = false;

void dfs(int now, int col){
    cnt[c[now] = col]++;
    for(auto &e: es[now]){
        if(c[e] == -1) dfs(e, col^1);
        if(c[e] == col) flag = true;
    }
}

int main(){
    ll V, E;
    cin >> V >> E;
    rep(i, E){
        int u, v; cin >> u >> v; u--, v--;
        es[u].pb(v), es[v].pb(u);
    }
    ll base = 0;
    bitset<MAX_V+1> bs;
    bs.set(0);
    rep(i, V){
        if(c[i] != -1) continue;
        dfs(i, 0);
        if(cnt[0] < cnt[1]) swap(cnt[0], cnt[1]);
        base += cnt[1], bs |= (bs << (cnt[0]-cnt[1]));
        cnt[0] = cnt[1] = 0;
    }
    if(flag) {cout << -1 << endl; return 0;}
    ll ans = E;
    rep(i, V){
        if(!bs[i]) continue;
        ll x = base+i;
        chmax(ans, x*(V-x));
    }
    cout << ans-E << endl;
}


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

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

    // ダイクストラ法。計算量はO((V+E)*log(V))
    const ll sv = 0;  // 始点となる頂点。デフォルトでは0
    vl dist(MAX_N, INF);  // dist[v] : 頂点svから頂点vへの最短距離
    priority_queue<P, vector<P>, greater<P>> prQ;
    dist[sv] = 0;
    prQ.push(make_pair(0, sv));  // (頂点svからの最短距離, 頂点番号)
    while(!prQ.empty()) {
        auto p1 = prQ.top();
        prQ.pop();
        ll v = p1.second;
        if(dist[v] < p1.first) {
            continue;
        }
        for(ll pow6 = 1; v + pow6 <= n; pow6 *= 6) {
            ll u = v + pow6;
            ll cost = 1;
            if(dist[u] > dist[v] + cost) {
                dist[u] = dist[v] + cost;
                prQ.push(make_pair(dist[u], u));
            }
        }
        for(ll pow9 = 1; v + pow9 <= n; pow9 *= 9) {
            ll u = v + pow9;
            ll cost = 1;
            if(dist[u] > dist[v] + cost) {
                dist[u] = dist[v] + cost;
                prQ.push(make_pair(dist[u], u));
            }
        }
    }

    out(dist[n]);
    re0;
}

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

using namespace std;

int main(){
	int x=-1, y=-1,z=-1;
	double c=0;
	cin >> x >> y ;
	printf("%d %d %.5f\n", x / y, x%y, (double)x / y);
	return 0;
}

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

int main() {
  string S;
  cin >> S;

  int L = S.size();
  string ans = "AC";
  if (S.front() != 'A') {
    ans = "WA";
  }
  int cnt = 0;
  for (int i = 1; i < L; ++i) {
    if (isupper(S.at(i))) {
      if (i == 1 || i == L - 1 || S.at(i) != 'C') {
        ans = "WA";
      }
      cnt++;
    }
  }
  if (cnt != 1) {
    ans = "WA";
  }

  printf("%s", ans.c_str());
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cassert>
#include<vector>
#include<cmath>
#include<cstdio>
#include<algorithm>

#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define inf (1<<29)

using namespace std;

struct P
{
  int to,cost;
  P(int to=inf,int cost=inf):to(to),cost(cost){}
};

//
template<typename T>
bool visit(const T& G,int v,vector<int>& order,vector<int>& color)
{
  color[v] = 1;
  for(__typeof((G[v]).begin()) e = G[v].begin();e != G[v].end();e++)
    {
      if(color[e->to] == 2)continue;//このvisit以外のvisitで訪れた
      if(color[e->to] == 1)return false;//このvisitで訪れた
      if(!visit(G,e->to,order,color))return false;
    }
  order.push_back(v);
  color[v] = 2;
  return true;
}

template<typename T>
bool topologicalSort(const T& G,vector<int>& order)
{
  int SizeG = G.size();
  vector<int> color(SizeG); 
  for(int u=0;u<SizeG;u++)
    if(!color[u] && !visit(G,u,order,color))
      return false;
  reverse(order.begin(),order.end());
  return true;
}
//

int n,m,a,b;

int main()
{
  cin >> n >> m;
  assert(n >= 2);
  vector<vector<P> > G(n,vector<P>());
  rep(_,m)
    {
      scanf("%d %d",&a,&b);
      a--,b--;
      G[a].push_back(P(b,1));
    }
  vector<int> order;
  topologicalSort(G,order);
  rep(i,order.size())cout << order[i]+1 << endl;
  int stlen[n],cnt[n];

  rep(i,n)stlen[i] = 0,cnt[i] = 0;
  rep(i,n)rep(j,G[order[i]].size())
    stlen[G[order[i]][j].to] = max(stlen[G[order[i]][j].to],stlen[order[i]]+1);

  //rep(i,n)cout << "stlen[" << i << "] = " << stlen[i] << endl;

  rep(i,n)cnt[stlen[i]]++;

  bool check = false;
  rep(i,n)if(cnt[i] >= 2)check = true;

    cout << check << endl;

  return 0;
}

Measured memory_bytes: 2788
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <map>
#include <numeric>
using namespace std;

int main()
{
  int x,a,b;
  cin>>x>>a>>b;
  if(b<=a){cout<<"delicious"<<endl;}
  else if(b<=a+x){cout<<"safe"<<endl;}
  else{cout<<"dangerous"<<endl;}
}


Measured memory_bytes: 256
a = [True] * 1001
a[0] = False
a[1] = False
b = []
c = {}
for i in range(2, 1001):
    if a[i]:
        b.append(i)
        for j in range(2, 1001, 2):
            a[j] = False
d = int(input())
for j in range(2, d + 1):
    temp_j = j
    for i in b:
        while True:
            if temp_j % i != 0:
                break
            else:
                if i not in c:
                    c[i] = 1
                else:
                    c[i] += 1
                temp_j //= i
e = 1
for k in c.keys():
    e = (e * (c[k] + 1)) % (10 ** 9 + 7)
print(e)


Measured memory_bytes: 3064
fun main(args: Array<String>) {
    val (x, y) = readIntegerList()
    if (y * 2 < x || x * 2 < y || (x + y) % 3 != 0) {
        println(0)
        return
    }

//    y = -x + b
//    b = y1 + x1
//    y = -x + x1 + y1
//    -----------
//    y = x / 2
//    -2x + 2x1 + 2y1 = x
//    x = 2 * (x1 + y1) / 3
//    y = (x1 + y1) / 3
    val lowX = 2 * (x + y) / 3
    val lowY = (x + y) / 3
    val cX = lowX / 2
    val cY = y - lowY
    val table = Combination(10000000)
    println(table.value(cX, cY))

}

/** n <= 1000000 */
class Combination(n: Int, val MOD: Long = 1000000007L) {
    val fact = LongArray(n + 1)
    val ifact = LongArray(n + 1)

    /** O(n) */
    init {
        fact[0] = 1L
        for (i in 1..n) { fact[i] = (fact[i - 1] * i) % MOD }
        ifact[n] = inverse(fact[n], MOD)
        for (i in n downTo 1) { ifact[i - 1] = (ifact[i] * i) % MOD }
    }

    /** O(1) */
    fun value(n: Int, k: Int) = if (k < 0 || k > n) 0 else (((fact[n] * ifact[k]) % MOD) * ifact[n-k]) % MOD

    /** O(log(m)) */
    fun pow(n: Long, m: Long, MOD: Long): Long {
        var ret = 1L
        var x = n
        var k = m
        while (k > 0) {
            if ((k and 1L) == 1L) { ret = (ret * x) % MOD }
            x = (x * x) % MOD
            k = k shr 1
        }
        return ret
    }

    /** O(log(MOD)) */
    fun inverse(n: Long, MOD: Long) = pow(n, MOD - 2L, MOD)
}

fun readInteger() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readStringList() = readLine()!!.split(" ")
fun readIntegerList() = readStringList().map(String::toInt)
fun readLongList() = readStringList().map(String::toLong)


Measured memory_bytes: 196212
#include <stdio.h>
int main(void){
    int n,i;
    scanf("%d",&n);
    int a[n];
    for(i=0;i<n;i++) scanf("%d",&a[i]);
    for(i=0;i<n;i++){
        if(a[i]%2==0){
            if(a[i]%3!=0 && a[i]%5!=0){
                printf("DENIED");
                return 0;
            }
        }
    }
    printf("APPROVED");
    return 0;
}


Measured memory_bytes: 128
DIVISOR = 10**9+7
N, M = gets.split(" ").first(2).map(&:to_i)
Xa = gets.split(" ").first(N).map(&:to_i).reverse
Ya = gets.split(" ").first(M).map(&:to_i).reverse

widths = (0..Xa.size-2).map{|i| Xa[i] - Xa[i+1] }
heights = (0..Ya.size-2).map{|i| Ya[i] - Ya[i+1] }
total_width = widths.map.with_index{|w, i|
  w * (i + 1) * (widths.size-i)
}.inject(0, :+)
total_height = heights.map.with_index{|h, i|
  h * (i + 1) * (heights.size-i)
}.inject(0, :+)

puts total_width * total_height % DIVISOR


Measured memory_bytes: 19716
N = int(input()) - 1
rst = ''
for i in range(1, 10 ** 15):
    if N >= 26 ** i:
        N -= 26 ** i
        continue
    for j in range(i):
        rst += chr(ord('a') + N % 26)
        N //= 26
    print(rst[::-1])
    break

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

int main(){
    int sum=0;
    char S[20000];
    stack<int> A;
    stack<pair<int,int> > B;
    scanf("%s",S);
    int k;
    for(int i=0;i<strlen(S);i++){
        if(S[i]=='\\')A.push(i);
        else if(S[i]=='/'){
            if(!A.empty()){
                k=A.top();A.pop();
                sum+=i-k;
                pair<int,int> u;
                int sss=i-k;
                while(!B.empty()&&k<B.top().first){
                    u=B.top();B.pop();
                    sss+=u.second;
                }
                B.push(make_pair(k,sss));
            }
        }
    }
    cout<<sum<<endl;
    cout<<B.size();
    vector<int> ans;
    while(!B.empty()){ans.push_back(B.top().second);B.pop();}
    int nn=ans.size();
    for(int i=nn-1;i>=0;i--){
        printf(" %d",ans[i]);
    }
    printf("\n");

}


Measured memory_bytes: 3352
n = int(input())
t = [0]
x = [0]
y = [0]
for _ in range(n):
    t_tmp, x_tmp, y_tmp = map(int, input().split(" "))
    t.append(t_tmp)
    x.append(x_tmp)
    y.append(y_tmp)

reachable = True
for j in range(1, n + 1):
    dt = t[j] - t[j - 1]
    dist = abs(x[j] - x[j - 1]) + abs(y[j] - y[j - 1])
    if dt < dist or dist % 2 != dt % 2:
        reachable = False

print("Yes" if reachable == True else "No")


Measured memory_bytes: 11816
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
using namespace std;
typedef long long int ll;

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	int n; cin >> n;
	string s; cin >> s;
	if(n%2==0&&s.substr(0,n/2)==s.substr(n/2,n/2)){
		cout << "Yes" << endl;
	}
	else{
		cout << "No" << endl;
	}
} 

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

#define N 10000

using namespace std;

int is_prime(int p)
{
  if (p == 1) return 0;
  if(p == 2) return 1;
  for (int i = 2; i < sqrt((double)p) + 1.0; i++) {
    if (p % i == 0) return 0;
  }

  return 1;
}

int count_prime_number(int A[], int n)
{
  int count = 0;

  for(int i = 0; i< n; i++) {
    if(is_prime(A[i]) ) count++;
  }
  
  return count;
}

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

  int A[N];
  for(int i = 0; i < n; i++) cin >> A[i];

  int count = count_prime_number(A, n);
  cout << count << endl;

  return 0;
}


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


class UnionFind():
    def __init__(self, n):
        self.n = n
        self.root = [-1] * (n + 1)
        self.rnk = [0] * (n + 1)

    def find_root(self, x):
        if self.root[x] < 0:
            return x
        else:
            self.root[x] = self.find_root(self.root[x])
            return self.root[x]

    def unite(self, x, y):
        x = self.find_root(x)
        y = self.find_root(y)
        if x == y:
            return
        elif self.rnk[x] > self.rnk[y]:
            self.root[x] += self.root[y]
            self.root[y] = x
        else:
            self.root[y] += self.root[x]
            self.root[x] = y
            if self.rnk[x] == self.rnk[y]:
                self.rnk[y] += 1

    def isSameGroup(self, x, y):
        return self.find_root(x) == self.find_root(y)

    def size(self, x):
        return -self.root[self.find_root(x)]


N, M = map(int, input().split())
lang = [[] for _ in range(M+1)]
for i in range(N):
    lang_list = list(map(int, input().split()))
    for j in range(1, len(lang_list)):
        lang[lang_list[j]].append(i)

UF = UnionFind(N)
for speaker in lang:
    for i in range(1, len(speaker)):
        UF.unite(speaker[0], speaker[i])

if UF.size(0) == N:
    print('YES')
else:
    print('NO')


Measured memory_bytes: 72736
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String input = null;
		try {
			input = br.readLine();
			br.close();
		} catch (IOException e) {
		}

		String[] ab = input.split(" ");

		int a = Integer.parseInt(ab[0]);
		int b = Integer.parseInt(ab[1]);

		// a = 1,b = 1;
		if(a < b){
			System.out.println("a < b");
		}else if(a > b){
			System.out.println("a > b");
		}else{
			System.out.println("a == b");
		}


		/*
		if(a < b){
			System.out.println(a < b);
		}

		if(a > b){
			System.out.println(a > b);
		}

		if(a == b){
			System.out.println(a == b);
		}
		*/
	}
}


Measured memory_bytes: 24480
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include<math.h>
#include<iomanip>
#include<functional>
using namespace std;

#define ll long long
using vt = ll; //ここで数値の型を変えられる
#define rep(i, n) for (vt i = 0; i < (vt)(n); i++)
#define reps(i, s, n) for(vt i = (vt) (s); i < (vt) (n); i++) 
#define all(v) v.begin(), v.end()
#define P pair<int, int>
const ll  MOD = 1000000007;

vector<vector<ll>> to(200005);
vector<ll> ans;

void dfs(ll v, ll p = -1) {
	for (auto u : to.at(v)) {
		if (u == p) continue;
		ans.at(u) += ans.at(v);
		dfs(u, v);
	}
}

int main() {
	ll n, q;
	cin >> n >> q;
	rep(i, n - 1) {
		ll a, b;
		cin >> a >> b;
		a--; b--;
		to.at(a).push_back(b);
		to.at(b).push_back(a);
	}
	ans.resize(n);
	rep(i, q) {
		ll p, x;
		cin >> p >> x;
		p--;
		ans.at(p) += x;
	}
	dfs(0);
	rep(i, n) {
		cout << ans.at(i) << " ";
	}
	return 0;
}

Measured memory_bytes: 24320
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
  int N;
  cin >> N;
  int count = 0;
  bool inzero=false;
  long long ans = 0;
  int ln = (int)1e9;
  vector<int> line(N);
  for(int i=0;i<N;++i){
    cin>>line[i];
    if(line[i] < 0){
      ++count;
    }
    if(line[i]==0)inzero=true;
    ans += abs(line[i]);
    ln = min(ln,abs(line[i]));
  }
  if(inzero || (count % 2 == 0)){
    cout << ans << endl;
  }else{
    cout << ans - ln * 2 << endl;
  }
  return 0;
}


Measured memory_bytes: 640
S = input()
N = len(S)

m = N//2
if N%2 == 0:
    if S[m] != S[m-1]:
        print(m)
        exit()
    ans = m+1
    for i in range(1,m):
        if S[m] == S[m+i] == S[m-1-i]:
            ans += 1
        else:
            break
else:
    ans = m+1
    for i in range(1,m+1):
        if S[m] == S[m+i] == S[m-i]:
            ans += 1
        else:
            break
print(ans)


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


using namespace std;

#define int long long
#define all(a) a.begin(),a.end()
#define sz(x) ((int)x.size())
#define ff first 
#define ss second 
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector<string> vs;
typedef map<int,int> mii;
typedef map<char,int> mci;
typedef vector<vector<int>> vvi;
typedef vector<pair<int,int>> vpii;
template<class T>
istream &operator>>(istream &in, vector<T> &arr){
	for(auto &x: arr) in >> x;
	return in;
}

int n;
vi a;
vvi dp;
int solve(int l, int r){
    if(r == l + 1){
        return max(a[l],a[r]);
    }
    if(l == r)return a[l];

    if(dp[l][r] != -1) return dp[l][r];

    dp[l][r] = max(a[l] + min(solve(l + 2,r),solve(l + 1,r - 1)), a[r] + min(solve(l + 1, r - 1),solve(l,r - 2)));

    return dp[l][r];
}
signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> n;
    a.resize(n);
    dp.resize(n + 1,vi(n + 1,-1));
    cin >> a;
    int x = solve(0,n - 1);
    int y = accumulate(all(a),0LL);
    cout << 2*x - y;
}

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


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
const long long MD=1e9+7;
long long n,m,k,fact[200005],ans;
long long qpow(long long b,long long exp) {
    long long ret=1;
    while (exp!=0) {
        if (exp%2==1) {ret*=b; ret%=MD;}
        b*=b; b%=MD;
        exp/=2;
    }
    return ret;
}
long long xcy(int x,int y) {
    if (y>x) return 0;
    if (y==0 or y==x) return 1;
    long long nom=fact[x];
    long long de1=qpow(fact[x-y],MD-2),de2=qpow(fact[y],MD-2);
    return (((nom*de1)%MD)*de2)%MD;
}
int main() {
    cin>>n>>m>>k;
    fact[0]=1;
    for (int i=1; i<=n*m; i++) {fact[i]=fact[i-1]*i; fact[i]%=MD;}
    for (int i=0; i<=n-1; i++) {
        for (int j=0; j<=m-1; j++) {
            long long co=xcy(n*m-2,k-2);
            long long p1=1LL*j*(j+1)*(n-i-1)/2; p1%=MD;
            long long p2=1LL*m*(n-i)*(n-i-1)/2; p2%=MD;
            long long p3=1LL*(m-j)*(m-j-1)*(n-i-1)/2; p3%=MD;
            long long yval=1LL*(m-j)*(m-j-1)/2; yval%=MD;
            ans+=(co*((p1+p2+p3+yval)%MD))%MD; ans%=MD;
        }
    }
    cout<<ans<<'\n';
}

Measured memory_bytes: 5100
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,copy,time
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(input())
def inpl(): return list(map(int, input().split()))
def inpl_str(): return list(input().split())

N,K = inpl()
aa = inpl()
dp = [0]*(K+1) # 0:未巡回 1:先手勝 -1:後手勝

for i in range(aa[0]):
    dp[i] = -1

for i in range(aa[0],K+1):
    for a in aa:
        if i < a: break
        if dp[i-a] == -1:
            dp[i] = 1
            break

    if dp[i] == 0:
        dp[i] = -1

if dp[-1] == -1:
    print('Second')
else:
    print('First')


Measured memory_bytes: 4852
n, d = map(int, input().split())
lst = sorted([list(map(int, input().split())) for _ in range(n)]) + [[10 ** 20, 1]]
cnt = 0
time = 0
floor = 1
ans = 0
for i in range(n):
  t, f = lst[i]
  if f - floor > t - time or cnt >= d:
    print(-1)
    break

  ans += cnt * (t - time)
  cnt += 1
  time = t
  floor = f
  next_t, next_f = lst[i + 1]
  if time + (floor - 1) + (next_f - 1) <= next_t:
    ans += cnt * (floor - 1)
    cnt = 0
    time += floor - 1
    floor = 1
else:
  print(ans)


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

using namespace std;
#define endl '\n'
#define eb emplace_back
#define fst first
#define scd second

constexpr int mod = 1000000007;

using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;

ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }

// value
int N, D;

void solve() {

	cin >> N >> D;

	double tmp = 2 * D + 1;

	cout << int(ceil(N / tmp)) << endl;

	return;

}

int main() {

	cin.tie(0);
	ios::sync_with_stdio(false);

	solve();

	return 0;

}


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

typedef long long ll;

const int mod = 1e9 + 7;
const int maxn = 1e5 + 5;

int fact[maxn], inv[maxn];
int n, k;
vector<int> adj[maxn];

long long binpow(long long a, long long b, long long m) {
    a %= m;
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}

int Inv(int x) { return binpow(x, mod - 2, mod); }

int P(int n, int k)
{
    if (n < 0 || k < 0 || k > n) return 0;
    return ll(fact[n]) * inv[n - k] % mod;
}

int dfs(int u, int p)
{
    int my = int(adj[u].size()) - 1;
    int res = P(k - 2, my);
    for (int v : adj[u]) {
        if (v == p) continue;
        res = ll(res) * dfs(v, u) % mod;
    }
    return res;
}

int main()
{
    fact[0] = inv[0] = 1;
    for (int i = 1; i < maxn; i++) {
        fact[i] = ll(fact[i - 1]) * i % mod;
        inv[i] = Inv(fact[i]);
    }
    cin >> n >> k;
    for (int i = 0; i < n - 1; i++) {
        int a, b;
        cin >> a >> b;
        adj[a].push_back(b);
        adj[b].push_back(a);
    }
    ll ans = k;
    ans *= P(k - 1, int(adj[1].size()));
    ans %= mod;
    for (int v : adj[1]) {
        ans = (ans * dfs(v, 1)) % mod;
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 11264
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;

int f(const vector<vector<int>>& v, int x1, int y1, int x2, int y2) {
    int kk = v.size(), k = v.size() / 2;
    if (x1 >= kk || y1 >= kk || x2 < 0 || y2 < 0) return 0;
    x1 = max(0, min(x1, kk - 1));
    y1 = max(0, min(y1, kk - 1));
    x2 = max(0, min(x2, kk - 1));
    y2 = max(0, min(y2, kk - 1));
    int res = v[x2][y2];
    if (x1 > 0) {
        res -= v[x1 - 1][y2];
    }
    if (y1 > 0) {
        res -= v[x2][y1 - 1];
    }
    if (x1 > 0 && y1 > 0) {
        res += v[x1 - 1][y1 - 1];
    }
    return res;
}

int main() {
    int n, k;
    cin >> n >> k;
    vector<vector<int>> black(2 * k, vector<int> (2 * k, 0));
    vector<vector<int>> white(2 * k, vector<int> (2 * k, 0));
    int kk = 2 * k;
    int c1 = 0, c2 = 0;
    for (int i = 0; i < n; i++) {
        int x, y;
        cin >> x >> y;
        char color;
        cin >> color;
        x %= kk, y %= kk;
        if (color == 'W') {
            white[x][y]++;
            c1++;
        } else {
            black[x][y]++;
            c2++;
        }
    }

    for (int i = 0; i < kk; i++) {
        for (int j = 0; j < kk; j++) {
            if (i > 0) {
                white[i][j] += white[i - 1][j];
                black[i][j] += black[i - 1][j];
            }
            if (j > 0) {
                white[i][j] += white[i][j - 1];
                black[i][j] += black[i][j - 1];
            }
            if (i > 0 && j > 0) {
                white[i][j] -= white[i - 1][j - 1];
                black[i][j] -= black[i - 1][j - 1];
            }
        }
    }

    int res = 0;
    for (int i = 0; i <= k; i++) {
        for (int j = 0; j <= k; j++) {
            int cc1 = 0, cc2 = 0;
            cc1 += f(white, i, j, i + k - 1, j + k - 1);
            cc1 += f(white, i + k, j + k, i + kk - 1, j + kk - 1);
            cc1 += f(white, i + k, j - k, i + kk - 1, j - 1);
            cc1 += f(white, i - k, j + k, i - 1, j + kk - 1);
            cc1 += f(white, i - k, j - k, i - 1, j - 1);
            cc2 += f(black, i, j, i + k - 1, j + k - 1);
            cc2 += f(black, i + k, j + k, i + kk - 1, j + kk - 1);
            cc2 += f(black, i + k, j - k, i + kk - 1, j - 1);
            cc2 += f(black, i - k, j + k, i - 1, j + kk - 1);
            cc2 += f(black, i - k, j - k, i - 1, j - 1);
            
            res = max(res, cc1 + c2 - cc2);
            res = max(res, cc2 + c1 - cc1);
        }
    }
    cout << res << endl;
}




Measured memory_bytes: 34652
def LI():return list(map(int,input().split()))
def II():return int(input())
def yes():return print("Yes")
def no():return print("No")
#INF=float("inf")
#from collections import deque, defaultdict, Counter
#from heapq import heappop, heappush
#from itertools import product, combinations
#from functools import reduce, lru_cache
#from math import pi, gcd
#from decimal import Decimal

class Combination:
    """
    O(n)の前計算を1回行うことで，O(1)でnCr mod mを求められる
    n_max = 10**6のとき前処理は約950ms (PyPyなら約340ms, 10**7で約1800ms)
    使用例：
    comb = Combination(1000000)
    print(comb(5, 3))  # 10
    """
    def __init__(self, n_max, mod=10**9+7):
        self.mod = mod
        self.modinv = self.make_modinv_list(n_max)
        self.fac, self.facinv = self.make_factorial_list(n_max)

    def __call__(self, n, r):
        return self.fac[n] * self.facinv[r] % self.mod * self.facinv[n-r] % self.mod

    def make_factorial_list(self, n):
        # 階乗のリストと階乗のmod逆元のリストを返す O(n)
        # self.make_modinv_list()が先に実行されている必要がある
        fac = [1]
        facinv = [1]
        for i in range(1, n+1):
            fac.append(fac[i-1] * i % self.mod)
            facinv.append(facinv[i-1] * self.modinv[i] % self.mod)
        return fac, facinv

    def make_modinv_list(self, n):
        # 0からnまでのmod逆元のリストを返す O(n)
        modinv = [0] * (n+1)
        modinv[1] = 1
        for i in range(2, n+1):
            modinv[i] = self.mod - self.mod//i * modinv[self.mod%i] % self.mod
        return modinv

class Unionfind:
    def __init__(self, N):
        self.p = list(range(N))
        self.rank = [0] * N
        self.size = [1] * N

    def root(self, x):
        if self.p[x] != x:
            self.p[x] = self.root(self.p[x])

        return self.p[x]

    def same(self, x, y):
        return self.root(x) == self.root(y)

    def unite(self, x, y):
        u = self.root(x)
        v = self.root(y)

        if u == v: return

        if self.rank[u] < self.rank[v]:
            self.p[u] = v
            self.size[v] += self.size[u]
            self.size[u] = 0
        else:
            self.p[v] = u
            self.size[u] += self.size[v]
            self.size[v] = 0

            if self.rank[u] == self.rank[v]:
                self.rank[u] += 1

    def count(self, x):
        return self.size[self.root(x)]


d,t,s=LI()

if (d<=t*s):
    yes()
else:
    no()


Measured memory_bytes: 62416
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N;
    cin>>N;
    vector<int>flag(101);
 
    for(int i=0;i<N;++i){
        int D;
         cin>>D;
         flag[D] =1;
    }    
    
    int sum=0;
    for(int i=0;i<101;++i)
        sum += flag[i];
    cout<<sum<<endl;
}


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

#define int long long
const int MOD=1e9+7;
int pw(int k,int n){
  assert(k>=0);
  int res=1;
  while(k){
    if(k&1)(res*=n)%=MOD;
    (n*=n)%=MOD;
    k>>=1;
  }
  return res;
}

signed main(){
  int n;cin>>n;
  int ans=0;
  ans+=pw(n,10);
  ans+=MOD-pw(n,9);
  ans+=MOD-pw(n,9);
  ans+=pw(n,8);
  cout<<ans%MOD<<endl;
}


Measured memory_bytes: 3644
fn main() {
	let mut s = String::new();
	use std::io::Read;
	std::io::stdin().read_to_string(&mut s).unwrap();
	let mut s = s.split_whitespace();
	let n: usize = s.next().unwrap().parse().unwrap();
	let k: usize = s.next().unwrap().parse().unwrap();
	let a: Vec<u64> = vec![0].into_iter().chain(s.map(|a| a.parse::<u64>().unwrap())).scan(0, |s, a|{ *s += a; Some(*s) }).collect();
	let mut a: Vec<u64> = (0..n).flat_map(|i| (i + 1..n + 1).map(move |j| (i, j))).map(|(i, j)| a[j] - a[i]).collect();
	a.sort_by_key(|a| std::u64::MAX - a);
	let msb = 63 - a[0].leading_zeros();
	let mut ans: u64 = 0;
	let mut g: std::collections::BTreeSet<_> = (0..a.len()).collect();
	for bit in (0..msb + 1).rev() {
		let index: std::collections::BTreeSet<_> = g.iter().filter(|&&i| a[i] & (1 << bit) != 0).map(|&i| i).collect();
		if index.len() >= k {
			g = g.intersection(&index).cloned().collect();
			ans |= 1 << bit;
		}
	}
	println!("{}", ans);
}


Measured memory_bytes: 22772
#include <bits/stdc++.h>
using namespace std;
static const int MAX_K = 15;
string x;
void solve()
{
}
int main()
{
    int result = 0;
    cin >> x;
    for (int i = 0; i < x.length(); ++i)
    {
        if (x[i] == 'o')
            ++result;
    }
    if (15 - x.length() >= 8 - result)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
    return 0;
}

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

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author kessido
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        CSequenceGrowingEasy solver = new CSequenceGrowingEasy();
        solver.solve(1, in, out);
        out.close();
    }

    static class CSequenceGrowingEasy {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.NextInt();
            int[] a = in.NextIntArray(n);
            long res = 0;
            int needsToBeArLeast = 0;
            for (int i = n - 1; i >= 0; i--) {
                if (a[i] < needsToBeArLeast || a[i] > i) {
                    out.println(-1);
                    return;
                }
                if (a[i] != needsToBeArLeast) {
                    res += a[i];
                }
                needsToBeArLeast = a[i];
                if (needsToBeArLeast != 0) needsToBeArLeast--;
            }
            out.println(res);
        }

    }

    static class InputReader {
        BufferedReader reader;
        StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine(), " \t\n\r\f,");
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

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

        public int[] NextIntArray(int n) {
            return NextIntArray(n, 0);
        }

        public int[] NextIntArray(int n, int offset) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = NextInt() + offset;
            }
            return a;
        }

    }
}



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

#define rep(i,z) for(int i = 0; i<(int)(z); i++)
#define rep1(i,z) for(int i = 1; i<=(int)(z); i++)
 
using namespace std;

typedef long long ll;
const ll MOD=1e9+7;
using pear = pair<int,int>;

int main(){
int x; cin>>x;
if(x==0)cout<<1<<endl;
else cout<<0<<endl;
}


Measured memory_bytes: 3596
<?php
list($H,$W,$N) = explode(" ",trim(fgets(STDIN)));

$ans = array(0,0,0,0,0,0,0,0,0,0);

if($N > 0){
    for($i = 1;$i <= $N;$i++){
        list($a,$b) = explode(" ",trim(fgets(STDIN)));
        for($j = -1;$j <= 1;$j++){
            if($a + $j > 1 && $a + $j < $H){
                for($k = -1;$k <= 1;$k++){
                    if($b + $k > 1 && $b + $k < $W){
                        if(isset($map[$a + $j][$b + $k]) == true){
                            $map[$a + $j][$b + $k] ++;
                        }else{
                            $map[$a + $j][$b + $k] = 1;
                        }
                    }
                }
            }
        }
    }
    
    foreach($map as $val){
        foreach($val as $val2){
            $ans[$val2] ++;
        }
    }

    $num = ($H - 2) * ($W - 2) - array_sum($ans);
    echo $num . PHP_EOL;
}else{
    echo ($H - 2) * ($W - 2) . PHP_EOL;
}

for($i = 1;$i <= 9;$i++){
    echo $ans[$i] . PHP_EOL;
}
?>

Measured memory_bytes: 219768
n = int(input())
v = list(map(int, input().split()))
v1 = v[0::2]
v2 = v[1::2]

from collections import Counter
c1 = list(Counter(v1).items())
c2 = list(Counter(v2).items())

c1 = sorted(c1, key= lambda x: x[1], reverse= True)
c2 = sorted(c2, key= lambda x: x[1], reverse= True)

c1.append((0,0))
c2.append((0,0))

#print(c1[:3], c2[:3])
if c1[0][0] != c2[0][0]:
    print(n - c1[0][1] - c2[0][1])
else:
    a = c1[0][1] + c2[1][1]
    b = c1[1][1] + c2[0][1]
    if a < b:
        print(n - b)
    else:
        print(n - a)

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

int main() {
    int N;
    cin >> N;
    vector<double>p(N);
    for (int i = 0; i < N; ++i) {
        cin >> p[i];
    }
    // dp[i][j] はi枚のコインで表がj個の確率
    vector<vector<double>>dp(N+1, vector<double>(N+1, 0));
    dp[0][0] = 1;
    for (int i = 0; i < N; ++i) {
        for (int j = 0; j <= i; ++j) {
            dp[i+1][j+1] += dp[i][j] * p[i];
            dp[i+1][j] += dp[i][j] * (1 - p[i]);
        }
    }
    double ans = 0;
    for (int j = N; j > N/2; --j) {
        ans += dp[N][j];
    }
    cout << setprecision(20) << ans;
    return 0;
}

Measured memory_bytes: 70656
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <queue>
#include <unordered_map>
#include <set>
#include <algorithm>
#include <utility>
#include <cmath>
using namespace std;

typedef long long llong;
typedef unsigned long long ullong;
// -2.1e-9 <= int <= 2.1e9
// -9.2e-18 <= long long <= 9.2e18
// 0 <= unsigned int <= 4.2e9
// 0 <= unsigned long long <= 18.4e18
// cout << fixed << setprecision(10);

int main() {
    int H1, M1, H2, M2, K;
    cin >> H1 >> M1 >>  H2 >> M2 >> K;
    int len = H2 * 60 + M2 - (H1 * 60 + M1);
    int ans = len - K;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3620
import sys
def main():
    input = sys.stdin.readline
    N,M,Q=map(int, input().split())
    ABCD=[tuple(map(int, input().split())) for _ in range(Q)]

    def f(l):
        res=0
        for a,b,c,d in ABCD:
            if l[b]-l[a]==c: res+=d
        return res

    ans=0
    stk=[[1]]
    while stk:
        l=stk.pop()
        if len(l)==N+1:
            ans = max(ans, f(l))
        else:
            for i in range(l[-1],M+1):
                stk.append(l+[i])
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 68940
#include <bits/stdc++.h>
#define Task "A"

using namespace std;

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    string s, t;
    cin >> s >> t;
    int res = 0;
    for(int i = 0; i<s.size(); ++i) res += (s[i] == t[i]);
    cout << res;
    return 0;
}


Measured memory_bytes: 256
import scala.io.StdIn.readLine

object Main {
  def getNum(c:Char) = c match {
    case 'I' => 1
    case 'V' => 5
    case 'X' => 10
    case 'L' => 50
    case 'C' => 100
    case 'D' => 500
    case 'M' => 1000
    case _ => 0
  }

  def main(args:Array[String]) = {
    Iterator.continually(readLine).takeWhile(_!=null).foreach { s =>
      var prev = getNum(s(0))
      var sum = prev
      for(j<-1 until s.length) {
        val n = getNum(s(j))
        if(n>prev) sum += n -(2*prev) else sum += n
        prev = n
      }
      println(sum)
    }
  }
}

Measured memory_bytes: 43800
#include<stdio.h>
#include<math.h>




int main(void){
	int i, n;
	char c[200001];
	int count, ans;
	int d;
	double dist;

	scanf("%d", &n);
	count=0;
	ans=0;
	scanf("%s", c);
	for(i=0; i<n; i++){
		if(c[i]=='R') count++;
	}
	for(i=0; i<count; i++){
		if(c[i]=='W') ans++;
	}

	printf("%d", ans);

	return 0;
}

Measured memory_bytes: 1924
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  loop(i,0,n)
#define all(c) c.begin(),c.end()
#define rall(c) c.rbegin(),c.rend()
#define vi vector<int>
#define vl vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pll>

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

    cout<<(c/a)*b<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long mod=pow(10,9)+7;
int dp[1001][1001];
char arr[1001][1001];
long long  solve(int i,int j,int n,int m)
{    
      
	 
	   if (i == n - 1 && j == m - 1)
		return 1;
 
	if (dp[i][j] != -1)
		return dp[i][j];
 
	int right = 0, down = 0;
 
	if (i != n - 1 && arr[i + 1][j] !='#')
		down =  solve(i + 1, j,n,m);
	if (j != m - 1 && arr[i][j + 1] != '#')
		right = solve(i, j + 1,n,m);
 
	return dp[i][j] = (down + right) % mod;
	    
}

int main() {	
	int t=1;
	//cin >> t;
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

	while (t--) {
	   
	   int n,m;
	   cin>>n>>m;
	   
	   
	   
	   for(int i=0;i<n;i++)
	   {
	   	for(int j=0;j<m;j++)
	   	 {
	   		 cin>>arr[i][j];
		 }
	   }
	   memset(dp, -1, sizeof(dp));
	     long long ans=solve(0,0,n,m);
	     cout<<ans<<endl;
	   
      }
	} 
	
	
	

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

int main()
{
    int n;
    cin >> n;
    vector<long long> v;

    long long mp[n + 3];
    fill(mp, mp + n + 3, 0);

    for (int i = 0, vx; i < n; ++i)
    {
        cin >> vx;
        v.push_back(vx);
        mp[vx]++;
    }

    // for (int i = 1; i < n + 1; ++i)
    // {
    //     cout << i << " " << mp[i] << endl;
    // }

    long long ans = 0;
    for (int i = 1; i < n + 1; ++i)
    {
        if (mp[i] > 1)
        {
            ans += 1ll * (mp[i] * (mp[i] - 1)) / 2;
        }
    }

    for (int i = 0; i < v.size(); ++i)
    {
        if (mp[v[i]] == 1)
        {
            cout << ans << endl;
        }
        else
        {
            long long len = mp[v[i]];
            long long ak = (1ll * len * (len - 1) / 2) - (1ll * (len - 2) * (len - 1) / 2);
            cout << (ans - ak) << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 5872
#include<bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); 
#define endl '\n'
#define ll long long
#define mod 1000000007
#define inf 1000000000000000000
int main()
{
	fastio;
	#ifdef APNA_IO
		freopen("input.txt" , "rt" ,stdin);
		freopen("output.txt" , "wt" ,stdout);
	#endif
	ll n,k,m,g,h,j;
	cin>>n>>k;
	ll a=(n-1)*(n-2);
	a=a/2;
	if(k>a)
		cout<<-1<<endl;
	else
	{
		m=n-1+(a-k);
		cout<<m<<endl;
		for(ll i=2;i<=n;i++)
			cout<<1<<" "<<i<<endl;
		m=m-(n-1);
		for(j=2;j<=n-1;j++)
		{
			for(k=j+1;k<=n;k++)
			{
				if(m==0)
					break;
				cout<<j<<" "<<k<<endl;
				m--;
				if(m==0)
					break;
			}
			if(m==0)
				break;
		}

	}
	return 0;
}





Measured memory_bytes: 256
package main

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

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

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

	scanner := getScanner(fp)
	writer := bufio.NewWriter(os.Stdout)

	x := getNextInt(scanner)

	min := 1 << 30

	for i := x; i > 99; i /= 10 {
		abs := absint(i%1000 - 753)
		if abs < min {
			min = abs
		}
	}
	fmt.Fprintln(writer, min)
	writer.Flush()
}
func absint(a int) int {
	if a < 0 {
		return -a
	}
	return a
}


Measured memory_bytes: 640
"use strict";

function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); }

function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance"); }

function _iterableToArrayLimit(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }

function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }

!function () {
  function splitNum(line) {
    return (Array.isArray(line) ? line : line.split(/\s+/)).map(function (n) {
      return parseInt(n);
    });
  }

  !function (input) {
    var lines = input.split("\n");

    var _splitNum = splitNum(lines[0]),
        _splitNum2 = _slicedToArray(_splitNum, 1),
        N = _splitNum2[0];

    var rs = lines.slice(1, N + 1).map(function (line, i) {
      var _line$split = line.split(" "),
          _line$split2 = _slicedToArray(_line$split, 2),
          S = _line$split2[0],
          P = _line$split2[1];

      return {
        S: S,
        P: parseInt(P, 10),
        i: i + 1
      };
    });
    rs.sort(function (a, b) {
      if (a.S < b.S) return -1;
      if (a.S > b.S) return 1;else return b.P - a.P;
    });
    var _iteratorNormalCompletion = true;
    var _didIteratorError = false;
    var _iteratorError = undefined;

    try {
      for (var _iterator = rs[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
        var i = _step.value.i;
        console.log(i);
      }
    } catch (err) {
      _didIteratorError = true;
      _iteratorError = err;
    } finally {
      try {
        if (!_iteratorNormalCompletion && _iterator.return != null) {
          _iterator.return();
        }
      } finally {
        if (_didIteratorError) {
          throw _iteratorError;
        }
      }
    }
  }(require("fs").readFileSync("/dev/stdin", "utf8"));
}();


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

int main(){
    char pattern[8][8];
    for(int i=0; i<8; i++)
        for(int j=0; j<8; j++)
            cin >> pattern[i][j];
    cout << "90" << endl;
    for(int i=0; i<8; i++){
        for(int j=0; j<8; j++) cout << pattern[7-j][i];
        cout << endl;
    }
    cout << "180" << endl;
    for(int i=0; i<8; i++){
        for(int j=0; j<8; j++) cout << pattern[7-i][7-j];
        cout << endl;
    }
    cout << "270" << endl;
    for(int i=0; i<8; i++){
        for(int j=0; j<8; j++) cout << pattern[j][7-i];
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 0
def main():
    x = input()
    a = int(x)
    c = []
    b = a
    f = 1000
    for i in range(len(x)):
        c.append(b % 10)
        b = b // 10
    c.reverse()


    for i in range(len(x)-2):
        d = abs(100*c[i] + 10*c[i+1] + c[i+2] - 753)
        if abs(f) > d:
            f = d

    print(f)



if __name__ == '__main__':
    main()

Measured memory_bytes: 3064