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

int main() {

  int data[] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
  int month, day;
  while( cin >> month >> day, month + day ) {
    int sum = 0;
    for(int i=0; i<month-1; i++) {
      sum += data[i];
    }
    sum += day;
    sum %= 7;

    if( sum == 1 ) {
      cout << "Thursday" << endl;
    }
    else if( sum == 2 ) {
      cout << "Friday" << endl;
    }
    else if( sum == 3 ) {
      cout << "Saturday" << endl;
    }
    else if( sum == 4 ) {
      cout << "Sunday" << endl;
    }
    else if( sum == 5 ) {
      cout << "Monday" << endl;
    }
    else if( sum == 6 ) {
      cout << "Tuesday" << endl;
    }
    else if( sum == 0 ) {
      cout << "Wednesday" << endl;
    }
  }
}

Measured memory_bytes: 1156
import java.util.Scanner;
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int i = 1;
    while(true){
      int a = sc.nextInt();
      if(a == 0){
        break;
      }else{;
        System.out.printf("Case %d: %d\n", i, a);
        i=i+1;
      }
    }
    sc.close();
  }
}


Measured memory_bytes: 62272
//
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<ll, P>IP;
typedef vector<ll> V;
typedef vector<V> V2;
typedef vector<vector<P> > G;
void g_dir(G &graph, ll a, ll b, ll w = 1){graph[a].push_back(P(b, w));}
void g_undir(G &graph, ll a, ll b, ll w = 1){g_dir(graph, a, b, w);g_dir(graph, b, a, w);}
#define rep(i, n) for(ll (i) = 0; (i) < (n); (i)++)
#define rep1(i, n) for(ll (i) = 1; (i) <= (n); (i)++)
#define rrep(i, n) for(ll (i) = (n) - 1; (i) >= 0; (i)--)
#define rrep1(i, n) for(ll (i) = (n); (i) >= 1; (i)--)
template<class T> void chmax(T &a, const T &b){if(a < b){a = b;}}
template<class T> void chmin(T &a, const T &b){if(a > b){a = b;}}
const ll INF = 1145141919;
const ll MOD = 1000000007;
const ll NUM = 101010;

int main(){

    string ans = "APPROVED";
    ll N;
    cin >> N;
    rep(i, N){
        ll x;
        cin >> x;
        if(x % 2 == 0){
            if(x % 3 && x % 5)ans = "DENIED";
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
import sys
def input(): return sys.stdin.readline().rstrip()


def main():
    N=int(input())
    A=list(map(int, input().split()))
    ans=0
    for i in range(1,N):
        ans+=max(A[i-1]-A[i],0)
        A[i]+=max(A[i-1]-A[i],0)
    print(ans)



if __name__ == '__main__':
    main()

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

#define F first
#define S second
#define pb push_back
#define ll long long
#define all(v) (v).begin(),(v).end()
#define endl '\n'

using namespace std;

const int N = 200005;
const int INF = 2000000000;
const ll INFLL = 1LL * INF * INF;

int main() {
    ios_base :: sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    int w, h, x, y;
    cin >> w >> h >> x >> y;
    cout << 1.0 * w * h / 2.0 << " ";
    if (w % 2 == 0 && h % 2 == 0 && x == w / 2 && y == h / 2) cout << 1 << endl;
    else cout << 0 << endl;
    return 0;
}


Measured memory_bytes: 256
import qualified Data.ByteString.Char8 as B
import Data.Maybe (fromJust)
import Data.Char

f :: Int -> Int -> Int -> Bool
f a b n =
    let s x = foldr ((+) . digitToInt) 0 (show x)
    in a <= s n && s n <= b

main :: IO ()
main = do
    [n, a, b] <- map (fst . fromJust . B.readInt) . B.words <$> B.getLine
    print $ sum $ filter (f a b) [1..n]


Measured memory_bytes: 892
// inputに入力データ全体が入る
function Main(input) {
    // input = input.split(' ').map(i => parseInt(i, 10));
    input = input.split("\n");

    var num = parseInt(input[0], 10);
    var hat = input[1]

    var redNum = hat.split('R').length - 1;

    console.log((num / 2) < redNum ? 'Yes' : 'No');

}

//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 21064
# 以下のいずれか
# :3つともKの倍数である
# :3つともKで割った余りがKの1/2である(Kが偶数)
n,k=map(int,input().split())
ans=0
if n>=k:
  c=n//k
  ans+=c**3
if k%2==0:
  if n>=k//2:
    c=(n-k//2)//k+1
    ans+=c**3
print(ans)

Measured memory_bytes: 2940
#include <algorithm>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <cmath>

using namespace std;

int main()
{
	string S;
	cin>>S;
	int l = S.length();
	for(int i = 0; i < l; i++){
		cout<<"x";
	}
	cout<<endl;
	return 0;
}



Measured memory_bytes: 256
n = int(input())
a = [int(x) for x in input().split()]
q = int(input())
bc=[]
for i in range(q):
    bc.append([int(x) for x in input().split()])

a_cnt=[0]*(10**5+1)

for i in range(len(a)):
	a_cnt[a[i]]+=1

a_goukei=sum(a)

for gyou in range(q):
	a_goukei+=(bc[gyou][1]-bc[gyou][0])*a_cnt[bc[gyou][0]]
	print(a_goukei)
	a_cnt[bc[gyou][1]]+=a_cnt[bc[gyou][0]]
	a_cnt[bc[gyou][0]]=0

Measured memory_bytes: 97104
#include <iostream>
#include <stdio.h>
#include <string>
#include <math.h>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cassert>
#include <utility>
#include <numeric>
#include <cstring>
#include <map>
#include <set>
#define rep(i,n) for (int i=0; i<(n); ++i)

using namespace std;
using ll = long long;

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

    for (int i=1;i<10;i++){
        for (int j=1;j<10;j++){
            if (i*j == N){
                cout << "Yes";
                return 0;
            }
            else {
                
            }
        }
    }
    cout << "No";
    return 0;

}

Measured memory_bytes: 256
#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;
}
void debug() { cerr << "\n"; }
template <class T> void debug(const T &x) { cerr << x << "\n"; }
template <class T, class... Args> void debug(const T &x, const Args &... args) {
    cerr << x << " ";
    debug(args...);
}
template <class T> void debugVector(const vector<T> &v) {
    for(const T &x : v) {
        cerr << x << " ";
    }
    cerr << "\n";
}
using ll = long long;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
constexpr int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string r, g, b;
    cin >> r >> g >> b;
    r = r + g + b;
    cout << (stoi(r) % 4 == 0 ? "YES" : "NO") << endl;
}

Measured memory_bytes: 3632
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>

using namespace std;

//vector string deque break continue
#define forn(i, s, f) for (int i = (int)s; i < (int)f; i++)
#define ll long long
#define ull unsigned long long
#define ld long double
#define pii pair <int, int>
#define fs first
#define sc second
#define pf push_front
#define pb push_back
#define pop_f pop_front
#define pop_b pop_back
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()

template <typename T> istream& operator>>(istream& in, vector <T>& a) {for (auto& i : a) in >> i; return in;}
template <typename T> ostream& operator<<(ostream& out, vector <T>& a)  {for (auto& i : a) out << i << " "; return out;}
template <typename T, typename U> void chkmin(T& a, U b) {if (a > b) a = b;}
template <typename T, typename U> void chkmax(T& a, U b) {if (a < b) a = b;}

#define int long long

main() {
    ios_base::sync_with_stdio(0), cin.tie(0);
    int n;
    cin >> n;
    int ans = 0;
    forn (i, 1, n + 1)
        if (i % 3 && i % 5)
            ans += i;
    cout << ans;
    return 0;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define int long long
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e18;

signed main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	int x;
	cin >> x;
	for(int a = -1000; a <= 1000; a++){
		for(int b = -1000; b <= 1000; b++){
			int tmp = a * a * a * a * a - b * b * b * b * b;
			if(tmp == x){
				cout << a << ' ' << b << endl;
				return 0;
			}
		}
	}
}

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

using ll = long long;

using vi = vector<int>;
#define pb push_back
#define rsz resize
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()

using pi = pair<int,int>;
#define f first
#define s second
#define mp make_pair

// the code that we provide requires everything above this line to compile

int N, W;
ll dpa[100001][100], dpv[100001];
int w[100], v[100];

int main() {
    cin >> N >> W;
    for (int i = 0; i < N; i++)
        cin >> w[i] >> v[i];
    
    for (int i = 1; i <= W; i++) {
        for (int j = 0; j < N; j++) {
            if (w[j] <= i && !dpa[i - w[j]][j] && dpv[i - w[j]] + v[j] > dpv[i]) {
                memcpy(dpa[i], dpa[i - w[j]], N * sizeof(ll));
                dpa[i][j] = 1;
                dpv[i] = dpv[i - w[j]] + v[j];
            }
        }
    }
    
    ll mx = -1;
    for (int i = 0; i <= W; i++)
        mx = max(mx, dpv[i]);
    cout << mx;

}


Measured memory_bytes: 82212
using System;
using System.Collections.Generic;

namespace ABC103A
{
    class ABC103A
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');

            var a = new List<int>();
            for (int i = 0; i < 3; ++i)
            {
                a.Add(int.Parse(input[i]));
            }

            a.Sort();

            int n = 0;
            n += a[2] - a[1];
            n += a[1] - a[0];

            Console.WriteLine(n);
        }
    }
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

int main() {
  char c;
  cin >> c;
  cout << (char)(c + 1) << endl;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <random>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;

typedef
tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> orderedSet;

#define pb push_back
#define F first
#define S second
#define all(a) (a).begin(), (a).end()

#define for1(i0, l0, r0) for (int i0 = l0; i0 < r0; ++i0)
#define for2(i0, l0, r0) for (int i0 = l0; i0 <= r0; ++i0)
#define forn(i0, n0) for (int i0 = 0; i0 < n0; ++i0)
#define forn1(i0, n0) for (int i0 = 1; i0 < n0; ++i0)
#define forr(i0, n0) for (int i0 = n0; i0 >= 0; --i0)
#define forr1(i0, r0, l0) for (int i0 = r0; i0 > l0; --i0)
#define forr2(i0, r0, l0) for (int i0 = r0; i0 >= l0; --i0)

#define Sort(a) sort(all(a))
#define Reverse(a) reverse(all(a))

typedef long double ld;
#define ui unsigned int
#define ull unsigned long long

typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef pair<string, string> pss;

typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<double> vd;
typedef vector<ld> vld;
typedef vector<bool> vb;
typedef vector<string> vs;

typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<pdd> vpdd;

typedef vector<vi> vvi;
typedef vector<vd> vvd;
typedef vector<vll> vvll;
typedef vector<vb> vvb;

#define vpss vector<pss>
#define vvs vector<vs>
#define vvpii vector<vpii>
#define vvpll vector<vpll>
#define vpt vector<pt>
#define vvvi vector<vvi>
#define vsi vector<set<int>>
#define ss second
#define ff first

#define printvi(arr) for (int x0 : arr) cout << x0 << ' '; cout << '\n';
#define printvll(arr) for (ll x0 : arr) cout << x0 << ' '; cout << '\n';
#define printpair(pair0) cout << pair0.F << ' ' << pair0.S << '\n';
#define printvp(arr) for (auto pair0 : arr) printpair(pair0);
#define initArray(arr, N0, X0) memset(arr, X0, N0 * sizeof(int))
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

void init() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    //cout.precision(16);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
}

void solve() {
    int n;
    string s, t;
    cin >> n >> s >> t;
    for (int i = n; i > 0; --i){
        bool flag = true;
        forn(j, i){
            if (t[j] != s[n - i + j]){
                flag = false;
                break;
            }
        }
        if (flag){
            cout << 2 * n - i << '\n';
            return;
        }
    }
    cout << 2 * n << '\n';
}

bool multitest = false;

int main() {
    init();
    int t = 1;
    if (multitest) cin >> t;
    forn(i, t) solve();
}

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

string S;

bool check_str(string s1, string s2) {
	unsigned int p1 = S.find(s1, 0);
	bool b1 = (p1 >= 0 && p1 < S.length()) ? true : false;
	unsigned int p2 = S.find(s2, 0);
	bool b2 = (p2 >= 0 && p2 < S.length()) ? true : false;
	if (b1 && b2)
		return true;
	if (!b1 && !b2)
		return true;
	return false;
}

int main(void) {
	cin >> S;
	if (check_str("N", "S") && check_str("W", "E"))
		cout << "Yes\n";
	else
		cout << "No\n";
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <numeric>

using namespace std;

int main()
{
    int tbl[26];

    for (int i = 0; i < 26; i++)
    {
        tbl[i] = 0;
    }

    string s;
    cin >> s;

    for (int i = 0; i < 4; i++)
    {
        int idx = s[i] - 'A';
        tbl[idx]++;
    }

    int twos = 0;
    int zeros = 0;
    for (int i = 0; i < 26; i++)
    {
        if (tbl[i] == 0)
        {
            zeros++;
        }
        else if (tbl[i] == 2)
        {
            twos++;
        }
    }

    if (zeros == 24 && twos == 2)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    return 0;
}

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

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

using namespace std;

using ll = long long;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int x;
  cin >> x;
  for (int i = 1; i <= 1000; i++) {
    if (100 * i <= x && x <= 105 * i) {
      cout << 1;
      return 0;
    }
  }
  cout << 0;
  return 0;
}


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

using namespace std;
const int N = 200010;
const int M = 1000010;
const int MOD = 998244353;
int _w;

int fpow( int a, int b ) {
	int c = 1;
	while(b) {
		if( b & 1 ) c = int(1LL * c * a % MOD);
		a = int(1LL * a * a % MOD);
		b >>= 1;
	}
	return c;
}

int inv( int x ) {
	return fpow(x, MOD-2);
}

void add_mod( int &a, int b ) {
	a += b;
	a -= a >= MOD ? MOD : 0;
}

void sub_mod( int &a, int b ) {
	a -= b;
	a += a < 0 ? MOD : 0;
}

int n, a[N], s[M], s2[M];

void factor( int x ) {
	for( int i = 1; i*i <= x; ++i )
		if( x % i == 0 ) {
			add_mod( s[i], x );
			add_mod( s2[i], int(1LL * x * x % MOD) );
			if( x/i != i ) {
				add_mod( s[x/i], x );
				add_mod( s2[x/i], int(1LL * x * x % MOD) );
			}
		}
}

bool vis[M];
int prime[M], pidx, miu[M];

void init() {
	miu[1] = 1;
	for( int i = 2; i < M; ++i ) {
		if( !vis[i] ) {
			prime[pidx++] = i;
			miu[i] = -1;
		}
		for( int j = 0; j < pidx; ++j ) {
			int k = i * prime[j];
			if( k >= M ) break;
			vis[k] = 1;
			if( i % prime[j] ) miu[k] = -miu[i];
			else break;
		}
	}
}

int f[M];

void add2( int &a, int b ) {
	if( b == 0 ) return;
	else if( b > 0 ) {
		add_mod(a, b);
	} else {
		sub_mod(a, -b);
	}
}

int invn[M];

void solve() {
	for( int i = 1; i < M; ++i )
		invn[i] = inv(i);
	int ans = 0;
	const int inv2 = inv(2);
	for( int i = 1; i < M; ++i ) {
		f[i] = int(1LL * s[i] * s[i] % MOD);
		sub_mod( f[i], s2[i] );
		f[i] = int(1LL * f[i] * inv2 % MOD);
		if( f[i] )
			for( int j = 1; j*j <= i; ++j )
				if( i % j == 0 ) {
					int tmp = int(1LL * f[i] * invn[i/j] % MOD);
					add2( ans, miu[j] * tmp );
					if( i/j != j ) {
						tmp = int(1LL * f[i] * invn[j] % MOD);
						add2( ans, miu[i/j] * tmp );
					}
				}
	}
	cout << ans << endl;
}

int main() {
	_w = scanf( "%d", &n );
	for( int i = 1; i <= n; ++i ) {
		_w = scanf( "%d", a+i );
		factor( a[i] );
	}
	init(), solve();
	return 0;
}


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

using namespace std;
typedef long long Int;
Int n, b, c, num[4320];
Int sum[4320];
int main(){
	while(cin >> n, n){
		fill(sum, sum + 4320, 0);
		for(int i = 0;i < n;i++){
			cin >> num[i] >> b >> c;
			sum[num[i]] += b * c;
		}
		bool na = true;
		for(int i = 0;i < n;i++){
			if(sum[num[i]] >= 1000000){
				na = false;
				cout << num[i] << endl;
				sum[num[i]] = 0;
			}
		}
		if(na)cout << "NA" << endl;
	}
	return 0;
}

Measured memory_bytes: 1200
using System;
using System.Linq;

class program
{
    static void Main()
    {
        var x = int.Parse(Console.ReadLine());
        for(int i = -199; i < 120; i++)
        {
            for(int j = -199; j < 120; j++)
            {
                if((long)Math.Pow(i,5) - (long)Math.Pow(j, 5) == x)
                {
                    Console.Write(i + " " + j);
                    return;
                }
            }
        }
    }
}

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

#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL);
#define eof !cin.eof()
#define pb push_back
#define pf push_front
#define pof pop_front
#define pob pop_back
#define ull unsigned long long
#define ll long long
#define ld long double
#define sz(a) a.size()
#define all(s) s.begin(), s.end()
#define rall(s) s.rbegin(), s.rend()
#define x first
#define y second
#define mp make_pair
#define ub upper_bound
#define lb lower_bound
#define ii pair <int, int>
#define iii pair <int, ii>
#define EPS 1e-10
#define INF 1000000000
#define mod 1000000007
#define reset(a, nilai) memset(a, nilai, sizeof(a))
#define minof min_element
#define maxof max_element
using namespace std;

int n, ans;
string s;
int main () {
	IOS;
	
	cin >> n >> s;
	for (int i = 0; i < n; i++) {
		if (s[i] != s[i + 1]) {
			ans++;
		} else {
			continue;
		}
	}
	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
//#define int long long
#define ll long long
#define all(a) (a).begin(), (a).end()
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define sz() size()
#define fr first
#define sc second
#define pb push_back
#define er erase
#define in insert
#define mp make_pair
#define el cout<<'\n'
#define rc(s) return cout<<s,0
//#define cin fin
//#define cout fout
using namespace std;

#define MAX_N 2000001
#define inf 1000000000

//ifstream fi("darb.in");
//ofstream fo("darb.out");

const int mod=1e9+7;

int n,root,maxi,x,y,viz[MAX_N],dist[MAX_N];
vector<int>nod[MAX_N];


void bfs(int s){
    memset(viz,0,MAX_N);
    memset(dist,0,MAX_N);
    maxi=0;
    queue<int>q;
    viz[s]=1;
    q.push(s);
    while(!q.empty()){
        s=q.front();
        for(auto it:nod[s]){
            if(!viz[it]){
                viz[it]=1;
                q.push(it);
                dist[it]=dist[s]+1;
                maxi=dist[it];
            }
        }
        if(q.size()==1) root=s;
        q.pop();
    }
}

int32_t main(){
    ios_base::sync_with_stdio(0);cin.tie();cout.tie();
    cin >> n;
    for(int i=1;i<n;i++){
        cin >> x >> y;
        nod[x].pb(y);
        nod[y].pb(x);
    }
    bfs(1);
    bfs(root);
    if((maxi+2)%3>=1) rc("First");
    else rc("Second");
}


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

int main() {
  int n,s=0,t=0;
  cin >> n;
 vector<int> x(n),v(n/2+1),u(n/2+1);

  for (int i=0;i<n;i++)
   cin >> x.at(i);
  
  for (int i=0;i<n;i++) {
    int M=0;
    for (int j=0;j<n;j++) {
      for (int k=0;k<n;k++) {
       if(x.at(j)>=x.at(k)&&x.at(j)>M)
        M=x.at(j);
      }//fork
    }//forj

    for (int j=0;j<n;j++) {
      if (x.at(j)==M) {
        x.at(j)=0;
        break;
      }//if
    }//forj
    if(i%2==0)
      v.at(i/2)=M;
    else
      u.at(i/2)=M;
  }//fori
  
  for (int i=0;i<n/2+1;i++)
    s +=v.at(i);
  for (int i=0;i<n/2+1;i++)
    t +=u.at(i);
  cout << s-t << endl;
}

Measured memory_bytes: 256
a, b, c, x, y = map(int, input().split())

normal_price = a * x + b * y
min_price = float('inf')
minn = min(x, y)
maxx = max(x, y)

for mi in range(2, maxx * 2 + 1, 2):
    mix_price = c * mi
    xz = x - mi // 2
    yz = y - mi // 2
    if xz < 0: xz = 0
    if yz < 0: yz = 0
    x_price = xz * a
    y_price = yz * b
    total_price = mix_price + x_price + y_price
    min_price = min(min_price, total_price)

min_price = min(min_price, normal_price)
print(min_price)

Measured memory_bytes: 3064
H,V,M=map(int,input().split())
h=[0 for i in range(M)]
w=[0 for i in range(M)]
for i in range(M):
    h[i],w[i]=map(int,input().split())
Dh=dict()
Dw=dict()
for i in range(M):
    if h[i] in Dh:
        Dh[h[i]]+=1
    else:
        Dh[h[i]]=1
    if w[i] in Dw:
        Dw[w[i]]+=1
    else:
        Dw[w[i]]=1
Hmax=0
Wmax=0
for i in Dh:
    if Dh[i]>Hmax:
        Hmax=Dh[i]
for i in Dw:
    if Dw[i]>Wmax:
        Wmax=Dw[i]
A=0
B=0
for i in Dh:
    if Dh[i]==Hmax:
        A+=1
for i in Dw:
    if Dw[i]==Wmax:
        B+=1
tmp=0
for i in range(M):
    if Dh[h[i]]==Hmax and Dw[w[i]]==Wmax:
        tmp+=1
if A*B>tmp:
    print(Hmax+Wmax)
else:
    print(Hmax+Wmax-1)


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

using ll = long long;

// 辺の情報
struct edge {
   ll to, cost;
};

const ll INF = 1e18;
ll N, M; // Nはノードの個数、Mは辺の個数
ll dist[1010]; // 最短距離
vector<edge> Graph[2010]; // グラフ

bool bellman() {
   // for (int i = 0; i < N; i++) {
   //    dist[i] = -INF;
   // }
   // dist[0] = 0;
   for (int k = 0; k < N-1; k++) {
      for (int i = 0; i < N; i++) {
         if (dist[i] == -INF) continue;
         for (edge e : Graph[i]) {
            if (dist[e.to] < dist[i] + e.cost) {
               dist[e.to] = dist[i] + e.cost;
               if (k == N-1) return true;
            }
         }
      }
   }
   return false;
}

// ベルマンフォード法
void bellmanFord() {
   for (int i = 0; i < N; i++) {
      dist[i] = -INF;
   }
   dist[0] = 0;
   while (true) {
      bool update = false;
      for (int i = 0; i < N; i++) {
         if (dist[i] == -INF) continue;
         for (edge e : Graph[i]) {
            if (dist[e.to] < dist[i] + e.cost) {
               dist[e.to] = dist[i] + e.cost;
               update = true;
            }
         }
      }
      if (!update) break;
   }
}

int main() {
   cin >> N >> M;
   for (int i = 0; i < M; i++) {
      int a, b, c;
      cin >> a >> b >> c;
      a--, b--;
      Graph[a].push_back(edge{b, c});
   }

   for (int i = 0; i < N; i++) dist[i] = -INF;
   dist[0] = 0;
   bellman();
   ll ans1 = dist[N-1];

   bellman();
   ll ans2 = dist[N-1];

   if (ans1 != ans2) {
      puts("inf");
   } else {
      cout << dist[N-1] << endl;
   }

   return 0;
}

Measured memory_bytes: 384
#include <cstdio>
#include <iostream>
#include <vector>
#include <map>
#include<cmath>
#include<climits>
// #include<bits/stdc++.h>

using namespace std;
#define lli long long int

int main()
{
// #ifndef ONLINE_JUDGE
// 	freopen("input.txt" , "r" , stdin);
// 	freopen("output.txt" , "w" , stdout);
// #endif
	// int n;
	// cin >> n;
	int n, m;
	cin >> n >> m;
	float temp = 1 / (float)(4 * m);
	// cout << temp << "\n";
	int A[n], cnt = 0, s = 0;
	for (int i = 0; i < n; i++)
	{
		cin >> A[i];
		s += A[i];
	}
	float total = temp * (float)s;
	for (int j = 0; j < n; j++)
	{
		if (A[j] >= total)
			cnt++;
	}
	if (cnt >= m)
		cout << "Yes" << '\n';
	else
		cout << "No\n";
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<cstdio>
using namespace std;
int main(){
	int st[1000005]={0};
	int a[1000005]={0};
	int n,k,q;
	cin>>n>>k>>q;
	int i;
	int sign;
	for(i=1;i<=q;i++){
		cin>>sign;
		st[sign]++;
	}
	for(int i=1;i<=n;i++){
		a[i]=k-(q-st[i]);
		if(a[i]<=0)
			printf("No\n");
		else
			printf("Yes\n");
	}
	
	
	return 0;
}

Measured memory_bytes: 4480
#include <iostream>
using namespace std;
int main(void){
 int N,M;
 cin>>N>>M;
 int a,b;
 int P[M],Q[M];
 int S[N];
 int c=0;
 for(int i=0;i<N;i++){
     S[i]=0;
 }
 for(int i=0;i<M;i++){
     cin>>a>>b;
     P[i]=a;
     Q[i]=b;
     S[P[i]-1]=Q[i];
     if(P[i]==1 & Q[i]==0){
         c=1;
     }
 }
 for (int i=0;i<M;i++){
     for(int j=0;j<M;j++){
         if(P[i]==P[j] & Q[i]!=Q[j]){
             cout<<-1<<endl;
             return 0;
         }
     }
 }
 if(N>1){
     if(S[0]==0 & c==1){
        cout<<-1<<endl;
        return 0;
     }
     else if(S[0]==0 & c==0){
         S[0]=1;
     }
 }
 for(int i=0;i<N;i++){
     cout<<S[i];
 }
 cout<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n;
    cin>>n;
    string ss;
    cin>>ss;
    int x=0,temp=0;
    for(int i=0;i<ss.size();i++){
    
    	if(ss[i]=='I')x++;
    	else x--;
        if(x>=temp)temp=x;
    }
    cout<<temp;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,X;
  cin>>N>>X;
  vector<int> m(N);
  for(int i=0; i<N;i++){
    cin>>m.at(i);
  }
  sort(m.begin(),m.end());
  int stock = X;
  for(int i=0; i<N;i++){
    stock -= m.at(i);
  }
  cout <<N + stock/m.at(0)<<endl;
}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		String s1 = sc.next();
		String s2 = new StringBuffer(sc.next()).reverse().toString();

		System.out.println(s1.equals(s2) ? "YES" : "NO");
	}
}

Measured memory_bytes: 35288
#include<stdio.h>
#include<stdlib.h>
int main()
{
    int i,n,count=1,mean;
    scanf("%d",&n);
    int a[n];
     for(i=0;i<n;++i)
        scanf("%d",&a[i]);
    mean=a[0];
    for(i=1;i<n;++i)
    {
        if(a[i]<=mean){
            count++;
            mean=a[i];}
    }
    printf("%d",count);
    
}

Measured memory_bytes: 896
# D - Powerful Discount Tickets
import heapq

n, m = map(int, input().split())
data = list(map(int, input().split()))

pq = []

for i in data:
    heapq.heappush(pq, -i)

for _ in range(m):
    # 先頭の "最小値"
    p = heapq.heappop(pq)
    heapq.heappush(pq, -(-p // 2))

print(-sum(pq))



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

int main() {
    int n;
    cin >> n;
    vector<string> w(n);
    bool flag=true;
    for (int i=0;i<n;i++) cin >> w[i];
    for (int i=1;i<n;i++) {
        for (int j=0;j<i;j++) {
            if (w[i]==w[j]) flag=false;
        }
        if (w[i-1][w[i-1].size()-1]!=w[i][0]) flag=false;
        if (!flag) break;
    }

    if (flag) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define repLRE(i, l, r) for (ll i = (l); i <= (r); ++i)
#define rrepLRE(i, l, r) for (ll i = (l); i >= (r); --i)
#define Sort(v) sort(v.begin(), v.end())
#define rSort(v) sort(v.rbegin(), v.rend())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

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

/* Macros reg. ends here */

const ll INF = 1LL << 50;

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

  ll n, c;
  cin >> n >> c;

  ll const tmax = 100005;
  vvll chan(c, vll(tmax, 0));
  rep(i, n) {
    ll s, t, d;
    cin >> s >> t >> d;
    s--, t--, d--;
    chan[d][s]++;
    chan[d][t+1]--;
  }

  rep(i, c) {
    repLRE(j, 1, tmax - 1) { chan[i][j] += chan[i][j - 1]; }
  }

  ll ans = 0;
  rep(j, tmax) {
    ll tmp = 0;
    rep(i, c) { tmp += (chan[i][j] > 0) ? 1 : 0; }
    chmax(ans, tmp);
  }

  cout << ans << endl;

  return 0;
}


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

int main(){
	string a,b;
    cin >> a >> b;
	string s = a + b;
	int t = atoi(s.c_str());
	for(int i = 1;i <= t;i++){
		if(t/i == i && t%i == 0){
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

var sc = bufio.NewScanner(os.Stdin)

func Scanner() string {
	sc.Scan()
	return sc.Text()
}

func intScanner() int {
	n, _ := strconv.Atoi(Scanner())
	return n
}

func floatScanner() float64 {
	n, _ := strconv.ParseFloat(Scanner(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func stringSliceScanner(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scanner()
	}
	return a
}
func intSliceScanner(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = intScanner()
	}
	return a
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}

var mod int

func main() {
	mod = 1000000007
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	h, w, a, b := intScanner(), intScanner(), intScanner(), intScanner()
	for i := 0; i < h; i++ {
		if i < b {
			fmt.Println(strings.Repeat("0", a) + strings.Repeat("1", w-a))
		} else {
			fmt.Println(strings.Repeat("1", a) + strings.Repeat("0", w-a))
		}
	}
}


Measured memory_bytes: 4864
n,*abc=map(int,input().split())
ip=[0]*n
for i in range(n):
	tmp=input()
	if tmp=="AB":
		ip[i]=[0,1]
	elif tmp=="BC":
		ip[i]=[1,2]
	else:
		ip[i]=[0,2]
ans="Yes"
res=[0]*n
s=sum(abc)
if s==0:
	ans="No"
elif s==1:
	for i in range(n):
		i1=ip[i][0]
		i2=ip[i][1]
		if abc[i1]+abc[i2]==0:
			ans="No"
		elif abc[i1]+abc[i2]==1:
			if abc[i1]==0:
				abc[i1]+=1
				abc[i2]-=1
				res[i]=i1
			else:
				abc[i1]-=1
				abc[i2]+=1
				res[i]=i2
else:
	i1=ip[0][0]
	i2=ip[0][1]
	if abc[i1]+abc[i2]==0:
		ans="No"
	else:
		for i in range(n):
			i1=ip[i][0]
			i2=ip[i][1]
			if abc[i1]*abc[i2]==0:
				if abc[i1]==0:
					abc[i1]+=1
					abc[i2]-=1
					res[i]=i1
				else:
					abc[i1]-=1
					abc[i2]+=1
					res[i]=i2
			elif i+1<n and ip[i+1]!=ip[i]:
				c=list(set(ip[i])&set(ip[i+1]))[0]
				if i1==c:
					abc[i1]+=1
					abc[i2]-=1
					res[i]=i1
				else:
					abc[i1]-=1
					abc[i2]+=1
					res[i]=i2
			else:
				if abc[i1]>=abc[i2]:
					abc[i1]+=1
					abc[i2]-=1
					res[i]=i1
				else:
					abc[i1]-=1
					abc[i2]+=1
					res[i]=i2
print(ans)
if ans=="Yes":
	for i in range(n):
		if res[i]==0:
			print("A")
		elif res[i]==1:
			print("B")
		else:
			print("C")

Measured memory_bytes: 18384
A, B, C, D = map(int, input().split())

cnt = 0
from fractions import gcd


def lcm(x, y):
    return (x * y) // gcd(x, y)


c = B // C
c2 = A // C
if A % C == 0:
    c2 -= 1
d = B // D
d2 = A // D
if A % D == 0:
    d2 -= 1
t = B // lcm(C, D)
t2 = A // lcm(C, D)
if A % lcm(C, D) == 0:
    t2 -= 1

print(B - A + 1 - ((c - c2) + (d - d2) - (t - t2)))
# for i in range(A, B + 1):
#     if i % C != 0 and i % D != 0:
#         continue
#     else:
#         print(i)


Measured memory_bytes: 5076
import sys
sys.setrecursionlimit(10**7)

n,m,q = map(int,input().split())
abcd = [[int(i) for i in input().split()] for j in range(q)]

s = [1] * (n)

ans = []

def dfs(k, c,old,ans):
    #ans = 0
    #print(s,k)
    if k == n:
        tmp = 0
        for i in range(q):
            if s[abcd[i][1]-1] - s[abcd[i][0]-1] == abcd[i][2]:
                tmp += abcd[i][3]
        #ans = max(ans,tmp)
        ans.append(tmp)
        return# ans
    for i in range(old,c+1):
        #print(old,c+1)
        s[k] = i
        dfs(k+1, m,i,ans)
        #print(k+1,c)
    #s[k] = chr(c+ord('a'))
    #dfs(k+1, c+1)
    return ans

print(max(dfs(0, m,1,ans)))


Measured memory_bytes: 78884
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
using ll = long long;
using P = pair<ll,ll>;

int main(){
ios::sync_with_stdio(false);
std::cin.tie(nullptr);
ll r,d,x;
cin >> r >> d >> x;
ll ans = x;
rep(i,10){
    ans = ans * r - d;
    cout << ans << endl;
}
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std; 
long long k,a,x;
string s; 
int main(){
    cin>>s>>k;
    for(int i=0;i<s.size();i++)
    {
    	a=s[i]-48;
    	if(a>1) {cout<<a;break;}
    	else k--;
    	if(k==0) {cout<<1;break;}
	}
	return 0;
} 

Measured memory_bytes: 256
#include <cstdio>

using namespace std;

int main() 
{
    int n;
    scanf("%d", &n);
    int a[n];

   for (int i = 0; i < n; ++i) {
        scanf("%d", &a[i]);
    } 
    
    int first = 0;
    int firstcount = 0;
    int second = 0;

    for (int i = 0; i < n; ++i) {
        if (a[i] > first) {
            second = first;
            first = a[i];
            firstcount = 1;
        } else if (a[i] == first) {
            firstcount++;
        } else if (a[i] > second) {
            second = a[i];
        }
    }

    for (int i = 0; i < n; ++i) {
        if (a[i] == first && firstcount == 1) {
            printf("%d\n", second);
        } else {
            printf("%d\n", first);
        }
    }

    return 0;
}

Measured memory_bytes: 2304
#include<iostream>
#include<map>
using namespace std;
int data[1000];
int main(){
	int n,q;
	while(cin>>n>>q && n){
		for(int i=0;i<1000;i++)data[i]=0;
		
		for(int i=0;i<n;i++){
			int m;
			cin>>m;
			for(int j=0;j<m;j++){
				int x;
				cin>>x;
				data[x]++;
			}
		}
		int ma=0,ans=0;
		for(int i=0;i<1000;i++){
			if(data[i]>ma){
				ma=data[i];
				ans=i;
			}
		}
		if(ma>=q)cout<<ans<<endl;
		else cout<<0<<endl;
	}
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
constexpr int mod=1000000007;
constexpr int mod1=998244353;
vector<int> dx={0,1,0,-1},dy={-1,0,1,0};
bool inside(int y,int x,int h,int w){
	if(y<h && y>=0 && x<w && x>=0) return true;
	return false;
}





int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;cin >> n;
	ll k;cin >> k;
	ll ma = 0;
	vector<ll> a(n),f(n);
	rep(i,n) cin >> a.at(i);
	rep(i,n) cin >> f.at(i);
	sort(f.rbegin(),f.rend());
	sort(a.begin(),a.end());
	ll ng = -1, ok = 1e18;
	while(true){
		if((ng == -1 && ok == 0) || (ng != -1 && ok - ng <= 1)) break;
		ll mid;
		if(ng == -1) mid = ok / 2;
		else mid = (ok + ng) / 2;
		ll sum = 0;
		rep(i,n){
			sum += max(0LL, a.at(i) - mid / f.at(i));
		}
		if(sum <= k) ok = mid;
		else ng = mid;
	}
	cout << ok << endl;
}

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

#define rep(i,n) for (decay_t <decltype (n)> i = 0, i ## __len = (n); i < i ## __len; ++ i)

constexpr auto MOD = static_cast <int64_t> (1e+9+7);

auto main () -> int
{
  cin.tie (nullptr);
  ios::sync_with_stdio (false);

  size_t n, m;
  cin >> n >> m;

  vector <int> a (n + 1, 0);

  rep (i, m)
  {
    size_t a_;
    cin >> a_;
    a [a_] = 1;
  }
  vector <int64_t> ans (n + 1, 0);

  ans [0] = 1;
  rep (i, n)
  {
    auto up1 = i + 1;
    if (up1 <= n && a [up1] != 1)
    {
      ans [up1] += ans [i];
      ans [up1] %= MOD;
    }

    auto up2 = i + 2;
    if (up2 <= n && a [up2] != 1)
    {
      ans [up2] += ans [i];
      ans [up2] %= MOD;
    }
  }

  cout << ans [n] << endl;
}



Measured memory_bytes: 1408
using System;
 
class Program{
    static void Main(){
            int[] input = new int[10];
            
            for (int i=0; i<input.Length; i++){
                input[i]=int.Parse(Console.ReadLine());
            }
            Array.Sort(input);
            Array.Reverse(input);
            for (int i=0; i<3; i++){
                Console.WriteLine(input[i]);
            }
    }
}

Measured memory_bytes: 9224
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define FIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define T() int t; cin>>t; while(t--)                      
#define pb push_back
#define endl "\n"

int main()
{	
	FIO;
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);

	ll n,k;
	cin>>n>>k;

	vector<ll> arr(n);
	for(int i=0;i<n;i++) cin>>arr[i];

	sort(arr.begin(),arr.end());
	
	ll ans = 0;
	for(int i=0;i<k;i++) ans += arr[i];

	cout<<ans<<endl;

	return 0;
	
}

Measured memory_bytes: 3608
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cstdint>
#include <cstdlib>
#include <cmath>
#include <complex>
#include <chrono>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>
#include <random>
#include <utility>
#include <limits>
#include <list>
#include <type_traits>

/* template start */
 
#define rep(i, a, b) for (long long i = (a); (i) < (b); (i)++)
#define all(i) i.begin(), i.end()

#ifdef LOCAL
#define debug(...) std::cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

void debug_out(){std::cerr<<std::endl;}

template<typename Head,typename... Tail>
void debug_out(Head h,Tail... t){
  std::cerr<<" "<<h;
  if(sizeof...(t)>0)std::cout<<" :";
  debug_out(t...);
}
 
template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, std::pair<T1, T2> pa) {
  return os << pa.first << " " << pa.second;
}
 
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (std::size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}
 
template<typename T1,typename T2>
inline bool chmax(T1& a,T2 b){return a<b && (a=b,true);}
 
template<typename T1,typename T2>
inline bool chmin(T1& a,T2 b){return a>b && (a=b,true);}

template<typename Num>
constexpr Num mypow(Num a, long long b) {
  if(b==0)return 1;
  if (a==0)return 0;
  Num x = 1;
  while (b > 0) {
    if(b & 1)x*=a;
    a*=a;
    b >>= 1;
  }
  return x;
}

/* template end */

using ll = long long;

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

  ll n;
  std::cin>>n;

  std::cout<<(1000 - n%1000)%1000<<"\n";

  return 0;
}

Measured memory_bytes: 3652
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
inf = 10**17
mod = 10**9 + 7

a,b,c,d=MI()
print(max(a*b,c*d))

Measured memory_bytes: 3316
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define rep(x) for(int i=0;i<x;i++)
#define reprev(x) for(int i=x-1;i>=0;i--)
#define repdef(x,n) for(int i=x;i<n;i++)
#define Debug(x) cout<<x<<"\n";
#define Debug2(x,y) cout<<x<<" "<<y<<"\n";
#define mod 1000000007
#define MAX 100005
int fast_exp(ll base,ll exp){
	if(exp==1){
		return base%mod;
	}
	if(exp&1){
		int ans=fast_exp(base,exp-1);
		return (base%mod*ans%mod)%mod;
	}else{
		int ans=fast_exp(base,exp/2);
		return (ans%mod*ans%mod)%mod;
	}
}
int fast_exp_itr(ll base,ll exp,ll p){
	ll ans=1;
	base=base%p;
	while(exp>0){
		if(exp&1){
			ans=((ans%p)*(base%p))%p;
		}
		exp>>=1;
		base=((base%p)*(base%p))%p;
	}
	return ans;
}
int euclid_gcd(int a,int b){
	if(b==0){
		return a;
	}
	return euclid_gcd(b,a%b);
}
bool comp(pair<int,pair<int,int>> a,pair<int,pair<int,int>> b){
	if(a.first==b.first){
		return a.second.second<b.second.second;
	}
	return a.first<b.first;
}
int main(int argc, char const *argv[])
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	string s;
	cin>>s;
	rep(s.size()){
		if(i%2==0){
			if(!(s[i]=='R'||s[i]=='U'||s[i]=='D')){
				cout<<"No\n";
				return 0;
			}
		}else{
			if(!(s[i]=='L'||s[i]=='U'||s[i]=='D')){
				cout<<"No\n";
				return 0;
			}
		}
	}
	cout<<"Yes\n";
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int a = Integer.parseInt(sc.next());
        int remainder = n%500;
        if (remainder-a<=0) {
        	System.out.println("Yes");
        } else {
        	System.out.println("No");
        }
	}
}

Measured memory_bytes: 35532
if __name__ == '__main__':
  n, m = map(int, input().split())
  a_lst = []
  for i in range(n):
    a_lst.append(input())
  b_lst = []
  for i in range(m):
    b_lst.append(input())
  for j in range(n-m+1):
    for k in range(n-m+1):
      flag = 0
      for l in range(m):
        if a_lst[k+l][j:j+m] != b_lst[l]:
          flag = 1
          break
      if flag == 0:
        break
    if flag == 0:
      break
  if flag == 0:
    print("Yes")
  else:
    print("No")

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

int main () {
  int a,b,c;
  cin >> a >> b >> c;

  int count=3;
  if (a==b && b==c) {
    cout << 1 << endl;
    return 0;
  }
  if (a==b) --count;
  if (b==c) --count;
  if (a==c) --count;

  cout << count << endl;

  return 0;
}


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

ll N;
ll a[200000];

int main(){
  cin>>N;
  ll total=0;
  for(int i=0;i<N;i++){
    cin>>a[i];
    total+=a[i];
  }

  ll sum=0;
  ll ans=(1LL<<60);
  for(int i=0;i+1<N;i++){
    sum+=a[i];
    ans=min( ans, abs(sum - (total-sum) ) );
  }
  cout<<ans<<endl;
  
  return 0;
}


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

int main(){
	int N,max = 0 , min = 1000000001,zet;
	int A[110];

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

	for(int j=1;j<=N;++j){
		if(A[j] > max) max = A[j];
		if(A[j] < min) min = A[j];
	}
	zet = max - min;

	cout << zet << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i[] = (s); i < (int)(n); i++)
using ll = long long;
using vec = vector<ll>;
using vec2 = vector<vector<int>>;

int main()
{
    int n;
    cin >> n;
    if (n % 1000 == 0)
    {
        cout << 0;
    }
    else
    {
        cout << 1000 - n % 1000;
    }
}


Measured memory_bytes: 3612
#include <bits/stdc++.h> 
#include<cmath>
#include<string>
#define pb push_back
#define x first
#define y second
#define fast ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define all(x) x.begin(),x.end()
#define int long long
using namespace std;
 
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
//void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
 
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
 
// look for  all edge cases
//search for a pattern



signed main() {    
	ios::sync_with_stdio(0);
	cout.tie(0);
	cin.tie(0);
		
	int a,b,c,d;
	cin >> a>> b>> c >>d;
	
	int ans = max({a*c , a*d , b*c, b*d});
	cout<<ans;
	
	 
	return 0;
}


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

int main(){
    int n;
    cin >> n;
    vector<int> a(n+1);
    for(int i = 1; i <= n; i++) cin >> a[i];

    int ans = 0;
    int cur = 1;
    for(; ans <= n; ans++){
        if(cur == 2) break;
        else cur = a[cur];
    }

    if(ans > n) ans = -1;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3760
n = int(input())
a_lis = list(map(int, input().split()))
a_sum = sum(a_lis)
a_avg = a_sum / n
minimum = 1000
ans = 0
for i in a_lis:
    n = abs(a_avg - i)
    if n < minimum:
        minimum = n
        ans = i
print(a_lis.index(ans))

Measured memory_bytes: 3060
def main():
    i = list(map(int, input().split()))
    n = i[0]

    if n < 100 or 999 < n or isinstance(n, int) == False:
        return

    if(str(n)[0] == str(n)[2]):
        print('Yes')
    else:
        print('No')

if __name__ == "__main__":
    main()

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main(){
    string n;
    cin>>n;
    bool y = false;
    for(int i=0; i<3; i++){
        if(n.at(i)=='7') y = true;
    }
    cout<<(y? "Yes": "No")<<endl;
}

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

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

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

double p[3005];
//! [i番目まで見たとき][面がnマイ出る]=確率
double dp[3005][3005];

int main()
{
    ll N;
    cin >> N;
    REP(i, N)
    {
        cin >> p[i];
    }
    dp[0][0] = 1;
    REP(i, N)
    {
        REP(j, N + 1)
        {
            dp[i + 1][j] = dp[i][j] * (1 - p[i]);
            if (j > 0)
                dp[i + 1][j] += dp[i][j - 1] * p[i];
        }
    }

    double s = 0;
    FOR(i, N + 1, N / 2 + 1)
    {
        s += dp[N][i];
    }
    cout << OF64 << s << endl;
    return 0;
}

Measured memory_bytes: 70656