akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
// x^y≡x^(y%(p-1))mod p
// but there is a condition that x needs to be coprime to p
///assic value of ('0'-'9') is(48 - 57) and (a-z) is (97-122) and (A-Z) is(65-90) and 32 for space
typedef tree<int, null_type, less<int>, rb_tree_tag,
             tree_order_statistics_node_update>
    indexed_set; */
typedef long long int ll;
typedef pair<ll, ll> pii;
typedef vector<pii> vii;
#define  pb push_back
#define f(i,a,b) for(ll i=a;i<b;i++)
#define fo(i,a,b) for(ll i = a; i<=b;i+=1)
#define rf(i,a,b)  for(ll i=a;i>=b;i--)
#define vll vector<ll>
#define tests() int test_cases ; cin >> test_cases ; while(test_cases--)
#define ub upper_bound
#define lb lower_bound
#define all(v) v.begin(),v.end()
#define MAXN 100010
#define MOD 1000000007
#define mod 998244353
#define deb(x) cout << '>' << #x << ':' << x << endl;
#define sp " "
#define nl '\n'
#define MS(x,y) fill_n(*x, sizeof x / sizeof **x, y);
#define mem(x,y) memset(x,y,sizeof(x));
#define INF 1000000000000000000
#define IO                 \
	ios::sync_with_stdio(0); \
	cin.tie(0);              \
	cout.tie(0);
#define debug(x) cerr << (#x) << " is " << (x) << endl;

#ifndef ONLINE_JUDGE
#define cerr if(true)cerr
#endif

template<int D, typename T>
struct Vec : public vector<Vec<D - 1, T>> {
static_assert(D >= 1, "Vector dimension must be greater than zero!");
template<typename... Args>
	Vec(int n = 0, Args... args) : vector<Vec<D - 1, T>>(n, Vec<D - 1, T>(args...)) {
	}
};
template<typename T>
struct Vec<1, T> : public vector<T> {
	Vec(int n = 0, const T& val = T()) : vector<T>(n, val) {
	}
};

ll power(ll x, ll y,ll p)
{
    ll res = 1;     // Initialize result
    x = x % p;
    if (y==0)return 1;
    if(x==0)return 0;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % p;
        y = y>>1; // y = y/2
        x = (x*x) % p;  // Change x to x^2
    }
    return res;
}
int gcd(int a, int b) { if (a == 0)return b;return gcd(b % a, a);}

ll modinv(ll a,ll p){return power(a,p-2,p);}


void solve(){
    ll n;
    cin>>n;
    vll a(n);
    bool isZero =false;
    f(i,0,n){
        cin>>a[i];
        if (a[i]==0)
        {
            isZero = true;
        }
    }
    if (isZero)
    {
        cout<<0<<endl;
        return;
    }
    ll pro = 1;
    double inf = 1000000000000000000;
    f(i,0,n){
        inf = inf/(1.0*a[i]);
    }
    // deb(inf)
    if (inf<1)
    {
        cout<<-1<<endl;
    }
    else {
        ll pro = 1;
        f(i,0,n){
            pro*=a[i];
        }
        if (pro>INF)
        {
            cout<<-1<<endl;return;
        }
        cout<<pro<<endl;
    }
    return ;
}
int main()

{
    IO;
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt", "r", stdin);
    // freopen("out.txt", "w", stdout);
    // #endif
    int T=1;
	// cin >> T;
	f(c,0,T){
		solve();
	}
    return 0;
}// make_pair make_tuple  tuple<int,int,int> continue resize insert count size else true isValid second first false erase double priority_queue


Measured memory_bytes: 3956
def hand(card, board):
    for i, c in enumerate(card):
        if board < c:
            board = card.pop(i)
            return board
    else:
        return board


while 1:
    n = int(input())
    if n == 0:
        break

    taro = []
    for _ in range(n):
        taro.append(int(input()))
    taro.sort()

    hanako = []
    for i in range(1, 2*n+1):
        if i not in taro:
            hanako.append(i)
    hanako.sort()

    board = 0
    order = 0
    while 1:
        if order == 0:
            card = hand(taro, board)
            if taro == [] or hanako == []:
                break
            if board == card:
                board = 0
                order = 1
                continue
            board = card
            card = hand(hanako, board)
            if taro == [] or hanako == []:
                break
            if board == card:
                board = 0
                continue
            board = card
        else:
            card = hand(hanako, board)
            if taro == [] or hanako == []:
                break
            if board == card:
                board = 0
                order = 0
                continue
            board = card
            card = hand(taro, board)
            if taro == [] or hanako == []:
                break
            if board == card:
                board = 0
                continue
            board = card

    print(len(hanako))
    print(len(taro))



Measured memory_bytes: 5608
<?php
list($n) = ints();
$res = ($n + 1) * $n / 2;
for ($i = 2; $i <= $n; $i++) {
    $res += $i * (intdiv($n, $i) + 1) * intdiv($n, $i) / 2;
}
echo $res;
function ints()
{
    return array_map('intval', explode(' ', trim(fgets(STDIN))));
}

Measured memory_bytes: 16100
#include <iostream>

using namespace std;

int main()
{
    long long a,b,c,d,x,y;
    cin>>a>>b>>c>>d;
    x=a/d;
    if(a%d!=0)
        x++;
    y=c/b;
    if(c%b!=0)
        y++;
    if(y<=x)
        cout<<"Yes";
    else cout<<"No";
    return 0;
}


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

#define MOD 100000

int dp[17712][400]; //1(JOがある)は連続してはいけない->fib(21) = 17711通り
int x, y;
char map[20][21];
int mask;
short check[1 << 20];

/* 1~x-1番目のbitは, その場所を基準として, JOが続くか否かを表す.
x番目のbitは, そこにJが来るか来ないかを表す. (JOが作れるか作れないか知るために必要) */
int solve(int place, int bit)
{
    int res;
    int nx, ny;
    
    if (place == y * x){
        return (1);
    }
    
    ny = place / x;
    nx = place % x;
    
    res = dp[(int)check[bit]][place];
    if (res == -1){
        int temp = 0;
        
        // 置かれるのがJ
        if (map[ny][nx] == '?' || map[ny][nx] == 'J'){
            int nextbit = bit;
            if (nextbit & 1){
                nextbit = ((nextbit - 1) << 1) | 1; //Jを置いた時点で, そこはJOが連続しない
            }
            else {
                nextbit = (nextbit << 1) | 1;       //上と同じ.
            }
            nextbit &= mask;
            temp += solve(place + 1, nextbit);
            temp %= MOD;
        }
        
        //置かれるのがO
        if (map[ny][nx] == '?' || map[ny][nx] == 'O'){
            int nextbit = bit;
            nextbit <<= 1;
            nextbit &= mask;
            temp += solve(place + 1, nextbit);
            temp %= MOD;
        }
        
        //置かれるのがI
        if (map[ny][nx] == '?' || map[ny][nx] == 'I'){
            if (((1 << (x - 1)) & bit) == 0 || nx == x - 1){ //今の場所が, 行の端か, ちょうど上の場所にJOがなければ
                int nextbit = bit;
                if (nextbit & 1){
                    nextbit = (nextbit - 1) << 1;
                }
                else {
                    nextbit <<= 1;
                }
                nextbit &= mask;
                temp += solve(place + 1, nextbit);
                temp %= MOD;
            }
        }
        res = temp;
    }
    return (dp[(int)check[bit]][place] = res);
}

int main(void)
{
    int i, j;
    int q;
    int ans;
    int temp, num, flag;
    
    scanf("%d%d", &y, &x);
    getchar();
    q = 1;
    for (i = 0; i < y; i++){
        for (j = 0; j < x; j++){
            scanf("%c", &map[i][j]);
            
            if (map[i][j] == '?'){
                q = (q * 3) % MOD;
            }
        }
        getchar();
    }
    
    memset(check, -1, sizeof(check));
    num = 0;
    for (i = 0; i < 1 << x; i++){
        flag = 1;
        temp = i << 1;
        while (temp != 0){
            if ((temp >> 1) & 1 && (temp >> 2) & 1){
                flag = 0;
                break;
            }
            temp >>= 1;
        }
        if (flag){
            check[i] = num++;
        }
    }
    mask = (1 << x) - 1;
    memset(dp, -1, sizeof(dp));
    ans = solve(0, 0);
    
    printf("%d\n", (q - ans + MOD) % MOD);
    
    return (0);
}

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

int main()
{
  int N;
  cin >> N;
  int a[100010];
  for (int i = 1; i <= N; i++) {
    cin >> a[i];
  }
  int button = 1;
  int count = 0;
  for (int i = 1; i <= N; i++) {
    button = a[button];
    if (button == 2) {
      count = i;
      break;
    }
  }
  if (count == 0) {
    cout << -1 << endl;
  } else {
    cout << count << endl;
  }
  return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
void fac(long long n,vector<long long> &ans) 
{ 
    int cnt = 0; 
    while(!(n%2)) { 
        n>>=1;
        cnt++; 
    } 
    if(cnt) 
      ans.push_back(cnt); 
    for (long long i = 3; i <= sqrt(n); i += 2) { 
        cnt=0; 
        while(n%i==0) { 
            cnt++; 
            n=n/i; 
        } 
        if (cnt) 
            ans.push_back(cnt);
    } 
    if (n>2) 
       ans.push_back(1);
} 
int main(){
 long long n;
 cin>>n;
 vector<long long >nums;
 fac(n,nums);
 int val=0;
 if(n!=1){
 for(int i=0;i<nums.size();i++){
 	int spikes=1;
 	int j=1;
 	while(spikes<=nums[i]){
 			j++;
 		spikes+=j;
 		val++;
	 }
 }}
 cout<<val<<"\n";
}


Measured memory_bytes: 3720
import sys
import fractions
from functools import reduce
stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

n, m = na()
a = na()
lcm = lcm_list(a)
lcm //= 2
for i in a:
    if lcm // (i // 2) % 2 == 0:
        print(0)
        exit()
print(((m // lcm) + 1) // 2)

Measured memory_bytes: 16260
#pragma GCC optimize ("O3")
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <list>
#include <algorithm>
#include <numeric>
#include <functional>
#include <utility>
#include <bitset>
#include <cstdio>

using namespace std;
using namespace std::placeholders;

// namespace { struct NoSync { NoSync() { cin.tie(0); ios::sync_with_stdio(false); } } nosync; }

using ll = long long;
#define float double

constexpr ll INF = 999999999;
constexpr ll MOD = 1e9 + 7;

#define y0 Y0
#define y1 Y1
#define j0 J0
#define j1 J1
#define prev PREV
#define next NEXT

#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i##_len = (n), i = (i##_len) - 1; i >= 0; i--)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define permutations(v) sort(all(v));for(bool v##p = true; v##p; v##p=next_permutation(all(v)))
#define UNIQUE(v) (v).erase(unique(all(v)), (v).end())
#define REMOVE(v) (v).erase(remove(all(v)), (v).end())
#define ROTATE(v, n) rotate((v).begin(), (v).begin() + (n), (v).end())
#define TO_SUMS(v) partial_sum(all(v), (v).begin())
#define SUMS(srcv, dstv) partial_sum(all(srcv), (dstv).begin())
#define nth_bit(n) (1LL<<(n))

template <typename T> T high()  { return numeric_limits<T>::max(); }
template <typename T> T high(T) { return numeric_limits<T>::max(); }
template <typename T> T low()   { return numeric_limits<T>::lowest(); }
template <typename T> T low(T)  { return numeric_limits<T>::lowest(); }

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

// f には functional のオブジェクトが便利 (lambda 式も   [](int a){ return a / 2 }   みたいな)
template<class C, class F> inline C mapped(const C& c, F f){// mapっていうSTLがあるから...
    // ex: mapped(v, bind(plus<ll>(), _1, 2))   [v の各要素について x + 2]
    C r; r.reserve(c.size()); transform(all(c), back_inserter(r), f); return r;
}
template<class C, class F> inline C filtered(const C& c, F f){
    // ex: filtered(v, bind(equal_to<ll>(), bind(modulus<ll>(), _1, 2), 0)   [x mod 2 == 0 な x を取ってくる]
    C r; copy_if(all(c), back_inserter(r), f); return r;
}
template<class C, class I, class F> inline typename C::value_type foldl(const C& c, I i, F f){
    // ex: foldl(v, 1, multiplies<int>())   [v の総乗]
    return accumulate(all(c), static_cast<typename C::value_type>(i), f);
}


int main(){
    ll a, b, c;
    cin >> a >> b >> c;

    cout << ((a < b and b < c)? "Yes" : "No") << endl;

    return 0;
}



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

typedef pair<int, int> P;

int main() {
    ll n;
    cin >> n;
    ll h[n];
    rep(i,n){
        cin >> h[i];
    }
    bool ok = true;
    rep(i,n-1){
        if(h[n-i-1]>=h[n-i-2]){
            continue;
        }else if(h[n-i-2]-h[n-i-1]>1){
            ok = false;
            break;
        }else{
            h[n-i-2]--;
        }
    }

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


    return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>

// 22から３２
int main() {
	int N;
	int A, B;


	scanf("%d", &N);

	if (N == 2) {
		scanf("%d %d", &A, &B);
	}

	if (N == 1) {
		printf("Hello World\n");
	}
	else {//制約より
		printf("%d\n", A + B);
	}
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const int mod=1000000007;
const int INF=1001001001;


int main() {
  int N,R;
  cin>>N>>R;
  if(N>=10){cout<<R<<endl;}
  else{cout<<R+100*(10-N)<<endl;}
  return 0;  
}

Measured memory_bytes: 3540
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;


int main()
{
   int i,j,k,n,m; int a[3];
   for(i=0;i<3;i++) cin>>a[i];
   sort(a,a+3);
   int res=abs(a[1]-a[0])+abs(a[2]-a[1]);
   cout<<res;
}


Measured memory_bytes: 256
///
// File:  b.go
// Author: ymiyamoto
//
// Created on Tue Apr  3 00:43:51 2018
//
package main

import (
	"fmt"
)

var K, S int

func main() {
	fmt.Scan(&K, &S)

	var count int64
	for x := 0; x <= K; x++ {
		for y := 0; y <= K; y++ {
			z := S - (x + y)
			if 0 <= z && z <= K {
				count++
			}
		}
	}
	fmt.Println(count)
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define nl '\n'
#define pb push_back
#define ub upper_bound
#define lb lower_bound
#define flood(x) memset(x, 0x3f3f3f3f, sizeof x)
#define drain(x) memset(x, 0, sizeof x)
#define dcit cin.sync_with_stdio(0);cin.tie(0);
#define frp(x, y) freopen(x, "r", stdin);freopen(y, "w", stdout);
typedef pair<int, int> pii;
typedef long long ll;

#ifdef LOCAL_PROJECT

#define gc getchar()
#define pc(x) putchar(x)

#endif
#ifndef LOCAL_PROJECT

#define gc getchar_unlocked()
#define pc(x) putchar_unlocked(x)

#endif

template<typename T> void scani(T &x) {x = 0;register bool _=0;register T c=gc;_=c==45;c=_?gc:c;while(c<48||c>57)c=gc;for(;c<48||c>57;c=gc);for(;c>47&&c<58;c=gc)x=(x<<3)+(x<<1)+(c&15);x=_?-x:x;}
template<typename T> void printi(T n) {register bool _=0;_=n<0;n=_?-n:n;char snum[65];int i=0;do{snum[i++]=n%10+48;n/= 10;}while(n);--i;if (_)pc(45);while(i>=0)pc(snum[i--]);pc(10);}
string nextstring() { string r; register char c=gc;while(c==32||c==10) c = gc;while(!(c==32||c==10)) { r += c;c = gc; }return r; }
char nextgetchar(){ register char c = gc; while(c==32 || c==10) c = gc; return c;}

void prints(string k){ for (int i = 0; i < k.length(); i++)pc(k[i]); }
void scani() {}

template<typename First, typename ... Ints>
void scani(First &arg, Ints&... rest) { scani(arg);scani(rest...); }

int N, M, in[100002];ll dis[100002], maxi= 0; queue<int> nextNode;
vector<int> adj[100002]; int sorted[100002];
int main(){
    memset(dis, -1, sizeof dis);
    scani(N, M);
    for (int i = 0, x, y; i < M; i++) {
        scani(x, y);
        in[y]++;
        adj[x].pb(y);
    }
    for (int i = 1; i <= N; i++)if(in[i]==0) {nextNode.push(i);dis[i]=0;}
    int l = 1;
    while(!nextNode.empty()){
        int node = nextNode.front(); nextNode.pop();
        sorted[l++] = node;
        for (int i = 0; i < adj[node].size(); i++) {
            in[adj[node][i]]--;
            if(in[adj[node][i]]==0) nextNode.push(adj[node][i]);
        }
    }

    for (int i = 1; i <= N; i++) {
        int node = sorted[i];
        maxi = max(maxi, dis[node]);
        for (int j = 0; j < adj[node].size(); j++)
            dis[adj[node][j]] = max(dis[adj[node][j]], dis[node]+1);
    }
    printi(maxi);
    return 0;
}

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

using namespace std;

int cost[200010];
vector <int> v[200010];

void bfs(){
    queue<int>q;
    q.push(1);
    cost[1]=0;
    while(!q.empty()){
        int idx=q.front();
        q.pop();
        for(int i=0;i<v[idx].size();i++){
            if(cost[v[idx][i]]!=-1)
                continue;
            q.push(v[idx][i]);
            cost[v[idx][i]]=cost[idx]+1;
        }

    }

}

int main() {
    int n,m;
    memset(cost,-1,sizeof cost);
    scanf("%d%d",&n,&m);
    for(int i=1;i<=m;i++){
        int a,b;
        scanf("%d%d",&a,&b);
        v[a].push_back(b);
        v[b].push_back(a);
    }
    bfs();
    if(cost[n]!=-1&&cost[n]<=2){
        puts("POSSIBLE");
    }
    else{
        puts("IMPOSSIBLE");
    }
    return 0;
}


Measured memory_bytes: 13168
#include<bits/stdc++.h>
using namespace std;
signed main(){
  long long a,b[100000],c[4]={};
  cin>>a;
  for(int i=0;i<a;i++){
    cin>>b[i];
    c[2]=c[2]+b[i];
  }
  sort(b,b+a);
  c[0]=b[0];
  sort(b,b+a,greater<int>());
  c[1]=b[0];
  for(int i=0;i<3;i++){
    cout<<c[i];
    if(i!=2){
      cout<<" ";
    }
  }
  cout<<"\n";
  return(0);
}



Measured memory_bytes: 3208
#include <iostream>
using namespace std;
long GCD(long a,long b);
long LCM(long a,long b);
long fly(long a,long m,long p);

int main(void){
        int a1,m1,a2,m2,a3,m3;
        while(1) {
                cin>>a1>>m1>>a2>>m2>>a3>>m3;
                if (a1==0 and m1==0 and a2==0 and m2==0 and a3==0 and m3==0) {return 0;}
                long x,y,z;
                x=fly(a1,m1,a1%m1)+1;
                y=fly(a2,m2,a2%m2)+1;
                z=fly(a3,m3,a3%m3)+1;
                cout<<LCM(x,LCM(y,z))<<endl;

        }
}

long GCD(long a,long b){
    long A,B;
    A=min(a,b);
    B=max(a,b);
    if(A==0){return B;}
    else{
        return GCD(A,B%A);
    }
}
long LCM(long a,long b){
    return a*b/GCD(a,b);
}
long fly(long a,long m,long p){
    if(p==1){return 0;}
    else{
        return fly(a,m,(a*p)%m)+1;
    }
}



Measured memory_bytes: 3076
n=int(input())
a,b=map(int,input().split())
P=[int(i) for i in input().split()]
x,y,z=0,0,0
for p in P:
  if p<=a:
    x+=1
  elif p<=b:
    y+=1
  else:
    z+=1
print(min(x,y,z))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(k,i,n) for(ll i=k;i<n;++i)
#define pb push_back
int main(void){
    ll n,k;
    cin>>n>>k;
    ll a[n],c[n];
    rep(0,i,n)c[i]=-1;
    rep(0,i,n){
        cin>>a[i];
        --a[i];
    }
    ll x=0;
    c[0]=0;
    bool t=false;
    rep(0,i,k){
        //cout<<c[x]<<endl;
        if(c[x]==-1||i==0){
            c[x]=i;
            x=a[x];
        }else if(!t){
            ll r=i-c[x];
            i=r*((k-c[x]-1)/r)+c[x];
            //cout<<i<<endl;
            t=true;
        }
        if(t)x=a[x];
    }
    cout<<x+1;
}

Measured memory_bytes: 6768
package main

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

func main() {
	sc.Split(bufio.ScanWords)

	n := nextInt()
	q := nextInt()
	cs := make([]int, n)
	for i := 0; i < n; i++ {
		cs[i] = nextInt()
	}

	qs := make(map[int][]Query, q)
	for i := 0; i < q; i++ {
		l := nextInt()
		r := nextInt()
		qs[r] = append(qs[r], Query{l, r, i})
	}

	bit := newBIT(n)
	pm := make(map[int]int)
	ans := make([]int, q)
	for i := 0; i < n; i++ {
		c := cs[i]
		if pm[c] > 0 {
			bit.add(pm[c], -1)
		}
		bit.add(i+1, 1)
		pm[c] = i + 1
		for _, qe := range qs[i+1] {
			ans[qe.i] = bit.sum(qe.r) - bit.sum(qe.l-1)
		}
	}

	for i := 0; i < q; i++ {
		fmt.Println(ans[i])
	}
}

// Query .
type Query struct {
	l, r, i int
}

// BIT .
type BIT struct {
	n   int
	bit []int
}

func newBIT(n int) BIT {
	b := BIT{n: n}
	n2 := 1
	for n2 <= n {
		n2 *= 2
	}
	b.bit = make([]int, n2)
	return b
}

func (b *BIT) sum(i int) int {
	s := 0
	for i > 0 {
		s += b.bit[i]
		i -= i & -i
	}
	return s
}

func (b *BIT) add(i, x int) {
	for i <= b.n {
		b.bit[i] += x
		i += i & -i
	}
}

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}


Measured memory_bytes: 125196
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <utility>

#define INF 9999999999
#define mod 1000000007

#define rep(i,n) for(int i=0;i<int(n);i++)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define MOD(x) (x%(mod))
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int>pi;

/*---------------------------------------------------*/

int main(){
  ll x;
  ll cnt=0;
  cin>>x;
  cnt=x/11*2;
  x-=11*(cnt/2);

  //cout<<x<<endl;
  
  if(x!=0&&x<=6)cnt+=1;
  else if(x!=0) cnt+=2;
  
  cout<<cnt<<endl;
  return 0;
}


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

int main(){
  int s;
  int s1, s2, s3;
  
  cin >> s;
  
  s1 = s / 100;
  s2 = (s % 100) / 10;
  s3 = (s % 100) % 10;
  
  cout << s1 + s2 + s3 << endl;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using P = pair<int, int>;
using vec = vector<int>;
using mat = vector<vector<int>>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"

constexpr int MOD = 1000000007;
const int INF = 1 << 30;

int main() {
    int n, m;
    cin >> n >> m;
    vec g[300010];
    rep(i, m) {
        int u, v;
        cin >> u >> v;
        --u; --v;
        g[u*3].push_back(v*3+1);
        g[u*3+1].push_back(v*3+2);
        g[u*3+2].push_back(v*3+0);
    }
    int s, t;
    cin >> s >> t;
    --s; --t;
    s *= 3;
    t *= 3;

    vec dist(n*3, INF);
    dist[s] = 0;

    queue<int> que;
    que.push(s);

    while (!que.empty()) {
        int v = que.front();
        que.pop();

        for (auto&& c : g[v]) {
            if (dist[c] == INF) {
                dist[c] = dist[v] + 1;
                que.push(c);
            }
        }
    }

    if (dist[t] == INF) {
        cout << "-1" << endl;
        exit(0);
    }
    else {
        cout << dist[t]/3 << endl;
    }
    return 0;
}

Measured memory_bytes: 17792
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;

int main() {
  int w, h, x, y;
  cin >> w >> h >> x >> y;
  cout << 1.0 * w * h / 2.0 << ' ' << flush;
  cout << ((w / 2.0 == x && h / 2.0 == y) ? 1 : 0) << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int k,sum;
ll ans=1,p=1;
ll calc(ll x){
	if(!x)return 0;
	else return calc(x/10)+x%10;
}
int main(){
	scanf("%d",&k);
	while(sum<k){
		printf("%lld\n",ans);
		ll x=ans+p,y=ans+p*10;
		if(x*calc(y)<=y*calc(x))ans=x;
		else{
			ans=y;
			p*=10;
		}
		sum++;
	}
	return 0;
}

Measured memory_bytes: 3840
N = int(input())
S = input()
L=len(S)

A=""
c=0
for i in range(L):
  if ord(S[i])+N <91:
    A=A+ chr(ord(S[i])+N)
  else:
    A=A+ chr(ord(S[i])-26+N)
  
print(A)

Measured memory_bytes: 3060
function main(input) {
  const args=input.split(" ");
  const a=parseInt(args[0],10);
  const b = parseInt(args[1], 10);  
  if((a*b)%2==0){
    console.log("Even");
  }
  else {
    console.log("Odd");
  }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7372
import java.util.Scanner;

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

        Integer max_len = s.length();
        int[] n_mod = new int[max_len+1];
        int[] map2019 = new int[2019];
        int pow = 1;
        for(int i=max_len-1;i>=0;i--){
            Integer num = Integer.valueOf(s.substring(i, i+1));
            Integer tmp = (num*pow + n_mod[i+1])%2019;
            n_mod[i] = tmp;
            map2019[tmp]+=1;
            pow *= 10;
            pow %= 2019;
        }

        Long count = (long)map2019[0];
        for(int i=0;i<2019;i++){
            Integer num = map2019[i];
            if(num<2)continue;
            count += num*(num-1)/2;
        }
        System.out.println(count);
    }
}

Measured memory_bytes: 46148
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;


int main(void){
  int n,c,i,j,k,x,y,d[33][33],g[505][505],t[3][33]={};
  
  cin >> n >> c;
  for (i=1;i<=c;i++) for (j=1;j<=c;j++){
    cin >> d[i][j];
  }
  for (i=0;i<n;i++) for (j=0;j<n;j++){
    cin >> g[i][j];
  }
  
  for (i=0;i<n;i++) for (j=0;j<n;j++){
    for (k=1;k<=c;k++){
      t[(i+j)%3][k]+=d[g[i][j]][k];
    }
  }
  
  int ans=1e9,s;
  for (i=1;i<=c;i++) for (j=1;j<=c;j++){
    if (i==j) continue;
    
    for (k=1;k<=c;k++){
      if (i==k || j==k) continue;
      s=t[0][i]+t[1][j]+t[2][k];
      ans=min(ans,s);
      
    }
    
  }
  
  cout << ans << endl;
  
  return 0;
}

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

int main(){
    string s,t;
    cin >> s >> t;

    vector<int> sa, ta;
    for(int i = 0; i < s.length(); i++){
       sa.push_back(s[i] - 'a');
    }
    sort(sa.begin(), sa.end());
    for(int i = 0; i < t.length(); i++) ta.push_back(t[i] - 'a');
    sort(ta.begin(), ta.end(), greater<int>());

    for(int i = 0; i < min(sa.size(), ta.size()); i++){
        if(sa[i] < ta[i]){
            cout << "Yes\n";
            return 0;
        }else if(sa[i] > ta[i]){
            cout << "No\n";
            return 0;
        }
    }

    if(sa.size() < ta.size()){
        cout << "Yes\n";
    }else   cout << "No\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define rep2(i,n) for(int i = 1; i <= (n); ++i)
#define rrep2(i,n) for(int i = (n); i > 0; --i)
#define srep(i,s,n) for(int i = s; i < (n); ++i)
#define rsrep(i,s,n) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<(x)<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { int n = (__VA_ARGS__).size(); rep(i, n) printf("%d%s", (__VA_ARGS__)[i], i != n-1 ? " " : "\n"); }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;


int main() {
    int n;
    cin >> n;
    vint a(n);
    rep(i, n) cin >> a[i];

    int mx = 0;
    ll ans = 0;
    rep(i, n) {
        ans += max(mx-a[i], 0);
        if (a[i] > mx) mx = a[i];
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4016
def factional(n,m)
    a = 0
    while n % m == 0
        a += 1
        n /= m
    end
    a
end

b = 0
c = 0
D,N = gets.split.map(&:to_i)
while b < N 
    c += 1
    if factional(c,100) == D 
        b += 1
    end
end

puts c


Measured memory_bytes: 1788
import Queue
INF = 10**9
n = input()
p = [i+int(raw_input()) for i in xrange(n)]

used = [0] * n
idx = 0
for i in xrange(n):
    if p[i]!=i:
        path = []
        go = i
        idx += 1
        while go!=INF and p[go]!=go:
            if used[go]==idx:
                go = INF
                break
            used[go] = idx
            path.append(go)
            go = p[go]
        for e in path:
            p[e] = go

dist = [INF] * n
que = Queue.Queue()
que.put(0)
dist[0] = 0
while not que.empty():
    v = que.get()
    for k in xrange(1, min(7, n-v)):
        go = p[v+k]
        if go==n-1:
            print dist[v]+1
            exit(0)
        if go!=INF and dist[v] + 1 < dist[go]:
            dist[go] = dist[v] + 1
            que.put(go)

Measured memory_bytes: 9852
n,t=map(int,input().split())
cost,time=zip(*list(map(int,input().split()) for i in range(n)))
ans='TLE'
c=list(cost)
ti=list(time)
for i in range(n):
    sc=min(c)
    if ti[c.index(sc)]<=t:
        ans=sc
        break
    else:
        ti.pop(c.index(sc))
        c.remove(sc)


print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <tuple>
#include <queue>
#include <bitset>
#include <set>
#include <map>
#include <list>

using ll = long long;
using ld = long double;
using namespace std;
const int INF = 1e9+100;
const ll INF64 = 7e18l;
const int mod = 1000000007;
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(a) (a).begin(), (a).end()
#define FIN ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);

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

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


int main(){
    FIN;
    ll n,x;
    cin >> n >> x;
    vector<ll> a(n);
    cin >> a[0];
    ll ans = abs(x - a[0]);

    if(n == 1){
        cout << ans << endl;
        return 0;
    }

    for(ll i=1;i<n;i++){
        cin >> a[i];
        ans = gcd(ans,abs(a[i]-x));
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3956
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<queue>
#include<stack>
#include<vector>
#include<map>
using namespace std;

int read(){
	int x=0,f=1;
	char c=getchar();
	while(!isdigit(c)){if(c=='-')f=-1;c=getchar();}
	while(isdigit(c)){x=(x<<3)+(x<<1)+c-48;c=getchar();}
	return x*f;
}

int k,m,n;
string s1,s2,s;
int main(){
	cin>>s1>>s2;
	n=read();m=read();
	cin>>s;
	if(s==s1)n--;
	if(s==s2) m--;
	printf("%d %d\n",n,m);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n,m;
	while(cin>>n>>m&&n){
		for(int i=0;i<n;i++){
			for(int j=0;j<m;j++){
				if(i==0||i==n-1||j==0||j==m-1)cout<<'#';
				else cout<<'.';
			}cout<<endl;
		}cout<<endl;
	}
	return 0;
}


Measured memory_bytes: 3072
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n - 1); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
#define get_unique(x) x.erase(unique(all(x)), x.end());
typedef long long ll;
typedef complex<double> Complex;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
template <class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T& a, const T& b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    map<int, int> mp;
    rep(bit, 1 << n) {
        int now = 0;
        rep(i, n) if (bit & (1 << i)) now += a[i];
        mp[now]++;
    }
    int q;
    cin >> q;
    while (q--) {
        int m;
        cin >> m;
        cout << (mp.count(m) ? "yes" : "no") << endl;
    }
}


Measured memory_bytes: 3152
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
#define REP(var, a, b) for (int var = (a); var < (b); var++)
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define ALL(c) (c).begin(), (c).end()
#define rALL(c) (c).rbegin(), (c).rend()
ll MOD = 1000000007;
const ll INF = 1LL << 62;
int main() {
  //
  ll n;
  cin >> n;
  vl x(n), y(n);
  vl par(n);
  rep(i, n) {
    cin >> x[i] >> y[i];
    par[i] = (x[i] + y[i]) & 1;
  }
  REP(i, 1, n) {
    if (par[i] != par[0]) {
      cout << -1 << endl;
      return 0;
    }
  }

  ll m = 33;
  vl d(m);
  vector<string> ans(n, "");
  for (int i = 32; i >= 0; i--) {
    d[32 - i] = (1LL << i);
  }
  if (par[0] == 0) {
    m++;
    d.emplace_back(1);
  }
  rep(i, n) {
    if (par[0] == 0) {
      y[i]++;
    }
    rep(j, 33) {
      ll u = x[i] + y[i];
      ll v = x[i] - y[i];
      if (u > 0 && v > 0) {
        ans[i].push_back('R');
        x[i] -= d[j];
      } else if (u > 0 && v < 0) {
        ans[i].push_back('U');
        y[i] -= d[j];
      } else if (u < 0 && v > 0) {
        ans[i].push_back('D');
        y[i] += d[j];
      } else {
        ans[i].push_back('L');
        x[i] += d[j];
      }
    }
    if (par[i] == 0) {
      ans[i].push_back('D');
    }
  }
  cout << m << endl;
  rep(i, m) {
    cout << d[i];
    if (i < m - 1) {
      cout << " ";
    } else {
      cout << endl;
    }
  }
  rep(i, n) { cout << ans[i] << endl; }
  return 0;
}


Measured memory_bytes: 504
import numpy as np
line = input().split()
h = int(line[0])
w = int(line[1])
grid = []
for i in range(h):
  grid.append(list(input()))
              
grid = np.array(grid)


def get8(grid,y,x):
  v = [None]*8
  try :
    if y-1 < 0 :
      pass
    else:
      v[0] = grid[y-1][x]
  except :
    pass
  try :
    if y-1 < 0 :
      pass
    else :
      v[1] = grid[y-1][x+1]
  except :
    pass  
  try :
    v[2] = grid[y][x+1]
  except :
    pass
  try :
    v[3] = grid[y+1][x+1]
  except :
    pass
  try :
    v[4] = grid[y+1][x]
  except :
    pass
  try :
    if x-1 < 0 :
      pass
    else:
      v[5] = grid[y+1][x-1]
  except :
    pass
  try :
    if x-1 < 0 :
      pass
    else:
      v[6] = grid[y][x-1]
  except :
    pass
  try :
    if y-1 < 0 or x-1 < 0 :
      pass
    else :
    	v[7] = grid[y-1][x-1]
        
  except :
    pass
  
  return v

for i in range(h) :
  for j in range(w) :
    v = get8(grid,i,j)
    if grid[i][j] == "." :
    	grid[i][j] = v.count("#")
  
  
for i in range(h) :
  print("".join(grid[i]))
  
  
  

Measured memory_bytes: 12452
//#define NDEBUG
#include <cstddef>
#include <cstdint>
#include <iostream>
#include <vector>

namespace n91 {

using i8 = std::int_fast8_t;
using i32 = std::int_fast32_t;
using i64 = std::int_fast64_t;
using u8 = std::uint_fast8_t;
using u32 = std::uint_fast32_t;
using u64 = std::uint_fast64_t;
using isize = std::ptrdiff_t;
using usize = std::size_t;

constexpr usize operator"" _z(unsigned long long x) noexcept {
  return static_cast<usize>(x);
}

class rep {
  const usize f, l;

public:
  class itr {
    friend rep;
    usize i;
    constexpr itr(const usize x) noexcept : i(x) {}

  public:
    void operator++() noexcept { ++i; }
    constexpr usize operator*() const noexcept { return i; }
    constexpr bool operator!=(const itr x) const noexcept { return i != x.i; }
  };
  constexpr rep(const usize first, const usize last) noexcept
      : f(first), l(last) {}
  constexpr itr begin() const noexcept { return itr(f); }
  constexpr itr end() const noexcept { return itr(l); }
};
class revrep {
  const usize f, l;

public:
  class itr {
    friend revrep;
    usize i;
    constexpr itr(usize x) noexcept : i(x) {}

  public:
    void operator++() noexcept { --i; }
    constexpr usize operator*() const noexcept { return i; }
    constexpr bool operator!=(const itr x) const noexcept { return i != x.i; }
  };
  constexpr revrep(usize first, usize last) noexcept : f(--first), l(--last) {}
  constexpr itr begin() const noexcept { return itr(l); }
  constexpr itr end() const noexcept { return itr(f); }
};
template <class T> using vec_alias = std::vector<T>;
template <class T> auto md_vec(const usize n, const T &value) {
  return std::vector<T>(n, value);
}
template <class... Args> auto md_vec(const usize n, Args... args) {
  return std::vector<decltype(md_vec(args...))>(n, md_vec(args...));
}
template <class T> constexpr T difference(const T &a, const T &b) {
  return a < b ? b - a : a - b;
}
template <class T> T scan() {
  T ret;
  std::cin >> ret;
  return ret;
}

} // namespace n91

#include <algorithm>
#include <iostream>
#include <utility>

namespace n91 {

void main_() {
  const auto r = scan<u32>();
  std::cout << static_cast<u32>(3) * r * r << std::endl;
}

} // namespace n91

int main() {
  n91::main_();
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <map>
#include <vector>
#include <cmath>
#include <ios>
#include <iomanip>
#include <algorithm>
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP2(i, m, n) for (int i = (m); i < (int)(n); ++i)
#define REPR(i, n) for (int i = (n)-1; i >= 0; --i)
#define REPR2(i, m, n) for (int i = (n)-1; i >= (m); --i)
#define REPx(x, a) for(auto x : a)
#define ALL(a) a.begin(), a.end()
#define SORT(a) sort(ALL(a))
#define SORTR(a) sort(ALL(a), greater<int>())
#define REVERSE(a) reverse(ALL(a))
#define bit_search(bit, n) REP(bit, 1<<(n))
#define bit_check(bit, i) (bit>>(i)) & 1
#define setpre(n) fixed << setprecision((n))
#define UNIQUE(a) do {SORT(a); (a).erase(unique(ALL(a)), (a).end());} while(0)
#define MAX(a) *max_element(ALL(a))
#define MIN(a) *min_element(ALL(a))
#define bisect_left(a, x) lower_bound(ALL(a), (x)) - a.begin()
#define bisect_right(a, x) upper_bound(ALL(a), (x)) - a.begin()
#define INPUT(a) REP(i, a.size()) cin >> a[i];
#define INPUTP(a) REP(i, a.size()) cin >> a[i].first >> a[i].second;
#define OUTPUT_PERMUTATION(n) do{VI v(n); iota(ALL(v), 1); do{REPx(x, v) cout << x << " "; ENDL} while(next_permutation(ALL(v)));} while(0);
#define MAKE_PERMUTATION(n) do{VVI a(fact(n), VI(n)); int idx = 0; VI v(n); iota(ALL(v), 1); do{REP(i, n) a[idx][i] = v[i]; idx++; PER = a;} while(next_permutation(ALL(v)));} while(0); // int fact(), VVI PERを宣言しておく
#define ENDL cout << endl;
using namespace std;
using LL = long long;
using LD = long double;
using PII = pair<int, int>;
using VPII = vector<PII>;
using PLL = pair<LL, LL>;
using VPLL = vector<PLL>;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VC = vector<char>;
using VS = vector<string>;
using VB = vector<bool>;
using VD = vector<double>;
const int INF = 1e9;
const LL MOD = 1e9 + 7;

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;}

void END(){cout << 1 << endl; exit(0);}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  VI X(n);
  INPUT(X);
  int ans = INF;
  REP2(i, 1, 101)
  {
    int tmp = 0;
    REPx(x, X) tmp += abs(x-i)*abs(x-i);
    chmin(ans, tmp);
  }
  cout << ans;

  return 0;
}


Measured memory_bytes: 256
use std::io;
use std::str::FromStr;
use std::cmp::max;
use std::collections::HashMap;

type Item = (u64, u64);

fn input_tuple() -> (u64, u64) {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    let vec: Vec<u64> = line.split_whitespace().map(|s| s.parse().unwrap()).collect();
    (vec[0], vec[1])
}

fn dp(i: u64, w: u64, items: &Vec<Item>, caches: &mut HashMap<u64, u64>) -> u64 {
    // println!("{:?}", caches);
    if i == items.len() as u64 {
        return 0;
    }
    if caches.contains_key(&(1000 * w + i)) {
        // println!("cache hit: {}, {} -> {}", w, i, *caches.get(&(1000 * w + i)).unwrap());
        return *caches.get(&(1000 * w + i)).unwrap();
    }
    if w < items[i as usize].1 {
        let result = dp(i+1, w, items, caches);
        caches.insert(1000 * w + i, result);
        return result;
    }
    let result = max(dp(i+1, w, items, caches), dp(i+1, w - items[i as usize].1, items, caches) + items[i as usize].0);
    caches.insert(1000 * w + i, result);
    result
}

fn main() {
    let (n, w) = input_tuple();
    let mut items: Vec<Item> = Vec::new();
    let mut caches: HashMap<u64, u64> = HashMap::new();
    for _ in 0..n {
        let item = input_tuple();
        items.push(item);
    }
    println!("{}", dp(0, w, &items, &mut caches));
}



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

using namespace std;

int main() {
	int n, m; 
	while (cin >> n >> m && (n || m)) {
		vector<pair<int, int> > dv(n);
		int d, v;
		for (int i = 0; i < n; ++i) {
			cin >> d >> v;
			dv[i] = make_pair(d, v);
		}
		sort(dv.begin(), dv.end(), greater<pair<int, int> >());
		int ans = 0, level = m;
		for (int i = 0; i < n; ++i) {
			if (dv[i].first == m) {
				ans += dv[i].second;
				m--;
			}
		}
		cout << ans << endl;
	}

	return 0;
}


Measured memory_bytes: 3084
H, W = map(int, input().split())
S = [input() for i in range(H)]

MOD = 10**9 + 7

dp = [[0]*(W+1) for i in range(H+1)]
dp[1][0] = 1
for i in range(H):
    s = S[i]
    for j in range(W):
        if s[j] == '#':
            continue
        dp[i+1][j+1] = (dp[i][j+1] + dp[i+1][j]) % MOD
print(dp[H][W])

Measured memory_bytes: 53232
#include<iostream>
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<math.h>
#include<algorithm>
#include<iomanip>

using namespace std;

vector<vector<long long >>memo;

long long f(long long n, long long k) {
	if (memo[n][k] > -1)
		return memo[n][k];
	if (k <= 0) {
		memo[n][k] = 1;
		return memo[n][k];
	}
	else if (k >= n) {
		memo[n][k] = 1;
		return memo[n][k];
	}
	else {
		memo[n][k] = f(n - 1, k - 1) + f(n - 1, k);
		return memo[n][k];
	}
}

int main() {
	int n;
	long long ans = 0;
	vector<long long> a;
	cin >> n;
	a.resize(3 * n);
	for (int i = 0; i < 3 * n; i++) {
		cin >> a[i];
	}
	sort(a.begin(), a.end());
	for (int i = 0; i < 2 * n; i+=2) {
		ans += a[3*n - 2 - i];
	}
	cout << ans << endl;
//	cin >> n;
	return 0;
}

Measured memory_bytes: 2560
n = int(input())
AC = 0
WA = 0
TLE = 0
RE = 0
for i in range(n):
    j = input()
    if j == "AC":
        AC += 1
    elif j == "WA":
        WA += 1
    elif j == "TLE":
        TLE += 1
    else:
        RE += 1
print("AC x", AC)
print("WA x", WA)
print("TLE x", TLE)
print("RE x", RE)

Measured memory_bytes: 9168
#include <iostream>
#include <math.h>
using namespace std;

int main() {
	int N;
	cin >> N;
	long long int ans = 1;
	for (int x = 0;x < N;x++) {
		ans = ans * (x + 1);
		ans = ans % 1000000007;
	}
	cout << ans << endl;
}

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

int     main() {
        int N;
        cin >>N;
        vector<long> H(N);
        for (int i=0; i<N; i++)
                cin >>H.at(i);
        int S=0;
        int ss=0;
        for (int i=0; i<N-1; i++) {
                if (H.at(i+1)<=H.at(i)) {
                        ss++;
                        S=max(S, ss);
                } else
                        ss=0;
        }
        cout <<S <<endl;
        return 0;
};

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define fast                                                                   \
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int long long
#define ll long long
#define f(i, n) for (int i = 0; i < n; i++)
#define ff(i, n) for (int i = 1; i <= n; i++)
#define F first
#define S second
#define vpii vector<pair<int,int> >
#define sz size()
#define all(v) v.begin(),v.end()
#define pb push_back   
#define PB pop_back
#define vl vector<int>
#define mp make_pair
#define mod 1000000007
typedef unsigned long long ull;
const int N = 200005;
const int MOD = 998244353 ;

void solve(){
    int n, k, ans = 0;
    cin>>n;
    ff(i,n){
        cin>>k;
        if(k%2 && i%2)ans++;
    }
    cout<<ans;
}

int32_t main() {
    fast
    int t;
    t = 1;
    //cin >> t;
    while(t--)solve();
    return 0;
}


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

int main(){
  int a[9];
  for(int i=0;i<9;i++) cin >> a[i];
  int n;
  cin >> n;
  
  int b;
  for(int i=0;i<n;i++){
    cin >> b;
    for(int j=0;j<9;j++){
      if(b==a[j]) a[j] = 0;
    }
  }
  //
  for(int i=0;i<9;i+=3){
    if(a[i]==0 && a[i+1]==0  && a[i+2]==0){
      cout << "Yes" << endl;
      return 0;
    }
  }
  
  for(int i=0;i<3;i++){
    if(a[i]==0 && a[i+3]==0 && a[i+6]==0){
      cout << "Yes" << endl;
      return 0;
    }
  }
  
  if(a[0]==0 && a[4]==0 && a[8]==0){
    cout << "Yes" << endl;
      return 0;
  }else if(a[2]==0 && a[4]==0 && a[6]==0){
    cout << "Yes" << endl;
    return 0;
  }
  cout << "No" << endl;
  return 0;
}


/*
84 97 66
79 89 11
61 59 7
7
89
7
87
79
24
84
30
*/




Measured memory_bytes: 256
def main():
  import math
  import sys
  imput=sys.stdin.readline
  a=int(input())
  b=input()
  R=0
  L=0
  ans=1
  mod=10**9+7
  if b[0]=="W" or b[-1]=="W":
    print(0)
    exit()
  for i in range(2*a):
    if i==0:
      L+=1
      fr="L"
    else:
      if b[i]==b[i-1]:
        if fr=="L":
          ans=ans*(L-R)%mod
          R+=1
          fr="R"
        else:
          L+=1
          fr="L"
      else:
        if fr=="L":
          L+=1
        else:
          ans=ans*(L-R)%mod
          R+=1
    
  if L!=R:
    print(0)
    exit()


  
  print(ans*math.factorial(a)%mod)
  

if __name__ == '__main__':  
  main()
  

Measured memory_bytes: 4328
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#define _USE_MATH_DEFINES
using namespace std;
typedef long long ll;
double pi = 3.141592653589793;
ll mod = 1000000007;

bool isPrime(int n) {
    bool ok = true;
    for (int i = 2; i * i <= n; i++) {
        if(n % i == 0) {
            ok = false;
        }
    }
    return ok;
}

int main() {
    int N;
    cin >> N;
    int a[N];
    int count = 0;
    for (int i = 1; i < 10000; i++) {
        if(isPrime(5 * i + 1)) {
            a[count] = 5 * i + 1;
            count++;
        }
        if(count == N) {
            break;
        }
    }
    for(int i = 0; i < N; i++) {
        cout << a[i] << " ";
    }
    cout << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int i, n;
	double a;
	
	scanf("%d", &n);
	a = 1;
	for (i = 2; i <= n; i++) {
		a *= i;
	}
	printf("%0.0lf\n", a);
	return (0);
}

Measured memory_bytes: 632
//大文字->小文字 tolower(),逆はtoupper()
//int a = stoi(c); 文字列をintへ
//途中の出力をそのまま残さない
//数値計算 個数以外はdouble
//map<キー,値> p は辞書。p[キー] = 値
//mapのキー：p->first mapのバリュー：p->second
//map 全探索
//auto begin = p.begin(), end = p.end();
//for (auto i = begin; i != end; i++) {}
//絶対値 abs()
//入力は空白で切れる
//大文字判定 isupper(文字) 小文字判定 islower(文字)
//do{}while(next_permutation(ALL(配列)))
#include <bits/stdc++.h>
#define rep(i,N) for(int i = 0; i < N;i++)
#define ALL(a) (a).begin(),(a).end()
#define ll long long int
using namespace std;

// Nの桁数
ll dig(ll N) {
	ll dig = 0;
	while (N) {
		dig++;
		N /= 10;
	}
	return dig;
}
// x,yの最大公約数
ll gcd(ll x, ll y) {
	ll r;
	while (x%y) {
		r = x % y;
		x = y;
		y = r;
	}
	return y;
}

int main() {
	int A, B; cin >> A >> B;

	int ans = 0;
	for (int x = A; x <= B; x++) {
		int a, b, c, d;
		a = x / 10000;
		b = (x / 1000) % 10;
		c = (x / 10) % 10;
		d = x % 10;

		if (a == d && b == c) {
			ans++;
		}
	}

	cout << ans << endl;
}

Measured memory_bytes: 256