akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <queue>
#include <set>
#include <fstream>
using namespace std;
#define inf 2000000000
int main()
{
	int N, h, n;
	long long w;
	scanf("%d", &N);
	for(h = 1; h <= 3500; ++h)
	{
		for(n = 1; n <= 3500; ++n)
		{
			if(4LL * h * n - 1LL * N * n - 1LL * N * h != 0 && 1LL * N * h * n % (4LL * h * n - 1LL * N * n - 1LL * N * h) == 0)
			{
				w = 1LL * N * h * n / (4LL * h * n - 1LL * N * n - 1LL * N * h);
				if(w > 0)
                    goto c;
			}
		}
	}
	c:;
	printf("%d %d %lld\n", h, n, w);
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
  int n;
  int a[4];
  scanf("%d", &n);
  for(int i = 0; i < 4; i++){
    a[i] = n % 10;
    n /= 10;
  }
  for(int i = 0; i < 4; i++){
    if(a[i] == 2) n++;
  }
  printf("%d\n" , n);
  return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;
public class Main
{
	public static void main(String[] args) 
	{
		Scanner in=new Scanner(System.in);
		int dp[][]=new int[100][100];
		int p[][]=new int[100][100];
		int ans=0;
		int y=0;
		int ch=0;
		while(in.hasNext())
		{
			String st[]=in.next().split(",");
			ch=Math.max(ch, st.length);
			for(int i=0;i<st.length;i++)
				p[y][i]=Integer.valueOf(st[i]);
			y++;
		}
		dp[0][0]=p[0][0];	
		for(y=1;y<ch*2;y++)
		{
			for(int x=0;x<ch;x++)
			{
				if(y<ch)
				{
					if(x-1>=0)
						dp[y][x]=p[y][x]+Math.max(dp[y-1][x-1], dp[y-1][x]);
					else
						dp[y][x]=p[y][x]+dp[y-1][x];
				}
				else
				{
						dp[y][x]=p[y][x]+Math.max(dp[y-1][x], dp[y-1][x+1]);
				}
				ans=Math.max(ans, dp[y][x]);
			}
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 12000
#include<cstdio>
#include<cstring>
#include<cmath>
#include<bitset>
#include<iostream>
#include<algorithm>
#include<string>
#include<utility>
#include<tuple>
#include<vector>
#include<list>
#include<map>
#include<queue>
#include<stack>
#include<numeric>

#define IOS ios::sync_with_stdio(false),cin.tie(0)
#define REP(i,n) for(int i = 0;i < n;i++)
#define MEM(a,b) memset(a,b,sizeof(a))

typedef long long ll;
using namespace std;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;

int dx[] = { 1,0,-1,0 }, dy[] = { 0,1,0,-1 };

int N, M;
int con[9][9];

int main() {
	IOS;	
	cin >> N >> M;
	MEM(con, false);
	REP(i, M) {
		int x, y;
		cin >> x >> y;
		con[x][y] = con[y][x] = true;
	}
	vector<int> graph(N);
	iota(graph.begin(),graph.end(),1);
	int ans = 0;
	do {
		bool ok = true;
		REP(i, N - 1) {
			if (!con[graph[i]][graph[i + 1]])ok = false;
		}
		if (ok)ans++;
	} while (next_permutation(++graph.begin(),graph.end()));
	cout << ans << endl;
}

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

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

using namespace std;

int main(){
	int n,a0,b0,c0; cin>>n>>a0>>b0>>c0;
	vector<string> s(n);
	rep(i,n) cin>>s[i];

	vector<vector<tuple<int,int,int>>> S(n+1);
	S[n].emplace_back(0,0,0);
	for(int i=n-1;i>=0;i--){
		vector<tuple<int,int,int>> tmp;

		for(auto [a,b,c]:S[i+1]){
			if(s[i]=="AB"){
				tmp.emplace_back(a+1,max(b-1,0),c);
				tmp.emplace_back(max(a-1,0),b+1,c);
			}
			else if(s[i]=="BC"){
				tmp.emplace_back(a,b+1,max(c-1,0));
				tmp.emplace_back(a,max(b-1,0),c+1);
			}
			else{
				tmp.emplace_back(a+1,b,max(c-1,0));
				tmp.emplace_back(max(a-1,0),b,c+1);
			}
		}

		sort(tmp.begin(),tmp.end());
		tmp.erase(unique(tmp.begin(),tmp.end()),tmp.end());

		rep(j,tmp.size()){
			auto [aj,bj,cj]=tmp[j];
			bool ok=true;
			rep(k,tmp.size()) if(j!=k) {
				auto [ak,bk,ck]=tmp[k];
				if(ak<=aj && bk<=bj && ck<=cj) ok=false;
			}
			if(ok) S[i].emplace_back(tmp[j]);
		}
	}

	auto check=[&](int a,int b,int c,int i){
		for(auto [ai,bi,ci]:S[i]){
			if(a>=ai && b>=bi && c>=ci) return true;
		}
		return false;
	};

	if(!check(a0,b0,c0,0)) return puts("No"),0;

	puts("Yes");
	rep(i,n){
		if(s[i]=="AB"){
			if(check(a0+1,b0-1,c0,i+1)){ puts("A"); a0++; b0--; continue; }
			if(check(a0-1,b0+1,c0,i+1)){ puts("B"); a0--; b0++; continue; }
		}
		else if(s[i]=="BC"){
			if(check(a0,b0+1,c0-1,i+1)){ puts("B"); b0++; c0--; continue; }
			if(check(a0,b0-1,c0+1,i+1)){ puts("C"); b0--; c0++; continue; }
		}
		else{
			if(check(a0+1,b0,c0-1,i+1)){ puts("A"); a0++; c0--; continue; }
			if(check(a0-1,b0,c0+1,i+1)){ puts("C"); a0--; c0++; continue; }
		}
	}

	return 0;
}


Measured memory_bytes: 19624
// inputに入力データ全体が入る
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
	input = input.split("\n");
     var a = input[0];
  
    var S=[];
    for(i=0;i<a.length-2;i++){
    var s = a.slice(i,i+3);
       var s = parseInt(s, 10);
    var r = Math.abs(s-753);
    S[i] = r;
    }
  var ans =Math.min.apply(null,S);  // → 1
  console.log(ans);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7500
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long> vii;
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define PB push_back
#define F first
#define S second
#define nul -1
int main()
{
  fast;
  ll n;cin>>n;
  ll a[n+1];
  a[0] = 0;
  for(ll i=1;i<=n;i++){
    cin>>a[i];
  }
  sort(a,a+n+1);
  ll comfort =0;
  for(ll i=1;i<n;i++){
     ll o = floor(i/2);
     comfort+=a[n-o];
  }
  cout<<comfort;
  return 0;
}


Measured memory_bytes: 5172
#include <array>
#include <cstdlib>
#include <cstring>
#include <iostream>
using namespace std;

const int MAX_V = 100;
array<int, MAX_V + 1> degree;

int main() {
	int a, b;
	while(cin >> a >> b) {
		if(a == 0 && b == 0) {
			bool ok = ((degree[1] & 1) && (degree[2] & 1));
			for(int i = 3; i <= MAX_V; ++i) {
				if(degree[i] & 1) ok = false;
			}

			cout << (ok ? "OK" : "NG") << endl;
			degree.fill(0);
		}
		else {
			++degree[a];
			++degree[b];
		}
	}

	return EXIT_SUCCESS;
}

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

int main() {
  
  int S;
  int s, m, h;
  
  std::cin >> S;
  
  h = S / (60 * 60);
  m = S / 60 - h * 60;
  s = S - h*60*60 - m*60;
  
  std::cout << h << ":" << m << ":" << s << std::endl;
  
  return 0;
}


Measured memory_bytes: 3068
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <math.h>
#include <string>
#include <numeric>
#include <algorithm>
#include <utility>


using std::cout;
using std::cin;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;


ll gcd(ll a, ll b) {
    while (b != 0) {
        auto tmp = a;
        a = b;
        b = tmp % a;
    }
    return a;
}

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

int isPrime(int a) {
    for (int i = 2; i * i <= a; ++i) {
        if (a % i == 0) {
            return 0;
        }
    }
    return 1;
}




void oneCase () {
    int n, m;
    cin >> n >> m;
    vector<int> x(n);
    vector<int> y(n);
    vector<int> c(m);
    vector<int> d(m);
    for (int i = 0; i < n; ++i) {
        cin >> x[i] >> y[i];
    }
    for (int j = 0; j < m; ++j) {
        cin >> c[j] >> d[j];
    }
    for (int i  = 0; i < n; ++i) {
        int best = 1e9;
        int ans = 0;
        for (int j = 0; j < m; ++j) {
            auto cur = abs(x[i] - c[j]) + abs(y[i] - d[j]);
            if (best > cur) {
                best = cur;
                ans = j;
            }
        }
        cout << ans + 1 << "\n";
    }
}





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

    return 0;
}

Measured memory_bytes: 256
N=int(input())
print(N*(N-1)//2-N//2)

if N%2 == 0:
  for i in range(1,N):
    for j in range(i+1,N+1):
      if i+j != N+1:
        print("{} {}".format(i,j))
else:
  for i in range(1,N):
    for j in range(i+1,N+1):
      if i+j != N:
        print("{} {}".format(i,j))

Measured memory_bytes: 3336
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <numeric>
#include <array>
#include <cmath>
#include <memory>
using namespace std;
//変数デバッグ
#define DEB(variable) cout << #variable << '=' << variable << endl

//for簡易表記(引数ミス防止)
#define FOR(LoopVariable,numberOFbegin,numberOFend) for (long long int LoopVariable = (numberOFbegin); (LoopVariable) < (numberOFend); (LoopVariable)++)
#define DEFOR(LoopVariable,numberOFbegin,numberOFend) for (long long int LoopVariable = (numberOFbegin)-1; (LoopVariable) >= (numberOFend); (LoopVariable)--)
#define REP(LoopVariable,numberOFend) for(long long int LoopVariable = 0;(LoopVariable)<(numberOFend);LoopVariable++)

using llint = long long int;

constexpr long long int linf = numeric_limits<long long int>::max()-5;
constexpr int inf= numeric_limits<int>::max()-5;
constexpr long long int mod = 1000000007;

int main(){

    string s;cin>>s;
    llint n = s.size();
    vector<vector<llint>>dp(2, vector<llint>(n + 1, 0));
    dp[0][0] = 1;
    dp[1][0] = 2;
    FOR(i,1,n){
        if(s[i]=='1'){
            dp[1][i] += dp[1][i - 1] * 2;
            dp[0][i] += dp[1][i - 1] + dp[0][i - 1] * 3;
        }else{
            dp[1][i] = dp[1][i - 1];
            dp[0][i] += dp[0][i - 1] * 3;
        
        }
        dp[1][i] %= mod;
        dp[0][i] %= mod;
        
    }
    cout <<(dp[0][n-1]+ dp[1][n - 1])%mod << endl;
    return 0;
}


Measured memory_bytes: 2880
d = {}
n = int(input())
for _ in range(n):
  s = input()
  if s in d: d[s] += 1
  else: d[s] = 1

m = int(input())
for _ in range(m):
  t = input()
  if t in d: d[t] -= 1
    
maxNum = max(d.values())
if maxNum > 0: print(maxNum)
else: print(0)

Measured memory_bytes: 9192
import re

N = int(input())
S = input()

while True:
    pre = S
    S = re.sub(r'\(((L|R)*?)\)', r'L\1R', S)
    if pre == S:
        break

S = '(' * S.count(')') + S + ')' * S.count('(')
S = S.replace('L', '(')
S = S.replace('R', ')')
print(S)

Measured memory_bytes: 3316
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = (int)1e7;  
using  p = pair<int,int>;
ll n,m;

int main(){
   cin >> n >> m;
   ll a = n -2;
   ll b = m -2;
   
   if(a>0&&b>0){
      cout << a*b;
   }else if((a==0&&b>0)||(a>0&&b==0)||(a==b&&b==0)){
      cout << 0;
   }else{
      if(a<0&&b<0){
         cout << (n==m&&m==1) ? 1 : 0;
      }else if(a<0){
         cout << b;
      }else if(b<0){
         cout << a;
      }
   }

}
  
  

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	long long int b,c,d,e,f,g,h,j,i;


	long long int n;
	cin >> n;
	vector<long long int> a(n);
	for(i=0;i<n;i++){cin>>a[i];}
	long long int ans = 0;
	long long int sum = a[0];
	if(sum <= 0){
		ans += -a[0] + 1;
		sum = 1;
	}
	for(i=1; i<n;i++){
		if(i %2==1){
			if(a[i] < 0){
				sum += a[i];
				if(sum >= 0) ans += sum + 1, sum = -1;
			}
			else{
				ans += sum + a[i] + 1;
				sum = -1;
			}
		}
		else{
			if(a[i] >= 0){
				sum += a[i];
				if(sum <= 0) ans += -sum + 1, sum = 1;
			}
			else{
				ans += -sum + -a[i] + 1;
				sum = 1;
			}
		}
	}
	long long int ans1 = 0;
	long long int sum1 = a[0];
	if(sum1 >= 0){
		ans1 += a[0] + 1;
		sum1 = -1;
	}
	for(i=1;i<n;i++){
		if(i % 2 == 0){
			if(a[i] < 0){
				sum1 += a[i];
				if(sum1 >= 0) ans1 += sum1 + 1, sum1 = -1;
			}
			else{
				ans1 += sum1 + a[i] + 1;
				sum1 = -1;
			}
		}
		else{
			if(a[i] >= 0){
				sum1 += a[i];
				if(sum1 <= 0) ans1 += -sum1 + 1, sum1 = 1;
			}
			else{
				ans1 += -sum1 + -a[i] + 1;
				sum1 = 1;
			}
		}
	}
	cout << min(ans1, ans) << endl;
	return 0;
}


Measured memory_bytes: 1024
#include<stdio.h>
int main ()
{

    char a,b;
    scanf("%c",&a);
    getchar();
    scanf("%c",&b);
    if(a=='H')
    {
        if(b=='H')
            printf("H");
        if(b=='D')
            printf("D");
    }
    if(a=='D')
    {
        if(b=='H')
            printf("D");
        if(b=='D')
            printf("H");
    }
    return 0;
}


Measured memory_bytes: 128
import sys
sys.setrecursionlimit(10**7)

def dfs(n):
  if n in dic:
    return dic[n]
  ret=n*d
  if n%2==0:
    ret=min(ret,a+dfs(n//2))
  elif n%2==1:
    ret=min(ret,a+d+dfs((n-1)//2))
    ret=min(ret,a+d+dfs((n+1)//2))
  if n%3==0:
    ret=min(ret,b+dfs(n//3))
  elif n%3==1:
    ret=min(ret,b+d+dfs((n-1)//3))
    ret=min(ret,b+2*d+dfs((n+2)//3))
  elif n%3==2:
    ret=min(ret,b+2*d+dfs((n-2)//3))
    ret=min(ret,b+d+dfs((n+1)//3))
  if n%5==0:
    ret=min(ret,c+dfs(n//5))
  elif n%5==1:
    ret=min(ret,c+d+dfs((n-1)//5))
    ret=min(ret,c+4*d+dfs((n+4)//5))
  elif n%5==2:
    ret=min(ret,c+2*d+dfs((n-2)//5))
    ret=min(ret,c+3*d+dfs((n+3)//5))
  elif n%5==3:
    ret=min(ret,c+3*d+dfs((n-3)//5))
    ret=min(ret,c+2*d+dfs((n+2)//5))
  elif n%5==4:
    ret=min(ret,c+4*d+dfs((n-4)//5))
    ret=min(ret,c+d+dfs((n+1)//5))
  dic[n]=ret
  return ret

t=int(input())
for _ in range(t):
  n,a,b,c,d=map(int,input().split())
  dic={}
  dic[0]=0
  dic[1]=d
  dfs(n)
  print(dic[n])

Measured memory_bytes: 94488
S = input()
T = input()
ans = []
for i in range(len(S)-len(T)+1):
  ans.append(S[i:len(T)+i])
s = []

for i in ans:
  count = 0
  for k in range(len(T)):
    if i[k]==T[k]:
      count+=1
  s.append(count)
  
print(len(T)-max(s))      
    
  

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

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

  int updated = 1, ans = 0;
  while(updated){
    updated = 0;
    int cont = 0;
    for(int i = 0; i < N; i++){
      if(h[i] > 0){
        h[i]--;
        updated = 1;
        if(!cont){
          cont = 1;
          ans++;
        }
      }else{
        cont = 0;
      }
    }
  }
  cout << ans << endl;
  return 0;
}


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

int main ()
{
  const int max_size = 101;
  std::array<std::array<long int, max_size>, max_size> A, B;

  int n, m, l;
  std::cin >> n >> m >> l;

  auto read_elm = [](auto & a){ std::cin >> a; };
  auto read_row = [&](auto & Ai, int ncol){ std::for_each(Ai.begin(), Ai.begin()+ncol, read_elm); };
  auto read_matrix = [&](auto & matrix, int nrow, int ncol){
                       std::for_each(matrix.begin(), matrix.begin()+nrow, [&](auto & Ai){read_row(Ai, ncol);});
                     };

  read_matrix(A, n, m);
  read_matrix(B, m, l);

  long prod_ij{};

  for (int i=0; i<n; i++)
    {
      for (int j=0; j<l; j++)
        {
          prod_ij = 0;
          for (int k=0; k<m; k++)
            prod_ij += A.at(i).at(k) * B.at(k).at(j);

          if (j<l-1)
            std::cout << prod_ij << " ";
          else
            std::cout << prod_ij << std::endl;
        }
    }
}


Measured memory_bytes: 3256
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include<algorithm>
#include<string>
#include <map>
#include <queue>
#include <stack>
#include<set>
#include<tuple>

#define DIV 1000000007
#define M 2e5
using namespace std;
using ll = long long;
using ldb = long double;

int main() {
	ll N; cin >> N;
	map<int, ll> mp;
	for (int i = 1; i <= N; i++) {
		int p; cin >> p;
		mp[p] = i;
	}

	vector<ll> a(N + 1), b(N + 1);
	for (ll i = 1; i <= N; i++) {
		a[i] = (ll)40000 * i + mp[i];
		b[i] = (ll)40000 * (N - i + 1);
	}

	for (int i = 1; i <= N; i++)cout << a[i] << " ";
	cout << endl;
	for (int i = 1; i <= N; i++)cout << b[i] << " ";
	cout << endl;
	//cout << 24000 * 20000 << endl;
}

Measured memory_bytes: 4884
#include <cstdio>
using namespace std;

int main ()
{
  int count = 1;
  int x;
  while (1) {
    scanf("%d", &x);
    if (x == 0) {
      return 0;
    }
    printf("Case %d: %d\n", count, x);
    count++;
  }
}

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

int c;

int seisu_1(int n){
    if(0<=n && n<10) return c;
    if(n == (n/10)*(n%10)) return -1;
    else{    
    int nmax=(n/10)*(n%10), m;
    for(int j=10; j<=n; j*=10){
        m = (n/j)*(n%j);
        if(nmax<m)  nmax = m;
    }
    c++;
    return seisu_1(nmax);
    }
}


int main(void){
    int Q, n;
    cin >> Q;
    for(int i=1; i<=Q; i++){
        c = 0;
        cin >> n;
        cout << seisu_1(n) << endl;
    }
    
    return 0;
}


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

int main()
{
  int a, b, h, m;
  cin >> a >> b >> h >> m;
  double dh = 30 * h + m / 2.0;
  double dm = 6 * m;
  cout << fixed << setprecision(10) << sqrt(a * a + b * b - 2 * a * b * cos(abs(dh - dm) * M_PI / 180.0)) << "\n";
}

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

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	ll n;
	cin>>n;
	ll a[n+1];
	rep(i,1,n)
	cin>>a[i];
	ll dp[n+1];
	dp[1]=0;
	rep(i,2,n)
	{
		if(i==2)
			dp[i]=abs(a[i]-a[1]);
		else
		{
			dp[i]=min(dp[i-1]+abs(a[i]-a[i-1]),dp[i-2]+abs(a[i]-a[i-2]));
		}
	}
	cout<<dp[n];

	


	return 0;
	
}

Measured memory_bytes: 5188
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <cstring>
#define rep(i, N) for (int i = 0; i < (int)N; i++)
using namespace std;
typedef long long ll;
const ll LLINF = 9223372036854775807;
const int MOD = 1000000007;

int main() {
  int N; cin >> N;
  int a[N]; rep(i, N) cin >> a[i];
  int rate[9]={};
  rep(i, N) {
    if (a[i] >= 3200) rate[8]++;
    else rate[a[i]/400]++;
  }
  int r_min = 0;
  rep(i, 8) if (rate[i]!=0) r_min++;
  int r_max = r_min + rate[8];
  r_min = max(r_min, 1);
  cout << r_min << " " << r_max << endl;
  return 0;
}

Measured memory_bytes: 256
// ARC093
// C - Traveling Plan

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;

const int MAX_N = 100000;

int N;
vector<int> a;

int main() {
    vector<int> a_s;

    cin >> N;
    a.resize(N + 2);
    a[0] = 0;
    for (int i = 1; i <= N; i++) {
        cin >> a[i];
    }
    a[N + 1] = 0;

    int s = 0;
    for (int i = 1; i < N + 2; i++) {
        s += abs(a[i - 1] - a[i]);
    }

    for (int i = 1; i <= N; i++) {
        cout << s - abs(a[i - 1] - a[i]) - abs(a[i] - a[i + 1]) +
                    abs(a[i - 1] - a[i + 1])
             << endl;
    }

    return 0;
}


Measured memory_bytes: 1664
import heapq

n,m=map(int,input().split())
X=[[] for _ in range(10**5+5)]
for i in range(n):
    a,b=map(int,input().split())
    X[a-1].append(-b)

ans=0
p=[]
heapq.heapify(p)
for i in range(m):
    if len(p)==0 and len(X[i])==0:
        continue
    for j in range(len(X[i])):
        heapq.heappush(p,X[i][j])
    a=heapq.heappop(p)
    ans+=a*-1
print(ans)

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

using namespace std;

#define ALL(x) x.begin(), x.end()

typedef long long int lld;
typedef pair<int, int> pii;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.precision(15);
	cout << fixed;

	int a, b;
	cin >> a >> b;

	for (int i = b - a + 1; i <= b + a - 1; i++) {
		cout << i << ' ';
	}
	cout << '\n';
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
    int A,B,x,y;
    cin >> A >> B;
    x=0;
    y=0;
    if(A>B){
        x=A+A-1;
    }
    else
        x=B+B-1;
    y=A+B;
    if(x>y)
        cout << x;
    else
        cout << y;
    return 0;
}

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

using namespace std;
using ll = long long;
using ii = pair<int, int>;

const int MAX { 100010 };
const ll MOD { 1000000007 }, oo { 1LL << 62 };

vector<int> adj[MAX];
bitset<MAX> found;

ll dfs(ll u, ll n, ll K)
{
    ll res = 1;

    for (auto v : adj[u])
    {
        if (found[v])
            continue;

        found[v] = true;
        ll ways = (n * dfs(v, K - 2, K)) % MOD;
        res = (res * ways) % MOD;
        --n;
    }

    return res;
}

ll solve(ll K)
{
    found.reset();
    found[1] = true;

    ll ans = (K * dfs(1, K - 1, K)) % MOD;

    return ans;
}

int main()
{
    ios::sync_with_stdio(false);

    int N, K;
    cin >> N >> K;

    while (--N)
    {
        int a, b;
        cin >> a >> b;

        adj[a].push_back(b);
        adj[b].push_back(a);
    }

    auto ans = solve(K);

    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 11648
#include <stdio.h>

int main()
{
  int n,q,i,j,C=0;
  
  scanf("%d",&n);

  int S[n];

  for(i=0;i<n;i++){
    scanf("%d",&S[i]);
  }

  scanf("%d",&q);

  int Q[q];

  for(i=0;i<q;i++){
    scanf("%d",&Q[i]);
    for(j=0;j<n;j++){
      if(S[j]==Q[i]){
          C++;
          break;
      }
    }
  }
  
   printf("%d\n",C);


  return 0;
}



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

int main()
{
    int H,N,i,sum;
    cin >> H >> N;
    int A[N];
    sum = 0;

    for (i = 0; i < N; i++)
    {
        cin >> A[i];
        sum += A[i];
    }
    
    if (H <= sum) cout << "Yes";
    else cout << "No";

     return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main(){
    int h,w;
    cin>>h>>w;
    char ch[52][52];
    for(int i=1;i<=h;i++){
        for(int j=1;j<=w;j++)cin>>ch[i][j];
    }
    for(int i=1;i<=h;i++){
        for(int j=1;j<=w;j++){
            if(ch[i][j]=='#'&&ch[i][j-1]=='.'&&ch[i][j+1]=='.'&&ch[i+1][j]=='.'&&ch[i-1][j]=='.'){
                cout<<"No"<<endl;
                return 0;
            }
        }
    }
    cout<<"Yes"<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main()
{
    int n,m;
    scanf("%d %d",&n,&m);

    int a[n],sum=0,c=0;
    for (int i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
        sum+=a[i];
    }
    int x=4*m;
    int h=sum/x;
    if (sum%x!=0)
        h++;
    for (int i=0;i<n;i++)
    {
        if (a[i]>=h)
            c++;
    }
    if (c>=m)
        printf("Yes\n");
    else
        printf("No\n");

    return 0;
}


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


int bubbleSort(string A[], int N){ // N個の要素を含む0-オリジンの配列
  int flag = 1;
  // int cnt = 0;
  while(flag) {
    flag = 0;
    for ( int j = N-1; j > 0; j--) {
      if ( A[j].at(1) < A[j-1].at(1) ) { // 交換処理があるなら、次も続けます。
        swap(A[j], A[j-1]);
        // cnt++; // counter は不要
        flag = 1;
      }
    }
  }
  return 0;
}


int selectionSort(string A[], int N) {
  int minj, flag = 1;
  for ( int i = 0; i < N - 1; i++ ) {
    minj = i;
    for ( int j = i; j < N; j++ ) { // j < Nをi < Nとすると、セグメンテーション違反となる
      if ( A[j].at(1) < A[minj].at(1) ) {
        minj = j;
      }
    }
    if ( i != minj ) {
      swap(A[i], A[minj]);
    }
  }
  return 0;
}


bool isStable(string in[], string out[], int N) {
  for ( int i = 0; i < N; i++ ) {
    for ( int j = i + 1; j < N - 1; j++ ) {
      for ( int a = 0; a < N; a++ ) {
        for ( int b = a + 1; b < N - 1; b++ ) {
          // i < j and a < b なので、1つでも入れ替わっていればfalseを返す
          if ( in[i].at(1) == in[j].at(1) && in[i] == out[b] && in[j] == out[a] ) {
            return false;
          }
        }
      }
    }
  }
  return true;
}

void out(string A[], int N, bool stability) {
  // int flag
  for (int i = 0; i < N; i++) {
    if(i) cout << " ";
    cout << A[i];
  }
  cout << endl;

  if (stability) {
    cout << "Stable" << endl;
  } else {
    cout << "Not stable" << endl;
  }
}

int main() {
  int N;
  cin >> N;
  string A[N], B[N], C[N];
  bool stability;

  for (int i = 0; i < N; i++) {
    cin >> A[i];
    B[i] = A[i];
    C[i] = A[i];
  }
  // cout << C[0].at(0) << " " << C[0].at(1);

  bubbleSort(B, N);
  stability = isStable(A, B, N);
  // cout << stability;
  out(B, N, stability);

  selectionSort(C, N);
  stability = isStable(A, C, N);
  out(C, N, stability);

}



Measured memory_bytes: 3188
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Convert;
using static System.Math;

class Program
{
    static void Main(string[] args)
    {
        var num = ToInt32(ReadLine());
        var up = Array.ConvertAll(ReadLine().Split(' '), int.Parse);
        var down = Array.ConvertAll(ReadLine().Split(' '), int.Parse);
        var sum1 = new int[num];
        var sum2 = new int[num];
        sum1[0] = up[0];
        sum2[0] = down[num-1];
        for(var i = 1; i < num; i++)
        {
            sum1[i] = sum1[i - 1] + up[i];
            sum2[i] = down[num - i - 1] + sum2[i - 1];
        }
        var result = 0;
        for(var i = 0; i < num; i++)
        {
            if (result < sum1[i] + sum2[num-i-1]) result = sum1[i] + sum2[num-i-1];
        }
        WriteLine(result);
    }
}


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


int main() {
  int n; cin >> n;
  string s; cin >> s;
  int k; cin >> k;
  k--;
  rep(i,n) {
    if (s[i] == s[k]) cout << s[k];
    else cout << "*";
  }
}


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

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

        long long ans = 0;
        for (int x = 0; x <= K; ++x) {

                for (int y = 0; y <= K; ++y) {

                        int z = S - x - y;
                        if (z >= 0 && z <= K) {

                                ans++;
                        }

                }
        }
        cout << ans << endl;




}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int main()
{
  char S[3];
  int ans=0;
  for(int i=0;i<3;i++){
  	cin >>S[i];
  }
  bool p = S[0] =='R';
  bool q = S[1] =='R';
  bool r = S[2] =='R';
  if(p && q && r){
    ans = 3;
  }else if((p&&q) || (q&&r)){
    ans = 2;
  }else if(p || q || r){
    ans =1;
  }else{
    ans=0;
  }
    
  cout << ans;
  return 0;
	
}
  

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

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            // 整数の入力
         
            string[] input = Console.ReadLine().Split(' ');
            int ans;//カーテンの残り
            int a= int.Parse(input[0]);
            int b= int.Parse(input[1]);

            ans = a - (2 * b);

            if (ans > 0)
            {
                Console.WriteLine(ans);
            }


            else if (ans <= 0)
            {
                Console.WriteLine(0);
            }

            
        }
    }
}

Measured memory_bytes: 13140
N = int(input())
ret = 0
prime_list = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47]
if N >= 78:
    ret += 1
if N >= 28:
    ret += len([a for a in prime_list if 2 * a <= N]) - 1
if N >= 54:
    ret += len([a for a in prime_list if 2 * a <= N]) - 1
if N >= 100:
    ret += len([a for a in prime_list if 2 * a <= N]) - 1
if N >= 16:
    ret += len([a for a in prime_list if 4 * a <= N]) - 1
if N >= 30:
    ret += len([a for a in prime_list if 4 * a <= N]) - 1
if N >= 60:
    ret += len([a for a in prime_list if 4 * a <= N]) - 1
if N >= 91:
    ret += len([a for a in prime_list if 4 * a <= N]) - 1
if 9 <= N < 20:
    ret += len([a for a in prime_list if 2 * a <= N]) - 2
if N >= 20:
    temp = len([a for a in prime_list if 4 * a <= N])
    temp2 = int(temp * (temp - 1) / 2 + 0.1)
    ret += temp2 * (len([a for a in prime_list if 2 * a <= N]) - 2)
print(str(ret))

Measured memory_bytes: 3064
#define  _CRT_SECURE_NO_WARNiINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include <map>
#include <fstream>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <cassert>
#include <set>
using namespace std;
#define eps 0.000000001
#define LONG_INF 10000000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define REP(i,n) for(long long i = 0;i < n;++i)
#define cycle_per_sec 2806192512
int main() {
	int n;
	cin >> n;
	for (int i = 6; i < 55555;i += 5) {
		int hoge = 0;
		for (int q = 2; q <= sqrt(i); ++q) {
			if (i % q == 0) {
				hoge = 1;
			}
		}
		if (hoge == 0) {
			n--;
			cout << i << " ";
			if (n == 0) {
				cout << endl;
				return 0;
			}
		}
	}
	cout << "FAILED" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;

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

    int a[n];
    for (int i = 0; i < n; i++) cin >> a[i];

    int mn = 1e9;
    for (int i = -100; i <= 100; i++) {
        int cost = 0;
        for (int j = 0; j < n; j++) {
            cost += (a[j] - i) * (a[j] - i);
        }
        mn = min(mn, cost);
    }

    cout << mn << "\n";
    return 0;
}

Measured memory_bytes: 256
var x = require('fs').readFileSync('/dev/stdin', 'utf8');
var y = x.split(' ');
var a = parseInt(y[0]);
var b = parseInt(y[1]);
var c = parseInt(y[2]);
if(a < b && a < c && b < c){
    console.log('Yes')
}else{
    console.log('No')
}


Measured memory_bytes: 15096
Module problemB

    Sub Main()
        Dim prm As Integer = Integer.Parse(Console.ReadLine)
        Dim s As Char() = Console.ReadLine.ToCharArray()

        For i As Integer = 0 To s.Length - 1
            s(i) = Chr(((Asc(s(i)) - 65 + prm) Mod 26) + 65)
        Next

        Console.WriteLine(New String(s))
    End Sub

End Module

Measured memory_bytes: 13312
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int k , s , ans ;
  cin >> k >> s;
  for(int i = 0; i<= k ; i++){
    for(int j = 0 ; j<= k ; j++){
      if( s - i - j <= k && s - i - j >= 0 ){
        ans += 1;
      }
    }
  }
   cout << ans << endl;   

}

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;
using P = pair<int , int>;
  
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);

  string s; cin >> s;

  cout << (s[1] == 'B' ? "ARC" : "ABC");
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=(ll)1e9+7;
//const ll MOD=(ll)998244353;
const ll INF=(ll)1e18+10;
const double PI = 2.0*acos(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 dy[]={-1,1,0,0};
int dx[]={0,0,-1,1};

void solve(int ca){
    int a,b,c,d;
    string s,t,u;

    cin>>s;

    int l=s[s.length()-1]-'0';

    if(l==3){
        cout<<"bon"<<endl;
    }else if(l==0||l==1||l==6||l==8){
        cout<<"pon"<<endl;
    }else{
        cout<<"hon"<<endl;
    }


}

//#define MULTI
int main() {
#ifdef MULTI
    int N; cin>>N;
    for (int i = 0; i < N; ++i) {
        solve(i+1);
    }
#else
    solve(0);
#endif
    return 0;
}


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

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

vector<pii> st[15];

int main()
{
    //freopen("input.txt", "r", stdin);
    //freopen("path.out", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n;
    cin >> n;
    for (int i = 0; i < n; i++) {
        int k;
        cin >> k;
        while (k--) {
            int x, y;
            cin >> x >> y;
            st[i].emplace_back(x-1, y);
        }
    }

    int ans = 0;
    for (int mask = 0; mask < (1 << n); mask++) {
        bool can = true;
        for (int i = 0; i < n && can; i++) {
            if ((mask & (1 << i)) == 0) continue;
            for (pii it: st[i]) {
                can &= (mask & (1 << it.first)) == (it.second << it.first);
            }
        }
        if (can)
            ans = max(ans, __builtin_popcount(mask));
    }
    cout << ans;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<string>
#define MOD 1000000007
typedef long long ll;
using namespace std;

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    int sum = 0;
    for(int i=0;i<5;i++){
        int x; cin >> x;
        sum += x;
    }
    cout << 15 - sum << endl;
    return 0;

}

Measured memory_bytes: 3608
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
using ll=long long;
static const ll mod = 1e9 + 7;
static const ll INF = 1LL << 50;
using namespace std;

//頂点fromから頂点toへのcost
struct edge{
  ll from,to,cost;
  edge (ll from,ll to,ll cost):from(from),to(to),cost(cost){}
};

vector<ll>d;//最短距離

void bellman_ford(vector<edge> &es,int V,int s){//es:頂点,costという要素からなる、辺についての配列、V:頂点数,s:スタート地点
    d.resize(V+1,INF);
    ll cnt=0;
    d[s]=0;
    bool upgrade=true;
    while(upgrade){
      ++cnt;
      if(cnt>V){
        for(int i=0;i<V;i++){
		      for(auto &e:es){
			      if(d[e.to]!=INF && d[e.to] > d[e.from] + e.cost)d[e.to] = -INF;
		      }
	      }
        return ;
      }
      upgrade=false;//フラグ
    //それぞれの頂点につき1回ずつしか通らないため、V-1回しかループは実行されない(V回目があるときは負の辺を含む)
        for(auto &e:es){//esの変更が反映される
            if(d[e.from]==INF)continue;
            if(d[e.to]>d[e.from]+e.cost){
            d[e.to]=d[e.from]+e.cost;
            upgrade=true;
            }
        }
    }
}

int main(){
  int n,m;
  ll p;
  cin>>n>>m>>p;
  ll a,b,c;
  vector<edge>es;
  rep(i,m){
    cin>>a>>b>>c;
    a--;b--;
    es.emplace_back(a,b,p-c);
  }
  bellman_ford(es,n,0);
  if(d[n-1]==-INF)cout<<-1<<endl;
  else cout<<max((ll)0,-d[n-1])<<endl;
  return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(),x.end()
#define fi first
#define se second
#define pb push_back
#define mp make_pair
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long long ll;

template<class T> void read(T &x){
	int f=0; x=0; char ch=getchar();
	for(;!isdigit(ch);ch=getchar()) f|=(ch=='-');
	for(;isdigit(ch);ch=getchar()) x=x*10+ch-'0';
	if(f) x=-x;
}

const int N=2005,mod=1e9+7;
int f[N][N],n,m,K,ans;

void add(int &x,int y){
	x=(x+y>=mod?x+y-mod:x+y);
}

int main(){
	read(n),read(m),read(K);
	rep(i,1,K-1) f[i][K-i]=1;
	rep(i,0,n) rep(j,2*K-1-i,m){
		if((i+j)%(K-1)!=1%(K-1)) continue;
		rep(k,0,K-1){
			if(i-k<0) continue;
			if(j-(K-1-k)<0) continue;
			add(f[i][j],f[i-k][j-(K-1-k)]);
		}
	}
	for(int i=n;i>=0;i-=K-1)
		for(int j=m;j>=0;j-=K-1)
			add(ans,f[i][j]);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 15872
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>
#include <iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<P,P> PP;
const ll MOD=1000000007;
const ll MAX_N=500100;
const ll INF=4999999996000000001;
vector<vector<int> > G(MAX_N);
vector<bool> visited(MAX_N,false);
int n,k;
ll ans;

void 起(){
    cin>>n>>k;
    ans=k;
}

void 承(){
    for(int i=0;i<n-1;i++){
        int a,b;
        cin>>a>>b;
        a--; b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
}

void 転(int now){
    int kmi=2;
    if(now==0) kmi--;
    visited[now]=true;
    for(int to:G[now]){
        if(visited[to]) continue;
        ans*=k-kmi;
        ans%=MOD;
        転(to);
        kmi++;
    }
}

void 結(){
    cout<<ans<<endl;
}

int main(){
    起();
    承();
    転(0);
    結();
}

Measured memory_bytes: 21224
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=(ll)1e9+7;



int main(){
    int n,m,s,t; cin>>n>>m>>s>>t; s--; t--;
    vector<pair<int,int>> tonariy[100010],tonaris[100010];
    int u,v,a,b;
    for (int i = 0; i < m; ++i) {
        cin>>u>>v>>a>>b; u--; v--;
        tonariy[u].push_back({a,v});
        tonaris[u].push_back({b,v});
        tonariy[v].push_back({a,u});
        tonaris[v].push_back({b,u});
    }
    //出発地から各都市への円コスト
    priority_queue<pair<ll,int>,vector<pair<ll,int>>,greater<>> pq;

    vector<ll> dist(n,1e18);
    vector<bool> det(n,false);

    dist[s]=0ll;

    pq.push({0ll,s});

    while(!pq.empty()){
        ll d=pq.top().first; ll node=pq.top().second;
        pq.pop();
        if(det[node]) continue;
        det[node]=true;
        for(auto tsugi:tonariy[node]){
            dist[tsugi.second]=min(dist[tsugi.second],dist[node]+tsugi.first);
            pq.push({dist[tsugi.second],tsugi.second});
        }
    }

    vector<ll> dists(n,1e18);
    vector<bool> dets(n,false);

    dists[t]=0ll;

    pq.push({0ll,t});

    while(!pq.empty()){
        ll d=pq.top().first; ll node=pq.top().second;
        pq.pop();
        if(dets[node]) continue;
        dets[node]=true;
        for(auto tsugi:tonaris[node]){
            dists[tsugi.second]=min(dists[tsugi.second],dists[node]+tsugi.first);
            pq.push({dists[tsugi.second],tsugi.second});
        }
    }

    vector<ll> anses(n);

    priority_queue<ll> cost;
    for(int i=n-1;i>=0;--i){
        cost.push(1e15-dist[i]-dists[i]);
        anses[i]=cost.top();
    }

    for(auto ans: anses) cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 17652
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cmath>

using namespace std;

long magicPP(int x, int y, int i, int j){
  return fabs(x - i) + fabs(y - j);
}


int main(){
  // input
  int H, W, D, A;
  cin >> H >> W >> D;
  int d[H*W+1];
  int px[H*W+1];
  int py[H*W+1];
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      cin >> A;
      px[A]=i;
      py[A]=j;
    }
  }

  for(int i=D+1;i<=H*W;i++){
    d[i] = d[i-D] + magicPP(px[i], py[i], px[i-D], py[i-D]);
  }
  int Q;
  cin >> Q;
  int L, R;
  for(int i=0;i<Q;i++){
    cin >> L >> R;
    cout << d[R] - d[L] << endl;
  }
  
  return 0;
}


Measured memory_bytes: 2176
n,y = map(int,input().split())
for i in range(n + 1):
    for j in range(n - i + 1):
        if i * 10000 + j * 5000 +(n - i - j)*1000 == y:
            print(i,j,n - i - j)
            exit()
print(-1,-1,-1)


Measured memory_bytes: 2940
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<bitset>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
typedef long long int ll;
typedef pair<int,int> P;
struct edge{int to,cost;};
#define REP(i,n) for(int i=0;i<(n);i++)
const int INF=100000000;

int main(){
	int N,T,c[110],t[110],min=INF;
	cin>>N>>T;
	REP(i,N){
		cin>>c[i]>>t[i];
	}
	REP(i,N){
		if(t[i]<=T&&c[i]<min){
			min=c[i];
		}
	}
	if(min==INF){
		cout<<"TLE"<<endl;
	}
	else{
		cout<<min<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
const int maxn = 200000 + 5;
const int mod = 10007;
const double PI = acos(-1.0);
const double eps = 1e-10;
int a[maxn], n, l[maxn], r[maxn];
stack<int> stk;
ULL ans ;
int main()
{
    while (~scanf("%d", &n)) {
        ans = 0;
        while (!stk.empty()) stk.pop();
        for (int i=1; i<=n; i++) scanf("%d", &a[i]);
        for (int i=n; i>0; i--) {
            while (!stk.empty() && a[stk.top()]>a[i]) {l[stk.top()]=i+1; stk.pop();}
            stk.push(i);
        }
        while (!stk.empty()) {l[stk.top()]=1; stk.pop();}

        for (int i=1; i<=n; i++) {
            while (!stk.empty() && a[stk.top()]>a[i]) {r[stk.top()]=i-1; stk.pop();}
            stk.push(i);
        }
        while (!stk.empty()) {r[stk.top()]=n; stk.pop();}

        for (int i=1; i<=n; i++) {
            ans += 1LL*(i-l[i]+1)*(r[i]-i+1)*a[i];
            //cout<<i<<": "<<l[i]<<" "<<r[i]<<" "<<(i-l[i]+1)*(r[i]-i+1)*a[i]<<endl;
        }
        cout<<ans<<endl;
    }
    return 0;
}


Measured memory_bytes: 3228
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>
#include <assert.h>
#include <unordered_set>
#include <random>



using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e18;
const ll MOD = 1e9 + 7;

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












 
int main(){
    ll n, m;
    cin >> n >> m;
    vector<ll> a(m), b(m);
    vector<vector<ll>> c(m);
    REP(i, m){
        cin >> a[i] >> b[i];
        c[i].resize(b[i]);
        REP(j, b[i]){
            cin >> c[i][j];
        }
    }
    vector<ll> dp(1 << n, INF);
    dp[0] = 0;
    for(ll bit = 0; bit < (1 << n); bit++){
        REP(i, m){
            ll t = bit;
            REP(j, b[i]){
                t |= 1 << (c[i][j] - 1);
                dp[t] = min(dp[t], dp[bit] + a[i]);
            }
        }
    }
    cout << ((dp[(1 << n) - 1] != INF)? dp[(1 << n) - 1] : -1) << endl;
}

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

#define fi first
#define se second
#define sz(a) (int)(a).size()
#define all(a) (a).begin(), (a).end()
#define reset(a, v) memset((a), v, sizeof(a))

using namespace std;

typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<ii> vii;

const int MAX = 12;

ll n;

int main() {
	scanf("%lld", &n);
	vector<char> ans;
	while (n) {
		int mods = n % 26;
		if (mods == 0) ans.push_back('z');
		else ans.push_back('a' - 1 + mods);
		n = (n-1) / 26;
	}
	reverse(all(ans));
	for (char ch : ans) printf("%c", ch);
	printf("\n");
	return 0;
}

Measured memory_bytes: 3692
#include <bits/stdc++.h>
#define LOOP(n) for (int _i = 0; _i < (n); _i++)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define FOR(i, r, n) for (int i = (r); i < (n); ++i)
#define ALL(obj) begin(obj), end(obj)
using namespace std;
using ll = long long;
using ull = unsigned long long;

const int INF = 2100100100;
const int MOD = 1e9 + 7;

// 多次元 vector 生成
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}

int main() {
    // cin.tie(0);
    // ios::sync_with_stdio(false);
    int N, H;
    cin >> N >> H;
    priority_queue<int> pa, pb;
    REP(i, N) {
        int a, b;
        cin >> a >> b;
        pa.push(a);
        pb.push(b);
    }

    int ans = 0;
    while (!pb.empty() && pb.top() > pa.top()) {
        int b = pb.top();
        pb.pop();
        H -= b;
        ans++;
        if (H <= 0) break;
    }

    if (H > 0) ans += (H + pa.top() - 1) / pa.top();

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


Measured memory_bytes: 1276
#include<stdio.h>
int main()
{
  long int a,b,c;
  scanf("%ld%ld%ld",&a,&b,&c);
  if(c-a-b<0) printf("No");
  else
  {
    if((a-b)*(a-b)>c*((2*a)+(2*b)-c)) printf("Yes");
    else printf("No");
  }
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

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

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

#define IN(l, r, x) ((l) <= (x) && (x) < (r))

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

    int n, m;
    cin >> n >> m;
    vector< pair<int, int> > vp(m);
    int a, b;
    rep (i, m)
    {
        cin >> a >> b;
        vp[i] = make_pair(b, a);
    }

    sort(vp.begin(), vp.end());

    int ans = 0;
    int t = 0;
    rep (i, m)
    {
        if (t <= vp[i].second)
        {
            ++ans;
            t = vp[i].first;
        }
    }

    cout << ans << "\n";
    return 0;
}



Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define dcout cout << fixed << setprecision(15)
#define rep(i, a) for(int i = 0; i < a; i++)
#define arep(i, x) for(auto i : x)
#define all(v) v.begin(), v.end()
#define int long long
#define F first
#define S second
#define VE vector<int>
#define pb(x) push_back(x)
using namespace std;
signed main() {
    int n;
    cin >> n;
    int ans = 0;
    rep(i, n - 1) {
        ans += i + 1;
    }
    cout << ans << endl;
    return 0;
}
/*
1 % 2=1
2 % 1=0


*/

Measured memory_bytes: 256
// Vicfred
// https://atcoder.jp/contests/abc052/tasks/abc052_a
// math
import std.stdio;

void main() {
    long a, b, c, d;

    readf("%s %s %s %s", &a, &b, &c, &d);

    if(a*b > c*d) {
        writefln("%s", a*b);
    } else {
        writefln("%s", c*d);
    }
}



Measured memory_bytes: 256