akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int N,M;
int G[9][9] = {{0}};
int main(){
	cin >> N >> M;
	for(int i=0;i<M;i++){
		int a,b;
		cin >> a >> b;
		G[a][b] = 1;
		G[b][a] = 1;
	}
	vector<int> A = {1,2,3,4,5,6,7,8};
	int ans = 0;
	do{
		int c = 1;
		for(int i=0;i<N-1;i++){
			if(G[A[i]][A[i+1]]==1){
				//cout << c << endl;
				c++;
			}
			if(c==N) ans++;
		}
	}while(next_permutation(A.begin()+1,A.begin()+N));
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int main()
{
    Int A, B, C, D; cin >> A >> B >> C >> D;
    Int X = abs(C - A), Y = abs(D - B);
    cout << X + Y - __gcd(X, Y) << endl;
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include<bits/stdc++.h>
using namespace std;

#define int long long
#define endl '\n'

const int N = 200005;

string s;
string t;

int nx[N][26];
signed main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> s >> t;
	for(int i = 0 ; i < s.size() ; i ++)
		fill(nx[i], nx[i] + 26, -1);
	for(char c = 'a' ; c <= 'z' ; c ++){
		int last = -1;
		int ender = -1;
		for(int j = s.size() - 1 ; j >= 0 ; j --){
			nx[j][c - 'a'] = last;
			if(s[j] == c) {
				if(last == -1){
					last = j, ender = j;
				}
				else last = j;
			}
		}
		for(int j = ender ; j < s.size() ; j ++)
			nx[j][c - 'a'] = last;
	}
	int cur = 102150125, used = 0;
	for(int i = 0 ; i < s.size() ; i ++)
		if(s[i] == t[0]){
			cur = i;
			used = i + 1;
			break;
		}
	if(cur == 102150125) return cout << "-1", 0;
	//cout << "pre " << used << endl;
	for(int i = 1 ; i < t.size() ; i ++){
		//cout << "turn " << i << endl;
		int sf = t[i] - 'a';
		int nxt = nx[cur][sf];
		if(nxt == -1) return cout << "-1", 0;
		if(nxt > cur) {
			//cout << "upper " << (nxt - cur) << endl;
			used += (nxt - cur);
			cur = nxt;
		}
		else {
			//cout << "under " << (s.size() - cur) + nxt << endl;
			used += (s.size() - cur);
			used += (nxt);
			cur = nxt;
		}
	}
	cout << used;
}


Measured memory_bytes: 21072
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;



int main()
{
	/*
		ABC92C問題

	*/
	int a, b, c;
	cin >> a >> b >> c;

	vector<int> nums;
	nums.push_back(a);
	nums.push_back(b);
	nums.push_back(c);

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

	int times = 0;
	cout << ((nums[2] - nums[1]) + (nums[2] - nums[0])) / 2 + ((nums[2] - nums[1]) + (nums[2] - nums[0])) % 2 * 2;
}

Measured memory_bytes: 256
n = str(input().rstrip())

ans = 0

a = list(map(int, list(n)))
a = a[::-1]
a.append(0)
for i in range(len(a) - 1):
    c = a[i]
    if c < 5:
        ans += c
    else:
        if c == 5 and a[i+1] < 5:
            ans += 5
        else:
            a[i+1] += 1
            ans += 10 - c
ans += a[-1]

print(ans)



Measured memory_bytes: 22208
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll,ll> pi;
typedef vector<pi> vpi;
typedef long double ld;
#define pb emplace_back
#define emp emplace
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define ALL(x) x.begin(), x.end()
#define SZ(x) (ll)x.size()
#define f first
#define s second
const ll MAXN = 200100;
const ll INF = 1e9;
const ll MOD = 1e9+7;

ll N,Q,a,b,c,d,e,T;
vi V;
ll A[MAXN];
ll B[MAXN];

int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);
	cin>>c>>a>>b;
	if((a-1)/c==(b/c))cout<<"NG";
	else cout<<"OK";
}

Measured memory_bytes: 3616
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
string appe[4]= {"dreamer","dream","eraser","erase"};
bool flag=0;
int lena;
string a;
int cnt=1;
void dfs(int x)
{
    if(x==lena)
    {
        flag=1;
        cout << "YES" <<endl;
        return ;
    }
    for(int i=0; i<4; i++)
    {
        int len=appe[i].size();
        string temp=a.substr(x,len);
        //cout <<len<<" "<< temp <<endl;

        if(temp==appe[i])
        {
            //cout << cnt++ << endl;
            x+=len;
            //cout <<len<<" "<<x<<endl;
            dfs(x);
            x-=len;
        }
    }
}
int main()
{

    cin>>a;
    lena=a.size();
    dfs(0);
    if(!flag)
        cout << "NO" << endl;

    return 0;
}


Measured memory_bytes: 2816
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ll long long
using namespace std;

const ll P = 1000000007;
int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

int main()
{
  cout << fixed << setprecision(10);
  ll a,b,x;
  cin >> a >> b >> x;
  ll B = b/x;
  ll A = (a)/x;
  if(a%x==0) A -= 1;
  cout << B - A << endl;
  return 0;
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
int main(){
    long long int A,B,C,K;
    cin >> A >> B >> C >> K;
    if(K<A)cout << K << endl;
    else if(K<A+B)cout << A << endl;
    else cout << A-(K-A-B) << endl;
}

Measured memory_bytes: 3636
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
using namespace std;

const int N = 205;

int n;
int P[ N ];

int main( void ) {
	scanf( "%d", &n );
	for( int i = 0; i < n * 2; i++ ) scanf( "%d", P + i );
	sort( P, P + n * 2 );
	int sol = 0;
	for( int i = 0; i < n * 2; i += 2 ) sol += P[ i ];
	printf( "%d\n", sol );
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define maxn 100005

ll fastpower (ll b , ll p){
    ll k= p%2 ? b : 1 ;
    return p==0 ? 1 : k*(fastpower(b*b,p/2));
}

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	ll n;
	cin>>n;
	double p[n+1];
	for(int i=1;i<=n;i++)
		cin>>p[i];
	double dp[n+1][n+1];
	memset(dp,0.0,sizeof(dp));
	dp[0][0]=1.0;
	for(int i=1;i<=n;i++){
		for(int j=0;j<=n;j++){
			if(j==0) dp[i][j]=dp[i-1][j]*(1.0-p[i]);
			else dp[i][j]=(dp[i-1][j-1]*p[i])+(dp[i-1][j]*(1.0-p[i]));
		}
	}
	double ans=0.0;
	for(int i=(n+1)/2;i<=n;i++)
		ans+=dp[n][i];
	cout.precision(20);
	cout<<ans;
}

Measured memory_bytes: 74128
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    vector <string> s(n);
    for(int i = 0; i < n; i++){
        cin >> s[i];
    }
    sort(s.begin(),s.end());
    int waCnt = 0;
    int tleCnt = 0;
    int acCnt = 0;
    int reCnt = 0;
    for(int i = 0; i < n; i++){
        if(s[i].compare("WA")==0)waCnt++;
        if(s[i].compare("TLE")==0)tleCnt++;
        if(s[i].compare("AC")==0)acCnt++;
        if(s[i].compare("RE")==0)reCnt++;
    }
    // AC x 3
    // WA x 1
    // TLE x 2
    // RE x 0
    cout << "AC x " << acCnt << endl;
    cout << "WA x " << waCnt << endl;
    cout << "TLE x " << tleCnt << endl;
    cout << "RE x " << reCnt << endl;

    return 0;
}

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

using namespace std;

int main() {
	int task = 0;
	int A[3];
	for (int i = 0;i < 3;i++) {
		cin >> A[i];
	}
	
	sort(A, A+3);

	for (int i = 1;i < 3;i++) {
		task += abs(A[i - 1] - A[i]);
	}

	cout << task << endl;

	return 0;
}

Measured memory_bytes: 256
N, x = map(int, input().split())
a = list(map(int, input().split()))
count = 0
maxcandy = 0
X = x

A = sorted(a)

for i in range(N):
    maxcandy += A[i]

for i in range(N):
    if x >= A[i]:
        x = x - A[i]
        count += 1
    else:
        break

if maxcandy < X:
    print(count-1)
else:
    print(count)


Measured memory_bytes: 3060
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPS(I, a, b) for (int i = (a); i < (b); ++i)
using namespace std;
using ll = long long;

int main() {
  double n,k;
  cin >> n >> k;
  double i = 1;
  double ans = 0;
  while(i <= n){
	if(i >= k){
	  ans += 1;
    }
    else{
      double b = 1;
      double a = i;
      while(a < k){
        a *= 2;
        b = b / 2;
      }
      ans += b;
    }
    i++;
  }
  
  ans /= n;
  cout << std::fixed << std::setprecision(12) << ans << endl;
      
      
}


Measured memory_bytes: 3784
#include<iostream>
#include<cstdio>
using namespace std;
int n,m,i,j,k,q,a[1010][1010],f[1010][1010],l,r;
int main(){
	scanf("%d%d%d",&n,&m,&q);
	for (i=1;i<=m;i++) scanf("%d%d",&l,&r),a[l][r]++;
	for (i=n;i>=1;i--) for (j=i;j<=n;j++){if (i==j) f[i][j]=a[i][j]; else f[i][j]=f[i+1][j]+f[i][j-1]-f[i+1][j-1]+a[i][j];}
	for (i=1;i<=q;i++) scanf("%d%d",&l,&r),printf("%d\n",f[l][r]);return 0;
}

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

void swap( int& x, int& y )
{
    int temp = x;
    x = y;
    y = temp;
}

void swapRange( int* a, int b, int e, int t )
{
    for( int k = 0; k < e - b; k++ )
    {
        int x = b + k;
        int y = t + k;
        swap( a[x], a[y] );
    }
}

int main()
{
    int n, q;
    int b, e, t;

    cin >> n;

    int a[n];

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

    for( int i = 0; i < q; i++ )
    {
        cin >> b >> e >> t;
        swapRange( a, b, e, t );
    }

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


Measured memory_bytes: 3100
#include <stdio.h>
int main(void) {
	int N;
	int L[100];
	int max = 1;
	int count = 0;
	int sum = 0;
	scanf("%d", &N);
	for (int i = 0; i < N; i++) {
		scanf("%d", &L[i]);
	}

	for (int i = 0; i < N; i++) {
		sum += L[i];
			if (L[i] > max) {
				max = L[i];
				count = i;
			}
	}



	if (max < sum - max) {
		printf("Yes");
	}
	else {
		printf("No");
	}

	return 0;
}

Measured memory_bytes: 128
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
inline void rd(int &x){
  int k, m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(int x){
  char f[10];
  int m=0, s=0;
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
template<class S, class T> inline S divup_L(S a, T b){
  return (a+b-1)/b;
}
int N;
int A;
int B;
int H[100000];
int main(){
  int KL2GvlyY, Q5VJL1cS, e98WHCEY, res;
  long long ok, t;
  rd(N);
  rd(A);
  rd(B);
  {
    int Lj4PdHRW;
    for(Lj4PdHRW=0;Lj4PdHRW<(N);Lj4PdHRW++){
      rd(H[Lj4PdHRW]);
    }
  }
  KL2GvlyY = 1;
  Q5VJL1cS = 1000000000;
  while(KL2GvlyY < Q5VJL1cS){
    int i;
    if((KL2GvlyY + Q5VJL1cS)%2==0){
      e98WHCEY = (KL2GvlyY + Q5VJL1cS) / 2;
    }
    else{
      e98WHCEY = (KL2GvlyY + Q5VJL1cS - 1) / 2;
    }
    ok = e98WHCEY;
    for(i=0;i<(N);i++){
      t = H[i] - (long long) B * e98WHCEY;
      if(t > 0){
        ok -=divup_L(t,(A-B));
      }
    }
    if(ok >= 0){
      Q5VJL1cS = e98WHCEY;
    }
    else{
      KL2GvlyY = e98WHCEY + 1;
    }
  }
  res =Q5VJL1cS;
  wt_L(res);
  wt_L('\n');
  return 0;
}
// cLay varsion 20190827-1

// --- original code ---
// int N, A, B, H[1d5];
// {
//   int res;
//   ll ok, t;
//   rd(N,A,B,H(N));
//   res = bsearch_min[int,x,1,1d9][
//     ok = x;
//     rep(i,N){
//       t = H[i] - (ll) B * x;
//       if(t > 0) ok -= t /+ (A-B);
//     }
//   ](ok >= 0);
//   wt(res);
// }


Measured memory_bytes: 640
#include<iostream>
#include<array>
#include<math.h>
#include <stdio.h>
#include <stdlib.h>
#include<string>
#include<stack>
#include<vector>
#include<queue>
using namespace std;
#define ll long long
int main()
{
	int A, B, C;
	cin >> A >> B >> C;
	if (A + B >= C&&A<=C)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
	return 0;
}

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

int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    cout << max({a * 10 + b + c, a + b * 10 + c, a + b + c * 10});

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define dunk(a) cout << (a) << endl
#define rall(a) (a).rbegin(),(a).rend()
const int INF = 2e9;
using namespace std;
using Graph = vector<vector<int>>;
typedef pair<int,int> P;
typedef long long ll;

int main(){
    int n; cin >> n;
    int d1 = n%10;
    int d2 = (n/10);

    if(d1 == 9 || d2 == 9) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
typedef long long int ll;
typedef vector<ll> vi;
typedef vector<pair<ll, ll> > vp;
typedef vector<string> vs;
typedef vector<char> vc;
typedef list<ll> lst;
typedef pair<ll, ll> P;
const long long INF = numeric_limits<ll>::max();
const long long MOD = 1000000007;
const long double PI = 3.1415926;
template <class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <class T> T &chmax(T &a, const T &b) { return a = max(a, b); }
 
ll n, m, k, ans = 0, sum = 0, cnt = 0;
string s;
//char c;
 
#define Endl endl
 
/*--------------------template--------------------*/
int main() {
    cin>>s;
    ll K;
    cin>>K;
    ll sz=s.size();
    set<string> can;
    REP(i,sz)REP(j,5){
        if(i>=j)can.insert(s.substr(i-j,j+1));
    }
    //sort(can.begin(),can.end());
    auto iter=can.begin();
    REP(i,K-1){
        iter++;
    }
    cout<<*iter<<endl;
    return 0;
}

Measured memory_bytes: 1664
object Main {
  var _buf = List[String]()
  def str : String = {
    if (_buf.isEmpty) _buf = io.StdIn.readLine().split(' ').toList
    val res = _buf.head
    _buf = _buf.tail
    return res
  }
  def strs(n:Int) : Array[String] = {
    return new Array[String](n).map(i => str)
  }
  def int : Int = { return str.toInt }
  def long : Long = { return str.toLong }
  def ints(n:Int) : Array[Int] = { return strs(n).map(_.toInt) }
  def longs(n:Int) : Array[Long] = { return strs(n).map(_.toLong) }

  def main(args:Array[String]) = {
    println(if (ints(3).sorted sameElements Array[Int](5, 5, 7)) "YES" else "NO")
  }
}


Measured memory_bytes: 21548
#include<iostream>
#include <cstdio>
#include<stack>
#include <cstring>
#include <algorithm>
#include <queue>

using namespace std;
#define F(i,j,n) for(int i=j;i<=n;i++)
#define D(i,j,n) for(int i=j;i>=n;i--)
#define mem(a,x) memset(a,x,sizeof(a))
#define LL  long long
const int maxn=1e5+10;

int main()
{
    int n,i;
    scanf("%d%d",&n,&i);
    printf("%d",n-i+1);
    return 0;
}


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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
using P = pair<ll,ll>;
using ld=long double;

int main(){
    ll h,w;cin >>h>>w;
    ll ans;
    if(h==1||w==1)ans=1;
    else ans=(h*w-1)/2+1;
    cout <<ans <<endl;
    return 0;
}

Measured memory_bytes: 256
#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 = 1e12;
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 n;
vector<ll> a, b, c;

int main() {
	cin >> n;
	a.resize(n);
	b.resize(n);
	c.resize(n);
	rep(i, n)cin >> a[i];
	rep(i, n)cin >> b[i];
	rep(i, n)cin >> c[i];
	sort(ALL(a));
	sort(ALL(b));
	sort(ALL(c));
	ll ans = 0;
	rep(i, n) {
		ll num = lower_bound(ALL(a), b[i]) - a.begin();
		ll num2 = c.end() - upper_bound(ALL(c), b[i]);
		//cout << num << " " << num2 << endl;
		ans += num*num2;
	}
	cout << ans << endl;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
   
int main() {
    int n,m;
    cin>>n>>m;
    vector<int> a(m);
    for(int i=0;i<m;i++) cin>>a.at(i);
    int ans=0;
    for(int i=0;i<m;i++) ans+=a.at(i);
    if(n>=ans) cout<<n-ans;
    else cout<<"-1";
    
}
   

Measured memory_bytes: 3612
import java.io.PrintWriter;
import java.util.*;

public class Main {


    static Scanner sc;
    static PrintWriter out;

    public static void main(String[] args) {
        sc = new Scanner(System.in);
        out = new PrintWriter(System.out);
        new Main().solve();
        out.flush();
    }

    public void solve() {
        int s = sc.nextInt();
        long mod = 1_000_000_007;
        long[][] dp = new long[701][s+1];
        long[][] sum = new long[701][s+1];
        for(int i=3; i<=s; i++) {
            dp[1][i] = 1;
            sum[1][i] = sum[1][i-1]+1;
        }
        long res = dp[1][s];
        for(int j=2; j<=700; j++) {
            for (int i = 3; i <= s; i++) {
                dp[j][i] = sum[j-1][i-3];
                sum[j][i] = sum[j][i-1]+dp[j][i];
                sum[j][i] %= mod;
            }
            res += dp[j][s];
            res %= mod;
        }
        out.println(res);
    }

}


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

#define ld long double
#define ll long long
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define MP make_pair
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
ll INF = 1e18;
void chmin(ll &a,ll b){if(a>b)a=b;}
void chmax(ll &a,ll b){if(a<b)a=b;}
void pmod(ll &a,ll b){a=(a+b)%MOD;}
void qmod(ll &a,ll b){a=(a*b)%MOD;}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
void ans(bool x,ll y,ll z){if(x)cout<<y<<endl;else cout<<z<<endl;}
void ans(bool x,string y,string z){if(x)cout<<y<<endl;else cout<<z<<endl;}   
ll gcd(ll x,ll y){ll r;while((r=x%y)!=0){x=y;y=r;}return y;}

int main(){
  ll i,j,o;
  ll res=0,res1=INF,res2=-INF,buf=0,buf1=0,buf2=0,buf3=0,buf4=0,sum=0;
  ll l,r;
  bool judge = true;
  ll sx,sy,tx,ty;cin>>sx>>sy>>tx>>ty;
  string s;
  for(i=0;i<ty-sy;i++)s+='U';
  for(i=0;i<tx-sx;i++)s+='R';
  for(i=0;i<ty-sy;i++)s+='D';
  for(i=0;i<tx-sx;i++)s+='L';
  s+='L';
  for(i=0;i<=ty-sy;i++)s+='U';
  for(i=0;i<=tx-sx;i++)s+='R';
  s+="DR";
  for(i=0;i<=ty-sy;i++)s+='D';
  for(i=0;i<=tx-sx;i++)s+='L';
  s+='U';
  cout<<s<<endl;


  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> i_i;
typedef pair<int, i_i> i_i_i;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;

int main() {
    //cout.precision(10);
    int n;
    cin >> n;
    int x[520];
    for(int i = 1; i <= n; i++){
        cin >> x[i];
    }
    vector<i_i_i> before, after;
    for(int i = 2; i <= n; i++){
        before.push_back({x[i], {i - 1, i}});
    }
    for(int i = 1; i < n; i++){
        after.push_back({x[i], {n - i, i}});
    }
    bool finished[520];
    for(int i = 2; i <= n; i++){
        finished[i] = false;
    }
    finished[1] = true;
    vector<i_i> now;
    for(int i = 1; i <= n; i++){
        now.push_back({x[i], i});
    }
    sort(before.begin(), before.end());
    sort(after.begin(), after.end());
    sort(now.begin(), now.end());
    int IndexBefore = 0;
    int IndexAfter = 0;
    int IndexNow = 0;
    for(int i = 0; i < now.size() - 1; i++){
        if(now[i].first == now[i + 1].first){
            cout << "No" << endl;
            return 0;
        }
    }
    int ans[250500];
    for(int index = 1; index <= n * n; index++){
        //cout << index - 1 << " " << ans[index - 1] << endl;
        if(IndexNow < n){
            if(now[IndexNow].first == index){
                if(finished[now[IndexNow].second]){
                    ans[index] = now[IndexNow].second;
                    IndexNow++;
                    continue;
                }
                cout << "No" << endl;
                return 0;
            }
        }
        if(IndexBefore < n - 1){
            ans[index] = before[IndexBefore].second.second;
            before[IndexBefore].second.first--;
            if(before[IndexBefore].second.first == 0){
                finished[before[IndexBefore].second.second] = true;
                IndexBefore++;
            }
            continue;
        }
        if(IndexAfter >= n - 1){
            cout << "No" << endl;
            return 0;
        }
        if(after[IndexAfter].first >= index){
            cout << "No" << endl;
            return 0;
        }
        ans[index] = after[IndexAfter].second.second;
        after[IndexAfter].second.first--;
        if(after[IndexAfter].second.first == 0){
            IndexAfter++;
        }
    }
    cout << "Yes" << endl;
    for(int i = 1; i <= n * n; i++){
        cout << ans[i];
        if(i < n * n){
            cout << " ";
        }
    }
    cout << endl;
    return 0;
}


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

const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

const string YES = "Yes";
const string NO = "No";

int main(){
    int n, m;
    cin >> n >> m;
    if (n == m) cout << YES << endl;
    else cout << NO << endl;
    return 0;
}


Measured memory_bytes: 3620
#include<stdio.h>
#include<stdlib.h>
#define MAX 100005
#define NIL -1
typedef struct Node {
	int p;
	int l;
	int r;
}Node;

Node T[MAX];
int n, D[MAX];

void print(int u){
	int i,c;
	printf("node %d: ",u);
	printf("parent = %d, ",T[u].p);
	printf("depth = %d, ",D[u]);

	if(T[u].p == NIL) printf("root, ");
	else if(T[u].l == NIL) printf("leaf, ");
	else printf("internal node, ");

	printf("[");
	for(i = 0, c = T[u].l; c != NIL; i++, c = T[c].r) {
		if(i) printf(", ");
		printf("%d",c);
	}
	printf("]\n");
}

void rec(int u, int p){
	D[u] = p;
	if(T[u].r != NIL) rec(T[u].r, p);
	if(T[u].l != NIL) rec(T[u].l, p + 1);
}
int main(){
    int n, i, j, l = 0;
    int tmp;
    int a[10];

    scanf("%d", &n);
    
    for(i = 0; i < n; i++){
        T[i].p = T[i].l = T[i].r = NIL;
    }

    for(i = 0; i < n; i++){
        int id, k;
        scanf("%d%d", &id, &k);
    
        for(j = 0; j < k; j++){
            int c;
            tmp = scanf("%d", &c);
            if(j == 0) T[id].l = c;
            else T[l].r = c;
            l = c;
            T[c].p = id;
        }
    }

    int r;
    for(i = 0; i < n; i++){
        if(T[i].p == NIL) r = i;
    }
    rec(r, 0);
    for(i = 0; i < n; i++) print(i);
    return 0;
}


Measured memory_bytes: 6484
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
#define mod 1000000007
using ll = long long;
using namespace std;
#define pi_ 3.1415926535

int main(){
  double a,b,x;
  cin >> a >> b >> x;
  x /= a;
  double ans;
  // x少ない
  if(a*b/2>x){
    double tei = x*2/b;
    //cout << "x" << tei << endl;
    ans = 90-180*atan(tei/b)/pi_;
  }
  // x多い
  else{
    double jotei = x*2/a-b;
    b-= jotei;
    // cout << b << endl;
    ans = 90-180*atan(a/b)/pi_;
  }
  cout << setprecision(20) << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i <(n); ++i)
#define ALL(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
static const double PI = acos(-1);



int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  REP(i,n) cin >> a[i];
  vector<int> b(n);
  b = a;

  sort(ALL(b));
  int MX = *(b.end()-1);
  b.pop_back();
  int MX2 = *(b.end()-1);

  int ans = 0;

  REP(i,n){
    if(a[i] == MX){
      ans = MX2;
    }
    else{
      ans = MX;
    }
    cout << ans << endl;
  }

  return 0;
}

Measured memory_bytes: 4784
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i <= (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,m,n) for(ll i = (m); i <= n; i++){cout << (x[i]) << " ";} cout<<endl;

ll n, m;
string s;

int main(){
	cin.tie(0); ios::sync_with_stdio(false);
	
	cin >> n;
	print((n-1)/2)
	return 0;
}

Measured memory_bytes: 764
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
using namespace std;

vector<char> s;
string str;

int main(){
	cin >> str;
	int n = str.size();
	for(int i=0;i<n;++i){
		if(str[i] == 'S'){
			s.push_back('S');
		}else{
			if(s.size() && s.back() == 'S'){
				s.pop_back();
			}else{
				s.push_back('T');
			}
		}
	}


	printf("%d\n",s.size());




	return 0;
}

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

using namespace std;
#define ll long long

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

    int n;
    cin>>n;

    int temp = ((n + 999)/1000)*1000;
    cout<<(temp-n)<<endl;

    return 0;
}


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

int main(){
int h,w;
  cin>>h>>w;
  vector<vector<char>> table(h,vector<char>(w));
  vector<int> r(h);
  vector<int> c(w);
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      cin>>table.at(i).at(j);
      if(table.at(i).at(j)=='#'){
        r.at(i)=1;
        c.at(j)=1;
      }
    }
  }
  int max=0;
  for(int j=0;j<w;j++){
    if(c.at(j)){
      max=j;
    }
  }
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      if(r.at(i)&&c.at(j)){
        if(j!=max){
        cout<<table.at(i).at(j);
        }else{
        cout<<table.at(i).at(j)<<endl;
        }
      }
    }
  }
}
 


Measured memory_bytes: 256
import sys
input = sys.stdin.readline

def main():
  
  row, col = map(int, input().split())
  ls2 = []
  for i in range(row):
    ls = list(input().split())
    ls = ['#']+ls+['#']
    ls2.append(ls)

  ls_line = ['#']*(col+2) 
  print(''.join(ls_line))
  for row in ls2:
    print(''.join(row))
  print(''.join(ls_line))
  
if __name__ == "__main__":
  main()
  

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

int main() {
	int N, K, ans;
	cin >> N >> K;
	ans = K;
	for (int i = 0; i < N - 1; i++) {
		ans *= (K - 1);
	}
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<queue>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
#define forn(i,a,b)for(int i=(a),_b=(b);i<=_b;i++)
#define fore(i,b,a)for(int i=(b),_a=(a);i>=_a;i--)
#define rep(i,n)for(int i=0,_n=n;i<n;i++)
#define ll long long
#define pii pair<int,int>
#define vi vector<int>
#define vpii vector<pii>
#define m_p make_pair
#define re return
#define pb push_back
#define si set<int>
#define ld long double
#define X first
#define Y second
#define st string
#define ull unsigned long long
#define mod 1000000007
#define INF 1000000007
#define x1 XZVJDFADSPFOE
#define y1 GASDIJSLDAEJF
#define x2 DFDAJKVOHKWIW
#define y2 PSFSAODSXVNMQ
#define LLINF 0x3f3f3f3f3f3f3f3fLL
using namespace std;
inline void read(int &x)
{
	short negative=1;
    x=0;
    char c=getchar();
    while(c<'0' || c>'9')
    {
		if(c=='-')
			negative=-1;
		c=getchar();
	}
    while(c>='0' && c<='9')
        x=(x<<3)+(x<<1)+(c^48),c=getchar();
    x*=negative;
}
ll quickpower(ll n,ll k){
	ll ans=1;
	while(k){
		if(k%2){
			ans*=n;
			ans%=mod;
		}
		n*=n;
		n%=mod;
		k/=2;
	}
	return ans;
}
string int_to_string(int n)
{
	string s="";
	while(n)
	{
		int now=n%10;
		s+=now+'0';
		n/=10;
	}
	reverse(s.begin(),s.end());
	return s;
}
int string_to_int(string s)
{
	int n=0;
	rep(i,s.size())
	{
		n*=10;
		n+=s[i]-'0';
	}
	return n;
}
int n;
ll a[111];
int main()
{
	ios::sync_with_stdio(0);
	//think twice,code once
	cin>>n;
	rep(i,n)cin>>a[i];
	sort(a,a+n);
	int res=0;
	rep(i,n)	
		forn(j,i+1,n-1)
			forn(k,j+1,n-1)
				if(a[i]!=a[j]&&a[j]!=a[k]&&a[i]+a[j]>a[k])res++;
	cout<<res<<endl; 
	return 0;
}



Measured memory_bytes: 3648
import java.util.*;
public class Main {
//トレーニングキャンプ
	public static void main(String[] args) {
		int N;
		long ans, power = 1;
		Scanner sc = new Scanner(System.in);
		N = sc.nextInt();
		for(int i = 1; i <= N; i++)
		{
			power = power * i % 1000000007;
		}
		ans = power % 1000000007;
		System.out.println(ans);
	}

}

Measured memory_bytes: 23252
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;

int vet[100005],dp[100005];

long long rec (long long a,long long b){
    if(dp[a]>-1) return dp[a];
    if(a==b-1) return dp[b-1]=0;
    if(a==b-2) return dp[b-2]=abs(vet[b-2]-vet[b-1]);
    return dp[a]=min(abs(vet[a]-vet[a+1])+rec(a+1,b),abs(vet[a]-vet[a+2])+rec(a+2,b));
}
 
int main() {
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    long long n,m,p=0,i,j,maior=0,t=1,l,r;
    cin>>n;
    memset(dp,-1,sizeof(dp));
    for(i=0;i<n;i++) cin>>vet[i];
    cout<<rec(0,n)<<endl;
}



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

using namespace std;

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

int main(){
	string s;
	cin >> s;
	int res = 1000;
	for(int i=0; i<s.size()-2; i++) {
		int x = stoi(s.substr(i, 3));
		res = min(res, abs(753 - x));
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 256
import collections

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a


n = int(input())

itm = collections.Counter(prime_factorize(n))

ans = 0

for i in itm.keys():
    num = 1
    while True:
        if itm[i] - num < 0:
            break
        else:
            ans+=1
            itm[i] -= num
            num += 1

counter = 0

for i in itm.keys():
    if itm[i] != 0:
        counter += 1

# if counter != 1:
#     ans += 1 
    
print(ans)

Measured memory_bytes: 9472
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/




int A, B, C;
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> A >> B >> C;
    if (A == B) printf("%d\n", C);
    else if (A == C) printf("%d\n", B);
    else printf("%d\n", A);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long; 
using vpii = vector<pair<int, int>>;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define rep1(i, n) for (int i = 1; i < (int)n; i++)
ll inf = 1e9+7;

ll gcd(ll a, ll b){
  return (b != 0) ? gcd(b, a%b) : a;
}

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

int main(){
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<int> s(n);
  rep(i, n) cin >> s[i];
  sort(s.begin(), s.end());
  int ans = 0;
  rep(i, n) ans += s[i];
  if(ans %10 != 0){ cout << ans << "\n"; return 0;}
  rep(i, n){
     if((ans-s[i]) %10 != 0){cout << ans-s[i] << "\n"; return 0;} 
  }
  cout << 0 << "\n"; 
  return 0;
}   

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

int main() {
  int N, M;
  cin >> N >> M;
  vector<pair<int, int>> vec[100005];
  for(int i=0; i<M; i++){
    int p, y;
    cin >> p >> y;
    vec[p].push_back({y, i});
  }
  pair<int,int> ans[100001];
  for(int i=1; i<=N; i++){
    sort(vec[i].begin(), vec[i].end());
    for(int j=0; j<vec[i].size(); j++){
      ans[vec[i][j].second] = {i, j+1};
    }
  }

  for(int i=0; i<M; i++){
    printf("%06d%06d\n", ans[i].first, ans[i].second);
  }
}

Measured memory_bytes: 7808
//Ruthless Coding 
#include <bits/stdc++.h>

#define uni(x)      (x).resize(unique(all(x)) - (x).begin())
#define fprint(v)   for(auto x : v) cout << x << ' '
#define ALL(x)      (x).begin(), (x).end()
#define MP(x, y)    make_pair(x, y)
#define SZ(x)       int((x).size())
#define PB(x)       push_back(x)
#define ll          long long
#define S           second 
#define F           first
#define nl          '\n'

using namespace std;
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
mt19937_64 rnd;

const int N = 2e5 + 5;

int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);
    ll a, b, c;
    cin >> a >> b >> c;
    ll ans = LLONG_MAX;
    if(a % 2 == 0 || b % 2 == 0 || c % 2 == 0){
        cout << 0;
    }else{
        cout << min({a * b, b * c, a * c});
    }
    return 0;
}
/*
    *** Most Impo.. -> check base case always
    1. Overflow Check (*, +)
    2. Index check (0 - based or 1 - based)
    3. Check for n = 1, 2, 3, 4....
    4. Corner Cases
*/

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//make_tuple emplace_back next_permutation push_back make_pair second first setprecision

#if MYDEBUG
#include "lib/cp_debug.h"
#else
#define DBG(...) ;
#endif

using LL = long long;
constexpr LL LINF=334ll<<53;
constexpr int INF=15<<26;
constexpr LL  MOD=1E9+7;

struct Problem{
    LL n,weight;
    vector<LL> v,w;
    Problem(LL n):n(n),v(n),w(n){};

    void solve(){
        cin >> weight;
        for(int i=0; i<n; ++i){
            cin >> w[i] >> v[i];
        }
        unordered_map<LL,LL> dp;
        dp[0]=0;
        for(int i=0;i<n;i++){
            vector<pair<LL,LL>> add;
            for(auto &j : dp){
                if(j.first+w[i]<=weight){
                    add.emplace_back(j.first+w[i],j.second+v[i]);
                }
            }
            for(auto &j : add){
                dp[j.first]=max(dp[j.first],j.second);
            }
        }
        LL ans = 0;
        for(auto &x : dp){
            DBG(x)
            if(x.first<=weight)ans = max(ans, x.second);
        }
        cout << ans <<"\n";
    }
};

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    long long n=0;
    cin >> n;
    Problem p(n);
    p.solve();
    return 0;
}



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

int main(){
 long long a,b;

 cin >> a >> b;

   for(int i=1; i<=a; i++){
 	  if((b*i)%a == 0){
        cout << b*i << endl;
     	break;
     }
   }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
typedef long long ll;
int main() {
    ll a = 0, b = 0;
    cin >> a >> b;
    if(a == b) {
        cout << 0 << endl;
    } else {
        ll t = (a + b) >> 1;
        if(t * 2 == a + b) {
            cout << t << endl;
        } else {
            cout << "IMPOSSIBLE" << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define RFOR(i,a,b) for(int i=(a);i>=(b);--i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define RREP(i,n) for(int i=(n);i>0;--i)
#define CI cin>>
#define CO cout<<
#define EN <<endl
#define all(x) (x).begin(),(x).end()
using namespace std;
 
template <typename T>
istream& operator >> (istream& is, vector<T>& vec) {
	for (T& x : vec) is >> x;
	return is;
}
 
using ll = long long;

int main(){
    int a,b; CI a>>b;
    CO max(a+b,max(a-b,a*b)) EN;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;


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

	int n, i, j, k, hh, a, b, h2;
	cin >> n;
	vector<int> x(n), y(n), h(n);
	for (i = 0; i < n; i++) {
		cin >> x[i] >> y[i] >> h[i];
	}

	if (n == 1) cout << x[0] << " " << y[0] << " " << h[0] << "\n";
	else {
		for (i = 0; i <= 100; i++) {
			for (j = 0; j <= 100; j++) {
				bool valid = true;
				set<int> s;
				for (k = 0; k < n; k++) {
					if (h[k] != 0) {
						hh = h[k] + abs(i - x[k]) + abs(j - y[k]);
						s.insert(hh);
					}
				}
				if (s.size() == 1) {
					bool valid = true;
					for (k = 0; k < n; k++) {
						h2 = max(0, hh - abs(i - x[k]) - abs(j - y[k]));
						if (h2 != h[k]) valid = false;
					}
					if (!valid) continue;

					cout << i << " " << j << " " << hh << "\n";
					goto found;
				}
			}
		}

		// not found -- hh = 1
		for (i = 0; i <= 100; i++) {
			for (j = 0; j <= 100; j++) {
				bool valid = true;
				set<int> s;
				for (k = 0; k < n; k++) {
					hh = max(0, 1 - abs(i - x[k]) - abs(j - y[k]));
					if (hh != h[k]) valid = false;
				}
				if (valid) {
					cout << i << " " << j << " " << hh << "\n";
					goto found;
				}
			}
		}
	}



found:;


	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<fstream>
#include<sstream>
#include<algorithm>
#include<cstdio>
#include<cassert>
#include<cmath>
#include<cstdlib>
#include<cstring>
#include<string>
#include<deque>
#include<queue>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<iomanip>
#include<utility>
#include<functional>
using namespace std;
int n;
int d[100005],cc[100005];
vector<pair<int,int> > edge[100005];
void dfs(int x,int prev)
{
	for(int i=0;i<edge[x].size();i++)
	{
		int y=edge[x][i].first;
		int z=edge[x][i].second;
		if(y==prev)
			continue;
		d[y]=d[x]+z;
		cc[y]=d[y]%2;
		dfs(y,x);
	}
}
int main()
{
	cin>>n;
	for(int i=0;i<n-1;i++)
	{
		int a,b,c;
		cin>>a>>b>>c;
		a--;
		b--;
		c=c%2;
		edge[a].push_back(make_pair(b,c));
		edge[b].push_back(make_pair(a,c));
	}
	dfs(0,-1);
	for(int i=0;i<n;i++)
		cout<<cc[i]<<endl;
	return 0;
}


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

#define FI(i,a,b) for(int i=(a);i<=(b);i++)
#define FD(i,a,b) for(int i=(a);i>=(b);i--)

#define LL long long
#define Ldouble long double
#define PI 3.14159265358979323846264338327950288419

#define PII pair<int,int>
#define PLL pair<LL,LL>
#define mp make_pair
#define fi first
#define se second

using namespace std;

int h, w, cnt;
char s[10][10];

int main(){
	scanf("%d %d", &h, &w);
	FI(i, 1, h) scanf(" %s", s[i] + 1);
	FI(i, 1, h) FI(j, 1, w) if(s[i][j] == '#') cnt++;
	if(cnt != h + w - 1 || s[1][1] != '#' || s[h][w] != '#'){
		printf("Impossible\n");
		return 0;
	}
	int cx = 1, cy = 1;
	while(cx < h || cy < w){
		if(s[cx + 1][cy] == '#') cx++;
		else if(s[cx][cy + 1] == '#') cy++;
		else{
			printf("Impossible\n");
			return 0;
		}
	}
	printf("Possible\n");
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
     
    int main() {
      int a, b;
      int arr[3] = {0};
      int max = -1000;
      
      scanf("%d %d", &a, &b);
      
      arr[0] = a + b;
      arr[1] = a - b;
      arr[2] = a * b;
      
      int i;
      for (i = 0; i < 3; i++) {
        if (max < arr[i]) {
          max = arr[i];
        }
      }
      
      printf("%d\n", max);
      
      return 0;
    }

Measured memory_bytes: 128
#include<bits/stdc++.h>
            using namespace std;
            #define rep(i,b) for(i=0;i<b;++i)
            #define repp(i,a,b) for(i=a;i<b;++i)
            #define endl "\n"
            //#define LLONG_MAX 99999999999999
            typedef long long int lli;
            int main(){
                //ios_base::sync_with_stdio(false);
                //cin.tie(NULL);
                lli t,n,i,j,b,a,q,m;
                cin>>n;
                set<string> st;
                rep(i,n){
                    string s;
                    cin>>s;
                    st.insert(s);
                }
                cout<<st.size()<<endl;

            }



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

#define ll long long

using namespace std;

const ll MOD = 1e9 + 7;

ll n, k, upper = 0, lower = 0;
vector<ll> a, fac;

ll exp(ll a, ll n){
    if(n == 0) return 1;
    ll tmp = exp(a, n/2);
    tmp *= tmp;
    tmp %= MOD;
    if(n%2) tmp *= a;
    tmp %= MOD;
    return tmp;
}

ll inv(ll a){
    return exp(a, MOD - 2);
}

ll comb(ll a, ll b){
    ll pres = fac[a];
    pres *= inv(fac[a - b]);
    pres %= MOD;
    pres *= inv(fac[b]);
    pres %= MOD;
    return pres;
}

int main(){
    cin >> n >> k;
    a.assign(n, 0);
    fac.assign(1e5 + 1, 1);
    for(int i = 0; i < n; ++i){
        cin >> a[i];
    }
    for(int i = 1; i <= 1e5; ++i){
        fac[i] = fac[i - 1] * i;
        fac[i] %= MOD;
    }
    sort(a.begin(), a.end());
    for(int i = 0; i < n; ++i){
        if(n - i >= k){
            lower += a[i] * comb(n - i - 1, k - 1);
            lower %= MOD;
        }
    }
    reverse(a.begin(), a.end());
    for(int i = 0; i < n; ++i){
        if(n - i >= k){
            upper += a[i] * comb(n - i - 1, k - 1);
            upper %= MOD;
        }
    }
    cout << (((upper - lower) % MOD) + MOD) % MOD;
    return 0;
}

Measured memory_bytes: 1792
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Aman Kumar Singh
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        BBuffet solver = new BBuffet();
        solver.solve(1, in, out);
        out.close();
    }

    static class BBuffet {
        PrintWriter out;
        InputReader in;

        public void solve(int testNumber, InputReader in, PrintWriter out) {
            this.out = out;
            this.in = in;
            int n = ni();
            int[] a = new int[n];
            int[] b = new int[n];
            int[] c = new int[n];
            int hola = 0, i = 0;
            for (i = 0; i < n; i++)
                a[i] = ni() - 1;
            for (i = 0; i < n; i++)
                b[i] = ni();
            for (i = 0; i < n - 1; i++)
                c[i] = ni();
            int last = a[0];
            int sum = b[a[0]];
            for (i = 1; i < n; i++) {
                sum += b[a[i]];
                if (a[i] - 1 >= 0 && a[i - 1] + 1 == a[i])
                    sum += c[a[i - 1]];
            }
            pn(sum);

        }

        int ni() {
            return in.nextInt();
        }

        void pn(long zx) {
            out.println(zx);
        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1) {
                throw new UnknownError();
            }
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new UnknownError();
                }
                if (numChars <= 0) {
                    return -1;
                }
            }
            return buf[curChar++];
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public String next() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            StringBuffer res = new StringBuffer();
            do {
                res.appendCodePoint(c);
                c = read();
            } while (!isSpaceChar(c));

            return res.toString();
        }

        private boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

    }
}



Measured memory_bytes: 21460