akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner() {
        s = new string[0];
        i = 0;
    }

    public string next() {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int Int() {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0) {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++) {
            Array[i] = Int() + add;
        }
        return Array;
    }

    public long Long() {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0) {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++) {
            Array[i] = Long() + add;
        }
        return Array;
    }
}
class Program {
    static Scanner cin = new Scanner();
    static void Main() {
        int N = cin.Int();
        int M = cin.Int();

        var list = new List<Info>();
        for (int i = 0; i < M; i++) {
            int p = cin.Int();
            int y = cin.Int();
            list.Add(new Info { index = i, pref = p, year = y });
        }

        foreach (var p in list.GroupBy(x => x.pref)) {
            int order = 1;
            foreach (var y in p.OrderBy(x => x.year)) {
                y.code = y.pref.ToString("D6") + order.ToString("D6");
                order++;
            }
        }

        foreach (var x in list.OrderBy(i => i.index)) {
            Console.WriteLine(x.code);
        }
        Console.ReadLine();
    }
}

class Info {
    public int index { get; set; }
    public int pref { get; set; }
    public int year { get; set; }
    public string code { get; set; }
}

Measured memory_bytes: 39788
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long MOD = 1e9 + 7, MAX = 1e18, larg = 1e5, INF = -1e9;
long long A, B, C, D, E, F, G, H, I, J, K, L, N, M, O, P, Q, R, S, T, U, V, W;
typedef long long ll;
typedef pair<ll, ll> Pa;

vector<int> to[50];
vector<Pa> edges;
bool visited[50];
bool dfs(int curr, int prev, int goal) {
	if (curr == goal) return true;
	if (visited[curr]) return false;
	bool flag = false;
	visited[curr] = true;
	rep(i, to[curr].size()) {
		int next = to[curr][i];
		if (prev == next) continue;
		flag |= dfs(next, curr, goal);
	}
	return flag;
}

int main()
{
	cin >> N >> M;
	rep(i, M) {
		cin >> A >> B; A--; B--;
		edges.push_back(Pa(A, B));
		to[A].push_back(B);
		to[B].push_back(A);
	}
	int cnt = 0;
	rep(i, M) {
		memset(visited, false, 50);
		if (!dfs(edges[i].first, edges[i].second, edges[i].second)) cnt++;
	}
	cout << cnt;
}


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

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

  string T(100, 0);
  int ans = 0;

  for (int i = 0; i < S.length(); i++) {
    T[i] = S[S.length()-i-1];
  }

  for (int i = 0; i < S.length()/2; i++) {
    if (S[i] != T[i]) {
      ans++;
    }
  }

  cout << ans << 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;

using ll = long long;

int main() {
    int N, K;
    cin >> N >> K;
    vector<int> D(K);
    rep(i, K) cin >> D[i];
    for (int i = N; i < 100000; i++) {
        string S = to_string(i);
        bool f = false;
        rep(j, S.size()) {
            rep(k, K) {
                if (S[j] - '0' == D[k]) f = true;
            }
        }
        if (f) continue;
        cout << i << "\n";
        return 0;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c,d,e,k,ans;
  cin>>a>>b>>c;
  cin>>k;
  e=max(a,b);
  d=max(c,e);
  ans=a+b+c-d;
  for (int i=0; i<k; i++){
    d=d*2;
  }
  ans+=d;
  cout<<ans;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for (int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
 
int main(void){
    string s;
    cin>>s;
    int n=s.size();
    vector<int>div;
    rep(i, n-1) if(s[i]=='R' && s[i+1] == 'L') div.push_back(i);
    int now = 0;//divのidx
    vector<pair<int, int> > LR(div.size()+1);
    rep(i, n){
        if(i>1){
            if(s[i] == 'R' && s[i-1] == 'L') now++;
        }
        if((div[now]-i)%2 == 0) LR[now].first++;
        else LR[now].second++;
    }
    int nowdiv = 0;
    rep(i, n){
        if(i==div[nowdiv]) cout<<LR[nowdiv].first<<" ";
        else if(i == div[nowdiv]+1) {
            cout<<LR[nowdiv].second<<" ";
            nowdiv++;
        }
        else cout<<0<<" ";
    }
    cout<<endl;
    return 0;
}

Measured memory_bytes: 1276
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <utility>
using namespace std;
using ll = long long int;
using pa = pair<int, int>;
int H, W;
pa dfs(vector<pa>& n,vector<vector<int>>& f, vector<string>& s, int i, int j) {
	int sha = 0;
	int dot = 0;

	if (s[i][j] == '.') { dot++; }
	else { sha++; }

	if (i!=H-1 && f[i + 1][j] == 0) {
		if (s[i][j] != s[i + 1][j]) {
			f[i + 1][j] = 1;
			pa kari = dfs(n, f, s, i+1, j);
			sha += kari.first;
			dot += kari.second;
		}
	}
	if (j!=W-1 && f[i][j+1] == 0) {
		if (s[i][j] != s[i][j+1]) {
			f[i][j+1] = 1;
			pa kari = dfs(n, f, s, i, j+1);
			sha += kari.first;
			dot += kari.second;
		}
	}
	if (i!=0 && f[i-1][j] == 0) {
		if (s[i][j] != s[i-1][j]) {
			f[i-1][j] = 1;
			pa kari = dfs(n, f, s, i-1, j);
			sha += kari.first;
			dot += kari.second;
		}
	}
	if (j!=0 && f[i][j-1] == 0) {
		if (s[i][j] != s[i][j-1]) {
			f[i][j-1] = 1;
			pa kari = dfs(n, f, s, i, j-1);
			sha += kari.first;
			dot += kari.second;
		}
	}
	return pa(sha, dot);
}

int main() {
	cin >> H >> W;
	vector<string> S(H);
	for (int i = 0; i<H; i++) {
		cin >> S[i];
	}

	vector<pa> ness;
	vector<vector<int>> flag(H, vector<int>(W));
	ll ans = 0;
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			
			if (flag[i][j] == 0) {
				flag[i][j] = 1;
				pa kari = dfs(ness, flag, S, i, j);
				ans += (ll)kari.first*kari.second;
			}
			else { continue; }
		}
	}

	cout << ans;
	return 0;
}

Measured memory_bytes: 23552
#include<stdio.h>

int main(void){
 int i;
 int N;
 int max;
 scanf("%d",&N);
  
 for(i=N;i>1;i--){
 	if(i%2==0){
      max=i;
      while(max>2){
         max=max/2;
         if(max%2!=0)
           max=-1;
         };
      
      if(max==2){
      printf("%d\n",i);
      return 0;
      }
      
    }
   
 }
printf("%d\n",i);
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include<algorithm>
#define int long long
using namespace std;
typedef pair<int,int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1000000000000

int MOD=1000000007;
int modpow(int a,int x){
  if(a<0)a+=MOD;
  int ans=1;
  while(x>0){
    if(x&1) ans=ans*a%MOD;
      a=a*a%MOD;
      x>>=1;
  }
  return ans;
}

int gyaku(int n){
    return modpow(n,MOD-2);
}
////////////////////////////////////////////////////////////
int keta(int n){
  int c=0;
  while(n>0){
    n/=10;
    c++;
  }
  return c;
}
signed main() {
  int a,b,x;
  cin>>a>>b>>x;
  if(a==0)cout<<b/x+1<<endl;
  else{
    cout<<b/x-(a-1)/x<<endl;
  }
}


Measured memory_bytes: 3564
import sys

sys.setrecursionlimit(10 ** 7)

debug = True
debug = False


def dprint(*objects):
    if debug == True:
        print(*objects)


def solve():
    N = int(input())
    A = list(map(int, input().split()))

    def check(A, x):
        ans = [x]
        for i in range(1, N):
            tmp = A[i - 1] - ans[i - 1]
            if tmp < 0:
                if i % 2 == 1:
                    return 1, ans
                else:
                    return -1, ans
            else:
                ans.append(tmp)

        tmp = A[N - 1] - (ans[N - 1])
        if x > tmp:
            return 1, ans
        elif x < tmp:
            return -1, ans
        else:
            return 0, ans

    x = min(A[0], A[N - 1])
    jump = min(A[0], A[N - 1]) // 2

    # i = 0
    while True:
        # i += 1
        # if i > 10:
        #     break
        ret, ans = check(A, x)
        if ret == 1:
            x = x - jump
        elif ret == -1:
            x = x + jump
        else:
            dprint(x, ret, ans, jump)
            break
        jump = max(jump // 2, 1)
        dprint(x, ret, ans, jump)

    print(" ".join([str(i * 2) for i in ans]))


solve()

Measured memory_bytes: 19128
#include <bits/stdc++.h>
using namespace std;
vector<int>A[100001];
int dp[100001];
bool visit[100001];
int dfs(int x)
{
	int mx=0;
	visit[x]=true;
	if(A[x].size()==0){dp[x]=0;return 0;}
	for(int i=0;i<A[x].size();i++)
		if(visit[A[x][i]]==false)
			mx=max(mx,dfs(A[x][i]));
		else
			mx=max(mx,dp[A[x][i]]);
	dp[x]=mx+1;
	return mx+1;
}
int main() {
	int n,m,a,b;
	cin>>n>>m;
	for(int i=0;i<m;i++)
	{
		cin>>a>>b;
		A[a].push_back(b);
	}
	memset(visit,false,sizeof visit);
	memset(dp,-1,sizeof dp);
	for(int i=0;i<=n;i++)
	{
		if(visit[i]==false)
		dfs(i);
	}
	sort(dp,dp+n+1,greater<int>());
	cout<<dp[0];
	return 0;
}

Measured memory_bytes: 8192
from collections import deque

n,k=map(int,input().split())
p=list(map(int,input().split()))

q=deque(p[0:k])
tmp=sum(q)
res=tmp
for i in range(k,n):
	q.append(p[i])
	tmp+=(p[i]-q.popleft())
	res=max(res,tmp)
	
print((float(res)+k)/2)

Measured memory_bytes: 25572
require 'mathn'

loop {
	n = gets.to_i
	break if n == 0
	a = []
	b = []
	n.times {
		t, c = gets.split.map &:to_i
		a << [-1/t, 1, c]
	}
	a.sort!
	t = 0
	
	until a.empty? && b.empty?
		dt1 = (a.empty? ? Float::INFINITY : -a[0][1] / a[0][0])
		dt2 = (b.empty? ? Float::INFINITY : -b[0][1] / b[0][0])
		dt = (dt1 < dt2 ? dt1 : dt2)
		a[0][1] += dt * a[0][0] if !a.empty?
		(1..a.size-1).each{|i| a[i][1] = [a[i][1] + dt * a[i][0],  a[i-1][1]].max}
		b[0][1] += dt * b[0][0] if !b.empty?
		(1..b.size-1).each{|i| b[i][1] = [b[i][1] + dt * b[i][0],  b[i-1][1]].max}

		f = []
		f << a.shift while !a.empty? && a[0][1] == 0
		f.each{|s| s[1] = 1}
		f.sort!
		b += f

		f = []
		while !b.empty? && b[0][1] == 0
			f << b.shift 
			f.pop if f[-1][2] == 1
		end
		f.each{|s| s[1] = 1; s[2] -= 1}
		f.sort!
		a += f
		t += dt
	end
	p t
}

Measured memory_bytes: 7576
#include<bits/stdc++.h>
#define pb push_back
#define mk make_pair
#define fi first
#define se second
#define ins insert
typedef std::pair<int,int> pii;
typedef long long ll;
typedef unsigned long long ull;

using namespace std;

const int N=2e5+5;

int n,a[N];

ll b[N],ans,sum;

int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d%lld",&a[i],&b[i]);
		sum+=b[i]*a[i];
		ans+=b[i];
	}
	ans+=(sum/9)-1;
	if((sum>8)&&(sum%9==0)){
		--ans;
	}
	printf("%lld\n",ans);
	return 0;
} 

Measured memory_bytes: 2560
#include <iostream>
#include <iomanip>

using namespace std;
typedef long long ll;

int main()
{
    int W, H, x, y;
    cin >> W >> H >> x >> y;

    double ans1 = (double)W * H / 2;
    bool ans2 = (x + x == W && y + y == H);

    cout << fixed << setprecision(10) << ans1;
    cout << " " << ans2 << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.stream.IntStream;

public class Main {
    private static java.util.Scanner scanner = new java.util.Scanner(System.in);

    private static int n, a, b, c, l[];
    public static void main(String[] args) {
        n = scanner.nextInt();
        a = scanner.nextInt();
        b = scanner.nextInt();
        c = scanner.nextInt();
        l = IntStream.range(0, n).map(i -> scanner.nextInt()).toArray();

        System.out.println(dfs(0, 0, 0, 0));
    }

    private static int dfs(int cur, int a0, int b0, int c0) {
        if (cur == n)
            return (Math.min(Math.min(a0, b0), c0) > 0 ? Math.abs(a0 - a) + Math.abs(b0 - b) + Math.abs(c0 - c) - 30 : 1000000000);

        int ret0 = dfs(cur + 1, a0, b0, c0);
        int ret1 = dfs(cur + 1, a0 + l[cur], b0, c0) + 10;
        int ret2 = dfs(cur + 1, a0, b0 + l[cur], c0) + 10;
        int ret3 = dfs(cur + 1, a0, b0, c0 + l[cur]) + 10;

        return Math.min(Math.min(Math.min(ret0, ret1), ret2), ret3);
    }
}

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

int main() {
  int a,b,x;
  cin >> a >> b >> x;
  if(x-a <= b && x-a>=0)cout << "YES" << endl;
  else cout << "NO" << endl;
}

Measured memory_bytes: 3624
import numpy as np
N, L = map(int,input().split())
AL = []
ans = 0

for i in range(1, N+1):
    Ap = L + i - 1
    AL.append(Ap)
tmp = sorted(np.abs(AL))[0] 

for i in range(1, N+1):
    App = L + i - 1
    if abs(App) != tmp:
        ans += App

print(ans)

Measured memory_bytes: 27072
#include<bits/stdc++.h>
using namespace std;
// #include <ext/pb_ds/assoc_container.hpp>
// using namespace __gnu_pbds;
// typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
#define int long long
#define pb push_back
#define inf 1e9
#define mod 1000000007

const int maxn = 100010;
vector<int> adj[maxn];
int dp[maxn]; // dp[i] = length of longest path starting at node i

//we have to check for every node and we will find overlapping paths that's where dp comes in

int fun(int src)
{
	if (dp[src] != -1)
		return dp[src];

	bool leaf = 1;
	int x = 0;
	for (int child : adj[src])
	{
		leaf = 0;
		x = max(fun(child), x);
	}
	return dp[src] = leaf ? 0 : 1 + x; // if it is leaf then it will have no child so ans is simply zero
}


void solve()
{
	int n, m;
	cin >> n >> m;
	memset(dp, -1, sizeof(dp));

	for (int i = 0; i < m; i++)
	{
		int u, v;
		cin >> u >> v;
		adj[u].push_back(v);
	}

	int len = 0;
	for (int i = 1; i <= n; i++) // checking for every child node
		len = max(len, fun(i));

	cout << len;


}

int32_t main()
{
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	solve();
	return 0;
}


Measured memory_bytes: 8576
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()
    {
        var sw = Console.ReadLine().Split().Select(int.Parse).ToArray();

        Console.WriteLine(sw[0] <= sw[1] ? "unsafe" : "safe");
    }
}


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

using namespace std;

typedef long long ll;

const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = (ll)1e9 + 7;

int main()
{
  string s; cin >> s;
  int n = s.size();
  int i = 0, j = n - 1;
  while (s[i] != 'A' and i < n) { ++i; }
  while (s[j] != 'Z' and j >= 0) { --j; }
  int ans = j - i + 1;
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<complex>
using namespace std;
int a[99],b[99],c[99],d[99],n,m;
int main(){
	cin>>n>>m;
	for(int i=0;i<n;i++)cin>>a[i]>>b[i];
	for(int j=0;j<m;j++)cin>>c[j]>>d[j];
	for(int i=0;i<n;i++){
		int ans=0;
		for(int j=1;j<m;j++){
			if(abs(a[i]-c[j])+abs(b[i]-d[j])<abs(a[i]-c[ans])+abs(b[i]-d[ans])){
				ans=j;
			}
		}
		cout<<ans+1<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  scanf("%d", &n);
  int arr[n+1];
  pair<int, int> tvs[n];
  for(int i = 1; i <= n; i++){
    scanf("%d", &arr[i]);
    tvs[i-1] = make_pair(arr[i], i);
  }
  sort(tvs, tvs+n);
  vector<int> adjlist[n+1];
  for(int i = 1; i < n; i++){
    int a, b;
    scanf("%d %d", &a, &b);
    adjlist[a].push_back(b);
    adjlist[b].push_back(a);
  }
  vector<int> ans;
  for(int i = 0; i < n; i++){
    int ving = tvs[i].second;
    for(int j = 0; j < adjlist[ving].size(); j++){
      if(arr[adjlist[ving][j]] < arr[ving]){
        arr[ving] = 1000000009;
        ans.push_back(ving);
        break;
      }
    }
  }
  sort(ans.begin(), ans.end());
  for(int i = 0; i < ans.size(); i++) printf("%d ", ans[i]);
}

Measured memory_bytes: 512
N,D = map(int, input().split())
XY = [list(map(int, input().split())) for i in range(N)]
ans = 0
for i in range(N):
    if (XY[i][0]**2 + XY[i][1]**2)**(1/2) <= D:
        ans+=1
print(ans)

Measured memory_bytes: 45828
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <iomanip>
#include <bitset>
using namespace std;

typedef long long ll;

int N, Q;
ll x;
ll a[100005], sum[100005], jmp[100005];

bool check(int idx) {
	if (a[idx] < x) return false;
	ll t = abs(a[idx] - x);
	int lo = -1, hi = idx + 1;
	while (hi - lo > 1) {
		int mid = lo + (hi - lo) / 2;
		if (t < abs(x - a[mid])) lo = mid;
		else hi = mid;
	}
	return N - 1 - idx < idx - lo;
}


int main() {
	cin >> N >> Q;
	for (int i = 0; i < N; i++) cin >> a[i];
	for (int i = 0; i < N; i++) sum[i + 1] = sum[i] + a[i];
	jmp[1] = a[0];
	for (int i = 1; i < N; i++) jmp[i + 1] = jmp[i - 1] + a[i];

	while (Q--) {
		cin >> x;

		int lo = -1, hi = N;
		while (hi - lo > 1) {
			int mid = lo + (hi - lo) / 2;
			if (check(mid)) hi = mid;
			else lo = mid;
		}
		//cout << lo << " " << hi << endl;
		ll ans = sum[N] - sum[hi];
		if (2*hi - N >= 0) ans += jmp[2 * hi - N];
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 4096
#include<bits/stdc++.h>
using namespace std;
 
#define TRACE
 
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
 
#define ll   long 
#define ld long double
#define all(v) v.begin(),v.end()
#define pb push_back
#define S second
#define F first
#define die() return 0;
 
 
#define md          1000000007
#define fmd         998244353 
#define M           200011
#define N            18
ll exp(ll a,ll b){if(b<0)return 0;ll r=1;while(b){if(b&1)r=r*a%md,r%=md;a=a*a%md;b/=2;}return r;}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
class BIT{
public:
    int n;
    vector<ll> B;
    BIT(int sz){
        n=sz;
        B=vector<ll> (n+1);
    }
    void up(int x,int y=1){
        for(;x<=n;x+=x&-x)B[x]+=y;
    }
    ll sum(int x){int s=0;
        for(;x>=1;x-=x&-x)s+=B[x];
        return s;
    }
 
};
vector<ll> v;
ll les(ll po){
	int i,j,k,n=v.size()-1;
	vector<int > d(n+1);
	for(i=1;i<=n;++i){
		if(v[i]>=po)d[i]=1;
		else d[i]=-1;
		d[i]+=d[i-1];
	}
 
	int c=0;
	map<int ,int > h1;
	for(i=0;i<=n;++i)h1[d[i]];
	for(auto x:h1)h1[x.F]=++c;
		BIT b(c);
	ll ans=0;
	b.up(h1[d[0]]);
	for(i=1;i<=n;++i){
		ans+=b.sum(h1[d[i]]);
		b.up(h1[d[i]]);
	}
	return ans;
 
 
}
 
int solve(){
    ll n,i,j,k,m,x,y,z;
    cin>>n;
    v=vector<ll> (n+1);
    ll p=1;
    for(i=1;i<=n;++i){cin>>v[i];p=max(p,v[i]);}
 
    if(n==1){
    	cout<<v[1]<<"\n";die();
    }
    x=0;ll go=(n*(n+1))/2;
// trace(les(20));
	for(;p>=1;p/=2){
		while(x+p<=1e9&&les(x+p)>=go/2)x+=p;
	}
	// trace(les(x));
	cout<<x<<"\n";
 
 
 
 
 
 
 
 
 
    // trace(f(2,2));
 
 
 
	die();
 
}
 
 
int main(){
 
 
#ifndef ONLINE_JUDGE
    double _tBeg=clock();
#endif
 
     
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
 
    int t;
    t=1;;
    // prec();
    // cin>>t;
 
    while(t--){
 
        solve();
    }
 
 
 
 
 
 
#ifndef ONLINE_JUDGE
    double _tEnd=clock();
    // printf("\ntotal time %.6f\n",(_tEnd-_tBeg)/CLOCKS_PER_SEC);
#endif
 
    die();
}

Measured memory_bytes: 6936
#include <iostream>
#include <set>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <string>
#include <stack>
#include <cmath>
#include <cstring>
#include <climits>
using namespace std;

#define FORN(i, j, k) for(int i=j;i<k;i++)
#define FORR(i, j, k) for(int i=j;i>=k;i--)
#define REP(i, n) FORN(i, 0, n)
#define int long long
#define pii pair<int, int>
#define vi vector<int>
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define endl '\n'

const int MODO = 1e+9 + 7;
int N, W;

void solve(){
	int w[N], v[N];
	REP(i, N){
		cin >> w[i] >> v[i];
	}
	int dp[N+1][W+1];
	REP(i, N+1){
		REP(j, W+1){
			if(i==0 || j==0){
				dp[i][j] = 0;
			}
			else{
				dp[i][j] = dp[i-1][j];
				if(j>=w[i-1]){
					dp[i][j] = max(dp[i][j], dp[i-1][j-w[i-1]]+v[i-1]);
				}
			}
		}
	}
	cout << dp[N][W] << endl;
	return;
}

int32_t main(){
		ios_base::sync_with_stdio(false);
		cin.tie(NULL);
		cin >> N >> W;
		solve();
		return 0;
}



Measured memory_bytes: 82452
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<iomanip>
#include<bitset>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,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 fi first
#define sc second
#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll 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())

const int MAX = 510000;
const int MOD = 1000000007;

int main(){
  ll N, K; cin >> N >> K;
  vector<ll> a(N);
  rep(i,N) cin >> a[i];
  rep(i,N) a[i]--;

  ll zan = K;
  ll now = 0;
  map<ll,ll> m;
  m[0] ++;
  vector<ll> tr;
  tr.pb(0);
  while(1){
    // 移動してzanが0になったら終了
    now = a[now];
    zan--;
    if(zan == 0){
      cout << now + 1 << endl;
      return 0;
    }
    tr.pb(now);
    // mapが重複したらloopの出来上がり
    m[now]++;
    if(m[now] > 1) break;
  }

  // cirを求める
  ll si = tr.size();
  ll start = 0;
  rep(i,si - 1){
    if(tr[i] == tr.back()){
      start = i;
    }
  }
  // si - 1 と startにある状態
  ll cir = (si - 1) - start;
  // marが0ならstartに戻っている状態
  ll mar = (K - start) % cir;

  // rep(i,si) cout << tr[i] << " ";
  // cout << endl;
  // cout << start << " " << cir << endl;
  cout << tr[start + mar] + 1 << endl;
}


Measured memory_bytes: 15828
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
using namespace std;

const int MOD = 1000000007;

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

    vector<int> dp(4, 0);
    dp[0] = 1;
    for(int i=0; i<63; ++i){
        vector<int> nextDp(4, 0);
        for(int a=0; a<4; ++a){
            for(int j=0; j<3; ++j){
                int sum = (a & 1) + j;
                int b = sum / 2;
                if((sum & 1) > ((n>>i)&1) || ((sum & 1) == ((n>>i)&1) && (a & 2)))
                    b |= 2;
                nextDp[b] += dp[a];
                nextDp[b] %= MOD;
            }
        }
        dp.swap(nextDp);
    }
    cout << dp[0] << endl;

    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <tuple>
using namespace std;
using ll = long long;
const int INF = 1e9;
const int MOD = 1e9 + 7;

int main()
{
  int n, a, b, c;
  cin >> n >> a >> b >> c;
  vector<int> l(n);
  for (auto &e : l)
    cin >> e;

  int ans = INF;
  bool flag = true;
  sort(l.begin(), l.end());
  do
  {
    vector<int> sum(n + 1);
    for (int i = 0; i < n; ++i)
    {
      sum[i + 1] = sum[i] + l[i];
    }
    for (int h = 1; h <= n; ++h)
    {
      int hh = sum[h];
      for (int i = h + 1; i <= n; ++i)
      {
        int ii = sum[i] - sum[h];
        for (int j = i + 1; j <= n; ++j)
        {
          int jj = sum[j] - sum[i];
          int h_res = (h - 1) * 10 + abs(hh - a);
          int i_res = (i - h - 1) * 10 + abs(ii - b);
          int j_res = (j - i - 1) * 10 + abs(jj - c);
          ans = min(ans, h_res + i_res + j_res);
        }
      }
    }
  } while (next_permutation(l.begin(), l.end()));

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<pair<int, ll>, int>;
#define rep(i,n) for(int i=0;i<n;i++)
inline ll in() {ll x;cin>>x;return x;}

const int N = 305;
const int INF = 1001001001;
const ll LINF = 1LL<<60;

vector<vector<ll>> g(N, vector<ll>(N, LINF));
vector<vector<pair<int, ll>>> d(N, vector<pair<int, ll>>(N, {INF, LINF})); // pair<給油回数、移動後の燃料の残量>

int main() {
  int n = in(), m = in();
  ll l = in();

  rep(i,m) {
    int a = in() - 1, b = in() - 1;
    g[a][b] = g[b][a] = in();
  }

  rep(s,n) {
    //d[s][s] = {0, 0};
    priority_queue<P, vector<P>, greater<P>> q;
    //q.push({d[s][s], s});
    q.push({{0, 0}, s});
    while (!q.empty()) {
      auto p = q.top();
      q.pop();

      ll v = p.second;
      ll kaisuu = p.first.first;
      ll used = p.first.second;
      
      if (p.first > d[s][v]) continue;
      rep(nv,n) {
        if (nv == v) continue;
        if (g[v][nv] > l) continue;
        ll nused = used + g[v][nv];
        pair<int, ll> np;
        if (nused > l) np = {kaisuu + 1, g[v][nv]};
        else np = {kaisuu, nused};

        if (d[s][nv] > np) { // 給油回数と燃料の残量が少なくなっていれば更新してqueueにpushする
          d[s][nv] = np;
          q.push({np, nv});
        }
      }
    }
  }

  int q = in();
  rep(i, q) {
    int s = in() - 1, t = in() - 1;
    if (d[s][t].first == INF) cout << -1 << endl;
    else cout << d[s][t].first << endl;        
  }
  return 0;
}

Measured memory_bytes: 3964
/*Saurav Paul*/
#include<bits/stdc++.h>
using namespace std;


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

    return 0;
}


Measured memory_bytes: 256
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


def main():
    d = dict()
    d["a"] = list(input())
    d["b"] = list(input())
    d["c"] = list(input())

    now = "a"
    while True:
        if len(d[now]) == 0:
            print(now.upper())
            return
        now = d[now].pop(0)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3948
#pragma GCC target ("avx2")
#pragma GCC optimize ("unroll-loops")
#pragma GCC optimize ("O3")
#include "bits/stdc++.h"
#include <unordered_set>
#include <unordered_map>
#include <random>
using namespace std;
typedef long long ll;
const ll MOD = /*1'000'000'007LL;*/ 998'244'353LL;
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int (i)=0; (i)<(n); (i)++)
const int dx[4]={ 1,0,-1,0 };
const int dy[4]={ 0,1,0,-1 };

string S;
int K;
vector<int> v, sum;

ll dp[305][305][305], memo1[305][305][305], memo2[305][305][305];

ll solve(int, int, int);

ll calc1(int n, int k, int d){
	if(k < 0 || d < 0) return 0;
	if(memo1[n][k][d] != -1) return memo1[n][k][d];
	return memo1[n][k][d] = (calc1(n, k-1, d-1) + solve(n, k, d)) % MOD;
}

ll calc2(int n, int k, int d){
	if(k < 0 || d < 0) return 0;
	if(memo2[n][k][d] != -1) return memo2[n][k][d];
	return memo2[n][k][d] = (calc2(n, k, d-1) + solve(n, k, d)) % MOD;
}

ll solve(int n, int k, int d){
	if(k < 0) return 0;
	if(n == 0){
		return 1;
	}
	if(dp[n][k][d] != -1) return dp[n][k][d];
	ll ret = 0;
	/*for(int i=0; i<=v[n]; i++){
		ret += solve(n-1, k-v[n]+i, d+i);
	}*/
	ret += calc1(n-1, k, d+v[n]) - calc1(n-1, k-v[n]-1, d-1) + MOD;
	/*for(int i=v[n]+1; i<=sum[n]-d; i++){
		ret += solve(n-1, k, d+i);
	}*/
	ret += calc2(n-1, k, sum[n]) - calc2(n-1, k, d+v[n]) + MOD;
	return dp[n][k][d] = ret % MOD;
}

signed main(){
	cin >> S >> K;
	K = min(K, 302);
	int cnt = 0;
	rep(i, S.size()){
		if(S[i] == '0'){
			v.pb(cnt);
			cnt = 0;
		}
		else cnt++;
	}
	if(v.size() == 0){
		cout << 1 << endl;
		return 0;
	}
	sum.resize(v.size());
	sum.back() = v.back() + cnt;
	for(int i=v.size()-2; i>=0; i--){
		sum[i] = sum[i+1] + v[i];
	}
	
	memset(dp, -1, sizeof(dp));
	memset(memo1, -1, sizeof(memo1));
	memset(memo2, -1, sizeof(memo2));
	ll ans = 0;
	for(int i=0; i<=cnt; i++){
		ans += solve(v.size()-1, K-(cnt-i), i);
	}
	cout << ans % MOD << endl; 
}

Measured memory_bytes: 668572
# -*- coding: utf-8 -*-

s = input()

if s == "SUN":
    print(7)
elif s == "MON":
    print(6)
elif s == "TUE":
    print(5)
elif s == "WED":
    print(4)
elif s == "THU":
    print(3)
elif s == "FRI":
    print(2)
else:
    print(1)


Measured memory_bytes: 2940
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>

using namespace std;

void reverse(vector<int>& as)
{
  int l = 0;
  int u = as.size() - 1;
  while (l < u) {
    swap(as[l], as[u]);
    ++l;
    --u;
  }
}

void dump(int n)
{
  vector<int> as;
  as.reserve(n);
  for (int i = 1; i <= n; ++i) {
    as.push_back(i);
    reverse(as);
  }
  for (const auto& a: as) cout << a << " ";
  cout << endl;
}

int main()
{
  int n;
  cin >> n;
  vector<int> as;
  as.reserve(n);
  for (int i = 0; i <n ; ++i) {
    int a;
    cin >> a;
    as.push_back(a);
  }
  bool first = true;
  for (int i = n; i > 0; i -= 2) {
    if (first) {
      first = false;
    } else {
      cout << " ";
    }
    cout << as[i-1];
  }
  for (int i = n % 2 ? 2 : 1; i <= n; i += 2) cout << " " << as[i-1];
  cout << endl;
  return 0;
}

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

int main() {
  string s1, s2, s3;
  cin >> s1 >> s2 >> s3;

  char c1 = toupper(s1[0]);
  char c2 = toupper(s2[0]);
  char c3 = toupper(s3[0]);
  
  cout << c1 << c2 << c3 << endl;  

  return 0;
}


Measured memory_bytes: 3600
# include <bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin >> n;
	for(int i = 1; i < 10; i ++){
		for(int j = 1; j < 10; j ++){
			if(i * j == n){
				cout << "Yes\n";
				return 0;
			}
		}
	}
	cout << "No\n";
}

Measured memory_bytes: 256
n = gets.to_i
h = gets.split.map(&:to_i)
result = 0
start = 0

while start<=n-1
  if h[start]==0
    start += 1 
    next
  end
  (start..n-1).each do |i|
    h[i]==0 ? break : h[i] -= 1
  end
  result += 1
end

puts result

Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) Rep(i, 0, n)
#define all(a) (a).begin(), (a).end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int mod = 1000000007;
//const int mod = 998244353;

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

    int n, m;
    cin >> n >> m;
    cout << (n == m ? "Yes" : "No") << endl;
}


Measured memory_bytes: 3668
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>

int main()
{
  int a, b;
  int n;
  bool ans;

  scanf("%d %d", &a, &b);
  
  if (b == 100) {
    n = a * 1000 + b;
  } else if (b >= 10) {
    n = a * 100 + b;
  } else {
    n = a * 10 + b;
  }

  ans = false;
  for (int i = 0; i <= 1000000; i++) {
    if (i * i == n){
      ans = true;
    }
  }
  
  if (ans){
    printf("Yes\n");
  } else {
    printf("No\n");
  }
}


Measured memory_bytes: 128
using System;

namespace AOJ
{
    class Program
    {
        static void Main()
        {
            string[] line = Console.ReadLine().Split(' ');
            int x = int.Parse(line[0]);
            int y = int.Parse(line[1]);
            int z = int.Parse(line[2]);

            string output = (x < y && y < z) ? "Yes" : "No";

            Console.WriteLine(output);
        }
    }
}

Measured memory_bytes: 5292
//
// Created on 2020/09/06.
//


#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <ios>
#include <iomanip>
#include <numeric>

#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long ll;
using namespace std;
const long long LINF =1e18;
const int INF = 1e9;



int main() {
    int d,t,s;
    cin>>d>>t>>s;
    if(t * s >= d){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
    return 0;
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
int sum(long long j)
{
	int res = 0;
	while(j)
	{
		res += j % 10;
		j /= 10;
	}
	return res;
}
int main ()
{
	long long n;
	cin >> n;
	stringstream s1;
	string s;
	s1 << n;
	s1 >> s;
	int j = s.size(), l = j;
	s1.clear();
	string res;
	long long ans = 0, a = 1;
	while(j--)
	{
		ans += a * 9;
		a *= 10;
	}
	s1 << ans;
	s1 >> res;
	s1.clear();
	for(int i = 0; i < l; i++)
	{
		if(ans < n) break;
		while(ans > n)
		{
			int h = res[i] - '0';
			h--;
			res[i] = h + '0';
			s1 << res;
			s1 >> ans;
			s1.clear();
		}
	}
	cout << sum(ans);
}

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

using namespace std;
using ll = int64_t;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
using mii = map<int, int>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
using tpi = tuple<int, int, int>;

using vqi = vector<queue<int>>;
using vpi = vector<pii>;
using bs = bitset<60>;
using vbi = vector<bs>;

ll gcd(ll a, ll b) {
    if (a < b) {
        swap(a, 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; }

constexpr int64_t __pow_mod(int64_t n, int64_t p, int64_t mod) noexcept {
    if (p == 0) {
        return 1;
    }
    if (p % 2 == 0) {
        int64_t t = __pow_mod(n, p / 2, mod);
        return (t * t) % mod;
    }
    return (n * (__pow_mod(n, p - 1, mod) % mod)) % mod;
}

constexpr int64_t pow_mod(int64_t n, int64_t p, int64_t mod) noexcept {
    int64_t res = __pow_mod(n, p, mod);
    if (res == 0) {
        res = mod;
    }
    return res;
}

void solve(long long N, long long D, long long A, std::vector<pll> E) {
    sort(E.begin(), E.end());
    deque<pll> q;
    q.push_back(E[0]);
    ll ans = E[0].second;
    ll num = E[0].second;
    for (int i = 1; i < N; i++) {
        while (!q.empty() && q.front().first + 2 * D < E[i].first) {
            num -= q.front().second;
            q.pop_front();
        }
        E[i].second -= num;
        if (E[i].second > 0) {
            ans += E[i].second;
            num += E[i].second;
            q.push_back(E[i]);
        }
    }
    cout << ans << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You
// use the default template now. You can remove this line by using your custom
// template)
int main() {
    long long N;
    std::cin >> N;
    long long D;
    std::cin >> D;
    long long A;
    std::cin >> A;
    vector<pll> E(N);
    for (int i = 0; i < N; i++) {
        ll x, h;
        std::cin >> x;
        std::cin >> h;
        ll play = h / A;
        if (h % A != 0) {
            play++;
        }
        E[i].first = x;
        E[i].second = play;
    }
    solve(N, D, A, std::move(E));
    return 0;
}


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

int main(){
        int x, y;
        char op;
        while(1){
                cin >> x >> op >> y;
                if(op == '?') break;

                if(op == '+'){
                        cout << x+y << endl;
                }else if(op == '-') {
                        cout << x-y << endl;
                }else if(op == '*') {
                        cout << x*y << endl;
                }else if(op == '/') {
                        cout << x/y << endl;
                }else{
                        break;
                }

        }
        return 0;
}

Measured memory_bytes: 3084
using System;
using System.Collections.Generic;

namespace NTL1_D
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int ans = n;
            var P = new List<int>();
            eratos(P, (int)(Math.Sqrt(n)));
            var L = new HashSet<int>();
            int i = 0;
            while (true)
            {
                if (n % P[i] != 0)
                {
                    i++;
                }
                else
                {
                    n /= P[i];
                    L.Add(P[i]);
                }
                if (i == P.Count)
                {
                    L.Add(n);
                    break;
                }
                if (n == 1)
                {
                    break;
                }

            }
      
           //Console.WriteLine(string.Join(" ",L));
            
            foreach (var s in L)
            {
                ans = ans - ans / s;
            }
            Console.WriteLine(ans);
        }
        //2???n?????§????´???°????????????(n>=2)
        static void eratos(List<int> P, int n)
        {
            var a = new bool[n + 1];
            a[0] = a[1] = true;
            int i;
            for (i = 2; i * i <= n; i++)
            {
                if (!a[i])
                {
                    P.Add(i);
                    int j = i << 1;
                    while (j <= n)
                    {
                        a[j] = true;
                        j = j + i;
                    }
                }
            }
            for (; i <= n; i++) if (!a[i]) P.Add(i);
        }

    }
}

Measured memory_bytes: 10168
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define ll long long
#define P pair<int,int>
const int MOD = 1000000007;
const int INF = 1001001001;
const ll LINF = 9223372036854775807;
using namespace std;

int main() {
    int n, m;
    cin >> n >> m;
    struct Edge {
        int from, to;
        ll cost;
        Edge (int from_, int to_, ll cost_) {
            from = from_;
            to = to_;
            cost = cost_;
        }
    };
    int from, to;
    ll cost;
    vector<Edge> e;
    rep(i,m) {
        cin >> from >> to >> cost;
        from--; to--;
        e.emplace_back(from, to, -cost);
    }

    vector<ll> dp(n,LINF);
    int s = 0;
    dp[s] = 0;

    rep(i,n) {
        rep(j,m) {
            if (dp[e[j].from] == LINF) continue;
            else if (dp[e[j].to] > dp[e[j].from] + e[j].cost) {
                if (e[j].to == n-1 && i == n-1) {
                    cout << "inf" << endl;
                    return 0;
                }
                dp[e[j].to] = dp[e[j].from] + e[j].cost;
            }
        }
    }
    
    cout << -dp[n-1] << endl;
    return 0;
}

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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define sf scanf
#define pf printf
#define pb push_back
#define mp make_pair
#define PI ( acos(-1.0) )
#define mod 1000000007LL
#define maxn 100005
#define IN freopen("C.in","r",stdin)
#define OUT freopen("output.txt","w",stdout)
#define FOR(i,a,b) for(i=a ; i<=b ; i++)
#define DBG pf("Hi\n")
#define INF 1000000000
#define i64 long long int
#define eps (1e-8)
#define xx first
#define yy second
#define ln 17
#define off 2
#define sq(x) ((x)*(x))

using namespace __gnu_pbds;
using namespace std ;

// typedef tree< i64, null_type, less<i64>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
// typedef pair<i64, i64> pii;

int main()
{
    i64 i , j , k , l , m , n ;

    scanf("%lld %lld",&n,&k) ;

    i64 ans = 0LL ;

    for(i=k+1 ; i<=n ; i++)
    {
        j = n/i ;
        l = n%i ;

        ans += j*(i-k) ;
        ans += max(0LL,l-k+1) ;
    //    printf("%lld\n",ans) ;
    }

    if(k==0) ans -= n ;

    printf("%lld\n",ans) ;
    return 0 ;
}


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

using namespace std;
int main()
{
  vector<int> pqr(3,0);
  cin >> pqr[0] >> pqr[1] >> pqr[2];
  sort(pqr.begin(), pqr.end());
  cout << pqr[0]+pqr[1] << endl;

  return 0;
}


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

int main(){
	int total;
	int books;
        int count=0;
       
	while(true){
         if(count==0){
           cin>>total;
           if(total==0){
               break;
           }
           count++;
          }else{
           cin>>books;
           total-=books;
           count++;
          }
         if(count==10){
           cout<<total<<'\n';
           count=0;
         }
	}
	return 0;
}

Measured memory_bytes: 1160
is k [] = [k]
is k (x:xs)
  | k <= x    = (k:x:xs)
  | otherwise = x:(is k xs)

ans n i x
  | n == i    = []
  | otherwise =
    let k = x!!i
        t = drop (i+1) x
        h = is k $ take i x
        r = h ++ t
    in
      (r:ans n (i+1) r)

main = do
  n <- getLine
  i <- getLine
  let n' = read n :: Int
      i' = map read $ words i :: [Int]
      o  = ans n' 0 i'
  mapM_ putStrLn $ map unwords $ map (map show) o

Measured memory_bytes: 3988
# include <bits/stdc++.h>
using namespace std;
# define fi cin
# define fo cout
# define x first
# define y second
# define ll long long
# define IOS ios_base :: sync_with_stdio(0)
int v[1 << 20];
int main(void)
{
    #ifdef CF
    freopen("input","r",stdin);
    #endif // CF
    srand(time(0));
    fo << fixed << setprecision(7);
    cerr << fixed << setprecision(7);
    string s;
    fi>>s;
    int n = s.length();
    for (char c = 'a';c <= 'z';++c)
    {
        for (int i = 1;i <= n;++i) v[i] = s[i-1] == c;
        pair < int , int > cnt = {0,0};
        for (int i = 1;i <= n;++i)
            v[i] += v[i-1];
        for (int i = 2;i <= n;++i)
        {
            if (i > 2) cnt = min(cnt,{v[i - 2] + v[i - 2] - i + 2,i - 2});
            if (v[i] + v[i] - i > cnt.x) return fo << cnt.y + 1 << ' ' << i << '\n',0;
        }
    }
    return puts("-1 -1") * 0;
    return 0;
}




Measured memory_bytes: 896
import java.util.*;
import java.io.*;

public class Main {
    static IO io = new IO();
    public static void main(String[] args) {

        int a = io.nextInt();
        int b = io.nextInt();
        System.out.println(a*b + " " + 2*(a+b));

    }

    static class IO extends PrintWriter {
        private final InputStream in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int buflen = 0;

        IO() {
            this(System.in);
        }

        IO(InputStream source) {
            super(System.out);
            this.in = source;
        }

        boolean hasNextByte() {
            if (ptr < buflen) return true;
            else {
                ptr = 0;
                try {
                    buflen = in.read(buffer);
                } catch (IOException e) {
                    e.printStackTrace();
                }
                if (buflen <= 0) return false;
            }
            return true;
        }

        int readByte() {
            if (hasNextByte()) return buffer[ptr++];
            else return -1;
        }

        boolean isPrintableChar(int c) {
            return 33 <= c && c <= 126;
        }

        void skipUnprintable() {
            while (hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;
        }

        boolean hasNext() {
            skipUnprintable();
            return hasNextByte();
        }

        long nextLong() {
            if (!hasNext()) throw new NoSuchElementException();
            long n = 0;
            boolean minus = false;
            int b = readByte();
            if (b == '-') {
                minus = true;
                b = readByte();
            }
            if (b < '0' || '9' < b) throw new NumberFormatException();
            while (true) {
                if ('0' <= b && b <= '9') {
                    n *= 10;
                    n += b - '0';
                } else if (b == -1 || !isPrintableChar(b)) return minus ? -n : n;
                else throw new NumberFormatException();
                b = readByte();
            }
        }

        int nextInt() {
            long nl = nextLong();
            if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
            return (int) nl;
        }

        public void close() {
            super.close();
            try {
                in.close();
            } catch (IOException ignored) {
            }
        }
    }
}

Measured memory_bytes: 24196
#include<iostream>
#include<cstdlib>
#include<cstdio>
#include<sstream>
#include<vector>
#include<map>
 
using namespace std;
string t,num;
int mex;
int cnt;
int int_t;
string ans_s;
 
void dfs(int p,int total,string s)
{
  //cout << "now s : " <<s << " p = " << p <<" total = " << total << endl; 
  if(p >= num.size())
    {
      if(int_t >= total && total == mex)
    {
      cnt++;
    }
      else if(int_t >= total && total > mex)
    {
      cnt = 1;
      mex = total;
      ans_s = s;
    }
      return;
    }
 
  for(int i=p;i<num.size();i++)
    {
      dfs(i+1,total + (atoi)(num.substr(p,i-p+1).c_str()),s+" "+num.substr(p,i-p+1));
    }
 
     
 
}
 
int main()
{
  
  while(cin >> t >> num,((atoi)(t.c_str()) || (atoi)(num.c_str())))
    {
      int pre = 0;
      for(int i=0;i<num.size();i++)
    {
      pre += num[i]-'0';
    }      
     
 
      bool F = false;
      int_t = (atoi)(t.c_str());
      if(t == num)
    {
      cout << t << " " << num << endl;
      F = true;
    }
 
      if(!F)
    {
      mex = -1,cnt = 0;
      dfs(0,0,"");  
      
      if(cnt > 1)
        cout << "rejected" << endl;
      else if(mex != -1)
        cout << mex << ans_s << endl;
      else
        cout << "error" << endl;
    }
       
      
 
 
    }
  return 0;
}

Measured memory_bytes: 1208
import java.util.*;

class Main{
	public static void main(String[] $){
		//入力
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String s = sc.next();
		sc.close();

		//処理
		//String[] pat = {"SS", "SW", "WS", "WW"};
		boolean[] bs = new boolean[s.length()];
		for(int i = 0; i < s.length(); i++){bs[i] = s.charAt(i) == 'o';}
		boolean[][] pat = {{true,true}, {true,false}, {false,true}, {false,false}};
		for(boolean[] mat : pat){
			ArrayList<Boolean> ans = new ArrayList<>();
			ans.add(mat[0]);ans.add(mat[1]);
			for(int i = 1; i < n-1; i++){
				ans.add((ans.get(i) == ans.get(i-1)) == bs[i]);
			}

			boolean ok = (ans.get(0) == bs[0]) == (ans.get(n-1) == ans.get(1)) && (ans.get(n-1) == bs[n-1]) == (ans.get(n-2) == ans.get(0));
			if(ok){
				for(int i = 0; i < n; i++){
					if(ans.get(i)) System.out.print('S');
					else System.out.print('W');
				}
				System.out.println();
				return;
			}
		}

		//出力
		System.out.println(-1);
	}
}


Measured memory_bytes: 44720