akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int main()
{
	unsigned long long a,b,c,d;
	cin>>a>>b>>c>>d;
	if(a==b && b==c && c==d)
	{
	  cout<<0;
	  return 0;
    }
	unsigned long long ans=0;
	unsigned long long s=b-a;
	unsigned long long k1=b/c-a/c;
	if(a%c==0)
	  k1++;
	unsigned long long k2=b/d-a/d;
	if(a%d==0)
	  k2++;
	if(c==d)
	  ans=k1;
	else
	  ans=k1+k2-(b/(c/__gcd(c,d)*d)-a/(c/__gcd(c,d)*d));
	if(a%(c/__gcd(c,d)*d)==0 && ans)
	  ans--;
	cout<<s+1-ans;
	return 0;
}


Measured memory_bytes: 256
A, B = map(int,input().split())

def f(n):
    ret=[]
    for i in range(1,49):
        a = 2**i
        b = (n+a//2)//a
        if a>(n+a//2):
            break
        c = (b-1)*(2**(i-1)) + min((n+a//2)-a*b+1, a//2)
        ret.append(c)
    return ret

l1 = f(B)
l2 = f(A-1) if A>0 else []
l2 += [0]*(len(l1)-len(l2))
l3 = []
for i in range(len(l1)):
    l3.append((l1[i]-l2[i])%2)

ans = 0

for i in range(len(l3)):
    ans += (2**i)*l3[i]

print(ans)

Measured memory_bytes: 3064
#include <stdio.h>
#include <cctype>
#include <limits.h>
#include <math.h>
#include <complex>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cstring>
#include <string>
#include <sstream>
#include <algorithm>
#include <iomanip>
#include <iostream>

#define VARIABLE(x) cerr << #x << "=" << x << endl
#define BINARY(x) static_cast<bitset<16> >(x);
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for (int i=m;i<(int)(n);i++)
#define if_range(x, y, w, h) if (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))

const int INF = 1000000000;
const double EPS = 1e-8;
const double PI = 3.14159;
int dx[4]={-1, 0, 1, 0}, dy[4]={0, -1, 0, 1};
using namespace std;
typedef pair<int, int> P;

/** Problem0522 : JOI and IOI **/
int main()
{
	string s;
	while (cin>>s) {
		int joi=0, ioi=0;
		if (s.size()>=3) {
			for (int i=0; i<=s.size()-3; i++) {
				string t = s.substr(i, 3);
				if (t == "JOI")
					joi++;
				else if (t == "IOI")
					ioi++;
			}
		}
		cout << joi << endl;
		cout << ioi << endl;
	}
}

Measured memory_bytes: 1212
comparison_a, comparison_b, comparison_c = map(int, input("").split())

if comparison_a > comparison_b:
    temp = comparison_a
    comparison_a = comparison_b
    comparison_b = temp

if comparison_a > comparison_c:
    temp = comparison_a
    comparison_a = comparison_c
    comparison_c = temp

if comparison_b > comparison_c:
    temp = comparison_b
    comparison_b = comparison_c
    comparison_c = temp

print(f"{comparison_a} {comparison_b} {comparison_c}")



Measured memory_bytes: 5608
#include <bits/stdc++.h>
#define pb push_back
#define fr first
#define sc second
#define mk make_pair
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
const double eps = 0.000000001;
const int MOD = 1000000009;
const int N = 100005;
int main()
{
      int a, b, c;
      cin >> a >> b >> c;
      a *= 100;
      a += c + b * 10;
      if (a % 4 == 0) cout << "YES" << endl;
      else cout << "NO" << endl;
      return 0;
}






Measured memory_bytes: 256
import sys


atoe = []
for i in range(5):
    atoe.append(int(sys.stdin.readline()))

k = int(sys.stdin.readline())

flag = 0
for i in range(5):
    for j in range(4):
        if abs(atoe[i] - atoe[j+1]) <= k:
            continue
        else:
            flag = 1

if flag > 0:
    print(":(")
else:
    print("Yay!")


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

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back

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

int n;
int m;

const int mod = 998244353;
const int maxn = 5e6 + 5;

int fac[maxn], inv[maxn];

int qpow(int a, int n){
    int ret = 1;
    while(n > 0){
        if(n & 1){
            ret = 1LL * ret * a % mod;
        }
        a = 1LL * a * a % mod;
        n >>= 1;
    }
    return ret;
}

void pre_comb(){
    fac[0] = 1;
    for(int i = 1;i < maxn;i++){
        fac[i] = 1LL * fac[i - 1] * i % mod;
    }
    inv[maxn - 1] = qpow(fac[maxn - 1], mod - 2);
    for(int i = maxn - 2;i >= 0;i--){
        inv[i] = 1LL * inv[i + 1] * (i + 1) % mod;
    }
}

int comb(int n, int m){
    if(m > n or m < 0) return 0;
    return 1LL * fac[n] * inv[m] % mod * inv[n - m] % mod;
}

int solve(int m, int n, int b){
    int ret = 0;
    for(int a = 0;a <= b;a++){
        if((m - a) & 1)
            continue;
        ret = (ret + 1LL * comb(n, a) * comb((m - a) / 2 + n - 1, n - 1)) % mod;
    }
    return ret;
}

int main(){
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    pre_comb();
    cin >> n >> m;
    int ans = solve(m * 3, n, m);
    int tmp = (solve(m, n, m) - solve(m, n - 1, m) + mod) % mod;
    tmp = 1LL * n * tmp % mod;
    ans = (ans - tmp + mod) % mod;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 39296
dict = ['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z']
new_str = ''
S = int(input())
strs = input()
 
for x in strs:
  new_idx = (dict.index(x)+S)%26
  new_str += str(dict[new_idx])
  
print(new_str)

Measured memory_bytes: 3064
#include <stdio.h>

int main()
{
	int height = 0, width = 0;
	
	scanf("%d %d", &height, &width);
	
	if((1 > height) || (100 < height))
	{
		return 1;
	}
	
	if((1 > width) || (100 < width))
	{
		return 1;
	}
	
	printf("%d %d\n", height * width, 2 * (height + width));
	
	return 0;
}


Measured memory_bytes: 2724
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define eps 1e-9
#define maxp 100000000000000000000
#define mod 1000000007
#define pi 3.141592653589793238
#define sin(s) scanf("%lld",&s);
#define sout(s) printf("%lld\n",s);
#define in(s) cin>>s
#define in2(a,b) cin>>a>>b
#define in3(a,b,c) cin>>a>>b>>c
#define vll vector<ll>
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define nl '\n'
#define sp ' '
#define gear_change ios_base::sync_with_stdio(false),cin.tie(0)
#define nfl(i,n) for(i=0;i<n;i++)
#define sfl(i,s,e) for(i=s;i<e;i++)
#define ufl(i,n) for(i=n-1;i>=0;i--)
ll get(ll n){
	return (n*(n+1))/2;
}
void solve(){
	ll a,b,i;
	cin>>a>>b;
	for(i=1;i<1000;i++){
		ll sum=get(i);
		ll sum2=get(i+1);
		if(sum-a==sum2-b){
			cout<<sum-a<<endl;
			return;
		}
	}
}	
int main(){
	gear_change;
	ll test=1;
	// in(test);
	while(test--){
		solve();
	}
}	


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#define LEN 100005
 
typedef struct pp {
  char name[100];
  int t;
} P;
 
P Q[LEN];
int head, tail, n;
 
void enqueue(P x) {
  Q[tail] = x;
  tail = (tail + 1) % LEN;
}
 
P dequeue() {
  P x = Q[head];
  head = (head + 1) % LEN;
  return x;
}
 
int min(int a,int b) {
  return a < b ? a : b; 
}
 
int main() {
  int elaps = 0, c;
  int i, q;
  P u;
  char str[64];
  
  scanf("%d %d",&n ,&q);
  for(i=1; i<=n; i++) {
    scanf("%s", Q[i].name);
    scanf("%d", &Q[i].t);
  }
  head = 1; tail = n + 1;
 
  while(head != tail) {
    u = dequeue();
    c = min(q, u.t);
    u.t -= c;
    elaps += c;
    if(u.t > 0) enqueue(u);
    else {
      printf("%s %d\n",u.name,elaps);
    }
  }
  return 0;
}


Measured memory_bytes: 11880
#include <vector>
#include <map>
#include <set>
#include <cmath>
#include <iostream>
#include <algorithm>

typedef char                SINT8;
typedef unsigned char       UINT8;
typedef short               SINT16;
typedef unsigned short      UINT16;
typedef int                 SINT32;
typedef unsigned int        UINT32;
typedef long long           SINT64;
typedef unsigned long long  UINT64;
typedef double              DOUBLE;

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))
#define rep(i,a,b) for(int (i)=int(a);(i)<int(b);(i)++)

#define INF 1e9;
#define MOD 1e9+7;
#define INF64 1e18;

#define F first
#define S second


using namespace std;

int main() {

	SINT32 A,B;
	SINT32 ANS = 0;

	cin >> A >> B;
	
	rep(i,A,B+1) {
		if (((i/10000)%10) == (i%10)) {
			if (((i/1000)%10) == ((i/10)%10)) {
				ANS++;
			}
		}
	}

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

//	sort(DATA.begin(),DATA.end());
//	sort(DATA.begin(),DATA.end(),std::greater<SINT32>());
//	__gcd(ANS,DATA[i]);

//	// DATA.emplace_back(BUF);	//後ろに追加

//  DATA.erase(std::unique(DATA.begin(), DATA.end()), DATA.end());	//ソート後に使用

//	DATA.insert(DATA.begin() + X, 0);	//X番目の要素に0を挿入


//	vector<vector<SINT32>> DP(N,vector<SINT32>(3));　//2次元配列

/*
	SINT32 M = 3;
	vector<pair<SINT32,SINT32>> DATA2(M);
	for (SINT32 i = 0; i < M; i++) {
		cin >> DATA2[i].first;
		cin >> DATA2[i].second;
	}
	sort(DATA2.begin(),DATA2.end());
	cout << DATA2[0].first << endl;
	cout << DATA2[0].second << endl;
*/

// 	vector<pair<int,pair<int,int>>> DATA(M);
//	cin >> DATA[i].first;
//	cin >> DATA[i].second.first;
//	cin >> DATA[i].second.second;


//		APOSI = lower_bound(ADATA.begin(),ADATA.end(),QDATA[i]) - ADATA.begin();	//key以上を探す
//		BPOSI = lower_bound(BDATA.begin(),BDATA.end(),QDATA[i]) - BDATA.begin();


/* 文字列回転
	string N;
	cin >> N;
	N = N[N.length()-1] + N.substr(0,N.length()-1);
*/

/* SET コンテナ
	set<SINT32> DATA;
	for (SINT32 i = 0; i < N; i++) {
		SINT32 buf;
		cin >> buf;
		DATA.insert(buf);
	}

	//全表示
    set<string>::iterator it; //  イテレータを用意
    for(it = DATA.begin(); it != DATA.end(); it++) {
        cout << *it << endl;
    }

	//N番目を一部表示
	set<string>::iterator it; //  イテレータを用意
	it = DATA.begin();
	rep (i,0,N) {
		it++;
	}
	cout << *it << endl;
*/

/* map
	map<string,SINT32> mp;
	SINT32 N = 0;
	SINT32 mx = 0;

	cin >> N;
	for (SINT32 i = 0; i < N; i++) {
		string s;
		cin >> s;
		mp[s]++;
	}
	for(auto it=mp.begin();it!=mp.end();it++) {
		mx=max(mx,it->second);
	}

*/

Measured memory_bytes: 256
import sys

def input():
    return sys.stdin.readline().strip()

def main():
    N = int(input())
    ans = 0
    for i in range(1,N+1):
        Y = N // i
        ans += (Y * (Y + 1) * i) // 2
    print(ans)
if __name__ == "__main__":
    main()

Measured memory_bytes: 9048
N = int(input())
A = [list(map(int, input().split())) for _ in range(N)]
Map = [[] for _ in range(N)]
ans = 0
for i in range(N):
    for j in range(i+1, N):
        for k in range(N):
            if A[i][j] != A[j][i]:
                print(-1)
                exit()
            if k == i or k == j:
                continue
            if A[i][j] > A[i][k] + A[k][j]:
                print(-1)
                exit()
            elif A[i][j] == A[i][k] + A[k][j]:
                break
        else:
            Map[i].append(j)
            Map[j].append(i)
            ans += A[i][j]
print(ans)


Measured memory_bytes: 75420
from sys import stdin
l = stdin.readline().rstrip().split()

cnt5 = cnt7 = 0

for ln in range(3):
	if l[ln] == '5' : cnt5 += 1
	if l[ln] == '7' : cnt7 += 1

if cnt5 == 2 and cnt7 == 1 : print('YES')
else : print('NO')


Measured memory_bytes: 38256
s = input()
YYMM = 0
MMYY = 0
if 1 <= int(s[2:4]) <= 12: YYMM = 1
if 1 <= int(s[0:2]) <= 12: MMYY = 1
if YYMM and MMYY:
  print('AMBIGUOUS')
  quit()
elif YYMM:
  print('YYMM')
  quit()
elif MMYY:
  print('MMYY')
  quit()
else:
  print('NA')
  quit()

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

using namespace std;
long long int ara[100009];
int main()
{
    long long int n, k, now, tmp, rng, sum=0, i;
    cin >> n >> k;
    while(n--)
    {
        cin >> tmp >> rng;
        ara[tmp] += rng;
    }
    for(i=1;;i++)
    {
        sum += ara[i];
        if(sum>=k) cout<<i<<endl, exit(0);
    }
    return 0;
}


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

using namespace std;
const int N = 105;

int a[N], k, t, m;

void init(){
	scanf("%d%d",&k,&t);
	for(int i = 0; i < t; i++){
		scanf("%d",&a[i]);
		m = max(m,a[i]);
	}
	int res = max(0, 2 * m - k - 1);
	printf("%d\n",res);
}

int main(){
	
	init();
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <set>
#include <algorithm>
#include <unordered_map>
#include <queue>
#include <iomanip>
#include <map>
#include <utility>
#include <numeric>
#include <chrono>
#include <ctime>
#include <cassert>
#include <bitset>
#include <iterator>
#include <cmath>
#include <stack>
#include <random>

#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define debug(x) cerr << #x << ": " << x << ", "
#define debugln(x) cerr << #x << ": " << x << '\n'

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; }

using namespace std;
using ll = long long;
using P = pair<ll, ll>;

//constexpr ll mod = 998244353;
constexpr ll mod = 1e9+7;
const double PI = acos(-1.0);
mt19937_64 engine(chrono::steady_clock::now().time_since_epoch().count());

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

  int n; cin >> n;
  string s; cin >> s;
  vector<int> white(n+1), black(n+1);

  for(int i=n-1; i>=0; i--) {
    white[i] = white[i+1];
    if (s[i] == '#') {
    } else {
      white[i]++;
    }
  }

  for(int i=0; i<n; i++) {
    black[i+1] = black[i];
    if (s[i] == '#') {
      black[i+1]++;
    }
  }

  int ans = INT_MAX;
  for(int i=0; i<=n; i++) {
    //debug(black[i]);debugln(white[i]);
    int now = black[i] + white[i];
    chmin(ans, now);
  }
  cout << ans << endl;
}

Measured memory_bytes: 2196
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long int;
using ull = unsigned long long int;
using P = pair<ll, ll>;

ll sum(ll x){
    ll res = 0;
    while(x > 0){
        res += x%10;
        x /= 10;
    }
    return res;
}

ll prod(ll x){
    ll res = 1;
    while(x > 0){
        res *= (x%10+1);
        x /= 10;
    }
    return res;
}

map<ll,ll> dp[15][3][150];

int main(){
    string d;
    cin >> d;
    int n = d.size();
    ll S = sum(stoll(d)), P = prod(stoll(d));
    dp[0][1][0][1] = 1;
    for(int i=0;i<n;i++){
        int D = d[i] - '0';
        for(int f=0;f<3;f++){
            for(int j=0;j<=S;j++){
                for(int x = 0; x <= 9; x++){
                    if(j+x <= S){
                        for(auto p : dp[i][f][j]){
                            int k = 1;
                            if(x < D) k = 0;
                            if(x > D) k = 2;
                            dp[i+1][(f!=1?f:k)][j+x][p.first*(x+1)] += dp[i][f][j][p.first];
                        }
                    }
                }
            }
        }
    }
    ll ans = 0;
    for(int i=0;i<S;i++){
        for(int f=0;f<3;f++){
            for(auto p : dp[n][f][i]){
                ans += p.second;
            }
        }
    }
    for(int f=0;f<3;f++){
        for(auto p : dp[n][f][S]){
            if(p.first < P){
                ans += p.second;
            }
        }
    }
    for(auto p : dp[n][0][S]){
        if(p.first == P) ans += p.second;
    }
    cout << ans << endl;
    return 0;
}


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

int main(){
  int A,B;
  cin >> A >> B;
  vector <int> v(3);
  v.at(0)=A+B;
  v.at(1)=A-B;
  v.at(2)=A*B;
  sort(v.begin(),v.end());
  cout << v.at(2) << endl;
  return 0;
}


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

int main() {
	int a, b;
	scanf("%d%d", &a, &b);
	if (a > 0)printf("Positive");
	else if (a <= 0 && b >= 0)printf("Zero");
	else {
		int z = b - a;
		if (z & 1)printf("Positive");
		else printf("Negative");
	}
	printf("\n");
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <string>
#include <vector>
#include <utility>
#include <complex>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <tuple>
#include <bitset>
#include <limits>
#include <algorithm>
#include <array>
#include <random>
#include <complex>
#include <regex>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef complex<ld> compd;
#define quickIO()	{cin.tie(0);	cout.sync_with_stdio(false);}
#define reach(i,a)	for(auto i:a)
#define rep(i,n)	for(int i=0;i<(int)n;i++)
#define REP(i,n)	for(int i=0;i<=(int)n;i++)
#define srep(i,a,n)	for(int i=a;i<(int)n;i++)
#define SREP(i,a,n)	for(int i=a;i<=(int)n;i++)
#define rrep(i,n)	for(int i=n-1;i>=0;i--)
#define RREP(i,n)	for(int i=n;i>=0;i--)
#define all(a)	(a).begin(),(a).end()
#define mp(a,b)	make_pair(a,b)
#define mt	make_tuple
#define pb	push_back
#define fst	first
#define scn second
int bitcnt(ll x) {
	x = ((x & 0xAAAAAAAAAAAAAAAA) >> 1) + (x & 0x5555555555555555);
	x = ((x & 0xCCCCCCCCCCCCCCCC) >> 2) + (x & 0x3333333333333333);
	x = ((x & 0xF0F0F0F0F0F0F0F0) >> 4) + (x & 0x0F0F0F0F0F0F0F0F);
	x = ((x & 0xFF00FF00FF00FF00) >> 8) + (x & 0x00FF00FF00FF00FF);
	x = ((x & 0xFFFF0000FFFF0000) >> 16) + (x & 0x0000FFFF0000FFFF);
	x = ((x & 0xFFFFFFFF00000000) >> 32) + (x & 0x00000000FFFFFFFF);
	return x;
}
int bitcnt(int x) {
	x = ((x & 0xAAAAAAAA) >> 1) + (x & 0x55555555);
	x = ((x & 0xCCCCCCCC) >> 2) + (x & 0x33333333);
	x = ((x & 0xF0F0F0F0) >> 4) + (x & 0x0F0F0F0F);
	x = ((x & 0xFF00FF00) >> 8) + (x & 0x00FF00FF);
	x = ((x & 0xFFFF0000) >> 16) + (x & 0x0000FFFF);
	return x;
}
ll sqrt(ll x) {
	ll left = 0, right = x;
	rep(i, 100) {
		ll mid = (left + right) >> 1;
		if (mid*mid <= x)	left = mid;
		else	right = mid;
	}
	return left;
}
ll gcd(ll a, ll b) {
	return a%b == 0 ? b : gcd(b, a%b);
}
#define debug(x)	printf("Case #%d: ", x)
#define DEBUG 0
const ll inf = 1e18;
const ll mod = 1e9 + 7;
const ld eps = 1e-15;
const int dx[] = { 1,0,-1,0,0 };
const int dy[] = { 0,1,0,-1,0 };

// bit全探索の解法
// 取り敢えずループ回して、式を生成して解きます。

int main() {
	string s;	cin >> s;
	int end = (1 << (s.size()-1));
	ll ret = 0;
	rep(i, end) {
		// 確定したものは全部retに足していきます
		ll add = (s[0] - '0');
		srep(j, 1, s.size()) {
			if (i&(1 << (j - 1))) {
				// +を手前に入れて足す
				ret += add;
				add = s[j] - '0';
			}
			else {
				// +を入れない
				add = add * 10 + s[j] - '0';
			}
		}
		ret += add;
	}
	cout << ret << endl;
}

Measured memory_bytes: 256
#include <utility>
#include <vector>
#include <iostream>
#include <algorithm>
#include <set>
#define REP(i,n) for(int i=0;i<n;i++)
typedef unsigned long ul;
typedef unsigned long long ull;
typedef long long ll;
using namespace std;
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
    int A, B, C;
    cin >> A >> B>> C;
    string ans = "";
    if(A> B){
        if(C < B || A < C){
            ans = "No";
        }else{
            ans = "Yes";
        }
    }else{
        if (C < A || B < C){
            ans = "No";
        }else{
            ans = "Yes";
        }
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import sys

def swap(a, i, j):
    tmp = a[j]
    a[j] = a[i]
    a[i] = tmp
    return a

def list_to_string(a):
    s = ""
    for n in a:
        s += str(n) + " "
    return s.strip()

num = int(sys.stdin.readline().strip())

array = map(lambda x: int(x), sys.stdin.readline().strip().split(" "))

flag = True
swap_num = 0

while flag:
    flag = False
    for i in reversed(range(1, len(array))):
        if array[i] < array[i - 1]:
            swap(array, i, i-1)
            flag = True
            swap_num += 1
            
print list_to_string(array)
print str(swap_num)

Measured memory_bytes: 6412
#include <stdio.h>
int month[12]={0,31,29,31,30,31,30,31,31,30,31,30};
char mes[7][11]={
  {"Wednesday"}, {"Thursday"},{"Friday"},{"Saturday"},{"Sunday"},{"Monday"},{"Tuesday"}
};
int main(){
  int m,d;
  int sum=0;
  int i;
  while(1){
    sum=0;
    scanf("%d %d",&m,&d);
    if(m==0 && d==0)break;
    for(i=0;i<m;i++)sum+=month[i];
    sum+=d;
    
    switch(sum%7){
    case 0:printf("%s\n",mes[0]);
      break;
    case 1:printf("%s\n",mes[1]);
      break;
    case 2:printf("%s\n",mes[2]);
      break;
    case 3:printf("%s\n",mes[3]);
      break;
    case 4:printf("%s\n",mes[4]);
      break;
    case 5:printf("%s\n",mes[5]);
      break;
    case 6:printf("%s\n",mes[6]);
      break;
    }
  }
  return 0;
}

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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(x) (x).begin(),(x).end()
#define endl "\n"

using ll = long long;
using P = pair<int,int>;
using mp =  map<char,int>;

const int MOD = 1e9 + 7;
const int INF = 1001001001;


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

    int n;
    cin >> n;

    vector<int> a(n);
    int ans = 0;
    rep(i, n){
        cin >> a[i];
    }

    int cnt = 1;
    rep(i, n){
        if(a[i] == a[i+1]){
            cnt++;
        }else{
            ans += cnt / 2;
            cnt = 1;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <algorithm> //STLͨ���㷨
#include <cmath> //������ѧ����
#include <cstdio> //��������/�������
#include <iostream> //����������/���
#include <cstring> //�ַ�������
#include <string> //�ַ�����
#include <ctime> //�������ʱ��ĺ���
#define itn int
#define fro for
#define ll long long
#define reg register
#define inf 1234567890
#define rep(i,a,b,c) for (int i=a;i<=b;i+=c)
/*#include <bitset> //STLλ������
#include <cstype> //�ַ�����
#include <cerrno> //���������
#include <complex> //������
#include <clocale> //���屾�ػ�����
#include <cstdlib> //������������ڴ���亯��
#include <deque> //STL˫�˶�������
#include <exception> //�쳣������
#include <fstream> //�ļ�����/���
#include <functional> //STL�������㺯��(���������)
#include <limits> //�����������������ֵ����
#include <list> //STL�����б�����
#include <map> //STLӳ������
#include <iomanip> //����������/���
#include <ios> //��������/���֧��
#include <iosfwd> //����/���ϵͳʹ�õ�ǰ������
#include <istream> //����������
#include <ostream> //���������
#include <queue> //STL��������
#include <set> //STL��������
#include <sstream> //�����ַ�������
#include <stack> //STL��ջ����
#include <stdexcept> //��׼�쳣��
#include <streambuf> //�ײ�����/���֧��
#include <utility> //STLͨ��ģ����
#include <vector> //STL��̬��������
#include <cwchar.h>//���ַ�����������/���
#include <cwctype.h> //���ַ�����*/

using namespace std;

int ans;

int max(int x,int y){return x>y?x:y;}

int min(int x,int y){return x<y?x:y;}

int abs(int x){return x>0?x:-x;}

int gcd(int x,int y){return (!y)?x:gcd(y,x%y);}

void exgcd(int a,int b,int &d,int &x,int &y){if (!b){d=a,x=1,y=0;}else{exgcd(b,a%b,d,y,x);y-=x*(a/b);}}

int quick_power(ll a,int b){ll r=1;for (;b;b>>=1,a=a*a)if (b&1) r=r*a;return r;}

inline char read() {
	static const int IN_LEN = 1000000;
	static char buf[IN_LEN], *s, *t;
	return (s == t ? t = (s = buf) + fread(buf, 1, IN_LEN, stdin), (s == t ? -1 : *s++) : *s++);
}
template<class T>
inline void read(T &x) {
	static bool iosig;
	static char c;
	for (iosig = false, c = read(); !isdigit(c); c = read()) {
		if (c == '-') iosig = true;
		if (c == -1) return;
	}
	for (x = 0; isdigit(c); c = read()) x = x * 10 + (c ^ '0');
	if (iosig) x = -x;
}

char sr[10000000],z[20];int C=-1,Z=0;
void Ot(){fwrite(sr,1,C+1,stdout),C=-1;}
void print(int x){
	if (x<0) sr[++C]='-',x=-x;
	while(z[++Z]=x%10+48,x/=10);
	while(sr[++C]=z[Z],--Z);sr[++C]='\n';
}
//int find(int x){return fa[x]=fa[x]==x?x:find(fa[x]);}

//void add(int x,int y,int z){to[++cnt]=y;v[cnt]=z;Next[cnt]=head[x];head[x]=cnt;}
int n,m,l,d[512][512],a,b,c,Q,s,t;

void floyd()
{
	for (int k=1;k<=n;k++)
		for (int i=1;i<=n;i++)
			for (int j=1;j<=n;j++)
				d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
}

int main()
{
	read(n);read(m);read(l);

	for (int i=1;i<=n;i++)
		for (int j=1;j<=n;j++)
			d[i][j]=l+1;

	for (int i=1;i<=m;i++)
	{
		read(a);read(b);read(c);
		d[a][b]=d[b][a]=c;
	}

	floyd();

	for (int i=1;i<=n;i++)
		for (int j=1;j<=n;j++)
			d[i][j]=d[i][j]<=l?1:l+1;

	floyd();

	int T;
	read(T);

	while (T--)
	{
		read(s);read(t);
		print(d[s][t]>l?-1:d[s][t]-1);
	}
	Ot();
	return 0;
}










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

using namespace std;

const int N = 2e5 + 5;

int n;
int px[N], sx[N];
char s[N];

int main() {
  scanf("%d", &n);
  scanf("%s", s + 1);
  for (int i = 1; i <= n; ++i) {
    px[i] = px[i - 1] + (s[i] == '#');
  }
  for (int i = n; i >= 1; --i) {
    sx[i] = sx[i + 1] + (s[i] == '.');
  }

  int ans = N;
  for (int i = 0; i <= n; ++i) {
    ans = min(ans, px[i] + sx[i + 1]);
  }
  printf("%d\n", ans);
  
  return 0;
}


Measured memory_bytes: 2048
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <tuple>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(perm),end(perm)
#define showall(obj) for(auto x:obj)cout<<x<<endl;
typedef long long ll;
typedef pair<int,int> ip;
typedef pair<ll,ll> lp;
typedef vector<int> vint;
typedef vector<ll> vll;
const int inf = 537427207;
const ll INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

int main(){
    int n;cin>>n;
    int t = 0 , m = 0;
    rep(i,n){
        char c; cin>>c;
        if(c=='I')t++;
        else --t;
        m = max(m,t);
    }
    cout<<m<<endl; return 0;
}

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

void solve() {
    string S;
    cin >> S;
    int ans = 0;
    int N = S.size();
    for(int i = 0; i < S.size() / 2; ++i) {
        if(S[i] != S[N - 1 - i]) ans++;
    }
    cout << ans << '\n';
}

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


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

int main()
{
	int q,flip=0;
	string s,a,b;
	cin>>s>>q;
	for(int i=0;i<q;i++)
	{
		int t;
		cin>>t;
		if(t==1)
			flip++;
		else
		{
			int f;
			char c;
			cin>>f>>c;
			f--;
			if(f^(flip%2))
				b.push_back(c);
			else
				a.push_back(c);
		}
	}
	reverse(a.begin(),a.end());
	s=a+s+b;
	if(flip%2)
		reverse(s.begin(),s.end());
	cout<<s;
	return 0;
}

Measured memory_bytes: 1348
// AC - B - Sum of Three Integers

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

int main(){
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  
  int k,s,i,j,r = 0,x; cin >> k >> s;
  for(i = 0;i <= k;i++)
    for(j = 0;j <= k;j++){
      x = s - (i+j);
      if(0 <= x && x <= k)
        r = r + 1;
    }
  cout << r <<"\n";
  return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
int K,i;
long long dp[3][101],ans;
int main(){
  string N;
  cin>>N>>K;
  dp[1][1]=9;
  dp[2][1]=0;
  dp[3][1]=0;
  for(i=2;i<=(int)N.size();i++){
    dp[1][i]=9*i;
    dp[2][i]=81*i*(i-1)/2;
    dp[3][i]=243*i*(i-1)*(i-2)/2;
  }
  if(K==1){cout<<dp[1][(int)N.size()-1]+(N.at(0)-'0')<<endl;}
  if(K==2){
    ans=dp[1][(int)N.size()-1]*(N.at(0)-'0'-1)+dp[2][(int)N.size()-1];
    while((int)N.size()>=2){
      N=N.substr(1);
      if(N.at(0)!='0'){
        ans+=dp[1][(int)N.size()-1]+N.at(0)-'0';
        break;
      }
    }
    cout<<ans<<endl;
  }
  if(K==3){
    ans=dp[3][(int)N.size()-1]+dp[2][(int)N.size()-1]*(N.at(0)-'0'-1);
    while((int)N.size()>=3){
      N=N.substr(1);
      if(N.at(0)!='0'){
        ans+=dp[2][(int)N.size()-1]+dp[1][(int)N.size()-1]*(N.at(0)-'0'-1);
        while((int)N.size()>=2){
          N=N.substr(1);
          if(N.at(0)!='0'){
            ans+=dp[1][(int)N.size()-1]+N.at(0)-'0';
            if(ans!=0){
              cout<<ans<<endl;
              return 0;
            }
          }
          cout<<ans<<endl;
          return 0;
        }
      }
    }
  }
}

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

#define PI 3.14159265359
#define INF 1e9
#define LINF 1e18
#define IMOD 1000000007 
#define irep(i,n) for(int i = 0; i < (int)(n); i++)
#define irep2(i,a,n) for(int i = (int)(a); i <= (int)(n); i++)
#define lrep(i,n) for(long long  i = 0; i < (long long)(n); i++)
#define lrep2(i,a,n) for(long long i = (long long)(a); i <= (long long)(n); i++)

#define irrep(i,n) for(int i = (int)(n); i > -1; i--)
#define irrep2(i,a,n) for(int i = (int)(n); i >= (int)(a); i--)

typedef long long ll;
typedef std::vector<char> v_char;
typedef std::vector<std::vector<char> > v2_char;
typedef std::vector<double> v_double;
typedef std::vector<std::vector<double> > v2_double;
typedef std::vector<int> v_int;
typedef std::vector<std::vector<int> > v2_int;
typedef std::vector<ll> v_ll;
typedef std::vector<std::vector<ll> > v2_ll;
typedef std::vector<std::string> v_string;
typedef std::vector<std::vector<std::string> > v2_string;
typedef std::vector<bool> v_bool;
typedef std::vector<std::vector<bool> > v2_bool;
typedef std::pair<ll, ll> pll;
typedef std::pair<int, int> pii;

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

using namespace std; 

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

    v_int h(n);
    irep(i, n) {
        cin >> h[i];
    }

    int ans = 0;

    while(1) {
        int l = INF, r = n-1;
        irep2(i, 0, n-1) {
            if(h[i] != 0) { 
                l = i;
                break; 
            } 
        }

        if(l == INF) { break; }

        irep2(i, l+1, n-1) {
            if(h[i] == 0) { 
                r = i-1;
                break;
            }
        }
        
        //printf("%d,%d\n", l, r);
        int min_h = INF;
        irep2(i, l, r) {
            min_h = min(min_h, h[i]);
            //cout << min_h << endl;
        }
        irep2(i, l, r) {
            h[i] -= min_h;
        }
        ans += min_h;
        #if 0
        irep(i, n) {
            printf("%d,", h[i]);
        } printf("\n");
        #endif
    }

    cout << ans << endl;
    return 0;
}
/** atcoder **/


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



int main()
{
	ios_base::sync_with_stdio( 0 );
	cin.tie( 0 );
	int n, s = 0;
	cin>>n;
	int ans = 0;
	for( int a = 1; a <= 100000; a++ )
	{
		s += a;
		ans++;
		if( s >= n )break;
	}
	cout<<ans;
	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(void){
	string s,t;
	int count = 0;
	cin >> s >> t;
	rep(i,s.size()){
		if(s[i]!=t[i]) count++;
	}
	cout << count << endl;
	return 0;
}

Measured memory_bytes: 3856
import java.util.*;
public class Main {
  public static void main  (String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
	String str = String.valueOf(n);
    int cnt = 0;
    for (int i = 0; i < str.length() - 1; i++) {
      if (str.charAt(i) == str.charAt(i + 1)) {
        cnt++;
      }
      else {
        cnt = 0;
      }
      if (cnt >= 2) {
        System.out.println("Yes");
        return;
      }
    }
    System.out.println("No");
  }
}

Measured memory_bytes: 20948
#include <bits/stdc++.h>   
#define rep(i, n) for(long long int i = 0; i < n; i++)
#define _rep(i, m, n) for(long long int i = m; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll mod = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
     
ll gcd(ll A, ll B){
    if(B == 0)return A;
    return gcd(B, A % B);
}
ll lcm(ll A, ll B){
    return A * B / gcd(A, B);
}
using Graph = vector<vector<int>>;
Graph G;


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

    int n; cin >> n;

    vector<int> b;
    rep(i, n){
        int a; cin >> a;
        if(b.empty()){
            b.push_back(a);
            continue;
        }else{
            auto itr = lower_bound(b.begin(), b.end(), a);
            int idx = distance(b.begin(), itr);
            if(idx == 0) b.insert(b.begin(), a);
            else b[idx - 1] = a;
        }
    }
    //for(auto it : b) cout << it << endl;
    cout << b.size() << endl;
}

Measured memory_bytes: 3868
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
int n, m;
string a[50], b[50];

bool isContained(int y, int x) {
    for (int i = 0; i < m; i++) {
        for (int j = 0; j < m; j++) {
            if (a[i + y][j + x] != b[i][j]) {
                return false;
            }
        }
    }
    return true;
}


int main() {
    //int n, m;
    cin >> n >> m;
    //string a[n], b[m];
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    for (int i = 0; i < m; i++) {
        cin >> b[i];
    }

    for (int i = 0; i < n - m + 1; i++) {
        for (int j = 0; j < n - m + 1; j++) {
            if (isContained(i, j)) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }

    cout << "No" << endl;


    return 0;
}


Measured memory_bytes: 256
N = int(input())
A_list = list(map(int, input().split()))
 
f = True
for a in A_list:
  if a % 2 == 1:
    continue
  elif a % 3 == 0 or a % 5 == 0:
    continue
  else:
    f = False
    
if f:
  print("APPROVED")
else:
  print("DENIED")

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

using namespace std;

bool f(string s, string w) {
  for (int i = 0; i < w.size(); i++) {
    if (w[i] != s[0]) continue;
    for (int j = 1; j < w.size(); j++) {
      for (int k = 1; k < s.size(); k++) {
        if (i + j * k >= w.size() || w[i + j * k] != s[k]) break;
        if (k == s.size() - 1) return true;
      }
    }
  }
  return false;
}

int main(void) {
  int n;
  string s;
  cin >> n >> s;
  
  int ans = 0;
  for (int i = 0; i < n; i++) {
    string w;
    cin >> w;
    ans += f(s, w);
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3160
#include <stdio.h>

int main(void){
	int a,b,c,i;
	scanf("%d %d %d",&a,&b,&c);
	
	if(a > b){
		i = a;
		a = b;
		b = i;
	}
	if(b > c){
		i = b;
		b = c;
		c = i;
	}
	if(a > b){
		i = a;
		a = b;
		b = i;
	}
	
	printf("%d %d %d\n",a,b,c);
	return 0;
}

Measured memory_bytes: 596
c = [list(map(int, input().split())) for _ in range(3)]
flg = False

for i in range(max(c[0][0], c[1][0], c[2][0]) + 1):
    a1, a2, a3 = c[0][0] - i, c[1][0] - i, c[2][0] - i
    
    if c[0][1] - a1 == c[1][1] - a2 and c[0][1] - a1 == c[2][1] - a3 and\
       c[0][2] - a1 == c[1][2] - a2 and c[0][2] - a1 == c[2][2] - a3:
       flg = True

print("Yes" if flg else "No")

Measured memory_bytes: 38256
#include <cstdlib>
#include <iostream>
#include <set>
using namespace std;

pair<int, int> xy(char c){
  const int m = c - 'A';
  return make_pair(m % 3, m / 3);
}

int main(){
  string s;

  while(cin >> s){
    const int n = s.length();
    pair<int, int> now = xy(s[0]);

    bool ok = true;
    for(int i = 1; i < n; i++){
      const pair<int, int> next = xy(s[i]);
      if(std::abs(next.first - now.first) +
         std::abs(next.second - now.second) != 1)
        ok = false;
      now = next;
    }

    if(ok) cout << s << endl;
  }

  return 0;
}

Measured memory_bytes: 1176
#include <bits/stdc++.h>
using namespace std;
int main() {
 	long a, b;
  	cin >> a >> b;
  	for (int i = 0; i <= 100 * b; i++) {
      long aa = (8 * i) / 100;
      long bb = (10 * i) / 100;
      if (aa == a && bb == b) {
        cout << i << endl;
        return 0;
      }
    }
  	cout << -1 << endl;
	return 0;
}

Measured memory_bytes: 256
/**
 *    author  : 𝒌𝒚𝒐𝒎𝒖𝒌𝒚𝒐𝒎𝒖𝒑𝒖𝒓𝒊𝒏
 *    created : 2020-01-26 20:28:25
**/

#include <iostream>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
#include <bitset>
#include <cassert>
#include <cctype>
#include <iomanip>
#include <random>
#include <utility>
#include <chrono>

using namespace std;

using int64 = long long;

template<class T> std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) { os << '{'; size_t n = vec.size(); for (size_t i = 0; i < n; ++i) { os << vec[i]; if (i != n - 1) os << ','; } os << '}'; return os; }
template<class T, class U> std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p) { return os << '{' << p.first << " " << p.second << '}'; }
template<class T, class U> std::ostream& operator<<(std::ostream& os, const std::map<T, U>& mp) { for (auto it = mp.begin(); it != mp.end(); ++it) { os << '{' << it->first << ':' << it->second << '}'; if (it != --mp.end()) os << ','; } return os; }
template<class T> std::ostream& operator<<(std::ostream& os, const std::set<T>& st) { os << '{'; for (auto it = st.begin(); it != st.end(); ++it) { os << *it; if (it != --st.end()) os << ','; } os << '}'; return os; }
template<class T> std::istream& operator>>(std::istream& is, std::vector<T>& vec) { size_t n = vec.size(); for (size_t i = 0; i < n; ++i) is >> vec[i]; return is; }

#define all(_) begin(_), end(_)
#define rall(_) rbegin(_), rend(_)

#ifdef LOCAL
#define debug(_) cerr << #_ << ": " << (_) << '\n'
#else
#define debug(_) 1728
#endif

constexpr int INF = 1e9;

int dp[1010][10101];

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

  int h, n; cin >> h >> n;
  vector<int> a(n), b(n);
  for (int i = 0; i < n; ++i) cin >> a[i] >> b[i];

  fill(dp[0], dp[1010], INF);

  for (int i = 0; i < 1010; ++i) {
    dp[i][0] = 0;
  }

  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < 10101; ++j) {
      dp[i + 1][j] = min(dp[i + 1][j], dp[i][j]);
      if (j - a[i] < 0) continue;
      dp[i + 1][j] = min(dp[i + 1][j], dp[i + 1][j - a[i]] + b[i]);
    }
  }

  int ans = INF;

  for (int i = 0; i < 10101; ++i) {
    if (i >= h) {
      ans = min(ans, dp[n][i]);
    }
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 40064
#include<cstdio>
#include<ctime>

#define gec     getchar
#define FILE(F) freopen(F".in","r",stdin),freopen(F".out","w",stdout)
#define RunTime fprintf(stderr,"Running Time:%.5lfs\n",1.*clock()/1e6)

typedef long long ll;
typedef long double lb;
template<typename T>void umin(T &x,T y){if(x>y)x=y;}
template<typename T> T min(T x,T y){return x<y?x:y;}
template<typename T>void umax(T &x,T y){if(x<y)x=y;}
template<typename T> T max(T x,T y){return x>y?x:y;}
template<typename T>
inline void read(T &x)
{
	x=0;bool f=0; char c=gec();
	for(;c<'0'||c>'9';c=gec())f=(c=='-');
	for(;c>='0'&&c<='9';c=gec())x=x*10+c-'0';
	x=f?-x:x;
}

namespace DEBUG{
inline void fpr(char *c){fprintf(stderr,"%s\n",c);}
inline void fpr(int    x,char *c){fprintf(stderr,"[ %s ] : = %d   \n",c,x);}
inline void fpr(ll     x,char *c){fprintf(stderr,"[ %s ] : = %lld \n",c,x);}
inline void fpr(double x,char *c){fprintf(stderr,"[ %s ] : = %.5lf\n",c,x);}
inline void fpr(lb     x,char *c){fprintf(stderr,"[ %s ] : = %.5Lf\n",c,x);} 
}using namespace DEBUG;

char ch[10];

ll NOW=999991515;
int sa[20],sb[20];
bool cmp(ll a,ll b)
{
	sa[0]=sb[0]=0;
	while(a)sa[++sa[0]]=a%10,a/=10;
	while(b)sb[++sb[0]]=b%10,b/=10;
	while(sa[sa[0]]==sb[sb[0]]&&sa[0]&&sb[0])sa[0]--,sb[0]--;
	fpr(sa[0],"sa");
	fpr(sb[0],"sb");
	if(!sa[0]||!sb[0])return sa[0]<sb[0];
	return sa[sa[0]]<sb[sb[0]];
}

bool Check(ll x)
{
	return (x<NOW)==cmp(x,NOW);
}

bool ASK(ll x)
{
	printf("? %lld\n",x);
	fflush(stdout);
	scanf("%s",ch);
	return ch[0]=='Y';
	/*fpr(x,"x");
	fpr(Check(x),"bf");
	return Check(x);*/
}

ll p9[11],p10[12];
int leng,Ans;
void Bit()
{
	int l=1,r=10,mid,id=1;p10[0]=1;
	for(int i=1;i<=10;i++)p9[i]=p9[i-1]*10+9,p10[i]=p10[i-1]*10;
	while(l<=r) if(ASK(p9[mid=(l+r)>>1]))r=mid-1,id=mid;else l=mid+1;
	leng=id;
	l=1,r=10,id=1;
	while(l<=r) if(ASK(p10[mid=(l+r)>>1]))l=mid+1;else r=mid-1,id=mid;
	umax(leng,id);
}

void Get_Last()
{
	int Last=0;
	for(int i=9;i>=(Ans==0);i--)
	if(ASK(1ll*(Ans*10+i)*10))Last=i;else break;
	Ans=Ans*10+Last;
	printf("! %d\n",Ans);
}

void ByBit()
{
	if(leng==10){printf("! %d\n",1000000000);return ;}
	int l=1,r=9,mid;
	if(leng==1)Get_Last();
	else
	{
		while(l<=r) if( ASK( 1ll*(mid=(l+r)>>1)) )l=mid+1,Ans=mid;else r=mid-1;
		for(int i=2;i<leng;i++)
		{
			fpr(Ans,"Ans");
			int l=0,r=9,mid,x;
			while(l<=r)
			{
				if(ASK( (1ll*Ans*10+(mid=(l+r)>>1))) )l=mid+1,x=mid;else r=mid-1;
			}
			Ans=Ans*10+x;
		}
		Get_Last();
	}
}

int main()
{
	Bit();
	ByBit();
	return 0;
}	

Measured memory_bytes: 504
#include <stdio.h>
int main()
{
    char str[10];
    scanf("%s", str);
    int flag = 1;
    for(int i=1; i<=4; i++)
    {
        if(str[i]==str[i-1])
            flag=0;
    }
    if(flag==1)
        printf("Good\n");
    else
        printf("Bad\n");
    return 0;
}

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

using namespace std;

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

const int INF = 1 << 29;

int N, R;
int A[3000], B[3000], D[3000];
int cost[1500][1500];
bool used[1500], v[1500];
vector< int > g[1500];

void dfs(int idx, int *dist)
{
  if(v[idx]++) return;
  used[idx]++;
  for(auto &i : g[idx]) {
    if(A[i] == idx && dist[B[i]] + D[i] == dist[idx]) dfs(B[i], dist);
    if(B[i] == idx && dist[A[i]] + D[i] == dist[idx]) dfs(A[i], dist);
  }
}

int main()
{
  fill_n(*cost, 1500 * 1500, INF);
  rep(i, 1500) cost[i][i] = 0;

  cin >> N >> R;
  rep(i, R) {
    cin >> A[i] >> B[i] >> D[i];
    --A[i], --B[i];
    cost[A[i]][B[i]] = cost[B[i]][A[i]] = D[i];
    g[A[i]].push_back(i);
    g[B[i]].push_back(i);
  }
  rep(i, N) rep(j, N) rep(k, N) cost[j][k] = min(cost[j][k], cost[j][i] + cost[i][k]);

  int ret = 0;
  rep(i, N) rep(j, N) if(cost[i][j] != INF) ret = max(ret, cost[i][j]);

  rep(i, N) {
    memset(v, false, sizeof(v));
    rep(j, N) if(cost[i][j] == ret) dfs(j, cost[i]);
  }
  cout << count(used, used + N, false) << endl;
  rep(i, N) if(!used[i]) cout << i + 1 << endl;

}

Measured memory_bytes: 12008
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define pb push_back
const int maxn = 10000;
const int INF32 = 1'050'000'000;
const long long INF64 = 4'000'000'000'000'000'000;
const int MOD7 = 1'000'000'007;
const int MOD9 = 1'000'000'009;

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

int main()
{
	int D, G;
	cin >> D >> G;
	vector<ll> p(D), c(D);
	rep(i,D) cin >> p[i] >> c[i];
	int num = INF32;
	rep(bit,1<<D){
		int sum = 0;
		int num2 = 0;
		rep(i,D){
			if(bit & 1<<i){
				sum += c[i] + p[i] * 100 * (i+1);
				num2 += p[i];
			}
		}
		if(sum>=G){
			num = min(num,num2);
			continue;
		}else{
			for(int i=D-1; i>=0; i--){
				if(bit & (1<<i)) continue; 
				rep(j,p[i]){
					if(sum >= G) break;
					sum += 100 * (i+1);
					num2++;
				}
			}
			num = min(num,num2);
		}
	}
	cout << num << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>

using namespace std;

typedef long long ll;

int main(){
  ll d, g;
  std::cin >> d >> g;

  vector< pair<ll, ll> > tests;

  for(int i=0; i<d; i++){
    ll f, s;
    cin >> f >> s;
    tests.push_back(make_pair(f, s));
  }

  ll min = LLONG_MAX;
  for(int i=0; i<pow(2, d); i++){
    bitset<10> bits(i);
    ll score = 0;
    int num = 0;
    for(int j=0; j<d; j++){
      if( bits[j] ){
        // 問題を全完した場合のスコアと問題数を記録していく
        score += (j+1)*100 * tests[j].first + tests[j].second;
        num += tests[j].first;
      }
    }
    if( g <= score ){
      if( min > num ){
        min = num;
      }
    }else{
      bool dropflag = false;
      for(int k=d-1; 0<=k; k--){
        if( g <= score ) continue;
        if( !bits[k] ){
          for(int l=0; l<tests[k].first-1; l++){
            score += (k+1) * 100;
            num += 1;
            if( g <= score ){
              if( min > num ){
                min = num;
                dropflag = true;
                break;
              }
            }
          }
        }
      }
    }
  }

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


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

int main(){
  int N;
  cin >>N;
  for(int i=0; i<N; i++){
    char S;
    cin >>S;
    if(S!='Y'&&i==N-1)
      cout <<"Three" <<endl;
    else if(S!='Y')
      continue;
    else{
      cout<<"Four" <<endl;
      break;
    }
  }
}    


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
const int MOD=(int)1e9+7;
using namespace std;
int main(){
    int a,b,c;
    cin >> a >> b >> c;
    if(b-a == c-b) cout << "YES" << endl;
    else cout << "NO" << endl;
    }

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <fstream>
#include <string>
#include <vector>
#include <array>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cstdint>
#include <cmath>
#include <algorithm>
#include <utility>
#include <numeric>
#include <functional>
#include <cassert>

using namespace std;
using ll = int64_t;
using ull = uint64_t;

constexpr ll INF = 1000000000;/* 1e+9a */

void solve(istream &cin) {
    ll N;
    if (!(cin >> N)) { return; }
    vector<ll> A, B;
    priority_queue<pair<ll, ll>> apb;
    for (int i = 0; i < N; ++i) {
        ll ta, tb;
        cin >> ta >> tb;
        A.push_back(ta);
        B.push_back(tb);
        apb.push({ta+tb, i});
    } // end i
    ll ans = 0;
    bool turn_t = true;
    while(!apb.empty()){
        ans += (turn_t ?  1 : -1) * (turn_t ? A : B)[apb.top().second];
        apb.pop();
        turn_t = !turn_t;
    }
    cout << ans <<endl;



}

int main(int argc, char *argv[]) {
    string FileName("C"), Modifier("MEPH_");
    string ExecutionName = Modifier + FileName;
    string sub(argv[0]);
    // /home/USER/.../MEPH_X -> MEPH_X
    if (sub.size() > ExecutionName.size())
        sub = sub.substr(sub.size() - ExecutionName.size(), ExecutionName.size());

    cout << setprecision(16) << scientific;
    if (sub != ExecutionName) {
        cin.tie(0);
        ios::sync_with_stdio(false);
        while (cin) { solve(cin); }
    } else {
        cerr << sub << " test" << endl;
        string inFile = FileName + ".txt";
        auto fs = fstream(inFile, fstream::in);
        while (fs) { solve(fs); }
    }
}


Measured memory_bytes: 3672
#include<bits/stdc++.h>
using namespace std ;
#define pb push_back

int n,m ;
char C[20] ;

void f( int x , int y , int k ){
	if( x==n && y==m ){
		for( int i=0 ; i<k ; i++ )
			cout << C[i] ;
		cout << endl ;
	}
	else {
		if( x==5 && y<=3 || y==5 && x<=3 ){}
		else if( x>=4 && y>=4 && x+y==10 ){}
		else {
			if( x+1 <= n ){
				C[k] = 'A' ;
				f(x+1,y,k+1) ;
			}
			if( y+1 <= m ){
				C[k] = 'B' ;
				f(x,y+1,k+1) ;
			}
		}
	}
	return ;
}

main(){
	cin >> n >> m ;
	f(0,0,0) ;
}

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

using namespace std;
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;

void AGC034A()
{
	int N, A, B, C, D;
	cin >> N >> A >> B >> C >> D;
	--A; --B; --C; --D;
	string S;
	cin >> S;
	int sign = D - C > 0 ? 1 : -1;
	for (int i = A; i < C-1; ++i)
	{
		if (S[i] == '#' && S[i + 1] == '#')
		{
			cout << "No" << endl;
			return;
		}
	}
	for (int i = B; i < D - 1; ++i)
	{
		if (S[i] == '#' && S[i + 1] == '#')
		{
			cout << "No" << endl;
			return;
		}
	}
	if (sign == -1)
	{
		bool isOk = false;
		for (int i = B-1; i < D; ++i)
		{
			if (S[i] == '.' && S[i + 1] == '.' && S[i+2] == '.')
			{
				isOk = true;
				break;
			}

		}
		if (!isOk)
		{
			cout << "No" << endl;
			return;
		}
	}
	cout << "Yes" << endl;
}
int main()
{
	AGC034A();
	return 0;
}

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

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
typedef long double ld;

const int INF = 1e9;
const ld EPS = 1e-8;

int main(){
  int N;
  cin >> N;
  cout << N * (N + 1) / 2 << endl;
  return 0;
}



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

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

    if (abs(a - b) <= d && abs(b - c) <= d)
        cout << "Yes" << endl;
    else if (abs(a - c) <= d)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
n,k=map(int,input().split())
l=list(map(int,input().split()))
d=dict()
for a in l:
    if a in d:
        d[a]+=1
    else:
        d[a]=1
ans=0
for _,c in sorted(d.items(),key=lambda x:x[1])[:len(d)-k]:
    ans+=c
print(ans)


Measured memory_bytes: 42788
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c,s=0;
    cin>>a>>b>>c;
    s=a+b+c;
    if(s<22)
        cout<<"win"<<endl;
    else
        cout<<"bust"<<endl;
    return 0;
}


Measured memory_bytes: 256