akhauriyash/Code-Regression huggingface dataset:
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10**8)

import heapq
from collections import defaultdict
INF = float("inf")


class Graph(object):
    def __init__(self, N):
        self.N = N
        self.E = defaultdict(list)

    def add_edge(self, s, t, w=1):
        self.E[s].append((t, w))
        self.E[t].append((s, w))


def shortestPath(g: Graph, s: int):
    # 返り値 (dist, prev)
    # dist: 始点からの距離が格納されたリスト
    # prev: 始点から最短経路で移動する場合、各頂点に至る前の頂点のリスト
    dist = [INF]*g.N
    dist[s] = 0

    prev = [None]*g.N
    Q = []
    heapq.heappush(Q, (dist[s], s))

    while len(Q) > 0:
        _, u = heapq.heappop(Q)
        for v, w in g.E[u]:
            if dist[v] > dist[u] + w:
                dist[v] = dist[u] + w
                prev[v] = u
                heapq.heappush(Q, (dist[v], v))
    return dist, prev


def solve(N: int, X: int, Y: int):

    g = Graph(N)
    for i in range(1, N):
        g.add_edge(i-1, i)
    g.add_edge(X-1, Y-1)

    ans = [0]*N
    for i in range(N):
        dist, prev = shortestPath(g, i)
        for j, d in enumerate(dist):
            if i < j:
                ans[d] += 1
    print(*ans[1:], sep="\n")
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    X = int(next(tokens))  # type: int
    Y = int(next(tokens))  # type: int
    solve(N, X, Y)


if __name__ == '__main__':
    main()


Measured memory_bytes: 120168
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=100010;
const ll mod=1e9+7;


int main(){
  string s;
  cin >> s;
  int n = s.size();
  int ans = n;
  REP(i,1,n){
    if(s[i]!=s[i-1]){
      ans = min(ans, max(i,n-i));
    }
  }
  cout << ans << endl;
  return 0;
}

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

int main() {
  int a, b;

  cin >> a >> b;
  
  if ( (a * b) % 2 == 0 ) {
    
    cout << "Even" << endl;   
  }
  else {
    cout << "Odd" << endl;
  }
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,b,a) for(int i=b;i>=a;i--)
#define fori(a) for(auto i : a )
#define all(a) begin(a), end(a)
#define set(a,b) memset(a,b,sizeof(a))
#define sz(a) a.size()
#define pi 3.14159
#define ll long long
#define ull unsigned long long
#define pb push_back
#define PF push_front //deque
#define mp make_pair
#define pq priority_queue
#define mod 1000000007
#define f first
#define s second
#define pii pair< int, int >
#define vi vector<int>
#define vpii vector<pii>
#define debug(v) for(auto i:v) cout<<i<<" ";
#define tc int t; cin >> t; while(t--)

using namespace std;
string repeat(string s, int n) {
    string s1 = "";
    for (int i=0; i<n;i++)
        s1+=s;
    return s1;
}
string getString(char x) {
    string s(1, x);
    return s;
}

void optimizeIO(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}
int gcd(int a, int b){
    if (a == 0)  return b;
    return gcd(b % a, a);
}
void  solve(){
  string s,t;
  cin>>s>>t;
  int n=s.length();
  int ans=0;
  rep(i,0,n) if(s[i]!=t[i]) ans++;
  cout<<ans<<endl;
}
int main(){
    optimizeIO();
    // tc
    { solve();
    }
}


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

using namespace std;

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

    int loop = X/100;

    for(int i=0; i<=loop; ++i){
        if(100*i > X){
            break;
        }
        for(int j=0; j<=loop; ++j){
            if(100*i + 101*j > X){
                break;
            }
            for(int k=0; k<=loop; ++k){
                if(100*i + 101*j + 102*k > X){
                    break;
                }
                for(int l=0; l<=loop; ++l){
                    if(100*i + 101*j + 102*k + 103*l > X){
                        break;
                    }
                    for(int m=0; m<=loop; ++m){
                        int sum = 100*i + 101*j + 102*k + 103*l + 104*m;
                        if(sum > X){
                            break;
                        }
                        if((X - sum)%105 == 0){
                            cout<<1<<endl;
                            return 0;
                        }
                    }
                }
            }
        }
    }
    cout<<0<<endl;

    return 0;
}









Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
int a[105];
int main() {
    int n;
    cin >> n;
    for(int i = 0; i < n; ++i) cin >> a[i];
    sort(a,a+n);

    int Min = 0x7fffffff;
    for(int i = a[0]-1; i <= a[n-1] + 1; ++i) {
        int ans = 0;
        for(int j = 0; j < n; ++j)
            ans += pow(i-a[j],2);
        if(ans < Min) Min = ans;
    }
    cout << Min << '\n';
return 0;
}

Measured memory_bytes: 3576
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    int a, b;
    cin >> a >> b;
    if (a * b % 2 == 1) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <math.h>
#include <map>
#include <list>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <string>
#include <sstream>
#include <string.h>
// #include <limits.h>

#define FOR(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define FORUL(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#define FORULE(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define FOREACH(it, X) for(__typeof((X).begin()) it = (X).begin(); it != (X).end(); it++)
#if defined(_MSC_VER) || __cplusplus > 199711L
#define AUTOVAR(newvar,v) auto newvar = (v)
#else
#define AUTOVAR(newvar,v) __typeof(newvar) r = (v)
#endif
#define PB(x) push_back(x)
#define MP(x,y) make_pair((x),(y))
#define MEMSET(m,v) memset(m,v,sizeof(m))

typedef long long				 ll;
typedef unsigned long long		ull;

#define INTMAX  99999999

#define DEBUG 1

#if DEBUG
#define DOUT cout<<"["<<__LINE__<<"]:"
#else
#define DOUT 0 && cout
#endif

using namespace std;

int N;
#define MAX_N (1000*100)
#define MAX_A (1000*1000*1000)

int A[MAX_N+2];

int main(int argc, char *argv[])
{
	ios::sync_with_stdio(false);

	cin >> N;

	int n_even = 0;

	FOR(n,N) {
		cin >> A[n];
		if(A[n]%2==1) { n_even++; }
	}
	if(n_even%2) {
		cout << "NO" << endl;
	}
	else {
		cout << "YES" << endl;
	}
	return 0;
}



Measured memory_bytes: 640
N, K = input("").split(" ")

N = int(N)
K = int(K)

prob = 0.
for i in range(1, N+1):
    if i >= K:
        prob += (N-i+1)/N
        break
    else:
        c = 0
        while i < K:
            i = i*2
            c += 1
        prob += (1./N) * (.5**c)

print("%.10f" % prob)


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

#define fs first
#define sc second
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define pb emplace_back

using pii = pair<int, int>;
using vi = vector<int>;
using lint = long long;

const int inf = 1001001001;
const lint linf = 1001001001001001001ll;
const int mod = 1e9 + 7;
const int dx[]{0, 1, 0, -1, -1, -1, 1, 1}, dy[]{1, 0, -1, 0, -1, 1, -1, 1};

template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; } return a > b; }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; } return a < b; }
template<typename T> inline void print(const T &x, string s = "\n") { cout << x << s; }
template<typename T> inline void print(const vector<T> &v, string s = " ") 
{ rep(i, v.size()) cout << v[i] << (i + 1 == v.size() ? "\n" : s); }
inline bool inside(int y, int x, int H, int W) { return 0 <= y && y < H && 0 <= x && x < W; }
inline lint in() { lint x; std::cin>>x; return x; }

int main() {
	int n = in(), x = in();
	
	if (x == 1 || x == 2 * n - 1) {
	 cout << "No" << endl;
	 return 0;
	} else {
	 cout << "Yes" << endl;
	}

	vi a(2 * n - 1);
	bool f[202020] = {false};
	
	a[n - 1] = x;
	f[x] = true;

	if (x == 2) {
		a[n - 2] = x + 1;
		a[n] = x - 1;
		a[n + 1] = x + 2;
		f[x + 1] = f[x - 1] = f[x + 2] = true;
	} else {
		a[n - 2] = x - 2;
		a[n] = x + 1;
		a[n + 1] = x - 1;
		f[x - 2] = f[x + 1] = f[x - 1] = true;
	}

	for (int i = 0, idx = 1; i < a.size(); ++i) {
		if (a[i]) continue;
		while (f[idx]) idx++;
		a[i] = idx;
		f[idx] = true;
	}

	print(a, "\n");
}


Measured memory_bytes: 2432
#include <bits/stdc++.h>
#define ll long long
#define all(x) begin(x), end(x)
#define range(x) begin(x), begin(x)
#define what(x) cout << #x << ": " << x << '\n'
#define print(x) for (auto &el: x) cout << el << ' '; cout << '\n'
using namespace std;
 
template<typename S, typename T>
ostream& operator <<(ostream &os, pair<S, T> &m) { 
    os << '[' << m.first << " " << m.second << ']'; 
    return os; 
}

#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template <typename T> using ordered_set =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; 


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

    int n, m, k;
    cin >> n >> m >> k;
    vector<ll> v1(n + 1), v2(m + 1);
    for (int i = 1; i <= n; ++i) {
        cin >> v1[i];
        v1[i] += v1[i - 1];
    }

    for (int i = 1; i <= m; ++i) {
        cin >> v2[i];
        v2[i] += v2[i - 1];
    }

    int ans = 0;
    for (int i = 0; i <= n; ++i) {
        if (v1[i] <= k) {
            ll rem = k - v1[i];
            int pos = upper_bound(all(v2), rem) - begin(v2) - 1;
            ans = max(ans, i + pos);
        }
    }

    cout << ans << endl;


    return 0;
}

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

#define rep(i, n) for (int i = 0; i < (n); i++)
#define contains(v, t) (find(v.begin(), v.end(), t) != v.end())
#define MOD 1000000007
typedef long long ll;
typedef unsigned long long ull;

int main() {
  string s;
  cin >> s;
  int pos = s.find("AC");
  if (pos != string::npos) {
    cout << "Yes";
  } else {
    cout << "No";
  }
}

Measured memory_bytes: 256
using System;
using System.IO;

class Program
{
    static void Main(string[] args) {
        var writer = new StreamWriter(Console.OpenStandardOutput()) {AutoFlush = false};
        Console.SetOut(writer);
        Console.WriteLine(Solve());
        Console.Out.Flush();
    }

    static object Solve() {
        var N = long.Parse(Console.ReadLine());
        var a = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
        Array.Sort(a);
        Array.Reverse(a);
        long sum = 0;
        for (long i = 1; i < N * 2; i += 2) {
            sum += a[i];
        }
        return sum;
    }
}

Measured memory_bytes: 55836
def main():
    n, m, x = map(int, input().split())
    c = [None for _ in range(n)]
    a = [None for _ in range(n)]
    for i in range(n):
        p = list(map(int, input().split()))
        c[i] = p[0]
        a[i] = p[1:m+1]

    ans = 10 ** 18
    for i in range(1 << n):
        mask = [False for _ in range(n)]
        p = i
        q = 0
        while p > 0:
            if p & 1:
                mask[q] = True
            p = p >> 1
            q += 1
        skill = [0 for _ in range(m)]
        cost = 0
        for j in range(n):
            if mask[j]:
                for k in range(m):
                    skill[k] += a[j][k]
                cost += c[j]
        good = True
        for j in range(m):
            if skill[j] < x:
                good = False
                break
        if good and cost < ans:
            ans = cost

    if ans == 10 ** 18:
        print(-1)
    else:
        print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 9272
import sys

input = sys.stdin.readline

def main():
    ans = 0
    n,m,c = map(int, input().split())
    b = list(map(int, input().split()))
    for _ in range(n):
        temp = 0
        a = list(map(int, input().split()))
        for j in range(m):
            temp += a[j]*b[j]
        if temp + c > 0:
            ans += 1
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define f first
#define s second
#define MOD 1000000007
#define PMOD 998244353
#define pb(x) push_back(x)
using namespace std;

typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> plii;
typedef pair<int, pii> piii;
const int INF = 1e9+10;
const ll LINF = 1LL*INF*INF;
const int MAXN = 2e5+10;
const int MAXM = 5e3+10;

priority_queue<int> pq;
vector<vector<int> > graph;
queue<int> que;

int A[MAXN];
char S[MAXN];

int main()
{
    int n,m,k,a,b,x,y,q;
    int sum = 0;
    int cnt = 0;
    int mx = 0;
    int mn = INF;
    int cur = 0, idx = -1;

    cin>>m>>k;

    if(k>=(1<<m)||(m==1&&k==1)){
        cout<<"-1\n";
        return 0;
    }

    if(!k){
        for(int i=0;i<(1<<m);i++)
            cout<<i<<" "<<i<<" ";
        return 0;
    }

    cout<<"0"<<" "<<k<<" "<<"0"<<" ";

    for(int i=1;i<(1<<m);i++)
        if(i!=k)cout<<i<<" ";

    cout<<k<<" ";

    for(int i=(1<<m)-1;i>=1;i--)
        if(i!=k)cout<<i<<" ";

    return 0;
}


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

int main()
{
  string s;
  cin >> s;
  int q;
  cin >> q;
  int rev = 1;
  string front = "", last = "";
  rep(i, q)
  {
    int t; cin >> t;
    if (t == 1)
      rev *= -1;
    else
    {
      int f;
      char c;
      cin >> f >> c;
      if (f == 1)
        if (rev == 1)
          front += c;
        else
          last += c;
      else
        if (rev == 1)
          last += c;
        else
          front += c;
    }
  }
  if (rev == 1)
  {
    reverse(front.begin(), front.end());
    cout << front << s << last << endl;
  }
  else
  {
    reverse(s.begin(), s.end());
    reverse(last.begin(), last.end());
    cout << last << s << front << endl;
  }
}

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

int main(){
  string S;
  int topping=0;
  cin >>S;
  for (int i=0;i<3;i++){
    if(S.at(i)=='o'){
      topping++;
    }
  }
  cout <<700+topping*100<<endl;
  return 0;
}


Measured memory_bytes: 256
import sys

sys.setrecursionlimit(4100000)


def inputs(num_of_input):
    ins = [input() for i in range(num_of_input)]
    return ins


def solve(inputs):
    [A, B] = string_to_int(inputs[0])

    C = A - 2 * B

    if C >= 0:
        return C
    else:
        return 0


def string_to_int(string):
    return list(map(lambda x: int(x), string.split()))


if __name__ == "__main__":
    ret = solve(inputs(1))
    print(ret)


Measured memory_bytes: 3060
R,G,B,N = map(int, input().split())

ans = int(0)
x = int(N//R)

for i in range(x+1):
    t = N-i*R
    y = int(t//G)
    for j in range(y+1) :
        s = int(t-G*j)
        if s%B==0 : ans +=1

print(ans)

Measured memory_bytes: 3060
#include <stdio.h>
#include <string.h>

int main(){
	char S[11], T[12];

	scanf("%s", S);
	scanf("%s", T);

	if(strlen(S)!=strlen(T)-1) printf("No");
	else if(strncmp(S, T, strlen(S))!=0) printf("No");
	//if(strstr(T, S) != NULL) printf("Yes");
	else printf("Yes");

	return 0;
}


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

using namespace std;
using ll = long long;

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

Measured memory_bytes: 4048
"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 main(input) {
  var lines = input.split('\n');

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

  var as = splitNum(lines[1]).slice(0, N);
  var res = as.map(function (a) {
    var res = 0; // 1 000 000 000 < 2**31

    while ((a & 1) === 0) {
      a >>= 1;
      res++;
    }

    return res;
  }).reduce(function (a, b) {
    return a + b;
  }, 0);
  console.log(res);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));

function splitNum(line) {
  return line.split(/\s+/).map(function (n) {
    return parseInt(n);
  });
}


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

const int INF = 1 << 29;

struct edge {
    int to;
    double dist;

    edge() {}
    ~edge() {}

    edge(int a, int b): to(a), dist(b) {}
};

struct status {
    int pos;
    double dist;
    int used;

    status () {}
    ~status () {}

    status(int a, double b, int c): pos(a), dist(b), used(c) {}

    bool operator < (const status& o) const {
        return dist > o.dist;
    }
};

bool eq(double a, double b) {
    return abs(a - b) < 1e-8;
}

bool solve () {
    int n, m, p, a, b;

    cin >> n >> m >> p >> a >> b;
    if (n == 0 && m == 0 && p == 0 && a == 0 && b == 0) {
        return false;
    }

    --a; --b;

    vector<int> t(n);
    vector<vector<edge>> g(m, vector<edge>(0));
    vector<vector<double>> dist(m, vector<double>(1 << n, INF));

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

    for (int j = 0; j < p; ++j) {
        int x, y, z;
        cin >> x >> y >> z;
        --x; --y;
        g[x].push_back(edge(y, z));
        g[y].push_back(edge(x, z));
    }

    dist[a][0] = 0;

    priority_queue<status> pq;

    pq.push(status(a, 0, 0));

    while (!pq.empty()) {
        status st = pq.top(); pq.pop();
        
        if (st.dist > dist[st.pos][st.used]) {
            continue;
        }

        for (int j = 0; j < n; ++j) {
            if (st.used & (1 << j)) {
                continue;
            }

            int nu = st.used | (1 << j);
            for (edge& e : g[st.pos]) {
                if (st.dist + e.dist / t[j] < dist[e.to][nu]) {
                    dist[e.to][nu] = st.dist + e.dist / t[j];
                    pq.push(status(e.to, dist[e.to][nu], nu));
                }
            }
        
        }
    }
    
    double ret = INF;

    for (int j = 0; j < (1 << n); ++j) {
        ret = min(ret, dist[b][j]);
    }

    if (eq(ret, INF)) {
        cout << "Impossible" << endl;
        return true;
    }

    printf("%.12f\n", ret);
    return true;
}

int main () {
    bool ctd;
    while(ctd = solve());
    return 0;
}

Measured memory_bytes: 3568
#include <iostream>
#include <queue>

using namespace std;

typedef long long ll;
typedef queue<ll> ql;

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

    int n, k, c;
    cin >> n >> k >> c;
    bool s[n];
    for (int i = 0; i < n; i++) {
        char t;
        cin >> t;
        s[i] = t == 'o';
    }

    int dp1[n], dp2[n];
    for (int i = 0; i < n; i++) {
        dp1[i] = s[i] ? (i - c - 1 >= 0 ? dp1[i-c-1] : 0) + 1 : i - 1 >= 0 ? dp1[i-1] : 0;
    }
    for (int i = n - 1; i >= 0; i--) {
        dp2[i] = s[i] ? (i + c + 1 < n ? dp2[i+c+1] : 0) + 1 : i + 1 < n ? dp2[i+1] : 0;
    }

    int diff[n+1];
    fill(diff, diff+n+1, 0);
    int t = max(c, 1);
    for (int i = -(t + 1); i < n; i++) {
        if ((i < 0 ? 0 : dp1[i]) + (i + t + 1 >= n ? 0 : dp2[i+t+1]) >= k) {
            diff[max(0,i+1)]++;
            diff[min(i+t+1,n)]--;
        }
    }

    for (int i = 0; i < n; i++) {
        diff[i] += i == 0 ? 0 : diff[i-1];
        if (s[i] && diff[i] == 0) {
            cout << i + 1 << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 4096
//
// Created by 海老晃行 on 2019-07-23.
//

#include <bits/stdc++.h>
#define pb push_back
#define fi first
#define se second

#define rep(ii, n) for((ii) = 0; (ii) < (n); (ii)++)
#define all(x) (x).begin(),(x).end()

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using VP = vector<P>;
using VVP = vector<VP>;
using VI = vector<ll>;
using VVI = vector<VI>;
using st = string;
using VS = vector<st>;
using VVS = vector<VS>;

int main(void){
    // std::cout << "ora" << std::endl;
    int i, j;
    int wid, height;
    cin >> height >> wid;
    VVS map = VVS(height, VS(wid, "a"));
    //cout << "ok1"  << endl;
    rep(i, height){
        rep(j, wid){
            //cout << "i, j: " << i << "," << j << endl;
            cin >> map[i][j];
        }
    }
    rep(i, 40){
        // printf("%c \n", 'a' + i);
    }
    rep(i, height){
        rep(j, wid){
            if(map[i][j] == "snuke"){
                printf("%c", 'A' + j);
                printf("%d", i + 1);
            }
        }
    }
    return 0;
}



Measured memory_bytes: 256
import sys
readline = sys.stdin.readline
from operator import itemgetter

def main():
    N = int(readline())
    AB = [list(map(int, readline().rstrip().split())) for _ in range(N)]
    AB.sort(key=itemgetter(1))
    t = 0
    for a, b in AB:
        if t + a > b:
            print('No')
            return
        t += a
    
    print('Yes')

if __name__ == '__main__':
    main()

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

int main() {
  int h, w;
  while (cin >> h >> w, (h || w)) {
    bool b1 = false, b2 = false;
    for (int i = 0; i < h; i++) {
      b2 = !b2;
      b1 = b2;
      for (int j = 0; j < w; j++) {
        if (b1) {
          cout << "#";
        } else {
          cout << ".";
        }
        b1 = !b1;
      }
      cout << "\n";
    }
    cout << endl;
  }
}

Measured memory_bytes: 3068
import sys
import bisect


def input():
    return sys.stdin.readline().rstrip()


def main():
    N, W = map(int, input().split())
    vsup = 10 ** 3 * N + 2
    dp = [10 ** 12 + 1] * (vsup)  # 価値の総和を i (以上にするための重さの最小値
    dp[0] = 0

    for i in range(N):
        w, v = map(int, input().split())
        for j in range(vsup-2, -1, -1):
            if j - v >= 0:
                dp[j] = min(dp[j], dp[j - v] + w)
            dp[j] = min(dp[j],dp[j+1])

    print(bisect.bisect_right(dp,W)-1)

if __name__ == "__main__":
    main()


Measured memory_bytes: 69380
N = int(input())
h = list(map(int,input().split()))

dp = [0 for _ in range(N)]
dp[1] = abs(h[1] - h[0])
for i in range(1,N-1):
    dp[i+1] = min(dp[i] + abs(h[i+1] - h[i]),
                dp[i-1] + abs(h[i+1] - h[i - 1]))
print(dp[N-1])

Measured memory_bytes: 13980
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int N, A;
    cin >> N >> A;
    
    int i = N / 500;
    int j = N - (500 * i);
    
    if ( A >= j)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}


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

int main () {
  int n, m;
  cin >> n >> m;
  vector<pair<ll, ll>> ab(n);
  rep(i, n) cin >> ab[i].first >> ab[i].second;
  sort(ab.begin(), ab.end());

  pair<ll, ll> ans(0, 0);
  rep(i, n) {
    if (m - ans.second > ab[i].second) {
      ans.first += ab[i].first * ab[i].second;
      ans.second += ab[i].second;
    }
    else {
      ans.first += ab[i].first * (m - ans.second);
      ans.second = m;
      break;
    }
  }

  cout << ans.first << endl;

}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=1LL<<61;

int main() {
  ll n;
  cin >> n;
  vec a(n);
  for(ll i=0;i<n;i++) cin >> a[i];
  ll sum=0;
  for(ll i=0;i<n;i++) {
    sum+=a[i];
  }
  ll ans=0;
  for(ll i=0;i<n;i++) {
    if(abs(sum-a[ans]*n)>abs(sum-a[i]*n)) {
      ans=i;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bitset>
#include <cmath>
#include <cstdio>
#include <map>
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <set>
#include <iterator>
#include <climits>
#include <stack>
#include <cassert>
#include <list>
#include <cstring>
using namespace std;

#define ll long long int
#define dd double
#define endl "\n"
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define vi vector<ll>
#define mii map<ll,ll>
#define mod 1000000007
#define matrix vector<vector<ll>>
#define fast_io ios_base :: sync_with_stdio(false),cin.tie(NULL);

matrix multiply(matrix A, matrix B) {
    matrix C(5);
    for (int i = 0; i < 5; ++i) {
        for (int j = 0; j < 5; ++j) {
            for (int x = 0; x < 5; ++x) {
                C[i][j] = (C[i][j]+(A[i][x] * B[x][j]) % mod) % mod;
            }
        }
    }
    return C;
}

matrix power(matrix T, ll n) {
    if (n == 1)
        return T;

    if (n & 1)
        return multiply(T, power(T, n - 1));

    matrix X = power(T, n >> 1);
    return multiply(X, X);
}

signed main(void) {

    fast_io;
    vector<ll> raa;
    for(ll i = 1;i <= 9;++i)
        for(ll j = 1;j <= 9;++j)
            raa.pb(i*j);
    ll n;
    cin >> n;
    if(find(raa.begin(),raa.end(),n) != raa.end())
        cout << "Yes" << endl;
    else 
        cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>//cout
#include <stdio.h>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <queue>
#include <stack>
#include <functional>
#include <list>
#include <utility>//swap
using namespace std;
static const int MAX = 200000;
#define rep(i,n) for(int i=0;i<n;i++)
#define GET_ARRAY_SIZE(a) (sizeof(a)/sizeof(a[0]))
 
int main() {
  long long int n;
  cin >> n;
  vector<int> k;
  int x;
  for (int i = 0; i < n; i++) {
    cin >> x;
    k.push_back(x);
  }
  sort(k.rbegin(), k.rend());
  int max = 1000;
  int num = 0;
  for (const int & e : k) {
    if (max > e) {
      num++;
      max = e;
    }
  }
  cout << num << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main{
    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);
        int num = 1;
        int i = 0;

        while(i >= 0){
          i++;
          num = scanner.nextInt();
          if(num != 0){
          System.out.println("Case " + i + ": " + num);
          }else{
          break;
          }
        }
    }
}



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

#define int long long
struct Fast {Fast(){cin.tie(0);ios::sync_with_stdio(0);}} fast;
using intpair = pair<int, int>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define ceiv(a, b) ((int)((a) + (b) - 1)/(int)(b))

signed main(){
    int n; cin >> n;
    vector<int> d(n);
    rep(i,n) cin >> d[i];
    
    int ans = 0;
    reps(i,0,n-2)reps(j,i+1,n-1){
        ans += d[i] * d[j];
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <numeric>
#include <set>
#include <boost/math/constants/constants.hpp>
#include <boost/math/common_factor_rt.hpp>

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

int main(){
  int A, B;
  cin >> A >> B;
    
  cout << max(max(A+B,A-B),A*B) << endl;
}

Measured memory_bytes: 256
import numpy as np
[a,b,h,m] = list(map(int, input().split()))
minute = h*60 + m
corrMin = minute % 60
minPointAngle = corrMin/60 * 360
hour = h + m/60
corrHour = hour % 12
hourPointAngle = corrHour/12 * 360
angleDiff = abs(hourPointAngle - minPointAngle)
length = np.sqrt(a**2 + b**2 - 2*a*b*np.cos(2*np.pi*angleDiff/360))
print(length)

Measured memory_bytes: 27204
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()

typedef long long lint;

using namespace std;

struct UnionFind{
  vector<int> par;
  UnionFind(int N):par(N){
    REP(i,N)par[i]=i;
  }
  int root(int x){
    if(par[x]==x)return x;
    return par[x]=root(par[x]);
  }
  void unite(int x,int y){
    int rx=root(x);
    int ry=root(y);
    if(rx==ry)return;
    par[rx]=ry;
  }
};

int main(){
  int N,M,K;
  cin>>N>>M>>K;
  vector<int> f[N],b[N];
  UnionFind t(N);
  REP(i,M){
    int A,B;
    cin>>A>>B;
    A--;B--;
    f[A].push_back(B);
    f[B].push_back(A);
    t.unite(A,B);
  }
  REP(i,K){
    int A,B;
    cin>>A>>B;
    A--;B--;
    b[A].push_back(B);
    b[B].push_back(A);
  }
  int s[N];
  REP(i,N)s[i]=0;
  REP(i,N){
    s[t.root(i)]++;
  }
  REP(i,N){
    lint ans=s[t.root(i)]-1;
    for(auto e:f[i])if(t.root(i)==t.root(e))ans--;
    for(auto e:b[i])if(t.root(i)==t.root(e))ans--;
    cout<<ans<<" ";
  }
  cout<<endl;
  return 0;
}


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

#define itn int
#define all(x) (x).begin(), (x).end()
#define make_unique(x) sort(all((x))); (x).resize(unique(all((x))) - (x).begin())

using namespace std;

inline int nxt() {
	int x;
	scanf("%d", &x);
	return x;
}

const int mod = 998244353;

const int N = 41;
long long dp[N][N][N][N];
long long single[N][N][N][N];
bool a[N][N];

int main() {
	int n = nxt() * 2;
	for (int i = 0; i < n; ++i) {
		string s;
		cin >> s;
		for (int j = 0; j < n; ++j) {
			a[i][j] = s[j] == '1';
		}
	}

	for (int i = 0; i < n + 1; ++i) {
		for (int j = 0; j < n + 1; ++j) {
			single[i][0][j][0] = 1;
			dp[i][0][j][0] = 1;
		}
	}
	for (int sumlen = 2; sumlen <= n; ++sumlen) {
		for (int l1 = 1; l1 < sumlen; ++l1) {
			int l2 = sumlen - l1;
			for (int i = 0; i < n; ++i) {
				vector<char> used(n, 0);
				for (int k = 0; k < l1; ++k) {
					used[(i + k) % n] = 1;
				}
				for (int j = 0; j < n; ++j) {
					bool ok = true;
					for (int k = 0; k < l2; ++k) {
						ok &= !used[(j + k) % n];
					}
					if (!ok) {
						continue;
					}

					if (l1 % 2 != l2 % 2) {
						continue;
					}

					for (int i1 = 0; i1 < l1; ++i1) {
						for (int j2 = 0; j2 < l2; ++j2) {
							if (a[(i + i1) % n][(j + j2) % n]) {
								single[i][l1][j][l2] += dp[i][i1][(i + i1 + 1) % n][l1 - 1 - i1] * dp[j][j2][(j + j2 + 1) % n][l2 - 1 - j2];
							}
						}
					}
					dp[i][l1][j][l2] = single[i][l1][j][l2];
					for (int i1 = 1; i1 < l1; ++i1) {
						for (int j2 = 1; j2 < l2; ++j2) {
							dp[i][l1][j][l2] += single[i][i1][(j + l2 - j2) % n][j2] * dp[(i + i1) % n][l1 - i1][j][l2 - j2];
						}
					}
				}
			}
		}
	}

	long long ans = 0;
	for (int i = 1; i < n; ++i) {
		if (a[0][i]) {
			ans += dp[1][i - 1][i + 1][n - i - 1];
		}
		// cerr << dp[1][i - 1][i + 1][n - i - 1] << " ";
	}

	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 43136
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>

typedef long long ll;

using namespace std;

int main(int argc, const char * argv[]) {
  ll N;
  cin >> N;
  vector<ll> A(N);
  vector<ll> B(N);
  vector<ll> C(N-1);
  ll i,j,k;
  for(i=0;i<N;i++){
    cin >> A[i];
    A[i]-=1;
  }
  for(i=0;i<N;i++){
    cin >> B[i];
  }
  for(i=0;i<N-1;i++){
    cin >> C[i];
  }
  ll ans = B[A[0]];
  for(i=1;i<N;i++){
    ans += B[A[i]];
    if(A[i] == A[i-1]+1) ans += C[A[i-1]];
  }
  cout << ans;
}


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

using namespace std;

#define N 4
#define N2 16
#define LIMIT 45

const int dx[4] { -1, 0, 1, 0 };
const int dy[4] { 0, -1, 0, 1 };
const char dir[4] { 'u', 'l', 'd', 'r' };
int MDT[N2][N2];

struct Puzzle {
	int f[N2], space, MD;
};
int getAllMd(Puzzle p) {
	int sum = 0;
	for (int i = 0; i < N2; ++i) {
		if (p.f[i] == N2)
			continue;
		sum += MDT[i][p.f[i] - 1];
	}
	return sum;
}
int limit;
Puzzle state;
int path[LIMIT];
bool dfs(int depth, int prevR) {
	if (state.MD == 0)
		return true;
	if (state.MD + depth > limit)
		return false;

	int sx = state.space / N;
	int sy = state.space % N;

	Puzzle tmp;
	for (int r = 0; r < 4; ++r) {
		int tx = sx + dx[r];
		int ty = sy + dy[r];
		if (tx < 0 || ty < 0 || tx >= N || ty >= N)
			continue;
		if (max(prevR, r) - min(prevR, r) == 2)
			continue;
		tmp = state;
		state.MD -= MDT[tx * N + ty][state.f[tx * N + ty] - 1];
		state.MD += MDT[sx * N + sy][state.f[tx * N + ty] - 1];
		swap(state.f[sx * N + sy], state.f[tx * N + ty]);
		state.space = tx * N + ty;
		if (dfs(depth + 1, r)) {
			path[depth] = r;
			return true;
		}
		state = tmp;
	}
	return false;
}

string deepeing(Puzzle p) {
	int md = getAllMd(p);
	p.MD = md;
	state = p;
	for (limit = md; limit <= LIMIT; ++limit) {
		string ans = "";
		if (dfs(0, -10)) {
			for (int i = 0; i < limit; ++i) {
				ans += dir[path[i]];
			}
			return ans;
		}
	}
	return "";
}

int main() {
	for (int i = 0; i < N2; ++i) {
		for (int j = 0; j < N2; ++j) {
			MDT[i][j] = abs(i / N - j / N) + abs(i % N - j % N);
		}
	}
	Puzzle p;
	for (int i = 0; i < N2; ++i) {
		scanf("%d", &p.f[i]);
		if (p.f[i] == 0) {
			p.f[i] = N2;
			p.space = i;
		}
	}
	string ans = deepeing(p);
	cout << ans.size() << endl;
	return 0;
}

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

int n, m;
vector<int> l, r, d;

vector<queue<pair<int, long long> > > to;

int main()
{
    cin >> n >> m;
    l = r = d = vector<int>(m);
    to.resize(n);
    for (int i=0; i<m; i++)
    {
        cin >> l[i] >> r[i] >> d[i];
        l[i]--;
        r[i]--;
        to[l[i]].push(make_pair(r[i], d[i]));
        to[r[i]].push(make_pair(l[i], -d[i]));
    }

    vector<bool> flg(n, false);
    vector<long long> x(n, 0);
    for (int i=0; i<n; i++)
    {
        if (flg[i]) continue;
        flg[i] = true;
        queue<pair<int, long long> > toSearch;

        while (!to[i].empty())
        {
            toSearch.push(to[i].front());
            flg[to[i].front().first] = true;
            to[i].pop();
        }

        while (!toSearch.empty())
        {
            int st = toSearch.front().first;
            long long xtmp = toSearch.front().second;
            toSearch.pop();
            x[st] = xtmp;
            while(!to[st].empty())
            {
                if (!flg[to[st].front().first])
                {
                    toSearch.push(make_pair(to[st].front().first, xtmp + to[st].front().second));
                    flg[to[st].front().first] = true;
                }
                to[st].pop();
            }
        }
    }

    for (int j=0; j<m; j++)
    {
        if (x[r[j]] - x[l[j]] != d[j])
        {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 72320
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <cstring>
#include <string>
#include <sstream>
#include <algorithm>
#include <iomanip>
#include <iostream>

#define VARIABLE(x) cerr << #x << "=" << x << endl
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for (int i=m;i<(int)(n);i++)

const int INF = 10000000;
using namespace std;
typedef long long  ll;

/** Problem0072 : Carden Lantern **/
int n, m;
int cost[100][100];
int mincost[100];
bool used[100];

// 最小全域木を求める : プリム法
int prim()
{
	rep(i, n) {
		mincost[i] = INF;
		used[i] = false;
	}
	mincost[0] = 0;
	int res = 0;
	
	while (1) {
		int v = -1;
		for (int u=0; u<n; u++) {
			if (!used[u] && (v == -1 || mincost[u]<mincost[v])) v=u;
		}
		
		if (v==-1) break;
		used[v] = true;
		res += mincost[v];
		
		rep(u, n)
			mincost[u] = min(mincost[u], cost[v][u]);
	}
	return res;
}

int main()
{
	char ca;
	
	while (cin>>n, n) {
		cin >> m;
		fill(cost[0], cost[0]+100*100, INF);
		rep(i, m) {
			int a, b, c;
			cin >> a >> ca >> b >> ca >> c;
			cost[a][b] = c/100-1;
			cost[b][a] = c/100-1;
		}
		
		cout << prim() << endl;
	}
	return 0;
}

Measured memory_bytes: 1200
#include <cstdio>
#include <vector>
#include <stack>
#include <iostream>
#include <string>
#include <tuple>
#include <random>
#include <map>
#include <queue>
#include <set>
#include <complex>
#include <algorithm>
#include <cassert>
#include <iterator>
#include <numeric>
#include <cmath>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;

const double eps = 1e-8;

const ll INF = 1e15;

int main(){
	ll N, x;
	cin >> N >> x;
	vector<ll> A(N);
	for (int i = 0;i < N;i++)
		cin >> A[i];
	sort(A.begin(), A.end());
	ll ans = 0;
	for (int i = 0;i < N;i++)
		if (x >= A[i]) {
			ans++;
			x -= A[i];
		}
	if (x != 0 && ans == N)
		ans--;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using pint = pair<int, int>;
using pll = pair<int, int>;
using Edge = pair<int, ll>;
using Graph = vector<vector<int>>;
using WeightedGraph = vector<vector<Edge>>;
const ll INF = 1LL << 60;
const int INF32 = 1 << 29;
const ll MOD = 1000000007;

int main(){
	ll n; cin >> n;
	map<int, int> mp;
	for(int i = 0; i < 13; ++i) mp[i] = 0;
	++mp[0];
	for(int i = 0; i < n; ++i){
		int a; cin >> a;
		++mp[a];
	}

	bool f = false;
	for(int i = 0; i < 13; ++i) if(mp[i] >= 3) f = true;
	if(mp[0] >= 2 || mp[12] >= 2) f = true;
	if(f){
		cout << 0 << endl;
		return 0;
	}

	int ans = 0;
	for(int s = 0; s < (1 << 13); ++s){
		bitset<12> bs(s);
		vector<int> times{ 0, 24 };
		for (int i = 1; i < 13; ++i) {
			if (mp[i] == 1) {
				if (bs[i-1]) times.push_back(i);
				else times.push_back(24 - i);
			}
			else if (mp[i] == 2) {
				times.push_back(i);
				times.push_back(24 - i);
			}
		}
		sort(times.begin(), times.end());
		int tmp = INF32;
		for (int i = 1; i < times.size(); ++i) {
			tmp = min(tmp, times[i] - times[i-1]);
		}
		ans = max(ans, tmp);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
// **** WHEN THE GOING GETS TOUGH, THE TOUGH GETS GOING. ****

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define ordered_set tree < ll ,  null_type ,  less<ll> ,  rb_tree_tag ,  tree_order_statistics_node_update >
//added two more functions to set
//(1)*(set.find_by_order(k))[kth element in the sorted set] 
//(2)set.order_of_key(k)[count of elements strictly less than k]

typedef vector< int > vi;
typedef vector< ll > lvi;
typedef vector< vi > vvi;
typedef vector< lvi > lvvi;
typedef pair< int,int > ii;
typedef pair< ll,ll > lii;
typedef vector<ii> vii;
typedef vector<lii> lvii;

#define min_prq(t) priority_queue<t,vector<t>,greater<t>>
#define max_prq(t) priority_queue<t>
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(auto i = (c).begin(); i != (c).end(); i++)//remember i is an iterator
#define present(c,x) ((c).find(x) != (c).end())//for sets,maps,multimaps
#define cpresent(c,x) (find(all(c),x) != (c).end())//for vectors
#define tc(t) int (t); cin>>(t);while((t)--)
#define ff first
#define ss second
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " is " << a << endl;
	err(++it, args...);
}

//-----------------------------------------------------------------------------------------------------------------------------------------------------------------
#define mod 1000000007
//-----------------------------------------------------------------------------------------------------------------------------------------------------------------

ll mod_sum() { return 0LL; }
template<typename T, typename... Args>
T mod_sum(T a, Args... args) { return ((a + mod_sum(args...))%mod + mod)%mod; }

ll mod_product() { return 1LL; }
template<typename T, typename... Args>
T mod_product(T a, Args... args) { return (a*mod_product(args...))%mod; }
//-----------------------------------------------------------------------------------------------------------------------------------------------------------------

vector<lvvi> dp;
ll d;
lvi a;

ll recurs(ll idx,ll sum,ll tight)
{
	if(idx==a.size()) {
		if(sum==0) return 1;
		else return 0;
	}
	if(dp[idx][sum][tight]!=-1) return dp[idx][sum][tight];
	ll up=tight?a[idx]:9;
	ll rval=0;
	for(int i=0;i<=up;i++)
	{
		ll new_tight=(i==up)?tight:0;
		rval=mod_sum(rval,recurs(idx+1,(sum+i)%d,new_tight));
	}
	dp[idx][sum][tight]=rval;
	return rval;
}

signed main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);	
    string k;
    cin>>k;
    ll len=k.length();
    for (int i = 0; i < len; ++i)
    {
    	a.pb(k[i]-'0');
    }
    cin>>d;
    dp.assign(1e4+5,lvvi(105,lvi(3,-1))); // idx, sum%d,tight
    cout<<(recurs(0,0,1)-1+mod)%mod<<endl;
	return 0;
}

Measured memory_bytes: 59136
h,w,k=map(int,input().split())
c=[list(input()) for _ in range(h)]
ans=0
for x in range(2**h):
    for y in range(2**w):
        cnt=0
        for i in range(h):
            for j in range(w):
                if x>>i&1 and y>>j&1:
                    if c[i][j]=="#":
                        cnt+=1
        if cnt==k:
            ans+=1
print(ans)

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

using namespace std;

int main(){
        int n,tmp,count = 0,limit;
        scanf("%d",&n);

        for(int i = 0; i < n; i++)
        {
                scanf("%d",&tmp);
                limit = sqrt(tmp);
                for(int j = 2; j <= limit; j++) {
                        if(tmp%j==0) {
                                count++;
                                break;
                        }
                }
        }
        printf("%d\n",n-count);
}



Measured memory_bytes: 3204
//templates
#include <iostream>
#include <algorithm>
#include <string>
#include <numeric>
#include <vector>
#include <unordered_map>
#include <map>
#include <cmath>
#include <iomanip>
#include <bitset>
#include <sstream>
#include <queue>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define ALL(x) (x).begin(), (x).end()
#define sort_key(struct_name,key_name) [](const struct_name &x, const struct_name &y){return x.key_name < y.key_name;}
#define pb(x) push_back(x)
typedef long long ll;
const long long MOD = 1e9 + 7;
using namespace std;

//main
int main(){
  int r; cin >> r;
  cout << r*r << endl;
}


Measured memory_bytes: 256
import math
def solve():
  d,g = (int(i) for i in input().split())
  query = []
  ans = 10**15
  for i in range(d):
    p,c = (int(i) for i in input().split())
    query.append((p,c,(i+1)*100))
  for i in range(2**d):
    ct = 0
    point = 0
    use = [False]*d
    for j in range(d):
      if (i>>j)&1 == 1:
        use[j] = True

    for m in range(d):
      if use[m]:
        tp,tc,ti = query[m]
        ct += tp
        point += ti*tp+tc
        
    if point >= g:
      ans = min(ans,ct)
    else:
        for l in range(d):
          if use[d-l-1]:
            continue
          else:
            tp,tc,ti = query[d-l-1]
            twant = math.ceil((g-point)/ti)
            if tp >= twant:
              point += twant*ti
              ct += twant

            if point >= g:
              ans = min(ans,ct)
              break


            

  print(ans)
    
    
solve()


Measured memory_bytes: 3064
// review
#include <iostream>

using namespace std;
typedef long long ll;

int n, a, maxX;
int x[51];
ll dp[51][51][3001]; // dp[i][j][k] num of combination that till ith, select j number and its sum is k

void solve() {
  dp[0][0][0] = 1;
  for (int i=0;i<n;i++) {
    for (int j=0;j<n;j++) {
      for (int k=0;k<=maxX * n;k++) {
        dp[i+1][j][k] += dp[i][j][k];
        dp[i+1][j+1][k+x[i]] += dp[i][j][k];
      }
    }
  }
  ll cnt = 0;
  for (int i=1;i<=n;i++) {
    cnt += dp[n][i][i * a];
  }
  cout << cnt << endl;
}

int main() {
  cin >> n >> a;
  maxX = 0;
  for (int i=0;i<n;i++) {
    cin >> x[i];
    maxX = max(maxX, x[i]);
  }
  solve();
}


Measured memory_bytes: 60032
#include<stdio.h>
#include<stdlib.h>
int main(void){
	int n, m;
	int x=0;
	int flg=1;
	int *l, *r;
	int lmax=1;
	int rmin=100000;
	scanf("%d",&n);
	scanf("%d",&m);
	l = (int *)malloc(sizeof(int) * m);
	r = (int *)malloc(sizeof(int) * m);
	for(int i=0; i<m; i++){
		scanf("%d",&l[i]);
		scanf("%d",&r[i]);
	}
	for(int j=0; j<m; j++){
		if(lmax<=l[j]){
			lmax=l[j];
		}
		if(rmin>=r[j]){
			rmin=r[j];
		}
	}
	for(int k=1; k<=n; k++){
		if(k<lmax || k>rmin){
			flg=0;
		}
		if(flg==1){
			x+=1;
		}
		flg=1;
	}
	printf("%d\n", x);
	return 0;
}

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

using namespace std;

template<typename Data, typename T>
struct ReRooting {

    struct Node {
        int to, rev;
        Data data;
    };

    using F1 = function<T(T, T)>;
    using F2 = function<T(T, Data)>;

    vector<vector<Node> > g;
    vector<vector<T> > ldp, rdp;
    vector<int> lptr, rptr;
    const F1 f1;
    const F2 f2;
    const T ident;

    // ident: dp配列の初期値
    // f2: 子頂点のDP配列の値を処理する演算
    // f1: f2で処理された値をDP配列にマージする演算
    ReRooting(int n, const F1 &f1, const F2 &f2, const T &ident) :
            g(n), ldp(n), rdp(n), lptr(n), rptr(n), f1(f1), f2(f2), ident(ident) {}

    void add_edge(int u, int v, const Data &d) {
        g[u].emplace_back((Node) {v, (int) g[v].size(), d});
        g[v].emplace_back((Node) {u, (int) g[u].size() - 1, d});
    }

    void add_edge_bi(int u, int v, const Data &d, const Data &e) {
        g[u].emplace_back((Node) {v, (int) g[v].size(), d});
        g[v].emplace_back((Node) {u, (int) g[u].size() - 1, e});
    }


    T dfs(int idx, int par) {
        while (lptr[idx] != par && lptr[idx] < g[idx].size()) {
            auto &e = g[idx][lptr[idx]];
            ldp[idx][lptr[idx] + 1] = f1(ldp[idx][lptr[idx]], f2(dfs(e.to, e.rev), e.data));
            ++lptr[idx];
        }
        while (rptr[idx] != par && rptr[idx] >= 0) {
            auto &e = g[idx][rptr[idx]];
            rdp[idx][rptr[idx]] = f1(rdp[idx][rptr[idx] + 1], f2(dfs(e.to, e.rev), e.data));
            --rptr[idx];
        }
        if (par < 0) return rdp[idx][0];
        return f1(ldp[idx][par], rdp[idx][par + 1]);
    }

    vector<T> solve() {
        for (int i = 0; i < g.size(); i++) {
            ldp[i].assign(g[i].size() + 1, ident);
            rdp[i].assign(g[i].size() + 1, ident);
            lptr[i] = 0;
            rptr[i] = (int) g[i].size() - 1;
        }
        vector<T> ret;
        for (int i = 0; i < g.size(); i++) {
            ret.push_back(dfs(i, -1));
        }
        return ret;
    }
};

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

    int n;
    cin >> n;

    auto f2 = [&](vector<int> a, int d) -> vector<int> {
        a[0] += d;
        a[1] = 0;
        return a;
    };
    auto f1 = [&](vector<int> a, const vector<int> b) -> vector<int> {
        for (int c : b) a.push_back(c);
        sort(a.rbegin(), a.rend());
        a.pop_back();
        a.pop_back();
        return a;
    };

    ReRooting<int, vector<int>> g(n, f1, f2, {0, 0});
    for (int i = 0; i < n - 1; i++) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        g.add_edge(a, b, 1);
    }
    for (auto &p : g.solve()) {
        cout << 2 * (n - 1) - max(p[0], p[1]) << '\n';
    }
}



Measured memory_bytes: 77008
#include<iostream>
#include<bits/stdc++.h>
#define int long long
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
int32_t main()
{
  int r;
  cin>>r;
  double pi = 2 * acos(0.0); 
  int N=20;
printf("%.*lf\n", N, pi*2*r);
}


Measured memory_bytes: 3748