akhauriyash/Code-Regression huggingface dataset:
/*program from Wolfycz*/
#include<cmath>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#define inf 0x3f3f3f3f
#define min(x,y) (x<y?x:y)
#define max(x,y) (x>y?x:y)
using namespace std;
typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
inline char gc(){
	static char buf[1000000],*p1=buf,*p2=buf;
	return p1==p2&&(p2=(p1=buf)+fread(buf,1,1000000,stdin),p1==p2)?EOF:*p1++;
}
inline int frd(){
	int x=0,f=1; char ch=gc();
	for (;ch<'0'||ch>'9';ch=gc())	if (ch=='-')	f=-1;
	for (;ch>='0'&&ch<='9';ch=gc())	x=(x<<3)+(x<<1)+ch-'0';
	return x*f;
}
inline int read(){
	int x=0,f=1; char ch=getchar();
	for (;ch<'0'||ch>'9';ch=getchar())	if (ch=='-')	f=-1;
	for (;ch>='0'&&ch<='9';ch=getchar())	x=(x<<3)+(x<<1)+ch-'0';
	return x*f;
}
inline void print(int x){
	if (x<0)	putchar('-'),x=-x;
	if (x>9)	print(x/10);
	putchar(x%10+'0');
}
const int N=1e3,M=5e3;
int pre[N+10],now[N+10],child[N+10],tot;
int f[N+10],g[2][M+10],v[N+10];
void join(int x,int y){pre[++tot]=now[x],now[x]=tot,child[tot]=y;}
void dfs(int x){
	for (int p=now[x],son=child[p];p;p=pre[p],son=child[p])	dfs(son);
	memset(g[0],63,sizeof(g[0]));
	int T=0; g[T][0]=0;
	for (int p=now[x],son=child[p];p;p=pre[p],son=child[p]){
		T^=1;
		memset(g[T],63,sizeof(g[T]));
		for (int i=0;i<=v[x];i++){
			if (i>=v[son])	g[T][i]=min(g[T][i],g[T^1][i-v[son]]+f[son]);
			if (i>=f[son])	g[T][i]=min(g[T][i],g[T^1][i-f[son]]+v[son]);
		}
	}
	for (int i=0;i<=v[x];i++)	f[x]=min(f[x],g[T][i]);
}
int main(){
	int n=read();
	for (int i=2;i<=n;i++)	join(read(),i);
	for (int i=1;i<=n;i++)	v[i]=read();
	memset(f,63,sizeof(f));
	dfs(1);
	printf(f[1]<inf?"POSSIBLE\n":"IMPOSSIBLE\n");
	return 0;
}

Measured memory_bytes: 384
a,b = map(int, input().split())
s=str(input())
ok=True
for i in range(a+b+1):
    if(i==a):
        if(not s[i]=='-'):
            ok=False
    else:
        subs=s[i:i+1]
        if(not subs.isdecimal()):
            ok=False

if(ok==True):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
N = int(input())
S = input()

def check(s, i, j, k):
    if j and s == "o" and i != k:
        return True
    elif j and s == "x" and i == k:
        return True
    elif not j and s == "o" and i == k:
        return True
    elif not j and s == "x" and i != k:
        return True
    return False

def func(f, s):
    l = [-1]*N
    l[0] = f
    l[1] = s
    for i in range(1, len(l) - 1):
        if l[i] and S[i] == "o" or not l[i] and S[i] == "x":
            l[i + 1] = l[i - 1] ^ 1
        else:
            l[i + 1] = l[i - 1]
    if check(S[-1], l[-2], l[-1], l[0]):
        if check(S[0], l[-1], l[0], l[1]):
            return l
    return False

for i, j in [(0, 0), (0, 1), (1, 1), (1, 0)]:
    l = func(i, j)
    if l:
        for v in l:
            print("SW"[v], end="")
        print()
        exit()
print(-1)

Measured memory_bytes: 56408
package main;import "fmt";func main(){var n,q int;var k int64;fmt.Scan(&n,&q);p:=[]int64{0,int64(n)};for i:=0;i<q;i++ {fmt.Scan(&k);j:=len(p);for k<=p[j-1] {j--};p=append(p[:j],k)};q=len(p)-1;t:=make([]int64,q+1);t[q]=1;ans:=make([]int64,n+1);for i:=q;i>0;i-- {j:=i;k=p[i];for k>p[1] {l,r:=1,j;for r-l>1 {m:=(l+r)/2;if p[m]>k {r = m} else {l = m}};j=l;t[j]+=k/p[j]*t[i];k%=p[j]};ans[k]+=t[i]};for i:=n-1;i>0;i-- {ans[i]+=ans[i+1]};for i:=1;i<n+1;i++ {fmt.Println(ans[i])}}

Measured memory_bytes: 7936
{-# LANGUAGE CPP #-}
module Main where

import qualified Data.Vector as V 
import qualified Data.Map.Strict as M
import Control.Monad
import qualified Data.ByteString.Char8 as BS
import Data.Maybe

dump :: (Show a) => a -> IO()
#if __GLASGOW_HASKELL__ >= 850
dump x = print x
#else
dump _ = pure ()
#endif

readint :: IO Int
readint = (fst . fromJust . BS.readInt) <$> BS.getLine

readvec :: IO [Int]
readvec = (fmap (read . BS.unpack) . BS.words) <$> BS.getLine

newtype UF a = UF (M.Map a a) deriving (Show) -- Map node parent

makeuf :: Int -> UF Int
makeuf n = let m = M.fromList $ zip [0..n] [0..n]
                in UF m

union :: (Eq a, Ord a) => a -> a -> UF a -> UF a
union l r uf@(UF m) = let lp = find l uf
                          rp = find r uf
                      in if lp == rp
                         then uf
                         else if size l uf < size r uf
                              then UF $ M.update (const $ Just rp) lp m
                              else UF $ M.update (const $ Just lp) rp m

find :: (Eq a, Ord a) => a -> UF a -> a
find x uf@(UF m) = let px = m M.! x
                in if px == x
                   then px
                   else find px uf

size :: (Eq a, Ord a) => a -> UF a -> Int
size x (UF m) = M.size $ M.filter (\par -> par==x) m

main :: IO()
main = do
  [a,b,c] <- readvec
  print $ min (b `div` a) (fromIntegral c)


Measured memory_bytes: 508
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <numeric>
using namespace std;
typedef long long int ll;

typedef long double lld;

#define REP(i,n) for(int i=0;i<n;i++)
#define EPS (1e-9)
#define INF (1e9 + 1)
#define PI (acos(-1))

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

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

ll A, B, C, D;

int main() {
	cin >> A >> B >> C >> D;

	if (C < D) swap(C, D);
	ll g = lcm(C, D);

	ll cMae = (A - 1) / C;
//	cout << "cMae" << cMae << endl;
	ll dMae = (A - 1) / D;
//	cout << "dMae" << dMae << endl;
	ll MaeGcd = (A - 1) / g;
//	cout << "MaeGcd" << MaeGcd << endl;
	//gCDの分ひく
	ll MaeSum = cMae + dMae - MaeGcd;

	ll cAto = B / C;
//	cout << "cAto" << cAto << endl;
	ll dAto = B / D;
//	cout << "dAto" << dAto << endl;
	ll AtoGcd = B / g;
//	cout << "AtoGcd" << AtoGcd << endl;
	ll AtoSum = cAto + dAto - AtoGcd;
	
	ll Sum = AtoSum - MaeSum;

	ll E = B - A + 1;

	cout << E - Sum << endl;
}

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

int Checker(vector<vector<int>> sw,vector<int> s,vector<int> *p){
  for(int i = 0;i<sw.size();i++){
    int sum = 0;
    for(int j = 0; j<sw.at(i).size();j++){
      sum+=s.at(sw.at(i).at(j)-1);
    }
    if(sum%2!=p->at(i)){
      return 0;
    }
  }


  return 1;
}

void Search(vector<vector<int>> sw,vector<int> s,int *count,vector<int> *p){
  int i;
  int f=0;
  for(i=0;i<s.size();i++){
    if(s.at(i)==-1)break;
    if(i==s.size()-1)f=1;
  }
  if(f==1){
    *count+=Checker(sw,s,p);
    return;
  }else{
    s.at(i)=0;
    Search(sw,s,count,p);
    s.at(i)=1;
    Search(sw,s,count,p);
  }
  return;
}

int main(){
  int N,M;
  cin>>N>>M;
  vector<int> s(N,-1);
  vector<int> p(M);
  vector<vector<int>> sw(M);
  int count = 0;
  for(int i = 0;i<M;i++){
    int k;
    cin>>k;
    for(int j = 0; j < k;j++){
      int ind;
      cin>>ind;
      sw.at(i).push_back(ind);
    }
  }
  for(int i = 0;i<M;i++){
    cin>>p.at(i);
  }
  Search(sw,s,&count,&p);

  cout<<count<<endl;

}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <ios> 
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>
#include <map>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)

using namespace std;
typedef long long int lli;
typedef vector<int> vi;
//const int MAX=;

long double dp[305][305][305];

int main(){
	int N;
	cin>>N;
	int a[4]={};
	
	rep(i,N){
		int x;
		cin>>x;
		a[x]++;
	}
	
	//dp[i][j][k]=(dp[i-1][j][k]*i+dp[i+1][j-1][k]*j+dp[i][j+1][k-1]*k)/s+N/s;
	
	rep(k,N+1)rep(j,N+1)rep(i,N+1){
		long double s=(long double)i+j+k;
		if(s>N)break;
		if(s==0)continue;
		
		if(i)dp[i][j][k]+=dp[i-1][j][k]*i;
		if(j)dp[i][j][k]+=dp[i+1][j-1][k]*j;
		if(k)dp[i][j][k]+=dp[i][j+1][k-1]*k;
		dp[i][j][k]+=N;
		dp[i][j][k]/=s;
	}
	cout<<fixed<<setprecision(12)<<dp[a[1]][a[2]][a[3]];
}

Measured memory_bytes: 436480
//#include <cmath>
//#include <ctime>
#include <cstdio>
//#include <cstdlib>
//#include <cstring>

//#include <map>
//#include <set>
//#include <queue>
//#include <string>
//#include <vector>
//#include <sstream>
//#include <iostream>
#include <algorithm>
//#include <functional>

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;

const int MAXN = 100005;
const int P = 1000000007;
const int INF = 1000000007;
const double eps = 1e-6;

inline int getint() {
    int r = 0; bool b = true; char c = getchar();
    while (c < '0' || c > '9') { if (c == '-') b = false; c = getchar(); }
    while (c >= '0' && c <= '9') { r = (r<<1)+(r<<3) + c - '0'; c = getchar(); }
    return b ? r : -r;
}

int n;
pair<pair<int, int>, LL > a[MAXN];

//s w v

LL dp[MAXN], ans;

bool cmp(pair<pair<int, int>, LL > a, pair<pair<int, int>, LL > b) {
    return a.first.first + a.first.second < b.first.first + b.first.second;
}

int main() {
    
    n = getint();
    for (int i = 1; i <= n; ++i) {
        a[i].first.first = getint();
        a[i].first.second = getint();
        a[i].second = getint();
    }

    sort(a + 1, a + n + 1, cmp);
    for (int i = 1; i <= n; ++i) {
        for (int j = a[i].first.second; j >= 0; --j)
            ans = max(ans, dp[j + a[i].first.first] = max(dp[j + a[i].first.first], dp[j] + a[i].second));
        #ifdef DEBUGMODE
        for (int j = 0; j <= a[n].first.second*2; ++j)
            printf("%d ", dp[j]);
        putchar('\n');
        #endif
            
    }
    printf("%lld", ans);
}


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

using namespace std;

int main () {
    unsigned long long x;
    cin >> x;

    double t = 100;
    unsigned long long n = 0;
    while (t < x) {
        t = t * 101 / 100;
        t = floor(t);
        n++;
    }
    cout << n << endl;

}



Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<ll, ll>;
#define rep(i, n)  for (int i = 0; i <  (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define all(x) (x).begin(), (x).end()

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

    ll N;
    cin >> N;
    vector<ll> Ai(N);
    rep(i,N){
        cin >> Ai[i];
    }

    string result = "APPROVED";

    rep(i,N){
        if(Ai[i] % 2 == 0){
            if(Ai[i] % 3 != 0 && Ai[i] % 5 != 0){
                result = "DENIED";
            }
        }
    }

    cout << result;
}

Measured memory_bytes: 256
package main

import (
  "fmt"
)

func main() {
  var (
    n int
    count int
    )

  fmt.Scan(&n)
  nums := make([]int, n)
  for i := 0; i < n; i++ {
      fmt.Scan(&nums[i])
  }

  count = 1
  for i := 1; i < n; i++ {
    k := 0
    for j := 0; j < i; j++ {
      if nums[j] <= nums[i] {
        k = k + 1
      }
    }
    if i == k {
      count = count + 1
    }
  }
  fmt.Println(count)

}


Measured memory_bytes: 512
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << (x) << '\n'

using namespace std;
using Graph = vector<vector<int>>;

typedef int64_t Int;
const double pi = M_PI;

int main() {
    int N;
    string S;
    cin >> N >> S;

    int ans = 0;

    for (char i = '0'; i < '0' + 10; i++) {
        for (char j = '0'; j < '0' + 10; j++) {
            for (char k = '0'; k < '0' + 10; k++) {
                queue<char> digits;
                digits.push(i);
                digits.push(j);
                digits.push(k);

                for (auto n : S) {
                    if (!digits.empty() && digits.front() == n) {
                        digits.pop();
                    }
                }

                if (digits.empty()) {
                    ans++;
                }
            }
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i= (a); i < (b); ++i)
typedef long long ll;
typedef pair<int,int> P;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
int main() { int N;
  cin >> N;
  cout << "ABC" << N << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define sz 100002
#define pb push_back
#define ff first
#define ss second
#define ll long long
#define P push
#define PQ priority_queue<double, vector<double>, greater<double> >q

#define VEC(n) ll int x; vector<ll int>v;for(int i=0;i<n;i++){cin>>x;v.pb(x);}
#define TEST() int test;cin>>test; while(test--)
#define FAST() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
using namespace std;
//Upper_bound   auto x=upper_bound(v[a].begin(),v[a].end(),les);les=*x; if(x==v[a].end())break;
//ll int LCM(ll int a,ll int b) { ll int gcd=__gcd(a,b);ll int lcm=a*b/gcd;return lcm;}
//ll int bigmod(ll int b, ll int p, ll int m){if(p==0)return 1;if(p%2!=0) return b%m*fun(b,p-1,m)%m;if(p%2==0){ ll int res=fun(b,p/2,m);return (res%m*res%m)%m;}}
//void seive() { prime[np++]=2;for(i=3; i<=sz; i+=2){if(mark[i]==0){ prime[np++]=i;for(j=i*i; j<=sz; j+=i) mark[j]=1; } }}
//string add(string s1,string s2) {string s;int j=s1.size()-1,c=0,m; for(int i=s2.size()-1; i>=0; i--) {if(j>=0)m=s2[i]-'0'+s1[j]-'0'+c;else m=s2[i]-'0'+c; if(m>9) { s+=m%10+'0';c=m/10; } else {  c=0;s+=m+'0'; }j--; } if(c!=0) {s+=c+'0'; }reverse(s.begin(),s.end());return s;}
//int pos;string mul(int n) {string s;for(int i=0; i<pos; i++) { s+="0"; }pos++;int c=0,m; for(int i=s1.size()-1; i>=0; i--) { m=(s1[i]-'0')*n+c;if(m>9) { s+=m%10+'0';c=m/10;} else { c=0; s+=m+'0';} }while(c!=0) { s+=c%10+'0';c=c/10;}    reverse(s.begin(),s.end());return s;}

int main()
{
    FAST();
    int n,res=-1,num=0;
  cin>>n;
  for(int i=1;i<=n+1;i++)
  {
      num=num*10+7;
      num%=n;
      if(num==0){cout<<i<<endl;return 0;}
  }
  cout<<"-1"<<endl;


}



Measured memory_bytes: 3648
#0:上面 1:南 2:東 3:西 4:北 5:裏側
class Dice():

    def __init__(self):
        self.number = [i for i in range(6)]  #[0, 1, 2, 3, 4, 5]
        self.work = [i for i in range(6)]

    def setNumber(self, n0, n1, n2, n3, n4, n5):
        self.number[0] = n0
        self.number[1] = n1
        self.number[2] = n2
        self.number[3] = n3
        self.number[4] = n4
        self.number[5] = n5


    def roll(self,loc):
        for i in range(6):
            self.work[i] = self.number[i]

        if loc == 'E':
            self.setNumber(self.work[3],self.work[1],self.work[0],self.work[5],self.work[4],self.work[2])
        elif loc == 'N':
            self.setNumber(self.work[1],self.work[5],self.work[2],self.work[3],self.work[0],self.work[4])
        elif loc == 'S':
            self.setNumber(self.work[4],self.work[0],self.work[2],self.work[3],self.work[5],self.work[1])
        elif loc == 'W':
            self.setNumber(self.work[2],self.work[1],self.work[5],self.work[0],self.work[4],self.work[3])


    def get_Top(self):
        return self.number[0]


# n = list(map(int, input().split()))
dice = Dice()
n = list(map(int, input().split()))
dice.setNumber(n[0], n[1], n[2], n[3], n[4], n[5])
directions = input()
for direction in directions:
    dice.roll(direction)
print(dice.get_Top())


Measured memory_bytes: 5616
import java.util.Scanner;



public class Main {
    public static void main(String[] args) {

        Scanner in = new Scanner(System.in);
        int n = in.nextInt();

        int[][]  arr = new  int[n][3];

        for(int i=0;i<n;i++){
            for(int j=0;j<=2;j++){
                arr[i][j] = in.nextInt();
            }
        }

        int[][] dp = new int[n][3];

        dp[0][0] = arr[0][0];
        dp[0][1] = arr[0][1];
        dp[0][2] = arr[0][2];


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

                dp[i][0] = arr[i][0] + Math.max(dp[i-1][1],dp[i-1][2]);
                dp[i][1] = arr[i][1] + Math.max(dp[i-1][0],dp[i-1][2]);
                dp[i][2] = arr[i][2] + Math.max(dp[i-1][1],dp[i-1][0]);

        }

        int x = Math.max(Math.max(dp[n-1][0],dp[n-1][1]),dp[n-1][2]);

//        for(int i=0;i<n;i++){
//            for(int j=0;j<=2;j++){
//                System.out.print(dp[i][j]+" ");
//            }
//            System.out.println();
//        }



        System.out.println(x);





    }

}


Measured memory_bytes: 96808
using System;
using System.Collections.Generic;
using System.Linq;

namespace T1PBC2019C
{
    class MainClass
    {


        static int[] n;

        public static void Main(string[] args)
        {

            n = Array.ConvertAll(Console.ReadLine().Split().ToArray(), int.Parse);
            string s = Console.ReadLine();

            int wcnt = 0;
            for(int i = 0; i < n[0]; i++)
            {
                if (s[i] == '.') wcnt++;
            }

            int bcnt = 0;
            int ans = wcnt;

            for(int i = 0; i < n[0]; i++)
            {
                if (s[i] == '#')
                {
                    bcnt++;
                }
                else
                {
                    wcnt--;
                }
                ans = Math.Min(ans, bcnt + wcnt);
            }

            Console.WriteLine(ans);




        }
    }
}


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

int main(){
  int N;
  cin >> N;
  int sum = 0;
  
  int num = N;
  while ( num != 0){
    sum += num % 10;
    num /= 10;    
  }
  
  if(N % sum == 0) cout << "Yes"<<endl;
  else cout << "No" << endl;
  
  return 0;
}

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

void solve() {
    int n;
    std::cin >> n;

    std::vector<std::string> ss(n);
    for (auto& s : ss) std::cin >> s;

    int ans = n + 1;
    for (int i = 0; i < n; ++i) {
        int cnt = std::count(ss[i].begin(), ss[i].end(), '.');
        ++cnt;
        for (int j = 0; j < n; ++j) {
            if (ss[j][i] != '.') {
                --cnt;
                break;
            }
        }
        ans = std::min(ans, cnt);
    }

    for (int j = 0; j < n; ++j) {
        bool allblack = true;
        for (int i = 0; i < n; ++i) {
            if (ss[i][j] != '#') allblack = false;
        }
        if (!allblack) ++ans;
    }

    std::cout << (ans > n * 2 ? -1 : ans) << std::endl;
}

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

    solve();

    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A,B,C,D;
  cin>>A>>B>>C>>D;
  if(A+B==C+D){
  cout<<"Balanced"<<endl;
  }
  else if(A+B>C+D){
  cout<<"Left"<<endl;
  }
  else{
  cout<<"Right"<<endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define debug  freopen("in.txt","r",stdin),freopen("out.txt","w",stdout);
#define pb push_back
#define all(x) x.begin(),x.end()
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int maxn = 1e6+10;
const int maxM = 1e6+10;
const int inf = 0x3f3f3f3f;

int N,M;
int a[maxn],pos[maxn],curpos = 1;
int tr[maxn];
int ans[maxn];
struct node
{
	int l,r,id;
	bool operator <(const node &o)const{
		return r < o.r;
	}
}lr[maxn];
int lowbit(int x){
	return x & -x;
}
void add(int x,int v){
	for(int i = x;i<=N;i += lowbit(i)) tr[i] += v;
}
int query(int r){
	int sum = 0;
	for(int i = r;i>=1;i -= lowbit(i)) sum += tr[i];
	return sum;
}
inline void read(int &x){
    int s=0,w=1;
    char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=getchar();}
    while(ch>='0'&&ch<='9') s=s*10+ch-'0',ch=getchar();
    x = s*w;
}
void todo(int r){
	// cout<<"curpos = "<<curpos<<'\n';
	for(int i = curpos;i<=r;i++){
		if(pos[a[i]] == 0){
			pos[a[i]] = i;
			add(i,1);
		}else{
			add(pos[a[i]],-1);
			pos[a[i]] = i;
			add(i,1);
		}
	}
	curpos = r+1;
}
void solve(){
	sort(lr+1,lr+M+1);
	for(int i = 1;i<=M;i++){
		todo(lr[i].r);
		ans[lr[i].id] = query(lr[i].r) - query(lr[i].l-1);
	}
	for(int i = 1;i<=M;i++) printf("%d\n",ans[i]);
}
int main(){
	// debug;
	// ios;

	cin>>N>>M;
	for(int i = 1;i<=N;i++) read(a[i]);
	for(int i = 1;i<=M;i++){
		lr[i].id = i;
		read(lr[i].l);
		read(lr[i].r);
	}
	solve();
	return 0;
}


Measured memory_bytes: 17444
#include<iostream>
#include<cmath>
using namespace std;
int min_num(int x){
    if(x%2 == 0)return x/2;
    else return x;
}
int main(void){
    int n,k;
    cin>>n>>k;
    long long ans(0);
    for(int i(1);i<=n;i++){
        if(i%min_num(k) == 0){
            long long num = (n-i)/k + 1;
            ans += (long long)pow(num,3) - (long long)pow(num-1,3);
        } 
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    int w, h;
    while (cin >> h >> w, w) {
        while (h--) {
            for (int i = 0; i < w; i++) {
                cout << "#";
            }
            cout << endl;
        }
		cout << endl;
    }
}


Measured memory_bytes: 3100
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)


int main(){
  ll N;
  cin >> N;
  ll a[3*N];
  rep(i,3*N) cin >> a[i];
  ll smae[N+1];//前N+i要素のうちのN要素の総和の最大値
  ll sato[N+1];//後ろN+i要素うちのN要素の総和の最小値
  rep(i,N+1) smae[i]=0;
  rep(i,N+1) sato[i]=0;
  //  cout << "mae" << endl;
  priority_queue<int, vector<int>, greater<int> > quemae;
  priority_queue<int> queato;
  rep(i,N) quemae.push(a[i]);
  rep(i,N) queato.push(a[2*N+i]);
  rep(i,N+1){
    if(i==0) rep(j,N)smae[i]+=a[j];
    else if(a[N-1+i]<quemae.top()){
      smae[i]=smae[i-1];
    }
    else {
      int mae_min=quemae.top();
      quemae.pop();
      smae[i]=smae[i-1]-mae_min+a[N-1+i];
      quemae.push(a[N-1+i]);
    }
    
    //    cout << smae[i] << endl;
  }
  rep(i,N+1){
    if(i==0) rep(j,N) sato[i]+=a[2*N+j];
    else if(a[2*N-i]>queato.top()){
      sato[i]=sato[i-1];
    }
    else{
      int ato_min=queato.top();
      queato.pop();
      sato[i]=sato[i-1]-ato_min+a[2*N-i];
      queato.push(a[2*N-i]);
    }
    //        cout << a[2*N-i] << endl;
    //    cout << sato[i] << endl;
  }
  ll ans=-INT_MAX*(N*1LL);
  rep(i,N+1){
    ans = max(smae[i] - sato[N-i],ans);
  }
  cout << ans << endl;

  
  return 0;

}


Measured memory_bytes: 5368
#include <bits/stdc++.h>
#define int long long
#define ALL(v) (v).begin(),(v).end()
#define Vi vector<int>
#define pb push_back
#define mp make_pair
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repeq(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=a;i>b;i--)
#define repreq(i,a,b) for(int i=a;i>=b;i--)
#define leng(n) (int)(log10(n)+1)
#define INF 9000000000000000000  //  9.0 * 10^18
#define MOD 1000000007  //  10^9 + 7
#define PAI 3.14159265358979
// ver1.8
using namespace std;

int gcd(int a,int b){return b?gcd(b,a%b):a;}  //  最大公約数gcd
int lcm(int a,int b){return a/gcd(a,b)*b;}  //  最小公倍数lcm

signed main() {
  cout << fixed << setprecision(14);
  int n;
  cin >> n;
  Vi col(0);
  
  if(n%2==0) {
    rep(i,0,n/2) {
      col.pb(2*i+1);
      col.pb(2*i+1);
    }
  }
  else {
    col.pb(0);
    rep(i,0,(n-1)/2) {
      col.pb(2*(i+1));
      col.pb(2*(i+1));
    }
  }
  
  Vi a(n);
  rep(i,0,n) cin >> a[i];
  sort(ALL(a));
  
  if(a!=col) cout << 0 << endl;
  else{
    int ans = 1;
    rep(i,0,n/2){
      ans *= 2;
      ans %= MOD;
    }
    cout << ans << endl;
  }
  
  return 0;
}


Measured memory_bytes: 1908
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <numeric>
#include <functional>
#include <set>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cctype>
#include <climits>
#include <fstream>
#include <bitset>
#include <time.h>
#include <assert.h>

#define LL long long
#define VI vector<int>
#define VL vector<long long>
#define FOR(i,a,b) for(int i= (a); i<((int)b); ++i)
#define RFOR(i,a) for(int i=(a); i >= 0; --i)
#define FOE(i,a) for(auto i : a)
#define ALL(c) (c).begin(), (c).end()
#define RALL(c) (c).rbegin(), (c).rend()
#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v,x) (std::find(v.begin(), v.end(), x) != v.end())
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
#define EPS 1e-14

using namespace std;

bool ok(int N, int h, int n , LL w) {
    LL u = n * w + h * w + h * n;
    LL d = h * n * w;
    return 4 * d == u * N; 
} 

int main(int argc, char *argv[]) {
    int N;
    cin >> N;
    FOR(h, 1, 3501) {
        FOR(n, 1, 3501) {
            LL u = 4LL * h * n - N * n - N * h;
            LL d = 1LL * N * h * n;
            if (u > 0 && d % u == 0) {
                LL w = d / u;
                if (ok(N, h, n, w)) {
                    std::cout << h << " " << n << " " << w << std::endl;
                    return 0;
                }
            }
        }
        
    }
    
    
    
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i = (a); i <= (b); i++)
#define rng(a) a.begin(), a.end()
#define ina(n,a) cin >> n; for(int i = 1; i <= n; i++) cin >> a[i]
#define sz(x) (int)(x).size()
#define se second
#define fi first
#define prev            coyhhhhhhyoc    
#define next          sdNNNmNNNNNNNmds  
#define y0           hNNNNy_yNNNNNN_sNh
#define y1          mNNNNNdtdNNNNNNtsNNm
#define yn          mNNNNNNNNy___smNNNms
#define tm            oooooosyysooooot 
#define read               tyhyt        
#define rank              ytmNmo         
#define index              yyy
#define pb push_back
#define pcnt __builtin_popcountll
#define rrep(i,a,b) for(int i = (b); i >= (a); i--)
#define rall(x,a) for(auto x : a)
#define MOD 1000000007
#define endl "\n"
typedef long long ll;
using namespace std;

int solve() {
    int n;
    cin >> n;
    int cur = 0, ans = 0;
    rep(i, 1, n) {
        int a, b;
        cin >> a >> b;
        if(a == b) {
            cur++;
        } else {
            cur = 0;
        }
        if(cur == 3) {
            ans = 1;
        }
    }
    cout << (ans == 1 ? "Yes" : "No") << endl;
    return 0;
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int t = 1;
    while(t--) {
        solve();
    }
    return 0;
}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,l;
  cin >> n >> l;
  vector<string>v(n);
  for(int i=0;i<n;i++)  cin >> v[i];
  sort(v.begin(),v.end());
  for(int i=0;i<n;i++)
    cout << v[i];
}

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

using namespace std;

int main() {
	int a[5];
	for (int i = 0; i < 5; i++) {
		cin >> a[i];
	}
	int k; cin >> k;
	if (a[4] - a[0] > k) {
		cout << ":(" << endl;
	}
	else {
		cout << "Yay!" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
using namespace std;
long long p,len,num[30];
long long ans=0;
char s[2000012];
int main(){  
	scanf("%s",s);
	len=strlen(s);
	ans=0;
	for (int i=0;i<len;i++)
	  num[s[i]-'a']++;
	for (int i=0;i<26;i++)
	  ans+=num[i]*(num[i]+1)/2;
	long long tot=(long long)(len+1)*len/2;
	printf("%lld\n",tot-ans+1);
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <cmath>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>
#include <bitset>
#include <sstream>

typedef  long long ll;
#define mop 1000000007
using namespace std;

int main() {
    
    ll n;
    cin >> n;
    vector <ll> v, ans;
    for (ll i=0;i<n;i++){
        ll b;
        cin >> b;
        v.push_back(b);
    }
    reverse(v.begin(), v.end());
    int flag = 0;
    while(!v.empty()){
        ll vs = v.size();
        ll idx = 0;
        while(v[idx] != vs - idx){
            idx++;
            if(idx == vs){
                flag = 1;
                break;
            }
        }

        if(flag == 1){
            break;
        }
        ans.push_back(v[idx]);
        v.erase(v.begin() + idx);
    }
    if(flag == 1){
        cout << -1 << endl;
    }else{
        reverse(ans.begin(), ans.end());
        for (ll i=0;i<ans.size();i++){
            cout << ans[i] << endl;
        }
    }

}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigDecimal;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.StringTokenizer;

class Main {
	public static void main(String[] args)
			throws IOException {
		BufferedReader br = new BufferedReader(
				new InputStreamReader(System.in));

		String s = br.readLine();
		StringTokenizer st;
		ArrayList<BigDecimal[]> list = new ArrayList<>();

		while (!(s == null || "".equals(s))) {
			st = new StringTokenizer(s);
			double a = Double.parseDouble(st
					.nextToken());
			double b = Double.parseDouble(st
					.nextToken());
			double c = Double.parseDouble(st
					.nextToken());
			double d = Double.parseDouble(st
					.nextToken());
			double e = Double.parseDouble(st
					.nextToken());
			double f = Double.parseDouble(st
					.nextToken());

			double x = (e * c - f * b) / (a * e
					- d * b);
			double y = (c * d - f * a) / (b * d
					- a * e);
			BigDecimal[] bd = new BigDecimal[2];
			bd[0] = new BigDecimal(x);
			bd[1] = new BigDecimal(y);
			list.add(bd);

			s = br.readLine();
		}

		for (BigDecimal bd[] : list) {
			DecimalFormat df = new DecimalFormat(
					"#.#");
			df.setMinimumFractionDigits(3);

			System.out.print(df.format(bd[0]));
			System.out.print(" ");
			System.out.println(df.format(bd[1]));

		}

	}

}

Measured memory_bytes: 26520
#include <iostream>
#include <algorithm>
#include <vector>
#include <string.h>
typedef long long ll;

#define MAX(x, y)	(((x) > (y))? (x) : (y))
#define MIN(x, y)	(((x) < (y))? (x) : (y))
#define ABS(x)		(((x) < 0)? (-1*(x)) : (x))
#define REPI(x,y)	for (int i=(x);i<(y);i++)
#define REPJ(x,y)	for (int j=(x);j<(y);j++)
#define MEMCLR(X)	memset((X),0,sizeof((X)))

using namespace std;
typedef vector<vector<pair<int, int>>> GRA;

int i,j,N,A;

int main() {
	cin >> N >> A;
	
	if ((N%500) <= A) cout << "Yes"; 
	else cout << "No";
	
	return 0;
}


Measured memory_bytes: 256
a,b,c,d=map(int,input().split())
for i in range(c-a):
  print('R',end='')
for j in range(d-b):
  print('U',end='')
for i in range(c-a):
  print('L',end='')
for j in range(d-b):
  print('D',end='')
print('D',end='')
for k in range(c-a+1):
  print('R',end='')
for l in range(d-b+1):
  print('U',end='')
print('L',end='')
print('U',end='')
for k in range(c-a+1):
  print('L',end='')
for l in range(d-b+1):
  print('D',end='')
print('R')

Measured memory_bytes: 4468
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
        char[] s = sc.next().toCharArray();
        char[] t = sc.next().toCharArray();

        int res=s.length;
        for(int i=0; i<s.length; i++){
            if(s[i] == t[i]){
                res--;
            }
        }
        System.out.println(res);
        }
    }

Measured memory_bytes: 42104
#include <bits/stdc++.h>
using namespace std;
using LL = long long; using PII = pair<LL, LL>; using VI = vector<LL>; using VVI = vector<VI>;
using VB = vector<bool>; using VS = vector<string>; using VP = vector<PII>;
#define VV(T)        vector<vector<T>>
#define PB           push_back
#define MP           make_pair
#define SZ(a)        LL((a).size())
#define EACH(x, c)   for (auto x : (c))
#define ALL(c)       (c).begin(), (c).end()
#define REVERSE(c)   reverse(ALL(c))
#define SORT(c)      stable_sort(ALL(c))
#define RSORT(c)     stable_sort((c).rbegin(), (c).rend())
#define FOR(i, a, b) for (LL i = (a); i < (b); ++i)
#define REP(i, n)    FOR(i, 0, n)
#define $(x)         {cout << #x << " = " << (x) << endl;}


void solve(long long N, long long D, std::vector<std::vector<long long>> X){
    LL ans = 0;
    REP(i, N) {
        REP(j, N) {
            if (i >= j) continue;
            LL dist = 0;
            REP(k, D) {
                dist += (X[j][k] - X[i][k]) * (X[j][k] - X[i][k]);
            }
            double s = sqrt(dist);
            /*$(dist);
            $(s);
            $(LL(s));*/
            if (s - LL(s) == 0) {
                ans++;
            }
        }
    }
    cout << ans << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long D;
    scanf("%lld",&D);
    std::vector<std::vector<long long>> X(N, std::vector<long long>(D));
    for(int i = 0 ; i < N ; i++){
        for(int j = 0 ; j < D ; j++){
            scanf("%lld",&X[i][j]);
        }
    }
    solve(N, D, std::move(X));
    return 0;
}


Measured memory_bytes: 256
const main = input => {
  const inputs = input.split('\n')
  if (inputs[0] === '1') {
    console.log('Hello World')
  } else {
    console.log(parseInt(inputs[1]) + parseInt(inputs[2]))
  }
}
// 標準入力
main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 29404
#include <bits/stdc++.h>
#include <unordered_map>
typedef long long ll;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " \n"[i == n-1];}
#define printp(x,n) for(ll i = 0; i < n; i++){ cout << "(" << x[i].first << ", " << x[i].second << ") "; } cout << endl;
#define INF (1e18)
using namespace std;
const ll MOD = 1e9 + 7;
typedef pair<ll, ll> lpair;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    if(N < 1200){
        print("ABC");
    }else{
        print("ARC");
    }

}


Measured memory_bytes: 256
s = input()
l = len(s)
ans = 0
for i in range(2**(l-1)):
    formula = s[0]
    for j in range(l-1):
        if (i >> j) & 1: formula += '+'
        formula += s[j+1]
    ans += sum(map(int, formula.split('+')))
print(ans)

Measured memory_bytes: 41452
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
using namespace std;
typedef long long ll;
typedef pair<int, int> P; 
const int inf = 1<<21;
const ll INF = 1LL << 60;
const ll mod = 1e9+7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> a;
    rep(i, n){
        int tmp;
        cin >> tmp;
        if(tmp%2==0){
            a.push_back(tmp);
        }
    }

    int m = a.size();
    rep(i, m){
        if (a[i]%3!=0 and a[i]%5!=0){
            cout << "DENIED" << endl;
            return 0;
        }
    }

    cout << "APPROVED" << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
#define INF ( 1 << 30 )
int main(){
  int n, dp[1000], tmp[] = {500,100,50,10,5,1};
  fill_n(dp,1000,INF);
  dp[0] = 0;
  for(int i = 0 ; i < 1000 ; i++ ){
    for(int j = 0 ; j < 6 ; j++ ){
      if(i-tmp[j] >= 0) dp[i] = min( dp[i-tmp[j]] + 1, dp[i]);
    }
  }
  while(cin >> n , n ) cout << dp[1000-n] << endl;
}

Measured memory_bytes: 1164
#include<bits/stdc++.h>
#define pb push_back
#define pf push_front

using namespace std;	
typedef long long int lli;
lli n,k,m,t,a,b,l,r,temp1,temp2,s,x,y,temp,q,d,mod=1e9+7,w,p,c;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
  	
  	cin>>d>>t>>s;
  	
  	if(s*t>=d)cout<<"Yes"<<endl;
  	else cout<<"No"<<endl;
}


Measured memory_bytes: 3612
//
// Created by swift on 2020/8/2.
//

#include<bits/stdc++.h>
using namespace std;
int main(){
    int a;
    cin>>a;
    if(a>=30){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
    return 0;
}

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

int main()
{
    int n, m;
    cin >> n >> m;
    int c[n];
    for (int i = 0; i < n; i++)
        c[i] = 0;

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


Measured memory_bytes: 3612
#pragma GCC optimize "Ofast"
#pragma GCC optimize "unroll-loops"
#pragma GCC target "sse,sse2,sse3,sse4,abm,avx,mmx,popcnt,tune=native"
#include <bits/stdc++.h>
using namespace std;

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define init(a, b) memset(a, b, sizeof(a))
#define all(a)      (a).begin(),(a).end()
#define rall(a)     (a).rbegin(),(a).rend()

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpii;
typedef unordered_map<int,int> uoii;
typedef unordered_map<string,int> uosi;

#define MOD = 1e9+7;

/******* Debugging Class Template *******/
#define DEBUG

#ifdef DEBUG

    #define de(args...)     (Debugger()) , args

    class Debugger
    {
        public:
        Debugger(const std::string& _separator = " - ") :
        first(true), separator(_separator){}

        template<typename ObjectType> Debugger& operator , (const ObjectType& v)
        {
            if(!first)
                std:cerr << separator;
            std::cerr << v;
            first = false;
            return *this;
        }
        ~Debugger() {  std:cerr << endl;}

        private:
        bool first;
        std::string separator;
    };

#else
    #define debug(args...)                  // Just strip off all debug tokens
#endif





int32_t main()
{
    int n,W;
    cin>>n>>W;
    vi w(n+1),v(n+1);
    for(int i=1;i<=n;i++) cin>>w[i]>>v[i];
    vector<vector<int>> dp(n+1,vi(W+1,0));
    for(int i=1;i<=n;i++){
		for(int j=1;j<=W;j++){
			if(j>=w[i]){
				dp[i][j]=max(dp[i-1][j],v[i]+dp[i-1][j-w[i]]);
			}else{
				dp[i][j]=dp[i-1][j];
			}
		}
	}
    cout<<dp[n][W];
    
	//getc();
    return 0;
}


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


int main() {
	string ans;
	int sx, sy, tx, ty;
	cin >> sx >> sy >> tx >> ty;
	for (int i = 1; i <= (ty - sy); i++) {
		ans += "U";
	}
	for (int i = 1; i <= (tx - sx); i++) {
		ans += "R";
	}
	for (int i = 1; i <= (ty - sy); i++) {
		ans += "D";
	}
	for (int i = 1; i <= (tx - sx); i++) {
		ans += "L";
	}
	ans += "L";
	for (int i = 1; i <= (ty - sy + 1); i++) {
		ans += "U";
	}
	for (int i = 1; i <= (tx - sx + 1); i++) {
		ans += "R";
	}
	ans += "D";
	ans += "R";
	for (int i = 1; i <= (ty - sy + 1); i++) {
		ans += "D";
	}
	for (int i = 1; i <= (tx - sx + 1); i++) {
		ans += "L";
	}
	ans += "U";
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9) + 7;

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

	int ans = 0;
	for(int i = 0; i < n; ++i) {
		int cnt = 0;
		while( a[i] % 2 == 0 ) {
			a[i] /= 2LL;
			cnt++;
		}
		
		ans += cnt;
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 384
h, n = map(int, input().split())
inf = 1001001001
dp = [inf for _ in range(h+1)]
dp[0] = 0
ans = inf
for i in range(n):
    a, b = map(int, input().split())
    for j in range(h + 1):
        # 外側参照しないように
        nj = min(j+a, h)
        dp[nj] = min(dp[nj], dp[j]+b)

print(dp[h])


Measured memory_bytes: 43868
#include <stdio.h>
#include <stdlib.h>

#define SN 1  //定数関数の宣言 SN:SmallNumber=1
#define BN 10000  //BN:BigNumber=10000

void Constraints(int a,int b,int c) //制約関数の宣言
{
  if(SN<=a&&a<=BN&&SN<=b&&b<=BN&&SN<=c&&c<=BN){}
  else
  {
    printf("条件を満たす入力をしてください。\n");
    exit(0); //条件を満たさない場合プログラム終了
  }
}

void Sort(int *pa,int *pb)  //Sort関数の宣言
{
    if(*pa>*pb)
    {//もし*paが*pbより大きいなら入れ替える
      int tmp=*pa;
      *pa=*pb;
      *pb=tmp;
    }
}

void Bubble(int array[],int n){ //BubbleSort関数 n:配列の要素数
  for(int i=0;i<n-1;i++)
  {
    for(int j=0;j<n-1;j++)
    {
      Sort(&array[j],&array[j+1]);
    }
  }
}

int main(void)
{
  int a,b,c;
  scanf("%d %d %d",&a,&b,&c);
  Constraints(a,b,c);
  Sort(&a,&b);
  Sort(&a,&c);
  Sort(&b,&c);
  printf("%d %d %d\n",a,b,c);
	return 0;
}



Measured memory_bytes: 2100
import java.io.*;
import java.util.*;
import static java.lang.System.out;

public class Main {
    static MyReader in = new MyReader();

    public static void main(String[] args) {
        int N = in.i();
        int K = in.i();
        int[] A = in.ii(N);

        StringBuilder sb = new StringBuilder();
        for (int i = K; i < N; i++) {
            sb.append(A[i - K] < A[i] ? "Yes" : "No").append('\n');
        }
        out.println(sb);
    }
}

class MyReader extends BufferedReader {
    char[] cbuf = new char[1024];
    int head = 0;
    int tail = 0;

    MyReader() {
        super(new InputStreamReader(System.in));
    }

    char next() {
        if (head == tail) {
            try {
                tail = super.read(cbuf, 0, cbuf.length);
            } catch (IOException e) {
                e.printStackTrace();
            }
            head = 0;
        }
        return cbuf[head++];
    }

    void back() {
        head--;
    }

    boolean minus() {
        boolean minus;
        while (true) {
            char c = next();
            if (!isDelimiter(c)) {
                if (!(minus = c == '-')) back();
                return minus;
            }
        }
    }

    void skip() {
        while (isDelimiter(next()));
        back();
    }

    char[] s(int N) {
        char[] cbuf = new char[N];
        read(cbuf, 0, N);
        return cbuf;
    }

    public int read(char[] cbuf, int off, int len) {
        skip();
        int i;
        for (i = 0; i < cbuf.length; i++) {
            char c = next();
            if (isDelimiter(c)) {
                break;
            }
            cbuf[i] = c;
        }
        return i;
    }

    boolean isDelimiter(char c) {
        return c == ' ' || c == '\n' || c == '\r';
    }

    int i() {
        boolean minus = minus();
        int n = 0;
        while (true) {
            int k = next() - '0';
            if (k < 0 || 9 < k) break;
            n = 10 * n + k;
        }
        return minus ? -n : n;
    }

    int[] ii(final int N) {
        int[] a = new int[N];
        for (int j = 0; j < a.length; j++) a[j] = i();
        return a;
    }

    long l() {
        boolean minus = minus();
        long n = 0;
        while (true) {
            int k = next() - '0';
            if (k < 0 || 9 < k) break;
            n = 10 * n + k;
        }
        return minus ? -n : n;
    }
}


Measured memory_bytes: 39340
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

typedef long long ll;
typedef uint64_t ull;
typedef pair<int, int> P;
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
// constexpr int mod = 1000000007;
constexpr int mod = 998244353;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)

ll __ceil(ll a, ll b){
    return (a + b - 1) / b;
}

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

    int k, q;
    cin >> k >> q;
    vector<int> d(k);
    for(int i = 0; i < k; ++i)  cin >> d[i];
    for(int loop = 0; loop < q; ++loop){
        int n, x, m;
        cin >> n >> x >> m;
        ll last = x, eq = 0;
        for(int i = 0; i < k; ++i){
            ll num = __ceil(n - i - 1, k);
            last += (d[i] % m) * num;
            if(d[i] % m == 0)   eq += num;
        }
        ll ans = (n - 1) - (last / m - x / m) - eq;
        cout << ans << '\n';
    }
}

Measured memory_bytes: 384
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <string>
#include <map>
#include <cmath>
#include <cstring>

#define fi first
#define se second
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for (int i = 1; i < (n); ++i)
#define drep(i,n) for (int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define all(x) (x).begin(), (x).end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define pb push_back
#define sz(x) (int)(x).size()
#define PQ(T) priority_queue<T, v(T), greater<T> >

using namespace std;
typedef long long ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;

const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;

const int mod = 1000000007;

const int MAXN = 100100;
int dp[MAXN];

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

    rep(i, MAXN) dp[i] = INF; 
    dp[0] = 0;

    rep(n, MAXN) {
        for (int i = 1; n+i <= N; i *= 6) {
            dp[n+i] = min(dp[n+i], dp[n] + 1);
        }
        for (int i = 1; n+i <= N; i *= 9) {
            dp[n+i] = min(dp[n+i], dp[n] + 1);
        }
    }
    cout << dp[N] << endl;

    return 0;
}


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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++) 
#define ll long long
#define ld long double
#define repl(i, n) for (ll i = 0; i < (ll)(n); i++)  
#define outdeb(fir, sec, thr) cout << fir << ":" << sec << ":" << thr << endl

int main()
{
  ll k;
  cin >> k ;
  k--;
  char alp[27] = "abcdefghijklmnopqrstuvwxyz";
  string ans = "";
  while(k >= 26)
  {
    ll div = k / 26;
    ll ama = k % 26;
    ans = alp[ama] + ans;
    k = div - 1;
  }

  ll ama = k % 26;
  ans = alp[ama] + ans;

  cout << fixed << ans << endl;

  return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <bits/stdc++.h>
#include <time.h>
#include <sys/timeb.h>
#include <cstdio>
#include <sys/time.h>

using namespace std;
#define ll long long
#define uint unsigned int
#define ulong unsigned long long int

template<typename T> bool InRange(T t, T l, T r){ return l <= t && t < r; }

int main(){
	
	int N;
	vector<int> A;
	cin >> N;
	A.resize(N);
	for(int i=0;i<N;i++) cin >> A[i];
	
	int mi = (int) 1e9;
	for(int i=-100;i<=100;i++){
		int di = 0;
		for(auto v : A){
			di += (v - i) * (v - i);
		}
		mi = min(mi, di);
	}
	
	cout << mi << endl;
	
	
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int i[1024], j;
	int n;
	int p[1024], q[1024], r[1024], c[1024];
	int pc, qc, rc, cc;
	int f;
	
	while (scanf("%d", &n), n != 0){
		for (j = 0; j < n; j++){
			scanf("%d %d %d %d", &i[j], &p[j], &q[j], &r[j]);
			c[j] = 4 * p[j] + 9 * q[j] + 4 * r[j];
		}
		scanf("%d %d %d %d", &pc, &qc, &rc, &cc);
		f = 0;
		for (j = 0; j < n; j++){
			if (pc >= p[j] && qc >= q[j] && rc >= r[j] && cc >= c[j]){
				printf("%d\n", i[j]);
				f = 1;
			}
		}
		if (f == 0){
			printf("NA\n");
		}
	}
	
	return (0);
}

Measured memory_bytes: 1060
fun main(args: Array<String>) {
    val n = readInt()
    var ans = 0
    for (i in n downTo 1) {
        val k = i.toString().length
        if (k % 2 != 0) {
            ans++
        }
    }
    println(ans)
}

// Tools
fun readString() = readLine()!!
fun readInt() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readStringList() = readLine()!!.split(" ")
fun readIntList() = readLine()!!.split(" ").map(String::toInt)
fun readLongList() = readLine()!!.split(" ").map(String::toLong)

Measured memory_bytes: 40080
using System;
class A{static void Main(){
	
int n=int.Parse(Console.ReadLine());
int []a=new int[6];
for(int i=0;i<n;i++){
double s=double.Parse(Console.ReadLine());
if(s<165){a[0]++;}
else if(s<170){a[1]++;}
else if(s<175){a[2]++;}
else if(s<180){a[3]++;}
else if(s<185){a[4]++;}
else{a[5]++;}
}for(int i=0;i<6;i++){
	Console.Write((i+1)+":");
	for(int k=0;k<a[i];k++){
		Console.Write("*");
	}Console.WriteLine();
	

	
	
}	
	
	
	
	
	
	
	
	
	
	
	

	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
		
		
	}
	
}

Measured memory_bytes: 9220