akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <iostream>
#define memcle(a) memset(a, 0, sizeof(a))
#define fo(i, a, b) for (i = a; i <= b; i++)
#define fd(i, a, b) for (i = a; i >= b; i--)
#define debug(x) cerr << #x << '=' << x << endl;
using namespace std;
typedef long long LL;
const int mo = int(1e9) + 7;
const int N = 100010;
int b[N], a[N], fac[N], ny[N], n;

int mi(int x, int y)
{
    if (y == 0) return 1;
    int t = mi(x, y >> 1);
    t = LL(t) * t % mo;
    if (y & 1) t = LL(t) * x % mo;
    return t;
}

void init()
{
    fac[0] = 1;
    for (int i = 1; i <= n; i++) fac[i] = LL(fac[i - 1]) * i % mo;
    ny[n] = mi(fac[n], mo - 2);
    for (int i = n; i >= 1; i--) ny[i - 1] = LL(ny[i]) * i % mo;
}

int C(int m, int n)
{
    if (m < n) return 0;
    return LL(fac[m]) * ny[n] % mo * ny[m - n] % mo;
}

int main()
{
    //freopen("a.in", "r", stdin);
    //freopen("a.out", "w", stdout);

    int i, j, ans = 1;
    scanf("%d", &n);
    init();
    fo(i, 1, n) scanf("%d", &a[i]);
    int cnt = 1, t = 0;
    fo(i, 2, n)
    {
        for (; a[i - 1] + 1 < cnt * 2; cnt --) t++;
        //debug(i);
        //debug(cnt);
        //debug(ans);
        b[i] = t;
        //ans = LL(ans) * (cnt + 1) % mo;
        cnt++;
    }
    cnt = 0;
    int k = 0;
    fd(i, n, 1)
    {
        cnt++;
        if (b[i - 1] != b[i] || i == 1)
        {
            ans = LL(ans) * C(n - b[i] - k, cnt) % mo;
            ans = LL(ans) * fac[cnt] % mo;
            k += cnt;
            cnt = 0;
        }
    }
    cout << ans << endl;
    return 0;
}




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

char S[101][101];
int dp[101][101];


const int mv_r[2] = {0, 1};
const int mv_c[2] = {1, 0};

int main(void) {
  int H, W;
  cin >> H >> W;

  for (int r = 1; r <= H; r++) {
    for (int c = 1; c <= W; c++) {
      cin >> S[r][c];
      dp[r][c] = 1000;
    }
  }

  if (S[1][1]=='#') {
    dp[1][1] = 1;
  } else {
    dp[1][1] = 0;
  }

  queue <pair<int, int>> pos;
  pos.push(make_pair(1, 1));

  while (pos.size() > 0) {
    pair <int, int> wkpos = pos.front();
    pos.pop();

    int r = wkpos.first;
    int c = wkpos.second;

    for (int i = 0; i < 2; i++) {
      int chgcnt;
      int nr = r+mv_r[i];
      int nc = c+mv_c[i];

      if (nr>H || nc>W) continue;

      if (S[r][c]=='.' && S[nr][nc]=='#') {
        chgcnt = dp[r][c]+1;
      } else {
        chgcnt = dp[r][c];
      }

      if (chgcnt < dp[nr][nc]) {
        dp[nr][nc] = chgcnt;
        pos.push(make_pair(nr, nc));
      }
    }
  }

  cout << dp[H][W] << endl;
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <string>
#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <cstring>
using namespace std;
typedef long long ll;
int n;
ll sum;
const int maxn = 1e6 + 5;
int vis[maxn];
int main(){
	scanf("%d", &n);
	for(int i = 1; i <= n; i++){
		if(i % 3 != 0 && i % 5 != 0)
			sum += i;
	}
	printf("%lld\n", sum);

	return 0;
}

Measured memory_bytes: 3828
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, N) for (int i = 0; i < (int)N; i++)
#define all(a) (a).begin(), (a).end()

int N;
vector<int> A;

int main () {
  cin >> N;
  A.resize(N+2, 0);

  rep(i,N) cin >> A[i+1];

  ll S = 0;
  rep(i,N+1) {
    S += abs(A[i] - A[i+1]);
  }

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

  return 0;
}


Measured memory_bytes: 1664
#include <iostream> // cin, cout, cerr, clog
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota, gcd, lcm 
#include <cstdio> // printf, scanf
#include <climits> // INT_MIN, LLONG_MIN
#include <cmath> // long, trig, pow
#include <vector> // vectors
#include <string> // string
#include <queue> // queue
#include <stack> // stack
#include <map> // key-value pairs sorted by keys
#include <unordered_map> // hashed by keys
#define _for(i,n) for(int i = 0; i < n; i++)

typedef long long ll; // at least int64 > 9*10^18
typedef unsigned long long ull; // at least uint64

using namespace std;

int main() {
  int n,k;
  cin >> n >> k;
  cout << n-k+1 << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        
        int n_bld = Integer.parseInt(sc.next());
        int wanted_colors = Integer.parseInt(sc.next());
        long[] h_each = new long[n_bld];
        for(int i=0; i<n_bld; i++){
            h_each[i] = Integer.parseInt(sc.next());
        }
        long min = get_min_yey(n_bld, wanted_colors, h_each, 0, 0, 0, 0);
        
        
        System.out.println(min);
    }
    private static long get_min_yey(int num, int desired, long[] h_each, long highest_former, int visible_n, long cost, int pos_now){
        if(visible_n >= desired) return cost;
        if((num - pos_now) < (desired - visible_n)) return Long.MAX_VALUE;
        
        if(h_each[pos_now] > highest_former) return get_min_yey(num, desired, h_each, h_each[pos_now], visible_n+1, cost, pos_now+1);
        long a = get_min_yey(num, desired, h_each, highest_former, visible_n, cost, pos_now+1);     //自分を無視した場合
        long b = get_min_yey(num, desired, h_each, highest_former+1, visible_n+1, cost+highest_former-h_each[pos_now]+1, pos_now+1);     //かさ上げした場合
        return Math.min(a, b);
    }
}

Measured memory_bytes: 21716
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i < (n); i++)
#define lower(s) transform(s.begin(), s.end(), s.begin(), ::tolower)
using namespace std;
using ll = long long;
int INF = 1001001001;

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

  rep(i, n) a[i]=i+1;
  map<vector<int>,int> mp;
  int i = 0;
  do {
    mp[a] = ++i;
  }
  while(next_permutation(a.begin(), a.end()));
  cout << abs(mp[p]-mp[q]) << endl;
  return 0;
}

Measured memory_bytes: 8632
import java.util.*;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		while(true){
			int m = sc.nextInt();
			if(m==0) break;
			
			int[] mx = new int[m];
			int[] my = new int[m];
			for(int i=0;i<m;i++){
				mx[i] = sc.nextInt();
				my[i] = sc.nextInt();
			}
			
			int n = sc.nextInt();
			int[] nx = new int[n];
			int[] ny = new int[n];
			for(int i=0;i<n;i++){
				nx[i] = sc.nextInt();
				ny[i] = sc.nextInt();
			}
			
			for(int z=0;z<n;z++){
				int x = nx[z]-mx[0];
				int y = ny[z]-my[0];
				boolean flag = true;
				for(int i=0;i<m;i++){
					for(int j=0;j<n;j++){
						if(mx[i]+x==nx[j] && my[i]+y==ny[j]) break;
						if(j==n-1) flag = false;
					}
					if(flag==false) break;
				}
				if(flag==true){
					System.out.println(x + " " + y);
					break;
				}
			}
		}
	}	
}

Measured memory_bytes: 29708
import java.util.Scanner
object Main extends App {
  val sc = new Scanner(System.in)
  val n = sc.nextInt
  val as = Array.fill(n)(sc.nextLong)
  val abss = as.map(Math.abs)

  println(if (as.count(_ < 0) % 2 == 0) abss.sum else abss.sum - abss.min * 2)
}

Measured memory_bytes: 65780
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ll long long int
const int INF = 2147483647;
const ll MOD = 1000000007;

using namespace std;

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

  vector<ll> a(n);
  vector<ll> f(n);
  REP(i, n) { cin >> a[i]; }
  REP(i, n) { cin >> f[i]; }

  sort(a.begin(), a.end());
  sort(f.begin(), f.end(), greater<ll>());

  ll ng = -1;
  ll ok = 1000000002000;

  while (abs(ok - ng) > 1) {
    ll mid = (ok + ng) / 2;
    ll c = 0;

    REP(i, n) {
      if (a[i] * f[i] <= mid)
        continue;
      c += (a[i] * f[i] - mid + f[i] - 1) / f[i];
    }
    if (c <= k) {
      ok = mid;
    } else {
      ng = mid;
    }
  }

  cout << ok << endl;
}


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

int main(){
  int64_t N,A,B,i=0,ans=0,total=0,nokori;
  cin >> N >> A >> B;
  total=A+B;
  ans=N/total;
  nokori=N%total;
  if(nokori>=A)
    nokori=A;
  
  ans=ans*A+nokori;
    
  cout<<ans<<endl;
}
  


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(LL i=0;i<N;++i)
typedef long long int LL;

int main()
{
	LL D, G;
	in >> D >> G;
	std::vector<LL>p(D), c(D);
	rep(i, D) in >> p[i] >> c[i];

	LL ans = 114514;
	rep(bit, (1LL << D))
	{
		LL resP = 0, resC = 0;
		rep(i, D)
		{
			if (bit&(1LL << i))
			{
				resP += 100 * (i + 1)*p[i] + c[i];
				resC += p[i];
			}
		}
		for (LL i = D - 1; i >= 0; --i)
		{
			if (!(bit&(1LL << i)))
			{
				LL wantP = G - resP;
				if (wantP <= 0) break;
				LL cnt = std::min(wantP / (100 * (i + 1)) + (wantP % (100 * (i + 1)) == 0 ? 0 : 1), p[i] - 1);
				resP += 100 * (i + 1)*cnt;
				resC += cnt;
			}
		}
		if (resP >= G) ans = std::min(ans, resC);
	}

	out << ans << std::endl;
	return 0;
}


Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author yassin
 */

#include <bits/stdc++.h>

using namespace std;

class arc096_c {
public:
    void solve(istream& in, ostream& out) {
        int A, B, C, X, Y;
        in >> A >> B >> C >> X >> Y;
        int cost = 1'000'000'000;
        /*for (int a = 0; a <= X; ++a) {
            int c = (X - a) * 2;
            int b = max(0, Y - c / 2);
            cost = min(cost, a * A + b * B + c * C);
        }
        for (int b = 0; b <= Y; ++b) {
            int c = (X - b) * 2;
            int a = max(0, Y - c / 2);
            cost = min(cost, a * A + b * B + c * C);
        }*/
        for (int c = 0; c <= 2 * max(X, Y); ++c) {
            int a = max(0, X - c / 2);
            int b = max(0, Y - c / 2);
            cost = min(cost, a * A + b * B + c * C);
        }
        out << cost << "\n";
    }
};

int main() {
	std::ios::sync_with_stdio(false); cin.tie(nullptr);
	arc096_c solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

public class Main{

    public static void main(String[] args)throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] t = br.readLine().split(" ");
        int a = Integer.parseInt(t[0]);
        int b = Integer.parseInt(t[1]);
        System.out.println(gcd(a, b));
    }

    public static int  gcd(int x, int y){
        int r;
        if(x < y){
            int temp;
            temp = x;
            x = y;
            y = temp;
        }

        while(y > 0){
            r = x % y;
            x = y;
            y = r;
        }
        return x;
    }

}

Measured memory_bytes: 24296
#include <iostream>
#include <vector>
#include <queue>

using namespace std;

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

typedef struct Point{
    int x;
    int y;
}Point_t;

void init_searched(bool **is_found, int height, int width);

int main(void)
{
    int height;
    int width;

    cin >> height;
    cin >> width;

    vector<string> maze;

    for(int i = 0; i < height; i++){
        string maze_line;
        cin >> maze_line;

        maze.push_back(maze_line);
    }

    queue<Point_t> search_que;
    bool **is_found;

    is_found = new bool*[height];
    for(int i = 0; i < height; i++){
        is_found[i] = new bool[width];
    }

    int max_dist = 0;
    for(int h = 0; h < height; h++){
        for(int w = 0; w < width; w++){
            Point_t start_point = {w, h};
            if(maze[h][w] == '#'){
                continue;
            }
            init_searched(is_found, height, width);
            search_que.push(start_point);
            is_found[h][w] = true;

            int max_d = 0;
            while(!search_que.empty()){
                int current_size = search_que.size();
                for(int que_index = 0; que_index < current_size; que_index++){
                    Point_t current_point = search_que.front();
                    search_que.pop();
                    for(int dir = 0;dir < 4; dir++){
                        int x = dx[dir] + current_point.x;
                        int y = dy[dir] + current_point.y;

                        if(x >= 0 && x < width && y >= 0 && y < height){
                            if(maze[y][x] == '.'){
                                if(!is_found[y][x]){
                                    search_que.push(Point_t{x, y});
                                    is_found[y][x] = true;
                                }
                            }
                        }
                    }
                }
                max_d += 1;
            }
            
            max_d -= 1;
            if(max_dist < max_d){
                max_dist = max_d;
            }
        }
    }

    cout << max_dist << endl;

    for(int i = 0; i < height; i++){
        delete[] is_found[i];
    }
    delete[] is_found;

    return 0;
}

void init_searched(bool **is_found, int height, int width)
{
    for(int i = 0; i < height; i++){
        for(int j = 0; j < width; j++){
            is_found[i][j] = false;
        }
    }
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int main(){
    int ans=0;
    vector<int>A(3);
    cin >> A.at(0) >> A.at(1) >> A.at(2);
    sort(A.begin(), A.end(), greater<int>());
    for(int i=1; i<3; i++){
        ans += abs(A.at(i)-A.at(i-1));
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		while(true){
			int n = sc.nextInt();
			int q = sc.nextInt();
			if(n==0 && q==0) break;
			
			int[] a = new int[102];
			int m;
			for(int i=0;i<n;i++){
				m = sc.nextInt();
				for(int j=0;j<m;j++) a[sc.nextInt()]++;
			}
			
			int ans = 0;
			for(int i=n;i>=q;i--){
				for(int j=0;j<102;j++){
					if(a[j]==i){
						ans = j;
						i = -1;
						j = 102;
					}
				}
			}
			System.out.println(ans);
		}	
	}	
}

Measured memory_bytes: 60420
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

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


int main() {
int a,b,c;
cin>>a>>b>>c;
if(a<=c&&c<=b) cout<<"Yes"<<endl;
else cout<<"No"<<endl;
}

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

 using namespace std;
 typedef long long ll;
 #define rep(i, n) for(int i = 0; i < (int)(n); i++)

 int main() {
   int N, M, drink = 0;
   ll ans = 0;
   cin >> N >> M;

   vector<pair<ll, ll>> AB(N);
   rep(i, N) cin >> AB.at(i).first >> AB.at(i).second;

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

   int i = 0;
   while (drink < M) {
     if (AB.at(i).second >= M - drink) {
       ans += AB.at(i).first * (M - drink);
       break;
     }
     else {
       ans += AB.at(i).first * AB.at(i).second;
       drink += AB.at(i).second;
       i++;
     }
   }

   cout << ans << endl;
 }


Measured memory_bytes: 1792
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <string.h>
#include <stack>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <memory.h>
#include <set>
#include <cmath>
#define fio ios::sync_with_stdio(false); cin.tie(NULL);

using namespace std;
#define ERR(x) cout << #x << " is: " << x << '\n';
typedef long long ll;
typedef pair<int, int> pii;
const long double PI = acos(-1);


ll p = 1e9 + 7; //this value must be prime
ll fact(ll x, ll y) {
	/*
		return x * (x-1) * (x-2) * .... * (y+1) * y;
	*/
	ll ans = 1;
	while (y <= x) {
		ans *= y;
		ans %= p;
		y++;
	}
	return ans;
}
ll trans(ll x) {
	/*
		return x's multiplicative inverse in p's modular state space
		that is x^(p-2);
	*/
	ll y = p - 2;
	ll ans = 1;
	for (int i = 0; y >> i; i++) {
		if ((y >> i) & 1) {
			ans *= x;
			ans %= p;
		}
		x *= x;
		x %= p;
	}
	return ans;
}
ll comb(ll x, ll y) {
	ll up, down;
	if (x < 2 * y) {
		up = fact(x, y + 1);
		down = fact(x - y, 1);
	}
	else {
		up = fact(x, x - y + 1);
		down = fact(y, 1);
	}
	return (up * trans(down)) % p;
}
ll a, b;
int main(void) {
	scanf("%lld %lld", &a, &b);
	if ((a + b) % 3) return !printf("0\n");
	ll k = (a + b) / 3;
	if (2 * b < a) return !printf("0\n");
	if (2 * a < b) return !printf("0\n");
	printf("%lld\n", comb(k, b - k));
}

Measured memory_bytes: 256
#include <iostream>
#include <string>

using namespace std;

int main() {
  string S;
  int64_t K;
  cin >> S >> K;
  char result = '1';
  for (int64_t i = 0; i < K; ++i) {
    if (S[i] != '1') {
      result = S[i];
      break;
    }
  }
  cout << result << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long n,ans=0;
  cin >> n;
  if(n<=6){
    ans++;
  }else if((n-6)%11==0){
    ans+=(n-6)/11*2+1;
  }else if(n%11==0){
    ans+=n/11*2;
  }else{
    if(n%11<=6){
      ans+=n/11*2+1;
    }else{
      ans+=n/11*2+2;
    }
  }
  cout << ans << endl;
}


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

class AIZU0022
   {
   public static int par() { string s = Console.ReadLine() ; return int.Parse(s); }
   public static HashSet<int> Mount=new HashSet<int>(), Valley=new HashSet<int>();
   public static List<int> M=new List<int>();  //register the sum from first to n-th
   public static void Main(string[] args) {
      int N;
      int k,kp=0;
      while (true) {
         N=par();
         if (N<=0) break;
         M.Clear();  Mount.Clear(); Valley.Clear();
         kp=0;
         for (int i = 0; i<N; i++) {
            k=par(); M.Add((i>0?M.Last():0)+k);
            if (kp<=0 && k>0 && i!=0&&i!=N-1) Valley.Add(i-1);
            if (kp>=0 && k<0 && i!=0&&i!=N-1) Mount.Add(i-1);
            kp=k;
         }
         Console.WriteLine(Sup());
      }
   }

   public static int Sup() { 
      //versus First
      int Max = M.Max();
      //versus Last
      int beta;
      if (M.Last()>=0) {
         beta=M.Last()-M.Min();
         if (beta>Max) Max=beta;
      }
      if (Mount.Count==0) {
         List<int> m = new List<int>() { M[0] };
         for (int i = 1; i<M.Count; i++) {
            m.Add(M[i]-M[i-1]);
         }
         beta=m.Max();
         if (beta>Max) Max=beta;
      }
      foreach (int st in Valley) {
         IEnumerable<int> G = Mount.Where(i => i>st);
         foreach (int g in G) {
            beta=M[g]-M[st];
            if (beta>Max) Max=beta;
         }
      }
      return Max;
   }
}

Measured memory_bytes: 10248
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	private static final int B = 4;
	private static final int F = 3;
	private static final int R = 10;

	public static void main(String[] args) throws  IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder sb = new StringBuilder();
		int[][][] residence = new int[B][F][R];

		int n = Integer.parseInt(br.readLine());
		for (int i = 0; i < n; i++) {
			String[] str = br.readLine().split(" ");
			int b = Integer.parseInt(str[0]);
			int f = Integer.parseInt(str[1]);
			int r = Integer.parseInt(str[2]);
			int v = Integer.parseInt(str[3]);
			residence[b - 1][f - 1][r - 1] += v;
		}

		for (int i = 0; i < B; i++) {
			for (int j = 0; j < F; j++) {
				for (int k = 0; k < R; k++) {
					sb.append(" ").append(residence[i][j][k]);
				}
				sb.append("\n");
			}
			if (i != B - 1) {
				sb.append("####################").append("\n");
			}
		}

		System.out.print(sb);
	}

}

Measured memory_bytes: 24320
#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
	int N, M, X, Y;
	int x[100];
	int y[100];
	int i;

	cin >> N >> M >> X >> Y;
	for (i = 0; i < N; i++) {
		cin >> x[i];
	}
	for (i = 0; i < M; i++) {
		cin >> y[i];
	}

	sort(x, x + N);
	sort(y, y + M);
	int xmax = max(x[N - 1], X);
	int ymin = min(y[0], Y);

	if (xmax < ymin) {
		cout << "No War" << endl;
	}
	else {
		cout << "War" << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
int main(){
  int n,m;
  while(cin >> n >> m && n != 0 && m != 0){
	vector<bool> seki(n,true);
	int cn = -1;
	for(int i = 0;i < n-1;i++){
	  int offset = 0;
	  for(int j = 0;j < m+offset;j++){
		cn++;
		cn = cn%n;
		if(!seki[cn]){
		  offset++;
		}
	  }
	  seki[cn] = false;
	}
	for(int i=0;i < n;i++){
	  if(seki[i])cout << i+1 << endl;
	}
		
  }
}

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

'''
n = 10
l = [9,5,10,3,6,7,4,1,2,8]
'''

start_index = 0
swap_cnt = 0

for j in range(start_index, n):
    if len(l[start_index:n]) == 1:
        break
    else:
        tmp = l[start_index]
        min_value = l[start_index]
        min_index = start_index

        for idx in range(start_index,n):
            if min_value > l[idx]:
                min_value = l[idx]
                min_index = idx

        l[start_index] = min_value
        l[min_index] = tmp

        if min_value != tmp:
            swap_cnt += 1

        start_index += 1

print(' '.join(map(str,l)))
print(swap_cnt)


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

int main() {
  int a,b,c;
  cin >> a >> b >> c ;
  int ans=a+b+c;

  if(ans>=22) cout << "bust" << endl;

  else cout << "win" << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define rep1(i,n) for(int i=1;i<=(n);++i)
#define all(c) (c).begin(),(c).end()
typedef long long ll;
ll f[220001],mod=1e9+7;
ll extgcd(ll a,ll b,ll &x,ll &y){
	if(b==0){
		x=a,y=0;
		return a;
	}
	ll d=extgcd(b,a%b,x,y),xx=y,yy=((x-a/b*y)%mod+mod)%mod;
	x=xx,y=yy;
	return d;
}
ll inv(ll a){
	ll x,y;
	extgcd(a,mod,x,y);
	return x;
}
ll comb(int a,int b){
	if(b==-1) return 0;
	return f[a]*inv(f[a-b])%mod*inv(f[b])%mod;
}
int main(){
	f[0]=1;
	rep1(i,220000) f[i]=f[i-1]*i%mod;
	int n,m,k;
	ll ans=0;
	scanf("%d%d%d",&n,&m,&k);
	rep(kx,k+1){
		int ky=k-kx;
		ans+=(comb(n+2*kx,kx)-comb(n+2*kx,kx-1)+mod)*(comb(m+2*ky,ky)-comb(m+2*ky,ky-1)+mod)%mod*comb(n+m+2*k,n+kx*2)%mod;
		ans%=mod;
	}
	printf("%lld\n",ans);
	return 0;
}

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

#define fi first
#define se second
#define be begin
#define en end
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define ALL(a) (a).be() , (a).en()
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)        //repeat n times
#define REP2(i,s,n) for(int (i)=(s);(i)<(n);(i)++)   //repeat from s to n 
#define REPD(i,n) for(int (i)=(n);(i)>=0;(i)--)      //repeat from n to 0
#define REPD2(i,s,e) for(int (i)=(s);(i)>=(e);(i)--) //repeat from s to e
#define RANGE(i,v) for(auto &(i):v)                  //repeat range
#define ASIZE(a) (sizeof(a) / sizeof(a[0]))          //array size

using LL = long long;

template<typename T> using V = vector< T >;
using Vi = V<int>;
using Vll = V<LL>;
using Vs = V<string>;

template<typename T>
T vec_sum(V<T> v, T init_val=0){return accumulate(ALL(v),T(init_val));}

int main(){
    int N,M;
    cin>>N>>M;
    Vi A(N);
    REP(i,N) cin>>A[i];
    int sum_A = vec_sum(A);
    int cnt = 0;
    REP(i,N){
        if(A[i]*4*M>=sum_A) cnt++;
    }
    if(cnt>=M){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
    return 0;
}

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

int main(){
	string s;
	int j;
	cin >> s;
	vector<string> weather{"Sunny", "Cloudy", "Rainy"};

	for(int i=0; i<3; i++){
		if(s == weather[i]){
			j = i;
		}
	}
	j = (j+1)%3;
	cout << weather[j] << endl;
	return 0;
}

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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define UB upper_bound
#define LB lower_bound
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

int n, s[100];
int dp[10001];

int main() {
	cin >> n;
	inc(i, n) { cin >> s[i]; }
	
	dp[0] = 1;
	inc(i, n) {
	dec(j, 10001) {
		if(dp[j]) { dp[j + s[i]] = 1; }
	}
	}
	
	int ans = 0;
	inc(i, 10001) {
		if(i % 10 != 0 && dp[i]) { ans = i; }
	}
	
	cout << ans << endl;
	
	return 0;
}


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

struct Card{
	char suit;
	int value;
};

struct Card L[MAX / 2 + 2], R[MAX / 2 + 2];

void merge(struct Card A[], int n, int left, int mid, int right){
	int i,j,k;
	int n1 = mid - left;
	int n2 = right - mid;
	for( i=0; i<n1; i++) L[i] = A[left + i];
	for( i=0; i<n2; i++) R[i] = A[mid + i];
	L[n1].value = R[n2].value = SENTINEL;
	i = j = 0;
	for( k=left; k<right; k++){
		if(L[i].value <= R[j].value){
			A[k] = L[i++];
		} else{
			A[k] = R[j++];
		}
	}
}

void mergeSort(struct Card A[], int n, int left, int right){
	int mid;
	if( left + 1 < right){
		mid = (left+right)/2;
		mergeSort(A, n, left, mid);
		mergeSort(A, n, mid, right);
		merge(A, n, left, mid, right);
	}
}

int partition(struct Card A[], int n, int p, int r){
	int i, j;
	struct Card t, x;
	x = A[r];
	i = p - 1;
	for( j=p; j<r; j++){
		if( A[j].value <= x.value ){
			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;
}

void quickSort( struct Card A[], int n, int p, int r){
	int q;
	if( p<r ){
		q=partition(A, n, p, r);
		quickSort(A,n,p,q-1);
		quickSort(A,n,q+1,r);
	}
}

int main(){
	int n, i, v;
	struct Card A[MAX], B[MAX];
	char S[10];
	int stable=1;
	
	scanf("%d",&n);
	
	for(i=0; i<n; i++){
		scanf("%s %d",S, &v);
		A[i].suit = B[i].suit =S[0];
		A[i].value = B[i].value = v;
	}
	
	mergeSort(A, n, 0, n);
	quickSort(B, n, 0, n-1);
	
	for( i=0; i<n; i++){
		//マージソートとクイックソートの結果を比べる
		if (A[i].suit != B[i].suit) stable =0;
	}
	
	if( stable == 1 ) printf("Stable\n");
	else printf("Not stable\n");
	for( i=0; i<n; i++){
		printf("%c %d\n", B[i].suit, B[i].value);
	}
	
	return 0;
}


Measured memory_bytes: 4024
#アルゴリズムの実装
def greatest_common_divisor(x, y):
    if x == y:
        return x
    elif x > y:
        while True:
            x, y = y, x % y
            if y == 0: break
        return x
    else:
        x, y = y, x
        while True:
            x, y = y, x % y
            if y == 0: break
        return x

#入力dataの挿入
input_data = list(map(int, input().split()))

#処理の実行
result = greatest_common_divisor(input_data[0], input_data[1])
print(result)



Measured memory_bytes: 5600
#include<bits/stdc++.h>
//#pragma GCC optimize("O3")
//#pragma GCC target ("sse4")
using namespace std;
#define PB push_back
#define all(x) (x).begin(),(x).end()
#define MEM(x,a) memset((x),a,sizeof((x)))
#define F first
#define S second
#define imx INT_MAX
#define inI(x) scanf("%d",&x)
#define inI2(x,y) scanf("%d %d",&x,&y)
#define inI3(x,y,z) scanf("%d %d %d",&x,&y,&z)
const long long MOD = (long long)(1e9+7);
const long long MMX = (long long)(1e18);
typedef long long LL;
int a,b,x;
LL ss;
vector<int>v;
int main()
{
    scanf("%d %d",&a,&b);
    for(int i=0;i<a;i++)
    {
        scanf("%d",&x);
        v.push_back(x);
    }
    sort(all(v));
    for(int i=0;i<a-b;i++)ss+=v[i];
    printf("%lld",ss);
}


Measured memory_bytes: 1400
import math


def distance(A,B):
    tmp = 0
    for i in range(len(A)):
        tmp += (A[i] - B[i]) ** 2
    tmp = math.modf(tmp ** 0.5)
    if tmp[0] == 0.0:
        return True
    else:
        return False


N,D = [int(i) for i in input().split()]
X = [[int(i) for i in input().split()] for _ in range(N)]    
ans = 0
for i in range(N-1):
    for j in range(i+1, N):
        if distance(X[i],X[j]):
            ans+=1
print(ans)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(i64 (i) = (s);(i) < (e);(i)++)
#define rev(i,s,e) for(i64 (i) = (e);(i) --> (s);)
#define all(x) x.begin(),x.end()

int main() {
  i64 N, M;
  cin >> N >> M;
  vector<vector<i64>> s;
  rep(m,0,M) {
    i64 k = 0;
    cin >> k;
    vector<i64> vec(k);
    rep(i,0,k) {
      i64 a;
      cin >> a;
      a--;
      vec[i] = a;
    }
    s.push_back(std::move(vec));
  }

  vector<i64> p(M);
  rep(i,0,M) cin >> p[i];

  i64 ans = 0;
  for(i64 t = 0;t < (1 << N); t++) {
    bool OK = true;
    rep(i,0,M) {
      auto& v = s[i];
      i64 cnt = 0;
      for(auto& x: v) {
        if(t & (1 << x)) cnt++;
      }
      if(cnt % 2 != p[i])
        OK = false;
    }
    if(OK) ans++;
  }
  cout << ans << endl;
}


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

#define i64 long long int

int n;
int fac;
i64 ans;

int main() {
	scanf("%d", &n);
	
	fac = 1;
	ans = 1LL;
	for(int i=0;i<n;i++) {
		i64 x;
		scanf("%lld", &x);
		
		if(x==0) fac = 0;
		else 
		if(ans<0) continue;
		else 
		if(1000000000000000000LL/x < ans) ans = -1LL;
		else ans *= x;
	}
	printf("%lld\n", ans * fac);
	
	return 0;
}

Measured memory_bytes: 3796
n = int(input())
a = list(map(int,input().split()))
dic = {}
for i in a:
    if i in dic:
        dic[i] += 1
    else:
        dic[i] = 1
point = 0
for j,k in dic.items():
    point += k*(k-1)//2

for i in a:
    j = point
    j -= dic[i]*(dic[i]-1)//2
    j += (dic[i]-1)*(dic[i]-2)//2
    print(j)

Measured memory_bytes: 26140
#include<iostream>
#include<vector>
#include<unordered_map>
#include<unordered_set>
#include<cmath>
#include<algorithm>
using namespace std;

//input
long long N;
unordered_set<long long> s;

long long isqrt(long long n) {
    int i;
	for (i = 1; n > 0; ++i) {
		n -= i * 2 + 1;
	}
	return i - 1;
}

void divisor(long long n) {
    int sq = isqrt(n);
    for (int i = 1; i < sq + 1; ++i) {
        if (n % i == 0) {
            s.insert(i);
            s.insert(n / i);
        }
    }
    return;
}

int main() {
    cin >> N;
    divisor(N);

    long long ans = 0;
    for (auto itr = s.begin(); itr != s.end(); ++itr) {
        //cout << "Yay" << endl;
        long long d = *itr - 1; 
        if (d == 0) continue;
        if (N / d == N % d) ans += d; 
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll mod = pow(10, 9) + 7;
  ll N;
  cin >> N;
  ll dp[N + 1][4][4][4]{};
  // dp[i][j][k][l] i 文字目まで見た時、後ろの文字が、jkl となる
  // 0: A, 1: G, 2: C, T: 3
  for (int i = 0; i < 4; i++) {
    for (int j = 0; j < 4; j++) {
      for (int k = 0; k < 4; k++) {
        if (i == 0 && j == 1 && k == 2) continue;
        if (i == 0 && j == 2 && k == 1) continue;
        if (i == 1 && j == 0 && k == 2) continue;
        dp[3][i][j][k] = 1;
      }
    }
  }
  
  for (int i = 4; i <= N; i++) {
    for (int j = 0; j < 4; j++) {
      for (int k = 0; k < 4; k++) {
        for (int l = 0; l < 4; l++) {
          if (j == 0 && k == 1 && l == 2) continue;
          if (j == 0 && k == 2 && l == 1) continue;
          if (j == 1 && k == 0 && l == 2) continue;
          for (int m = 0; m < 4; m++) {  
            if (j == 0 && k == 1 && m == 2) continue;
            if (j == 0 && l == 1 && m == 2) continue;
            dp[i][j][k][l] += dp[i - 1][k][l][m];
            dp[i][j][k][l] %= mod;
          }
        }
      }
    }
  }

  ll ans = 0;

  for (int i = 0; i < 4; i++) {
    for (int j = 0; j < 4; j++) {
      for (int k = 0; k < 4; k++) {
        ans += dp[N][i][j][k];
        ans %= mod;
      }
    }
  }
  cout << ans << "\n";
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

class Edge
{
public:
    int to, cost;
    Edge(){};
    Edge(int to0, int cost0){to = to0; cost = cost0;}
};

void shortestPath(const vector<vector<Edge> >& edges, int start, vector<int>& dist)
{
    dist.assign(edges.size(), INT_MAX);
    dist[start] = 0;
    priority_queue<pair<int,int> ,vector<pair<int,int> >, greater<pair<int,int> > > q;
    q.push(make_pair(0, start));

    while(!q.empty()){
        pair<int, int> p = q.top();
        q.pop();
        int v = p.second;
        if(dist[v] < p.first)
            continue;
        for(unsigned i=0; i<edges[v].size(); ++i){
            Edge e = edges[v][i];
            if(dist[v] + e.cost < dist[e.to]){
                dist[e.to] = dist[v] + e.cost;
                q.push(make_pair(dist[e.to], e.to));
            }
        }
    }
}

int main()
{
	for(;;){
		int m, n, k, d;
		cin >> m >> n >> k >> d;
		if(m == 0)
			return 0;

		vector<int> cake(m);
		for(int i=0; i<m; ++i)
			cin >> cake[i];

		vector<vector<Edge> > edges((m+n+2)*(1<<m));
		while(--d >= 0){
			vector<string> s(2);
			int cost;
			cin >> s[0] >> s[1] >> cost;
			cost *= k;

			vector<int> a(2);
			for(int i=0; i<2; ++i){
				if(s[i][0] == 'H')
					a[i] = 0;
				else if(s[i][0] == 'C')
					a[i] = s[i][1] - '0';
				else if(s[i][0] == 'L')
					a[i] = atoi(s[i].substr(1).c_str()) + m;
				else
					a[i] = m+n+1;
			}

			for(int k=0; k<2; ++k){
				for(int i=0; i<(1<<m); ++i){
					if(1 <= a[1] && a[1] <= m && (i & (1<<(a[1]-1))))
						continue;
					if(1 <= a[1] && a[1] <= m && !(i & (1<<(a[1]-1)))){
						int j = i | (1<<(a[1]-1));
						edges[i*(m+n+2)+a[0]].push_back(Edge(j*(m+n+2)+a[1], cost-cake[a[1]-1]));
					}else
						edges[i*(m+n+2)+a[0]].push_back(Edge(i*(m+n+2)+a[1], cost));
				}
				swap(a[0], a[1]);
			}
		}

		vector<int> dist;
		shortestPath(edges, 0, dist);
		int ret = INT_MAX;
		for(int i=0; i<(1<<m); ++i)
			ret = min(ret, dist[(m+n+2)*(i+1)-1]);
		cout << ret << endl;
	}
}

Measured memory_bytes: 1504
import re

class IO_for_Contest(object):
    @staticmethod
    def my_input():
        #return raw_input()
        return input()

    @staticmethod
    def read_from_input():
        n, l = IO_for_Contest.read_n_int(2)
        a = IO_for_Contest.read_n_int(n)
        return l, a

    @staticmethod
    def read_line():
        return IO_for_Contest.my_input().strip()

    @staticmethod
    def read_int():
        return int(IO_for_Contest.my_input().strip())

    @staticmethod
    def read_n_int(n):
        return list(map(int, re.split('\W+', IO_for_Contest.my_input().strip())))[ : n]


def solve():
    l, a = IO_for_Contest.read_from_input()
    result = find_way_how_to_split_ropes(l, a)
    if result is None:
        print('Impossible')
    else:
        print('Possible')
        for x in result:
            print(x)

def find_way_how_to_split_ropes(l, a):
    adjencent_sum = []
    for i in range(len(a) - 1):
        adjencent_sum.append(a[i] + a[i + 1])
    if max(adjencent_sum) < l:
        return None
    x = 0
    result = []
    for y in range(len(adjencent_sum)):
        if adjencent_sum[y] >= l:
            x = y + 1
            break
        result += [y + 1]
    for y in range(len(adjencent_sum) - 1, x - 1, -1):
        result += [y + 1]
    result += [x]
    return result

if __name__ == '__main__':
    solve()

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

using namespace std;
using ll =long long;
typedef pair<int,int> P;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//Write From this Line

int main()
{
	int d;
	cin >> d;
	vector<int> c(26);
	rep(i,26) cin >> c[i]; 
	vector<vector<int>> s(d,vector<int>(26));
	rep(i,d) rep(j,26) cin >> s[i][j];

	vector<int> t(d);
	rep(i,d){
		cin >> t[i];
		t[i]--;//ゲームは0-indexed
	}
	// 最後に試合を行った日を保持する。
	//vector<int> last_d(26,0);
	vector<vector<int>> last_d(d,vector<int>(26,-1));
	ll ans = 0;
	rep(i,d){
		// i日目に試合t[i-1]を行う。
		int game = t[i];
		if(i != 0){
			rep(j,26){
				last_d[i][j] = last_d[i-1][j];
			}
		}
		last_d[i][game] = i;
		ans += s[i][game];
		rep(j,26){
			ans -= c[j] * (i - last_d[i][j]);
		}
		cout << ans << endl;
	}
//	int m;
//	cin >> m;
//	rep(i,m){
//		int d, q;
//		cin >> d >> q;
//		--d, --q;
//
//	}
}


Measured memory_bytes: 3728
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef long  l;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
const double PI=3.141592653589;
const int INF=1000000007;
const ll LMAX=1000000000000001;
int gcd(int a,int b){if(a<b)swap(a,b);int c=a%b;while(c!=0){a=b;b=c;c=a%b;}return b;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
int dx[]={-1,0,1,0};
int dy[]={0,1,0,-1};


int main(){
  int n,X; cin>>n>>X;
  vector<int> x(n+1);
  rep(i,n) cin>>x[i];
  x[n]=X;
  sort(ALL(x));
  int gc=x[1]-x[0];
  rep(i,n){
    gc=gcd(gc,x[i+1]-x[i]);
  }
  cout<<gc<<endl;

  return 0;
}


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

int main(){
  set<int> hon={2,4,5,7,9},pon={0,1,6,8},bon={3};	
  int n; cin>>n;
  int l = n%10;
  if(hon.find(l)!=hon.end()) cout<<"hon";
  else if(pon.find(l)!=pon.end()) cout<<"pon";
  else cout<<"bon";
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int n,k,now = 1;
  cin >> n >> k;
  for(int i=0; i<n; i++){
    if(now * 2 < now + k) now *= 2;
    else now += k;
  }
  cout << now << endl;
  return 0;
}


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

int main(){
  string s; cin >> s;
  for(int i=0;i<3;i++){
      if(s.at(i) == '7'){
          cout << "Yes" << endl;
          return 0;
          }}
cout << "No" << endl;
}


Measured memory_bytes: 3624
#include <iostream>
#include <algorithm>
using namespace std;
int main() {

  //a+b a-b a*b
  int a, b, pl, mi, cr;
  cin >> a >> b;

pl = a+b;
mi = a-b;
cr = a*b;




  cout << max({pl,mi,cr});
  return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for (int &e : A) cin >> e;
  
  int h = 0;
  for (int i = N-1; i >= 0; i -= 2) {
    cout << A[i] << " ";
    if (i == 0) h = 1;
  }
  for (int i = h; i < N; i += 2) {
    cout << A[i];
    if (i < N-2) cout << " ";
  }
  cout << endl;
}

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

#define rep(i,N) for(int i=0;i<N;i++)
#define rep2(i,N) for(int i=1;i<=N;i++)
using namespace std;
long long  INF=1e18;
long long mod=1e9+7;

//status unsolved

int main(){
    double n,m,d;
    cin>>n>>m>>d;

    
    double ans;
    
    
    double tmp=n;
        if(n>=2*d+1 && d>0){
        tmp+=(n-2*d);
        }
    
    ans=(double)tmp*(m-1);
    ans/=n;
    ans/=n;
    printf("%.10lf\n",ans);
    
    
    return 0;

}
/*


*/


Measured memory_bytes: 256
using System;
using static System.Console;
using static System.Convert;

class Program
{
    static void Main(string[] args)
    {
        var num=ToInt32(ReadLine());
        var nums = Array.ConvertAll(ReadLine().Split(' '), int.Parse);
        Array.Sort(nums);
        WriteLine(nums[num - 1] - nums[0]);
    }
}



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

typedef long long ll;
#define MOD1 1000000007
#define MOD2 1000000009
#define FOR(a,b) for(ll i=a;i<b;i++)
#define endl "\n"

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

  string s;
  cin >> s;
  int ans;
  int sum = 0;
  for (int i = 0; i < s.size(); i++)
    sum += ((int)s[i] - 48) % 9;
  if (sum % 9 == 0)
    cout << "Yes\n";
  else
    cout << "No\n";


  return 0;
}



Measured memory_bytes: 3744
N,M = map(int, input().split())
L = []
R = []
for _ in range(M):
  l,r = map(int, input().split())
  L.append(l)
  R.append(r)

ans = min(R)-max(L)+1
if ans < 0:
  print(0)
else:
  print(ans)
  

Measured memory_bytes: 11020
#define _CRT_SECURE_NO_WARNINGS

#include<iostream>
#include<string>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<map>
#include<tuple>
#include<algorithm>
#include<numeric>
#include<math.h>

#define REPS(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) for (int i = 0; i < (n); i++)

using namespace std;

using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;

const int mod = 1e9 + 7;
const long double pi = 3.141592653589793238462643383279502884197;
const long double eps = 1e-7;

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

	int ans = mod;
	REP(i, N) {
		int num;
		cin >> num;
		int div_num = 0;
		while (1) {
			if (num % 2 == 0) {
				num /= 2;
				div_num++;
			}
			else break;
		}
		ans = min(ans, div_num);
	}
	cout << ans;
	system("pause");
	return 0;
}

Measured memory_bytes: 504
#include<bits/stdc++.h>
using namespace std;
#define inf INT_MAX
#define INF LLONG_MAX
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
#define IN(a,n) rep(i,n){ cin>>a[i]; }
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
#define vi vector<int>
#define IP pair<int,P>
#define PP pair<P,P>


int c[1100][1100];

void comb_table(void){
  for(int i=0;i<=1000;i++){
    for(int j=0;j<=i;j++){
      if(j==0||j==i){
        c[i][j] = 1LL;
      }
      else{
        c[i][j]=(c[i-1][j-1]+c[i-1][j]);
      }
    }
  }
}

signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(20);

  int n,a,b;
  cin>>n>>a>>b;
  vi v(n);
  rep(i,n){
    cin>>v[i];
  }

  sort(all(v));
  reverse(all(v));

  int s=0,t=0;
  rep(i,n){
    if(v[i]==v[a-1]){
      s++;
      if(i<a) t++;
    }
  }

  double ave=0;
  rep(i,a){
    ave+=v[i];
  }

  ave/=a;
  comb_table();
  cout<<ave<<endl;
  int ans=0;
  if(a==t){
    FOR(i,a,b+1){
      ans+=c[s][i];
    }
  }else{
    ans=c[s][t];
  }

  cout<<ans<<endl;



}

Measured memory_bytes: 7936
#include <algorithm>
#include <iostream>

#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, m, n) for (int i = m; i < n; i++)
#define nbs(y) (y % 2 ? odd_y : even_y)

int builds[102][102];
int odd_y[][2] = {{0, 1}, {1, 1}, {1, 0}, {1, -1}, {0, -1}, {-1, 0}};
int even_y[][2] = {{-1, 1}, {0, 1}, {1, 0}, {0, -1}, {-1, -1}, {-1, 0}};

bool in_rng(int x, int y, int w, int h) {
    return x >= 0 && y >= 0 && w + 1 >= x && h + 1 >= y;
}
int main() {
    int w, h;
    std::cin >> w >> h;

    rep(x, 102) rep(y, 102) builds[x][y] = 0;
    repr(y, 1, h + 1) repr(x, 1, w + 1) {
        int v;
        std::cin >> v, builds[x][y] = v;
    }

    bool labeled;
    do {
        labeled = false;
        rep(x, w + 2) rep(y, h + 2) {
            if (x == 0 && y == 0)
                builds[0][0] = 2;
            else if (!builds[x][y] &&
                     std::any_of(nbs(y), nbs(y) + 6, [&](int ns[]) {
                         int p = x + ns[0], q = y + ns[1];
                         return in_rng(p, q, w, h) && builds[p][q] == 2;
                     }))
                builds[x][y] = 2, labeled = true;
        }
    } while (labeled);

    int count = 0;
    rep(x, w + 2) rep(y, h + 2) rep(i, 3) {
        int p = x + nbs(y)[i][0], q = y + nbs(y)[i][1];
        if (in_rng(p, q, w, h) && ((builds[x][y] == 1 && builds[p][q] == 2) ||
                                   (builds[x][y] == 2 && builds[p][q] == 1)))
            count++;
    }
    std::cout << count << std::endl;
}

Measured memory_bytes: 3128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ldb = long double;
using pa = pair < ll, ll >;
using vec = vector < ll >;
#define pb push_back
#define po pop_back
#define mp make_pair
#define mt make_tuple
#define F  first
#define S  second
#define f(i,x,n) for(ll i=x;i<n;i++) 
#define all(c) c.begin(),c.end()
#define str string
#define edl "\n"
#define add insert
#define cot continue
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL)
const int MOD = 1e9 + 7, INF = INT_MAX, N = 1e5 + 10;
const double PI = acos(-1);
const ll LINF = LLONG_MAX;




int main() 
{

 fast();
  
  // #ifndef ONLINE_JUDGE
  //   freopen("input.txt", "r", stdin);
  //   freopen("output.txt","w",stdout);
  // #endif
  ll a;
  cin>>a;
  vector<tuple<str,ll,ll>>q;
  str s;ll a1;
  f(i,0,a)
  {
    cin>>s>>a1;
    q.pb(mt(s,-a1,i+1));
  }
  sort(all(q));
  f(i,0,a)
  {
    cout<<get<2>(q[i])<<edl;
  }
  


    




    // cerr << "Time taken: " << int((clock() * 1000.) / CLOCKS_PER_SEC) << "ms\n";
    return 0;
}
 

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>
using namespace std;

template <typename Tp> inline void getint(Tp &num){
	register int ch, neg = 0;
	while(!isdigit(ch = getchar())) if(ch == '-') neg = 1;
	num = ch & 15;
	while(isdigit(ch = getchar())) num = num * 10 + (ch & 15);
	if(neg) num = -num;
}

int N, A, B;

int main(){
	getint(N), getint(A), getint(B);
	return printf("%d %d\n", min(A, B), max(0, A + B - N)), 0;
}

Measured memory_bytes: 384