akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
using namespace std;
int main() {
	int n;
	int out[4] = { false };
	while (cin >> n&&n != 0) {
		int line[5];
		bool used[4] = { false };
		int count = 1;
		used[n] = true;
		line[0] = n;
		for (int i = 1; i < 5; ++i) {
			cin >> line[i];
			if (used[line[i]] == false)++count;
			used[line[i]] = true;
		}
		if (count == 3 || count == 1) {
			for(int i=0;i<5;++i)
			cout << 3 << endl;
		}
		else {
			if (used[1] == false) {
				out[2] = 1;
				out[3] = 2;
			}
			else if (used[2] == false) {
				out[1] = 2;
				out[3] = 1;
			}
			else {
				out[1] = 1;
				out[2] = 2;
			}
			for (int i = 0; i < 5; ++i) {
				cout << out[line[i]] << endl;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 3000
#include <iostream>
#include <stdio.h>
#include <cmath>
using namespace std;

int main(){
    int x1, y1, x2, y2;
    double xm, ym, xc, yc, x3, y3, x4, y4;
    cin >> x1 >> y1 >> x2 >> y2;
    x3 = y3 = x4 = y4 = xm = ym = xc = yc = 0;
    xm = (x1 + x2) / 2.0;
    ym = (y1 + y2) / 2.0;
    xc = (x2 - xm) * 0.0 + (y2 - ym) * (-1.0) + xm;
    yc = (x2 - xm) * 1.0 + (y2 - ym) * 0.0 + ym;
    x3 = (x2 - xc) * 0.0 + (y2 - yc) * (-1.0) + xc;
    y3 = (x2 - xc) * 1.0 + (y2 - yc) * 0.0 + yc;
    x4 = (x3 - xc) * 0.0 + (y3 - yc) * (-1.0) + xc;
    y4 = (x3 - xc) * 1.0 + (y3 - yc) * 0.0 + yc;
    printf("%d %d %d %d\n", (int)x3, (int)y3, (int)x4, (int)y4);
    return 0;
}

Measured memory_bytes: 256
N,M=map(int,input().split())
root=[-1]*N
def find(i):
    global root
    if root[i]>=0:
        root[i]=find(root[i])
        return root[i]
    return i
for i in range(M):
    X,Y,Z=map(int,input().split())
    rx=find(X-1)
    ry=find(Y-1)
    if rx==ry:
        continue
    elif root[rx]<=root[ry]:
        root[rx]+=root[ry]
        root[ry]=rx
    elif root[rx]>root[ry]:
        root[ry]+=root[rx]
        root[rx]=ry
ans=0
for r in root:
    if r<0:
        ans+=1
print(ans)

Measured memory_bytes: 5412
use proconio::input;

#[allow(unused_imports)]
use proconio::marker::{Bytes, Chars, Usize1};
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::ops::*;
#[derive(Clone, Debug, Default)]
struct Struct;

const MAX_ALPHA:usize = 26;

//#[proconio::fastout]
fn main() {
    input! {
        n: usize,
        mut s: [Bytes;n],
    }

    for i in 0..n {
        s[i].reverse();
    }
    // 末尾の文字を無視してソートする。sliceのcmpは辞書順
    s.sort_unstable_by(|a,b|{a[0..a.len()-1].cmp(&b[0..b.len()-1])}); 

    let mut samelen = Vec::with_capacity(n); // 次の文字列と比べて、先頭何文字が一致するか
    for i in 0..n-1 {
        let mut j = 0;
        let maxlen = min(s[i].len() , s[i+1].len());
        while j < maxlen && s[i][j] == s[i+1][j] {
            j += 1;
        }
        samelen.push(j);
    }

    let mut char_count = vec![vec![0;MAX_ALPHA];n]; // 文字の出現頻度
    for i in 0..n {
        for j in 0..s[i].len() {
            char_count[i][(s[i][j] - b'a') as usize] += 1;
        }
    }

    let mut ans = 0u64;
    for i in 0..n-1 {
        let len1 = s[i].len()-1;
        let lastchar = (s[i][len1] - b'a') as usize;
        for j in i+1 .. n {
            if samelen[j-1] < len1 {
                break;
            }
            if char_count[j][lastchar] >= char_count[i][lastchar] {
                ans += 1;
            }
        }
        //let st = std::str::from_utf8(&s[i][..]).unwrap();
        //println!("{} {}", st, ans );
    }

    println!("{}", ans);
}


Measured memory_bytes: 42004
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ll;
#define rep(i,n) for(int i=0; i<(n); i++)
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; }

int main(){
    ll n; cin>>n;
    string s; cin>>s;
    ll ans=0;
    rep(i,1000){
        string str=to_string(i);
        if(str.size()<3) str='0'+str;
        if(str.size()<3) str='0'+str;
        ll cnt=0;
        rep(j,n){
            if(s[j]==str[cnt])cnt++;
            if(cnt==3){ans++; break;}
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <deque>
#include <algorithm>
#include <numeric>
#include <string>
#include <cstring>
#include <list>
#include <unordered_set>
#include <tuple>
#include <cmath>
#include <limits>
#include <type_traits>
#include <iomanip>
using namespace std;

using INT = long long;
using UINT = unsigned long long;

unsigned gcd(unsigned a, unsigned b) {
	while (1) {
		if (a < b) swap(a, b);
		if (!b) break;
		a %= b;
	}
	return a;
}

const UINT mod = 1000000007;

UINT PowMod(UINT x, UINT y)
{
	if (y == 0)
	{
		return 1;
	}
	else if (y == 1)
	{
		return x % mod;
	}
	else if (y % 2 == 0)
	{
		auto tmp = PowMod(x, y / 2);
		return tmp * tmp % mod;
	}
	else
	{
		auto tmp = PowMod(x, y / 2);
		return (tmp * tmp % mod) * x % mod;
	}
}

UINT getModInv(UINT N)
{
	return PowMod(N, mod - 2);
}

struct uf
{
	vector<INT> p;

	uf(INT n) : p(n)
	{
		for (size_t i = 0; i < n; i++)
		{
			p[i] = i;
		}
	}

	INT rt(INT n)
	{
		return p[n] == n ? n : p[n] = rt(p[n]);
	}

	void un(INT n, INT m)
	{
		p[rt(n)] = p[rt(m)];
	}

	bool eq(INT n, INT m)
	{
		return rt(n) == rt(m);
	}
};

int main()
{
	INT l, r;
	cin >> l >> r;

	if (r - l >= (r % 2019))
	{
		cout << 0 << endl;
		return 0;
	}
	r %= 2019;
	l %= 2019;
	INT ans = 2019;
	for (INT i = l; i <= r - 1; i++)
	{
		for (INT j = i + 1; j <= r; j++)
		{
			ans = min(ans, i * j % 2019);
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <set>
#include <iterator>
#include <math.h>
#include <bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
#define pb push_back
#include <algorithm>
using namespace std;
int main()
{
	ll N;
	cin>>N;
	if(N>=30)
	cout<<"Yes\n";
	else
	cout<<"No\n";
	return 0;
}

Measured memory_bytes: 3620
// C++ (GCC 9.2.1)
#include <bits/stdc++.h>
using namespace std;
#define repex(i, a, b, c) for(int i = a; i < b; i += c)
#define repx(i, a, b) repex(i, a, b, 1)
#define rep(i, n) repx(i, 0, n)
#define repr(i, a, b) for(int i = a; i >= b; i--)

struct Bracket{
    int l, r;
    bool operator<(const Bracket& rhs) const {
        return (l < rhs.l) || ((l == rhs.l) && (r < rhs.r));
    }
};

int main(){
    
    // 1. 入力情報.
    int N;
    scanf("%d", &N);
    
    // 2. 括弧情報を取得.
    priority_queue<Bracket> pq;
    rep(i, N){
        char c[1010101];
        scanf("%s", c);
        string S(c);
        int sl = S.size();
        // 括弧情報 を 整理.
        // {'(': a個, ')': b個} の 情報 を 保存.
        Bracket b;
        b.l = 0, b.r = 0;
        rep(j, sl){
            if(S[j] == '('){
                b.l++;
            }else{
                if(b.l) b.l--;
                else    b.r++;
            }
        }
        // 追加.
        if(b.l || b.r) pq.push(b);
    }
    
    // 3. 集計.
    Bracket ans;
    ans.l = 0, ans.r = 0;
    while(!pq.empty()){
        Bracket b = pq.top();
        pq.pop();
        if(b.r == 0){
            if(ans.r >= b.l) ans.r -= b.l;
            else             ans.l += (b.l - ans.r), ans.r = 0;
        }
        if(b.l == 0){
            if(ans.l >= b.r) ans.l -= b.r;
            else             ans.r += (b.r - ans.l), ans.l = 0;
        }
        if(b.l && b.r){
            // 左: ans, 右: b で 連結.
            int al1 = ans.l, ar1 = ans.r;
            if(ans.l >= b.r){
                al1 = ans.l - b.r + b.l;
                ar1 = ans.r;
            }else{
                ar1 = ans.r - ans.l + b.r;
                al1 = b.l;
            }
            
            // 左: b, 右: ans で 連結.
            int al2 = ans.l, ar2 = ans.r;
            if(b.l >= ans.r){
                al2 = b.l - ans.r + ans.l;
                ar2 = b.r;
            }else{
                ar2 = b.r - b.l + ans.r;
                al2 = ans.l;
            }
            
            // 比較.
            if(al1 + ar1 <= al2 + ar2) ans.l = al1, ans.r = ar1;
            else                       ans.l = al2, ans.r = ar2;
        }
        // printf("l=%d r=%d ans.l=%d ans.r=%d\n", b.l, b.r, ans.l, ans.r);
    }
    
    // 4. 出力.
    printf("%s\n", (ans.l == 0 && ans.r == 0) ? "Yes" : "No");
    return 0;
    
}

Measured memory_bytes: 11688
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll MOD = (1e+9)+7;
const ll INF = (ll)1000000007 * 1000000007;
const double EPS = 1e-9;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-11;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
bitset<4000001> exi;
int main() {
	exi.set(0);
	int n; cin >> n;
	int a[2000];
	int sum = 0;
	rep(i, n) {
		cin >> a[i]; sum += a[i];
		exi |= exi << a[i];
	}
	int d = (sum + 1) / 2;
	Rep(i, d, 5000000) {
		if (exi[i]) {
			cout << i << endl; break;
		}
	}
	return 0;
}

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

int main(){
  int N;
  cin>>N;
  string S;
  cin>>S;
  int B[N+1]={};
  int W[N+1]={};
  int temp=0;
  B[0]=0;

  for(int i=0;i<N;i++){
    if(S.at(i)=='#'){
      temp++;
    }
    B[i+1]=temp;
  }
  temp=0;
  for(int i=N-1;i>=0;i--){
    if(S.at(i)=='.'){
      temp++;
    }
    W[i]=temp;
  }  
  W[N+1]=0;
  int ans=1000000000;
  for(int i=0;i<N;i++){
    ans=min(ans,B[i]+W[i+1]);
    //cout<<i<<" "<<B[i]<<" "<<W[i+1]<<endl;
  }
  cout<<ans<<endl;
  return 0;
}

  

Measured memory_bytes: 5324
#include <cstdio>
#include <cstring>
#include <iostream> 
#include <algorithm>
using namespace std;
int a[105][105][2], dp[105][105][105][105];
int main () {
	int n, m, Ex, Ey;
	scanf ("%d %d", &n, &m);
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= m; j++) {
			char ch;
			cin >> ch;
			if (ch == 'o') a[i][j][0] = a[i][j][1] = 1;
			if (ch == 'E') Ex = i, Ey = j;
		}
	}
	for (int i = 1; i <= n; i++) for (int j = 1; j <= m; j++) a[i][j][1] += a[i-1][j][1];
	for (int i = 1; i <= n; i++) for (int j = 1; j <= m; j++) a[i][j][0] += a[i][j-1][0];
	int ans = 0;
	for (int l = 0; l < Ey; l++) {
		for (int r = 0; r + Ey <= m; r++) {
			for (int u = 0; u < Ex; u++) {
				for (int d = 0; d + Ex <= n; d++) {
					if (u + d < n - Ex) dp[l][r][u][d+1] = max (dp[l][r][u][d+1], dp[l][r][u][d] + a[Ex+d+1][min(m-l,Ey+r)][0] - a[Ex+d+1][max(r,Ey-l-1)][0]);
					if (l + r < m - Ey) dp[l][r+1][u][d] = max (dp[l][r+1][u][d], dp[l][r][u][d] + a[min(n-u,Ex+d)][Ey+r+1][1] - a[max(d,Ex-u-1)][Ey+r+1][1]);
					if (l + r < Ey - 1) dp[l+1][r][u][d] = max (dp[l+1][r][u][d], dp[l][r][u][d] + a[min(n-u,Ex+d)][Ey-l-1][1] - a[max(d,Ex-u-1)][Ey-l-1][1]);
					if (u + d < Ex - 1) dp[l][r][u+1][d] = max (dp[l][r][u+1][d], dp[l][r][u][d] + a[Ex-u-1][min(m-l,Ey+r)][0] - a[Ex-u-1][max(r,Ey-l-1)][0]);
					ans = max (ans, dp[l][r][u][d]);
				}
			}
		}
	}
	printf ("%d", ans);
	return 0;
}

Measured memory_bytes: 99432
#include <cstdio>
#include <cstring>
#include <algorithm>
#define ll long long
#define inf 1<<30
#define il inline 
#define in1(a) read(a)
#define in2(a,b) in1(a),in1(b)
#define in3(a,b,c) in2(a,b),in1(c)
#define in4(a,b,c,d) in2(a,b),in2(c,d)
il void readl(ll &x){
    x=0;ll f=1;char c=getchar();
    while(c<'0'||c>'9'){if(c=='-')f=-f;c=getchar();}
    while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}
    x*=f;
}
il void read(int &x){
    x=0;int f=1;char c=getchar();
    while(c<'0'||c>'9'){if(c=='-')f=-f;c=getchar();}
    while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}
    x*=f;
}
using namespace std;
/*===================Header Template=====================*/
#define N 100010
#define lowbit(x) x&-x
int c[N*10];
int n,a[N],s[N*10];
void add(int x){
    for(int i=x;i<=2*N;i+=lowbit(i))c[i]++;
}
ll query(int x){
    ll sum=0;
    for(int i=x;i>0;i-=lowbit(i))sum+=c[i];
    return sum;
}
bool check(int x){
    for(int i=1;i<=2*N;i++)c[i]=0;
    s[0]=0;
    for(int i=1;i<=n;i++)
        s[i]=s[i-1]+(a[i]>=x?1:-1);
    ll sum=0;
    for(int i=0;i<=n;i++){
        sum+=query(s[i]+N);
        add(s[i]+N);
    }
    return sum>=1ll*n*(n+1)/4;
}
int main(){
    in1(n);
    int l=0,r=0;
    for(int i=1;i<=n;i++){
        in1(a[i]);
        r=max(r,a[i]);
    }
    int ans=0;
    while(l<=r){
        int mid=(l+r)>>1;
        if(check(mid))l=mid+1;
        else r=mid-1;
    }
    printf("%d\n",r);
}

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

int n,d;
std::vector<std::vector<int>> x;

void input()
{
    std::cin>>n>>d;
    x.resize(n);
    for(int i=0;i<n;i++){
        x[i].resize(d);
        for(int j=0;j<d;j++){
            std::cin>>x[i][j];
        }
    }
}
//double型の整数判定
bool is_int(double a){
    if((long long)a == a)return true;
    else return false;
}



int main()
{
    input();
    int cnt = 0;

    //各点に関して
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            double dis = 0;
            for(int k=0;k<d;k++){
                dis += (x[i][k] - x[j][k])*(x[i][k] - x[j][k]);
            }
            dis = std::sqrt(dis);
            if(is_int(dis))cnt++;
        }
    }
    std::cout<<cnt<<std::endl;
}

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

int main() {
  string s;
  
  cin >> s;
  int res;
  if(s == "SSS"){
    res = 0;
  }else if(s == "RRS" || s == "SRR"){
    res = 2;
  }else if(s == "RRR"){
    res = 3;
  }else{
    res = 1;
  }
  cout << res << endl;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	ll a, b, c, ans = 1e18; cin >> a >> b >> c;
	ans = min(ans, abs(b * c * (a % 2)));
	ans = min(ans, abs(c * a * (b % 2)));
	ans = min(ans, abs(a * b * (c % 2)));
	cout << ans << endl;
	return 0;
}

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

int main(void)
{
    int N;
    cin >> N;
    vector<int> T(N);
    int sum{0};

    for(int i{0}; i<N; ++i){
        cin >> T[i];
        sum += T[i];
    }

    int M;
    cin >> M;



    int P, X;
    for(int i{0}; i<M; ++i){
        cin >> P >> X;
        
        cout << sum-(T[P-1]-X) << endl;
    }
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
	int H,W;
	int 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: 572
N,M,X,Y=map(int,input().split())
x=list(map(int,input().split()))
y=list(map(int,input().split()))
A=max(x)
B=min(y)
if A>=B:
    print("War")
else:
    if X<=A and B<=Y:
        print("No War")
    else:
        print("War")

Measured memory_bytes: 3060
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10**8)
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return [LIST() for _ in range(n)]
def NSTR(n): return [input() for _ in range(n)]


INF = float("inf")
MOD = 10**9 + 7


def main():
    X = INT()
    if 1800 <= X:
        print(1)
    elif 1600 <= X:
        print(2)
    elif 1400 <= X:
        print(3)
    elif 1200 <= X:
        print(4)
    elif 1000 <= X:
        print(5)
    elif 800 <= X:
        print(6)
    elif 600 <= X:
        print(7)
    else:
        print(8)
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 9216
#k = int(input())
#s = input()
#a, b = map(int, input().split())
#s, t = map(str, input().split())
#l = list(map(int, input().split()))
#l = [list(map(int,input().split())) for i in range(n)]
#a = [input() for _ in range(n)]

s = input()

h = {"A":"T","C":"G","G":"C","T":"A"}

print(h[s])





Measured memory_bytes: 8944
n,m,q = [int(_) for _ in input().split()]
a = []
b = []
c = []
d = []

for q in range(q):
  tmplist = [int(_) for _ in input().split()]
  a.append(tmplist[0])
  b.append(tmplist[1])
  c.append(tmplist[2])
  d.append(tmplist[3])

# Aという数列を再帰関数で求める
# {} → {A1, A2, A3...AN} の数

result=[]
def score(A):
  max_score = 0
  for i in range(q+1):
    if A[b[i]-1] - A[a[i]-1] != c[i]: # なぜマイナス１をしているのか？：ｑ
      continue
    else:
      max_score+= d[i]
  return max_score

def dfs(A):
  if len(A) == n+1: # 配列の個数はN個
    return score(A)
  result = 0
  past_data = A[-1]
  for v in range(past_data,m+1):
    A.append(v)
    result = max(result,dfs(A))
    A.pop()
  return result

print(dfs([1]))


Measured memory_bytes: 9192
#include <bits/stdc++.h>
#define ll long long
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end))) // rep(i, 1, 5) --> {1,2,3,4} // rep(i, 5, 1) --> {4,3,2,1} // rep(it, end(v), begin(v)) --> *it

using namespace std;

int main()
{
    int k, a, b;
    cin >> k >> a >> b;
    rep(i, a, b+1)
        if (i%k==0)
            return cout << "OK", 0;
    cout << "NG";
    return 0;
}

Measured memory_bytes: 3592
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
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; }

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n, a, b;
	cin >> n >> a >> b;
	ll ans;
	if((b-a)%2 == 0) ans = (b-a)/2;
	else{
		ll ans1 = a;
		ll A = 1, B = b - a;
		ans1 += (B - A) / 2;
		ll ans2 = n - b + 1;
		B = n; A = a + (n - b + 1);
		ans2 += (B - A) / 2;
		ans = min(ans1, ans2);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define SZ(x) ((int)x.size())
#define ALL(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
typedef long double ld;
int n, k;
int main() {
	scanf("%d%d", &n, &k);
	ll res = 0;
	for(int i=k+1; i<=n; i++) {
		ll x = (n - k) / i;
		res += (i - k) * x + min((ll)n, (x + 1) * i - 1) - (i * x + k) + 1;
		res -= k == 0;
	}
	printf("%lld", res);
	return 0;
}

// [k, i-1]
// [i+k, 2i-1]
// [2i+k, 3i-1]
// ...
// [xi+k, min(n, (x+1)i - 1)]

// xi+k <= n
// xi <= n - k
// x <= (n - k) / i

Measured memory_bytes: 384
#include<iostream>
#include<math.h>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;

#define FOR(i, n) for(int i = 0; i < (n); i++)
#define FORq(i, m, n) for(int i = (m); i < (n); i++)
#define FORr(i, n) for (int i = (n); i >= 0; i++)

int main() {
	int N, H, W;
	cin >> N >> H >> W;

	cout << (N - H + 1) * (N - W + 1) << endl;
}

Measured memory_bytes: 256
// vvvvvvvvvvvv TEMPLATE vvvvvvvvvvvv
#include <bits/stdc++.h>
using namespace std; using ll = long long; using P = pair<ll, ll>;
const ll linf = 1e18; const double eps = 1e-12, pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define each(i,a) for (auto&& i : a)
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
#define pb push_back
#define eb emplace_back
#define all(a) begin(a),end(a)
#define chmin(x,v) x = min(x, v)
#define chmax(x,v) x = max(x, v)
template<typename T> ll min(ll a, const T&& b) { return a < b ? a : b; }
template<typename T> ll min(const T&& a, ll b) { return a < b ? a : b; }
template<typename T> ll max(ll a, const T&& b) { return a > b ? a : b; }
template<typename T> ll max(const T&& a, ll b) { return a > b ? a : b; }
template<typename Head> void out(Head h) { cout << h << endl; } template<typename Head, typename... Tail>void out(Head h, Tail... t) { cout << h << " "; out(t...); }
template<typename T> istream& operator>>(istream& is, vector<T>& v) { each(x,v) is >> x; return is; }
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) { rep(i,v.size()) { if (i) os << " "; os << v[i]; } return os; }
ostream& operator<<(ostream& os, const vector<string>& v) { rep(i,v.size()) { if (i) os << endl; os << v[i]; } return os; }
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) { rep(i,v.size()) { if (i) os << endl; os << v[i]; } return os; }
template<typename T1, typename T2> ostream& operator<<(ostream& os, const pair<T1, T2>& p) { return os << "(" << p.first << ", " << p.second << ")"; }
struct yes_no : std::numpunct<char> { string_type do_truename() const { return "Yes"; } string_type do_falsename() const { return "No"; } };
void solve(); int main() {
  ios::sync_with_stdio(false); cin.tie(0); locale loc(locale(), new yes_no); cout.imbue(loc); cout << fixed << setprecision(10) << boolalpha;
  solve();
}
// ^^^^^^^^^^^^ TEMPLATE ^^^^^^^^^^^^

struct Edge {
  ll a, b, c;
};

void solve() {
  ll n, m; cin >> n >> m;
  vector<vector<ll>> G(n, vector<ll>(n, linf));
  rep(i, n) {
    G[i][i] = 0;
  }
  vector<Edge> edges;
  rep(i, m) {
    ll a, b, c; cin >> a >> b >> c; --a, --b;
    G[a][b] = G[b][a] = c;
    edges.pb({a, b, c});
  }
  rep(k, n) rep(i, n) rep(j, n) {
    chmin(G[i][j], G[i][k] + G[k][j]);
  }
  ll ans = 0;
  each(e, edges) {
    bool f = false;
    rep(i, n) rep(j, n) {
      if (G[i][e.a] + e.c + G[e.b][j] == G[i][j]) {
        f = true;
        break;
      }
    }
    if (!f) ++ans;
  }
  cout << ans << endl;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,b,a) for(int i=b;i>=a;i--)
#define fori(a) for(auto i : a )
#define all(a) begin(a), end(a)
#define set(a,b) memset(a,b,sizeof(a))
#define sz(a) a.size()
#define pi 3.14159
#define ll long long
#define ull unsigned long long
#define pb push_back
#define PF push_front //deque
#define mp make_pair
#define pq priority_queue
#define mod 1000000007
#define f first
#define s second
#define pii pair< int, int >
#define vi vector<int>
#define vpii vector<pii>
#define debug(v) for(auto i:v) cout<<i<<" ";
#define tc int t; cin >> t; while(t--)

using namespace std;
string repeat(string s, int n) {
    string s1 = "";
    for (int i=0; i<n;i++)
        s1+=s;
    return s1;
}
string getString(char x) {
    string s(1, x);
    return s;
}

void optimizeIO(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}
int gcd(int a, int b){
    if (a == 0)  return b;
    return gcd(b % a, a);
}
void  solve(){
  string s;
  cin>>s;
  int n=s.length();
  int a[n],b[n];
  rep(i,0,n){
    a[i]=(i+1)%2;
  }
  rep(i,0,n){
    b[i]=i%2;
  }
  int mx1=0,mx2=0;
  rep(i,0,n){
    mx1 += abs(a[i]-(s[i]-'0'));
    mx2 += abs(b[i]-(s[i]-'0'));
  }
  cout<<min(mx1,mx2)<<endl;
}
int main(){
    optimizeIO();
    // tc
    { solve();
    }
}


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

int main() {
	int N; string S; cin >> N >> S;
	int max=0, now=0, mi=-1;
	for(int i=0; i<N; ++i){
	    if(S[i]=='(') --now;
	    else ++now;
	    if(max<=now){
	        max=now;
	        mi=i;
	    }
	}
	now=0;
	for(int i=mi+1; i<N; ++i){
	    if(S[i]==')') --now;
	    else ++now;
	}
	for(int i=0; i<max; ++i) cout << '(';
	cout << S;
	for(int i=0; i<now; ++i) cout << ')';
	cout << endl;
	return 0;
}


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

const int MAXN = 55;
char G[MAXN][MAXN];
int n,m;
struct node
{
    node(int _ = 0, int __ = 0, int ___ = 0)
    {
        x = _;
        y = __;
        cnt = ___;
    }
    int x,y,cnt;
};

int dir[4][2] = {0,1,1,0,0,-1,-1,0};
bool vis[MAXN][MAXN];

int main()
{
    int cnt = 0;
    scanf("%d %d",&n,&m);
    for(int i = 0; i < n; ++i)
    {
        for(int j = 0; j < m; ++j)
        {
            scanf(" %c",&G[i][j]);
            if(G[i][j] == '.')
                ++cnt;
        }
    }
    queue<node> que;
    que.push(node(0,0,1));
    node now;
    int cur,tx,ty;
    while(!que.empty())
    {
        now = que.front();
        que.pop();
        for(int k = 0; k < 4; ++k)
        {
            tx = now.x + dir[k][0];
            ty = now.y + dir[k][1];
            if(tx == n-1 && ty == m-1)
            {
                printf("%d\n",cnt-now.cnt-1);
                return 0;
            }
            if(tx < 0 || ty < 0 || tx >= n || ty >= m)
                continue;
            if(vis[tx][ty] || G[tx][ty] != '.')
                continue;
            vis[tx][ty] = true;
            que.push(node(tx, ty, now.cnt+1));
        }
    }
    puts("-1");
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(i64 (i) = (s);(i) < (e);(i)++)
#define all(x) x.begin(),x.end()

template<class T>
static inline std::vector<T> ndvec(size_t&& n, T val) noexcept {
  return std::vector<T>(n, std::forward<T>(val));
}

template<class... Tail>
static inline auto ndvec(size_t&& n, Tail&&... tail) noexcept {
  return std::vector<decltype(ndvec(std::forward<Tail>(tail)...))>(n, ndvec(std::forward<Tail>(tail)...));
}

template<class T, class Cond>
struct chain {
  Cond cond; chain(Cond cond) : cond(cond) {}
  bool operator()(T& a, const T& b) const {
    if(cond(a, b)) { a = b; return true; }
    return false;
  }
};
template<class T, class Cond>
chain<T, Cond> make_chain(Cond cond) { return chain<T, Cond>(cond); }

int main() {
  i64 K;
  i64 A, B;
  cin >> K;
  cin >> A >> B;
  B = (B / K) * K;
  if(A <= B) {
    cout << "OK" << endl;
  }
  else {
    cout << "NG" << endl;
  }
}



Measured memory_bytes: 3592
from fractions import gcd
from functools import* #reduce
from itertools import* #permutations("AB",repeat=2) combinations("AB",2) product("AB",2) groupby
from operator import mul
from bisect import* #bisect_left bisect_right
from heapq import* #heapify heappop heappushpop
from math import factorial,pi
from copy import deepcopy
import sys
#input=sys.stdin.readline  #危険！基本オフにしろ！
sys.setrecursionlimit(10**6)


def main():
    while 1:
        a,b,c=map(int,input().split())
#        print(a,b,c)
        if a==-1 and b==-1 and c==-1:
            break
        if a==-1 or b==-1:
            print("F")
            continue
        if a+b>=80:
            print("A")
        if 80>a+b>=65:
            print("B")
        if 65>a+b>=50:
            print("C")
        if 50>a+b>=30:
            if c>=50:
                print("C")
            else:
                print("D")
        if a+b<30:
            print("F")
    
    

if __name__ == '__main__':
    main()


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

int main(){
    int N;
    cin >> N;
    vector<int> vec(N);
    int maxP = 0;
    int sum = 0;
    int ans = 0;
    for(int i = 0;i < N;i++){
        cin >> vec.at(i);
        maxP = max(maxP, vec.at(i));
        sum = sum + vec.at(i);
    }
    ans = sum - (maxP/2);
    
    cout << ans << endl;
}

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

using namespace std;

int main(){
    for(int i=0; i<9; i++){
        for(int j=0; j<9; j++){
            cout << i+1 << "x" << j+1 << "=" << (i+1)*(j+1) << endl;
        }
    }

    return 0;
}


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

int A, B, M;
int arrA[100001];
int arrB[100001];

int main() {
  scanf("%d %d %d", &A, &B, &M);
  int ma = 1e9, mb = 1e9;
  for(int i = 1; i <= A; i++) {
    scanf("%d", &arrA[i]);
    ma = min(ma, arrA[i]);
  }

  for(int i = 1; i <= B; i++) {
    scanf("%d", &arrB[i]);
    mb = min(mb, arrB[i]);
  }

  int ans = ma+mb;
  for(int i = 0; i < M; i++) {
    int x, y, c;
    scanf("%d %d %d", &x, &y, &c);
    ans = min(ans, arrA[x]+arrB[y]-c);
  }

  printf("%d", ans);
}



Measured memory_bytes: 1024
#pragma GCC optimize("O3")
#pragma GCC target("sse4")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const double PI=acos(-1.0);
#define t1(x)             cerr<<#x<<"="<<x<<endl
#define t2(x, y)          cerr<<#x<<"="<<x<<" "<<#y<<"="<<y<<endl
#define t3(x, y, z)       cerr<<#x<<"=" <<x<<" "<<#y<<"="<<y<<" "<<#z<<"="<<z<<endl
#define t4(a,b,c,d)       cerr<<#a<<"="<<a<<" "<<#b<<"="<<b<<" "<<#c<<"="<<c<<" "<<#d<<"="<<d<<endl
#define t5(a,b,c,d,e)     cerr<<#a<<"="<<a<<" "<<#b<<"="<<b<<" "<<#c<<"="<<c<<" "<<#d<<"="<<d<<" "<<#e<<"="<<e<<endl
#define t6(a,b,c,d,e,f)   cerr<<#a<<"="<<a<<" "<<#b<<"="<<b<<" "<<#c<<"="<<c<<" "<<#d<<"="<<d<<" "<<#e<<"="<<e<<" "<<#f<<"="<<f<<endl
#define GET_MACRO(_1,_2,_3,_4,_5,_6,NAME,...) NAME
#define tr(...) GET_MACRO(__VA_ARGS__,t6,t5, t4, t3, t2, t1)(__VA_ARGS__)
#define __ freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define fastio() ios::sync_with_stdio(0);cin.tie(0)
#define MEMS(x,t) memset(x,t,sizeof(x));
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
/*-------------------------------------------------------------------------------------------------------------------------------------*/
//#define MOD 1000000007
#define endl "\n" 
#define int long long
#define inf 1e18
#define ld long double
/*-------------------------------------------------------------------------------------------------------------------------------------*/
 
int32_t main()
{
	fastio();
	char x;
	cin>>x;
	if(x>='A' && x<='Z')
	{
		cout<<'A';
	}
	else
	{
		cout<<"a";
	}
}


Measured memory_bytes: 3644
#include <algorithm>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PI;
const ll mod = 1e9 + 7;



int main(void) {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, k;
  cin >> n >> k;
  map<ll, int> freq;
  REP(i, 0, n) {
    ll a;
    cin >> a;
    freq[a]++;
  }
  VI ff;
  for (auto e: freq) {
    ff.push_back(e.second);
  }
  sort(ff.begin(), ff.end());
  int tot = 0;
  if ((int)ff.size() > k) {
    REP(i, 0, ff.size() - k) {
      tot += ff[i];
    }
  }
  cout << tot << endl;
  
}


Measured memory_bytes: 13944
#include <stdio.h>

int main(){
  int N,L[200],X,S=0;
  scanf("%d %d",&N,&X);
  for(int i=1;i<=N;i++)
    scanf("%d",L+i);
  while(X>=0) X-=L[++S];
  printf("%d\n",S);
  return 0;
}

Measured memory_bytes: 1724
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
#define dec(n) cout << fixed << setprecision(n);
#define large "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
#define small "abcdefghijklmnopqrstuvwxyz"
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;

ll gcd(ll a,ll b){
  if(b == 0) return a;
  return gcd(b , a % b);
}

ll mod(ll a){
  return (a % 1000000007);
}

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


int main(){
  string s,t; cin >> s >> t;
  
  sort(all(s)); sort(all(t)); reverse(all(t));
  
  if(s < t) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(map(int,input().split()))
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
INF = 10**9
mod = 10**9+7

S = deque(list(s()))
cnt = 0
N = len(S)
for i in range(N):
    N = len(S)
    if N <= 1:
        break
    if S[0] == 'x':
        if S[N-1] == 'x':
            S.pop()
            S.popleft()
        else:
            cnt += 1
            S.popleft()
    else:
        a = S[0]
        if S[N-1] == 'x':
            cnt += 1
            S.pop()
        elif S[N-1] == a:
            S.pop()
            S.popleft()
        else:
            print(-1)
            exit()
print(cnt)

Measured memory_bytes: 87040
s = input()
l = len(s)
t = [0]*l
c=0
ch=0
for i in range(l):
    if s[l-1-i]=='C' and c == 0:
        c=1
    elif s[l-i-1]=='B' and c == 1:
        c=0
        ch+=1
    elif s[l-i-1]=='A' and c == 1:
        c=0
        ch = 0
    elif s[l-i-1]=='A':
        c=0
    elif s[l-i-1]=='C' and c==1:
        ch=0
        c=1
    else:
        ch=0
        c=0
    t[l-i-1]=ch
ans = 0
for i in range(l):
    if s[i]=='A':
        ans += t[i]
print(ans)


Measured memory_bytes: 6984
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) rep(i,v.size())cout<<" "<<v[i];cout<<endl<<endl;
#define show2d(v) rep(i,v.size()){rep(j,v[i].size())cout<<" "<<v[i][j];cout<<endl;}cout<<endl;
using namespace std;
//kaewasuretyuui
typedef long long ll;
#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
//#define mt make_tuple
//typedef tuple<int,int,int> tp;
//typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int n;
string s;
string f(int l,int r){
	vvi pos((r-l)/2,vi(2));
	int q;
	q=0;loop(i,l,r)if(s[i]=='a')pos[q++][0]=i;
	q=0;loop(i,l,r)if(s[i]=='b')pos[q++][1]=i;
	string t="";
	if(s[l]=='a'){
		q=-1;
		rep(i,pos.size()){
			if(pos[i][0]>q){
				t+="ab";
				q=pos[i][1];
			}
		}
	}else{
		vi used(r-l);
		rep(i,pos.size()){
			string w="";
			used[pos[pos.size()-1-i][0]-l]=1;
			used[pos[pos.size()-1-i][1]-l]=1;
			rep(j,used.size())if(used[j])w+=s[l+j];
			cmax(t,w);
		}
	}
	return t;
}
signed main(){
	cin>>n>>s;
	vs dp;
	int t=0,p=0;
	rep(i,s.size()){
		if(s[i]=='a')t++;
		else t--;
		if(!t){
			dp.pb(f(p,i+1));
			p=i+1;
		}
	}
	int N=dp.size();
	for(int i=N-1;i>=0;i--){
		string w=dp[i];
		loop(j,i+1,N)cmax(w,dp[i]+dp[j]);
		if(i!=N-1)cmax(w,dp[i+1]);
		dp[i]=w;
	}
	cout<<dp[0]<<endl;
}

















Measured memory_bytes: 10496
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

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

typedef long long lint;

using namespace std;

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


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
# スペース区切りの整数の入力
n, k = map(int, raw_input().split())

winrate = 0.0


for i in range(n):
    i = i+1
    j = 0
    while(i < k):
        i *= 2
        j += 1
    winrate = winrate + (0.5) ** j

# 文字列の入力
winrate = winrate/n

# 出力
print winrate

Measured memory_bytes: 5764
// 失敗するからこそ そこから立ち向かって行く強さがあってそんな強さが本当の強さだと私は思うから
// ぜったいあきらめない
#if defined(DAIJOBU)
#include "/home/ichigo/includes.hpp"
#include "PP.hpp"
#define deb(x...) cerr << "[" << #x << "] = " << x << "\n";
#else
#include <bits/stdc++.h>
#define deb(x...)
#endif
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long lint;
typedef vector<lint> vlint;
typedef vector<vlint> vvlint;
typedef pair<lint, lint> plint;
typedef double ld;

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

int main() {
    ios::sync_with_stdio(false);
	cin.tie(0);
	
	string s;
	cin >> s;
	forn(i, s.size()){if(s[i] == '1')s[i] = '9';else if(s[i] == '9')s[i] = '1';}
	cout << s << '\n';
	return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
#include<map>
#include<stdio.h>
#include<vector>
using namespace std;
#define int long long
#define rep(s,i,n) for(int i=s;i<n;i++)
#define c(n) cout<<n<<endl;
#define ic(n) int n;cin>>n;
#define sc(s) string s;cin>>s;
#define mod 1000000007
#define inf 1000000000000000007
#define f first
#define s second
#define mini(c,a,b) *min_element(c+a,c+b)
#define maxi(c,a,b) *max_element(c+a,c+b)
#define P pair<int,int>
//printf("%.12Lf\n",);
int keta(int x){
	rep(0,i,30){
		if(x<10){
			return i+1;
		}
		x=x/10;
	}
}
int gcd(int x,int y){
	int aa=x,bb=y;
	rep(0,i,1000){
		aa=aa%bb;
		if(aa==0){
			return bb;
		}	
		bb=bb%aa;
		if(bb==0){
			return aa;
		}
	}
}	
int lcm(int x,int y){
	int aa=x,bb=y;
	rep(0,i,1000){
		aa=aa%bb;
		if(aa==0){
			return x/bb*y;
		}	
		bb=bb%aa;
		if(bb==0){
			return x/aa*y;
		}
	}
}
bool p(int x){
	if(x==1)return false;
	rep(2,i,sqrt(x)+1){
		if(x%i==0&&x!=i){
			return false;
		}
	}	
	return true;
}
int max(int a,int b){
	if(a>=b)return a;
	else return b;
}
int min(int a,int b){
	if(a>=b)return b;
	else return a;
}	
int n2[41];		
int nis[41]; 
int nia[41];
int mody[41];
int nn;
int com(int n,int y){
	int ni=1;
	for(int i=0;i<41;i++){
		n2[i]=ni;
		ni*=2;
	}
	int bunsi=1,bunbo=1;
	rep(0,i,y)bunsi=(bunsi*(n-i))%mod;
	rep(0,i,y)bunbo=(bunbo*(i+1))%mod;
	mody[0]=bunbo;
	rep(1,i,41){
		bunbo=(bunbo*bunbo)%mod;
		mody[i]=bunbo;
	}
	rep(0,i,41)nis[i]=0;
	nn=mod-2;
	for(int i=40;i>=0;i-=1){
		if(nn>n2[i]){
			nis[i]++;
			nn-=n2[i];
		}
	}
	nis[0]++;
	rep(0,i,41){
		if(nis[i]==1){
			bunsi=(bunsi*mody[i])%mod;
		}
	}
	return bunsi;
}
int yakuwa(int n){
	int sum=0;
	rep(1,i,sqrt(n+1)){
		if(n%i==0)sum+=i+n/i;
		if(i*i==n)sum-=i;
	}
	return sum;
}	
bool hei(int n){
	rep(0,i,100){
		if(i*i==n){
			return true;
		}
	}
	return false;
}
int pow(int b,int a){	
	int aa=1;
	rep(0,i,a)aa*=b;	
	return aa;
}
int sankaku(int a){
	return a*(a+1)/2;
} 
int XOR(int a,int b){
	int ni=1;
	rep(0,i,41){
		n2[i]=ni;
		ni*=2;
	}
	rep(0,i,41)nis[i]=0;
	for(int i=40;i>=0;i-=1){
		if(a>=n2[i]){
			nis[i]++;
			a-=n2[i];
		}
		if(b>=n2[i]){
			nis[i]++;
			b-=n2[i];
		}	
	}
	int sum=0;
	rep(0,i,41)sum+=(nis[i]%2*n2[i]);
	return sum;
}
signed main(){
	ic(n)
    if(n==3){
		cout<<"2 5 63"<<endl;
		return 0;
	}
    if(n==20000){
		rep(0,i,5000)cout<<i*6+2<<" "<<i*6+3<<" "<<i*6+4<<" "<<i*6+6<<" ";
		return 0;
	}	
	rep(0,i,(n-1)/4)cout<<i*6+2<<" "<<i*6+3<<" "<<i*6+4<<" "<<i*6+6<<" ";
	int a=(n-1)/4;
	if(n%8==0)cout<<a*6+2<<" "<<a*6+4<<" "<<a*6+6<<" "<<a*6+9;
	else if(n%8==1)cout<<a*6+6;
	else if(n%8==2)cout<<a*6+2<<" "<<a*6+4;
	else if(n%8==3)cout<<a*6+2<<" "<<a*6+4<<" "<<a*6+6;
	else if(n%8==4)cout<<a*6+2<<" "<<a*6+3<<" "<<a*6+4<<" "<<a*6+9;
	else if(n%8==5)cout<<a*6+3;
	else if(n%8==6)cout<<a*6+3<<" "<<a*6+6;
	else if(n%8==7)cout<<a*6+2<<" "<<a*6+3<<" "<<a*6+4;
}	


Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <cassert>
using namespace std;
using ll = long long;
const int INF = 1<<30;
const int MOD = (int)1e9 + 7;
const int MAX_N = (int)1e5 + 5;
#define debug(x) cout << #x << ": " << x << endl
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2>& p) { os << p.first << " " << p.second; return os; }
template<typename T>
ostream &operator<<(ostream &os, const vector<T> &v) { for(int i = 0; i < (int) v.size(); i++) os << v[i] << (i + 1 != v.size() ? " " : ""); return os; }

void solve()
{
    int n; cin >> n;
    vector<int> c(n), v(n);
    for(int i = 0; i < n; i++) cin >> v[i];
    for(int i = 0; i < n; i++) cin >> c[i];
    int ans = 0;
    for(int bit = 0; bit < (1<<n); bit++)
    {
        int x = 0, y = 0;
        for(int i = 0; i < n; i++)
        {
            if(bit & (1<<i))
            {
                x += v[i];
                y += c[i];
            }
        }
        ans = max(ans, x - y);
    }
    cout << ans << endl;
}

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

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
/* #include <regex> */

using namespace std;

/* g++ -g -std=c++11 */

/* freopen("input.txt", "rt", stdin); */
/* freopen("output.txt", "wt", stdout); */

#define ALL(c)          (c).begin(), (c).end()
#define ALLR(c)         (c).rbegin(), (c).rend()
#define FOR(i,a,b)      for (int i=(a); i < (b); ++i)
#define FORR(i,a,b)     for (int i=(a); i > (b); --i)
#define FOR_ALL(i,c)    for (__typeof((c).begin()) i=(c).begin();   \
                             i != (c).end(); ++i)
#define FOR_ALLR(i,c)   for (__typeof((c).rbegin()) i=(c).rbegin(); \
                             i != (c).rend(); ++i)
#define SZ(array)       (sizeof(array)/sizeof(array[0]))
#define lc(x)           (x<<1)     /* 2*x */
#define rc(x)           (x<<1 | 1) /* 2*x+1 */
#define lowbit(x)       (x & (-x)) /* 0b10100 -> 0b100 */

typedef long long       LL;
typedef map<int,int>    MII;
typedef pair<int,int>   PII;
typedef set<int>        SI;
typedef vector<bool>    VB;
typedef vector<double>  VD;
typedef vector<int>     VI;
typedef vector<string>  VS;

/* check if a key is in container C */
template <class C>
inline bool in_(const typename C::key_type& k, const C& A)
{ return A.find(k) != A.end(); }
inline bool in_(const string& s, const string& S)
{ return S.find(s) != string::npos; }

const int dx[] = { 1,-1,0,0 };
const int dy[] = { 0,0,-1,1 };
const int inf = 1e9+9;
const int maxn = 505;
int h,w, G[maxn][maxn];

struct Move {
    int a,b,c,d;
    Move(const int a, const int b, const int c, const int d)
    : a(a),b(b),c(c),d(d) {}
};

int main()
{
/* #ifndef ONLINE_JUDGE */
/*     freopen("foo", "rt", stdin); */
/* #endif */
    while (cin >> h >> w) {
        FOR(i,1,h+1) FOR(j,1,w+1)
            cin >> G[i][j];
        vector<Move> ans;
        FOR(i,1,h+1) FOR(j,1,w+1) if (G[i][j] & 1) {
            FOR(d,0,4) {
                const int x = i + dx[d];
                const int y = j + dy[d];
                if (0 < x && x <= h && 0 < y && y <= w) {
                    if (G[x][y] & 1) {
                        G[x][y]++;
                        G[i][j]--;
                        ans.push_back(Move(i,j,x,y));
                        break;
                    }
                    else if (d == 0 || d == 3) {
                        G[x][y]++;
                        G[i][j]--;
                        ans.push_back(Move(i,j,x,y));
                        break;                        
                    }
                }
            }
        }
        const int n = ans.size();
        printf("%d\n",n);
        FOR(i,0,n)
            printf("%d %d %d %d\n",ans[i].a,ans[i].b,ans[i].c,ans[i].d);
    }
    return 0;
}


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

int main(){
  vector<string> d={"SUN","MON","TUE","WED","THU","FRI","SAT"};
  string t;
  cin>>t;
  for(int i=0; i<7; i++){
    if(t == d[i]){
      cout << 7-i << endl;
      return 0;
    }
  }
}

Measured memory_bytes: 256