akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<algorithm>
using namespace std;


int main(){
    int a,b;
    while(scanf("%d %d",&a,&b)!=EOF){
        string s=to_string(a+b);
        printf("%d\n",s.size());
    }
    return 0;
}

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

#define MAX_N 100010

int N,L;
int a[MAX_N]={};
int sum[MAX_N]={};


int main(){

   cin >> N >> L;
   for(int i=1; i<=N; i++) scanf("%d",&a[i]);

   int ini=-1;
   for(int i=1; i<N; i++){
       if( a[i] + a[i+1] >= L ){
	   ini = i;
       }
   }
   if( ini == -1 ){
       cout << "Impossible" << endl;
	return 0;
   }
   cout << "Possible" << endl;
   for(int i=1; i<ini; i++)
       printf("%d\n",i);
   for(int i=N-1; i>=ini; i--)
       printf("%d\n",i);

}


Measured memory_bytes: 1152
# -*- coding: utf-8 -*-

import sys, re
from collections import deque, defaultdict, Counter
from math import sqrt, hypot, factorial, pi, sin, cos, radians
if sys.version_info.minor >= 5: from math import gcd
else: from fractions import gcd 
from heapq import heappop, heappush, heapify, heappushpop
from bisect import bisect_left, bisect_right
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from functools import reduce, partial
from fractions import Fraction
from string import ascii_lowercase, ascii_uppercase, digits

def input(): return sys.stdin.readline().strip()
def ceil(a, b=1): return int(-(-a // b))
def round(x): return int((x*2+1) // 2)
def fermat(x, y, MOD): return x * pow(y, MOD-2, MOD) % MOD
def lcm(x, y): return (x * y) // gcd(x, y)
def lcm_list(nums): return reduce(lcm, nums, 1)
def gcd_list(nums): return reduce(gcd, nums, nums[0])
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

x, y = MAP()

if x <= y:
    ans = min(y - x, abs(abs(x)-abs(y))+1)
else:
    if x > 0 and y > 0 or x < 0 and y < 0:
        ans = x - y + 2
    else:
        ans = abs(abs(x)-abs(y))+1
print(ans)


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

using namespace std;

int n, a, b, c, d;
string s;

int main()
{
    while(cin >> n >> a >> b >> c >> d >> s)
    {
        a--, b--, c--, d--;
        bool yes = 1;

        bool canPass = 0;
        if(a > b)
            swap(a, b), swap(c, d);

        while( yes && b < d)
        {
            if(b > 0 && s[b - 1] == '.' && s[b + 1] == '.')
                canPass = 1;
            if(s[b + 1] == '.')
                b++;
            else if(s[b + 2] == '.')
                b+= 2;
            else
                yes = 0;
            if(b > 0 && s[b - 1] == '.' && s[b + 1] == '.')
                canPass = 1;
        }

        while(yes && a < c)
        {
            if(a + 1 != b && s[a + 1] == '.')
                a++;
            else if(a + 2 != b && s[a + 2] == '.')
                a += 2;
            else if((a + 1 == b || a + 2 == b) && canPass)
                a = b;
            else
                yes = 0;
        }

        if(yes)
            cout << "Yes" << endl;
        else
            cout << "No" << endl;





    }
    return 0;
}


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

class Main{
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);

        int q = sc.nextInt();
        sc.nextLine();

        ArrayList<Integer> A = new ArrayList<Integer>();

        for(int i=0;i<q;i++){
            int order = sc.nextInt();
            switch (order){
                case 0:
                    int x = sc.nextInt();
                    A.add(x);
                    break;
                case 1:
                    int p = sc.nextInt();
                    System.out.println(A.get(p));
                    break;
                case 2:
                    A.remove(A.size()-1);
                    break;
            }
        }
    }
}


Measured memory_bytes: 140916
#include <bits/stdc++.h>
using namespace std;
// types
typedef long long ll; 
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int, int> pii;
// IO
#define fo(i, n) for (int i = 0; i < n; i++)
#define fo1(i, n) for (int i = 1; i <= n; i++)
#define sc(n) scanf("%d", &n) 
#define sca(a, n) fo(i, n) sc(a[i])
#define pd(a) printf("%d ", a)
#define pld(a) printf("%d\n", a)
#define pda(a, n) fo(i, n) pd(a[i])
#define pl printf("\n")
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b) 
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
// math
const ll mod = 1e9+7;
template<typename T> T gcf(T a, T b) {return (b == 0) ? a : gcf(b, a%b);} 
template<typename T> T lcm(T a, T b) {return (a*b)/gcf(a, b);}
template<typename T> T sumTo(T x) {return x * (x+1) / 2;}
template<typename T> T sumSquaresTo(T x) {return x * (x+1) * (2*x+1) / 6;}
template<typename T> T ceilDiv(T n, T d) {return (n+d-1)/d;}

void solve() {
    string s; cin >> s;
    fo(i, s.size()) {
        if ((i % 2 && s[i] == 'R') || (!(i % 2) && s[i] == 'L')) {
            No();
            return;
        }
    }
    Yes();
}

int main() {
    int t = 1;
    //scanf("%d", &t);
    while (t--) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 256
def solve(a, b, c):
    if (a % 2 == 0) or (b % 2 == 0) or (c % 2 == 0):
        return 0
    return min([a*b, b*c, c*a])

a, b, c = map(int, input().split())
print(solve(a, b, c))

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

int main(){
  int n,cnt=0,flag=1;
  cin >> n;
  queue<int> a;
  for(int i=0; i<n; i++){
    int tmp;
    cin >> tmp;
    a.push(tmp);
  }
  for(int i=0; i<n; i++){
    int tmp=a.front();
    a.pop();
    if(tmp==flag)flag++;
    else{
      cnt++;
    }
  }

  if(cnt==n)cout << -1;
  else cout << cnt;
  cout << endl;
}

Measured memory_bytes: 1152
#include <iostream>
#include <vector>
#include <iomanip>
#include <string>
#include <sstream>
#include <algorithm>
#include <map>
#include <bits/stdc++.h>

using namespace std;
#define REP(i,n) FOR(i,0,n)
#define FOR(i,a,b) for(long long i=(a),i##Len_=(b);i<i##Len_;i++)
typedef long long ll;
static const ll MOD = 1000000007;
static const ll INF = 1000000000000000000LL;

int main() {

    string S;
    cin >> S;

    bool res = true;

    REP(i,2)
    {
        if(S[i] != S[i+1])res = false;
    }

    if(res == false)
    {
        res = true;
        for(ll i = 1; i < 3;++i)
        {
            if(S[i] != S[i+1])res = false;
        }
    }

    if(res)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
import sys
stdin = sys.stdin
sys.setrecursionlimit(10**6)
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

n = ni()

import math

print(2*n*math.pi)

Measured memory_bytes: 9176
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using Graph = vector<vector<int>>;
const int INF = 1e9 + 1;
const ll LLINF = 1e18;
const int MOD = 1e9 + 7;

int main() {
    int N;
    cin >> N;
    int sum = 0, mi = INF;
    for(int i = 0; i < N; ++i) {
        int s;
        cin >> s;
        sum += s;
        if(s % 10)
            mi = min(mi, s);
    }
    cout << (sum % 10 ? sum : (mi == INF ? 0 : sum - mi)) << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int i,x;
	int a[3];
	int b[2];
	for(i=0;i<3;i++)	{
	scanf("%d",&a[i]);
	}
	for(i=0;i<2;i++)	{
	scanf("%d",&b[i]);
	}
	x=a[0];
	
	for(i=0;i<3;i++)	{
	if(x>a[i])	{
	x=a[i];
	}
	//printf("%d\n",x);
	}
	if(b[0]>b[1])	{
	x=(x+b[1])-50;
	}
	else	{
	x=(x+b[0])-50;
	}
	printf("%d\n",x);
	return 0;
}


Measured memory_bytes: 2712
import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)

A, B, C, D = list(read().rstrip().decode('utf-8'))

def F(op, v1, v2):
    if op == "1":
        return v1 + v2
    else:
        return v1 - v2

for operators in [list(format(i, "03b")) for i in range(2**3)]:
    op1, op2, op3 = operators
    op1 = "+" if op1 == "1" else "-"
    op2 = "+" if op2 == "1" else "-"
    op3 = "+" if op3 == "1" else "-"

    eq = A + op1 + B + op2 + C + op3 + D
    x = eval(eq)
    if x == 7:
        break

answer = eq + "=7"
print(answer)

Measured memory_bytes: 3064
#include<iostream>
using namespace std;
int main (){
	string A [7]={"SUN","MON","TUE","WED","THU","FRI","SAT"};

	string pass;
	cin>>pass;
    
	for (int i=6;0<=i;i--){
		if(pass==A[i]){
			cout<<7-i;
		}
	}
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>

int manko(const void *a, const void *b) {
    return *(int *)a - *(int *)b;
}

int main(void) {
  
 int a[3];
 int ans;
  
  for(int i =0 ;i < 3;i++){
  scanf("%d",&a[i]);
  }

 qsort(a,3,sizeof(int),manko);
 ans = a[2] *10 +a[1]+a[0];
  printf("%d",ans);
}


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

int main(){
    int n,a=0,b=0,c=0,d=0;
    cin >> n;
    while(n--){
        string s;
        cin >> s;
        s=="AC"?a++:s=="WA"?b++:s=="TLE"?c++:s=="RE"?d++:0;
    }
    cout << "AC x " << a << "\nWA x " << b << "\nTLE x " << c << "\nRE x " << d;
    return 0;
}

Measured memory_bytes: 3644
main = do
  s <- getContents
  let v = map (map read . words) . lines $ s
  let w = map solve v
  let x = map (\x-> if x then "YES" else "NO") $ w
  mapM_ putStrLn x

solve::[Double] -> Bool
solve [xa,ya,xb,yb,xc,yc,xd,yd] =
  abs(dot u v) < eps
  where u = (xb-xa, yb-ya)
        v = (xd-xc, yd-yc)
        dot (a,b) (c,d) = a*c + b*d
        eps=1e-10

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

const int N=2e5+10;
const int inf=1e9;
int l[N],r[N];
int lo[N],ro[N],mk[N];
char s[N];

int get_l(int x)
{
    if (x<1) return 0;
    else return l[x];
}

void inc_mk(int x,int &pre)
{
    if (x>0) mk[x]++;
    else ++pre;
}

int main()
{
    int n,k,c;
    scanf("%d%d%d",&n,&k,&c);
    scanf("%s",s+1);
    lo[0]=-inf;
    for (int i=1;i<=n;i++) {
        l[i]=l[i-1];
        lo[i]=lo[i-1];
        if (s[i]=='o') {
            lo[i]=i;
            if (i-c-1<1) l[i]=1;
            else l[i]=max(l[i],l[i-c-1]+1);
        }
    }
    ro[n+1]=inf;
    for (int i=n;i>=1;i--) {
        r[i]=r[i+1];
        ro[i]=ro[i+1];
        if (s[i]=='o') {
            ro[i]=i;
            if (i+c+1>n) r[i]=1;
            else r[i]=max(r[i],r[i+c+1]+1);
        }
    }
    if (c==0) {
        for (int i=1;i<=n;i++) {
            if (l[i-1]+r[i+1]<k) {
                printf("%d\n",i);
            }
        }
    } else {
        int now=0;
        for (int i=-c;i<=n;i++) {
            if (get_l(i)+r[i+c+1]>=k) {
                // printf("%d %d\n",i+1,i+c+1);
                inc_mk(i+1,now);
                mk[i+c+1]--;
            }
        }
        // printf("%d\n",now);
        // for (int i=1;i<=n;i++) {
        //     printf("%d ",mk[i]);
        // }
        // puts("");
        for (int i=1;i<=n;i++) {
            now+=mk[i];
            if (now==0 && s[i]=='o') printf("%d\n",i);
        }
    }
    // printf("L: ");
    // for (int i=1;i<=n;i++) {
    //     printf("%d ",l[i]);
    // }
    // puts("");
    // printf("R: ");
    // for (int i=1;i<=n;i++) {
    //     printf("%d ",r[i]);
    // }
    // puts("");
    return 0;
}

Measured memory_bytes: 4864
#include <bits/stdc++.h>
using namespace std;
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define inf 1e18+5
#define mod 1000000007
#define MAXN 100005
#define ll long long
#define pb push_back
#define sortv(v) sort(v.begin(),v.end())
#define tc(t) int t;cin>>t;while(t--)
#define copy copy_n
#define fr(i,a,b) for(long long i=a;i<b;i++)
#define frr(i,a,b) for(long long i=a;i>=b;i--)
#define frn(i,a,b,n) for(long long i=a;i<=b;i=i+n)
#define gcd(x,y) __gcd(x,y)
#define ld long double
#define um unordered_map
#define mkp make_pair
#define b_s binary_search
#define nob __builtin_popcount
#define des greater<ll>()
#define fi first
#define se second
ll mul(ll a, ll b, ll p = mod) {return ((a % p) * (b % p)) % p;}
ll add(ll a, ll b, ll p = mod) {return (a % p + b % p) % p;}
void input(ll a[], ll sz) {fr(i, 0, sz) cin >> a[i];}
void print(ll a[], ll sz) {fr(i, 0, sz) {if (i == sz - 1) cout << a[i] << "\n"; else cout << a[i] << " ";}}
ll maxr(ll a[], ll sz) {ll ma; fr(i, 0, sz) {if (i == 0) ma = a[i]; else if (a[i] > ma) ma = a[i];} return ma;}
ll minr(ll a[], ll sz) {ll mi; fr(i, 0, sz) {if (i == 0) mi = a[i]; else if (a[i] < mi) mi = a[i];} return mi;}
ll isprm(ll n) {
    if (n <= 1)  return 0;
    if (n <= 3)  return 1;
    if (n % 2 == 0 || n % 3 == 0) return 0;

    for (int i = 5; i * i <= n; i = i + 6)
        if (n % i == 0 || n % (i + 2) == 0)
            return 0;
    return 1;
}
/*ll spf[MAXN];
void sieve()
{
    spf[1]=1;
    for (ll i=2; i<MAXN; i++)
        spf[i] = i;
    for (ll i=4; i<MAXN; i+=2)
        spf[i] = 2;

    for(ll i=3;i*i<MAXN;i+=2)
    {
        if (spf[i]==i)
        {
            for (int j=i*i;j<MAXN;j+=i)
                if (spf[j]==j)
                    spf[j]=i;
        }
    }
}*/
ll power(ll x, ll y, ll p = mod)
{
    ll res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % p;
        y = y >> 1; // y = y/2
        x = (x * x) % p;
    }
    return res;
}
ll modInverse(ll n, ll p = mod)
{
    return power(n, p - 2, p);
}
ll ncrMod(ll n, ll r, ll p = mod)
{
    if (r == 0)
        return 1;
    ll fac[n + 1];
    fac[0] = 1;
    for (ll i = 1 ; i <= n; i++)
        fac[i] = fac[i - 1] * i % p;
    return (fac[n] * modInverse(fac[r], p) % p *
            modInverse(fac[n - r], p) % p) % p;
}
//a+b=xor(a,b)+2*(a&b)//
struct comp
{
    bool operator()(const pair<ll, ll> &a,
                    const pair<ll, ll> &b)const
    {
        if (a.fi == b.fi)
        {
            return (a.se > b.se); //second elem in descending
        }
        return (a.first < b.first);//first elem in ascending
    }
};




int main()
{
    fio;
    ll x;
    cin>>x;
    x^=1;
    cout<<x<<"\n";
    return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define Rep(i, m, n) for(ll i = m; i < n; i++)
#define all(vec) vec.begin(), vec.end()
#define tmax(x, y, z) max((x), max((y), (z)))
#define tmin(x, y, z) min((x), min((y), (z)))
#define MINUS(a) memset(a, 0xff, sizeof(a))
#define ZERO(a) memset(a, 0, sizeof(a))
const ll INF = 1LL << 60;
const ll MM = 1000000000; const ll MOD = MM + 7; const ll MMM=9223372036854775807;//2^63 -1
#define ADD(a,b) a = (a + ll(b)) % MOD
#define MUL(a,b) a = (a * ll(b)) % MOD
ll GCD(ll x, ll y){ if(y == 0) return x; else return GCD(y, x % y);}
ll LCM(ll x, ll y){ return x / GCD(x, y) * y;}
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;}
template<typename A, size_t N, typename T> void FILL(A (&array)[N], const T &val){ fill( (T*)array, (T*)(array+N), val );}
using Graph = vector<vector<ll>>;
ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
ll ddx[8] = {1, 1, 0, -1, -1, -1, 0, 1}, ddy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
//cout << fixed << setprecision(10);


int main(){
    ll x, k, d, ans;
    cin >> x >> k >> d;
    if(x >= 0){
        ans = x % d;
        if(chmin(ans, abs(x % d - d))) ans *= -1;
        if((x - ans)/d >= k){
            cout << abs(x - d*k) << endl;
            return 0;
        }
        else{
            if((k - (x - ans)/d) % 2 == 0){
                cout << abs(ans) << endl;
            }
            else{
                if(ans < 0){
                    cout << ans + d << endl;
                }
                else{
                    cout << abs(ans - d) << endl;
                }
            }
            return 0;
        }
    }
    else{
        x *= -1;
        ans = x % d;
        if(chmin(ans, abs(x % d - d))) ans *= -1;
        if((x - ans)/d >= k){
            cout << abs(x - d*k) << endl;
            return 0;
        }
        else{
            if((k - (x - ans)/d) % 2 == 0){
                cout << abs(ans) << endl;
            }
            else{
                if(ans < 0){
                    cout << ans + d << endl;
                }
                else{
                    cout << abs(ans - d) << endl;
                }
            }
            return 0;
        }
    }
}


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

map<string, int> NEWS = {
  {"North",1},
  {"East",2},
  {"South",3},
  {"West",4},
  {"Right",5},
  {"Left",6}};

class dice{
public:
  int me[6];
  void North();
  void East();
  void South();
  void West();
  void Right();
  void Left();
  int Rotate(string str);
  dice();
};
void dice::North(){
  swap(me[0],me[2]);
  swap(me[2],me[5]);
  swap(me[5],me[4]);
}
void dice::East(){
  swap(me[3],me[2]);
  swap(me[2],me[1]);
  swap(me[1],me[4]);
}
void dice::South(){
  swap(me[5],me[2]);
  swap(me[2],me[0]);
  swap(me[0],me[4]);
}
void dice::West(){
  swap(me[1],me[2]);
  swap(me[2],me[3]);
  swap(me[3],me[4]);
}
void dice::Right(){
  swap(me[0],me[1]);
  swap(me[1],me[5]);
  swap(me[5],me[3]);
}
void dice::Left(){
  swap(me[0],me[3]);
  swap(me[3],me[5]);
  swap(me[5],me[1]);
}

int dice::Rotate(string str){
  int &i = NEWS[str];
  if(i == 0){return me[2];}
  switch(NEWS[str]){
  case 1: North(); break;
  case 2: East();  break;
  case 3: South(); break;
  case 4: West();  break;
  case 5: Right(); break;
  case 6: Left();  break;
  default: break;
  }
  return me[2];
}
dice::dice(){
  me[0] = 5;
  me[1] = 4;
  me[2] = 1;
  me[3] = 3;
  me[4] = 6;
  me[5] = 2;
}

int main(){
  while(true){
    int n;
    string str;
    dice d;
    int sum = 1;
    cin >> n;
    if(0 == n) { break; }
    for(int i = 0; i < n; i++){
      cin >> str;
      sum += d.Rotate(str);
    }
    cout << sum << endl;
  }
  return 0;
}

Measured memory_bytes: 1224
import random
import math
import collections
import itertools
import functools
import operator
import os
import sys

ri = lambda: map(int, raw_input().split())
def pi(a): print (' '.join(map(str, a)))

n, a = input(), ri()
print reduce(lambda a, b : (a + b) / 2.0, sorted(a))


Measured memory_bytes: 3560
local mfl, mce, mmi = math.floor, math.ceil, math.min
local bls, brs = bit.lshift, bit.rshift
local SegTree = {}
SegTree.updateAll = function(self)
  for i = self.stagenum - 1, 1, -1 do
    for j = 1, self.cnt[i] do
      self.stage[i][j] = false
    end
  end
end
SegTree.create = function(self, n)
  local stagenum, mul = 1, 1
  self.cnt, self.stage = {1}, {{}}
  while mul < n do
    mul, stagenum = mul * 2, stagenum + 1
    self.cnt[stagenum], self.stage[stagenum] = mul, {}
  end
  self.stagenum = stagenum
  for i = 1, mul do self.stage[stagenum][i] = false end
  self:updateAll()
end
SegTree.getRange = function(self, left, right)
  if left == right then return self.stage[self.stagenum][left] end
  local stagenum = self.stagenum
  local ret = false
  while true do
    local stage = 1
    local sz = bls(1, stagenum - stage)
    local len = right + 1 - left
    while (left - 1) % sz ~= 0 or len < sz do
      stage = stage + 1
      sz = brs(sz, 1)
    end
    ret = ret or self.stage[stage][1 + brs(left - 1, stagenum - stage)]
    left = left + sz
    if right < left then break end
  end
  return ret
end
SegTree.setValue = function(self, idx, value)
  self.stage[self.stagenum][idx] = value
  for i = self.stagenum - 1, 1, -1 do
    local dst = brs(idx + 1, 1)
    local rem = dst * 4 - 1 - idx
    self.stage[i][dst] = self.stage[i + 1][idx] or self.stage[i + 1][rem]
    idx = dst
  end
end
SegTree.new = function(n, func, emptyvalue)
  local obj = {}
  setmetatable(obj, {__index = SegTree})
  obj:create(n, func, emptyvalue)
  return obj
end

local n = io.read("*n", "*l")
local s = io.read()
local q = io.read("*n", "*l")
local sts = {}
local t = {}
for i = 1, 26 do
  sts[i] = SegTree.new(n, function(a, b) return a or b end, false)
end
for i = 1, n do
  t[i] = s:sub(i, i):byte() - 96
  sts[t[i]]:setValue(i, true)
end

for iq = 1, q do
  local iqstr = io.read()
  local ic = iqstr:sub(1, 1)
  if ic == "1" then
    local i, cs = iqstr:match("%d (%d+) (%w)")
    i = tonumber(i)
    local c = cs:byte() - 96
    if t[i] ~= c then
      sts[t[i]]:setValue(i, false)
      t[i] = c
      sts[c]:setValue(i, true)
    end
  else
    local l, r = iqstr:match("%d (%d+) (%d+)")
    l, r = tonumber(l), tonumber(r)
    local cnt = 0
    for i = 1, 26 do
      if sts[i]:getRange(l, r) then cnt = cnt + 1 end
    end
    print(cnt)
  end
end


Measured memory_bytes: 221004
N = int(raw_input())
s = []
for i in xrange(N):
    s.append(int(raw_input()))

ret = sum(s)

if ret%10!=0:
    print ret
else:
    not_ten = filter(lambda x: x%10!=0, s)
    if len(not_ten)==0:
        print 0
    else:
        ret -= min(not_ten)
        print ret

Measured memory_bytes: 2568
import queue
q = queue.Queue()
for i in range(1,10):
    q.put(i)
K = int(input())

for k in range(K):
    x = q.get()  # dequeue
    last  = x % 10  # 一桁目を取り出す
    if last != 0:  # １桁目が0以外
        q.put(10*x + last - 1)
    q.put(10*x + last)
    if last != 9:  # １けた目が9以外
        q.put(10*x + last + 1)

print(x)


Measured memory_bytes: 12480
s=str(input())
t=str(input())
n,m=len(s),len(t)
ans=''
dp=[[0]*(m+1) for _ in range(n+1)]
for i in range(n):
  for j in range(m):
    if s[i]==t[j]:
      dp[i+1][j+1]=max(dp[i][j]+1,dp[i+1][j+1])
    else:
      dp[i+1][j+1]=max(dp[i+1][j],dp[i][j+1])
while m>0 and n>0:
  if s[n-1]==t[m-1]:ans=s[n-1]+ans;n-=1;m-=1
  elif dp[n][m]==dp[n-1][m]:n-=1
  else:m-=1
print(ans)

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    int h,a;
    cin >> h >> a;
    int ans;
    while(h>0){
        h -= a;
        ans++;
    }
    cout << ans <<"\n";



}

Measured memory_bytes: 256
#include <cstdio>

#define forto(_) for (int e = back[_], v = E[e].to; e; \
		v = E[e = E[e].next].to)

const int kMaxn = 1e5 + 10;

struct Edge {
	int to, next;
} E[kMaxn << 1];

int n, m, tote, dfs_clock;
int back[kMaxn], dfn[kMaxn], odeg[kMaxn];

inline void AddEdge(int u, int v) {
	E[++tote] = (Edge){v, back[u]}, back[u] = tote;
	E[++tote] = (Edge){u, back[v]}, back[v] = tote;
}
void Dfs(int, int);

int main() {
	scanf("%d%d", &n, &m);
	if (m & 1) {
		puts("-1");
		return 0;
	}
	for (int i = 0, u, v; i < m; i++) {
		scanf("%d%d", &u, &v);
		AddEdge(u, v);
	}

	Dfs(1, 0);
	return 0;
}

void Dfs(int u, int fa) {
	dfn[u] = ++dfs_clock;
	forto(u) {
		if (v == fa) continue;
		if (!dfn[v]) Dfs(v, u);
		else if (dfn[v] < dfn[u]) {
			++odeg[u];
			printf("%d %d\n", u, v);
		}
	}
	if (u == 1) return;
	if (odeg[u] & 1) {
		++odeg[u];
		printf("%d %d\n", u, fa);
	} else {
		++odeg[fa];
		printf("%d %d\n", fa, u);
	}
}


Measured memory_bytes: 8704
#include <cstdio>
#include <cstdlib>
#define N 10000
#define Q 500

using namespace std;


int main(){
	int *a,*b;
	a = new int[N];
	b = new int[Q];
	int n,q;
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf(" %d", &a[i]);
	}
	scanf("%d",&q);
	for(int i=0;i<q;i++){
		scanf(" %d", &b[i]);

	}
	int ans = 0;
	for(int i=0;i<q;i++){
		for(int j=0;j<n;j++){
			if(a[j] == b[i] ){
				ans++;
				break;
			}
		}
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 1064
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
using namespace std;

int a, b, c;
string s, t;

int main()
{
	cin >> a >> s;
	
	int t = 0;
	rep(i, a - 2)
	{
		if (s.at(i) == 'A' && s.at(i + 1) == 'B' && s.at(i + 2) == 'C')
			t++;
	}
	cout << t << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{

    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);

        // input
        final int NUM = scan.nextInt();
        int[] nums = new int[NUM];
        for(int i = 0; i < NUM; i++){
            nums[i] = scan.nextInt();
        }

        // search
        int count = 0;
        int leftIntex = -1;
        int rightIndex = -1;
        for(int i = 0; i < NUM - 1; i++){
            if(nums[i] > nums[i + 1]){
                if(count == 1){
                    rightIndex = i;
                } else {
                    leftIntex = i;
                }
                count++;
            }
        }

        // answer
        if(count == 0){
            System.out.println("YES");
        } else if (count == 1 || count == 2){
            String answer = "NO";
            for(int i = leftIntex + 1; i < NUM; i++){
                if(NUM == 2){
                    answer = "YES";
                } else if(nums[leftIntex+1] > nums[i] && nums[i - 1] < nums[leftIntex]){
                    answer = "YES";
                    break;
                }
            }
            System.out.println(answer);
        } else if (count >= 3){
            System.out.println("NO");
        }


    }
}

Measured memory_bytes: 21844
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        if (a <= 2 * b) {
            System.out.println(0);
        } else {
            System.out.println(a - 2 * b);
        }
        sc.close();
    }
}

Measured memory_bytes: 21972
n,a,b=map(int,input().split())	
s=list(input())
cnt=0
cnt2=0
for i in range(n):
    if s[i]=="a":
        if cnt<a+b:
            print("Yes")
            cnt+=1
        else:
            print("No")
    elif s[i]=="b":
        if cnt<a+b and b>cnt2:
            print("Yes")
            cnt+=1
            cnt2+=1
        else:
            print("No")
            cnt2+=1
    else:
        print("No")


Measured memory_bytes: 4712
a,b,c=map(int,input().split())
d=list(map(int,input().split()))
e=[]
for i in range(a):
    e.append(list(map(int,input().split())))
ans=0
for i in range(a):
    result=0
    for j in range(b):
        result+=d[j]*e[i][j]
    result+=c
    if result>0:
        ans+=1
print(ans)






Measured memory_bytes: 9192
import math
import copy
from queue import Queue
import heapq
import numpy as np

MOD = 5000000007

n = int(input())
#b = int(input())
#n, m = [int(i) for i in input().split()]
#table = [[int(i)  for i in input().split()] for j in range(m)]
#table = [list(input()) for n in range(r)] #table[h][w]
#p = [int(i) for i in input().split()]
#s = [int(i) for i in range(n)]
#p = [int(input()) for i in range(m)]
s = input()

#list = list(s)
#dp = [MOD for _ in range(m)]
#dp = [[0 for _ in range(n+1)] for _ in range(n+1)]
#dp = [[[0 for _ in range(11)] for _ in range(2)] for _ in range(11)]

#Combination = [[0 for _ in range(n+1)] for _ in range(n+1)]
#b = [[0 for _ in range(n+1)] for _ in range(n+1)]

flag = 0
for i in range(n-2):
    if(s[i] == "A" and s[i+1] == "B" and s[i+2] == "C"):
        flag += 1

print(flag)

Measured memory_bytes: 18600
#include <iostream>

using namespace std;

int N;
long long int Y;

int main(void) {

	cin >> N >> Y;
	int ans1=-1, ans2=-1, ans3=-1;

	for (int i = 0; i <= N; i++) {
		for (int j = 0; i+j <= N; j++) {
			if (Y - (10000 * i + 5000 * j) == (long long int) 1000 * (N - i - j)) { ans1 = i; ans2 = j; ans3 = N - i - j; break; }
		}
	}

	cout << ans1 << " " << ans2 << " " << ans3 << endl;
	//system("pause");
	return 0;
}

Measured memory_bytes: 256
n=int(input())
l=sorted(list(map(int,input().split())),reverse=0)
ans=0
for i in range(n):
    for j in range(i):
        for k in range(j):
            if l[i]!=l[j] and l[j]!=l[k] and l[i]-l[j]<l[k]<l[i]+l[j]:ans+=1
print(ans)

Measured memory_bytes: 9188
using System;
using static System.Console;
using static System.Math;

public class Hello{
    public static void Main(){
        string[] input = ReadLine().Split(' ');
        int kazu = int.Parse(input[0]);
        int total = int.Parse(input[1]);
        int count = 0;
        
        for(int i=0;i<=kazu;i++){
            for(int j=0;j<=kazu;j++){
                int a = total-i-j;
                if(a <= kazu && a >= 0){
                    count++;
                }
            }
        }
        WriteLine(count);
    }
}


Measured memory_bytes: 13140
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <utility>
#include <climits>
#include <vector>
#include <map>
using namespace std;

#define ll long long int
const int MOD = 1000000007;//10^9+7

int max(int a, int b) {

	if (a > b)return a;
	else return b;

}
//aとbの大きい方

int min(int a, int b) {

	if (a < b)return a;
	else return b;

}
//aとbの小さい方

int avd_i(int a, int b) {

	if (a > b)return a - b;
	else return b - a;

}
double avd_d(double a, double b) {

	double re;
	if (a > b)re = a - b;
	else re = b - a;
	return re;

}
//aとbの差の絶対値

ll calc(ll a, ll b, ll p) {

	if (b == 0) {

		return 1;

	}
	else if (b % 2 == 0) {

		ll d = calc(a, b / 2, p);
		return ((d%p)*(d%p)) % p;

	}
	else {

		return ((a%p)*calc(a, b - 1, p) % p) % p;

	}

}
//pは素数,aのb乗をpで割った余り

ll CMOD(ll n, ll r, ll p) {

	ll a = 1, b = 1, c = 1, re;
	for (int i = 1; i <= n; i++) {

		a *= i;
		a = a%p;

	}
	for (int i = 1; i <= r; i++) {

		b *= i;
		b = b%p;

	}
	for (int i = 1; i <= n - r; i++) {

		c *= i;
		c = c%p;

	}
	b = calc(b, p - 2, p);
	c = calc(c, p - 2, p);
	re = ((a%p)*(b%p)) % p;
	re = ((re%p)*c%p) % p;

	return re;

}
//pは素数,(nCr)%p

int main() {

	int X, T;

	cin >> X >> T;
	if (X > T)cout << X - T << endl;
	else cout << 0 << endl;

	return 0;
}

Measured memory_bytes: 256
YOKO = 0
TATE = 1

MOD = 1000000007

n = int(input().strip())
s1 = input().strip()
s2 = input().strip()

if s1[0] == s2[0]:
    state = TATE
    n_pattern = 3
    i = 1
else:
    state = YOKO
    n_pattern = 6
    i = 2

while i < n:
    current = int(s1[i] == s2[i])
    if state == TATE:
        n_pattern *= 2
        if n_pattern >= MOD:
            n_pattern = n_pattern % MOD
    else:
        if current == YOKO:
            n_pattern *= 3
            if n_pattern >= MOD:
                n_pattern = n_pattern % MOD

    state = current
    if state == TATE:
        i += 1
    else:
        i += 2
print(n_pattern % MOD)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <string>

int main(void) {
	// input
	int n;
	std::cin >> n;
	std::vector<std::string> s(n);
	for(int i = 0; i < n; ++i) std::cin >> s[i];
	int m;
	std::cin >> m;
	std::vector<std::string> t(m);
	for(int i = 0; i < m; ++i) std::cin >> t[i];

	// check text
	int money_max = 0;
	for(int i = 0; i < n; ++i) {
		int money = 0;
		for(int j = 0; j < n; ++j) {
			if(s[i] == s[j]) ++money;
		}
		for(int j = 0; j < m; ++j) {
			if(s[i] == t[j]) --money;
		}
		money_max = (money > money_max ? money : money_max);
	}
	for(int i = 0; i < m; ++i) {
		int money = 0;
		for(int j = 0; j < n; ++j) {
			if(t[i] == s[j]) ++money;
		}
		for(int j = 0; j < m; ++j) {
			if(t[i] == t[j]) --money;
		}
		money_max = (money > money_max ? money : money_max);
	}

	std::cout << money_max << std::endl;

	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;
// ??????????????????????????????????????????????????°OK??§???
int main()
{
  int N, M; cin >> N >> M;
  int P[M]; FOR(i,0,M) cin >> P[i];
  ll A[N-1],B[N-1],C[N-1]; FOR(i,0,N-1) cin >> A[i] >> B[i] >> C[i];
  ll visit[N]; CLR(visit); // ???????????????(??????????????§)
  FOR(i,0,M-1) {
    int a = min(P[i], P[i+1]);
    int b = max(P[i], P[i+1]);
    a--;b--;
    visit[a]++;
    visit[b]--;
  }
  FOR(i,0,N-1) visit[i+1] += visit[i];
  ll ans = 0;
  FOR(i,0,N-1) ans += min(visit[i]*A[i], visit[i]*B[i]+C[i]);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 6592
#coding: utf-8
import math
import heapq
import bisect
import numpy as np
from collections import Counter, deque
import itertools
#from scipy.misc import comb

S = input()
N = len(S)

ans = 0
for i in range(1<<(N-1)):
    func = S[0]
    for j in range(N-1):
        if (i>>j)&1:
            func += '+'
        func += S[j+1]
    ans += eval(func)

print(ans)

Measured memory_bytes: 20008
#include <iostream>
#include <cstring>
#include <map>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <set>
#include <vector>
#include <queue>
#include <list>
#include <numeric>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <math.h>
#include <stack>
#include <climits>
#include <bitset>
#include <utility>


using namespace std;
typedef long long ll;

//最小公倍数
ll gcd(ll x, ll y) {
  ll tmp = 0;
  if (x < y){
    tmp=x;
    x=y;
    y=tmp;
  }
  while (y > 0) {
    ll r = x % y;
    x = y;
    y = r;
  }
  return x;
}

//最大公倍数
ll lcm(ll x,ll y){
  return x/gcd(x,y)*y;
}

//階乗
ll kaijo(ll k){
    ll sum = 1;
    for (ll i = 1; i <= k; ++i)
    {
        sum *= i;
        sum%=1000000000+7;
    }
    return sum;
}

//for(int i = ; i < ; i++){}

ll lmax(ll s,ll t){
  if(s>t){
    return s;
  }
  else{
    return t;
  }
}

ll lmin(ll s,ll t){
  if(s<t){
    return s;
  }
  else{
    return t;
  }
}
// ここから開始

int main(){
  int n;
  cin>>n;
  int a[n],b[n],c[n];
  for(int i = 0; i < n; i++){
    cin>>a[i];
  }
  for(int i = 0; i < n; i++){
    cin>>b[i];
  }
  for(int i = 0; i < n-1; i++){
    cin>>c[i];
  }

  int sum = 0;
  sum+=b[a[0]-1];
  int tmp = a[0]-1;
 
  for(int i = 1; i < n; i++){
    sum+=b[a[i]-1];
    if(tmp+1==a[i]-1){
      sum+=c[tmp];
    }
    tmp = a[i]-1;
    
    
  }
  cout<<sum<<endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;
import static java.lang.System.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();
		
		int ans = Math.min(n * a,  b);
		out.println(ans);
		
	}
}

Measured memory_bytes: 21844
"use strict";
var input=require("fs").readFileSync("/dev/stdin","utf8");
var cin=input.split(/ |\n/),cid=0;
function next(){return +cin[cid++];}
function nextstr(){return cin[cid++];}
function nextbig(){return BigInt(cin[cid++]);}
function nexts(n,a){return a?cin.slice(cid,cid+=n):cin.slice(cid,cid+=n).map(a=>+a);}
function nextssort(n,a){return a?cin.slice(cid,cid+=n).map(a=>+a).sort((a,b)=>b-a):cin.slice(cid,cid+=n).map(a=>+a).sort((a,b)=>a-b);}
function nextm(h,w,a){var r=[],i=0;if(a)for(;i<h;i++)r.push(cin.slice(cid,cid+=w));else for(;i<h;i++)r.push(cin.slice(cid,cid+=w).map(a=>+a));return r;}
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill().map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill().map(x=>"+r+")";return eval(r);}
var streams=[];function print(s){streams.push(s);}

class unionFind{
  constructor(n){this.a=Array(n+1).fill(-1);}
  root(i){
    return this.a[i]<0?i:this.a[i]=this.root(this.a[i]);
  }
  same(x,y){return this.root(x)===this.root(y);}
  unite(x,y){
    const a=this.a;
    x=this.root(x),y=this.root(y);
    if(x===y)return false;
    if(a[y]<a[x])a[y]+=a[x],a[x]=y;
    else a[x]+=a[y],a[y]=x;
    return true;
  }
  size(i){return -this.a[this.root(i)];}
}

var myOut = main();
if(myOut !== undefined)console.log(String(myOut));
if(streams.length)console.log(streams.join("\n"));

function main(){
  var [n,m] = nexts(2);
  var uf = new unionFind(n+1);
  for(var i = 0; i < m; i++){
    var [a,b] = nexts(2);
    uf.unite(a,b);
  }
  var set = new Set();
  for(var i = 0; i < n; i++){
    var t = uf.root(i+1);
    set.add(t);
  }
  return set.size-1;
}

Measured memory_bytes: 61136
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 998244353


class BIT:
    def __init__(self, n):
        self.n = n
        self.data = [0] * (n + 1)
        self.step = pow(2, n.bit_length() - 1)

    def add(self, i, x=1):
        i += 1
        while i <= self.n:
            self.data[i] += x
            i += i & -i

    def get_sum(self, i):
        i += 1
        x = 0
        while i > 0:
            x += self.data[i]
            i -= i & -i
        return x

    # Return sum for [l, r)
    def get_sum_range(self, l, r):
        return self.get_sum(r - 1) - self.get_sum(l - 1)


def main():
    N, K, *LR = map(int, read().split())

    interval = [(l, r) for l, r in zip(*[iter(LR)] * 2)]

    bit = BIT(N + 2)
    bit.add(1, 1)
    bit.add(2, -1)

    for i in range(N):
        cur = bit.get_sum(i) % MOD
        for l, r in interval:
            bit.add(i + l, cur)
            bit.add(i + r + 1, -cur)

    print(bit.get_sum(N) % MOD)
    return


if __name__ == '__main__':
    main()


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

int dp[1001][1001];

int main() {
	int n;
	cin >> n;
	for (int k = 0; k < n; k++ ) {
		string a, b;
		cin >> a >> b;
		for (int i = 0; i < a.size(); i++) {
			for (int j = 0; j < b.size(); j++ ) {
				if (a[i] == b[j]) {
					dp[i+1][j+1] = dp[i][j]+1;
				} else {
					dp[i+1][j+1] = max(dp[i+1][j], dp[i][j+1]);
				}
			}
		}
		cout << dp[a.size()][b.size()] << endl;;
	}
	return 0;
}



Measured memory_bytes: 7132
#input of int(split by space)
def get_i()
  return gets.chomp.split(" ").map(&:to_i)
end
#input of float(split by space)
def get_f()
  return gets.chomp.split(" ").map(&:to_f)
end
#input of string(split by space)
def get()
  return gets.chomp.split(" ")
end
#input of string(split per one character)
def get_nsp()
  return gets.chomp.split("")
end
#yes or no decision
def yn_judge(bool,y="Yes",n="No")
  return bool ? y : n 
end
#create of array
def array(size1,init=nil,size2=-1)
  if size2==-1
      return Array.new(size1){init}
  else
      return Array.new(size2){Array.new(size1){init}}
  end
end

def max(a,b)
    return a>b ? a : b
end

def min(a,b)
    return a>b ? b : a
end

INF=Float::INFINITY

N=gets.to_i
A=get_i

x=1000
(N-1).times do|i|
  if A[i]<A[i+1]
    t=x/A[i]
    x-=A[i]*t
    x+=A[i+1]*t
  end
end
puts x

Measured memory_bytes: 14372
#include <bits/stdc++.h>
#define rep(i, a, b) for(ll i = ll(a); i < ll(b); i++)
#define rer(i, a, b) for(ll i = ll(a) - 1; i >= ll(b); i--)
#define sz(v) (int)(v).size()
#define pb push_back
#define sc second
#define fr first
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
using namespace std;
typedef long long int ll;
typedef pair <int, int> P;

const ll MOD=1000000007;
ll dp[3010]; //i番目を通りi-1番目までは通らない。

ll extgcd(ll a, ll b, ll& x, ll&y){
    ll d=a;
    if(b!=0){
        d=extgcd(b, a%b, y, x);
        y-=(a/b)*x;
    }
    else {
        x=1; y=0;
    }
    return d;
}

ll mod_inverse(ll a, ll m){
    ll x,y;
    extgcd(a,m,x,y);
    return (m+x%m)%m;
}

//n!modp
ll fact[200001]; //0<=n<pについてn! modpのテーブルO(p)
ll invfact[200001];
//n!=a p＾eとした時のa modpを求める。O(log_p n)
ll mod_fact(ll n, ll p, ll& e){
    e=0;
    if(n==0) return 1;
    
    //pの倍数の部分を計算
    ll res=mod_fact(n/p,p,e);
    e+=n/p;
    
    //(p-1)!≡-1なので(p-1)!^(n/p)はn/pの偶奇だけで計算できる
    if(n/p%2!=0) return res*(p-fact[n%p])%p;
    return res*fact[n%p]%p;
}

ll combination(ll a, ll b){
    return fact[a]*invfact[b]%MOD*invfact[a-b]%MOD;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int H,W,N;
    cin>>H>>W>>N;
    P p[N+1];
    rep(i,0,N){
        int r,c;
        cin>>r>>c;
        p[i]=P(r,c);
    }
    p[N]=P(H,W);
    sort(p,p+N+1);
    fact[0]=1;
    invfact[0]=1;
    rep(i,1,200001){
        fact[i]=fact[i-1]*i;
        fact[i]%=MOD;
        invfact[i]=mod_inverse(fact[i], MOD);
    }
    dp[0]=combination(p[0].fr+p[0].sc-2, p[0].fr-1);
    rep(i,1,N+1){
        dp[i]=combination(p[i].fr+p[i].sc-2, p[i].fr-1);
        rep(j,0,i){
            if(p[j].fr<=p[i].fr&&p[j].sc<=p[i].sc){
                dp[i]-=combination(p[i].fr+p[i].sc-p[j].fr-p[j].sc, p[i].fr-p[j].fr)*dp[j];
                dp[i]=dp[i]%MOD;
            }
        }
    }
    cout <<(dp[N]+MOD)%MOD<<"\n";
}

Measured memory_bytes: 3456
# include "bits/stdc++.h"
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)
# define INIT                 std::ios::sync_with_stdio(false);std::cin.tie(0)

int n;

int main(){
    cin >> n;
    for(int i = 1;i <= 9;i++)for(int j = 1;j <= 9;j++){
        if(i * j == n){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}

Measured memory_bytes: 256
def count_biscuits_num() -> int:
    after_a_sec, making_per_a, until_sec = map(int, input().split())
    limited_time = float(until_sec) + 0.5
    spent_time = after_a_sec
    total_making = 0

    while True:
        if limited_time >= spent_time:
            total_making += making_per_a
            spent_time += after_a_sec
        else:
            return total_making


print(count_biscuits_num())

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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

ll N; ll M;
vector<ll> A;

//判定
bool chk(ll x) {
    ll cnt = 0;
    for(int i=0; i<N; i++) {
        ll pos = lower_bound(A.begin(), A.end(), x - A[i]) - A.begin();
        cnt += (N - pos);
    }
    return cnt < M;//X以上の和がM個未満かどうか
}

int main()
{
    cin >> N >> M;
    A.resize(N);
    REP(i, N){
        cin >> A[i];
    }
    sort(A.begin(), A.end());

    //二分探索
    ll ng = 0, ok = LINF;
    while (abs(ok - ng) > 1) {
        ll mid = (ok + ng) / 2;
        if (chk(mid)) ok = mid;
        else ng = mid;
    }
    //終了時にngにX-1,okにXが入っている。


    ll ans = 0;
    vector<ll> wa(N + 1); //Aの累積和
    for(int i=0; i<N; i++) wa[i + 1] = wa[i] + A[i];
    for(int i=0; i<N; i++) {
        ll pos = upper_bound(A.begin(), A.end() , ng - A[i]) - A.begin();
        ll cnt = N - pos;
        ans += cnt * A[i] + (wa[N] - wa[pos]);
        M -= cnt;
    }
    ans += M * ng;
    cout << ans << endl;
    return 0;
}

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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long


#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)

const int N=366+5;
int32_t main() {
int n,m,sum=0;
cin>>n;
vector<int> in(n);
    for (int i = 0; i < n; ++i) {
        cin>>in[i];
        sum+=in[i];
    }
    cin>>m;
    for (int i = 0; i < m; ++i) {
        int p,x;
        cin>>p>>x;
        cout<<sum+x-in[p-1]<<endl;
    }
}

Measured memory_bytes: 256
#include <stdio.h>
 
 
int main(void)
{
    int x=0,A,B;
    scanf("%d %d %d",&x,&A,&B);
 
    if(A>=B)
    {
        printf("delicious\n");
    }
    else
    {
        if(x>=(B-A))
        {
            printf("safe\n");
        }
        else
        {
            printf("dangerous\n");
        }
    }
    return 0;
}

Measured memory_bytes: 128
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip> // fixed, setprecision 
#include <math.h> // double sqrt
#define rep(i,n) for(int i=0;i<(n);++i)
#define ll long long
using namespace std;

int n,k;

int kansu(int x){
    int count=0;
    while(x<k){
        x*=2;
        count++;
    }
return count;
}

int main(){
    cin>>n>>k;
    int i=1;
    vector<int>a(n,0);
    while(i<k&&i<=n){
       a[i-1]=kansu(i);
       i++;
    }
    double ans=0;
    rep(i,n)ans+=(double)(1/pow(2,a[i]));
    cout<<fixed<<setprecision(10)<<ans/n;
    return 0;
}

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

int main()
{
    int N;
    cin >> N;
    vector<int> a(N);
    for (int i = 0; i < N; i++)
    {
        cin >> a.at(i);
    }

    int cnt = 0;
    for (int i = 0; i < N; i++)
    {
        if (a.at(i) == cnt + 1)
        {
            cnt++;
        }
    }
    cout << ((cnt == 0) ? -1 : N - cnt) << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define int long long int 
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define vi vector<int>
#define pi pair<int,int>
#define all(v) v.begin(),v.end()
#define zeros(arr) memset(arr,0,sizeof(arr))
;
#define precise(num)  cout<<fixed; cout << std::setprecision(num)
#define nl cout<<"\n";
#define test int t;cin>>t;wahile(t--) 
const int maxx  = 3*1e5 , limit = 1e17 , MOD=1e9+7;
string binary(int n){bitset<32>b(n) ;string p =b.to_string();return p;}
int decimal(string s){int res = 0; for(int i = 0; i < s.size() ; i++ ){if(s[i] == '1')res = res + pow(2,s.size() - i -1);}    return res;}
bool isPrime(int n){if (n <= 1) return false; if (n <= 3) return true;if (n % 2 == 0 || n % 3 == 0) return false;
for (int i = 5; i * i <= n; i = i + 6) if (n % i == 0 || n % (i + 2) == 0) return false; return true; }
int pow (int x, int n,int mod) {if (n == 0) return 1; int res = pow (x, n / 2,mod);res = (res * res) % mod;if (n % 2) res = (res * x ) % mod;return res;}
int calcInverse(int a, int n = MOD){int t = 0, newt = 1;int r = n, newr = a;  while (newr != 0) {auto quotient = r /newr;tie(t, newt) = make_tuple(newt, t- quotient * newt);
tie(r, newr) = make_tuple(newr, r - quotient * newr);}if (r > 1)throw runtime_error("a is not invertible");if (t < 0)t += n;t=t%n;    return t;}
#define boost  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
int32_t main(){
    boost;
    int n;cin>>n;
    int a[n+1];
    for(int i =0 ; i < n;i++ )cin>>a[i];
    int dp[n+1];memset(dp,0,sizeof(dp));
    dp[1] = abs(a[1]-a[0]);
    for(int i = 2 ; i < n ; i++ ){
        dp[i] = min(dp[i-1]+abs(a[i]-a[i-1]) , dp[i-2] + abs(a[i]-a[i-2]));
    }
    cout<<dp[n-1]<<endl;
    
}   

Measured memory_bytes: 1792