akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <string.h>

int main(){
    int n, i, j = 0, point1 = 0, point2 = 0;
    char str1[100], str2[100];
    
    scanf("%d", &n);
    for (i = 0; i < n; i++){
        scanf("%s %s", str1, str2);
        if (strcmp(str1, str2) == 0) {point1++; point2++;}
        if (strcmp(str1, str2) > 0) point1 += 3;
        if (strcmp(str1, str2) < 0) point2 += 3;
    }
    printf("%d %d\n", point1, point2);
    
    return 0;
}

Measured memory_bytes: 604
#include<iostream>
#include<cmath>
#include <iomanip>
int main(){
    int A,B,H,M;
    int hourAng,minAng;
    std::cin>>A>>B>>H>>M;
    hourAng=30*H;
    minAng=6*M;
    const double pi = 3.141592653589793;
    double hourAngRad,minAngRad;
    double hourX,hourY,minX,minY;
    minAngRad=minAng*pi/180.0;
    hourAngRad=hourAng*pi/180.0+minAngRad/12.0;
    hourX=A*cos(hourAngRad);
    hourY=A*sin(hourAngRad);
    minX=B*cos(minAngRad);
    minY=B*sin(minAngRad);
    double dx,dy;
    dx=hourX-minX;
    dy=hourY-minY;
    // std::cout<<hourAng<<","<<minAng<<std::endl;
    // std::cout<<hourX<<","<<hourY<<":"<<minX<<","<<minY<<std::endl;
    std::cout<<std::fixed << std::setprecision(15);
    std::cout<<sqrt(dx*dx+dy*dy)<<std::endl;
}

Measured memory_bytes: 4168
import java.io.*;
import java.math.BigDecimal;
import java.math.BigInteger;

public class Main {
    static Input in = new Input(System.in);
    static PrintWriter out = new PrintWriter(System.out);

    public static void main(String[] args) throws IOException {
        int N = in.nextInt();
        if (N % 10 == 7) {
            out.println("Yes");
        } else if ((N / 10) % 10 == 7) {
            out.println("Yes");
        } else if ((N / 100) % 10 == 7) {
            out.println("Yes");
        } else {
            out.println("No");
        }

        out.flush();
    }
}

class Input {
    private BufferedReader br;
    private String[] buff;
    private int index = 0;

    Input(InputStream is) {
        br = new BufferedReader(new InputStreamReader(is));
    }
    String nextLine() {
        try {
            return br.readLine();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return null;
    }
    String next() {
        while (buff == null || index >= buff.length) {
            buff = nextLine().split(" ");
            index = 0;
        }
        return buff[index++];
    }
    byte nextByte() {
        return Byte.parseByte(next());
    }
    short nextShort() {
        return Short.parseShort(next());
    }
    int nextInt() {
        return Integer.parseInt(next());
    }
    long nextLong() {
        return Long.parseLong(next());
    }
    float nextFloat() {
        return Float.parseFloat(next());
    }
    double nextDouble() {
        return Double.parseDouble(next());
    }
    BigInteger nextBigInteger() {
        return new BigInteger(next());
    }
    BigDecimal nextBigDecimal() {
        return new BigDecimal(next());
    }
}

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

int main() {
  	int ans = 0;
  	string s;
  	string a[7] = {"SUN","MON","TUE","WED","THU","FRI","SAT"};
  	cin >> s;
  	for(int i=0; i<7 ;i++) {
      if(s==a[i]) {
        cout << 7-i << endl;
      }
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
    using namespace std;
 
int GCD(int a, int b) {
    if (b == 0) return a;
    else return GCD(b, a % b);
}

bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}
 
    int main(){
      int n,k;
      cin >> n >> k;
      cout << max(n*k,max(n+k,n-k));
      return 0;}

Measured memory_bytes: 256
import java.util.Scanner;

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

        for (int i = 1; i <= 16; i++) {
            if (i%2 == 0) {
                a--;
            } else {
                b--;
            }
        }

        if (a <= 0 && b <= 0) {
            System.out.println("Yay!");
        } else {
            System.out.println(":(");
        }
    }
}


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

int main(){
    int n,m;
    cin >> n;
    vector<string> s(n);
    for (int i=0;i<n;i++) cin >> s.at(i);
    cin >> m;
    vector<string> t(m);
    for (int j=0;j<m;j++) cin >> t.at(j);

    string stopword;
    vector<int> counts;
    for (int i=0;i<n;i++) {
        stopword = s.at(i);
        int count=0;
        for (int j=0;j<n;j++) {
            if (s.at(j) == stopword) count++;
        }
        for (int j=0;j<m;j++) {
            if (t.at(j) == stopword) count--;        
        }
        counts.push_back(count);
    } 
    
    for (int i=0;i<m;i++) {
        stopword = t.at(i);
        int count=0;
        for (int j=0;j<n;j++) {
            if (s.at(j) == stopword) count++;
        }
        for (int j=0;j<m;j++) {
            if (t.at(j) == stopword) count--;        
        }
        counts.push_back(count);
    } 
    sort(counts.begin(),counts.end());
    int result = counts.at(counts.size()-1);
    if (result <0) result = 0;
    cout << result<< endl;
}

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

int main(){
  int n,x; cin >> n;

  for(int i = 1; i <= n; i++){
    if(i % 3 == 0) cout << " " << i;
    else{
      x = i;
      while(x){
        if(x % 10 == 3){
          cout << " " << i;
          break;
        }
        x /= 10;
      }
    }
  }

  cout << endl;

  return 0;
}


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

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

int main() {
    int n; cin >> n;
    vector<int> mlt_cnt(n+1, 0);
    for(int i = 1; i <= n; ++i)
        for(int j = 1; i*j <= n; ++j)
            mlt_cnt[i*j]++;
    for(int i = 1; i < n; ++i) 
        mlt_cnt[i+1] += mlt_cnt[i];
    cout << mlt_cnt[n-1] << endl;
    return 0;
}

Measured memory_bytes: 7144
#include<iostream>
#include<vector>
#define NUM 102
using namespace std;

int main() {
	int n, m, x;
	cin >> n >> m >> x;
	int a[NUM] = { 0 };
	for (int i = 1;i <= m;i++) {
		int temp;
		cin >> temp;
		a[temp]++;
	}
	
	int suma = 0, sumb = 0;
	for (int i = x;i <= n - 1;i++) {
		suma += a[i];
	}
	for (int i = x;i >=0 ;i--) {
		sumb += a[i];
	}

	if (suma > sumb) 
		cout << sumb << endl;
	else 
		cout << suma << endl;

	return 0;
}


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

int gcd(int x, int y){
    if (y == 0)
        return x;
    x = x % y;
    gcd(y, x);
}

main(){
    string s;
    cin>>s;
    int count=0;
    int n=s.length();
    rep(i,n){
        if(s[i]!=s[n-i-1]) count++;
    }
    count/=2;
    cout<<count<<endl;
}

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


//c++ templte for help............................................................................................................................................
typedef long long ll;

//template<typename... T>
//void print1(T... t){
	//((cout<<t<<" "),...);
//}

//template<typename... T>
//void print2(T... t){
		//vector<vector<ll>> ans={t...};
		//for(ll i=0;i<(ll)ans.size();i++){
			//if(i!=0) cout<<"\t\t";
			//else cout<<"\t";
			//for(ll j=0;j<(ll)ans[i].size();j++){
				//cout<<ans[i][j]<<" ";
			//}
			//if(i!=(ll)ans.size()-1)
			//cout<<endl;
		//}
//}	
//#define deb(...) cout<<" [ "#__VA_ARGS__<<" : "; print1(__VA_ARGS__); cout<<"]"<<endl; 
//#define vdeb(...) cout<<" [ "#__VA_ARGS__<<" : "; print2(__VA_ARGS__); cout<<"]"<<endl;





	
 
//for loop
//#define fo(i,n) for(int i=0;i<(ll)n;i++)
//#define Fo(i,k,n) for(int i=k;i<n;i++)
 
 
//to print vector element 
//template<typename T>
//void printV(T vec){
	//fo(i,vec.size()) cout<<vec[i]<<" "<<flush;
	//cout<<endl;
	//}
	
 
//#define modulo 1000000007
//const int INF=1e9+5;
 
//iterate map
//template<typename T>
//void itR(T map){
	 //for(auto itr=map.begin();itr!=map.end();itr++){
				//deb(itr->first,itr->second);
			//}
	//cout<<endl;
//}
 
 
 
//c++ template for help...........................................................................................................................................


string solve(){
	ll x,y;
	cin>>x>>y;
	
	if((y-(2*x))%2==0 and y-(2*x)>=0 and ((4*x)-y)%2==0 and (4*x)-y>=0) return "Yes";
	return "No"; 
}

int main() {
	//stringstream ss;
	//ss<<"akhil";
	//cout<<ss.str()<<endl;
	cout<<setprecision(50);
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	
	 // TESTCASE KO DEKH KA BHAUT SARA CONDITION GENERATE MAT KRO 
	 // PAPER PD CONFIRM HO JAO THORA JADA TIME HI KYU NA LGA
	 // greedy ma jadatr exceptional case check kr ke dekh lo
	 
	 // WHILE DOING THE QUESTION OF DYNAMIC PROGRAMMING GREEDY KA TRAH SOCHNA BAND KRO
	 // DP M DATA KA BHI USE KRNA PDTA HA BE BHULO MT 
	 // DP BHI WO LEETCODE WALE MATRIX KA QUESTION KI TARAH HA
	 // CONSTRAIN WILL BE THE DIMENSION OF DP
	 // DP MA STATE PTA KRO AUR PHIR FUNCTION GENERATE KRO
	 // OBJECT KO CHOOSE KIA YA NAE KIA AGAR KIA TO KYA HOGA AUR NAE KIA TO KYA HOGA
	 // KYA KYA CHEJ IMPORTANT HA WO STATE BN JAGA AUR HUM LOG STATE KO CHANGE KR SKTA HA JYSA KNPSACK 2 WALE PROBLEM MA KIA THA
	 

	 
	//ll testCase;
	//cin>>testCase;
	//for(ll tt=0;tt<testCase;tt++){
		//solve();
		string ans=solve();
		cout<<ans<<endl;
	//}
	return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define INF 10000
using namespace std;

int main(){
  int N; cin>>N;
  for (int i =0; i<N; i++) {
    string s1,s2; cin >> s1 >> s2;
    int s1N = s1.size();
    int s2N = s2.size();
    int dp[s1N+1][s2N+1];
    
    for(int j=0; j<=s1N; j++) dp[j][0] =0;
    for(int k=0; k<=s2N; k++) dp[0][k] =0;
  
    for(int j=1; j<=s1N; j++){
      for(int k=1; k<=s2N; k++){ 
        if(s1[j-1] == s2[k-1]) {
          dp[j][k] = dp[j-1][k-1] +1;
        } else {
          dp[j][k] = max(dp[j][k-1], dp[j-1][k]);
        }
      }
    }
    cout << dp[s1N][s2N] <<endl; 
  }
}


Measured memory_bytes: 7116
// AOJ 2300: Calender Colors
// 2017.10.7 bal4u@uu

#include <stdio.h>
//#include <string.h>

double l[21], a[21], b[21]; int n, m;
int one, lim;
 
double calc(unsigned x)
{
	int i, j, s, t;
	double sm = 0;

	if (one) {
		for (s = 0, i = 1; i < lim; i <<= 1, s++) {
			if (x & i) for (t = s+1, j = i << 1; j < lim; j <<= 1, t++) {
				if (x & j) {
					sm += (l[s]-l[t])*(l[s]-l[t]) + (a[s]-a[t])*(a[s]-a[t])
						+ (b[s]-b[t])*(b[s]-b[t]);
				}
			}
		}
	} else {
		for (s = 0, i = 1; i < lim; i <<= 1, s++) {
			if (!(x & i)) for (t = s+1, j = i << 1; j < lim; j <<= 1, t++) {
				if (!(x & j)) {
					sm += (l[s]-l[t])*(l[s]-l[t]) + (a[s]-a[t])*(a[s]-a[t])
						+ (b[s]-b[t])*(b[s]-b[t]);
				}
			}
		}
	}
	return sm;
}

unsigned next(unsigned x)
{
	unsigned min, rip, new, one;

	min = x & -x;
	rip = x + min;
	new = rip & -rip;
	one = ((new / min) >> 1) - 1;
	return rip | one;
}

int main()  
{  
	int i;
	unsigned x, x0;
	double s, ans;

	scanf("%d%d", &n, &m);
	if (m == 0) { puts("0.00000000000000000000"); return 0; }
	for (i = 0; i < n; i++) scanf("%lf%lf%lf", l+i, a+i, b+i);
	lim = 1 << n, one = 1;
	if (m < n && m > n/2) m = n - m, one = 0;

	ans = 0;
	x = (1U << m) - 1U;
	x0 = ~((1U << n) - 1U);
	while (!(x & x0)) {
		if ((s = calc(x)) > ans) ans = s;
		x = next(x);
	}
	printf("%.20lf\n", ans);
	return 0;
}

Measured memory_bytes: 1828
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <cstdint>
#include <numeric>
#include <bitset>
#include <functional>

using namespace std;

using ll =  long long;
using Pll = pair<ll, ll>;
using Pii = pair<int, int>;

constexpr ll MOD = 1000000007;
constexpr long double EPS = 1e-10;
constexpr int dyx[4][2] = {
    { 0, 1}, {-1, 0}, {0,-1}, {1, 0}
};

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

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

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    ll a, b;
    cin >> a >> b;
    cout << lcm(a, b) << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cmath>
#include<climits>
#include<numeric>
using namespace std;

template<typename T>
void mymin(T& a, T b)
{
    if(a > b) a = b;
}

int main()
{
    int N, W; cin >> N >> W;
    vector<int> w(N, 0); vector<int> v(N, 0);
    for(int i = 0; i < N; i++) cin >> w.at(i) >> v.at(i);
    int Vmax = accumulate(v.begin(), v.end(), 0);
    vector< vector<long long> >dp(N+1, vector<long long>(Vmax+1, INT_MAX));
    dp.at(0).at(0) = 0;
    for(int i = 0; i < N; i++)
    {
        for(int sum_v= 0; sum_v <= Vmax; sum_v++)
        {
            dp.at(i+1).at(sum_v) = dp.at(i).at(sum_v);
            if(sum_v - v.at(i) >= 0)
            {
                mymin(dp.at(i+1).at(sum_v), dp.at(i).at(sum_v - v.at(i)) + w.at(i));
            }
        }
    }
    long long ans = 0;
    for(int i = 0; i <= Vmax; i++)
    {
        if(dp.at(N).at(i) <= W)
        {
            ans = i;
        }
    }
    cout << ans << endl;
}


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

using namespace std;

int main() {
  int d, n;
  scanf("%d %d", &d, &n);
  if (n == 100) {
    switch (d) {
    case (0):
      printf("101\n");
      break;
    case (1):
      printf("10100\n");
      break;
    case (2):
      printf("1010000\n");
    }
  } else {
    switch (d) {
    case (0):
      printf("%d\n", n);
      break;
    case (1):
      printf("%d00\n", n);
      break;
    case (2):
      printf("%d0000\n", n);
  }
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin() , v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)


int main(){
    int a, b, c, x, y; cin >> a >> b >> c >> x >> y;
    c = min(a + b, c * 2), a = min(a, c), b = min(b, c);
    int r = min(x, y);
    cout << (x - r) * a + (y - r) * b + r * c << endl;
}

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

Measured memory_bytes: 3064
package main

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

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)

	size := scanInt(sc)

	wants := make([]int, size+1)
	for i := 1; i <= size; i++ {
		wants[i] = scanInt(sc)
	}

	boxes := make([]int, size+1)
	for i := size; i > size/2; i-- {
		boxes[i] = wants[i]
	}

	for i := size / 2; i >= 1; i-- {
		max := i * (size / i)
		sum := 0
		for m := max; m > i; m -= i {
			// bit = (bit + boxes[m]) % 2
			sum += boxes[m]
		}

		parity := sum % 2
		if parity == wants[i] {
			boxes[i] = 0
		} else {
			boxes[i] = 1
		}
	}

	balls := make([]int, 0)
	for i, box := range boxes {
		if box == 1 {
			balls = append(balls, i)
		}
	}

	w := bufio.NewWriter(os.Stdout)
	fmt.Fprintln(w, len(balls))
	for _, idx := range balls {
		fmt.Fprintln(w, idx)
	}
	w.Flush()
}

func scanInt(sc *bufio.Scanner) int {
	sc.Scan()
	v, _ := strconv.Atoi(sc.Text())
	return v
}


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

using namespace std;

typedef unsigned int ui;
typedef long long ll;
typedef unsigned long long ull;

constexpr int MAXN = 200000;

pair<int, int> X[MAXN + 2];
int ans[MAXN + 2];

int main() {
	int N;
	cin >> N;
	for(int i = 0; i < N; i++) {
		cin >> X[i].first;
		X[i].second = i;
	}
	sort(X, X + N);
	for(int i = 0; i < N / 2; i++)
		ans[X[i].second] = X[N / 2].first;
	for(int i = N / 2; i < N; i++)
		ans[X[i].second] = X[N / 2 - 1].first;
	for(int i = 0; i < N; i++)
		cout << ans[i] << '\n';
}


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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
#define LINF 1e18
typedef long long ll;


int main() {
    int P,Q,R; cin >> P >> Q >> R;
    cout << P+Q+R-max({P,Q,R}) << endl;
    return 0;
}

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

int main() {
  int A, B, d;
  cin >> A >> B >> d;
  int cnt = 0;
  for(int i = A; i <= B; i++) {
    if(i%d==0) {
      cnt++;
    }
  }
  cout << cnt << endl;
}


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

using namespace std;

const long long inf = (long long) 1e10;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  long long mx1 = -inf;
  long long mx2 = -inf;
  long long mx3 = -inf;
  long long mx4 = -inf;
  for (int i = 0; i < n; i++) {
    long long x, y;
    cin >> x >> y;
    mx1 = max(mx1, + x + y);
    mx2 = max(mx2, + x - y);
    mx3 = max(mx3, - x + y);
    mx4 = max(mx4, - x - y);
  }
  cout << max(mx1 + mx4, mx2 + mx3) << endl;
  return 0;
}


Measured memory_bytes: 3648
import java.util.Scanner;

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

    private void run() {
        Scanner scanner = new Scanner(System.in);
        String T = scanner.next();
        T = T.replace("?", "D");
//        int sum = T.split("D", -1).length-1;
//        sum += T.split("PD", -1).length-1;


        System.out.println(T);
    }
}


Measured memory_bytes: 41008
package main

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

var sc = bufio.NewScanner(os.Stdin)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Scan()
	s := next()
	fmt.Print(strings.Count(s, "ABC"))
}


Measured memory_bytes: 640
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.StringTokenizer;

public class Main {
	// AtCoder Beginner Contest 128
	// https://atcoder.jp/contests/abc128/tasks
	final static int MOD = 10007;
	
	public static void main(String[] args) {
		FastReader sc = new FastReader();
		String s = sc.next();
		int res = 0;
		
		for (int i = 0; i < s.length(); i++) {
			if (s.charAt(i) == '1') { res++; }
		}
		
		System.out.println(res);
	}
	
	static class FastReader { 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastReader() { 
            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: 21076
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));
	
	int input = Integer.parseInt(br.readLine());
	
	int h = input/3600;
	int ms = input%3600;
	int m = ms/60;
	int s = ms%60;

	System.out.println(h + ":" + m + ":" + s);
    }
}

Measured memory_bytes: 24324
#include <iostream>
using namespace std;
int main(void){
  const int inf=1500000000;
  int n,wt,i,j,w[100],v[100],lv=0;
  long int dp[100][100005],a,b;
  cin >> n >> wt;
  for (i=0;i<n;i++){
    cin >> w[i] >> v[i];
    lv+=v[i];
  }
  for (i=0;i<n;i++){
    for (j=0;j<=lv;j++){
      dp[i][j]=inf;
    }
  }
  for (i=0;i<=v[0];i++) dp[0][i]=w[0];
  for (i=1;i<n;i++){
    for (j=0;j<=lv;j++){
      a=dp[i-1][j];
      if (j<=v[i]) dp[i][j]=(a<w[i])? a:w[i];
      else{
        b=dp[i-1][j-v[i]]+w[i];
        dp[i][j]=(a<b)? a:b;
      }
    }
  }
  for (j=lv;1;j--){
    if (dp[n-1][j]<=wt) break;
  }
  cout << j << '\n';
  return 0;
}

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

using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;

#define REPS(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) REPS(i, 0, n)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (int i = (a); i >= n; --i)
#define DEP(i, n) DEPS(i, n, 0)

#define vint(v,n) vector<int> v(n); REP(i,n) cin >> v[i];
#define vlint(v,n) vector<ll int> v(n); REP(i,n) cin >> v[i];
#define vdouble(v,n) vector<double> v(n); REP(i,n) cin >> v[i];
#define vvdoube(v,n1,n2) vector<vector<double> > v(n1, vector<double>(n2, 0)); REP(i,n1) REP(j,n1) cin >> v[i][j];
#define string(x) string x; cin >> x;
#define vstring(v,n) vector<string> v(n); REP(i,n){string a; std::cin >> a; v.push_back(a); }

#define all(v) (v).begin(), (v).end()
#define rall(v) (v).begin(), (v).end(), std::greater<int>()
#define len(v) (v).length()

static const string abet("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ");
static const long long int MOD = 1000000007;
static const double PI=3.1415926535897932;
static const int INF = 0x3f3f3f3f;
static const int INFTY = (1 << 29);
static const long long LINFTY = (1LL << 32);

static const int dy4[]={0, 0, 1, -1};
static const int dx4[]={1, -1, 0, 0};
static const int dx8[] = {1, 1, 1, 0, 0, -1, -1, -1};
static const int dy8[] = {-1, 0, 1, -1, 1, -1, 0, 1};


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

  int n, m;
  cin >> n >> m;
  vint(c, m);
  int dp[n+1];
  REP(j, n+1) dp[j]=INFTY;
  dp[0]=0;
  REP(i, m) REPS(j, c[i], n+1) dp[j] = min(dp[j], dp[j-c[i]]+1);

  cout << dp[n] << endl;
}

Measured memory_bytes: 3296
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int C = sc.nextInt();
        int X = sc.nextInt();
        int Y = sc.nextInt();

        if(X > Y){
            //Bの方が少ない時
            if(Y * B + Y * A < 2 * Y * C){
                //Y枚まで個別で買った方が安い時
                System.out.println(X * A + Y * B);
            }else{
                //Cピザの方がお得な時
                int Z = X - Y;
                if(2 * Y * C + A * Z < 2 * X * C){
                    System.out.println(2 * Y * C + A * Z);
                }else{
                    System.out.println(2 * C * X);
                }
            }
        }else if(Y > X){
            //Aの方が少ない時
            if(X * B + X * A < 2 * X * C){
                //Y枚まで個別で買った方が安い時
                System.out.println(X * A + Y * B);
            }else{
                //Cピザの方がお得な時
                int Z = Y - X;
                if(2 * X * C + B * Z < 2 * Y * C){
                    System.out.println(2 * X * C + B * Z);
                }else{
                    System.out.println(2 * C * Y);
                }
            }
        }else{
            //同枚数
            if(A * X + B * Y > 2 * C * X){
                //C買った方が安い時
                System.out.println(2 * C * X);
            }else{
                //別々の方がいい時
                System.out.println(A * X + B * Y);
            }
        }
    }
}

Measured memory_bytes: 21716
n,m,l = map(int,input().split())
tbl = [[0 for i in range(l)] for j in range(n)]
a = [list(map(int,input().split())) for _ in range(n)]
b = [list(map(int,input().split())) for _ in range(m)]
for i in range(n):
    for j in range(l):
        sum = 0
        for k in range(m):
            sum += a[i][k]*b[k][j]
        tbl[i][j] = sum
for i in range(n):
    for j in range(l):
        if j != l-1:
            print(tbl[i][j], end=' ')
        else:
            print(tbl[i][j]) 


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

using namespace std ;

int a[ 100001 ] , n , dp[ 100001 ] ;

void solve( int i )
{
    if( i <= 2 )
        return ;

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

     solve( i - 1 ) ;
     solve( i - 2 ) ;

    dp[ i ] = min( dp[ i -1 ] + abs( a[ i ] - a[ i - 1 ] ) , dp[ i -2 ] + abs( a[ i ] - a[ i - 2 ] ) ) ;

}
int main()
{
    cin >> n ;

    for( int i = 1 ; i <= n ; i++ )
    {
        cin >> a[ i ] ;
        dp[ i ] = -1 ;
    }

    dp[ 1 ] = 0 ;
    dp[ 2 ] = abs( a[ 1 ] - a[ 2 ] ) ;

    solve( n ) ;
    cout << dp[ n ] << endl ;
}


Measured memory_bytes: 7444
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(false), cin.tie(0);
#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define endl '\n'

using namespace std;

main()
{
    fast;
    int a,b,c,d,e,f;
    cin>>a>>b>>c>>d>>e>>f;
    int x1,x2,y1,y2;
    int sugar=0,total=100*a;
    int water_tp,sugar_tp;
    for (x1=0;x1<=100;x1++) for (y1=0;y1<=100;y1++) for (x2=0;x2<=100;x2++) for (y2=0;y2<=100;y2++)
    {
        water_tp=(a*x1+b*y1)*100;
        sugar_tp=x2*c+y2*d;
        if (sugar_tp+water_tp<=f)
        {
            if (sugar_tp*100<=water_tp*e)
            {
                if (sugar_tp*total>=sugar*(sugar_tp+water_tp))
                {
                    sugar=sugar_tp;
                    total=sugar_tp+water_tp;
                }
            }
        }
    }
    cout<<total<<" "<<sugar<<endl;
}

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;

public static class P
{
    public static void Main()
    {
        long res = 0;
        int n = int.Parse(Console.ReadLine());
        for (int i = 1; i <= n; i++)
        {
            for (int j = 1; j <= n; j++)
            {
                var gcd = GCD(i, j);
                for (int k = 1; k <= n; k++)
                {
                    res += GCD(gcd, k);
                }
            }
        }
        Console.WriteLine(res);
    }


    static long GCD(long a, long b)
    {
        while (true)
        {
            if (b == 0) return a;
            a %= b;
            if (a == 0) return b;
            b %= a;
        }
    }
}

Measured memory_bytes: 27560
#include<iostream>
using ll = long long;
using namespace std;
ll gcd(ll a,ll b){
  ll r=a%b;
  while(r>0){
    a=b;
    b=r;
    r=a%b;
  }
  return b;
}
ll lcm(ll a,ll b){
  return a/gcd(a,b)*b;
}
int main(){
  ll n;cin>>n;
  ll now;cin>>now;
  for(int i=1;i<n;i++){
    ll a;cin>>a;
    now=lcm(now,a);
  }
  cout<<now<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include <vector>
#include<queue>
#include<map>
#include<algorithm>
#include<iomanip>
#include<cmath>
#include<bitset>
using namespace std;
using vi = vector<int>;
using vii = vector<vi>;
using vs = vector<string>;
using pii = pair<int, int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,m,n) for(int i=m;i<n;i++)
#define vsort(v) sort(v.begin(), v.end())
#define rv(v) reverse(v.begin(), v.end())
#define ll long long
#define PI 3.141592653589793
using vll = vector<ll>;
using Graph = vii;
const ll MOD = 998244353;

int main() {
	ll n;
	cin >> n;
	vll a(n);
	vll s(n + 1);
	rep(i, n) {
		cin >> a[i];
		s[i + 1] = s[i] + a[i];
	}
	ll ans = 1e11;
	//rep(i, n + 1) cout << s[i] << endl;
	for (int i = 1; i < n; i++) {
		ll k = s[n] - 2 * s[i];
		k = max(k, -k);
		if (ans >= k) {
			ans = k;
			//cout << i << endl;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
ll ans = 0;
ll n , m , q ;
vector<vector<ll>> vv(100, vector<ll>(4,0) );

void dfs(vector<ll> v,ll mx){
  if(v.size()==n){
    ll sc=0;
    rep(i,q){
      if(v[vv[i][1]-1]-v[vv[i][0]-1]==vv[i][2])sc+=vv[i][3];
    }
    ans=max(ans,sc);
    return ;
  }
  for (ll i = mx; i <= m ; i++)
  {
    v.push_back(i);
    dfs(v,i);
    v.pop_back();
  }
}

int main()
{
cin >> n >> m >> q ;
rep(i,q){
  cin >> vv[i][0] >> vv[i][1] >> vv[i][2] >> vv[i][3] ;
}
vector<ll> h;
dfs(h,1);

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

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

const int N = 5e5, inf = 1e17;
int a[N], n, n3, ans,dp1[N], dp2[N], S, cur;
multiset <int> s;

main() {
    cin >> n; n3 = n * 3;
    for (int i = 0; i < n3; ++i) cin >> a[i];
    for (int i = 0; i < n; ++i) {
        S += a[i];
        s.insert(a[i]);
    }
    dp1[n - 1] = S;
    for (int i = n; i < n3; ++i) {
        s.insert(a[i]);
        cur = *(s.begin());
        *s.erase(s.begin());
        S += a[i] - cur;
        dp1[i] = S;
    }
    S = 0;
    for (int i = n3 - 1; i >= n3 - n; --i) {
        s.insert(-a[i]);
        S -= a[i];
    }
    dp2[n3 - n] = S;
    for (int i = n3 - n - 1; i >= 0; --i) {
        s.insert(-a[i]);
        cur = *(s.begin());
        *(s.erase(s.begin()));
        S += -a[i] - cur;
        dp2[i] = S;
    }
    ans = -inf;
    for (int i = n; i < n3 - n + 1; ++i) {
        ans = max(ans, dp1[i - 1] + dp2[i]);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 17280
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main(){
	int K,A,B;
	cin>>K>>A>>B;
	for(int i=A;i<=B;i++){
		if(i%K==0){cout<<"OK";return 0;}
	}
	cout<<"NG";
	return 0;
}

Measured memory_bytes: 3620
import std.stdio, std.string, std.conv, std.algorithm, std.array;
alias L = long;
L n, a, k, f, m;
L[] A, U, V;

void main(){
	readf("%d\n", &n);
	A = readln.split.map!(to!L).array ~ 1;
	U = A.dup, V = A.dup;
	
	m = 1;
	while(n - m > 1){
		k = (m + n) / 2;
		//writeln("k:", k);
		L* u = &U[0], v = &V[0];
		*u = *v = 0;
		foreach(a; A){
			//writeln(" a:", a);
			if(*u < a) *++u = a, *++v = 1;
			else{
				while(*(u - 1) >= a){
					//writeln(" a:", a, " u:", *u);
					while(--*u >= *(u - 1) && *v) --*v, *v /= k;
					*(v - 1) += *v;
					--u, --v;
					//writeln(" a:", a, " U:", U, " V:", V);
				}
				if(*u > a){
					while(--*u >= a && *v) --*v, *v /= k;
					*u = a, ++*v;
					//writeln(" a:", a, " U:", U, " V:", V);
				}
				++f, ++*v;
			}
			//writeln(" a:", a, " U:", U, " V:", V);
		}
		//writeln(*v > k + 1);
		--f;
		(*v > k + 1? m : n) = k;
	}
	//writeln("f:", f);
	writeln(f? n: 1);
	
}

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

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

	for (int x = 0; x < n; x++) {
		int y, m, d;
		cin >> y >> m >> d;

		int res = 0;
		while (1) {
			if (y == 1000)break;
			d++;
			res++;
			if (y % 3 == 0) {
				if (d == 21) {
					d = 1;
					m++;
				}
				if (m == 11) {
					m = 1;
					y++;
				}
			}
			else {
				if (m %2== 0) {
					if (d == 20) {
						d = 1;
						m++;
					}
					if (m == 11) {
						m = 1;
						y++;
					}
				}
				else {
					if (d == 21) {
						d = 1;
						m++;
					}
				}
			}
		}
		cout << res << endl;
	}
	return 0;
}

Measured memory_bytes: 2992
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ITP1
{
    class ITP1_1_D
    {
        static void Main(string[] args)
        {
            int time;
            int h, m, s;

            time = int.Parse(Console.ReadLine());

            s = time;

            h = time / 3600;
            s %= 3600;
            m = s / 60;
            s %= 60;
      
            Console.WriteLine(h + ":" + m + ":" + s);
        }
    }
}


Measured memory_bytes: 17936
N = int(input())

A = sorted(list(map(int, input().split())))

INF = 10**6

ind = INF
for i in range(len(A)):
    if A[i]>=0:
        ind = i
        break
    else:
        A[i] *= -1

if ind == INF:
    ind = N

if ind %2 == 0:
    print(sum(A))
elif ind==N:
    print(sum(A)-2*A[ind-1])
else:
    print(sum(A)-2*min(A[ind], A[ind-1]))

Measured memory_bytes: 64752
#include<cstdio>
#include<algorithm>
using namespace std;
int n, K, s = 0;
int C[201000];
int main() {
	int i, a;
	scanf("%d%d", &n, &K);
	for (i = 1; i <= n; i++) {
		scanf("%d", &a);
		C[a]++;
	}
	sort(C + 1, C + n + 1);
	for (i = n; i > n - K; i--) {
		s += C[i];
	}
	printf("%d\n", n - s);
}

Measured memory_bytes: 896
S = input()
# 2^(|S|-1)のbit全探索
ans = 0
N = len(S)

for i in range(2**(N-1)):
  prej = 0
  for j in range(N-1):
    if (i >> j) & 1:
      ans += int(S[prej:j+1])
      prej = j+1
  ans += int(S[prej:])
print(ans)

Measured memory_bytes: 3060
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE BinaryLiterals #-}
{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE NumDecimals #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-}

import Control.Applicative
import Control.Arrow
import Control.Monad
import Control.Monad.ST

import Data.Char
import Data.List
import Data.Maybe

import qualified Data.ByteString.Char8 as B

import Data.Array.ST.Safe
import Data.STRef

import Debug.Trace
import Text.Printf

readInt = readLn :: IO Int
readInts = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine
readNInts = readInt >>= flip replicateM readInt

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

main = do
	[ n, x ] <- readInts
	ls <- readInts
	print $ length $ filter ( <= x ) $ scanl (+) 0 ls

Measured memory_bytes: 508
#include <algorithm>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define rep(i, n) repd(i, 0, n)
typedef long long ll;

using namespace std;

template <typename T> void output(T, int);
int gcd(int a, int b);

int main() {
    // source
    int n, m, x;
    cin >> n >> m >> x;
    int a[m];
    rep(i, m) { cin >> a[i]; }
    int index = lower_bound(a, a + m, x) - a;
    cout << min(index, m - index) << endl;
    return 0;
}

template <typename T> void output(T a, int precision) {
    if (precision > 0) {
        cout << setprecision(precision) << a << "\n";
    } else {
        cout << a << "\n";
    }
}

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


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

int main()
{
    int N;
    cin >> N;
    int a[N+3];
    for(int i = 0; i < N; ++i) cin >> a[i];

    sort(a, a + N,
        [](int &x, int &y) {return x > y; });
    int cnt = 0;
    int sub = 0;
    while(cnt < N) {
        if(cnt % 2 ) sub -= a[cnt];
        else sub += a[cnt];
        ++cnt;
    }
    cout << sub << endl;
    return 0;
}

Measured memory_bytes: 256
H, W = map(int, input().split())
N = int(input())
a = list(map(int, input().split()))

c = [[0]*W for _ in range(H)]
now_h, now_w = 0, 0

rest = 0
col = 0
direction = 1
while now_h + now_w < H * W:
  if rest == 0:
    if len(a) == 0:
      break
    rest = a.pop(0)
    col += 1
  if direction == 1:
    if now_w + 1 < W:
      c[now_h][now_w] = col
      now_w += 1 
      rest -= 1
    elif now_w + 1 == W:
      c[now_h][now_w] = col
      now_h += 1
      direction = -1
      rest -= 1
  elif direction == -1:
    if now_w - 1 > -1:
      c[now_h][now_w] = col
      now_w -= 1
      rest -= 1
    elif now_w - 1 == -1:
      c[now_h][now_w] = col
      now_h += 1
      direction = 1
      rest -= 1

  
for h in range(H):
  for w in range(W):
    print(c[h][w], end=" ")
  print()
  



Measured memory_bytes: 45160
import java.util.Scanner;

public class Main{
	public static void main(String args[]) {
		Scanner scn = new Scanner(System.in);
		boolean[] n = new boolean[4];
		for (int i = 0; i < 4; i++) {
			int a = scn.nextInt();
			switch (a) {
			case 1:
				n[0] = true;
				break;
			case 9:
				n[1] = true;
				break;
			case 7:
				n[2] = true;
				break;
			case 4:
				n[3] = true;
				break;
			default:
				break;
			}
		}
		boolean ans = true;
		for(int i = 0;i < 4;i++) {
			ans &= n[i];
		}
		System.out.println(ans?"YES":"NO");
	}
}


Measured memory_bytes: 23636
n = int(input())
s = input()
c = s.count('R') * s.count('G') * s.count('B')
for i in range(n - 2):
    for j in range(i + 1, n - 1):
        k = j + (j - i)
        if k >= n:
            continue
        if s[i] == s[j] or s[j] == s[k] or s[k] == s[i]:
            continue
        c -= 1
print(c)

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

typedef long long llt;

const int MaxN = 100000 + 5, MaxM = 100000 + 5;
const llt INF = 0x7F7F7F7F7F7F7F7F;

int N, M, Q;
llt A[MaxN], B[MaxM];

void init() {
  scanf("%d %d %d", &N, &M, &Q);
  for (int i = 1; i <= N; ++i) scanf("%lld", &A[i]);
  for (int i = 1; i <= M; ++i) scanf("%lld", &B[i]);
}

inline llt getdis(llt a, llt b, llt x) {
  if (a > b) swap(a, b);
  if (a < x && x < b) return min(x - a, b - x) + b - a;
  if (b < x) return x - a;
  if (x < a) return b - x;
}

void solve() {
  for (int i = 1; i <= Q; ++i) {
    llt x; scanf("%lld", &x);
    int posa = lower_bound(A + 1, A + 1 + N, x) - A;
    int posb = lower_bound(B + 1, B + 1 + M, x) - B;

    llt ans = INF;
    if (posa <= N && posb <= M)
      ans = min(ans, getdis(A[posa], B[posb], x));
    if (posa > 1 && posb <= M)
      ans = min(ans, getdis(A[posa - 1], B[posb], x));
    if (posa <= N && posb > 1)
      ans = min(ans, getdis(A[posa], B[posb - 1], x));
    if (posa > 1 && posb > 1)
      ans = min(ans, getdis(A[posa - 1], B[posb - 1], x));
    printf("%lld\n", ans);
  }
}

int main() {
  init();
  solve();
  return 0;
}


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

using namespace std;

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int a, b;
    cin >> a >> b;
    // aaa...a (b times)
    // bbb...b (a times)
    char ca = a+'0', cb = b+'0';
    string sa(b, ca), sb(a, cb);
    if(sa > sb) swap(sa, sb);
    cout << sa << "\n";
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<cstring>
#include<set>
#include<queue>
#include<map>
#include<math.h>
#include<climits>

#define FASTREAD      ios_base::sync_with_stdio(0);cin.tie(nullptr);
#define ll long long
#define dd double
#define scl(n)        scanf("%lld",&n)
#define scd(n)        scanf("%lf",&n)
#define scc(n)        scanf("%c",&n)
#define scs(n)        scanf("%s",&n)
#define ptl(n)        printf("%lld",n)
#define ptd(n)        printf("%f",n)
#define ptc(n)        printf("%c",n)
#define pts(n)        printf("%s",n)
#define nline         printf("\n")
#define pb            push_back
#define FOR(i,a,b)    for(ll i=a;i<=b;i++)
#define FORr(i,a,b)   for(ll i=a;i>=b;i--)
#define pi            2*acos(0.0)
#define pii           pair<ll,ll>
#define uu            first
#define vv            second
#define MAX  1e13
using namespace std;
ll dp[105][100005];
int main()
{
    ll n,W,w[105],v[105],op1,op2;
    scl(n);
    scl(W);
    FOR(i,1,n)
    {
        scl(w[i]);
        scl(v[i]);
    }
    FOR(i,1,100000)
    {
        dp[n+1][i]=MAX;
    }
    FORr(i,n,1)
    {
        FOR(j,0,100000)
        {
            if(j-v[i]>=0){
                op1=dp[i+1][j-v[i]]+w[i];
            }
            else
                op1=MAX;
            op2=dp[i+1][j];
            dp[i][j]=min(op1,op2);
           // cout<<j<<" "<<dp[i][j]<<endl;
        }
     //   nline;
    }
  //  cout<<dp[2][0]<<endl;
    ll ans;
    FORr(i,100000,1)
    {
        if(dp[1][i]<=W)
        {
          //  cout<<dp[1][i]<<endl;
            ans=i;
            break;
        }
    }
    ptl(ans);
    nline;
    return 0;
}


Measured memory_bytes: 82684
import java.io._
import java.util.StringTokenizer
import scala.util.control.Breaks.{breakable,break}
import scala.collection.mutable.{Map, Stack, Queue, PriorityQueue, Set}

object Main extends App {
  val in = new InputReader(System.in)
  val pw = new PrintWriter(System.out)

  val k, q = in.next().toInt
  val d = new Array[Int](k)
  for (i <- 0 until k)
    d(i) = in.next().toInt
  
  //
  val d2 = new Array[Int](k)
  for (_ <- 1 to q) {
    //  n, x, m
    val num, init, mod = in.next().toInt

    for (i <- 0 until k)
      d2(i) = d(i) % mod

    var ans: Long = num-1
    val base = (num-1) / k
    val extra = (num-1) % k // これ未満の j は base+1回足される

    // ==
    for (j <- 0 until k) {
      if (d2(j) == 0) {
        ans -= base
        if (j < extra) ans -= 1
      }
    }

    // >
    var acc: Long = init
    for (j <- 0 until k) {
      acc += d2(j).toLong * base
      if (j < extra) acc += d2(j)
    }
    ans -= acc / mod - init / mod
    
    pw.println(ans)
  }

  pw.flush()
}

object Sub {
  def print2DimArray[A](mat: Array[Array[A]]): Unit = {
    mat.foreach(lin => println(lin.deep))
  }
}

class InputReader(stream: InputStream) {
  private[this] val reader = new BufferedReader(new InputStreamReader(stream))
  private[this] var tokenizer: StringTokenizer = new StringTokenizer(reader.readLine())
  def next(): String = {
    while (!tokenizer.hasMoreTokens()) {
      tokenizer = new StringTokenizer(reader.readLine())
    }
    tokenizer.nextToken()
  }
}


Measured memory_bytes: 40280
N = input()[::-1] # 文字列, N[0]が1の位となるように反転
K = int(input())

# N = a[0] + a[1]*10 + ... + a[n]*10^n （n+1桁）のとおく
n = len(N) - 1
# dp[i][j] = i桁以下の数字0〜999...9のうちNonzeroがj桁の数
# dp[i][4] = dp[i][-1]はダミー
dp = [[1, 0, 0, 0]] + [[0 for _ in range(5)] for _ in range(n + 1)]

for i in range(1, n + 1):
    dp[i][0] = 1
    for j in [1, 2, 3]:
        dp[i][j] = sum([9 * dp[ii][j - 1] for ii in range(0, i)])

# nzd[i] := a[i], .., a[n]のうちnonzeroの桁数
nzd = [0] * (n + 2)  # nzd[n + 1]はダミー
for i in range(n, -1, -1):
    nzd[i] = nzd[i + 1] + int(N[i] != '0')

ans = 0
for i in range(0, n):
    if N[n - i] == '0': continue
    # a[n]a[n-1]...a[n-i+1]00....0 〜 a[n]a[n-1]...a[n-i+1]09...9
    ans += dp[n - i][max(-1, K - nzd[n - i + 1])]

    # a[n]a[n-1]...a[n-i+1]d0...0 〜 a[n]a[n-1]...a[n-i+1]d9...9 for d = 1,...,a[n-i]-1
    ans += (int(N[n - i]) - 1) * dp[n - i][max(-1, K - nzd[n - i + 1] - 1)]

# a[n]a[n-1]...a[1]0 〜 a[n]a[n-1]...a[1]a[0]
if nzd[1] == K:
    ans += 1
elif nzd[1] == K - 1:
    ans += int(N[0])

print(ans)


Measured memory_bytes: 3064
#include<iostream>
using namespace std;
 
int main(){
  int n;
  int a;
  int max;
  int min;
  long long sum;
  cin >> n;
  for(int i=0; i<n; i++){
    cin >> a;
    if(i == 0){
      max = a;
      min = a;
      sum = a;
    } else{
      if(max < a)max = a;
      if(min > a)min = a;
      sum += a;
    }
  }
  cout << min << " "<< max << " " << sum << endl;
  return 0;
}

Measured memory_bytes: 1168
#![allow(non_snake_case, unused)]
use std::collections::*;

////////// missing functions in 1.15.1 //////////
macro_rules! eprint {
	($($t:tt)*) => {{
		use ::std::io::Write;
		let _ = write!(::std::io::stderr(), $($t)*);
	}};
}
macro_rules! eprintln {
	() => { eprintln!(""); };
	($($t:tt)*) => {{
		use ::std::io::Write;
		let _ = writeln!(::std::io::stderr(), $($t)*);
	}};
}
macro_rules! dbg {
	($v:expr) => {{
		let val = $v;
		eprintln!("[{}:{}] {} = {:?}", file!(), line!(), stringify!($v), val);
		val
	}}
}
/////////////////////////////////////////////////
pub trait SetMinMax {
	fn setmin(&mut self, v: Self) -> bool;
	fn setmax(&mut self, v: Self) -> bool;
}
impl<T> SetMinMax for T where T: PartialOrd {
	fn setmin(&mut self, v: T) -> bool {
		*self > v && { *self = v; true }
	}
	fn setmax(&mut self, v: T) -> bool {
		*self < v && { *self = v; true }
	}
}

macro_rules! mat {
	($($e:expr),*) => { Vec::from(vec![$($e),*]) };
	($($e:expr,)*) => { Vec::from(vec![$($e),*]) };
	($e:expr; $d:expr) => { Vec::from(vec![$e; $d]) };
	($e:expr; $d:expr $(; $ds:expr)+) => { Vec::from(vec![mat![$e $(; $ds)*]; $d]) };
}

pub fn readln() -> String {
	let mut line = String::new();
	::std::io::stdin().read_line(&mut line).unwrap_or_else(|e| panic!("{}", e));
	line
}

macro_rules! read {
	($($t:tt),*; $n:expr) => {{
		let stdin = ::std::io::stdin();
		let ret = ::std::io::BufRead::lines(stdin.lock()).take($n).map(|line| {
			let line = line.unwrap();
			let mut it = line.split_whitespace();
			_read!(it; $($t),*)
		}).collect::<Vec<_>>();
		ret
	}};
	($($t:tt),*) => {{
		let line = readln();
		let mut it = line.split_whitespace();
		_read!(it; $($t),*)
	}};
}

macro_rules! _read {
	($it:ident; [char]) => {
		_read!($it; String).chars().collect::<Vec<_>>()
	};
	($it:ident; [u8]) => {
		Vec::from(_read!($it; String).into_bytes())
	};
	($it:ident; [$t:ty]) => {
		$it.map(|s| s.parse::<$t>().unwrap_or_else(|e| panic!("{}", e))).collect::<Vec<_>>()
	};
	($it:ident; $t:ty) => {
		$it.next().unwrap_or_else(|| panic!("input mismatch")).parse::<$t>().unwrap_or_else(|e| panic!("{}", e))
	};
	($it:ident; $($t:tt),+) => {
		($(_read!($it; $t)),*)
	};
}

pub fn main() {
	let _ = ::std::thread::Builder::new().name("run".to_string()).stack_size(32 * 1024 * 1024).spawn(run).unwrap().join();
}

fn run() {
	let (N, K) = read!(usize, usize);
	let hs = read!([i32]);
	let mut dp = vec![0; N];
	for i in 1..N {
		dp[i] = i32::max_value();
		for j in 1..K+1 {
			if j <= i {
				let t = dp[i - j] + (hs[i] - hs[i - j]).abs();
				dp[i].setmin(t);
			}
		}
	}
	println!("{}", dp[N - 1]);
}


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

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

	// 条件設定から解は0か1
	int amari = N % K;
	if (amari == 0) {
		cout << "0" << endl;
	} else {
		cout << "1" << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
  char c;
  cin >> c;
  if (c == 'a' or c == 'e' or c == 'i' or c == 'o' or c == 'u') {
    cout << "vowel" << endl;
  } else {
    cout << "consonant" << endl;
  }
  return 0;
}

Measured memory_bytes: 764