akhauriyash/Code-Regression huggingface dataset:
import math

A,B,T=map(int,input().split())

if isinstance(A,int) and isinstance(B,int) and isinstance(T,int) :
    num_biscuit=0
    if 1<=A<=20 and 1<=B<=20 and 1<=T<=20:
        for i in range(math.floor(T/A)):
            num_biscuit=num_biscuit+B
        print(num_biscuit)
    # else :                                                                               
    #     print(0)                                                                         

else :
    print("ERROR")
    exit()


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

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
 
    ll N; cin >> N;
    ll sum = 0;
    vel a(N); rep(i,N) {cin >> a[i]; sum += a[i];}
 
    ll  x = 0;
    ll ans=1000000000000000000LL;
 
    rep(i,N-1) {
        x += a[i];
        ans = min(ans, abs(2*x - sum));
    }
 
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, x, n) for (int i = x; i < (n); i++)
#define all(n) begin(n), end(n)
struct cww
{
    cww()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
} star;
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<char> vchar;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;
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 <typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template <typename T, typename... Ts>
auto make_v(size_t a, Ts... ts)
{
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }

template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v)
{
    for (auto &e : t)
        fill_v(e, v);
}
bool ok(string s, int x[3])
{
    int p = s[0] - 'A', q = s[1] - 'A';
    if (x[p] == 0 and x[q] == 0)
        return false;
    return true;
}
int main()
{
    int N;
    int x[3];
    cin >> N >> x[0] >> x[1] >> x[2];
    vector<string> s(N);
    vector<char> ans;
    for (size_t i = 0; i < N; i++)
    {
        cin >> s[i];
    }
    for (size_t i = 0; i < N; i++)
    {
        int n1 = s[i][0] - 'A', n2 = s[i][1] - 'A';
        if (x[n1] == 0 and x[n2] == 0)
        {
            cout << "No";
            return 0;
        }
        else if (x[n1] == 1 and x[n2] == 0)
        {
            x[n1]--;
            x[n2]++;
            ans.push_back(s[i][1]);
        }
        else if (x[n1] == 0 and x[n2] == 1)
        {
            x[n1]++;
            x[n2]--;
            ans.push_back(s[i][0]);
        }
        else if (x[n1] < x[n2])
        {

            x[n1]++;
            x[n2]--;
            ans.push_back(s[i][0]);
        }
        else if (x[n1] > x[n2])
        {
            x[n1]--;
            x[n2]++;
            ans.push_back(s[i][1]);
        }
        else if (x[n1] == x[n2])
        {
            int next[3];
            next[n1] = x[n1] - 1;
            next[n2] = x[n2] + 1;
            next[3 - n1 - n2] = x[3 - n1 - n2];
            if (ok(s[i + 1], next))
            {
                x[n1]--;
                x[n2]++;
                ans.push_back(s[i][1]);
            }
            else
            {
                x[n1]++;
                x[n2]--;
                ans.push_back(s[i][0]);
            }
        }
    }

    cout << "Yes\n";
    for (auto &&i : ans)
    {
        cout << i << "\n";
    }

    return 0;
}

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

int KetanoWa(std::string str)
{
    int sum = 0;
    for(std::size_t i = 0; i < str.size(); ++i){
        sum += str[i] - 48;
    }
    return sum;
}
int main()
{
    
    while(true){
        std::string s;
        std::cin >> s;
        int sum = KetanoWa(s);
        if(sum == 0) break;
        std::cout << KetanoWa(s) << std::endl;
    }
    return 0;
}

Measured memory_bytes: 1192
H, W = map(int, input().split())

l = [input() for i in range(H)]

y = [False] * H
x = [False] * W

for i in range(H):
    flg = True
    for j in range(W):
        if l[i][j] != '.':
            flg = False
            break
    if flg:
        y[i] = True

for i in range(W):
    flg = True
    for j in range(H):
        if l[j][i] != '.':
            flg = False
            break
    if flg:
        x[i] = True

for i in range(H):
    if y[i]:
        continue
    for j in range(W):
        if x[j]:
            continue
        print(l[i][j], end='')
    print()

Measured memory_bytes: 4468
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class Program
{
    static void Main(string[] args)
    {
        var n = int.Parse(Console.ReadLine());
        var s = Console.ReadLine();
        //var d = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();

        var ans = s.Length;
        for (int x = 0; x < s.Length - 1; x++)
        {
            if (s[x] == s[x + 1])
            {
                ans--;
            }
        }

        Console.WriteLine(ans);
    }
}

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

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vector<vector<bool>>> vvvb;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<vpll> vvpll;
typedef vector<double> vd;
typedef vector<vd> vdd;

#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)
#define REP(i,y) FOR(i, 0, y)
#define RFOR(i,x,y) for(ll i=(ll)x; i>=(ll)y; --i)
#define RREP(i,x) RFOR(i, x, 0)
#define ALL(a) a.begin(), a.end()
#define pb push_back
#define debug_print(x...) cerr << "line " << __LINE__ << " : "; debug_print_in(x);

template <typename First>
void debug_print_in(First first){
  cerr << first << endl;
  return;
}

template <typename First, typename... Rest>
void debug_print_in(First first, Rest... rest){
  cerr << first << " ";
  debug_print_in(rest...);
  return;
}

void IN(void){
  return;
}

template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){
  cin >> first;
  IN(rest...);
  return;
}

template <typename First>
void OUT(First first){
  cout << first << endl;
  return;
}

template <typename First, typename... Rest>
void OUT(First first, Rest... rest){
  cout << first << " ";
  OUT(rest...);
  return;
}

template<class t, class u> void chmax(t&a,u b){if(a<b)a=b;};
template<class t, class u> void chmin(t&a,u b){if(a>b)a=b;};
int popcount(int t){return __builtin_popcount(t);} //GCC
int popcount(ll t){return __builtin_popcountll(t);} //GCC

template <typename T>
void vec_print(vector<T> VEC){
  REP(i, VEC.size()){
    cerr << VEC[i] << " ";
  }
  cerr << endl;
};

template <typename T>
void mat_print(vector<vector<T> > MAT){
  REP(i,MAT.size()){
    REP(j,MAT[i].size()){
      cerr << MAT[i][j] << " ";
    }
    cerr << endl;
  }
};

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;
constexpr ll MOD = (ll)((1E+9)+7);

int main(){
  cin.tie(0); // cut the cin and cout (default, std::flush is performed after std::cin)
  ios::sync_with_stdio(false); // cut the iostream and stdio (DON'T endl; BUT "\n";)

  ll T1, T2;
  ll A1, A2;
  ll B1, B2;

  IN(T1,T2);
  IN(A1,A2);
  IN(B1,B2);

  if(T1*A1+T2*A2 == T1*B1+T2*B2){
    OUT("infinity");
    return 0;
  }

  if(T1*A1+T2*A2<T1*B1+T2*B2){
    swap(A1, B1);
    swap(A2, B2);
  }

  if(A1>B1 && A2>B2){
    OUT(0);
    return 0;
  }

  if(A2>B2){
    ll Q1 = (T1*A1-T1*B1);
    ll Q2 = (T1*B1+T2*B2-T1*A1-T2*A2);
    ll N = Q1/Q2;
    if(Q1==N*Q2){
      OUT(2*N);
    }else{
      OUT(2*N+1);
    }
    return 0;
  }
  OUT(0);

  return 0;
}

Measured memory_bytes: 256
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

#A
def A():

    return

#B
def B():

    return

#C
def C():
    n,c = LI()
    a = LI()
    b = LI()
    s = [[0]*(c+1) for i in range(n)]
    for i in range(n):
        ai,bi = a[i],b[i]
        for x in range(ai,bi+1):
            e = 1
            for k in range(c+1):
                s[i][k] += e
                if s[i][k] >= mod:
                    s[i][k] %= mod
                e *= x
                if e >= mod:
                    e %= mod
    dp = [[0]*(c+1) for i in range(n)]
    for k in range(c+1):
        dp[0][k] = s[0][k]

    for i in range(1,n):
        for k in range(c+1):
            for j in range(k+1):
                dp[i][k] += dp[i-1][j]*s[i][k-j]
                if dp[i][k] >= mod:
                    dp[i][k] %= mod
    print(dp[-1][c])
    return

#D
def D():

    return

#E
def E():

    return

#F
def F():

    return

#Solve
if __name__ == "__main__":
    C()


Measured memory_bytes: 44272
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int H,W,K;
    cin >> H >> W >> K;
    int i,j;
    vector<vector<char>> c(H,vector<char>(W));
    for(i=0;i<H;i++){
        for(j=0;j<W;j++){
            cin >> c.at(i).at(j);
        }
    }
    int count = 0;
    int ans = 0;
    int bitX,bitY;
    for(bitY=0;bitY<(1<<H);bitY++){
        for(bitX=0;bitX<(1<<W);bitX++){
            count = 0;

            for(i=0;i<H;i++){
                for(j=0;j<W;j++){
                    if(!(bitY&(1<<i)) && !(bitX&(1<<j)) && c.at(i).at(j) == '#'){
                        count++;
                    }
                }
            }

            if(count == K){
                ans++;
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3608
<?php
fscanf(STDIN, "%d %d", $N, $M);
$sum = array_pad(array(), $M, 0);
for ($i = 0; $i < $N; $i++) {
    list($K, $dummy) = explode(" ", trim(fgets(STDIN)), 2);
    $A = explode(" ", $dummy);
    foreach ($A as $v) {
        $sum[$v - 1]++;
    }
}
$ans = 0;
for ($i = 0; $i < $M; $i++) {
    if ($sum[$i] === $N) {
        $ans++;
    }
}
echo $ans;


Measured memory_bytes: 5368
#include <bits/stdc++.h>
using namespace std;
int a,b,c,d,e,f;
const int MaxS = 3003;
bool can1[MaxS],can2[MaxS];
int main() {
    scanf("%d%d%d%d%d%d",&a,&b,&c,&d,&e,&f);
    can1[0]=true;
    for (int i=0;i<=f;i+=100) if (can1[i]){
        if (i+100*a<=f) can1[i+100*a]=true;
        if (i+100*b<=f) can1[i+100*b]=true;
    }
    can2[0]=true;
    for (int i=0;i<=f;++i) if (can2[i]) {
        if (i+c<=f) can2[i+c]=true;
        if (i+d<=f) can2[i+d]=true;
    }
    int ans1=100*a,ans2=0;
    double p=0;
    for (int i=100;i<=f;i+=100) if (can1[i])
        for (int j=0;j<=e*i/100 && i+j<=f;++j) if (can2[j]) {
            double t=(double)j/(i+j)*100;
            if (t>p) {
                p=t;
                ans1=i,ans2=j;
            }
        }
    printf("%d %d\n",ans1+ans2,ans2);
    return 0;
}

Measured memory_bytes: 256
using System;

namespace ABC178
{
    class Program
    {
        static void Main()
        {
            // 全体 - (0がない場合 + 9がない場合 - 0,9がない場合)
            var n = int.Parse(Console.ReadLine());

            var mod = new Modulo();
            long l = (mod.Pow(10, n) - (mod.Multiply(mod.Pow(9, n), 2) - mod.Pow(8, n)) % 1000000007) % 1000000007;
            Console.WriteLine(l < 0 ? 1000000007 + l : l);
        }
    }

    public class Modulo
    {
        private readonly int M = 1000000007;

        public int Multiply(int a, int b)
        {
            return (int)(Math.BigMul(a, b) % M);
        }

        public int Pow(int a, int m)
        {
            switch (m)
            {
                case 0:
                    return 1;
                case 1:
                    return a;
                default:
                    int p1 = Pow(a, m / 2);
                    int p2 = Multiply(p1, p1);
                    return ((m % 2) == 0) ? p2 : Multiply(p2, a);
            }
        }
    }
}


Measured memory_bytes: 27400
#include<iostream>

using namespace std;

long long s[2010];
long long t[2010];
long long dp[2010][2010] = {{}};
#define mod 1000000007

int main(){
  int n, m;
  cin >> n >> m;
  for(int i = 0 ; i < n; i++){
    cin >> s[i];
  }
  for(int i = 0; i < m; i++){
    cin >> t[i];
  }
  for(int i = 0; i <= n ; i++) dp[i][0] = 1;
  for(int j = 0; j <= m ; j++) dp[0][j] = 1;
  for(int i = 0; i < n; i++){
    for(int j = 0; j < m ; j++){
      dp[i+1][j+1] = (dp[i][j+1] + dp[i+1][j])%mod;
      if(s[i] == t[j]){
        dp[i+1][j+1] += dp[i][j];
        dp[i+1][j+1] %= mod;
      }
      dp[i+1][j+1] += mod-dp[i][j]; //The point
      dp[i+1][j+1] %= mod;
    }
  }
  cout << dp[n][m] << endl;
}


Measured memory_bytes: 31744
#include <iostream>
#include <string.h>
#include <stdlib.h>
using namespace std;

int main(int argc, const char * argv[]) {
    int a, b, c;
    cin >> a >> b >> c;
    int cache,count = 0;
    for(int i = 0; i < 2; i++){
        if(a > b){
            cache = a;
            a = b;
            b = cache;
        }
        if(b > c){
            cache = b;
            b = c;
            c = cache;
        }
    }
    if(a % 2 == b % 2){
        while(a != c && a != c - 1){
            a+=2;
            count++;
        }
        while(b != c && b != c - 1){
            b+=2;
            count++;
        }
        if(a == c - 1 && b == c - 1){
            a++;
            b++;
            count++;
        }
    }else{
        a++;
        c++;
        count++;
        while(b != c){
            a++;
            b++;
            count++;
        }
        while(a != c){
            a+=2;
            count++;
        }
    }
    cout << count << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)n; i++)
typedef long long ll;
typedef pair<int,int> P;
 
int main(){
  int n, count=0; cin >> n;
  vector<int> vec(n);
  rep(i, n) cin >> vec.at(i);
  rep(i, n-2) {
    if (vec.at(i) < vec.at(i+1) && vec.at(i+1) < vec.at(i+2)) count++;
  }
  rep(i, n-2) {
    if (vec.at(i) > vec.at(i+1) && vec.at(i+1) > vec.at(i+2)) count++;
  }
  cout << count << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;

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

const int maxn = 2e5;
const ll mod = 998244353LL;
const ll inf = 1e9;

int main() {
	int i, j, n;
	cin >> n;
	ll ans = 0;
	map<string, int> mp;
	for(i = 1; i <= n; ++i) {
		string s;
		cin >> s;
		sort(s.begin(), s.end());
		ans += mp[s];
		mp[s]++;
	}
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 11136
#include <bits/stdc++.h>
using namespace std;
#define ALL(x) (x).begin(),(x).end()
#define COUT(x) cout<<(x)<<"\n"
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define REP(i, n) for(int i=0;i<n;i++)
#define YES(x) cout<<(x?"YES":"NO")<<"\n"
#define Yes(x) cout<<(x?"Yes":"No")<<"\n"
#define dump(x) cout<<#x<<" = "<<(x)<<"\n"
#define endl "\n"
using G = vector<vector<int>>;
using M = map<int,int>;
using P = pair<int,int>;
using PQ = priority_queue<int>;
using PQG = priority_queue<int,vector<int>,greater<int>>;
using V = vector<int>;
using ll = long long;
using edge = struct { int to; int cost; };
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; }
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

int main() {
  IOS;
  int n,m; cin >> n >> m;

  int g[n][n];
  int dp[n][n];
  REP(i,n) REP(j,n) {
    g[i][j] = 0;
    dp[i][j] = j==i ? 0 : INF;
  }

  REP(i,m) {
    int from, to, cost;
    cin >> from >> to >> cost;
    from--; to--;
    g[from][to] = cost;
    g[to][from] = cost;
    dp[from][to] = cost;
    dp[to][from] = cost; // 双方向
  }

  REP(k,n) { // 経由する頂点
    REP(i,n) { // 開始頂点
      REP(j,n) { // 終端
        dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j]);
      }
    }
  }

  int ans = 0;
  REP(i,n) REP(j,n) {
    if (dp[i][j] < g[i][j]) ans++;
  }
  COUT(ans/2);
  return 0;
}

Measured memory_bytes: 3724
#include<bits/stdc++.h>
#define ll long long
#define MAXN 100010
#define INF 1000000010

using namespace std;

ll n, dp[MAXN], h[MAXN], k;

void init(){
    for(int i=1; i<=n; i++) dp[i]=INF;
    dp[1]=0;
    h[0]=INF;
}

int main(){

    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    cin>>n>>k;

    for(int i=1; i<=n; i++) cin>>h[i];

    init();

    for(int i=2; i<=n; i++){
        for(int j=1; j<=k; j++){
            if(i-j>0) dp[i]=min(dp[i], dp[i-j]+abs(h[i]-h[i-j]));
        }
    }

    cout<<dp[n];

return 0;
}


Measured memory_bytes: 1792
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define sbits(a) __builtin_popcount(a)
#define smin(a, b) a = min(a, b)
#define smax(a, b) a = max(a, b)
#define gcd __gcd
#define lcm(a, b) ((a * b) / gcd(a, b))
#define pq priority_queue
#define um unordered_map
#define us unordered_set
#define lb lower_bound
#define ub upper_bound
#define F first
#define B begin()
#define E end()
#define ln length()
#define sz size()
#define S second
#define em empty()
#define nani(x) cerr << #x << " is " << x << endl;
#define ch(x) (x - 'a' + 1)
#define mp make_pair
#define pb push_back
#define loop(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define scan(x, n) loop(i, 0, n) cin >> x[i];
#define adde(g, u, v) g[u].pb(v), g[v].pb(u);
#define addew(g, u, v, w) g[u].pb({ v, w }), g[v].pb({ u, w });
#define print(x, n) loop(i, 0, n) cout << x[i] << " ";
#define fast ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define inf 10000000000001
#define mod 1000000007

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<long> vl;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef pair<long, long> pll;
typedef vector<ii> vii;
typedef vector<pll> vll;
typedef um<int, int> umii;
typedef um<char, int> umci;
typedef map<char, int> mci;
typedef map<int, int> mii;

const int N = 101, maxV = 1e5 + 1;
ll W[N], V[N], dp[maxV][N];

int main()
{
    fast;
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    int n, w;
    cin >> n >> w;

    for (int i = 1; i <= n; i++)
        cin >> W[i] >> V[i];

    dp[0][0] = 0;

    for (int i = 1; i < maxV; i++) {
        dp[i][0] = inf;
        int idx = 0;
        for (int j = 1; j <= n; j++) {
            if (V[j] > i)
                continue;
            if (dp[i - V[j]][j])
                continue;
            if (dp[i - V[j]][0] + W[j] > w)
                continue;
            if (dp[i][0] > dp[i - V[j]][0] + W[j]) {
                dp[i][0] = dp[i - V[j]][0] + W[j];
                idx = j;
            }
        }
        if (idx) {
            dp[i][idx] = 1;
            for (int k = 1; k <= n; k++)
                dp[i][k] |= dp[i - V[idx]][k];
        }
    }

    for (int i = maxV - 1; i > 0; i--)
        if (dp[i][0] <= w) {
            cout << i;
            break;
        }

    return 0;
}


Measured memory_bytes: 79232
#include<stdio.h>
#include<algorithm>
#include<functional>
using namespace std;
int main(void)
{
	int N;
	int a[100000];
	int count = 1;
	int y=0;

	scanf("%d", &N);
	for (int i = 0; i < N; i++) {
		scanf("%d", &a[i]);
		if (i == 0) {
			y = a[i];
		}
	}
	if (a[0] == 2) {
		printf("1");
		return 0;
	}
	
	while (1) {
		if (a[y-1] == 2) {
			count++;
			break;
		}
		else {
			y = a[y-1];
			count++;
		}

		if (count > 100000) {
			printf("-1");
			return 0;
		}
	}

	printf("%d", count);
	return 0;
}


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

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

#define forn(i, a, n) for (int i = a; i < n; ++i)
#define ford(i, a, n) for (int i = n - 1; i >= a; --i)
#define fore(i, a, n) for (int i = a; i <= n; ++i)
#define all(a) (a).begin(), (a).end()
#define fs first
#define sn second
#define trace(a)\
	for (auto i : a) cerr << i << ' ';\
	cerr << '\n'
#define eb emplace_back

#ifndef M_PI
const ld M_PI = acos(-1.0);
#endif

const ld eps = 1e-9;
const int INF = 2000000000;
const ll LINF = 1ll * INF * INF;
const ll MOD = 1000000007;

struct Matrix {
	ll a[2][2];

	Matrix () {};

	Matrix (int cells, int inBound, int outBound) {
		a[0][0] = cells;
		a[0][1] = -inBound;
		if (a[0][1] < 0) a[0][1] += MOD;
		a[1][0] = 0;
		a[1][1] = outBound;
	}

	Matrix operator* (Matrix other) {
		Matrix m(0, 0, 0);
		forn(i, 0, 2) forn(j, 0, 2) forn(k, 0, 2) {
			m.a[i][k] += a[i][j] * other.a[j][k];
			m.a[i][k] %= MOD;
		}
		return m;
	}

	Matrix Pow (ll k) {
		Matrix x = *this, y = Matrix(1, 0, 1);
		while (k) {
			if (k % 2) y = x * y;
			x = x * x;
			k /= 2;
		}
		return y;
	}
};

ll Pow (ll n, ll k) {
	ll x = n, y = 1;
	while (k) {
		if (k % 2) y = y * x % MOD;
		x = x * x % MOD;
		k /= 2;
	}
	return y;
}

const int N = 1002;
char a[N][N];

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int h, w;
	ll k;
	cin >> h >> w >> k;
	if (k <= 1) {
		cout << "1\n";
		return 0;
	}
	forn(i, 0, h) forn(j, 0, w) cin >> a[i][j];
	bool ver = false, hor = false;
	forn(i, 0, h) if (a[i][0] == '#' && a[i][w - 1] == '#') hor = true;
	forn(i, 0, w) if (a[0][i] == '#' && a[h - 1][i] == '#') ver = true;
	if (hor && ver) {
		cout << "1\n";
		return 0;
	}
	int sz = 0;
	forn(i, 0, h) forn(j, 0, w) if (a[i][j] == '#') ++sz;
	if (!hor && !ver) {
		cout << Pow(sz, k - 1) << '\n';
		return 0;
	}
	if (ver) {
		forn(i, 0, N) forn(j, 0, i) swap(a[i][j], a[j][i]);
		swap(h, w);
	}
	int in = 0;
	forn(i, 0, h) forn(j, 0, w - 1) if (a[i][j] == '#' && a[i][j + 1] == '#') ++in;
	int out = 0;
	forn(i, 0, h) if (a[i][0] == '#' && a[i][w - 1] == '#') ++out;
	Matrix M = Matrix(sz, in, out);
	Matrix P = M.Pow(k - 1);
	cout << (P.a[0][0] + P.a[0][1]) % MOD << '\n';
	return 0;
}


Measured memory_bytes: 1280
#include <iostream>
#include<queue>
#include<stack>
#include<vector>
#include<set>
#include<map>
#include<algorithm>
#include<cstring>
#include<string>
#include<cassert>
#include<cmath>
#include<climits>
#include<iomanip>
#include<bitset>
#include<unordered_map>

using namespace std;

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define rep(i,j,n) for(ll (i)=(j);(i)<(n);(i)++)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define ll long long
#define ull unsigned long long
#define all(hoge) (hoge).begin(),(hoge).end()
#define F first
#define S second
typedef pair<ll, ll> P;
const long long INF = 1LL << 60;
const long long MOD = 1e9 + 7;
typedef vector<ll> Array;
typedef vector<Array> Matrix;
const int loose = 0;
const int tight = 1;


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

//グラフ関連
struct Edge {//グラフ
	ll to, cap, rev;
	Edge(ll _to, ll _cap, ll _rev) {
		to = _to; cap = _cap; rev = _rev;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

void add_edge(Graph& G, ll from, ll to, ll cap, bool revFlag, ll revCap) {
	G[from].push_back(Edge(to, cap, (ll)G[to].size()));
	if (revFlag)G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}

void Dijkstra(Graph& G, ll s, Array& d) {//O(|E|log|V|)
	d.resize(G.size());
	REP(i, d.size())d[i] = INF;
	d[s] = 0;
	priority_queue<P, vector<P>, greater<P>> q;
	q.push(make_pair(0, s));
	while (!q.empty()) {
		P a = q.top();
		q.pop();
		if (d[a.second] < a.first)continue;
		REP(i, G[a.second].size()) {
			Edge e = G[a.second][i];
			if (d[e.to] > d[a.second] + e.cap) {
				d[e.to] = d[a.second] + e.cap;
				q.push(make_pair(d[e.to], e.to));
			}
		}
	}
}


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

	ll n, m;
	cin >> n >> m;

	Graph g(3 * n);

	REP(i, m) {
		ll u, v;
		cin >> u >> v;
		u--; v--;

		add_edge(g, u * 3 + 0, v * 3 + 1, 0, false, 0);
		add_edge(g, u * 3 + 1, v * 3 + 2, 0, false, 0);
		add_edge(g, u * 3 + 2, v * 3 + 0, 1, false, 0);
	}

	ll s, t;
	cin >> s >> t;
	s--; t--;
	Array d;
	Dijkstra(g, s * 3, d);

	if (d[t*3] == INF) cout << -1 << endl;
	else cout << d[t*3] << endl;

	return 0;
}

Measured memory_bytes: 19072
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
const int mod = 1e9+7;

int main() {
  int N; cin >> N;
  vector<int> colors(3, 0);
  long long ans = 1LL;
  for(int i = 0; i < N; i++) {
    int A; cin >> A;
    ans *= count(colors.begin(), colors.end(), A);
    ans %= mod;
    for(int j = 0; j < 3; j++) {
      if(colors[j] == A) {
        colors[j] += 1;
        break;
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IO ios_base::sync_with_stdio(false); cin.tie(NULL);

#define endl '\n'
#define D(x) cout << #x << " = " << (x) << endl;

struct counter {
  const int magic = 1000;
  const int maxn = 1000 * 1000 + 100;

  vector<long long> range, sqrt_range;

  counter() : range(maxn),
              sqrt_range((maxn + magic - 1) / magic)
  {}

  void update(int at, long long by) {
    range[at] += by;
    sqrt_range[at / magic] = max(sqrt_range[at / magic], by);
  }

  long long query_max(int left, int right) {
    long long value = 0;

    for (int i = 0; i < sqrt_range.size(); ++i) {
      if (left / magic < i and i < right / magic) {
        value = max(value, sqrt_range[i]);
      }
    }

    for (int i = left; i <= right; ) {
      value = max(value, range[i]);

      i++;
      if (i % magic == 0) break;
    }

    for (int i = right; i >= left; ) {
      value = max(value, range[i]);

      if (i % magic == 0) break;
      i--;
    }

    return value;
  }
} counter;

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

  vector<int> h(n);
  for (auto &x : h) cin >> x;

  vector<int> beauty(n);
  for (auto &x : beauty) cin >> x;

  long long ans = 0;
  for (int i = 0; i < n; ++i) {
    long long mx = counter.query_max(1, h[i]);

    long long b = mx + beauty[i];
    counter.update(h[i], b);
    ans = max(ans, b);
  }

  cout << ans << endl;

  return 0;
}


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

int conv(int a, int b)
{
    if(a < b)
    {
        return 0;
    }
    int t1 = 1;
    int t2 = 1;
    for(int i = 0; i < b; ++i)
    {
        t1 *= (a-i);
        t2 *= (i+1);
    }
    return t1 / t2;
}

int main()
{
    int n,m;
    cin >> n >> m;
    cout << conv(n,2)+conv(m,2) << endl;
}

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

#define ll long long
#define mtv(kit) cout<<#kit<<" - "<<kit<<"\n";
#define ff first
#define ss second
#define pb push_back
#define rep(i,a,b) for(i=a;i<b;i++)
#define pii pair<ll , ll>
#define all(x) x.begin(),x.end()
#define nl "\n"
#define ump unordered_map

void doit(){
	ll n,m = 0,i,a[5];
	a[1] = a[2] = a[3] = -1;
	cin >> n >> m;
	bool ok = 0;
	while(m--){
		ll x,y;
		cin >> x >> y;
		if(ok)continue;
		if(x == 1 && y == 0 && n != 1){
			ok = 1;
			continue;
		}
		if(a[x] != -1){
			if(a[x] != y){ok = 1 ;continue;}
		}
		a[x] = y;
	}
	if(!ok && n == 1){
		cout << max(a[1] , 0LL) << nl;
		return ;
	}
	if(ok) cout << -1 << nl;
	else {
		rep(i,1,n+1){
			if(i == 1){
				if(a[i] == -1)cout << 1;
				else cout << a[i];
				continue;
			}
			if(a[i] == -1)cout << 0;
			else cout << a[i];
		}
	}	
}

int main() {
#ifndef ONLINE_JUDGE
	freopen("input1.txt","r",stdin);
	freopen("output1.txt","w",stdout);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll t = 1;
	// cin >> t;
	for(ll i = 1; i <= t; i++){
		doit();
	}
}


Measured memory_bytes: 3592
#include<bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
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 all(x) (x).begin(),(x).end()
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long int ll;
typedef long double ld;
const ll INF=(1LL<<62);
const ld pi=acosl((ld)-1);
const ll mod = 1000000007;
// const ll mod = 1234567;
const int dx[4]={0,1,0,-1};
const int dy[4]={1,0,-1,0};
const int ddx[8]={1,0,-1,-1,-1,0,1,1};
const int ddy[8]={1,1,1,0,-1,-1,-1,0};
#define endn "\n"
#define TO_STRING(VariableName) # VariableName

template <typename T>ostream &operator<<(ostream &out,const vector<T> &v) {rep(i,(int)v.size()-1)cout<<v[i]<<" ";cout<<v[(int)v.size()-1];return out;}
template <typename T1, typename T2>ostream &operator<<(ostream &out, const map<T1, T2> &p) {out << "(" << p.first << ", " << p.second << ")";return out;}
template <typename T1, typename T2>ostream &operator<<(ostream &out, const pair<T1, T2> &p){out << "(" << p.first << ", " << p.second << ")";return out;}
template<class T>void debag(const T &obj){cout<<obj<<endl;}

bool solve(){
  ll n;cin>>n;
  ll A=0;
  ll B=0;
  ll C=0;
  rep(i,n){
    ll a;cin>>a;
    if(a==1)A++;
    if(a==2)B++;
    if(a==3)C++;
  }

  vector<vector<vector<ld>>>dp(n+2,vector<vector<ld>>(n+2,vector<ld>(n+2,0)));
  rep(i,n+1)rep(j,n+1)rep(k,n+1)dp[i][j][k]=0;

  rep(i,n+1)rep(j,n+1)rep(k,n+1){
    dp[i][j][k]=0;
    if(i+j+k==0)continue;
    if(i>0)dp[i][j][k]+=dp[i-1][j+1][k]*(ld)((ld)i/(ld)(i+j+k));
    if(j>0)dp[i][j][k]+=dp[i][j-1][k+1]*(ld)((ld)j/(ld)(i+j+k));
    if(k>0)dp[i][j][k]+=dp[i][j][k-1]*(ld)((ld)k/(ld)(i+j+k));
    // cout<<i<<" "<<j<<" "<<k<<" "<<dp[i][j][k]<<endl;
    dp[i][j][k]+=(ld)n/(ld)(i+j+k);
  }

  cout<<dp[C][B][A]<<endl;

  return false;
}

signed main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout<<fixed<<setprecision(30);
  solve();
}


Measured memory_bytes: 435712
M=99;main(n,i,j,k,a,b,c){
    float p=atan(1)*4,X[100],Y[100],x,y;
    for(;scanf("%d",&n),n;printf("%d\n",a)){
        for(i=0;i<n;i++)scanf("%f,%f",X+i,Y+i);
        for(a=i=0;i<n;i++){
            for(b=k=0;k<M;k++){
                x=X[i]+cos(p*k/M),y=Y[i]+sin(p*k/M);
                for(c=0,j=0;j<n;j++){
                    if((X[j]-x)*(X[j]-x)+(Y[j]-y)*(Y[j]-y)<1+1e-3)c++;
                }
                if(b<c)b=c;
            }
            if(a<b)a=b;
        }
    }
exit(0);}

Measured memory_bytes: 640
from itertools import product
N, M = map(int, input().split())
k = []
s = []
for i in range(M):
    ks = list(map(int, input().split()))
    k.append(ks[0])
    s.append(ks[1:])
p = list(map(int, input().split()))

ans = 0
for t in product([0, 1], repeat=N):
    sw = {i+1: t[i] for i in range(N)}
    flg = 1
    # 電球確認
    for ind in range(M):
        num = 0
        # スイッチON個数確認
        for j in s[ind]:
            if sw[j] == 1:
                num += sw[j]
        # 電球OFF時はnot answer
        if num % 2 != p[ind]:
            flg = 0
            break
    if flg:
        ans += 1
print(ans)

Measured memory_bytes: 3064
#include <algorithm>
#include <cstdlib>
#include <iostream>
#include <string>
#include <vector>
using namespace std;

vector<unsigned long long> pow_hash, hashes;
inline void rolling_hash(const string& s) {
	const int n = s.size();
	const unsigned long long base = 1000000007ull;
	pow_hash.clear();
	pow_hash.resize(n + 1);
	hashes.clear();
	hashes.resize(n + 1);

	pow_hash[0] = 1;
	hashes[0] = 0;

	for(int i = 0; i < n; ++i) {
		pow_hash[i + 1] = pow_hash[i] * base;
		hashes[i + 1] = hashes[i] * base + s[i];
	}
}

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

	int n, m;
	cin >> n >> m;

	string str;
	cin >> str;

	rolling_hash(str);

	int l = 0, r = 1;
	vector<unsigned long long> str_hash;
	str_hash.reserve(m);
	for(int i = 0; i < m; ++i) {
		string ope;
		cin >> ope;

		if(ope == "R++")
			++r;

		else if(ope == "R--")
			--r;

		else if(ope == "L++")
			++l;

		else
			--l;

		str_hash.push_back(hashes[r] - hashes[l] * pow_hash[r - l]);
	}

	sort(str_hash.begin(), str_hash.end());
	cout << unique(str_hash.begin(), str_hash.end()) - str_hash.begin() << endl;

	return EXIT_SUCCESS;
}

Measured memory_bytes: 8608
#include<stdio.h>
#include<math.h>
int main(){
    long long int r,c,i,j,k,co=0,s=0,b;
    scanf("%lld %lld",&r,&c);
    long long int a[r][c];
    for(i=0;i<r;i++){
        for(j=0;j<c;j++){
            scanf("%lld",&a[i][j]);
        }
    }
    for(i=0;i<r;i++){
        for(j=i+1;j<r;j++){
                s=0;
            for(k=0;k<c;k++){
                s=s+pow((a[i][k]-a[j][k]),2);
            }
            b=sqrt(s);
            if(b*b==s)co++;
        }
    }
    printf("%lld",co);}


Measured memory_bytes: 2140
import java.util.Scanner;

public class Main{
    
    int HEIGHT = 4;
    int WIDTH = 4;
    int[][] relationXY;

    void run(){
        Scanner sc = new Scanner(System.in);
        //int[][] temp = { { -2, 1},{ -1, 1},{ 1, 1},{ 1, 2}};
        
        while(true){
            int[][] temp = new int[4][2];
            int x = sc.nextInt();
            if(x > 4){
                break;
            }
            int y = sc.nextInt();
            temp[0][0] = x;
            temp[0][1] = y;
            for(int i = 1;i < 4;i++){
                temp[i][0] = sc.nextInt();
                temp[i][1] = sc.nextInt();
            }
            relationXY = temp;
            boolean[][] visited = new boolean[HEIGHT][WIDTH];
            System.out.println(dfs(visited,HEIGHT*WIDTH,0));
        }
    }
    int dfs(boolean[][] visited,int remain,int next){
        /*
        System.out.println("remain "+remain);
        for(int i = 0;i < HEIGHT;i++){
            for(int ii = 0;ii < WIDTH;ii++){
                System.out.print(visited[i][ii]? 1: 0);
            }
            System.out.println();
        }
        */
        if(remain == 0){
            return 1;
        }
        if(next >= HEIGHT*WIDTH){
            return 0;
        }

        int count = 0;

        int y = next / HEIGHT;
        int x = next % WIDTH;
        if( visited[y][x]){
            count+=dfs(visited,remain,next+1);
        }
        else{
            for(int i = 0;i < relationXY.length;i++){
                int rx = x + relationXY[i][0];
                int ry = y + relationXY[i][1];
                if(rx < 0 || WIDTH <= rx || ry < 0 || HEIGHT <= ry){
                    continue;
                }
                if(!visited[ry][rx]){
                    visited[y][x] = true;
                    visited[ry][rx] = true;
                    count += dfs(visited,remain-2,next+1);
                    visited[y][x] = false;
                    visited[ry][rx] = false;
                }
            }
        }

        return count;
    }
    public static void main(String[] args) {
        new Main().run();
    }
}
    

Measured memory_bytes: 17212
W,H,N=map(int,input().split())
R=[0,0,W,0,H]
for _ in[0]*N:
    *wh,a=map(int,input().split())
    R[a]=eval(['min','max'][a%2]+'(R[a],wh[a//3])')
_,w,W,h,H=R
print((W-w)*(H-h)*(W>w)*(H>h))

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

int SumOfEachDits(long long N){
	int ans = 0;
	string S = to_string(N);
	for(int i = 0; i < S.size(); i++){
		ans += (N % 10);
		N /= 10;
	}
	return ans;
}

int main(){
	long long A;
	cin >> A;
	int Sn = SumOfEachDits(A);
	bool jdg = false;
	if(A % Sn == 0) jdg = true;
	if(jdg) cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 256
/*--------------------------"SABUJ-JANA"------"JADAVPUR UNIVERSITY"--------*/
/*-------------------------------@greenindia-----------------------------------*/
//
//		  _____       _           _        _
//		 / ____|     | |         (_)      | |
//		| (___   __ _| |__  _   _ _       | | __ _ _ __   __ _
//		 \___ \ / _` | '_ \| | | | |  _   | |/ _` | '_ \ / _` |
//		 ____) | (_| | |_) | |_| | | | |__| | (_| | | | | (_| |
//		|_____/ \__,_|_.__/ \__,_| |  \____/ \__,_|_| |_|\__,_|
//		                        _/ |
//		                       |__/
/*---------------------- Magic. Do not touch.-----------------------------*/
/*------------------------------God is Great/\---------------------------------*/
#include <bits/stdc++.h>
using namespace std;
#define crap ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
//cout<<fixed<<showpoint<<setprecision(12)<<ans<<endl;
#define int long long int
#define double long double
#define PI acos(-1)

void print1d(const vector<int>& vec) {for (auto val : vec) {cout << val << " ";} cout << endl;}

void print2d(const vector<vector<int>>& vec) {for (auto row : vec) {for (auto val : row) {cout << val << " ";} cout << endl;}}


signed main() {
 
	crap;	

	int n;
	cin >> n;

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

	for(int day = 1; day < n; day++){
		vector<int> new_dp(3, INT_MIN);
		vector<int> cost(3);
		for (int i = 0; i < 3; ++i){
			cin >> cost[i];
		}
		for(int i = 0; i < 3; i++){
			for(int j = 0; j < 3; j++){
				if(i != j){
					new_dp[i] = max(new_dp[i], dp[j] + cost[i]);
				}
			}
		}

		dp = new_dp;
	}


	cout << max({dp[0], dp[1], dp[2]}) << endl;


	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(int i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(int i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(int i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define uniq(x) (x).erase(unique((x).begin(), (x).end()), (x).end())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int a, b, c;
    cin >> a >> b >> c;
    int ans = 0;
    
    if ((a == b) && (b == c) && (a % 2 == 0)) {
        cout << -1 << endl;
        return 0;
    }
    
    while((a % 2 == 0) && (b % 2 == 0) && (c % 2 == 0)) {
        int ta = b / 2 + c / 2;
        int tb = a / 2 + c / 2;
        int tc = a / 2 + b / 2;
        a = ta; b = tb; c = tc;
        ans++;
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <string>
#include <iostream>
#include <vector>
#include <list>
#include <cmath>
#include <iomanip>
#include <queue>
#include <stack>


using namespace std;


int main(void) {
	int A, B;

	cin >> A >> B;

	cout << A*B;


	return 0;
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define GET_MACRO(_1,_2,_3,_4,_5,NAME,...) NAME
#define pr(...) GET_MACRO(__VA_ARGS__,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__)
#define pr1(a) (#a)<<"="<<(a)
#define pr2(a,b) pr1(a)<<", "<<pr1(b)
#define pr3(a,b,c) pr2(a,b)<<", "<<pr1(c)
#define pr4(a,b,c,d) pr3(a,b,c)<<", "<<pr1(d)
#define pr5(a,b,c,d,e) pr4(a,b,c,d)<<", "<<pr1(e)
#define int long long
#define double long double
using namespace std;
const int N = 100010;
const int INF = 1LL<<55;
const int mod = (1e9)+7;
const double EPS = 1e-8;
const double PI = 6.0 * asin(0.5);
typedef pair<double,int> P;
typedef long long ll;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
ostream& operator<<(ostream& o,P p){return o<<"("<<p.first<<","<<p.second<<")";}
istream& operator>>(istream& i,P &p){return i>>p.first>>p.second;}
ostream& operator<<(ostream& o,vector<auto> &a){int i=0;for(auto t:a)o<<(i++?" ":"")<<t;return o;}
istream& operator>>(istream& i,vector<auto> &a){for(auto &t:a)i>>t;return i;}
void prArr(auto a,string s=" "){int i=0;for(auto t:a)cout<<(i++?s:"")<<t;cout<<endl;}


int h,w;
vector<string> mp;

//   1   -1    1   -1
//  #.   ..   .#   ##
//  ..   .#   ##   #.


bool O___(int x,int y){
  return mp[y][x] == '.' && mp[y][x+1] == '.' && mp[y+1][x] == '#' && mp[y+1][x+1] == '.';
}

bool ___O(int x,int y){
  return mp[y][x] == '.' && mp[y][x+1] == '#' && mp[y+1][x] == '.' && mp[y+1][x+1] == '.';
}

bool _OOO(int x,int y){
  return mp[y][x] == '#' && mp[y][x+1] == '#' && mp[y+1][x] == '.' && mp[y+1][x+1] == '#';
}

bool OOO_(int x,int y){
  return mp[y][x] == '#' && mp[y][x+1] == '.' && mp[y+1][x] == '#' && mp[y+1][x+1] == '#';
}


signed main(){
  cin>>h>>w;

  int ofset = 1;
  mp.resize(h+ofset * 2,string(w+ofset * 2,'.'));

  for(int i=0;i<h;i++) 
    for(int j=0;j<w;j++) cin>>mp[h-i][j+1];
  
  auto getArg=[](double x,double y){
    return 180 * (arg(complex<double>(x,y))/ PI);
  };
  
  vector<P> A;
  for(int i=0;i<=h;i++)
    for(int j=0;j<=w;j++){
      if(O___(j,i)) A.push_back(P(getArg(j,i),1));
      if(___O(j,i)) A.push_back(P(getArg(j,i),-1));
      if(_OOO(j,i)) A.push_back(P(getArg(j,i),1));
      if(OOO_(j,i)) A.push_back(P(getArg(j,i),-1));
    }
  sort(A.begin(),A.end());  
  
  int ans = 1;
  int cnt = 1;
  for(int i=0;i<(int)A.size();){
    double th = A[i].first;
    while(i < (int)A.size()){
      double th2 = A[i].first;
      int type = A[i].second;
      if(abs(th - th2) > EPS) break;
      i++;
      cnt += type;
    }
    Max(ans,cnt);
  }
  cout<<ans<<endl;
  
  return 0;
}



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

int main(void) {
    set<char> s;
    string S = "abcdefghijklmnopqrstuvwxyz";
    for (int i = 0; i < S.size(); i++) s.insert(S[i]);
    string in;cin>>in;
    for (int i = 0; i < in.size(); i++) {
        if (s.find(in[i]) != s.end()) s.erase(in[i]);
    }
    if (s.size() == 0) cout << "None" << endl;
    else {
        set<char>::iterator it = s.begin();
        cout << *it << endl;
    }
    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <iomanip>
#include <vector>
#include <valarray>
#include <map>
#include <set>
#include <list>
#include <queue>
#include <stack>
#include <bitset>
#include <utility>
#include <numeric>
#include <algorithm>
#include <functional>
#include <complex>
#include <string>
#include <sstream>

#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cmath>

using namespace std;

#define all(c) c.begin(),c.end()
#define repeat(i,n) for(int i=0;i<static_cast<int>(n);i++)
#define debug(x) #x << "=" << (x)
#define dump(x) cerr << debug(x) << " (L:" << __LINE__ << ")"<< endl

typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<string> vs;

template<typename T>
ostream& operator<<(ostream& os, const vector<T>& vec){
    os << "[";
    for(int i = 0; i < vec.size(); i++){
        os << vec[i] << ",";
    }
    os << "]";
    return os;
}

template<typename T>
T input(){
    T t;
    cin >> t;
    return t;
}

template<typename T>
vector<T> input(const int N){
    vector<T> v(N);
    repeat(i,N) cin >> v[i];
    return v;
}

long long gcd(long long a, long long b){
    if(b == 0){
        return a;
    }
    return gcd(b, a % b);
}

long long lcm(long long a, long long b){
    return (a / gcd(a, b)) * b;
}

long long mul(const long long& a, const long long& b, const long long& mod) {
    return ((a % mod) * (b % mod)) % mod;
}

long long power(const long long& x, const long long& y, const long long& mod) {
    if (y == 0) {
        return 1;
    } else if (y == 1) {
        return x % mod;
    } else {
        long long value = power(x, y / 2, mod);
        if (y % 2 == 0) {
            return mul(value, value, mod);
        } else {
            return mul(value, value, mod) * x % mod;
        }
    }
}

long long div(const long long& a, const long long& b, const long long& mod) {
    return mul(a, power(b, mod - 2, mod), mod);
}

map<long long, long long> factorials;
long long factorial(const long long& n, const long long& mod) {
    if (n == 0 || n == 1) {
        return 1;
    }
    if (factorials[n] != 0) {
        return factorials[n];
    }
    factorials[n] = n * factorial(n - 1, mod) % mod;
    return factorials[n] % mod;
}

long long combination(const long long& n, const long long& x, const long long& mod) {
    long long numerator = 1;
    long long denominator = 1;
    repeat(i, x) {
        numerator *= (n - i) % mod;
        numerator %= mod;
        denominator *= (i + 1) % mod;
        denominator %= mod;
    }
    return div(numerator, denominator, mod);
}

int main(){
    ll X, Y;
    cin >> X >> Y;

    int length = 0;
    ll item = X;
    while (item <= Y) {
        length += 1;
        item *= 2;
    }
    cout << length << endl;
    return 0;
}


Measured memory_bytes: 256
A,B,C,D,E,F=map(int,input().split())
water=set({})
for i in range(F//(100*A)+1):
    for j in range(F//(100*B)+1):
        if 100*A*i + 100*B*j <= F:
            water|={100*A*i + 100*B*j}
sugar=set({})
for i in range(F//C+1):
    for j in range(F//D+1):
        if C*i + D*j <= F:
            sugar|={C*i + D*j}
water-=set({0})
max_=0
for w in water:
    for s in sugar:
        if w+s<=F and s*(100+E)<=E*(w+s) and max_*(w+s)<=s:
            max_=s/(w+s)
            ans=[w+s,s]
print(ans[0],ans[1])

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define st string
#define ve(i) vector<i>
#define repi(i, m, n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i, n) repi(i, 0, n)
#define each(i, n) for(auto&& i: n)

int main() {
  st S;
  cin >> S;
  int a = 0, N;
  N = S.size();
  rep(i, N / 2) {
    if(S.at(i) != S.at(N - 1 - i)) {
      a++;
    }
  }
  cout << a << endl;
}  

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

int main(){
  int N;
  cin>>N;
  vector<int> dan(N+1);
  vector<int> frog(N+1);
  for(int i=1; i<=N; i++){
    int h;
    cin>>h;
    dan.at(i)=h;
  }
  frog.at(1)=0;
  frog.at(2)=abs(dan.at(2)-dan.at(1));
  for(int i=3; i<=N; i++){
    int cost1=frog.at(i-1)+abs(dan.at(i)-dan.at(i-1));
    int cost2=frog.at(i-2)+abs(dan.at(i)-dan.at(i-2));
    frog.at(i)=min(cost1, cost2);
  }
  cout<<frog.at(N)<<endl;
}
 

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
long long LCM(long long a, long long b)  {return a/GCD(a,b)*b;}

int main(){
    int A,B,C;
    cin>>A>>B>>C;
    cout<<C<<" "<<A<<" "<<B<<endl;

}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <vector>
#define REP(i, n) for(int i = 0; i < (n); ++i)
typedef long long ll;
const ll MOD = 1000000007;
using namespace std;

int main(){
    int n; cin >> n;
    vector<int> x(n), y(n);
    REP(i, n){
        cin >> x[i]; y[i] = x[i];
    }
    sort(y.begin(), y.end());
    REP(i, n){
        cout << (x[i] < y[n/2] ? y[n/2] : y[n/2-1]) << endl;
    }
    return 0;
}

Measured memory_bytes: 3712