akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#define MOD (1000000007)
/*AGC,GAC,ACG,AG-C,A-GC=>023,203,032,02-3,0-23*/
/*
[2][3][-]は[0][2][3]
[0][3][-]は[2][0][3]
[3][2][-]は[0][3][2]
[2][-][3]は[0][2][-]
[-][2][3]は[0][-][2]からの寄与を受けない*/
int main(){
  int n;
  long dp[98][4][4][4],ans=0;/*dp[i]=>n=i+3までの並べ方*/
  if (!scanf("%d",&n) || n>101) printf("input ERROR!\n");
  else {
    for (int i=0;i<98;i++){
      for (int j=0;j<4;j++){
        for (int k=0;k<4;k++){
          for (int l=0;l<4;l++){/*初期化*/
          dp[i][j][k][l]=1;
          }
        }
      }
    }
    dp[0][0][2][3]=0;
    dp[0][2][0][3]=0;
    dp[0][0][3][2]=0;
    for (int i=0;i<n-3;i++){
      for (int j=0;j<4;j++){
        for (int k=0;k<4;k++){
          for (int l=0;l<4;l++){/*dp[i][j][k][l]の処理*/
            if (j==0 && k==2 && l==3) dp[i+1][j][k][l]=0;
            else if (j==2 && k==0 && l==3) dp[i+1][j][k][l]=0;
            else if (j==0 && k==3 && l==2) dp[i+1][j][k][l]=0;
            else if (j==2 && l==3) 
              dp[i+1][j][k][l]
              =(dp[i][1][j][k]+dp[i][2][j][k]+dp[i][3][j][k])%MOD;
            else if (k==2 && l==3) 
              dp[i+1][j][k][l]
              =(dp[i][1][j][k]+dp[i][2][j][k]+dp[i][3][j][k])%MOD;
            else dp[i+1][j][k][l]
              =(dp[i][0][j][k]+dp[i][1][j][k]+dp[i][2][j][k]+dp[i][3][j][k])%MOD;
          }
        }
      }
    }
    for (int j=0;j<4;j++){
      for (int k=0;k<4;k++){
        for (int l=0;l<4;l++){
          ans+=dp[n-3][j][k][l];
          ans%=MOD;
        }
      }
    }
    printf("%ld\n",ans);
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define vi vector<ll>
#define pb push_back
#define ff first
#define ss second
#define inf 2e18
#define ull unsigned long long
#define pi acos(-1.0)
#define mod 1000000007
#define lop0(n) for(ll i=0;i<n;i++)
#define lopj(n) for(ll j=0;j<n;j++)
#define lop1(n) for(ll i=1;i<=n;i++)
#define all(v) v.begin(),v.end()
ll Set(ll N,ll pos){ return N=N | (1LL<<pos); }
ll reset(ll N,ll pos){ return N= N & ~(1LL<<pos); }
bool check(ll N,ll pos){ return (bool)(N & (1LL<<pos)); }
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

main()
{
   ll x,k,d;
   cin>>x>>k>>d;
   ll xx=abs(x);
   ll lagbe=xx/d;
   k-=lagbe;
   if(k<=0)
   {
       k+=lagbe;
       cout<<xx-k*d;
       return 0;
   }
   if(x<0)
   {
       x+=(lagbe*d);
   }
   else if(x>0)
   {
        x-=(lagbe*d);
   }
   if(x==0)
   {
       if(k%2) cout<<d;
       else cout<<0;
       return 0;
   }

   if(k%2)
   {
       if(x>0) cout<<abs(x-d);
       else cout<<x+d;
   }
   else cout<<abs(x);



}



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

int main(void) {
    int n;
    std::string s;
    int count;
    std::string now_status;
    while (1) {
        std::cin >> n;
        if (n == 0) {
            break;
        }
        count = 0;
        now_status = "";
        for (int i = 0; i < n; i++) {
            // ??????????????????????¶???????????????????????????????????????????
            // ????????°???????????????????¶??????????????????????????????????????????\?????????????????¨?????????????????????
            std::cin >> s;
            if (now_status == "") {
                now_status = s;
                continue;
            }
            if (now_status[0] != s[0] && now_status[1] == s[1]) {
                count++;
            } 
            now_status = s;
        }
        std::cout << count << std::endl;
    }
    return 0;
}

Measured memory_bytes: 3144
#include <algorithm>
#include <cmath>
#include <complex>
#include <cstdio>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <string>
#include <vector>

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

const long long int INF = 1e14;
typedef long long int ll;

using namespace std;

char bomb[52][52];
char count[52][52];

// -1,1
// 0,1
// 1,1
// -1,0
// 1,0
// -1,-1
// 0,-1
// 1,-1

int x_diff[] = {-1,0,1,-1,1,-1,0,1};
int y_diff[] = {1,1,1,0,0,-1,-1,-1};

int main(){
    int H,W;
    char c;
    cin >> H >> W;

    rep(i,H){
        rep(j,W){
            cin >> c;
            bomb[i][j] = c;
        }
    }
    rep(i,H){
        rep(j,W){
            if(bomb[i][j]=='#') cout << '#';
            else{
                int cnt=0;
                rep(k,8){
                    int x = i + x_diff[k];
                    int y = j + y_diff[k];
                    if (x<0||y<0||x>=H||y>=W) continue;
                    if (bomb[x][y]=='#') cnt ++;
                }
                cout << cnt;
            }
        }
        cout << "" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
/*
  AOJ 2669
  Title:A-Z Cat
  @kankichi573
*/
#include <stdio.h>

char buf[21];

int countAZ(char * s)
{
  int flag=0,ret=0;

  while(*s)
    {
      if(flag==0)
	{
	  if(*s=='A')
	    flag=1;
	}
      else if(flag==1) 
	{
	  if(*s=='Z')
	    {
	      flag=0;
	      ret++;
	      printf("AZ");
	    }
	}
      s++;
    }
  return(ret);
}

main()
{
  int ret;

  scanf("%s",buf);
  ret=countAZ(buf);
  if(ret)
    printf("\n");
  else
    printf("-1\n");
  return(0);
}

Measured memory_bytes: 524
N = int(input())
name = {"M":0,"A":0,"R":0,"C":0,"H":0}
for i in range(N):
    tmp = input()
    f = tmp[0]
    if f in name:
        name[f] += 1

num = list(name.values())
ans = 0
for i in range(3):
    for j in range(i+1,4):
        for h in range(j+1,5):
            ans += num[i]*num[j]*num[h]

print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define all(x) (x).begin(),(x).end()
#define INF 10000000
using ll = long long ;
ll gcd(ll a, ll b) {
  if(b == 0) return a;
  return gcd(b, a % b);
}
template< int id > struct CompTupleBy
{
  template<class T> 
  bool operator()( const T& a, const T& b ) const {
    return std::get<id>(a) < std::get<id>(b);
  }
};

using namespace std;

int main(){
    ll n,m;
    cin >> n >> m;
    priority_queue<ll> pque;
    rep(i,n){
      ll a;
      cin >> a;
      pque.push(a);
    }

    rep(i,m){
        ll tmp_max = pque.top();
        pque.pop();
        pque.push(tmp_max / 2);
    }
    ll ans = 0;
    while(!pque.empty()){
        ans += pque.top();
        pque.pop();
    }
    cout << ans << endl;

    
}

Measured memory_bytes: 1400
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#define REP(i, n) for(int i = 0; i < n;i++)
using namespace std;
int main()
{
    int h, w;
    const int MAX = 100;
    char C[MAX][MAX];
    cin >> h >> w;
    REP(i, h) REP(j, w) cin >> C[i][j];
    REP(i, 2 * h) {REP(j, w) {cout << C[i / 2][j];} cout << endl;}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;    using vvi = vector<vi>;
using vb = vector<bool>;   using vvb = vector<vb>;
using vl = vector<ll>;     using vvl = vector<vl>;
using vd = vector<double>; using vvd = vector<vd>;

#define REP(i,n) for(auto i = 0 * n; i < (n); ++i)
#define ALL(c) (c).begin(), (c).end()
#define FOR(i,s,e) for (ll i = s; i < (ll)e; i++)
#define TEN(x) ((ll)1e##x)

template<class T> struct SegTree {
	typedef size_t U;
	U n; T init;
	vector<T> d, s;
	SegTree(U _n, T init) : n(1), init(init) {
		while (n < _n) n <<= 1;
		d = vector<T>(2 * n - 1, init);
		s = vector<T>(2 * n - 1, 0);
	}
	void set(U i, T x) { add(i, x - get(i, i + 1)); }
	void add(U i, T x) { add(i, i + 1, x); }
	void add(U a, U b, T x) { add(a, b, x, 0, 0, n); }
	T add(U a, U b, T x, U k, U l, U r) {
		if (b <= l || r <= a) return d[k];
		if (a <= l && r <= b) {
			s[k] += x;
			return d[k] += x;
		}
		U m = (l + r) / 2;
		return d[k] = min(
			add(a, b, x, 2 * k + 1, l, m),
			add(a, b, x, 2 * k + 2, m, r)
		) + s[k];
	}
	T get(U a, U b) { return get(a, b, 0, 0, n); }
	T get(U a, U b, U k, U l, U r) {
		if (b <= l || r <= a) return init;
		if (a <= l && r <= b) return d[k];
		U m = (l + r) / 2;
		return min(
			get(a, b, 2 * k + 1, l, m),
			get(a, b, 2 * k + 2, m, r)
		) + s[k];
	}
};

int main() {
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(50);

	size_t n, q; cin >> n >> q;
	SegTree<ll> st(n, (1ll<<31) - 1);
	REP(i, q) {
		size_t c, x, y; cin >> c >> x >> y;
		if (c == 1) {
			cout << st.get(x, y+1) << endl;
		} else {
			st.set(x, y);
		}
	}
}

Measured memory_bytes: 6992
//look at my code
//my code is amazing
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define int long long
#define mod 1000000007 //998244353
#define fast  ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define f(i,n) for(ll i=0;i<n;i++)
#define nl "\n"
#define trace(x) cerr<<#x<<": "<<x<<" "<<endl
#define trace2(x, y) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z) cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define cout1(a) cout<<a<<nl
#define cout2(a,b) cout<<a<<" "<<b<<nl
#define cout3(a,b,c) cout<<a<<" "<<b<<" "<<c<<nl
#define cout4(a,b,c,d) cout<<a<<" "<<b<<" "<<c<<" "<<d<<nl
#define vcout(v,i) cout<<v[i].fi<<" "<<v[i].se<<nl
#define x first
#define y second
#define vc vector
#define pb push_back
#define ar array
#define all(a) (a).begin(), (a).end()
#define ms(v,n,x) fill(v,v+n,x);
#define init(c,a) memset(c,a,sizeof(c))
#define pll pair<ll,ll>
#define mll map<ll,ll>
#define sll set<ll>
#define vll vector<ll>
#define vpll vector<pll>
#define maxi(a,b,c) max(a,max(b,c))
#define maxii(a,b,c,d) max(max(a,b),max(c,d))
#define mini(a,b,c) min(a,min(b,c))
#define md(a,b)  ((a%mod)*(b%mod)+mod)%mod 
#define inf 9e18
#define cases ll T;cin>>T;while(T--)
#define BLOCK 500
//const double PI = 3.141592653589793238460;
template<typename T> bool mmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T> bool mmin(T &m, const T q) { if (m > q) {m = q; return true;} else return false; }
typedef std::complex<double> Complex;
typedef std::valarray<Complex> CArray;
// const int N=;

int32_t main()
{
    
	fast
	ll a,b,n;
	cin>>a>>b>>n;
	ll m=min(b-1,n);
	cout<<a*m/b;//-a*(n/b);
	
	

	



    

	return 0;
    
}

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

using namespace std;

#define LOG(...) fprintf(stderr,__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

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

int H, W, C;

int count_panels(vvi& panels) {
    int color = panels[0][0];
    vvi G(H, vi(W, false));
    queue<pii> que;
    int cnt = 0;
    que.push({0, 0});
    while (!que.empty()) {
        pii p = que.front(); que.pop();
        REP(i, 4) {
            int sx = p.first + dx[i], sy = p.second + dy[i];
            if (0 <= sx && sx < W && 0 <= sy && sy < H) {
                if (panels[sy][sx] == color) {
                    if (!G[sy][sx]) {
                        G[sy][sx] = true;
                        cnt++;
                        que.push({sx, sy});
                    }
                }
            }
        }
    }
    return cnt;
}

void dfs2(vvi& panels, int c1, int c2, int x, int y) {
    panels[y][x] = c2;
    REP(i, 4) {
        int sx = x + dx[i], sy = y + dy[i];
        if (0 <= sx && sx < W && 0 <= sy && sy < H) {
            if (panels[sy][sx] == c1) {
//                LOG("%d %d\n", sx, sy);
                dfs2(panels, c1, c2, sx, sy);
            }
        }
    }
}

void dfs(vvi& panels, int& ma, int depth) {
    int c1 = panels[0][0];
    if (depth == 4) {
        if (c1 != C) {
            vvi copy = panels;
//            copy[0][0] = C;
            dfs2(copy, c1, C, 0, 0);
            ma = max(ma, count_panels(copy));
        }
    } else {
        FOR(c2, 1, 7) {
            if (c1 == c2) continue;
            vvi copy = panels;
//            copy[0][0] = c2;
            dfs2(copy, c1, c2, 0, 0);
            dfs(copy, ma, depth+1);
        }
    }
}

int main() {
    while (cin >> H >> W >> C, H|W|C) {
        vvi panels(H, vi(W));
        REP(i, H) REP(j, W) {
            cin >> panels[i][j];
        }
        int ma = 1;
        dfs(panels, ma, 0);
        cout << ma << endl;
    }
}

Measured memory_bytes: 3148
import java.util.Scanner;

public class Main {
	public static Scanner sc;
	
	public static void main(String [] args){
		sc = new Scanner(System.in);
		long a = sc.nextInt();
		long b = sc.nextInt();
		long c = sc.nextInt();
		
		if(a%2==0 || b%2==0 || c%2==0){
			System.out.println(0);
		} else {
			long e = a*b;
			long d = b*c;
			long f = c*a;
			
			long ans = Math.min(f,Math.min(d,e));
			System.out.println(ans);
		}
	}
}


Measured memory_bytes: 9556
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,n) for(long long i=0;i<n;++i)
#define REPP(i,m,n) for(long long i=m;i<n;++i)
#define rep(i,n) for(long long i = n-1;i>=0;--i)
#define repp(i,n,m) for(long long i = n-1; i >= m; --i)
#define ALL(N) (N.begin(),N.end())
#define de cout << "line : " << __LINE__ << " debug" << endl;
#define pb push_back
#define pq priority_queue
#define Dcout(N) cout << setprecision(20) << N << endl
constexpr int INF = 2147483647;
constexpr long long INFF = 9223372036854775807;

signed main() {  
    int A;
    cin >> A;
    REP(i,10){
        REP(j,10){
            if(A == i * j){
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <complex>
#include <vector>
#include <algorithm>
#include <cstdio>
using namespace std;

const double EPS = 1e-10;
const double INF = 1e12;
#define EQ(n,m) (abs((n)-(m)) < EPS)
#define X real()
#define Y imag()

typedef complex<double> P;
typedef vector<P> VP;
struct L : array<P, 2>{
    L(const P& a, const P& b){ at(0)=a; at(1)=b; }
    L(){}
};

double dot(P a, P b){
    return (conj(a)*b).X;
}
double cross(P a, P b){
    return (conj(a)*b).Y;
}
int ccw(P a, P b, P c){
    b -= a;
    c -= a;
    if(cross(b,c) > EPS) return +1; //ccw
    if(cross(b,c) < -EPS) return -1; //cw
    if(dot(b,c) < -EPS) return +2; //c-a-b
    if(abs(c)-abs(b) > EPS) return -2; //a-b-c
    return 0; //a-c-b
}
bool intersectSP(const L& s, const P &p){
    return abs(cross(s[0]-p, s[1]-p))<EPS  && dot(s[0]-p, s[1]-p)<EPS;
}
bool intersectSS(const L& a, const L& b){
    return ( ccw(a[0],a[1],b[0]) *ccw(a[0],a[1],b[1]) <= 0 ) &&
        ( ccw(b[0],b[1],a[0]) *ccw(b[0],b[1],a[1]) <= 0 );
}
int in_poly(const P &p, const VP &poly){
    int n = poly.size();
    int ret = -1;
    for(int i=0; i<n; i++){
        P a = poly[i]-p;
        P b = poly[(i+1)%n]-p;
        if(a.Y > b.Y) swap(a,b);
        if(intersectSP(L(a,b), P(0,0))) return 0;
        if(a.Y<=0 && b.Y>0 && cross(a,b)<0) ret = 1-ret;
    }
    return ret;
}

int main(){
	double x[4],y[4];
	while(cin >> x[0] >> y[0]){
		for(int i=1; i<4; i++) cin >> x[i] >> y[i];
		VP a = {P(x[0],y[0]), P(x[1],y[0]), P(x[1],y[1]), P(x[0],y[1])};
		VP b = {P(x[2],y[2]), P(x[3],y[2]), P(x[3],y[3]), P(x[2],y[3])};
		bool ans=false;
		for(int i=0; i<4; i++){
			for(int j=0; j<4; j++){
				if(intersectSS(L(a[i], a[(i+1)%4]), L(b[j], b[(j+1)%4]))){
					ans = true;
				}
			}
		}
		if(in_poly(a[0], b)>=0 || in_poly(b[0], a)>=0){
			ans = true;
		}
		if(ans){
			cout << "YES" << endl;
		}else{
			cout << "NO" << endl;
		}
	}
	return 0;
}


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

using ll=long long;
using namespace std;

int main(){
    ll a,b,n;
    cin>>a>>b>>n;
    
    if(b>n)
        cout<<floor(a*n/b)<<endl;
    else
        cout<<floor(a*(b-1)/b)<<endl;
}

Measured memory_bytes: 3724
// review
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, P> PP;
const int MAXN = 310;
const ll INF = 1e16;

int n;
ll a[MAXN][MAXN];
ll dist[MAXN][MAXN];

void warshall_floyd() {
  for (int i=0;i<n;i++) {
    for (int j=0;j<n;j++) {
      dist[i][j] = a[i][j];
    }
  }
  for (int k=0;k<n;k++) {
    for (int i=0;i<n;i++) {
      for (int j=0;j<n;j++) {
        dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
      }
    }
  }
}

void solve() {
  warshall_floyd();
  for (int i=0;i<n;i++) {
    for (int j=0;j<n;j++) {
      if (dist[i][j] < a[i][j]) {
        cout << -1 << endl;
        return;
      }
    }
  }
  ll sum = 0;
  for (int i=0;i<n;i++) {
    for (int j=i+1;j<n;j++) {
      bool need = true;
      for (int k=0;k<n;k++) {
        if (i != k && k != j && dist[i][k] + dist[k][j] == dist[i][j]) {
          need = false;
        }
      }
      if (need) {
        sum += a[i][j];
      }
    }
  }
  cout << sum << endl;
}

int main() {
  cin >> n;
  for (int i=0;i<n;i++) {
    for (int j=0;j<n;j++) {
      cin >> a[j][i];
    }
  }
  solve();
}


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

typedef long long ll;
const int INF = 2e9;
//const ll INF = 9e18;


int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int H, W;
    cin >> H >> W;
    vector<vector<int>> board(H+1,vector<int>(W+1));
    for (int i=0;i<H;i++){
        for (int j=0;j<W;j++){
            char c;
            cin >> c;
            if (c == '#') board[i][j] = 1;
        }
    }
    vector<vector<int>> dp(H+5,vector<int>(W+5,INF));
    if (board[0][0] == 1){
        dp[0][0] = 1;
    } else {
        dp[0][0] = 0;
    }
    for (int i=0;i<H;i++){
        for (int j=0;j<W;j++){
            if (board[i+1][j] == 1 && board[i][j] == 0) {
                dp[i+1][j] = min(dp[i+1][j], dp[i][j] + 1);
            } else {
                dp[i+1][j] = min(dp[i+1][j], dp[i][j]);
            }
            if (board[i][j+1] == 1 && board[i][j] == 0) {
                dp[i][j+1] = min(dp[i][j+1], dp[i][j] + 1);
            }else {
                dp[i][j+1] = min(dp[i][j+1], dp[i][j]);
            }
        }
    }
    cout << dp[H-1][W-1] << "\n";
}

Measured memory_bytes: 384
//  @ /\/\ BESH //

#include <bits/stdc++.h>
#define inp_out_work ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define testCase    int T; cin>>T; while(T--)
#define fr(i,n) for(int i=0;i<n;i++)
#define fro(i,s,e) for(int i=s;i<=e;i++)
#define endl '\n'
#define debug(P) cout<<#P<<" = "<<P<<endl;
#define pb push_back


using namespace std;

typedef long long ll;
typedef long double ld;

const int MAXN = 200001;
const ll mod = 1e9 + 7;

int main(){
    inp_out_work
    int n;
    cin>>n;
    string s;
    cin>>s;
    bool hai = true;
    if(n&1)hai = false;
    else if(s.substr(0, n>>1) != s.substr(n>>1))hai = false;
    if(hai)cout<<"Yes\n";
    else cout<<"No\n";
}


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

struct TRAMP{
	char mark;
	int number;
};

void buble_sort(TRAMP array[] , int array_size);
void selection_sort(TRAMP array[] , int array_size);
void print_sort(TRAMP *array,int array_size);
void judge_sort(TRAMP buble[], TRAMP select[], int array_size);


int main(){
	int size=0;
	scanf("%d",&size);
	TRAMP buble[size],select[size];
	char array[3]={'\0'};
	for(int i=0; i<size; i++){
		scanf("%s",array);
		buble[i].mark=array[0];
		buble[i].number=atoi(&array[1]);
		select[i].mark=array[0];
		select[i].number=atoi(&array[1]);
	}
	buble_sort(buble,size);
	selection_sort(select,size);
	print_sort(buble,size);
	printf("Stable\n");
	print_sort(select,size);
	judge_sort(select,buble,size);
	return 0;
}

void swap(struct TRAMP *x,struct TRAMP *y){
	TRAMP tmp;
	tmp=*x;
	*x=*y;
	*y=tmp;
}

void buble_sort(TRAMP array[] , int array_size){
	for(int i=0; i<array_size-1; i++){
		for(int j=array_size-1; j>=i+1; j--){
			if(array[j].number<array[j-1].number){
				swap(&array[j],&array[j-1]);
			}
		}
	}
}

void selection_sort(TRAMP array[] , int array_size){
	int min_index=0;
	for(int i=0; i<array_size-1; i++){
		min_index=i;
		for(int j=i+1; j<array_size; j++){
			if(array[j].number<array[min_index].number){
				min_index=j;
			}
		}
		swap(&array[min_index],&array[i]);
	}
}

void print_sort(TRAMP *array,int array_size){
	for(int i=0; i<array_size-1; i++){
		printf("%c%d ",array[i].mark,array[i].number);
	}
	printf("%c%d\n",array[array_size-1].mark,array[array_size-1].number);
}

void judge_sort(TRAMP buble[], TRAMP select[],int array_size){
	for(int i=0; i<array_size; i++){
		if(!(buble[i].mark==select[i].mark)){
			printf("Not stable\n");
			return;
		}
	}
	printf("Stable\n");

	return;
}



Measured memory_bytes: 2756
#include "bits/stdc++.h"

#define sz(x) (int)x.size()
#define ld long double
#define ll long long
#define pb push_back
#define mp make_pair
#define f first
#define s second

using namespace std;

string s;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> s;
    if(s == "ABC") cout << "ARC";
    else cout << "ABC";
    return 0;
}

Measured memory_bytes: 3616
s = list(input())
cnt = 0
for i in range(1,len(s)):
#    print(s[i-1],s[i])
    if s[i] == s[i-1]:
        cnt += 1
        if s[i] == '1':
            s[i] = '0'
        else:
            s[i] = '1'
print(cnt)

Measured memory_bytes: 3956
#include <stdio.h>

int main()
{
    int N, I = 1;

    scanf("%d", &N);

    /*while(1)
    {
        if(I%2 == 0 && I%N == 0)
        {
            printf("%d divisible by both 2 and %d\n", I, N);
            break;
        }

        printf("%d\n", I++);
    };*/

    if (N % 2 == 0)
    {
        printf("%d\n", N);
    }
    else
    {
        printf("%d\n", 2*N);
    }

    return 0;
}

Measured memory_bytes: 128
N, W = map(int, input().split())
items = [list(map(int, input().split())) for _ in range(N)]
sum_v = sum([item[1] for item in items])
inf = float("inf")
dp = [inf for _ in range(sum_v+1)]

dp[0] = 0
for i in range(N):
    for j in range(sum_v, -1, -1):
        if j - items[i][1] >= 0:
            dp[j] = min(dp[j], dp[j - items[i][1]] + items[i][0])

for v in range(sum_v, -1, -1):
    if dp[v] <= W:
        print(v)
        exit()



Measured memory_bytes: 95136
#include <bits/stdc++.h>
using namespace std;
struct P
{
    //string r;
    int x,y,z;

    bool operator<(const P &a)const{
       // if(y!=a.y)
       // return y>a.y;
       return x<a.x;
//        return z>a.z;
    }
};

vector<int> v[155];
//bitset<4001000> b;
int a,c,i,b,k,d,n,m;
long long e[100100];//dy[15]={0,1,0,-1,-1,1,-1,1},dx[15]={1,0,-1,0,1,1,-1,-1};//
long long l[1201010];
int o[1200150];
int dx[10]={0,1,0,-1},dy[10]={1,0,-1,0},dz[10]={0,0,0,0,1,-1};

long long x[200100],y,z[200100],mod=1000000007;
P u[11];
long long j[200011];

stack<int> s;
queue<int> q;

//'1'==49;
//'A'==65;
//'a'==97;
//unordered_
//map<int,int > p;
//list<int> l;
//string r[111],r2;
char r[510][555];


bool as(P a,P b)
{
   // if(a.x!=b.x)
        return a.x<b.x;
    //return a.y>b.y;
}


long long f(int a,int b)
{
    long long k=0;
    for(;a<b;)
    {
        if(a%2) k+=l[a],a++;
        else if(b%2==0) k+=l[b],b--;
        else a>>=1,b>>=1;
    }
    return k+l[a];
}

int main()
{
    long long a,b;
    scanf("%lld %lld",&a,&b);
    if(a==b&&a==1)
    {
        puts("1");
        return 0;
    }
    if(a<2||b<2)
    {
        printf("%lld",a*b-2);
        return 0;
    }
    //if(a<3||b<3)
    {
        printf("%lld",(long long)a*b-((a-1)*2+(b-1)*2));
        return 0;
    }


}


Measured memory_bytes: 256
import itertools

ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))

n = ii()
A = [tuple(int(i) for i in input().split()) for _ in range(n)]

ban = [['.'] * 8 for i in range(8)]

# for i in A:
#     ban[i[0]][i[1]] = '.'

for i in itertools.permutations(range(8)):
    flg = 0
    for j in A:
        if(i[j[0]] != j[1]):
            flg = 1
            break
    if flg:
        continue

    nc = []
    nc2 = []
    for k,j in enumerate(i):
        nc.append(k + j)
        nc2.append(k-j)
    
    if(len(set(nc)) != 8) |(len(set(nc2)) != 8) :
        continue

    else:
        for k,j in enumerate(i):
            ban[k][j] = 'Q'
        break
    

for i in ban:
    for j in i:
        print(j,end='')
    print('')
    


Measured memory_bytes: 5672
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
const ll INF = 1LL<<60;
const ll MOD = 1e9+7;

vector<P> primes(ll n){
    vector<P> ans;
    for(ll i=2; i*i<=n; i++){
        int cnt = 0;
        if(n%i!=0)continue;
        while(n%i==0){
            n/=i;
            cnt++;
        }
        ans.push_back(P(i,cnt));
    }
    if(n!=1)ans.push_back(P(n,1));
    return ans;
}

ll mod(ll x){
    ll res=x%MOD;
    return res+(res<0?MOD:0);
}
ll inv(ll x){
    ll b=MOD,u=1,v=0;
    while(b){
        ll t=x/b;
        x-=t*b;swap(x,b);
        u-=t*v;swap(u,v);
    }
    return mod(u);
}
vector<ll> prods(int x){
    vector<ll> res(x+1);
    res[0]=1;
    for(int i=1; i<=x; i++)res[i]=mod(i*res[i-1]);
    return res;
}
vector<ll> pows(ll a,int x){
    vector<ll> res(x+1);
    res[0]=1;
    a=mod(a);
    for(ll i=1; i<=x; i++)res[i]=mod(a*res[i-1]);
    return res;
}
ll power(ll a, ll n){
    ll res=1;
    a=mod(a);
    for(;n>0;n>>=1){
        if(n&1)res=mod(res*a);
        a=mod(a*a);
    }
    return res;
}

vector<ll> p;//p=prods(MAX_n)
ll comb(ll a, ll b){
    if(b<0||b>a)return 0;
    return mod(mod(p[a]*inv(p[b]))*inv(p[a-b]));
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n,m;cin>>n>>m;
    vector<P> pr = primes(m);
    p = prods(n+30);
    ll ans = 1;
    for(P pa:pr){
        ans *= comb(n+pa.second-1,pa.second);
        ans%=MOD;
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
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; }

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ for(auto it : P) { s << "<" << it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ for(auto it : P) { s << "<" << it.first << "->" << it.second << "> "; } return s << endl; }


int N;

int main() {
    while (cin >> N) {
        set<string> se;
        for (int i = 0; i < N; ++i) {
            string str;
            cin >> str;
            se.insert(str);
        }
        cout << se.size() << endl;
    }
}

















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

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define ALL(v) (v).begin(), (v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define BIT(x, n) bitset<n>(x)
#define PI 3.14159265358979323846

typedef long long ll;
typedef pair< int, int > P;   
typedef pair< int, P > PP;

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

int n;
int p[200001];
int cnt[200001];
int ma = 0;

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

	cin >> n;
	REP(i, n) {
		cin >> p[i];
		cnt[p[i]] = cnt[p[i] - 1] + 1;
	}
	REP(i, n) ma = max(ma, cnt[i + 1]);
	cout << n - ma << endl;

    return 0;
}


Measured memory_bytes: 1792
import sys
sys.setrecursionlimit(10**6)
n, q = map(int, input().split())
lis = [[] for _ in range(n)]
for _ in range(n-1):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    lis[a].append(b)
    lis[b].append(a)
c_plus = [0 for _ in range(n)]
for _ in range(q):
    p, x = map(int, input().split())
    p -= 1
    c_plus[p] += x
ans = [-1 for _ in range(n)]
def dfs(inp):
    now = inp[0]
    count = inp[1]
    count += c_plus[now]
    ans[now] = count
    for next in lis[now]:
        if ans[next] == -1:
            dfs([next, count])
dfs([0,0])
for i in range(n):
    ans[i] = str(ans[i])
print(" ".join(ans))

Measured memory_bytes: 240928
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
                int ab = Math.max(a+b,a-b);
                int an = Math.max(ab,a*b);
		System.out.println(an);
	}
}

Measured memory_bytes: 22100
n = int(input())

s = []
for i in range(n):
    x = str(input())
    s.append(x)


s.sort()

cnt = 1
if n == 1:
    print(1)
else:
    for i in range(n-1):
        if not (s[i] == s[i + 1]):
            cnt += 1
    print(cnt)
    
 

Measured memory_bytes: 23876
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.Scanner;

class Main {

    static final int MOD = 1000000007;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int ans = 0;
        int streak = -1;
        int prev = Integer.MAX_VALUE;
        for (int i = 0; i < N; i++) {
            int num = sc.nextInt();
            if (prev >= num)
                streak++;
            else
                streak = 0;
            if (streak > ans)
                ans = streak;
            prev = num;
        }

        System.out.println(ans);
    }
}

Measured memory_bytes: 48520
#include<iostream>
using namespace std;
int main(){
  int N, d[100000];
  cin >> N;
  for(int i=0; i<N; i++){
    cin >> d[i];
  }
  sort(d, d+N);
  int ans = d[N/2] - d[N/2-1];
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 888
[S,T] = list(input().split()) #文字列やからmapいらん
[A,B] = list(map(int,input().split())) #map(関数,list))でlistの要素それぞれに関数適用
N=input()
if S==N:
    print(A-1,B)
else:
    print(A,B-1)

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

using namespace std;

int main()
{
	int i,n,m;
	cin >> n >> m;
	int road_left[m],road_right[m];
	vector<int> city(n);

	for(i=0; i<m; i++){
		cin >> road_left[i] >> road_right[i];
		city[road_left[i] - 1]++;
		city[road_right[i] - 1]++;
			
	}

	for(i=0; i<n; i++)
		cout << city[i] << endl;
	


	

}


Measured memory_bytes: 256
# seishin.py
from collections import deque
N, K = map(int, input().split())
G = [[] for i in range(N)]
E = []
for i in range(N-1):
    a, b = map(int, input().split())
    G[a-1].append(b-1)
    G[b-1].append(a-1)
    E.append((a-1, b-1))

def bfs0(s):
    que = deque()
    prev = [-1]*N
    prev[s] = s
    que.append(s)
    while que:
        v = que.popleft()
        for w in G[v]:
            if prev[w] == -1:
                prev[w] = v
                que.append(w)
    L = []
    while v != s:
        L.append(v)
        v = prev[v]
    L.append(s)
    return L

D = bfs0(0)
D = bfs0(D[0])

C = {e for e in D}

l = len(D)
if l <= K+1:
    print(0)
    exit(0)

def bfs(que, U, K2):
    if K2 == 0:
        return 0
    cnt = 0
    while que:
        v = que.popleft()
        for w in G[v]:
            if U[w] != -1:
                continue
            U[w] = r = U[v] + 1
            cnt += 1
            if r < K2:
                que.append(w)
    return cnt

ans = 0
que = deque()
if K % 2:
    for a, b in E:
        U = [-1]*N
        U[a] = U[b] = 0
        que.append(a)
        que.append(b)
        ans = max(ans, bfs(que, U, K // 2) + 2)
else:
    for i in range(N):
        U = [-1]*N
        U[i] = 0
        que.append(i)
        ans = max(ans, bfs(que, U, K // 2) + 1)
print(N - ans)


Measured memory_bytes: 4084
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
using ll = long long;
typedef vector<int> vi;
typedef vector<vi> vvi;


int main() {

	int n;
	cin >> n;
	vector<pair<int, int>> work(n);
	rep(i, n)cin >> work[i].second >> work[i].first;

	sort(all(work));

	int time = 0;
	rep(i, n) {
		int a = work[i].second;
		int b = work[i].first;
		if (time + a <= b)time += a;
		else {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
}

Measured memory_bytes: 1792
//#pragma warning(disable:4996)
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
#include <iomanip>
#include <cassert>
//#include <boost/multiprecision/cpp_int.hpp>
#include <complex>
#include <cstdio>
#include <list>
#include <bitset>
//#include <stdio.h>

//< in.txt > out.txt
using namespace std;
//std::ios::sync_with_stdio(false);
//std::cin.tie(0);
const long long MOD = 1e9 + 7;
const long long INF = 1e15;
typedef long long LL;
typedef long double LD;
//typedef boost::multiprecision::cpp_int bigint;
typedef pair<LL, LL> PLL;
typedef pair<int, int> PI;
typedef pair<LD, LL> pdl;
typedef pair<LD, LD> pdd;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef unsigned long long ULL;

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	int H, W;
	cin >> H >> W;
	for (int y = 0; y < H; y++) {
		for (int x = 0; x < W; x++) {
			string S;
			cin >> S;
			if (S == string("snuke")) {
				string s("A");
				s[0] += x;
				cout << s << y + 1 << "\n";
				return 0;
			}
		}
	}
	return 0;
}

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

int main() {
    #ifdef DEBUG
        freopen("in.txt", "r", stdin);
    #endif
    ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);

    string a, b; cin >> a >> b;
    int x = stoi(a + b);
    for (int i = 0; i <= 1000; i++) {
        if (i * i == x) {
            cout << "Yes\n";
            return 0;
        }
    }
    cout << "No\n";

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <map>

using namespace std;

const long MOD = 1000000007;
typedef pair<int, int> P;
typedef long long ll;

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

    map<int ,P> m;
    for(int i=0; i<H; i++){
        for(int j=0; j<W; j++){
            int a;
            cin >> a;
            m[a] = make_pair(i, j);
        }
    }

    map<int, int> sum;
    for(int i=1; i<=H*W; i++){
        if(sum.count(i) != 0) continue;

        int now = i;
        sum[now] = 0;
        P prev = m[now];
        now += D;
        while(now <= H*W){
            P next = m[now];
            sum[now] += sum[now-D] + abs(prev.first-next.first) + abs(prev.second-next.second);
            prev = next;
            now += D;
        }
    }

    int Q;
    cin >> Q;
    int ans[Q];
    for(int i=0; i<Q; i++){
        int l, r;
        cin >> l >> r;
        ans[i] = sum[r] - sum[l];
    }

    for(int i=0; i<Q; i++){
        cout << ans[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 11392
import * as fs from 'fs';

const lines = fs.readFileSync('/dev/stdin', 'utf8').split('\n');

const [N, M, C] = lines[0].split(' ').map(Number);
const B = lines[1].split(' ').map(Number);
let answer = 0;

for(let i=2; i<N+2; i++) {
	let A = lines[i].split(' ').map(Number);
	if (A.map((a, i) => {return a*B[i]}).reduce((a, b) => {return a+b}, 0)+C > 0) {
		answer += 1;
	}
}

console.log(answer);


Measured memory_bytes: 29632
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;

#define REP(i,n) for(int (i)=0; (i)<(n); (i)++)
#define For(i,a,b) for(int (i)=(a); (i)<(b); (i)++)

void cutk(vector<int> &v, int k) {
    REP(i,k) {
        v.push_back(v[0]);
        v.erase(v.begin());
    }
}

void shuff(vector<int> &v) {
    vector<int> w;
    int n = v.size()/2;
    REP(i,n) {
        w.push_back(v[i]);
        w.push_back(v[i+n]);
    }
    v.clear();
    copy(w.begin(), w.end(), back_inserter(v));
}

void solve13(int n, int m) {
    vector<int> v;
    REP(i,2*n) v.push_back(i+1);
    REP(i,m) {
        int k;
        cin >> k;
        if (k) cutk(v, k);
        else shuff(v);
    }
    REP(i,2*n) cout << v[i] << endl;
}


int main() {
    int n, m;
    cin >> n >> m;
    solve13(n, m);
    return 0;
}

Measured memory_bytes: 1224
import sys
n = int(input())
w = input()
words=[]

words.append(w)

for i in range(1,n):
    w = input()
    if w not in words:
        if words[-1][-1]==w[0]:
            words.append(w)
            continue
        else:
            print("No")
            sys.exit()
    else:
        print("No")
        sys.exit()
print("Yes")

Measured memory_bytes: 9116
#include <bits/stdc++.h>
#include <algorithm>
#include <vector>
#include <iostream>
using namespace std;
 
int main() {
  int n,m,c;
  int counter = 0;
  cin >> n >> m >> c;
  vector<int> b(m);
  vector<int> sum(n);
  vector<vector<int>> a(n, vector<int>(m));
  
  //bの取得
  for(int i = 0;i < m; i++) cin >> b[i]; 
  
  //aの取得
  for(int i = 0;i < n; i++){
     for(int j = 0;j < m; j++){
          cin >> a[i][j];
     }
     }
  
  //合計
  for(int i = 0;i < n; i++){
     for(int j = 0;j < m; j++){
          sum[i] += b[j] * a[i][j]; 
     }
     }
    
  for(int i = 0;i < n; i++){
        if(sum[i] + c > 0){
           counter++ ;
         }
     }

 cout << counter << endl;
  
}


Measured memory_bytes: 3612
#include<iostream>
#include <numeric>
using namespace std;
int main() {
    int N;
    cin >> N;
    int d[N];
    for(int i = 0; i < N; i++) {
        cin >> d[i];
    }

    int sum = 0;
    for (int i = 0; i < N; i++) {
        for (int j = i + 1; j < N; j++) {
            sum += d[i] * d[j];
        }
    }

    cout << sum << endl;
}


Measured memory_bytes: 256
program sample
	implicit none
    integer(8) :: x(5)
    
    read(*,*) x
    
    if (x(1) ==0) then
    	write(*,*) 1
    else if (x(2) ==0) then
    	write(*,*) 2
    else if (x(3) ==0) then
    	write(*,*) 3
    else if (x(4) ==0) then
    	write(*,*) 4
    else if (x(5) ==0) then
    	write(*,*) 5        
    end if
    stop
end program sample


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

bool input(std::string&);

int main() {
	
	std::string str;

	while (input(str))
	{
		int sum = 0;
		for (size_t i = 0; i < str.length(); i++)
		{
			sum += str[i] - '0';
		}
		std::cout << sum << '\n';
	}
	return 0;
}

bool input(std::string& str) {
	std::cin >> str;
	if (str == "0\0")
	{
		return false;
	}
	return true;
}


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

#define debug(...) fprintf(stderr, __VA_ARGS__)

#ifndef AT_HOME
#define getchar() IO::myGetchar()
#define putchar(x) IO::myPutchar(x)
#endif

namespace IO {
	static const int IN_BUF = 1 << 23, OUT_BUF = 1 << 23;

	inline char myGetchar() {
		static char buf[IN_BUF], *ps = buf, *pt = buf;
		if (ps == pt) {
			ps = buf, pt = buf + fread(buf, 1, IN_BUF, stdin);
		}
		return ps == pt ? EOF : *ps++;
	}

	template<typename T>
	inline bool read(T &x) {
		bool op = 0;
		char ch = getchar();
		x = 0;
		for (; !isdigit(ch) && ch != EOF; ch = getchar()) {
			op ^= (ch == '-');
		}
		if (ch == EOF) {
			return false;
		}
		for (; isdigit(ch); ch = getchar()) {
			x = x * 10 + (ch ^ '0');
		}
		if (op) {
			x = -x;
		}
		return true;
	}

	inline int readStr(char *s) {
		int n = 0;
		char ch = getchar();
		for (; isspace(ch) && ch != EOF; ch = getchar())
			;
		for (; !isspace(ch) && ch != EOF; ch = getchar()) {
			s[n++] = ch;
		}
		s[n] = '\0';
		return n;
	}

	inline void myPutchar(char x) {
		static char pbuf[OUT_BUF], *pp = pbuf;
		struct _flusher {
			~_flusher() {
				fwrite(pbuf, 1, pp - pbuf, stdout);
			}
		};
		static _flusher outputFlusher;
		if (pp == pbuf + OUT_BUF) {
			fwrite(pbuf, 1, OUT_BUF, stdout);
			pp = pbuf;
		}
		*pp++ = x;
	}

	template<typename T>
	inline void print_(T x) {
		if (x == 0) {
			putchar('0');
			return;
		}
		static int num[40];
		if (x < 0) {
			putchar('-');
			x = -x;
		}
		for (*num = 0; x; x /= 10) {
			num[++*num] = x % 10;
		}
		while (*num){
			putchar(num[*num] ^ '0');
			--*num;
		}
	}

	template<typename T>
	inline void print(T x, char ch = '\n') {
		print_(x);
		putchar(ch);
	}

	inline void printStr_(const char *s, int n = -1) {
		if (n == -1) {
			n = strlen(s);
		}
		for (int i = 0; i < n; ++i) {
			putchar(s[i]);
		}
	}

	inline void printStr(const char *s, int n = -1, char ch = '\n') {
		printStr_(s, n);
		putchar(ch);
	}
}
using namespace IO;

long long n, a, b;

int main() {
	read(n), read(a), read(b);
	if (a > b) {
		std::swap(a, b);
	}
	if ((b - a) & 1) {
		print(std::min(a, n - b + 1) + (b - a - 1) / 2);
	} else {
		print((b - a) / 2);
	}
}


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

//using Graph = vector<vector<edge>>;
using dou =long double;
string yes="yes";
string Yes="Yes";
string YES="YES";
string no="no";
string No="No";
string NO="NO";

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define rep(i, n)         for(int i = 0; i < (int)(n); i++)
#define brep(n)           for(int bit=0;bit<(1<<n);bit++)
#define erep(i,container) for (auto i : container)
#define irep(i, n)        for(int i = n-1; i >= (int)0; i--)
#define rrep(i,m,n) for(ll i = m; i < (ll)(n); i++)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define all(x) (x).begin(),(x).end()
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define query int qq;std::cin >> qq;rep(qqq,qq)
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define itn int
#define mp make_pair
#define sum(a) accumulate(all(a),0ll)
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<t>(n,a)));
#define vvvvector(name,t,k,l,m,n,a) vector<vector<vector<vector<t> > > > name(k,vector<vector<vector<t> > >(l, vector<vector<t> >(m, vector<t>(n,a)) ));
#define case std::cout <<"Case #" <<qqq+1<<": "
#define res resize
#define as assign
#define ffor for(;;)
#define ppri(a,b) std::cout << a<<" "<<b << std::endl
#define pppri(a,b,c) std::cout << a<<" "<<b <<" "<< c<<std::endl
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define ssum(a) accumulate(a,0ll) 

typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
//typedef long long T;
const int INF = 1000000000;
const ll INF64 = 922337203685477580ll;
const ll MOD = 1000000007ll;
const dou pi=3.141592653589793;

struct edge {// ダイクストラ法
    ll to, cost;
    
};
typedef vector<vector<edge> > AdjList;  // 隣接リストの型
typedef vector<vector<edge> > Graph;
vector<ll> dist;
typedef pair<int, int> P;
void dijkstra(AdjList& graph,int n, int s){
    dist = vector<ll>(n,INF64);
    dist[s] = 0;
    priority_queue<P, vector<P>, greater<P> > que;
    que.push(P(0,s));
 
    while(!que.empty()){
        P p = que.top();
        que.pop();
        int v = p.second;
        if(dist[v] < p.first){
            continue;
        }
        for(int i=0;i < graph[v].size();i++){
            edge e = graph[v][i];
            if(dist[e.to] > dist[v] + e.cost){
                dist[e.to] = dist[v] + e.cost;
                que.push(P(dist[e.to],e.to));
            }
        }
    }
}

int main(){
    int v,e,r;
    std::cin >> v>>e>>r;
    Graph g(v);
    rep(i,e){
        int s,t,d;
        std::cin >> s>>t>>d;
        edge e={t,d};
        g[s].pb(e);
    }
    dijkstra(g,v,r);
    rep(i,v){
        if(dist[i]==INF64)std::cout << "INF" << std::endl;
        else std::cout << dist[i] << std::endl;
        
    }
}


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

using namespace std;

const int maxn = 1e5 + 5;

struct Edges
{
    int v, next;
} e[maxn << 1];
int h[maxn], mem;
int fa[maxn][20];
int dep[maxn];
bool vis[maxn];
bool du[maxn];
int ansx[maxn], ansy[maxn], top;
bool sum[maxn];
void pre()
{
    memset(h, -1, sizeof(h));
    mem = 0;
    top = 0;
    memset(vis, 0, sizeof(vis));
    memset(fa, 0, sizeof(fa));
    memset(du, 0, sizeof(du));
    memset(sum, 0, sizeof(sum));
}

void add( int u, int v )
{
    e[mem].v = v;
    e[mem].next = h[u];
    h[u] = mem++;
}

void dfs(int u, int f)
{
    vis[u] = 1;
    dep[u] = dep[f] + 1;
    fa[u][0] = f;
    for(int i=1; i<20; i++)
        fa[u][i] = fa[fa[u][i-1]][i-1];
    for(int i=h[u]; i+1; i=e[i].next)
    {
        int v = e[i].v;
        if(v==f) continue;
        if(vis[v]){
            if(dep[u]<dep[v]||(dep[u]==dep[v]&&u<v))
            {
                du[u] ^= 1;
                ansx[top] = u;
                ansy[top++] = v;
            }
            continue;
        }
        du[u]^=1;
        dfs(v, u);
    }
}

vector<int> last;

int findfa(int u, int v)
{
    if(dep[u]<dep[v]) swap(u, v);
    for(int i=19; i>=0; i--)
    {
        if(dep[fa[u][i]] >= dep[v])
            u = fa[u][i];
    }
    if(u==v) return u;
    for(int i=19; i>=0; i--)
    {
        if(fa[u][i]!=fa[v][i]){
            u = fa[u][i];
            v = fa[u][i];
        }
    }
    return fa[u][0];
}

void change(int u, int v)
{
    int f = findfa(u, v);
    // du[f] ^= 1;
    du[u] ^= 1;
    du[v] ^= 1;

}

bool dfsans(int u, int f)
{
    vis[u] = 1;
    //printf("dfsans %d %d\n", u, f);
    bool now=du[u];
    for(int i=h[u]; i+1; i=e[i].next)
    {
        int v = e[i].v;
        if(v==f) continue;
        if(vis[v]) continue;
        bool flag = dfsans(v, u);
        if(flag){
            ansx[top] = v;
            ansy[top] = u;
        }
        else{
            ansx[top] = u;
            ansy[top] = v;
        }
        top++;
        now ^= flag;
    }
    return now;
}

int main()
{
    int n, m;
    scanf( "%d%d", &n, &m );
    pre();
    for( int i = 1; i <= m; i++ )
    {
        int u, v;
        scanf("%d%d", &u, &v);
        add(u, v);
        add(v, u);
    }
    if(m&1){
        printf("-1\n");
        return 0;
    }
    dep[1] = 1;
    dfs(1, 1);
    last.clear();
    for(int i=1; i <= n; i++)
    {
        if(du[i]){
            last.push_back(i);
        }
    }
    memset(du, 0, sizeof(du));
    memset(vis, 0, sizeof(vis));
    int l = last.size();
    for(int i=0; i < l / 2; i++)
    {
        change(last[i], last[l-1-i]);
    }
    dfsans(1, 1);
    for(int i=0; i<top; i++)
    {
        printf("%d %d\n", ansx[i], ansy[i]);
    }
    //printf("%d\n", top);
    return 0;
}


Measured memory_bytes: 17784
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define ui unsigned int
#define us unsigned short
#define IOS ios_base::sync_with_stdio(0);
#define INF LONG_MAX
#define PI 3.1415926535897932384626
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define rep(x,j,n)for(ll x=j;x<n;x++)
#define repr(x,j,n)for(ll x=j;x>n;x--)
#define mod 1000000007
typedef vector<pair<ll,ll>> vpi;
typedef vector<ll> vi;
typedef vector<vi> vvi;

ll modexp(ll a,ll b,ll m)
{
    ll r=1;
    a=a%m;
    while(b>0)
    {
    if(b&1)
    r=(r*a)%m;
    b=b/2;
    a=(a*a)%m;
    }
    return r%m;
}

int main()
{
    int d,l,r;
    cin>>l>>r>>d;
    int ans=0;
    rep(i,l,r+1)if(i%d==0)ans++;
    cout<<ans;
}


Measured memory_bytes: 3592
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner scan = new Scanner(System.in);
        int K = scan.nextInt();
        
        if (K % 2 == 0) {
            System.out.println((K / 2) * (K / 2));
        }
        else {
            System.out.println((int)(Math.ceil(K / 2.0) * (Math.ceil(K / 2.0) - 1)));
        }
        scan.close();
    }
}


Measured memory_bytes: 22868