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

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
 
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for (ll i = 1; i <= (ll)(n); i++)
#define INF 10000000000
#define MOD 1000000007
using ll = long long;
using pint = pair<int,int>;
using pll = pair<ll,ll>;
using Graph = vector<vector<int>>;

int main(){
    ll N,C; cin>>N>>C;
    vector<ll> x(N),v(N),O(N,0),R(N,0),Ox(N,0),Rx(N,0);
    rep(i,N)cin>>x[i]>>v[i];
    O[0] = v[0] - x[0];
    Ox[0] = O[0] - x[0];
    R[0] = v[N-1] - (C-x[N-1]);
    Rx[0] = R[0] - (C-x[N-1]);
    rep1(i,N-1){
        O[i] = O[i-1] + v[i] - (x[i] - x[i-1]);
        Ox[i] = O[i] - x[i];
        R[i] = R[i-1] + v[N-1-i] - (x[N-i] - x[N-i-1]);
        Rx[i] = R[i] - (C-x[N-1-i]);
    }
    rep1(i,N-1){
        Ox[i] = max(Ox[i],Ox[i-1]);
        Rx[i] = max(Rx[i],Rx[i-1]);
    }
    rep(i,N-1){
        O[i] = O[i] + max((ll)0,Rx[N-1-i-1]);
        R[i] = R[i] + max((ll)0,Ox[N-1-i-1]);
        // cout<<O[i]<<" "<<R[i]<<endl;
    }
    ll res = 0;
    rep(i,N){
        res = max({res,O[i],R[i]});
    }
    cout<<res<<endl;
}


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

#define int long long

int32_t main(){
	int n; 
	cin >> n; 
	int x[n] , y[n] ;
	for(int i = 0 ; i < n ; i++) cin >> x[i] >> y[i] ;
	vector<int> val(4 , -1e10) ;
	for(int i = 0 ; i < n ; i++){
		for(int j = 0 ; j < 4 ; j++){
			int a = x[i] , b = y[i] ;
			if(1&j){
				a = -a ;
			}
			if((1 << 1) & j){
				b = -b ;
			}
			val[j] = max(val[j] , a + b) ;
		}
	}
	int ans = 0 ;
	for(int i = 0 ; i < n ; i++){
		for(int j = 0 ; j < 4 ; j++){
			int a = x[i] , b = y[i] ;
			if(1&j) a = -a ;
			if((1<<1)&j) b = -b ;
			ans = max(ans , a + b + val[3-j]) ;
		}
	}
	cout << ans;
	return 0 ;
}



Measured memory_bytes: 6732
/*input
5
3 1 4 1 5
3
5 4 3
7
100 200 500 700 1200 1600 2000
6
100 200 500 700 1600 1600
*/
#include "bits/stdc++.h"
#define db(x) cout<<#x<<"="<<(x)<<" "
#define el cout<<endl
using namespace std;

const int MXN = 1e6 + 10;
long long t, n, m, a, b;
map<int, int> cnt;
int main() {
    cin >> n;
    for (long long i = 0; i < n; ++i)
    {
        int x;
        cin >> x;
        ++cnt[x];
    }
    int flag = 0;
    cin >> m;
    for (long long i = 0; i < m; ++i)
    {
        int x;
        cin >> x;
        if (!cnt[x]--)
        {
            flag = 1;
        }
    }
    if (flag) puts("NO");
    else puts("YES");
    return 0;
}



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

int main() {
  ios::sync_with_stdio(false), cin.tie(0);
  string s;
  cin >> s;
  vector<string> v = {"RUD", "LUD"};
  bool dance = true;
  for (int i = 0; i < s.length(); i++) 
    if (v[i & 1].find(s[i]) == string::npos)
      dance = false;
  cout << (dance ? "Yes\n" : "No\n");
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <ctype.h>
#include <math.h>
using namespace std;


int main ()
{

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

if((a*c)<=b)
{
	cout << c << endl;
}
else if((a*c)>b)
{
	cout << b/a << endl;
}

	return 0;
}











Measured memory_bytes: 3188
#include<stdio.h>
#define N 100
#define WHITE 0
#define GRAY 1
#define BLACK 2

int n,M[N][N];
int color[N],d[N],f[N],tt;

void dfs_visit(int u)
{

  int v;
  color[u] = GRAY;
  d[u] = ++tt;
  for(v=0;v<n;v++)
    {
      if(M[u][v]==0) continue;
      if(color[v]==WHITE)
	{
	  dfs_visit(v);
	}
    }
  color[u]=BLACK;
  f[u]=++tt;
}

void dfs()
{
  int u;
  for(u=0;u<n;u++) color[u]=WHITE;
  tt=0;

  for(u=0;u<n;u++)
    {
      if(color[u]==WHITE) dfs_visit(u);
    }
  for(u=0;u<n;u++)
    {
      printf("%d %d %d\n",u+1,d[u],f[u]);
    }
}

int main()
{
  int u,v,k,i,j;

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



Measured memory_bytes: 2108
#include <cstdio>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <algorithm>

using namespace std;

int d[100000];
set <int> s[100000];
map <int, vector<int> > mp[100000];

void dfs(int x, int y, int z, queue <int> &q) {
    int i;
    
    s[x].insert(y);
    
    if (d[x] > z) {
        d[x] = z;
        q.push(x);
    }
    
    for (i = 0; i < mp[x][y].size(); i++) {
        int nx = mp[x][y][i];
        
        if (!s[nx].count(y)) dfs(nx, y, z, q);
    }
}

int main() {
    int n, m, i;
    queue <int> q;
    
    scanf("%d %d", &n, &m);
    
    for (i = 0; i < m; i++) {
        int x, y, z;
        
        scanf("%d %d %d", &x, &y, &z);
        
        x--;
        y--;
        
        mp[x][z].push_back(y);
        mp[y][z].push_back(x);
    }
    
    for (i = 0; i < n; i++) d[i] = 1e9;
    
    d[0] = 0;
    q.push(0);
    
    while (!q.empty()) {
        int x = q.front();
        map <int, vector <int> >::iterator it;
        
        q.pop();
        
        if (x == n - 1) {
            printf("%d\n", d[n - 1]);
            
            return 0;
        }
        
        for (it = mp[x].begin(); it != mp[x].end(); it++) {
            if (!s[x].count(it->first)) dfs(x, it->first, d[x] + 1, q);
        }
    }
    
    puts("-1");
    
    return 0;
}


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

bool f[105];

int main() {
  int n,k;
  cin>>n>>k;
  for(int i=1;i<=k;i++) {
    int m;
    cin>>m;
    for(int i=1;i<=m;i++) {
      int x;
      cin>>x;
      f[x]=1;
    }
  }
  int ans=0;
  for(int i=1;i<=n;i++) {
    if(!f[i]) {
      ans++;
    }
  }
  cout<<ans;
  return 0;
}

Measured memory_bytes: 3632
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#pragma GCC optimize("O2")
typedef long long ll;
#define pb push_back
#define mii map <int, int>
#define mll map <ll, ll>
#define pii pair <int, int>
#define pll pair <ll, ll>
#define vi vector <int>
#define vd vector <double>
#define vll vector <ll>
#define fi first
#define se second
#define si set <int>
#define sll set <ll>
#define spii set <pii>
#define vs vector <string>
#define vpii vector <pair <int,int> >
#define vpll vector <pair <long long,long long> >
#define vvi vector <vector <int> >
#define vvpii vector <vector <pii > >
#define forn(i, n) for (int i = 0; i < (n); i++)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define for1(i, n) for (int i = 1; i < (n); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(),(x).rend()


using namespace std;
const ll INFLL = 1e18;
const int MAXN = 1e6+100;
const ll INF = 1e9;
const ll mod1=1e9+7;
const ll mod2=2e9+11;
set <string> ss;
int n;
void solve(string s,int cur,int k)
{
    //cout<<n<<'\n';
    if (cur==n) {
        ss.insert(s);
        return;
    }
    for (int i=0;i<k;i++) {
        char c='a'+i;
        solve(s+c,cur+1,k);
    }
    char c='a'+k;
    solve(s+c,cur+1,k+1);
}
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    #ifdef LOCAL
    freopen("a.in","r",stdin);
 //   freopen("a.out","w",stdout);
    #endif
    cin>>n;
    string s="";
    solve(s,0,0);
    for (auto to:ss)
        cout<<to<<'\n';





}

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

#define _USE_MATH_DEFINES

#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <functional>
#include <utility>
#include <tuple>
#include <vector>
#include <string>
#include <list>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <stack>
#include <iterator>
#include <bitset>
#include <complex>
#include <limits>
#include <random>


using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;

const double EPS = 1e-9;

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

	int H, W;
	cin >> H >> W;

	int sx, sy, gx, gy;

	cin >> sy >> sx >> gy >> gx;
	sx--, sy--, gx--, gy--;

	vector<string> smap(H);
	rep(i, 0, H)cin >> smap[i];

	priority_queue<pair<int, pii>, vector<pair<int, pii>>, greater<pair<int, pii>>> pq;
	pq.push(make_pair(0, make_pair(sx, sy)));
	vector<vector<int>> D(H, vector<int>(W, INF));
	D[sy][sx] = 0;

	while (!pq.empty())
	{
		auto p = pq.top();
		pq.pop();
		if (D[p.second.second][p.second.first] < p.first)continue;
		static const int dx[] = { 1,0,-1,0 };
		static const int dy[] = { 0,1,0,-1 };
		rep(i, 0, 4)
		{
			int nx = p.second.first + dx[i];
			int ny = p.second.second + dy[i];
			if (0 <= nx && nx < W && 0 <= ny && ny < H&&smap[ny][nx]=='.')
			{
				if (chmin(D[ny][nx], p.first))
				{
					pq.push(make_pair(D[ny][nx], make_pair(nx, ny)));
				}
			}
		}
		rep(i, -2, 3)rep(j, -2, 3)
		{
			int nx = p.second.first + j;
			int ny = p.second.second + i;
			if (0 <= nx && nx < W && 0 <= ny && ny < H&&smap[ny][nx] == '.')
			{
				if (chmin(D[ny][nx], p.first + 1))
				{
					pq.push(make_pair(D[ny][nx], make_pair(nx, ny)));
				}
			}
		}
	}

	if (D[gy][gx] == INF)
	{
		cout << "-1" << endl;
	}
	else
	{
		cout << D[gy][gx] << endl;
	}

	return 0;
}


Measured memory_bytes: 12808
n = gets.to_i
shops = []
n.times do |i|
  city, point = gets.split
  point = point.to_i
  shops << {index: i, city: city, point: point}
end
shops.sort! { |a, b|
  (a[:city] <=> b[:city]).nonzero? ||
  b[:point] <=> a[:point]
}
shops.each do |shop|
  puts shop[:index] + 1
end


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

using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define REP(NAME, NUM) for (int NAME = 0; NAME < (NUM); ++NAME)
#define BREP(NAME, NUM) for (int NAME = (NUM)-1; NAME >= 0; --NAME)
#define ALL(NAME) (NAME).begin(), (NAME).end()

#define cMOD 1000000007ULL
#define cINF ((1ull<<62)-1)
#define cINFINT ((1<<30)-1)


int main()
{
	ll q;cin>>q;

	set<pair<ll,ll>> v;
	ll listN = 0;
	ll sum = 0;
	set<pair<ll,ll>>::iterator it;
	REP(i,q)
	{
		ll a,b,c;
		cin>>a;
		if( a == 2 )
		{
			cout << (*it).first << " " << sum << endl;
		}
		else
		{
			cin>>b>>c;
			if( listN == 0 )
			{
				v.insert(pair<ll,ll>(b,listN));
				++listN;
				sum += c;
				it = v.begin();
			}
			else if( listN % 2 == 1 )
			{
				v.insert(pair<ll,ll>(b,listN));
				++listN;
				if( b < (*it).first )
				{
					sum += abs((*it).first - b) + c;
					--it;
				}
				else
				{
					sum += abs((*it).first - b) + c;
				}
			}
			else
			{
				auto itt = it;
				++itt;
				v.insert(pair<ll,ll>(b,listN));
				++listN;
				if( b < (*it).first )
				{
					sum += abs((*it).first - b) + c;
				}
				else if( b < (*it).first )
				{
					sum += c;
					++it;
				}
				else
				{
					++it;
					sum += abs((*it).first - b) + c;
				}
			}
		}
		
	}
	
	return 0;
}

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

int main() {
	int k, n;
	string s;
	cin>>k;
	cin.ignore();
	getline(cin, s);
	n = (int) s.length();
	if(k >= n) cout<<s<<endl;
	else{
		for(int i = 0; i < k; i++) cout<<s[i];
		cout<<"..."<<endl;
	}
	return 0;
}


Measured memory_bytes: 3624
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <memory.h>
#include <deque>

using namespace std;
typedef long long LL;
const int maxn = 100005;
const int mod = 1e9+7;
const LL inf = 1ll<<59;

int dp1[maxn],dp2[maxn];
LL sdp1[maxn],sdp2[maxn];

LL a,b,x[maxn];int n;
int pre1[maxn],pre2[maxn];
int to1[maxn],to2[maxn];

int calcs1(int l,int r) {
	return l>r?0:(l<1?sdp1[r]:sdp1[r]-sdp1[l-1]);
}
int calcs2(int l,int r) {
	return l>r?0:(l<1?sdp2[r]:sdp2[r]-sdp2[l-1]);
}
int main()
{
	#ifdef Amberframe
		freopen("agc009c.in","r",stdin);
		freopen("agc009c.out","w",stdout);
	#endif
	scanf("%d %lld %lld",&n,&a,&b);
	for (int i=1;i<=n;i++) scanf("%lld",&x[i]);
	sort(x+1,x+n+1);x[0]=-inf;
	for (int i=1;i<=n;i++) {
		pre1[i]=pre1[i-1];while (x[i]-x[pre1[i]+1]>=a) ++pre1[i];
		pre2[i]=pre2[i-1];while (x[i]-x[pre2[i]+1]>=b) ++pre2[i];
		to1[i]=(pre1[i]==i-1)?to1[i-1]:i;
		to2[i]=(pre2[i]==i-1)?to2[i-1]:i;
	}
	pre1[n+1]=pre2[n+1]=n;
	for (int i=1;i<=n;i++) {
		sdp1[i]=sdp1[i-1];sdp2[i]=sdp2[i-1];
		dp1[i]=calcs2(to1[i]-1,pre2[i+1]);
		dp2[i]=calcs1(to2[i]-1,pre1[i+1]);
		to1[i]?0:dp1[i]++;dp1[i]%=mod;
		to2[i]?0:dp2[i]++;dp2[i]%=mod;
		sdp1[i]=(sdp1[i-1]+dp1[i])%mod;
		sdp2[i]=(sdp2[i-1]+dp2[i])%mod;
	}
	int ans=(dp1[n]+dp2[n])%mod;
	printf("%d",ans<0?ans+mod:ans);
	return 0;
}

Measured memory_bytes: 4992
#include<cstdio>
#include<cstring>
using namespace std;
int a,b;
int main()
{
	while(~scanf("%d%d",&a,&b))
	{
		if(a*b%2) printf("Odd\n");
		else printf("Even\n");
	}
	return 0;
	 
 } 

Measured memory_bytes: 128
import java.io.IOException;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		double rate = 380_000.0;
		double sum = 0.0;
		for (int i = 0; i < n; i++) {
			double x = sc.nextDouble();
			String u = sc.next();
			if (u.equals("JPY")){
				sum += x;
			} else {
				sum += x * rate;
			}
		}
		System.out.println(sum);
		sc.close();
	}
}


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

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

    int a, b, c, k;
    cin >> a >> b >> c >> k;
    int cnt = 0;
    while(a >= b) {
        b *= 2;
        cnt++;
    }
    while(b >= c) {
        c *= 2;
        cnt++;
    }
    if(cnt <= k) {
        cout << "Yes" << "\n";
    } else {
        cout << "No" << "\n";
    }
    return 0;
}


Measured memory_bytes: 3612
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

class Main {

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

  private static void dfs(int i, int j, boolean[][] isLand, int H, int W) {
    isLand[i][j] = false;
    for (int k = 0; k < 8; k++) {
      int ci = i + dx[k];
      int cj = j + dy[k];
      if (0 <= ci && ci < H && 0 <= cj && cj < W && isLand[ci][cj]) {
        dfs(ci, cj, isLand, H, W);
      }
    }
  }

  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    List<Integer> list = new ArrayList<>();
    while (true) {
      int W = scanner.nextInt();
      int H = scanner.nextInt();
      if (W == 0 && H == 0) {
        break;
      }
      boolean[][] isLand = new boolean[H][W];
      for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
          isLand[i][j] = scanner.nextInt() == 1;
        }
      }
      int ans = 0;
      for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
          if (isLand[i][j]) {
            ans++;
            dfs(i, j, isLand, H, W);
          }
        }
      }
      list.add(ans);
    }
    for (Integer integer : list) {
      System.out.println(integer);
    }
  }
}



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

typedef long long ll;

ll dp[99][21] = {};

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

    int x;
    cin >> x;
    dp[0][x] = 1;

    for(int i = 1; i < n-1; i++){
        cin >> x;
        for(int j = 0; j <= 20; j++){
            int p = j+x, m = j-x;
            if(0 <= p && p <= 20)   dp[i][p] += dp[i-1][j];
            if(0 <= m && m <= 20)   dp[i][m] += dp[i-1][j];
        }
    }

    cin >> x;

    cout << dp[n-2][x] << endl;

    return 0;
}


Measured memory_bytes: 3052
#include <iostream>
#include <string>
#include <map>
#include <queue>
#include <algorithm>
#include <vector>
#include <math.h>
#include <bitset>
#include <cmath>
#include <set>

#define rep(i,s,n)for(int i = s;i<n;i++)
#define repe(i,s,n)for(int i = s;i<=n;i++)
#define rep_r(i,s,n)for(int i = n-1;i>=0;i--)
#define rep_re(i,s,n)for(int i = n;i>=0;i--)
using namespace std;
typedef long long ll;
static const ll MOD = 1e9 + 7;
static const ll INF = 1e25;
static const ll MAX_M = 100001;

ll N[200001] = {};
int main() {
	ll n, x; cin >> n >> x;

	if (x == 1 || x == 2 * n - 1) {
		cout << "No" << endl;
		return 0;
	}

	cout << "Yes" << endl;
	if (n == 2) {
		cout << 1 << endl;
		cout << 2 << endl;
		cout << 3 << endl;
		return 0;
	}
	else {
		N[n - 2] = x - 1;
		N[n - 1] = x;
		N[n] = x + 1;
		ll pos = 0;

		for (int i = 1; i <= 2 * n - 1;) {
			if (i == x || i == x - 1 || i == x + 1) {
				i++; continue;
			}
			if (N[pos] != 0) {
				pos++;
				continue;
			}
			N[pos] = i;
			pos++;
			i++;
		}
	}

	rep(i, 0, 2 * n - 1) {
		cout << N[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 3072
#include <stdio.h>
#include <string.h>

int main(void)
{
  int n, len;
  char s[10005];
  scanf("%d %s", &n, s);
  len = strlen(s);
  
  for (int i = 0; i < len; i++)
    s[i] = (s[i]-'A'+n)%26+'A';
  
  printf("%s", s);
  
  return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
#include<assert.h>
const int N=10000;

void judge_score(int* a_score,int* b_score,const int a_card,const int b_card);
void CardGame(const int n);

int main(int argc,char* argv[])
{
	int n;
	for(;1;)
	{
		scanf("%d",&n);
		assert(n<=N && "exceed n threshold");
		if(n)
		{
			CardGame(n);
		}
		else
		{
			break;
		}
	}
	return 0;
}

void judge_score(int* a_score,int* b_score,const int a_card,const int b_card)
{
	if(a_card>b_card)
	{
		*a_score+=a_card+b_card;
	}
	else if(a_card<b_card)
	{
		*b_score+=a_card+b_card;
	}
	else
	{
		*a_score+=a_card;
		*b_score+=b_card;
	}
	
	return;
}

void CardGame(const int n)
{
	
	int i;
	int a_score=0,b_score=0;
	int a_card,b_card;
	for(i=0;i<n;i++)
	{
		scanf("%*c%d %d",&a_card,&b_card);
		judge_score(&a_score,&b_score,a_card,b_card);
	}
	
	printf("%d %d\n",a_score,b_score);
}

Measured memory_bytes: 600
#include <iostream>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>
using namespace std;

typedef pair<int,int> P;
struct edge{
	int to, d, c;
	edge(int to_, int d_, int c_){
		to = to_; d = d_; c = c_;
	}
	edge(){}
};

const int INF = 1e+8;
const int MAX_N = 10001;
int N, M;
vector<edge> G[MAX_N];
vector<int> from[MAX_N];
map<P,int> es;
int d[MAX_N];

void add_edge(int u, int v, int d, int c){
	G[u].push_back( edge(v, d, c) );
	G[v].push_back( edge(u, d, c) );
	es[P(u,v)] = es[P(v,u)] = c;
}

void dijkstra(){
	fill(d, d+MAX_N, INF);
	
	priority_queue<P, vector<P>, greater<P> > q;
	q.push( P(0, 0) );
	d[0] = 0;
	while( !q.empty() ){
		int dist = q.top().first;
		int v = q.top().second;
		q.pop();
		
		if( d[v] < dist ) continue;
		
		for(int i=0 ; i < G[v].size() ; i++ ){
			int to = G[v][i].to;
			int next_dist = G[v][i].d + dist;
			if( next_dist < d[to] ){
				from[to].clear();
				from[to].push_back( v );
				d[to] = next_dist;
				q.push( P(next_dist, to) );
			}else if( next_dist == d[to] ){
				from[to].push_back( v );
				q.push( P(next_dist, to) );
			}
		}
	}
}

int solve(){
	int res = 0;
	for(int v=0 ; v < N ; v++ ){
		int cost = INF;
		for(int i=0 ; i < from[v].size() ; i++ ){
			cost = min(cost, es[P(from[v][i], v)] );
		}
		if( cost != INF ){
			res += cost;
		}
	}
	return res;
}

int main(){
	while( cin >> N >> M , N || M ){
		// 初期化.
		es.clear();
		for(int i=0 ; i < MAX_N ; i++ ){
			G[i].clear();
			from[i].clear();
		}
		
		for(int i=0 ; i < M ; i++ ){
			int u, v, d, c;
			cin >> u >> v >> d >> c;
			u--, v--;
			add_edge(u, v, d, c);
		}
		dijkstra();
		cout << solve() << endl;
	}
}

Measured memory_bytes: 6328
import java.io.*;
import java.util.*;

import javax.lang.model.element.*;

public class Main {

	final static long MOD = 1000000007;
	public static String[] Ws = null;
	public static int wsIndx = 0;
	public static BufferedReader in = null;
	public static long cnt=0;
	public static PrintWriter pw = new PrintWriter(System.out);
	public static void main(String[] args) throws Exception {
		solutionA(args);
		if(in!=null){
			in.close();
		}
		pw.flush();
		pw.close();
	}

	public static void solutionA(String[] args) throws Exception{

		int N = nextInt();
		int[] a = nextInts();
		Arrays.sort(a);
		System.out.println(a[N-1]-a[0]);

	}

	public static void check() throws Exception{
		if(in == null){
			in = new BufferedReader(new InputStreamReader(System.in));
		}
		if(Ws==null || Ws.length<=wsIndx){
			Ws = in.readLine().split(" ");
			wsIndx=0;
		}
	}
	public static int nextInt()throws Exception{
		check();
		return Integer.parseInt(Ws[wsIndx++]);
	}

	public static long nextLong()throws Exception{
		check();
		return Long.parseLong(Ws[wsIndx++]);
	}

	public static String nextString()throws Exception{
		check();
		return Ws[wsIndx++];
	}

	public static int[] nextInts()throws Exception{
		check();
		int[] tmp = new int[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Integer.parseInt(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static long[] nextLongs()throws Exception{
		check();
		long[] tmp = new long[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Long.parseLong(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static String[] nextStrings()throws Exception{
		check();
		wsIndx=Ws.length;
		return Ws;
	}

}



Measured memory_bytes: 22612
#include <bits/stdc++.h>
typedef long long LL;
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

using namespace std;

int main(void)
{
  int n;
  cin >> n;
  LL p = 1000000007ll;
  LL dp[101][4][4][4];
  REP(i,101) REP(j,4) REP(k,4) REP(l,4) dp[i][j][k][l] = 0ll;
  dp[0][3][3][3] = 1ll;
  REP(i,100) REP(j,4) REP(k,4) REP(l,4) REP(m,4) {
    if(k==0 && l==1 && m== 2) continue;
    if(k==1 && l==0 && m== 2) continue;
    if(k==0 && l==2 && m== 1) continue;
    if(j==0 && l==1 && m== 2) continue;
    if(j==0 && k==1 && m== 2) continue;
    dp[i+1][k][l][m] += dp[i][j][k][l];
    dp[i+1][k][l][m] %= p;
  }
  LL answer = 0ll;
  REP(j,4) REP(k,4) REP(l,4) {
    answer += dp[n][j][k][l];
    answer %= p;
  }
  cout << answer << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main()
{
    char a[3];
    scanf("%s",&a);
    int len=strlen(a);
    if(len==2)
    {
    	printf("%s\n",&a);
	}
	if(len==3)
    {
    	printf("%c%c%c\n",a[2],a[1],a[0]);
	}
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>

using namespace std;

int main() {
  int N, K;
  cin >> N >> K;
  
  vector<pair<long long int, int> > sushi(N);
  long long int a;
  int b;
  for (int i = 0; i < N; i++) {
    cin >> b >> a;
    sushi[i] = make_pair(-a, b);
  }
  
  sort(sushi.begin(), sushi.end());
  
  map<int, bool> added;
  long long int total = 0;
  long long int maxTotal;
  long long int count = 0;
  vector<long long int> buffer;
  for (int i = 0; i < K; i++) {
    long long int d = -sushi[i].first;
    int t = sushi[i].second;
    if (!added[t]) {
      added[t] = true;
      d += (count + 1) * (count + 1) - count * count;
      count++;
    } else {
      buffer.push_back(-d);
    }
    total += d;
  }
  
  maxTotal = total;
  
  sort(buffer.begin(), buffer.end());
  
  for (int i = K; i < N; i++) {
    long long int d = -sushi[i].first;
    int t = sushi[i].second;
    if (buffer.size() > 0 && !added[t]) {
      long long int temp = -buffer.back();
      total -= temp;
      total += d + (count + 1) * (count + 1) - count * count;
      count++;
      buffer.pop_back();
      added[t] = true;
      if (maxTotal < total) {
        maxTotal = total;
      }
    }
  }
  
  cout << maxTotal << endl;
  
  return 0;
}


Measured memory_bytes: 5244
from collections import Counter
n=int(input())
l=list(map(int,input().split()))
d=[]
L=Counter(l)
a=L.most_common()
for i in range(len(a)):
  if a[i][1]>=4:
    d.append(a[i][0])
    d.append(a[i][0])
  elif a[i][1]>=2:
    d.append(a[i][0])
d.sort(reverse=True)
print(d[0]*d[1] if len(d)>=2 else 0)


Measured memory_bytes: 21668
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
using ll = long long;


int main() {
    int H,W;
    cin >> H >> W;
    char A[H+2][W+2];
    stack <pair<int, int>> s;
    for (int i = 0; i < H + 2; ++i) {
        A[i][0] = '#';
        A[i][W+1] = '#';
    }
    for (int j = 0; j < W + 2; ++j) {
        A[0][j] = '#';
        A[H+1][j] = '#';
    }
    for (int i = 1; i < H + 1; ++i) {
        for (int j = 1; j < W + 1; ++j) {
            cin >> A[i][j];
            if(A[i][j] == '#') s.push(make_pair(i,j));
        }
    }

    int ans = -1;
    while(! s.empty()){
        stack <pair<int, int>> s1;
        while(! s.empty()){
            int x, y;
            tie(x, y) = s.top();
            if(A[x+1][y] == '.') {
                s1.push(make_pair(x+1,y));
                A[x+1][y] = '#';
            }
            if(A[x-1][y] == '.') {
                s1.push(make_pair(x-1,y));
                A[x-1][y] = '#';
            }
            if(A[x][y+1] == '.') {
                s1.push(make_pair(x,y+1));
                A[x][y+1] = '#';
            }
            if(A[x][y-1] == '.') {
                s1.push(make_pair(x,y-1));
                A[x][y-1] = '#';
            }
            s.pop();
        }
        s = s1;
        ans++;
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 9600
#include <iostream>
#include <string>
#include <iomanip>

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

	double mirror = 2.0;
	if (d == 0) {
		mirror = 1.0; 
	}

	cout << setprecision(20) << fixed;
	cout << mirror * (m - 1.0) / (n * n) * (n-d) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <numeric>

int main(){
  while(true){
    unsigned int n;
    std::cin >> n;
    if (n==0) return EXIT_SUCCESS;

    std::vector<unsigned int> p, j;
    p.clear(); j.clear();
    for(unsigned int i=0; i<n; i++){
      unsigned int tmp;
      std::cin >> tmp;
      p.push_back(tmp);
    }
    for(unsigned int i=0; i<n-1; i++){
      unsigned int tmp;
      std::cin >> tmp;
      j.push_back(tmp);
    }

    unsigned int length = std::accumulate(p.begin(), p.end(), 0);
    unsigned int amount = p.size();
    unsigned int max = length * amount;

    std::sort(j.rbegin(), j.rend());
    for(auto i : j){
      length += i;
      amount--;
      if((length * amount) > max) max = length * amount;
    }

    std::cout << max << std::endl;
  }
}


Measured memory_bytes: 3564
#include <cassert>
#include <cstdio>
#include <string>

class TDllist
{
    int* FList; //[4000000];
    int FBegin;
    int FEnd;
public:
    TDllist()
    {
        FList = new int[4000000];
        FBegin = 2000000;
        FEnd  = 2000000;
    }
    ~TDllist()
    {
        delete[] FList;
    }
    void Insert(int X)
    {
        --FBegin;
        FList[FBegin] = X;
    }
    void Delete(int X)
    {
        int Index = FEnd;
        for(int i = FBegin; i < FEnd; ++i){
            if(X == FList[i]){
                Index = i;
                break;
            }
        }
        if(Index == FEnd) return;
        for(int i = Index; i < FEnd; ++i){
            FList[i] = FList[i+1];
        }
        FEnd--;
    }
    void DeleteFirst()
    {
        FBegin++;
    }
    void DeleteLast()
    {
        FEnd--;
    }
    void Show()const
    {
        printf("%d", FList[FBegin]);
        for(int i = FBegin + 1; i < FEnd; ++i){
            printf(" %d", FList[i]);
        }
        printf("\n");
    }
};

int main()
{
    TDllist List;
    int n, X;
    std::scanf("%d\n", &n);
    char com[1024];
    for(int i = 0; i < n; ++i){
        // List.Show();
        // std::printf("n:%d\n", i);
        std::fgets(com, 1024, stdin);
        if(com[6] == 'F'){
            // printf("deleteFirst\n");
            List.DeleteFirst();
        }else
        if(com[6] == 'L'){
            // printf("deleteLast\n");
            List.DeleteLast();
        }else{
            int v = 0;
            for(int j = 7; com[j] >= '0' && com[j] <= '9'; ++j){
                // printf("%s\n", com);
                // printf("%d\n", com[j]);
                v = v*10 + (com[j] - '0');
            }
            if(com[0] == 'i'){
                // printf("insert %d\n", v);
                List.Insert(v);
            }else
            if(com[0] == 'd'){
                // printf("delete %d\n", v);
                List.Delete(v);
            }
        }
    }
    List.Show();
    return 0;
}

Measured memory_bytes: 6288
# -*- coding: utf-8 -*-

H, W, K = map(int,input().split())

fibonacci = [1,1,2,3,5,8,13,21] # W <= 8なのでこれだけでいい

Amida = [ [0] * W for h in range(H+1)]

for h in range(H+1):
	if W == 1:
		break
	for w in range(W):
		if h == 0:
			if w == 0:
				Amida[h][w] = 1
			else:
				break
		elif w == 0:
			Amida[h][w] = fibonacci[W-2] * Amida[h-1][w+1] + fibonacci[W-1] * Amida[h-1][w]
		elif w == W-1:
			Amida[h][w] = fibonacci[W-2] * Amida[h-1][w-1] + fibonacci[W-1] * Amida[h-1][w]
		else:
			Amida[h][w] += (fibonacci[w-1] * fibonacci[W-w-1] * Amida[h-1][w-1])
			Amida[h][w] += (fibonacci[w] * fibonacci[W-w-1] * Amida[h-1][w])
			Amida[h][w] += fibonacci[w] * fibonacci[W-w-2] * Amida[h-1][w+1]

		Amida[h][w] = Amida[h][w] % 1000000007

if W == 1:
	if K == 1:
		print(1)
	else:
		print(0)
else:
	print(Amida[H][K-1])

Measured memory_bytes: 3064
#include <stdio.h>

/*  選択ソート(0オリジン) */
int selectionSort(int A[], int N) {
    int i, j, t, sw =0, minj;
    for(i=0;i<N-1;i++) {
        minj = i;
        for(j=i;j<N;j++) {
            if(A[j]<A[minj]) minj = j;
        }
        t=A[i]; A[i]=A[minj]; A[minj]=t;
        if(i!=minj) sw++;
    }
    return sw;
}

int main(void) {
    int A[100], N, i, sw;

    scanf("%d",&N);
    for(i=0;i<N;i++) scanf("%d",&A[i]);

    sw = selectionSort(A,N);

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

    return 0;
}



Measured memory_bytes: 2068
#include<iostream>
#include<cstdio>
#include<ios>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<vector>
#include<stack>
#include<queue>
#include<deque>
#include<string>
#include<list>
#include<utility>
#include<tuple>
#include<map>
#include<unordered_map>
#include<complex>
#include<set>
using namespace std;
typedef long long llong;
llong gcd(llong a, llong b) {
	if (a < b) std::swap(a, b);
	if (a % b == 0) return b;
	else return gcd(b, a % b);
}
llong lcm(llong a, llong b) {
	llong g = gcd(a, b);
	return a * b / g;
}
//ここまで共通
string s;
int main() {
	cin >> s;
	if (s == "Sunny") cout << "Cloudy" << endl;
	else if (s == "Cloudy") cout << "Rainy" << endl;
	else cout << "Sunny" << endl;
	return 0;
}

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

#define PB          push_back
#define PF          push_front
#define MP          make_pair
#define FI          first
#define SE          second
#define SIZE( A )   int( ( A ).size( ) )
#define ALL( A )    ( A ).begin( ), ( A ).end( )
#define ALLR( A )   ( A ).rbegin( ), ( A ).rend( )

using namespace std;

typedef long long           ll;
typedef unsigned long long  ull;
typedef long double         lf;
typedef pair< int, int >    pii;
typedef pair< ll, ll >      pll;
typedef vector< bool >      vb;
typedef vector< lf >        vd;
typedef vector< ll >        vll;
typedef vector< int >       vi;
typedef vector< pii >       vpii;

const int MAXN = int( 2e5 );
const int MOD  = int( 360 );
const int oo   = INT_MAX;

string str;

int main( ) {

  #ifdef LOCAL
    freopen( "input", "r", stdin );
    //freopen( "output", "w", stdout );
  #else
    //freopen( "attack.in", "r", stdin );
    //freopen( "attack.out", "w", stdout );
    ios_base::sync_with_stdio( 0 );
    cin.tie( 0 );
  #endif

  while( cin >> str ) {
    bool n = false, s = false, w = false ,e = false;
    for( int i = 0; i < SIZE( str ); ++i ) {
      if( str[i] == 'N' ) n = true;
      if( str[i] == 'S' ) s = true;
      if( str[i] == 'W' ) w = true;
      if( str[i] == 'E' ) e = true;
    }
    cout << ( (n == s) && (e == w) ? "Yes\n" : "No\n" );

  }

  return 0;
}


Measured memory_bytes: 256
#include <cstdio>

const int MN = 100005;

int N, A[3][MN], B[MN], C[MN];
int bit[MN];
inline void Add(int i) { for (; i; i -= i & -i) bit[i] ^= 1; }
inline int Qur(int i) { int s = 0; for (; i <= N; i += i & -i) s ^= bit[i]; return s; }

int main() {
	scanf("%d", &N);
	for (int j = 0; j < 3; ++j)
		for (int i = 1; i <= N; ++i)
			scanf("%d", &A[j][i]);
	for (int i = 1; i <= N; ++i) {
		int x = A[1][i] / 3 + 1;
		B[i] = x;
		if (A[1][i] != x * 3 - 1) return puts("No"), 0;
		if (A[0][i] == x * 3 && A[2][i] == x * 3 - 2) C[i] = 1;
		else if (A[0][i] == x * 3 - 2 && A[2][i] == x * 3) C[i] = 0;
		else return puts("No"), 0;
	}
	for (int i = 1; i <= N; ++i) if ((B[i] ^ i) & 1) return puts("No"), 0;
	int p1 = 0, p2 = 0;
	for (int i = 1; i <= N; i += 2)
		p2 ^= C[i], p1 ^= Qur(B[i]), Add(B[i]);
	for (int i = 1; i <= N; ++i) bit[i] = 0;
	for (int i = 2; i <= N; i += 2)
		p1 ^= C[i], p2 ^= Qur(B[i]), Add(B[i]);
	puts(p1 || p2 ? "No" : "Yes");
	return 0;
}

Measured memory_bytes: 3980
// B - Trained?
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
#define rp(i,s,e) for(int i=(s);i<(e);++i)

int main(){
	int N; cin>>N;
	vi A(N); rp(i, 0, N){cin>>A[i]; --A[i];}
	set<int> visited;
	for(int t=0, a=0; visited.count(a)==0; a=A[a], ++t){
		visited.insert(a);
		if(a == 1){
			cout<< t <<endl;
			return 0;
		}
	}
	cout<< -1 <<endl;
}

Measured memory_bytes: 5376
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define sz(c) (int)(c).size()
#define ALL(c) (c).begin(), (c).end()

const int mod = (int)1e9 + 7;
void add (int &a, int b)
{
    a += b;
    if (a >= mod)
        a -= mod;
}
void sub (int &a, int b)
{
    a -= b;
    if (a < 0)
        a += mod;
}
int mult (int a, int b)
{
    return (ll)a * b % mod;
}

void solve (int n)
{
    vi a(n), b(n);
    for (int i = 0; i < n; i++)
        cin >> a[i] >> b[i];

    const int bound = 2 * *max_element(ALL(a)) + 2 * *max_element(ALL(b)) + 2;
    vi fact(bound, 1), invfact(bound, 1), inv(bound, 1);
    for (int i = 2; i < bound; i++)
    {
        fact[i] = mult(fact[i - 1], i);
        inv[i] = mult(inv[mod % i], mod / i);
        inv[i] = mod - inv[i];
        assert(mult(inv[i], i) == 1);
        invfact[i] = mult(invfact[i - 1], inv[i]);
        assert(mult(fact[i], invfact[i]) == 1);
    }

    const int D = max(*max_element(ALL(a)), *max_element(ALL(b)));
    const int C = 2 * D + 5;
    int dp[C + 1][C + 1];
    memset(dp, 0, sizeof dp);
    int cnt_f[C][C];
    memset(cnt_f, 0, sizeof cnt_f);

    for (int i = 0; i < n; i++)
    {
        dp[D - a[i]][D - b[i]]++;
        cnt_f[D + a[i]][D + b[i]]++;
    }

    int ans = 0;

    for (int i = 0; i < C; i++)
    for (int j = 0; j < C; j++)
    {
        add(ans, mult(cnt_f[i][j], dp[i][j]));
        add(dp[i + 1][j], dp[i][j]);
        add(dp[i][j + 1], dp[i][j]);
    }

//    cerr << ans << endl;

    for (int i = 0; i < n; i++)
    {
        int from = 2 * (a[i] + b[i]);
        int what = 2 * a[i];
        int cur = mult(fact[from], invfact[what]);
        cur = mult(cur, invfact[from - what]);
        sub(ans, cur);
    }

 //   cerr << ans << endl;

    const int inv2 = (mod + 1) / 2;
    ans = mult(ans, inv2);
    cout << ans << endl;
}

int main()
{
    #ifndef ONLINE_JUDGE
 //   freopen("input.txt", "rt", stdin);
 //   freopen("output.txt", "w", stdout);
    #endif

    ios_base::sync_with_stdio(false);
    cin.tie(0);

    int n;
    while (cin >> n)
        solve(n);
}


Measured memory_bytes: 127232
#include <iostream>
#include<vector>
#include<algorithm>
#include<queue>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for(int i=m;i<(int)(n);i++)
typedef long long ll;
typedef pair<int,int> pint;
const int inf   = 1<<30;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};

int main(){
  ll n,m;
  cin>>n>>m;
  if(n>m) swap(n,m);
  if(n==1){
    if(m==1)cout<<1<<endl;
    else cout<<m-2<<endl;
    return 0;
    }  
  cout<<(m-2)*(n-2)<<endl;    
  return 0;
  }

Measured memory_bytes: 256
import java.io.*;
import java.lang.*;
import java.util.*;

class Main
{
	public static void main(String args[])throws IOException
	{
		FastReader scn = new FastReader();
		long a = scn.nextLong();
		long b = scn.nextLong();
		long c = scn.nextLong();
		long d = scn.nextLong();

		long p1 = a * c;
		long p2 = a * d;
		long p3 = b * c;
		long p4 = b * d;

		System.out.println(Math.max(p1, Math.max(p2, Math.max(p3, p4))));
	}


	static class FastReader 
    { 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastReader() 
        { 
            br = new BufferedReader(new InputStreamReader(System.in)); 
        } 
  
        String next() 
        { 
            while (st == null || !st.hasMoreElements()) 
            { 
                try
                {
                    st = new StringTokenizer(br.readLine()); 
                }
                catch (IOException  e) 
                {
                    e.printStackTrace(); 
                }
            } 
            return st.nextToken(); 
        } 
  
        int nextInt() 
        { 
            return Integer.parseInt(next()); 
        } 
  
        long nextLong() 
        { 
            return Long.parseLong(next()); 
        } 
  
        double nextDouble() 
        { 
            return Double.parseDouble(next()); 
        } 
  
        String nextLine() 
        { 
            String str = ""; 
            try
            {
                str = br.readLine(); 
            }
            catch (IOException e) 
            {
                e.printStackTrace(); 
            }
            return str; 
        } 
    }
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int main(){
  int n,m;
  cin>>n>>m;
  int rate = 1;
  REP(i,m)rate *= 2;
  int time = n*100 + 1800*m;
  cout << (time*rate) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <deque>
#include <queue>//for queue and priority_queue
#include <fstream>
#include <iomanip>
#include <stack>
#include <algorithm>
#include <set>
#include <map>
#include <list>
#define endl "\n"
typedef long long ll;
using namespace std;
void Lancer() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); }
bool isPrime(ll n){
	if (n == 2 || n == 3 || n == 5)
		return true;
	else if (n % 2 == 0 || n % 3 == 0 || n % 5 == 0 || n == 1)
		return false;
	else {
		for (int i = 5; i <= sqrt(n); i += 2){
			if (n%i == 0)
				return false;
		}
		return true;
	}
}

//char arr[107][107];
int main(){
	Lancer();
	double n, t, a,h, ind=1,res = 1000000000000000000,d;
	cin >> n >> t >> a;
	for (int i = 0; i < n; i++){
		cin >> h;
		d = t- (h*0.006);
		d = abs(d-a);
		//cout << d << endl;
		if (d < res){
			res = d;
			ind = i+1;
		}
	}
	cout << ind;
	cout << endl;
	return 0;
}


Measured memory_bytes: 3832
/*~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=
*$* WRITER:kakitamasziru/OxOmisosiru *$*
~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=*/
#ifdef LOCAL_JUDGE
#define _GLIBCXX_DEBUG //FOR THE DEBUG! COMMENT OUT THIS WHEN SUBMITTING!
#endif
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <iomanip>
#include <limits>//setprecision
//#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
//#include <unordered_set> //unordered_set
#include <stack> // stack
#include <deque> // deque
#include <math.h>//pow,,,
#include <cmath>//abs,,,
#include <bitset> // bitset
//It is so troublesome that I include bits/stdc++.h !
using namespace std;

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
const long long INF = 10010010010010;
const long long MOD = 1000000007;
typedef pair<int,int> P;

//Solve N^M. This, mod_pow use Iterative Square Method.
long long mod_pow(long long N, long long M) {
    if (M == 0) return 1;
    long long res = mod_pow((N * N) % MOD, M / 2);
    //最下位ビット(*N)が1の時は単独でNをかける
    if (M & 1) res = (res * N) % MOD;

    return res %= MOD;
}

long long gcd(long long a, long long b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}
long long lcm(long long a, long long b) {
    return a / gcd(a, b) * b ;
}

int main() {
    long long A,B;cin >> A >> B;
    long long GCD = gcd(A,B);
    map<long long,long long> M;
    M[1]++;
    while(true){
        long long now = GCD;
        for(long long i = 2;i<=(long long)sqrt(GCD);i++){
            if(GCD % i == 0){
                GCD /= i;
                M[i]++;
                break;
            }
        }
        if(now == GCD){
            M[GCD]++;
            break;
        }
    }
    cout << M.size() << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
    
using namespace std;
typedef long long ll;
    
int main()
{
    int A, B;
    cin >> A >> B;

    int count = 0;
    for (int i = A; i <= B; i++) {
        string istr = to_string(i);
        string reversestr = istr;
        std::reverse(reversestr.begin(), reversestr.end());
        if (istr == reversestr) {
            count++;
        }
    }
    cout << count;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define vi vector<int>
#define vvi vector<vector<int> >
#define mii map<int,int>
#define pb push_back
#define pii pair<int,int>
#define mkp make_pair
#define scan(a,n) for(int i =0 ; i<n ; i++) cin>>a[i]
#define print(a,n) for(int i = 0 ; i < n ; i++) cout<<a[i]<<' '
#define mem(a,v) memset(a,v,sizeof(a))
#define loop(i,a,n) for (int i = a; i < n; i++)
#define FastIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define PRECISION std::cout.unsetf ( std::ios::floatfield );std::cout.precision(15)
double PI=acos(-1.0);
using namespace std;
int mod = 1000000007;
int inf=INT_MAX;
int minf = INT_MIN;

/*int main()
{
    int x;
    cin>>x;
    if(x>=30)
        cout<<"Yes";
    else
        cout<<"No";
}*/

/*int main()
{
    ll n,d;
    cin>>n>>d;
    int cnt=0;
    while(n--)
    {
        ll x,y;
        cin>>x>>y;
        ll temp=x*x+y*y;
        ll ans=ceil(sqrt(temp));
        //cout<<ans<<endl;
        if(ans<=d)
            cnt++;
    }
    cout<<cnt;
}*/

/*int main()
{
    int k;
    cin>>k;
    if(k%2==0 || k%5==0)
    {
        cout<<"-1";
        return 0;
    }
    int first=7,cnt=1;
    while(k>first)
    {
        first=first*10+7;
        cnt++;
    }
    while(first>0)
    {
        first=first%k;
        if(first>0)
        {
            first=first*10+7;
            cnt++;
        }
    }
    cout<<cnt;
}*/

int main()
{
    int n;
    cin>>n;
    string s;
    cin>>s;
    int white=0,red=0,posw=-1,posr=n;
    for(int i=0;i<n;i++)
    {
        if(s[i]=='W')
        {
            white++;
            if(posw==-1)
                posw=i;
        }
        else
        {
            red++;
            posr=i;
        }
    }
    if(white==0 || red==0 || posw>posr)
    {
        cout<<"0";
        return 0;
    }
    queue<int> q;
    int cnt=0;
    for(int i=0;i<n;i++)
    {
        if(s[i]=='R')
        {
            if(i>=red && q.size())
            {
                s[q.front()]='R';
                s[i]='W';
                q.pop();
                cnt++;
            }
        }
        else
            q.push(i);
    }
    cout<<cnt;
}


Measured memory_bytes: 4412
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
using ll=long long;
int main(){
    int n,q; string s;
    cin>>n>>q>>s;
    vector<int>a(n,0);
    for(int i=1; i<n; ++i){
        if(s[i-1]=='A'&&s[i]=='C')a[i]=a[i-1]+1;
        else a[i]=a[i-1];
    }
    vector<int>l(q),r(q);
    rep(i,q)cin>>l[i]>>r[i];
    rep(i,q){
        l[i]--; r[i]--;
        cout<<a[r[i]]-a[l[i]]<<endl;
    }
}

Measured memory_bytes: 2176
#include <iostream>

using namespace std;

int A, B, C, X, Y;
int main(){
  cin >> A >> B >> C >> X >> Y;
  if(X==Y) cout << min(X*A+Y*B,2*C*X) << endl;
  else if(X>Y) cout << min(X*A+Y*B,min(C*X*2,min((X-Y)*C*2+Y*(A+B),(X-Y)*A+Y*C*2))) << endl;
  else if(X<Y) cout << min(X*A+Y*B,min(C*Y*2,min((Y-X)*C*2+X*(A+B),(Y-X)*B+X*C*2))) << endl;
  return 0;
}


Measured memory_bytes: 256
//============================================================================
// Name        : template.cpp
// Author      : 
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <set>
#include <vector>
#include <string.h> // for memset in CF judge.
using namespace std;
#define _CRT_SECURE_NO_DEPRECATE // suppress some compilation warning messages (for VC++ users)
// Shortcuts for "common" data types in contests
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef set<int> si;
typedef map<string, int> msi;
// To simplify repetitions/loops, Note: define your loop style and stick with it!
#define x first
#define y second
#define pb push_back
#define mp make_pair
#define REP(i, a, b) \
for (int i = int(a); i <= int(b); i++) // a to b, and variable i is local!
#define forn(i,n) \
for (int i =0; i<(n); i++)
#define TRvi(c, it) \
for (vi::iterator it = (c).begin(); it != (c).end(); it++)
#define TRvii(c, it) \
for (vii::iterator it = (c).begin(); it != (c).end(); it++)
#define TRmsi(c, it) \
for (msi::iterator it = (c).begin(); it != (c).end(); it++)
#define INF 2000000000 // 2 billion
// If you need to recall how to use memset:
#define MEMSET_INF 127 // about 2B
#define MEMSET_HALF_INF 63 // about 1B
//memset(dist, MEMSET_INF, sizeof dist); // useful to initialize shortest path distances
//memset(dp_memo, -1, sizeof dp_memo); // useful to initialize DP memoization table
//memset(arr, 0, sizeof arr); // useful to clear array of integers

int main() {
	ios::sync_with_stdio(false);
 cin.tie(0);
 int n; cin >> n;
 int b[n];  int mx = 0;
 forn(i,n) {
 	int xx; cin >> xx;
 	b[i] = xx;
 	mx = max(mx, xx);
 }
 int ans = 100000500;
 REP(p, 1, mx) {
 	int mt = 0;
 	forn(j,n) {
 		int x = pow((b[j] - p), 2);;
     mt += x;
 	}
 	ans = min(ans, mt);
 }
 cout << ans << endl;
return 0;
}


Measured memory_bytes: 256
N,Y = map(int,input().split())
Y //= 1000
for i in range(N+1):
    for j in range(N+1-i):
        if 10*i + 5*j + 1*(N-i-j) == Y:
            print(i,j,N-i-j)
            exit()
print(-1,-1,-1)


Measured memory_bytes: 2940