akhauriyash/Code-Regression huggingface dataset:
def fastio():
    import sys
    from io import StringIO 
    from atexit import register
    global input
    sys.stdin = StringIO(sys.stdin.read())
    input = lambda : sys.stdin.readline().rstrip('\r\n')
    sys.stdout = StringIO()
    register(lambda : sys.__stdout__.write(sys.stdout.getvalue()))
fastio()

INF = 10**20
MOD = 10**9 + 7
I = lambda:list(map(int,input().split()))
from collections import defaultdict as dd

a, b, c = I()
if a + b + c >= 22:
    print('bust')
else:
    print('win')


Measured memory_bytes: 3564
#include <stdio.h>

int main()
{
	int N, i, j, k, count = 0;
	int A[100];
	
	scanf("%d",&N);
	for(i = 0; i < N; i++) scanf("%d",&A[i]);
	
	for(j = 0; j < N-1; j++){
		for(i = N-1; i > 0; i--){
			if(A[i] < A[i-1]){
				k = A[i];
				A[i] = A[i-1];
				A[i-1] = k;
				count++;
			}
		}
	}

	
	for(i = 0; i < N; i++){
          if(i > 0) printf(" "); 
	printf("%d", A[i]);
        }
        printf("\n");
	printf("%d\n",count);
	
	return 0;
}

Measured memory_bytes: 1804
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll mod=1e9+7;
int dy[]={1,-1,0,0};
int dx[]={0,0,1,-1};

int main(){
  int N,W;
  cin>>N>>W;
  vector<int> w(N),v(N);

  for(int i=0;i<N;i++){
    cin>>w[i]>>v[i];
  }
  vector<vector<ll>> dp(N,vector<ll>(1e5+1,1e15));
  dp[0][0]=0;
  dp[0][v[0]]=w[0];
  for(int i=1;i<N;i++){
    for(int j=0;j<1e5+1;j++){
      dp[i][j]=dp[i-1][j];
      if(j-v[i]>=0) dp[i][j]=min(dp[i][j],dp[i-1][j-v[i]]+w[i]);
    }
  }
  int ans=0;
  for(int i=0;i<1e5+1;i++){
    if(dp[N-1][i]>0&&dp[N-1][i]<=W) ans=i;
  }
  
  cout<<ans<<endl;
  return 0;
}




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

int main(){
	long double N,D,a2,b2,ab2,nuevaA,nuevaB, contador=0;
  long double distancia;
  cin>>N>>D; 

  vector<int> a(N,0);
  vector<int> b(N,0);

  for (int i =0; i<N; i++){
    cin>> a[i] >> b[i];
    if (a[i]<0){
      nuevaA=a[i]*(-1);
    }
    else{
      nuevaA=a[i];
    }

    if (b[i]<0){
      nuevaB=b[i]*(-1);
    }
    else{
      nuevaB=b[i];
    }
    a2=nuevaA*nuevaA;
    b2=nuevaB*nuevaB;
    ab2=a2+b2;
    distancia= sqrt(ab2);
     //cout<< distancia<< endl;
    if(distancia<=D){
      contador++;
    }
  }

    cout<< contador;
}

Measured memory_bytes: 4900
#include<bits/stdc++.h>
#define INF 0x3f3f3f3f
const int MOD=1e9+7;
const double eps=1e-8;
typedef long long ll;
//orz yht
using namespace std;
ll n,a[200005],b[200005],c[200005],sum;
int main(){
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	cin>>n;
	for(ll i=1;i<=n;i++){
		cin>>b[i];
		a[b[i]]++;
	}
	for(ll i=1;i<=200000;i++)
	c[i]=a[i];
	for(ll i=1;i<=200000;i++)
	a[i]=a[i]*(a[i]-1)/2,sum+=a[i];
	for(ll i=1;i<=n;i++){
		sum=sum-a[b[i]]+(c[b[i]]-1)*(c[b[i]]-2)/2;
		cout<<sum<<endl;
		sum=sum+a[b[i]]-(c[b[i]]-1)*(c[b[i]]-2)/2;
//		cout<<sum<<
	}
	return 0;
}

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

int n,k;
int d[10];

int judge(int x)
{
    while(x){
        if(d[x%10] != 0) return 0;
        x /= 10;
    }
    return 1;
}

int main()
{
    cin >> n >> k;
    for(int i = 0; i < k; i++){
        int tmp;
        cin >> tmp;
        d[tmp]++;
    }

    int ans = n;
    while(1){
        if(judge(ans)){
            cout << ans << endl;
            return 0;
        }
        ans++;
    }
}

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

int const N= 1e5;
int arr1[N];
int arr2[N];
int main()
{

 int n;
 cin>>n;
for(int i=1;i<n+1;i++)
{
    cin>>arr1[i];
}

for(int i=1;i<n+1;i++)
{
arr2[arr1[i]]=i;
}
for(int i=1;i<n+1;i++)
{cout<<arr2[i]<<" ";}
}


Measured memory_bytes: 1536
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<math.h>
#include<vector> 
using namespace std;
int a[110],b[110],c,ans;
int main()
{int n,d,k;
 cin>>n>>d>>k;
 for(int i=0;i<n;i++)
 cin>>a[i];
 for(int i=0;i<n;i++)
 {if(d%a[i]!=0){
  b[c++]=d/a[i]+1;
  }
  else
 {b[c++]=d/a[i];
 }
 }
 for(int i=0;i<c;i++)
 {ans+=b[i];
 }
 cout<<ans+k<<endl;
 system("pause");
 return 0;
}

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

int main(void)
{
char a[11], b[11], c[11];
cin>>a>>b>>c;

cout<<char(a[0] - 'a' + 'A')<<char(b[0] - 'a' + 'A')<<char(c[0] - 'a' + 'A')<<endl;

return 0;
}

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

#define rep(i,n) for(i = 0;i < n;++i)
#define all(v) v.begin(), v.end()
using ll = long long;

int main()
{
    ll i,j;
    ll l,r,d;
    cin >> l >> r >> d;
    ll ans = r/d - l/d;
    if(l%d == 0) ++ans;
    cout << ans << endl;
    return 0;
}

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


/* エイリアス */
#define ll long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vpi vector<pii>
#define vpll vector<pll>
#define endl '\n'

#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define em emplace
#define mp make_pair


/* 関数マクロ */
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rep2(i, n, m) for (ll i = n; i <= m; ++i)
#define rep3(i, n, m) for (ll i = n; i >= m; --i)
#define all(v) v.begin(), v.end()
#define si(v) int(v.size())
#define UNIQUE(v) sort(all(v)), v.erase(unique(all(v)),v.end())


/* 定数 */
const ll mod = 1e9 + 7;
const ll infll = (1LL << 62) - 1;
const ll inf = (1LL << 30) - 1;


/* その他 */
template<class S, class T> inline bool chmax(S &a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class S, class T> inline bool chmin(S &a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T> using pq = priority_queue<T>;
template<class T> using pqg = priority_queue<T, vector<T>, greater<T>>;


signed main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cout << fixed << setprecision(15);

  int n, m, x; cin >> n >> m >> x;
  vi a(n+1);

  rep(i, m) {
    int b; cin >> b;
    ++a[b];
  }

  int ans = inf;
  int score = 0;
  rep2(i, x, n) score += a[i];
  chmin(ans, score);

  score = 0;
  rep3(i, x, 1) score += a[i];
  chmin(ans, score);
  
  cout << ans << endl;
}


Measured memory_bytes: 3660
#include <stdio.h>
#define INFINITY 1000000
#define MAX 100
#define WHITE 0
#define GRAY 1
#define BLACK 2

int n, M[MAX][MAX];

void dijkstra()
{
  int i, u, v, minv;
  int d[MAX], color[MAX];

  for( i=0; i<n; i++ )
    {
      d[i] = INFINITY;
      color[i] = WHITE;
    }

  d[0] = 0;
  color[0] = GRAY;               
  while(1)
    {
      minv = INFINITY;          
      for( i=0; i<n; i++ )
	{
	  if( minv > d[i] && color[i] != BLACK )   
	    {
	      u = i;
	      minv = d[i];
	    }
	}
      if( minv == INFINITY ) break;
      color[u] = BLACK;
      for( v=0; v<n; v++ )
	{
	  if( color[v] != BLACK && M[u][v] != INFINITY )
	    {
	      if( d[v] > d[u] + M[u][v] )
		{
		  d[v] = d[u] + M[u][v];
		  color[v] = GRAY;
		}
	    }
	}
    }

  for( i=0; i<n; i++ )
    {
      printf("%d %d\n", i, d[i]);
    }
  
}


int main()
{
  int i, j,u, k, v, c;
  
  scanf("%d", &n);

  for( i=0; i<n; i++ )
    {
      for( j=0; j<n; j++ )
	{
	  M[i][j] = INFINITY;
	}
    }
  
  for( i=0; i<n; i++ )
    {
      scanf("%d%d", &u, &k);

      for( j=0; j<k; j++ )
	{
	  scanf("%d%d", &v, &c);
	  M[u][v] = c;
	}
    }

  dijkstra();

  return 0;
}




Measured memory_bytes: 2088
#include<iostream>

using namespace std;

long long int dp[51][51][2501] = {};

int main(void) {
	int n, a;
	int x[51];
	long long int total = 0;

	cin >> n >> a;

	for (int i = 1; i <= n; i++) {
		cin >> x[i];
	}

	dp[0][0][0] = 1;
	

	for (int i = 1; i <= n; i++) {
		for (int j = 0; j <= i; j++) {
			for (int k = 0; k <= 2500; k++) {
				if (j == 0 || k - x[i] < 0) {
					dp[i][j][k] = dp[i - 1][j][k];
				}
				else {
					dp[i][j][k] = dp[i - 1][j - 1][k - x[i]] + dp[i - 1][j][k];
				}
			}
		}
	}

	for (int i = 1; i <= n; i++) {
		total += dp[n][i][i*a];
	}

	cout << total << endl;

	return 0;
}

Measured memory_bytes: 49152
#include <iostream>
    #include <fstream>
    #include <vector>
    #include <map>
    #include <unordered_map>
    #include <string>
    #include <cmath>
    #include <cstdio>
    #include <algorithm>
    #include <functional>
    using namespace std;
    typedef long long  ll;
    const ll INF = 1000000000000000000;
    ll N, A, B, C;
    vector<ll> l;
     
    ll dfs(ll num, ll a, ll b, ll c) {
    	if (num == N) {  
    		if (a == 0 || b == 0 || c == 0) return INF;
    		else return abs(a - A) + abs(b - B) + abs(c - C) - 30;
    	}
    	ll r1 = dfs(num + 1, a, b, c);
    	ll r2 = dfs(num + 1, a + l[num], b, c) + 10;
    	ll r3 = dfs(num + 1, a, b + l[num], c) + 10;
    	ll r4 = dfs(num + 1, a, b, c + l[num]) + 10;
    	return min({ r1, r2, r3, r4 });
    }
     
    int main() {
    	cin >> N >> A >> B >> C;
     
    	for (int i = 0; i < N; ++i) {
    		ll tmp;
    		cin >> tmp;
    		l.push_back(tmp);
    	}
     
    	cout << dfs(0, 0, 0, 0) << endl;
    }

Measured memory_bytes: 256
import java.util.*;

public class Main{
	public static void main(String args[]){
    	Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();

        int[] base_a = new int[N]; // 0 or 1
        int[] remainder_b = new int[N]; // 0 or 1
        for(int i = 0; i < N; i++){
            base_a[i] = scanner.nextInt();
            remainder_b[i] = 0;
        }
      
       /*
       * 最後の箱(Nコ目)の余り計算は、以下の箱のボールの個数に依存しない
       * そのため、最後の箱から余りを考えていくのが良さそう
       */
       for(int i = N-1; i >= 0; i--){
           int total_b = 0;
           
           for(int j = i; j < N; j += i+1){
                total_b += remainder_b[j];
           }
           
           if(base_a[i] == 1 && total_b % 2 == 0){
               remainder_b[i] = 1;
           } else if(base_a[i] == 0 && total_b % 2 == 1){
               remainder_b[i] = 1;
           }
       }
      
       int count_b = 0;
       for(int i = 0; i < N; i++){
           if(remainder_b[i] == 1){
               count_b++;
           }
       }
       System.out.print(count_b);

       System.out.println("");

       for(int i = 0; i < N; i++){
           if(remainder_b[i] == 1){
               System.out.print(i+1 + " ");
           }
       }
    }
}

Measured memory_bytes: 82740
#include <stdio.h>
#include <stdlib.h>

// k < K
// k -> 0 になる確率
double prob(int N, int k, double *DP) {
    if (DP[k] != -1)
        return DP[k];
    if (k == 0)
        return DP[k] = 0;

    if (k > N) {
        if (k % 2 == 1) {
            DP[k] = 0;
        } else {
            DP[k] = prob(N, k / 2, DP) / 2.0;
        }
    } else {
        // そのものズバリが出た後に、裏が出る確率
        DP[k] = 1.0 / 2.0 / (double) N;
        if (k % 2 == 0) {
            // と、合わせて、k/2の値から来る場合を足し合わせる
            DP[k] += prob(N, k / 2, DP) / 2.0;
        }
    }
    //printf("DP[%d]: %lf\n", k, DP[k]);
    return DP[k];
}

int main () {
    // N面サイコロ
    // コイン
    int N;
    int K;

    scanf("%d", &N);
    scanf("%d", &K);

    double *DP = calloc(1 + K, sizeof(double));
    for (int i = 0; i < K; i++) {
        DP[i] = -1;
    }

    double ans = 0;
    for (int i = 1; i < K; i++){
        ans += prob(N, i, DP);
    }
    printf("%.10lf\n", (1.0 - ans));

    return 0;
}


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

int main(void) {
	int R;
	cin >> R;
	
	if (R < 1200) {
		cout << "ABC";
	}
	else {
		if (R < 2800) {
			cout << "ARC";
		}
		else {
			cout << "AGC";
		}
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define x_ real()
#define y_ imag()
#define cross(a, b) (conj(a)*(b)).imag()
#define dot(a, b) (conj(a)*(b)).real()
#define PI acos(-1)
#define F first
#define S second
#define fastIO ios_base::sync_with_stdio(false), cin.tie(NULL)
#define fileIO freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout)
#define ordered_set tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update>
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef complex<ld> point;
typedef tuple<int, int, int> line;
typedef vector<point> polygon;
typedef pair<double, double> pd;
pair<int, int> dirs[] = { {1, 2}, {-1, 2}, {2, 1}, {2, -1}, {-2, 1}, {-2, -1}, {1, -2}, {-1, -2} };



int main() {
	fastIO;
	int h, w, n, x;
	cin >> h >> w >> n;
	vector<int> v;
	for (int i = 0; i < n; i++) {
		cin >> x;
		v.push_back(x);
	}

	int grid[h][w];

	int curr = 0;
	for (int i = 0; i < h; i++) {
		if (i&1) {
			for (int j = w-1; j >= 0; j--) {
				grid[i][j] = curr+1;
				v[curr]--;
				if (v[curr] == 0)
					curr++;
			}
		}
		else {
			for (int j = 0; j < w; j++) {
				grid[i][j] = curr+1;
				v[curr]--;
				if (v[curr] == 0)
					curr++;
			}
		}
	}

	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++)
			cout << grid[i][j] << " ";
		cout << endl;
	}






}


Measured memory_bytes: 512
#include <cstdio>

int main(){
	int n;
	bool ok = false;
	while(scanf("%d",&n),n){
		if(ok) printf("\n");
		if(!ok) ok = true;
		n /= 10;
		int a[4];
		int ans = 100;
		int out[4];
		int num[4] = {10,50,100,500};
		for(int i = 0; i < 4; i++) scanf("%d", &a[i]);
		for(int i = 0; i <= a[0]; i++){
			for(int j = 0; j <= a[1]; j++){
				for(int k = 0; k <= a[2]; k++){
					for(int l = 0; l <= a[3]; l++){
						int m = i+j*5+k*10+l*50-n;
						if(m < 0) continue;
						int cnt = 0;
						//cout << m << endl;
						if(l > 0 && m/50 > 0) continue;
						cnt += (m/50);
						m %= 50;
						if(k > 0 && m/10 > 0) continue;
						cnt += (m/10);
						m %= 10;
						if(j > 0 && m/5 > 0) continue;
						cnt += (m/5);
						m %= 5;
						if(i > 0 && m > 0) continue;
						cnt += m;
						int tmp = a[0]+a[1]+a[2]+a[3]-i-j-k-l+cnt;
						//cout << tmp  << " " << cnt << " " << i << " " << j << " " << k << " " << l << endl;
						if(ans > tmp){
							ans = tmp;
							out[0] = i;
							out[1] = j;
							out[2] = k;
							out[3] = l;
						}
					}
				}
			}
		}
		for(int i = 0; i < 4; i++){
			if(out[i] == 0) continue;
			printf("%d %d\n", num[i],out[i]);
		}
	}
}

Measured memory_bytes: 1032
def d_factorization(N, M):
    if M == 1:
        return 1

    def prime_factorization_power_list(n):
        i = 2
        table = {}
        while i**2 <= n:
            table[i] = 0
            while n % i == 0:
                table[i] += 1
                n //= i
            if table[i] == 0:
                table.pop(i)
            i += 1
        if n > 1:
            table[n] = 1
        return table

    MOD = 10**9 + 7
    prime_m = prime_factorization_power_list(M)
    b_max = max(prime_m.values())  # 素因数分解の指数の最大値
    # フェルマーの小定理による組合せの計算
    factorial = [1] * (b_max + N)  # (b_i + N - 1)!を計算するため。0!も入れておく
    for k in range(1, b_max + N - 1):
        factorial[k + 1] = (factorial[k] * (k + 1)) % MOD
    # k!のmod 10**9+7における逆元を計算
    fact_inv = [1] * (b_max + N)
    fact_inv[b_max + N - 1] = pow(factorial[b_max + N - 1], MOD - 2, MOD)
    for k in range(b_max + N - 1, 0, -1):
        fact_inv[k - 1] = (fact_inv[k] * k) % MOD

    def nCr(n, r, M):
        if n < 0 or r < 0 or n < r:
            return 0
        else:
            return (factorial[n] * fact_inv[r] * fact_inv[n - r]) % M

    ans = 1
    for b in prime_m.values():
        ans = (ans * nCr(b + N - 1, b, MOD)) % MOD

    return ans

N, M = [int(i) for i in input().split()]
print(d_factorization(N, M))

Measured memory_bytes: 10868
//O(nlogn+mlogm)解
#include <iostream>
#include <algorithm>

using namespace std;

const int INF = 100000;

int main(){
	int n,m;//太郎、花子のそれぞれのカードの枚数
	while(true){
		cin >> n >> m;
		if(n==0 && m==0){
			break;
		}
		int *card1 = new int[n];//太郎
		int *card2 = new int[m];//花子のカード
		int sum1=0;//交換する前のcard1の和
		int sum2=0;//            card2の和
		for(int i=0;i<n;i++){
			cin >> card1[i];
			sum1 += card1[i];
		}
		for(int i=0;i<m;i++){
			cin >> card2[i];
			sum2 += card2[i];
		}

		if((sum1-sum2) %2 == 1 || (sum1-sum2) %2 == -1){//下コメ参照、(1-2)%2は-1になるので注意
			cout << -1 << endl;
		}else{
			sort(card1,card1+n);//昇順 O(nlogn)
			sort(card2,card2+m);
			//交換して組み合わせが等しい場合に代入。組み合わせがない場合はずっとINF
			int change1 = INF;
			int change2 = INF;
			int idx1 = 0;
			int idx2 = 0;
			int dst = (sum1-sum2)/2;//e1-e2の目標の値(下コメ参照)
			bool check = false;//満たすe1とe2の組み合わせが見つかったかどうか
			while(idx1 != n && idx2 != m){//O(n+m)
				if(card1[idx1] - card2[idx2] > dst){
					idx2++;//card2[idx2]を増やす
				}else if(card1[idx1] - card2[idx2] < dst){
					idx1++;//card1[idx1]を増やす
				}else if(card1[idx1] - card2[idx2] == dst){
					//交換して和が等しい
					change1 = card1[idx1];
					change2 = card2[idx2];
					check = true;
					break;//これより先のものを調べても、idxを足していくので、交換するカードが大きくなってしまう。
				}
			}


			if(check == false){//見つからなかった
				cout << -1 << endl;
			}else{
				cout << change1 << ' ' << change2 << endl;
			}
		}//else終わり

		delete[] card1;
		delete[] card2;
	}//while終わり
	return 0;
}
/*
太郎が渡すカードe1
花子が渡すカードe2
交換して和が等しいとき
sum1-e1+e2 = sum2-e2+e1
⇔sum1 - sum2 = 2*(e1 - e2)
⇔(sum1 - sum2)/2 = e1 - e2
を満たすe1、e2を探せばよい。カードの値は整数なので、sum1-sum2が奇数のとき解なし
sum1-sum2の値はO(n+m)で求まる
e1-e2の値を全探索するときO(nm)
*/

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

#define F               first
#define S               second
#define ull             unsigned long long
#define ll              long long
#define db              long double
#define ST              string
#define pb              push_back
#define mp              make_pair
#define el              "\n"
#define vll             vector <ll>
#define vi              vector <int>
#define pii             pair <int, int>
#define pll             pair <ll, ll>
#define vec(v)          vector <v>
#define all(v)          (v.begin(), v.end())
#define rall(v)         (v.rbegin(), v.rend())
#define is_sort(v)      is_sorted all(v)
#define max_of(v)       *max_element all(v)
#define min_of(v)       *min_element all(v)
#define itos(s)         to_string(s)
#define cntone(x)       __builtin_popcountll(x)
#define cntzro(x)       __builtin_clz(x)
#define clr(x,y)        memset(x, y, sizeof(x))
#define For(i, a, b)    for(int i=a; i<b; i++)
#define Forr(i, a, b)   for(int i=a; i>=b; i--)
const ll mod = 1e9 + 7;

void solve()
{

}

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


    /***************-Code starts from here-***************/
    int n;
    cin >> n;
    int count = 0;
    for (int i = 1; i < n; i++)
    {

        for (int j = 1; j <= n - i; j++)
        {
            if (i * j >= n)
                break;
            if (n - i * j >= 1)
            {
                count++;
            }
        }
    }
    cout << count;
    return 0;
}

Measured memory_bytes: 3648
#include <iostream>
#include <math.h>
#include <numeric>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <queue>
#include <queue>
#include <stack> 
#include <sstream>
#include <set>
typedef  long long ll;
const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};
const int dr[4] = {-1, 0, 1, 0};
const int dc[4] = { 0, 1, 0,-1};
const int INF = 1e9;
#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define SORT(a) sort(a.begin(),a.end())
#define REVERSE(a) reverse(a.begin(),a.end())
using namespace std;
//start
const int limit = 2e5 + 1;
int k;
vector<int> g[limit];
bool vis[limit];

void dfs(int s,int k){
    if(k >= 2) return;

    for(auto it :g[s]){
        if(!vis[it]){
            vis[it] = true;
            dfs(it,k+1);
        }
    }
}


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

    REP(i,m){
        int x,y;
        cin >> x >> y;
        g[x].push_back(y);
        g[y].push_back(x);
    }
    vis[1] = true;
    dfs(1,0);
    if(vis[n]) cout << "POSSIBLE" <<endl;
    else cout << "IMPOSSIBLE" <<endl;
}


Measured memory_bytes: 12144
import java.io.*;
import java.util.Scanner;

public class Main{
    public static void main(String []args) throws IOException
    {
        Scanner sc = new Scanner(System.in);
        String str = sc.next();
        for(int i=0;i<str.length();i++)
        {
            if(str.charAt(i)=='1')
                System.out.print('9');
            else if(str.charAt(i)=='9')
                System.out.print('1');
            else
                System.out.print(str.charAt(i));

        }
        System.out.println();

    }
}

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

using namespace std;
int main()
{
	double n,a[110], sum = 0,ans;
	cin >> n;
	for(int i=0; i<n; i++){
		cin >> a[i];
		sum += a[i];
	}
	double ave = sum / n, tmp = 200;
	for(int i=0; i<n; i++){
		if(abs(ave - a[i]) < tmp ){
			tmp = abs(ave - a[i]);
			ans = i;
		}
	}
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int r,d,x,xx,i;
	scanf("%d%d%d",&r,&d,&x);
	for(i=1;i<=10;i++)
	{
		xx=r*x-d;
		printf("%d\n",xx);
		x=xx;
	} 
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <numeric> // accumulate(v.begin(), v.end(), 0)

using namespace std;
#define ll long long

int main(){
  string S, T;
  cin >> S >> T;
  bool ret = false;
  int n = S.size();
  for(int i=0; i<n; i++){
    if(S == T){
      ret = true;
      break;
    } else {
      S = S[n-1] + S.substr(0,n-1);
    }
  }
  if(ret)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}


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

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int N[11]={};
  rep(i,3){
    int X; cin>>X;
    N[X]++;
  }
  rep(i,10){
    if(N[i]==2){
      cout<<"Yes\n";
      return 0;
    }
  }
  cout<<"No\n";
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <bits/extc++.h>
using namespace std;
#define _rep(n, a, b) for (ll n = (a); n <= (b); ++n)
#define _rev(n, a, b) for (ll n = (a); n >= (b); --n)
#define _for(n, a, b) for (ll n = (a); n < (b); ++n)
#define _rof(n, a, b) for (ll n = (a); n > (b); --n)
#define oo 0x3f3f3f3f3f3fll
#define ll long long
#define db double
#define eps 1e-8
#define bin(x) cout << bitset<10>(x) << endl;
#define what_is(x) cerr << #x << " is " << x << endl
#define met(a, b) memset(a, b, sizeof(a))
#define all(x) x.begin(), x.end()
#define pii pair<ll, ll>
#define pdd pair<db, db>
#define pi acos(-1.0)
#define lowbit(x) x &(-x)
const ll maxn = 1e5 + 10;
const ll mod = 1e9;

signed main()
{
	ll n, a, b;
	cin >> n >> a >> b;
	ll res = n/(a+b) * a + min(n%(a+b), a);
	cout << res << endl;
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))
for i in range(N):
 v = A[i]
 j = i - 1
 while j >= 0 and A[j] > v:
  A[j+1] = A[j]
  j -= 1
 A[j+1] = v
 print(" ".join(map(str, A)))

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

using namespace std;
typedef long long ll;
typedef string str;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector <pii> vpii;
typedef vector <pll> vpll;
typedef map <str,int> mapsi;
typedef map <str,int> :: iterator mapsitr;
typedef map <int , int> mint;
typedef map <ll , ll> mll;
typedef set <int> si;
typedef set <ll> sll;
typedef si :: iterator sitr;
typedef si :: reverse_iterator rsitr;
typedef sll :: iterator sltr;
typedef sll :: reverse_iterator rsltr;
#define mset multiset

typedef mset <int> msi;
typedef mset <ll> msll;
typedef msi :: iterator msitr;
typedef msi :: reverse_iterator msritr;
typedef msll :: iterator msltr;
typedef msll :: reverse_iterator mslritr;

#define mp make_pair
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define fi first
#define se second
#define fs first.second
#define ss second.second
#define ff first.first
#define sf second.first
#define newl '\n'

char to_upper (char x){
    if( 97 <= int(x) && int(x) <= 126)return char(x-32);
    else if( 65 <= int(x) && int(x) <= 90)return x;
}
char to_lower (char x){
    if( 97 <= int(x) && int(x) <= 126)return x;
    else if( 65 <= int(x) && int(x) <= 90)return char(x+32);
}
int numerize (char x){
    if(48 <= int(x) && int(x) <= 57)return int(x-'0');
    else if( 97 <= int(x) && int(x) <= 126)return int(x-96);
    else if( 65 <= int(x) && int(x) <= 90)return int(x-64);
}
bool isect (int l1, int r1, int l2, int r2){
    pii p1,p2;
    p1 = mp(l1,r1); p2 = mp(l2,r2);
    if(p1>p2)swap(p1,p2);
    if(p2.fi <= p1.se)return true;
    else return false;
}
ll fexp (ll num1, ll num2, ll MOD){
    if(num2==0)return 1;
    else if(num2==1)return num1;
    else{
        ll temp = fexp (num1,num2/2,MOD); ll res = ((temp%MOD) * (temp%MOD))%MOD;
        if(num2%2==1) res = ((res%MOD)*(num1%MOD))%MOD; return res;
    }
}
ll invmod (ll num, ll MOD){return fexp (num,MOD-2,MOD);}
ll gcd (ll num1, ll num2){
    if(num1 < num2) swap(num1,num2); ll num3 = num1 % num2 ;
    while(num3 > 0){ num1 = num2; num2 = num3; num3 = num1 % num2;}
    return num2;
}
ll lcm (ll num1 , ll num2){return (ll) (num1/gcd(num1,num2))*num2;}


// end of Template
int a;
str s;
int main(){

//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>a;
    cin>>s;
    if(a<3200)cout<<"red\n";
    else cout<<s<<newl;
}


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

int m;
long long sum=0,ans=0;
int main(){
    scanf("%d",&m);
    while (m--){
        int u;
        long long v;
        scanf("%d%lld",&u,&v);
        sum+=u*v, ans+=v;
    }
    printf("%lld\n",(sum-1)/9+ans-1);
    return 0;
}

Measured memory_bytes: 256
#include<iostream>

int main()
{
    int H,W;
    
    while(1){    
        
        std::cin>>H>>W;
        
        if(H==0 && W==0){
            break;
        }else{
            for (int i=1; i<=H;i++){
                for (int j=1; j<=W;j++){
                    if(i==1 || i==H){
                        std::cout<<'#';
                    }else{
                        if(j==1 || j==W){
                            std::cout<<'#';
                        }else{
                            std::cout<<'.';
                        }
                    }
                }
            std::cout<<std::endl;
            }
        }
        std::cout<<std::endl;
    }
    return 0;
}


Measured memory_bytes: 3088
#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 n,k;
    cin>>n>>k;
    if(n%k==0) cout<<0<<endl;
    else cout<<1<<endl;
}

Measured memory_bytes: 256
n = int(input())
if n == 1:
    print(1)
    exit()

ans = [0] * 2
for i in range(1, n + 1):
    num = i
    cnt = 0
    while num % 2 == 0:
        num //= 2
        cnt += 1

    if cnt > ans[1]:
        ans[0] = i
        ans[1] = cnt

print(ans[0])


Measured memory_bytes: 3060
import sys

sys.setrecursionlimit(10 ** 6)
INF = float("inf")
MOD = 10 ** 9 + 7


def input():
    return sys.stdin.readline().strip()


def main():
    N, C = map(int, input().split())
    X = []
    V = []
    for _ in range(N):
        x, v = map(int, input().split())
        X.append(x)
        V.append(v)

    # [0, i]までで得られるカロリーの最大値
    dp_right = [0] * N
    dp_right[0] = -X[0] + V[0]
    for i in range(1, N):
        dp_right[i] = dp_right[i - 1] + V[i] - (X[i] - X[i - 1])

    # [i, n - 1] までで得られるカロリーの最大値
    dp_left = [0] * N
    dp_left[N - 1] = V[N - 1] - (C - X[N - 1])
    for i in range(N - 2, -1, -1):
        dp_left[i] = dp_left[i + 1] + V[i] - (X[i + 1] - X[i])

    # 最大値に書き換える
    for i in range(1, N):
        if dp_right[i] >= dp_right[i - 1]:
            continue
        else:
            dp_right[i] = dp_right[i - 1]

    for i in range(N - 2, -1, -1):
        if dp_left[i] >= dp_left[i + 1]:
            continue
        else:
            dp_left[i] = dp_left[i + 1]

    # 折り返さない
    ans = max(0, dp_left[0], dp_right[-1])
    # 時計周りに進んで，i個目の寿司で半時計周りに折り返す
    for i in range(N - 1):
        tmp = dp_right[i] + dp_left[i + 1] - X[i]
        if tmp > ans:
            ans = tmp

    # 最初に半時計周りに進む
    for i in range(N - 1, 0, -1):
        tmp = dp_left[i] + dp_right[i - 1] - (C - X[i])
        if tmp > ans:
            ans = tmp

    print(ans)


if __name__ == "__main__":
    main()


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

int main() {
  int a, b;
  cin >> a >> b;
  
  if ( a % 2 == 1 && b % 2 == 1 ) {
  cout << "Odd" << endl;
  }
  else {
    cout << "Even" << endl;
  }
}

Measured memory_bytes: 256
a=int(input())
b=int(input())
c=int(input())
x=int(input())

cnt = 0
for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            if 500*i+100*j+50*k==x:
                cnt+=1
print(cnt)

Measured memory_bytes: 40048
#include <iostream>
#include <stack>

int main ()
{
    std::stack<u_int> st;
    int number;

    while(std::cin >> number){
        if(number != 0)
            st.push(number);
        else{
            std::cout << st.top() << std::endl;
            st.pop();
        }
    }
    
    return 0;
}

Measured memory_bytes: 1196
#include <iostream> // cout, endl, cin
#include <cmath> //sqrt pow
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
 
#define rep(i,n) for(int i = 0; i < n; i++)
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define mod 1000000007
using ll = long long;
using namespace std;
int main(){
  int n;
  cin >> n;
  vi d(n);
  rep(i, n) cin >> d[i];
  sort(d.begin(), d.end());
  int a = d[n / 2 - 1], b = d[n / 2];
  cout << b - a << endl;
}

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

# define REP(i,n) for (int i=0;i<(n);++i)
# define rep(i,a,b) for(int i=a;i<(b);++i)
# define p(s) std::cout << s ;
# define pl(s)  std::cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
# define yes(j) std::cout << (j ? "yes" : "no") << endl;
# define all(v) v.begin(),v.end()
# define showVector(v) REP(i,v.size()){p(v[i]);p(" ")} pl("")
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;}
typedef pair<int,int> P_ii;
typedef pair<double,double> P_dd;
typedef long long int ll;

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...));
}

const int MOD = 1000000007;
const ll INF = (ll)1e12;

void addM(long long &a, long long b) {
    a += b;
    if (a >= MOD) a -= MOD;
}

void mulM(long long &a, long long b) {
    a = ((a%MOD)*(b%MOD))%MOD ;
}

bool compare_by_second(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}

int main() {
    int N;
    long long K;
    cin >> N >> K;
    vector<long long> A(N);
    for (int i = 0; i < N; ++i) cin >> A[i];
        
    long long res = 0;
    for (int d = 60; d >= -1; --d) {
        if (d != -1 && !(K & (1LL<<d))) continue;
        
        long long tmp = 0;
        for (int e = 60; e >= 0; --e) {
            long long mask = 1LL<<e;
            int num = 0;
            for (int i = 0; i < N; ++i) if (A[i] & mask) ++num;
            
            if (e > d) {
                if (K & mask) tmp += mask * (N - num);
                else tmp += mask * num;
            }
            else if (e == d) {
                tmp += mask * num;
            }
            else {
                tmp += mask * max(num, N - num);
            }
        }
        res = max(res, tmp);
    }
    cout << res << endl;
}

Measured memory_bytes: 1024
(* O(n * log(k)) *)
Scanf.scanf "%d %d" @@ fun n k ->
  let rec find acc x =
    if x >= k then acc
    else find (acc *. 0.5) (x * 2) in
  let sum = ref 0. in
  for i = 1 to n do
    let p = find 1. i in
    sum := !sum +. p /. float n
  done;
  Printf.printf "%.12f\n" !sum

Measured memory_bytes: 1920
// Math = ♥️

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

#define ll long long
#define ld long double
typedef pair<ll, ll> ii;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<vii> vvii;
#define pq priority_queue
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(), (c).end()
#define sz(c) ((ll)c.size())
#define ordered_set                            \
    tree<ll, null_type, less<ll>, rb_tree_tag, \
         tree_order_statistics_node_update>

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

    ll n;
    cin >> n;

    vi arr(3 * n);
    for (auto &it : arr) {
        cin >> it;
    }

    pq<ll, vi, greater<ll>> q;
    ll sum = 0;
    for (int i = 0; i < n; i++) {
        q.push(arr[i]);
        sum += arr[i];
    }

    ll pre[n + 1];
    pre[0] = sum;
    for (int i = 0; i < n; i++) {
        if (arr[n + i] > q.top()) {
            sum += (arr[n + i] - q.top());
            q.pop();
            q.push(arr[n + i]);
        }
        pre[i + 1] = sum;
    }

    sum = 0;

    pq<ll> q2;
    ll post[n + 1];
    for (int i = 3 * n - 1; i >= 2 * n; i--) {
        sum += arr[i];
        q2.push(arr[i]);
    }

    post[n] = sum;
    for (int i = 0; i < n; i++) {
        if (arr[(2 * n - 1) - i] < q2.top()) {
            sum += arr[(2 * n - 1) - i] - q2.top();
            q2.pop();
            q2.push(arr[(2 * n - 1) - i]);
        }
        post[n - i - 1] = sum;
    }

    ll ans = LLONG_MIN;
    for (int i = 0; i <= n; i++) {
        ans = max(ans, pre[i] - post[i]);
    }

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


Measured memory_bytes: 5876
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a; i<=b; i++)
#define per(i,b,a) for(int i=b; i>=a; i--)
#define pb push_back
using namespace std;
typedef pair<int, int> pi ;
typedef vector<pair<int,int> > vpi ;
typedef vector<int> vi ;
typedef long long ll ;
const ll mod = 998244353 ;
ll powmod(ll a, ll b) { ll res = 1 ; while(b) { if(b&1) res = (res*a)%mod ;  a = (a*a)%mod ; b >>= 1 ; }  return res ; }
const int maxn = 2e5+5 ;
const int inf = 1e9+5 ;
int n ;
ll a[maxn] ;
ll pow2[32] ;
map<int, int> ds ;
int main()
{
    ios::sync_with_stdio(false) ;
    cin.tie(NULL) ;
    pow2[0] = 1 ;
    rep(i,1,31) pow2[i] = pow2[i-1]*2 ;
    cin >> n ;
    rep(i,0,n-1)
    cin >> a[i] ;
    sort(a,a+n) ;
    ds.clear() ;
    rep(i,0,n-1)
    ds[a[i]]++ ;
    ll ret = 0 ;
    per(i,n-1,0)
    {
        rep(j,0,31)
        {
            ll val = pow2[j] - a[i] ;
            if(val < 0) continue ;
            bool chk = binary_search(a,a+n,val) ;
            if(chk)
            {
                if(val == a[i] && ds[val] <= 1) continue ;
                if(ds[val] >= 1 && ds[a[i]] > 0 )
                {
                    ret++ ;
                    ds[a[i]]-- ;
                    ds[val]-- ;
                    break ;
                }
            }
        }
    }
    cout << ret << "\n" ;
    return 0 ;
}




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

using namespace std;
using ll = long long;
using ld = long double;
using ii = pair<ll, ll>;
using vi = vector<ll>;
using vb = vector<bool>;
using vvi = vector<vi>;
using vii = vector<ii>;
using vvii = vector<vii>;

constexpr int INF = 2000000000;
constexpr ll LLINF = 9000000000000000000;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	
	int N;
	cin >> N;
	vi A(N, 0LL);
	for (ll &v : A) cin >> v;
	ll sum = accumulate(A.begin(), A.end(), 0LL);
	partial_sum(A.begin(), A.end(), A.begin());
	A.pop_back();
	ll best = LLINF;
	for (ll v : A) best = min(best, abs(v - (sum - v)));
	cout << best << endl;
	
	return 0;
}


Measured memory_bytes: 1792
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
#include<math.h>
#include<bitset>
#include<queue>
#include<set>
#include<iomanip>
#include<math.h>
#include<assert.h>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long INF = 1LL << 40;
const double INFD = 1e100;
const ll mod = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
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;
}
// ----------------------------------------------------------------------------

int main(){
  int N,k;
  cin >> N >> k;
  vector<vector<int>> G(N);
  for(int i=0; i<N; i++){
    int t,d;
    cin >> t >> d;
    t--;
    G[t].push_back(d);
  }
  vector<int> y0,y1;
  for(int i=0; i<N; i++){
    if(G[i].size() == 0) continue;
    sort(G[i].begin(),G[i].end(),greater<ll>());
    for(int j=0; j<G[i].size(); j++){
      if(j){
        y0.push_back(G[i][j]);
      }else{
        y1.push_back(G[i][j]);
      }
    }
  }
  sort(y0.begin(),y0.end(),greater<ll>());
  sort(y1.begin(),y1.end(),greater<ll>());
  ll ans=0;
  int Y = max(0,k-int(y0.size()));
  ll X=0;
  for(int i=0; i<Y; i++){
    X += y1[i];
  }
  for(int i=0; i<k-Y; i++){
    X += y0[i];
  }
  while(1){
    ans = max(ans,X+(ll)Y*Y);
    if(Y >= k || Y >= y1.size()) break;
    X += y1[Y];
    X -= y0[k-Y-1];
    Y++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 6396
#include <iostream>
#include <string>
using namespace std;
int main()
{long int a,b,sum=0,c;
    cin >> a >> b;
    for(int i=0;i<b;i++)
    {   cin >> c;
        sum+=c;
    }
if(a>=sum)
cout << (a-sum);
else
cout << "-1";
return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
using namespace std;
const int mod=1e9+7;
const int nax=1e7;
const ll inf=1e10+17;
vector<int> prime(nax,-1);
ll pow1(ll a,ll b)
{
    ll res=1;
    while(b>0)
    {
        if(b%2) res=(res*a)%mod;
        a=(a*a)%mod;
        b/=2;
    }
    return res;

}
ll mul(ll a,ll b)
{
    return (a*1LL*b)%mod;
}
int main()
{
    int t;
    char ch;
    cin>>ch;
    if(isupper(ch))
    cout<<'A';
    else cout<<'a';
}

Measured memory_bytes: 42180
#include <vector>
#include <sstream>
#include <algorithm>
#include <fstream>
#include <list>
#include <map>
#include <istream>
#include <bitset>
#include <sstream>
#include <unordered_map>
#include <stack>
#include <set>
#include <cmath>
#include <random>
#include <iostream>
#include <bitset>
#include <iomanip>
#include <queue>
#include <string>

#define int long long
#define endl "\n"
#define all(x) x.begin(),x.end()
#define rr return 0
#define xx first
#define yy second
#define pii pair<int,int>

using namespace std;

typedef long long ll;
typedef long double ld;

signed main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int a, b;
    cin >> a >> b;
    int p = max(a + b, a- b);
    cout << max(p, a * b);
    rr;
}


Measured memory_bytes: 256
class RollingHash:
    def __init__(self, s: str, base: int=1007, mod: int=10**9+7):
        self.s = s
        self.n = len(s)
        self.base = base
        self.mod = mod

        # preprocess
        self.hash_cum = [0] * (self.n + 1) # hash_cum[i] = (hash of s[:i])
        self.base_pow = [1] * (self.n + 1) # base_pow[i] = base ** i
        for i in range(self.n):
            self.hash_cum[i+1] = (self.hash_cum[i] * base + ord(s[i])) % mod
            self.base_pow[i+1] = (self.base_pow[i] * base) % mod

    def get_hash(self, l: int, r: int) -> int:
        hash_val = self.hash_cum[r] - self.hash_cum[l] * self.base_pow[r-l] % self.mod
        if hash_val < 0:
            hash_val += self.mod
        return hash_val


class RollingHashMulti:
    def __init__(self, s: str, base_list: list=[1007, 2009], mod_list: list=[10**9+7, 10**9+9]):
        self.n = len(base_list)
        self.base_list = base_list
        self.rh_list = [RollingHash(s, base_list[i], mod_list[i]) for i in range(self.n)]

    def get_hash(self, l: int, r: int) -> tuple:
        return tuple( self.rh_list[i].get_hash(l, r) for i in range(self.n) )




n = int(input())
s = input()

rh = RollingHashMulti(s)

def check(x):
    hash_dict = dict()
    for i in range(n-x+1):
        hash_val = rh.get_hash(i, i+x)
        if hash_val in hash_dict:
            if i - hash_dict[hash_val] >= x:
                return True
        else:
            hash_dict[hash_val] = i
    return False


lb = 0
ub = n // 2 + 1
while ub - lb > 1:
    mid = (ub + lb) // 2
    if check(mid):
        lb = mid
    else:
        ub = mid

print(lb)


Measured memory_bytes: 47580
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
int N,M;
int C[20];
int X[20004];
const long long INF = 1000000000000;
long long dp[20004][260];
long long dfs(int i_,int y_) {
    if(i_ == N) return dp[i_][y_] = 0;
    if(dp[i_][y_]!=INF) return dp[i_][y_];

    long long ret = INF;

    rep(i,M) {
        int y = y_ + C[i];
        y = max(y,0);
        y = min(y,255);
        //cout<<y<<","<<X[i_]<<endl;
        ret = min(ret,dfs(i_+1,y)+(X[i_]-y)*(X[i_]-y));

    }
    //cout<<i_<<","<<y_<<","<<ret<<endl;
    return dp[i_][y_] = ret;

}
void solve() {
    rep(i,20004) rep(j,260) dp[i][j] = INF;
    rep(i,M) cin>>C[i];
    rep(i,N) cin>>X[i];
    long long ans = INF;
    ans = min(ans,dfs(0,128));
    cout<<ans<<endl;
    rep(i,M) C[i] = 0;
    rep(i,N) X[i] = 0;

}
int main() {
    while(cin>>N>>M) {
        if(N+M==0) return 0;
        solve();
    }

    return 0;
}

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

using namespace std;

template< typename Semigroup >
struct Node {
  Node *l, *r, *p;
  int idx;
  Semigroup key, sum;
  bool rev;
  int sz;

  Node() = default;

  Node(int idx, const Semigroup &v) {
    init_node(idx, v);
  }

  void init_node(int idx, const Semigroup &v) {
    this->idx = idx;
    this->key = this->sum = v;
    this->l = this->r = this->p = nullptr;
    rev = false;
    sz = 1;
  }

  void push() {
    if(rev) {
      swap(l, r);
      if(l) l->rev ^= true;
      if(r) r->rev ^= true;
    }
  }

  bool is_root() {
    return !p || (p->l != this && p->r != this);
  }

  void update() {
    sz = 1;
    sum = key;
    if(l) sz += l->sz, sum = l->sum + sum;
    if(r) sz += r->sz, sum = sum + r->sum;
  }

  void rotr() { // 右回転
    auto *x = p, *y = x->p;
    if((x->l = r)) r->p = x;
    r = x, x->p = this;
    x->update(), update();
    if((p = y)) {
      if(y->l == x) y->l = this;
      if(y->r == x) y->r = this;
      y->update();
    }
  }

  void rotl() { // 左回転
    auto *x = p, *y = x->p;
    if((x->r = l)) l->p = x;
    l = x, x->p = this;
    x->update(), update();
    if((p = y)) {
      if(y->l == x) y->l = this;
      if(y->r == x) y->r = this;
      y->update();
    }
  }

  void splay() {
    push();
    while(!is_root()) {
      auto *q = p;
      if(q->is_root()) {
        q->push(), push();
        if(q->l == this) rotr();
        else rotl();
      } else {
        auto *r = q->p;
        r->push(), q->push(), push();
        if(r->l == q) {
          if(q->l == this) q->rotr(), rotr();
          else rotl(), rotr();
        } else {
          if(q->r == this) q->rotl(), rotl();
          else rotr(), rotl();
        }
      }
    }
  }

  Node *expose() {
    Node *rp = nullptr;
    for(Node *cur = this; cur; cur = cur->p) {
      cur->splay();
      cur->r = rp;
      cur->update();
      rp = cur;
    }
    splay();
    return rp;
  }

  void link(Node *parent) {
    expose();
    parent->expose();
    p = parent;
    parent->r = this;
  }

  void cut() {
    expose();
    auto *parent = l;
    l = nullptr;
    parent->p = nullptr;
  }

  void evert() {
    expose();
    rev ^= true;
    push();
  }

  Node *lca(Node *t) {
    t->expose();
    return expose();
  }
};


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

  Node< int > uku[100000];
  for(int i = 0; i < N; i++) {
    uku[i].init_node(i, 0);
  }

  for(int i = 0; i < N; i++) {
    int K;
    scanf("%d", &K);
    while(K--) {
      int T;
      scanf("%d", &T);
      uku[T].link(&uku[i]);
    }
  }
  int Q;
  scanf("%d", &Q);
  while(Q--) {
    int U, V;
    scanf("%d %d", &U, &V);
    printf("%d\n", uku[V].lca(&uku[U])->idx);
  }
}


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

namespace ABC116_C
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var num = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            var ans = 0;
            ans += num[0];
            for (var i = 1; i < n; i++)
            {
                if(num[i] > num[i-1])
                {
                    ans += num[i] - num[i - 1];
                }
            }
            Console.WriteLine(ans);
        }
    }
}


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

int main() {
  ll n;cin>>n;
  ll sm = n*(n+1)/2;
  ll n3 = n/3, n5 = n/5, n15 = n/15;
  sm -= n3*(n3+1)*3/2;
  sm -= n5*(n5+1)*5/2;
  sm += n15*(n15+1)*15/2;
  cout << sm;
}


Measured memory_bytes: 3584
#! /Library/Frameworks/Python.framework/Versions/3.7/bin/python3
N = int(input())
a = list(map(int, input().split()))
b = [0] * 100001  # 0から100000まで b[0]:0,b[1]:1…
c = [0] * 99999
for i in range(N):
    b[a[i]] += 1
for i in range(99999):  # 0から99998まで
    c[i] = b[i] + b[i + 1] + b[i + 2]
print(str(max(c)))

Measured memory_bytes: 13964
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 1e18
#define pb push_back
#define ld long double
#define mod 1000000007
#define mk make_pair
#define ull unsigned long long
#define fastIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
int main()
{
    ll n;
    cin>>n;
    string str,ans;
    cin>>str;
    ll i,j;
    char ch;
    i=0;
    while(i<n)
    {   
        ch=str[i];
        j=i;
        while(str[j]==ch)
        {
            j++;
        }
        ans+=ch;
        i=j;
    }
   // cout<<ans<<'\n';
    cout<<ans.size()<<'\n';
    return 0;
}

Measured memory_bytes: 512
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>

using namespace std;

typedef pair<long long int, long long int> P;

long long int INF = 1e18;
long long int MOD = 1e9 + 7;

int main(){
	
	int A, B;
	cin >> A >> B;
	
	if(B % A == 0){
		cout << A + B << endl;
	}else{
		cout << B - A << endl;
	}
	
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
	int N;
	cin >> N;
	int sum = 0, mx = 0;
	for (int i = 0; i < N; ++i) {
		int L;
		cin >> L;
		sum += L;
		mx = max(mx, L);
	}
	cout << (sum > mx * 2 ? "Yes" : "No") << endl;
	return 0;
}

Measured memory_bytes: 256