akhauriyash/Code-Regression huggingface dataset:
import java.io.*;
import java.util.Scanner;
 
public class Main {
    public static double btsp(int[] x, int[] y) {
        int n = x.length;

        double[][] aux = new double[n][n];
        for (int j = 1; j < n; j++) {
            aux[0][j] = aux[0][j-1] + distance(x[j-1], y[j-1], x[j], y[j]);
        }

        for (int i = 1; i < n; i++) {
            for (int j = i; j < n; j++) {
                if (i == j) {
                    aux[i][j] = aux[i-1][j] + distance(x[i-1], y[i-1], x[j], y[j]);
                } else if (i == j - 1) {
                    double min = Double.POSITIVE_INFINITY;
                    for (int k = 0; k < j; k++) {
                        min = Math.min(min, aux[k][j-1] + distance(x[k], y[k], x[j], y[j]));
                    }
                    aux[i][j] = min;
                } else {
                    aux[i][j] = aux[i][j-1] + distance(x[j-1], y[j-1], x[j], y[j]);
                }
            }
        }
        return aux[n-1][n-1];
    }

    public static double distance(int x1, int y1, int x2, int y2) {
        return Math.sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));
    }

    public static void main (String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int x[] = new int[n];
        int y[] = new int[n];

        for(int i = 0; i < n; i++) {           
            x[i] = sc.nextInt();
            y[i] = sc.nextInt();
        }

        System.out.println(btsp(x, y));
    }
}


Measured memory_bytes: 42356
#include<bits/stdc++.h>
#include<algorithm>
#include<math.h>
#include<string>
#include<iostream>
#include<vector>
#include<cstdlib>
using namespace std;
 
template <class T> using V = vector<T>;
 
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 = 1LL << 60;
 
using ll = long long;
using db = double;
using st = string;
using ch = char;
using bl = bool;
using vll = V<ll>;
using vpll =V<pair<ll,ll>>;
using vst = V<st>;
using vdb = V<db>;
using vch = V<ch>;
using vbl = V<bl>;

 
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define rFOR(i,a,b) for(ll i=(a);i>=(b);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define M(a,b) max(a,b)
#define rM(a,b) min(a,b)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define co(a) cout<<a<<endl;
#define ci(a) cin>>a;
  
 

ll sum(ll n) {
ll m=0;
  FOR(i,0,20){
    m+=n%10;
    n/=10;
    if(n==0){
      break;
    }
  }
  return m;
}
 
 
const int MAX = 510000;
const int MOD = 1000000007;
 
long long fac[MAX], finv[MAX], inv[MAX];
 
void Comuse() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
 
#define comuse Comuse()
 
ll combi(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
 
 
 
 
ll lcm(ll a,ll b){
  ll n;
  n=a/gcd(a,b)*b;
  return n;
}




 
/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/
 
 
signed main() {
  ll h,w,a,b;
    ci(h>>w>>a>>b);

  FOR(i,0,h){
    FOR(j,0,w){
      if(i<b&&j<a){
        cout<<0;
      }

      else if(i>=b&&j>=a){
        cout<<0;
      }

      else{
        cout<<1;
      }
    }
    cout<<""<<endl;
  }
}

Measured memory_bytes: 1280
h,w=map(int, input().split())
s = [list(input()) for i in range(h)]
s=[i for i in s if '#' in i]
count=0
while count<len(s[0]):
    check=0
    for i in s:
        if i[count]=='#':
            check=1
    if check==0:
        for i in s:
            i.pop(count)
    else:count+=1
for i in s:print(''.join(i))

Measured memory_bytes: 3064
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;
 
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
 
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
 
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
 
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
 
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
 

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

LL lcm(LL a, LL b){
    LL g = gcd(a,b);
    return a/g *b;
}

int main(){
    int N;
    cin >> N;
    LL T;
    LL ans=1;  
    REP(i,N){
        cin >> T;
        ans= lcm(ans,T);
    }
    cout << ans;
    }

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define fi first
#define se second

#define PI acos(-1.0)
#define INF 1000000007
#define EPS 1e-10

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> PD;
typedef pair<string, ll> PS;
typedef vector<ll> V;

int co[100];
int n, a;

int main(){
	while (cin >> n&&n){
		REP(i, 10)co[i] = 0;
		REP(i, n){
			cin >> a;
			co[a]++;
		}
		REP(i, 10){
			if (co[i] == 0){
				cout << "-" << endl;
			}
			else {
				REP(j, co[i])cout << "*";
				cout << endl;
			}
		}
	}
}

Measured memory_bytes: 1152
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <bitset>
#include <math.h>
#include <iomanip>
#include <queue>
#define inp(X) cin >> X
#define out(X) cout << X << endl
#define out16(X) cout << setprecision(16) << X << endl
#define rep(i,n) for(int i=0;i<n;i++ )
#define rep2(i,f,n) for(int i=f;i<n;i++ )
#define MAX(A) *max_element(A.begin(),A.end())
#define MIN(A) *min_element(A.begin(),A.end())
#define SORT(A) sort(A.begin(),A.end())
#define REV(A) reverse(A.begin(),A.end())
typedef long long int ll;
using vi = std::vector<int>;
using vvi = std::vector<std::vector<int>>;
using vd = std::vector<double>;
using vvd = std::vector<std::vector<double>>;
using vll = std::vector<ll>;
using vvll = std::vector<std::vector<ll>>;
using namespace std;
#define MOD 1000000007
#define INF 1000000001
#define LL_INF 1001001001001001001

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

bool bfs(vector<vector<int>> g, vector<int> &dist, int sv){
	queue<int> q;
	q.push(sv);
	dist[sv]=0;
	while(!q.empty()){
		int now = q.front(); q.pop();
		for(auto v : g[now]){
			if(dist[v]!=-1) continue;
			dist[v] = dist[now]+1;
			q.push(v);
		}
	}
}

int main(void) {
	int n; cin >> n;
	vi a(n); 
	vector<vector<pair<int,int>>> x(n);	
	rep(i,n){
		cin >> a[i];
		rep(j,a[i]){
			int a,b; cin >> a >> b;
			--a;
			x[i].emplace_back(a,b);			
		}
	}
	int ans=0;
	int state = 0;
	rep(s,(1<<n)){
		vi hu(n);
		rep(i,n) hu[i] = (s>>i)%2;
		int cnt = 0;
		rep(i,n) cnt += hu[i];
//		rep(i,n)out(hu[i]);
		bool unkind = false;
		rep(i,n){
			if(hu[i]==0) continue;
			rep(j,a[i]){
				if(hu[x[i][j].first]!=x[i][j].second) unkind = unkind||true;
			}
		}
		if(!unkind) ans=max(ans,cnt);
//		cout << "cnt = " << cnt << endl;
	}
	out(ans);

}


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

int n, k;
string str;
int nxt[26];
int bit[200005];
inline void add(int i, int x){
  i++;
  while(i<200005){
    bit[i]+=x;
    i+=i&-i;
  }
}
inline int sum(int i){
  i++;
  int ret=0;
  while(i){
    ret+=bit[i];
    i-=i&-i;
  }
  return ret;
}

void gonext(int i){
  while(nxt[i]<n && str[nxt[i]]!='a'+i) nxt[i]++;
}
int main(){
  cin >> str >> k;
  n=str.length();
  fill(bit, bit+200005, 0);
  for(int i=0; i<n; i++) add(i, 1);
  fill(nxt, nxt+26, 0);
  for(int i=0; i<26; i++) gonext(i);
  for(int i=0; i<n; i++){
    for(int j=0; j<26; j++){
      if(nxt[j]==n) continue;
      int cnt=sum(nxt[j]-1);
      if(cnt<=k){
        k-=cnt;
        add(nxt[j], -1);
        cout << (char)('a'+j);
        nxt[j]++;
        gonext(j);
        break;
      }
    }
  }
  cout << endl;
}

Measured memory_bytes: 4068
k,n = map(int,input().split())
a = list(map(int,input().split()))
for i in range(n-1):
    a.append(k+a[i])
ans = a[n-1]-a[0]
for i in range(n,n*2-1):
    ans = min(ans,a[i]-a[i-n+1])
print(ans)

Measured memory_bytes: 32228
import java.io.PrintStream;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception{
		new Main(new Scanner(System.in), System.out, System.err).exec();
	}
	public final Scanner sc;
	public final PrintStream out, err;
	public Main(final Scanner sc, final PrintStream out, final PrintStream err) {
		this.sc = sc;this.out = out;this.err = err;
	}
	static public final long pair(int a, int b) {return (((long)a) << 32) + b;}
	static public final int getPair1(long v) {return (int)(v >> 32);}
	static public final int getPari2(long v) {return (int)(v & 0xFFFFFFFF);}

	static public final long quad(long a, long b, long c, long d) {
		return ((a&0xFFFF)<< 48) + ((b&0xFFFF)<< 32) + ((c&0xFFFF)<< 16) +(d&0xFFFF);}
	static public final int getQuad1(long v) {return (int)( v >> 48          );}
	static public final int getQuad2(long v) {return (int)((v >> 32) & 0xFFFF);}
	static public final int getQuad3(long v) {return (int)((v >> 16) & 0xFFFF);}
	static public final int getQuad4(long v) {return (int)( v        & 0xFFFF);}

	static public final long record(int e, int m, int i) {
		return quad(-1, e, m, i);
	}
	static public final int re(long record) {
		return getQuad2(record);
	}
	static public final int rm(long record) {
		return getQuad3(record);
	}
	static public final int ri(long record) {
		return getQuad4(record);
	}

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

	private int p;
	private int[] inv;
	private int[] fact;
	private int[] finv;
	public final int mod(long v) {
		v %= p;
		return (int)(v < 0 ? v+p : v);
	}
	public final int mul(long a, long b) {
		return mod(a*b);
	}
	public final void initFact(double limit, double p) {
		initFact((int)limit, (int)p);
	}
	public final void initFact(int limit, int p) {
		this.p = p;
		this.inv = new int[limit+1];
		this.fact = new int[limit+1];
		this.finv = new int[limit+1];
		fact[1] = finv[1] = inv[0] = inv[1] = 1;
		for(int i=2;i<=limit;i++) {
			int a = p / i;
			int b = p % i;
			inv[i]  = mul(-a, inv[b]);
			fact[i] = mul(fact[i-1], i);
			finv[i] = mul(finv[i-1], inv[i]);
		}
	}
	public final int comb(int m, int n) {
		return mul(mul(fact[m], finv[n]), finv[m-n]);
	}
	//------------------------------------------
	static long lcm (long a, long b) {
		long temp;
		long c = a;
		c *= b;
		while((temp = a%b)!=0) {
			a = b;
			b = temp;
		}
		return (long)(c/b);
	}

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



	public void exec() throws Exception{
		final int A = sc.nextInt();
		final int B = sc.nextInt();
		final int C = sc.nextInt();
		if(A == B && A != C) {
			out.println("Yes");
			return;
		}
		if(A == C && A != B) {
			out.println("Yes");
			return;
		}
		if(B == C && A != B) {
			out.println("Yes");
			return;
		}
		out.println("No");
	}
}


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

using namespace std;

#define rep(a, b) for(int i = a; i <= b; i++)
#define mst(a) memset(a, 0, sizeof(a))
#define mem(a, p) memset(a, p, sizeof(a))

const int MAX = 1e2 + 10;


bool mtx[MAX][MAX];
int vis[MAX];
int n;

queue<int> q;

void init(void)
{
	while(!q.empty())
		q.pop();
	mem(vis, -1);
	return;
}

bool check(int x, int y)
{
	if(mtx[x][y] && vis[y] == -1)
		return true;
	return false;
}

void Bfs(void)
{
	int cnt = 1;
	q.push(1);
	vis[1] = 0;
	while(!q.empty())
	{
		int cur = q.front();
		q.pop();
		rep(1, n)
		{
			if(check(cur, i))
			{
				q.push(i);
				vis[i] = vis[cur] + 1;
				cnt++;
				if(cnt == n)
					return;
			}
		}
	}
	return;
}

int main()
{
	while(~scanf("%d", &n))
	{
		init();
		rep(1, n)
		{
			int row;
			scanf("%d", &row);
			int num;
			scanf("%d", &num);
			while(num--)
			{
				int tmp;
				scanf("%d", &tmp);
				mtx[row][tmp] = true;
			}
		}
		
		Bfs();
		
		rep(1, n)
			printf("%d %d\n", i, vis[i]);
	}
	return 0;
}



Measured memory_bytes: 3188
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cfloat>
#include <cmath>
#include <iomanip>
using namespace std;
using llong = long long;

const double eps = 1e-12;
const double g = 1e-6 - eps;
double a, b, x;

int main() {
    cin >> a >> b >> x;
    x /= a;
    
    cout << setprecision(15);
    if (fabs((a * b / 2) - x) <= eps) {
        cout << 90.0 - (atan2(a, b) * 180.0 / M_PI) << endl;
    }
    else if (a * b / 2 < x) {
        double valid = eps;
        double invalid = b;
        double mid;

        for (int i = 0; i < 10000; i++) {
            mid = (valid + invalid) / 2;

            if (a * (b - mid) + a * mid / 2 >= x) {
                valid = mid;
            }
            else {
                invalid = mid;
            }
        }

        cout << 90 - (atan2(a, valid) * 180.0 / M_PI) << endl;
    }
    else {
        double valid = eps;
        double invalid = M_PI / 2;
        double ang;

        for (int i = 0; i < 10000; i++) {
            ang = (valid + invalid) / 2;

            if (b * b * tan(ang) / 2 <= x) {
                valid = ang;
            }
            else {
                invalid = ang;
            }
        }
        cout << 90 - (valid * 180.0 / M_PI) << endl;
    }
    

    return 0;
}


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

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP0(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define RREP0(i, n) for (int i = (n)-1; i >= 0; --i)
#define REP1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define RREP1(i, n) for (int i = (n); i >= 1; --i)
#define pow10(n) int(1e##n + n)

typedef long long LL;
typedef pair<int, int> P;

const int INTINF = int(1e9) + 1;
const LL LLINF = LL(1e17) + 1;
long double eps = 1.0E-14;
// dp[i][j] i番目までに, 「余分な空白」を j 個挟んだとしたときの和の最大値
LL dp[2 * pow10(5)][3];

void solve()
{
    int N;
    cin >> N;
    vector<LL> A(N);
    REP0 (i, N)
    {
        cin >> A[i];
        REP0 (j, 3)
        {
            dp[i][j] = -LLINF;
        }
    }

    if (N % 2 == 0)
    {
        dp[0][0] = A[0];
        dp[1][0] = A[0];
        dp[1][1] = A[1];
        LL ans = -LLINF;

        for (int i = 2; i < N; i++)
        {
            dp[i][1] = max(dp[i][1], dp[i - 2][1] + A[i]);
            if (i - 3 >= 0)
                dp[i][1] = max(dp[i][1], dp[i - 3][0] + A[i]);

            dp[i][0] = max(dp[i][0], dp[i - 2][0] + A[i]);
        }

        // ans = max(ans, dp[N - 1][0]);
        ans = max(ans, dp[N - 1][1]);
        ans = max(ans, dp[N - 2][0]);

        std::cout << ans << endl;
        return;
    }

    dp[0][0] = dp[1][0] = A[0];
    dp[1][1] = A[1];
    dp[2][0] = dp[0][0] + A[2];
    dp[2][2] = A[2];
    LL ans = -LLINF;

    for (int i = 3; i < N; i++)
    {
        dp[i][2] = max(dp[i][2], dp[i - 2][2] + A[i]);
        dp[i][2] = max(dp[i][2], dp[i - 3][1] + A[i]);
        if (i - 4 >= 0)
            dp[i][2] = max(dp[i][2], dp[i - 4][0] + A[i]);

        dp[i][1] = max(dp[i][1], dp[i - 2][1] + A[i]);
        dp[i][1] = max(dp[i][1], dp[i - 3][0] + A[i]);

        dp[i][0] = max(dp[i][0], dp[i - 2][0] + A[i]);
    }

    // ans = max(ans, dp[N - 1][0]);
    // ans = max(ans, dp[N - 1][1]);
    ans = max(ans, dp[N - 1][2]);

    ans = max(ans, dp[N - 2][1]);

    ans = max(ans, dp[N - 3][0]);

    std::cout << ans << endl;
}

int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(20);
    solve();
    return 0;
}


Measured memory_bytes: 9544
// includes
#include <cstdio>
#include <cstdint>
#include <iostream>
#include <iomanip>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <utility>
#include <functional>
#include <cmath>
#include <climits>
#include <bitset>

// macros
#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue
#define FOR(i, a, b) for(int i=(a); i<(b);++i)
#define rep(i, n) FOR(i, 0, n)

using namespace std;

//  types
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
 
// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double EPS = 1e-10;

// solve
double x[4], y[4];

double calc(int i, int j, int k){
  return 0.5 * abs((x[j] - x[i]) * (y[k] - y[i]) - (x[k] - x[i]) * (y[j] - y[i]));
}

int main(int argc, char const* argv[])
{
  while(cin >> x[0]){
    cin >> y[0];
    FOR(i, 1, 4){
      cin >> x[i] >> y[i];
    }
    double area = calc(0, 1, 2);
    double tmp = calc(0, 1, 3) + calc(0, 2, 3) + calc(1, 2, 3);
    if(abs(area - tmp) < EPS){
      cout << "YES" << endl;
    }else{
      cout << "NO" << endl;
    }
  }
	return 0;
}



Measured memory_bytes: 3200
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define fi first
#define se second
typedef long long ll;
typedef pair<int,int> P;
#define MOD 1000000007
#define INF 1000000000
int gcd(int a,int b){
	if(b==0)return a;
	return gcd(b,a%b);
}
int lcm(int a,int b){
	return a/gcd(a,b)*b;
}
int modpow(int a,int b){
    if(!b)return 1;
    if(b%2)return modpow(a,b-1)*a%MOD;
    return modpow(a,b/2)*modpow(a,b/2)%MOD;
}
int fac(int a){
    int Ans=1;
    for(int i=1;i<=a;i++){
        Ans*=i;
        Ans%=MOD;
    }
    return Ans;
}//kaijo
int comb(int a,int b){
    return fac(a)*modpow(fac(a-b),MOD-2)%MOD*modpow(fac(b),MOD-2)%MOD;
}
int main(){
	int k;
	cin>>k;
	cout<<((k+1)/2)*(k/2)<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
//#include<iostream>
 
using namespace std;
 
typedef long long ll;
 
const int N = 200005;
 
int n,m;

//vector<int> same[N],opp[N];
vector<int> adj[N];

int vstd[N];

void dfs(int x){
	vstd[x] = true;
	for(int y:adj[x]){
		if(!vstd[y])dfs(y);
	}
}

int main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	
	cin>>n>>m;
	for(int i=0;i<m;i++){
		int x,y,z;
		cin>>x>>y>>z;
		/*
		if(z & 1){
			opp[x].push_back(y);
			opp[y].push_back(x);
		}else{
			same[x].push_back(y);
			same[y].push_back(x);
		}
		*/
		adj[x].push_back(y);
		adj[y].push_back(x);
	}
	
	int ans = 0;
	for(int i=1;i<=n;i++){
		if(!vstd[i]){
			ans++;
			dfs(i);
		}
	}
	
	cout<<ans;
	
	return 0;
}


Measured memory_bytes: 14856
#include <bits/stdc++.h>
#include <fstream>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>


typedef long long ll;
typedef long double ld;
using namespace std;
using namespace __gnu_pbds;


#define endl "\n"
#define FIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
const int N=1e5+5, mxN=(1<<20)+5;
int mod=1e9+7;

int main()
{
    FIO;
string s1,s2;
cin>>s1>>s2;
if(s1[0]==s2[2]&&s1[1]==s2[1]&&s1[2]==s2[0])
    cout<<"YES";
else
    cout<<"NO";
    return 0;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fr first
#define se second
#define ll long long
#define pb push_back
using namespace std;
const long long N = 1e5+ 7;
string s , s1 ;
ll n , m , k , cnt;
int main(){
    cin >> n;
    ll arr[n];
    map<ll,ll>mp;
    for( int i = 0;i < n;i ++ ){
        cin >> arr[i] , cnt+=arr[i];
        mp[arr[i]] ++;
    }
    cin >> m;
    for( int i = 0;i < m;i ++ ){
            ll a , b , ans = 0;
        cin >> a >> b;
       ans = mp[a] * b - mp[a] * a;
       cnt+=ans;
       mp[b] += mp[a];
       mp[a] = 0;
       cout << cnt << endl;
    }
}


Measured memory_bytes: 10120
def solve(problem,l):
    re = []
    for i in range(len(l)):
        if i == problem:
            re.append(l[i] + 1)
        else:
            re.append(l[i])
    return re



D,G = (int(i) for i in input().split())  
p = []
c = []
for _ in range(D):
    p_t,c_t =  (int(i) for i in input().split())
    p.append(p_t)
    c.append(c_t)

state = []
for _ in range(10100):
    state.append([0] * (D + 1))

i = 0
for j in range(D):
    point = state[i][-1]
    if p[j] > state[i][j]:
        point += 100 * (j + 1) * (p[j] - state[i][j])
        point += c[j]

        if state[i + (p[j] - state[i][j])][-1] < point:
            new_state = state[i] 
            for _ in range(p[j] - state[i][j]):
                new_state = solve(j,new_state)
            state[i + (p[j] - state[i][j])] = new_state
            state[i + (p[j] - state[i][j])][-1] = point
i += 1
while(True):
     #最後だけ取れる得点
    problem = 0
    for j in range(D):
        point = state[i-1][-1]
        if p[j] > state[i-1][j]:
            point += 100 * (j + 1)
            if p[j] - state[i-1][j] == 1:
                point += c[j]

        if state[i][-1] < point:
            state[i] = solve(j,state[i-1])
            state[i][-1] = point
    #print(state[0:10])
    for j in range(D):
        point = state[i][-1]
        if p[j] > state[i][j]:
            point += 100 * (j + 1) * (p[j] - state[i][j])
            point += c[j]

            if state[i + (p[j] - state[i][j])][-1] < point:
                new_state = state[i] 
                for _ in range(p[j] - state[i][j]):
                    new_state = solve(j,new_state)
                state[i + (p[j] - state[i][j])] = new_state
                state[i + (p[j] - state[i][j])][-1] = point

    #print(state[0:10])
    if state[i][-1] >= G:
        #print(state)
        print(i)
        break
    i += 1
    

Measured memory_bytes: 47580
using System;
class Program{
    static void Main(){
        // Your code here!
        string[] input = Console.ReadLine().Split(' ');
        int a = int.Parse(input[0]);
        int b = int.Parse(input[1]);
        int c = int.Parse(input[2]);
        Console.WriteLine(a+b >= c ? "Yes" : "No");
    }
}


Measured memory_bytes: 11092
fn main() {
    let _ = read::<usize>();
    let v = read_vec::<u64>();

    let ret = v.into_iter().fold(1u64, |sum, a| sum.saturating_mul(a));

    if ret > 10u64.pow(18) {
        println!("-1");
    } else {
        println!("{}", ret);
    }
}

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

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


Measured memory_bytes: 4732
#[allow(unused_macros)]
macro_rules! input {
    ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } };
    ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( std :: io :: BufReader :: new ( stdin . lock ( ) ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } };
}
#[allow(unused_macros)]
macro_rules! input_inner {
    ( $ next : expr ) => { };
    ( $ next : expr , ) => { };
    ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } };
}
#[allow(unused_macros)]
macro_rules! read_value {
    ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) };
    ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) };
    ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) };
    ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 };
    ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) };
}

fn main() {
    input! {
        r: u64, d: u64, x: u64
    }
    let mut ret = x;
    for _ in 0..10 {
        ret = r * ret - d;
        println!("{}", ret);
    }
}


Measured memory_bytes: 4352
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <bitset>
#include <vector>
#include <queue>
#include <map>
#include <set>

#define i64 int64_t
#define ff(ii,nn,mm) for(int ii=nn;ii<mm;ii++)
#define st(vvv) sort(vvv.begin(),vvv.end())
#define rvs(vvv) reverse(vvv.begin(),vvv.end())
int inf = 1000000007;

using namespace std;

int main() {
	string s;
	cin >> s;
	set<char> data;
	ff(i, 0, s.size()) {
		data.insert(s[i]);
	}
	if (data.size() == s.size()) {
		cout << "yes" << endl;
	}
	else cout << "no" << endl;
	return 0;
}

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

int main() {
  string s;
  cin >> s;
  int N = s.size();
  deque<char> dq;
  for (int i = 0; i < N; i++) {
    if (s[i] == 'B' && !dq.empty()) dq.pop_back();
    if (s[i] != 'B') dq.push_back(s[i]);
  }
  while (!dq.empty()) {
    cout << dq.front();
    dq.pop_front();
  }
  cout << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
#define MAX 100005
#define NIL -1

struct Node {int p, l, r;};

Node T[MAX];
int n, D[MAX];

void print(int u){
int i, c;
cout<< "node "<< u <<": ";
cout<< "parent = "<< T[u].p <<", ";
cout<< "depth = " << D[u] <<", ";

if ( T[u].p==NIL ) cout << "root, ";
else if ( T[u].l ==NIL ) cout << "leaf, " ;
else cout <<"internal node, ";

cout <<"[";

for(i=0, c=T[u].l; c!=NIL; i++, c=T[c].r){
   if (i) cout<<", ";
   cout << c;
  }
cout<< "]" <<endl;
}

int rec(int u, int p){
  D[u] = p;
  if (T[u].r != NIL) rec(T[u].r, p);
  if (T[u].l != NIL) rec(T[u].l, p+1);
}

int main(){
  int i, j, d, v, c, l, r;
  cin >> n;
  for(i=0; i<n; i++) T[i].p = T[i].l=T[i].r=NIL;

  for (i=0; i<n; i++){
     cin >> v >> d;
     for(j=0; j<d; j++){
       cin >> c;
       if (j==0)T[v].l=c;
       else T[l].r=c;
       l=c;
       T[c].p=v;
      }
   }
   for(i=0; i<n; i++){
     if (T[i].p == NIL) r=i;
    }

  rec(r, 0);

  for(i=0; i<n; i++) print(i);
  
  return 0;
}




Measured memory_bytes: 7784
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
#define bit(n) (1LL << (n))
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;

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

struct edge {
  int to, cost;
  edge(int to, int cost) : to(to), cost(cost) {}
};

int V;
vector<vector<edge>> G;
vector<ll> dist;

typedef pair<ll, int> P;  // <最短距離, 頂点の番号>

/* 負閉路の検出はできない。O(E logV) */
/* 負の辺があってもダメ */
void dijkstra(int s) {
  priority_queue<P, vector<P>, greater<P>> que;
  fill(dist.begin(), dist.end(), LINF);
  dist[s] = 0;
  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 < G[v].size(); ++i) {
      edge e = G[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 N, M;
  cin >> N >> M;

  vector<int> a(M), b(M);
  int V = bit(N);
  G = vector<vector<edge>>(V);

  vector<vector<int>> c(M);
  int temp;
  rep(i, M) {
    cin >> a[i] >> b[i];
    int key_comb = 0;
    rep(j, b[i]) {
      int temp;
      cin >> temp;
      c[i].pb(temp);
      key_comb |= bit(temp - 1);
    }

    rep(now, V) {
      int next = now | key_comb;
      if (next != now) {
        G[now].pb(edge(next, a[i]));
      }
    }
  }

  dist = vector<ll>(V);
  dijkstra(0);
  ll ans = dist[bit(N) - 1];
  if (ans == LINF)
    ans = -1;
  cout << ans << endl;
}

Measured memory_bytes: 36608
#include<cstdio>
#include<cstring>
using namespace std;
int main()
{
	char a[15];scanf("%s",a+1);
	int len=strlen(a+1);if(len<4) {printf("No\n");return 0;}
	if(a[1]=='Y'&&a[2]=='A'&&a[3]=='K'&&a[4]=='I') printf("Yes\n");
	else printf("No\n");
	return 0;
}

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

int main(){
	int q;
	cin >> q;
	int p,n;
	char c;
	long long st=0;
	for(int i=0;i<q;i++){
		cin >> p >> c >> n;
		if(c=='(') st+=n;
		else st-=n;
		if(st) cout <<"No"<< endl;
		else cout <<"Yes"<< endl;
	}
  return 0;
}


Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
int main(){
  string s;   cin >> s;
  int ans = 0;
  for(int i=0 ; i+1<s.size() ; i++){
    if(s[i]!=s[i+1]) ans++;
  }

  cout << ans << endl;
  return 0;
}


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

using namespace std;


int main(void){
  
  int N;
  
  cin >> N ;
  
  if(N%2 == 0){
    cout << N << endl;
    
  }
  
  if (N%2 != 0){
    cout << N*2 << endl;
  }
  
}


  

Measured memory_bytes: 256
n,m=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
A=set(a);B=set(b)
if len(A)!=len(a) or len(B)!=len(b):
  print(0)
else:
  L=[]
  for i in range(n):
    l=[]
    for j in range(m):
      l.append(0)
    L.append(l)
  ct=1;ctn=0;ctm=0
  for k in range(m*n,0,-1):
    if k in A and k in B:
      L[n-ctn-1][m-ctm-1]=k
      ctn+=1;ctm+=1
    elif k in A:
      ct*=ctm;ctn+=1
    elif k in B:
      ct*=ctn;ctm+=1
    else:
      ct*=(ctm*ctn-m*n+k)
    if ct==0:
      break
    ct=ct%(10**9+7)
  print(ct)

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

vector<vector<int>> graph(100000);

ll dfs(int now, ll k, int from){
    ll ret = 1LL;
    ll size = graph[now].size(); // 子の数
    ll color;
    ll perm = 1LL;
    if(from == -1) color = k-1;
    else color = k-2;
    if(k < size) return 0;
    rep(next,size){
        if(graph[now][next] == from) continue;
        ret = (ret*dfs(graph[now][next], k, now))%MOD;
        perm = (perm*color)%MOD;
        --color;
    }
    return (ret*perm)%MOD;
}

int main(){
    ll n; ll k; cin >> n >> k;
    int a, b;
    rep(i,n-1){
        cin >> a >> b; --a; --b;
        graph[a].push_back(b);
        graph[b].push_back(a);
    }
    cout << (k*dfs(0, k, -1))%MOD << "\n";
}

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


int main()
{
  int x; cin >> x;
  ll ans = 0;
  ans += x / 500 * 1000;
  ans += x % 500 / 5 * 5;
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>

int main()
{
    int a, b, c;
    std::cin >> a >> b >> c;
    if (b - a == c - b)
    {
        std::cout << "YES";
    }
    else
    {
        std::cout << "NO";
    }
    std::cout << std::endl;
    return 0;
}


Measured memory_bytes: 3600
#include <algorithm>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
// const int INF = (1 << 30) - 1;
// const ll LL_INF = (1LL << 62) - 1;
const ll MOD = 1e9 + 7;
const int MAX = 1000000;

// fac[n]: n!
// finv[n]: (n!)^-1
// inv[n]: nの逆元
ll fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void comb_init() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++) {
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

// 二項係数計算 (combination)
// nCk = (n!) * (k!)^-1 * ((n-k)!)^-1 として計算
ll comb(int n, int k) {
  if (n < k) {
    return 0;
  }
  if (n < 0 || k < 0) {
    return 0;
  }
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll X, Y;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> X >> Y;
  if ((X + Y) % 3 != 0) {
    cout << 0 << endl;
    return 0;
  }
  ll n = (X + Y) / 3;
  if (abs(X - Y) > n) {
    cout << 0 << endl;
    return 0;
  }
  if (n <= 1) {
    cout << 1 << endl;
    return 0;
  }

  comb_init();
  ll ans = 0;
  if (n % 2 == 0) {
    ans = comb(n, (n / 2) - abs(X - Y) / 2);
  } else {
    ans = comb(n, (n / 2) - abs(X - Y) / 2);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 23680
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <queue>
#include <functional>

#define INPUT_FROM_FILE (0) 
#if INPUT_FROM_FILE
#include <fstream>
#endif

typedef std::pair<int, int> P;

class Edge{
public:
	int to;
	int cost;

	Edge(){
		return;
	}
	~Edge(){
		return;
	}
};

int main(int argc, char **argv){
	std::vector<std::vector<Edge> >  G;
	std::vector<long> min_cost;
	std::priority_queue<P, std::vector<P>, std::greater<P> > que;

	int n, u, k, v, c;

#if INPUT_FROM_FILE
	std::ifstream ifs("test.txt");
	//FILE *fp = fopen("test.txt", "r");
#endif

	
#if INPUT_FROM_FILE
	ifs >> n;
#else
	std::cin >> n;
#endif
	G.resize(n);
	min_cost.resize(n, 1000000000) ;

	for(int i = 0; i < n; i++){
#if INPUT_FROM_FILE
		ifs >> u >> k;
#else
		std::cin >> u >> k;
#endif
		for(int j = 0; j < k; j++){
#if INPUT_FROM_FILE
			ifs >> v >> c;
#else
			std::cin >> v >> c;
#endif
			Edge e;
			e.to = v;
			e.cost = c;

			G[u].push_back(e);

		}
	}

	min_cost[0] = 0;
	que.push(P(0, 0));

	while(!que.empty()){
		P p = que.top(); que.pop();
		int v = p.second;

		if(min_cost[v] < p.first){ 
			continue;
		}

		for(int i = 0; i < G[v].size(); i++){
			Edge e = G[v][i];
			if(min_cost[e.to] > min_cost[v] + e.cost){
				min_cost[e.to] = min_cost[v] + e.cost;
				que.push(P(min_cost[e.to], e.to));
			}
		}
	}

	for(int i = 0; i < n; i++){
		std::cout << i << " " << min_cost[i] << std::endl;
	}
	return 0;
}


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

int main(void){
	std::vector<int> a(6);
	for(int i=0; i<6; i++) cin >> a[i];
	if((a[4] - a[0]) <= a[5]){
		cout << "Yay!";
	}else{
		cout << ":(";
	}
	return 0;
}

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

int main() {
    int n, x;
    cin >> n >> x;
    vector<long long> dat(n+1, x);
    for (int i = 0; i < n; i++) cin >> dat[i];
    sort(dat.begin(), dat.end());
    
    vector<long long> dist;
    for (int i = 0; i < n; i++) dist.emplace_back(dat[i+1] - dat[i]);
    
    cout << accumulate(dist.begin(), dist.end(), 0LL, [](long long a, long long b){ return __gcd(a, b); }) << endl;
    return 0;
}

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

const int N=1e6+50, mod=998244353;
inline int add(int x,int y) {return (x+y>=mod) ? (x+y-mod) : (x+y);}
inline int dec(int x,int y) {return (x-y<0) ? (x-y+mod) : (x-y);}
inline int mul(int x,int y) {return (long long)x*y%mod;}
inline int power(int a,int b,int rs=1) {for(;b;b>>=1,a=mul(a,a)) if(b&1) rs=mul(rs,a); return rs;}
inline int inv(int a) {return power(a,mod-2);}

struct combin {
	int fac[N],ifac[N];
	combin() {
		fac[0]=1;
		for(int i=1;i<N;i++) fac[i]=mul(fac[i-1],i);
		ifac[0]=ifac[1]=1;
		for(int i=2;i<N;i++) ifac[i]=mul(mod-mod/i,ifac[mod%i]);
		for(int i=2;i<N;i++) ifac[i]=mul(ifac[i-1],ifac[i]);
	}
	inline int C(int a,int b) {return mul(fac[a],mul(ifac[b],ifac[a-b]));}
} C;
#define x1 dqoaspjdioq
#define x2 dnasuihquih
#define y1 adsjiohejqu
#define y2 dnasuigqyuw
inline int path(int x1,int y1,int x2,int y2) {
	return C.C(x2-x1+y2-y1,x2-x1);
}
int n,m;
int main() {
	cin>>n>>m; if(n>m) swap(n,m);
	int ans=0;
	for(int i=1;i<=n;i++)
		ans=add(ans,mul(path(0,0,i,i),path(i,i,n,m)));
	ans=mul(ans,inv(2));
	ans=mul(ans,inv(path(0,0,n,m)));
	cout<<add(m,ans);
}

Measured memory_bytes: 8064
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>
#include <deque>

using namespace std;

/*
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
*/

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<long long, long long> pll;
typedef vector<pll> vpll;

typedef long double ld;
typedef vector<ld> vld;

typedef vector<bool> vb;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, n) for (ll i = 1; i <= (n); i++)
#define rrep(i, n) for (ll i = (n) - 1; i >= 0; i--)
#define rreps(i, n) for (ll i = (n); i >= 1; i--)
#define all(v) (v).begin(), (v).end()

template <class T> void chmin(T& a, T b) { a = min(a, b);}
template <class T> void chmax(T& a, T b) { a = max(a, b);}

constexpr int INF = 1 << 30;
constexpr ll INFL = 1LL << 60;
constexpr ll MOD = 1000000007;
constexpr ld EPS = 1e-12;
constexpr ld PI = 3.14159265358979323846;

vvll g;
vll hist;
vb seen, finished;
ll pos = -1;

void dfs(ll v) {
    seen[v] = true;
    hist.push_back(v);
    for(auto nv : g[v]) {
        if(finished[nv]) continue;
        if(seen[nv] && !finished[nv]) {
            pos = nv;
            return;
        }
        dfs(nv);
        if(pos != -1) return;
    }
    finished[v] = true;
    hist.pop_back();
}

void solve() {
    ll n, m;
    cin >> n >> m;

    g = vvll(n);
    for(ll i = 0; i < m; i++) {
        ll a, b;
        cin >> a >> b;
        a--, b--;
        g[a].push_back(b);
    }

    pos = -1;
    for(ll i = 0; i < n; i++) {
        seen.assign(n, false);
        finished.assign(n, false);
        hist.clear();
        dfs(i);
        if(pos != -1) break;
    }

    if(pos == -1) {
        cout << -1 << endl;
        return;
    }

    vll cycle;
    while(!hist.empty()) {
        cycle.push_back(hist.back());
        hist.pop_back();
        if(cycle.back() == pos) break;
    }
    reverse(cycle.begin(), cycle.end());

    ll from, to;
    while(true) {
        from = -1, to = -1;
        vll order(n, -1);
        for(ll i = 0; i < cycle.size(); i++) order[cycle[i]] = i;
        for(ll i = 0; i < cycle.size(); i++) {
            for(auto nv : g[cycle[i]]) {
                if(nv != cycle[(i+1)%cycle.size()] && order[nv] != -1) {
                    from = i;
                    to = order[nv];
                }
            }
        }
        if(from == -1) break;
        ll cur = to;
        vll ncycle;
        ncycle.push_back(cycle[from]);
        while(cur != from) {
            ncycle.push_back(cycle[cur]);
            cur = (cur + 1) % cycle.size();
        }
        cycle = ncycle;
    }
    cout << cycle.size() << endl;
    for(auto v : cycle) cout << v + 1 << endl;
    return;
}

int main() {
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
}

Measured memory_bytes: 384
#include <iostream>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <queue>
#include <stack>
#include <stdlib.h>
using namespace std;
#define rep(i,n) for (int (i) = 0; (i) <(n); (i)++) 
#include <math.h>
#include <bits/stdc++.h>
using namespace std;
int binary(int bina){
    int ans = 0;
    for (int i = 0; bina>0 ; i++)
    {
        ans = ans+(bina%2)*pow(10,i);
        bina = bina/2;
    }
    return ans;
}
long comb(int n, int r) {
    long ans = 1;
    for (int i = n; i > n - r; --i) {
        ans = ans*i;
    }
    for (int i = 1 ; i < r + 1; ++i) {
        ans = ans / i;
    }
    return ans;
}
using namespace std;
/*int main(){
    int n;std::cin >> n;
    int keta=0;
    while(true){
        keta++;
        if(n/10==0)break;
        n=n/10;
    }
    keta=keta-1;
    if(n>=7)n=3;
    else if(n>=5)n=2;
    else if(n>=3)n=1;
    int k=0;
    for(int i=3;i<=keta;i++){
        k+=comb(i-1,2);
        std::cout << k << std::endl;
    }std::cout << k << std::endl;
    k+=n*(keta);
    
    std::cout << k << std::endl;
    
}


*/
int main(){
  int n,b,c;
  std::cin>>n;
  std::cout << (n+1)/2<< std::endl;
}


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

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

int ans = 0;
for(int i = 0; i < N; i++){ 
     int a, b;
     cin >> a >> b;
     ans += (b - a) + 1;
}
cout << ans << endl; 
}

Measured memory_bytes: 384
let split_string ?(pattern="") = Str.split @@ Str.regexp pattern
let n = Scanf.sscanf (read_line ()) "%d" @@ fun n -> n
let s = read_line () |> split_string |> Array.of_list

let west, east = 
  Array.init n (fun i -> if s.(i) = "W" then 1 else 0), 
  Array.init n (fun i -> if s.(i) = "E" then 1 else 0)

let () =  
  let ans = ref max_int in
  for i = 1 to n - 1 do west.(i) <- west.(i) + west.(i - 1) done;
  for i = n - 2 downto 0 do east.(i) <- east.(i) + east.(i + 1) done;
  ans := min east.(1) west.(n - 2);
  for i = 1 to n - 2 do
    ans := min !ans (west.(i - 1) + east.(i + 1))
  done;
  Printf.printf "%d\n" !ans

Measured memory_bytes: 32096
def main():
    n = int(input())
    h = list(map(int, input().split()))
    c = [0]
    for i in range(1, n):
        if i == 1:
            c.append(abs(h[0] - h[1]))
            continue
        step1 = abs(h[i] - h[i-1]) + c[i-1]
        step2 = abs(h[i] - h[i-2]) + c[i-2]
        if step1 < step2:
            c.append(step1)
        else:
            c.append(step2)
    print(c.pop())


if __name__ == "__main__":
    main()


Measured memory_bytes: 54384
#include<bits/stdc++.h>
#define N (1009)
#define LL long long
#define MOD (1000000007)
using namespace std;

struct Edge{int from,to,next;}edge[N<<1];
int n,m,k,u,v,s[N];
int Low[N],DFN[N],Stack[N],ID[N],BCC_num,dfs_num,top;
LL ans=1,fac[N],facinv[N],inv[N];
int head[N],num_edge;
vector<int>E[N],P[N];

void add(int u,int v)
{
	edge[++num_edge].from=u;
	edge[num_edge].to=v;
	edge[num_edge].next=head[u];
	head[u]=num_edge;
}

void Init()
{
	fac[0]=facinv[0]=inv[1]=1;
	for (int i=1; i<=1000; ++i)
	{
		if (i!=1) inv[i]=(MOD-MOD/i)*inv[MOD%i]%MOD;
		fac[i]=fac[i-1]*i%MOD; facinv[i]=facinv[i-1]*inv[i]%MOD;
	}
}

LL gcd(LL a,LL b) {return b==0?a:gcd(b,a%b);}

LL C(LL n,LL m)
{
	if (n<m) return 0;
	return fac[n]*facinv[m]%MOD*facinv[n-m]%MOD;
}

LL Qpow(LL a,LL b)
{
	LL ans=1;
	while (b)
	{
		if (b&1) ans=ans*a%MOD;
		a=a*a%MOD; b>>=1;
	}
	return ans;
}

LL Polya(int n)
{
	LL ans=0;
	for (int i=1; i<=n; ++i) (ans+=Qpow(k,gcd(i,n)))%=MOD;
	return ans*inv[n]%MOD;
}

void Tarjan(int x,int fa)
{
	Low[x]=DFN[x]=++dfs_num;
	for (int i=head[x]; i; i=edge[i].next)
		if (!DFN[edge[i].to])
		{
			Stack[++top]=i;
			Tarjan(edge[i].to,x);
			Low[x]=min(Low[x],Low[edge[i].to]);
			if (Low[edge[i].to]>=DFN[x])
			{
				BCC_num++;
				while (1)
				{
					int now=Stack[top--];
					E[BCC_num].push_back(now);
					if (ID[edge[now].from]!=BCC_num)
					{
						P[BCC_num].push_back(edge[now].from);
						ID[edge[now].from]=BCC_num;
					}
					if (ID[edge[now].to]!=BCC_num)
					{
						P[BCC_num].push_back(edge[now].to);
						ID[edge[now].to]=BCC_num;
					}
					if (edge[now].from==x && edge[now].to==edge[i].to) break;
				}
				int e=0,p=0;
				for (int i=0,s=P[BCC_num].size(); i<s; ++i)
				{
					int x=P[BCC_num][i]; p++;
					for (int j=head[x]; j; j=edge[j].next)
						if (ID[edge[j].to]==BCC_num) e++;
				}
				e/=2;
				if (e==p) (ans*=Polya(e))%=MOD;
				else if (p==2 && e==1) (ans*=k)%=MOD;
				else (ans*=C(e+k-1,k-1))%=MOD;
			}
		}
		else if (edge[i].to!=fa)
			Low[x]=min(Low[x],DFN[edge[i].to]);
}

int main()
{
	Init();
	cin>>n>>m>>k;
	for (int i=1; i<=m; ++i)
		cin>>u>>v, add(u,v), add(v,u);
	for (int i=1; i<=n; ++i)
		if (!DFN[i]) Tarjan(i,0);
	cout<<ans<<endl;
}

Measured memory_bytes: 384
#include <stdio.h>
#include <string.h>

int main(void)
{
    char s[200001], t[200001];
    int count = 0;

    scanf("%s%s", s, t);

    int str_len = strlen(s);

    for (int i=0; i<str_len; i++)
    {
        if (s[i] != t[i]) count++;
    }

    printf("%d\n", count);

    return 0;
}

Measured memory_bytes: 2116
#include <iostream>
#include <iomanip>
#include <cmath>
#include <vector>
#include <queue>
#include <limits>
#include <algorithm>
#include <string>
using namespace std;

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

	vector<int32_t> cnt_min(26);
	fill(begin(cnt_min), end(cnt_min), numeric_limits<int32_t>::max());

	for (int32_t i = 0; i  < n; i++) {
		string S;
		cin >> S;
		vector<int32_t> cnt(26);
		fill(begin(cnt), end(cnt), 0);
		for (size_t j = 0; j  < S.size(); j++) {
			cnt[S[j] - 'a']++;
		}
		for (int32_t j = 0; j  < 26; j++) {
			cnt_min[j] = min(cnt_min[j], cnt[j]);
		}
	}

	for (int32_t i = 0; i  < 26; i++) {
		for (int32_t j = 0; j  < cnt_min[i]; j++) {
			cout << (char)('a' + i);
		}
	}

	cout << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int delta=10139;
int mark[2003][2003];
int prev_in_colum[2003];
int after_in_colum[2003];
int befor_r[2003][2003],befor_c[2003][2003];
int main() {
    int h,w;
    cin>>h>>w;
    for(int i=1;i<=h;i++){
        int prev_in_row=0;
        string s;
        cin>>s;
        for(int j=1;j<=w;j++){
            if(s[j-1]=='#'){
                mark[i][j]=1;
                prev_in_row=j;
                prev_in_colum[j]=i;
            }
            else{
                befor_r[i][j]=prev_in_row;
                befor_c[i][j]=prev_in_colum[j];
            }
        }
    }
    /*
    for(int i=1;i<=h;i++){
        cout<<endl;
        for(int j=1;j<=w;j++){
            cout<<befor_c[i][j];
        }
    }
    cout<<endl;
    */
    int ans=0;
    for(int i=1;i<=w;i++){
        after_in_colum[i]=h+1;
    }
    for(int i=h;i>0;i--){
        int after_in_row=w+1;
        for(int j=w;j>0;j--){
            if(mark[i][j]==1){
                after_in_row=j;
                after_in_colum[j]=i;
                //cout<<"* ";
            }
            else{
                //cout<<after_in_row-befor_r[i][j]+after_in_colum[j]-befor_c[i][j]-3<<' ';
                ans=max(ans,(after_in_row-befor_r[i][j]-1+after_in_colum[j]-befor_c[i][j]-1-1));
            }
        }
        //cout<<endl;
    }
    cout<<ans;
}


Measured memory_bytes: 47232