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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

const long long INF=INT_MAX/4;
const long long MOD=998244353;
const double EPS=1e-14;
const bool DEBUG=false;

const string YES = "YES";
const string NO = "NO";
const string Yes = "Yes";
const string No = "No";

template<class T>
void debug(T head){
    if(DEBUG){
        cout<<head<<endl;
    }
}

template <class Head, class... Body>
void debug(Head head, Body... body){
    if(DEBUG){
        cout<<head<<" ";
        debug(body...);
    }
}

/////
void answer(ll N, ll K){
    ll answer = 0;
    if(K == 0){
        cout<<N*N<<endl;
        return;
    }

    for(int b=K+1; b<=N; ++b){
        ll t = N / b;
        debug(b, t, b-K);
        answer += t * (b - K);
        answer += max(0ll, (N % b) - (K - 1));
    }
    cout<<answer<<endl;

    return;
}

/////

int main(int argc, char* argv[]){
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout.precision(16);

    ll N, K;
    cin>>N>>K;
    answer(N, K);

    return 0;
}


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

int main(){
    int sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;

    int x_range = tx - sx;
    int y_range = ty - sy;
    string s = "";
    s.append(x_range, 'R');
    s.append(y_range, 'U');
    s.append(x_range, 'L');
    s.append(y_range, 'D');
    s.append(1, 'L');
    s.append(y_range+1, 'U');
    s.append(x_range+1, 'R');
    s.append(1, 'D');
    s.append(1, 'R');
    s.append(y_range+1, 'D');
    s.append(x_range+1, 'L');
    s.append(1, 'U');

    cout << s << endl;
}

Measured memory_bytes: 256
import sys
input=sys.stdin.readline
h,w,n = map(int, input().split())
l=[list(map(int,input().split())) for i in range(n)]

from collections import defaultdict
d = defaultdict(int)
for tmp in l:
    y=tmp[0]-1
    x=tmp[1]-1
    for i in [-1,0,1]:
        for j in [-1,0,1]:
            if 1<=x+i<w-1 and 1<=y+j <h-1:
                s = str(x+i) + "_" + str(y+j)
                d[s]+=1

import collections
lis = list(d.values())
c = collections.Counter(lis)

ans=[0]*10
for itm in c.items():
    ans[itm[0]]=itm[1]

ans[0]=(h-2)*(w-2)-sum(ans)

for a in ans:
    print(a)

Measured memory_bytes: 228860
#include <stdio.h>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
    
    vector<int> W(10),K(10);
    
    for(int i=0;i<10;i++) scanf("%d",&W[i]);
    for(int i=0;i<10;i++) scanf("%d",&K[i]);
    
    sort(W.begin(),W.end());
    sort(K.begin(),K.end());
    
    printf("%d %d\n",W[7]+W[8]+W[9],K[7]+K[8]+K[9]);
    
    return 0;
}

Measured memory_bytes: 2704
local n = io.read("*n")

local parent = {}
for i = 1, 2 * n do parent[i] = i end

local function uf_findroot(idx)
  local idx_update = idx
  while parent[idx] ~= idx do
    idx = parent[idx]
  end
  while parent[idx_update] ~= idx do
    parent[idx_update], idx_update = idx, parent[idx_update]
  end
  return idx
end

local x, y = {}, {}
local xinvmap, yinvmap = {}, {}
local xary, yary = {}, {}
for i = 1, n do
  x[i], y[i] = io.read("*n", "*n")
  if not xinvmap[x[i]] then
    table.insert(xary, x[i])
    xinvmap[x[i]] = #xary
  end
  if not yinvmap[y[i]] then
    table.insert(yary, y[i])
    yinvmap[y[i]] = n + #yary
  end
end

for i = 1, n do
  local xi, yi = x[i], y[i]
  local idx1, idx2 = xinvmap[xi], yinvmap[yi]
  local p1, p2 = uf_findroot(idx1), uf_findroot(idx2)
  parent[p2], parent[idx2] = p1, p1
end
local groups = {}
for i = 1, 2 * n do
  local p = uf_findroot(i)
  if not groups[p] then
    groups[p] = {}
    groups[p].xcnt = 0
    groups[p].ycnt = 0
    groups[p].pointcnt = 0
  end
  if i <= n then
    groups[p].xcnt = groups[p].xcnt + 1
  else
    groups[p].ycnt = groups[p].ycnt + 1
  end
end
for i = 1, n do
  local xi, yi = x[i], y[i]
  local p = uf_findroot(xinvmap[xi])
  groups[p].pointcnt = groups[p].pointcnt + 1
end
local ret = 0
for k, v in pairs(groups) do
  if 1 < v.xcnt and 1 < v.ycnt then
    ret = ret + v.xcnt * v.ycnt - v.pointcnt
  end
end
print(ret)


Measured memory_bytes: 37620
#include <bits/stdc++.h>
#define int long long
#define double long double
using namespace std;
const int MOD = 1000000007;
const int INF = 1e18;
using Graph = vector<vector<int>>;

signed main() {
  map<string, int> cnt;
  int N;
  cin >> N;
  for( int i = 0; i < N; i++ ){
    string S;
    cin >> S;
    cnt[S]++;
  }
  cout << "AC x " << cnt["AC"] << endl;
  cout << "WA x " << cnt["WA"] << endl;
  cout << "TLE x " << cnt["TLE"] << endl;
  cout << "RE x " << cnt["RE"] << endl;
 }


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

public class Main {
	public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int c = sc.nextInt();
        int k = sc.nextInt();
        int[] t = new int[n];
        for(int i=0; i<n; i++){
            t[i] = sc.nextInt();
        }
        sc.close();
        
        Arrays.sort(t);

        int ans = 0;
        int lt = t[0];
        int ln = 0;
        for(int i=0; i<n-1; i++){
            ln++;
            if(ln == c || t[i+1] - lt > k){
                ln = 0;
                lt = t[i+1];
                ans++;
            }
        }
        ans++;
        System.out.print(ans);
	}
}


Measured memory_bytes: 50016
#include<stdio.h>
int main(void)
{
 int N,M,n,play;
 int sum =0;
 scanf("%d",&N);
 scanf("%d",&M);
  
 int m[M];
  
 for(n=0;n<M;n++){
   scanf("%d",&m[n]);
   sum += m[n];
 }
 play =N-sum;
 if(play>=0)
   printf("%d",play);
 else
   printf("-1");
  
 return 0;
}

Measured memory_bytes: 1752
#include<bits/stdc++.h>
using namespace std;
#define INF LONG_MAX
#define SUGOI_DEKAI 1000000000000000
#define yen first
#define snk second

struct Node {
  vector<int> dst;
  map<int, pair<int, int>> cost;
};

int main() {
  int n, m, src, dst;
  vector<Node> Graph; //vertex is expressed as integer
  vector<pair<long, long>> cost;
  vector<long> result;
  queue<int> Queue;
  cin >> n >> m >> src >> dst;
  src--; dst--;
  Graph.resize(n); cost.resize(n); result.resize(n);
  for (int i=0;i<m;i++) {
    int u, v, a, b;
    cin >> u >> v >> a >> b;
    u--; v--;
    Graph[u].dst.push_back(v);
    Graph[v].dst.push_back(u);
    Graph[u].cost[v].yen = Graph[v].cost[u].yen = a;
    Graph[u].cost[v].snk = Graph[v].cost[u].snk = b;
  }
  for (int i=0;i<n;i++)cost[i].yen = cost[i].snk = result[i] = INF, Graph[i].cost[i].yen = Graph[i].cost[i].snk = 0;
  cost[src].yen = cost[dst].snk = 0;
  Queue.push(src);
  while (!Queue.empty()) {
    bool flag = false;
    int pos = Queue.front(); Queue.pop();
    for (int i=0;i<Graph[pos].dst.size();i++) {
      int to = Graph[pos].dst[i];
      long change = cost[to].yen;
      cost[to].yen = min(Graph[pos].cost[to].yen + cost[pos].yen, cost[to].yen);
      if(change != cost[to].yen)Queue.push(to);
    }
  }

  //snuke
  Queue.push(dst);
  while (!Queue.empty()) {
    bool flag = false;
    int pos = Queue.front(); Queue.pop();
    for (int i = 0; i < Graph[pos].dst.size(); i++) {
      int to = Graph[pos].dst[i];
      long change = cost[to].snk;
      cost[to].snk = min(Graph[pos].cost[to].snk + cost[pos].snk, cost[to].snk);
      if(change != cost[to].snk)Queue.push(to);
    }
  }

  for (int i=0;i<n;i++)result[i] = cost[i].yen + cost[i].snk; //minimum cost from src to dst via i:0~n-1
  for (int i=n-2;i>=0;i--)result[i] = min(result[i],result[i+1]); //consider year: if later is smaller, then that is better in earlier
  for(int i=0;i<n;i++)cout << SUGOI_DEKAI - result[i] << endl;
  return 0;
}


Measured memory_bytes: 33024
#pragma region Macros
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i, n) for(int i=(n); i>=0; --i)
#define FOR(i, n, m) for(int i=(m), i##_len=(n); i<i##_len; ++i)
#define EACH(i, v) for(const auto& i : v)
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class Value>using vec = vector< Value >;
using ll = long long;
using P = pair< long long, long long >;
#define fi first
#define se second
#define el endl
#pragma endregion

void Main();

int main(){
    std::cin.tie(nullptr);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}

void Main(){
    string S, T;
    cin >> S >> T;
    S += S;
    if(S.find(T) != string::npos){
        cout << "Yes\n";
    }else{
        cout << "No\n";
    }
}



Measured memory_bytes: 256
#include<stdio.h>
int a[1000100],g[1000],top=1,cnt=0,n;
void add(){
    while(g[top]*3+1<n){  
        top++;
        g[top]=g[top-1]*3+1;
    }
}
void sort(int a[],int g){
    int v,i,j;
    for(i=g+1;i<=n;i++){
        v=a[i];
        j=i-g;
        while(j>=1&&a[j]>v){
            a[j+g]=a[j];
            j-=g;
            cnt++;
        }
        a[j+g]=v;
    }
}
int main(){
    int i;
    scanf("%d",&n);
    g[1]=1;
    for(i=1;i<=n;i++)
        scanf("%d",&a[i]);
    add();
    for(i=top;i>=1;i--)
        sort(a,g[i]);
    printf("%d\n",top);
    for(i=top;i>=1;i--)
        printf("%d ",g[i]);
    printf("\n");
    printf("%d\n",cnt);
    for(i=1;i<=n;i++)
        printf("%d\n",a[i]);
    return 0;
}

Measured memory_bytes: 5700
n=int(input())
a=list(map(int,input().split()))

s1=c1=s2=c2=0
for i in range(n):
    if i%2:
        c1+=max(0,a[i]+s1+1); s1+=min(-s1-1,a[i])
        c2+=max(0,-s2+1-a[i]); s2+=max(-s2+1,a[i])
    else:
        c1+=max(0,-s1+1-a[i]); s1+=max(-s1+1,a[i])
        c2+=max(0,a[i]+s2+1); s2+=min(-s2-1,a[i])
print(min(c1,c2))

Measured memory_bytes: 14468
import bisect
import cmath
import heapq
import itertools
import math
import operator
import os
import random
import re
import string
import sys
from collections import Counter, deque, defaultdict
from copy import deepcopy
from decimal import Decimal
from fractions import gcd
from functools import lru_cache, reduce
from operator import itemgetter, mul, add, xor

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353


K = int(sys.stdin.buffer.readline())
a = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51
     ]
print(a[K - 1])


Measured memory_bytes: 24188
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define print(x)cout<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

int main() {
  int n;
  cin>>n;
  double cnt = 0;
  rep(i,n+1){
    if(i%2) cnt++;
  }
  double ans = cnt/(double)n;
  printf("%.10f\n",ans);
  return 0;
}

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

int main(){
  string s;
  cin >> s;
  
  int cnt[2] = {};
  for(auto i : s){
    cnt[i - '0']++;
  }
  
  cout << min(cnt[0], cnt[1]) * 2 << endl;
  return 0;
}

Measured memory_bytes: 512
#include <algorithm>
#include <iostream>
#include <limits.h>
#include <vector>

#define REP(i,x) for(int i{ 0 }; i < (int)(x); i++)
#define REPC(i,x) for(int i{ 0 }; i <= (int)(x); i++)
#define RREP(i,x) for(int i{ (int)(x) - 1 }; i >= 0 ;i--)
#define RREPC(i,x) for(int i{ (int)(x)}; i >= 0; i--)
#define REP1O(i,x) for(int i{ 1 }; i < (int)(x); i++)
#define REP1C(i,x) for(int i{ 1 }; i <= (int)(x); i++)

#define PB push_back
#define MP make_pair
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()

using namespace std;

typedef vector<bool> Vb;
typedef vector<int> Vi;

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

void init();
int rec(int x);

int n;
Vi opt, memo;
const int inf = 1 << 25;

int main()
{
	init();

	cout << rec(n) << endl;
}

void init()
{
	cin >> n;
	memo.resize(n + 1, inf);
	memo[0] = 0;

	opt.PB(1);
	int x = 6;
	while (x <= n)
	{
		opt.PB(x);
		x *= 6;
	}

	x = 9;
	while (x <= n)
	{
		opt.PB(x);
		x *= 9;
	}
}

int rec(int x)
{
	if (memo[x] < inf)
		return memo[x];

	int ret = inf;

	for (int y : opt)
		if (x >= y)
			chmin(ret, rec(x - y) + 1);

	return memo[x] = ret;
}

Measured memory_bytes: 5376
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define sc(x) scanf("%d",&x);
int main(){
    int n,x; sc(n)
    map<int, int> mp;
    for (int i = 0; i < n; i++){
        sc(x)
        ++mp[x];
    }
    int ans = 0, tmp;
    for (const auto &a : mp){
        tmp = a.second;
        if (mp.find(a.first - 1) != mp.end()) tmp += mp[a.first - 1];
        if (mp.find(a.first + 1) != mp.end()) tmp += mp[a.first + 1];
        ans = max(ans, tmp);
    }
    cout << ans << endl;
    return 0;
}

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

int f(int n) {
  int j, k;
  for (j = 0; j <= n / 4 + 1; j++) {
    for (k = 0; k <= n / 7 + 1; k++) {
      if (j * 4 + k * 7 == n) {
        return 1;
      }
    }
  }
  return 0;
}

int main() {
  int n, i, j;
  cin >> n;
  if (f(n)) {
    cout << "Yes"
         << "\n";
  } else {
    cout << "No"
         << "\n";
  }
  return 0;
}

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

#define rep(i,n) for(int i=0; i<n; i++)
#define rep1(i,n) for(int i=1; i<n+1; i++)
#define repr(i,n) for(int i=n-1; i>=0; i--)
typedef long long ll;

using namespace std;
const int V = 100005;
int INF = 1000000000;


int main(){
  int m,k;
  cin >> m >> k;
  int n = pow(2,m);
  if (m == 1 && k == 1){
    cout << -1 << endl;
    return 0;
  }
  if (k > n-1) {
    cout << -1 << endl;
    return 0;
  }
  if (k == 0){
    rep(i,n){
    cout << i << ' ' << i;
    if (i!=n-1) cout << ' ';
    }
    cout << endl;
    return 0;
  }

  rep(i,n){
    if(i == k) continue;
    cout << i << ' ';
  }
  cout << k << ' ';
  repr(i,n){
    if(i == k) continue;
    cout << i << ' ';
  }
  cout << k << endl;

  return 0;

}


Measured memory_bytes: 1792
n,ma,mb=map(int,input().split())
abc=[list(map(int,input().split())) for i in range(n)]
dp=[[[10**9]*401 for i in range(401)] for j in range(n+1)]
dp[0][0][0]=0
for i in range(1,n+1):
  for j in range(401):
    for k in range(401):
      if j-abc[i-1][0]>=0 and k-abc[i-1][1]>=0:
        dp[i][j][k]=min(dp[i-1][j][k],dp[i-1][j-abc[i-1][0]][k-abc[i-1][1]]+abc[i-1][2])
      else:
        dp[i][j][k]=dp[i-1][j][k]
ans=10**18
for j in range(1,401):
  for k in range(1,401):
    if dp[n][j][k]<10**9 and k*ma==j*mb:
      ans=min(ans,dp[n][j][k])
if ans==10**18:
  print(-1)
else: 
  print(ans)

Measured memory_bytes: 97500
#include <stdio.h>

int main(void) {
  int N, i, d[105], a[105], X;
  X=0;
  scanf("%d", &N);
  for (i=1; i<=100; i++) {
    a[i]=0;
  }
  for (i=1; i<=N; i++) {
    scanf("%d", &d[i]);
    a[d[i]]=1;
  }
  for (i=1; i<=100; i++) {
    if(a[i]==1) X++;
  }
  printf("%d", X);
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
typedef long long ll;
using namespace std;
int main()
{
  string s;
  cin >> s;
  bool N = false, W = false, S = false, E = false;
  rep(i, s.size())
  {
    switch (s.at(i))
    {
    case 'N':
      N = true;
      break;
    case 'W':
      W = true;
      break;
    case 'S':
      S = true;
      break;
    case 'E':
      E = true;
      break;
    default:
      break;
    }
  }
 // cout << N << S << " " << W << E << endl;
 // cout << (N ^ S) << " " << (W ^ E) << endl;
  if ((N ^ S) || (W ^ E))
  {
    cout << "No" << endl;
  }
  else
  {
    cout << "Yes" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
#define INF 1e18

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef vector < pair<int, int> > vii;
typedef long double ld;
typedef tree<pair<int,int>, null_type, less<pair<int,int> >, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

map <ii, vector<pair<ii, ll> > > adjList;
set <int> color[111111];
map <ii, ll> dist;
priority_queue <pair<ll,ii>, vector<pair<ll,ii> >, greater<pair<ll,ii> > > pq;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n, m;
	cin >> n >> m;
	ll p, q, c;
	for(int i = 0; i < m; i++){
		cin >> p >> q >> c;
		adjList[mp(p,c)].pb(mp(mp(p,0),1));
		adjList[mp(q,c)].pb(mp(mp(q,0),1));
		adjList[mp(p,0)].pb(mp(mp(p,c),0));
		adjList[mp(q,0)].pb(mp(mp(q,c),0));
		adjList[mp(p,c)].pb(mp(mp(q,c),0));
		adjList[mp(q,c)].pb(mp(mp(p,c),0));
	}
	for(int i = 1; i <= n; i++){
		dist[mp(i,0)]=INF;
	}
	for(auto it: adjList){
		dist[it.fi]=INF;
	}
	dist[mp(1,0)]=0;
	pq.push(mp(0,mp(1,0)));
	while(!pq.empty()){
		ii x = pq.top().se;
		ll d = pq.top().fi;
		pq.pop();
		for(int i = 0; i < adjList[x].size(); i++){
			if(dist[adjList[x][i].fi]>adjList[x][i].se+d){
				dist[adjList[x][i].fi]=adjList[x][i].se+d;
				pq.push(mp(adjList[x][i].se+d,adjList[x][i].fi));
			}
		}
	}
	if(dist[mp(n,0)]>=INF){
		cout<<-1;
	}
	else{
		cout<<dist[mp(n,0)];
	}
	return 0;
}
	 


Measured memory_bytes: 119432
# def max_comn_div(n, m):
#     """give max common divisor"""
#     if n > m:
#         a, b = n, m
#     else:
#         a, b = m, n
#     while b != 0:
#         a, b = b, a % b
#     return a


# a = int(input())
# b = int(input())
# print(max_comn_div(a, b))

# def euc(a, b):
#      if a % b == 0:
#          return b
#      else:
#          return euc(b, a % b)


def euc(a, b):
    return b if a % b == 0 else euc(b, a % b)


def div(n):
    """give divisors"""
    divisors = [1]
    for i in range(2, int(n**0.5)+1):
        while n % i == 0:
            divisors.append(i)
            n /= i
    if n != 1:
        divisors.append(int(n))
    return set(divisors)


a, b = map(int, input().split())
# print(euc(a, b))
c = div(euc(a, b))
# print(c)
print(len(c))


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

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

int main(){
    ll a,b;
    REP(i,10000){
        cin >> a>>b;
        if(a==0&&b==0)break;
        if(a>b)swap(a,b);
        cout << a << " " << b <<endl;
    }
    return 0;
}


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

#define rep(i, n)  for (int i = 0; i < (n) ; ++i)
#define mod 1000000007

using namespace std;
using ll=long long;
const ll INF = 100000000;

int main() {
    ll n, m, x;
    ll c[12];
    ll a[12][12];
    ll res = INF;
    cin >> n >> m >> x;
    for (int i = 0; i < n; ++i) {
        cin >> c[i];
        for (int j = 0; j < m; ++j) {
            cin >> a[i][j];
        }
    }


    rep(s, 1 << n) {
        ll sum = 0;
        ll u[12] = {};
        rep(i, n) {
            if (s >> i & 1) {
                sum += c[i];
                rep(j, m) {
                    u[j] += a[i][j];
                }
            }
        }
        bool ok = true;
        rep(j, m) {
            if (u[j] < x) ok = false;
        }
        if (ok) {
            res = min(res, sum);
        }
    }
    if (res == INF) {
        cout << -1;
    } else {
        cout << res;
    }
    return 0;
}

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

int main() {
double a,b;
cin >> a >> b;
for(double i=0;i<1001;i++){
    if((floor(i*0.1)==b)&&(floor(i*0.08)==a)){cout << i;
    return 0;}
}
cout << "-1";
}


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

public class Main 
{

	public static void main(String[] args) 
	{
		Scanner scan = new Scanner(System.in);
		
		while(true)
		{
			int ruleNum = scan.nextInt();
			int packNum = scan.nextInt();
			ArrayList<Rule> rules = new ArrayList<Rule>();
//			ArrayList<Rule> permits = new ArrayList<Rule>();
//			ArrayList<Rule> denies = new ArrayList<Rule>();
			ArrayList<String> okpacks = new ArrayList<String>();
			
			if(ruleNum == 0 && packNum == 0)
			{
//				System.out.println("..... (terminated because of the limitation)");
				break;
			}
			
			for(int i = 0; i < ruleNum; i++)
			{
				String type = scan.next();
				if(type.equals("permit"))
				{
					rules.add(new Rule(scan.next(), scan.next(), 1));
				}
				
				if(type.equals("deny"))
				{
					rules.add(new Rule(scan.next(), scan.next(), 0));
				}
			}
			
			for(int i = 0; i < packNum; i++)
			{
				String ip1 = scan.next();
				String ip2 = scan.next();
				String content = scan.next();
				
				int status = 0;
				
				for(int r = 0; r < rules.size(); r++)
				{
					Rule rul = rules.get(r);
					
					if(rul.ip1matches(ip1) && rul.ip2matches(ip2))
					{
						//affected
						status = rul.type;
					}
				}
				
				if(status == 1)
				{
					okpacks.add(ip1 + " " + ip2 + " " + content);
				}
			}
			
			//print all okpacks
			System.out.println(okpacks.size());
			for(String pack : okpacks)
			{
				System.out.println(pack);
			}
		}
	}
	
	static class Rule
	{
		String ip1 = "";
		String ip2 = "";
		int type;
		
		public Rule(String ip1, String ip2, int type)
		{
			this.ip1 = ip1;
			this.ip2 = ip2;
			this.type = type;
		}
		
		boolean ip1matches(String enter)
		{
			for(int i = 0; i < ip1.length(); i++)
			{
				String curlet1 = ip1.substring(i, i+1);
				String curlet2 = enter.substring(i, i+1);
				
				if(!curlet1.equals(curlet2) && !curlet1.equals("?"))
				{
					return false;
				}
			}
			
			return true;
		}
		
		boolean ip2matches(String enter)
		{
			for(int i = 0; i < ip2.length(); i++)
			{
				String curlet1 = ip2.substring(i, i+1);
				String curlet2 = enter.substring(i, i+1);
				
				if(!curlet1.equals(curlet2) && !curlet1.equals("?"))
				{
					return false;
				}
			}
			
			return true;
		}
	}
}



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

int main()
{
	int n;
	cin >> n;
	vector<int> a(n);
	int b[n];
	long long a_sum = 0, b_sum = 0;
	for(int i = 0; i < n; i++){
		cin >> a[i];
		a_sum += a[i];
	}
	for(int i = 0; i < n; i++){
		cin >> b[i];
		b_sum += b[i];
	}

	if(a_sum < b_sum){
		cout << "-1\n";
		return 0;
	}

	int ans = 0;
	long long pointNeeded = 0;
	for(int i = 0; i < n; i++){
		if(a[i] < b[i]){
			ans++;
			pointNeeded += b[i] - a[i];
		}
	}

	for(int i = 0; i < n; i++)
		a[i] -= b[i];
	
	sort(a.begin(), a.end());

	
	for(int i = a.size() - 1; pointNeeded > 0; i--){
		pointNeeded -= a[i];
		ans++;
	}

	cout << ans << "\n";

	return 0;
}


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

using namespace std;


//repetition
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define euc_dis(x, y) sqrt(x*x + y*y)

#define MOD 1e9+7
#define sp ' '


using ll = long long;


ll mod(ll a, ll b){return (a%b+b)%b;}
ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void Judge(bool b){b?Yes():No();}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void JUDGE(bool b){b?YES():NO();}
ll powMod(ll b, ll e, ll m){ll r=1;while(e>0){if(e&1)r=(r%m)*(b%m)%m;b=(b%m)*(b%m)%m;e>>=1;}return r;}
double distance(ll x1, ll y1, ll x2, ll y2){return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));}

template<typename T>
void ppp(T n){cout << n << endl;}

int main(){

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

    int n;
    ll c, k;
    cin >> n >> c >> k;

    vector<ll>t(n);
    rep(i, n){
        cin >> t[i];
    }

    sort(t.begin(), t.end());
    ll ans = 1LL;
    int aboard = 1;
    int currentTime = t[0];
    for(int i = 1; i < n; ++i){
        if(aboard >= c or t[i] - currentTime > k) {
            aboard = 1;
            currentTime = t[i];
            ans++;
        }
        else{
            aboard++;
        }

    }

    ppp(ans);
    return 0;
}


Measured memory_bytes: 1024
#97b
X = int(input())

#X <= 1000より最大は10^3
#maxは31^2
#minは2^9
ans = 1

for b in range(1,32):
    for p in range(2,9):
        if b**p > ans and b**p <= X:
            ans = b**p
            
print(ans)

Measured memory_bytes: 2940
import java.util.*;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int h = n/3600;
        int m = (n%3600)/60;
        int s = (n%3600)%60;
        System.out.printf("%d:%d:%d\n", h, m, s);

    }
}



Measured memory_bytes: 26428
require 'pp'
$DEBUG ? define_method(:dpp){|e|pp e} : define_method(:dpp){|e|}

# [a, b].min が遅いので
def min(a, b)
  return a < b ? a : b
end

# [a, b].max が遅いので
def max(a, b)
  return a > b ? a : b
end

# Nと空白区切の入力値を数値の配列で返却する
def gets_n_and_i_list()
  return gets.chomp.to_i, gets.chomp.split(" ").map(&:to_i).sort
end
N, L = gets_n_and_i_list

ans=0
1.upto(N-1) do|i|
    a=L[i]
    k=i+1
    num=0
    i.times do|j|
        b=L[j]
        while k<N
            if L[k]<a+b
                num+=1
            else
                break
            end
            k+=1
        end
        ans+=num
    end
end
puts ans


Measured memory_bytes: 2172
// #pragma GCC target ("avx2")
// #pragma GCC optimization ("O3")
// #pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>
using namespace std;
#define FastRead ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
#define ll int
#define cps CLOCKS_PER_SEC
#define bits_count __builtin_popcountll
#define endl '\n'
#define double long double
#define ld double
#define FOR(i,a,n) for (ll i=(a);i<=(n);++i)
#define RFOR(i,a,n) for (ll i=(n);i>=(a);--i)
#define ZERO(a) memset((a),0,sizeof((a)))
#define MINUS(a) memset((a),-1,sizeof((a)))
#define f first
#define s second
#define pb push_back
#define mk make_pair
#define all(g) g.begin(),g.end()
#define sz(x) (ll)x.size()
#define pr pair<int,int>
int fastMax(int x, int y) { return (((y-x)>>(32-1))&(x^y))^y; }
int fastMin(int x, int y) { return (((y-x)>>(32-1))&(x^y))^x; }
 
// #include <ext/pb_ds/assoc_container.hpp> // Common file
// #include <ext/pb_ds/tree_policy.hpp>     // Including tree_order_statistics_node_updat
// using namespace __gnu_pbds;
// typedef tree<ll, null_type, less_equal<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
// const int RANDOM = chrono::high_resolution_clock::now().time_since_epoch().count();
// struct chash { int operator()(int x) const { return x ^ RANDOM; }};
// cc_hash_table<int, int, hash<int>> cnt;

const int MAXN = 2e5 + 10;
vector<int> graph[MAXN];
int c[MAXN];
int cnt[MAXN],subsum[MAXN];

void dfs(int u,int p){
    subsum[u] = 1;
    for(int v:graph[u]){
        if(v == p) continue;
        dfs(v,u);
        subsum[u] += subsum[v];
    }
}

int soln[MAXN];

void dfs_solve(int u,int p){
    int n = cnt[c[u]];
    int t_add = subsum[u]*(n-subsum[u]+1),sum = 0;

    for(int v:graph[u]){
        if(v == p) continue;
        t_add += sum*subsum[v];
        sum += subsum[v];
    }

    soln[c[u]] += t_add;

    for(int v:graph[u]){
        if(v == p) continue;
        cnt[c[u]] = subsum[v];
        dfs_solve(v,u); 
    }    

    cnt[c[u]] = n - subsum[u];
}

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

    FOR(i,1,n) {cin>>c[i]; cnt[i] = n;}
    FOR(i,1,n-1){
        int u,v; cin>>u>>v;
        graph[u].push_back(v);
        graph[v].push_back(u);
    }

    dfs(1,0);
    dfs_solve(1,0);

    FOR(i,1,n) cout<<soln[i]<<endl;
}
 
signed main(){
 
    FastRead; 

#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    int t = 1; 
    // cin>>t;
    FOR(i,1,t){
        // cout<<"Case #"<<i<<": ";
        solve();
    }
}

Measured memory_bytes: 36360
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <sstream>
using namespace std;

string str;
string::iterator it;

int s2i(string s){
  stringstream ss(s);
  int x;
  ss >> x;
  return x/2 + 1;
}

int calc(){
  int ans = 0;
  ++it;
  if(*it == '['){
    vector<int> v;
    while(*it == '['){
      v.push_back(calc());
    }
    sort(v.begin(),v.end());
    for(int i = 0 ; i < v.size()/2+1 ; i++){
      ans += v[i];
    }
  }
  else if(*it != ']'){
    string ss = "";
    while('0' <= *it && *it <= '9'){
      ss += *it;
      ++it;
    }
    ans = s2i(ss);
  }
  ++it;
  
  return ans;
}

int main(){
  int n;

  cin >> n;
  while(n--){
    cin >> str;
    it = str.begin();
    cout << calc() << endl;
  }

  return 0;
}

Measured memory_bytes: 1300
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  double ans;
  cin>>n;
  vector<double> a(n);
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  for(int i=0;i<n;i++){
    ans+=1.0/a[i];
  }
  cout<<1.0/ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint     = long long;
const lint inf = 1LL << 60;
const lint mod = 1000000007;

template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<vector<int>> edges(n);
    for (int i = 0; i < n - 1; ++i) {
        int u, v;
        cin >> u >> v;
        u--, v--;
        edges[u].emplace_back(v);
        edges[v].emplace_back(u);
    }
    pair<int, lint> ret = {100000, 1e16};
    for (int i = 0; i < n; ++i) {
        vector<int> dist(n, -1);
        vector<lint> deg(n, 0);
        vector<lint> maxdeg(n + 1, 0);
        int col = 0;
        dist[i] = 1;
        vector<int> que;
        que.emplace_back(i);
        for (int j = 0; j < (int)que.size(); ++j) {
            for (auto &v : edges[que[j]]) {
                if (dist[v] != -1)
                    continue;
                dist[v] = dist[que[j]] + 1;
                deg[que[j]]++;
                que.emplace_back(v);
            }
            chmax(maxdeg[dist[que[j]]], deg[que[j]]);
            chmax(col, dist[que[j]]);
        }
        lint leaf = 1;
        for (int i = 0; i < n + 1; ++i) {
            if (maxdeg[i] != 0)
                leaf *= maxdeg[i];
        }
        chmin(ret, {col, leaf});
    }
    for (int i = 0; i < n; ++i) {
        for (auto &v : edges[i]) {
            vector<int> dist(n, -1);
            vector<lint> deg(n, 0);
            vector<lint> maxdeg(n + 1, 0);
            int col = 0;
            dist[i] = 1;
            dist[v] = 1;
            vector<int> que;
            que.emplace_back(i);
            que.emplace_back(v);
            for (int j = 0; j < (int)que.size(); ++j) {
                for (auto &w : edges[que[j]]) {
                    if (dist[w] != -1)
                        continue;
                    dist[w] = dist[que[j]] + 1;
                    deg[que[j]]++;
                    que.emplace_back(w);
                }
                chmax(maxdeg[dist[que[j]]], deg[que[j]]);
                chmax(col, dist[que[j]]);
            }
            lint leaf = 1;
            for (int i = 1; i < n + 1; ++i) {
                if (i == 1)
                    leaf *= max(1LL, maxdeg[i]) * 2LL;
                else if (maxdeg[i] != 0)
                    leaf *= maxdeg[i];
            }
            chmin(ret, {col, leaf});
        }
    }
    cout << ret.first << " " << ret.second << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define loop(n, i) for(int i=0;i<n;i++)

using namespace std;
typedef long long ll;

int main()
{
    int n; cin >> n;
    ll ans = 0;
    vector<vector<int>> m(n, vector<int>(n));
    loop (n, i) loop (n, j) cin >> m[i][j];
    loop (n, i) loop (n, j) ans += min(m[i][j], m[j][i]);
    cout << ans / 2 << endl;
    return 0;
}

Measured memory_bytes: 3192
import sys
import copy
import string
import  math
from _bisect import *
from collections import *
from operator import itemgetter
from math import factorial
"""
from fractions import gcd
def lcm(x, y):
    return (x * y) // gcd(x, y)
"""
stdin = sys.stdin
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline()

a, b = input().split()
print('H' if a == b else 'D')


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

int main(){
	int n;
	string s;
	cin >> n >> s;
	int pf = 0, nc = 0;
	for(int i = 0; i < n; i++){
		if(s[i] == '(') nc++;
		else{
			if(--nc < 0){
				nc = 0;
				pf++;
			}
		}
	}
	for(int i = 0; i < pf; i++) cout << '(';
	cout << s;
	for(int i = 0; i < nc; i++) cout << ')';
	cout << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vel;
typedef vector<int> vei;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> ve_vel;
typedef vector<vector<int>> ve_vei;
typedef vector<vector<char>> ve_vec;
typedef vector<vector<bool>> ve_veb;
typedef vector<vector<string>> ve_ves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pub push_back
#define puf push_front
#define pob pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

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

    ll N,M; cin >> N >> M;


    if(N == 1) {
        if(M == 1) {cout << 1 << endl; return 0;}
        if(M == 2) {cout << 0 << endl; return 0;}
        if(M >= 3) {cout << M - 2 << endl; return 0;}
    }
    else if(N == 2) {cout << 0 << endl; return 0;}
    else {
        if(M ==1) {cout << N - 2 << endl; return 0;}
        if(M == 2) {cout << 0 << endl; return 0;}
        if(M >= 3){
            cout << (M - 2) * (N  - 2) << endl; 
            return 0;
        }
    }

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define sz(a) int(a.size())
#define clr(a) memset(a,0,sizeof(a))
#define all(a) a.begin(),a.end()
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
const int inf=1e9;
const ll Inf=1e18;
const int mod=0;
int gi() {
    int x=0,o=1;char ch=getchar();
    while((ch<'0'||ch>'9')&&ch!='-') ch=getchar();
    if(ch=='-') o=-1,ch=getchar();
    while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
    return x*o;
}
template<typename T> bool chkmax(T &a,T b) { return a<b?a=b,1:0; };
template<typename T> bool chkmin(T &a,T b) { return a>b?a=b,1:0; };
int add(int a,int b) { return a+b>=mod?a+b-mod:a+b; }
int sub(int a,int b) { return a-b<0?a-b+mod:a-b; }
void inc(int &a,int b) { a=(a+b>=mod?a+b-mod:a+b); }
void dec(int &a,int b) { a=(a-b<0?a-b+mod:a-b); }
char s[200010];
int n;
int main() {
    scanf("%s",s+1),n=strlen(s+1);
    int cnt=0;
    ll ans=0;
    for(int i=1;i<=n;i++) {
        if(s[i]=='B') ++cnt;
        else ans+=cnt;
    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define N 100005

using namespace std;

int n,l[N],x,tmp;
int ans = 1;

int main(){
	cin >> n >> x;
	for(int i = 1; i <= n; ++i){
		int a;
		cin >> a;
		tmp += a;
		if(tmp <= x) ++ans;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int gcd(int a,int b){
    int t;
    while(a&&b){
        t=a%b;
        a=b;
        b=t;
    }
    return (a+b);
}
int main(){
  int n ;
  cin >> n ;
  int ret=0;
  for(int i=1;i<=n;i++)
      for(int j=1;j<=n;j++)
          for(int k=1;k<=n;k++)
              ret += gcd(k,gcd(i,j));

          cout << ret << endl ;
}

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

typedef long long ll;
const int INF = 1e9;
int main(){
	// ios::sync_with_stdio(false);
	// cin.tie(NULL);
	
	int a,b,c;
	cin>>a>>b>>c;
	printf("%d %d %d\n", c, a, b);
	return 0;
}

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

using namespace std;


#include <math.h> 


int main() {
	

	int64_t max = 1000000000000001;
						


	vector<uint64_t> check;
	int64_t  j = 1;
	int64_t  k = 1;
	while (j < max) {
		
		check.push_back(j);
		j += pow(26, k);
		
		k++;
		
	}
	check.push_back(9223372036854775807);
	
	int64_t  N;
	cin >> N;
	


	int64_t  i = 0;
	
	while (N >= check[i]) {
	
		i++;
	}
	
	vector<uint64_t> amari(i,0);
	int64_t  index = N - check[i - 1];
	for (int64_t  k = 0; k < i; k++) {
		amari[k] = index % 26;
		if (index / 26 == 0)break;
		index = index/26;
		
	}
	
	for (int64_t  k = 0; k < i; k++) {
		char c;
		c = 97;
		
		c += amari[i-1-k];
	
		cout << c;
	}
	
}

Measured memory_bytes: 4052
import sys
for line in sys.stdin:
    H, W = map(int, line.split())
    if H == W == 0:
        break
    for i in range(H):
        for j in range(W):
            if i == 0 or i == H - 1\
            or j == 0 or j == W - 1:
                print('#', end='')
            else:
                print('.', end='')
        print()
    print()

Measured memory_bytes: 8984
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
typedef long long ll;
const int mod=1e9+7;
struct mat{
	ll a[3][3];
	friend mat operator *(mat a,mat b){
		mat c;memset(c.a,0,sizeof(c.a));
		for(int i=1;i<=2;i++){
			for(int p=1;p<=2;p++){
				for(int j=1;j<=2;j++) c.a[i][p]=(c.a[i][p]+a.a[i][j]*b.a[j][p])%mod; 
			}
		}
		return c;
	}
}dan;
char a[1005][1005];
int n,m,sum;
ll K;
ll quick_pow(ll a,ll b){
	ll ans=1;
	for(;b;b>>=1,a=a*a%mod)
		if(b&1) ans=ans*a%mod;
	return ans;
}
mat quick_pow(mat a,ll b){
	mat ans;memset(ans.a,0,sizeof(ans.a));
	for(int i=1;i<=2;i++) ans.a[i][i]=1;
	for(;b;b>>=1,a=a*a)
		if(b&1) ans=ans*a;
	return ans;
}
int main(){
	scanf("%d%d%lld",&n,&m,&K);
	if(K==1) return puts("1"),0;
	for(int i=1;i<=n;i++){
		scanf("%s",a[i]+1);
		for(int p=1;p<=m;p++) if(a[i][p]=='#') sum++;
	}
	int type=0,tot=0;
	for(int i=1;i<=n;i++){
		if(a[i][1]=='#'&&a[i][m]=='#') type|=1,tot++;
	}
	for(int i=1;i<=m;i++){
		if(a[1][i]=='#'&&a[n][i]=='#') type|=2,tot++;
	}
	if(type==0) return printf("%lld",quick_pow(sum,K-1)),0;
	if(type==3) return puts("1"),0;
	int G=0;
	for(int i=1;i<=n;i++){
		for(int p=1;p<=m;p++){
			if(a[i][p]!='#') continue;
			if(type==1&&a[i][p+1]=='#') G++;
			if(type==2&&a[i+1][p]=='#') G++;
		}
	}
	dan.a[1][1]=sum;dan.a[1][2]=-G;
	dan.a[2][1]=0;dan.a[2][2]=tot;
	mat ans=quick_pow(dan,K-1);
	ll lst=ans.a[1][1]+ans.a[1][2];
	lst=(lst%mod+mod)%mod;
	printf("%lld",lst);
	return 0;
}

Measured memory_bytes: 1280
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

int main()
{
    vector<int> x(5);
    for (int i = 0; i < 5; ++i) {
        cin >> x[i];
    }

    int min_ = 9999999;
    do {
        int count = 0;
        for (int j = 0; j < 5; ++j) {
            if (j != 4) {
                const auto a = x[j] % 10 != 0 ? 10 - x[j] % 10 : 0;
                count += x[j] + a;
            }
            else {
                count += x[j];
            }
        }
        min_ = min(min_, count);
    } while (next_permutation(begin(x), end(x)));
    cout << min_ << endl;
}


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

int find(int X,vector<int> &U){
  if(U.at(X)<0){
    return X;
  }
  return U.at(X)=find(U.at(X),U);
}

void unite(int X,int Y,vector<int> &U){
  X=find(X,U);
  Y=find(Y,U);
  if(X==Y){
    return;
  }
  U.at(Y)+=U.at(X);
  U.at(X)=Y;
  return;
}

int main(){
  int N,M;
  cin >> N >> M;
  vector<int> U(N,-1);
  for(int i=0;i<M;i++){
    int A,B;
    cin >> A >> B;
    A--;
    B--;
    unite(A,B,U);
  }
  sort(U.begin(),U.end());
  cout << (-1)*U.at(0) << endl;
}
    
  

Measured memory_bytes: 4016
S = int(input())
mod = 10**9+7

table = [1]*(S+1)
table[0] = 0
table[1] = 0
if S >= 2:
    table[2] = 0

for s in range(6,S+1):
    for i in range(3,s-2):
        table[s] += table[i]
        table[s] %= mod
        
print(table[S]%mod)

Measured memory_bytes: 64680
fun main(args: Array<String>) {
    val N = readLine()!!.toInt()
    val F = Array(N) { readLine()!!.split(" ").map{it.toInt()}}
    val P = Array(N) { readLine()!!.split(" ").map{it.toLong()}}

    var res = -1e16.toLong()

    for (s in 1 until (1 shl 10)) {
        var t = 0L
        val u = Array(10) { (s shr it) and 1 }

        for (i in F.indices) {
            val c = F[i].indices.count { F[i][it] == 1 && F[i][it] == u[it] }
            t += P[i][c]
        }
        res = Math.max(res, t)
    }

    println(res)
}


Measured memory_bytes: 41456
// Problem : B - Trick or Treat
// Contest : AtCoder - AtCoder Beginner Contest 166
// URL : https://atcoder.jp/contests/abc166/tasks/abc166_b
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<string, int> psi;
typedef pair<string, string> pss;
#define pb push_back
#define PI acos(-1.0)
#define EPS 1e-4
#define mp make_pair
#define all(x) x.begin(), x.end()
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define fout(S,x)            cout<<fixed<<setprecision(x)<<(S)<<endl
#define present(c,x) ((c).find(x) != (c).end())
#define T() ll t;cin>>t;while(t--)
#define mem(input,b) memset(input,b,sizeof(input))
#define ff first
#define ss second
#define fread(input) freopen("input","r",stdin)
#define fwrite(b) freopen("b","w",stdout)
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#define FOREACH(i,c) for (__typeof ((c).begin()) i = (c).begin() ; i != (c).end() ; i++)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
int main(){
    fastio;
    int n,k;
    cin>>n>>k;
    set<int>st;
    while(k--){
    	int d;
    	cin>>d;
    	while(d--){
    		int x;
    		cin>>x;
    		st.insert(x);
    	}
    }
    cout<<n-st.size()<<endl;
    return 0;
}    


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

int main()
{
    string s;
    cin >> s;
    int cnt = 0;
    for (auto c : s) {
        if (c == '+') {
            cnt++;
        } else {
            cnt--;
        }
    }
    cout << cnt << endl;
    return 0;
}

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

const int MAXN = 1e3;
int a[MAXN];

int main(void){
	int n;
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> a[i];
	}
	sort(a, a + n);
	cout << a[n-1] - a[0] << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
#define fi first
#define se second
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define pf push_front
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define ge(a, b) get<(b)>((a))
#define SZ(x) (x).size()
#define ft front()
#define bk back()
#define endl '\n'
#define FOR(a, b, c) for (auto(a) = (b); (a) < (c); ++(a))
#define ROF(a, b, c) for (auto(a) = (b); (a) > (c); --(a))
#define F0R(a, b) FOR ((a), 0, (b))
#define R0F(a, b) ROF ((a), (b), -1)
#define CEIL(a, b) ((a) + (b)-1) / (b)
#define SET(a, b) memset((a), (b), sizeof(a))
#ifndef DEBUG
#define DEBUG 0
#endif
#define dout \
    if (DEBUG) std::cerr
const int xd[4] = {0, 1, 0, -1}, yd[4] = {1, 0, -1, 0};
template <typename t>
bool ckmin(t& a, const t& b) {
    return a > b ? a = b, true : false;
}
template <typename t>
bool ckmax(t& a, const t& b) {
    return a < b ? a = b, true : false;
}

int main() {
    ios_base::sync_with_stdio(0);
    cout.tie(0);

    int n;
    cin >> n;
    bool ok = false;
    while (n) {
        if (n % 10 == 7) ok = true;
        n /= 10;
    }
    cout << (ok ? "Yes" : "No") << endl;

    return 0;
}


Measured memory_bytes: 3612
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>

using namespace std;

int main()
{
  int N;
  cin >> N;
  vector< pair<int,int> >x(N);

  for(int i=0;i<N;i++)
    {
      int a,b;
      cin >> a >> b;
      x[i] = make_pair(b, a);
    }
  
  sort(x.begin(), x.end());

  int t=x[N-1].first;

  for(int i=N-1;i>-1;i--)
    {
      //      cout << i << " " << t << " " << x[i].first << " " << x[i].second << endl;
      if(x[i].first<=t)
	  t = x[i].first;
      t -= x[i].second;
    }
  if(t>=0)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
    
}


Measured memory_bytes: 1792
use std::io;
use std::cmp;

fn main() {
    let (x, t) = {
        let i = read::<isize>();
        (i[0], i[1])
    };

    println!("{}", cmp::max(0, x - t));
}


#[allow(dead_code)]
fn read<T>() -> Vec<T>
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.split_whitespace()
        .map(|s| s.trim().parse().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_one<T>() -> T
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().unwrap()
}

Measured memory_bytes: 4352