akhauriyash/Code-Regression huggingface dataset:
//Coded by Abhijay Mitra
#include <iostream>
#include <stdlib.h>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <numeric>
#include <vector>
#include <iterator> 
#include <map>
#include <set>
#include <climits>
#include <queue>
#include <cmath>
#include <stack>
#include <cctype>
#include <bitset>
// #include <bits/stdc++.h>
#define double long double
#define int long long int
#define ll int
#define ibs ios_base::sync_with_stdio(false)
#define cti cin.tie(0)
#define bp __builtin_popcount
#define pb push_back
#define res(v) v.resize(unique(v.begin(), v.end()) - v.begin());
#define cnt_res(v) std::distance(v.begin(),std::unique(v.begin(), v.end())); 
#define timer cerr << "Time elapsed : " << 1.0 * clock() / CLOCKS_PER_SEC << " sec \n";
using vi = std::vector<int>;
using vvi = std::vector<vi>;
using pii = std::pair<int,int>;
using vpii = std::vector<pii>;
using vvpii = std::vector<vpii>;
#define mp         make_pair
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define per(i,b,a) for (int i = b; i >= a; i--)
#define all(x)     x.begin(), x.end()
using namespace std;
const int N=2e6+10;
const int inf = /*0x3f3f3f3f*/1e18+10;
// const ll M = 998244353 ; // Mulo
// const int M = 1e9+7 ; // Mulo
const double Pi = 3.14159265;
#define F first
#define S second
int n,k;vi v,dp;
void solve(){
  cin>>n>>k;v=vi(n,0);dp=vi(n,inf);dp[0]=0;
  rep(i,0,n-1)cin>>v[i];
  rep(i,1,n-1){
    rep(j,1,min(i,k)){
      dp[i]=min(dp[i],abs(v[i-j]-v[i])+dp[i-j]);
    }
  }
  cout<<dp[n-1];
}
int32_t main()
{
  ibs;cti;
  solve()
  /*,cout<<"\n"*/;
  // cout<<"\n";
  int xx=0;
  // int t;cin>>t;while(t--){/*xx++;cout<<"Case "<<xx<<":\n"*/;solve();cout<<"\n";}
  return 0;
}

Measured memory_bytes: 1792
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

template <typename T>
void print(T x) {
    cout << x << endl;
}

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;


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

    int M;
    cin >> M;

    print(24 * 2 - M);

}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
void small_ink(int tile[][10], int x, int y){
  int i;
  for(i=-1;i<=1;i++){
    if(x+i>=0 && x+i<=9){
      tile[x+i][y] += 1;
    }
    if(y+i>=0 && y+i<=9){
      tile[x][y+i] += 1;
    }
    tile[x][y] -= 1;
  }
}
void medium_ink(int tile[][10], int x, int y){
  int i, j;
  for(i=-1;i<=1;i++){
    for(j=-1;j<=1;j++){
      if(x+i>=0 && x+i<=9 && y+j>= 0 && y+j <=9){
	tile[x+i][y+j] += 1;
      }
    }
  }
}
void large_ink(int tile[][10], int x, int y){
  int i, j;
  for(i=-2;i<=2;i++){
    for(j=-(2-abs(i));j<=(2-abs(i));j++){
      if(x+i>=0 && x+i<=9 && y+j>= 0 && y+j <=9){
	tile[x+i][y+j] += 1;
      }
    }
  }
}

int main(){
  int x, y, num;
  int tile[10][10] = {{0,0,0,0,0,0,0,0,0,0}};
  int i,j, cnt=0,max;
  while(scanf("%d,%d,%d",&x,&y,&num) != EOF){
    switch(num){
    case 1:
      small_ink(tile,x,y);
      break;
    case 2:
      medium_ink(tile,x,y);
      break;
    case 3:
      large_ink(tile,x,y);
      break;
    }
  }
  max = tile[0][0];
  for(i=0;i<10;i++){
    for(j=0;j<10;j++){
      if(tile[i][j] == 0){
	cnt++;
      }
      if(max < tile[i][j]){
	max = tile[i][j];
      }
    }
  }
  printf("%d\n%d\n", cnt, max);
  return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<tuple<string, int, int>> res(N);
  for(int i = 0; i < N; i++) {
    int x = i + 1, y;
    string s;
    cin >> s >> y;
    res.at(i) = make_tuple(s, y, x);
  }
  sort(res.begin(), res.end());  
  //for(int k = 0; k < N; k++) {
    for(int i = 0; i < N; i++) {
      for(int j = i + 1; j < N; j++) {
        if(get<0>(res.at(i)) == get<0>(res.at(j))) {
          tuple<string, int, int> resx, resy;
          resx = res.at(i); resy = res.at(j);
          res.at(i) = max(resx, resy);
          res.at(j) = min(resx, resy);
        }
      }
    }
  //}
  
  for(int i = 0; i < N; i++) {
    int a, b;
    string s;
    tie(s, a, b) = res.at(i);
    cout << b << endl;
  }
}

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

int main(){
	double a,b,x;
	cin>>a>>b>>x;
	double v=a*a*b-x;
	if(a*a*b-2*x<=0){
		printf("%.6f",atan(2*v/a/a/a)*180/3.1415926535);
	}
	else{
		printf("%.6f",atan(a*b*b/2/x)*180/3.1415926535);
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(v) v.begin(), v.end()
#define sh cin.tie(0); cin.sync_with_stdio(0); cout.tie(0);
#define FILE freopen("test.in", "r", stdin);
#define vprint(v) for (int ii = 0; ii < v.size(); ii++){cout << v[ii] << " ";}
#define debugv(v) if (v.size() != 0) {cout << "[ "; for (int __ = 0; __ < (int)(v.size()) - 1; __++){cout << v[__] << ", ";} cout << v[(int)(v.size()) - 1] << " ]" << endl;} else {cout << "[]" << endl;}
#define debug cout << "-----------------------------------------------" << endl;
#define print1(a) cout << "{ " << a << " }" << endl;
#define print2(a, b) cout << "{ " << a << ", " << b << " }" << endl;
#define print3(a, b, c) cout << "{ " << a << ", " << b << ", " << c << " }" << endl;
#define print4(a, b, c, d) cout << "{ " << a << ", " << b << ", " << c << ", " << d << " }" << endl;
using namespace std;
#define int long long
const int INF = 1e9 + 228;
const int MAXN = 1e5 + 228;
map<pair<int, int>, int> mapa;

int to(string s) {
	int pw = 1;
	int ans = 0;
	reverse(all(s));
	for (int i = 0; i < s.size(); i++) {
		ans += (pw * (s[i] - '0'));
		pw *= 10;
	}
	return ans;
}

string tos(int x) {
	string res = "";
	while (x > 0) {
		res += ((x % 10) + '0');
		x /= 10;
	}
	reverse(all(res));
	return res;
}

signed main()
{
#ifdef LOCAL
    FILE;
#endif
    sh;
	string n;
	cin >> n;
	int m = to(n);
	int ans = 0;
	for (int i = 1; i <= m; i++) {
		string ss = tos(i);
		mapa[{ss[0] - '0', ss[ss.size() - 1] - '0'}]++;
		//print2(ss[0] - '0', ss[ss.size() - 1] - '0');
	}
	for (int x1 = 1; x1 <= 9; x1++) {
		for (int x2 = 1; x2 <= 9; x2++) {
			ans += (mapa[{x1, x2}] * mapa[{x2, x1}]);
		}
	}
	cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <complex>
#include <iostream>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using std::cin;
using std::cout;
using std::endl;
using std::cerr;

using std::string;
using std::to_string;
using std::vector;
using std::set;
using std::queue;
using std::stack;
using std::priority_queue;

using std::min;
using std::max;
using std::sort;
using std::abs;

typedef long long int ll;
const int MOD = 1e9 + 7;

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

    bool ans = (a == 5 && b == 5 && c == 7) || (a == 5 && b == 7 && c == 5) ||
               (a == 7 && b == 5 && c == 5);
    cout << (ans ? "YES" : "NO") << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <mylib.h>
using namespace std;
//cin.sync_with_stdio(false);

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define FOR_EQ(i,a,b) for(int i = (a); i <= (b); ++i)
#define FOR_RE(i,a,b) for(int i = (a); i > (b); --i)
#define rep(i,n) FOR(i,0,n)
#define rep_eq(i,n) FOR_EQ(i,0,n)
//1個上から時計周り
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
//上右下左
const int dx[4] = {0, 1, 0, -1};
const int dy[4] = {1, 0, -1, 0};

typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> Vector;
typedef vector<Vector>	DVector;
int n;

int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    cin >> n;
    
    int rest;
    for(int i = 0; i < 15; i++){
        rest = n - 7 * i;
        if(rest < 0)    break;
        if(rest % 4 == 0){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

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

template<typename T>
T gcd(T a, T b) {
	while (a != 0) {
		if (a < b) { //to be a > b
			std::swap(a, b);
		}
		a = a % b;
	}
	return b;
}
template<typename T>
T lcm(const T& a, const T& b) {
	return a * b / gcd(a, b);
}

int main(int argc, char const* argv[])
{
	unsigned long a{}, b{};
	while (std::cin >> a >> b) {
		std::cout << gcd(a, b) << ' ';
		std::cout << lcm(a, b) << std::endl;
	}
	return 0;
}

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

int main() {
  long long A, B, K;
  cin >> A >> B >> K;
  int turn = 0;
  for(int i = 0; i < K; i++) { 
    if (turn == 0) {
      if (A % 2 == 1) {
      	A--;
      }
      long long half = A / 2;
      A -= half;
      B += half;
    } else {
      if (B % 2 == 1) {
      	B--;
      }
      long long half = B / 2;
      A += half;
      B -= half;
    }
    turn = 1 - turn;
  }
  cout << A << " " << B << endl;
  return 0;
}

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


/* macro */
#define rep(i,a,b) for(int i=a;i<b;i++)
#define revrep(i,a,b) for(int i = a; i > b; i--)
//#define int long long
#define exist(s,e) ((s).find(e)!=(s).end())
#define all(v) (v).begin(), (v).end()
#define each(s,itr) for(auto (itr) = s.begin(); (itr) != s.end(); (itr)++)
#define sum(v) accumulate(all(v), (0LL))
#define pb push_back


/* alias */
template<class T> using vec = vector<T>;
typedef vector<int> vi;
typedef pair<int, int> pi;


/* constant */
const int inf = pow(2, 57);
const int mod = 1e9 + 7;
int dx[8]={1,0,-1,0,-1,1,-1,1};
int dy[8]={0,1,0,-1,-1,-1,1,1};
const string alpha = "abcdefghijklmnopqrstuvwxyz";

/* io_method */
int input(){int tmp;cin >> tmp;return tmp;}
string raw_input(){string tmp;cin >> tmp;return tmp;}
string readline(){string s;getline(cin, s);return s;}
template<class T> void printx(T n){cout << n;}
template<class T, class U> void printx(pair<T, U> p){cout << "(" << p.first << "," << p.second << ")";}
template<class T> void printx(vector<T> v){cout << "{";rep(i,0,v.size()){printx(v[i]);if(i != v.size()-1)printx(",");}cout << "}";}
template<class T> void print(T n){printx(n);cout << endl;}
template<class T> void print(set<T> s){cout << "{";each(s, e){if(e != s.begin()) printx(",");printx(*e);}cout << "}" << endl;}
template<class T, class U> void print(map<T, U> mp){cout << "{";each(mp, e){cout << "(" << e -> first << "," << e -> second << ")";}cout << "}" << endl;}


/* general_method */
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; }




/* main */








signed main(){

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

    int n = input();

    vi arr; rep(i,0,n) arr.push_back(input());

    bool even = true;
    rep(i,0,n){
        if(arr[i] % 2 == 1) even = false;
    }

    if(even){
        print("second");
    }else{
        print("first");
    }


    


     



     





    


    


   





    


    


    





    
    






    



    





    


    

}



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

using namespace std;

int main()
{
	int n, k;
	scanf("%d %d", &n, &k);
	
	char inp[n + 3];
	scanf("%s", inp);
	int num[n];
	for(int i = 0; i < n; i++) {
		num[i] = inp[i] == '0' ? 0 : 1;
	}
	
	int l = 0;
	int sum = 0, ans = 0;
	int i = 0;
	// 111000111
	// 000111000
	// 000111
	// 111000
	while(i < n) {
		while(i < n && num[i] == 1)
			i++;
		ans = max(ans, i - l);
		while(i < n && num[i] == 0)
			i++;
		k--;
		if(k < 0) {
			while(l < n && num[l] == 1)
				l++;
			while(l < n && num[l] == 0)
				l++;
		}

		ans = max(ans, i - l);
	}

	printf("%d\n", ans);

	return 0;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    if(a*b>=c*d){
        cout<<a*b<<endl;
    }
    else{
        cout<<c*d<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
# -*- coding:utf-8 -*-
import math

N, A, B = map(int, input().split(' '))
hn = sorted([int(input()) for i in range(N)])

maxT = hn[-1] // B + 1
minT = 0

def enough(T):
    count = sum([math.ceil((h - B*T) / (A-B)) if (h - B*T) >= 0 else 0 for h in hn])
    return True if count <= T else False

while True:
    med = (maxT + minT) // 2
    if enough(med):
        maxT = med
    else:
        minT = med
    if maxT - minT <= 1:
        break
print(maxT)


Measured memory_bytes: 10948
#include<stdio.h>

int main(){
	//a=0, b=1, d=2, r=3, f=4
	int num[2]={0};
	for(int i=0; i<2; i++){
		scanf("%d",&num[i]);
	}
	printf("%d %d %f",num[0]/num[1],num[0]%num[1],(double)num[0]/num[1]);
	return 0;
}



Measured memory_bytes: 2756
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define mp make_pair
#define F first
#define S second
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
typedef long long ll;
ll n;
ll a[1005];
int main()
{
    //IOS;

    string s;
    while(cin>>s)
    {
        set<char> ss;
        rep(i,26)
        {
            ss.insert(char('a'+i));
        }
        rep(i,s.size())
        {
            if(ss.count(s[i])) ss.erase(s[i]);
        }
        if(ss.size()==0) cout<<"None\n";
        else cout<<*ss.begin()<<"\n";
    }
    return 0;
}



Measured memory_bytes: 512
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;

public class Main
{
    public static void main(String[] args) throws IOException
    {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String s;
		while((s=br.readLine())!=null){
			String[] nums = s.split(" ");
			ArrayList<Integer> num = new ArrayList<Integer>();
			for(int i=0; i<5; i++)
				num.add(Integer.parseInt(nums[i]));
			Collections.sort(num);
			for(int i=4; i>0; i--)
				System.out.print(num.get(i)+" ");
			System.out.println(num.get(0));
		}
    }
}

Measured memory_bytes: 9356
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
typedef pair<double,int>Q;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int n,p[20005],a[20005],b[20005];
int x[20005];
int main(){
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>p[i];
		x[p[i]] = i;
	}
	for(int i=1;i<=n;i++) b[i] = (n+1-i)*30000;
	a[1] = 1;
	for(int i=2;i<=n;i++){
		//(a_i-a_1) - 30000 * (i-1) = x[i]-x[1]
		a[i] = 30000*(i-1)+x[i]-x[1]+a[1];
	}
	for(int i=1;i<=n;i++)cout<<a[i]<<" ";cout<<endl;
	for(int i=1;i<=n;i++)cout<<b[i]<<" ";cout<<endl;
}

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

public class Main {

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] lines = br.readLine().split(" ");
        int n = Integer.parseInt(lines[0]);
        int m = Integer.parseInt(lines[1]);
        int l = Integer.parseInt(lines[2]);
        long[][] matrix1 = new long[n][m];
        long[][] matrix2 = new long[m][l];
        long[][] matrix3 = new long[n][l];
        createMatrix(br, n, m, matrix1);
        createMatrix(br, m, l, matrix2);
        for(int i=0;i<n;i++){
            for(int j=0;j<l;j++){
                for(int k=0;k<m;k++){
                    matrix3[i][j]+=matrix1[i][k]*matrix2[k][j];
                }
            }
        }
        for(int i=0;i<n;i++){
            for(int j=0;j<l;j++){
                System.out.print(matrix3[i][j]);
                if(j<l-1)
                    System.out.print(" ");
            }
            
            System.out.println();
        }

    }

    private static void createMatrix(BufferedReader br, int n, int m, long[][] matrix1) throws IOException {
        String[] lines;
        for (int i = 0; i < n; i++) {
            lines = br.readLine().split(" ");
            for (int j = 0; j < m; j++) {
                matrix1[i][j] = Long.parseLong(lines[j]);
            }
        }
    }
}

Measured memory_bytes: 33004
#d=日数, c=満足低下度, s=満足上昇度, t=コンテストの日程 
d = int(input())
c = list(map(int, input().split()))
s = [list(map(int, input().split())) for i in range(d)]

t_lst = []
res = 0
last = [0 for i in range(26)]
#old = t[dq[j][0] - 1]
#t[dq[0] - 1] = dq[1]
"""for day in range(d):
  t = s[day].index(max(s[day])) + 1
  m = s[day].index(max(s[day]))
  res += max(s[day])
  last[m] = day + 1
  t_lst.append(t)
  combined1 = [x * (day + 1 - y) for (x, y) in zip(c, last)]
  res -= sum(combined1)
  #t[dq[j][0] - 1] = old
  print(t)"""
for day in range(d):
  t = c.index(max(c)) + 1
  m = c.index(max(c))
  res += s[day][m]
  last[m] = day + 1
  t_lst.append(t)
  combined1 = [x * (day + 1 - y) for (x, y) in zip(c, last)]
  res -= sum(combined1)
  #t[dq[j][0] - 1] = old
  print(t)



Measured memory_bytes: 9212
import java.util.Scanner;
import java.util.HashMap;
import java.util.List;
import java.util.Arrays;
import java.util.ArrayList;
import java.lang.Math;

public class Main {

    static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        int n = sc.nextInt();
        int l = sc.nextInt();
        int[] t = new int[n];
        int sum = 0;
        for (int i = 0; i < n; i++) {
            t[i] = l + i;
            sum += t[i];
        }
        int sumsum = 0;
        int min = 100000;
        int ans = 0;
        for (int i = 0; i < n; i++) {
            int hazusi = t[i];
            sumsum = sum - t[i];
            if (min > Math.abs(sum-sumsum)) {
                min = Math.abs(sum-sumsum);
                ans = sumsum;
            }
        }
        System.out.println(ans);
    }

}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
const int maxn=200010;
char sk[maxn],s[maxn];
int main() {
	scanf("%s",s+1);
	int n=strlen(s+1),top=0;
	for(int i=1;i<=n;i++) {
		sk[++top]=s[i];
		if(top>1&&sk[top]=='T'&&sk[top-1]=='S')top-=2;
	}
	printf("%d\n",top);
	return 0;
}

Measured memory_bytes: 640
N = int(input())
ans = 0

def dfs(x, a, b, c):
    global ans
    if x > N:
        return
    if (a & b & c):
        ans += 1
    dfs(10 * x + 3, 1, b, c)
    dfs(10 * x + 5, a, 1, c)
    dfs(10 * x + 7, a, b, 1)

dfs(0, 0, 0, 0)
print(ans)


Measured memory_bytes: 3188
#include <stdio.h>

int main(void){
  int n, a, b;
  int i, t, sum, ans;

  scanf("%d %d %d", &n, &a, &b);

  ans = 0;
  for (i = 1; i <= n; i++) {
    t = i;
    sum = 0;
    while(t > 0) {
      sum += t % 10;
      t = t / 10;
    }
    if (sum >= a && sum <= b) {
      ans += i;
    }
  }

  printf("%d\n", ans);

  return 0;
}


Measured memory_bytes: 128
object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val n = sc.next()
  if (n.tail.forall(_ == '9')) {
    println(n.toList.map(_.asDigit).sum)
  } else {
    println((n.head.asDigit - 1) + (9 * (n.length - 1)))
  }
}


Measured memory_bytes: 55528
import collections
h, w= map(int, raw_input().split())
n,ais = int(raw_input()), map(int, raw_input().split())
mat = [[-1 for _ in range(w)] for ii in range(h)]
c = 0
for i in range(len(mat)):
	for j in range(len(mat[0]))[::(-1 if i % 2 else 1)]:
		mat[i][j] = c +1
		ais[c] -= 1
		if ais[c] == 0: c +=1
for l in mat: print ' '.join(map(str,l))

Measured memory_bytes: 73652
#include <bits/stdc++.h>
 using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
 int main(){
   int a,b,c,d;
   cin>>a>>b;
   c=0;
   d=0;
   rep(i,1009){
    if(c*8/100==a&&c*10/100==b){
      cout<<c<<endl;
      d++;
      break;
    }
     c++;
   }
  if(d==0){
  cout<<-1<<endl;
  }

}

Measured memory_bytes: 256
//omajinai c++
#include <iostream>
#include<cmath>
#include<vector>
#include <algorithm>
#include <limits>
#include <numeric>
#include <type_traits>
#include <map>
#include <string>
#include <iomanip>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define itn int
using ll = long long;
constexpr auto mod = 1000000007;
using namespace std;
int main() {

int k;
  cin>>k;
  vector<int> a={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  cout<<a.at(k-1);
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <bitset>
#include <complex>
#include <unistd.h>
#include <cassert>
#include <cctype>
#include <random>
#define _USE_MATH_DEFINES
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef complex<double> xy_t;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
double pi = 3.141592653589793;
ll mod = 1000000007;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;
ll inf = llmax / 2;
double eps = 1e-11;

struct edge {
    int to, cost;
};

int V;
vector<edge> G[2][1000000];
ll d[2][1000000];

void dijkstra(int mark, int s) {
    priority_queue<pii, vector<pii>, greater<pii> > que;
    fill(d[mark], d[mark] + V + 10, llmax);
    d[mark][s] = 0;
    que.push(pii(0, s));

    while (!que.empty()) {
        pii p = que.top();
        que.pop();
        int v = p.second;
        if (d[mark][v] < p.first) {
            continue;
        }
        for (int i = 0; i < G[mark][v].size(); i++) {
            edge e = G[mark][v][i];
            if (d[mark][e.to] > d[mark][v] + e.cost) {
                d[mark][e.to] = d[mark][v] + e.cost;
                que.push(pii(d[mark][e.to], e.to));
            }
        }
    }
}

int main() {
    int n, m, s, t;
    cin >> n >> m >> s >> t;
    V = n;
    for (int i = 0; i < m; i++) {
        int u, v, a, b;
        cin >> u >> v >> a >> b;
        edge e1;
        e1.to = v - 1;
        e1.cost = a;
        G[0][u - 1].push_back(e1);
        edge e2;
        e2.to = u - 1;
        e2.cost = a;
        G[0][v - 1].push_back(e2);
        edge e3;
        e3.to = v - 1;
        e3.cost = b;
        G[1][u - 1].push_back(e3);
        edge e4;
        e4.to = u - 1;
        e4.cost = b;
        G[1][v - 1].push_back(e4);
    }
    dijkstra(0, s - 1);
    dijkstra(1, t - 1);
    ll sum[n];
    for (int i = 0; i < n; i++) {
        sum[i] = d[0][i] + d[1][i];
    }
    ll mini[n];
    mini[n - 1] = sum[n - 1];
    for (int i = n - 2; i >= 0; i--) {
        mini[i] = min(mini[i + 1], sum[i]);
    }
    ll num = 1e15;
    for (int i = 0; i < n; i++) {
        cout << num - mini[i] << endl;
    }
}


Measured memory_bytes: 63832
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef pair<int, int> p_ii;
const int INF = 1e9;
const double PI = acos(-1.0);

int main() {
	
	vector<int>x(4, 0), y(4, 0);
	for (int i = 0; i < 2; i++)cin >> x[i] >> y[i];

	int vecx = x[1] - x[0], vecy = y[1] - y[0];
	x[2] = x[1] - vecy;
	y[2] = y[1] + vecx;
	x[3] = x[2] - vecx;
	y[3] = y[2] - vecy;

	cout << x[2] << " " << y[2] << " " << x[3] << " " << y[3] << endl;

	return 0;
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var N int
	fmt.Scan(&N)
	DP := make([]int, N+101010)
	for i := 1; i < len(DP); i++ {
		DP[i] = i // 1円で支払う気持ち
	}
	for i := 1; i <= N; i++ {
		for c := 6; c <= N; c *= 6 {
			if i >= c {
				DP[i] = min(DP[i], DP[i-c]+1)
			}
		}
		for c := 9; c <= N; c *= 9 {
			if i >= c {
				DP[i] = min(DP[i], DP[i-c]+1)
			}
		}
	}
	fmt.Println(DP[N])
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}


Measured memory_bytes: 2176
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<cassert>
#define PB push_back
#define MP make_pair
#define sz(v) (in((v).size()))
#define forn(i,n) for(in i=0;i<(n);++i)
#define forv(i,v) forn(i,sz(v))
#define fors(i,s) for(auto i=(s).begin();i!=(s).end();++i)
#define all(v) (v).begin(),(v).end()
using namespace std;
typedef int in;
typedef vector<in> VI;
typedef vector<VI> VVI;
struct bipm{
  in n,m;
  VVI a;
  VI pr,vs;
  void ini(in pn, in pm){
    n=pn;
    m=pm;
    a.clear();
    a.resize(n);
    pr.clear();
    pr.resize(m,-1);
  }
  void ad(in u, in v){
    a[u].PB(v);
  }
  bool mm(in u){
    if(vs[u])
      return 0;
    vs[u]=1;
    in tt;
    forv(i,a[u]){
      tt=a[u][i];
      if(pr[tt]==-1){
	pr[tt]=u;
	return 1;
      }
      if(mm(pr[tt])){
	pr[tt]=u;
	return 1;
      }
    }
    return 0;
  }
  in mmat(){
    vs.resize(n);
    in sm=0;
    forn(i,n){
      forn(j,n)
	vs[j]=0;
      sm+=mm(i);
    }
    return sm;
  }
};
bipm mat;
bool isp(in a){
  if(a<=2)
    return 0;
  for(in i=2;i*i<=a;++i){
    if(a%i==0)
      return 0;
  }
  return 1;
}
in ab(in a){
  return a<0?-a:a;
}
int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  in n;
  cin>>n;
  VI x(n);
  forn(i,n)
    cin>>x[i];
  VI lft,rgt;
  in c;
  forv(i,x){
    if(i==0 || x[i-1]+1!=x[i]){
      c=x[i];
      if(c%2==0)
	lft.PB(c);
      else
	rgt.PB(c);
    }
    if(i==n-1 || x[i]+1!=x[i+1]){
      c=x[i]+1;
      if(c%2==0)
	lft.PB(c);
      else
	rgt.PB(c);
    }
  }
  in l=sz(lft);
  in r=sz(rgt);
  mat.ini(l,r);
  forv(i,lft){
    forv(j,rgt){
      if(isp(ab(rgt[j]-lft[i])))
	mat.ad(i,j);
    }
  }
  c=mat.mmat();
  in res=c;
  l-=c;
  r-=c;
  assert(l%2==r%2);
  if(l%2){
    res+=3;
    --l;
    --r;
  }
  res+=l+r;
  cout<<res<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
 
int main(){
    int i,j,t,data[10];
     
    for(i=0;i<10;i++)
    {
        scanf("%d",&data[i]);
    }
     
    for(i=0;i<9;i++)
    {
        for(j=0;j<9-i;j++)
        {
            if(data[j]<data[j+1])
            {
                t=data[j];
                data[j]=data[j+1];
                data[j+1]=t;
            }
        }
    }
    for(i=0;i<3;i++)
    {
        printf("%d\n",data[i]);
    }
 
    return 0;
}

Measured memory_bytes: 600
N,T=map(int,input().split())
c=[list(map(int,input().split())) for i in range(N)]
ans=10**4
for i in range(N):
  if c[i][1]<=T:
    ans=min(ans,c[i][0])
if ans==10**4:
  ans='TLE'
print(ans)

Measured memory_bytes: 9188
#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <set>
#include <cstring>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <map>
#include <numeric>
#define bogo_sort std::sort
#define bozo_sort std::stable_sort
#define alles(obj) obj.begin(), obj.end()
#define elif else if
#define unless(flg) if(!(flg))
#define elless(flg) else if(!(flg))
#define echo std::cout <<
#define read std::cin >>
#define endl std::endl
#define fin << '\n'
#define bash push_back
#define makePair std::make_pair
#define _ << ' ' <<
// type-define
#define Stack std::stack
#define Queue std::queue
#define Set std::set
#define PQueue std::priority_queue
#define Vector std::vector
#define Pair std::pair
#define Map std::map
#define Greater std::greater
using String = std::string;
using llong = long long;
using boolean = bool;
using Pii = Pair<int, int>;
using Vi = Vector<int>;
using Vii = Vector<Pii>;
// utils
constexpr int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
constexpr int dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
constexpr int INF = 0x3f3f3f3f;
constexpr llong LINF = 0x3f3f3f3f3f3f3f3fLL;

namespace {
    llong power ( llong x, llong n, llong mod ) {
        llong ans = 1;
        while ( n > 0 ) {
            if ( n & 1 ) ans = ( ans * x ) % mod;
            x = ( x * x ) % mod;
            n >>= 1;
        }
        return ans;
    }
    llong power ( llong x, llong n ) { return power( x, n, 1000000007 ); }
    llong gcd ( llong x, llong y ) { return x % y ? gcd( y, x % y ) : y; }
    llong lcm ( llong x, llong y ) { return ( x / gcd(x, y) * y ); }
    boolean isMovable ( int x, int y, int w, int h ) { 
        return ( x >= 0 && y >= 0 && x < w && y < h ); }
    llong abs ( llong n ) { return n < 0 ? -n : n; }
}

#define int long long

namespace Rlyeh {

    int dp[1001000];
    int h[1001000];

    signed call_of_Cthulhu( signed datum ) {

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

        echo dp[n-1] fin;

        return 0;
    }
}

signed main(){std::cin.tie(0); std::ios::sync_with_stdio(false); int main_result = Rlyeh::call_of_Cthulhu(114514); return 0;}


Measured memory_bytes: 5120
#include <bits/stdc++.h>
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end() 
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define INF 1000000000
using namespace std;
typedef long long ll;

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

    if(S[K-1] == 'A') S[K-1] = 'a';
    if(S[K-1] == 'B') S[K-1] = 'b';
    if(S[K-1] == 'C') S[K-1] = 'c';

    cout << S << endl;
}

Measured memory_bytes: 3644
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.Queue;

public class Main {

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

  public void run() {

    try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {

      int n = Integer.parseInt(br.readLine());
      Graph graph = new Graph(n);
      int[] ajacent;
      String[] vInfo;
      int id,degree;

      for(int i=0; i<n; i++) {
        vInfo  = br.readLine().split(" ");
        id     = Integer.parseInt(vInfo[0]);
        degree = Integer.parseInt(vInfo[1]);
        ajacent = new int[degree];
        for(int j=0; j<degree; j++) {
          ajacent[j] = graph.convIdToIndex( Integer.parseInt(vInfo[j+2]) );
        }
        graph.setVertex(id, ajacent);
      }

      graph.vertexSearch();

      graph.dispReport();
    }
    catch (IOException e) {
      System.err.println(e);
    }
  }

  class Graph {

    Vertex[] vertices;
    Queue<Vertex> queue;
    int time;

    public Graph(int size ) {
      vertices  = new Vertex[size];
      queue = new ArrayDeque<>(size);
      time = 0;
    }

    public void setVertex(int id) {
      vertices[convIdToIndex(id)] = new Vertex(id);
    }
    public void setVertex(int id, int[] ajacent) {
      setVertex(id);
      setAjacent(id, ajacent);
    }
    public void setAjacent(int id, int[] ajacent) {
      vertices[convIdToIndex(id)].ajacent = ajacent;
    }
    public void vertexSearch() {
      breadthFirstSearch(0);
    }
    public void dispReport() {
      StringBuilder buf = new StringBuilder();

      for (Vertex v : vertices) {
          buf.append(v.id).append(" ")
             .append(v.distance).append("\n");
      }

      System.out.print(buf);
    }
    public int convIdToIndex(int id) {
      return id-1;
    }

    private void breadthFirstSearch(int index) {
      vertices[index].state = Vertex.GRAY;
      vertices[index].distance = 0;
      queue.offer(vertices[index]);

      Vertex v;
      while(queue.peek() != null) {
        v = queue.poll();
        for (int ajcIndex : v.ajacent) {
          if(vertices[ajcIndex].state == Vertex.WHITE) {
            vertices[ajcIndex].state = Vertex.GRAY;
            vertices[ajcIndex].distance = v.distance + 1;
            queue.offer(vertices[ajcIndex]);
          }
        }
        v.state = Vertex.BLACK;
      }
    }

    class Vertex {

      static final int WHITE = 0;
      static final int GRAY  = 1;
      static final int BLACK = 2;
      int id;
      int index;
      int state;
      int[] ajacent;
      int findTime;
      int doneTime;
      int distance;

      public Vertex(int id) {
        this.id = id;
        index = id-1;
        state = WHITE;
        distance = -1;
      }
    }
  }
}


Measured memory_bytes: 24588
#include<iostream>
#include<cstdio>

using namespace std;

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

long long nck[60][60];

int main() {
  rep (i, 60) nck[i][i] = 1;
  rep (i, 60) nck[i][0] = 1;
  rep (i, 55) rep (j, i) nck[i + 1][j + 1] = nck[i][j] + nck[i][j + 1];
  int n, m;
  double l;
  cin >> n >> m >> l;
  double p[n], t[n], v[n];
  rep (i, n) cin >> p[i] >> t[i] >> v[i];
  rep (i, n) p[i] /= 100;
  double tt[n][m + 1];
  rep (i, n) rep (j, m + 1) tt[i][j] = l / v[i] + t[i] * j;
  double pp[n][m + 1];
  rep (i, n) rep (j, m + 1) {
    pp[i][j] = nck[m][j];
    rep (k, j) pp[i][j] *= p[i];
    rep (k, m - j) pp[i][j] *= 1 - p[i];
  }
  rep (i, n) {
    double res = 0;
    rep (j, m + 1) {
      double r = pp[i][j];
      rep (ii, n) if (i != ii) {
	double rr = 0;
	rep (jj, m + 1) if (tt[i][j] < tt[ii][jj] - 1e-8) rr += pp[ii][jj];
	r *= rr;
      }
      res += r;
    }
    printf("%.12lf\n", res);
  }
}

Measured memory_bytes: 1348
#include <stdio.h>

int main(void){

	int N;
	int a[100000];

	scanf("%d", &N);

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

	int X = 1;
	int count = 0;

	while(X != 2){				
		count++;
		X = a[X];

		if(count >= N){
			printf("-1\n");
			return 0;
	
		}
		
	}

	printf("%d\n", count);

	return 0;

}

Measured memory_bytes: 512
a=[]
for _ in range(3): a.append(list(map(int,input().split())))
n=int(input())
for _ in range(n):
    b=int(input())
    for i in range(3):
        for j,val in enumerate(a[i]):
            if val==b: a[i][j]=0

for i in range(3):
    if a[i]==[0,0,0]:
        print("Yes")
        exit()
    if a[0][i]==0 and a[1][i]==0 and a[2][i]==0:
        print("Yes")
        exit()
if a[0][0]==0 and a[1][1]==0 and a[2][2]==0:
    print("Yes")
    exit()
if a[0][2]==0 and a[1][1]==0 and a[2][0]==0:
    print("Yes")
    exit()
print("No")

Measured memory_bytes: 9252
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define FOR(i, a, b) for(int i = (int)a; i <= (int)b; i++)
#define DEC(i, a, b) for(int i = (int)a; i >= (int)b; i--)
typedef pair<int, int> pi;
typedef pair<pi, int> pii;
typedef pair<pi, pi> pipi;
#define f first
#define s second
typedef vector<int> vi;
typedef vector<pi> vpi;
typedef vector<pii> vpii;
#define pb push_back
#define pf push_front
#define all(v) v.begin(), v.end()
#define disc(v) sort(all(v)); v.resize(unique(all(v)) - v.begin());
#define INF (int) 1e9 + 100
#define LLINF (ll) 1e18
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define sandybridge __attribute__((optimize("Ofast"), target("arch=sandybridge")))
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());    //can be used by calling rng() or shuffle(A, A+n, rng)
inline ll rand(ll x, ll y) { ++y; return (rng() % (y-x)) + x; } //inclusivesss

int n, a[105], b[105];

int main() {
	fastio; cin >> n;
	FOR(i, 1, n) cin >> a[i] >> b[i];
	FOR(i, 1, n-2) {
		if (a[i] == b[i] and a[i+1] == b[i+1] and a[i+2] == b[i+2]) {
			cout << "Yes";
			return 0;
		}
	}
	cout << "No";
}


Measured memory_bytes: 3656
#include<bits/stdc++.h>
#define ll long long
#define cri const register int
#define re register
using namespace std;
const int mod=1e9+7;
vector<int>to[5003];
int dp[5003][5003],f[5003],sz[5003],F[5003];
void dfs(cri x,cri ff){
	dp[x][1]=1;sz[x]=1;
	for(int y:to[x]) if(y!=ff){
		dfs(y,x);
		for(int i=0;i<=sz[x]+sz[y];i++) F[i]=0;
		for(int i=0;i<=sz[x];i++)
			for(int j=0;j<=sz[y];j++) F[i+j]=(F[i+j]+1ll*dp[x][i]*dp[y][j])%mod;
		sz[x]+=sz[y];
		for(int i=0;i<=sz[x];i++) dp[x][i]=F[i];
	}
	for(int i=2;i<=sz[x];i+=2) dp[x][0]=(dp[x][0]-1ll*dp[x][i]*f[i]%mod+mod)%mod;
}
int main(){
	int n;cin>>n;f[0]=1;
	for(int i=2;i<=n;i+=2) f[i]=1ll*f[i-2]*(i-1)%mod;
	for(int i=1,x,y;i<n;i++){
		scanf("%d%d",&x,&y);
		to[x].push_back(y);to[y].push_back(x);
	}
	dfs(1,0);
	cout<<(mod-dp[1][0])%mod<<endl;
}

Measured memory_bytes: 58588
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    from collections import Counter

    n = int(readline())
    a = list(map(int, readline().split()))
    counter = Counter(a)
    ok = True

    if n % 2 == 1:
        if counter[0] != 1:
            ok = False

        for i in range(2, n, 2):
            if counter[i] != 2:
                ok = False
    else:
        for i in range(1, n, 2):
            if counter[i] != 2:
                ok = False

    if ok:
        print(pow(2, n // 2, MOD))
    else:
        print(0)


if __name__ == '__main__':
    main()


Measured memory_bytes: 93580
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main()
{
    int a,b,x;
    while(~scanf("%d %d %d",&a,&b,&x))
    {
        if(a<x)
        {
            if((x-a)<b)
                printf("YES\n");
            else
                printf("NO\n");
        }
        else if(a>x)
            printf("NO\n");
        else if(a=x)
           printf("YES\n");

    }
    return 0;
}




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

#define M_PI       3.14159265358979323846

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }
inline int readInt() { int x; scanf("%d", &x); return x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;


//container util

//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SQ(a) ((a)*(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

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


struct Edge {
    int to, from;
    ll cost;
    Edge(int from, int to, ll cost): from(from), to(to), cost(cost) {}
};


typedef vector<vector<Edge>> AdjList;
AdjList graph;

vector<Edge> es;
int d[2510];
int main() {
    //cin.tie(0);
    //ios::sync_with_stdio(false);
    //cout << fixed << setprecision(10);

    int N, M, P; cin >> N >> M >> P;

    REP(i, M){
        int A, B, C; cin >> A >> B >> C;
        A--;
        B--;
        es.push_back(Edge(A, B, -C));
    }

    REP(i, N) d[i] = INT_MAX;

    d[0] = 0;
    for(int i=0; i<N-1; ++i){
        for(int j=0; j<M; ++j){
            Edge e = es[j];
            if(d[e.from] != INT_MAX && d[e.to] > d[e.from] + e.cost + P){
                d[e.to] = d[e.from] + e.cost + P;
            }
        }
    }

    bool negative[2510];
    ll ans = -d[N-1];
    REP(i, N) negative[i] = false;

    for(int i=0; i<N; ++i){
        for(int j=0; j<M; ++j){
            Edge e = es[j];
            if(d[e.from] != INT_MAX && d[e.to] > d[e.from] + e.cost + P){
                d[e.to] = d[e.from] + e.cost + P;
                negative[e.to] = true;
            }

            if(negative[e.from])
                negative[e.to] = true;
        }
    }
    if(negative[N-1]) cout << -1 << endl;
    else cout << max(0LL,ans) << endl;
    return 0;

}

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

int main(){
    int a,b;
    cin >> a >> b;
    int s = b-a;
    int t = 0;
    rep(i,s+1){
      t += i;
    }
    cout << t-b << endl;
}

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

public class Main {

	public static final int BIG_NUM  = 2000000000;
	public static final int MOD  = 1000000007;

	public static void main(String[] args) {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		try {
			int N = Integer.parseInt(br.readLine());

			int x;

			for(int i = 1; i <= N; i++)
			{
				if(i%3 == 0){
					System.out.printf(" %d",i);
				}else{
					x = i;
					do{
						if(x%10 == 3){
							System.out.printf(" %d",i);
							break;
						}
						x /=10;
					}while(x != 0);
				}
			}
			System.out.printf("\n");

		} catch (NumberFormatException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}





Measured memory_bytes: 39128
n = int(input())
l = [list(map(int, input().split())) for i in range(n)]
check = True
for i in range(len(l)):
    if not((l[i][0] >= l[i][1] + l[i][2]) and (l[i][0] % 2 == ((l[i][1] + l[i][2]) % 2))):
        check = False
if check:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 27428
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>

#define FOR(x,to) for(x=0;x<(to);x++)

using namespace std;

int main(){
	int i,k;
	int N;
	int A[202020];
	int B[202020];
	int b[202020];
	int ans=0;

	cin>>N;
	FOR(i,N) cin>>A[i];
	FOR(i,N) cin>>B[i];

	for(k=0;k<29;k++){
		int T=1<<k;
		FOR(i,N) b[i]=B[i]%(2*T);
		sort(b, b+N);

		int t_sum=0;
		FOR(i,N){
			int aa = A[i] % (T*2);
			int T1=lower_bound(b,b+N,T-aa)-b;
			int T2=lower_bound(b,b+N,2*T-aa)-b;
			int T3=lower_bound(b,b+N,3*T-aa)-b;
			t_sum+=(T2-T1)+(N-T3);
		}
		
		if (t_sum%2!=0)	ans+=T;
	}
	cout<< ans <<endl;
}



Measured memory_bytes: 2560
program main

  implicit none

  integer :: a, b
  integer :: tmp, i
  
  read(*,*) a, b
  
  tmp = 0 

  do i = 1, 1250 
    if( int( i*0.08 ) == a .and. int( i*0.1 ) == b ) then
      tmp = i
      exit
    else
    end if
  end do
  
  if( tmp == 0 ) then
    print*, "-1"
  else
    print*, tmp
  end if
  
  
end program main


Measured memory_bytes: 256
#[int(i) for i in input().split()]
P = 1000000007
n = int(input())
a = [int(i) for i in input().split()]
pref = [0]*n
pref[n-1] = a[n-1]
for i in range(n-2,-1,-1):
	pref[i] = pref[i+1]+a[i]

ans = 0
for i in range(n-1):
	ans = (ans + (a[i] * pref[i+1]) % P)%P
print(ans)


Measured memory_bytes: 31560
#include<cstdio>
#include<queue>
#include<utility>
#include<cstring>
#include<stack>
#include<algorithm>
#include<cmath>
#include<iostream>
#include<map>
#define MAX_N 100001
#define INF_INT 2147483647
#define INF_LL 9223372036854775807
#define REP(i,n) for(int i=0;i<(int)(n);i++)
int dx[4] = {1,0,0,-1};
int dy[4] = {0,1,-1,0};
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;
bool cmp_P(const P &a,const P &b){
  return a.second < b.second;
}
int main()
{
  int N,l=0,r=0;
  cin  >> N;
  vector<int> a(N);
  vector<int> b(N);
  REP(i,N)cin >> a[i];
  r=N-1;
  if(N % 2){
  for(int i=N-1;i>=0;i--){
    if(i % 2 == 0){
      b[l] = a[i];
      l++;;
    }else{
      b[r] = a[i];
      r--;
    }
  }
  }else{
    for(int i=N-1;i>=0;i--){
    if(i % 2 == 1){
      b[l] = a[i];
      l++;;
    }else{
      b[r] = a[i];
      r--;
    }
  }
  }
  REP(i,N)cout << b[i] << " ";
  cout << endl;
    return 0;
}



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

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

    for (int i = 1; i <= 1000; i++)
    {
        int x = 0.08 * i, y = 0.1 * i;
        if ((x == a) && (y == b))
        {
            cout << i << endl;
            return 0;
        }
    }

    cout << -1 << endl;
}

Measured memory_bytes: 3628
#include <stdio.h>
int main(void)
{
    int a, b, c, x;
    scanf("%d %d %d", &a, &b, &c);
    if (a > b)
    {
        x = a;
        a = b;
        b = x;
    }
    if (a > c)
    {
        x = a;
        a = c;
        c = x;
    }
    if (b > c)
    {
        x = b;
        b = c;
        c = x;
    }
        printf("%d %d %d\n", a, b, c);
    return 0;
}


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

using namespace std;
typedef long long  ll;
#define rep(i,s,n)for(int i = s;i<n;i++)

int main()
{
	int N; cin >> N;
	int d[101];
	int s[101];

	rep(i, 0, 101) {
		s[i] = 0;
	}
	rep(i, 0, N) {
		cin >> d[i];
		s[d[i]]++;
	}
	int count = 0;
	rep(i, 0, 101) {
		if (s[i] != 0) {
			count++;
		}
	}
	cout << count << endl;

	return 0;
}

Measured memory_bytes: 256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <complex>

#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

#include <stdexcept>

using namespace std;

// type alias
using ll = long long;
using ull = unsigned long long;
using comp = complex<double>;

const ll MOD = 1000000007LL;
const double PI = 3.14159265358979323846;

//conversion
//------------------------------------------
inline int toint(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class t> inline string tostring(t x) { ostringstream sout; sout << x; return sout.str(); }

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

//debug
#define DUMP(x)  cerr << #x << " = " << (x) << endl
#define DEBUG(x) cerr << #x << " = " << (x) << " (l" << __line__ << ")" << " " << __file__ << endl

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

	bool exist = true;
	if (Y % 2 != 0) {
		exist = false;
	}
	if (X * 2 > Y) {
		exist = false;
	}
	if (Y > X * 4) {
		exist = false;
	}

	cout << (exist ? "Yes" : "No") << endl;

	return 0;
}

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

	solve();

	return 0;
}


Measured memory_bytes: 3604
#include <stdio.h>

int main(void)
{
	int a, b, c, d, p;
	int x, y;
	int sa;
	
	scanf("%d %d %d %d %d", &a, &b, &c, &d, &p);
	
	if (p > c) {
		sa = p - c;
		y = sa * d;
	}
	x = a * p;
	y += b;
	
	if (x < y){
		printf("%d\n", x);
	}
	else {
		printf("%d\n", y);
	}
	return (0);
}


Measured memory_bytes: 2100