akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <climits>
#include <cmath>
#include <vector>
#define REP(i, n) for (int i = 0; i < (n); i++)
using namespace std;

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

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

    int n;
    cin >> n;

    vector<int> h(n);
    REP(i, n) cin >> h[i];

    vector<int> dp(n + 2, INT_MAX);

    dp[0] = 0;
    REP(i, n) {
        chmin(dp[i + 1], dp[i] + abs(h[i] - h[i + 1]));
        chmin(dp[i + 2], dp[i] + abs(h[i] - h[i + 2]));
    }

    cout << dp[n - 1] << '\n';
    return 0;
}

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

double n;
pair<double, double> s[4];
int ans;

signed main()
{
    int j = 0;
    for(double i = 0.25; i < 4; i *= 2){
        cin >> s[j].first;
        s[j].second = i;
        s[j].first /= i;
        j++;
    }
    cin >> n;
    sort(s, s + 4);
    for(int i = 0; i < 4; i++){
        if((int)(n / s[i].second) > 0){
            double k = s[i].first * s[i].second;
            ans += (int)k * (int)(n / s[i].second);
            n -= s[i].second * (int)(n / s[i].second);
        }
    }
    cout << ans << endl;


    return 0;
}


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

public class Main {

	static char[] in = new char[123];
	static char[] out = new char[123];

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

		initialize();
		int n = 0;
		while ((line = br.readLine()) != null) {
			if (n == 0) {
				if ((n = Integer.parseInt(line)) == 0)
					break;
			} else {
				if (line.contains(" ")) {
					in[line.charAt(0)] = line.charAt(0);
					out[line.charAt(0)] = line.charAt(2);
				} else {
					System.out.print(String.valueOf(out[line.charAt(0)]));
				}
				n--;
				if (n == 0 && line.length() == 1) {
					System.out.println();
					initialize();
				}
			}
		}
	}

	public static void initialize() {
		for (int i = 0; i < 123; i++) {
			in[i] = (char) i;
			out[i] = (char) i;
		}
	}
}

Measured memory_bytes: 42152
import os
import sys

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7


def ModInt(mod):
    class _ModInt:
        def __init__(self, value):
            self.value = value % mod

        def __add__(self, other):
            if isinstance(other, _ModInt):
                return _ModInt(self.value + other.value)
            else:
                return _ModInt(self.value + other)

        def __sub__(self, other):
            if isinstance(other, _ModInt):
                return _ModInt(self.value - other.value)
            else:
                return _ModInt(self.value - other)

        def __radd__(self, other):
            return self.__add__(other)

        def __mul__(self, other):
            if isinstance(other, _ModInt):
                return _ModInt(self.value * other.value)
            else:
                return _ModInt(self.value * other)

        def __truediv__(self, other):
            # TODO: 実装
            raise NotImplementedError()

        def __repr__(self):
            return str(self.value)

    return _ModInt


MI = ModInt(MOD)
# 解説AC
N, C = list(map(int, sys.stdin.readline().split()))
A = list(map(int, sys.stdin.readline().split()))
B = list(map(int, sys.stdin.readline().split()))


def solve():
    # P[n][c]: n^c
    P = [[1] * (C + 1) for _ in range(max(B) + 1)]
    P[0] = [MI(0)] * (C + 1)
    for i in range(1, len(P)):
        for c in range(1, C + 1):
            P[i][c] = P[i][c - 1] * i

    # cs[n][c]: 0^c + 1^c + ... + n^c
    cs = [[0] * (C + 1) for _ in range(max(B) + 1)]
    for c in range(C + 1):
        s = 0
        for i in range(len(P)):
            s += P[i][c]
            cs[i][c] = s

    # S[i][c]: X[i]^c (A[i]<=X[i]<=B[i]) の合計
    S = [[0] * (C + 1) for _ in range(N)]
    for i in range(N):
        for c in range(C + 1):
            S[i][c] = cs[B[i]][c] - cs[A[i] - 1][c]

    # dp[c]: 各項の次数が c で、i 番目の子供まで見たときの f(X) の値
    dp = S[0][:]
    for i in range(1, N):
        for c in reversed(range(C + 1)):
            s = 0
            for j in range(c + 1):
                s += dp[c - j] * S[i][j]
            dp[c] = s
    return dp[-1]


# print(f_partial([1, 1]))
# print(f_partial([1, 2]))
# print(f_partial([2, 1]))
# print(f_partial([2, 2]))
print(solve())


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

typedef long long LL;

const int maxn=2e5+5;

struct E{
	int x,y;
} e[maxn];

int n,d0,e0,d[maxn];

int main()
{
	scanf("%d",&n);
	
	if (n&1)
	{
		d[++d0]=n;
		fo(i,1,(n-1)/2)
		{
			int x=i, y=n-i;
			fo(j,1,d0) e[++e0]=(E){x,d[j]}, e[++e0]=(E){y,d[j]};
			d[++d0]=x, d[++d0]=y;
		}
	} else
	{
		d[++d0]=1, d[++d0]=n;
		fo(i,2,n/2)
		{
			int x=i, y=n+1-i;
			fo(j,1,d0) e[++e0]=(E){x,d[j]}, e[++e0]=(E){y,d[j]};
			d[++d0]=x, d[++d0]=y;
		}
	}
	
	printf("%d\n",e0);
	fo(i,1,e0) printf("%d %d\n",e[i].x,e[i].y);
}

Measured memory_bytes: 256
use std::cmp::*;
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("Failed to read bytes") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let a:usize = read();
    let b:usize = read();
    let c:usize = read();
    let x:usize = read();
    let y:usize = read();
    let mut ans = 0;
    ans += min(a+b, c*2) * min(x, y);
    if x > y {
        ans += min(a, c*2) * (x-y);
    } else {
        ans += min(b, c*2) * (y-x);
    }
    println!("{}", ans);
}

Measured memory_bytes: 4352
#include <string.h>

#include <algorithm>
#include <iostream>

using namespace std;
using ll = long long;

int main(void) {
  string S, T;
  cin >> S;
  cin >> T;

  int S_len = S.length();
  int T_len = T.length();

  int min = T_len;
  int cnt = 0;

  for (int i = 0; i < S_len - T_len + 1; i++) {
    for (int j = 0; j < T_len; j++) {
      if (S[i + j] != T[j]) {
        cnt++;
      }
    }

    if (cnt < min) {
      min = cnt;
    }
    cnt = 0;
  }

  cout << min << endl;
  return 0;
}

Measured memory_bytes: 3632
fn main() {
    let scan = std::io::stdin();
    let mut line = String::new();
    let _ = scan.read_line(&mut line);
    let vec: Vec<&str> = line.split_whitespace().collect();
    let mut n: i32 = vec[0].parse().unwrap();

    let mut ans: i32 = 0;
    loop{
        if n - 3 < 0{
            break;
        }else{
            n = n - 3;
            ans = ans + 1;
        }
    }
    println!("{}",ans);
}


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

using namespace std;
using ll = long long;

const int N = 3e5;
ll a[N];

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

	int n;
	cin >> n;

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

	ll last = n-1, t = 0, ans = 0;
	for(int i=n-1; i>=0; i--){
		ll b = t - (last-i);

		if(a[i]<b || a[i]>i){
			cout << -1 << endl;
			return 0;
		}

		if(a[i]>b){
			last = i;
			t = a[i];

			ans += t;
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#include<string>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long int
#define pb push_back
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define mem(x,y) memset(x,y,sizeof(x))//memset only use to initialize 0 or -1 no other number.
#define pii pair<int,int>
#define pll pair<ll,ll>
#define INF 1e9
#define INFL 1e18
//#define mod 1000000007
#define mod 998244353
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
using namespace __gnu_pbds; 
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> os;
typedef tree<pii,null_type,less<pii>,rb_tree_tag,tree_order_statistics_node_update> os_pair;

ll power(ll x,ll n){ll res =1;while(n>0){if(n%2==1){res=res*x;}x=x*x;n=n/2;}return res;}
ll powm(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}

//cout<< fixed << setprecision(10)


int main(){

    fast
    int T;
    T=1;
    //cin>>T;
    while(T--){
    	int x,i;
        int ans;
        for(i=0;i<5;i++)
        {
        	cin>>x;
        	if(x==0)
        	{
        		ans=i+1;
			}
		}
		cout<<ans;
    	
    	

}
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
 
using namespace std;
 
typedef pair<int,int> P;
typedef long long ll; 
 
#define int ll
 
 
main(){
	ll a;
	float b;
	cin >> a >> b;
	b *= 100.0001;
	ll b2  = (ll)b;
	ll ans = (ll) a*b2/100;
	printf("%lld\n",ans);
 
	return 0;
}


Measured memory_bytes: 3780
public class Main {
	public static void main(String[] args) {
		java.util.Scanner s = new java.util.Scanner(System.in);
		int n = s.nextInt();
		int[] h = new int[n];
		int res = 0;
		int count = 0;
		for(int i=0;i<n;i++) {
			h[i] = s.nextInt();
			if(1<= i) {
				if(h[i]<=h[i-1]) {
					count++;
				}else {
					res = Math.max(count, res);
					count=0;
				}
			}
		}
		res = Math.max(count, res);
		System.out.println(res);

	}
}


Measured memory_bytes: 49712
#include <bits/stdc++.h>
using namespace std;
typedef long double LD;
typedef long long ll;
#define int ll
#define pb push_back
#define mp make_pair
typedef map<int, int> mii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
#define forn(i, n) for (int i = 0; i < n; i++)
void solve()
{
    string s;
    cin >> s;
    if (s[s.length() - 1] == 's')
        cout << s << "es" << endl;
    else
    {

        cout << s << "s" << endl;
    }
}
int32_t main()
{
    // int t;
    // cin >> t;
    // while(t--)
    solve();

    return 0;
}

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

#define rp(i, k, n) for (int i = k; i < n; i++)
#define ll  long long
int main() {
    int N, M, X, Y;
    cin >> N >> M >> X >> Y;
    vector<int> x(N);
    int now;
    int xmax = X, ymin = Y;
    rp (i, 0, N) {
        cin >> now;
        xmax = max(xmax, now);
    }
    vector<int> y(M);
    rp(i, 0, M) {
        cin >> now;
        ymin = min(ymin, now);
    }
    if (xmax < ymin) {
        cout << "No War" << endl;
        return 0;
    } else {
        cout << "War" << endl;
        return 0;
    } 
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define debug(x) cerr<<#x<<" = "<<x
#define sp <<"  "
#define el <<endl
#define fgx cerr<<"-----------------------------------"<<endl
#define LL long long
#define M 5020
#define INF 10000000000000000ll
using namespace std;
namespace IO{
	const int BS=(1<<23)+5; int Top=0;
	char Buffer[BS],OT[BS],*OS=OT,*HD,*TL,SS[20]; const char *fin=OT+BS-1;
	char Getchar(){if(HD==TL){TL=(HD=Buffer)+fread(Buffer,1,BS,stdin);} return (HD==TL)?EOF:*HD++;}
	void flush(){fwrite(OT,1,OS-OT,stdout),OS=OT;}
	void Putchar(char c){*OS++ =c;if(OS==fin)flush();}
	void write(int x){
		if(!x){Putchar('0');return;} if(x<0) x=-x,Putchar('-');
		while(x) SS[++Top]=x%10,x/=10;
		while(Top) Putchar(SS[Top]+'0'),--Top;
	}
	int read(){
		int nm=0,fh=1; char cw=getchar();
		for(;!isdigit(cw);cw=getchar()) if(cw=='-') fh=-fh;
		for(;isdigit(cw);cw=getchar()) nm=nm*10+(cw-'0');
		return nm*fh;
	}
}using namespace IO;
int n,m,fs[M],nt[M<<2],to[M<<2],tmp,sz[M]; LL F[M][M][2],G[M][2],p[M];
inline void link(int x,int y){nt[tmp]=fs[x],fs[x]=tmp,to[tmp++]=y;}
inline void upd(LL &x,LL y){x=min(x,y);}
void dp(int x,int last){
	F[x][sz[x]=1][p[x]<0]=p[x];
	for(int i=fs[x],v;i!=-1;i=nt[i]) if((v=to[i])^last){
		dp(v,x);
		for(int j=1;j<=sz[x]+sz[v];j++) G[j][0]=G[j][1]=INF;
		for(int k=1;k<=sz[x];k++) for(int j=1;j<=sz[v];j++){
			for(int tx=0;tx<2;tx++) for(int ty=0;ty<2;ty++){
				if(F[x][k][tx]==INF||F[v][j][ty]==INF) continue;
				upd(G[k+j-1][tx|ty],F[x][k][tx]+F[v][j][ty]);
				if(F[v][j][ty]<0||!ty) upd(G[k+j][tx],F[x][k][tx]);
			}
		} sz[x]+=sz[v];
		for(int k=1;k<=sz[x];k++) F[x][k][0]=G[k][0],F[x][k][1]=G[k][1];
	}
//	debug(x)sp,debug(p[x])el;
//	for(int i=1;i<=sz[x];i++) debug(i)sp,debug(F[x][i][0])sp,debug(F[x][i][1])el;fgx;
}
void over(int ans){printf("%d\n",ans);exit(0);}
int main(){
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	n=read(),memset(fs,-1,sizeof(fs));
	for(int i=1;i<=n;i++) p[i]=read();
	for(int i=1,x,y;i<n;i++) x=read(),y=read(),link(x,y),link(y,x);
	for(int i=1;i<=n;i++) for(int j=1;j<=n;j++) F[i][j][0]=F[i][j][1]=INF;
	dp(1,0);
	for(int i=1;i<=n;i++){
		if(F[1][i][0]<INF||F[1][i][1]<0) over(i-1);
	} over(n-1);
	return 0;
}

Measured memory_bytes: 396032
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define set0(k,n) for(int nn=0;nn<(n);nn++){ (k).push_back(0); }
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define vecsize(b,size) vector<int> (b)((size));
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsl(s) vector<pair<ll,ll>> (s);
#define pairss(s) vector<pair<string,string>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairspl(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsps(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsREV(s) (s).push_back(make_pair(bb,aa));
#define pairslREV(s) (s).push_back(make_pair(bb,aa));
#define pairssREV(s) (s).push_back(make_pair(bb,aa));
#define MOD 1000000007

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

	if (A >= 13) {
		ce(B)

	}
	else if (A > 5) {
		ce(B/2)
	}
	else {
		ce(0)
	}

    return 0;
}



Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
#define ll long long
using namespace std;
template <class T>
inline void rd(T &x) {
	x=0; char c=getchar(); int f=1;
	while(!isdigit(c)) { if(c=='-') f=-1; c=getchar(); }
	while(isdigit(c)) x=x*10-'0'+c,c=getchar(); x*=f;
}
template <class T> inline void cmin(T &x,T y) { x=min(x,y); }
const int N=510;
ll a[N][N],b[N][N];
ll f[N][N];
int n;
void getsum(ll a[][N]) {
	for(int i=1;i<=n;++i)
		for(int j=1;j<=n;++j)
			a[i][j]+=a[i-1][j]+a[i][j-1]-a[i-1][j-1];
}
ll query(ll a[][N],int x1,int x2,int y1,int y2) {
	if(x2<x1||y2<y1) return 0;
	x1--,y1--;
	return a[x2][y2]-a[x1][y2]-a[x2][y1]+a[x1][y1];
}
int main() {
	rd(n);
	for(int i=1;i<=n;++i)
		for(int j=1;j<=n;++j) {
			if(i==j) continue;
			int x; rd(x);
			if(i<j) a[i][j]=x;
			if(i>j) b[i][j]=x;
		}
	getsum(a),getsum(b);
	memset(f,0x3f,sizeof(f));
	for(int i=1;i<=n;++i)
		f[0][i]=query(a,1,i-1,2,i);
	for(int i=0;i<=n-1;++i)
		for(int j=i+1;j<=n-1;++j)
			for(int k=j+1;k<=n-1;++k)
				f[j][k]=min(f[j][k],f[i][j]+query(a,j+1,k-1,j+2,k)+query(b,j+1,k,1,i));
	ll ans=query(a,1,n-1,2,n);
	for(int i=0;i<=n-1;++i)
		for(int j=i+1;j<=n-1;++j) 
			ans=min(ans,f[i][j]+query(a,j+1,n-1,j+2,n)+query(b,j+1,n,1,i));
	printf("%lld",ans);
	return 0;
}


Measured memory_bytes: 6272
#include <bits/stdc++.h>
#define Maxn 100007
using namespace std;
int n,x;
int b[Maxn],l[Maxn],r[Maxn];
bool flag[Maxn];
priority_queue<pair<long long,int> >pq;
long long solve(int id,long long tmp)
{
    if (tmp<=0LL) return 0LL;
    if (tmp<=1LL*l[id]*b[id])
    {
        return (tmp+l[id]-1)/l[id];
    } else
    {
        tmp-=1LL*l[id]*b[id];
        return (tmp+r[id]-1)/r[id]+b[id];
    }
}
int main()
{
    scanf("%d%d",&n,&x);
    while (!pq.empty()) pq.pop();
    long long tmp=0LL;
    for (int i=1;i<=n;i++)
    {
        scanf("%d%d%d",&b[i],&l[i],&r[i]);
        tmp+=1LL*l[i]*b[i];
        pq.push(make_pair(1LL*r[i]*(x-b[i])+1LL*l[i]*b[i],i));
    }
    long long ans=1LL*x*n;
    int cnt=0;
    while ((!pq.empty())&&tmp>=0)
    {
        tmp-=pq.top().first;
        int id=pq.top().second;
        flag[id]=true;
        pq.pop();
        ++cnt;
    }
    ans=min(ans,1LL*cnt*x);
    --cnt;
    long long t=x;
    for (int i=1;i<=n;i++)
        if (flag[i])
        {
            tmp+=1LL*r[i]*(x-b[i])+1LL*l[i]*b[i];
            t=min(t,solve(i,tmp));
            tmp-=1LL*r[i]*(x-b[i])+1LL*l[i]*b[i];
        }
    ans=min(ans,1LL*cnt*x+t);
    while (!pq.empty()) pq.pop();
    tmp=0LL;
    for (int i=1;i<=n;i++)
    {
        tmp+=1LL*l[i]*b[i];
        pq.push(make_pair(1LL*r[i]*(x-b[i])+1LL*l[i]*b[i],i));
    }
    memset(flag,false,sizeof(flag));
    cnt=0;
    while ((!pq.empty())&&tmp>pq.top().first)
    {
        tmp-=pq.top().first;
        int id=pq.top().second;
        flag[id]=true;
        pq.pop();
        ++cnt;
    }
    ans=min(ans,1LL*cnt*x+x);
    t=x;
    for (int i=1;i<=n;i++)
        if (!flag[i]) t=min(t,solve(i,tmp));
    ans=min(ans,1LL*cnt*x+t);
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 6256
#include <iostream>
using namespace std;
typedef long long ll;
ll K,N,inf = 998244353;
ll func[4010] = {0};
ll inv[4010] = {0};

ll mult(ll n, ll m){
	if(n==0 || m==0) return 1;
	if(m==1) return n%inf;
	else if(m%2==0){
		ll t = mult(n,m/2);
		return (t*t)%inf;
	}else{
		ll t = mult(n,m-1);
		return (t*n)%inf;
	}
}

void factorial(ll N){
	for(ll i=0;i<=N;i++){
		if(i==0){
			func[i] = 1;
			inv[i] = 1;
		}
		else{
			func[i] = (i*func[i-1])%inf;
			inv[i] = mult(func[i],inf-2);
		}
	}
}

ll comb(ll n,ll k){
	if(n<k || n<0 || k<0) return 0;
	else return (((func[n]*inv[k])%inf)*inv[n-k])%inf;
}

ll hcomb(ll n,ll k){
	if(n==0 && k==0) return 1;
	return comb(n+k-1,k);
}

int main(){
	cin >> K >> N;
	factorial(4000);
	for(ll i=2;i<=2*K;i++){
		ll ans = 0;
		ll n = min(i,(2*K+2-i))/2;
		for(ll j=1;j<=n;j++){
			ans = (ans+(j%2==0? -1:1)*hcomb(K,N-2*j)*comb(n,j))%inf;
		}
		ans = (hcomb(K,N)-ans)%inf;
		cout << (ans+inf)%inf << endl;
	}
}

Measured memory_bytes: 384
n = input()
t, a = map(int, raw_input().split())
l=600.0
H=map(int, raw_input().split())
ans=n+1
for i in range(n):
    if abs(a-(t-H[i]*0.006)) <l:
        l=abs(a-(t-H[i]*0.006))
        ans=i+1

print ans

Measured memory_bytes: 2692
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
#define ll long long 
#define lli long long int
#define ff              first
#define ss              second
//#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
//mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;


#define int long long 

int ar[100005];
int n,k;
int dp[100005];
//int ar[200001];

int func(int idx)
{
	if(idx==n) return 0;


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


	int mini=10000000000;

	for(int i=idx+1;i<=min(n,idx+k);i++)
	{
		mini=min(mini,abs(ar[i]-ar[idx]) + func(i));
	}

	return dp[idx]= mini ;
}
signed main()
{
	
	memset(dp,-1,sizeof dp);
    //int n;
    cin>>n>>k;
    //int ar[n];
    for(int i=1;i<=n;i++)
    {
    	cin>>ar[i];
    }

    cout<<func(1);

}


Measured memory_bytes: 6528
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include <string.h>

int main(void) {
	int n;
	int taro_point = 0;
	int hanako_point = 0;
	char taro_animal [101] = "";
	char hanako_animal[101] = "";

	scanf("%d", &n);

	for (int i = 0; i < n; i++) {
		scanf("%s %s", taro_animal, hanako_animal);

		if (0 < strcmp(taro_animal, hanako_animal)) {
			taro_point += 3;
		}
		else if (0 > strcmp(taro_animal, hanako_animal)) {
			hanako_point += 3;
		}
		else if (0 == strcmp(taro_animal, hanako_animal)) {
			taro_point++;
			hanako_point++;
		}
	}
	printf("%d %d\n", taro_point, hanako_point);


	return 0;
}


Measured memory_bytes: 2044
#![allow(non_snake_case)]
#![allow(unused_imports)]

use proconio::{input, fastout};
use proconio::marker::*;
use whiteread::parse_line;
use std::collections::*;
use num::*;
use num_traits::*;
use superslice::*;
use std::ops::*;

use itertools::Itertools;
use itertools_num::ItertoolsNum;

#[derive(Debug, Clone)]
struct Combination {
    fact_inv: Vec<usize>,
    inv: Vec<usize>,
    com: Option<Vec<usize>>,
    MOD: usize,
}
impl Combination {
    fn new(n: usize, MOD: usize) -> Combination {
        let mut fact_inv = vec![0; n + 1];
        let mut inv = vec![0; n + 1];
        fact_inv[0] = 1;
        fact_inv[1] = 1;
        inv[1] = 1;
        for i in 2..=n {
            inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
            fact_inv[i] = fact_inv[i - 1] * inv[i] % MOD;
        }
        Combination {
            fact_inv: fact_inv,
            inv: inv,
            com: None,
            MOD: MOD,
        }
    }
    fn fix_n(&mut self, n: usize) {
        let mut com = vec![0; n + 1];
        com[0] = 1;
        for i in 1..=n {
            com[i] = com[i - 1] * ((n - i + 1) * self.inv[i] % self.MOD) % self.MOD;
        }
        self.com = Some(com)
    }
    fn _calc_nck(&self, n: usize, k: usize) -> usize {
        if n < k {
            return 0;
        }
        let mut ans: usize = 1;
        let mut i = n;
        while n - k < i {
            ans *= i;
            ans %= self.MOD;
            i -= 1;
        }
        ans * self.fact_inv[k] % self.MOD
    }
    fn nck(&self, n: usize, k: usize) -> usize {
        match self.com.clone() {
            None => self._calc_nck(n, k),
            Some(x) => x[k],
        }
    }
    fn nhk(&self, n: usize, k: usize) -> usize {
        if self.fact_inv.len() < n + k - 1 {
            panic!("length must be n+k-1 or larger!")
        }
        self.nck(n + k - 1, k)
    }
}

#[fastout]
fn main() {
    input!{
        x: isize, y: isize,
    }
    if (x + y) % 3 == 0 { 
        let move_cnt = (x + y) / 3;
        let new_x = x - move_cnt;
        let new_y = y - move_cnt;
        if new_x < 0 || new_y < 0 {
            println!("0")
        } else {
            let comb = Combination::new((new_x+new_y) as usize, 1e9 as usize + 7);
            println!("{}", comb.nck((new_x+new_y) as usize, new_x as usize))
        }

    } else {
        println!("0")
    }
}


Measured memory_bytes: 12312
#pragma warning(disable:4996)

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <float.h>

#pragma region 定義
#define i_cin(X) scanf("%d", &X)
#define i_cin2(X,Y) scanf("%d %d",&X,&Y)
#define i_cin4(X,Y,Z,W) scanf("%d %d %d %d",&X,&Y,&Z,&W)
#define i_cin3(X,Y,Z) scanf("%d %d %d",&X,&Y,&Z)
#define l_cin(X) scanf("%ld",&X)
#define f_cin(X) scanf("%f",&X)
#define l_cin2(X,Y) scanf("%ld %ld",&X,&Y)
#define s_cin(X) scanf("%s",&X)

#define  i_cout(X) printf("%d\n",X)
#define  f_cout(X) printf("%g\n",X)
#define  i_cout2(X,Y) printf("%d %d\n",X,Y)
#define  l_cout(X) printf("%ld\n",X)
#define  s_cout(X) printf("%s\n",X)
#define  ll_cout(X) printf("%lld\n",X)

typedef long long  ll;
#define rept(x, s, n) for (int x = s; x < n; x++)

#define S_RTN(S)  s_cout(S);return 0


#define _itoa(A,N) sprintf(A, "%d", N);

int i_cins(int n, int* A);
int l_cins2(int n, long* A, long* B);
int s_dsort(const void* a, const void* b);
int s_asort(const void* a, const void* b);

int  _gcd(int a, int b);
int  _swp(int* a, int* b);
int _cknum(char* a, int n);
int _atoi(char* s, int len);


int s_asorts(const void* a, const void* b);

//昇順
int s_asorts(const void* a, const void* b) {
	return(strcmp((char*)a, (char*)b));
}
int s_dsort(const void* a, const void* b) {
	return(*(int*)b - *(int*)a);
}
int s_asort(const void* a, const void* b) {
	return(*(int*)a - *(int*)b);
}
int l_cins2(int n, long* a, long* b) {
	int i;
	rept(i, 0, n) {
		l_cin2(*(a + i), *(b + i));
	}
	return 0;
}
int i_cins(int n, int* a) {
	int i;
	for (i = 0; i < n; i++) {
		i_cin(*(a + i));
	}

	return 0;
}
int _gcd(int a, int b) {
	int r, tmp;
	if (a < b) { tmp = a; a = b; b = tmp; }
	r = a % b;
	while (r) {
		if (!r) break;
		a = b; b = r;
		r = a % b;
	}
	return(b);
}

long _max(long a, long b) {
	return a > b ? a : b;
}
long _min(long a, long b) {
	return a < b ? a : b;
}
int _swp(int* a, int* b)
{
	int tmp;
	tmp = *b; *b = *a; *a = tmp;
	return 0;
}

int _cknum(char* a, int n) {
	int i;
	char t = '0';

	for (i = 0; i < n; i++) {
		if (a[i] < '0' || a[i]>'9') return 1;
	}
	return 0;
}


int _atoi(char* s, int len) {
	char tmp[20];
	memcpy(tmp, s, len);
	tmp[len] = 0x00;
	return (atoi(tmp));
}
#pragma endregion


#include <stdio.h>

#include<stdio.h>

int main(void)
{
	int  i, cnt = 0;
	int  x,a[101],n;

	i_cin2(n,x);
	i_cins(n, a);
	qsort(a,n,sizeof(int),s_asort);
	
	for (i = 0; i < n; i++) {
	
		cnt++;
		x -= a[i];
		if (x <= 0)break;
	}
	
	(!x) ? i_cout(cnt) : i_cout(cnt - 1);
	return 0;
}



Measured memory_bytes: 1708
import java.io.*;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args)
    {
        Reader r=new Reader();
        PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out));
        int A=r.nextInt();
        int B=r.nextInt();
        int T=r.nextInt();
        int total=(int)(T+0.5)/A*B;
        System.out.println(total);
        out.println(total);



    }

    //Fast I/O class
    static class Reader
    {
        BufferedReader br;
        StringTokenizer st;

        public Reader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine(){
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }


}


Measured memory_bytes: 23124
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using ll = long long;
using VI = vector<int>;
using VVI = vector<vector<int>>;
using P = pair<int, int>;

using VL = vector<ll>;

int main(){
    int n;
    cin >> n;
    VL a(n), b(n), c(n);
    rep(i,n) cin >> a[i];
    rep(i,n) cin >> b[i];
    rep(i,n) cin >> c[i];

    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    sort(c.begin(), c.end());

    VL B(n);
    rep(i,n){
        VL::iterator low = lower_bound(a.begin(), a.end(), b[i]);
        if(i==0){
            B[i] = (ll)(low - a.begin());
        }else{
            B[i] = B[i-1] + (ll)(low - a.begin());
        }
    }

    ll out = 0;
    rep(i,n){
        VL::iterator low = lower_bound(b.begin(), b.end(), c[i]);
        int id = (int)(low - b.begin() - 1);
        if(id < 0){
            continue;
        }else{
            out += B[id];
        }
    }

    cout << out << endl;

    return 0;
}

Measured memory_bytes: 3328
S = gets.chomp
def check_str(s)
    return "WA" if s[0] != "A"
    return "WA" if s[2..-2].split("").select { |c| c == "C" }.size != 1
    return "WA" if S.split("").select { |c| c != "A" && c != "C" }.join.match(/[A-Z]/) != nil
    return "AC"
end
puts check_str(S)

Measured memory_bytes: 1916
#include <bits/stdc++.h>
#define maxs 2202002
#define mme(i,j) memset(i,j,sizeof(i))
using namespace std;
char s[205];

int main()
{
    while(~scanf("%s",s))
    {
        int len = strlen(s);
        printf("%c%d%c\n",s[0],len-2,s[len-1]);
    }

    return 0;
}

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

using namespace std;

#define ll long long
#define ar array

int n, k, tmp;
string s;




void solve(){
    
    cin >> n;

    if(n >= 30)
        cout << "Yes" << "\n";
    else
    {
        cout << "No" << "\n";
    }
    

}





int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);

    solve();

}

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

const int MAX_N = 100;
int n, ans, sum, a[2][MAX_N];

int main() {
    cin >> n;
    for (int i = 0; i < n; i++) scanf("%d", &a[0][i]);
    for (int i = 0; i < n; i++) scanf("%d", &a[1][i]);
    for (int i = 0; i < n; i++) {
        sum = 0;
        for (int j = 0; j <= i; j++) sum += a[0][j];
        for (int j = i; j < n; j++) sum += a[1][j];
        ans = max(ans, sum);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <bitset>		//UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>		//do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double

const double pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;


int main()
{
	int N, M;
	vector < string > A, B;
	cin >> N >> M;
	REP(i,N)
	{
		string s;
		cin >> s;
		A.push_back(s);
	}
	REP(i,M)
	{
		string s;
		cin >> s;
		B.push_back(s);
	}

	bool ok = 0;
	REP(i,A.size()-B.size()+1)REP(j,A.front().length()-B.front().length()+1)
	{
		bool spr = 1;
		REP(ii,M)REP(jj,M)
			if(B[ii][jj] != A[ii+i][jj+j])
				spr = 0;

		if(spr)
			ok = 1;
	}

	if(ok)
		cout << "Yes";
	else
		cout << "No";

	cout << "\n";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
bool carry = false;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  string S;
  cin >> S;
  int N = S.size();
  int ans = 0;
  for (int i = N; i >= 0; i--) {
    int n = S[i] - '0';
    if (carry) n++;
    switch(n){
    case 5:
      ans+=5;
      break;
    case 0:
    case 10:
      break;
    case 1:
    case 9:
      ans+=1;
      break;
    case 2:
    case 8:
      ans+=2;
      break;
    case 3:
    case 7:
      ans+=3;
      break;
    case 4:
    case 6:
      ans+=4;
      break;
    }
    carry = (n > 5 || (n == 5 && i > 0 && S[i-1] > '4'));
  }
  if (carry) ans++;
  cout << ans << '\n';
  return 0;
}
 

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

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    vector<long long> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    vector<vector<int>> e(n);
    for (int i = 0; i < n-1; i++) {
        int u, v; cin >> u >> v;
        u--, v--;
        e[u].emplace_back(v);
        e[v].emplace_back(u);
    }
    if (n == 2) {
        if (a[0] == a[1]) cout << "YES\n";
        else cout << "NO\n";
        return 0;
    }
    vector<long long> emit(n, 0);
    bool ok = true;
    auto f = [&](auto f, int curr, int prev) {
        if (prev != -1 && e[curr].size() == 1) {
            emit[curr] = a[curr];
            return;
        }
        long long all = 0, maxi = 0;
        for (auto &to: e[curr]) {
            if (prev == to) continue;
            f(f, to, curr);
            all += emit[to];
            maxi = max(maxi, emit[to]);
        }
        emit[curr] = 2 * a[curr] - all;
        if (emit[curr] < 0 || emit[curr] > all) ok = false;
        if ((all - emit[curr]) / 2 > all - maxi) ok = false;
    };
    for (int i = 0; i < n; i++) {
        if (e[i].size() == 1) continue;
        f(f, i, -1);
        if (emit[i] == 0 && ok) cout << "YES\n";
        else cout << "NO\n";
        break;
    }
    return 0;
}

Measured memory_bytes: 13056
import java.util.Scanner;


public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		long num = sc.nextInt();

		System.out.println(factorial(num));
	}
	
	public static long factorial(long n) {
		long fact = 1;
		if(n == 0)
			return fact;
		else{
			for(long i = n; i > 0; i--)
				fact = fact * i;
			return fact;
		}
	}
}

Measured memory_bytes: 17156
# include <iostream>
# include <stdint.h>
# include <stdio.h>
# include <math.h>
using namespace std;


int main(){
	int a ,b ;
	do
	{cin >> a>>b;
		if(a !=0 ||b !=0)
		{for (int i =1;i<a+1;i++ ){
					for(int j =1;j<b+1;j++){
						cout <<'#';
					}
					cout <<"\n";
				}  }else break;
		cout <<"\n";
	}while(a =!0 ||b !=0);

return 0;
}



Measured memory_bytes: 3072
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define pi 3.141592653589793238
#define int long long
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

const int mod=1e9+7;
int fac[200005];
int inv[200005];
int modInverse(int a, int m) 
{ 
    int m0 = m; 
    int y = 0, x = 1; 
  
    if (m == 1) 
      return 0; 
  
    while (a > 1) 
    { 
        // q is quotient 
        int q = a / m; 
        int t = m; 
  
        // m is remainder now, process same as 
        // Euclid's algo 
        m = a % m, a = t; 
        t = y; 
  
        // Update y and x 
        y = x - q * y; 
        x = t; 
    } 
  
    // Make x positive 
    if (x < 0) 
       x += m0; 
  
    return x; 
} 
int n,m;
int dp[3005];
bool comp(pair<int,int>p1,pair<int,int>p2)
{
  return (p1.first+p1.second)<(p2.first+p2.second);
}

int find(int x,int y,int n,int m)
{
  x=n-x;
  y=m-y;  
  int z=fac[x+y];
  z=(z*inv[x])%mod;
  z=(z*inv[y])%mod;
  return z;
}

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);  
    cout.tie(0);   
#ifndef ONLINE_JUDGE
    if(fopen("INPUT.txt","r"))
    {
    freopen ("INPUT.txt" , "r" , stdin);
    freopen ("OUTPUT.txt" , "w" , stdout);
    }
#endif

// -------------------------------------Code starts here---------------------------------------------------------------------     

  fac[0]=1;
  for(int i=1;i<=200000;i++)
    fac[i]=(fac[i-1]*i)%mod;
  inv[0]=1;
  for(int i=1;i<=200000;i++)
  {
    inv[i]=(modInverse(fac[i],mod))%mod;
  }

  int k;
  cin>>n>>m>>k;
  pair<int,int>p[k+1];
  for(int i=1;i<=k;i++)
    cin>>p[i].first>>p[i].second;
  sort(p+1,p+k+1,comp);
  p[0].first=1;
  p[0].second=1;
  for(int i=k;i>=0;i--)
  {
    dp[i]=find(p[i].first,p[i].second,n,m);
    for(int j=i+1;j<=k;j++)
    {
      if(p[j].first>=p[i].first&&p[j].second>=p[i].second)
        dp[i]=(dp[i]-(dp[j]*find(p[i].first,p[i].second,p[j].first,p[j].second))%mod+mod)%mod;
    }
  }

  if(p[1].first+p[1].second==2)
  {
    cout<<0;
    return 0;
  }
  cout<<dp[0];
  

// -------------------------------------Code ends here------------------------------------------------------------------
    clock_t clk;
  clk = clock();

    clk = clock() - clk;
  cerr << fixed << setprecision(6) << "Time: " << ((double)clk)/CLOCKS_PER_SEC << "\n";
  return 0;
}


Measured memory_bytes: 3456
#include<stdio.h>
int main(){
  int con,n,i,j,k,c=0,a[100],flag=1;
  scanf("%d",&n);
  for(k = 0;k < n;k++){
    scanf("%d",&a[k]);
  }
  while(flag){
    flag=0;
    for (j = n-1; j > 0; j--){
      if(a[j] < a[j-1]){
	con=a[j-1];
	a[j-1]=a[j];
	a[j]=con;
	c++;
	flag=1;
      }
    }
  }
  for (i = 0; i < n; i++) {
    if(i<n-1){
      printf("%d ",a[i]);
    }
    else if(i==n-1){
      printf("%d\n",a[i]);
    }
  }
  printf("%d\n",c);
  return 0;
}

Measured memory_bytes: 600
#include<stdio.h>
#include<algorithm>
using namespace std;
char str[1100][11];
int H[1100];
int L[1100];
int n;
int ret[12];
int ans=0;
int v[12];
int now[12];
int tmp[12];
int m;
void solve(int a){
	if(ans>1)return;
	for(int j=0;j<n;j++){
		int h=0;
		int bl=0;
		for(int k=0;k<m;k++)tmp[k]=0;
		for(int k=0;k<a;k++){
			if(str[j][k]-'0'==now[k]){tmp[k]=1;h++;}
		}
		for(int k=0;k<a;k++){
			for(int l=0;l<a;l++){
				if(tmp[l])continue;
				if(str[j][k]-'0'==now[l]){tmp[l]=1;bl++;break;}
			}
		}
		if(h>H[j])return;
		if(h+m-a<H[j])return;
		if(bl>L[j])return;
		if(bl+(m-a)*2<L[j])return;
	}
	if(a==m){
		ans++;
		for(int i=0;i<m;i++)ret[i]=now[i];
		return;
	}
	for(int i=0;i<10;i++){
		if(!v[i]){
			v[i]=1;
			now[a]=i;
			solve(a+1);
			v[i]=0;
		}
	}
}
int main(){
	int a,b;
	while(scanf("%d%d",&a,&b),a){
		m=a;
		n=b;
		for(int i=0;i<b;i++){
			scanf("%s%d%d",str[i],H+i,L+i);
		}
		ans=0;
		for(int i=0;i<12;i++)v[i]=0;
		solve(0);
		if(ans!=1){
			printf("NO\n");continue;
		}
		for(int i=0;i<a;i++)printf("%d",ret[i]);
		printf("\n");
	}
}

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

int main(){
  using coord= pair<int64_t, int64_t>;
  // 入力
  int H,W,D,buf;
  cin >> H >> W >> D;
  const int N= H* W;
  const int Nlen= N/D+ 1;

  vector<coord> data(N);
  for(int64_t i=0; i<H; i++){
    for(int64_t j=0; j<W; j++){
      cin >> buf;
      buf--; // 1-indexed -> 0-indexed
      data.at(buf)= make_pair(i, j);
    }
  }

  // 前処理として累積和を計算
  vector<vector<int64_t>> cumsums(D, vector<int64_t>(Nlen));

  auto dist= [](coord p1, coord p2){
    return abs(p1.first- p2.first)+ abs(p1.second- p2.second);
  };
  for(int r=0; r<D; r++){
    for(int q=1; q<Nlen; q++){
      int diff= (q*D+ r < N) ? dist(data.at(q*D+ r), data.at((q-1)*D+ r))
                             : 0;

      cumsums.at(r).at(q)= cumsums.at(r).at(q-1)+ diff;
    }
  }

  // クエリ処理
  int Q,left,right;
  cin >> Q;
  for(int i=0; i<Q; i++){
    cin >> left >> right;
    left--; right--; // 1-indexed -> 0-indexed

    cout << cumsums.at(right% D).at(right/D)- cumsums.at(left% D).at(left/D) << endl;
  }
}

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

vector<vector<int>> g;
vector<int> color;

bool dfs(int v, int c) {
  color.at(v) = c;
  for (int x : g.at(v)) {
    if (color.at(x) == c) return false;
    if (color.at(x) == -1 && !dfs(x, 1 - c)) return false;
  }
  return true;
}

int main() {
  ll N, M;
  cin >> N >> M;
  
  g.resize(N);
  color.resize(N, -1);
  
  for (int i = 0; i < M; i++) {
    int A, B;
    cin >> A >> B;
    A--;
    B--;
    
    g.at(A).push_back(B);
    g.at(B).push_back(A);
  }
  
  bool isBipartite = dfs(0, 0);
  ll ans = 0;
  if (isBipartite) {
    ll whiteCnt = 0;
    for (int i = 0; i < N; i++) {
      if (color.at(i) == 0) whiteCnt++;
    }
    ans = whiteCnt * (N - whiteCnt) - M;
  } else {
    ans = N * (N - 1) / 2 - M;
  }
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 6528
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
int main(void){
  int n;
  cin>>n;
  ll lucas[86];
  lucas[0]=2;
  lucas[1]=1;
  for(int i=2;i<=n;i++){
    lucas[i]=lucas[i-2]+lucas[i-1];
  }
  cout<<lucas[n]<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<functional>
#include<string>
#include<cmath>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<cstdio>
using namespace std;
using ll = long long;
int main(){
  string s;
  cin >> s;
  if(s[2] == s[3]){
    if(s[4] == s[5]){
      cout << "Yes\n";
      return 0;
    }
  }
  cout << "No\n";
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0,i##_len=(int)(n);i<i##_len;i++)
#define rep1(i,n)for(int i=1,i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=(int)(n)-1;0<=i;i--)
#define rrep1(i,n) for(int i=(int)(n);1<=i;i--)

#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define all(obj) (obj).begin(),(obj).end() 

#define pcount __builtin_popcount
#define SZ(x) ((int)(x).size())
#define LEN(x) ((int)(x).length())

#define dump(x)  cerr << #x << " = " << (x) << endl;

#define endl "\n"

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

typedef long long lint;

using namespace std;
int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int k,a,b;
	cin>>k>>a>>b;
	for(int i=a;i<=b;i++){
		if(i%k==0){
			cout<<"OK"<<endl;
			return 0;
		}
	}
	cout<<"NG"<<endl;
}

Measured memory_bytes: 3620
#include <map>
#include <set>
#include <ctime>
#include <cmath>
#include <stack>
#include <queue>
#include <bitset>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <cstring> 
#include <iostream>
#include <algorithm>
using namespace std;

int A, B, C, K;

int main()
{
	cin >> A >> B >> C >> K;
	while(B <= A)
	{
		B *= 2;
		--K;
	}
	while(C <= B)
	{
		C *= 2;
		--K;
	}
	if(K >= 0)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;

	return 0;
}

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

#define ll long long
#define endl '\n'
#define REP(i, a, n) for(int i=a; i<n; ++i)
#define pb push_back
#define sz(x) (int)((x).size())
#define all(x) (x).begin(), (x).end()

typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

const double PI = 3.141592653589793238460;
const ll mod = 1e9 + 7;

void FAST(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
}

int main(){
  FAST();
  
  int w, h, n;
  cin >> w >> h >> n;
  
  int xmin = w, xmax = 0, ymin = h, ymax = 0;
  REP(i, 0, n){
    int x, y, a;
    cin >> x >> y >> a;
    if(a == 1){
      xmax = max (xmax, x);
    }
    else if(a == 2){
      xmin = min (xmin, x);
    }
    else if(a == 3){
      ymax = max (ymax, y);
    }
    else if(a == 4){
      ymin = min (ymin, y);
    }
  }
  
  if ((xmax >= xmin) || (ymax >= ymin))
    cout << 0 << endl;
  else
    cout << (xmin - xmax) * (ymin - ymax) << endl;
  return 0;
}


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

int main(){
  int n;
  cin >> n;
  float x,ans=0;
  string u;
  for(int i=0; i<n; i++){
    cin >> x >> u;
    if(u=="JPY"){
      ans+=x;
    }else{
      ans+=x*380000;
    }
  }
  cout << ans;
}
  

Measured memory_bytes: 256
#include <bits/stdc++.h>
long long n, s;
bool check(long long base) {
    long long ret = 0, tmp = n;
    while (tmp) ret += tmp % base, tmp /= base;
    return ret == s;
}
bool check(long long a1, long long tmp, long long a0 = 0, long long b = 0) {
    return (a0 = s - a1) >= 0 && a0 < (b = tmp / a1 + 1) && a1 < b;
}
int main() {
    scanf("%lld%lld", &n, &s);
    long long up = (long long)sqrt(n) + 1;
    for (long long base = 2; base <= up; base++) if (check(base)) return 0 * printf("%lld\n", base);
    if (n <= s) return 0 * printf("%lld\n", n < s ? -1: n + 1);
    long long tmp = n - s, upper = tmp / up + 1;
    for (long long a1 = upper; a1 >= 1; a1--)
        if (!(tmp % a1) && check(a1, tmp)) return 0 * printf("%lld\n", tmp / a1 + 1);
    return 0 * puts("-1");
}

Measured memory_bytes: 256
#include <stdio.h>

int main() {
    int a, b;
    scanf("%d %d", &a, &b);

    if((a+b)%2==0) {
        printf("%d\n", (a+b)/2);
    } else {
        printf("%d\n", (a+b+1)/2);
    }

    return 0;

}

Measured memory_bytes: 128
#include <iostream>
#include <math.h>
using namespace std;
#define int long long
#include <stdio.h>
signed main(void){
    // Your code here!
    int h;
    cin>>h;
    int k=0;
    for(int i=0;h!=0;i++){
        if(h%2==0){
            h=h/2;
        }
        else{
            h=(h-1)/2;
        }
        k++;
    }
    if(h==1){
        cout<<1;
    }
    else{
        printf("%.0f",(pow(2,k)-1));
    }
}
    


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

using namespace std;

int main()
{
	int N, K;
	string S;
	cin >> N;
	cin >> S;
	cin >> K;
	for (int i = 0; i < N; ++i)
	{
		if (S[i] != S[K - 1])
			S[i] = '*';
	}
	cout << S << endl;

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_set>
#include <queue>
#include <stack>
#include <functional>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <limits>

using namespace std;

#define ll long long

#define in(x) cin >> x
#define out(x) cout << x << endl

#define PI acos(-1)
#define pp push_back

#define Yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define No cout << "No" << endl
#define NO cout << "NO" << endl

#define vec2(type) vector<vector<type>>
#define vec3(type) vector<vector<vector<type>>>

#define For(i, n) for(int i = 0; i < n; i++)

template<typename T> void input(T *data, int n){
	For(i, n){
		cin >> data[i];
	}
}

template<typename T> void input(vector<T> &vec, int n){
	T temp;
	For(i, n){
		cin >> temp;
		vec.push_back(temp);
	}
}

template<typename T> void sort(vector<T> &ary){
	sort(ary.begin(), ary.end());
}

template<typename T> void rsort(vector<T> &ary){
	sort(ary.rbegin(), ary.rend());
}

void rstring(string &str){
	string temp = str;

	For(i, (int)str.size()){
		str[i] = temp[(str.size() - 1) - i];
	}
}

struct Vec{
	int x, y;
	Vec():
	x(0), y(0){}
	Vec(int _x, int _y):
	x(_x), y(_y){}
};

template<typename T> void print(T *x, int n){
	For(i, n){
		cout << x[i] << " ";
	}
	cout << endl;
}

template<typename T> void print(vector<T> &x){
	For(i, (int)x.size()){
		cout << x[i] << " ";
	}
	cout << endl;
}

int gcd(int n, int m){
	if(n % m == 0){
		return m;
	}
	else{
		return gcd(m, n % m);
	}
}

int main(){

	int n;
	double x;
	string u;
	double sum;

	in(n);
	For(i, n){
		cin >> x >> u;

		if(u == "JPY"){
			sum += x;
		}
		else{
			sum += x * 380000.0;
		}
	}

	out(sum);

	return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
using LL = long long;
const LL LINF = 1e18;
using namespace std;
#define COUT(v) cout<<(v)<<endl
#define CIN(n)  int(n);cin >> (n)
#define LCIN(n) LL(n);cin >> (n)
#define SCIN(n) string(n);cin >> (n)
#define YES(n) cout<<((n)? "YES" : "NO")<<endl
#define Yes(n) cout<<((n)? "Yes" : "No")<<endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) <<endl

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)

#define FOREACH(x,a) for(auto& (x) : (a) )

#define ALL(obj) (obj).begin(),(obj).end()

#define P pair<LL,LL>
#define I vector<int>
#define S set<int>
#define pb(v) push_back(v)
#define V vector
#define rt return
#define rmsame(a) sort(ALL(a)),a.erase(unique(ALL(a)), a.end())

typedef string::const_iterator State;
class PalseError {};
class Edge{
public:
    LL from,to,value;
    Edge(LL a,LL b,LL c){
        from = a;
        to = b;
        value = c;
    }
    Edge(LL a,LL b){
        from = a;
        to = b;
    }
};

int main(){
    CIN(A);CIN(B);CIN(C);
    Yes(A<=C&&C<=B);
    return 0;
}


Measured memory_bytes: 256