akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef unsigned int ui;
 
typedef vector<int> vi;
typedef vector<ui> vui;
typedef vector<ll> vll;
typedef vector<ull> vull;
typedef vector<string> vs;
 
typedef vector<vi> vvi;
typedef vector<vui> vvui;
typedef vector<vll> vvll;
typedef vector<vull> vvull;
typedef vector<vs> vvs;
 
typedef string ss;
#define forr(i,b) for(int i = 0; i < b; i++)
#define ford(i,b) for(int i = b; i >= 0; i--)
#define ff for(;;)
 
template<typename T> int sgn(T val) { return (T(0) < val) - (val < T(0)); }
int gcd(int a, int b) { if(a == 0) return b; return gcd(b % a, a); }
int ncr(int n, int k) { int r = 1; if(k > n - k) k = n - k; for(int i=0;i<k;i++) { r *= n - i; r /= i + 1; } return r; }
template<typename T> void printa(vector<T> arr) { for(ui i = 0; i < arr.size(); i++) if(i != arr.size() - 1) cout << arr[i] << ' '; else cout << arr[i] << '\n'; }
 
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);

    string s;
    cin >> s;

    for(char &c:s)
        if(c == 'B')
            c = 'R';
        else if(c == 'R')
            c = 'B';

    printf("%s\n",s.c_str());

    return 0;
}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
#include<math.h>
#include<string.h>
#include<vector>
using namespace std;
#define MAX 100005
#define MOD 998244353
int main()
{
    FILE *input=stdin;
    //input=fopen("in.txt","r");
    int t,T=1;
    //fscanf(input,"%d",&T);
    for(t=1; t<=T; t++)
    {
        long long int X;
        fscanf(input,"%lld",&X);
        long long int ans=(X/500);
        ans=ans*1000;
        X=X%500;
        ans=ans+(X/5)*5;
        printf("%lld",ans);
        if(t!=T) printf("\n");
    }
    fclose(input);
    return 0;
}


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

template <typename T> class union_find {
  vector<T> par, rank;

public:
  union_find(size_t n) {
    par.reserve(n + 1);
    rank.reserve(n + 1);
  }

public:
  void init(T n) { // add a set
    rep(i, 0, n) {
      par[i] = i;
      rank[i] = 0;
    }
  }

public:
  T find(T x) { // find the parent of x
    if (par[x] == x)
      return x;
    else
      return par[x] = find(par[x]);
  }

public:
  void unite(T x, T y) { // unite x and y
    x = find(x);
    y = find(y);
    if (x == y)
      return;
    if (rank[x] < rank[y])
      par[x] = y;
    else
      par[y] = x;
    if (rank[x] == rank[y])
      rank[x]++;
  }

public:
  bool same(T x, T y) { // compare x's parent and y's parent
    return find(x) == find(y);
  }
};

int n, m;
vector<int> s, t;
int q;  
int main() {
 ios::sync_with_stdio ( false );
 cin.tie ( 0 );
    cin >> n >> m;
    union_find<int> uf = union_find<int>(n+1);
    uf.init(n);
    rep(i, 0, m) {
        int a, b;
        cin >> a >> b;
        s.pb(a); t.pb(b);
        uf.unite(a, b);
    }
    cin >> q;
    rep(i, 0, q) {
        int k, l; cin >> k >> l;
        if (uf.same(k, l)) cout << "yes" << endl;
        else cout << "no" << endl;
    }
    return 0;
}


Measured memory_bytes: 4608
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#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 <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 EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#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)
#define loop(n) FOR(i,0,n)
#define rrep(i,a,b) for(int i=(a);i>=(b);--i)
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

int main() {
	int n, y; cin >> n >> y;
	y /= 1000;
	for (int a = 0; a <= n; a++) {
		for (int b = 0; b <= n; b++) {
			int c = n - (a + b);

			if (c < 0) continue;

			int sum = 10 * a + 5 * b + c;

			if (sum == y) {
				cout << a <<" "<< b <<" "<<c<< endl;
				return 0;
			}
			
		}
	}

	cout << -1 <<" "<< -1 <<" "<< -1<<endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int mode = Integer.parseInt(scanner.nextLine());
        if (mode == 1) {
            new Main().helloWorld();
            return;
        }

        int a = Integer.parseInt(scanner.nextLine());
        int b = Integer.parseInt(scanner.nextLine());

        new Main().plus(a, b);
    }

    public void helloWorld() {
        System.out.println("Hello World");
    }

    public void plus(int a, int b) {
        System.out.println(a + b);
    }
}


Measured memory_bytes: 21332
#include <bits/stdc++.h>
using namespace std;
typedef long long  ll;
#define FOR(i,a,n) for(ll i=(ll)a;i<(ll)n;i++)
#define RFOR(i,a,n) for(ll i=(ll)n-1;i >= (ll)a;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,0,n)
#define ALL(v) v.begin(), v.end()
ll MOD = 1000000007;
ll INF = 214748364700000000;
double EPS = 1e-12;
double PI = 3.141592653589793238;
template<typename T>
void remove(std::vector<T>& vector, unsigned int index){
    vector.erase(vector.begin() + index);
}

using Graph = vector<vector<ll>>;

ll H,W,D;
ll table[310][310];
ll d[100000];
pair<ll,ll> MP[100000];

void dijkstra(ll s){
    priority_queue<pair<ll,ll>> Q;
    d[s] = 0;
    Q.emplace(0,s);
    while(Q.size()){
        ll x = Q.top().second;
        Q.pop();
        if(x+D > H*W) continue;
        if(d[x+D] != INF) continue;
        ll cost = d[x+D] = d[x] + abs(MP[x+D].first - MP[x].first) + abs(MP[x+D].second - MP[x].second);
        Q.emplace(-cost,x+D);
    }
}

int main(){
    cin >> H >> W >> D;
    rep(i,H) rep(j,W){
        cin >> table[i][j];
        MP[table[i][j]].first = i;
        MP[table[i][j]].second = j;
    }
    fill(d,d+100000,INF);
    rep(i,D){
        dijkstra(i+1);
    }
    ll Q;cin >> Q;
    vector<ll> ans(Q);
    rep(i,Q){
        ll L,R;cin >> L >> R;
        ans[i] = d[R]-d[L];
    }
    rep(i,Q) cout << ans[i] << endl;
}

Measured memory_bytes: 4864
#include<cstdio>
#include<iostream>
#include<cmath>
#include<cstring>
#include<cstdlib>
#include<algorithm>

using namespace std;

typedef long long ll;
const ll p=998244353;
ll n,a,b,k,ans;
const ll maxn=3e5+10;
ll fac[maxn],inv[maxn];

ll qpow(ll a,ll b){
	ll sum=1;
	while(b){
		if(b&1) sum=sum*a%p;
		a=a*a%p,b>>=1;
	}
	return sum;
}

ll c(ll a,ll b){
	if(b>a) return 0;
	return fac[a]*inv[b]%p*inv[a-b]%p;
}

int main(){
	scanf("%lld%lld%lld%lld",&n,&a,&b,&k);

	if(!k){puts("1");return 0;}

	if(ceil((double)k/(a+b))>n) {puts("0");return 0;}
	fac[0]=1;
	for(ll i=1;i<=n;i++) fac[i]=i*fac[i-1]%p;
	inv[n]=qpow(fac[n],p-2);
	for(ll i=n;i;i--) inv[i-1]=inv[i]*i%p;
	for(ll i=1;i<=n&&a*i<=k;i++){
		ll last=k-a*i;
		if(last%b) continue;
		ll nb=last/b;
		ans=(ans+c(n,i)*c(n,nb)%p)%p;
	}
	printf("%lld",ans);
	return 0;
}


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

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define INF         INT_MAX/3
#define LLINF       LLONG_MAX/3
#define MOD         (1000000007LL)
#define MODA(a, b)  a=((a)+(b))%MOD
#define MODP(a, b)  a=((a)*(b))%MOD
#define inc(i, l, r)   for(int i=(l);i<(r);i++)
#define dec(i, l, r)   for(int i=(r)-1;i>=(l);i--)
#define pb          push_back
#define se          second
#define fi          first
#define mset(a, b)  memset(a, b, sizeof(a))

using LL  = long long;
using G   = vector<vector<int>>;

int di[] = {0, -1, 0, 1};
int dj[] = {1, 0, -1, 0};
// }}}

int main() {
    cin.tie(0);ios::sync_with_stdio(false);
    int n;cin >> n;
    string ss;cin >> ss;
    string s = ss.substr(0, n);
    string t = ss.substr(n, n);reverse(t.begin(), t.end());
    map<pair<string, string>, LL> ms, mt;
    inc(k, 0, 1 << n){
        string s1, s2, t1, t2;
        inc(i, 0, n){
            if(k&(1 << i)){
                s1.pb(s[i]);
                t1.pb(t[i]);
            }else{
                s2.pb(s[i]);
                t2.pb(t[i]);
            }
        }
        ms[pair<string, string>(s1, s2)]++;
        mt[pair<string, string>(t1, t2)]++;
    }
    LL ans = 0;
    for(auto kv : ms){
        //if(mt.find(kv.fi) == mt.end()) continue;
        ans += kv.se*mt[kv.fi];
    }
    cout << ans << endl;
    return 0;
}


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

#include <atcoder/dsu.hpp>

int main() {
    int64_t N, M;
    cin >> N >> M;

    atcoder::dsu d(N);
    for (int64_t i = 0; i < M; i++) {
        int64_t A, B;
        cin >> A >> B;
        A--; B--;
        d.merge(A, B);
    }

    int64_t ans = 0;
    int64_t root = d.leader(0);
    for (int64_t i = 1; i < N; i++) {
        if (!d.same(i, root)) {
            ans++;
            d.merge(i, root);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3788
import java.util.Scanner;

public class Main{
    public static void main(String args[]){
	Scanner in =new Scanner(System.in);

	int n = in.nextInt();
	int m = in.nextInt();
       
	int[][] A = new int[n][m];
	int[] B = new int[m];
	int[] C = new int[n];
	
	for(int i=0; i<n;i++){
	    for(int j=0;j<m;j++){
		A[i][j]=in.nextInt();
	    }
	}
	for(int j=0;j<m;j++){
	    B[j]=in.nextInt();
	}

	for(int i=0; i<n;i++){
	    for(int j=0;j<m;j++){
		C[i]+=A[i][j]*B[j];
	    }
	}

	for(int i=0; i<n;i++){
	    System.out.println(C[i]);
	}
    }
}


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

int main(){
  int a,b,m;
  cin >> a >> b >> m;
  vector<int> A(a);
  vector<int> B(b);
  for (int i=0; i<a; i++) cin >> A[i];
  for(int j=0; j<b; j++) cin >> B[j];
  int ans = 0;
  int minA = *min_element(A.begin(), A.end());
  int minB = *min_element(B.begin(), B.end());
  ans = minA+minB;
  for(int k=0; k<m; k++){
    int a_ind,b_ind,c;
    cin >> a_ind >> b_ind >> c;
    int tmp;
    tmp = A[a_ind-1]+B[b_ind-1]-c;
    ans = min(ans,tmp);
  }  
  cout << ans << endl;
}

Measured memory_bytes: 1024
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using static System.Math;
 
public class Hello{
    public static void Main(){
        string[] reader = ReadLine().Split(' ');
        int placenum = int.Parse(reader[0]);
        int canjump = int.Parse(reader[1]);
        string[] coststr = ReadLine().Split(' ');

        int[] cost = new int[placenum];
        for(int i=0;i<placenum;i++){
            cost[i] = int.Parse(coststr[i]);
        }
        
        int[] dp = new int[placenum+10];
        
        for(int i=1;i<placenum;i++){
            dp[i] = 999999999;
            for(int j=1;j<=canjump && j<=i;j++){
                dp[i] = Min(dp[i],dp[i-j] + Abs(cost[i] - cost[i-j]));
            }
        }
        /*for(int i=1;i<placenum;i++){
            Write(dp[i]);
            Write(" ");
        }
        WriteLine();*/
        WriteLine(dp[placenum-1]);
    }
}

Measured memory_bytes: 19168
a, b = map(int, input().split())

def F(n):
    a = n//2
    if n % 2 == 0:
        if a % 2 == 0:
            return n
        else:
            return n ^ 1
    else:
        if a % 2 == 0:
            return 1
        else:
            return 0

ans = F(a-1) ^ F(b)
print(ans)


Measured memory_bytes: 9060
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long LL;
typedef long double ld;
typedef vector<ll>VI;
typedef pair<ll,ll>P;
#define VV(T) vector<vector<T>>
#define sz(x) int(x.size())
#define PI 3.1415926535897932384626433832795
#define rep(i, n) for (ll i = 0; i < (ll)n; i++)
#define ALL(a)  (a).begin(),(a).end()
#define c_max(a, b) (((ll)a)>((ll)b)?(a):(b))
#define c_min(a,b) (((ll)a)<((ll)b)?(a):(b))
#define chmax(x,a) x=max(x,a)
#define chmin(x,a) x=min(x,a)
#define vmax(v) *max_element(ALL(v))
#define vmin(v) *min_element(ALL(v))
#define $(x) {cout<<#x<<" = " <<(x)<<endl;}
#define fi first
#define se second
#define MAX 100100//5
#define MAX2 200100
#define MAX_6 1001001//6
#define MAX_7 10010010//7
#define SENTINEL 2000000000//9
const int MOD = 1000000007;
#define INF 1<<30
#define INFTY 1LL<<61
#define MAX_INT INT_MAX
#define Endl '\n'
#define CLR(mat) memset(mat, 0, sizeof(mat))
inline ll GCD(ll a,ll b){return b?GCD(b,a%b):a;}
inline ll lcm(ll a,ll b){return a*b/GCD(a,b);}
template<class T> bool contain(const std::string& s, const T& v) {
   return s.find(v) != std::string::npos;
}
using Edge=pair<int,ll>;
using Graph=vector<vector<ll> >;//ll or Edge
//const int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
// sort_reverse -> greater<long long>()
// vector型から重複を削除 list.erase(unique(ALL(list)),list.end());
// g++ -o a a.cpp -Wall -lm -std=c++17
//push_back -> emplace_back
struct UnionFind {
    vector<int> par;
    
    UnionFind(int n) : par(n, -1) { }

    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }
    
    bool issame(int x, int y) {
        return root(x) == root(y);
    }
    
    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }
    
    int size(int x) {
        return -par[root(x)];
    }
};
int main(){
   int n,m;cin>>n>>m;
   UnionFind U(n);
   rep(i,m){
      int a,b;cin>>a>>b;
      a--;b--;
      U.merge(a,b);
   }
   int ans=0;
   rep(i,n){
      chmax(ans,U.size(i));
   }
   cout<<ans<<endl;
}

Measured memory_bytes: 4048
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(void){
    int n;
    cin >> n;
    vector<int> p(n);
    for (int i = 0; i < n; i++)
        cin >> p[i];
    
    int m_p = p[0];
    int ans = 1;
    for (int i = 1; i < n; i++) {
        if (p[i] < m_p) {
            ans++;
            m_p = p[i];
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
// ! 選択ソート

// ==========
// 入力例
// ==========
// 6
// 5 6 4 2 1 3

// ==========
// 出力例
// ==========
// 1 2 3 4 5 6
// 4
#include <iostream>
using namespace std;

int main()
{
  int n;

  cin >> n;

  int R[n];

  for (int i = 0; i < n; i++)
  {
    cin >> R[i];
  }

  int swapCount = 0;
  int minValueIndex;
  for (int k = 0; k < n - 1; k++)
  {
    minValueIndex = k;
    for (int j = k; j < n - 1; j++)
    {
      if (R[minValueIndex] > R[j + 1])
      {
        minValueIndex = j + 1;
      }
    }
    if (minValueIndex != k)
    {
      swap(R[k], R[minValueIndex]);
      swapCount++;
    }
  }

  for (int i = 0; i < n; i++)
  {
    cout << R[i];
    if (i == n - 1)
    {
      cout << endl;
    }
    else
    {
      cout << ' ';
    }
  }
  cout << swapCount << endl;

  return 0;
}


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

#define forn(i,n) for(int i=0;i<(int)(n);i++)
#define si(c) ((int)(c).size())
#define forsn(i,s,n) for(int i = (int)(s); i<((int)n); i++)
#define dforsn(i,s,n) for(int i = (int)(n)-1; i>=((int)s); i--)
#define all(c) (c).begin(), (c).end()
#define D(a) cerr << #a << "=" << a << endl;
#define pb push_back
#define eb emplace_back
#define mp make_pair

typedef long long int ll;
typedef vector<int> vi;
typedef pair<int,int> pii;

ll ceil(ll a, ll b) { return (a+b-1) / b; }

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

    int n; cin >> n;
    ll a = 1, b = 1;
    while (n--) {
        ll x,y; cin >> x >> y;
        ll k = max(ceil(a,x), ceil(b,y));
        a = k*x; b = k*y;
    }
    cout << a+b << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cmath>
using namespace std;
int main()
{
	int n,m,k,f=1;
	scanf("%d %d %d",&n,&m,&k);
	for(int j=0;j<=n;j++)
	{
		for(int i=0;i<=m;i++)
		{
			int x=j*m+i*n-2*i*j;
			//printf("%d\n",x);
			if(x==k)
			{
				f=0;
				printf("Yes\n");break;
			}
		}
		if(f==0)break;
	}
	if(f)printf("No\n");
	return 0;
}


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

using namespace std;
using ll = long long;
#define int ll
using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define PB push_back

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const int MOD = 1000000007;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template <typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }
template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
  out<<'('<<a.first<<','<<a.second<<')';
  return out;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
  out<<'[';
  REP(i, a.size()) {out<<a[i];if(i!=a.size()-1)out<<',';}
  out<<']';
  return out;
}

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

const double EPS = 1e-8;

using R = long double;
using P = complex<R>;
using L = pair<P,P>;

inline int sgn(const R& r) { return (r>EPS) - (r<-EPS); }
namespace std {
	bool operator < (const P& a, const P& b) {
		return sgn(real(a-b)) ? real(a-b) < 0 : sgn(imag(a-b)) < 0;
	}
	bool operator == (const P& a, const P& b) {
		return sgn(real(a-b)) == 0 && sgn(imag(a-b)) == 0;
	}
}
inline R dot(const P& a, const P& b) {
  return real(a)*real(b) + imag(a)*imag(b);
}
inline R det(const P& a, const P& b) {
  return real(a)*imag(b) - imag(a)*real(b);
}
// a/b
inline P div(const P &a, const P &b) {
  return {dot(b,a)/norm(b), det(b,a)/norm(b)};
}

// PとLについて入力
inline istream& operator>>(istream& is, P& p) {
  R x, y;
  is >> x >> y;
  p = P(x, y);
  return is;
}
inline istream& operator>>(istream& is, L& l) {
  P a, b;
  is >> a >> b;
  l = L(a, b);
  return is;
}

// 線分abから見たcの位置
enum CCW{LEFT=1, RIGHT=2, BACK=4, FRONT=8, ON=16};
int ccw(P a, P b, P c) {
	P p = div(c-a, b-a);
	if(sgn(imag(p)) > 0) return LEFT;
	if(sgn(imag(p)) < 0) return RIGHT;
	if(sgn(real(p)) < 0) return BACK;
	if(sgn(real(p)-1) > 0) return FRONT;
	return ON;
}

P projection(const L &l, const P &p) {
	R t = dot(p-l.first, l.first-l.second) / norm(l.first-l.second);
	return l.first + t*(l.first-l.second);
}
// 反射
P reflection(const L &l, const P &p) {
	return p + (R)2 * (projection(l, p) - p);
}

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

  L l;
  cin >> l;
  int q;
  cin >> q;
  REP(i, q) {
    P p;
    cin >> p;
    P ret = reflection(l, p);
    cout << fixed << setprecision(9) << real(ret) << " " << imag(ret) << endl;
  }

  return 0;
}



Measured memory_bytes: 3376
#include <stdio.h>

int main (void){
  int x;
  scanf("%d",&x);
  x = x%10;
  if(x == 3){
    printf("bon");
  }else if(x == 0 || x ==1 || x == 6 || x ==8){
    printf("pon");
  }else{
    printf("hon");
  }
  return (0);
  }


Measured memory_bytes: 1736
import collections

n = int(input())
ws = [input().strip() for _ in range(n)]

counter = collections.Counter()
ok = True
prev = ws[0][0]
for w in ws:
    counter[w] += 1
    if counter[w] > 1 or w[0] != prev:
        ok = False
        break
    prev = w[-1]
if ok:
    print('Yes')
else:
    print('No')

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

int main() {
    int a, b, c, d, e, k;
    cin >> a >> b >> c >> d >> e >> k;

    if (e - a > k) {
      cout << ":(" << endl;
    } else if (d - a > k) {
      cout << ":(" << endl;
    } else if (d - a > k) {
      cout << ":(" << endl;
    } else if (c - a > k) {
      cout << ":(" << endl;
    } else if (b - a > k) {
      cout << ":(" << endl;
    } else {
      cout << "Yay!" << endl;
    }
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;

namespace Program
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] a = Input.ScanIntArray();
            int N = a[0];
            int Q = a[1];
            Node[] Nodes = new Node[N];
            for (int i = 0; i < N; i++) { Nodes[i] = new Node(); }
            for (int i = 0; i < N-1; i++)
            {
                a = Input.ScanIntArray();
                Nodes[a[0]-1].Child.Add(Nodes[a[1]-1]);
            }
            for(int i=0; i<Q; i++){
                a = Input.ScanIntArray();
                Nodes[a[0]-1].AddCount(a[1]);
            }

            Console.Write($"{Nodes[0].GetCount()}");
            for(int i=1;i<N; i++){
                Console.Write($" {Nodes[i].GetCount()}");
            }
            Console.WriteLine();
        }

        class Node
        {
            private long Count = 0;
            public List<Node> Child = new List<Node>();

            public long GetCount(){
                foreach(var c in Child){
                    c.AddCount(Count);
                }
                return Count;
            }
            public void AddCount(long value){
                Count+= value;
            }

            public Node(){}
        }

        static class Input {
            static public int ScanInt() { return int.Parse(Console.ReadLine()); }
            static public long ScanLong() { return long.Parse(Console.ReadLine()); }
            static public int[] ScanIntArray() { return Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray(); }
            static public long[] ScanLongArray() { return Console.ReadLine().Split().Select(x => long.Parse(x)).ToArray(); }
        }
    }
}


Measured memory_bytes: 46392
def main():
    h, w = input().split()
    h = int(h)
    w = int(w)

    lst =[]
    for i in range(h):
        tmp = input()
        lst.append(list(tmp))

    flag = False

    for i in range(len(lst)):
        if flag:
            break

        for j in range(len(lst[i])):
            if lst[i][j] == "#":
                if j != w - 1:
                    if lst[i][j+1] == "#":
                        continue

                if j != 0:
                    if lst[i][j-1] == '#':
                        continue

                if i != 0:
                    if lst[i-1][j] == '#':
                        continue

                if i != h -1:
                    if lst[i+1][j] == '#':
                        continue

                print("No")
                flag = True
                break

    if flag == False:
        print("Yes")

if __name__ == "__main__":
        main()


Measured memory_bytes: 3064
n=input()
n=list(n)
if n[0]=='1':
    n[0]='9'
elif n[0]=='9':
    n[0]='1'
if n[1]=='1':
    n[1]='9'
elif n[1]=='9':
    n[1]='1'
if n[2]=='1':
    n[2]='9'
elif n[2]=='9':
    n[2]='1'
ans=int("".join(n))
print(ans)

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

int main() {
    string str;
    cin >> str;
    int q;
    cin >> q;
    
    for(int i = 0; i < q; i++) {
        string order;
        cin >> order;
        
        int a, b;
        cin >> a >> b;
        if(order == "reverse") {
            string Temp;
            for(int i = a; i <= b; i++) {
                Temp[i] = str[i];
            }
            for(int i = a; i <= b; i++) {
                str[a + b - i] = Temp[i];
            }
        }
        if(order == "replace") {
            string p;
            cin >> p;
            str.replace(a, b - a + 1, p);
        }
        if(order == "print") {
            for(int i = a; i <= b; i++) {
                cout << str[i];
            }
            cout << endl;
        }
    }
}


Measured memory_bytes: 3224
import java.util.Scanner;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		while (true) {
			int a = sc.nextInt();
			int b = sc.nextInt();
			if (a == 0 && b == 0) break;
			printFrame(a, b);
			System.out.println();
		}
		sc.close();
	}
	static void printFrame (int h, int w) {
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				System.out.print((i + j) % 2 == 0 ? "#" : ".");
			}
			System.out.println();
		}
	}
}

Measured memory_bytes: 34656
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repf(i, a, b) for(ll i = (a); i < (b) ; i++ )
const ll mo = 1000000007;
const ll INF = 1LL << 60; //MAX 9223372036854775807
ll ans = 0;
set<ll> G[100000];
set<ll> H[100000];

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

rep(i, n)
{
    ll a,b;
    cin >> a>>b;
    G[a-1].insert(b-1);
    H[b-1].insert(a-1);
}
queue<ll> qx;
queue<ll> qy;
set<ll> x,y;
rep(i,100000){
    
    if(G[i].size()!=0){
        ll si=G[i].size();
        rep(j,si){
            ll itre=*G[i].begin();
            qy.push(itre);
            G[i].erase(itre);
            H[itre].erase(i);
            x.insert(i);
            y.insert(itre);
        }
    }
    while(!qx.empty()||!qy.empty()){
        if(!qy.empty()){
            ll qyy= qy.front();
            qy.pop();
            ll si=H[qyy].size();
            rep(j,si){
                ll itre=*H[qyy].begin();
                qx.push(itre);
                G[itre].erase(qyy);
                H[qyy].erase(itre);
                x.insert(itre);
                y.insert(qyy);
            }
        }
        if(!qx.empty()){
            ll qxx= qx.front();
            qx.pop();
            ll si=G[qxx].size();
            rep(j,si){
                ll itre=*G[qxx].begin();
                qy.push(itre);
                H[itre].erase(qxx);
                G[qxx].erase(itre);
                y.insert(itre);
                x.insert(qxx);
            }
        }
    }
    ans+=x.size()*y.size();
    x.clear();
    y.clear();
}


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

Measured memory_bytes: 19456
#define DEB
#include<bits/stdc++.h>
#define REP(i,m) for(int i=0;i<(m);++i)
#define REPN(i,m,in) for(int i=(in);i<(m);++i)
#define ALL(t) (t).begin(),(t).end()
#define CLR(a) memset((a),0,sizeof(a))
#define pb push_back
#define mp make_pair
#define fr first
#define sc second

using namespace std;


#ifdef DEB
#define dump(x)  cerr << #x << " = " << (x) << endl
#define prl cerr<<"called:"<< __LINE__<<endl
#define dumpR(x) cerr<<"\x1b[31m"<<#x<<" = " <<(x)<<"\x1b[39m"<<endl
#define dumpY(x) cerr<<"\x1b[33m"<<#x<<" = " <<(x)<<"\x1b[39m"<<endl
#define dumpG(x) cerr<<"\x1b[32m"<<#x<<" = " <<(x)<<"\x1b[39m"<<endl
template<class T> void debug(T a,T b){ for(;a!=b;++a) cerr<<*a<<' ';cerr<<endl;}
#else
#define dump(x) ;
#define dumpR(x) ;
#define dumpY(x) ;
#define dumpG(x) ;
#define prl ;
template<class T> void debug(T a,T b){ ;}
#endif

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

typedef long long int lint;
typedef pair<int,int> pi;

namespace std{
  template<class S,class T>
  ostream &operator <<(ostream& out,const pair<S,T>& a){
    out<<'('<<a.fr<<','<<a.sc<<')';
    return out;
  }
}

//const int INF=5e8;
int h,w;
char buf[105][105];
int dp[5505][5505];

pi itop[5505];
int ptoi[105][105];

int rsum[105][105];
int csum[105][105];
int getr(int y,int r,int l){
  if(l>=r) return 0;
  return rsum[y][r]-rsum[y][l];
}
int getc(int x,int b,int t){
  if(t>=b) return 0;
  return csum[x][b]-csum[x][t];
}
void renew(int y1,int y2,int x1,int x2,int a){
  chmax(dp[ptoi[y1][y2]][ptoi[x1][x2]],a);
}
int main(){
  int cnt=0;
  REP(i,100){
    REPN(j,101,i+1){
      itop[cnt]=mp(i,j);
      ptoi[i][j]=cnt;
      ++cnt;
    }
  }

  cin>>h>>w;
  int gx,gy;
  REP(i,h){
    scanf("%s",buf[i]);
    REP(j,w) if(buf[i][j]=='E'){
      gx=j;
      gy=i;
    }
  }
  REP(i,h) REP(j,w) rsum[i][j+1]=rsum[i][j]+(buf[i][j]=='o'?1:0);
  REP(i,w) REP(j,h) csum[i][j+1]=csum[i][j]+(buf[j][i]=='o'?1:0);

  memset(dp,-1,sizeof(dp));
  renew(gy,gy+1,gx,gx+1,0);

  int res=0;
  for(int len1=1;len1<=h;++len1) for(int len2=1;len2<=w;len2++){
    REP(i1,h+1-len1) REP(j1,w+1-len2){
      int i2=i1+len1,j2=j1+len2;
      
      int idx1=ptoi[i1][i2],idx2=ptoi[j1][j2];
      int val=dp[idx1][idx2];
      if(~val){
        chmax(res,val);
        int top=i2-(gy+1),bot=h-(gy-i1),left=j2-(gx+1),right=w-(gx-j1);//[left...right)
        if(i2<bot){
          renew(i1,i2+1,j1,j2,val+getr(i2,min(right,j2),max(left,j1)));
        }
        if(i1>top){
          renew(i1-1,i2,j1,j2,val+getr(i1-1,min(right,j2),max(left,j1)));
        }
        if(j2<right){
          renew(i1,i2,j1,j2+1,val+getc(j2,min(bot,i2),max(top,i1)));
        }
        if(j1>left){
          renew(i1,i2,j1-1,j2,val+getc(j1-1,min(bot,i2),max(top,i1)));
        }
      }
    }
  }
  cout<<res<<endl;

  return 0;
}





Measured memory_bytes: 118912
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc.Split(bufio.ScanWords)

	n := nextInt()
	d := nextInt()

	if n <= (2*d + 1) {
		fmt.Println(1)
		return
	}

	if n%(2*d+1) == 0 {
		fmt.Println(n / (2*d + 1))
		return
	} else {
		fmt.Println(1 + n/(2*d+1))
		return
	}

}

// ---- readfunc
func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}
func nextStr() string {
	sc.Scan()
	return sc.Text()
}


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

typedef unsigned long long ull;

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

    vector<int> b;
    vector<int> a(n, 0);

    for (int i = 0; i < n-1; i++)
    {
        cin >> bi;
        b.push_back(bi);
    }

    for (int i = 0; i < n-1; i++)
    {
        if (i == 0)
        {
            a[i] = a[i+1] = b[i];
        }
        else
        {
            if (b[i] < a[i])
            {
                a[i] = a[i+1] = b[i];
            }
            else
            {
                a[i+1] = b[i];
            }
        }
    }
    
    cout << accumulate(a.begin(), a.end(), 0) << endl;

    return 0;
}


Measured memory_bytes: 256
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 ans = 0;
        for (int i = 0; i < 2; i++) {
            if(a > b){
                ans += a;
                a--;
            }else{
                ans += b;
                b--;
            }
        }
        System.out.println(ans);
        sc.close();

    }

}


Measured memory_bytes: 23636
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
typedef long long LL;

const int MAX_N=100005;
int n;
int a[MAX_N],d[MAX_N];

int main()
{
	while(cin>>n){
		for(int i=1;i<=n;++i)
			cin>>a[i];
		sort(a+1,a+n+1);
		LL ans=a[n]-a[1]+a[n-1]-a[1];
		int t=n/2;
		for(int i=2,r=n;i<t;r--,++i)
			ans+=a[r]-a[i]+a[r-2]-a[i];
		if(n==3){
			ans=a[3]-a[1]+max(a[3]-a[2],a[2]-a[1]);
		}else	if(n==4){
			ans+=a[n]-a[t];
		}else	if(n>4){
			if(n%2){
				ans+=a[t+3]-a[t];
				ans+=max(a[t+1]-a[t],a[t+2]-a[t+1]);
			}else	ans+=a[t+2]-a[t];
		}
		cout<<ans<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 640
#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <map>
#include <list>
#include <set>
#include <numeric>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <climits>
#include <cfloat>
#include <ctime>
#include <complex>
#include <cassert>
#include <array>
#include <bitset> 
#include <unordered_map>

using namespace std;
typedef long long LL;
typedef pair<int,int> P;

int main() {
	int N;
	cin >> N;
	vector<P> ret;
	if(N%2)
	{
		for(int i=1;i<N;i++)
		{
			ret.push_back(P(i,N));
		}
		for(int i=1;i<N;i++)
		{
			for(int j=i+1;j<N;j++)
			{
				if(i+j!=N){
					ret.push_back(P(i,j));
				}
			}
		}
	}
	else
	{
		for(int i=1;i<=N;i++)
		{
			for(int j=i+1;j<=N;j++)
			{
				if(i+j!=N+1){
					ret.push_back(P(i,j));
				}
			}
		}
	}
	cout << ret.size() << endl;
	for(auto p:ret)
	{
		cout << p.first << " " << p.second << endl;
	}

	return 0;
}



Measured memory_bytes: 384
#include<bits/stdc++.h>
#define pb push_back
#define fr first
#define sc second
#define all(x) x.begin(), x.end()
#define skip continue
#define NAME "code"
#define tabs(a, b) ((a<b) ? (b-a) : (a-b))
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
 
void faster(){
   	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}
 
const ull INF = 1e9;
const ll MOD = 1e9 + 7;
const ll MAXN = 3e5 + 123;
const ld EPS = 1e-12;
const int dx[4] = {-1, 0, 0, 1};
const int dy[4] = {0, -1, 1, 0};
 
ll n, sum, a[MAXN];
 
void solve(){
	cin >> n;
 
	for(int i = 0; i < n; ++i){
		cin >> a[i];
		sum += a[i];
	}
 
	if(sum % (n * (n + 1) / 2) != 0){
		cout << "NO\n";
		return;
	}
 
	ll k = sum / (n * (n + 1) / 2);
 
	for(int i = 0; i < n; ++i){
		if((k - (a[(i + 1) % n] - a[i])) % n != 0 || (k - (a[(i + 1) % n] - a[i])) < 0){
			cout << "NO\n";
			return;
		}
	}
 
	cout << "YES\n";
}
 
int main(){
 
	faster();
 
	int T = 1;
	// cin >> T;
	
	while(T--){
		solve();
	}
 
	return 0;
}

Measured memory_bytes: 1024
a,b,c,d=map(int,input().split())
x=[]
x.append(max(a,b)*max(c,d))
x.append(max(a,b)*min(c,d))
x.append(min(a,b)*max(c,d))
x.append(min(a,b)*min(c,d))
print(max(x))

Measured memory_bytes: 61660
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <numeric>
#include <iostream>

using namespace std;

#define FOR(i, a, b)   for(int i = (a); i < (b); ++i)
#define RFOR(i, a, b)  for(int i = (a); i > (b); --i)
#define rep(i, n)      for(int i = 0; i < (n); ++i)
#define all(c)         begin(c), end(c)
#define rall(c)        rbegin(c), rend(c)
#define SZ(a)          ((ll) a.size())

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

int main() {
	string S;
	cin >> S;
	int w;
	cin >> w;
	int i=0;
	while(i<SZ(S)){
		cout << S[i];
		i+=w;
	}
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#define mod 1000000007

int main(void){
  int N;
  scanf("%d",&N);

  long long ans = 1;
  for(int i = 1;i <= N;i++){
    ans *= i;
    ans %= mod;
  }

  printf("%lld\n",ans);   

  return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(){
  int x;
  char s[200];
  signed long long stack[200];
  int esp = 0;

  while( scanf("%s", s) != EOF ){
    if ( s[0] == '+' ){
      esp--;
      stack[esp - 1] += stack[esp];
    } else if ( s[0] == '-' ){
      esp--;
      stack[esp - 1] -= stack[esp];
    } else if ( s[0] == '*' ){
      esp--;
      stack[esp - 1] *= stack[esp];
    } else {
      x = atoi(s);
      stack[esp] = x;
      esp++;
    }
  }

  printf("%lld\n", stack[0]);

  return 0;
}

Measured memory_bytes: 548
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstring>
#include <cstdio>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map> //pair is also included in this library
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

#define REP(i, s, n) for(int i = (int)(s); i < (int)(n); i++)
#define fst first
#define snd second
#define MP make_pair //incase c++11 or later is not available

using namespace std;

typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

//prefer define statement
//for reason that const int ver. of INF will raise a silly warning (unused variable)
#define INF (INT_MAX/3)
#define LIM_INF (INT_MAX)
//const int INF = INT_MAX/3;
#define PI = 3.14159265358979323846
/*------------------------------------------------------------------------------*/

bool comp_pic(const vector<vector<char>>& A, const vector<vector<char>>& B, int offsetY, int offsetX){
  bool ans = true;

  REP(i, 0, (int)B.size()){
    REP(j, 0, (int)B.size()){
      if(A[i+offsetY][j+offsetX] != B[i][j]){
        ans = false;
        break;
      }
    }
  }
  return ans;
}

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

  vector<vector<char>> A(N, vector<char>(N));
  vector<vector<char>> B(M, vector<char>(M));

  REP(i, 0, N){
    REP(j, 0, N){
      cin >> A[i][j];
    }
  }
  REP(i, 0, M){
    REP(j, 0, M){
      cin >> B[i][j];
    }
  }
  int offset = N - M;

  bool ans = false;
  REP(i, 0, offset+1){
    REP(j, 0, offset+1){
      if(comp_pic(A, B, i, j)){
        ans = true;
      }
    }
  }
  if(ans){
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations

sys.setrecursionlimit(100000)


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap



@mt
def slv(H, W, D, A, Q, LR):
    S = [0] * (H * W + 1)
    A_ = {}
    for i, r in enumerate(A):
        for j, c in enumerate(r):
            A_[c] = (i, j)
    
    for i in range(D+1, H*W+1):
        S[i] = S[i-D] + abs(A_[i][0]-A_[i-D][0]) + abs(A_[i][1]-A_[i-D][1])
    
    for l, r in LR:
        # print(H, W, r, l)
        print(S[r]-S[l])
    



def main():
    H, W, D = read_int_n()
    A = [read_int_n() for _ in range(H)]
    Q = read_int()
    LR = [read_int_n() for _ in range(Q)]
    slv(H, W, D, A, Q, LR)


if __name__ == '__main__':
    main()


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

typedef long long ll;

ll p = 1e9 + 7;
ll fact[2020];
ll inv[2020];
ll fact_inv[2020];

void get_arr(void)
{
	fact[1] = inv[1] = fact_inv[1] = 1;
	
	for (ll i = 2; i < 2000; i++)
	{
		fact[i] = fact[i - 1] * i % p;
		inv[i] = p - inv[p % i] * (p / i) % p;
		fact_inv[i] = fact_inv[i - 1] * inv[i] % p;
	}
}

ll binom(ll a, ll b)
{
	if (b == 0 || b == a) return 1;
	
	ll ans = fact[a];
	ans = (ans * fact_inv[b]) % p;
	ans = (ans * fact_inv[a - b]) % p;
	return ans;
}


int main() {
	ll s;
	scanf("%lld", &s);
	
	get_arr();
	ll ans = 0;
	for (ll n = 1; n <= s / 3; n++)
	{
		ans += binom(s - 2 * n - 1, n - 1);
		ans %= p;
	}
	printf("%lld", ans);
	return 0;
}


Measured memory_bytes: 1776
#include <iostream>

int main()
{
	int a, b;
	std::cin >> a;
	std::cin >> b;
	if (a < b) {
		int x = a;
		a = b;
		b = x;
	}
	if (a > b) {
		a = a + a - 1;
	}
	else {
		a = a + a;
	}
    std::cout << a; 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef pair<int, int> P;
typedef long long ll;
int main()
{
    string n;
    cin >> n;
    for (int i = 0; i < 8; i++)
    {
        int res = n[0] - '0';
        for (int j = 0; j < 3; j++)
        {
            if (i & (1 << j))
            {
                res += n[j + 1] - '0';
            }
            else
            {
                res -= n[j + 1] - '0';
            }
        }
        if (res == 7)
        {
            string ans = "";
            ans.push_back(n[0]);
            for (int j = 0; j < 3; j++)
            {
                if (i & (1 << j))
                {
                    ans.push_back('+');
                }
                else
                {
                    ans.push_back('-');
                }
                ans.push_back(n[j + 1]);
            }
            cout << ans << "=7" << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 256
n, m = map(int, input().split())
graph = {i: [] for i in range(1, n + 1)}
for _ in range(m):
    u, v = map(int, input().split())
    graph[u].append(v)
    graph[v].append(u)

import queue
voi = [100] * (n + 1)
tf = [False] * (n + 1)
def bfs(v):
    q = queue.Queue()
    q.put(v)
    tf[v] = True
    voi[v] = 0
    while not q.empty():
        now = q.get()
        for nex in graph[now]:
            if tf[nex]:
                continue
            q.put(nex)
            voi[nex] = voi[now] + 1
            tf[nex] = True

bfs(1)
if voi[n] <= 2:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

Measured memory_bytes: 59744
N,M=map(int,input().split())
H=list(map(int,input().split()))
A=[0]*M
B=[0]*M
ans=[1 for _ in range(N)]

for i in range(M):
  A[i],B[i] = map(int,input().split())
  if H[A[i]-1]<H[B[i]-1]:
    ans[A[i]-1]=0
  elif H[A[i]-1]>H[B[i]-1]:
    ans[B[i]-1]=0
  else:
    ans[A[i]-1]=0
    ans[B[i]-1]=0
  
#print(ans)
print(sum(ans))

Measured memory_bytes: 21596
open Printf
open Scanf

let map2 f a1 a2 = Array.of_list (List.map2 f (Array.to_list a1) (Array.to_list a2))

let count (s1, s2) =
  let count_array s =
    let toi x = int_of_char x - int_of_char 'a' in
    let a = Array.make (toi 'z' + 1) 0 in
    String.iter (fun x -> a.(toi x) <- 1) s;
    a in
  let a1 = count_array s1 in
  let a2 = count_array s2 in
  let b = map2 (fun a b ->
      match (a, b) with
      | (1, 1) -> 1
      | _ -> 0
    ) a1 a2 in
  Array.fold_left (+) 0 b

let split_string s i length =
  let s1 = String.sub s 0 i in
  let s2 = String.sub s i (length - i) in
  (s1, s2)

let main =
  let (length, s) = scanf "%d\n%s" (fun a b -> (a, b)) in
  let rec iter i v =
    match i with
    | i when i = length -> v
    | i -> iter (i + 1) (max (count (split_string s i length)) v)
  in printf "%d\n" (iter 2 (count (split_string s 1 length)))




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

typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pair<int, int> > vii;
#define rrep(i, m, n) for(int (i)=(m); (i)<(n);  (i)++)
#define erep(i, m, n) for(int (i)=(m); (i)<=(n); (i)++)
#define  rep(i, n)    for(int (i)=0; (i)<(n);  (i)++)
#define rrev(i, m, n) for(int (i)=(n)-1; (i)>=(m); (i)--)
#define erev(i, m, n) for(int (i)=(n); (i)>=(m); (i)--)
#define  rev(i, n)    for(int (i)=(n)-1; (i)>=0; (i)--)
#define vrep(i, c)    for(__typeof((c).begin())i=(c).begin(); i!=(c).end(); i++)
#define  ALL(v)       (v).begin(), (v).end()
#define mp            make_pair
#define pb            push_back
template<class T, class S> inline bool minup(T& m, S x){ return m>(T)x ? (m=(T)x, true) : false; }
template<class T, class S> inline bool maxup(T& m, S x){ return m<(T)x ? (m=(T)x, true) : false; }

const int    INF = 1000000000;
const ll     MOD = 1000000007LL;
const double EPS = 1E-12;

template<typename T> T add(T x, T y){ if(abs(x+y) < EPS*(abs(x)+abs(y))) return 0; return x + y; }
template<typename T> inline bool semieq(T x, T y){ return abs(x - y) < EPS; }
template<typename T> inline bool semige(T x, T y){ return y - x < -EPS; }
template<typename T> inline bool semile(T x, T y){ return x - y < -EPS; }


struct Point : public complex<double>
{
public:
  Point() { this->real(0);  this->imag(0); }
  Point(const double& x, const double& y) { this->real(x);  this->imag(y); }
  Point(const complex<double> w)  { this->real(w.real());  this->imag(w.imag()); }
  inline double dot(Point p){ return (conj(*this) * p).real(); }  // ??????
  inline double det(Point p){ return (conj(*this) * p).imag(); }  // ??????
};

namespace std
{
  bool operator < (const Point& a, const Point& b)
  {
    return real(a) != real(b) ? real(a) < real(b) : imag(a) < imag(b);
  }
}
typedef vector<Point> Polygon;
#define currPoint(P, i) P[i]
#define nextPoint(P, i) P[(i+1)%P.size()]

struct Circle : Point
{
private:
  Point p;
  double r;

public:
  Circle(Point& p, double r) : p(p), r(r) {}
  Circle(double x, double y, double r) : p(Point(x, y)), r(r) {}
  inline Point center(){ return this->p; }
  inline double radius(){ return this->r; }
};

int circlesIntersection(Circle& A, Circle& B)
{
  double d = abs(A.center() - B.center());
  if(semile(d, A.radius() - B.radius())) return  1;  // B in A
  if(semile(d, B.radius() - A.radius())) return -1;  // A in B
  if(semieq(d, A.radius() - B.radius())) return  2;  // B in A????????\???
  if(semieq(d, B.radius() - A.radius())) return -2;  // A in B????????\???
  if(semige(d, A.radius() + B.radius())) return  3;  // ???????????????
  if(semieq(d, A.radius() + B.radius())) return -3;  // ?????\
  return 4;  // ????????£?????????
}

int n;
double x, y, r;

Point N(0.0, 0.0);

int main()
{
  cin >> n;

  while(n--){
    cin >> x >> y >> r;  Circle A(x, y, r);
    cin >> x >> y >> r;  Circle B(x, y, r);

    int res = circlesIntersection(A, B);
    if(res ==  1){ puts("2");   continue; }
    if(res == -1){ puts("-2");  continue; }
    if(res ==  3){ puts("0");   continue; }
    puts("1");
  }

  return 0;
}

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

int main() {
  int N,M,A;
  cin >> N >> M;
  vector<int> vec(2*M);
  
  for (int i=0;i<2*M;i++) {
    cin >> vec.at(i); 
  }
  for (int i=0;i<N;i++) {
    A=0;
    for (int j=0;j<2*M;j++) {
      if (vec.at(j)==i+1){
        A++;
      }    
    }
    cout << A << endl;
  }  
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;

#define fi first
#define se second
#define m_p make_pair
#define p_b push_back
#define e_b emplace_back
#define all(x) (x).begin(),(x).end()
#define uniq(x) ((x).erase(unique(all(x)),(x).end()))
#define sz(x) ((int)(x).size())

#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)

#ifdef LOCAL//compile with -DLOCAL
#define debug(x) cerr<<"LINE"<<__LINE__<<" : "<<#x<<" = "<<(x)<<endl
#define debug_vec(x) cerr<<"LINE"<<__LINE__<<" : "<<#x<<" = ";\
  rep(i,sz(x)){cerr<<x[i]<<" ";}cerr<<endl
#define debug_mat(x) cerr<<"LINE"<<__LINE__<<" : "<<#x<<" = "<<endl;\
  rep(i,sz(x)){rep(j,sz(x[i])){cerr<<x[i][j]<<" ";}cerr<<endl;}cerr<<endl
#else
#define debug(x) void(0)
#define debug_vec(x) void(0)
#define debug_mat(x) void(0)
#endif

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


int main(){
  ios_base::sync_with_stdio(false);cin.tie(0);
  string S,T;
  cin >> S >> T;

  int ans=1e9;
  rep(i,sz(S)){
    int cnt=0;
    rep(j,sz(T)){
      if(i+j>=sz(S)){
        cnt=1e9;
        break;
      }
      if(S.at(i+j)!=T.at(j))  cnt++;
    }
    chmin(ans,cnt);
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3648