akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define MOD = 998244353;
#define int long long int
#define inf (int)(1e15)
#define all(x) (x).begin(), (x).end()
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define isYes(x) printf("%s\n", (x) ? "Yes" : "No")
#define isYES(x) printf("%s\n", (x) ? "YES" : "NO")
#define isIn(x, y, h, w) (x >= 0 && x < h && y >= 0 && y < w)
#define pair pair<int, int>
typedef vector<int> vi;   // Vector of long long
typedef vector<vi> vvi;   // Vector of vi
typedef vector<pair> vii; // Vector of pairs
typedef vector<vii> vvii; // Vector of Vector of pairs
typedef vector<bool> vb;  // Vector of bool
#define pq priority_queue // Max heap (To convert to min heap, use negative sign before every value)
#define ff first          // For pairs
#define ss second
const int dx4[] = {1, 0, -1, 0}, dy4[] = {0, -1, 0, 1};
const int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1}, dy8[] = {1, -1, 1, 0, -1, 1, -0, -1};
#define testcases(t) \
    int(t);          \
    cin >> (t);      \
    while ((t)--)
#define range(c, r) (c).begin(), (c).begin() + (r)    // Mainly used in sorting
#define present(c, x) ((c).find(x) != (c).end())      // for sets, maps, multi-maps
#define cpresent(c, x) (find(all(c), x) != (c).end()) // for vectors
#define run(x, c) for ((x) = (c).begin(); (x) != (c).end(); (x)++)
vvi adj;
vi parent;
vb visited;
void bfs()
{
    queue<int> q;
    q.push(1);
    visited[1] = true;
    while (q.size())
    {
        int current = q.front();
        q.pop();
        for (auto it : adj[current])
        {
            if (parent[it] == -1)
            {
                q.push(it);
                parent[it] = current;
                visited[it] = true;
            }
        }
    }
}
signed main()
{
    int n, m;
    cin >> n >> m;
    adj.resize(n + 1);
    parent.assign(n + 1, -1);
    visited.assign(n + 1, false);
    while (m--)
    {
        int u, v;
        cin >> u >> v;
        adj[u].pb(v);
        adj[v].pb(u);
    }
    bfs();
    for (int i = 1; i <= n; i++)
    {
        if (visited[i])
            continue;
        cout << "No" << endl;
        return 0;
    }
    Yes;
    for (int i = 2; i <= n; i++)
    {
        cout << parent[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 12944
#include <iostream>
#include <string>
#include <bitset>
using namespace std;
constexpr int dx[] = {1,0,1,0,-1,0,-1}, dy[] = {0,-1,1,0,-1,1,0}, x = ((1LL<<3)|(1LL<<4)|(1LL<<9)|(1LL<<15)|(1LL<<20)|(1LL<<21));

int filter(const int &t, const string &s){
  int ret = (t&(31|(31<<20)));
  for(int i = 1; i < 4; ++i){
    ret |= (t&(17<<(5*i)));
    for(int j = 1; j < 4; ++j){
      int u = 0;
      for(int k = 0; k < 7; ++k){
        int x = i + dx[k], y = j + dy[k];
        u |= (((t>>(x*5+y))&1)<<k);
      }
      ret |= ((s[u]-'0')<<(5*i+j));
    }
  }
  return ret;
}

bool filter2(const int &t, const string &s){
  int i = 2, j = 2, u = 0;
  for(int k = 0; k < 7; ++k){
    int x = i + dx[k], y = j + dy[k];
    u |= (((t>>(x*5+y))&1)<<k);
  }
  return (s[u]-'0' == ((t>>12)&1));
}

bool check(const int &t, const string &s){
  int u = filter(t,s);
  return filter2(u,s);
}

signed main(){
  string s;
  while(cin >> s, s != "#"){
    string ans = "yes";
    for(int i = 0; i < (1LL<<25); i = ((i+1)|x)){
      if(!check(i,s)){
        ans = "no";
        break;
      }
    }
    cout << ans << endl;
  }
  return 0;
}



Measured memory_bytes: 3036
dic = {"r":1,"g":2,"b":3}
while 1:
	worm = raw_input()
	if worm == "0": break
	n = len(worm)
	ref = ["r"*n,"g"*n,"b"*n]
	cnt = flag = 0
	queset = set([worm])
	done = set()
	while 1:
		que = list(queset)
		queset = set()
		for Worm in que:
			if Worm in ref:
				flag = 1
				break
			for i in range(n-1):
				if Worm[i] != Worm[i+1]:
					nextclr = "rgb"[5-dic[Worm[i]]-dic[Worm[i+1]]]
					queset.add(Worm[:i] + 2*nextclr + Worm[i+2:])
		if flag or cnt > 14: break
		cnt += 1
		queset -= done
		done |= queset
	print cnt if flag else "NA"

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

#define int long long

const int N = 1e6 + 10 ;
constexpr int mod = 1e9 + 7 ;
int dp[N][2][2] ;
int n; 

int solve(int i = 0 , bool a = 0 , bool b = 0){
	if(i == n){
		return a & b ;
	}
	if(~dp[i][a][b]) return dp[i][a][b] ;
	int ans = 0 ;
	for(int j = 0 ; j < 10 ; j++){
		ans = (ans + solve(i + 1 , a | (j == 0) , b | (j == 9)))  % mod ;
	}
	return dp[i][a][b] = ans ;
}

int32_t main(){
	cin >> n ;
	memset(dp , -1 , sizeof(dp)) ;
	cout << solve() ;
	return 0 ;
}



Measured memory_bytes: 128380
#include<iostream>
#include<stdio.h>
#include<string>
#include <math.h>
using namespace std;
# define maxn 100001
 
int main(){
  // int n,m,a[maxn],b[maxn],c[maxn],cnt(0),sum(0);
  long long n,k,c[maxn]={0},cnt(0),sum(0);
  cin>>n>>k;
  // for(int i(0);i<n;i++){
  //   cin>>a[i];
  // }
  for(int i(0);i<n;i++){
    int a,b;
    cin>>a>>b;
    c[a]+=b; // 要素が個数
  }
  for (int i(0);i<maxn;i++){
    cnt+=c[i];
    if(cnt>=k){
      cout<<i;
      return 0;
    }
  }
}

Measured memory_bytes: 1024
#include <iostream>

using namespace std;

int main() {
	int y1, m1, d1; cin >> y1 >> m1 >> d1;
	int y2, m2, d2; cin >> y2 >> m2 >> d2;
	if (y1 * 10000 + m1 * 100 + d1 > y2 * 10000 + m2 * 100 + d2) {
		y1 ^= y2 ^= y1 ^= y2;
		m1 ^= m2 ^= m1 ^= m2;
		d1 ^= d2 ^= d1 ^= d2;
	}
	int ans = y2 - y1;
	if (m1 * 100 + d1 < m2 * 100 + d2) ans++;
	cout << ans << endl;

	return 0;
}


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

#define Fi first
#define Se second
#define pb push_back
#define mp make_pair
#define rep(x, a, b) for(int x = (a); x <= (b); ++ x)
#define per(x, a, b) for(int x = (a); x >= (b); -- x)
#define rop(x, a, b) for(int x = (a); x < (b); ++ x)
#define por(x, a, b) for(int x = (a); x > (b); -- x) 

typedef long long LL;
typedef unsigned long long ULL;
typedef unsigned int unt;
typedef double db;
typedef pair <int, int> pii;
typedef vector <int> vi;

const db eps  = 1e-8;
const db _PI  = 3.1415926535897932384;
const db _E   = 2.7182818284590452354;
const int inf = 0x3f3f3f3f;
const LL INF  = 0x3f3f3f3f3f3f3f3fll;

struct Point {
	db x, y;
	Point(db _x = 0, db _y = 0) : x(_x), y(_y) {}
	void print() { printf("%.10f %.10f", x, y); }
};
struct Line {
	Point p1, p2;
	Line() {};
	Line(Point _p1, Point _p2) : p1(_p1), p2(_p2) {};
};

typedef Point Vector;
typedef Line Segment;

Vector operator + (const Vector &a, const Vector &b) {
	return Vector(a.x + b.x, a.y + b.y);
}
Vector operator - (const Vector &a, const Vector &b) {
	return Vector(a.x - b.x, a.y - b.y);
}
Vector operator * (const Vector &a, const db &b) {
	return Vector(a.x * b, a.y * b);
}
Vector operator / (const Vector &a, const db &b) {
	return Vector(a.x / b, a.y / b);
}
db operator * (const Vector &a, const Vector &b) {
	return a.x * b.x + a.y * b.y;
}
db operator ^ (const Vector &a, const Vector &b) {
	return a.x * b.y - a.y * b.x;
}
db dis(const Point &a, const Point &b) {
	return sqrt((a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y));
}
db dis2(const Point &a, const Point &b) {
	return (a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y);
}
Point Projection(const Line &L, const Point &p) {
	Vector Base = L.p2 - L.p1;
	db len = Base * (p - L.p1);
	return L.p1 + Base * (len / dis2(L.p1, L.p2));
}
Point Reflection(const Line &L, const Point &p) {
	return p + (Projection(L, p) - p) * 2.0;
}

int main() {
	Point p1, p2;
	scanf("%lf%lf%lf%lf", &p1.x, &p1.y, &p2.x, &p2.y);
	int q; scanf("%d", &q);
	rep(i, 1, q) {
		Point p;
		scanf("%lf%lf", &p.x, &p.y);
		Reflection(Line(p1, p2), p).print();
		putchar('\n');
	}
	return 0;
}


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

int main() {
  int w,a,b;
  cin >> w >> a >> b;
  if (a+w < b) {
    cout << b-(a+w) << endl;
  } else if (a > b+w) {
    cout << a-(b+w) << endl;
  } else {
    cout << 0 << endl;
  }
}


Measured memory_bytes: 256
# your code goes here
import math

n = int(input())
for i in range(n):
	xa, ya, ra, xb, yb, rb = [float(x) for x in input().split(" ")]
	distance = math.sqrt((xb-xa)**2 + (yb-ya)**2)

	if distance > ra+rb:
		print(0)
	elif distance < abs(ra-rb):
		if ra > rb:
			print(2)
		elif ra < rb:
			print(-2)
		else:
			print(1)
	elif distance <= ra+rb:
		print(1)
			

Measured memory_bytes: 6836
import java.util.Arrays;
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] a = new int[n];
    for(int i = 0; i < n; i++) {
      a[i] = sc.nextInt();
    }
    Arrays.sort(a);
    System.out.println(a[n - 1] - a[0]);
  }

}


Measured memory_bytes: 21716
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

struct RangeSumQuery {
	int n;
	vector<int> d;
	RangeSumQuery(int m) {
		for (n = 1; n < m; n *= 2);
		d.assign(n * 2, 0);
	}
	void add(int i, int x) {
		d[n + i] += x;
		for (int j = (n + i) / 2; j > 0; j >>= 1)
			d[j] = d[j * 2] + d[j * 2 + 1];
	}
	//[l, r)
	int query(int l, int r) {
		int sum = 0;
		for (; l && l + (l&-l) <= r; l += l&-l)
			sum += d[(n + l) / (l&-l)];
		for (; l < r; r -= r&-r)
			sum += d[(n + r) / (r&-r) - 1];
		return sum;
	}
	int get(int i) { return d[n + i]; }
};

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	string A, B;
	cin >> A >> B;
	RangeSumQuery C(A.size()), D(B.size());
	rep(i, 0, A.size()) {
		if (A[i] == 'A')C.add(i, 1);
		else C.add(i, 2);
	}
	rep(i, 0, B.size()) {
		if (B[i] == 'A')D.add(i, 1);
		else D.add(i, 2);
	}
	int q; cin >> q;
	rep(i, 0, q) {
		int a, b, c, d; cin >> a >> b >> c >> d;
		a--, c--;
		if (C.query(a, b) % 3 == D.query(c, d) % 3) {
			cout << "YES" << endl;
		}
		else {
			cout << "NO" << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 5072
#include <stdio.h>
int main(void)
{
	char moji[1202];
	int i;
	
	fgets(moji,1202,stdin);
	
	for(i=0;moji[i];i++){
		if(('a'<=moji[i]&&'z'>=moji[i])||('A'<=moji[i]&&'Z'>=moji[i]))
		moji[i] ^= 0x20;
		putchar(moji[i]);
	}
	
	
	
	return 0;
}


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

int main(){
  int n,l;
  cin >> n >> l;
  vector<int> A(n+10);
  int a = 101;
  int ans = 0;
  rep(i,n){
    A[i] = l + i - 1;
    ans += A[i];
    a = min(a,abs(A[i]));
  }
  if(A[n] < 0) cout << ans + a << endl;
  else cout << ans - a << endl;
  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<string>
#include<vector>

using namespace std;

int main()
{
	int n;
	cin >> n;
	vector<string> s;
	int alp[26][50];
	for (int i = 0; i < 26; i++) {
		for (int j = 0; j < 50; j++) {
			alp[i][j] = 0;
		}
	}

	for (int i = 0; i < n; i++) {
		string str;
		cin >> str;
		s.push_back(str);
	}

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < s[i].length(); j++) {
			alp[s[i][j] - 'a'][i]++;
		}
	}

	int ope = 0;
	for (int i = 0; i < 26; i++) {
		int imin = alp[i][0];
		for (int j = 1; j < n; j++) {
			if (alp[i][j] < imin) {
				imin = alp[i][j];
			}
		}
		if (imin != 0)ope++;
		char ialp = 'a' + i;
		for (int k = 0; k < imin; k++) {
			cout << ialp;
		}
	}
	if (ope == 0)cout << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <map>
#include <vector>
#include <queue>
#define maxn 105
#define LL long long 

using namespace std;

LL n,m;

int main()
{
	cin >>n>>m;
	if (n>=m) n=n%m;
	cout <<min(n,m-n);
	return 0;
}

Measured memory_bytes: 256
def solve(i,m):
    if dp[i][m] != -1:
        return dp[i][m]
    if m == 0:
        dp[i][m] = True
    elif i >= n:
        dp[i][m] = False
    elif solve(i+1, m):
        dp[i][m] = True
    elif solve(i+1, m-a[i]):
        dp[i][m] = True
    else:
        dp[i][m] = False
    return dp[i][m]

n = input()
a = map(int,raw_input().split())
q = input()
p = map(int,raw_input().split())
dp = [[-1 for i in xrange(2001)] for j in xrange(21)]
for i in xrange(q):
    if solve(0,p[i]):
        print "yes"
    else:
        print "no"

Measured memory_bytes: 6748
local K = io.read("*n")

local function euc(arg1, arg2)
    --print(arg1, arg2)
    if arg1 == arg2 or arg2 == 0 then
        return arg1
    elseif arg1 == 0 then
        return arg2
    elseif arg1 > arg2 then
        return euc(arg2, arg1 % arg2)
    else
        return euc(arg1, arg2 % arg1)
    end
end

local function gcd(i, j, k)
    return euc(euc(i, j), euc(j, k))
end

local total = 0
for i = 1, K do
    for j = 1, K do
        for k = 1, K do
            total = total + gcd(i, j, k)
        end
    end
end

print(total)

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

/* → → → → → → → → → → → → → → → → → → → → → → → → → → → →
	→ → → → → → → → → → → → → → → → → → → → → → → → → → → → */

#define int long long int
#define ld long double
#define F first
#define S second
#define P pair<int,int>
#define pb push_back
#define endl '\n'

/* → → → → → → → → → → → → → → → → → → → → → → → → → → → →
	→ → → → → → → → → → → → → → → → → → → → → → → → → → → → */

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

	int aa[n + 1], bb[m + 1];

	aa[0] = 0;
	for (int i = 1; i <= n; i++)
		aa[i] = aa[i - 1] + a[i];

	bb[0] = 0;
	for (int i = 1; i <= m; i++)
		bb[i] = bb[i - 1] + b[i];

	int ans = 0;
	int j = n;
	for (int i = 0; i <= m; i++) {
		if (bb[i] > k)
			break;
		while (aa[j] > k - bb[i]) {
			j--;
		}
		ans = max(ans, i + j);
	}
	cout << ans;
	return ;
}

int32_t main() {

	/* → → → → → → → → → → → → → → → → → → → → → → → → → → → →
	→ → → → → → → → → → → → → → → → → → → → → → → → → → → → */

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

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	/* → → → → → → → → → → → → → → → → → → → → → → → → → → → →
	→ → → → → → → → → → → → → → → → → → → → → → → → → → → → */

	//int t;cin>>t;while(t--)
	solve();

	return 0;
}

Measured memory_bytes: 9888
#include<stdio.h>
int main(void){
	int c1, c5, c10, c50, c100, c500;
	scanf("%d%d%d%d%d%d", &c1, &c5, &c10, &c50, &c100, &c500);
	if (c1 * 1 + c5 * 5 + c10 * 10 + c50 * 50 + c100 * 100 + c500 * 500 >= 1000){
		printf("1\n");
	}
	else{
		printf("0\n");
	}
	return 0;
}

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

#pragma GCC optimize "O3"
#define rep(i,a,n) for(long long i=a; i<n; i++)
typedef long long ll;
typedef pair<int,int> P;
const ll MOD = (int)1e9+7;
const ll INF = MOD*MOD;
const double EPS = 1e-9;
const ll powll = 1LL<<1;

/*
while(!frag && cin >> a >>b, a|b)
*/

int main(void){
    int n; cin >> n;
    int h[n]; rep(i,0,n) cin >> h[i];
    int dp[n];
    rep(i,0,n) dp[i] = MOD;
    dp[0] = 0;
    dp[1] = abs(h[1]-h[0]);
    rep(i,2,n){
        dp[i] = min(dp[i-1] + abs(h[i]-h[i-1]), dp[i-2] + abs(h[i]-h[i-2]));
    }

    cout << dp[n-1] << "\n";
    
}

Measured memory_bytes: 4308
#include<bits/stdc++.h>
#define ll long long int
#define mi map<int,int>
#define mcr map<char,int>
using namespace std;

int main()
{
    ll t, ans = 0;
    cin >> t;
    map<string,ll> m;
    while(t--)
    {
        string s;
        cin >> s;
        m[s]++;
    }
    cout << "AC x " << m["AC"] << endl;
    cout << "WA x " << m["WA"] << endl;
    cout << "TLE x " << m["TLE"] << endl;
    cout << "RE x " << m["RE"] << endl;

    return 0;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define MOD 1000000007
#define ll long long
#define mp make_pair
#define pb push_back 
using namespace std;
int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	int n, k;
	cin >> n >> k;
	vector<int> df;
	for(int i = 0; i < n; i++){
		int x;
		cin >> x;
		df.pb(x);
	}
	sort(df.begin(), df.end());
	ll ans = 0;
	for(int i = 0; i < n - k; i++)
		ans += df[i];
	cout << ans << '\n';

}

Measured memory_bytes: 1400
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		System.out.println(attackNum(scanner.nextLong()));

	}

	static long attackNum(long X) {
		if (X == 1)
			return 1;
		return attackNum(X / 2) * 2+1;
	}

}


Measured memory_bytes: 22996
#include <iostream>

using namespace std;

void solve()
{
	int n;
	cin >> n;
	while(n--)
	{
		int a;
		cin >> a;
		int down = 0;
		int up = 0;
		int buf = 0;
		cin >> buf;
		for(int i = 0; i < a - 1; ++i)
		{
			int temp;
			cin >> temp;
			if(temp < buf)
			{
				if(down < buf - temp)
				{
					down = buf - temp;
				}
			}
			else if(temp > buf)
			{
				if(up < temp - buf)
				{
					up = temp - buf;
				}
			}
			buf = temp;
		}
		cout << up << " " << down << endl;
	}
}

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

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
int main(){
  string A;
  cin >> A;
  string ans = "Yes";
  if(A.at(0) == A.at(1) && A.at(1) == A.at(2)){
    ans = "No";
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=100001,INF=1<<30;

int main(){
    
    int N;cin>>N;
    vector<ll> A(N),B(N),S(2*N);
    for(int i=0;i<N;i++){
        cin>>A[i]>>B[i];
        S[i]=A[i];
        S[i+N]=B[i];
    }
    
    sort(all(S));
    
    bool ok=false,acheck=true,bcheck=true;;
    for(int i=0;i<N;i++){
        if(A[i]<=S[N-1]&&B[i]<=S[N-1]) ok=true;
        if(A[i]>S[N-1]) acheck=false;
        if(B[i]>S[N-1]) bcheck=false;
    }
    
    if(ok){
        ll ans=0;
        for(int i=0;i<N;i++){
            ans+=S[i];
        }
        cout<<ans<<endl;
    }else{
        if(acheck||bcheck){
            ll ans=0;
            for(int i=0;i<N;i++){
                ans+=S[i];
            }
            cout<<ans<<endl;
        }else{
            ll ans=0;
            for(int i=0;i<N;i++){
                ans+=S[i];
            }
            for(int i=0;i<N;i++){
                if(A[i]==S[N-1]){
                    if(B[i]==S[N]){
                        ans=min(ans-S[N-1]+S[N+1],ans-S[N-2]+S[N]);
                    }
                    else ans=ans-S[N-1]+S[N];
                }else if(B[i]==S[N-1]){
                    if(A[i]==S[N]){
                        ans=min(ans-S[N-1]+S[N+1],ans-S[N-2]+S[N]);
                    }
                    else ans=ans-S[N-1]+S[N];
                }
            }
            
            cout<<ans<<endl;
        }
    }
    
}



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

#ifdef _DEBUG
#define debug(x) cerr << "line: " << __LINE__ << ", func: " << __func__ << " ->  " << #x << " = " << x << endl
#else
#define debug(x)
#endif

#define all(s) begin(s), end(s)
#define rall(s) rbegin(s), rend(s)
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = ((a)-1); i >= (b); i--)
#define pb push_back
#define sz(a) int((a).size())
#define put(a) ((cout) << (a) << (endl))
#define putf(a, n) ((cout) << (fixed) << (setprecision(n)) << (a) << (endl))
#define deg2rad(x) (((x)*PI) / (180.0))
#define rad2deg(x) (((x) * (180.0)) / PI)

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;
using i_i = pair<int, int>;
using ll_ll = pair<ll, ll>;
using d_ll = pair<double, ll>;
using ll_d = pair<ll, double>;
using d_d = pair<double, double>;
template <class T> using vec = vector<T>;

static constexpr ll LL_INF = 1LL << 60;
static constexpr int I_INF = 1 << 28;
static constexpr double PI = static_cast<double>(3.14159265358979323846264338327950288);
static constexpr double EPS = numeric_limits<double>::epsilon();

static map<type_index, const char* const> scanType = {
    {typeid(int), "%d"}, {typeid(ll), "%lld"}, {typeid(double), "%lf"}, {typeid(char), "%c"}};

template <class T> static void scan(vector<T>& v);
[[maybe_unused]] static void scan(vector<string>& v, bool isWord = true);
template <class T> static inline bool chmax(T& a, T b);
template <class T> static inline bool chmin(T& a, T b);
template <class T> static inline T gcd(T a, T b);
template <class T> static inline T lcm(T a, T b);
template <class A, size_t N, class T> static void Fill(A (&arr)[N], const T& val);
template <class T> T mod(T a, T m);

int main(int argc, char* argv[]) {
  long long N;
  scanf("%lld", &N);

  if (N % 2 == 1) {
    put(0);
    return 0;
  }

  ll k = N / 2;
  ll count = 0, div = 5;
  while (div <= k) {
    count += k / div;
    div *= 5;
  }
  put(count);
  return 0;
}

template <class T> static void scan(vector<T>& v) {
  auto tFormat = scanType[typeid(T)];
  for (T& n : v) {
    scanf(tFormat, &n);
  }
}

static void scan(vector<string>& v, bool isWord) {
  if (isWord) {
    for (auto& n : v) {
      cin >> n;
    }
    return;
  }

  int i = 0, size = v.size();
  string s;
  getline(cin, s);

  if (s.size() != 0) {
    i++;
    v[0] = s;
  }

  for (; i < size; ++i) {
    getline(cin, v[i]);
  }
}

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

template <class T> inline T gcd(T a, T b) { return __gcd(a, b); }

template <class T> inline T lcm(T a, T b) {
  T c = min(a, b), d = max(a, b);
  return c * (d / gcd(c, d));
}

template <class A, size_t N, class T> void Fill(A (&arr)[N], const T& val) {
  std::fill((T*)arr, (T*)(arr + N), val);
}

template <class T> T mod(T a, T m) { return (a % m + m) % m; }


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

#define rep(i,begin,end) for(int i=begin; i<end; i++)
#define revrep(i,begin,end) for(int i=begin; i>end; i--)
#define lld long long int

int main(){
    int n;
    int a[300000], l=150000 + 1, r=150000;
    scanf("%d", &n);
    rep(i, 0, n){
        int b;
        scanf("%d", &b);
        if(i % 2){
            r++;
            a[r] = b;
        }else{
            l--;
            a[l] = b;
        }
    }
    if(n%2){
        rep(i, l, r+1){
            printf("%d ", a[i]);
        }
    }else{
        revrep(i, r, l-1){
            printf("%d ", a[i]);
        }
    }

    return 0;
}

Measured memory_bytes: 2944
#[allow(dead_code)]
use std::collections::HashSet;

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn main() {
    let s = read::<String>();
    let s1 = s.chars().collect::<Vec<_>>();
    let n = s.len();

    let answer = solve(n, &s1);
    if answer {
        println!("Yes");
    } else {
        println!("No");
    }
}

fn solve(n: usize, s: &[char]) -> bool {
    for i in 0..n {
        if i%2 == 0 {
            if s[i] == 'L' {
                return false;                
            }
        } else {
            if s[i] == 'R' {
                return false;
            }
        }
    }
    return true;
}


Measured memory_bytes: 4352
while line = gets
  n = line.chomp.to_i
  answer = 0
  
  for a in 0..9 do
    for b in 0..9 do
      for c in 0..9 do
        for d in 0..9 do
          answer = answer + 1 if a + b + c + d == n
        end
      end
    end
  end

  puts answer
end

Measured memory_bytes: 8600
#include "iostream"
#include "vector"
#include "string"
#include "algorithm"

using namespace std;
typedef long long ll;

int main()
{
  int n;
  cin >> n;
  int sum = 0;
  int max = 0;
  int p[15];
  for (int i = 0; i < n; i++)
  {
    cin >> p[i];
    sum += p[i];
    if (max < p[i])
    {
      max = p[i];
    }
  }
  cout << sum - (max / 2) << endl;
}

Measured memory_bytes: 256
package main

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

type pair struct {
	s, t rune
}

func solve() {
	s, t := getRunes(), getRunes()
	n := len(s)

	ps := make([]pair, 0, 26)
	ans := "Yes"
L:
	for i := 0; i < n; i++ {
		cs, ct := s[i], t[i]
		flagDup := false
		for _, p := range ps {
			if (p.s != cs && p.t == ct) || (p.s == cs && p.t != ct) {
				ans = "No"
				break L
			} else if p.s == cs && p.t == ct {
				flagDup = true
				break
			}
		}
		if !flagDup {
			ps = append(ps, pair{cs, ct})
		}
	}

	fmt.Fprintln(wr, ans)
}

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

const (
	inf = 1 << 60
	// mod = 1000000007
)

var (
	sc = bufio.NewScanner(os.Stdin)
	wr = bufio.NewWriter(os.Stdout)
)

func main() {
	maxBufSize := int(1e8)
	sc.Buffer(make([]byte, 4096), maxBufSize)
	sc.Split(bufio.ScanWords)
	solve()
	wr.Flush()
}

func getInt() (ret int) {
	sc.Scan()
	ret, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return
}

func getIntSlice(n int) (ret []int) {
	ret = make([]int, n)
	for i := range ret {
		ret[i] = getInt()
	}
	return
}

func getString() (ret string) {
	sc.Scan()
	ret = sc.Text()
	return
}

func getRunes() (ret []rune) {
	ret = []rune(getString())
	return
}


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

using namespace std;

int main(void){
    string a,b,c;
    int an,bn;
    cin >> a >> b >> an >> bn >> c;
    if(a==c)
        an--;
    else if(b==c)
        bn--;
    cout << an << ' ' << bn;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	int a[n];
	int b[n];
	int c[n-1];
	for (int i = 0; i < n; ++i)
	{
		cin>>a[i];
	}
	for (int i = 0; i < n; ++i)
	{
		cin>>b[i];
	}
	for (int i = 0; i < n-1; ++i)
	{
		cin>>c[i];
	}
	int ans=0;
	for (int i = 0; i < n; ++i)
		ans+=b[i];
	
	for (int i = 0; i < n-1; ++i)
	{
		if(a[i]+1==a[i+1])
		{
			ans+=c[a[i]-1];
		}
	}

	cout<<ans;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
using namespace std;
bool flag[1000000000];
signed main(){
  int n,m;
  cin >> n;
  int s[10000],t[10000];
  rep(i,n) cin >> s[i];
  cin >> m;
  int cnt=0;
  rep(i,m) cin >> t[i];
  rep(i,n){
    rep(j,m){
      if(s[i]==t[j] && flag[s[i]]==false){
        cnt++;
        flag[s[i]] = true;
        break;
      }
    }
  }
  cout << cnt << endl;
}


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

using Size = int;
using Vertex = int;
using Weight = long long;
struct Edge {Vertex from, to; Weight weight;};
using Graph = std::vector<std::vector<Edge>>;

using LL = long long;
const LL M = 1e9 + 7;

LL combination(LL n, LL r) {
  if(n < r) return 0;
  if(n < 0 || r < 0) return 0;
  static std::vector<LL> fact{1, 1}, inv{1, 1}, finv{1, 1};
  for(LL i = fact.size(); i <= n; ++i) {
    fact.emplace_back(fact.back() * i % M);
    inv.emplace_back(inv.at(M % i) * (M - M / i) % M);
    finv.emplace_back(finv.back() * inv.back() % M);
  }
  return (fact[n] * finv[n - r] % M) * finv[r] % M;
}

void rerooting(const Graph& G) {
  struct DP {
    LL val=1, size=0;
    const DP operator+(const DP& o) const {return {(val*o.val%M)*combination(size+o.size,o.size)%M, size+o.size};}
    const DP addRoot() const {return {val, size+1};}
  };
  std::vector<std::vector<DP>> dp(G.size());
  std::function<DP(Vertex, Vertex)> dfs = [&](Vertex v, Vertex p) {
    const int N = G[v].size();
    DP res;
    dp[v].resize(N);
    for(auto i=0; i<N; ++i) if(G[v][i].to != p) res = res + (dp[v][i] = dfs(G[v][i].to, v));
    return res.addRoot();
  };
  std::function<void(Vertex, Vertex)> rev = [&](Vertex v, Vertex p) {
    const int N = G[v].size();
    std::vector<DP> sl(N+1), sr(N+1);
    for(auto i=0; i<N; ++i) sl[i+1] = sl[i] + dp[v][i];
    for(auto i=N; 0<i; --i) sr[i-1] = sr[i] + dp[v][i-1];
    for(auto i=0; i<N; ++i) {
      auto nex = G[v][i].to;
      if(nex == p) continue;
      for(auto j=0; j<G[nex].size(); ++j) if(G[nex][j].to == v) dp[nex][j] = (sl[i] + sr[i+1]).addRoot();
      rev(nex, v);
    }
  };
  dfs(0,-1);
  rev(0,-1);
  for(auto v=0; v<G.size(); ++v) cout << std::accumulate(std::begin(dp[v]), std::end(dp[v]), DP()).addRoot().val << endl;
}

int main() {
  int N;
  cin >> N;
  Graph G(N);
  for(auto i=1; i<N; ++i) {
    int a, b;
    cin >> a >> b;
    --a; --b;
    G[a].push_back({a, b});
    G[b].push_back({b, a});
  }
  rerooting(G);
}


Measured memory_bytes: 42608
def f(k,x):
    if(k==0):
        return 1
    assert(x>=1)
    if(x==1):
        return 0
    if(x<l[k-1]+2):
        return f(k-1, x-1)
    elif(x==l[k-1]+2):
        return b[k-1] + 1
    else:
        return b[k-1] + 1 + f(k-1, x-2-l[k-1])

n,x=map(int,input().split())
l = {0: 1}
b = {0: 1}
for i in range(1,n+1):
    l[i] = 2*l[i-1]+3
    b[i] = 2*b[i-1]+1

ans = f(n,x)
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int mod = 1000000007;
const double PI = acos(-1);

int main()
{
	int x;
	cin >> x;
	if (400 <= x && x <= 599) cout << 8 << endl;
	else if (600 <= x && x <= 799) cout << 7 << endl;
	else if (800 <= x && x <= 999) cout << 6 << endl;
	else if (1000 <= x && x <= 1199) cout << 5 << endl;
	else if (1200 <= x && x <= 1399) cout << 4 << endl;
	else if (1400 <= x && x <= 1599) cout << 3 << endl;
	else if (1600 <= x && x <= 1799) cout << 2 << endl;
	else if (1800 <= x && x <=1999) cout << 1 << endl;

}


Measured memory_bytes: 3628
import java.util.*;
  public class Main {
    public static void main(String[] args) {
     
        //sec--1 (definition)
        Scanner sc = new Scanner(System.in);
        int K = sc.nextInt();
        int[] A = new int[1000001];
        //配列Aの初期化
        A[0] = 7 % K;
        for (int i=1; i<=K; i++) {
         //A[i] += 7;
         A[i] = (A[i-1]*10 + 7) % K;
        }
          
        //sec--2 (loop)
        //A[i](7の倍数)がKの倍数<=>A[i](7の倍数)はKで割り切れる
        for (int i=0; i<=K; i++) {
        if(A[i] == 0){
         System.out.println(i+1);
         return;
        }
        }
         System.out.println(-1);
    }
  }

Measured memory_bytes: 39540
use std::collections::HashMap;
use std::io;

macro_rules! input {
    ( $($x:expr ),*) => {
        {
            let temp_str = input_line_str();
            let mut split_result_iter = temp_str.split_whitespace();
                $(
                let buf_split_result = split_result_iter.next();
                let buf_split_result = buf_split_result.unwrap();
                    ($x) = buf_split_result.parse().unwrap();
                )*
        }
    };
}

#[allow(dead_code)]
fn input_line_str() -> String {
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

#[allow(dead_code)]
fn input_vector<T>(line: usize) -> Vec<Vec<T>>
where
    T: std::str::FromStr,
{
    let mut v: Vec<Vec<T>> = Vec::new();

    for _ in 0..line {
        let s = input_line_str();
        let split_result = s.split_whitespace();
        let mut vec_line: Vec<T> = Vec::new();
        for z in split_result {
            let buf = match z.parse() {
                Ok(r) => r,
                Err(_) => panic!("Parse Error"),
            };
            vec_line.push(buf);
        }
        v.push(vec_line);
    }
    v
}

fn main() {
    let s = input_line_str();
    let mut m = HashMap::new();

    for z in s.chars() {
        let p = m.entry(z).or_insert(0);
        *p += 1;
    }

    let mut ans = true;
    for (_, n) in &m {
        if *n != 2 {
            ans = false;
        }
    }

    if ans {
        println!("Yes");
    } else {
        println!("No");
    }
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << endl
#define COUTF(x) cout << setprecision(15) << (x) << endl
#define ENDL cout << endl
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#define init() \
  cin.tie(0);  \
  ios::sync_with_stdio(false)
#define debug(x) cerr << "[debug] " << #x << ": " << x << endl;
#define debugV(v)                       \
  cerr << "[debugV] " << #v << ":";     \
  rep(i, v.size()) cerr << " " << v[i]; \
  cerr << endl;
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using P = pair<ll, ll>;
constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr double PI = 3.141592653589793238462643383279;
ll getDigit(ll x) {
  return x == 0 ? 1 : log10(x) + 1;
}

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

ll lcm(ll a, ll b) {
  return a / gcd(a, b) * b;
}

vector<P> factorize(ll n) {
  vector<P> result;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      result.pb({i, 0});
      while (n % i == 0) {
        n /= i;
        result.back().second++;
      }
    }
  }
  if (n != 1) {
    result.pb({n, 1});
  }
  return result;
}

vll divisor(ll n) {
  vll ret;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n) ret.push_back(n / i);
    }
  }
  SORT(ret);
  return (ret);
}

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

signed main() {
  init();
  string S, T;
  cin >> S >> T;

  bool condition1 = false;
  repr(i, S.size() - 1) {
    bool flag = true;

    if (i - (ll)T.size() + 1 >= 0) {
      repr(j, T.size() - 1) {
        ll index = i - (T.size() - (j + 1));
        if (S[index] == '?' || S[index] == T[j]) {
          continue;
        } else {
          flag = false;
          break;
        }
      }

      if (flag) {
        repr(j, T.size() - 1) {
          ll index = i - (T.size() - (j + 1));
          S[index] = T[j];
        }
        condition1 = true;
        break;
      }
    }
  }

  if (condition1) {
    rep(i, S.size()) {
      if (S[i] == '?') {
        S[i] = 'a';
      }
    }
    COUT(S);
  } else {
    COUT("UNRESTORABLE");
  }

  return 0;
}

Measured memory_bytes: 256
N = int(input())
c = list(input())

Nw, Nr = 0, 0
for i in range(len(c)):
    Nw += 1 if c[i] == "W" else 0
    Nr += 1 if c[i] == "R" else 0

if Nw == 0 or Nr == 0:
    print(0)
    exit()

left_w = 0
right_r = 0
if c[0] == "W":
    left_w = 1
    right_r = Nr
else:
    left_w = 0
    right_r = Nr - 1

#仕切りの位置をiの横とすると
ans = max(left_w, right_r)

for i in range(len(c)):
    if i > 0:
        if c[i] == "W":
            left_w += 1
        else:
            right_r -= 1
    swap = max(left_w, right_r)
    ans = min(swap, ans)
print(ans)


Measured memory_bytes: 82364
#include <stdio.h>
#include <math.h>

#define A 246912

int main(void){
    int n, i, j;
    while(1){
        scanf("%d", &n);
        int N[A] = {};    //0が格納されていれば（添字＋1）は素数．全て素数で初期化．
        int count = 0;
        int sqrt_2n = sqrt(2 * n);
        if(n == 0){
            break;
        }
        for(i = 1; i <= sqrt_2n; i++){
            if(N[i] == 0){
                for(j = 2; j * (i + 1) <= 2 * n; j++){
                    N[j * (i + 1) - 1] = 1;
                }
            }
        }
        for(i = n; i < (2 * n); i++){
            if(N[i] == 0){
                count++;
            }
        }
        printf("%d\n", count);
    }
    return 0;
}


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

#define int long long
const double PI = 3.14159265358979323846;
typedef vector<int> vint;
typedef pair<int, int> pint;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

int R1, R2;
signed main() {
    cin >> R1 >> R2;
    cout << setprecision(15) << (double)R1*R2 / (R1 + R2) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(){
    int H,W,i,j;
    
    while(1){
    scanf("%d %d",&H,&W);
    if(H==0 && W==0) break;
    
    for(i=0;i<H;i++){
        for(j=0;j<W;j++){
            printf("#");
        }
    printf("\n");    
    }
    printf("\n");
    }
    return 0;
}


Measured memory_bytes: 2076
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

	static BufferedReader reader;
	final static boolean MODE_DEBUG = true;
	//static field here
	
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		reader = new BufferedReader(new InputStreamReader(System.in));
		//code here
		
		int[] NM = readLineInt();
		long N = NM[0];
		long M = NM[1];
		
		if(N==1||M==1) {
			print(1);
		}
		else if(N*M%2==0) {
			print(N*M/2);
		}else {
			print((N-1)*M/2+(M-1)/2+1);
		}
		
		
		//String[] s = readLine();
		//print(num);
	}
	
	//functions here
	//note that all methods should be STATIC

	private static <T> int arraySearch(T needle, T[] heystack) {
		for(int i=0;i<heystack.length;i++) {
			if(needle.equals(heystack[i])) {
				return i;
			}
		}
		return -1;
	}
	private static String[] readLine(){
		try{
			return reader.readLine().split(" ");
		}catch(Exception e){
			e.printStackTrace();
			return new String[]{e.getMessage()};
		}
	}
	private static int[] readLineInt(){
		try{
			String[] s = readLine();
			int[] ints = new int[s.length];
			for(int i=0;i<ints.length;i++) {
				ints[i] = Integer.parseInt(s[i]);
			}
			return ints;
		}catch(Exception e){
			e.printStackTrace();
			return null;
		}
	}
	private static byte[] readLineByte(){
		try{
			String[] s = readLine();
			byte[] bytes = new byte[s.length];
			for(int i=0;i<bytes.length;i++) {
				bytes[i] = Byte.parseByte(s[i]);
			}
			return bytes;
		}catch(Exception e){
			e.printStackTrace();
			return null;
		}
	}
	private static char[] readLineChar(){
		try{
			String[] s = readLine();
			char[] chars = new char[s.length];
			for(int i=0;i<chars.length;i++) {
				chars[i] = (char)Integer.parseInt(s[i]);
			}
			return chars;
		}catch(Exception e){
			e.printStackTrace();
			return null;
		}
	}
	private static void print(Object o){
		System.out.println(o);
	}
	private static void print(){
		System.out.println();
	}
	private static void printd(Object o){
		if(MODE_DEBUG)System.err.println(o);
	}
	private static void printd(){
		if(MODE_DEBUG)System.err.println();
	}
}


Measured memory_bytes: 22612
#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
#include<functional>
#include<string>
#include<cstring>
#include<cmath>
#include<sstream>
using namespace std;
int  main()
{
	int L,ans;
	string s;
	vector<string> cnt;
	while(cin>>s>>L)
	{
	if(L==0)return 0;
	cnt.push_back(s);
	for(int i=1;i<=20;i++)
	{
		//L=s.size();
		int mmax=0,mmin=0;
		//string mm,mi;
		while(s.size()<L)
		{
			s+='0';
		}
		sort(s.begin(),s.end());
		//cout<<s<<endl;
		for(int j=0;j<L;j++)
		{
			if(s[j]=='0'&&j==0)
			{
				continue;
			}
			else if(s[j]!='0')
			{
				mmin+=pow(10,(L-j-1))*(s[j]-'0');
			}
			else if(s[j]!='0')
			{
				mmin+=pow(10,(L-j-1));
			}
			
			//cout<<s[j]-'0'<<endl;
		}
		for(int j=L-1;j>=0;j--)
		{
			if(s[j]=='0'&&j==0)
			{
				continue;
			}
			else if(s!="0")
			{
				mmax+=pow(10,(j))*(s[j]-'0');
			}
		}
		//cout<<mmax<<" "<<mmin<<endl;
		ans=mmax-mmin;
		//cout<<ans<<endl;
		stringstream ss;
		ss<<ans;
		s=ss.str();
	//	A:
		if(count(cnt.begin(),cnt.end(),s))
		{
			
			int num=0;
			for(int k=0;k<cnt.size();k++)
			{
				if(s==cnt[k])
				{
					num=k;
					break;
				}
			}
			cout<<num<<" "<<s<<" "<<i-num<<endl;
			break;
		}
		cnt.push_back(s);
		//s.clear();
	}
	//A:;
	if(!cnt.empty())cnt.clear();
	}
	return 0;
}

Measured memory_bytes: 1296
#include<iostream>
#include<set>
#define rep(i,a,b) for(int i=a;i<b;i++)
using namespace std;
multiset<int> num;
int main(){
	int x,r=0;
	rep(i,0,10){
		cin>>x;
		num.insert(x);
	}
	multiset<int>::iterator ite=num.end();
	ite--;
	while(r<3){
		cout<<*ite<<endl;
		ite--;
		r++;
	}
	return 0;
}

Measured memory_bytes: 0
#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
//#include <atcoder/all>
using namespace std;
//using namespace atcoder;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef tuple<ll, ll, ll> tl3;

//typedef modint998244353 mint;

const int BIG_NUM = 1e9;
const ll INF = 1000000000000000000;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;

const ll MAX = 1e9 + 5;


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

	if (n < 6) {
		switch (n)
		{

		case 5:
			cout << 30 << " ";
		case 4:
			cout << 20 << " ";

		case 3:
			cout << 2 << " ";
			cout << 5 << " ";
			cout << 63 << " ";
		default:
			break;
		}
		return 0;
	}
	set<int> s;
	ll sum = 0;
	int cnt = 0;
	int num = 1;
	while (cnt < n) {
		num++;
		if (num % 6 == 1 || num % 6 == 5) {
			continue;
		}
		s.insert(num);
		sum += num;
		cnt++;
	}

	
	if (sum % 6 == 2) {
		s.erase(8);
		num = (num / 6 + 1) * 6;
		s.insert(num);
	}
	if (sum % 6 == 3) {
		s.erase(9);
		num = (num / 6 + 1) * 6;
		s.insert(num);
	}

	if (sum % 6 == 5) {
		s.erase(9);
		num = ((num - 4) / 6 + 1) * 6 + 4;
		s.insert(num);
	}

	for (auto it = s.begin(); it != s.end(); it++) {
		cout << *it << " ";
	}
	



}

Measured memory_bytes: 4508
import sys
sys.setrecursionlimit(10**7)
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return sys.stdin.readline().strip()
INF = 10 ** 18
MOD = 10 ** 9 + 7


from functools import lru_cache


def main(): 
    S = SI()

    # 桁DP
    dp_table = [[0 for _ in range(13)] for _ in range(len(S))]

    # 最初の桁を見る。
    if S[0] == '?':
        region = range(10)
    else:
        region = [int(S[0]),]
    for i in region:
        dp_table[0][i] = 1

    # 以降の桁を見ていく。
    for digit in range(1, len(S)):
        if S[digit] == '?':
            region = range(10)
        else:
            region = [int(S[digit]),]

        for prev_res, comb in enumerate(dp_table[digit-1]):
            for x in region:
                res = (prev_res*10+x)%13
                dp_table[digit][res] = (dp_table[digit][res] + comb)%MOD

    print(dp_table[len(S)-1][5])



main()

Measured memory_bytes: 66012
#include <iostream>
using namespace std;
 
int main(){
	long long A,B,V,W,T;
  	cin >> A >> V >> B >> W >> T;
  	if(B>A){
  	if((A+V*T)>=(B+W*T)){cout << "YES" << endl;}
  	else{cout << "NO" << endl;}
    }
  	else{
    if((A-V*T)<=(B-W*T)){cout << "YES" << endl;}
  	else{cout << "NO" << endl;}
    }
}

Measured memory_bytes: 3632
import java.util.Scanner;

public class Main {

	public static void main(String args[])
	{
		Scanner scan=new Scanner(System.in);
		int n=scan.nextInt();
		int ar[]=new int[n];
		for(int i=0;i<n;i++)
		{
			ar[i]=scan.nextInt();
		}
		int left[]=new int[n];
		int right[]=new int[n];
		for(int i=0;i<n;i++)
		{
			if(i==0)left[i]=ar[i];else
				left[i]=Math.max(ar[i],left[i-1]);
		}
		for(int i=n-1;i>=0;i--)
		{
			if(i==n-1)
			{
				right[i]=ar[i];
			}else{
				right[i]=Math.max(ar[i],right[i+1]);
			}
		}
		for(int i=0;i<n;i++)
		{
			if(i==0)
			{
				System.out.println(right[i+1]);
			}else if(i==n-1)
			{
				System.out.println(left[n-2]);
			}else {
			System.out.println(Math.max(left[i-1],right[i+1]));
			}
			}
	}
}


Measured memory_bytes: 89196
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <utility>
#include <set>
#include <stack>
#include <climits>
#include <cmath>

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define rep1(i,n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
#define reps(i,s,n) for(int i=s, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define MEMSET(v, h) memset((v), h, sizeof(v))
typedef long long ll;
const char sp = ' ';


using namespace std;

int main(void){
    ll X;
    cin>>X;
    if(X%100<=5*(ll)(X/100)) cout<<1<<endl;
    else cout<<0<<endl;
    return 0;
}


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

#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

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

  cout << a * b << endl;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define erep(i,a,b) for(int i=a;i<=(int)(b);++i)
#define per(i,a,b) for(int i=(b);i>(a);--i)
#define eper(i,a,b) for(int i=((int)(a));i>=b;--i)
#define pb push_back
#define mp make_pair
#define INF 2000000000
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a, b)*b;}

int a, b;
int main() {
 ios::sync_with_stdio ( false );
 cin.tie ( 0 );
    cin >> a >> b;
    if (a + b == 15) {
        cout << "+" << endl;
    } else if (a * b == 15) 
        cout << "*" << endl;
    else 
        cout << "x" << endl;
    return 0;
}


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

#define ll long long

int main() {
//#ifndef ONLINE_JUGDE
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
//#endif
    ios::sync_with_stdio(0);
    cin.tie(0);

	int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++){
    	cin>>a[i];
	}
	sort(a,a+n,greater<int>());
	int id=0;
	ll total=0;
	for(int i=0;i<n-1;i++){
		total+=(ll)a[id];
		if(i%2==0)
			id++;
	}
	cout<<total;
	
	return 0;
}


Measured memory_bytes: 4376
_n = gets
L = gets.split("\s").map(&:to_i).sort
count = 0

0.step (L.size-1) do |l1|
  (l1+1).step (L.size-1) do |l2|
    (l2+1).step (L.size-1) do |l3|
      if L[l1] + L[l2] > L[l3] && L[l1] != L[l2] && L[l2] != L[l3]
        count += 1
      end
    end
  end
end

p count
        

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

typedef long long ll;
const ll MOD = 1e9+7;
const int N = 1e5+5;

int n,a[N];


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

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

    a[1]=max(1,a[1]-1);

    for(int i=2;i<=n;i++){
        if(a[i]<a[i-1]){
            cout<<"No";
            return 0;
        }else if(a[i]>a[i-1]){
            a[i]--;
        }
    }
    cout<<"Yes";
    return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
/************************************************/
#define rep(i,n) for(int i=0;i<n;i++)
#define m_p make_pair
#define pb push_back
#define fr first
#define se second
#define forn(i,a,n) for(int i=a;i<n;i++)
#define foreach(i,c) for(__typeof(c.begin())i=(c.begin());i!=(c).end();i++)
#define pii pair<int,int>
#define vi vector<int>
#define ll long long
#define sz(s) s.size()
#define all(s) s.begin(),s.end()
#define zero(x) memset(x,0,sizeof(x))
#define vii vector<pair<int,int> >
#define mpis map<int,string>
#define mpii map<int,int>
#define mpsi map<string,int>
#define re return
/************************************************/
using namespace std;

long long get(){
	char c=getchar();
	long long x=0LL;
	while(c<'0'||c>'9')
	c=getchar();
	while(c>='0'&&c<='9'){
		x*=10LL;
		x+=(c-'0');
		c=getchar();
	}
	return x;
}
int n,m,p[100001],ans,ans1[100001];
bool f[100001];
int main(){
	cin>>n>>m;
	rep(i,m){
		cin>>p[i];
		p[i]--;
		string s;
		cin>>s;
		if(f[p[i]])
		continue;
		if(s=="AC"){
			ans++;
			f[p[i]]=true;
		}else
		ans1[p[i]]++;
	}
	int sum=0;;
	rep(i,n)
	if(f[i])
	sum+=ans1[i];
	cout<<ans<<" "<<sum;
	re 0;
}


Measured memory_bytes: 1152