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

#define rep(i,n) for(long long int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(long long int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(long long int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define Abs(a,b) max(a,b)-min(a,b)
#define YES(condition) if(condition){cout << "YES" << endl;}else{cout << "NO" << endl;}
#define Yes(condition) if(condition){cout << "Yes" << endl;}else{cout << "No" << endl;}
#define Cout(x) cout<<(x)<<endl
#define POSSIBLE(condition) if(condition){cout << "POSSIBLE" << endl;}else{cout << "IMPOSSIBLE" << endl;}
#define Possible(condition) if(condition){cout << "Possible" << endl;}else{cout << "Impossible" << endl;}
#define possible(condition) if(condition){cout << "possible" << endl;}else{cout << "impossible" << endl;}
#define Size(n) (n).size()

typedef long long ll;


using namespace std;

const int INF = 1e9,MOD = 1e9 + 7,ohara = 1e6;
const ll LINF = 1e18;


long long int n,cnt=0,ans=0,a,b,c,d,cmp,cmpp,m,h,w,x,y,sum=0,pos,xdata[ohara],ydata[ohara];
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

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

      bitset<8000*2+1000> dpx;
      bitset<8000*2+1000> dpy;
      dpx[8000]=true;
      dpy[8000]=true;
      ll cntx=0,cnty=0,F=0;

      cin>>s>>x>>y;

      rep(i,Size(s)){
        if(s[i]=='T'){
          if(cnt%2==0){
            xdata[cntx++]=F;
          }
          else{
            ydata[cnty++]=F;
          }
          cnt++;
          F=0;
        }
        else{
          F++;
        }
      }

      if(F!=0){
       if(cnt%2==0){
            xdata[cntx++]=F;
          }
          else{
            ydata[cnty++]=F;
          }
          cnt++;
          F=0;
        }

      x+=8000;y+=8000;

      rep(i,cntx){
        if(i==0) dpx=(dpx<<xdata[i]);
        else dpx=(dpx<<xdata[i])|(dpx>>xdata[i]);
      }

       rep(i,cnty){
        dpy=(dpy<<ydata[i])|(dpy>>ydata[i]);
      }
      
     if(dpx[x]&&dpy[y])Cout("Yes");
     else Cout("No");
      


     

       
return 0;
}


Measured memory_bytes: 2304
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second

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

const ll INF = 1e18;
const ll MOD = 1e9 + 7;
const double EPS = 1e-8;

template<typename T> T chmax(T& a, const T& b){return a = (a > b ? a : b);}
template<typename T> T chmin(T& a, const T& b){return a = (a < b ? a : b);}

int main(){
    int a, b, m;
    cin >> a >> b >> m;
    vi u(a), v(b);
    rep(i, a) cin >> u[i];
    rep(i, b) cin >> v[i];
    int ans = *min_element(all(u)) + *min_element(all(v));
    rep(i, m) {
        int x, y, z;
        cin >> x >> y >> z;
        --x;--y;
        chmin(ans, u[x]+v[y]-z);
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1024
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cassert>
#include <string>
#include <algorithm>
#include <vector>
#include <valarray>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <iomanip>
#include <map>
#include <set>
#include <list>
#include <limits>
#include <numeric>
#include <utility>
#include <deque>
#include <unordered_set>
#include <unordered_map>
#include <regex>
#include <array>
#include <bitset>
#include <complex>
#include <tuple>
#include <random>

using namespace std;
using ll = long long;
const int INF = 1e9;
const ll MOD = 1e9 + 7;

int main()
{
  ll n, k;
  cin >> n >> k;
  vector<ll> a(n);
  for (auto &e : a)
    cin >> e;
  ll sum[2020] = {};
  ll ans = 0;
  for (int i = 0; i < n; ++i)
  {
    for (int j = 0; j < n; ++j)
    {
      if (a[i] > a[j])
        sum[i]++;
    }
    ans = (ans + ((k * (k - 1) / 2) % MOD) * sum[i] % MOD) % MOD;
  }
  ll tsum[2020] = {};
  for (int i = 0; i < n; ++i)
  {
    for (int j = i + 1; j < n; ++j)
    {
      if (a[i] > a[j])
        tsum[i]++;
    }
    ans = (ans + k * tsum[i] % MOD) % MOD;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
   int w,n;
   int i,j,k;
   int a=0,b=0,c=0;
   int stage[30];

   scanf("%d%d",&w,&n);

   for(i=0;i<w;i++){
       stage[i]=i+1;
   }

   for(j=0;j<n;j++){
       scanf("%d,%d",&a,&b);
       c=stage[a-1];
       stage[a-1]=stage[b-1];
       stage[b-1]=c;
   }
   for(k=0;k<w;k++){
       printf("%d\n",stage[k]);
   }
   return 0;
}

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

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

	string s, t; cin >> s >> t;
	int n = s.length();
	int m = t.length();
	vector<vector<int>>dp(n + 1, vector<int>(m + 1, 0));
	for (int i = 1; i <= n; i++)
	{
		for (int j = 1; j <= m; j++)
		{
			if (s[i - 1] == t[j - 1])
				dp[i][j] = dp[i - 1][j - 1] + 1;
			else
				dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
		}
	}

	// for (auto it : dp)
	// {
	// 	for (auto it2 : it)
	// 		cout << setw(2) << it2 << " ";
	// 	cout << "\n";
	// }
	// cout << "\n";
	string ans;
	int r = n;
	int c = m;

	while (r && c)
	{
		if (dp[r][c] == dp[r - 1][c])
			r--;
		else if (dp[r][c] == dp[r][c - 1])
			c--;
		else
		{
			ans += s[r - 1];
			r--; c--;
		}
	}
	reverse(ans.begin(), ans.end());

	cout << ans;

	return 0;
}


Measured memory_bytes: 38512
#include <iostream>
#include <cstdio>
#include <climits>
#include <cmath>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>

#define MAX 200000
#define INFTY 1<<30

using namespace std;

int main()
{
  int n; cin >> n;
  int F[MAX];
  F[0] = F[1] = 1;
  for(int i = 2; i <= n; i++) F[i] = F[i-1] + F[i-2];

  cout << F[n] << endl;
  return 0;
}

Measured memory_bytes: 1168
#include<stdio.h>
#define MAX 100000

int parent(int);
int left(int);
int right(int);

int main() {

  int n,i,num[MAX+1];

  scanf("%d",&n);
  for(i=1;i<=n;i++) scanf("%d",&num[i]);

  for(i=1;i<=n;i++) {
    printf("node %d: key = %d, ",i,num[i]);
    if(parent(i) >= 1) printf("parent key = %d, ",num[parent(i)]);
    if(left(i) <= n) printf("left key = %d, ",num[left(i)]);
    if(right(i) <= n) printf("right key = %d, ",num[right(i)]);
    printf("\n");
  }

  return 0;

}

int parent(int i) { return i/2; }
int left(int i) { return i*2; }
int right(int i) { return i*2+1; }


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

#define fastio 			ios::sync_with_stdio(0);	cin.tie(0); cout.tie(0);  cout<<fixed;  cout<<setprecision(12);
#define randomINT 		mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define	newl 			cout<<"\n"
#define DISP(as)		for(auto it : as) cout<<it<<" ";newl;
#define all(x)         	(x).begin(),(x).end()
#define mset(x,val)    	memset(x,val,sizeof(x))
#define newl           	cout<<"\n"
#define pb             	push_back
#define mp             	make_pair
#define f 				first
#define s 				second
#define dline          cerr<<"///REACHED///\n";
#define deb1(x)        cerr<<#x<<" = "<<x<<'\n';
#define deb2(x,y)      cerr<<'['<<#x<<','<<#y<<"] = "<<'['<<x<<','<<y<<']'<<'\n';
#define deb3(x,y,z)    cerr<<'['<<#x<<','<<#y<<','<<#z<<"] = "<<'['<<x<<','<<y<<','<<z<<']'<<'\n';

typedef long long 				ll;
typedef long double 			ld;
typedef vector<ll> 				vll;
typedef pair<ll , ll> 			pll;
typedef pair<ld, ld> 			pld;
typedef unordered_map<ll, ll> 	um;
typedef vector<pll> 			vpll;

const ll 	MAX5 	= 	1e+5 + 7;
const ll 	MAX7 	= 	1e+7 + 7;
const ll 	MAXN 	= 	MAX7;
const ll   	INF   	=  	0x7f7f7f7f7f7f7f7f;
const int  	INFi 	=  	0x7f7f7f7f;
const ll 	MOD		=  	1e+9 + 7;


// <------------- Declare Variables Here ------------> //

ll T = 1;
ll n, x, m, y, k, z, N;
ll s, t, d;


// <------------- Implement Functions Here ----------> //



// <------------- Start of main() -------------------> //

void MAIN() {
	cin >> n >> m >> x >> y;
	cout<<(n-x)*(m-y);
}

int main() {
	fastio; randomINT;
	//cin >> T;
	while (T--) {
		MAIN();
	}
	return 0;
}


Measured memory_bytes: 3616
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication7
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            var moti = new List<int>();
            for (int i = 0; i < N; i++)
            {
                moti.Add(int.Parse(Console.ReadLine()));
            }
            Console.WriteLine(moti.Distinct().ToList().Count());
        }
    }
}


Measured memory_bytes: 13280
#include <bits/stdc++.h>
char str[20];
int n,i,cnt=0;
int main()
{
	scanf("%s",str);
	n=strlen(str);
	for (i=0;i<n;i++)
		if (str[i]=='o') cnt++;
	cnt+=(15-n);
	if (cnt>=8) printf("YES\n");
		else printf("NO\n");
}

Measured memory_bytes: 256
<?php

$array = array();
$array[] = explode(' ', trim(fgets(STDIN)));
$array[] = explode(' ', trim(fgets(STDIN)));
$array[] = explode(' ', trim(fgets(STDIN)));

fscanf(STDIN, "%d", $n);

for ($i=0; $i < $n; $i++) {
  fscanf(STDIN, "%d", $b);

  foreach ($array as $k1 => $arr) {
    foreach ($arr as $k2 => $a) {
      if ($a == $b) {
        $array[$k1][$k2] = 'ok';
      }
    }
  }
}

// 横
for ($i=0; $i < 3; $i++) {
  $target = array($array[$i][0], $array[$i][1], $array[$i][2]);
  isBingo($target);
}

// 縦
for ($i=0; $i < 3; $i++) {
  $target = array($array[0][$i], $array[1][$i], $array[2][$i]);
  isBingo($target);
}

// 斜め
$target = array($array[0][0], $array[1][1], $array[2][2]);
isBingo($target);
$target = array($array[0][2], $array[1][1], $array[2][0]);
isBingo($target);

echo 'No';

function isBingo($target)
{
  $bingo = array('ok', 'ok', 'ok');

  if (empty(array_diff_assoc($bingo, $target))) {
    echo 'Yes';
    exit;
  }
}


Measured memory_bytes: 4728
#include <iostream>
#include <string>
#include <queue>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <iomanip>
#include <queue>
#include <numeric>
#define repl(i, l, r) for (ll i = l; i < r; i++)
#define rep(i, n) repl(i, 0, n)

using namespace std;
using ll = long long;

int main() {
    ll N, M, ans;
    cin >> N >> M;

    vector<ll> A(M);
    vector<ll> gap(M - 1);

    rep(i, M) {
        cin >> A[i];
    }

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

    ans = A[M - 1] - A[0];

    rep(i, M -1) {
        gap[i] = A[i + 1] - A[i];
    }

    sort(gap.begin(), gap.end(), greater<>());

    rep(i, min(N - 1, M - 1)) {
        ans -= gap[i];
    }

    cout << ans;

    return 0;
}


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

int main(){
  int n;
  cin >> n;
  for(int i = 0; i < n; i++){
    string s;
    cin >> s;
    if(s == "Y"){
      cout << "Four" << endl;
      return 0;
    }
  }
  cout << "Three" << endl;
  return 0;
}

Measured memory_bytes: 256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#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>
#include <fstream>
#include <complex>
#include <math.h>

using namespace std;

//conversion
//------------------------------------------
inline long toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
inline long toLong(string s) {long v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<long, long> PLL;
typedef long long LL;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(long i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

//constant
//--------------------------------------------

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

const long double EPS = 1e-6;
const long INF = 1e10;

int rng[10002][800];
int main(){
	int N,M,r,q;
	while(cin>>N>>M){
		if(N==0&&M==0)break;
		CLR(rng);
		cin>>r;
		REP(i,r){
			int t,n,m,s;
			cin>>t>>n>>m>>s;
			t-=540;
			if(s==1)rng[m][t]++;
			else rng[m][t]--;
		}
		cin>>q;
		REP(i,q){
			int ts,te,m;
			cin>>ts>>te>>m;
			ts-=540;te-=540;
			int sum=0,res=0;
			bool f=false;
			int b=0;
			for(int j=0;j<=te;j++){
				sum+=rng[m][j];
				if(j>=ts){
					if(sum>0){
						if(j==te&&f)res+=(j-b);
						if(!f)b=j;
						f=true;
					}else{
						if(f)res+=(j-b);
						
						f=false;
					}
					
				}
			}
			cout<<res<<endl;
		}
	}
	return 0;
}
/*
1 1
2
600 1 1 1
700 1 1 0
5
540 600 1
550 650 1
610 620 1
650 750 1
700 800 1
*/

Measured memory_bytes: 32424
#include <stdio.h>
int main(void) {
  int value[100][100];
  int sum_row[100] = {0}, sum_column[100] = {0};
  int sum = 0;
  int r, c, i, j;

  scanf("%d %d", &r, &c);

  for (i = 0; i < r; i++) {
    for (j = 0; j < c; j++) {
      scanf("%d", &value[i][j]);
      sum += value [i][j];
    }
  }

  for (i = 0; i < r; i++) {
    for (j = 0; j < c; j++) {
      sum_row[i] += value[i][j];
      sum_column[j] += value[i][j];
    }
  }

  for (i = 0; i < r; i++) {
    for (j = 0; j < c; j++) {
      printf("%d ", value[i][j]);
    }
    printf("%d\n", sum_row[i]);
  }

  printf("%d", sum_column[0]);
  for (j = 1; j < c; j++)
    printf(" %d", sum_column[j]);
  printf(" %d\n", sum);

  return 0;
}

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

int main() 
{
    ll n;
    cin >> n;
    map<ll, ll> mp;
    for (ll i=0; i<n; i++)
    {
        ll a;
        cin >> a;
        mp[a]++;
    }
    ll sum = 0;
    for (auto x:mp)
    {
        // cout << x.first << " " << x.second << endl;
        if (x.second > x.first)
            sum += x.second - x.first;
        if (x.first > x.second) 
            sum += x.second;
    }
    cout << sum;
    return 0;
}

Measured memory_bytes: 6272
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
#include <map>
#include <unordered_map>
#include <chrono>
#include <numeric>
using namespace std;
using ll = long long;
const ll INF = (ll)1e18+1;
const ll DIV = 1000000007;
//#define TEST
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
#ifdef TEST
    chrono::system_clock::time_point start, end;
    start = chrono::system_clock::now();
#endif
    long K;
    string S;
    cin >> K;
    cin >> S;
    if(S.size() <= K) cout << S << endl;
    else
    {
        cout << S.substr(0, K) << "..." << endl;
    }
    
#ifdef TEST
    end = chrono::system_clock::now();
    cerr << static_cast<double>(chrono::duration_cast<chrono::microseconds>(end - start).count() / 1000.0) << "[ms]" << endl;
#endif
    return 0;
}

Measured memory_bytes: 3656
l, r = map(int, input().split())
ans = []
for i in range(l, r+1):
    for j in range(i+1, r+1):
        if j == i+1:
            start = (i*j) % 2019
        tmp = (i*j) % 2019
        if tmp == 0:
            print(0)
            exit()
        if j != i+1 and tmp == start:
            break
        else:
            ans.append(tmp)
print(min(ans))

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

using i64 = int64_t;

constexpr int INF = 1e9;
int N, A, B, C;
vector<int> v;

int dfs(int n, int a, int b, int c){
    if(n == N){
        if(min({a, b, c}) <= 0)return INF;
        return abs(a-A) + abs(b-B) + abs(c-C) - 30;
    }

    int res = dfs(n+1, a, b, c);
    res = min(res, dfs(n+1, a+v[n], b, c) + 10);
    res = min(res, dfs(n+1, a, b+v[n], c) + 10);
    res = min(res, dfs(n+1, a, b, c+v[n]) + 10);
    return res;
}

int main(){
    cin >> N >> A >> B >> C;
    for(int i=0;i<N;++i){
        int l;
        cin >> l;
        v.push_back(l);
    }

    cout << dfs(0, 0, 0, 0) << endl;

    return 0;
}


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

map<ll,ll>m;

int main()
{
    int n;
    cin>>n;
    ll sum=0;
    for(int i=0;i<n;i++){
        ll shu;
        cin>>shu;
        sum+=shu;
        if(m[shu]==0){
            m[shu]=1;
        }else{
            m[shu]++;
        }
    }
    int q;
    cin>>q;
    for(int i=0;i<q;i++){
        ll b,c;
        cin>>b>>c;
        if(m[b]==0){

        }else{
            sum=sum-b*m[b]+c*m[b];
            m[c]+=m[b];
            m[b]=0;
        }
        cout<<sum<<endl;
    }
    return 0;
}

Measured memory_bytes: 9324
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>

using namespace std;
#define ll long long
#define ld long double
#define mp make_pair

void print(vector<auto> &a)
{
    for (int i = 0; i<a.size(); i++) cout<<a[i]<<' ';
    cout<<endl;
}

void get(vector<auto> &a)
{
    for (int i = 0; i<a.size(); i++) cin>>a[i];
}

const ll p = 998244353;

int mul(int a, int b) {
    return (1LL * a * b) % p;
}

int add(int a, int b) {
    int s = (a+b);
    s = s%p;
    if (s<0) s+=p; 
    return s;
}

int po(int a, int deg)
{
    if (deg==0) return 1;
    if (deg%2==1) return mul(a, po(a, deg-1));
    int t = po(a, deg/2);
    return mul(t, t);
}


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

    int n, w;
    cin>>n>>w;
    vector<ll> weight(n);
    vector<ll> value(n);
    for (int i = 0; i<n; i++) cin>>weight[i]>>value[i];
    
    vector<ll> dp(w+1);
    for (int i = 0; i<n; i++)
    {
        for (int j = w; j>=weight[i]; j--) dp[j] = max(dp[j], dp[j-weight[i]] + value[i]);
    }
    
    ll res = 0;
    for (int i = 0; i<=w; i++) res = max(res, dp[i]);
    cout<<res;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <numeric>
#include <array>
#include <cmath>
using namespace std;
//変数デバッグ
#define DEB(variable) cout << #variable << '=' << variable << endl

//for簡易表記(引数ミス防止)
#define FOR(LoopVariable,numberOFbegin,numberOFend) for (int LoopVariable = (numberOFbegin); (LoopVariable) < (numberOFend); (LoopVariable)++)
#define DEFOR(LoopVariable,numberOFbegin,numberOFend) for (int LoopVariable = (numberOFbegin)-1; (LoopVariable) >= (numberOFend); (LoopVariable)--)
#define REP(LoopVariable,numberOFend) for(int LoopVariable = 0;(LoopVariable)<(numberOFend);LoopVariable++)

constexpr long long int linf = numeric_limits<long long int>::max()-5;
constexpr int inf= numeric_limits<int>::max();
constexpr long long int mod = 1000000007;

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

    vector<int> v(n);
    REP(i, n) { cin >> v[i]; }

    vector<bool> dp(n * 100 + 1);
    dp[0] = true;
    REP(i,n){
        DEFOR(j,i*100+1,0){
            if(dp[j]){
                dp[j + v[i]] = true;
            }
        }
    }
    DEFOR(i,n*100+1,0){
        if(dp[i]&&i%10){
            cout << i << endl;
            return 0;
        }
    }

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


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

using namespace std;
int main(int argc, char const *argv[])
{
    string s    ;cin>>s;
    char a=s[0];
    for(int i=1;i<s.size();i++){
        if(a==s[i]){
            cout<<"Bad"<<endl;
            return 0;
        }
        a=s[i];
    }
    cout<<"Good"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(){
 int a,b;
 scanf("%d",&a);
 scanf("%d",&b);
 if (a<b) {
   printf("a < b\n");
 } else if (a>b) {
   printf("a > b\n");
 } else {
   printf("a == b\n");
 }
 return 0;
};

Measured memory_bytes: 580
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <iterator>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <regex>
using namespace std;
using pii  = pair<int,int>;
using ll=long long;
using ld=long double;
#define pb push_back
#define mp make_pair
#define sc second
#define fr first
#define stpr setprecision
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define rep(i,n) for(ll i=0;i<(n);++i)
#define Rep(i,a,b) for(ll i=(a);i<(b);++i)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define rRep(i,a,b) for(int i=a;i>=b;i--)
#define crep(i) for(char i='a';i<='z';++i)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define ALL(x) (x).begin(),(x).end()
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define endl '\n'
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
ll gcd(ll a,ll b){return (b == 0 ? a : gcd(b, a%b));}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
constexpr ll MOD=1000000007;
constexpr ll INF=1000000011;
constexpr ll MOD2=998244353;
constexpr ll LINF = 1001002003004005006ll;
constexpr ld EPS=10e-8;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<typename T> istream& operator>>(istream& is,vector<T>& v){for(auto&& x:v)is >> x;return is;}
template<typename T,typename U> istream& operator>>(istream& is, pair<T,U>& p){ is >> p.first; is >> p.second; return is;}
template<typename T,typename U> ostream& operator>>(ostream& os, const pair<T,U>& p){ os << p.first << ' ' << p.second; return os;}
template<class T> ostream& operator<<(ostream& os, vector<T>& v){
  for(auto i=begin(v); i != end(v); ++i){
    if(i !=begin(v)) os << ' ';
    os << *i;
  }
  return os;
}

ll  N,A,B,C,L[10],mi=INF;

void dfs(ll i,ll a,ll b,ll c,ll cost){
    if(i==N){
        if(a==0 || b==0 || c==0){
            return;
        }
        else{
            mi = min(mi,cost+abs(a-A)+abs(b-B)+abs(c-C));
        }
        return;
    }
    dfs(i+1,a+L[i],b,c,cost+(a>0?10:0));
    dfs(i+1,a,b+L[i],c,cost+(b>0?10:0));
    dfs(i+1,a,b,c+L[i],cost+(c>0?10:0));
    dfs(i+1,a,b,c,cost);
}

int main(){
    cin >> N >> A >> B >> C;
    rep(i,N){
        cin >> L[i];
    }
    dfs(0,0,0,0,0);
    cout << mi << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mset(m,v) memset(m,v,sizeof(m))
#define pr(a,s) printf("Case #%lld: %lld\n",a,s)
#define mod 1000000007
#define mp make_pair
#define all(a)                a.begin(),a.end()
#define pb push_back
#define scan(a) scanf("%d",&a)
#define scanl(a) scanf("%lld",&a)
#define se second
#define fi first
#define pi 3.14159265358979323
#define pii pair<ll,ll>

#define trace1(x)             cout <<#x<<": "<<x<< endl;
#define trace2(x, y)          cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<< endl;
#define trace3(x, y, z)       cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl;
#define trace4(a, b, c, d)    cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl;
#define trace5(a, b, c, d, e) cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<<": "<<e<<endl;


const int MAXM = 2e5+3;
const ll inf = 1e15;

ll height[MAXM], beuity[MAXM],n;
ll dp[MAXM];
ll tree[4*MAXM];

void build(int root, int l, int r)
{
	if (l == r) {
		tree[root] = beuity[l];
		return ;
	}
	int mid = (l+r)/2;
	build(root*2, l, mid);
	build(root*2+1, mid+1, r);
	tree[root] = max(tree[root*2], tree[root*2+1]);	
}

void update(int root, int l, int r, int pos, ll val) 
{
	if (l>r or l>pos or r<pos)	return ;
	if (l == r) {
		tree[root] = val;
		return;
	}
	int mid = (l+r)>>1;
	update(2*root, l, mid, pos, val);
	update(2*root+1, mid+1, r, pos, val);
	tree[root] = max(tree[root*2], tree[root*2+1]);
}

ll query(int root, int l ,int r, int ql,int qr)
{
	if (l > r or l > qr or r < ql)	return 0LL;
	if (ql <= l and qr >= r)	return tree[root];
	int mid = (l+r)>>1;
	ll r1 = query(2*root, l, mid, ql, qr);
	ll r2 = query(2*root+1, mid+1, r, ql, qr);
	return max(r1, r2);
}

int main()
{
	cin>>n;
	for (int i=1;i<=n;i++){
		cin>>height[i];
	}	
	for (int i=1;i<=n;i++){
		cin>>beuity[i];
	}
	// dp[x] -> maximum possible beuity upto point i including i.
	for (int i=1;i<=n;i++){
		ll ans = query(1, 1, n, 1, height[i]);
		update(1, 1, n, height[i], ans + beuity[i]);
		// for (int j=1;j<i;j++){
		// 	if (flowers[i] > flowers[j]) {
		// 		dp[i] = max(dp[i], dp[j] + beuity[i]);
		// 	}
		// }
	}
	cout << tree[1] << endl;
}

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


int main()
{
    int n;
    cin>>n;
    int i;
    
    long long a[100000],b[100000];
    for(i=0;i<n;i++)cin>>a[i]>>b[i];
    long long sum=0;
    for(i=n-1;i>=0;i--)
    {
        a[i]+=sum;
        long long  x= (a[i])/b[i];
        if((a[i])%b[i]){x+=1;
        sum+=(b[i]*x - a[i]);
        }
    }
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <queue>

using namespace std;

int h, w;
const int INF = (1 << 30) - 1;

struct pos {
    int x, y;
};

struct status {
    int cost;
    pos v;

    bool operator<(const status &rhs) const { return cost < rhs.cost; };
    bool operator>(const status &rhs) const { return cost > rhs.cost; };
};


const vector<pos> moves{{1,  0},
                        {-1, 0},
                        {0,  1},
                        {0,  -1}};

bool inRange(pos p) {
    return 0 <= p.x && p.x < h && 0 <= p.y && p.y < w;
}

int calc(vector<string> &ban, pos start, pos end) {
    vector<vector<int>> dis(h, vector<int>(w, INF));
    priority_queue<status, vector<status>, greater<>> que;
    dis[start.x][start.y] = 0;
    que.push({0, start});

    while (!que.empty()) {
        status now = que.top();
        que.pop();

        if (dis[now.v.x][now.v.y] < now.cost)continue;

        for (auto &move:moves) {
            pos next = {now.v.x + move.x, now.v.y + move.y};
            if (!inRange(next) || ban[next.x][next.y] == '#') continue;

            if (dis[next.x][next.y] > dis[now.v.x][now.v.y]) {
                dis[next.x][next.y] = dis[now.v.x][now.v.y];
                que.push({dis[next.x][next.y], next});
            }
        }

        for (int i = -2; i <= 2; i++) {
            for (int j = -2; j <= 2; j++) {
                if (abs(i) + abs(j) <= 1)continue;

                pos next = {now.v.x + i, now.v.y + j};
                if (!inRange(next) || ban[next.x][next.y] == '#') continue;

                if (dis[next.x][next.y] > dis[now.v.x][now.v.y] + 1) {
                    dis[next.x][next.y] = dis[now.v.x][now.v.y] + 1;
                    que.push({dis[next.x][next.y], next});
                }
            }
        }
    }

    return dis[end.x][end.y];
}

int main() {
    cin >> h >> w;
    pos start, goal;
    cin >> start.x >> start.y >> goal.x >> goal.y;
    start.x--, start.y--, goal.x--, goal.y--;

    vector<string> ban(h);
    for (int i = 0; i < h; i++)cin >> ban[i];

    int ret = calc(ban, start, goal);
    cout << (ret == INF ? -1 : ret) << endl;
    return 0;
}

Measured memory_bytes: 9280
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<stack>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<numeric>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;
typedef pair<ll, ll> mp;
ll MOD = 1e9+7;
//LLONG_MIN

//AC

int main(void){
	ll a,b;
	cin>>a>>b;
	cout<<max({a+b,a-b,a*b})<<endl;
	return 0;
}

Measured memory_bytes: 256
n, k = map(int, input().split())
r, s, p = map(int, input().split())
t = input()

d = dict()
ans = 0
for i, move in enumerate(t):
    if move == "r" and d.get(i, 0) != "r":
        ans += p
        d[i+k] = d.get(i+k, "r")
    elif move == "s" and d.get(i, 0) != "s":
        ans += r
        d[i+k] = d.get(i+k, "s")
    elif move == "p" and d.get(i, 0) != "t":
        ans += s
        d[i+k] = d.get(i+k, "t")
print(ans)

Measured memory_bytes: 15392
import math

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

if H == 1 or W == 1:
    print(1)
else:
    o = math.ceil(W/2)
    e = W//2

    if H % 2 == 0:
        print((o+e)*(H//2))
    else:
        print((o+e)*(H//2) + o)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const ll inf =1LL << 62;
const ll mod=1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b,const ll &mod) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b,const ll &mod) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b,const ll &mod) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b,const ll &mod) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
random_device rd;
mt19937 mt(rd());
uniform_int_distribution<int> dice(1,6);
uniform_real_distribution<double> score(0.0,10.0);

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

    ll K, A, B; cin >> K >> A >> B;

    ll res = -1;
    if(A >= K){
        res = 1;
    }
    else if(A > B){
        res = (K - B - 1) / (A - B) * 2 + 1;
    }

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 256
#include<cmath>
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<set>
#include<vector>
#include<string>
#include<map>
typedef long long ll;
using namespace std;
const double pi=4*atan(1.0);
const ll mod=1e9+7;
const int inf=0x3f3f3f3f;
int main()
{
	string a;
	int n;
	cin>>n>>a;
	if(n>=a.size())cout<<a;
	else
	{
		cout<<a.substr(0,n)<<"...";
	}
	return 0;
}


Measured memory_bytes: 3620
N = int(input())
S = input()

ans = S.count('R') * S.count('G') * S.count('B')
for i in range(N):
    for j in range(i + 1, N):
        if (j + j - i < N) and ({S[i], S[j], S[j + j - i]} == {'R', 'G', 'B'}):
            ans -= 1

print(ans)


Measured memory_bytes: 68264
using System;

public class Hello
{
    public static void Main()
    {
        Console.ReadLine();
        string[] line = Console.ReadLine().Trim().Split(' ');
        var a = Array.ConvertAll(line, int.Parse);
        var q = int.Parse(Console.ReadLine().Trim());
        for (int i = 0; i < q; i++)
        {
            var k = int.Parse(Console.ReadLine().Trim());
            Console.WriteLine(Array.BinarySearch(a, k) < 0 ? 0:1);
        }
    }
}



Measured memory_bytes: 22812
#include<stdio.h>
int main(void){
  int a,b;
  scanf("%d %d",&a,&b);
  if(a>b)for(int i=0;i<a;i++)printf("%d",b);
   else for(int i=0;i<b;i++)printf("%d",a);
                                    
  return 0;
}

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

using namespace std;

#define rep(i,n) for(int i = 0; i < (n); ++i)
 
typedef long long ll;
typedef char str255[256];

#define BIG_PRIME 1'000'000'007
#define BP_remainder(x) ((x) % BIG_PRIME)

const int INF = 1 << 30;
const int INF_NEG = INF * -1;
const ll INF_LONG = 1LL << 62;
const ll INF_LONG_NEG = INF_LONG * -1;

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

    int ans = (N - 1) / (K - 1);
    if ((N - 1) % (K - 1)) ++ans;
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 640
#include <stdio.h>

int main(void){

    int m,f,r;
    int kei;

    while(1){
        scanf("%d %d %d",&m,&f,&r);
        if(m==-1 && f==-1 && r==-1){
            break;
        }
        kei=m+f;
        if(m==-1 || f==-1){
            printf("F\n");
        }else if(kei >=80){
            printf("A\n");
        }else if(kei >=65 && kei < 80){
            printf("B\n");
        }else if(kei >=50 && kei < 65){
            printf("C\n");
        }else if(kei >= 30 && kei < 50 && r>=50){
            printf("C\n");
        }else if(kei >= 30 && kei < 50){
            printf("D\n");
        }else if(kei < 30){
            printf("F\n");
        }
    }
}


Measured memory_bytes: 2148
#[allow(unused_macros)]
macro_rules! parse_line {
    ( $t:ty ) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            iter.next().unwrap().parse::<$t>().unwrap()
        }
    );

    ( $( $t:ty), +) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ( $(iter.next().unwrap().parse::<$t>().unwrap()),* )
        }
    );
}

#[allow(unused_macros)]
macro_rules! read_line {
    () => {{
        let mut line = String::new();
        ::std::io::stdin().read_line(&mut line).unwrap();
        line.pop();
        line
    }};
}

#[allow(unused_macros)]
macro_rules! parse_vec {
    ( $t:ty ) => {{
        let mut line = String::new();
        ::std::io::stdin().read_line(&mut line).unwrap();
        let iter = line.split_whitespace();
        iter.map(|v| v.parse::<$t>().unwrap()).collect::<Vec<_>>()
    }};
}

use std::cell::RefCell;
use std::rc::Rc;

struct UnionFind {
    par: Rc<RefCell<Vec<usize>>>,
}

impl UnionFind {
    fn new(n: usize) -> Self {
        let uf = UnionFind {
            par: Rc::new(RefCell::new(vec![0; n])),
        };
        for i in 0..n {
            uf.par.borrow_mut()[i] = i;
        }
        uf
    }

    fn root(&self, x: usize) -> usize {
        let t = self.par.borrow()[x];
        if t == x {
            x
        } else {
            self.par.borrow_mut()[x] = self.root(t);
            self.par.borrow()[x]
        }
    }

    fn same(&self, x: usize, y: usize) -> bool {
        self.root(x) == self.root(y)
    }

    fn unite(&self, mut x: usize, mut y: usize) {
        x = self.root(x);
        y = self.root(y);
        if x == y {
            return;
        }

        self.par.borrow_mut()[x] = y;
    }
}

fn solve(xys: &[(usize, usize)]) -> usize {
    let n = xys.len();
    const MAX: usize = 110000;

    let uf = UnionFind::new(MAX * 2 + 1);

    let mut mx = vec![0; MAX * 2 + 1];
    let mut my = vec![0; MAX * 2 + 1];

    for &(x, y) in xys.iter() {
        uf.unite(x, y + MAX);
    }

    for i in 1..(MAX + 1) {
        mx[uf.root(i)] += 1;
        my[uf.root(i + MAX)] += 1;
    }

    let mut ans = 0;

    for i in 1..(MAX * 2 + 1) {
        ans += mx[i] * my[i];
    }

    ans - n
}

fn main() {
    let n = parse_line!(usize);
    let xys = (0..n)
        .map(|_| parse_line!(usize, usize))
        .collect::<Vec<_>>();
    println!("{}", solve(&xys));
}

#[test]
fn solve_test() {
    assert_eq!(solve(&[(1, 1), (5, 1), (5, 5)]), 1);
    assert_eq!(solve(&[(10, 10), (20, 20)]), 0);
}


Measured memory_bytes: 12540
import java.util.Scanner;
 
class Main{
 
    public static void main(String[] args){
 
        Scanner scanner = new Scanner(System.in);
        int a = scanner.nextInt();
        int b = scanner.nextInt();
        int c = scanner.nextInt();
        int k = scanner.nextInt();
        scanner.close();
        
        int sum = 0;
        if(a>=k){
            sum = k;
            System.out.println(sum);
            return;
        }else{
            sum += a;
            if(b>=k-a){
                System.out.println(sum);
                return;
            }else{
                sum -= k-a-b;
                System.out.println(sum);
            }
        }
    }
 
}

Measured memory_bytes: 26992
import java.util.Scanner;

public class Main {

	static int a,b;
    static int[][] tile;
    public static void main(String args[]){

        Scanner s=new Scanner(System.in);

        while(true){
            b=s.nextInt();
            a=s.nextInt();
            if(a==0)System.exit(0);
            tile=new int[a][b];
            String now;
            int p=0,q=0;
            for(int i=0;i<a;i++){
                now=s.next();
                for(int j=0;j<b;j++){
                    if(now.charAt(j)=='#')tile[i][j]=0;
                    else if(now.charAt(j)=='.')tile[i][j]=1;
                    else{
                        tile[i][j]=0;
                        p=i;
                        q=j;
                    }
                }
            }


            System.out.println(solve(p,q));
        }
    }
    static int solve(int m,int n){
        int count=0;

        tile[m][n]=0;

        if(m>0)
            if(tile[m-1][n]==1)count+=solve(m-1,n);
        if(m<a-1)
            if(tile[m+1][n]==1)count+=solve(m+1,n);
        if(n>0)
            if(tile[m][n-1]==1)count+=solve(m,n-1);
        if(n<b-1)
            if(tile[m][n+1]==1)count+=solve(m,n+1);


        return count+1;
    }

}



Measured memory_bytes: 38272
eval"N,K,*A="+`dd`.split*?,
f=A.pop(N).sort.reverse.zip A.sort
p (0..2**40).bsearch{|x|d=K
#f.map{|f,a|t=x-f*a;t<0&&d+=t/f}
f.map{|f,a|x<f*a&&d+=x/f-a}
d>=0}

Measured memory_bytes: 91656
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int,int> pint;
typedef vector<pint> vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=n-1;i>=(0);i--)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define all(v) (v).begin(),(v).end()
#define eall(v) unique(all(v), v.end())
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
const int MOD = 1e9 + 7;
const int INF = 1e9;
const ll INFF = 1e18;


int main() {
	double a, b; cin >> a >> b;
	cout << ceil((a + b)/2 )<< endl;
	return 0;
}

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

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

    int n, q;
    string s;
    cin >> n >> q >> s;
    vector<int> occ(n);
    for (int i = n-2; i >= 0; --i) {
        occ[i] += occ[i+1];
        occ[i] += s[i] == 'A' && s[i+1] == 'C';
    }
    for (int i = 0, l, r; i < q; ++i) {
        cin >> l >> r;
        cout << occ[l-1]-occ[r-1] << "\n";
    }
}

Measured memory_bytes: 1488
#include<stdio.h>

int main(void){
	int x;
	int y;
	int z;
	int i = 0;
	
	while(i<3000){
		scanf("%d %d",&x,&y);
		i++;
		if(x==0&&y==0){
			break;
		}else{
			if(x>y){
				z=x;
				x=y;
				y=z;
			}		
			printf("%d %d\n",x,y);
		}
	}
		return 0;
	
}
		

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(a)     (a).begin(),(a).end()
#define VI         vector<int>
#define MOD 1000000007

using ll = long long int;
using P = pair<int,int>;

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

const ll INF=(ll)1e19;
//const int INF=(1<<30);

int main(){
  int N,M,X,Y;
  cin >> N >> M >> X >> Y;
  VI x(N),y(M);
  REP(i,N)cin >> x[i];
  REP(i,M)cin >> y[i];

  sort(ALL(x));
  sort(ALL(y));

  if(x.back() < y.front() && X < y.front() && x.back() < Y){
    cout << "No War" << endl;
  }else{
    cout << "War" << endl;
  }

}



Measured memory_bytes: 256
while True:
    m,nMin,nMax=map(int,raw_input().split())
    if m==0: break
    p=[]
    for _ in xrange(m):
        p.append(int(raw_input()))
    maxN=0
    maxD=0
    for i in xrange(nMin-1,nMax):
        if maxD <= p[i]-p[i+1]:
            maxD = p[i]-p[i+1]
            maxN = i+1
    print maxN

Measured memory_bytes: 6324
// Package main provides
//
// File:  main.go
// Author: ymiyamoto
//
// Created on Thu Jul 11 07:49:35 2019
//
package main

import "fmt"

func min(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}

func main() {
	var l, r int64
	fmt.Scan(&l, &r)
	if r-l > 2019 {
		fmt.Println(0)
		return
	}

	ans := l * r
	for i := l; i < r; i++ {
		for j := i + 1; j <= r; j++ {
			ans = min(ans, (i*j)%2019)
		}
	}
	fmt.Println(ans)
}


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


int main() {
  int n, a;
  cin >> n;
  int ans = 0;
  for (int i=0; i<n; i++) {
    cin >> a;
    if ((a % 2 == 0) & (a % 3 != 0) & (a % 5 != 0)) {
      ans ++;
    }
  }
  if (ans > 0) {
      cout << "DENIED" << endl;
  }
else {
  cout << "APPROVED" << endl;
    }
}

Measured memory_bytes: 256
print('?', 10**10)
if input() == 'Y':
    for nod in range(10):
        print('?', 10**nod+1)
        if input() == 'Y':
            break
    ans = 10**nod
else:
    for nod in range(1, 10):
        print('?', 10**nod)
        if input() == 'Y':
            continue
            nod -= 1
        break
    ok = 10**(nod-1)
    ng = 10**nod
    while abs(ok - ng) > 1:
        med = (ok + ng)//2
        print('?', med*10+1)
        if input() == 'N':
            ok = med
        else:
            ng = med
    ans = ok+1
print('!', ans)

Measured memory_bytes: 38848
let () =
  let n = Scanf.scanf "%d" (fun n -> n) in
  let t = Scanf.scanf " %d %d" (fun t a -> (a - t) * 1000) in
  let hs =
    Array.init n (fun i ->
        (Scanf.scanf " %d" (fun h -> abs ((6 * h) + t)), i + 1) )
  in
  let ans, _ =
    Array.fold_left
      (fun (ans, min_h) (h, ind) ->
        if min_h < h then (ans, min_h) else (ind, h) )
      (1, fst hs.(0))
      hs
  in
  Printf.printf "%d\n" ans


Measured memory_bytes: 896
#include<iostream>
#include<complex>
#include<cmath>
#include<stdio.h>
using namespace std;
typedef complex<double> xy_t;
xy_t P[110];
int main(){
    int N;
    double x,y;
    while(scanf("%lf,%lf",&x,&y)!=EOF){
        P[N++]=xy_t(x,y);
    }
    double sum=0.0;
    for(int i=0;i<N-2;++i){
        xy_t a=P[0],b=P[i+1],c=P[i+2];
        double d1=abs(b-a),d2=abs(c-b),d3=abs(a-c);
        double z=(d1+d2+d3)/2.0;
        sum+=sqrt(z*(z-d1)*(z-d2)*(z-d3));
    }
    printf("%.6f\n",abs(sum));
}

Measured memory_bytes: 3168
n = input()
l = len(n)
d = [9, 0, 900, 0, 90000, 0, 9000000]
if l % 2 == 0:
    print(sum(d[:l]))
else:
    print(sum(d[:l - 1]) + int(n) - (10 ** (l - 1) - 1))


Measured memory_bytes: 2940
/*
    ( ´-ω･)︻┻┳══━一一一一一一一				(× _ ×)
	
	Stay Low. Go Fast
	Kill First. Die Last
	One Shot. One Kill
	No Luck. Pure Skill 
*/

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

/*************************** MACROS **************************/
#define ld long double
#define ll long long  
#define ull unsigned long long
#define loop(i,x,y) for(ll i=x;i<y;i++)
#define rloop(i,x,y) for(ll i=x;i>=y;i--)
#define vll vector<ll>
#define pb push_back
#define S second
#define F first
#define B begin()
#define E end()
#define W(x) while(x--)
#define pll pair< ll,ll >
#define vpll vector< pll >
#define qll queue<ll>
#define dqll deque<ll>
#define qpll queue<pll>
#define dqpll deque<pll>
#define pqll priority_queue<ll>
#define pqpll priority_queue<pll>
#define Line cout<<"\n**************************\n\n";

/*************************** CONST ******************************/

const ll MOD = 1000000007;
const ll MOD1 = 998244353;
const ll MIN_LL = -1e18;
const ll MAX_LL = 1e18;
const int MAX_INT = 1e9;
const int MIN_INT = -1e9;
const ld pie = 3.1415926535;
 
/************************** POW UTIL *****************************/
 
ll fpow(ll n,ll p){;ll m=1;while(p){if(p%2)m*=n;p>>=1;n*=n;}return m;}
ll mfpow(ll n,ll p,ll M){ll m=1;n%=M;while(p){if(p%2)m=(m*n)%M;n=(n*n)%M;p>>=1;}return m%M;}
 
/************************* PRINT UTIL *****************************/

template<class T> inline ostream& operator<<(ostream& o,vector<T> v){for(auto i:v)o<<i<<" ";return o;};
template<class T> inline ostream& operator<<(ostream& o,set<T> s){for(auto i:s)o<<i<<" ";return o;}
template<class T> inline ostream& operator<<(ostream& o,multiset<T> s){for(auto i:s)cout<<i<<" ";return o;}
template<class T1,class T2> inline ostream& operator<<(ostream& o,pair<T1,T2> p){o<<p.F<<" "<<p.S<<"\n";return o;}
template<class T1,class T2> inline ostream& operator<<(ostream& o,map<T1,T2> m){for(auto p:m)o<<p.F<<" "<<p.S<<"\n";return o;}

/*************************** VARIABLES **************************/

const vll days={31,28,31,30,31,30,31,31,30,31,30,31};
 
bool br,br1,br2; 
char ch,ch1,ch2;
 

ll n,m,k,x,y,z,mini,maxi,l,r,sum,t,w;
pll p,p1,p2;

string s,s1,s2;

set<ll> st,st1,st2;
multiset<ll> mst; 

map<ll,ll> mp;

/**************************** FXNS ****************************/

void solve()
{

	cin>>s1>>s2;

	n = s1.length();

	for(int i=0;i<n;i++)x += s1[i] != s2[i];

	cout<<x<<endl;

}
 
/*************************** MAIN ****************************/
 
int main(){
 
 
	// #ifndef ONLINE_JUDGE
	        // freopen("input.txt", "rt", stdin);
	        // freopen("output.txt", "wt", stdout);
	// #endif
 
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);cout.tie(NULL);

	solve();
 
	return 0;
}


Measured memory_bytes: 3900