akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include<bits/stdc++.h>
#include <ios>
#include <iterator>
using namespace std;
#define ll long long
#define f(n)  for(int i=0;i<n;i++) 
#define pb push_back
#define take(t) int t;cin>>t
#define np nake_pair
#define vi vector<int>
#define all(v)   v.begin(),v.end()  
#define w(t)   while(t--)
void speed (){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}
void swap(int *a,int *b){
    int t=*a;
    *a=*b;
    *b=t;
}
int main()
{
  
  speed();
int a,b,c;
cin>>a>>b>>c;
cout<<c<<" "<<a<<" "<<b;
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 ll long long int
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define INF 0x3f3f3f3f

using namespace std;
using namespace __gnu_pbds;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef tree<pair<int,int>,null_type, less<pair<int,int>>,rb_tree_tag,tree_order_statistics_node_update>   ordered_set;
const int N=1e5+10, mod=1e9+7;
ll dp[N][110];

int main(){
	ios_base::sync_with_stdio(0);	cin.tie(0);
	int n,w,i,j;
	cin>>n>>w;
	
	for(i=0;i<N;i++)for(j=0;j<110;j++) dp[i][j]=INF;
	
	for(i=0;i<n;i++){
		int a,b;
		cin>>a>>b;  // weight,value
		if( i==0 ){
			dp[b][i]=a;
		}else{
			for(j=0;j<N;j++)dp[j][i]= dp[j][i-1];
			for(j=N-b-1;j>=0;j--){
				dp[j+b][i]= min( (j==0?0:dp[j][i]) + a ,dp[j+b][i] );
			}
		}
	}
	
	int res=-1;
	for(i=0;i<N;i++){
		if( dp[i][ n-1 ]<=w ){
			res=i;
		}
	}

	cout<<res;
}
// check for any potential overflow before submitting


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

using namespace std;

#define FOR(i, x, y) for(int i = (x); i < (y); ++i)
#define REP(i, x, y) for(int i = (x); i <= (y); ++i)
#define PB push_back
#define MP make_pair
#define PH push
#define fst first
#define snd second
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair<int, int> pii;

const int maxn = 6e5 + 5;

int n, k, ans;
int a[maxn], f[maxn];

class SegmentTree{
private:
	static const int siz = 1048576;
	int dat[siz << 1];
public:
	inline int size(){ return siz; }
	inline int query(int x, int l, int r, int s, int t){
		if(l >= s && r <= t)
			return dat[x];
		int md = l + r >> 1, ret = 0;
		ret = max(ret, s <= md ? query(x << 1, l, md, s, t) : 0);
		ret = max(ret, t > md ? query(x << 1 | 1, md + 1, r, s, t) : 0);
		return ret;
	}
	inline void update(int x, int l, int r, int y, int v){
		if(l == r){
			dat[x] = max(dat[x], v);
			return;
		}
		int md = l + r >> 1;
		if(y <= md)
			update(x << 1, l, md, y, v);
		else
			update(x << 1 | 1, md + 1, r, y, v);
        dat[x] = max(dat[x << 1], dat[x << 1 | 1]);
		return;
	}
}seg;

int main(){
	scanf("%d%d", &n, &k);
	FOR(i, 0, n)
		scanf("%d", a + i);
	FOR(i, 0, n){
		f[i] = seg.query(1, 0, seg.size() - 1, max(a[i] - k, 0), a[i] + k) + 1;
		seg.update(1, 0, seg.size() - 1, a[i], f[i]);
		ans = max(ans, f[i]);
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 8508
#include<iostream>
#include<vector>
using namespace std;
int main()
{
	int n,m;
	cin>>n>>m;
	vector<int>v(m);
	for(int i=0;i<m;++i){
		cin>>v[i];
		n = n - v[i];
	}
	if(n < 0) cout<<-1<<endl;
	else cout<<n<<endl;
	return 0;
}

Measured memory_bytes: 3668
#include <iostream>
#include <cmath>
#include <algorithm>
#include <climits>
#include <vector>
#include <string>
#include <set>
#include <iomanip>
#include <map>
#define rep(i,n) for (int i=0;i<(n);++i)
using namespace std;
using ll = long long;

int main(){
    int n; cin >> n;
    vector<pair<int, int>> p(n);
    rep(i, n){
        int t; cin >> t;
        p[i] = make_pair(t, i);
    }

    sort(p.begin(), p.end());
    rep(i, n){
        cout << p[i].second+1;
        if(i < n-1) cout << " ";
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 1664
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		
		long x = scan.nextLong();
		scan.close();
		
		long ans = 0;
		long yen = 100;
		while(x > yen) {
			yen += yen/100;
			ans++;
		}
		
		System.out.println(ans);
	}
}

Measured memory_bytes: 35784
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvec;
typedef vector<vector<bool>> vveb;
typedef vector<vector<string>> vves;
#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 rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pb push_back
#define pp pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
//const int64 INF = 1LL << 58;
#define dame { puts("-1"); return 0;}
#define YES { cout << "YES" << endl; return 0; }
#define NO { cout << "NO" << endl; return 0; }
#define Yes { cout << "Yes" << endl; return 0; }
#define No { cout << "No" << endl; return 0; }
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; }
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};
int func(int n){
  int sum =1;
  rep1(i,n+1){sum *= i;}
  return sum;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
  	
  	ld l;
  	cin >> l;
  	l/=3;
  	cout <<fixed << setprecision(15)<< l*l*l << endl;
  	

return 0;

  
  
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using static System.Console;
using static System.Math;
using static MyIO;
using static MyUtil;

public class E
{
	public static void Main() => (new Solver()).Solve();
}

public class Solver
{
	public void Solve()
	{
		int N = GetInt();
		int K = GetInt();
		int C = GetInt();
		var S = GetString();

		var L = new int[N];
		int lc = 0;
		int lp = 0;
		while(lp < N)
		{
			if(S[lp] == 'x')
			{
				lp++;
			}
			else
			{
				L[lp] = ++lc;
				lp += C + 1;
			}
		}
		
		var R = new int[N];
		int rc = K + 1;
		int rp = N - 1;
		while(rp >= 0)
		{
			if(S[rp] == 'x')
			{
				rp--;
			}
			else
			{
				R[rp] = --rc;
				rp -= C + 1;
			}
		}

		var ans = new List<int>();
		for(int i = 0; i < N; i++)
		{
			if(L[i] != 0 && L[i] == R[i])
				ans.Add(i + 1);
		}
		WriteLine(string.Join("\n", ans));
	}
}

public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt() => int.Parse(getArg());
	public static long GetLong() => long.Parse(getArg());
	public static double GetDouble() => double.Parse(getArg());
	public static decimal GetDecimal() => decimal.Parse(getArg());
	public static string GetString() => getArg();
	public static char GetChar() => getArg()[0];
	public static int[] GetInts(long N) => Enumerable.Range(0, (int)N).Select(_ => GetInt()).ToArray();
	public static long[] GetLongs(long N) => Enumerable.Range(0, (int)N).Select(_ => GetLong()).ToArray();
	public static double[] GetDoubles(long N) => Enumerable.Range(0, (int)N).Select(_ => GetDouble()).ToArray();
	public static decimal[] GetDecimals(long N) => Enumerable.Range(0, (int)N).Select(_ => GetDecimal()).ToArray();
	public static string[] GetStrings(long N) => Enumerable.Range(0, (int)N).Select(_ => GetString()).ToArray();
}

public static class MyUtil
{
	public static void chmax<T>(ref T x, T y) where T : IComparable<T>
	{
		if(x.CompareTo(y) < 0)
			x = y;
	}

	public static void chmin<T>(ref T x, T y) where T : IComparable<T>
	{
		if(x.CompareTo(y) > 0)
			x = y;
	}

	public static void swap<T>(ref T x, ref T y)
	{
		T tmp = x;
		x = y;
		y = tmp;
	}
}

Measured memory_bytes: 29020
def actual(X, A, B):
    is_unexpired = (A - B)

    if is_unexpired >= 0:
        return 'delicious'

    elapsed_after_expiration_day = (B - A)
    if elapsed_after_expiration_day <= X:
        return 'safe'

    return 'dangerous'

X, A, B = map(int, input().split())
print(actual(X, A, B))

Measured memory_bytes: 9016
import scala.io.StdIn._

object Main extends App {
  val Array(a, b) = readLine.split(" ").map(_.toLong)

  def gcd(l: Long, r: Long): Long = if (r == 0) l else gcd(r, l % r)

  def div(n: Long, d: Int, cnt: Int): Int = {
    if (d > 1000000) {
      cnt + (if (n == 1) 1 else 2)
    } else {
      def divP(l: Long): Long = if (l % d == 0) divP(l / d) else l
      divP(n) match {
        case `n` => div(n, d + 1, cnt)
        case other => div(other, d + 1, cnt + 1)
      }
    }
  }

  println(div(gcd(a, b), 2, 0))
}


Measured memory_bytes: 25500
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <queue>
using ll = long long;
using graph = std::vector<std::vector<ll>>;

using namespace std;

int main() {
    ll N;
    cin >> N;
    ll A[N];
    for(ll i = 0; i < N; i++){
        cin >> A[i];
        A[i] *= -1;
    }
    ll DP[N];
    fill(DP,DP + N,1e+9);
    for(int i = 0; i < N; i++){
        *upper_bound(DP,DP + N,A[i]) = A[i];
    }
    ll l = 0;
    for(int i = 0; i < N; i++){
        if(DP[i] == 1e+9){
            break;
        }
        l++;
    }
    cout << l << endl;
}


Measured memory_bytes: 1792
#include <iostream>
#include <map>
#include <algorithm>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i,k,n) for(int i = k; i < (int)(n); i++)
using namespace std;
int main(){
        int N,t[100010],x[100010],y[100010];
        cin >> N;
        t[0]=x[0]=y[0]=0;
        rep(i,N){
                cin>>t[i+1]>>x[i+1]>>y[i+1];
        }
        string ans = "Yes";
        rep(i,N){
                int dt = t[i+1]-t[i];
                int dist = abs(x[i+1]-x[i])+abs(y[i+1]-y[i]);
                if(dt < dist) ans="No";
                if(dt%2!=dist%2) ans="No";
        }
        cout << ans << endl;
        return 0;
}


Measured memory_bytes: 1408
#include "bits/stdc++.h"

/*#define _USE_MATH_DEFINES
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>*/

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

//#define int long long
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

int onecnt[1 << 10];

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

	rep(i, 0, 1 << 10)rep(j, 0, 10)
	{
		if ((i >> j) & 1)
		{
			onecnt[i]++;
		}
	}

	while (true)
	{
		int R, C, a;
		cin >> R >> C;
		if (R == 0 && C == 0)
		{
			break;
		}
		vector<int> A(C, 0);
		rep(i, 0, R)rep(j, 0, C)
		{
			cin >> a;
			if (a == 1)
			{
				A[j] |= (1 << i);
			}
		}

		vector<int> statecnt(1024, 0);
		rep(i, 0, C)
		{
			statecnt[A[i]]++;
		}
		int ans = 0;
		rep(i, 0, 1 << (R - 1))
		{
			vector<int> tcnt(1024);
			rep(j, 0, 1 << R)
			{
				tcnt[j] = onecnt[j^i];
				tcnt[j] = max(onecnt[j^i], R - onecnt[j^i]);
			}
			int tans = 0;
			rep(j, 0, 1 << R)
			{
				tans += statecnt[j] * tcnt[j];
			}
			chmax(ans, tans);
		}

		cout << ans << endl;
	}

	return 0;
}


Measured memory_bytes: 3180
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		while(scan.hasNext()){
			int n = scan.nextInt();
			if(n == 0){
				break;
			}
			int max = 0;
			int min = 0;
			max = scanInt(scan);
			min = max;
			for(int i = 0;i < n-1;i++){
				int t = scanInt(scan);
				if(t > max){
					max = t;
				}else if(t < min){
					min = t;
				}
			}
			System.out.println(max + " " + min);
		}
	}
	
	public static int scanInt(Scanner scan){
		int t = 0;
		for(int i = 0;i < 5;i++){
			t += scan.nextInt();
		}
		return t;
	}
}

Measured memory_bytes: 33396
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <random>
#include <cmath>
#include <iomanip>
#include <climits>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>
#include <bitset>
#include <sstream>
#include <new>
#include <typeinfo>
#include <iterator>

typedef long long ll;
typedef unsigned long long ull;
constexpr ll mop = 1000000007;
constexpr ll mop2 = 998244353;

using namespace std;

int main() {
	ll elementMax, elementSum;
	cin >> elementMax >> elementSum;
	ll ans = 0;
	for (ll x = 0; x <= elementMax; x++) {
		for (ll y = 0; y <= elementMax; y++) {
			ll z = elementSum - x - y;
			if (0 <= z && z <= elementMax) {
				ans++;
			}
		}
	}
	cout << ans << endl;
}

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

int main() {
	int n,m,c;
	cin >> n >> m >> c;
	vector<int> b(m);
	vector<vector<int>> a(n,vector<int>(m));
	for (int i=0;i<m;i++) {
		cin >> b[i];
	}
	for (int i=0;i<n;i++) {
		for (int j=0;j<m;j++) {
			cin >> a[i][j];
		}
	}
	int count = 0;
	for (int i=0;i<n;i++) {
		int ans = 0;
		for (int j=0;j<m;j++) {
			ans += a[i][j] * b[j];
		}
		if (ans + c > 0) count++;
	}
	cout << count << endl;
}


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

int main(){

    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n){
        cin >> a[i];
    }

    for(int i=n-2;i>=0;i--){
        if(a[i+1]<a[i]){
            if(a[i+1]==a[i]-1){
                a[i]--;
                continue;
            }else{
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 640
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    long X = sc.nextLong();
    long[] a = new long[51]; // バーガーの段数
    long[] p = new long[51]; // パティの枚数
    a[0] = 1;
    p[0] = 1;
    for (int i = 1; i <= 50; i++) {
      a[i] = 2 * a[i - 1] + 3;
      p[i] = 2 * p[i - 1] + 1;
    }
    System.out.println(f(N, X, a, p));
  }

  public static long f(int N, long X, long[] a, long[] p) {
    if (N == 0 && X == 1) {
      return 1;
    } else if (0 < N && X == 1) {
      return 0;
    } else if (1 < X && X < p[N]) {
      return f(N - 1, X - 1, a, p);
    } else if (X == p[N]) {
      return p[N - 1] + 1;
    } else if (p[N] < X && X < a[N]) {
      return f(N - 1, X - p[N], a, p) + p[N - 1] + 1;
    } else {
      return p[N];
    }
  }
}

Measured memory_bytes: 21716
#include <stdio.h>

int keta(int num)
{
        int acc = 0;
        while(num > 0) {
                num /= 10;
                acc++;
        }
        return acc;
}

int main()
{
        int a,b;
        while(scanf("%d %d",&a,&b) != EOF) {
                printf("%d\n",keta(a+b));
        }
        return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <iomanip> // cout<<setprecision(n)
#include <functional> // std::function<void(long long)>
using namespace std;
#define All(v) (v).begin(),(v).end()
const long long mod = 1000000007;
const long long inf = mod*mod;
const long long MAXS = 114514;
const double EPS=1e-10;
const double INF=1e+10;
const double PI=acos(-1.0);
int res=0;
long long n;
 
void dfs(long long num, bool x, bool y, bool z){
    if(num>n)return;
    if(num<=n&&x&&y&&z)res++;
    dfs(10*num+3,true,y,z);
    dfs(10*num+5,x,true,z);
    dfs(10*num+7,x,y,true);
}
 
int main(){
    cin>>n;
    dfs(0,0,0,0);
    cout<<res<<endl;
}

Measured memory_bytes: 256
INF = 1000000000000
n = int(input())
rank = [0 for i in range(n)]
plst = [[0, i] for i in range(n)]

for i in range(n * (n - 1) // 2):
  a,b,c,d = map(int,input().split())
  if c == d:
    plst[a - 1][0] += 1
    plst[b - 1][0] += 1
  elif c < d:
    plst[b - 1][0] += 3
  else:
    plst[a - 1][0] += 3

plst.sort(reverse=True)

count = 0
same_num = 1
pre_point = INF

for p in plst:
  point = p[0]
  t_num = p[1]
  if point < pre_point:
    pre_point = point
    count += same_num
    rank[t_num] = count
    same_num = 1
  elif point == pre_point:
    same_num += 1
    rank[t_num] = count

for r in rank:
  print(r)


Measured memory_bytes: 5628
/*
    Author : Nishant Gupta 2.0
*/
#include<bits/stdc++.h>
using namespace std;

#define LL long long int
#define getcx getchar_unlocked
#define X first
#define Y second
#define PB push_back
#define MP make_pair
#define MAX 100005
#define LOG_MAX 20
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL (LL(1e18))
#define chk(a) cerr << endl << #a << " : " << a << endl
#define chk2(a,b) cerr << endl << #a << " : " << a << "\t" << #b << " : " << b << endl
#define chk3(a,b,c) cerr << endl << #a << " : " << a << "\t" << #b << " : " << b << "\t" << #c << " : " << c << endl
#define chk4(a,b,c,d) cerr << endl << #a << " : " << a << "\t" << #b << " : " << b << "\t" << #c << " : " << c << "\t" << #d << " : " << d << endl
#define rep(i, a, n) for(i=a;i<n;i++)
#define rev(i, a, n) for(i=a;i>=n;i--)
#define in(x) scanf("%d", &x)
#define inl(x) scanf("%lld", &x)
#define in2(x, y) scanf("%d %d", &x, &y)
#define inl2(x, y) scanf("%lld %lld", &x, &y)
#define MSV(A,a) memset(A, a, sizeof(A))
#define rep_itr(itr, c) for(itr = (c).begin(); itr != (c).end(); itr++)
#define finish(x) {cout<<x<<'\n'; return;}
typedef pair<int, int> pi;
typedef pair<LL, LL> pl;
const char en = '\n';

void solve() {
	int n;in(n);
	
	LL ans = 0;
	for(int i=1;i<=n;i++) {
		int q = n/i;
		int r = n%i;
		if(r == 0) q--;
		ans += q;
	}
	cout<<ans<<en;
}

int main() {
	int t = 1;
	
	//~cin>>t;
	while(t--) {
		solve();
	}
    return 0;
}


Measured memory_bytes: 3760
#include<bits/stdc++.h>
using namespace std;
 
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	string a;
	cin>>a;
	string x;
	string y;
	
	for(int i=0;i<a.length();i++){
		if(a.at(i)=='?'){
			x+='D';
		}else{
			x+=a.at(i);
		}
	}
	int count1=0;
	for(int i=0;i<x.length();i++){
		if(x.at(i)=='D'){
			count1+=1;
		}
	}
	for(int i=0;i<x.length()-1;i++){
		if(x.at(i)=='P' && x.at(i+1)=='D'){
			count1+=1;
		}
	}
	for(int i=0;i<a.length();i++){
		if(a.at(i)=='?'){
			y+='P';
		}else{
			y+=a.at(i);
		}
	}
	int count2=0;
	for(int i=0;i<y.length();i++){
		if(y.at(i)=='D'){
			count2+=1;
		}
	}
	for(int i=0;i<y.length()-1;i++){
		if(y.at(i)=='P' && y.at(i+1)=='D'){
			count2+=1;
		}
	}
	if(count1>count2){
		cout<<x<<"\n";
	}else{
		cout<<y<<"\n";
	}


 
	
	
	
	
	return 0;
}

Measured memory_bytes: 4036
#include<bits/stdc++.h>
using namespace std;
long long a,b,c,d,e,i,j,ii,jj,zx,xc,mod,dp[200009],dp2[200009],id[200009],msh[200009],dpmsh[200009],sup[200009];
vector <long long> v[200009],dpz[200009],dpx[200009];
void dfs(long long q, long long w){
	msh[q]=w;
	dp[q]=1;
	long long qw=0;
	dpz[q].resize(v[q].size()+3);
	dpx[q].resize(v[q].size()+3);
	if(q==1){
	dpz[q][0]=1;dpx[q][v[q].size()+1]=1;
}else{
	dpz[q][0]=1;dpx[q][v[q].size()]=1;
}
	for(vector <long long>::iterator it=v[q].begin(); it!=v[q].end(); it++){
		if((*it)==w) continue;
		qw++;
		id[(*it)]=qw;
		dfs((*it),q);
		dp[q]*=(dp[(*it)]+1);
		dp[q]%=mod;
	}
	for(int h=1; h<=v[q].size(); h++){
		zx=v[q][h-1];
		if(zx==w) continue;
		qw=id[zx];
		dpz[q][qw]=dpz[q][qw-1]*(dp[zx]+1);
		dpz[q][qw]%=mod;
	}
	for(int h=v[q].size(); h>=1; h--){
		zx=v[q][h-1];
		if(zx==w) continue;
		qw=id[zx];
		dpx[q][qw]=dpx[q][qw+1]*(dp[zx]+1);
		dpx[q][qw]%=mod;
	}
}
void dfs2(long long q, long long w){
	if(q!=1){
		dpmsh[q]=dpz[w][id[q]-1];
		dpmsh[q]*=dpx[w][id[q]+1];dpmsh[q]%=mod;
		dpmsh[q]*=dpmsh[w];
		dpmsh[q]++;
		dpmsh[q]%=mod;
		//cout<<q<<" "<<dpmsh[q]<<" "<<dpmsh[msh[w]]<<endl;
		dp2[q]=dpmsh[q];
		for(vector <long long>::iterator it=v[q].begin(); it!=v[q].end(); it++){
			if((*it)==w) continue;
			dp2[q]*=(dp[(*it)]+1);
			dp2[q]%=mod;
		}
	}
	for(vector <long long>::iterator it=v[q].begin(); it!=v[q].end(); it++){
		if((*it)==w) continue;
		dfs2((*it),q);
	}
}
int main(){
	ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
	cin>>a>>mod;
	for(i=1; i<a; i++){
		cin>>c>>d;
		v[c].push_back(d);
		v[d].push_back(c);
	}
	dfs(1,0);
	dp2[1]=dp[1];dp2[0]=1;sup[1]=1;dpmsh[1]=1;
	dfs2(1,0);
	for(i=1; i<=a; i++) cout<<dp2[i]<<endl;
	return 0;
}

Measured memory_bytes: 39984
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
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; }
const ll INF = 1LL << 60;
const int MAX = 1000000010;
const ll MOD = 1000000007;

int main() {
    int N; cin >> N;
    vector<int> A(N);
    vector<int> B(N);
    vector<int> C(N);
    for (int i = 0; i < N; i++) cin >> A[i];
    for (int i = 0; i < N; i++) cin >> B[i];
    for (int i = 0; i < N; i++) cin >> C[i];

    sort(A.begin(), A.end());
    sort(C.begin(), C.end());
    ll sum = 0;
    for (int j = 0; j < N; j++) {
        auto itr_A = lower_bound(A.begin(), A.end(), B[j]);
        auto itr_C = lower_bound(C.begin(), C.end(), B[j] + 1);
        int a = distance(A.begin(), itr_A);
        int c = distance(itr_C, C.end());
        sum += (ll)a * c;
    }

    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 1408
import java.util.*;
import java.util.Map.Entry;
 
class Main {
	 static int mod =  (int) (Math.pow(10,9)+7);
   	 static List<ArrayList<Integer>> list= new ArrayList<ArrayList<Integer>>();
   	 static int a_dist[];
//	 static int mod = 998244353;
	 public static void main(String[] args) {
	        Scanner sc = new Scanner(System.in);
	        long N = sc.nextLong();
	        if(N==2) {
	        	System.out.println(1);
	        	return;
	        }
	        int H = (int)Math.pow(N,0.5);
	        long[] d = new long[H+5];
	        int k=0;
	        for(int i=2;i<=H;i++) {
	        	if(N%i==0) {
	        		d[k]=i;
	        		k++;
	        		if(N/i!=i) {
		        		d[k]=N/i;
		        		k++;
	        		}
	        	}
	        }
		    d[k]=N;	        	
	        int ans=0;
	        H = (int)Math.pow(N-1,0.5);
	        for(int i=2;i<=H;i++) {
	        	if((N-1)%i==0) {
	        		ans++;
	        		if((N-1)/i!=i) {
	        			ans++;
	        		}
	        	}
	        }
	        ans++;
	        for(int i=0;d[i]!=0;i++) {
	        	long tmp=N;
	        	while(tmp>0) {
	        		if(tmp%d[i]==0) {
	        			tmp=tmp/d[i];
	        			if(tmp==1) {
	        				ans++;
	        				break;
	        			}
	        		} else {
	        			if((tmp-1)%d[i]==0) {
	        				ans++;
	        				break;
	        			} else {
	        				break;
	        			}
	        		}
	        	}
	        }
	        
	    	System.out.println(ans);
	        
	        	        	        
	 }
}


Measured memory_bytes: 32084
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;

/*
 <url:https://arc083.contest.atcoder.jp/tasks/arc083_a>
 問題文============================================================
 すぬけ君はビーカーに砂糖水を作ろうとしています。
 最初ビーカーは空です。すぬけ君は以下の 4 種類の操作をそれぞれ何回でも行うことができます。
 一度も行わない操作があっても構いません。
 
 操作 1: ビーカーに水を 100A [g] 入れる。
 操作 2: ビーカーに水を 100B [g] 入れる。
 操作 3: ビーカーに砂糖を C [g] 入れる。
 操作 4: ビーカーに砂糖を D [g] 入れる。
 すぬけ君の実験環境下では、水 100 [g] あたり砂糖は E [g] 溶けます。
 
 すぬけ君はできるだけ濃度の高い砂糖水を作りたいと考えています。
 
 ビーカーに入れられる物質の質量 (水の質量と砂糖の質量の合計) が F [g] 以下であり、
 ビーカーの中に砂糖を溶け残らせてはいけないとき、 すぬけ君が作る砂糖水の質量と、
 それに溶けている砂糖の質量を求めてください。 答えが複数ある場合はどれを答えても構いません。
 
 水 a [g] と砂糖 b [g] を混ぜた砂糖水の濃度は  100b/a+b  [%]です。
 また、この問題では、砂糖が全く溶けていない水も濃度 0 [%] の砂糖水と考えることにします。
 
 
 =================================================================
 
 解説=============================================================
 
 ================================================================
 */

double noudo = -1;
int ans = 0;
int ans2 = 0;
ll A,B,C,D,E,F;
bool f[33][33][103][103];
void dfs(int a,int b,int c,int d){
    if(f[a][b][c][d] == true) return;
    f[a][b][c][d] = true;
    ll AA = a*A,BB = b*B, CC = c*C, DD = d*D;
    if(100*AA + 100*BB + CC + DD > F) return;
    if(CC+DD <= E*(AA+BB)){
        if(a|b|c|d != 0){
            double satousui = 100*AA+100*BB+CC+DD;
            double satou = CC + DD;
            double t_noudo = 100*satou/satousui;
            if(t_noudo > noudo){
                noudo = t_noudo;
                ans = satousui;
                ans2 = satou;
            }
        }
    }
    
    dfs(a+1,b,c,d);
    dfs(a,b+1,c,d);
    dfs(a,b,c+1,d);
    dfs(a,b,c,d+1);
}

int main(void) {
    cin.tie(0); ios::sync_with_stdio(false);
    cin >> A >> B >> C >> D >> E >> F;
    dfs(0,0,0,0);
    cout << ans << " " << ans2 << endl;
    return 0;
}


Measured memory_bytes: 4608
N=int(input())
num_list=[]
while True:
    try:
        num_list.append(list(map(int,input().split())))
    except:
        break;

sum_list=[]
for k in range(N):
  sum_list.append(sum(num_list[0][0:k+1])+sum(num_list[1][k:N+1]))
          
print(max(sum_list))

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

const ll MAX = 1e5;
const ll MOD = 1e9+7;

ll fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i-1]*i%MOD;
        inv[i] = MOD-inv[MOD%i]*(MOD/i)%MOD;  // 逆元であるコイツが必要
        finv[i] = finv[i-1]*inv[i]%MOD;
    }
}

int main() {
	ios::sync_with_stdio(false);
    cin.tie(0);
	cout << setprecision(10) << fixed;
	int N;
	cin >> N;
	COMinit();
	vector<ll> x(N);
	rep(i, N) cin >> x[i];
	// スライムがx(i+1)~x(i)間を通る個数の総数的なもの
	ll c = 0;
	ll ans = 0;
	for(int i = 1; i < N; i++){
        c += inv[i];
        ans += (c*(x[i]-x[i-1]))%MOD;
        ans %= MOD;
    }
    ans *= fac[N-1];
    ans %= MOD;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3456
import bisect


def solve(a_list, b_list, position):
    # time O(log(A))
    a_right_key = bisect.bisect_left(a_list, position)
    a_left_key = a_right_key - 1
    # time O(log(B))
    b_right_key = bisect.bisect_left(b_list, position)
    b_left_key = b_right_key - 1

    a_left, a_right = a_list[a_left_key], a_list[a_right_key]
    b_left, b_right = b_list[b_left_key], b_list[b_right_key]

    ans = 10 ** 20
    for a_position in [a_left, a_right]:
        for b_position in [b_left, b_right]:
            distance1 = abs(position - a_position) + abs(a_position - b_position)
            distance2 = abs(position - b_position) + abs(a_position - b_position)
            ans = min(ans, distance1, distance2)
    return ans


def main():
    inf = 10 ** 20
    A, B, Q = map(int, input().split())

    # time O(A)
    a_list = [int(input()) for _ in range(A)]
    a_list = [-inf] + a_list + [inf]
    # time O(B)
    b_list = [int(input()) for _ in range(B)]
    b_list = [-inf] + b_list + [inf]

    # time O(Q (log(A) + log(B))
    for _ in range(Q):
        position = int(input())
        ans = solve(a_list, b_list, position)
        print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 13584
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <deque>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;

int main()
{
	int N, K;
	cin >> N >> K;
	vector<ll> a(N);
	for (auto& temp : a)
	{
		cin >> temp;
	}

	vector<ll> sum(N + 1);
	for (auto i = 0; i < N; ++i)
	{
		sum[i + 1] = sum[i] + a[i];
	}

	vector<ll> list;
	for (auto i = 0; i < N; ++i)
	{
		for (auto j = i; j < N; ++j)
		{
			list.push_back(sum[j + 1] - sum[i]);
		}
	}

	auto ans = 0ll;
	for (auto i = 45; i >= 0; --i)
	{
		auto bit = (1ll << i);
		auto sum = 0ll;
		for (auto j = 0; j < (int)list.size(); ++j)
		{
			if ((list[j] & ans) != ans)
			{
				continue;
			}
			if ((list[j] & bit) == 0)
			{
				continue;
			}
			++sum;
		}
		if (sum >= K)
		{
			ans |= bit;
		}
	}

	cout << ans << endl;

	return 0;
}

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

using namespace std;
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
 int n;
 cin>>n;
 if(n>=64)cout<<64;
 else if (n>=32) cout<<32;
 else if (n>=16) cout<<16;
 else if (n>=8) cout<< 8;
 else if(n>=4)cout<< 4;
 else if (n>=2)cout<<2;
 else cout<<1;
   return 0;
}

Measured memory_bytes: 256
def check(num, ng):
    for c in str(num):
        if int(c) in ng:
            return False
    return True
N, K = map(int, input().split())
D = set(list(map(int, input().split())))
while True:
    if check(N, D):
        print(N)
        break
    else:
        N += 1


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define all(v) v.begin(),v.end()
#define mem(arr) memset(arr,0,sizeof(arr))
#define ff first
#define ss second
#define int long long int
const int MOD = 1e9+7;
const int INF = 1e18;
const int N = 1e6 + 20;
vector<int> g[N];
vector<int> vis(N);
int32_t  main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int tc = 1;
    while(tc--){
        int n;
        string s;
        cin >> n >> s;
        set<int> st[26];
        for(int i = 0; i < n; i++){
            st[s[i] - 'a'].insert(i + 1);
        }
        int q;
        cin >> q;
        while(q--){
            int type;
            cin >> type;
            if(type == 1){
                int pos;
                char c;
                cin >> pos >> c;
                st[s[pos - 1] - 'a'].erase(pos);
                s[pos - 1] = c;
                st[c - 'a'].insert(pos);
            }else{
                int l, r;
                cin >> l >> r;
                int ans = 0;
                for(int i = 0; i < 26; i++){
                    auto it = st[i].lower_bound(l);
                    if(it != st[i].end() and *it <= r){
                        ans++;
                    }
                }
                cout << ans << '\n';
            }
        }
    } 
}

Measured memory_bytes: 55452
#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
ll lcm(ll a, ll b){return (a*b)/gcd(a, b);}
int main()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(0);
    string s;
    cin>>s;
    if(s[0]=='S')
    {
        cout<<"Cloudy";
    }
    else if(s[0]=='C')
    {
        cout<<"Rainy";
    }
    else cout<<"Sunny";
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    long long l,r;;
    cin >> l >> r;
        if((l-1)/2019!=r/2019)
            cout << 0 << endl;
        else
        {
            long long ans=999999999;
            for(long long i=l;i<=r;i++)
            {
                for(long long j=i+1;j<=r;j++)
                {
                    ans=min(i*j%2019,ans);
                }
            }
            cout << ans << endl;
        }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define repm(i,m,n) for(int i=m; i<(n); i++)
#define eps (1e-7)
#define inf (1e9)
#define pi (acos(-1))
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<double> vd;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

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

    string s;
    cin >> s;

    bool isdiff = true;
    rep(i, s.size())
    {
        int count = 0;
        rep(j, s.size())
        {
            //cout << s[i] << " , " << s[j] << endl;
            if(s[i] == s[j]) count++;

            //cout << count << endl;

            if(count == 2)
            {
                isdiff = false;
                break;
            }
        }
        //std::cout << std::endl;
        if(!isdiff) break;
    }

    if(isdiff) cout << "yes" << endl;
    else cout << "no" << endl;

    return 0;
}

Measured memory_bytes: 256
H,W=(int(i) for i in input().split())
L=[]
for i in range(H):
    L.append(list(input()))

for x in L[:]:
    if '#' in x:
        continue
    else:
        L.remove(x)
L=list(map(list,zip(*L)))
for x in L[:]:
    if '#' in x:
        continue
    else:
        L.remove(x)
        
L=list(map(list,zip(*L)))
for i in range(len(L)):
    print(''.join(L[i]))

Measured memory_bytes: 3188
import java.util.*;
/*
Main class for AOJ where there is no input.
*/
public class Main{
   public static void main(String[] args){
      Scanner sc = new Scanner(System.in);
      String str;
      String[] arr;
      int a;
      int b;
      String op;
      int answer;
      
      while(true){
         str = sc.nextLine();
         arr = str.split(" ");
         
         a = Integer.parseInt(arr[0]);
         b = Integer.parseInt(arr[2]);
         
         op = arr[1];
         
         if(op.equals("?")){
            break;
         }
         
         if(op.equals("+")){
            answer = a + b;
         }else if(op.equals("-")){
            answer = a - b;
         }else if(op.equals("*")){
            answer = a * b;
         }else{//if(op.equals("/"))
            answer = a / b;
         }
         System.out.println(answer);
         
      }
      
   }//main
}//class

Measured memory_bytes: 26100
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pll pair<long long,long long>
#define mod 1000000007
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);

ll power(ll a,ll b){
	ll ans=1;
	while(b>0){
		if(b%2!=0){
			ans=(ans*a)%mod;
		}
		a=(a*a)%mod;
		b>>=1;
	}
	return ans;
}

int main() {
	IOS;
	int t=1;
	//cin>>t;
	while(t--){
		ll a,b;
		cin>>a>>b;
		int o=-1;
		for(int i=1;i<=100000;i++){
			ll u,v;
			u=floor(double(i)*0.08);
			v=floor(double(i)*0.1);
			if(u==a&&v==b){
				o=i;
				break;
			}
		}
		cout<<o;
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      int a1 = sc.nextInt();
      int a2 = sc.nextInt();
      int a3 = sc.nextInt();
      int x = Math.abs(a1-a2);
      int y = Math.abs(a2-a3);
      int z = Math.abs(a3-a1);
      int max1 = Math.max(x,y);
      int max2 = Math.max(z,max1);
      System.out.println(x+y+z-max2);
      sc.close();
    }
}


Measured memory_bytes: 23892
#include <bits/stdc++.h>
using namespace std;
int a,b;
int main()
{
    cin>>a>>b;
    int kq=0;
    if(a<=3)
    {
        kq+=(4-a)*100000;
    }
    if(b<=3)
        kq+=(4-b)*100000;
    if(a==1&&b==1)
        kq+=400000;
    cout<<kq;
    return 0;
}


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: 2104
#include<bits/stdc++.h>
using namespace std;

int main() {
	int N;
  	cin >> N;
  
   int tmp = N;
   int SN = 0;
  
  	while(tmp > 0) {
    	SN += tmp % 10;
      	tmp /= 10;
    }
  
  	if(N % SN == 0) {
    	cout << "Yes" << endl;
    }else {
    	cout << "No" << endl;
    }
}

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

using namespace std;

bool is_a_b(int d, int a, int b) {
  string s = to_string(d);
  int sum = 0;
  for (size_t i = 0; i < s.size(); ++i) {
    sum += s[i] - '0';
  }
  return a <= sum && sum <= b;
}

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

  int n, a, b;
  cin >> n >> a >> b;
  int ans = 0;
  for (int i = 1; i <= n; ++i) {
    ans += is_a_b(i, a, b) ? i : 0;
  }
  cout << ans << "\n";
}


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


public class B
{
	public static void Main()	
	{
		int N = Int32.Parse(Console.ReadLine());
		long[] L = new long[N+1];
		L[0] = 2;
		L[1] = 1;
		for(int i = 2; i <= N; i++)
		{
			L[i] = L[i-1] + L[i-2];
		}
		Console.WriteLine(L[N]);
	}
}





Measured memory_bytes: 13140
#include <iostream>

using namespace std;

int main() {

  long long n, ans = 0;
  cin >> n;
  for(long long i = 1;i <= n;i++){
    if(i % 3 != 0 && i % 5 != 0){
      ans += i;
    }
  }
  cout << ans;
  return 0;
}


Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=1e9+7;
ll power(ll a,ll b){return b?power(a*a%mod,b/2)*(b%2?a:1)%mod:1;}
ll C(ll n,ll k)
{
    ll x=1,y=1;
    for(int i=1;i<=k;i++)
    {
        x=x*(n-i+1)%mod;
        y=y*i%mod;
    }
    return x*power(y,mod-2)%mod;
}
ll a[2005];
void pre(){
    a[0]=a[1]=a[2]=1;
    for(int i=3;i<=2000;i++) a[i]=(a[i-3]+a[i-1])%mod;
}
int ans=0;
void dfs(int n){
    if(n==0) ans=(ans+1)%mod;
    for(int i=3;i<=n;i++){
        if(n>=i){
            dfs(n-i);
        }
    }
}
int main()
{
    pre();
    int n;cin>>n;
    //dfs(n);
    if(n<3) cout<<0;
    else cout<<a[n-3];

    return 0;
}


Measured memory_bytes: 3652
x,y=gets.split.map &:to_i
a=[1,3,5,7,8,10,12]
b=[4,6,9,11]
c=[2]
if (a.include?(x) && a.include?(y)) || (b.include?(x) && b.include?(y)) || (c.include?(x) && c.include?(y))
  puts 'Yes'
else
  puts 'No'
end

Measured memory_bytes: 1788
#include<bits/stdc++.h>
#define REP(i,n) for (int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
int main() {
    ll N;
    cin >> N;
    vector<ll> l(N);
    vector<ll> r(N);
    REP(i,N) cin >> l[i] >> r[i];
    ll ans = 0;
    REP(i,N){
        ans += r[i] - l[i] + 1;
    }
    cout << ans;
    return 0;
}

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

const int INF = 1e9 + 7;
const int MN = 105;
const int MW = 100005;

ll dp[MN][MW];

int main(){
    int n, W;
    cin >> n >> W;
    ll w[n], v[n];
    rep(i, n) cin >> w[i] >> v[i];

    rep(i, n){
        rep(j, W + 1){
            if (w[i] > j) dp[i + 1][j] = dp[i][j];
            else dp[i + 1][j] = max(dp[i][j], dp[i][j - w[i]] + v[i]);
        }
    }
    cout << dp[n][W] << endl;
}

Measured memory_bytes: 79360
#include <stdio.h>
int main(){
  int a[4][3][10],i,j,k,n,b,f,v,r;
  for(i=0; i<4; i++){
    for(j=0; j<3; j++){
      for(k=0; k<10; k++){
        a[i][j][k]=0;
      }
    }
  }
  scanf("%d\n",&n);
  for(i=0; i<n; i++){
    scanf("%d %d %d %d\n",&b,&f,&r,&v);
    a[b-1][f-1][r-1]+=v;
  }
  for(i=0; i<4;  i++){
    for(j=0; j<3; j++){
      for(k=0; k<10; k++){
        printf(" %d",a[i][j][k]);
        if(k==9)printf("\n");
    if(k==9&&j==2&&i<3)printf("####################\n");
      }
    }
  }
  return 0;
}


Measured memory_bytes: 2100
def run(x, a_list):
    '''

    '''
    if x == 1:
        print(0)
    else:
        out = 0
        prev = 0
        for i,v in enumerate(a_list):
            if i == 0:
                continue
            prev_height = prev + a_list[i-1]
            if v > prev_height:
                out += 0
                prev = 0
            else:
                out += prev_height - v
                prev = prev_height - v
            
        print(out)
            


    



if __name__ == '__main__':
    x = int(input())
    a_list = list(map(int, input().split()))
    run(x, a_list)

Measured memory_bytes: 32064
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    return divisors

N, K = map(int,input().split())
A = list(map(int,input().split()))
S = sum(A)
L = make_divisors(S)
ans = 0
for i in L:
    D = []
    for a in A:
        if a % i != 0:
            D.append(a % i)
    D.sort()
    L1 = [0]
    L2 = [0]
    for j in range(len(D)):
        L1.append(L1[-1] + D[j])
        L2.append(L2[-1] + i - D[len(D)-1-j])
    L2.reverse()
    
    for j in range(len(D)+1):
        if K >= max(L1[j], L2[j]):
            ans = max(ans, i)

print(ans)

Measured memory_bytes: 3188
#include <algorithm>
#include <array>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 1000000002486618624LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


int acc[33][222222];


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(6);

  std::string A;

  std::cin >> A;

  int size = A.size();

  for (int i = 0; i < size; i ++) {
    int x = A[i] - 'a';

    for (int j = 0; j < 26; j ++)
      acc[j][i + 1] += acc[j][i] + (x == j ? 1 : 0);
  }

  long long s = 1;

  for (int i = 0; i < size; i ++) {
    int x = A[i] - 'a', c = acc[x][size] - acc[x][i + 1];

    s += (size - (i + 1) - c);
  }

  std::cout << s << std::endl;

  return 0;
}


Measured memory_bytes: 22932
#include<cstdio>
#include<algorithm>
#include<cstring>
#define mod 1000000007
using namespace std;
struct node
{
	int x;
	bool flag;	
}arr[200001];
bool cmp(node a,node b)
{
	return a.x < b.x;
}
int main()
{
	int N;
	while(~scanf("%d",&N))
	{
		for(int i=1;i<=2*N;i++)
		{
			scanf("%d",&arr[i].x);
			if(i<=N)
			arr[i].flag = 1;
			else 
			arr[i].flag = 0;
		}
		sort(arr+1,arr+1+2*N,cmp);
		
		long long ans = 1;
		long long balance = 0;
		for(int i=1;i<=2*N;i++)
		{
			if(arr[i].flag)
			{
				if(balance < 0)
				{
					ans *= (-balance)%mod;
					ans %= mod;
				}
				balance++;
			}
			else 
			{
				if(balance > 0)
				{
					ans *= (balance)%mod;
					ans %= mod;
				}
				balance--;
			}
		}
		printf("%lld\n",ans);
	}
	return 0;
}

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

using namespace std;

int n, m, k;
vector<int> friends[100000];
unordered_set<int> blocks[100000];
bool visited[100000];
unordered_set<int> comp;
int ans[100000];

void dfs(int v)
{
    visited[v - 1] = 1;
    comp.insert(v);

    for (auto a : friends[v - 1])
    {
        if (!visited[a - 1])
            dfs(a);
    }
}

int main()
{
  	std::ios_base::sync_with_stdio(false);
	std::cin.tie(NULL);

	cin >> n >> m >> k;

	for (int i = 0; i < n; i++)
    {
        visited[i] = 0;
        ans[i] = 0;
    }

	for (int i = 0; i < m; i++)
    {
        int t1, t2;
        cin >> t1 >> t2;
        friends[t1 - 1].push_back(t2);
        friends[t2 - 1].push_back(t1);
    }

    for (int i = 0; i < k; i++)
    {
        int t1, t2;
        cin >> t1 >> t2;
        blocks[t1 - 1].insert(t2);
        blocks[t2 - 1].insert(t1);
    }

    for (int i = 0; i < n; i++)
    {
        if (comp.size() != 0)
            comp.clear();
        if (!visited[i])
            dfs(i + 1);

        for (auto a : comp)
        {
            int b = 0;
            if (comp.size() <= blocks[a - 1].size())
            {
                for (const auto& x : comp)
                {
                    if (blocks[a - 1].count(x) != 0)
                        b++;
                }
            }
            else
            {
                for (const auto& x : blocks[a - 1])
                {
                    if (comp.count(x) != 0)
                        b++;
                }
            }
            ans[a - 1] = comp.size() - 1 - b - friends[a - 1].size();
        }
    }

    for (int i = 0; i < n; i++)
        cout << ans[i] << " ";

	return 0;
}


Measured memory_bytes: 27172
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i=0;i < (int)(n);i++)

int dp[3][100010];

int main(){
   int n;
   cin >> n;
   rep(i,n){
      int val[3];
      cin >> val[0] >> val[1] >> val[2];
      //if (i == 0){
      //   rep(x,3) dp[x][i] = val[x];
      //   continue;   
      //}
      rep(j,3){
         rep(k,3){
            if (j != k) dp[k][i+1] = max(dp[k][i+1],dp[j][i] + val[k]);
         }
      }
   }
   cout << max({dp[0][n],dp[1][n],dp[2][n]}) << endl;

  
  return 0;
}


Measured memory_bytes: 4772
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int solve(int a[],int n,int dp[]){
    if(n==0){
        return dp[n]=0;
    }
    if(n==1){
        return dp[n]=abs(a[n]-a[n-1]);
    }
    if(dp[n]!=-1){
        return dp[n];
    }
    int ans=min(solve(a,n-1,dp)+abs(a[n-1]-a[n]),abs(a[n-2]-a[n])+solve(a,n-2,dp));
    return dp[n]=ans;
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    int dp[n];
    for(int i=0;i<n;i++){
        dp[i]=-1;
    }
    cout<<solve(a,n-1,dp)<<endl;
    
    
    
    return 0;
}

Measured memory_bytes: 4992
n,m=map(int,input().split())
l=[]
for i in  range(m):
    a=[int(i) for i in input().split()]
    l.append(a)

ans=[]
li=[0 for i in range(n+1)]

def dfs(a,r):
    r[a]=1
    p=0
    q=0
    for i in range(m):
        if l[i][0]==a or l[i][1]==a:
            q+=1
            b=l[i][0]*l[i][1]//a
            if r[b]==0:
                dfs(b,r)
                r[b]=0
            else:
                p+=1
    if p==q and sum(r)==n:
        ans.append(1)

dfs(1,li)
print(sum(ans))
        






Measured memory_bytes: 3064
#include <iostream>
using namespace std;
typedef long long ll;
ll solve(ll w, ll h) {
        if (w==1 || h==1) return 1;
        return (w*h+1)/2;
}
int main() {
        ll w,h;
        cin>>w>>h;
        cout<<solve(w,h)<<'\n';
}


Measured memory_bytes: 256