akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define ll long long
#define N 100005
#define M 1000000007
#define pii pair<ll,ll>
#define fast ios_base::sync_with_stdio(0);cin.tie(0);
using namespace std;
main()
{
    double l;
    cin>>l;
    double a=l/3;
    cout<<setprecision(20)<< a*a*a;

}


Measured memory_bytes: 256
from collections import defaultdict
from collections import Counter
import math
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

n = int(input())

cnt_dic = defaultdict(lambda: 0)

for _ in range(n):
    s = list(input())
    cnt_s = [0] * 52
    for c in s:
        cnt_s[ord(c)- ord('a')] += 1
    cnt_dic[tuple(cnt_s)] +=1

ans = 0
for i in cnt_dic.values():
    if 1 < i:
        ans += combinations_count(i,2)

print(ans)


Measured memory_bytes: 162948
#include<iostream>
#include<queue>
#include<map>
#include<iomanip>
using namespace std;
typedef double D;
typedef pair<int,int> pii;
typedef pair<D,pii> state;

const D inf = 1e5;
D dis[40][1<<8];
vector<pii> g[40];

int main(){
  int n,m,p,a,b,t[10];
  int x,y,z;

  while(cin >> n >> m >> p >> a >> b, n){
    a--; b--;
    for(int i=0;i<n;i++)cin >> t[i];
    
    for(int i=0;i<m;i++)g[i].clear();
    for(int i=0;i<p;i++){
      cin >> x >> y >> z;
      x--; y--;
      g[x].push_back(pii(z,y));
      g[y].push_back(pii(z,x));
    }

    priority_queue<state, vector<state>, greater<state> > q;
    q.push(state(0,pii(a,0)));

    for(int i=0;i<m;i++){
      for(int j=0;j<(1<<n);j++)dis[i][j] = inf;
    }
    dis[a][0] = 0;

    while(q.size()){
      state s = q.top(); q.pop();
      D d = s.first;
      int cur = s.second.first, use = s.second.second;

      if(dis[cur][use] + 1e-8  < d)continue;
      if(cur == b)break;

      for(int i=0;i<(int)g[cur].size();i++){
	int nxt = g[cur][i].second, len = g[cur][i].first;
	for(int j=0;j<n;j++){
	  if( !((use>>j)&1) ){
	    D nxtd = d + (D)len/t[j];
	    int nxtuse = use | (1<<j);
	    if(dis[nxt][nxtuse] > nxtd + 1e-8){
	      dis[nxt][nxtuse] = nxtd;
	      q.push(state(nxtd,pii(nxt,nxtuse)));
	    }
	  }
	}
      }
    }

    D ans = inf;
    for(int i=0;i<(1<<n);i++)ans = min(ans, dis[b][i]);
    if(ans == inf)cout << "Impossible" << endl;
    else cout << fixed << setprecision(9) << ans << endl;
  }
}

Measured memory_bytes: 2776
#include <stdio.h>
#include <stdlib.h>
#include <memory.h>
  
long long int A[200005];
long long int merge_count(int l, int r){
    long long int count = 0;
    int i, j, k;
    int n = r - l;
    if(n > 1){
        long long int b[n+5];
        int m = l + n/2;
        count += merge_count(l, m);
        count += merge_count(m, r);
        memcpy((void*)b, (void*)&A[l], sizeof(b));
        for(i = l, j = 0, k = n/2; i < r; ++i){
            if(j == n/2) {
                A[i] = b[k++];
            } else if(k == n) {
                A[i] = b[j++];
            } else if(b[j] <= b[k]) {
                A[i] = b[j++];
            } else {
                A[i] = b[k++];
                count += n/2 - j;
            }
        }
    }
    return count;
}
  
long long int bubble_sort(int n) {
    return merge_count(0, n);
}
  
int main(void) {
    int i, n;
    scanf("%d\n", &n);
      
    for(i=0;i<n;i++) {
        scanf("%lld", &A[i]);
    }
      
    printf("%lld\n", bubble_sort(n));
  
    return 0;
}


Measured memory_bytes: 6560
import java.util.*;
public class Main {
	public static void main(String[] args){
       Scanner sc = new Scanner(System.in);
      
      // 整数の取得
	  int N = sc.nextInt();
      int M = sc.nextInt();
      long K = sc.nextLong();
      //読む時間の取得
      long[] A = new long[N+1];
      long[] B = new long[M+1];
      A[0]=0;
      B[0]=0;
      for(int i=1;i<=N;i++){
        A[i] = A[i-1]+sc.nextLong();
      }
      for(int i=1;i<=M;i++){
        B[i] = B[i-1]+sc.nextLong();
      }
      //Bの冊数
      int j = M;
      //カウント
      int count = 0;
      for(int i=0;i<=N;i++){
        if(A[i]>K){
          break;
        }
        while(A[i]+B[j]>K){
          j--;
        }
         count = Math.max(count,i+j);
      }
		System.out.println(count);
    }
}

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

int main(){
    int a,b,c;
    cin >> a >> b >> c;
    if(a<b) swap(a,b);
    if(a<c) swap(a,c);
    if(b<c) swap(b,c);
    int ans = 0;
    ans += a - b;
    c += ans;
    if((a-c)%2) ans += (a-c)/2 + 2;
    else ans += (a-c)/2;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
package main

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

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string   { sc.Scan(); return sc.Text() }
func scanRunes() []rune    { return []rune(scanString()) }
func scanInt() int         { a, _ := strconv.Atoi(scanString()); return a }
func scanInt64() int64     { a, _ := strconv.ParseInt(scanString(), 10, 64); return a }
func scanFloat64() float64 { a, _ := strconv.ParseFloat(scanString(), 64); return a }

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = scanInt()
	} 
	return res
}

func debug(a ...interface{}) { fmt.Fprintln(os.Stderr, a...) }

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

//•*¨*•.¸¸♪main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)
func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	x := scanInt()
	y := scanInt()
	z := scanInt()

	fmt.Fprintln(wr, z,x,y)
}


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

#include <ext/pb_ds/assoc_container.hpp>
template <class Key, class T>
using gp_hash_table = __gnu_pbds::gp_hash_table<Key, T>;

using namespace std;
using i64 = long long;
using u64 = unsigned long long;
template <typename T>
using V = std::vector<T>;
#define REP(i, n) for (int i = 0; (i64)(i) < (i64)(n); ++i)

#ifdef ENABLE_DEBUG
template <typename T>
void debug(T value) {
  cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  cerr << value << ", ";
  debug(args...);
}
#define DEBUG(...)                              \
  do {                                          \
    cerr << " \033[33m (L" << __LINE__ << ") "; \
    cerr << #__VA_ARGS__ << ":\033[0m ";        \
    debug(__VA_ARGS__);                         \
    cerr << endl;                               \
  } while (0)
#else
#define debug(...)
#define DEBUG(...)
#endif

const u64 B = 100'000'007ULL;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N;
  cin >> N;
  V<pair<size_t, string>> S(N);
  REP(i, N) {
    string s;
    cin >> s;
    S[i] = {s.size(), s};
  }
  sort(S.begin(), S.end());
  gp_hash_table<u64, array<int, 26>> mp;
  i64 ans = 0;
  REP(i, N) {
    int len = S[i].first;
    const string& ss = S[i].second;
    V<int> char_cnt(26);
    REP(j, len) {
      int ch = ss[j] - 'a';
      char_cnt[ch]++;
    }
    u64 shash = 0;
    u64 base = B;
    if (len > 1) {
      for (int j = len - 1; j >= 1; --j) {
        REP(c, 26) {
          if (char_cnt[c] > 0) {
            auto it = mp.find(shash);
            if (it == mp.end()) continue;
            ans += it->second[c];
          }
        }
        shash += base * ss[j];
        base *= B;
        --char_cnt[ss[j] - 'a'];
      }
    }
    int prefix = ss[0] - 'a';
    auto ait = mp.find(shash);
    array<int, 26>* ap = nullptr;
    if (ait == mp.end()) {
      auto& a = mp[shash];
      REP(j, 26) { a[j] = 0; }
      ap = &a;
    } else {
      ap = &ait->second;
    }
    (*ap)[prefix]++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 103292
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }
    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int N = scan.nextInt();
        int A = scan.nextInt();
        int B = scan.nextInt();
        int max = Math.min(A,B);
        int min = (A + B <= N) ? 0 : (A+B)-N;
        System.out.printf("%d %d\n", max, min);
    }
}


Measured memory_bytes: 23636
#include <bits/stdc++.h>
#define ld long double
#define LL long long
#define Accel ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define Re(a,b) memset(a,b,sizeof a)
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define ALL(X) (X).begin(), (X).end()
#define FOR(I, A, B) for (int I = (A); I <= (B); I++)
#define REP(I, N) for (int I = 0; I < (N); I++)
#define PII pair<int,int>
#define PLL pair<LL,LL>
#define SZ(a) ((int)a.size())
#define endl "\n" 
//#pragma GCC optimize(2)
using namespace std;
//typedef complex<double>C;
//const double PI(acos(-1.0));
//const double eps(1e-8);
//for(int mask=i;mask>0;mask=(mask-1)&i)
//int a[25]= { 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97 };
//__gcd, atan2(y,x)=y/x , __int128
//c(n,k)=c(n-1,k-1)+c(n-1,k)
//c(i,r),i for r to n =c(n+1,r+1)
//void add(int x){while(x<N)BIT[x]++,x+=x&-x;}
//int sum(int x){int s=0;while(x){s+=BIT[x];x-=x&-x;}return s;}
//int find(int x){return x==p[x]?x:p[x]=find(p[x]);}
//LL pw(LL a,LL b){LL t=1;for(;b;b>>=1,a=a*a%M)b&1?t=t*a%M:0;return t;}
//log() = ln() , log(x)/log(y)=log(y)-base-x
//INT_MAX 127,INT_MIN 128
//int dw[4][2]={{0,1},{1,0},{0,-1},{-1,0}};
//int dw[8][2]={{0,1},{1,0},{0,-1},{-1,0},{1,1},{1,-1},{-1,1},{-1,-1}};
//cout<<fixed<<setprecision(12)<<ans<<endl;
//__builtin_popcount(mask)
const int N=2e5+10;
const int M=1e9+7;
LL a,b,c,k;
int main(){Accel
	cin>>a>>b>>c>>k;	
	if(k&1){
		cout<<b-a<<endl;
	}
	else cout<<a-b<<endl;
}

Measured memory_bytes: 256
N, T = map(int, input().split())
r = [tuple(map(int, input().split())) for _ in range(N)]
f = [(c, t) for c, t in r if t <= T]
if len(f)==0:
  print('TLE')
else:
  print(min(f, key=lambda x: x[0])[0])


Measured memory_bytes: 2940
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <cmath>
using namespace std;
int main(){
    int a,b,c;
    int ans=0;
    scanf("%d%d%d",&a,&b,&c);
    if(a==b&&b==c){
    	printf("1\n");
	}else if(a==b||b==c||a==c){
		printf("2\n");
	}else{
		printf("3\n");
	}
    return 0;
}

Measured memory_bytes: 256
/*#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<map>
#include<cstdio>
#include<stack>
#include<queue>
#include<fstream>
#include<cstdio>
#include<deque>
#include<iomanip>
#include <numeric>*/
#include<bits/stdc++.h>

using namespace std;
#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);(i)--)
#define all(a) (a).begin(),(a).end()
#define reall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
const double pi = acos(-1.0);

typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef deque<ll> dll;
typedef pair<ll, ll> P;
typedef vector<P> vP;
const ll mod = 1e9 + 7;
ll dx[4] = {1,0,-1,0};
ll dy[4] = {0,1,0,-1};

int main(){
    ll k,a,b;
    cin >> k >> a >> b;
    ll bis=1,ans=1;
    //パターンＡ
    bis += k;
    //B
    k -= (a - ans);
    //cout << k << endl;
    if(k < 1){
        cout << bis << endl;
        return 0;
    }
    if(k%2==0){
        ans = a + ((k/2) * (b-a));
    }
    else {
        ans = a + ((k/2) * (b-a));
        ans++;
    }
    cout << max(bis,ans) << endl;
    return 0;
}  


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

template <typename T>
struct edge {
    int from, to; T cost;
    edge(int to, T cost) : from(-1), to(to), cost(cost) {}
    edge(int from, int to, T cost) : from(from), to(to), cost(cost) {}
};

template <typename T>
vector<T> dijkstra(int s,vector<vector<edge<T>>> &G){
    auto n = G.size();
    vector<T> d(n, INF<T>);
    priority_queue<pair<T, int>,vector<pair<T, int>>,greater<>> Q;
    d[s] = 0;
    Q.emplace(0, s);
    while(!Q.empty()){
        T cost; int i;
        tie(cost, i) = Q.top(); Q.pop();
        if(d[i] < cost) continue;
        for (auto &&e : G[i]) {
            auto cost2 = cost + e.cost;
            if(d[e.to] <= cost2) continue;
            d[e.to] = cost2;
            Q.emplace(d[e.to], e.to);
        }
    }
    return d;
}

int main() {
    int x, y, z, n, m, s, t;
    cin >> x >> y >> z >> n >> m >> s >> t;
    vector<vector<edge<int>>> G(x+y+z+n+m);
    for (int i = 0; i < n; ++i) {
        int a, b;
        scanf("%d %d", &a, &b);
        a--; b--;
        G[a].emplace_back(x+y+z+i, 1);
        G[x+y+z+i].emplace_back(a, 0);
        G[x+b].emplace_back(x+y+z+i, 1);
        G[x+y+z+i].emplace_back(x+b, 0);
    }
    for (int i = 0; i < m; ++i) {
        int a, b;
        scanf("%d %d", &a, &b);
        a--; b--;
        G[x+a].emplace_back(x+y+z+n+i, 1);
        G[x+y+z+n+i].emplace_back(x+a, 0);
        G[x+y+b].emplace_back(x+y+z+n+i, 1);
        G[x+y+z+n+i].emplace_back(x+y+b, 0);
    }
    auto dist = dijkstra(x+y+z+s-1, G);
    if(dist[x+y+z+n+t-1] == INF<int>) puts("-1");
    else cout << dist[x+y+z+n+t-1] << "\n";
    return 0;
}


Measured memory_bytes: 32084
#include <bits/stdc++.h>
#define FOR(i,bg,ed) for(ll i=(bg);i<(ed);i++)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007
//#define int long long
using namespace std;
typedef long long ll;
const int INF = 1e9;



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

    int sum = 0;
    int t;
    for (t=1; true; t++) {
        sum += t;
        if (sum >= X) break;
    }
    
    cout << t << endl;
}


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

struct Problem{
    ULL N, K;
    UL A[200000];
    UL D[200000];

    void Solve() {
        cin >> N >> K;
        rep(i, N) { cin >> A[i]; A[i]--; }
        UL d = 0;
        UL p = 0;
        rep(i, N) D[i] = (UL)-1;
        while (K > 0) {
            if (D[p] != (UL)-1) {
                K %= (d - D[p]);
                break;
            }
            D[p] = d;
            p = A[p]; d++;
            K--;
        }
        rep(i, K) p = A[p];
        cout << (p + 1) << endl;
    }
};
int main() {
    unique_ptr<Problem> p(new Problem());
    p->Solve();
    return 0;
}


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

int main() {

  long L, N, count = 0, lng = 0;
  char b = 'x', c;

  cin>>L>>N;

  for(int i = 0; i < L; i++) {
    cin>>c;
    if (b == 'o' && c == 'o') {
      count++;
    }
    
    b = c;
  }
  
  L = L + count*3;
  for (int i = 1; i < N; i++) {
    count = count * 2;
    L = L + 3*count;
  }

  cout<<L<<endl;
}



Measured memory_bytes: 3104
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <functional>
#include <complex>
using namespace std;

#define Rep(b, e, i) for(int i = b; i <= e; i++)
#define Repr(e, b, i) for(int i = e; i >= b; i--)
#define rep(n, i) Rep(0, n-1, i)
#define repr(n, i) Repr(n-1, 0, i)
#define all(v) (v).begin(), (v).end()
#define pb(v) push_back(v)
#define uniq(v) (v).erase(unique(all(v)),(v).end())
#define bitcnt(x) __builtin_popcount(x)
#define fst first
#define snd second

typedef long long ll;
const ll INFL = 1e18;
//vector の中身を出力
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

void solve(void){
	int N;
	cin >> N;
	ll sum = 0LL, mini = INFL, f = 0LL;
	rep(N, i) {
		ll x, y;
		cin >> x >> y;
		sum += x;
		if (x > y) mini = min(mini, y);
		f |= x != y;
	}
	cout << (f?sum - mini:0) << endl;
}

int main(void){
	solve();
	//cout << "yui(*-v・)yui" << endl;
	return 0;
}


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

/* using */
using namespace std;

/* main constructor */
struct Fast
{
    Fast()
    {
        std::cin.tie(0);
        ios::sync_with_stdio(0);
        //cout << fixed << setprecision(12);
    }
} fast;

/* template */
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;
}

/* define */
#define REP(i, x, n) for (int i = x; i < (int)(n); ++i)
#define RREP(i, x, n) for (int i = x - 1; i >= (int)(n); --i)
#define rep(i, n) REP(i, 0, n)
#define reps(i, n) REP(i, 1, n + 1)
#define rrep(i, n) RREP(i, n, 0)
#define each(i, n) for (auto &i : n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define eunique(x) (x).erase(unique(all(x)), (x).end())
#define int long long

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

/* const */
const int inf = 1e9 + 7;

/* main */
signed main(void)
{
    string o;
    string e;
    cin >> o >> e;
    if (o.size() == e.size())
    {
        rep(i, o.size())
        {
            cout << o[i] << e[i];
        }
        cout << endl;
    }
    else
    {
        if (o.size() > e.size())
        {
            rep(i, e.size())
            {
                cout << o[i] << e[i];
            }
            cout << o[o.size() - 1] << endl;
        }
        else
        {
            rep(i, o.size())
            {
                cout << o[i] << e[i];
            }
            cout << e[e.size() - 1] << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <list>
#include <vector>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

#define reps(i,f,n) for(int i=f; i<int(n); ++i)
#define rep(i,n) reps(i,0,n)

int func(int n)
{
    list<int> b;
    rep(i, n){
        int a;
        cin >> a;
        b.push_back(a);
    }
    
    rep(i, 10002){
        int j = 1;
        bool ok = true;
        for(int x : b){
            if(x != j){
                ok = false;
                break;
            }
            ++j;
        }
        if(ok) return i;
        
        int s = b.size();
        for(auto itr = b.begin(); itr != b.end();){
            --*itr;
            if(*itr == 0){
                itr = b.erase(itr);
            }
            else{
                ++itr;
            }
        }
        b.push_back(s);
    }
    
    return -1;
}

int main()
{
    int n;
    while(cin >> n, n){
        cout << func(n) << endl;
    }
}

Measured memory_bytes: 1236
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<algorithm>
#include<vector>
using namespace std;
string s;
#define rep2(x,from,to) for(long long x=from;x<to;x++)
#define rep(x,to) rep2(x,0,to)
#define MOD 1000000007
long long n,k;
long long ans;
long long a[2005];

int main()
{
    cin>>n>>k;
    rep(i,n)
    {
        cin>>a[i];
    }
    rep(i,n)
    {
        rep2(j,i+1,n)
        {
            if(a[i]<a[j])
            {
                ans+=(k*(k-1)/2);
                ans%=MOD;
            }
            else if(a[i]>a[j])
            {
                ans+=(k*(k+1)/2);
                ans%=MOD;
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
import math
from math import gcd,pi,sqrt
INF = float("inf")

import sys
sys.setrecursionlimit(10**6)
import itertools
from collections import Counter,deque
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]


def main():
    s = s_input()
    t = s_input()
    l_s = len(s)
    l_t = len(t)
    ans = INF
    for i in range(l_s-l_t+1):
        trial = 0
        r = s[i:]
        for k in range(l_t):
            if t[k] != r[k]:
                trial += 1
        ans = min(ans,trial)
    print(ans)



if __name__=="__main__":
    main()


Measured memory_bytes: 9428
#include<bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<Pi,int> Pii;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<P1,ll> P2;
const ll INF=1000000000000000001;
struct edge{int to,cost;};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};


int main() {

	int n,l;
	string s;
	string s2[101];

	cin>>n>>l;

	rep(i,n){
		cin>>s;
		s2[i]=s;
	}
	sort(s2,s2+n);
	rep(i,n){
		cout<<s2[i];
	}
	cout<<endl;
	return 0;
}


Measured memory_bytes: 256
fun main(args: Array<String>) {
    val input = readLine()!!
    
    val check = mutableListOf<String>()
    check.add("abc")
    check.add("acb")
    check.add("bca")
    check.add("bac")
    check.add("cab")
    check.add("cba")
    
    println(if (check.contains(input)) "Yes" else "No")
}

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

int main(){
    int n, sum, num = 0, ans = 0;
    cin >> n;
    for(int i=1; i<=n; i=i+2){
        for(int j=1; j<=i; ++j){
            if(i % j == 0){
                ++num;
            }
        }
        if(num == 8){
            ++ans;
        }
        num = 0;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
/**
 * @Author: Mingyu Li
 * @Date:   2019-02-24T19:53:08+08:00
 * @Email:  class11limingyu@126.com
 * @Filename: task.cpp
 * @Last modified by:   Mingyu Li
 * @Last modified time: 2019-02-24T20:12:00+08:00
 */

#include <bits/stdc++.h>
#define tpname typename
#define go(i , x , y) for(__typeof(x) i = x; i <= y; i++)
#define god(i , y , x) for(__typeof(y) i = y; i >= x; i--)
typedef long long LL;
typedef long double ld;
typedef unsigned long long ULL;
template < tpname T > void scan(T& t) {
  char c = getchar(); T x = 1; t = 0; while(!isdigit(c)) {if(c == '-') x = -1; c = getchar();}
  while(isdigit(c)) t = t * 10 + c - '0' , c = getchar();t *= x;
}
template < tpname T , tpname... Args > void scan(T& t , Args&... args) {scan(t); scan(args...);}
template < tpname T > T mul(T x , T y , T _) {
  x %= _,y %= _;
  return ((x * y - (T)(((ld)x * y + 0.5) / _) * _) % _ + _) % _;
}
using namespace std;

const int N = 100000 + 10;
int n;
double x[N] , u[N];
int main() {
  double ans = 0;
  cin >> n;
  for(int i = 1; i <= n; i++) {
    cin >> x[i];
    string y; cin >> y;
    if(y == "JPY") ans += x[i];
    else ans += x[i] * 380000.0;
  }
  cout << fixed << setprecision(8) << ans << endl;
  return 0;
}


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

int main(){
    string str1, str2, str3;
    cin >> str1;
    cin >> str2;
    cin >> str3;

    cout << str1[0] << str2[1] << str3[2] << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Rep(i, k, n) for (int i = k; i < (int)(n); i++)
#define RRep(i, k, n) for (int i = k; i > (int)(n); i--)
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define ALL(a)  (a).begin(),(a).end()
#define rALL(a)  (a).rbegin(),(a).rend()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
const int MOD = 1000000007;
const double PI = acos(-1); //3.14~
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main()
{
    int n, q; cin >> n >> q;
    string str; cin >> str;
    vector<int> s(n + 1, 0);
    rep(i, n)
    {
        if (str[i] == 'A' && str[i + 1] == 'C' && i + 1 < n) s[i + 1] = s[i] + 1;
        else s[i + 1] = s[i];
    }

    rep(i, q)
    {
        int l, r; cin >> l >> r; l--;r--;
        cout << s[r] - s[l] << endl;
    }
}

Measured memory_bytes: 1408
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <stdio.h>
#include <iomanip>
#include <limits>
#include <list>
#include <string>
#include <queue>
#include <deque>
#include <tuple>
#include <map>
#include <sstream>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort(ALL(x))
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const long double PI  = acos(-1.0L);
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
#define chmax(a,b) a = (((a)<(b))?(b):(a))
#define chmin(a,b) a = (((a)>(b))?(b):(a))

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

signed main(){
	string s; cin>>s;
	vector<string> w(3); w[0]="Sunny"; w[1]="Cloudy"; w[2]="Rainy";
	rep(i,3){
		if(s==w[i]) cout << w[(i+1)%3];
	}

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int h,w;
    cin >> h >> w;
    vector<vector<char>> a(h,vector<char>(w));
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            cin >> a[i][j];
        }
    }
   for(int i =0; i < w + 2; i++){
       cout << "#";
   }
   cout << endl;
   for(int i = 0; i < h; i++){
      for(int j = 0; j < w + 2; j++){
          if(j == 0 || j == w + 1)
          cout << "#";
          else
          {
              cout << a[i][j - 1];
          }
      }
      cout << endl;
      }
        for(int i = 0; i < w + 2; i++)
          cout << "#";
      cout << endl;
   }


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using LL = long long int;
#define incID(i, l, r) for(int i = (l)    ; i <  (r); ++i)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); --i)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); ++i)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define dec(i, n)  decID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec1(i, n) decII(i, 1, n)
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define FR front()
#define BA back()
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
auto setmin   = [](auto & a, auto b) { return (b <  a ? a = b, true : false); };
auto setmax   = [](auto & a, auto b) { return (b >  a ? a = b, true : false); };
auto setmineq = [](auto & a, auto b) { return (b <= a ? a = b, true : false); };
auto setmaxeq = [](auto & a, auto b) { return (b >= a ? a = b, true : false); };
#define SI(v) static_cast<int>(v.size())
#define RF(e, v) for(auto & e: v)
#define until(e) while(! (e))
#define if_not(e) if(! (e))
#define ef else if
#define UR assert(false)
#define IN(T, ...) T __VA_ARGS__; IN_(__VA_ARGS__);
void IN_() { };
template<typename T, typename ... U> void IN_(T & a, U & ... b) { cin >> a; IN_(b ...); };
template<typename T> void OUT(T && a) { cout << a << endl; }
template<typename T, typename ... U> void OUT(T && a, U && ... b) { cout << a << " "; OUT(b ...); }

// ---- ----

int main() {
	IN(string, s);
	OUT(s == "ABC" ? "ARC" : "ABC");
}


Measured memory_bytes: 3592
import java.util.*;
import java.util.stream.*;
class Main {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int n;
        int[] s;
        double mean,stdiv,var;
        while (true){
            n = input.nextInt();
            if (n == 0){
                break;
            }
            s = new int[n];
            var = 0;
            mean = 0;
            for (int i = 0; i < n; i++){
                s[i] = input.nextInt();
                mean += s[i];
            }
            mean /= n;
            for (int i = 0; i < n; i++){
                var += Math.pow(s[i]-mean,2);
            }
            var /= n;
            stdiv = Math.sqrt(var);
            System.out.println(stdiv);
        }
    }
}


Measured memory_bytes: 31400
prime = Array.new(10 ** 6,true)
for i in 2..10 ** 3
  if prime[i]
    for j in 2..10 ** 6 / i
      prime[i * j] = false
    end
  end
end
while n = gets
  puts prime[2..n.to_i].select{|i|i}.size
end



Measured memory_bytes: 28600
#include<stdio.h>
int main(){
	int n,i,min=0,count;
  	scanf("%d",&n);
  	char s[n];
  	scanf("%s",s);
  	for(i=0;i<n;i++){
    	if(s[i]=='.') min++;
    }
  	count=min;
  	for(i=0;i<n;i++){
    	if(s[i]=='#') count++;
      	else count--;
      	if(count<min) min=count;
    }
 	printf("%d",min);
	return 0;
}

Measured memory_bytes: 384
#define _USE_MAT_DEFINES
#include<iostream>
#include <iomanip>
#include<stdio.h>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include <queue>
#include <utility>
#include <map>
#include <set>
#include <stack>
#include <deque>
#include <numeric>
#include <functional>
using namespace std;

int main() {
    long long N, M;
    cin >> N >> M;
    if (N > M)swap(N, M);

    long long ans;
    if (N == 1 && M == 1)ans = 1;
    else if (N == 1)ans = M - 2;
    else ans = (N - 2)*(M - 2);

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main (){
       int k,s,ans = 0;
       cin >> k >> s;
       
       for (int i = 0; i <= k; i++)
              for (int y = 0; y <= k; y++)
                     if (s - i - y  <= k && s - i - y >= 0) ans++;
                     
       cout<<ans<<"\n";
}

Measured memory_bytes: 256
// Original: https://github.com/tanakh/competitive-rs
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::VecDeque;

const DXY: [(i64, i64); 4] = [(-1, 0), (0, -1), (0, 1), (1, 0)];
const INF: i64 = 1 << 30;

fn main() {
    input!(h: usize, w: usize, graph: [chars; h]);

    // 幅優先探索
    // 問題を読み替えると、'#'マスから最も遠い'.'マスへの最短路を求める問題に落とし込める
    let mut dist = vec![vec![INF; w]; h];
    let mut que = VecDeque::new();
    for y in 0..h {
        for x in 0..w {
            if graph[y][x] == '#' {
                que.push_back((y, x));
                dist[y][x] = 0;
            }
        }
    }

    while let Some((y, x)) = que.pop_front() {
        for &(dy, dx) in DXY.iter() {
            let ny = y as i64 + dy;
            let nx = x as i64 + dx;

            if !(0 <= ny && ny < h as i64 && 0 <= nx && nx < w as i64) {
                continue;
            }

            let ny = ny as usize;
            let nx = nx as usize;
            if dist[ny][nx] > dist[y][x] + 1 {
                dist[ny][nx] = dist[y][x] + 1;
                que.push_back((ny, nx));
            }
        }
    }

    let ans = dist.iter().map(|x| x.iter().max().unwrap()).max().unwrap();
    println!("{}", ans);
}


Measured memory_bytes: 31992
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <sstream>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <numeric>
#include <cctype>
#include <tuple>

#ifdef _MSC_VER
#include <agents.h>
#endif

#define FOR(i, a, b) for(int i = (a); i < (int)(b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ALL(v) begin(v), end(v)
#define REV(v) rbegin(v), rend(v)
#define MEMSET(v, s) memset(v, s, sizeof(v))
#define X first
#define Y second

using namespace std;

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

const int N = 1 << 16;
int isp[N];

int main(){
	fill(isp, isp + N, 1);
	isp[0] = isp[1] = 0;
	for (int i = 2; i * i < N; ++i){
		if (isp[i]){
			for (int j = i * 2; j < N; j += i) isp[j] = 0;
		}
	}

	int n;
	while (cin >> n, n){
		int cnt = 0;
		for (int i = 0; i <= n/2; ++i){
			if (isp[i] + isp[n - i] == 2) ++cnt;
		}
		cout << cnt << endl;
	}

	return 0;
}

Measured memory_bytes: 1416
n,x = map(int,input().split())
li = list(map(int,input().split()))
d = [0]*(n+1)
d[0] = 0
cnt = 0
for i in range(1,n+1):
    d[i] = d[i-1] + li[i-1]
    if d[i] <= x:
        cnt += 1
print(cnt+1)

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

int main() {
    int l, r;
    cin >> l >> r;

    bool b = false;
    int m = 2020;
    int n;

    for (int i = l; i < r; i++) {
        for (int k = 1; i + k <= r; k++){
            if((i+k)%2019==0){
                m = 0;
                break;
            }
            m=min(((i%2019)*((i+k)%2019))%2019, m);
        }

        if(m==0){
            break;
        }
    }


    cout << m << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ll long long int
const int INF = 2147483647;
const ll MOD = 1000000007;

using namespace std;

int main() {
  int n;
  cin >> n;
  cout << (n - 1) / 2 << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int co=0,co1=0,Rectangle=0,Rhombus=0;
    double side[3];
    char str[300];
    while(cin>>str){
        for(int i=0;i<3;i++)side[i]=0;
        for(int i=0;i<=strlen(str);i++){
            if(str[i]==','||str[i]=='\0'){
                for(int j=co;j<i;j++)side[co1]+=(str[j]-'0')*pow(10,i-j-1);
                co=i+1;
                co1++;
            }
        }co=0;co1=0;
        if(side[0]==side[1])Rhombus++;
        else if(side[0]*side[0]+side[1]*side[1]==side[2]*side[2])Rectangle++;
    }
    cout<<Rectangle<<endl<<Rhombus<<endl;
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
using namespace std;
#define int long long
using ll=long long;
using vi=vector<int>;
using pii=pair<int,int>;
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define FORE(x,c) for(auto &x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define SZ(c) ((int)c.size())
#define CONTAIN(c,x) (c.find(x)!=end(c))
#define OUTOFRANGE(y,x,h,w) (y<0||x<0||y>=h||x>=w)
#define dump(...)
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
#define INF (1001001001)
#define INFLL (1001001001001001001ll)
template<class T> ostream& operator << (ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v)) os<<*i<<(i==end(v)-1?"":" "); return os; }
template<class T> istream& operator >> (istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i; return is; }
template<class T> istream& operator >> (istream &is, pair<T,T> &p) {
    is>>p.first>>p.second; return is; }
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 T> using heap = priority_queue<T,vector<T>,greater<T>>;
struct before_main_function {
    before_main_function() {
        #ifdef int
            #undef INF
            #define INF INFLL
            #define stoi stoll
        #endif
        cin.tie(0);ios::sync_with_stdio(false);
        cout<<setprecision(15)<<fixed;
        #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

signed main() {
    int H,W;
    cin>>H>>W;
    if(H%3==0 || W%3==0) {
        cout<<0<<endl;
        return 0;
    }

    int ans=INF;
    REPF(i,1,H) {
        int A=i*W;
        int BC=(H-i)*W;
        int B=((H-i)/2)*W;
        int C=BC-B;
        chmin(ans,max({A,B,C})-min({A,B,C}));
        int B_=(W/2)*(H-i);
        int C_=BC-B_;
        chmin(ans,max({A,B_,C_})-min({A,B_,C_}));
    }
    REPF(i,1,W) {
        int A=i*H;
        int BC=(W-i)*H;
        int B=((W-i)/2)*H;
        int C=BC-B;
        chmin(ans,max({A,B,C})-min({A,B,C}));
        int B_=(H/2)*(W-i);
        int C_=BC-B_;
        chmin(ans,max({A,B_,C_})-min({A,B_,C_}));
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <math.h>

unsigned int factorial(unsigned int n){
    if (n==0) return 1;
    else return n*factorial(n-1);
}

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

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

    vector<pair<int,int>> xy(n);
    vector<int> a(n);
    for(int i=0;i<n;i++) {
        cin>>xy[i].first>>xy[i].second;
        a[i]=i;
    }

    double l_sum=0;

    do{
        for(int i=0;i<n-1;i++){
            l_sum+=sqrt(pow(xy[a[i]].first-xy[a[i+1]].first,2)+pow(xy[a[i]].second-xy[a[i+1]].second,2));
        }
    }while(next_permutation(a.begin(),a.end()));

    cout<<fixed<<setprecision(10)<<l_sum/(double) factorial(n)<<endl;

    return 0;
}

Measured memory_bytes: 3760
#include <stdio.h>
#include <math.h>
int main(void){
    double x1, y1, x2, y2,s,t,u,v;
    scanf("%lf %lf %lf %lf", &x1, &y1, &x2, &y2);
    s=x2-x1;
    t=y2-y1;
    u=pow(s,2);
    v=pow(t,2);

    
    printf("%.8f\n",sqrt(u+v));
    
    return 0;
    
}



Measured memory_bytes: 2104
#include <bits/stdc++.h>
#include <algorithm>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define stdi(in) freopen(in, "r", stdin)
#define stdo(out) freopen(out, "w", stdout)
#define stdio(in, out) stdi(in); stdo(out)
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define MAX 100007
#define MOD 1000000007
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)

using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
#define ordered_set tree<pair<int, int> , null_type, less<pair<int, int> >, rb_tree_tag, tree_order_statistics_node_update>

const ll modd = 998244353;
const ll inf = 1e18;

int n,m;
int dp[1002][1002];
string arr[3002];

ll solve(int i, int j){
	if(i==n-1 && j==m-1){
		return 1;
	}

	if(i>=n || j>=m) return 0;

	if(dp[i][j]!=-1) return dp[i][j];

	ll ans = 0;
	if(i<n && arr[i+1][j]!='#'){
		ans = (ans+solve(i+1, j))%MOD;
	}

	if(j<m && arr[i][j+1]!='#'){
		ans = (ans+solve(i, j+1))%MOD;
	}

	return dp[i][j] = ans;
}

int main(){
	/*#ifndef ONLINE_JUDGE
        stdio("in", "out");
    #endif*/
    fast;
    
    cin>>n>>m;
    for(int i=0;i<n;i++){
    	cin>>arr[i];
    }

    memset(dp, -1, sizeof(dp));

    cout<<solve(0,0)<<'\n';

	return 0;
}



Measured memory_bytes: 5376
import math
import time
from collections import defaultdict, deque
from sys import stdin, stdout
from bisect import bisect_left, bisect_right
n=int(input())
poss=False
for i in range(1,10):
    for j in range(i,10):
        if(i*j==n):
            poss=True
            break
if(poss):
    print("Yes")
else:
    print("No")

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

#define rep(i, u) for (int i = 0; i < u; i++)

using ll = long long;
using ull = unsigned long long;

int main() {
  string s;
  while (true) {
    cin >> s;
    if (s == "0") break;
    int ans = 0;
    rep(i, (int)s.size()) ans += s[i] - '0';
    cout << ans << endl;
  }
  return 0;
}



Measured memory_bytes: 3108
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define range(i,a,n) for(int i=(a);i<(n);i++)

#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.1415926535897932384

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

template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S acm(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
void YN(bool b){cout<<(b?"YES":"NO")<<"\n";}
void Yn(bool b){cout<<(b?"Yes":"No")<<"\n";}
void yn(bool b){cout<<(b?"yes":"no")<<"\n";}

ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s;a=0;} return os;}
#define _cTime (chrono::system_clock::now())
#define progress (chrono::duration_cast<chrono::milliseconds>(_cTime-_sTime).count())
#define reset _sTime=_cTime
auto reset;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int a,b,c;
	cin>>a>>b>>c;
	cout<<min(c,b/a)<<endl;
}


Measured memory_bytes: 892
using namespace std;

#include <bits/stdc++.h>

int main(){
    int N, K, Q;
    cin >> N >> K >> Q;
    int a[N+7] = {0};
    for ( int i = 0; i < Q; i ++ ){
        int t;
        cin >> t;
        a[t] += 1;
    }
    for ( int i = 1; i <= N; i ++ ){
        if ( K - ( Q - a[i] ) > 0 ) cout << "Yes" << endl;
        else cout << "No" << endl;
    }

}


Measured memory_bytes: 1024
#include <stdio.h>
#include <string.h>
#define MAX 101
#define max(a, b) ((a>b) ? (a) : (b))
#define min(a, b) ((a<b) ? (a) : (b))
int main(void) {
    long long i, j, len, a[11], t, sum=0;
    char s[11];
    scanf("%s", s);
    len = strlen(s);
    
    for(i=0; i<len; i++)
        a[i] = s[i] - '0';
    
    for(i=0; i<1<<(len-1); i++) {
        t=a[0];
        for(j=0; j<len-1; j++) {
            if(1&i>>j) {
                sum += t;
                t = 0;
                
            }
            t *= 10;
            t += a[j+1];
        }
        sum += t;
    }
    printf("%lld\n", sum);
}

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

public class Main {
    public static void main(String[] args) throws IOException {
        execute();
    }

    private static void execute() throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String number = br.readLine();
        System.out.println(divisibleDigitSum(number));
    }

    private static String divisibleDigitSum(String number) {
        int digitSum = 0;
        for (char digit : number.toCharArray()) {
            digitSum += Integer.parseInt(String.valueOf(digit));
        }
        boolean divisible = Integer.parseInt(number) % digitSum == 0;
        return divisible ? "Yes" : "No";
    }
}

Measured memory_bytes: 21076
n,m = map(int,input().split())
c = []
for i in range(n):
    x,y = map(int,input().split())
    c.append([x,y])
c = sorted(c)
cost = 0
for i in range(n):
    if(m==0):
        break
    else:
        if(c[i][1]>m):
            cost+=(m*c[i][0])
            m = 0
        else:
            cost+=(c[i][1]*c[i][0])
            m-=c[i][1]
print(cost)


Measured memory_bytes: 20824
#include<bits/stdc++.h>
using namespace std;
#ifdef LOCAL_DEBUG
  #include "LOCAL_DEBUG.hpp"
#endif
#define int long long

signed main(){

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

  vector<int> b(n+1);
  b[0] = 0;
  for(int i = 0; i < n; i++){
    b[i+1] = b[i] + a[i];
  }

  static int dp[500][500];
  function< int(int,int) > rec =
  [&](int l,int r){
    if(l+1 >= r) return 0LL;
    if(dp[l][r] > 0) return dp[l][r];
    int res = 1LL << 60;
    for(int i = l+1; i < r; i++){
      res = min(res,rec(l,i) + rec(i,r) + (b[r] - b[l]));
    }
    return dp[l][r] = res;
  };
  cout << rec(0,n) << endl;

  return 0;
}


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

int main() {
  int N; cin >> N; // 都市数
  int M; cin >> M; // 道路数
  vector<int> A(M); // 都市Ａ
  vector<int> B(M); // 都市Ｂ
  vector<int> R(N+1,0); // 各都市から出ている道路数：都市番号と配列番号を一致させる。
  
  rep(i,M){
    cin >> A.at(i);
    cin >> B.at(i);
    
    // cout << i << ":" << A.at(i) << ":" << B.at(i) << endl;
    R.at(A.at(i)) +=1;
    R.at(B.at(i)) +=1;
  }

  rep(i,N+1){
    //cout << i << ":";
    if ( i != 0 ) {
      cout << R.at(i) << endl;
    }
  }


}



Measured memory_bytes: 256