akhauriyash/Code-Regression huggingface dataset:
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author __shangu__
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        C755 solver = new C755();
        solver.solve(1, in, out);
        out.close();
    }

    static class C755 {
        private int[] dig;
        private int[] enu;
        private int n;
        private int len;

        public void solve(int testNumber, InputReader in, PrintWriter out) {
            dig = new int[20];
            enu = new int[]{3, 5, 7};
            n = in.nextInt();
            while (n > 0) {
                dig[len++] = n % 10;
                n /= 10;
            }
            out.println(calc(len - 1, new boolean[3], false, false));
        }

        private int calc(int curi, boolean[] has, boolean issmaller, boolean hasstarted) {
            if (curi == -1) return hasstarted && has[0] && has[1] && has[2] ? 1 : 0;
            int ans = 0;
            if (issmaller) {
                for (int i = 0; i < 3; ++i) {
                    boolean tmp[] = has.clone();
                    tmp[i] = true;
                    ans += calc(curi - 1, tmp, true, true);
                }
                if (!hasstarted) ans += calc(curi - 1, has, true, false);
            } else {
                for (int i = 0; i < 3; ++i) {
                    boolean tmp[] = has.clone();
                    tmp[i] = true;
                    if (enu[i] < dig[curi]) ans += calc(curi - 1, tmp, true, true);
                    else if (enu[i] == dig[curi]) ans += calc(curi - 1, tmp, false, true);
                }
                if (!hasstarted) ans += calc(curi - 1, has, true, false);
            }
            return ans;
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

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

    }
}



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

public static partial class Program
{
    public static void Main()
    {
        var nx = CRL().ArrayInts();
        var n = nx[0];
        var x = nx[1];
        var lis = CRL().ArrayInts();

        var cnt = 1;
        var buf = 0;
        for (int i = 0; i < lis.Length; i++)
        {
            buf += lis[i];
            if (buf <= x)
            {
                cnt++;
            }
        }
        
        CWL(cnt);
    }
}

public static partial class Program
{
    //テンプレここから
    public static int Sigma(int n, int next = 1, int val = 0) => next > n ? val : Sigma(n, next + 1, val + next);
    public static long GCD(long a, long b) => b == 0 ? a : GCD(b, a % b);
    public static int GCD(int a, int b) => b == 0 ? a : GCD(b, a % b);
    public static long LCM(long a, long b) => a * b / GCD(a, b);
    public static int LCM(int a, int b) => a * b / GCD(a, b);
    public static string CRL() => Console.ReadLine();
    public static void CWL(object obj) => Console.WriteLine(obj);
    public static int ToInt(this double d) => (int) d;
    public static long ToLong(this double d) => (long) d;
    public static int ToInt(this string str) => int.Parse(str);
    public static long ToLong(this string str) => long.Parse(str);
    public static long[] ToLong(this IEnumerable<string> strs) => strs.Select(x => x.ToLong()).ToArray();
    public static int[] ToInt(this IEnumerable<string> strs) => strs.Select(x => x.ToInt()).ToArray();
    public static long[] ArrayLongs(this string str, char opr = ' ') => str.Split(opr).ToLong();
    public static int[] ArrayInts(this string str, char opr = ' ') => str.Split(opr).ToInt();
    public static long Diff(long a, long b) => Math.Abs(Math.Max(a, b) - Math.Min(a, b));
    public static int Diff(int a, int b) => Math.Abs(Math.Max(a, b) - Math.Min(a, b));
    public static long Sign(this long i) => Math.Sign(i);
    public static bool IsEven(this long i) => i % 2 == 0;
    public static bool IsEven(this int i) => i % 2 == 0;
    public static readonly int[] Dx = {0, -1, 0, 1};
    public static readonly int[] Dy = {-1, 0, 1, 0};
    public const int Mod = 1000000007;
    public static string alphabet = "abcdefghijklmnopqrstuvwxyz";
    public static long ToLong(this char c) => c.ToString().ToLong();
    public static int ToInt(this char c) => c.ToString().ToInt();
    public static long[] Sort(this long[] array) => array.OrderBy(x => x).ToArray();
    public static int[] Sort(this int[] array) => array.OrderBy(x => x).ToArray();
    public static long[] DSort(this long[] array) => array.OrderByDescending(x => x).ToArray();
    public static int[] DSort(this int[] array) => array.OrderByDescending(x => x).ToArray();
    public static string Join(this IEnumerable<string> array, string sep = "") => string.Join(sep, array);
    public static string Join(this IEnumerable<char> array, string sep = "") => string.Join(sep, array);

    public static string JoinToStr(this IEnumerable<int> array, string sep = "")
        => array.Select(x => x.ToString()).Join(sep);

    //テンプレここまで
}

Measured memory_bytes: 13396
using System;
class Program{
	static void Main(){
		int[] s=Array.ConvertAll(Console.ReadLine().Split(),int.Parse);
		int n=s[0],k=s[1];
		s=Array.ConvertAll(Console.ReadLine().Split(),int.Parse);
		int i;
		for(i=n;;i++){
			string t=i.ToString();
			for(int j=0;j<t.Length;j++){
				for(int m=0;m<k;m++){
					if(t[j]-'0'==s[m]){goto f1;}
				}
			}
			goto f2;
			f1:;
		}
		f2:
		Console.WriteLine("{0}",i);
	}
}

Measured memory_bytes: 13140
#include <iostream>
#include <map>
#include <algorithm>
#include <vector>
using namespace std;

#define ll long long 

int main () {
  ll n;
  cin >> n;
  ll a[n], b[n];
  ll suma = 0;
  ll sumb = 0;
  for (ll i = 0; i < n; i++) {
    cin >> a[i];
    suma += a[i];  
  }
  ll sa[n];
  for (ll i = 0; i < n; i++) {
    cin >> b[i];
    sumb += b[i];
    sa[i] = a[i] - b[i];  
  }
  if (suma < sumb) {
    cout << -1 << endl;
    return 0;  
  }
  sort(sa, sa + n);
  if (sa[0] >= 0) {
    cout << 0 << endl;
    return 0;  
  }
  ll ans = 0;
  ll min = 0;
  for (ll i = 0; i < n; i++) {
    if (sa[i] < 0) {
      min += sa[i];
      ans++;  
    }
  }
  for (ll i = 0; i < n; i++) {
    ll j = n - i - 1;
    ans++;
    min += sa[j];
    if (min >= 0) {
      break;  
    }  
  }
  cout << ans << endl;

    
}

Measured memory_bytes: 2560
#Back and Forth
sx, sy, tx, ty = map(int, input().split())
R = ""
for i in range (tx-sx):
    R = R + "R"
for i in range (ty-sy):
    R = R + "U"
for i in range (tx-sx):
    R = R + "L"
for i in range (ty-sy):
    R = R + "D"
R = R + "D"
for i in range (tx-sx+1):
    R = R + "R"
for i in range (ty-sy+1):
    R = R + "U"
R = R + "LU"
for i in range (tx-sx+1):
    R = R + "L"
for i in range (ty-sy+1):
    R = R + "D"
R = R + "R"
print(R)

Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<cmath>
#include<algorithm>
using namespace std;
int revnum(int num,bool &f)
{
	int t = 0;
	f = true;
	while (num != 0)
	{
		t *= 10;
		t += num % 10;
		if (t == 0 && num % 10==0)
		{
			f = false;
			break;
		}
		num /= 10;
	}
	return t;
}

int main()
{
	int a, b;
	cin >> a >> b;
	int c = 0;
	for (int i = a; i <= b; i++)
	{
		bool f;
		if (i == revnum(i, f))
		{
			if (f)
			{
				c++;
			}
		}
	}
	cout << c;
	return 0;
}

Measured memory_bytes: 256
//途中で0があると積は0担ってしまうので一旦全て入力しきったあとでないと判断できない
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a, b, c;
  cin >> a >> b >> c;
  int M = max(a,b);
  M = max(M, c);
  int ans = a * b *c/(M*2);
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
//#define cerr if(false) cerr
#ifdef DEBUG
#define show(...) cerr << #__VA_ARGS__ << " = ", debug(__VA_ARGS__);
#else
#define show(...) 42
#endif
using namespace std;
using ll = long long;
using pii = pair<int, int>;
template <typename T, typename S>
ostream& operator<<(ostream& os, pair<T, S> a) {
    os << '(' << a.first << ',' << a.second << ')';
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for (auto x : v) os << x << ' ';
    return os;
}
void debug() {
    cerr << '\n';
}
template <typename H, typename... T>
void debug(H a, T... b) {
    cerr << a;
    if (sizeof...(b)) cerr << ", ";
    debug(b...);
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, k, q;
    cin >> n >> k >> q;
    vector<int>a(n);
    rep(i,q){
        int x;
        cin >> x;
        x--;
        a[x]++;
    }
    rep(i,n){
        if(k-q+a[i]>0){
            cout <<"Yes"<< "\n";
        }else{
            cout << "No" << "\n";
        }
    }
}

Measured memory_bytes: 1024
#include<stdio.h>

void QSort(int x[ ], int left, int right)
{
    int i, j;
    int pivot;

    i = left;                      /* ソートする配列の一番小さい要素の添字 */
    j = right;                     /* ソートする配列の一番大きい要素の添字 */

    pivot = x[(left + right) / 2]; /* 基準値を配列の中央付近にとる */

    while (1) {                    /* 無限ループ */

        while (x[i] < pivot)       /* pivot より大きい値が */
            i++;                   /* 出るまで i を増加させる */

        while (pivot < x[j])       /* pivot より小さい値が */
            j--;                   /*  出るまで j を減少させる */
        if (i >= j)                /* i >= j なら */
            break;                 /* 無限ループから抜ける */

        Swap(x, i, j);             /* x[i] と x[j]を交換 */
        i++;                       /* 次のデータ */
        j--;
    }

    if (left < i - 1)              /* 基準値の左に 2 以上要素があれば */
        QSort(x, left, i - 1);     /* 左の配列を Q ソートする */
    if (j + 1 <  right)            /* 基準値の右に 2 以上要素があれば */
        QSort(x, j + 1, right);    /* 右の配列を Q ソートする */
}

  /* 配列の要素を交換する */
void Swap(int x[ ], int i, int j)
{
    int temp;

    temp = x[i];
    x[i] = x[j];
    x[j] = temp;
}

int main(){
  int n,k,a[200010]={},i,b,cnt=0;
  scanf("%d %d",&n,&k);
  for(i=0;i<n;i++){
    scanf("%d",&b);
    a[b]++;
  }
  QSort(a, 0, n);
  for(i=0;i<=n-k;i++){
    cnt+=a[i];
  }
  printf("%d\n",cnt);
}

Measured memory_bytes: 896
'use strict'
function main(input) {
    const tmp = input.split(' ');
    const L = parseInt(tmp[0], 10);
    const R = parseInt(tmp[1], 10);

    const modNum = 2019;
    if (R - L + 1 >= modNum) {
        console.log(0);
    } else {
        const Lmod = L % modNum;
        const Rmod = R % modNum;

        let minimum = Infinity;
        for (let i = Lmod; i < Rmod; i++) {
            for (let k = i + 1; k <= Rmod; k++) {
                minimum = Math.min((i * k) % modNum, minimum);

            }
        }
        console.log(minimum);

    }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 21064
#include <iostream>
#include <vector>

using namespace std;

int main(){
  int n;
  cin >> n;
  vector<int> a(n), b(n), c(n - 1);
  for(auto &i : a) cin >> i;
  for(auto &i : b) cin >> i;
  for(auto &i : c) cin >> i;
  
  int satisfact = b[a[0] - 1];
  for(int i = 1; i < a.size(); i++){
  	satisfact += b[a[i] - 1];
    if(a[i - 1] + 1 == a[i])
      satisfact += c[a[i - 1] - 1];
  }
  
  cout << satisfact << '\n';
  return 0;
}

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

#define PI 3.141592653589793238462643383279
typedef long long ll;
const long double EPS = 1e-9;
const ll MOD = 1e9+7;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout << fixed << setprecision(20);
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    #ifdef LOCAL_TEST
    freopen("input.txt","r",stdin);
    #endif
    int a, b; cin >> a >> b;
    if(b % a) cout << b - a << '\n';
    else cout << a + b << '\n';
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//cout << fixed << setprecision(17) << res << endl;
 
int main() {
    ll n;
    cin >> n;
    vector<bool> dp(110, false);
    dp[4] = true;
    dp[7] = true;
    for (ll i = 0; i <= 100; ++i) {
        dp[i+4] = dp[i+4] | dp[i];
        dp[i+7] = dp[i+7] | dp[i];
    }
    if (dp[n]) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

}


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

int main(){
  int a, b;
  cin >> a >> b;
  if(a==1)a+=13;
  if(b==1)b+=13;
  if(a>b)cout << "Alice";
  else if(a<b)cout << "Bob";
  else cout << "Draw";
  return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.buffer.readline
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

ans = 0
for i in range(N):
    if A[i] >= B[i]:
        ans += B[i]
    else:
        ans += A[i]
        tmp = min(B[i]-A[i], A[i+1])
        ans += tmp
        A[i+1] -= tmp
print(ans)


Measured memory_bytes: 16992
#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;
#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,c,k,t[100005];
int main(){
	cin>>n>>c>>k;
	rep(i,n)cin>>t[i];
	sort(t,t+n);
	int pre = 0,ans = 0;
	for(int i=0;i<n;i++){
		if(t[i]-t[pre] > k){
			pre = i; ans++;
		}
		else if(i-pre+1==c){
			pre = i+1; ans++;
		}
	}
	if(pre!=n) ans++;cout<<ans<<endl;
}

Measured memory_bytes: 640
n, m, p = map(int, input().split())

abc = []
# edge = [[] for _ in range(n)]
rev_edge = [[] for _ in range(n)]
for _ in range(m):
    a, b, c = map(int, input().split())
    abc.append((a - 1, b - 1, p - c))
    # edge[a - 1].append(b - 1)
    rev_edge[b - 1].append(a - 1)


def dfs(e, s):
    v_set = {s}
    stack = [s]
    while stack:
        v = stack.pop()
        for next_v in e[v]:
            if next_v in v_set:
                continue
            v_set.add(next_v)
            stack.append(next_v)
    return v_set


def bellman_ford(sub_abc, n):
    inf = float("inf")
    dist = [inf] * n
    dist[0] = 0

    for _ in range(n):
        updated = False
        for u, v, d in sub_abc:
            if dist[u] + d < dist[v]:
                dist[v] = dist[u] + d
                updated = True
        if not updated:
            break
    else:
        return -1

    return max(-dist[n - 1], 0)


use = dfs(rev_edge, n - 1)
print(bellman_ford([(a, b, c)
                    for (a, b, c) in abc if a in use and b in use], n))


Measured memory_bytes: 4892
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
constexpr int MOD = 1000000007;
constexpr int INF = 2147483647;
void yes(bool expr) {
  cout << (expr ? "Yes" : "No") << "\n";
}
struct Query{
  lint idx;
  lint B;
  bool operator < (const Query &other) const { return B < other.B; }
};
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  lint N;
  cin >> N;
  vector<lint> A(N);
  vector<lint> B(N);
  REP(i, N) cin >> A[i];
  REP(i, N) cin >> B[i];
  multiset<Query> ms;
  REP(i, N) {
    if(A[i] < B[i]) {
      Query o;
      o.idx = i;
      o.B = B[i];
      ms.insert(o);
    }
  }
  lint ans = 0;
  while(!ms.empty()) {
    Query o = *prev(ms.end(), 1);
    ms.erase(prev(ms.end(), 1));
    lint num1 = (B[o.idx] - (B[(o.idx-1+N)%N] + B[(o.idx+1)%N]) - 1) / (B[(o.idx-1+N)%N] + B[(o.idx+1)%N]) + 1;
    lint num2 = (B[o.idx] - A[o.idx] - 1) / (B[(o.idx-1+N)%N] + B[(o.idx+1)%N]) + 1;
    lint num = min(num1, num2);
    if(num <= 0) {
      cout << -1 << endl;
      return 0;
    }
    B[o.idx] -= num * (B[(o.idx-1+N)%N] + B[(o.idx+1)%N]);
    ans += num;
    if(B[o.idx] < A[o.idx]) {
      cout << -1 << endl;
      return 0;
    } else if(B[o.idx] > A[o.idx]) {
      o.B = B[o.idx];
      ms.insert(o);
    }
  }
  cout << ans << endl;
}

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

#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define input_txt() freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define pb push_back
#define si set<int>
#define msi map<string, int>
#define test ll t; cin>>t; while(t--)
#define input(a,n) for(int i=0;i<n;i++) cin>>a[i];
#define sqr(a) (a)*(a)
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*(b/gcd(a,b)))
const double PI = acos(-1);
const int inf=2000000000;
const ll infLL=9000000000000000000;


void case_i()
{
    ll n,d;cin>>n>>d;
    ll a[n],b[n],cnt=0;
    ll xx;
    d=sqr(d);
    for(int i=0;i<n;i++)
    {
        cin>>a[i]>>b[i];
        xx=sqr(a[i])+sqr(b[i]);
        //cout<<xx<<endl;
        if(xx<= d)
            cnt++;
    }
    cout<<cnt<<endl;
}

int main()
{
    IOS;
    //    input_txt();
    //test
    case_i();
    /**/
    return 0;
}



//End up here once more;






Measured memory_bytes: 6756
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ll n,k,x;
    cin>>n>>k;

    if(n==0)
    {
        cout<<"0";
    }
    else if(n==k)
    {
        cout<<"0";
    }

    else
    {
        if(n%k==0)
        {
            cout<<"0";
        }
        else
        {
            x=n;
            ll d,e;
            d=n%k;
            x=min(x,d);
            d=n/k;
            d++;
            e=abs(d*k-n);
            x=min(x,e);

            cout<<x;
        }
    }
    cout<<endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

/**
 * Created by oka on 2018/06/23.
 */
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        char[] input = sc.next().toCharArray();

        int takahashi = 0;
        for (char c: input) {
            if (c == '+') {
                takahashi++;
            } else {
                takahashi--;
            }
        }
        System.out.println(takahashi);
    }
}


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

int main(){
    int N;
    cin >> N;
    vector<int> D(N);
    for(int i=0;i<N;i++) cin >> D[i];
    int ans = 0;
    for(int i=0;i<N;i++) for(int j=i+1;j<N;j++) ans += D[i]*D[j];
    cout << ans << endl;   
}

Measured memory_bytes: 256
#include <stdio.h>
#define MAX 100000

int A[MAX],n;

int partition(int p, int r){
	int x, i, j, t;
	x = A[r];
	i = p-1;
	for(j = p; j < r; j++){
		if(A[j] <= x){
			i++;
			t = A[i];
			A[i] = A[j];
			A[j] = t;
		}
	}
	t = A[i + 1];
	A[i + 1] = A[r];
	A[r] = t;
	return i+1;
}

int main(){
	int i,q;
	
	scanf("%d",&n);
	for(i = 0; i < n; i++){
		scanf("%d", &A[i]);
	}
	q = partition(0, n - 1);
	
	for(i=0 ; i < n; i++){
		if(i){printf(" ");}
		if(i == q){printf("[");}
		printf("%d", A[i]);
		if(i == q){printf("]");}
	}
	printf("\n");
	
	return 0;
}



Measured memory_bytes: 2156
#include <iostream>
using namespace std;
int main(){
	long long n;
	cin>>n;
	string s[n];
	long long arr[4]; //AC, TLE,RE,WA
	for(int i=0;i<n;i++){
		cin>>s[i];
	}
	for(int i=0;i<4;i++){
		arr[i]=0;
	}
	for(int i=0;i<n;i++){
		if(s[i]=="AC")arr[0]++;
		else if(s[i]=="TLE")arr[1]++;
		else if(s[i]=="RE")arr[2]++;
		else if(s[i]=="WA")arr[3]++;
	}
	cout<<"AC"<<" x "<<arr[0]<<"\n";
	cout<<"WA"<<" x "<<arr[3]<<"\n";
	cout<<"TLE"<<" x "<<arr[1]<<"\n";
	cout<<"RE"<<" x "<<arr[2]<<"\n";
}

Measured memory_bytes: 5484
//#include <bits/stdc++.h>                          //include all library
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <map>
#include <sstream>
#include <vector>
#include <stack>
#include <queue>
#include <string.h>
#include <functional> // greater<int> はfunctionalヘッダ
using namespace std;

#define REP(i, n) for(int i = 0;i < n;i++)          //REP(i, 10){...} //i=0～i=9までのループ
#define REPR(i, n) for(int i = n;i >= 0;i--)        //REPR(i, 10){...} //i=10～i=0までのループ
#define FOR(i, m, n) for(int i = m;i < n;i++)       //FOR(i, 3, 10){...} //i=3～i=9までのループ
#define FORR(i, m, n) for(int i = m;i >= n;i--)     //FORR(i, 10, 3){...} //i=10～i=3までのループ
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
#define PI 3.141592653589
#define npos -1


int main()
{
	int p, q, r, m;
	cin >> p >> q >> r;
	m = max(p, q);
	m = max(m, r);
	cout << p+q+r-m << endl;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
public class Main
{
    public static int gcd(int a,int b)
    {
        if(b==0)
        return a;
        return gcd(b,a%b);
    }
    public static void main(String args[])throws Exception
    {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        PrintWriter pw=new PrintWriter(System.out);
        //String str[]=br.readLine().split(" ");
        //int n=Integer.parseInt(br.readLine());
        //int n=Integer.parseInt(str[0]);
        //int n=Integer.parseInt(str[1]);
        //String s=br.readLine();
        int n=Integer.parseInt(br.readLine());
        String s=br.readLine();
        int rcntr=0,gcntr=0,bcntr=0;
        for(int i=0;i<s.length();i++)
        {
            if(s.charAt(i)=='R')
            rcntr++;
            else if(s.charAt(i)=='B')
            bcntr++;
            else
            gcntr++;
        }
        long possible=1L*rcntr*gcntr*bcntr;
        for(int i=1;i<=n;i++)
        {
            for(int j=0,k=i,p=2*i;j<n&&k<n&&p<n;j++,p++,k++)
            {
                if(s.charAt(j)!=s.charAt(p)&&s.charAt(j)!=s.charAt(k)&&s.charAt(k)!=s.charAt(p))
                possible--;
            }
        }
        pw.println(possible);
        pw.flush();
        pw.close();
    }
}

Measured memory_bytes: 34060
#include <iostream>
#include <string> 
#include <vector> 
#include <algorithm> 
#include <utility> 
#include <tuple> 
#include <cstdint> 
#include <cstdio> 
#include <map> 
#include <queue> 
#include <set> 
#include <stack> 
#include <deque> 
#include <unordered_map> 
#include <unordered_set> 
#include <bitset> 
#include <cctype> 
#include<math.h>
using namespace std;
//#define int long long
#define m_p make_pair
#define mod 1000000007
#define rep(i,n)  for(int i=0; i<(int)(n); i++)
#define all(v)  v.begin(),v.end()
#define vecin(v) for(int i=0; i<(int)v.size(); i++)cin>>vec[i];
using namespace std;

int jousu(int, int);
int jousu(int x00, int y00) {
	int z00 = 1;
	for (int i = 0; i < y00; i++) {
		z00 *= x00;
	}
	return z00;
}
int kurai(int x00, int y00) {
	int z00 = (x00 % jousu(10, y00)) / jousu(10, y00 - 1);
	return z00;
}
int keta(int x00) {
	int z00 = x00;
	int w00 = 0;
	while (z00 != 0) {
		z00 /= 10;
		w00++;
	}
	return w00;
}



int main() {
	int n, a;
	vector<int>vec(9);
	set<int>s;
	rep(i, 9) {
		cin >> vec[i];
	}
	cin >> n;
	rep(i, n) {
		cin >> a;
		rep(j, 9) {
			if (vec[j] == a) {
				s.insert(j);
			}
		}
	}
	if ((s.count(0) && s.count(3) && s.count(6)) || (s.count(1) && s.count(4) && s.count(7)) || (s.count(2) && s.count(5) && s.count(8))) {
		cout << "Yes" << endl;
		return 0;
	}
	if ((s.count(0) && s.count(1) && s.count(2)) || (s.count(3) && s.count(4) && s.count(5)) || (s.count(6) && s.count(7) && s.count(8))) {
		cout << "Yes" << endl;
		return 0;
	}
	if ((s.count(0) && s.count(4) && s.count(8)) || (s.count(2) && s.count(4) && s.count(6))) {
		cout << "Yes" << endl;
		return 0;
	}
	cout << "No" << endl;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<queue>
#include<cmath>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<bitset>
#include<unordered_map>
#include<climits>
#include<fstream>
using namespace std;
///////////////////library zone!!!!!!!!!!!!!!!!!!!!!!!!!!!!
typedef long long ll;
typedef long double ld;
#define all(a) (a).begin(),(a).end()
#define EPS (1e-5)
#define bit(n,k) ((n>>k)&1)
const ll Mod = 1000000007;
const ll mod = 998244353;
struct H {
	ll x, y;
	bool operator<(const H& b) const {
		if (x != b.x) return x < b.x;
		return y < b.y;
	}
	bool operator>(const H & b) const {
		if (x != b.x) return x > b.x;
		return y > b.y;
	}
	bool operator==(const H & b) const { return x == b.x && y == b.y; }
	bool operator!=(const H & b) const { return (*this) != b; }
};
struct P {
	ll pos, cost;
	bool operator<(const P& b) const { return cost < b.cost; }
	bool operator>(const P& b) const { return cost > b.cost; }
};
struct B {
	ll to, cost;
};
struct E {
	ll from, to, cost;
	bool operator<(const E& b) const { return cost < b.cost; }
	bool operator>(const E& b) const { return cost > b.cost; }
};
template<typename T, typename U>
void chmin(T & a, U b) {
	if (a > b) a = b;
}
template<typename T, typename U>
void chmax(T & a, U b) {
	if (a < b) a = b;
}
template<typename T>
T max_0(T a) {
	if (a < 0) return 0;
	return a;
}
template<typename T>
T min_0(T a) {
	if (a > 0) return 0;
	return a;
}
ll read() {
	ll u;
	ll k = scanf("%lld", &u);
	return u;
}
ll gcd(ll i, ll j) {
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcd(j % i, i);
}
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % p;
		x = x * x % p;
		n >>= 1;
	}
	return res;
}//x^n%p
const ll Inf = 3023372036854775807;
const int inf = 1500000000;
#define int long long
//----------------------------------------------------
int n, m, q;
signed main() {
	cin >> n >> m >> q;
	vector<int>a(n), b(m);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	for (int i = 0; i < m; i++) {
		cin >> b[i];
	}
	a.push_back(-Inf); a.push_back(Inf);
	b.push_back(-Inf); b.push_back(Inf);
	sort(all(a)); sort(all(b));
	n += 2; m += 2;
	for (int i = 0; i < q; i++) {
		int x = read();
		int ans = Inf;
		for (int i = 0; i < 2; i++) {
			int pos = (i ? upper_bound(all(a), x) - a.begin() - 1 : lower_bound(all(a), x) - a.begin());
			pos = a[pos];
			for (int j = 0; j < 2; j++) {
				int po = (j ? upper_bound(all(b), x) - b.begin() - 1 : lower_bound(all(b), x) - b.begin());
				po = b[po];
				ans = min(ans, abs(pos - x) + abs(pos - po));
				ans = min(ans, abs(po - x) + abs(pos - po));
			}
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 2912
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_ll.hpp>
//typedef boost::multiprecision::cpp_ll ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E18;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define endl "\n"
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);



int main(){fastio
    ll n;cin>>n;
    ll sum=0;
    rep(i,1,n){
        ll k=n/i;
        sum+=(i*((k*(k+1))/2));
    }
    cout<<sum<<endl;
}



Measured memory_bytes: 3620
#include <bits/stdc++.h>
#include <string>
#include <vector>
#include <algorithm>
#define rep(i,n) for (int i = 0;i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
int INF = 1e9;


int main(){
    ll n;cin >> n;
    ll d = 1e9;
    ll y3 = (n/d)+(n%d > 0);
    ll x3 = d-(n%d);
    if(n%d==0) x3 = 0;
    //cout << n%d << endl;

    if(n < d) printf("0 0 %lld 0 %d %d\n",n,0,1);
    else if(n <= d*d) printf("%d %d %lld %d %lld %lld\n",0,0,d,1,x3,y3);
    
    
}

Measured memory_bytes: 3704
#include<iostream>
#include<cmath>
#include<cstdio>
using namespace std;

int main(){
    int a,b,c;
    double sum;
    double L,h;
    double PI=acos(-1);
    cin>>a>>b>>c;
    double d=c*PI/180;
    //面積を求める
    sum=(a*b*sin(d))/2.0;
    //周の長さを求める
    L=sqrt(a*a+b*b-2*a*b*cos(d))+a+b;
    //hを求める
    h=2*sum/a;
    printf("%1f\n",sum);
    printf("%1f\n",L);
    printf("%1f\n",h);
    return 0;
}


Measured memory_bytes: 3500
using System;
using System.Collections.Generic;
using System.Text;

namespace AtTest.ABC_102
{
    class AtTemplate
    {
        static void Main(string[] args)
        {
            Method(args);
            Console.ReadLine();
        }

        static void Method(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            long[] array = new long[n];
            string[] input = Console.ReadLine().Split(' ');
            for (int i = 0; i < n; i++)
            {
                array[i] = long.Parse(input[i]);
            }

            long marginMax = 0;
            for(int i = 0; i < n; i++)
            {
                for(int j = i + 1; j < n; j++)
                {
                    long margin = Math.Abs(array[i] - array[j]);
                    if (margin > marginMax)
                    {
                        marginMax = margin;
                    }
                }
            }

            Console.WriteLine(marginMax);
        }
    }
}


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

import java.util.Collections;
import java.util.List;
import java.util.StringTokenizer;

public class Main {
	private StringTokenizer st;
	private BufferedReader bf;
	private int w,h,x,y,r;
	
	Main() {
		readData();
		


	}
	

	private void readData() {
		try {
			bf = new BufferedReader(new InputStreamReader(System.in));
			st = new StringTokenizer(bf.readLine());
			
			w = nextInt();
			int i = 1;
			while (w != 0) {
				System.out.println("Case "+i+": "+w);
				i++;
				w = nextInt();
			}

			
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	
	private int nextInt() throws IOException {
		return Integer.parseInt(next());
	}
	
	private String next() throws IOException {
		if (st == null || !st.hasMoreTokens())
			st = new StringTokenizer(bf.readLine());
		return st.nextToken();
	}
	
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Main m = new Main();
	}

}

Measured memory_bytes: 26604
#include <bits/stdc++.h>
using namespace std;
 
/*てんぷれぞーん！*/
//static const int INF = 2147483647;
static const int INF = 1000000000;
static const long long llINF = 9223372000000000000;
static const int NIL = -1;
static const int MOD = 1000000007;
typedef long long ll;
typedef pair<int,int> P;
struct edge {int to,cost;};
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define np next_permutation
#define pq priority_queue
/* t y p o っ て 知 っ て る ゥ ！ ？ */
#define itn int
#define scnaf scanf
#define reutnr return
/*必要に応じて使ってね*/
//int dx4[4] = {0,1,0,-1}, dy4[4] = {-1,0,1,0};
//int dx5[5] = {-1,0,0,0,1}, dy5[5] = {0,-1,0,1,0};
//int dx8[8] = {-1,0,1,1,1,0,-1,-1}, dy8[8] = {1,1,1,0,-1,-1,-1,0};
//int dx9[9] = {-1,0,1,1,1,0,-1,-1,0}, dy9[9] = {1,1,1,0,-1,-1,-1,0,0};
//#define int ll
//#define INF llINF
/*てんぷれぞーんしゅーりょー！*/
 
signed main(){
    char str[10000];
    scanf("%s",&str);
    int n= strlen(str);
    bool  ans=false;
    for(int i=0;i<n-8;i++){
        printf("%c",str[i]);
    }
    printf("\n");
}

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

int i,j,n;
string str;

int main(){
  cin >> n;
  vector<int> a(n),b(n);
  for(i = 0;i < n;i++) cin >> a[i];
  int s = 0,e = n-1;
  for(i = 0;i < n;i++){
    int index = n-1-i;
    if(i%2){
      b[e] = a[index];
      e--;
    }
    else{
      b[s] = a[index];
      s++;
    }
  }
  for(i = 0;i < n;i++){
    cout << b[i] << ' ';
  }cout << endl;
}


Measured memory_bytes: 3840
#include <math.h>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <iomanip>
#include <iterator>
#include <algorithm>
#include <functional>
#include <typeinfo>
#include <utility>
#include <tuple>
#include <queue>
#include <deque>

using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define reprrev(i, a, b) for (int i = (int)(b) - 1; i >= (int)(a); i--)
#define reprev(i, n) reprrev(i, 0, n)
#define mp(a, b) make_pair(a, b)
#define all(vec) (vec).begin(), (vec).end()
#define yn(formula) (formula) ? (cout << "Yes" << endl) : (cout << "No" << endl)
#define YN(formula) (formula) ? (cout << "YES" << endl) : (cout << "NO" << endl)
#define MIN(a, b) ((a) < (b)) ? (a) : (b)

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<pii> vp;
typedef vector<pll> vpl;
typedef vector<vi> vvi;
typedef vector<vll> vvl;
typedef vector<vb> vvb;
typedef vector<vc> vvc;
typedef vector<vs> vvs;
typedef vector<vp> vvp;
typedef vector<vpl> vvpl;

constexpr double PI = 3.14159265358979323846;
constexpr ll INF = 1 << 29;
constexpr ll MOD = (ll)1e9 + 7;
constexpr double EPS = 1e-7;
constexpr int dy[4] = { 0, 1, 0, -1 };
constexpr int dx[4] = { 1, 0, -1, 0 };

struct edge { ll to; ll cost; };

/*<ここから>***********************************************************/


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

	yn(A + B >= C);

	return 0;
}

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

using namespace std;

const double pi=3.1415926; 

int main()
{
	int n,m;
	cin>>n>>m;
	int sum=0;
	for(int i=1;i<=m;i++) {
		int k;
		cin>>k;
		sum+=k;
	}
	if(sum>n) cout<<-1<<'\n';
	else cout<<n-sum<<'\n';
 	return 0;
} 

Measured memory_bytes: 3636
#include <bits/stdc++.h>
 
using namespace std;
 
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl;
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}
typedef long long ll;
#define int ll
 
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(int)(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
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 (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const long double pi = 3.1415926535897932384626433832795028841971L;
#define Sp(p) cout<<setprecision(25)<< fixed<<p<<endl;
// int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
// int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
vi dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};
vi dx2 = { 1,1,0,-1,-1,-1,0,1 }, dy2 = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
const ll MOD = 1000000007;
// const ll MOD = 998244353;
// #define mp make_pair
//#define endl '\n'


signed main() {
	fio();
	int n, k;
	cin >> n >> k;
	vi a(n);
	rep (i, n) cin >> a[i];
	sort(all(a));
	int sum = 0;
	rep (i, k) sum += a[i];
	cout << sum << endl;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;

class SuffixArray {
  int N;
  std::string str;
  std::vector<int> rank;
  std::vector<int> sa;
  std::vector<int> lcp;
  struct Comp {
    int N;
    int k;
    std::vector<int>* rank;
    bool operator()(int i, int j){
      if((*rank)[i] != (*rank)[j]) return (*rank)[i] < (*rank)[j];
      int ri = (i+k <= N ? (*rank)[i+k] : -1);
      int rj = (j+k <= N ? (*rank)[j+k] : -1);
      return ri < rj;
    }
  };
public:
  SuffixArray(std::string str):str(str),N(str.length()),sa(N+1),rank(N+1),lcp(N+1){}
  //O(N log^2 N)
  void build_sa(){
    std::vector<int> tmp(N+1);
    for(int i=0; i<=N; i++){
      sa[i] = i;
      rank[i] = (i < N ? str[i] : -1);
    }
    Comp comp;
    comp.N = N;
    comp.rank = &rank;
    for(int k=1; k<=N; k*=2){
      comp.k = k;
      std::sort(sa.begin(), sa.end(), comp);
      tmp[sa[0]] = 0;
      for(int i=1; i<=N; i++){
        tmp[sa[i]] = tmp[sa[i-1]] + (comp(sa[i-1], sa[i]) ? 1 : 0);
      }
      for(int i=0; i<=N; i++){
        rank[i] = tmp[i];
      }
    }
  }
  std::vector<int> get_sa(){
    return sa;
  }
  //O(N)
  void build_lcp(){
    for(int i=0; i<=N; i++) rank[sa[i]] = i;
    int h = 0;
    lcp[0] = 0;
    for(int i=0; i<N; i++){
      int j = sa[rank[i]-1];
      if(h>0) h--;
      for(; j+h<N && i+h<N; h++){
        if(str[j+h] != str[i+h]) break;
      }
      lcp[rank[i]-1] = h;
    }
  }
  std::vector<int> get_lcp(){
    return lcp;
  }
  //O(|T|+|S|)
  bool contain(const std::string& query){
    int a=0, b=N;
    while(b-a>1){
      int c=(a+b)/2;
      if(str.compare(sa[c], query.length(), query) < 0) a = c;
      else b = c;
    }
    return str.compare(sa[b], query.length(), query) == 0;
  }
};

int main(){
  int N;
  cin >> N;
  string S;
  cin >> S;
  SuffixArray sa(S);
  sa.build_sa();
  sa.build_lcp();
  vector<int> v = sa.get_sa();
  vector<int> h = sa.get_lcp();

  int ret = 0;
  REP(i,1,v.size()-1){
    vector<int> tmp;
    int j=i;
    tmp.push_back(v[i]);
    while(j<h.size() && h[i] <= h[j]){
      tmp.push_back(v[j+1]);
      j++;
    }
    sort(ALLOF(tmp));
    int x = h[i];
    int y = tmp[tmp.size()-1] - tmp[0];    
    ret = max(ret, min(x, y));

    //cout << v[i] << " " << h[i] << " " << tmp[tmp.size()-1] << " " << tmp[0] << endl;
  }

  cout << ret << endl;
  
  return 0;
}



Measured memory_bytes: 384
# coding: utf-8
# Your code here!
while True:
   H, W = map(int, input().split())
   if H + W == 0: break
   for i in range(H):
      if (i == 0 or i == H - 1):
         for j in range(W):
            print("#", end = "")
         print("")
      else:
         for j in range(W):
            if (j == 0 or j == W - 1):
               print("#", end = "")
            else:
               print(".", end = "")
         print("")
   print("")


Measured memory_bytes: 7016
#include <stdio.h>

int main(void)
{
  int value;
  int i = 0;

  while(1)
  {
    i++;
    scanf("%d", &value);
    if( value == 0 )
    {
      break;
    }
    else
    {
      printf("Case %d: %d\n", i, value);
    }
  }
}


Measured memory_bytes: 2068
// 0/1 kanpsack problem in which sum is 1e9 in that case we take 2-d array where rows reperesents the current index and clooum represent the value we obtain in min cost 
// so in the end we iterate all over the table to find the maximum value whose a[i][j]<=sum;    
    #include <bits/stdc++.h>
    #define ll long long
    #define  fast ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);   
    const ll mod = 1000000007;
    using namespace std;
    int main()
    { fast
      ll n,W,sum=0,m=0;
	 cin>>n>>W;
      ll v[n+1],w[n+1];
       for(int i=1;i<=n;i++)
	   {cin>>w[i]>>v[i];sum+=v[i];}
    ll  dp[n+1][sum+1];
      memset(dp,0,sizeof(dp));
	 for(int i=0;i<=n;i++){
		 for(int j=1;j<=sum;j++)
			 dp[i][j]=1e9;
	 }
		 
      for(int i=0;i<=n;i++)
		   dp[i][0]=0;
	 
      for(int i=1;i<=n;i++){
          for(int j=0;j<=sum;j++)
          {
              if(v[i]>j)
              dp[i][j]=dp[i-1][j];
              else dp[i][j]=min(dp[i-1][j],dp[i-1][j-v[i]]+w[i]);
              if(dp[i][j]<=W)
              m=max(m,j*1LL);
          }
      }
	 cout<<m;
    }

Measured memory_bytes: 79104
/******
author :- Mahmoud Tarek.
*******/

#include<bits/stdc++.h>

using namespace std ;

#define rg register
#define dbg(v) cerr << #v << " " << v ;
typedef long long ll ;

string a, b ;
int n, m, idx ;
int mem[3001][3001] ;
char ans[3001] ;

int gen(int i, int j){
if(i == n || j == m){
    return 0;
}
int & ret = mem[i][j] ;
if(~ret) return ret ;
ret = 0 ;
if(a[i] == b[j]){
    ret = 1 + gen(i + 1, j + 1) ;
}
int mx = max(gen(i + 1, j), gen(i, j + 1)) ;
ret = max(ret, mx) ;
return ret ;
}

bool prn = 0 ;
int alt = 0 ;

void print(int i, int j){
if(i == n || j == m){
    if(!prn && idx == alt){
        for(int k = 0 ; k < idx ; k++) cout << ans[k] ;
        prn = 1 ;
    }
    return;
}
int ret = gen(i, j) ;
if(a[i] == b[j] && ret == 1 + gen(i + 1, j + 1) && !prn){
    ans[idx++] = a[i] ;
    print(i + 1, j + 1) ;
    idx--;
}

if(ret == gen(i + 1, j) && !prn){
    print(i + 1, j) ;
}

if(ret == gen(i, j + 1) && !prn){
    print(i, j + 1) ;
}

}

int main() {
//    freopen("in.txt", "r", stdin) ;
      ios_base:: sync_with_stdio(0) ;
      cin.tie(0);
      cout.tie(0);

      cin >> a >> b ;
      n = a.size(), m = b.size() ;
      memset(mem, -1, sizeof mem) ;
      alt = gen(0, 0) ;
      print(0, 0) ;
}

/*
  Empty set of troubles.
*/


Measured memory_bytes: 35968
import java.util.Scanner;

public class Main {

	static boolean[] primes;

	static void primeSet(final int MAX){
		primes = new boolean[MAX+1];

		primes[2] = true;
		for(int i=3;i<=MAX;i+=2){
			primes[i] = true;
		}
		int rt = (int) Math.sqrt(MAX);
		for(int i=3;i<=rt;i+=2){
			if(primes[i]){
				for(int j=i*2;j<=MAX;j+=i){
					primes[j] = false;
				}
			}
		}
	}

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);

		while(true){
			int max = 0;
			int n = stdIn.nextInt();

			if(max<n){
				primeSet(n);
				max=n;
			}
			
			if(n==0){
				break;
			}

			// if(ï) then "0" ÈóÅÍÈ¢Bn=7 ... [2,5]

			int cnt = 0;
			for(int i=2;i<=n/2;i++){
				if(primes[i]&&primes[n-i]){
//					System.out.println("["+i+","+(n-i)+"]");
					cnt++;
				}
			}
			System.out.println(cnt);
		}
	}
}

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

int selectionsort(int a[], int n) {
	int count = 0;
	int minj;
	for (int i = 0; i < n; i++) {
		minj = i;
		for (int j = i; j < n; j++) {
			if(a[j] < a[minj]) {
				minj = j;
			}
		}
		swap(a[i], a[minj]);
		if (a[i] != a[minj]) {
			count++;
		}
	}
	return count;
}

int main() {
	int n;
	cin >> n;
	int a[100] = {0};
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	int c = selectionsort(a, n);
	for (int i = 0; i < n; i++) {
		cout << a[i];
		if (i != n - 1) {
			cout << ' ';
		}
	}
	cout << endl << c << endl;
	return 0;
}

Measured memory_bytes: 3120
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define sz(x) ((int)x.size())
#define all(x) (x).begin(), (x).end()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define mset(x,y) memset(x,y,sizeof(x))
#define rep(i,n) for(int i=0;i<int(n);i++)
#define per(i,n) for(int i=int(n)-1;i>=0;i--)
#define rng(i,a,b) for(int i=int(a);i<=int(b);i++)
#define gnr(i,b,a) for(int i=int(b);i>=int(a);i--)
using namespace std;
using namespace __gnu_pbds;
using ordered_set = tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>;
#ifdef LOCAL
#define dmp(...) _dmp(#__VA_ARGS__, __VA_ARGS__)
#else
#define dmp(...) (__VA_ARGS__)
#endif
template<class T> using vt=vector<T>;
template<class T> using vvt=vt<vt<T>>;
template<class TA,class TB> void chmax(TA&a,TB b){if(a<b)a=b;}
template<class TA,class TB> void chmin(TA&a,TB b){if(b<a)a=b;}
template<class TA,class TB>
ostream& operator<<(ostream& os,const pair<TA,TB>& p){
	return os<<"{"<<p.fi<<","<<p.se<<"}";
}
template<class T> ostream& operator<<(ostream& os,const vt<T>& v){
	os<<"{";for(auto& e:v)os<<e<<",";return os<<"}";
}
template<class TH> void _dmp(const char *sdbg, TH h){cout<<sdbg<<"="<<h<<endl;}
template<class TH, class... TA> void _dmp(const char *sdbg, TH h, TA...a){
while(*sdbg!=',')cout<<*sdbg++;cout<<"="<<h<<","; _dmp(sdbg+1, a...);
}
template<class T> void make_unique(vt<T>& v) {
	sort(all(v));v.erase(unique(all(v)),v.end());
}
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
int ri(){int x;cin>>x;return x;}
ll rll(){ll x;cin>>x;return x;}
vi rvi(int n){vi v;rep(i,n)v.pb(ri());return v;}
int n,m,K;
int a[11][1010];
char in[1010];
void MAIN() {
	cin>>n>>m>>K;
	rep(i,n) {
		cin>>in;
		rep(j,m)a[i][j]=in[j]-'0';
	}
	int ans=1e9;
	rep(i,1<<(n-1)) {
		vt<pii> r;
		int cut=0;
		int p=0;
		rep(j,n-1) {
			if(i>>j&1) {
				r.pb({p,j});
				p=j+1;
				cut++;
			}
		}
		r.pb({p,n-1});
		vi sum(sz(r)),cnt(sz(r));
		bool f=true;
		rep(j,m) {
			bool g=true;
			int cur=0;
			for(auto& it:r) {
				cnt[cur]=0;
				rng(k,it.fi,it.se)cnt[cur]+=a[k][j];
				//dmp(i,j,it,cnt[cur]);
				if(cnt[cur]>K)f=false;
				if(sum[cur]+cnt[cur]>K)g=false;
				cur++;
			}
			if(!f)break;
			if(!g)cut++;
			cur=0;
			for(auto& it:r) {
				if(g)sum[cur]+=cnt[cur];
				else sum[cur]=cnt[cur];
				cur++;
			}
		}
		if(!f)continue;
		ans=min(ans,cut);
	}
	cout<<ans;
}
int main() {
	ios::sync_with_stdio(false);cin.tie(0);
	int T=1;
	//cin>>T;
	for(int tt=1;tt<=T;tt++) {
		MAIN();
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
ll mod=1e9+7;
#define PI 3.1415926535897932385
#define INF 100000000000000000ll
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
string char_to_str(char c){string tem(1,c);return tem;}
 
typedef pair<long long, long long> ii;
#define S second
#define F first
ll max(ll a,ll b){if(a>b){return a;}return b;}
ll min(ll a,ll b){if(a<b){return a;}return b;}
#define MAXN 200005
// string to integer stoi() Remember: it takes string not character
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();
 
// To compile--> g++ -std=c++0x -o output one.cpp
// To run--> ./output

int main() 
{
	fastio;
	// freopen("input.txt","r",stdin);
	// freopen("output.txt","w",stdout);

	ll n,k;
	cin>>n>>k;
	ll a[n];
	for (int i = 0; i < n; ++i)
	{
		cin>>a[i];
	}

	sort(a, a+n);
	reverse(a, a+n);
	for (int i = 0; i < min(n,k); ++i)
	{
		a[i]=0;
	}
	ll sum=0;
	for (int i = 0; i < n; ++i)
	{
		sum=sum+a[i];
	}
	cout<<sum;

	return 0;
}

Measured memory_bytes: 1792