akhauriyash/Code-Regression huggingface dataset:
// AOJ 1622 Go around the Labyrinth
// 2018.2.13 bal4u

#include <stdio.h>
#include <string.h>

typedef struct { char r, c; } Q;
Q q[1500]; int top;
int h, w;
char map[53][53];
char chk[53][53];
int mv4[4][2] = {{-1,0},{0,1},{1,0},{0,-1}};
int mv9[9][2] = {{-1,-1},{-1,0},{-1,1},{0,-1},{0,0},{0,1},{1,-1},{1,0},{1,1}};
char mk[53][53];

int qmax;
int check()
{
	int i, r, c, nr, nc, f;

	memset(mk, 0, sizeof(mk));
	q[0].r = 1, q[0].c = 1, top = 1, mk[1][1] = 1;
	f = 0;
	while (top) {
		r = q[--top].r, c = q[top].c;
		if (r == 1) { if (c == w) f++; }
		else if (r == h) { if (c == 1 || c == w) f++; }
		if (f == 3) return 0;
		for (i = 0; i < 4; i++) {
			nr = r + mv4[i][0], nc = c + mv4[i][1];
			if (!map[nr][nc] || mk[nr][nc]) continue;
			mk[nr][nc] = 1;
			q[top].r = nr, q[top++].c = nc;
		}
	}
	return 1;
}

int main()
{
	int r, c, i, f, nr, nc;
	char buf[10];

	while (fgets(buf, 10, stdin) && *buf != '0') {
		sscanf(buf, "%d%d", &h, &w);
		memset(map, 0, sizeof(map)), memset(chk, 1, sizeof(chk));
		for (r = 1; r <= h; r++) {
			fgets(map[r]+1, 52, stdin);
			for (c = 1; c <= w; c++) {
				if (map[r][c] == '.') map[r][c] = 1;
				else   chk[r][c] = 0, map[r][c] = 0;
			}
			map[r][w+1] = 0;
		}

		if (check()) goto no;
		for (r = 1; r <= h; r++) for (c = 1; c <= w; c++) {
			if (!map[r][c]) continue;
			if ((r == 1 || r == h) && (c == 1 || c == w)) continue;

			f = 0;
			for (i = 0; i < 9; i++) {
				nr = r + mv9[i][0], nc = c + mv9[i][1];
				if (!chk[nr][nc]) { f = 1; break; }
			}
			if (f) {
				map[r][c] = 0;
				if (check()) goto no;
				map[r][c] = 1;
			}
		}
		puts("YES"); continue;
no:		puts("NO");
	}
	return 0;
}



Measured memory_bytes: 2040
# 提出 #9630459

from fractions import gcd
n=int(input())
a=list(map(int,input().split()))
lcm = a[0]
for i in range(1,n):
  lcm = lcm*a[i] // gcd(lcm,a[i])
mod=pow(10,9)+7
ans=0
for x in a:
  ans+=lcm//x
print(ans%mod)

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

#define printl(s) cout << s << endl;
#define rep(i,n) for(int i=0;i<(n);i++)
using ll = long long;
using vvi = vector<vector<int>>;

const ll modSeed = pow(10,9) + 7;
const int INF = 1'000'000'000;

template <typename T>
vector<T> getVector(ll num){
    vector<T> values(num);
    for(ll i=0;i<num;i++){
        cin >> values.at(i);
    }
    return values;
}

string S;
ll A,B,C,K,ans;

int main(){
  ans = 0;
  cin >> A>>B>>C>>K;
  for(int a=0;a<=K;a++){
    for(int b=0;b<=K-a;b++){
      for(int c=0;c<=K-a-b;c++){
        int rA = A*pow(2,a);
        int rB = B*pow(2,b);
        int rC = C*pow(2,c);
        if((rB>rA)&&(rC>rB)){
          printl("Yes");
          return 0;
        }
      }
    }
  }
  printl("No");
}


Measured memory_bytes: 4016
#include <iostream>

const int MOD = 998244353;

using namespace std;

long dp[4001][4001];

int main(){
    string S;
    cin >> S;
    int N = S.size();
    int cnt_r = 0;
    int cnt_b = 0;
    dp[0][0] = 1;
    for(int i = 0; i < 2*N; i++){
        if(i < N){
            if(S[i] == '0'){
                cnt_r += 2;
            }
            if(S[i] == '1'){
                cnt_r += 1;
                cnt_b += 1;
            }
            if(S[i] == '2'){
                cnt_b += 2;
            }
        }
        for(int j = 0; j < 2*N;j++){
            int rem_r = cnt_r - j;
            int rem_b = cnt_r+cnt_b-i-rem_r;
            if(rem_r > 0){
                dp[i+1][j+1] += dp[i][j];
                dp[i+1][j+1] %= MOD;
            }
            if(rem_b > 0){
                dp[i+1][j] += dp[i][j];
                dp[i+1][j] %= MOD;
            }
        }
    }
    long ans = 0;
    for(int i = 0; i <= 2*N; i++){
        ans += dp[2*N][i];
        ans %= MOD;
    }
    cout << ans << endl;
}

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

using namespace std;
#define  ll  long long
#define f first
#define s second
#define matrix vector<vector<ll>>
#define zero(n,m) matrix(n , vector<ll>(m,0))
#define one(n,m) matrix(n , vector<ll>(m,1))

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

    string s;
    cin >> s;
    ll sum=0;
    for(int i=0; i<s.size(); i++)
    {
        sum += (s[i]-'0');
    }

    if (sum%9) cout << "No\n";
    else cout << "Yes\n";


    return 0;
}



Measured memory_bytes: 3764
/**
 *    author:  FromDihPout
 *    created: 2020-08-09
**/

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

#define all(x) (x).begin(), (x).end()

vector<vector<int>> adj;
vector<pair<int,int>> edges;
vector<bool> seen;

void del(int u, int par, int e) {
    seen[u] = true;
    for (int v : adj[u]) {
        if (v == par) continue;
        if (u == edges[e].first && v == edges[e].second) continue;
        if (v == edges[e].first && u == edges[e].second) continue;
        if (seen[v]) continue;
        del(v, u, e);
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n, m;
    cin >> n >> m;
    adj.resize(n);
    edges.resize(m);
    for (int i = 0; i < m; i++) {
        int u, v;
        cin >> u >> v;
        u--; v--;
        edges[i] = {u, v};
        adj[u].push_back(v);
        adj[v].push_back(u);
    }
    
    int ans = 0;
    for (int i = 0; i < m; i++) {
        seen.clear();
        seen.resize(n);
        fill(all(seen), false);
        del(0, -1, i);
        
        for (bool visited : seen) {
            if (!visited) {
                ans++;
                break;
            }
        }
    }
    
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 3656
#include "bits/stdc++.h"
using namespace std;

int main() {

	vector<int> vec(3);
	for (int i = 0; i < 3; i++) cin >> vec.at(i);

	sort(vec.begin(), vec.end());
	string res = "YES";
	if (vec.at(0) != 5) res = "NO";
	if (vec.at(1) != 5) res = "NO";
	if (vec.at(2) != 7) res = "NO";

	cout << res << endl;

	return 0;
}

Measured memory_bytes: 256
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <set>
#include <stack>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = n - 1; i >= 0; i--)
#define repone(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define each(i, mp) for(auto i:mp)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll half_inf = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);

int main() {
    int n, m, k;
    cin >> n >> m >> k;
    rep(i, n + 1) {
        rep(j, m + 1) {
            if (i * (m - j) + j * (n - i) == k) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
    return 0;
}

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

const ll INF = 3e18;

int main() {
    ll n, k; cin >> n >> k;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    ll ans = INF;
    rep(i, (1 << n)) {
        vector<ll> bit(n);
        rep(j, n) bit[j] = i / (1 << j) % 2;
        ll cnt = 0;
        rep(j, n) cnt += bit[j];
        if (cnt < k) continue;
        ll sum = 0, ma = 0;
        rep(j, n) {
            if (bit[j]) {
                if (ma < a[j]) {
                    ma = a[j];
                }
                else {
                    sum += ma + 1 - a[j];
                    ma = ma + 1;
                }
            }
            ma = max(ma, a[j]);
        }
        ans = min(ans, sum);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3596
def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7 #出力の制限
N = 2000
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

n,k=map(int,input().split())

for i in range(1,k+1):
    ans=(cmb(k-1,i-1,mod)*cmb(n-k+1,i,mod))%mod
    print(ans)

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

int main(void) {
	int a,b,c;
	cin >> a >> b >> c;
	if((a==5||a==7)&&(b==5||b==7)&&(c==5||c==7) && a+b+c == 17)
		cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(long long i=0;i<x;i++)
#define repn(i,x) for(long long i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
vector<pair<string,P> >vec;
// vector<vector<int>> data(3, vector<int>(4));

void solve(long long N, string S){
	ll res = 0;
	rep(i, N-2) {
		if (S[i] == 'A' && S[i+1] == 'B' && S[i+2] == 'C') res++;
	}
	cout << res << endl;
}

int main(){	
	long long N;
	string S;
	scanf("%lld",&N);
	cin >> S;
	solve(N, S);
	return 0;
}



Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
using namespace std;
int main() {
	long long a[3]; scanf("%lld %lld %lld", &a[0], &a[1], &a[2]);
	sort(a, a + 3);
	printf("%lld", a[0] * a[1] * (a[2] - a[2] / 2 * 2));
}

Measured memory_bytes: 128
import java.util.Scanner;

/**
 * Created by thompson on 08/09/2018.
 */
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int a = sc.nextInt();
        int b = sc.nextInt();

        if (a==2 || b==2)
            System.out.println("No");
        else
            System.out.println("Yes");


    }
}


Measured memory_bytes: 22612
/*~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=
*$* WRITER:kakitamasziru/OxOmisosiru *$*
~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=*/
#ifdef LOCAL_JUDGE
#define _GLIBCXX_DEBUG //FOR THE DEBUG! COMMENT OUT THIS WHEN SUBMITTING!
#endif
/* I REALLY HOPE MY WISH REACH YOU , ATCODER'S ONLINE JUDGE */
#define WOULD
#define YOU
#define PLEASE
#define ACCEPT
#define MY
#define SUBMISSION
/* I REALLY HOPE MY WISH REACH YOU , ATCODER'S ONLINE JUDGE */
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <iomanip>
#include <limits>//setprecision
//#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <math.h>//pow,,,
#include <cmath>//abs,,,
#include <bitset> // bitset
//It is so troublesome that I include bits/stdc++.h !
using namespace std;

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; }
const long long INF = 100100100100;
const long long MOD = 1000000007;
typedef pair<int,int> P;

//Solve N^M. This, mod_pow use Iterative Square Method.
long long mod_pow(long long N, long long M) {
    if (M == 0) return 1;
    long long res = mod_pow((N * N) % MOD, M / 2);
    //最下位ビット(*N)が1の時は単独でNをかける
    if (M & 1) res = (res * N) % MOD;

    return res %= MOD;
}

long long gcd(long long a, long long b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}
long long lcm(long long a, long long b) {
    return a * b / gcd(a, b);
}

int main() {
    string S;cin >> S;
    for(int i = 0;i <= (1<<4);i++){
        bitset<4> B(i);
        string T = "KIHBR";
        if(B.test(0)){
            T = "A" + T;
        }
        if(B.test(1)){
            if(T.at(3) == 'H'){
                string R = T.substr(0,4);
                string U = T.substr(4,2);
                T = R + 'A' + U;
               
            }
            if(T.at(2) == 'H'){
                string R = T.substr(0,3);
                string U = T.substr(3,3);
                T = R + 'A' + U;
            }
        }
        if(B.test(2)){
            if(T.at(3) == 'B'){
                string R = T.substr(0,4);
                string U = T.substr(4,1);
                T = R + 'A' + U;
            }
            if(T.at(4) == 'B'){
                string R = T.substr(0,5);
                string U = T.substr(5,1);
                T = R + 'A' + U;
            }
            if(T.at(5) == 'B'){
                string R = T.substr(0,6);
                string U = T.substr(6,1);
                T = R + 'A' + U;
            }
        }
        if(B.test(3)){
            T = T + 'A';
        }
        if(T == S){
            cout << "YES" << endl;
            return 0;
        }
    }
    
    cout << "NO" << endl;
}

Measured memory_bytes: 256
n = int(input())
l = list(map(int, input().split(" ")))
f = 0
for j in range(n-1):
    m = l[j:].index(min(l[j:]))
    if m != 0:
        l[j], l[m + j] = l[m + j], l[j]
        f += 1
print(*l)
print(f)


Measured memory_bytes: 5608
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;

#define MAX_V 200005
int V;
vector<int> nG[MAX_V], rG[MAX_V], G[MAX_V], vs; // 新しいグラフはG
bool used[MAX_V];
int cmp[MAX_V]; // ここに入る.

void add_edge(int from, int to){
    nG[from].push_back(to);
    rG[to].push_back(from);
}

void dfs(int v){
    used[v] = 1;
    for(int i = 0; i < nG[v].size(); i++) if(!used[nG[v][i]]) dfs(nG[v][i]);
    vs.push_back(v);
}

void rdfs(int v, int k){
    used[v] = 1;
    cmp[v] = k;
    for(int i = 0; i < rG[v].size(); i++) if(!used[rG[v][i]]) rdfs(rG[v][i],k);
}

int scc(){ // 新しい頂点数を返す
    memset(used, 0, sizeof(used));
    vs.clear();
    for(int v = 0; v < V; v++) if(!used[v]) dfs(v);
    memset(used, 0, sizeof(used));
    int k = 0;
    for(int i = vs.size() - 1; i >= 0; i--) if(!used[vs[i]]) rdfs(vs[i], k++);

    rep(i,V){
        int x = cmp[i];
        rep(j,nG[i].size()){
            int y = cmp[nG[i][j]];
            if(x == y)continue;
            G[x].push_back(y);
        }
    }
    
    rep(i,k){
        set<int> se;
        rep(j,G[i].size()) se.insert(G[i][j]);
        G[i].clear();
        for(auto x : se) G[i].push_back(x);
    }

    return k;
}

int main(){
    int n, m;
    cin >> n >> m;
    V = n;
    for(int i = 0; i < m; i++){
        int a, b;
        scanf("%d %d", &a, &b);
        // a--; b--;
        add_edge(a, b);
    }

    int nn = scc();
    /*
    cout << nn << endl;
    rep(i,n) cout << cmp[i] << ' ';
    cout << endl;

    rep(i,nn){
        rep(j,G[i].size()) cout << G[i][j] << ' ';
        cout << endl;
    }
    */
    int q;
    cin >> q;
    rep(i,q){
        int a, b;
        cin >> a >> b;
        if(cmp[a] == cmp[b]){
            cout << 1 << endl;
        }else{
            cout << 0 << endl;
        }
    }
    
    return 0;

}



Measured memory_bytes: 18572
import collections
import sys

def read_a_integer():
    return int(sys.stdin.readline())

def read_a_list(dtype):
    return list(map(dtype, sys.stdin.readline().split()))

def main():
    N = read_a_integer()
    print((N - 1) // 2)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3692
#!/usr/bin/env python3

import sys


def main():
    def input(): return sys.stdin.readline().rstrip()
    def ii():    return int(input())
    def isp():   return input().split()
    def mi():    return map(int, input().split())
    def mi_0():  return map(lambda x: int(x)-1, input().split())
    def lmi():   return list(map(int, input().split()))
    def lmi_0(): return list(map(lambda x: int(x)-1, input().split()))
    def li():    return list(input())



    def solve(L):
        M = 0
        command = []
        if L[-1] >= 0:
            # 全て正
            if len(L) > 2:
                command.append([L[-1], L[0]])
                neg = L[-1] - L[0]
                L = L[1:-1]
                for i in range(1, len(L)):
                    command.append([neg, L[i]])
                    neg -= L[i]
                # 最後に正 - 負
                command.append([L[0], neg])
                M = L[0] - neg
            else:
                command.append([L[0], L[1]])
                M = L[0] - L[1]
        elif L[0] <= 0:
            # 全て負
            command.append([L[0], L[-1]])
            pos = L[0] - L[-1]            
            L = L[1:-1]
            for i in range(len(L)):
                command.append([pos, L[i]])
                pos -= L[i]
            M = pos
        else:
            for i in range(len(L)):
                if L[i] < 0:
                    break
            neg = L[i]
            for j in range(1, i):
                command.append([neg, L[j]])
                neg -= L[j]
            L = [L[0], neg] + L[i+1:]
            M = L[0]
            for i in range(1, len(L)):
                command.append([M, L[i]])
                M -= L[i]
        return M, command
                

    
    
    n = ii()
    L = lmi()
    L.sort(reverse=True)
    M, command = solve(L)
    print(M)
    for x, y in command:
        print(f"{x} {y}")


if __name__ == "__main__":
    main()


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

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

typedef long long ll;
using namespace std;

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

  int A, B;
  cin >> A >> B;
  cout << A * B << endl;

  return 0;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n, m, K;
    cin >> n >> m >> K;
    int black = 0;
    char **c;
    c = new char *[n];
    for (register int i = 0; i < n; i++)
    {
        c[i] = new char[m];
        for (register int j = 0; j < m; j++)
        {
            cin >> c[i][j];
            if (c[i][j] == '#')
            {
                black++;
            }
        }
    }
    int cnt, ans = 0;
    bool **flg;
    flg = new bool *[n];
    for (register int i = 0; i < n; i++)
    {
        flg[i] = new bool[m];
    }
    for (register int i = 0; i < (1 << n); i++)
    {
        for (register int j = 0; j < (1 << m); j++)
        {
            for (register int k = 0; k < n; k++)
            {
                for (register int l = 0; l < m; l++)
                {
                    flg[k][l] = false;
                }
            }
            cnt = 0;
            for (register int k = 0; k < n; k++)
            {
                if ((i >> k) & 1)
                {
                    for (register int l = 0; l < m; l++)
                    {
                        if (c[k][l] == '#')
                        {
                            cnt++;
                            flg[k][l] = true;
                        }
                    }
                }
            }
            for (register int k = 0; k < m; k++)
            {
                if ((j >> k) & 1)
                {
                    for (register int l = 0; l < n; l++)
                    {
                        if (c[l][k] == '#' && !flg[l][k])
                        {
                            cnt++;
                        }
                    }
                }
            }
            if (black == K + cnt)
            {
                ans++;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

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

struct Fast {Fast(){cin.tie(0);ios::sync_with_stdio(0);}} fast;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define ceiv(a, b) (1 + (int)((a) - 1)/(int)(b))
#define int long long

signed main() {
    int n; cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    sort(rALL(a));
    
    int ans = 0;
    rep(i,n){
        ans += (i % 2 == 0 ? a[i] : -a[i]);
    }
    
    cout << ans << endl;
}

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

int gcd(int a, int b) {
  if(a < b){
    return gcd(b, a);
  } else if(a % b == 0){
    return b;
  } else {
    return gcd(b, a % b);
  }
}

int main() {
  int a;
  int b;

  cin >> a;
  cin >> b;

  cout << gcd(a, b) << endl;

  return 0;
}

Measured memory_bytes: 3100
/*
Sharif Hasan - CSE, PUST
Feb 22, 2020 12: 35 PM 
*/
#include<bits/stdc++.h>
#define br cout<<"\n"

/*STL definations*/
#define pb push_back

#define FOR(i,n) for(i=0;i<n;i++)
#define FROM(a,i,n) for(i=a;i<n;i++)
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

using namespace std;

/*Main function*/
int main()
{
int a,b;
cin>>a>>b;
int r = max(0,10-a);
cout<<b+r*100;br;

return 0;
}

Measured memory_bytes: 256
#include <functional>
#include <algorithm>
#include <stdexcept>
#include <iostream>
#include <sstream>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <cctype>
#include <vector>
#include <string>
#include <bitset>
#include <cmath>
#include <queue>
#include <stdio.h>
#include <stack>
#include <ctime>
#include <list>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <assert.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define TR(i,x) for(__typeof(x.begin()) i=x.begin();i!=x.end();i++)
#define ALL(x) x.begin(),x.end()
#define SORT(x) sort(ALL(x))
#define CLEAR(x) memset(x,0,sizeof(x))
#define FILL(x,c) memset(x,c,sizeof(x))
#define PB push_back
#define MP make_pair

using namespace std;

const double eps = 1e-8;

typedef map<int,int> MII;
typedef map<string,int> MSI;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<long double> VD;
typedef pair<int,int> PII;
typedef long long int64;
typedef long long LL;
typedef unsigned int UI;
typedef long double LD;

int main() {
    int h, n, a, sum;
    cin >> h >> n;
    REP(i, n) {
        cin >> a;
        sum += a;
        if (sum >= h) {
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout << "No"<< endl;
    return 0;
}



Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdint>
#include <cstdio>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

using i64 = int64_t;

int main() {
    int N, a[10];
    cin >> N; for (int j = 0; j < N; ++j) cin >> a[j];

    int c = 0;
    for (int j = 0; j < N; ++j) {
        c += 1 - a[j] % 2;
    }

    cout << (int)(pow(3, N) - pow(2, c)) << endl;

    return 0;
}


Measured memory_bytes: 1016
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstdlib>
#include<string>
#include<vector>
using namespace std;

int main(void){
	int a, b;
	cin >> a >> b;
	if (a > 8 || b > 8) {
		cout<<":(";
	}
	else {
		cout << "Yay!";
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <string>    
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long ll;
ll n, k, a_gcd, a, a_max;

ll gcd(ll x, ll y){
	if(x == 0){return y;}
	if(x > y){return gcd(x%y, y);}
	else{return gcd(y%x, x);}
}

int main(){
	cin >> n >> k;
	
	cin >> a_gcd;
	a_max = a_gcd;
	for(ll i = 2; i <= n; i++){
		cin >> a;
		a_gcd = gcd(a, a_gcd);
		a_max = max(a, a_max);
	}
	
	if(k%a_gcd == 0 && k <= a_max){cout << "POSSIBLE" << endl;}
	else{cout << "IMPOSSIBLE" << endl;}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define piii pair<int,pii>
#define pll pair<ll,ll>
#define plii pair<ll,pii>
#define vi vector<int>
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define lw(vc,num) lower_bound(vc.begin(), vc.end(), num) - vc.begin();
#define hg(vc,num) upper_bound(vc.begin(), vc.end(), num) - vc.begin();
#define bn(v,x) binary_search (v.begin(), v.end(), x)
#define mx 100001
#define eps 0.00000000001
#define mod 1000000007
#define pi acos(-1)
#define inf 100000000
#define loop(i,b,n) for(int i=b;i<n;++i)
#define rev_loop(i,b,n) for(int i=b;i>=n;--i)
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
bool isprime(int n)
{
    if(n == 1) return false;
    if(n == 2 || n == 3) return true;
    if(n%2 == 0 || n%3 == 0) return false;
    for(int i=5; i*i<=n; i+=6){
        if((n%i == 0)||(n%(i+2) == 0)) return false;
    }
    return true;
}
long long binpow(long long a, long long b) {
    if (b == 0)
        return 1;
    long long res = binpow(a, b / 2);
    if (b % 2)
        return res * res * a;
    else
        return res * res;
}
int main()
{
    fio;
    int n;
    cin>>n;
    int p = n/15;
    int k = 800*n;
    cout<<k-(200*p)<<endl;
    return 0;
}


Measured memory_bytes: 3588
#include <iostream>
#include <string.h>
#include <math.h>
#include <stdlib.h>
using namespace std;

int main(void) {
	// your code goes here
	int n,s=0,i,v;
	cin >> n;
	v=n;
	while(n>0){
		s+=(n%10);
		n=(n-n%10)/10;
	}
	if(v%s==0) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define double long double
#define endl '\n'
#define vi vector<int>
#define vvi vector<vi>
#define vpii vector<pii>
#define vpipii vector<pipii>
#define vpiipi vector<piipi>
#define pb push_back
#define pob pop_back
#define pii pair<int,int>
#define pipii pair<int,pii>
#define piipi pair<pii,int>
#define pld pair<long double,long double>
// #define mod 1000000007
// #define mod 163577857 
#define mod 998244353
#define rep(i,n) for (int i = 0; i < n; i++)
#define repp(i,a,b) for(int i = a ; i<b ; i++)
#define reppr(i,a,b) for(int i = a-1 ; i>=b ; i--)
#define repr(i,n) for (int i = n - 1; i >= 0; i--)
#define ff first
#define ss second
#define pc putchar_unlocked
#define gc getchar_unlocked
#define inf 9223372036854775807
#define infn -9223372036854775807
#define pi 3.14159265358979323846
#define eps 0.0000000001
#define sp << " " <<
#define setprec(x) cout << fixed << setprecision(x);
#define REVERSE(a) reverse(all(a));
#define SORT(a) sort(all(a));
#define all(n) n.begin(),n.end()
 
//GCD and LCM
    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; }
 
//Modular Exponentiation
    int powmod(int x,int y) 
    { 
        if (y == 0) return 1; 
        int p = powmod(x, y/2) % mod; 
        p = (p * p) % mod;   
        return (y%2 == 0)? p : (x * p) % mod; 
    }
 
//Modular Inverse
    int inverse(int a) 
    { 
       return powmod(a,mod-2); 
    }

//Binomial Coefficients
    int fact[500010], factinv[500010] , coefficientflag = 0;
    void Util_nCr()
    {
        fact[0] = 1 , factinv[0] = 1;
        repp(i,1,500010)
        {
            fact[i] = (fact[i-1] * i)%mod;
            factinv[i] = (factinv[i-1] * inverse(i))%mod;
        }
    }
    int nCr(int n , int r)
    {
        if(!coefficientflag) coefficientflag = 1 , Util_nCr();             
        return ((fact[n] * inverse(fact[n-r]) % mod * inverse(fact[r]))%mod) ;
    }

void solve();
signed main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    int t = 1;
    // cin >> t; 
    while(t--)
        solve();
} 

int prim[1000001] = {};

int ans = 0;
void primeFactors(int n)  
{  
    while (n % 2 == 0)  
    {  
        prim[2]++;
        n = n/2;  
    }  
    for (int i = 3; i <= sqrt(n); i = i + 2)  
    {  
        while (n % i == 0)  
        {  
            prim[i]++;
            n = n/i;  
        }  
    }  
    if (n > 2)  
        ans++;
}  

void solve()            
{
    int temp;
    cin >> temp;
    primeFactors(temp);
    for(auto i : prim)
    {
        for(int j = 1 ; j*(j+1)/2 <= i ; j++)
            ans++;
    }
    cout << ans;
}

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

class Graph
{
  public:
    struct Edge
    {
        int to;
        int distance;
        bool operator<(const Edge &e)
        {
            return distance < e.distance;
        }
        bool operator>(const Edge &e)
        {
            return distance > e.distance;
        }
    };
    vector<vector<int>> adjacency_matrix;
    int node;
    vector<list<Edge>> edge;

    Graph(int N)
    {
        node = N + 1;
        initializeEdgeList();
    }

    void initializeAdjacencyMatrix(int init)
    {
        adjacency_matrix = vector<vector<int>>(node, vector<int>(node, init));
    }

    void initializeEdgeList()
    {
        edge = vector<list<Edge>>(node);
    }

    void updateAdjacencyMatrix(int from, int to, int distance)
    {
        adjacency_matrix[from][to] = distance;
    }

    void addEdge(int from, int to, int distance)
    {
        edge[from].push_back({to, distance});
    }

    // O(V^3)
    // CAUTION: Use adjacency matrix
    void runFloydWarshall()
    {
        for (int i = 0; i < node; i++)
        {
            for (int j = 0; j < node; j++)
            {
                for (int k = 0; k < node; k++)
                {
                    adjacency_matrix[j][k] = min(
                        adjacency_matrix[j][k], adjacency_matrix[j][i] + adjacency_matrix[i][k]);
                }
            }
        }
    }

    // O(VE)
    void runBellmanFord(int from) {}

    // O(E + VlogV)
    // CAUTION: Use edge list
    vector<int> runDijkstra(int from, int init)
    {
        vector<list<Edge>> edge_copy = edge;
        vector<int> distance(node, init);
        distance[from] = 0;

        priority_queue<pair<int, int>> queue;
        for (auto itr = edge_copy[from].begin(); itr != edge_copy[from].end(); itr++)
        {
            queue.push(make_pair(itr->distance, itr->to));
            edge_copy[from].erase(itr);
            itr--;
        }

        while (!queue.empty())
        {
            int d = queue.top().first;
            int to = queue.top().second;
            queue.pop();
            if (distance[to] == init)
            {
                distance[to] = d;
                for (auto itr = edge_copy[to].begin(); itr != edge_copy[to].end(); itr++)
                {
                    if (distance[itr->to] == init)
                    {
                        queue.push(make_pair(itr->distance + d, itr->to));
                        edge_copy[to].erase(itr);
                        itr--;
                    }
                }
            }
        }

        return distance;
    }
};

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

    Graph g(N);
    int a;
    for (int i = 1; i <= N; i++)
    {
        cin >> a;
        g.addEdge(i, a, 1);
    }
    vector<int> distance = g.runDijkstra(1, -1);
    cout << distance[2] << endl;
}


Measured memory_bytes: 9984
/*
 * itikara.cpp
 *
 *  Created on: 2018/05/30
 *      Author: J01003
 */
#include<iostream>
#include<stdio.h>
using namespace std;
int main(){
	int t[1000],p;
	char w,bot;
string ohn;
	for(int i=0;i<26;i++){
		t[i]=0;
	};
	while(cin>>bot){
		p=0;w='a';
		while(1){
		if(bot==w)
		{t[p]++;}
		if(bot==w-32)
		{t[p]++;}
		p=p+1;w=w+1;
		if(w=='z'+1){
			break;
		}
		}
		if(bot=='\n'){break;}
		}
	w='a';p=0;

	while(1){
	cout<<w<<" : "<<t[p]<<endl;
	p+=1;
	w+=1;
	if(w=='z'+1){
		break;
	}
	}

	return 0;
}



Measured memory_bytes: 3096
#include<bits/stdc++.h>
using namespace std;
#define vi vector<int>
#define sl set<ll>
#define vs vector<string>
#define vl vector<ll>
#define vi vector<int>
#define vpl vector<pair<ll,ll>>
#define pb push_back
#define PI 3.14159265358979323846
#define ll long long
#define ld long double
#define endl "\n"
#define rep(i,a,b) for (ll i = (a); i < (b); i++)
#define repp(i,a,b) for (ll i = (a); i >= (b); i--)
#define rop(i,a,b)  for(ll i=(a); i>(b); i--)
#define min3(a, b, c) min(c, min(a, b))
#define min4(a, b, c, d) min(d, min(c, min(a, b)))
#define tt long long t; cin>>t; while(t--)
#define IOS ios::sync_with_stdio(0);cin.tie(0);
const int maxn=1e5+100;


int main()
{
ll n;
cin>>n;
ll k=0;
rep(i,0,n+1)
{ll p=
k=k*10+7;
k=k%n;
if(k==0){cout<<i+1;return 0;}
}
cout<<"-1";
}

Measured memory_bytes: 3640
#include<stdio.h>
#define rep(i,n) for(i=0;i<n;i++)
#define MAX 1000
const int QMAX = MAX*MAX;
typedef struct{unsigned short x,y;int h;char c;}P;
char Dx[]={1,0,-1,0},Dy[]={0,1,0,-1};
P q[MAX*MAX],p;
int main(void)
{
  int h,w,n,i,j,x,y,hp,tp,xx,yy,mc;
  char f[MAX][MAX],cost[MAX][MAX]={0};
  scanf("%d%d%d",&h,&w,&n);
  rep(i,h)rep(j,w){
    scanf(" %c",f[i]+j);
    if(f[i][j]=='S'){
      x=j; y=i;
    }
  }
  mc=1;hp=tp=0;q[tp++]=(P){x,y,0,1};
  while(hp!=tp){
    p=q[hp++];if(hp==QMAX)hp=0;
    if(mc>p.c)continue;
    if(p.c==n+1)break;
    rep(i,4){
      xx=p.x+Dx[i]; yy=p.y+Dy[i];
      if(xx>=0&&xx<w&&yy>=0&&yy<h&&cost[yy][xx]<p.c&&f[yy][xx]!='X'){
        cost[yy][xx]=p.c;
        if(f[yy][xx]-'0'==p.c){
          mc=p.c+1;
          q[tp++]=(P){xx,yy,p.h+1,p.c+1};
        }
        else{
          q[tp++]=(P){xx,yy,p.h+1,p.c};
        }
        if(tp==QMAX)tp=0;
      }
    }
  }
  printf("%d\n",p.h);
  return 0;
}

Measured memory_bytes: 6132
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define sz 100010
#define BeatMeScanf ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

#define pii pair<int,int>
#define ff first
#define ss second
#define pb push_back

int const mod = 1e9;
int const N = 2e5;

int main()
{
    BeatMeScanf;
    int t; cin>>t;
    map<string, int> mp;
    while(t--) {
        string str;
        cin>>str;
        mp[str]++;
    }
    cout<<"AC x "<<mp["AC"]<<endl;
    cout<<"WA x "<<mp["WA"]<<endl;
    cout<<"TLE x "<<mp["TLE"]<<endl;
    cout<<"RE x "<<mp["RE"]<<endl;

    return 0;

}

/*
AC x 3
WA x 1
TLE x 2
RE x 0
*/


Measured memory_bytes: 3660
import java.io.*;
import java.util.*;
import java.math.*;

public class Main{
	static final BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
	static int tc;
	static final int MOD=1_000_000_007;
	public static long[] inputArray(String str){
		String[] s=str.split(" ");
		long[] array=new long[s.length];
		for(int i=0;i<s.length;i++) {
			array[i]=Long.parseLong(s[i]);
		}
		return array;
	}
	public static void main(String[] args)throws IOException {
		//tc=Integer.parseInt(br.readLine());
		tc=1;
		while(tc-->0) {
			String str=br.readLine();
			int plus=0;
			int minus=0;
			for(int i=0;i<str.length();i++) {
				if(str.charAt(i)=='+')
					plus++;
				else
					minus++;
			}
			System.out.println(plus-minus);
		}
	}
}

Measured memory_bytes: 24532
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>

using namespace std;
typedef long long ll;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, f, n) for (ll i = (f); i < (n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define repv(v) for (auto it = (v).begin(); it != (v).end(); it++)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define INIT    \
    cin.tie(0); \
    ios::sync_with_stdio(false);

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

ll const INF = 1LL << 60;
ll const MOD = 1000000007;

int main() {
    INIT;

    ll N;
    cin >> N;
    vector<vector<ll>> a(N + 5, vector<ll>(3));
    rep(i, N) rep(j, 3) cin >> a[i][j];

    vector<vector<ll>> dp(N + 5, vector<ll>(3, 0));
    rep(i, 3) { dp[0][i] = a[0][i]; }

    reps(i, 1, N) {
        rep(j, 3) {
            rep(k, 3) {
                if (j == k) continue;
                chmax(dp[i][j], dp[i - 1][k] + a[i][j]);
            }
        }
    }

    // rep(i, N) {
    //     rep(j, 3) { cout << dp[i][j] << " "; }
    //     cout << endl;
    // }

    ll ans = 0;
    rep(i, 3) { chmax(ans, dp[N - 1][i]); }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 14140
#include<iostream>
#include<cstdio> 
#include<vector>
#include<cmath>
#include<string>
#include<cstring>
#include<algorithm> 
#include<set>
#define  endl '\n'
#define all(s) s.begin(),s.end()
#define lowbit(x) (x&-x)
#define fi first
#define se second 
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int inf=0x3f3f3f3f; 
const int N=2e5+10;
int main()
{
//	ios::sync_with_stdio(false);
//    cin.tie(0);cout.tie(0);
	int n,m,q,k;
	int a,b,c;	
	cin>>a>>b>>c;
	swap(a,b);
	swap(a,c);
	cout<<a<<' '<<b<<' '<<c; 
}

Measured memory_bytes: 256
<?php

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

$as = explode(' ', trim(fgets(STDIN)));

foreach ($as as $a) {
  if ($a % 2 === 0) {
    if ($a % 3 === 0 || $a % 5 === 0) {

    } else {
      echo 'DENIED';
      exit;
    }
  }
}

echo 'APPROVED';


Measured memory_bytes: 4728
M = 10**9 + 7

def combination(n, k):
  if k > n-k:
    k = n-k
  p = [-1 for i in range(k+1)]
  kp = {i:[] for i in range(n-k+1, n+1)}
  for i in range(2, k+1):
    if p[i] != -1:
      continue
    for j in range(i, k+1, i):
      if p[j] == -1:
        p[j] = i
    for j in range(((n-k)//i + 1)*i, n+1, i):
      kp[j].append(i)
  count = [0 for i in range(k+1)]
  for x in range(2, k+1):
    buf = x
    while p[buf]!=-1:
      m = p[buf]
      while buf > 1 and buf % m == 0:
        count[m] += 1
        buf = buf//m
  ans = 1
  for x in range(n-k+1, n+1):
    buf = x
    for i in kp[x]:
      while count[i]>0 and buf%i==0:
        buf = buf//i
        count[i] -= 1
    ans *= buf
    ans %= M
  return ans

X, Y = map(int, input().split())
a = X + Y
b = a//3
a = a%3
#print(a,b)
if a==0 and b <= X <= b*2:
  print(combination(b, X-b))
else:
  print(0)
  


Measured memory_bytes: 67336
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
 
int main(){
    ll x1,y1,x2,y2;
    cin>>x1>>y1>>x2>>y2;
    ll x=x2-x1;
    ll y=y2-y1;
    ll nrm=sqrt(x*x+y*y);
    
    ll x3,y3,x4,y4;
    x3=x2-y; y3=y2+x;
    x4=x1-y; y4=y1+x;
    cout<<x3<<" ";
    cout<<y3<<" ";
    cout<<x4<<" ";
    cout<<y4<<endl;
    return 0;
}

Measured memory_bytes: 256
package main

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

var (
	readString func() string
	stdout     *bufio.Writer
)

func init() {
	readString = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readIntSlice(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = readInt()
	}
	return b
}

func readLengthAndSlice() (int, []int) {
	n := readInt()
	return n, readIntSlice(n)
}

func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(stdout, f, args...)
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdout, args...)
}

func eprintln(args ...interface{}) (int, error) {
	return fmt.Fprintln(os.Stderr, args...)
}

// readString() string
// readInt() int
// readIntSlice(n int) []int
// readLengthAndSlice() []int

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

func main() {
	defer stdout.Flush()
	h := readInt()
	w := readInt()
	a := make([][]int, h)
	for i := range a {
		a[i] = make([]int, w)
		for j := range a[i] {
			a[i][j] = readInt() % 2
		}
	}
	pi := 0
	pj := 0
	ans := make([][]int, 0)
	for i := 0; i < h; i++ {
		for j := 0; j < w; j++ {
			if i == 0 && j == 0 {
				continue
			}
			if a[pi][pj] == 1 {
				ans = append(ans, []int{pi + 1, pj + 1, i + 1, j + 1})
				a[i][j] = (a[i][j] + a[pi][pj]) % 2
			}
			pi = i
			pj = j
		}
		i++
		if h <= i {
			break
		}
		for j := w - 1; j >= 0; j-- {
			if a[pi][pj] == 1 {
				ans = append(ans, []int{pi + 1, pj + 1, i + 1, j + 1})
				a[i][j] = (a[i][j] + a[pi][pj]) % 2
			}
			pi = i
			pj = j
		}
	}
	println(len(ans))
	for i := range ans {
		println(ans[i][0], ans[i][1], ans[i][2], ans[i][3])
	}
}

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


Measured memory_bytes: 21248
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtTest.AGC_041
{
    class A
    {
        static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(OpenStandardOutput()) { AutoFlush = false };
            SetOut(sw);

            Method(args);

            Out.Flush();
        }

        static void Method(string[] args)
        {
            long[] nab = ReadLongs();
            long n = nab[0];
            long a = nab[1];
            long b = nab[2];
            long res = 0;
            if ((b - a) % 2 == 0)
            {
                res = (b - a) / 2;
            }
            else
            {
                res = (b - a) / 2 + 1;
                res += Min(a - 1, n - b);
            }
            WriteLine(res);
        }

        private static string Read() { return ReadLine(); }
        private static char[] ReadChars() { return Array.ConvertAll(Read().Split(), a => a[0]); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 13140
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
int n, ans, ans2, cnt;
int main() {
	scanf("%d", &n);
	ans = 10; 
	for (int i = 1; i <= n; i++) {
		if (i / ans == 0) cnt++;
		else if (i / ans >= 10) ans *= 100, cnt++;
	}
	printf("%d\n", cnt);
	return 0;
}

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

using namespace std;
int main()
{
    string s[3];
    int a[2];

    cin>> s[0]>> s[1]>> a[0]>> a[1]>> s[2];
    (s[2]==s[0]? a[0]--: a[1]--);
    cout<< a[0]<< " "<< a[1]<< endl;

    return 0;
}


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

int main(){
  int d,n;
  cin >> d >> n;
  if(n==100){if(d==0)cout << 101 << endl;else if(d==1)cout <<10100 << endl;else cout << 1010000 << endl;}
  else{if(d==0)cout << n << endl;
  else if(d==1){cout << n*100 << endl;}
  else cout << (long int)(n*10000) << endl;
}}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
    public static void main(String[] args ) {
        Scanner scanner = new Scanner(System.in);
        int[][][] a = new int[4][3][10];
        int n = scanner.nextInt();
        for(int i = 0; i < n; i++){
            a[scanner.nextInt() - 1][scanner.nextInt() - 1][scanner.nextInt() - 1] += scanner.nextInt();
        }

        for(int b = 0; b < 4; b++){
            for(int f = 0; f < 3; f++){
                for(int r = 0; r < 10; r++){
                    System.out.print(" " + a[b][f][r]);
                }
                System.out.print("\n");
            }
            if(b != 3) System.out.println("####################");
        }
    }
}



Measured memory_bytes: 29340
#include<stdio.h>

int judge(int a);

int main()
{
  int X;
  int ans;
  
  scanf("%d",&X);
  
  if(X == 2){
    ans = 2;
  }
  else if(X%2 == 1){
    ans = judge(X);
  }
  else{
    ans = judge(X + 1);
  }

  printf("%d",ans);

  return 0;
}

int judge(int a){
  int i;

  for(i = 3;i < a;i += 2){
    if(a%i == 0){
      return judge(a + 2);
    }
  }

  return a;
}
    
    
    
  

Measured memory_bytes: 128
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;
#define MOD @
#define ADD(X,Y) ((X) = ((X) + (Y)%MOD) % MOD)
typedef long long i64; typedef vector<int> ivec; typedef vector<string> svec;

i64 K;
int N;
i64 A[55];

void waf()
{
	pair<i64, int> lg{ -1000LL, 0 };
	for (int i = 0; i < N; ++i) lg = max(lg, { A[i], i });

	for (int i = 0; i < N; ++i) {
		if (i == lg.second) A[i] -= N;
		else A[i] += 1;
	}
}

int main()
{
	scanf("%lld", &K);
	N = 50;
	i64 Kref = (K / 50 + 1) * 50;
	for (int i = 0; i < N; ++i) A[i] = 49 + Kref / 50;
	for (int i = 0; i < (int)(Kref - K); ++i) waf();

	printf("%d\n", N);
	for (int i = 0; i < N; ++i) printf("%lld%c", A[i], i == N - 1 ? '\n' : ' ');
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        boolean ans = true;
        String W[] = new String[N];
        for(int i=0;i<N;i++){
            
            W[i] =sc.next();
        
        }
        for(int i=1;i<N;i++){
            
            if(!(W[i-1].charAt(W[i-1].length()-1)==W[i].charAt(0))){
                ans=false;
                break;
            }
            for(int j=0;j<i;j++){
                
                if(W[i].equals(W[j])){
                    ans= false;
                    break;
                }
            }
        }
        if(ans==true){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 35688
#include<bits/stdc++.h>
using namespace std;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  long long n;
  cin >> n;
  long long sum = 0;
  for(long long i = 1; i < n; i++){
    sum += i;
  }
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 256
// Ver19.03
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define INF (1 << 29) * 2
#define LLINF 4545454545454545454
#define MOD 1000000007
#define ll long long
#define ull unsigned long long
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
int upll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? -1 : *(ll *)a > *(ll *)b ? 1 : 0; }
int downll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? 1 : *(ll *)a > *(ll *)b ? -1 : 0; }
void sortup(ll *a, int n) { qsort(a, n, sizeof(ll), upll); }
void sortdown(ll *a, int n) { qsort(a, n, sizeof(ll), downll); }

int main()
{
  int n, k;
  scanf("%d%d", &n, &k);
  for (int i = 0; i < n; i++)
    scanf("%*d");
  printf("%d\n", n <= k ? 1 : (MAX((int)ceil((float)(n - k) / (float)(k - 1)), 1) + 1));
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
#define pb push_back
#define sz(i) (int)(i.size())
#define F first
#define S second
#define L long double
#define P pair<int, int>
const int inf = 0x3f3f3f3f3f3f3f3LL;
const int mod = (int)1e9 + 7;
using namespace std;
#if LOCAL
#include "../../tr.h"
#else
#define tr(...)
#define endl '\n'
#endif
template<class T> void smin(T& a, T val) {if (a > val) a = val;}template<class T> void smax(T& a, T val) {if (a < val) a = val;}
const int N = 5*(int)1e5 + 10;

int n, a[N];
int32_t main(){_

   cin>>n;

   string s;
   cin >> s;
   int len = sz(s);

   string tt = "";
   for (int i = 0; i < len; ++i)
   {
      int idx = (s[i] - 'A' + n) % 26;
      tt += (char)(idx + 'A');
   }
      
   cout<<tt;

   return 0;
}

Measured memory_bytes: 256