akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

int main() {
    int arr[3][3];
    for(int i=0; i<3; i++){
        for(int j=0; j<3; j++){
            cin >> arr[i][j];
        }
    }
    int n;
    cin >> n;
    int brr[n]={0};
    for(int i=0; i<n; i++)
        cin >> brr[i];
    for(int i=0; i<3; i++){
        for(int j=0; j<3; j++){
            for(int k=0; k<n; k++){
                if(arr[i][j]==brr[k]){
                    arr[i][j]=0;
                    break;
                }
            }
        }
    }
   
    if(arr[0][0]==0 && arr[0][1]==0 && arr[0][2]==0)
        cout << "Yes";
    else if(arr[1][0]==0 && arr[1][1]==0 && arr[1][2]==0)
        cout << "Yes";
    else if(arr[2][0]==0 && arr[2][1]==0 && arr[2][2]==0)
        cout << "Yes";
    else if(arr[0][0]==0 && arr[1][0]==0 && arr[2][0]==0)
        cout << "Yes";
    else if(arr[0][1]==0 && arr[1][1]==0 && arr[2][1]==0)
        cout << "Yes";
    else if(arr[0][2]==0 && arr[1][2]==0 && arr[2][2]==0)
        cout << "Yes";
    else if(arr[0][0]==0 && arr[1][1]==0 && arr[2][2]==0)
        cout << "Yes";
    else if(arr[0][2]==0 && arr[1][1]==0 && arr[2][0]==0)
        cout << "Yes";
    else
        cout << "No";
}


Measured memory_bytes: 256
/*  Bismillahir Rahmanir Rahim  */

#include <bits/stdc++.h>

using namespace std;

typedef pair <int, int> pii;

const int N = 305;
const long long mod = 1e9 + 7;

int dp[N][N][N];
vector <pii> ck[N];
int n, m;

bool ok(int a, int b, int c){
	int at = max({a, b, c});
	for(auto u : ck[at]){
		int cnt = 0;
		cnt += (a >= u.first);
		cnt += (b >= u.first);
		cnt += (c >= u.first);
		if(cnt != u.second) return false;
	}
	return true;
}

int recur(int l1, int l2, int l3){
	if(!ok(l1, l2, l3)) return 0;
	int at = max({l1, l2, l3}) + 1;
	if(at == n + 1) return 1;
	if(dp[l1][l2][l3] != -1) return dp[l1][l2][l3];
	long long ret = 0;
	ret += recur(at, l2, l3);
	ret += recur(l1, at, l3);
	ret += recur(l1, l2, at);
	return dp[l1][l2][l3] = ret % mod;
}

int main(){
	int l, r, x;
	scanf("%d %d", &n, &m);
	for(int i = 1; i <= m; ++i){
		scanf("%d %d %d", &l, &r, &x);
		ck[r].push_back({l, x});
	}
	memset(dp, -1, sizeof(dp));
	printf("%d\n", recur(0, 0, 0));
	return 0;
}



Measured memory_bytes: 111104
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations, accumulate
import sys
import bisect
import string
import math
import time
import random


def I(): return int(input())


def S(): return input()


def MI(): return map(int, input().split())


def MS(): return map(str, input().split())


def LI(): return [int(i) for i in input().split()]


def LI_(): return [int(i)-1 for i in input().split()]


def StoI(): return [ord(i)-97 for i in input()]


def ItoS(nn): return chr(nn+97)


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


yn = {False: 'No', True: 'Yes'}
YN = {False: 'NO', True: 'YES'}
MOD = 10**9+7
inf = float('inf')
IINF = 10**10
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)
nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']

show_flg = False
# show_flg = True


def main():
    N, K = MI()
    v = min(N % K, abs(N % K - K))
    print(v)
    # a = N

    # for i in range(100):
    #     N = random.randint(0, 10**5)
    #     K = random.randint(0, 10**5)
    #     a = N
    #     ans = 10**19
    #     for j in range(10**5):
    #         a = abs(a - K)
    #         ans = min(ans, a)

        # if v == ans:
        #     print('Yes')

        # for j in range(10**5):
        #     if N >= K:
        #         N = N % K
        #     else:
        #         K = K % N
        # print(N, K)



if __name__ == '__main__':
    main()


Measured memory_bytes: 39276
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<bitset>
#include<queue>
#define FOR(i,l,r) for(int i=(l),i##R=(r);i<=i##R;i++)
#define DOR(i,r,l) for(int i=(r),i##L=(l);i>=i##L;i--)
#define loop(i,n) for(int i=0,i##R=(n);i<i##R;i++)
#define mms(a,x) memset(a,x,sizeof a)
#define pb push_back
using namespace std;
typedef long long ll;
template<typename A,typename B>inline void chkmax(A &x,const B y){if(x<y)x=y;}
template<typename A,typename B>inline void chkmin(A &x,const B y){if(x>y)x=y;}
const int N=2e5+5;
int n;
int a[N],op;
int b[N];
int cnt[N];
vector<int>ans;
int main(){
	mms(b,-1);
	scanf("%d",&n);
	FOR(i,1,n)scanf("%d",&a[i]);
	int ct=0;
	DOR(i,n,1){
		for(int j=i+i;j<=n;j+=i)
			a[i]^=a[j];
		if(a[i])ct++,ans.pb(i);
	}
	printf("%d\n",ct);
	loop(i,ans.size())printf("%d\n",ans[i]);
	return 0;
}

Measured memory_bytes: 3192
#include <bits/stdc++.h>
#define ll long long
using namespace std;
 
const int sz = 1e5+1;
ll mod=1e9+7;

 
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    int t;
    t=1;
    // cin>>t;
    //sieve();
    for(int cs=1;cs<=t;cs++)
    {
        
        ll n;
        cin>>n;
        // 
        ll rem = n%1000;
        if(rem==0)
        {
            cout<<rem<<endl;
        }
        else
        {
            cout<<1000-rem<<endl;
        }
        // sort(ar,ar+n);
         
        // for(int i=1;i<n;i++)
        // {

        // }

        
 
    }
    return 0;
} 

Measured memory_bytes: 3644
#include <iostream>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <math.h>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

#define mod ((ull)1e9+7)
#define MAX ((ull)1e9)

int main(){
	int n;
	cin >> n;
	ull a[n], b[n];
	for(int i=0; i<n; i++){
		cin >> a[i] >> b[i];
		if(i==0) continue;
		ull m=(a[i-1]+a[i]-1)/a[i], n=(b[i-1]+b[i]-1)/b[i];
		a[i]*=max(m,n); b[i]*=max(m,n);
	}
	cout << a[n-1]+b[n-1] << endl;
	return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
n = int(input())
a = [*map(int, input().split())]
b = [*map(int, input().split())]
s = sum(a)
for i in range(n):
    p = a[i]
    a[i] = max(0, a[i] - b[i])
    if a[i] == 0:
        a[i + 1] = max(0, a[i + 1] + p - b[i])

print(s - sum(a))


Measured memory_bytes: 97648
N,K = map(int ,input().split())
D = []
A = []
for _ in range(K):
  D.append(int(input()))
  A.append(list(map(int, input().split())))

# 各人ごとに、持っているお菓子の個数を数え、個数0の人数を出力する
l = [0]*N
for i in range(K):
  for j in range(D[i]):
    l[A[i][j]-1] +=1

print(l.count(0))

Measured memory_bytes: 9172
#!/usr/bin/env python3
r, c, k = map(int, input().split())
items = [[0] * (c+1) for _ in range(r+1)]
for _ in range(k):
    R, C, V = map(int, input().split())
    items[R][C] = V

dp0 = [[0] * (c+1) for _ in range(r+1)]
dp1 = [[0] * (c+1) for _ in range(r+1)]
dp2 = [[0] * (c+1) for _ in range(r+1)]
dp3 = [[0] * (c+1) for _ in range(r+1)]

for i in range(1, r+1):
    for j in range(1, c+1):
        dp0[i][j] = max(dp0[i][j-1], dp0[i-1][j], dp1[i-1][j], dp2[i-1][j], dp3[i-1][j])
        dp1[i][j] = max(dp1[i][j-1], dp0[i-1][j] + items[i][j], dp1[i-1][j] + items[i][j], dp2[i-1][j] + items[i][j], dp3[i-1][j] + items[i][j], dp0[i][j-1] + items[i][j])
        dp2[i][j] = max(dp2[i][j-1], dp1[i][j-1] + items[i][j])
        dp3[i][j] = max(dp3[i][j-1], dp2[i][j-1] + items[i][j])

ans = max(dp0[r][c], dp1[r][c], dp2[r][c], dp3[r][c])
print(ans)

Measured memory_bytes: 433756
fun main(args: Array<String>) {
    val (n, x) = readLine()!!.split(" ").map(String::toInt)
    val aa = readLine()!!.split(" ").map(String::toInt)
    val a = IntArray(n) { i -> aa[i] }
    var result = 0L
    for (i in 0 until n - 1) {
        val box1 = a[i]
        val box2 = a[i + 1]
        val d = box1 + box2 - x
        if (0 < d) {
            a[i + 1] = if (box2 < d) 0 else box2 - d
            result += d
        }
    }
    println(result)
}


Measured memory_bytes: 72000
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll = long long;
using ld = long double;

#define fi first
#define se second
#define m_p make_pair
#define p_b push_back
#define e_b emplace_back
#define all(x) (x).begin(),(x).end()
#define uniq(x) ((x).erase(unique(all(x)),(x).end()))
#define sz(x) ((int)(x).size())

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

#ifdef LOCAL//compile with -DLOCAL
#define debug(x) cerr<<"LINE"<<__LINE__<<" : "<<#x<<" = "<<(x)<<endl
#define debug_vec(x) cerr<<"LINE"<<__LINE__<<" : "<<#x<<" = ";\
  rep(i,sz(x)){cerr<<x[i]<<" ";}cerr<<endl
#define debug_mat(x) cerr<<"LINE"<<__LINE__<<" : "<<#x<<" = "<<endl;\
  rep(i,sz(x)){rep(j,sz(x[i])){cerr<<x[i][j]<<" ";}cerr<<endl;}cerr<<endl
#else
#define debug(x) void(0)
#define debug_vec(x) void(0)
#define debug_mat(x) void(0)
#endif

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


int main(){
  ios_base::sync_with_stdio(false);cin.tie(0);
  int N,K;
  cin >> N >> K;

  mcf_graph<int, ll> graph(2*N + 2);
  int s = 2*N;
  int t = 2*N + 1;
  const ll M = 1e9;

  graph.add_edge(s, t, N*K, M);
  rep(i,N){
    graph.add_edge(s, i, K, 0);
    graph.add_edge(N+i, t, K, 0);
  }

  rep(i,N){
    rep(j,N){
      ll a;
      cin >> a;
      graph.add_edge(i, N+j, 1, M-a);
    }
  }

  auto ans = graph.flow(s, t, N*K);
  cout << ll(ans.fi)*M - ans.se << endl;

  vector<string> S(N, string(N, '.'));
  auto edges = graph.edges();
  for(auto e : edges){
    if(e.from == s || e.to == t || e.flow == 0) continue;
    S.at(e.from).at(e.to - N) = 'X';
  }
  rep(i,N)  cout << S.at(i) << endl;

  return 0;
}

Measured memory_bytes: 3932
n,m=map(int,input().split())
dp=[0]*(n+1)
charge=[0]*(n+1)
cnt=0
ans=0
for i in range(m):
  q=input()
  if dp[int(q[:-3])]!="A" and q[-2]=="W":
    dp[int(q[:-3])]="W"
    charge[int(q[:-3])]+=1
  elif dp[int(q[:-3])]!="A" and q[-2]=="A":
    dp[int(q[:-3])]="A"
    ans+=1
    cnt+=charge[int(q[:-3])]
    charge[int(q[:-3])]=0
print(ans,cnt)

Measured memory_bytes: 75256
/******************************************
* AHAM BRAHMASHMI ;) *
******************************************/
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define sz(x) ((int)(x).size())
#define F first
#define S second
#define pi 3.14159265358979
int main()
{

// #ifndef ONLINE_JUDGE
// 	// for getting input from input.txt
// 	freopen("input1.txt", "r", stdin);
// 	// for writing output to output.txt
// 	freopen("output1.txt", "w", stdout);
// #endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	ll a, b, h, m;
	cin >> a >> b >> h >> m;
	double h_pos = 0.5 * m + 30 * h;
	double m_pos = 6 * m;
	double diff  = abs(h_pos - m_pos);
	diff = (diff * pi) / 180.0;
	double c = sqrt(a * a + b * b - 2 * a * b * cos(diff));
	printf("%.20f\n", c);
	return 0;
}


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

int main() {
  int i,j;
  long long mod = 1000000007;
  int n;
  cin >> n;
  vector<long long> a(n, 0),b(n+1, 0);
  for(i = 0; i < n;i++){
    cin >> a.at(i);
    b.at(i+1) += b.at(i) + a.at(i);
  }
  
 
  long long ans = 0;
  for(i = 0; i < n;i++){
    long long sum = ((b.at(n) - b.at(i+1)) % mod);
    ans += a.at(i)*sum;
    ans %= mod;
  }
  

  cout << ans << endl;

}


Measured memory_bytes: 6408
#include<iostream>
    using namespace std;
     
    int main(){
    	long long int n,k;
    	cin>>n>>k;
    	long long int a=0,b,res=0,p=0,r;
    	if(k==0){
    		res=n*n;
    		a=1;
    	}
    	for(long long int i=1;i<=n;i++){
    		if(a==1){break;}
    		b=i;
    		r=n%b;
    		p=n/b;
    		res+=p*max(b-k,0LL);
    		//res+=r;
    		res+=max(r-k+1,0LL);
    	}
    	cout<<res<<endl;
    }

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cstdlib>
#include <math.h>
#include<map>
using namespace std;

int main(int argc,char** argv)
{

	int n,m;
	cin >> n >> m;
	char a[n][n];
	char b[m][m];


	for(int i = 0; i < n; i++){
		for(int j = 0; j < n; j++){
			cin >> a[i][j];
		}
	}
	for(int i = 0; i < m; i++){
		for(int j = 0; j < m; j++){
			cin >> b[i][j];
		}
	}

	int cnt=0;
	for(int i = 0; i <= n-m; i++){
		for(int j = 0; j <= n-m; j++){

			int tmpi = i;
			int tmpj = j;

			for(int k = 0; k < m; k++){
				for(int l = 0; l < m; l++){
					if(a[tmpi][tmpj]==b[k][l]){
						cnt++;
					}
					tmpj++;
				}
				tmpi++;
			}
			if(cnt == m*m){
				cout << "Yes" <<endl;
				return 0;
			}
			cnt = 0;
		}
	}
	cout << "No" <<endl;

	return 0;

}

Measured memory_bytes: 256
#include<algorithm>
#include<array>
#include<cmath>
#include<iostream>
#include<iomanip>
#include<iso646.h>
#include<queue>
#include<stack>
#include<string>
#include<vector>

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

#define FOR(counter,initial_value,condition) for(int counter = initial_value; counter < condition;counter++)

int main()
{
	int x, a, b;
	cin >> x >> a >> b;
	cout << (x - a) % b << endl;
}


Measured memory_bytes: 256
def resolve():
    import sys
    input = sys.stdin.readline
    # 整数 1 つ
    # n = int(input())
    # 整数複数個
    a, v = map(int, input().split())
    b, w = map(int, input().split())
    t = int(input())
    # 整数 N 個 (改行区切り)
    # N = [int(input()) for i in range(N)]
    # 整数 N 個 (スペース区切り)
    # N = list(map(int, input().split()))
    # 整数 (縦 H 横 W の行列)
    # A = [list(map(int, input().split())) for i in range(H)]

    if v-w <= 0 or (v-w) * t < abs(a-b):
        print("NO")
    else:
        # if (v-w) * t < abs(a-b):
        #     print("NO")
        # else:
        print("YES")
resolve()

Measured memory_bytes: 61840
#include <iostream>
#include <queue>

using namespace std;

char s[20][20];

int bfs(int sx, int sy, int h, int w){
    queue <pair<int, int> > q;
    int d[h][w];
    int dx[4]={1,0,-1,0}, dy[4]={0,1,0,-1};

    for (int i = 0; i < h; i++){
      for (int j = 0; j < w; j++){
        d[i][j]=-1;
      }
    }
    
    q.push(make_pair(sx,sy));
    d[sx][sy]=0;

    while(!q.empty()){
        pair<int, int> p=q.front(); 
        q.pop();

        for (int i=0; i<4; i++){
            int nx=p.first+dx[i],ny=p.second+dy[i];

            if(0<=nx && nx<h && 0<=ny && ny<w && s[nx][ny]!='#' && d[nx][ny]==-1){
                q.push(make_pair(nx,ny));
                d[nx][ny]=d[p.first][p.second]+1;
            }
        }
    }

    int max_v = 0;
    for (int i = 0; i < h; i++){
      for (int j = 0; j < w; j++){
        if (max_v < d[i][j]) max_v = d[i][j];
      }
    }

    return max_v;
}

int main(){
  int H, W;
  cin >> H >> W;
  for (int i = 0; i < H; i++){
    for (int j = 0; j < W; j++){
      cin >> s[i][j];
    }
  }
  
  int ans = 0;
  for (int i = 0; i < H; i++){
    for (int j = 0; j < W; j++){
      if (s[i][j] == '.') {
        int t = bfs(i, j, H, W);
        if (ans < t) ans = t;
      }
    }
  }

  printf("%d\n",ans);
}


Measured memory_bytes: 3700
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <array>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>
#include <functional>

using namespace std;
using lli = long long int;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (lli i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

lli n;
int main() {
  cin >> n;
  lli k=1; bool ok = false;
  for (; k<10000; ++k) {
    if (n == k * (k+1) / 2) { ok = true; break; }
  }
  if (!ok) { cout << "No" << endl; return 0; }
  vector<vector<lli>> s(k+1);
  lli x=1;
  for (lli j=0; j<k+1; ++j) {
    lli ss = s[j].size();
    for (lli i=0; i<k-ss; ++i) {
      s[j].push_back(x);
      s[j+i+1].push_back(x);
      ++x;
    }
  }
  cout << "Yes" << '\n' << k+1 << '\n';
  for (auto& v : s) {
    cout << k;
    for (lli x : v) {
      cout << ' ' << x;
    }
    cout << '\n';
  }
  return 0;
}



Measured memory_bytes: 3200
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define puts(i) cout << i << endl
#define INF INT_MAX;
typedef long long ll;
using namespace std;

int main(){
  int64_t N,a,b; cin >> N >> a >> b;
  if((b-a)%2==0) cout << (b-a)/2 << endl;
  else{
    cout << min(a-1,N-b)+1+(b-a-1)/2 << endl;
  }
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{

	int buy, sell,max;

	int n;
	scanf("%d", &n);
	
	scanf("%d", &buy);
	scanf("%d", &sell);
	
	max = sell - buy;
	if (sell < buy)
		buy = sell;

	int tmp;
	for (int i = 2; i < n; i++) {
		scanf("%d", &tmp);
		if ((tmp - buy) > max)
			max = tmp - buy;
		else if(tmp < buy)
			buy = tmp;
	}

	printf("%d\n", max);

	return 0;
}


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

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

#define rep(i, n) for (int i = 0; i < (n); i++)
#define repp(i, s, e) for (int i = (s); i < (e); i++)
#define all(x) x.begin(), x.end()

#define endl "\n"

void use_cio() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
}

template <class L, class R>
ostream &operator<<(ostream &os, pair<L, R> P) {
  return os << "(" << P.first << "," << P.second << ")";
}
template <class T>
ostream &operator<<(ostream &os, vector<T> V) {
  os << "[";
  for (auto x : V) os << x << ", ";
  return os << "]";
}
//--------------------------------------------------//

int main() {
  use_cio();
  int n;
  cin >> n;
  cout << 1LL * (n - 2) * 180 << endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        int h = Integer.parseInt(sc.next());
        int w = Integer.parseInt(sc.next());
        int n = Integer.parseInt(sc.next());
        sc.close();

        // 主処理
        int max = Math.max(h, w);
        int result = (int) Math.ceil((double) n / max);

        // 出力
        System.out.println(result);
    }
}


Measured memory_bytes: 23892
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define chmax(x,y) x = max(x,y)
 
const ll INF = 1e18;

const int mod = 1000000007;
struct mint {
    ll x;
    mint(ll x=0):x( (x%mod + mod) % mod ) {}
    mint operator-() const { return mint(-x); }
    mint& operator+=(const mint a) {
        if ( (x += a.x) >= mod ) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ( ( x += mod - a.x) >= mod ) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) {
        ( x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const { return mint(*this) += a; }
    mint operator-(const mint a) const { return mint(*this) -= a; }
    mint operator*(const mint a) const { return mint(*this) *= a; }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }

    mint inv() const { return pow(mod - 2); }
    mint& operator/=(const mint a) { return *this *= a.inv(); }
    mint operator/(const mint a) { return mint(*this) /= a; }
};
istream& operator>>(istream& is, mint& a) { return is >> a.x; }
ostream& operator<<(ostream& os, const mint& a) { return os << a.x; }
 
mint dp[5005][5005][2];
vector<int> G[5005];
int sz[5005];
mint f[5005];
mint tmp[5005][2] = {};
int n;

void dfs(int v, int p = -1) {
  sz[v] = 1;
  dp[v][1][0] = 1;
  for (auto u : G[v]) {
    if (u == p) continue;
    dfs(u,v);

    rep(i,5005) rep(j,2) tmp[i][j] = mint(0);

    rep(i,sz[v] + 1) rep(j, sz[u] + 1) {
      tmp[i + j][0] += dp[v][i][0] * dp[u][j][0] + dp[v][i][1] * dp[u][j][1];
      tmp[i + j][1] += dp[v][i][0] * dp[u][j][1] + dp[v][i][1] * dp[u][j][0];

      tmp[i][1] += dp[v][i][0] * dp[u][j][0] * f[j] + dp[v][i][1] * dp[u][j][1] * f[j];
      tmp[i][0] += dp[v][i][0] * dp[u][j][1] * f[j] + dp[v][i][1] * dp[u][j][0] * f[j];
    }
    
    swap(dp[v], tmp);
    sz[v] += sz[u];
  }
}
 
int main() {
  f[2] = 1;
  for (int i = 3; i <= 5005; ++i) {
    f[i] = f[i-2] * mint(i-1);
  }
  cin >> n;
  rep(i,n-1) {
    int x, y;
    cin >> x >> y;
    --x, --y;
    G[x].emplace_back(y);
    G[y].emplace_back(x);
  }
  dfs(0);
  mint ans = 0;
  rep(i,n+1) {
    ans += dp[0][i][0] * f[i];
    ans -= dp[0][i][1] * f[i];
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 396052
import java.math.BigInteger;
import java.util.Scanner;
import java.util.*;
public class Main {
	public static void main(String[] args) {
		BigInteger a,b;
		Scanner cin=new Scanner(System.in);
		a=cin.nextBigInteger();
		b=cin.nextBigInteger();
		System.out.println(a.multiply(b));
	}
}



Measured memory_bytes: 249768
import scala.io.StdIn.readInt

object Main extends App {
  val s1 = {for(i<-1 to 4) yield readInt }.sortWith(_>_).take(3).sum
  val h = readInt
  val g = readInt
  val s2 = if(h>g) h else g
  println(s1+s2)
}

Measured memory_bytes: 43904
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>
#include<utility>
#include <functional>
#include <limits>

using namespace std;

#define int long long
#define endl "\n"

constexpr long long INF = (long long)1e18;
constexpr long long MOD = 998244353; 

struct fast_io {
	fast_io(){
		std::cin.tie(nullptr);
		std::ios::sync_with_stdio(false);
	};
} fio;


template<typename T>
class segment_tree{
	int n;
	T fval;
	function<T(T,T)> operation;
	vector<T> dat;
	
	T _query(int a, int b, int k, int l, int r){
		if(r <= a || b <= l){
			return fval;
		}
		
		if(a <= l && r <= b){
			return dat[k];
		}else {
			T vl = _query(a, b, k * 2 + 1, l, (l + r) / 2 );
			T vr = _query(a, b, k * 2 + 2, (l + r) / 2, r);
			return operation(vl, vr);
		}
	}
	
public:
	
	segment_tree(){
		
	}
	
	segment_tree(int n_, T val, function<T(T,T)> fun){
		init(n_, val, fun);
	}
	
	~segment_tree(){
		
	}
	
	void init(int n_, T val, function<T(T,T)> fun){
		fval = val;
		
		operation = fun;
		
		n = 1;
		
		while(n < n_) n *= 2;
		
		dat.resize(2 * n - 1);
	
		for(int i = 0; i < 2 * n - 1; i++) dat[i] = fval;
	}

	void update(int k, T a){
		k += n - 1;
		dat[k] = a;
		while(k > 0){
			k = (k - 1) / 2;
			dat[k] = operation(dat[k*2 + 1],dat[k*2 + 2]);
		}
	}
	
	T query(int a, int b){
		return _query(a, b, 0, 0, n);
	}
	
};


signed main(){
	cout<<fixed<<setprecision(10);
	
	int N;
	vector<int> Z, dp;
	vector<pair<int,int>> in;
	segment_tree<int> seg;
	
	cin>>N;
	
	in.resize(N);
	
	for(int i = 0; i < N; i++){
		cin>>in[i].first>>in[i].second;
		
		Z.push_back(in[i].first);
		Z.push_back(in[i].first + in[i].second);
	}
	
	sort(Z.begin(), Z.end());
	
	Z.erase(unique(Z.begin(), Z.end()), Z.end());
	
	seg.init(Z.size()+2,0, [](int first, int second){ return max(first,second);});
	
	dp.resize(Z.size()+1);
	
	dp[0] = 1;
	
	sort(in.begin(), in.end(), greater<pair<int,int>>());
	
	for(int i = 0; i < N; i++){
		int a = in[i].first;
		int b = in[i].second;
		
		in[i].first = lower_bound(Z.begin(), Z.end(), a) - Z.begin();
		in[i].second = lower_bound(Z.begin(), Z.end(), a + b) - Z.begin();
	}
	
	
	for(int i = 0; i < N; i++){
		int maximum = seg.query(in[i].first, in[i].second);
		in[i].second = max(in[i].second, maximum);
		seg.update(in[i].first, in[i].second);
	}
	
	sort(in.begin(), in.end());
	
	for(int i = 0, j = 0; i < dp.size()-1; i++){
		for(; j < N; j++){
			if(in[j].first == i) {
				dp[in[j].second] += dp[in[j].first];
				dp[in[j].second] %= MOD;
			} else break;
		}
		dp[i+1] += dp[i];
		dp[i+1] %= MOD;
	}
	
	cout<<dp.back()<<endl;
	
	return 0;
}

Measured memory_bytes: 18924
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
using namespace std;
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef long double ld;
const ll inf=1e9+7;
const ll mod=998244353;
int main(){
    ll n,r;cin>>n>>r;
    if(n>=10)cout<<r<<endl;
    else cout<<r+(10-n)*100<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<cassert>
#define PB push_back
#define MP make_pair
#define sz(v) (in((v).size()))
#define forn(i,n) for(in i=0;i<(n);++i)
#define forv(i,v) forn(i,sz(v))
#define fors(i,s) for(auto i=(s).begin();i!=(s).end();++i)
#define all(v) (v).begin(),(v).end()
using namespace std;
typedef long long in;
typedef vector<in> VI;
typedef vector<VI> VVI;
bool ub(string s){
  forv(i,s){
    forn(j,i){
      if(s[i]==s[j])
	return 1;
    }
  }
  return 0;
}
string s;
int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin>>s;
  forv(i,s){
    for(in j=2;j<=3;j++){
      if(i+j>sz(s))
	continue;
      if(ub(s.substr(i,j))){
	cout<<(i+1)<<" "<<(i+j)<<endl;
	return 0;
      }
    }
  }
  cout<<"-1 -1"<<endl;
  return 0;
}


Measured memory_bytes: 512
N,K=map(int,input().split())
alist=list(map(int,input().split()))

sum_list=[]
for i in range(N):
  s=0
  for j in range(i,N):
    s+=alist[j]
    sum_list.append(s)
    
sum_list.sort(reverse=True)
#print(sum_list)

answer=0
for i in reversed(range(41)):
  x=2**i
  cnt=0
  for s in sum_list:
    if answer+x>s:
      break
    elif (answer+x)&s==answer+x:
      cnt+=1
      if cnt>=K:
        answer+=x
        break
  
print(answer)

Measured memory_bytes: 28192
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};
    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, [graph1; $len:expr]) => {{
        let mut g = vec![vec![]; $len];
        let ab = read_value!($next, [(usize1, usize1)]);
        for (a, b) in ab {
            g[a].push(b);
            g[b].push(a);
        }
        g
    }};
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };
    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };
    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };
    ($next:expr, usize1) => (read_value!($next, usize) - 1);
    ($next:expr, [ $t:tt ]) => {{
        let len = read_value!($next, usize);
        read_value!($next, [$t; len])
    }};
    ($next:expr, $t:ty) => ($next().parse::<$t>().expect("Parse error"));
}

#[allow(unused)]
macro_rules! debug {
    ($($format:tt)*) => (write!(std::io::stderr(), $($format)*).unwrap());
}
#[allow(unused)]
macro_rules! debugln {
    ($($format:tt)*) => (writeln!(std::io::stderr(), $($format)*).unwrap());
}

fn f(a0: i64, a1: i64, sum: i64) -> i64 {
    if a0 + a1 < sum || (a0 + a1 + sum) % 2 == 1 {
        return -1;
    }
    let goal = (a0 + a1 - sum) / 2;
    if (sum & goal) != 0 {
        return -1;
    }
    if goal > a0 {
        return -1;
    }
    let mut u = goal;
    for i in (0..60).rev() {
        if (sum & 1 << i) != 0 && (u | 1 << i) <= a0 {
            u |= 1 << i;
        }
    }
    if u == 0 { -1 } else { a0 - u }
}

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (let _ = write!(out,$($format)*););
    }
    input! {
        n: usize,
        a: [i64; n],
    }
    let mut sum = 0;
    for i in 2..n {
        sum ^= a[i];
    }
    puts!("{}\n", f(a[0], a[1], sum));
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


Measured memory_bytes: 2284
#include<bits/stdc++.h>
using namespace std;
#define ll long long
typedef pair<ll,ll> P;
typedef pair<ll,P> PP;
const ll MOD = 1e9+7;

int main(){
  int h,w,n;
  char s[33][33];
  fill_n(*s,33*33,'#');

  cin>>h>>w>>n;
  for(int i=1;i<=h;i++)
    for(int j=1;j<=w;j++)
	 cin>>s[i][j];

  int ans=0;
  for(int i=1;i<=h;i++)
    for(int j=2;j<=w;j++){

	 //	 cout<<i<<" "<<j<<endl;
	 char t[33][33];
	 for(int x=0;x<33;x++)
	   for(int y=0;y<33;y++)
		t[x][y]=s[x][y];
	 
	 swap(t[i][j],t[i][j-1]);

	 while(1){

	   // cout<<"f"<<endl;
	   for(int x=h-1;x>0;x--){
		for(int y=1;y<=w;y++){
		  if(t[x][y]<'A'||'Z'<t[x][y])continue;
		  if(t[x+1][y]!='.')continue;
		  for(int k=x+1;;k++){
		    if(t[k][y]!='.'){
			 swap(t[x][y],t[k-1][y]);
			 break;
		    }
		  }
		}
	   }
	   //   cout<<i<<" "<<j<<endl;
	   int f=1;
	   int e[33][33]={};
	   for(int x=1;x<=h;x++)
		for(int y=1;y<=w;y++){
		  if(t[x][y]=='.')continue;
		  int dx[4]={0,0,1,-1};
		  int dy[4]={1,-1,0,0};
		  for(int k=0;k<4;k++){
		    int sum=0;
		    int nx=x,ny=y;
		    while(1){
			 if(t[x][y]!=t[nx][ny])break;
			 sum++;
			 nx+=dx[k];
			 ny+=dy[k];
		    }
		    if(sum>=n){
			 nx=x,ny=y;
			 while(1){
			   if(t[x][y]!=t[nx][ny])break;
			   e[nx][ny]=1;
			   nx+=dx[k];
			   ny+=dy[k];
			 }		
		    }
		  }
		}
	   for(int x=1;x<=h;x++)
		for(int y=1;y<=w;y++){
		  if(e[x][y]){
		    t[x][y]='.';
		    f=0;
		  }
		}
	   if(f)break;
	 }
	 //	 cout<<"flg"<<endl;
	 int flg=0;
	 for(int x=0;x<33;x++)
	   for(int y=0;y<33;y++){
		if('A'<=t[x][y]&&t[x][y]<='Z')flg=1;
	   }

	 if(flg==0)ans=1;

	 /*
	 for(int x=1;x<=h;x++){
	   for(int y=1;y<=w;y++){
		cout<<t[x][y];
	   }
	   cout<<endl;
	 }cout<<endl;
	 */
	 
    }
  cout<<(ans?"YES":"NO")<<endl;
  return 0;
}



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

int main() {
  
  	int N;
    cin >> N;
  
  	vector<int> d(N);
  	for ( int i = 0 ; i < N ; i++ ){
    	cin >> d.at(i);
    }
  
  	sort(d.begin(),d.end());
  	if(d.at(N/2) == d.at(N/2 - 1))
      cout << "0" << endl;
  	else
  	  cout << d.at(N/2) - d.at(N/2 - 1) << endl;
}

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

int main(){
  int N;
  cin >> N;
  for(int i = 1; i <= 9; i++){
    if(111 * i >= N){
      cout << 111 * i << endl;
      break;
    }
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <list>
#include <queue>

using namespace std;
using llint = long long int;
#define int long long int

vector<int> vadd, vxor;

signed main()
{
  int a, b;
  cin >> a >> b;
  cout << (a - 1) * (b - 1) << endl;
}


Measured memory_bytes: 256
fun main() {
    var n = readLine()!!.toInt()
    val sList = mutableListOf<String>()

    for(i in 1 .. n){
        sList.add(readLine()!!)
    }

    println("AC x " + sList.filter{it == "AC"}.size)
    println("WA x " + sList.filter{it == "WA"}.size)
    println("TLE x " + sList.filter{it == "TLE"}.size)
    println("RE x " + sList.filter{it == "RE"}.size)

}

Measured memory_bytes: 59564
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
typedef pair<ll, ll>P;
typedef tuple<ll, ll, ll, ll>T;
#define PI 3.14159265359
#define MOD 1000000007
ll A[200001];
ll visited[200001];
ll roop=0;
ll end=0;
ll length=0;
//ループを探す
void cicle(ll x,ll cn){
  ll p=A[x];
  if(visited[p]==-1){
  	visited[p]=cn+1;
    cicle(p,cn+1);
  }
  else{
  	::roop=cn+1-visited[p];
  	::end=p;
    ::length=cn+1;
  }
}
//xからn回で行ける位置をかえす
ll ans=0;
void go(ll x,ll n){
	if(n==0){::ans=x;}
  	else{
    	go(A[x],n-1);
    }
}



int main(){
  ll N,K;
  cin>>N>>K;
  rep(i,200001){visited[i]=-1;A[i]=0;}
  visited[0]=0;
  rep(i,N){
  	ll a;cin>>a;a--;
    A[i]=a;
  }
  cicle(0,0);
  if(K>::length){
  	K-=::length;
    K%=::roop;
    go(::end,K);
  }
  else{
  	go(0,K);
  }
  cout<<::ans+1<<endl;
}

Measured memory_bytes: 6760
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<set>
#include<map>
#include<iomanip>

#define INF 1<<29

using namespace std;

int main(void) {
	int k, t;
	cin >> k >> t;
	vector<int>a(t);
	for (int i = 0; i < t; i++)cin >> a[i];
	sort(a.begin(), a.end(),greater<int>());
	int most = a[0];
	for (int i = 1; i < t; i++) {
		if (most - a[i] <= 0) {
			cout << 0;
			return 0;
		}
		else {
			most -= a[i];
		}
	}
	cout << most - 1;
	return 0;
}

Measured memory_bytes: 256
while True:
    m, f, r = map(int, input().split())
    if m == f == r == -1:
        break
    if m == -1 or f == -1:
        print('F')
    elif m + f >= 80:
        print('A')
    elif m + f >= 65 and m + f < 80:
        print('B')
    elif m + f >= 50 and m + f < 65:
        print('C')
    elif m + f >= 30 and m + f < 50:
        if r >= 50:
            print('C')
        else:
            print('D')
    else:
        print('F')


Measured memory_bytes: 5592
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>
#include <time.h>
#include <tuple>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = (1LL << 60) - 1;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1
#define MAX_N 100100 * 3

int a, b, c;

int main() {
	cin >> a >> b >> c;
	if (a > b)swap(a, b);
	if (b > c)swap(c, b);
	cout << a + b << endl;
}

Measured memory_bytes: 256
import itertools
import bisect

def main():
    n = int(input())
    p = tuple(map(int,input().split()))
    q = tuple(map(int,input().split()))
    a = list(itertools.permutations(range(1,n+1)))
    print(abs(bisect.bisect_right(a,p)-bisect.bisect_right(a,q)))

if __name__ == '__main__':
    main()


Measured memory_bytes: 40560
#include<bits/stdc++.h>
using namespace std;
#define sc scanf
#define pr printf
#define pb push_back
#define ll long long int
int main()
{
    int cnt,a,b,c;
    while(cin>>a>>b>>c)
    {
        cnt=0;
        if(a*c<=b)
            cout<<c<<endl;
            else if(a>b)
                cout<<"0"<<endl;
        else
        {
            for(int i=0;i<c;i++)
            {
                b=b-a;
                cnt++;
                if(b<a)
                    break;
            }
            cout<<cnt<<endl;
        }

    }



    return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;//リストの使用
using System.Collections.Generic;
using System.Text;//テキストの高速出力に必要
class Program
{
	static void Main()
	{
		string[] input = Console.ReadLine().Split(' ');
		int n = int.Parse(input[0]);
		int k = int.Parse(input[1]);
    int q = int.Parse(input[2]);
		long[] nums = Array.ConvertAll(Console.ReadLine().Split(' '),long.Parse);
    long minNum = 0;
    long answer = long.MaxValue;
    int countMemo = 0;
    List<long> answerList = new List<long>();
    List<long> answerSubList = new List<long>();

    for(int i = 0; i < n; i++)//最小値の選択
    {
      minNum = nums[i];
      answerList.Clear();
      answerSubList.Clear();
      countMemo = 0;
      for(int j = 0; j < n; j++)
      {
        if(nums[j] >= minNum)
        {
          countMemo++;
          if(countMemo == k)
          {
            for(int l = 0; l < k; l++)
            {
              answerSubList.Add(nums[j-l]);
            }
          }else if(countMemo > k) answerSubList.Add(nums[j]);
        }else
        {
          if(countMemo >= k)
          {
            answerSubList.Sort((a, b) => a.CompareTo(b));
            for(int l = 0; l < answerSubList.Count()-k+1; l++)
            {
              answerList.Add(answerSubList[l]);
            }
          }
          answerSubList.Clear();
          countMemo = 0;
        }
      }
      if(countMemo >= k)
      {
        answerSubList.Sort((a, b) => a.CompareTo(b));
        for(int l = 0; l < answerSubList.Count()-k+1; l++)
        {
          answerList.Add(answerSubList[l]);
        }
      }
      if(answerList.Count() < q) continue;
      else
      {
        answerList.Sort((a, b) => a.CompareTo(b));
        answer = Math.Min(answer, answerList[q-1]-minNum);
      }
    }
    
		Console.WriteLine(answer);
	}
}

Measured memory_bytes: 19936
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin >> n;
    vector<int> a(n + 1), b(n);
    for (int i = 0; i < n + 1; i++)
    {
        cin >> a[i];
    }
    for (int i = 0; i < n; i++)
    {
        cin >> b[i];
    }
    long long sum = 0;
    for (int i = 0; i < n; i++)
    {
        if (a[i] >= b[i])
        {
            a[i] -= b[i];
            sum += b[i];
            b[i] = 0;
        }
        else if (a[i] < b[i])
        {
            b[i] -= a[i];
            sum += a[i];
            a[i] = 0;
            if (a[i + 1] >= b[i])
            {
                a[i + 1] -= b[i];
                sum += b[i];
                b[i] = 0;
            }
            else
            {
                b[i] -= a[i + 1];
                sum += a[i + 1];
                a[i + 1] = 0;
            }
        }
    }
    cout << sum << endl;
}


Measured memory_bytes: 1024
S = int(input())
MOD = 10 ** 9 + 7
if S < 3:
    print(0)

else:
    dp = [0 for i in range(S + 1)]
    dp[0] = 1

    for i in range(3, S + 1):
        dp[i] = sum(dp[: i - 2]) % MOD

    print(dp[S])


Measured memory_bytes: 9196
#include<iostream>
#include<string>
#include<vector>
#include <algorithm>
using namespace std;
int main() {
    int N,M;
    cin >> N >> M;
    vector<int> A(M);
    vector<int> B(M);
    for(int i=0;i<M;i++){
        int a, b;
        cin >> a >> b ;
        A.at(i) = a;
        B.at(i) = b;
    }
    for(int i=1;i<=N;i++){ // 各都市に関するfor
        int count =0;
        for(int j=0;j<M;j++){
            if( A.at(j) == i){
                count++;
            }
            if( B.at(j) == i){
                count++;
            }
        }
        cout << count << endl;
    }
}

Measured memory_bytes: 3628
#![allow(unused_imports)]
use std::io::*;
use std::fmt::*;
use std::str::*;
use std::cmp::*;
use std::collections::*;

pub trait InputValue {
    fn parse(s: &str) -> Self;
}

pub fn read<T: InputValue>() -> T {
    let mut buf = String::new();
    let _ = stdin().read_line(&mut buf);
    T::parse(&buf.trim())
}

pub fn readn<T: InputValue>(n: usize) -> Vec<T> {
    let mut vec = vec![];
    for _ in 0..n {
        vec.push(read());
    }
    vec
}

pub fn readnc<T: InputValue>() -> Vec<T> {
    let mut vec = vec![];
    let line: String = read();
    for token in line.split_whitespace() {
        vec.push(T::parse(token));
    }
    vec
}

macro_rules! parse_single_value {
    ($($t:ty),*) => {
        $(
            impl InputValue for $t {
                fn parse(s: &str) -> $t { s.parse().unwrap() }
            }
        )*
	}
}
parse_single_value!(i32, i64, f32, f64, usize, String);

macro_rules! parse_tuple {
	($($t:ident),*) => {
		impl<$($t),*> InputValue for ($($t),*) where $($t: InputValue),* {
			fn parse(s: &str) -> ($($t),*) {
				let mut tokens = s.split_whitespace();
				let t = ($($t::parse(tokens.next().unwrap())),*);
				t
			}
		}
	}
}
parse_tuple!(A, B);
parse_tuple!(A, B, C);

// ===

fn main() {
    let (a, b): (i32, i32) = read();
    let max = max(max(a-b, a+b), a*b);
    println!("{}", max);
}


Measured memory_bytes: 4352
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <numeric>
#include <functional>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <memory>
#include <thread>
#include <tuple>

using namespace std;

int main() {
  int n;
  scanf("%d", &n);
  vector<int> b(n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &b[i]);
    b[i] -= i;
  }
  sort(b.begin(), b.end());
  long long c = b[n / 2];
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    ans += abs(c - b[i]);
  }
  printf("%lld\n", ans);
  return 0;
}


Measured memory_bytes: 1024
n = int(input())
mod = 10**9 + 7
dp = [[[[0 for _ in range(n+1)] for _ in range(4)]for _ in range(4)] for _ in range(4)]

for i in range(4):
  for j in range(4):
    for k in range(4):
      if((i == 0 and j == 1 and k == 2) or (i == 0 and j == 2 and k == 1) or (i == 1 and j == 0 and k == 2)):
        pass
      else:
        dp[i][j][k][3] = 1
        
for length in range(3, n):
  for i in range(4):
    for j in range(4):
      for k in range(4):
        if(j == 0 and k == 2):
          dp[j][k][0][length + 1] += (dp[i][j][k][length])%mod
          dp[j][k][2][length + 1] += (dp[i][j][k][length])%mod
          dp[j][k][3][length + 1] += (dp[i][j][k][length])%mod
        elif((i == 0 and k == 1) or (i == 0 and j == 1) or (j == 0 and k == 1) or (j == 1 and k == 0)):
          dp[j][k][0][length + 1] += (dp[i][j][k][length])%mod
          dp[j][k][1][length + 1] += (dp[i][j][k][length])%mod
          dp[j][k][3][length + 1] += (dp[i][j][k][length])%mod
        else:
          dp[j][k][0][length + 1] += (dp[i][j][k][length])%mod
          dp[j][k][1][length + 1] += (dp[i][j][k][length])%mod
          dp[j][k][2][length + 1] += (dp[i][j][k][length])%mod
          dp[j][k][3][length + 1] += (dp[i][j][k][length])%mod
ans = 0
for i in range(4):
  for j in range(4):
    for k in range(4):
      ans += dp[i][j][k][n]
      
print(ans%mod)
          



Measured memory_bytes: 3192
#include <iostream>
#include<bits/stdc++.h>
#include<vector>
#include<string>
#define ll long long
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define vi vector<ll>
#define el printf("\n")
#define s second
#define pb(x) push_back(x)
#define f first
using namespace std;
int main(){
       ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);cout.precision(30);
        IOS;
        ll n,x;
        cin >> n >> x;
        vector<ll>L;
        for(int i=0;i<n;i++)
        {
            ll a;
            cin >> a;
            L.push_back(abs(a-x));
        }
        ll g=0;
        for(int i=0;i<L.size();i++)
        {
            g=__gcd(g,L[i]);
        }
        cout << g;
        return 0;
    }


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

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

    int x;
    cin >> x;

    if (x < 1200){
        cout << "ABC" << endl;
    }else{
        cout << "ARC" << endl;
    }

    return 0;
}


Measured memory_bytes: 888
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <math.h>
#include <sstream>

using namespace std;

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

  vector<int> v;
  if (S[0] == '0') v.push_back(0);
  char ch = S[0];
  int cnt = 0;
  for (int i = 0; i < N; ++i) {
    if (S[i] != ch) {
      v.push_back(cnt);
      cnt = 1;
      ch = ch == '0' ? '1' : '0';
    }
    else {
      ++cnt;
    }
  }
  v.push_back(cnt);
  if (S[N - 1] == '0') v.push_back(0);

  int ans = 0;
  int left = 0;
  int right = min(left + 2 * K, (int)v.size() - 1);
  int sum = 0;
  for (int i = left; i <= right; ++i) {
    sum += v[i];
  }
  ans = max(ans, sum);
  while (left + 2 < (int)v.size()) {
    sum -= v[left] + v[left + 1];
    if (right + 1 < (int)v.size()) sum += v[right + 1];
    if (right + 2 < (int)v.size()) sum += v[right + 2];
    ans = max(ans, sum);
    left = left + 2;
    right = min(right + 2, (int)v.size() - 1);
  }

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


Measured memory_bytes: 1020
#include <set>
#include <queue>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
typedef long long ll ;
#define rep(i, a, b) for (int i = a; i <= b; ++ i) 
const int N = 1e5 + 5, M = 2e5 + 5, inf = 1e9 + 7 ;
using namespace std ;

bool vis[N] ;
int n, m, e, nxt[M << 1], lnk[N], ter[M << 1], dis[N], w[M << 1] ;
set <int> S[N] ;
priority_queue <pair <int, int> > q ;


void add(int x, int y, int z) {
    ter[++ e] = y ;
    nxt[e] = lnk[x] ;
    lnk[x] = e ;
    w[e] = z ;
}

void Solve() {
    int x, y, z ;
    rep(i, 1, m) {
        scanf("%d%d%d", &x, &y, &z) ;
        add(x, y, z) ;
        add(y, x, z) ;
    }
    rep(i, 1, n) {
        dis[i] = inf ;
        vis[i] = true ;
    }
    dis[1] = 0 ;
    q.push(make_pair(0, 1)) ;
    for ( ; !q.empty() ; ) {
        int u = q.top().second ;
        q.pop() ;
        if (!vis[u]) continue ;
        vis[u] = false ;
        for (int i = lnk[u] ; i ; i = nxt[i]) {
            int v = ter[i] ;
            int c = (S[u].find(w[i]) != S[u].end() ? 0 : 1) ;
            if (dis[u] + c < dis[v]) {
                dis[v] = dis[u] + c ;
                S[v].clear() ;
                S[v].insert(w[i]) ;
                q.push(make_pair(- dis[v], v)) ;
            } else
            if (dis[u] + c == dis[v]) {
                S[v].insert(w[i]) ;
            }
        }
    }
    if (dis[n] == inf) puts("-1") ; else
        printf("%d\n", dis[n]) ;
}

void Clear() {
    rep(i, 1, n) lnk[i] = 0 ;
    rep(i, 1, n) S[i].clear() ;
    e = 0 ;
}

int main() {
    for ( ; scanf("%d%d", &n, &m) != EOF ; ) {
        Solve() ;
        Clear() ;
    }
    return 0 ;
}

Measured memory_bytes: 20216
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(void){
    int roop,stk;
    vector<int> number;
    cin >> roop;
    for(int i=0;i<roop;i++){
        cin >> stk;
        number.push_back(stk);
        number.push_back(stk+1);
        number.push_back(stk-1);
    }
    sort(number.begin(),number.end());
    int max_num=0;
    int count=0;
    int search = number[0];
    
    for(int N:number){
        if(N == search){
            count++;
        }else{
            if(count > max_num)max_num = count;
            count = 1;
            search = N;
        }
    }
    
    cout << max_num << endl;
}


Measured memory_bytes: 2420
#include <bits/stdc++.h>
using namespace std;
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = int(a); i < int(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define all(x) (x).begin(), (x).end()
typedef long long lint;
template <class T> bool chmax(T &a, const T &b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> bool chmin(T &a, const T &b) {
    if(a > b) {
        a = b;
        return 1;
    }
    return 0;
}
/* templates */ /* templates */ /* templates */ /* templates */ /* templates */

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

    int N, K;
    cin >> N >> K;
    vector<int> h(N + 1, 0);
    rep(i, 1, N + 1) { cin >> h[i]; }
    vector<int> dp(N + 10, 0);
    rep(i, 2, N + 1) {
        dp[i] = dp[i - 1] + abs(h[i - 1] - h[i]);
        rep(j, 2, K + 1) {
            if(i - j >= 1) {
                chmin(dp[i], dp[i - j] + abs(h[i - j] - h[i]));
            }
        }
    }
    cout << dp[N] << endl;
}

Measured memory_bytes: 1024