akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,n) for(int i=(a); i<(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;

int dp[100010];

int main() {
	int N; cin >> N;
	vector<int> H(N);
	rep(i, N) cin >> H[i];

	rep(i, 100010) dp[i] = INF;
	dp[0] = 0;

	// dp[足場i] 足場iまで辿り着くための最小コスト
	// dp[i+2] = min(dp[i]+abs(H[i+2]-H[i]))
	// dp[i+1] = min(dp[i]+abs(H[i+1]-H[i]))

	rep(i, N) {
		if (i+2<=N-1)	dp[i+2] = min(dp[i+2], dp[i]+abs(H[i+2]-H[i]));
		if (i+1<=N-1)	dp[i+1] = min(dp[i+1], dp[i]+abs(H[i+1]-H[i]));
	}

	cout << dp[N-1] << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout<< (x) << " "

int main(){
    int n;cin>>n;
    map<int,int>mp;
    rep(i,n){
        int a;cin>>a;
        if(mp[a]==0)mp[a]++;
        else mp[a]--;
    }
    int ans = 0;
    for(auto i=mp.begin();i!=mp.end();i++){
        ans+=i->second;
    }
    co(ans);
}

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

int main() {
    int64_t N,K;
    cin >> N >> K;
    vector<int64_t> V(N);
    for ( int64_t i = 0; i < N; ++i){
        cin >> V[i];
    }
    
    int64_t msum = 0;
    for ( int64_t l = 0; l <= min(K,N); ++l){
        for ( int64_t r = 0; r <= min(K-l,N-l); ++r){
            // 左からl個、右からr個取り出す
            //int sum = 0;
            vector<int64_t> S;
            for ( int64_t i = 1; i <= l; ++i){
                S.push_back(V[i-1]);
                //sum = sum + V[i-1];
            }
            for ( int64_t i = 1; i <= r; ++i){
                S.push_back(V[N-i]);
                //sum = sum + V[K-i];
            }
            sort(S.begin(),S.end());
            // このうち、min(l+r,K-l-r)個は戻せる
            int64_t sum = 0;
            for ( int64_t i = 0; i < (l+r); ++i){
                if ( i < min(l+r,K-l-r) and S[i] < 0 ){
                    sum = sum;
                } else {
                    sum = sum + S[i];
                }
            }
            /*cout << "lrsum " << l << " " << r << " " << sum << endl;
            for ( auto s: S){
                cout << s << " ";
            }
            cout << endl;*/
            msum = max(msum,sum);
        }
    }
    cout << msum << endl;
    return 0;
}


Measured memory_bytes: 256
/*
 * x 軸上に N 個の観光スポットがあり、1,2,…,N の番号がついています。 観光スポット i は座標 Ai の点にあります。 また、x 軸上を座標 a の点から座標 b の点まで移動するには |a−b| 円かかります。
 * 
 * あなたは x 軸上を旅行する計画を立てました。 計画では、最初に座標 0 の点を出発し、N 個の観光スポットを番号順に訪れ、最後に座標 0 の点に戻ってくることになっています。
 * 
 * ところが、旅行の直前に急用が入り、N 個すべての観光スポットを訪れる時間的余裕がなくなってしまいました。 そこで、ある i を選び、観光スポット i を訪れるのを取りやめることにしました。
 * それ以外の観光スポットは予定通り番号順に訪れます。 また、最初に座標 0 の点を出発し、最後に座標 0 の点に戻ってくることについても、予定に変更はありません。
 * 
 * i=1,2,…,N それぞれについて、観光スポット i を訪れるのを取りやめたときの、旅行中の移動にかかる金額の総和を求めてください。
 */

import java.util.*;
	public class Main{
        public static void main(String[] args){
            Scanner sc = new Scanner(System.in);
            //入力
            int n = Integer.parseInt(sc.next());
            // 観光スポットのx座標の配列
            long[] points = new long[n+2];
            // すべてのスポットを回ったときの総距離
            long sum = 0;
            points[0] = 0;
            points[n+1] = 0;
            
            // points, sumの初期化
            for(int i=1; i<n+1; i++){
            	points[i] = Long.parseLong(sc.next());
            	sum += Math.abs(points[i-1] - points[i]);
            }
            sum += Math.abs(points[n]);
            
            //出力
            for(int i=1; i<n+1; i++){ // 各ポイントについてそこに行かなかった場合の距離を出力
            	System.out.println(sum - Math.abs(points[i] - points[i-1]) - Math.abs(points[i] - points[i+1]) + Math.abs(points[i+1] - points[i-1]));
            }
            sc.close();
        }
    }


Measured memory_bytes: 57496
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define IOS                      \
	ios::sync_with_stdio(false); \
	cin.tie(0)

// *start on @date: 2020-02-16 20:14

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

bool cmp(const string &a, const string &b)
{
	return a < b; //按字典序从小到大排列
}

map<string, int> p;

string s[200005], ans[200005];

int main()
{
	int n;
	cin >> n;
	ll maxn = -9999;
	for (int i = 0; i < n; i++)
	{
		cin >> s[i];
		p[s[i]]++;
		if (p[s[i]] > maxn)
			maxn = p[s[i]];
	}
	ll t=0;
	for (int i = 0; i < n; i++)
	{
		if(p[s[i]]==maxn)
		ans[t++]=s[i];
		p[s[i]]--;
	}
	sort(ans,ans+t,cmp);
	for(int i=0;i<t;i++)
	cout<<ans[i]<<endl;
}

Measured memory_bytes: 28288
import java.util.*;

public class Main{
        public static void main(String[] args){
                Scanner scan = new Scanner(System.in);
                int N = scan.nextInt();
                double money[] = new double[N];
                String kind[] = new String[N];
                double res=0;

                for(int i = 0;i<N;i++ ){
                        money[i] = scan.nextDouble();
                        kind[i] = scan.next();
                }

                for(int i = 0;i<N;i++ ){
                        if(kind[i].equals("JPY")){
                                res += money[i];
                        }else{
                                res += money[i]*380000;
                        }
                }
                System.out.println(res);
        }
}

Measured memory_bytes: 21588
n, m = map(int, input().split())
l_max = 0
r_min = float('inf')
for i in range(m):
    l, r = map(int, input().split())
    l_max = max(l_max, l)
    r_min = min(r_min, r)
if r_min >= l_max:
    print(r_min - l_max + 1)
else:
    print('0')


Measured memory_bytes: 3064
// includes {{{
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<tuple>
#include<cmath>
#include<random>
#include<cassert>
// #include<deque>
// #include<multiset>
// #include<bitset>
// #include<cstring>
// #include<bits/stdc++.h>
// }}}
using namespace std;
using ll = long long;

int main() {
  ios::sync_with_stdio(false), cin.tie(0);
  int n, h, w;
  cin >> n >> h >> w;
  cout << (n - h + 1) * (n - w + 1) << endl;
  return 0;
}


Measured memory_bytes: 892
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
int main()
{
    ll X;
    cin >> X;
    ll x5 = X / 500;
    X -= x5 * 500;
    ll x1 = X / 5;

    ll ans = x5 * 1000 + x1 * 5;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
int main(){
    int n;
    cin >> n;
    int answer = 0;

    int table[7];
    int j = 2;
    REP(i,7){
        table[i]=j;
        j*=2;
    }

    FORR(i,6,1){
        if(n < table[i] && n > table[i-1]){
            cout << table[i-1] << endl;
            return 0;
        }
        if(n==table[i]){
            cout << table[i] << endl;
            return 0;
        }
    }
    if(n == 2){
        cout << 2 << endl;
        return 0;
    }

    cout << 1 << endl;
    return 0;
}

Measured memory_bytes: 256
l = list(map(int,input().split()))
ans = 0
l.sort()
a,b,c = l[0],l[1],l[2]
ans += (c-a) // 2 + (c-b) // 2
a = (c-a) // 2 * 2 + a
b = (c-b) // 2 * 2 + b

if a == b and b == c:
  ans += 0
elif a == b and b != c:
  ans += 1
else:
  ans += 2

print(ans)

Measured memory_bytes: 3064
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

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

#define MP make_pair
#define MT make_tuple
#define EACH(i,c) for(auto i: c)
#define SORT(c) sort((c).begin(),(c).end())

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()

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

	int N;
	cin >> N;

	VI A(N);
	REP(i, N) cin >> A[i];

	int ret = 0;
	REP(i, N){
		if(i + 1 == A[A[i] - 1]) ret++;
	}

	cout << ret / 2 << endl;

	return 0;
}


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

int main()
{
	int n,d;
	int X[10][10];
	cin >> n >> d;
	for (int i = 0; i < n; ++i)
	{
		for (int j = 0; j < d; ++j)
		{
			cin >> X[i][j];
		}
	}

	int cnt = 0;

	for (int i = 0; i < n-1; ++i)
	{
		for (int j = i+1; j < n; ++j)
		{
			int temp = 0;
			for (int k = 0; k < d; ++k)
			{
				temp += (X[i][k] -X[j][k]) * (X[i][k] - X[j][k]);
			}

			//cout << temp << endl;

			for (int k = 0; k <= temp; ++k)
			{
				if ((k * k) == temp)
				{
					cnt++;
					//cout << "a";
				}
			}
		}
	}

	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cstdio>

#include<vector>
#include<queue>
#include<set>
#include<map>
#include<string>

#include<algorithm>
#include<cmath>
#include<numeric>

using namespace std;
typedef long long ll;
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;}
const ll INF = 1e18+1;

/*
最大公約数の上界はM

最大公約数は配列すべての要素よりも小さくなるので

M/Nよりも確実に小さくなる

N/Mを下回る最大の整数をとって

公約数gを考えたとして、aiはすべてgの倍数なので
その候補の公約数はMの約数でなくてはならない

M / g の値がN以上なら分配が可能 -> OK

すなわちMの約数の内
g <= M / N なるものの最大値を取ればよい


*/
vector<ll> divisor(ll n) {
  vector<ll> ret;
  for(ll i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}

int main() {
    int N, M;
    cin >> N >> M;
    vector<ll> div = divisor(M);
    ll X = M / N;
    for (ll i = div.size()-1; i >= 0; i--) {
        if (div[i] <= X) {
            cout << div[i] << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int INF = 1LL<<55;
int Max(int &a,int b){return a=max(a,b);}
int Min(int &a,int b){return a=min(a,b);}
int M[5][5];
int X[20],Y[20];
int cnt;
void ume(int y,int x){
  X[cnt] = x+2;
  Y[cnt++] = y+2;
}

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

int filter(int y,int x,int M[5][5]){
  
  int bit = 0;
  for(int i=0;i<7;i++){
    int ny = y + dy[i];
    int nx = x + dx[i];
    if(ny<0||nx<0||ny>=5||nx>=5) return 0;
    if(M[ny][nx] == -1) return 0;
    bit += (M[ny][nx]<<i);
  }
  return fil[bit];
}

void sim(){
  int tmp[5][5];
  for(int i=0;i<5;i++)for(int j=0;j<5;j++) tmp[i][j] = M[i][j];
  for(int i=0;i<19;i++) M[Y[i]][X[i]] = filter(Y[i],X[i],tmp);
}

signed main(){
  memset(M,-1,sizeof(M));
  ume(-1,0);
  ume(-1,1);
  ume(0,-1);
  ume(0,0);
  ume(0,1);
  ume(1,0);
  ume(1,-1);

  ume(2,0);
  ume(1,1);
  ume(0,2);
  ume(-1,2);
  ume(-2,2);
  ume(-2,1);
  ume(-2,0);
  ume(-1,-1);
  ume(0,-2);
  ume(1,-2);
  ume(2,-2);
  ume(2,-1);

  while(1){
    int ans = true;
    for(int i=0;i<128;i++){
      char ch;
      cin>>ch;
      if(ch == '#')return 0;
      fil[i] = ch == '1'; 
    }
    for(int i=0;i<(1LL<<19) && ans;i++){
      for(int j=0,t=i;j<19;j++,t/=2) M[Y[j]][X[j]]  = t%2;
      int a,b;
      sim();
      a = M[2][2];
      sim();
      b = M[2][2];
      ans &= (a == b);
    }
    cout<<(ans? "yes":"no")<<endl;
  }
  return 0;
}

Measured memory_bytes: 3068
#include <stdio.h>

int main(void) 
{
	int		a, b;
	char	op;
	int		num;
	
	while(op != '?')
	{
		scanf("%d %c %d", &a, &op, &b);
		if(op == '+')
		{
			num = a + b;
		}
		else if(op == '-')
		{
			num = a - b;
		}
		else if(op == '*')
		{
			num = a * b;
		}
		else if(op == '/')
		{
			num = a / b;
		}
		else
		{
			break;	
		}
		printf("%d\n", num);
	}

	return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#pragma GCC target ("avx2")
#pragma GCC optimization ("unroll-loops")
#define rep(i, n) for(int i=0;i<(int)(n);++i)
template <typename T> ll gcd(T a, T b) {return b?gcd(b, a%b):a;}
template <typename T> ll lcm(T a, T b) {return a * b / gcd(a, b);};
template <typename T> inline void chmin(T &a, const T& b){if(a>b)a=b;}
template <typename T> inline void chmax(T &a, const T& b){if(a<b)a=b;}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int grid[3][3];
  bool ans[3][3] = {false};
  rep(i, 3) {
    rep(j, 3) {
      cin >> grid[i][j];
    }
  }
  int n;
  cin >> n;
  vector<int> b(n);
  for (int i = 0; i < n; ++i) {
    cin >> b[i];
  }
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < 3; ++j) {
      for (int k = 0; k < 3; ++k) {
        if (grid[j][k] == b[i]) {
          ans[j][k] = 1;
        }
      }
    }
  }
  bool flag = false;
  for (int i = 0; i < 3; ++i) {
    if (ans[0][i] && ans[1][i] && ans[2][i]) {
      flag = true;
    }
    if (ans[i][0] && ans[i][1] && ans[i][2]) {
      flag = true;
    }
    
  }
  if (ans[0][0] && ans[1][1] && ans[2][2]) {
    flag = true;
  }
  if (ans[0][2] && ans[1][1] && ans[2][0]) {
    flag = true;
  }
  if (flag) cout << "Yes" << '\n';
  else cout << "No" << '\n';
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n) for(ll i=0; i<ll(n); i++)
#define REPR(i, n) for(ll i=n-1; i>=0; i--)
#define FOR(i, m, n) for(ll i=m; i<ll(n); i++)
#define ALL(v) v.begin(), v.end()
#define SIZE(x) ll(x.size()) 
using P = pair<int, int>;
const int INF = 2e9;

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n; string s;
  cin >> n >> s;
  int left = 0;
  int right = n-1;
  int cnt = 0;
  while(left<right){
    while(s[left]=='R' && left<n) left++;
    while(s[right]=='W' && right!=0) right--;
    if(left>=right) break;
    s[left] = 'R';
    s[right] = 'W';
    cnt++;
  }
  cout << cnt << endl;
  return 0;
}


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

int main() {
	int X;
	int N;
	map<int,bool> appeared;
	cin>>X>>N;
	for(int i=0;i<N;i++){
		int temp;
		cin>>temp;
		appeared[temp]=true;
	}
	for(int d=0;d<=X;d++){
		int temp;
		temp = X - d;
		if(!appeared[temp]){
			cout<<temp<<endl;
			break;
		}
		temp = X + d;
		if(!appeared[temp]){
			cout<<temp<<endl;
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 3608
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
template<class T> bool INRANGE(T x,T a,T b) { return a<=x&&x<=b; }
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;
}

#define REP(i,n) for(int i=0;i<(n);++i)
#define RREP(i,n) for(int i=(n);i>=0;--i)
#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 ALL(v) (v).begin(),(v).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
                      << " " << __FILE__ << endl;


typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

int main()
{
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    int N, M;
    cin >> N >> M;
    int a;
    vector<pair<ll,ll>> v(N+M);
    REP(i,N) {
        cin >> a;
        v[i] = {a,1};
    }
    int b, c;
    REP(i,M) {
        cin >> b >> c;
        v[N+i] = {c,b};
    }
    sort(ALL(v),greater<>());
    ll ans = 0;
    int num = 0;
    REP(i,N){
        
        num += v[i].second;
        if (num >= N){
            int nokori = N-(num-v[i].second);
            //cout << N << " - " << num-v[i].second << endl;
            ans += v[i].first * nokori;
            //cout << v[i].first * nokori << endl;
            //cout << v[i].first << " * " << nokori << endl;
            break;
        }
        ans += v[i].first * v[i].second;
        //cout << v[i].first * v[i].second << endl;
        //cout << v[i].first << " * " << v[i].second << endl;
    }

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

Measured memory_bytes: 3456
#include<bits/stdc++.h>
using namespace std;
vector<int> d;
bool ok(int n){
    while(n){
        int r=n%10;
        for(int i=0;i<d.size();i++){
            if(r==d[i]){return false;}
        }
        n/=10;
    }
    return true;
} 
int main(){
    int n,k;
    cin>>n>>k;
    d.resize(k);
    for(int i=0;i<k;i++){
        cin>>d[i];
    }

    while(n<100000){
        if(ok(n)){cout<<n<<endl;return 0;}
        n++;
    }
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    var (n,m,x) = readLine()!!.split(" ").map(String::toInt).toMutableList()
    var A = readLine()!!.split(" ").map(String::toInt).toMutableList()
    var r = A.filter{it<x}.size
    var l = A.filter{it>x}.size
    println(Math.min(r,l))
}

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

from collections import Counter

N = int(input())
A = [int(x) for x in input().split()]

x = min(A)
y = max(A)

if x == y:
    # 全員がnon-uniqueな色 or 全員がuniqueな色
    bl = (x <= N//2) or (x == N-1)
elif y != x + 1:
    bl = False
else:
    a = A.count(x)
    b = A.count(y)
    # a人：unique color
    # b人：non-unique color
    # b人でc種類あるとする
    c = y - a
    bl = (1 <= c <= b//2)

answer = 'Yes' if bl else 'No'
print(answer)

Measured memory_bytes: 14132
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s; cin >> s;
  if(s == "SUN") cout<<7;
  else if(s == "MON")cout<<6;
  else if(s=="TUE") cout<<5;
  else if(s=="WED")cout<<4;
  else if(s=="THU")cout<<3;
  else if(s=="FRI")cout<<2;
  else cout<<1;
  cout<<endl;
}

Measured memory_bytes: 256
import java.util.*;
import static java.lang.System.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(in);
        int n=sc.nextInt();
        long k=sc.nextLong();
        long[] c=new long[100001];
        for (int i = 0; i < n; i++) {
            int a=sc.nextInt();
            int b=sc.nextInt();
            c[a]+=b;
        }
        long temp=0;
        for (int i = 0; i < 100001; i++) {
            temp+=c[i];
            if(temp>=k){
                out.println(i);
                break;
            }
        }
    }
}

Measured memory_bytes: 87008
using System;

public class Test
{
    public static void Main()
    {
        int a, b, c;
        string[] str = Console.ReadLine().Split(' ');
        a = int.Parse(str[0]);
        b = int.Parse(str[1]);
        c = int.Parse(str[2]);

        if (c > b && b > a)
        {
            Console.WriteLine("{0} {1} {2}", a, b, c);
        }

        if (b > c && c > a)
        {
            Console.WriteLine("{0} {1} {2}", a, c, b);
        }

        if (a > c && c > b)
        {
            Console.WriteLine("{0} {1} {2}", b, c, a);
        }

        if (c > a && a > b)
        {
            Console.WriteLine("{0} {1} {2}", b, a, c);
        }

        if (b > a && a > c)
        {
            Console.WriteLine("{0} {1} {2}", c, a, b);
        }

        if (a > b && b > c)
        {
            Console.WriteLine("{0} {1} {2}", c, b, a);
        }

        if (a == b && b == c)
        {
            Console.WriteLine("{0} {1} {2}", a, a, a);
        }

        if (a == b && b > c)
        {
            Console.WriteLine("{0} {1} {2}", c, a, a);
        }

        if (a == b && c > b)
        {
            Console.WriteLine("{0} {1} {2}", a, a, c);
        }

        if (a > c && b == c)
        {
            Console.WriteLine("{0} {1} {2}", b, b, a);
        }

        if (c > a && b == c)
        {
            Console.WriteLine("{0} {1} {2}", a, b, b);
        }

        if (b > a && a == c)
        {
            Console.WriteLine("{0} {1} {2}", a, c, b);
        }

    }
}


Measured memory_bytes: 15944
#include <iostream>

using namespace std;

int s[101][101];

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int r, c, t;
	cin>>r>>c;
	for(int i=0; i<r; ++i) {
		for(int j=0; j<c; ++j) {
			cin>>t;
			s[i][j]=t;
			s[r][j]+=t;
			s[i][c]+=t;
			s[r][c]+=t;
		}
	}
	for(int i=0; i<=r; ++i) {
		for(int j=0; j<=c; ++j) {
			if(j) cout<<' ';
			cout<<s[i][j];
		}
		cout<<'\n';
	}
	return 0;
}



Measured memory_bytes: 3176
from random import*
seed()
dd = ((-1, 0), (-1, -1), (0, -1), (1, -1), (1, 0), (1, 1), (0, 1), (-1, 1))
def make(C, rest, r=randint):
    p, q = C
    M = [[p]*100 for i in range(50)]
    while rest:
        x = r(1, 98)
        y = r(1, 48)
        if M[y][x] == q:
            continue
        for dx, dy in dd:
            if M[y+dy][x+dx] == q:
                break
        else:
            M[y][x] = q
            rest -= 1
    return map("".join, M)
A, B = map(int, input().split())
print(100, 100)
print(*make(".#", B-1), sep='\n')
print(*make("#.", A-1), sep='\n')

Measured memory_bytes: 5352
def main():
    n = int(input())
    a = list(map(int, input().split()))
    q = int(input())
    ans = [None]*q
    sm = sum(a)
    dic = {}
    for i in range(n):
        if a[i] in dic:
            dic[a[i]] += 1
        else:
            dic[a[i]] = 1
    for i in range(q):
        b, c = map(int, input().split())
        if b in dic:
            x = dic[b]
            dic[b] = 0
            df = c - b
            sm += df * x
            ans[i] = sm
            if c in dic:
                dic[c] += x
            else:
                dic[c] = x
        else:
            ans[i] = sm
    for v in ans:
        print(v)

if __name__ == "__main__":
    main()

Measured memory_bytes: 21048
#include<bits/stdc++.h>
using namespace std;
#define ios ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define ll long long
int main()
{
    ios;
    char c;
    cin>>c;
    if(c=='A')
        cout<<"T"<<endl;
    else if(c=='T')
        cout<<"A"<<endl;
    else if(c=='G')
        cout<<"C"<<endl;
    else
        cout<<"G"<<endl;


}










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

bool linearSearch(vector<int> S, int key) {
    bool ok = false;
    for (int i = 0; i < S.size(); i++) {
        if (S.at(i) == key) {
            ok = true;
            break;
        }
    }

    return ok;
}

int main() {
    int n;
    cin >> n;
    vector<int> S(n);
    for (int i = 0; i < n; i++) {
        cin >> S.at(i);
    }
    
    int q;
    cin >> q;
    int count = 0;
    for (int i = 0; i < q; i++) {
        int key;
        cin >> key;
        if (linearSearch(S, key)) {
            count++;
        }
    }

    cout << count << endl;
}


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

int main(){
    int K,S;
    cin >> K >> S;
    int ans;

    for(int i=0;i<=K;i++){
        for(int j=0;j<=K;j++){
            if((i+j<=S)&&(i+j+K>=S)) ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

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

int n, a[100005], cnt[4005];

int main(){
  
  cin>>n;
  
  for(int i=0;i<n;i++){
    string s;
    cin>>s;
    a[i]=stoi(s[0]+s.substr(2,3));
    cnt[a[i]]++;
  }
  
  for(int i=1;i<4005;i++) cnt[i]+=cnt[i-1];
  
  for(int i=0;i<n;i++) printf("%d\n", cnt[a[i]-1]*3+cnt[a[i]]-cnt[a[i]-1]-1);
  
  return 0;
}

Measured memory_bytes: 3672
'use strict'

const main = (input) => {
    input = input.split('\n').map(i => parseInt(i))
    const A = input[0]
    const B = input[1]
    const C = input[2]
    const D = input[3]

    console.log(Math.min(A, B) + Math.min(C, D))
}

main(require('fs').readFileSync('/dev/stdin', 'utf-8'))

Measured memory_bytes: 7372
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	string s;
	int b=0;
	cin>>n>>s;
	for(int i=0;i<n;i++)
	{
		if(s[i]=='R')
		b++;
		else
		b--;
	}
	if(b>0)
	cout<<"Yes";
	else
	cout<<"No";
	return 0;
} 

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

int main()
{
	int a, b;
	cin >> a >> b;
	if (a > b) {
		cout << "a > b" << endl;
	}if (a < b) {
		cout << "a < b" << endl;
	}
	if(a == b) {
		cout << "a == b" << endl;
	}
	getchar();
}



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

using namespace std;

long long xorsum(long long in) {
  if (in % 4 == 0) {
    return in;
  }
  
  if (in % 4 == 1) {
    return in ^ (in - 1);
  }
  
  if (in % 4 == 2) {
    return in + 1;
  }
  
  if (in % 4 == 3) {
    return 0;
  }
}

int main() {
  long long A, B;
  
  cin >> A >> B;
  
  cout << (xorsum(B) ^ xorsum(A - 1)) << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <bitset>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B;
string S, T;
//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
typedef pair<ll,ll> P;

class union_find{
        vector<long> parent, tree_size, w_size;
    public:
        union_find(unsigned long _n) : parent(_n), tree_size(_n, 1), w_size(_n, 0){
            for(unsigned long i = 0; i < _n; ++i)parent[i] = i;
        }
        void init(vector<string> g, int h, int w){
            rep(i, h) rep(j,w) if(g[i][j] == '.') w_size[i*w + j] = 1;
        }
        ll find(ll x){
            while(parent[x] != x)x = parent[x] = parent[parent[x]];
            return x;
        }
        void merge(ll a, ll b){
            a = find(a);
            b = find(b);
	        if(a==b) return;
            if(tree_size[a] < tree_size[b])swap(a, b);
            tree_size[a] += tree_size[b];
            w_size[a] += w_size[b];
            parent[b] = a;
            return;
        }
	    bool same(ll a, ll b){
	        a = find(a);
	        b = find(b);
	        return a == b;
	    }
	    ll white(ll a){
            return w_size[find(a)];
        }
    };
//uf.mergeのように使う
//ufはMAX_N+1でとるか、代入時に0-indexedにする

int main(){
    cin>>H>>W;
    vector<string> G(H);
    rep(i,H) cin>>G[i];
    union_find uf(H * W);
    uf.init(G, H, W);
    vec dh = {-1, 0, 1, 0}, dw = {0, -1, 0, 1};
    rep(h,H){
        rep(w, W){
            rep(i,4){
                ll nh = h + dh[i], nw = w + dw[i];
                if(nh >= 0 && nh < H && nw >= 0 && nw < W){
                    if(G[h][w] != G[nh][nw]) uf.merge(h*W + w, nh*W + nw);
                }
            }
        }
    }
    ll ans = 0;
    rep(h,H){
        rep(w, W){
            if(G[h][w] == '#') ans += uf.white(h*W + w);
        }
    }
    cout<<ans<<endl;
}

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

bool IsEven(int x){
  if(x%2==0)return true;
  else return false;
}

int main(){
  int N;
  cin>>N;
  int A[100010];
  for(int i=0;i<N;i++)cin>>A[i];

  int EvenCnt=0;
  int OddCnt=0;
  for(int i=0;i<N;i++){
    if(IsEven(A[i]))EvenCnt++;
    else OddCnt++;
  }

  if(IsEven(OddCnt)==true || OddCnt==0)cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
  return 0;
}


Measured memory_bytes: 640
#include<string>
#include<iostream>
#include<algorithm>
#include<set>
#include<unordered_set>
#include<math.h>
#include<vector>
#include<sstream>
#include<queue>
#include<functional>
#include<bitset>
#include<cstdio>
#include<iomanip>
#include<stack>
#include <cstring>
#include <climits>
using namespace std;
#define rep(i,n) for(int (i)=0;(i) < (n); (i)++)
#define rrep(f,i,n) for(int (i)=0;(i) < (f); (i)++)
#define FIND(v, k) find((v).begin(), (v).end(), k)
#define mset(a,x) memset(a,x,sizeof(a))

#define MAX 101
#define MAX_V 15
int a[1000000];
int main()
{
	int a, b;
	cin >> a >> b;
	if ((a + b) < 3) {
		cout << "Impossible" << endl;

	}
	else if (a % 3 == 0 || b % 3 == 0 || ((a + b) % 3 == 0)) {
		cout << "Possible" << endl;
	}
	else {
		cout << "Impossible" << endl;

	}
	return 0;
}



Measured memory_bytes: 256
#!/usr/bin/python
# -*- coding: utf-8 -*-
import sys
import math
import collections

N, Q = map(int, sys.stdin.readline().rstrip().split(" "))
s = sys.stdin.readline().rstrip()
s = "+" + s + "+"

halls = [[0, 0], [N + 1, N + 1]]

tds = []
for _ in range(Q):
    t, d = sys.stdin.readline().rstrip().split(" ")
    tds.append([t, d])
for t, d in reversed(tds):
    # print(t, d)
    # print(halls)
    for hall in halls:
        if d == "L":
            if s[hall[0]] == t:
                if hall[0] != 1:
                    hall[0] += 1
            if hall[1] != (N+1) and s[hall[1] + 1] == t:
                hall[1] += 1
        if d == "R":
            if hall[0] != 0 and s[hall[0] - 1] == t:
                hall[0] -= 1
            if s[hall[1]] == t:
                if hall[1] != (N + 1):
                    hall[1] -= 1
assert halls[0][1] >= halls[0][0]
assert halls[1][1] >= halls[1][0]
print(N - ((halls[0][1] - halls[0][0]) + (halls[1][1] - halls[1][0])))

#     if d == "L":
#         current[t] -= 1
#     else:
#         current[t] += 1
#     movings[t]["L"] = min(movings[t]["L"], current[t])
#     movings[t]["R"] = max(movings[t]["R"], current[t])
# print(movings)
# count = 0
# print(s)
# for i, c in enumerate(s):
#     print(c)
#     print(i + movings[c]["L"])
#     print(i + movings[c]["R"])
#     if i + movings[c]["L"] < 0:
#         continue
#     if i + movings[c]["R"] >= N:
#         continue
#     count += 1
# print(count)

exit(0)


Measured memory_bytes: 24052
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>

#define FOR(i, a, b) for (int i = (a); i < int(b); ++i)
#define RFOR(i, a, b) for (int i = (b)-1; i >= int(a); --i)
#define REP(i, n) FOR(i, 0, n)
#define REP1(i, n) FOR(i, 1, int(n) + 1)
#define RREP(i, n) RFOR(i, 0, n)
#define RREP1(i, n) RFOR(i, 1, int(n) + 1)
#define ALL(c) begin(c), end(c)

int _ = (
#ifndef LOCAL
    std::cin.tie(nullptr), std::ios::sync_with_stdio(false),
#endif
    std::cout.precision(10), std::cout.setf(std::ios::fixed));

using ll = long long;
using ull = unsigned long long;
using ld = long double;
template <typename T> using vec = std::vector<T>;
using namespace std;

ll solve(ll A, ll B, ll C, ll d) {
  if (A % 2 == 1 || B % 2 == 1 || C % 2 == 1) {
    return d;
  } else if (A == B && B == C && C == A) {
    return -1;
  } else {
    const ll A2 = A / 2, B2 = B / 2, C2 = C / 2;
    return solve(B2 + C2, C2 + A2, A2 + B2, d + 1);
  }
}

int main() {
  ll A, B, C;
  cin >> A >> B >> C;
  cout << solve(A, B, C, 0) << endl;
  return 0;
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n); i >= 0; i--)
#define sz(x) int(x.size())
#define all(x) (x).begin(), (x).end()
#define INF 2e9
typedef long long ll;
typedef pair<int, int> P;

int main() {
    int n, m; cin >> n >> m;
    vector<int> x(m);
    rep(i, m) cin >> x[i];
    sort(all(x));
    if (m <= n) {
        cout << 0 << endl;
        return 0;
    }
    vector<int> y(m-1); //間隔
    ll sum = 0;
    rep(i, m-1) {
        y[i] = x[i+1] - x[i];
        sum += y[i];
    }
    sort(all(y));
    rep(i, n-1) {
        sum -= y[m-2-i];
    }

    cout << sum << endl;

}

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

int main(){
    int n;
    cin >> n;
    vector<int> h(n);
    REP(i, n) cin >> h[i];
    int ans = 1;

    for (int i = 1; i < n; i++){
        bool ok = true;
        for (int j = 0; j < i; j++){
            if (h[j] > h[i]){
                ok = false;
                break;
            }
        }
        if (ok) ans++;
    }

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


Measured memory_bytes: 256
public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		java.util.Scanner sc = new java.util.Scanner(System.in);

		String[] data = sc.nextLine().split(" ");
		int n = Integer.parseInt(data[0]);
		int m = Integer.parseInt(data[1]);

		int[][] A = new int[n][m];
		int[] v = new int[m];

		for (int i=0; i<n; i++) {
			data = sc.nextLine().split(" ");

			for (int j=0; j<m; j++) {
				A[i][j] = Integer.parseInt(data[j]);
			}
		}

		for (int i=0; i<m; i++) {
			v[i] = sc.nextInt();
		}

		for (int i=0; i<n; i++) {

			int sum = 0;
			for (int j=0; j<m; j++) {
				sum += A[i][j] * v[j];
			}

			System.out.println(sum);

		}
	}

}

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

int main() {
	int c1, c2, c3;

	while (cin >> c1) {
		cin >> c2 >> c3;

		int hand = c1 + c2;

		int count = 0;
		for (int i = 1; i <= 10; ++i) {
			if (i == c1 || i == c2 || i == c3) continue;
			if (hand + i <= 20) ++count;
		}

		//cout << 1.0f*count / 7 << endl;
		if (1.0f*count / 7 >= 0.50f) cout << "YES" << endl;
		else cout << "NO" << endl;
	
	}
	return 0;
}

Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
#define lson root<<1,l,midd
#define rson root<<1|1,midd+1,r
#define pb push_back
#define ull unsigned long long
#define pii pair<int,int>
#define MP make_pair
typedef long long ll;
const ll INF=1e18;
const int inf=0x3f3f3f3f;
const int M=1e6+6;
int main(){
    ll D,T,S;
    cin>>D>>T>>S;
    if(T*S>=D)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 3644
#include <iostream>
#include <cstdlib>
#include <string>
#include <algorithm>
using namespace std;
int main(){
  int x;
  cin >> x;
  int max=1;

  int bb;
  for(int b=1;b<=31;b++){
    bb=b*b;
    if((x>=bb) && (bb>max)){max=bb;}
  }
  for(int b=1;b<=10;b++){
    bb=b*b*b;
    if((x>=bb) && (bb>max)){max=bb;}
  }
  for(int b=1;b<=5;b++){
    bb=b*b*b*b;
    if((x>=bb) && (bb>max)){max=bb;}
  }
  for(int b=1;b<=3;b++){
    bb=b*b*b*b*b;
    if((x>=bb) && (bb>max)){max=bb;}
  }
  for(int b=1;b<=3;b++){
    bb=b*b*b*b*b*b;
    if((x>=bb) && (bb>max)){max=bb;}
  }
  for(int b=2;b<=2;b++){
    bb=b*b*b*b*b*b*b;
    if((x>=bb) && (bb>max)){max=bb;}
  }
  for(int b=2;b<=2;b++){
    bb=b*b*b*b*b*b*b*b;
    if((x>=bb) && (bb>max)){max=bb;}
  }
  for(int b=2;b<=2;b++){
    bb=b*b*b*b*b*b*b*b*b;
    if((x>=bb) && (bb>max)){max=bb;}
  }
  cout << max << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define dhoom ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);  
typedef long long ll;
typedef long double ld;
const ll inf = 1e18;
const int nax = 2e6 + 7;
const ll mod = 1e9 + 7;
//ll tree[4 * nax];
//9uS-22RSwk7gQqh
//int t[100005] , x[100005] , y[100005];
ll exp(ll a , ll b){
	if(b == 0)	return 1;
	int x = b % 2 == 0 ?   ((exp(a , b/2)%mod)*(exp(a , b / 2)%mod))%mod :  (a%mod*exp(a , b - 1) % mod)%mod;
	return x;
}
ll dp[nax];
int main(){
	dhoom;
	ll n , k;
	cin >>n >> k;
	ll ans = 0;
	for(int i = k ; i >= 1 ; i--){
		dp[i] = (k / i); // that much multiples are there for i 
		dp[i] = exp(dp[i],n);
		for(int j = 2 * i ; j <= k ; j+=i){
			dp[i] = (dp[i] - dp[j] + mod)%mod;
		}
	//	cout << dp[i] << " " << i << endl;
		ans = ans + dp[i]*i;
		//cout << ans << endl;
		ans %= mod;
	}
	cout << ans << endl;
	return 0;
	
}

Measured memory_bytes: 4376
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <iomanip>

using namespace std;
int bitcount(int N){
   int ans =0;
   while(N!=0){
      ans++;
      N&=N-1;
   }
   return ans;
}
int main(){
   int H,W,K;
   cin >> H >> W >> K;
   string S[H];
   for(int i = 0 ; i < H; i++){
      cin >> S[i];
   }
   int minans=INT_MAX/2;
   for(int mask = 0 ; mask <(1<<(H-1)); mask++){
      int ans = bitcount(mask);
      //cout << mask << ", " << ans << endl;
      int size = ans+1;
      int cnt[size][2];
      memset(cnt,0,sizeof(cnt));
      for(int col = 0 ; col < W; col++){
         bool ok = true;
         int cur = 0;
         for(int j = 0 ; j < H; j++){
            cnt[cur][1]+=S[j][col]-'0';
            if(cnt[cur][0]+cnt[cur][1]>K) ok=false;
            if((mask&(1<<j))!=0) cur++;
         }
         if(ok){
            //cout << "ok"<< endl;
            for(int i = 0 ; i < size; i++){
               cnt[i][0]+=cnt[i][1];
               cnt[i][1]=0;
            }
         }
         else{
            //cout << "ng"<< endl;
            bool br = false;
            for(int i = 0 ; i < size; i++){
               cnt[i][0]=cnt[i][1];
               cnt[i][1]=0;
               if(cnt[i][0]>K){
                  ans = INT_MAX/2;
                  br = true;
               }
            }
            if(br) break;
            else ans +=1;
         }
      }
      //cout << mask << ", " << ans << endl;
      minans = min(ans,minans);
   }
   cout << minans << endl;
   return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define RREP(i, n) for (int i = n - 1; 0 <= i; i--)
#define FOR(i, start, end) for (int i = start; i < end; i++)
#define RFOR(i, start, end) for (int i = start - 1; 0 <= i; i--)
#define ALL(a) a.begin(), a.end()
using ll = long long;
using namespace std;
constexpr int INF32       = 1'050'000'000;
constexpr long long INF64 = 4'000'000'000'000'000'000;
constexpr int MOD7        = 1'000'000'007;
constexpr int MOD9        = 1'000'000'009;
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;
}
void print() { std::cout << '\n'; }
template <class H, class... T> void print(H &&head, T &&... args) {
    std::cout << head;
    sizeof...(args) == 0 ? std::cout << "" : std::cout << ' ';
    print(std::forward<T>(args)...);
}
template <class T> void print(std::vector<T> &v) {
    for (int i = 0; i < v.size(); i++) {
        std::cout << v[i];
        i == v.size() - 1 ? std::cout << '\n' : std::cout << ' ';
    }
}
template <class T> void print(std::vector<std::vector<T>> &v) {
    for (int i = 0; i < v.size(); i++) {
        for (int j = 0; j < v[i].size(); j++) {
            std::cout << v[i][j];
            j == v[i].size() - 1 ? std::cout << '\n' : std::cout << ' ';
        }
    }
}
void scan() {}
template <class H, class... T> void scan(H &&head, T &&... args) {
    std::cin >> head;
    scan(std::forward<T>(args)...);
}
template <class T> void scan(std::vector<T> &v) {
    for (auto &&i : v) {
        scan(i);
    }
}

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

    int a, b;
    scan(a, b);

    int ans = max(a - 2 * b, 0);
    print(ans);

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
typedef pair<int,int> Pint;
typedef pair<ll, int> P;
//typedef tuple<int,int,int> T;
ll INFL = 1000000000000000010;//10^18 = 2^60
int INF = 2147483600;//10^9
ll MOD  = 1000000007;


int d[10][10];

void warshall_floyd(){
    for(int k = 0; k < 10; k++){
        for(int i = 0; i < 10; i++){
            for(int j = 0; j < 10; j++){
                d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
            }
        }
    }
}



int main(void){
    int H,W;
    cin >> H >> W;
    for(int i = 0; i < 10; i++){
        for(int j = 0; j < 10; j++){
            cin >> d[i][j];
        }
    }
    warshall_floyd();
    int ans = 0;
    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
            int a;
            cin >> a;
            if(a == -1) continue;
            ans += d[a][1];
        }
    }
    cout << ans << endl;
}


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

const long MOD=998244353;
const long INF=100000000000000000;
int main(){
    long N;
    cin>>N;
    vector<long> a(N);
    for(int i=0;i<N;i++) cin>>a.at(i);
    
    vector<long> stack(100100,0);
    for(int i=0;i<N;i++){
        for(int j=0;j<3;j++) stack.at(a.at(i)+j)++;
    }
    
    long ans=0;
    for(int i=0;i<100100;i++) ans=max(ans,stack.at(i));
    
    cout<<ans<<endl;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std ;
#define rep(i,a,n) for(int i =a;i<n;i++)
#define ios ios_base::sync_with_stdio(0);cin.tie(0);

int main(){
	ios;
	int n,s=0;
	cin>>n;
	int b[n-1],a[n]={0};
	rep(i,0,n-1)
	{cin>>b[i];
	}
	a[0]=b[0];
	rep(i,1,n-1)
	{if(b[i-1]>=b[i])
	{a[i]=b[i];
	}
	else a[i]=b[i-1];
	}
	a[n-1]=b[n-2];
	rep(i,0,n)
	{s+=a[i];
	}
	cout<<s<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<queue>
#include<utility>
using namespace std;
int main () {
  int N, M;
  cin >> N >> M;
  vector<pair<int, int>>H(N);
  vector<queue<int>>roa(N);
  vector<int>H_(N);
  vector<int>si(N, 0);
  vector<int>good(N, -1);
  int ans = 0;
  for (int i = 0; i < N; i ++) {
    cin >> H_[i];
    H[i] = make_pair(H_[i], i);
  }
  for (int i = 0; i < M; i ++) {
    int a, b;
    cin >> a >> b;
    a --;
    b --;
    roa[a].push(b);
    roa[b].push(a);
    si[a] ++;
    si[b] ++;
  }
  sort(H.begin(), H.end());
  reverse(H.begin(), H.end());
  for (int i = 0; i < N; i ++) {
    int i_ = H[i].second;
    if (good[i_] == 1) continue;
    for (int j = 0; j < si[i_]; j ++) {
      int u = roa[i_].front();
      roa[i_].pop();
      roa[i_].push(u);
      if (H_[i_] < H_[u]) good[i_] = 0;
      if (H_[i_] > H_[u]) good[u] = 0;
      if (H_[i_] == H_[u]) good[i_] = good[u] = 0;
    }
    if (good[i_] == -1) good[i_] = 1;
  }
  for (int i = 0; i < N; i ++) ans += good[i];
  cout << ans << endl;
}



Measured memory_bytes: 72620
#include <iostream>
#include <string>
#include <queue>
#include <vector>
using namespace std;

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

int a[61][61];
int d[2][61][61];

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

struct node{
    bool left;
    int dist;
    int x,y;
    node(bool l,int d,int x,int y) : left(l), dist(d), x(x), y(y) {;}
};

bool operator<(const node &n,const node &m) {
    return n.dist > m.dist;
}

int main() {
    int w,h;
    while(cin>>w>>h) {
        if(h == 0 && w == 0) break;

        rep(i,61) rep(j,61) d[0][i][j] = d[1][i][j] = 1<<29;
        string s;
        rep(i,h)
            rep(j,w) {
            cin>>s;
            if(s[0] >= '0' && s[0] <= '9') a[i][j] = s[0] - '0';
            else if(s[0] == 'X') a[i][j] = -1;
            else if(s[0] == 'S') a[i][j] = -2;
            else a[i][j] = -3;
        }

        // rep(i,h) {
        //     rep(j,w) cout<<a[i][j]<<" ";
        //     cout<<endl;
        // }

        priority_queue<node> q;
        rep(i,h) rep(j,w) {
            if(a[i][j] == -2) {
                q.push(node(1,0,i,j));
                q.push(node(0,0,i,j));
                d[0][i][j] = d[1][i][j] = 0;
            }
        }

        while(!q.empty()) {
            int x = q.top().x, y = q.top().y;
            int di = q.top().dist,leg = q.top().left^1;
            q.pop();

            rep(i,9) {
                int nx = x + dx[leg][i], ny = y + dy[leg][i];
                if(nx < 0 || nx >= h || ny < 0 || ny > w-1) continue;
                if(a[nx][ny] == -1) continue;
                int pp = (a[nx][ny] == -2 || a[nx][ny] == -3) ? 0 : a[nx][ny];
                if(d[leg][nx][ny] > di + pp) {
                    d[leg][nx][ny] = di + pp;
                    q.push(node(leg,di+pp,nx,ny));
                }
            }
        }

        int ans = 1<<29;
        rep(i,h) rep(j,w) {
            if(a[i][j] != -3) continue;
            ans = min(ans, min(d[0][i][j], d[1][i][j]));
        }

        cout<<((ans==(1<<29))? -1 : ans)<<endl;
    }
}

Measured memory_bytes: 992
#include <bits/stdc++.h>
 
using namespace std;
 
const int MOD=1e9+7;
 
int main(){
 
	int n; 
	long long int k;
	cin>>n>>k;
 
	int A[n],i,tot=0;
	set<int> S;
	vector<int> Q;
	for( i=0;i<n;i++)
	{
		 cin>>A[i];
		 A[i]=A[i]-1;
	}
 

 
	while(S.find(tot)==S.end())
	{
		S.insert(tot);
		Q.push_back(tot);
		tot=A[tot];
	}
 
	int st=-1;
	int ed=Q.size();
 
	for( i=0;i<Q.size();i++)
	{
		if(Q[i]==tot){
			st=i;
			break;
		}
	}
 
	if(k<Q.size())
	{
		cout<<Q[k]+1<<endl;
	}
	else{
		int d=ed-st;
		
		long long int r=(k-st)%d;
		
		cout<<Q[st+r]+1<<endl;
	}
 
	return 0;
} 

Measured memory_bytes: 13876
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String s = scanner.nextLine();
        long n = Long.parseLong(s);

        long fact = 0;
        for (int i = 0; i < s.length(); i++) {
            fact += s.charAt(i) - '0';
        }
        if (n % fact == 0) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 21844
//↓見なくていいよ！ここから--------------------------------------------------
var read = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});
var obj;
var inLine = [];
read.on('line', function(input){inLine.push(input);});
read.on('close', function(){
  obj = init(inLine);
  console.error("\n");
  var start = Date.now();
  Main();
  var end = Date.now() - start;
  myerr("time : " + (end) + "ms");
  myerr("memory : " + Math.round(process.memoryUsage().heapTotal / 1024) + "KB");
});
function makeClone(obj){return JSON.parse(JSON.stringify(obj));}
function nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}
function nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();}
function init(input){  
  var returnObj = {
    list : input, index : 0, max : input.length,
    hasNext : function(){return (this.index < this.max);},
    next : function(){if(!this.hasNext()){throw "ArrayIndexOutOfBoundsException これ以上ないよ";}else{var returnInput = this.list[this.index];this.index++;return returnInput;}}
  };
  return returnObj;
}
function myout(s){console.log(s);}
function myerr(s){console.error("debug:" + require("util").inspect(s,false,null));}
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す 1:数値へ変換
//2:半角SPで分割 4:半角SPで分割し、数値配列へ
//6:1文字で分割  7:1文字で分割し、数値配列へ
//8:半角SPで結合 9:改行で結合 0:文字なしで結合
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map(Number);case 6:return i.split("");case 7:return i.split("").map(Number);case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}

//↑見なくていいよ！ここまで--------------------------------------------------
function Main(){
	var N = nextInt();
	var list = nextIntArray();
	var min = 1000000;
	for(var i = 0; i < N; i++){
		var L = 0;
		var R = 0;
		for(var j = 0; j < N; j++){
			if(j <= i){
				L += list[j];
			}else{
				R += list[j];
			}
		}
		min = Math.min(min, Math.abs(L - R));
	}
	myout(min);
}


Measured memory_bytes: 30148